示例#1
0
def test_vertical():
    """Test the LegendParameter continuous_legend property."""
    leg_par = LegendParameters()
    leg_par.vertical = False

    assert leg_par.vertical is False
    leg_par_copy = leg_par.duplicate()
    assert leg_par_copy.vertical is False

    leg_par.vertical = True
    assert leg_par.vertical is True

    with pytest.raises(Exception):
        leg_par = LegendParameters(vertical='yes')
    with pytest.raises(Exception):
        leg_par.vertical = 'yes'
示例#2
0
    def test_init_graphic_con_data_type(self):
        """Test the initialization of GraphicContainer objects with a DataType."""
        mesh2d = Mesh2D.from_grid(num_x=2, num_y=2)
        mesh3d = Mesh3D.from_mesh2d(mesh2d)
        data = [-1, 0, 1, 2]
        graphic_con = GraphicContainer(data, mesh3d.min, mesh3d.max,
                                       data_type=Temperature())

        assert graphic_con.legend_parameters.is_title_default is False
        assert graphic_con.legend_parameters.title == 'C'

        legend_par = LegendParameters()
        legend_par.vertical = False
        graphic_con = GraphicContainer(data, mesh3d.min, mesh3d.max,
                                       legend_par, data_type=Temperature())

        assert graphic_con.legend_parameters.is_title_default is False
        assert graphic_con.legend_parameters.title == 'Temperature (C)'
示例#3
0
def test_init_graphic_con_legend_parameters():
    """Test the initialization of ResultMesh objects with a LegendParameters."""
    mesh2d = Mesh2D.from_grid(num_x=2, num_y=2)
    mesh3d = Mesh3D.from_mesh2d(mesh2d)
    data = [-1, 0, 1, 2]
    legend_par = LegendParameters(base_plane=Plane(o=Point3D(2, 2, 0)))
    legend_par.vertical = False
    legend_par.segment_height = 0.25
    legend_par.segment_width = 0.5
    legend_par.text_height = 0.15
    graphic_con = GraphicContainer(data, mesh3d.min, mesh3d.max, legend_par)

    assert graphic_con.legend_parameters.is_base_plane_default is False
    assert graphic_con.legend_parameters.is_segment_height_default is False
    assert graphic_con.legend_parameters.is_segment_width_default is False
    assert graphic_con.legend_parameters.is_text_height_default is False
    assert graphic_con.legend_parameters.vertical is False
    assert graphic_con.legend_parameters.base_plane.o == Point3D(2, 2, 0)
    assert graphic_con.legend_parameters.segment_height == 0.25
    assert graphic_con.legend_parameters.segment_width == 0.5
    assert graphic_con.legend_parameters.text_height == 0.15
try:
    from ladybug.legend import LegendParameters
except ImportError as e:
    raise ImportError('\nFailed to import ladybug:\n\t{}'.format(e))

try:
    from ladybug_rhino.togeometry import to_plane
except ImportError as e:
    raise ImportError('\nFailed to import ladybug_rhino:\n\t{}'.format(e))

if colors_ == []:
    colors_ = None
if base_plane_:
    base_plane_ = to_plane(base_plane_)

leg_par = LegendParameters(min=min_,
                           max=max_,
                           segment_count=seg_count_,
                           colors=colors_,
                           base_plane=base_plane_)

leg_par.continuous_legend = continuous_leg_
leg_par.decimal_count = num_decimals_
leg_par.include_larger_smaller = larger_smaller_
leg_par.vertical = vert_or_horiz_
leg_par.segment_height = seg_height_
leg_par.segment_width = seg_width_
leg_par.text_height = text_height_
leg_par.font = font_