Skip to content

Commit e123aed

Browse files
authored
[BUGFIX] Wind directions steps check (#1165)
* Write test * Switch to allclose
1 parent caa2989 commit e123aed

2 files changed

Lines changed: 26 additions & 1 deletion

File tree

floris/utilities.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ def check_and_identify_step_size(wind_directions):
127127
raise ValueError("wind_directions must be evenly spaced")
128128

129129
else:
130-
if np.all(steps == steps[0]):
130+
if np.allclose(steps, steps[0]):
131131
return steps[0]
132132

133133
# If all but one of the steps are the same

tests/wind_data_integration_test.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,21 @@ def test_wind_rose_init():
114114
with pytest.raises(ValueError):
115115
WindRose(wind_directions, wind_speeds, 0.06, np.ones((3, 3)))
116116

117+
# Test that instantiating with non-integer wind directions and wind speeds works
118+
wind_directions = np.array([270.0, 280.0, 290.0])
119+
wind_speeds = np.array([6.0, 7.0])
120+
_ = WindRose(wind_directions, wind_speeds, ti_table=0.06)
121+
122+
wind_directions = np.array([270.5, 280.5, 290.5])
123+
wind_speeds = np.array([6.5, 7.5])
124+
_ = WindRose(wind_directions, wind_speeds, ti_table=0.06)
125+
126+
# Test that instantiating with non-integer steps works
127+
_ = WindRose(
128+
wind_directions=np.linspace(0.0, 360.0, 100, endpoint=False),
129+
wind_speeds=np.array([5.0]),
130+
ti_table=0.06,
131+
)
117132

118133
def test_wind_rose_grid():
119134
wind_directions = np.array([270, 280, 290])
@@ -799,6 +814,16 @@ def test_wind_ti_rose_init():
799814
with pytest.raises(ValueError):
800815
WindTIRose(wind_directions, wind_speeds, turbulence_intensities, np.ones((3, 3, 3)))
801816

817+
# Test that instantiating with non-integer wind directions and wind speeds works
818+
_ = WindTIRose(wind_directions+0.5, wind_speeds+0.2, turbulence_intensities)
819+
820+
# Test that instantiating with non-integer steps works
821+
_ = WindTIRose(
822+
wind_directions=np.linspace(0.0, 360.0, 100, endpoint=False),
823+
wind_speeds=np.array([5.0]),
824+
turbulence_intensities=turbulence_intensities,
825+
)
826+
802827

803828
def test_wind_ti_rose_grid():
804829
wind_directions = np.array([270, 280, 290, 300])

0 commit comments

Comments
 (0)