From 0672f27e16df0eb222ebc02c3e32f74dfe606d29 Mon Sep 17 00:00:00 2001 From: Benoit Bovy Date: Thu, 19 Dec 2024 20:41:40 +0100 Subject: [PATCH] rename get_dimensions -> get_dimension --- docs/api.rst | 2 +- src/geography.cpp | 4 ++-- src/spherely.pyi | 2 +- tests/test_geography.py | 16 ++++++++-------- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/docs/api.rst b/docs/api.rst index 0395f45..6cfcf5e 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -15,7 +15,7 @@ Geography properties GeographyType is_geography - get_dimensions + get_dimension get_type_id get_x get_y diff --git a/src/geography.cpp b/src/geography.cpp index 97d3630..8dfa296 100644 --- a/src/geography.cpp +++ b/src/geography.cpp @@ -228,7 +228,7 @@ std::int8_t get_type_id(PyObjectGeography obj) { return static_cast(obj.as_geog_ptr()->geog_type()); } -int get_dimensions(PyObjectGeography obj) { +int get_dimension(PyObjectGeography obj) { // note: in case of a collection with features of different dimensions: // - Geography::dimension() returns -1 // - s2geography::s2_dimension(geog) returns the max value found in collection @@ -323,7 +323,7 @@ void init_geography(py::module &m) { )pbdoc"); - m.def("get_dimensions", py::vectorize(&get_dimensions), py::arg("geography"), R"pbdoc( + m.def("get_dimension", py::vectorize(&get_dimension), py::arg("geography"), R"pbdoc( Returns the inherent dimensionality of a geography. Parameters diff --git a/src/spherely.pyi b/src/spherely.pyi index bdf8b04..b1724e6 100644 --- a/src/spherely.pyi +++ b/src/spherely.pyi @@ -161,7 +161,7 @@ class _VFunc_Nin1optprecision_Nout1( # Geography properties -get_dimensions: _VFunc_Nin1_Nout1[Literal["get_dimensions"], Geography, Any] +get_dimension: _VFunc_Nin1_Nout1[Literal["get_dimension"], Geography, Any] get_type_id: _VFunc_Nin1_Nout1[Literal["get_type_id"], int, np.int8] # Geography creation (scalar) diff --git a/tests/test_geography.py b/tests/test_geography.py index 930bef5..f7e4112 100644 --- a/tests/test_geography.py +++ b/tests/test_geography.py @@ -18,7 +18,7 @@ def test_not_geography_raise() -> None: arr = np.array([1, 2.33, spherely.create_point(30, 6)]) with pytest.raises(TypeError, match="not a Geography object"): - spherely.get_dimensions(arr) + spherely.get_dimension(arr) def test_get_type_id() -> None: @@ -66,7 +66,7 @@ def test_get_type_id() -> None: assert spherely.get_type_id(geog2) == spherely.GeographyType.POINT.value -def test_get_dimensions() -> None: +def test_get_dimension() -> None: # test n-d array expected = np.array([[0, 0], [1, 0]], dtype=np.int32) geog = np.array( @@ -78,11 +78,11 @@ def test_get_dimensions() -> None: ], ] ) - actual = spherely.get_dimensions(geog) + actual = spherely.get_dimension(geog) np.testing.assert_array_equal(actual, expected) # test scalar - assert spherely.get_dimensions(spherely.create_point(5, 40)) == 0 + assert spherely.get_dimension(spherely.create_point(5, 40)) == 0 @pytest.mark.parametrize( @@ -94,15 +94,15 @@ def test_get_dimensions() -> None: (spherely.create_collection([]), -1), ], ) -def test_get_dimensions_empty(empty_geog, expected) -> None: - assert spherely.get_dimensions(empty_geog) == expected +def test_get_dimension_empty(empty_geog, expected) -> None: + assert spherely.get_dimension(empty_geog) == expected -def test_get_dimensions_collection() -> None: +def test_get_dimension_collection() -> None: geog = spherely.create_collection( [spherely.create_point(0, 0), spherely.create_polygon([(0, 0), (1, 1), (2, 0)])] ) - assert spherely.get_dimensions(geog) == 2 + assert spherely.get_dimension(geog) == 2 def test_prepare() -> None: