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

ENH: Added support for int-like strings and numpy dtypes #1049

Conversation

iboates
Copy link
Contributor

@iboates iboates commented Mar 31, 2022

I don't think api/* needs updating but maybe I am wrong.

@snowman2
Copy link
Member

Thoughts about instead adding a method called _is_epsg_code to check for numpy scalar, integer, or integer string and passing it into from_epsg?

CRS.from_epsg should be able to handle them if they are detected properly:

>>> from pyproj import CRS
>>> import numpy
>>> CRS.from_epsg(numpy.array(4326))
<Geographic 2D CRS: EPSG:4326>
Name: WGS 84
Axis Info [ellipsoidal]:
- Lat[north]: Geodetic latitude (degree)
- Lon[east]: Geodetic longitude (degree)
Area of Use:
- name: World.
- bounds: (-180.0, -90.0, 180.0, 90.0)
Datum: World Geodetic System 1984 ensemble
- Ellipsoid: WGS 84
- Prime Meridian: Greenwich
>>> CRS.from_epsg("4326")
<Geographic 2D CRS: EPSG:4326>
Name: WGS 84
Axis Info [ellipsoidal]:
- Lat[north]: Geodetic latitude (degree)
- Lon[east]: Geodetic longitude (degree)
Area of Use:
- name: World.
- bounds: (-180.0, -90.0, 180.0, 90.0)
Datum: World Geodetic System 1984 ensemble
- Ellipsoid: WGS 84
- Prime Meridian: Greenwich

.pre-commit-config.yaml Outdated Show resolved Hide resolved
@iboates
Copy link
Contributor Author

iboates commented Apr 1, 2022

@snowman2 Indeed a _from_epsg_code function is cleaner. But I am not sure what to specify as its parameter type, since it could be a numpy dtype, so wouldn't object be the only choice? and therefore make it irrelevant?

@snowman2
Copy link
Member

snowman2 commented Apr 1, 2022

D

@snowman2 Indeed a _from_epsg_code function is cleaner. But I am not sure what to specify as its parameter type, since it could be a numpy dtype, so wouldn't object be the only choice? and therefore make it irrelevant?

I like the current implementation, it looks good 👍.

I think this would be sufficient:

def _is_epsg_code(auth_code: Any) -> bool:

README.md Outdated Show resolved Hide resolved
@snowman2 snowman2 changed the title Feature/1026 1035 handle more crs format edge cases ENH: Added support for int-like strings and numpy dtypes Apr 1, 2022
@snowman2
Copy link
Member

snowman2 commented Apr 1, 2022

@iboates would you like to squash your commits or would you mind if I did it on merge?

@iboates
Copy link
Contributor Author

iboates commented Apr 1, 2022

@snowman2 You can do it on merge it's fine

@iboates
Copy link
Contributor Author

iboates commented Apr 2, 2022

Realized that there was an elif after a return and the linter didnt like that

@codecov
Copy link

codecov bot commented Apr 2, 2022

Codecov Report

Merging #1049 (d54b811) into main (a463636) will increase coverage by 0.01%.
The diff coverage is 100.00%.

@@            Coverage Diff             @@
##             main    #1049      +/-   ##
==========================================
+ Coverage   96.27%   96.29%   +0.01%     
==========================================
  Files          20       20              
  Lines        1771     1779       +8     
==========================================
+ Hits         1705     1713       +8     
  Misses         66       66              
Impacted Files Coverage Δ
pyproj/crs/crs.py 98.01% <100.00%> (+0.03%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a463636...d54b811. Read the comment docs.

@snowman2 snowman2 merged commit 9a013e8 into pyproj4:main Apr 2, 2022
@snowman2 snowman2 added this to In progress in 3.3.1 Release via automation Apr 2, 2022
@snowman2
Copy link
Member

snowman2 commented Apr 2, 2022

Thanks @iboates 👍

@snowman2 snowman2 moved this from In progress to Done in 3.3.1 Release Apr 2, 2022
@iboates iboates deleted the feature/1026-1035-handle-more-crs-format-edge-cases branch April 2, 2022 23:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
2 participants