def test_decimal_count(): """Test the LegendParameter decimal_count property.""" leg_par = LegendParameters() leg_par.decimal_count = 3 assert leg_par.decimal_count == 3 leg_par_copy = leg_par.duplicate() assert leg_par_copy.decimal_count == 3 leg_par.decimal_count = 0 assert leg_par.decimal_count == 0 with pytest.raises(Exception): leg_par = LegendParameters(decimal_count='2') with pytest.raises(Exception): leg_par.decimal_count = '2'
def test_monthlychart_set_min_max_by_index(): """Test the set_minimum_by_index amd set_maximum_by_index methods.""" header = Header(Temperature(), 'C', AnalysisPeriod()) values = [i for i in range(12)] date_t = list(range(1, 13)) data_coll = MonthlyCollection(header, values, date_t) header2 = Header(RelativeHumidity(), '%', AnalysisPeriod()) values2 = [i for i in range(10, 70, 5)] data_coll2 = MonthlyCollection(header2, values2, date_t) l_par = LegendParameters(min=-20, max=40) l_par.decimal_count = 0 month_chart = MonthlyChart([data_coll, data_coll2], legend_parameters=l_par) assert month_chart.y_axis_labels1[0] == '-20' assert month_chart.y_axis_labels1[-1] == '40' month_chart.set_minimum_by_index(0, 1) assert month_chart.y_axis_labels2[0] == '0' month_chart.set_maximum_by_index(100, 1) assert month_chart.y_axis_labels2[-1] == '100'
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_