Skip to content

Commit 40001ba

Browse files
authored
Merge pull request #57 from ThomasBouche/hotfix/add_warning
add warnings for deprecated INDICATORS
2 parents abeaa9e + fc274b0 commit 40001ba

File tree

3 files changed

+47
-19
lines changed

3 files changed

+47
-19
lines changed

CHANGELOG.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
88

99
### Bugs
1010

11-
* INDICATORS and INSTANT_INDICATORS attributes of WeatherForecast object where not always in sync with
11+
* `INDICATORS` and `INSTANT_INDICATORS` attributes of WeatherForecast object where not always in sync with
1212
the actual capabilities. Changed these attributes to properties that compute these lists dynamically
13-
from the capabilities attribute. Changed their name to lowercase, since they are not constants anymore.
13+
from the `capabilities` attribute. Changed their name to lowercase (`indicators`, `instant_indicators`), since they are not constants anymore.
14+
(`DeprecationWarning` about use of `INDICATORS` and `INSTANT_INDICATORS`)
1415
See issue #54.
1516

1617
## [0.2.2] - November, 2025

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ logger = logging.getLogger("meteole")
7575
arome_client = AromeForecast(application_id=APPLICATION_ID)
7676

7777
# Check indicators available
78-
print(arome_client.INDICATORS)
78+
print(arome_client.indicators)
7979

8080
# Fetch weather data
8181
df_arome = arome_client.get_coverage(

src/meteole/forecast.py

Lines changed: 43 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from functools import reduce
1111
from importlib.util import find_spec
1212
from typing import Any
13+
from warnings import warn
1314

1415
import pandas as pd
1516
import xarray as xr
@@ -56,22 +57,6 @@ class WeatherForecast(ABC):
5657
DEFAULT_PRECISION: float = 0.01
5758
CLIENT_CLASS: type[BaseClient]
5859

59-
@property
60-
def indicators(self) -> list[str]:
61-
"""Computes the list of all indicators from self.capabilities
62-
63-
Returns: List of all indicators
64-
"""
65-
return self.capabilities["indicator"].unique().tolist()
66-
67-
@property
68-
def instant_indicators(self) -> list[str]:
69-
"""Computes the list of instant indicators from self.capabilities
70-
71-
Returns: List of instant indicators
72-
"""
73-
return self.capabilities[self.capabilities["interval"] == ""]["indicator"].unique().tolist()
74-
7560
def __init__(
7661
self,
7762
client: BaseClient | None = None,
@@ -112,6 +97,48 @@ def __init__(
11297
# Try to instantiate it (can be user friendly)
11398
self._client = self.CLIENT_CLASS(**kwargs)
11499

100+
@property
101+
def indicators(self) -> list[str]:
102+
"""Computes the list of all indicators from self.capabilities
103+
104+
Returns: List of all indicators
105+
"""
106+
return self.capabilities["indicator"].unique().tolist()
107+
108+
@property
109+
def instant_indicators(self) -> list[str]:
110+
"""Computes the list of instant indicators from self.capabilities
111+
112+
Returns: List of instant indicators
113+
"""
114+
return self.capabilities[self.capabilities["interval"] == ""]["indicator"].unique().tolist()
115+
116+
@property
117+
def INDICATORS(self) -> list[str]:
118+
"""Deprecated, will be removed in a future version, use indicators instead
119+
120+
Returns: List of all indicators
121+
"""
122+
warn(
123+
("Deprecated, will be removed in a future version, use indicators instead"),
124+
DeprecationWarning,
125+
stacklevel=2,
126+
)
127+
return self.indicators
128+
129+
@property
130+
def INSTANT_INDICATORS(self) -> list[str]:
131+
"""Deprecated, will be removed in a future version, use instant_indicators instead
132+
133+
Returns: List of instant indicators
134+
"""
135+
warn(
136+
("Deprecated, will be removed in a future version, use instant_indicators instead"),
137+
DeprecationWarning,
138+
stacklevel=2,
139+
)
140+
return self.instant_indicators
141+
115142
@property
116143
def capabilities(self) -> pd.DataFrame:
117144
"""Getter method of the capabilities attribute.

0 commit comments

Comments
 (0)