From 56eac34e88ddf1832621c8f9ccdc708092900000 Mon Sep 17 00:00:00 2001 From: Thomas Capelle Date: Sun, 16 Feb 2020 11:35:31 +0100 Subject: [PATCH] add index to segment (#102) * add index to segment * add test for segment indexes --- pvfactors/geometry/pvrow.py | 2 +- pvfactors/tests/test_geometry/test_timeseries.py | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/pvfactors/geometry/pvrow.py b/pvfactors/geometry/pvrow.py index 7ce025a6..66fe966c 100644 --- a/pvfactors/geometry/pvrow.py +++ b/pvfactors/geometry/pvrow.py @@ -338,7 +338,7 @@ def from_raw_inputs(cls, xy_center, width, rotation_vec, cut, is_shaded) # Create segment segment = TsSegment(segment_coords, illum, shaded, - n_vector=n_vector) + n_vector=n_vector, index=i) list_segments.append(segment) return cls(list_segments, n_vector=n_vector) diff --git a/pvfactors/tests/test_geometry/test_timeseries.py b/pvfactors/tests/test_geometry/test_timeseries.py index c6f44d14..c7149fff 100644 --- a/pvfactors/tests/test_geometry/test_timeseries.py +++ b/pvfactors/tests/test_geometry/test_timeseries.py @@ -27,6 +27,11 @@ def test_ts_pvrow(): cut, df_inputs.shaded_length_front, df_inputs.shaded_length_back) + + #check segment index + assert len(ts_pvrow.front.list_segments) == 3 + assert [s.index for s in ts_pvrow.front.list_segments] == [0,1,2] + # Check timeseries length of front and back segments for seg in ts_pvrow.front.list_segments: np.testing.assert_allclose(width / cut['front'], seg.length)