Skip to content

Commit

Permalink
Change numpy.NaN to numpy.nan for compatibility with numpy>2.0.0 (#160)
Browse files Browse the repository at this point in the history
  • Loading branch information
ngehrsitz authored Jun 19, 2024
1 parent d9585d7 commit 31ccb20
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions meteostat/interface/normals.py
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,8 @@ def normalize(self):
else df
)

# None -> NaN
temp._data = temp._data.fillna(np.NaN)
# None -> nan
temp._data = temp._data.fillna(np.nan)

# Return class instance
return temp
Expand Down
4 changes: 2 additions & 2 deletions meteostat/interface/timeseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,15 +123,15 @@ def _filter_model(self) -> None:
(pd.isna(self._data[f"{col_name}_flag"]))
| (self._data[f"{col_name}_flag"].str.contains(self._model_flag)),
col_name,
] = np.NaN
] = np.nan

# Conditionally, remove flags from DataFrame
if not self._flags:
self._data.drop(
map(lambda col_name: f"{col_name}_flag", columns), axis=1, inplace=True
)

# Drop NaN-only rows
# Drop nan-only rows
self._data.dropna(how="all", subset=columns, inplace=True)

def _init_time_series(
Expand Down
8 changes: 4 additions & 4 deletions meteostat/series/normalize.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"""

from copy import copy
from numpy import NaN
from numpy import nan
import pandas as pd
import pytz
from meteostat.core.warn import warn
Expand Down Expand Up @@ -56,7 +56,7 @@ def normalize(self):
# Add columns
for column in temp._columns[temp._first_met_col :]:
# Add column to DataFrame
df[column] = NaN
df[column] = nan

result = pd.concat([result, df], axis=0)

Expand All @@ -70,8 +70,8 @@ def normalize(self):
.first()
)

# None -> NaN
temp._data = temp._data.fillna(NaN)
# None -> nan
temp._data = temp._data.fillna(nan)

# Return class instance
return temp
6 changes: 3 additions & 3 deletions meteostat/units.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
The code is licensed under the MIT license.
"""

from numpy import NaN, isnan
from numpy import nan, isnan


def fahrenheit(value):
Expand Down Expand Up @@ -62,7 +62,7 @@ def direction(value):
Convert degrees to wind direction
"""

wdir = NaN
wdir = nan

if (337 <= value <= 360) or value <= 23:
wdir = "N"
Expand Down Expand Up @@ -90,7 +90,7 @@ def condition(value):
"""

if isnan(value) or value < 1 or value > 27:
return NaN
return nan

return [
"Clear",
Expand Down
4 changes: 2 additions & 2 deletions meteostat/utilities/aggregations.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def weighted_average(step: pd.DataFrame) -> pd.DataFrame:

data = np.ma.masked_array(step, np.isnan(step))
data = np.ma.average(data, axis=0, weights=data[:, -2])
data = data.filled(np.NaN)
data = data.filled(np.nan)

return pd.DataFrame(data=[data], columns=step.columns)

Expand All @@ -30,7 +30,7 @@ def degree_mean(data: pd.Series) -> float:
"""

if data.isnull().all():
return np.NaN
return np.nan

rads = np.deg2rad(data)
sums = np.arctan2(np.sum(np.sin(rads)), np.sum(np.cos(rads)))
Expand Down
2 changes: 1 addition & 1 deletion meteostat/utilities/mutations.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def adjust_temp(df: pd.DataFrame, alt: int):
# Adjust values for all temperature-like data
for col_name in temp_like:
if col_name in df.columns:
df.loc[df[col_name] != np.NaN, col_name] = df[col_name] + (
df.loc[df[col_name] != np.nan, col_name] = df[col_name] + (
temp_diff * ((df["elevation"] - alt) / 100)
)

Expand Down

0 comments on commit 31ccb20

Please sign in to comment.