コード例 #1
0
def test_text_height():
    """Test the LegendParameter text_height property."""
    leg_par = LegendParameters()
    leg_par.text_height = 0.25

    assert leg_par.text_height == 0.25
    assert leg_par.is_text_height_default is False
    leg_par_copy = leg_par.duplicate()
    assert leg_par_copy.text_height == 0.25

    leg_par.text_height = 2
    assert leg_par.text_height == 2

    with pytest.raises(Exception):
        leg_par = LegendParameters(text_height=0)
    with pytest.raises(Exception):
        leg_par.text_height = 0
コード例 #2
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
コード例 #3
0
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_