Skip to content

Commit 139b38e

Browse files
Merge pull request #347 from vss-2/issue-342
update read_health_facilities on python
2 parents 6e87524 + c787d67 commit 139b38e

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

python-package/geobr/read_health_facilities.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from geobr.utils import select_metadata, download_gpkg
22

33

4-
def read_health_facilities(verbose=False):
4+
def read_health_facilities(date=202303, verbose=False):
55
""" Download geolocated data of health facilities as an sf object.
66
77
Data comes from the National Registry of Healthcare facilities (Cadastro Nacional de Estabelecimentos de Saude - CNES),
@@ -19,6 +19,8 @@ def read_health_facilities(verbose=False):
1919
2020
Parameters
2121
----------
22+
date : Numeric. Date of the data in YYYYMM format. Defaults to `202303`,
23+
which was the latest data available by the time of this update.
2224
verbose : bool, optional
2325
by default False
2426
@@ -40,7 +42,7 @@ def read_health_facilities(verbose=False):
4042
>>> df = read_health_facilities()
4143
"""
4244

43-
metadata = select_metadata("health_facilities", year=2015, simplified=False)
45+
metadata = select_metadata("health_facilities", year=date, simplified=False)
4446

4547
gdf = download_gpkg(metadata)
4648

python-package/geobr/utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ def select_year(metadata, year):
111111
years = ", ".join([str(i) for i in metadata["year"].unique()])
112112

113113
raise Exception(
114-
"Error: Invalid Value to argument year. "
114+
"Error: Invalid Value to argument 'year/date'. "
115115
"It must be one of the following: "
116116
f'{_get_unique_values(metadata, "year")}'
117117
)

python-package/tests/test_read_health_facilities.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,10 @@ def test_read_health_facilities():
99

1010
assert isinstance(df, gpd.geodataframe.GeoDataFrame)
1111

12-
assert len(df) == 360177
12+
assert len(df) == 517629
1313

1414
with pytest.raises(Exception):
1515
read_health_facilities(year=9999999)
16+
17+
with pytest.raises(Exception):
18+
read_health_facilities(year="banana")

0 commit comments

Comments
 (0)