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

Minor change to avoid numpy DeprecationWarning #58

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

oscgonfer
Copy link

This is a minor PR to avoid numpy DeprecationWarning on:

numpy/core/_asarray.py:102: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray.
  return array(a, dtype, copy=False, order=order)

@@ -26,9 +26,11 @@ class are instantiated and queried directly
import numpy
WRAP = numpy.asarray

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this would be cleaner if you did:

WRAP = functools.partial(numpy.asarray, dtype=object)

Then WRAP will always get the dtype=object argument, and you won't have to add or branch onnumpy_avail.

Although you will have to import functools. :-)

@VivaLaPanda
Copy link

Bump on merging this?

@remi-dupre
Copy link

Hi!

Note that with latest numpy 1.24.0rc0 this deprecation notice becomes an exception:

  File "/home/remi/code/idunn/idunn/utils/__init__.py", line 4, in <module>
    tz = tzwhere.tzwhere(forceTZ=True)
  File "/home/remi/.local/share/virtualenvs/idunn-JfTPVegI/lib/python3.10/site-packages/tzwhere/tzwhere.py", line 62, in __init__
    self.timezoneNamesToPolygons[tzname] = WRAP(polys)
ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 2 dimensions. The detected shape was (1, 2) + inhomogeneous part.

@oscgonfer
Copy link
Author

As the repository is clearly not being maintained, maybe we should make a port and release it on pypi.
This should also guarantee that long term support is there, but in my case I don't have time to get fully involved in checking possible future issues for dependencies.

Opinions?

@jannikmi
Copy link

I don't want to hijack this PR, but I want to point out that my package timezonefinder offers the same functionality and is being actively maintained. If you are missing functionality, feel free to open an issue/PR there. Hope this helps.

@oscgonfer
Copy link
Author

oscgonfer commented Dec 21, 2022

@jannikmi, thank you for the comment. I personally hadn't heard of your timezonefinder package, but I have just tested it, and in my particular case, it works as I need it. It wouldn't make sense to keep working with pytzwhere unless someone else has another issue with yours, but eitherway development shouldn't be divided into two different repos that can potentially do the same thing.

Long story short, switching to timezonefinder seems like the best solution.

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

Successfully merging this pull request may close these issues.

5 participants