From 76cd007594f9728ed100b004c43de8ddd7fc40c6 Mon Sep 17 00:00:00 2001 From: Vitor Sousa <32624576+vss-2@users.noreply.github.com> Date: Tue, 23 Apr 2024 00:11:52 -0300 Subject: [PATCH 1/3] update read_health_facilities on python --- python-package/geobr/read_health_facilities.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/python-package/geobr/read_health_facilities.py b/python-package/geobr/read_health_facilities.py index 4994b0d3..3511715c 100644 --- a/python-package/geobr/read_health_facilities.py +++ b/python-package/geobr/read_health_facilities.py @@ -1,7 +1,7 @@ from geobr.utils import select_metadata, download_gpkg -def read_health_facilities(verbose=False): +def read_health_facilities(date=202303, verbose=False): """ Download geolocated data of health facilities as an sf object. 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): Parameters ---------- + date : Numeric. Date of the data in YYYYMM format. Defaults to `202303`, + which was the latest data available by the time of this update. verbose : bool, optional by default False @@ -40,7 +42,7 @@ def read_health_facilities(verbose=False): >>> df = read_health_facilities() """ - metadata = select_metadata("health_facilities", year=2015, simplified=False) + metadata = select_metadata("health_facilities", year=date, simplified=False) gdf = download_gpkg(metadata) From a07c82ad302a2aec9364186450d6c1e3a004e8b8 Mon Sep 17 00:00:00 2001 From: Vitor Sousa <32624576+vss-2@users.noreply.github.com> Date: Wed, 24 Apr 2024 00:34:42 -0300 Subject: [PATCH 2/3] Update tests and error messages --- python-package/geobr/utils.py | 2 +- python-package/tests/test_read_health_facilities.py | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/python-package/geobr/utils.py b/python-package/geobr/utils.py index 95c05a74..600fa445 100644 --- a/python-package/geobr/utils.py +++ b/python-package/geobr/utils.py @@ -111,7 +111,7 @@ def select_year(metadata, year): years = ", ".join([str(i) for i in metadata["year"].unique()]) raise Exception( - "Error: Invalid Value to argument year. " + "Error: Invalid Value to argument 'year/date'. " "It must be one of the following: " f'{_get_unique_values(metadata, "year")}' ) diff --git a/python-package/tests/test_read_health_facilities.py b/python-package/tests/test_read_health_facilities.py index bfe4791e..89398a74 100644 --- a/python-package/tests/test_read_health_facilities.py +++ b/python-package/tests/test_read_health_facilities.py @@ -9,7 +9,13 @@ def test_read_health_facilities(): assert isinstance(df, gpd.geodataframe.GeoDataFrame) - assert len(df) == 360177 + assert len(df) == 517629 with pytest.raises(Exception): read_health_facilities(year=9999999) + + with pytest.raises(Exception): + read_health_facilities(year="banana") + + with pytest.raises(Exception): + read_health_facilities(verbose="banana") \ No newline at end of file From c787d674ab1a89a49e4f287bd8e941bc6ed87f53 Mon Sep 17 00:00:00 2001 From: Vitor Sousa <32624576+vss-2@users.noreply.github.com> Date: Wed, 24 Apr 2024 00:59:17 -0300 Subject: [PATCH 3/3] Remove verbose test --- python-package/tests/test_read_health_facilities.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/python-package/tests/test_read_health_facilities.py b/python-package/tests/test_read_health_facilities.py index 89398a74..ef6dc5c9 100644 --- a/python-package/tests/test_read_health_facilities.py +++ b/python-package/tests/test_read_health_facilities.py @@ -16,6 +16,3 @@ def test_read_health_facilities(): with pytest.raises(Exception): read_health_facilities(year="banana") - - with pytest.raises(Exception): - read_health_facilities(verbose="banana") \ No newline at end of file