Skip to content

Commit abb42b5

Browse files
committed
Update doc/example and tests per ESTAT changes
1 parent 3c6c199 commit abb42b5

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

doc/example.rst

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,14 @@ These include *structural metadata* that together completely describe the data a
2424
sm
2525
2626
:py:`sm` is a Python object of class :class:`.StructureMessage`.
27-
We can explore some of the specific artifacts—for example, three **code lists**—using :meth:`.StructureMessage.get` to retrieve them and :func:`.to_pandas` to convert to :class:`.pandas.Series`:
27+
We can explore some of the specific artifacts
28+
—for example, three **code lists**—
29+
using :meth:`.StructureMessage.get` to retrieve them
30+
and :func:`.to_pandas` to convert to :class:`.pandas.Series`:
2831

2932
.. ipython:: python
3033
31-
for cl in "AGE(10.3)", "SEX(1.13)", "UNIT(55.0)":
34+
for cl in "ESTAT:AGE(11.0)", "ESTAT:SEX(1.13)", "ESTAT:UNIT(59.0)":
3235
print(sdmx.to_pandas(sm.get(cl)))
3336
3437
Next, we download a **data set** containing a portion of the data in this data flow, structured by this DSD.

sdmx/tests/test_docs.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,17 @@
2424

2525

2626
@pytest.mark.network
27-
def test_doc_example():
27+
def test_doc_example() -> None:
2828
"""Code from example.rst."""
2929
import sdmx
3030

3131
estat = sdmx.Client("ESTAT")
3232

33-
sm = estat.datastructure("UNE_RT_A")
33+
sm: "sdmx.message.StructureMessage" = estat.datastructure("UNE_RT_A")
3434

35-
for cl in "AGE(10.3)", "SEX(1.13)", "UNIT(55.0)":
35+
# NB Use partial URNs to match even if only single versions are stored under keys
36+
# like "AGE"
37+
for cl in "ESTAT:AGE(11.0)", "ESTAT:SEX(1.13)", "ESTAT:UNIT(59.0)":
3638
print(sdmx.to_pandas(sm.get(cl)))
3739

3840
dm = estat.data("UNE_RT_A", key={"geo": "EL+ES+IE"}, params={"startPeriod": "2007"})
@@ -44,7 +46,7 @@ def test_doc_example():
4446
# Further checks per https://github.com/dr-leo/pandaSDMX/issues/157
4547

4648
# DimensionDescriptor for the structure message
47-
dd1 = sm.structure.UNE_RT_A.dimensions
49+
dd1 = sm.structure.UNE_RT_A.dimensions # type: ignore [attr-defined]
4850

4951
# DimensionDescriptor retrieved whilst validating the data message
5052
dd2 = dm.data[0].structured_by.dimensions
@@ -104,7 +106,7 @@ def test_doc_index1() -> None:
104106
# NB At some times (e.g. between 2024-03-15 and 2024-06-18) this query retrieves
105107
# multiple versions of similar artefacts. A more explicit argument to get() that
106108
# includes the version (like get("GEO(21.0)")) may be temporarily needed.
107-
s = sdmx.to_pandas(sm1.get("GEO(23.4)"))
109+
s = sdmx.to_pandas(sm1.get("ESTAT:GEO"))
108110
assert_pd_equal(s.sort_index().head(), expected)
109111

110112

0 commit comments

Comments
 (0)