Skip to content

Commit 7c6472a

Browse files
authored
calling np.array on the DatetimeIndex type returned by suncalc to restore mutability (#32)
1 parent 76dea64 commit 7c6472a

2 files changed

Lines changed: 23 additions & 1 deletion

File tree

src/shadowfinder/shadowfinder.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ def find_shadows(self):
191191

192192
pos_obj = get_position(valid_datetimes, valid_lons, valid_lats)
193193

194-
valid_sun_altitudes = pos_obj["altitude"] # in radians
194+
valid_sun_altitudes = np.array(pos_obj["altitude"]) # in radians
195195

196196
# If object height and shadow length are set the sun altitudes are used
197197
# to calculate the shadow lengths across the world and then compared to

tests/test_shadowfinder.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,25 @@ def test_creation_with_valid_arguments_should_pass():
1515
ShadowFinder(
1616
object_height=object_height, shadow_length=shadow_length, date_time=date_time
1717
)
18+
19+
20+
def _gen_simple_finder_local_time():
21+
object_height = 6
22+
shadow_length = 3.2
23+
date_time = datetime.now()
24+
25+
return ShadowFinder(
26+
object_height=object_height,
27+
shadow_length=shadow_length,
28+
date_time=date_time,
29+
time_format="local",
30+
)
31+
32+
33+
def test_creation_with_valid_arguments_local_time_format_should_pass():
34+
_gen_simple_finder_local_time()
35+
36+
37+
def test_find_shadows_with_local_time_format():
38+
finder = _gen_simple_finder_local_time()
39+
finder.find_shadows()

0 commit comments

Comments
 (0)