Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Point no longer accepts arrays of shape (1,) #1587

Closed
martinfleis opened this issue Oct 28, 2022 · 3 comments · Fixed by #1590
Closed

Point no longer accepts arrays of shape (1,) #1587

martinfleis opened this issue Oct 28, 2022 · 3 comments · Fixed by #1590

Comments

@martinfleis
Copy link
Contributor

Expected behavior and actual behavior.

Shapely 2.0 no longer accepts arrays of shape (1,) as a valid input in Point constructor, while shapely 1.8.5 does and does not emit any warning while doing that.

Steps to reproduce the problem.

shapely 2.0b1:

In [1]: import numpy
   ...: import shapely
   ...: from shapely.geometry import Point
   ...: shapely.__version__
Out[1]: '2.0b1'

In [2]: x, y = numpy.array([1]), numpy.array([1])
   ...: x, y
Out[2]: (array([1]), array([1]))

In [3]: Point(x, y)
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Input In [3], in <cell line: 1>()
----> 1 Point(x, y)

File ~/mambaforge/envs/geo_dev/lib/python3.10/site-packages/shapely/geometry/point.py:77, in Point.__new__(self, *args)
     74     geom = shapely.points(np.array(args))
     76 if not isinstance(geom, Point):
---> 77     raise ValueError("Invalid values passed to Point constructor")
     78 return geom

ValueError: Invalid values passed to Point constructor

The same works correctly with 1.8.5:

In [3]: Point(x, y)
Out[3]: <shapely.geometry.point.Point at 0x10679b730>

Operating system

macOS 13.0, Ubuntu

Shapely version and provenance

2.0b1 installed from PyPI as well as from conda-forge

xref pysal/spopt#288 (comment)

@jorisvandenbossche
Copy link
Member

Good catch, thanks for the report. I think it is fine to allow that again.

@jorisvandenbossche
Copy link
Member

-> #1590

@jorisvandenbossche
Copy link
Member

A beta 2 is out with this fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants