Skip to content

Commit

Permalink
rename get_dimensions -> get_dimension
Browse files Browse the repository at this point in the history
  • Loading branch information
benbovy committed Dec 19, 2024
1 parent 7017018 commit 0672f27
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Geography properties

GeographyType
is_geography
get_dimensions
get_dimension
get_type_id
get_x
get_y
Expand Down
4 changes: 2 additions & 2 deletions src/geography.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ std::int8_t get_type_id(PyObjectGeography obj) {
return static_cast<std::int8_t>(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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/spherely.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
16 changes: 8 additions & 8 deletions tests/test_geography.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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(
Expand All @@ -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(
Expand All @@ -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:
Expand Down

0 comments on commit 0672f27

Please sign in to comment.