Skip to content

Commit a366c28

Browse files
committed
adjsut for name changes
1 parent 971689e commit a366c28

File tree

1 file changed

+26
-18
lines changed

1 file changed

+26
-18
lines changed

mhkit/tests/river/test_resource.py

+26-18
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def test_froude_number_g_type_error(self):
5555
h = 5
5656
g = "invalid_type" # String instead of int/float
5757
with self.assertRaises(TypeError):
58-
river.resource.Froude_number(v, h, g)
58+
river.resource.froude_number(v, h, g)
5959

6060
def test_exceedance_probability(self):
6161
# Create arbitrary discharge between 0 and 8(N=9)
@@ -121,7 +121,7 @@ def test_discharge_to_velocity(self):
121121
p, r2 = river.resource.polynomial_fit(np.arange(9), 10 * np.arange(9), 1)
122122
# Because the polynomial line fits perfect we should expect the V to equal 10*Q
123123
V = river.resource.discharge_to_velocity(Q, p)
124-
self.assertAlmostEqual(np.sum(10 * Q - V["V"]), 0.00, places=2)
124+
self.assertAlmostEqual(np.sum(10 * Q - V["velocity"]), 0.00, places=2)
125125

126126
def test_discharge_to_velocity_xarray(self):
127127
# Create arbitrary discharge between 0 and 8(N=9)
@@ -132,7 +132,7 @@ def test_discharge_to_velocity_xarray(self):
132132
p, r2 = river.resource.polynomial_fit(np.arange(9), 10 * np.arange(9), 1)
133133
# Because the polynomial line fits perfect we should expect the V to equal 10*Q
134134
V = river.resource.discharge_to_velocity(Q, p, to_pandas=False)
135-
self.assertAlmostEqual(np.sum(10 * Q - V["V"]).values, 0.00, places=2)
135+
self.assertAlmostEqual(np.sum(10 * Q - V["velocity"]).values, 0.00, places=2)
136136

137137
def test_discharge_to_velocity_D_type_error(self):
138138
D = "invalid_type" # String instead of pd.Series or pd.DataFrame
@@ -154,16 +154,18 @@ def test_velocity_to_power(self):
154154
# Calculate a first order polynomial on an VP_Curve x=y line 10 times greater than the V values
155155
p2, r22 = river.resource.polynomial_fit(np.arange(9), 10 * np.arange(9), 1)
156156
# Set cut in/out to exclude 1 bin on either end of V range
157-
cut_in = V["V"][1]
158-
cut_out = V["V"].iloc[-2]
157+
cut_in = V["velocity"][1]
158+
cut_out = V["velocity"].iloc[-2]
159159
# Power should be 10x greater and exclude the ends of V
160-
P = river.resource.velocity_to_power(V["V"], p2, cut_in, cut_out)
160+
P = river.resource.velocity_to_power(V["velocity"], p2, cut_in, cut_out)
161161
# Cut in power zero
162-
self.assertAlmostEqual(P["P"][0], 0.00, places=2)
162+
self.assertAlmostEqual(P["power"][0], 0.00, places=2)
163163
# Cut out power zero
164-
self.assertAlmostEqual(P["P"].iloc[-1], 0.00, places=2)
164+
self.assertAlmostEqual(P["power"].iloc[-1], 0.00, places=2)
165165
# Middle 10x greater than velocity
166-
self.assertAlmostEqual((P["P"][1:-1] - 10 * V["V"][1:-1]).sum(), 0.00, places=2)
166+
self.assertAlmostEqual(
167+
(P["power"][1:-1] - 10 * V["velocity"][1:-1]).sum(), 0.00, places=2
168+
)
167169

168170
def test_velocity_to_power_xarray(self):
169171
# Calculate a first order polynomial on an DV_Curve x=y line 10 times greater than the Q values
@@ -175,19 +177,19 @@ def test_velocity_to_power_xarray(self):
175177
# Calculate a first order polynomial on an VP_Curve x=y line 10 times greater than the V values
176178
p2, r22 = river.resource.polynomial_fit(np.arange(9), 10 * np.arange(9), 1)
177179
# Set cut in/out to exclude 1 bin on either end of V range
178-
cut_in = V["V"].values[1]
179-
cut_out = V["V"].values[-2]
180+
cut_in = V["velocity"].values[1]
181+
cut_out = V["velocity"].values[-2]
180182
# Power should be 10x greater and exclude the ends of V
181183
P = river.resource.velocity_to_power(
182-
V["V"], p2, cut_in, cut_out, to_pandas=False
184+
V["velocity"], p2, cut_in, cut_out, to_pandas=False
183185
)
184186
# Cut in power zero
185-
self.assertAlmostEqual(P["P"][0], 0.00, places=2)
187+
self.assertAlmostEqual(P["power"][0], 0.00, places=2)
186188
# Cut out power zero
187-
self.assertAlmostEqual(P["P"][-1], 0.00, places=2)
189+
self.assertAlmostEqual(P["power"][-1], 0.00, places=2)
188190
# Middle 10x greater than velocity
189191
self.assertAlmostEqual(
190-
(P["P"][1:-1] - 10 * V["V"][1:-1]).sum().values, 0.00, places=2
192+
(P["power"][1:-1] - 10 * V["velocity"][1:-1]).sum().values, 0.00, places=2
191193
)
192194

193195
def test_velocity_to_power_V_type_error(self):
@@ -278,7 +280,9 @@ def test_plot_flow_duration_curve(self):
278280

279281
f = river.resource.exceedance_probability(self.data.Q)
280282
plt.figure()
281-
river.graphics.plot_flow_duration_curve(self.data["Q"], f["F"])
283+
river.graphics.plot_flow_duration_curve(
284+
self.data["Q"], f["exceedance_probability"]
285+
)
282286
plt.savefig(filename, format="png")
283287
plt.close()
284288

@@ -291,7 +295,9 @@ def test_plot_power_duration_curve(self):
291295

292296
f = river.resource.exceedance_probability(self.data.Q)
293297
plt.figure()
294-
river.graphics.plot_flow_duration_curve(self.results["P_control"], f["F"])
298+
river.graphics.plot_flow_duration_curve(
299+
self.results["P_control"], f["exceedance_probability"]
300+
)
295301
plt.savefig(filename, format="png")
296302
plt.close()
297303

@@ -304,7 +310,9 @@ def test_plot_velocity_duration_curve(self):
304310

305311
f = river.resource.exceedance_probability(self.data.Q)
306312
plt.figure()
307-
river.graphics.plot_velocity_duration_curve(self.results["V_control"], f["F"])
313+
river.graphics.plot_velocity_duration_curve(
314+
self.results["V_control"], f["exceedance_probability"]
315+
)
308316
plt.savefig(filename, format="png")
309317
plt.close()
310318

0 commit comments

Comments
 (0)