Skip to content

Commit bd3b96c

Browse files
replace deprecated usage of np.can_cast with is_float in utils
1 parent 6eec981 commit bd3b96c

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

src/geophires_x/GeoPHIRESUtils.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@
9595

9696

9797
def InsertImagesIntoHTML(html_path: str, short_names: set, full_names: set) -> None:
98-
9998
# Write a reference to the image(s) into the HTML file by inserting before the "</body>" tag
10099
# build the string to be inserted first
101100
insert_string = ''
@@ -144,7 +143,7 @@ def render_default(p: float, unit: str = '', fmt: str = '') -> str:
144143
:type fmt: str
145144
:return: the string representation of the float
146145
"""
147-
if not np.can_cast(p, float):
146+
if not is_float(p):
148147
raise ValueError(f'Parameter ({p}) must be a float or convertible to float.')
149148

150149
unit = UpgradeSymbologyOfUnits(unit)
@@ -176,7 +175,7 @@ def render_scientific(p: float, unit: str = '', fmt: str = '') -> str:
176175
:rtype: str
177176
"""
178177

179-
if not np.can_cast(p, float):
178+
if not is_float(p):
180179
raise ValueError(f'Parameter ({p}) must be a float or convertible to float.')
181180

182181
unit = UpgradeSymbologyOfUnits(unit)
@@ -197,7 +196,7 @@ def render_Parameter_default(p: Parameter, fmt: str = '') -> str:
197196
:type fmt: str
198197
:return: the string representation of the float
199198
"""
200-
if not np.can_cast(p.value, float):
199+
if not is_float(p.value):
201200
raise ValueError(f'Parameter ({p.value}) must be a float or convertible to float.')
202201

203202
return render_default(p.value, p.CurrentUnits.value)
@@ -214,7 +213,7 @@ def render_parameter_scientific(p: Parameter, fmt: str = '') -> str:
214213
:return: the string representation of the float
215214
"""
216215

217-
if not np.can_cast(p.value, float):
216+
if not is_float(p.value):
218217
raise ValueError(f'Parameter ({p.value}) must be a float or convertible to float.')
219218

220219
return render_scientific(p.value, p.CurrentUnits.value)
@@ -241,7 +240,7 @@ def density_water_kg_per_m3(Twater_degC: float, pressure: Optional[PlainQuantity
241240
Raises:
242241
ValueError: If Twater_degC is not a float or convertible to float.
243242
"""
244-
if not np.can_cast(Twater_degC, float):
243+
if not is_float(Twater_degC):
245244
raise ValueError(f'Twater_degC ({Twater_degC}) must be a float or convertible to float.')
246245

247246
try:
@@ -276,7 +275,7 @@ def celsius_to_kelvin(celsius: float) -> float:
276275

277276
@lru_cache
278277
def viscosity_water_Pa_sec(
279-
Twater_degC: float,
278+
Twater_degC: float,
280279
pressure: Optional[PlainQuantity] = None) -> float:
281280
"""
282281
Calculate the dynamic viscosity of water as a function of temperature and pressure.
@@ -390,7 +389,7 @@ def vapor_pressure_water_kPa(temperature_degC: float) -> float:
390389

391390
try:
392391
return (quantity(CP.PropsSI('P', 'T', celsius_to_kelvin(temperature_degC), 'Q', 0, 'Water'), 'Pa')
393-
.to('kPa').magnitude)
392+
.to('kPa').magnitude)
394393

395394
except (NotImplementedError, ValueError) as e:
396395
raise ValueError(f'Input temperature ({temperature_degC}C) is out of range or otherwise not implemented') from e

0 commit comments

Comments
 (0)