GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — DEP: Deprecate setting the dtype of an exact numpy.ndarray by eendebakpt · Pull Request #29244 · numpy/numpy Conversation
|
| threads. As an alternative, you can create a new view (no copy) via: | ||
| * `np.lib.stride_tricks.strided_window_view` if applicable, | ||
| * `np.lib.stride_tricks.as_strided` for the general case, | ||
| * or the `np.ndarray` constructor (``buffer`` is the original array) for a light-weight version. |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
You should be using arr.view() for this, that is what it is for!
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
|
||
| #if !defined(PYPY_VERSION) | ||
| // On PyPy we skip the warning because we cannot rely on reference counts | ||
| // to be replaced with PyUnstable_Object_IsUniquelyReferenced https://github.com/python/cpython/pull/133144 |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
We are already using this in check_unique_temporary based on the Python version, would be nice to unify it.
(Maybe also with resize.)
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I looked at check_unique_temporary and the goal is difference, so unification does not seem worthwhile at this stage.
Here we want to check we have a guaranteed non-unique temporary. I did refactor a bit.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
| assert arr.strides == (0,) | ||
| with pytest.raises(ValueError): | ||
| arr.dtype = "i1" | ||
| with warnings.catch_warnings(): # gh-28901 |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Please just use pytest.warns(). That way you don't keep it around forever.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Using pytest.warns makes the test fail on pypy (there no deprecation warning is generated). If you want, I can skip this test on pypy instead of using the catch_warnings, but it seems have to pick the lesser of two evils.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| # The route via `__interface__` does not preserve structured | ||
| # dtypes. Since dtype should remain unchanged, we set it explicitly. | ||
| array.dtype = x.dtype | ||
| array._set_dtype(x.dtype) |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Do you even still need this here? At this point, it's a base class and you can just assign?
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
The array is indeed a base class due to the asarray. But if I assign to dtype here it will generate a deprecation warning.
Maybe we can combine it with the line above as
array = np.asarray(DummyArray(interface, base=x), dtype=dtype)
But I am not sure this covers all the corner cases.
I would prefer to leave this as is for now to keep this PR as safe and simple as possible. At some later point we will probably have to tackle this one (and some others).
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Co-authored-by: Sebastian Berg <[email protected]>
| if p.ls[-1] == 'simplefilter' or p.ls[-1] == 'filterwarnings': | ||
| if getattr(node.args[0], "value", None) == "ignore": | ||
| if node.args and getattr(node.args[0], "value", None) == "ignore": |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I know it's very much out of scope, so please ignore my neurotic rant, but this could be so much prettier with a match / case 😅
Sorry, something went wrong.
There was an error while loading. Please reload this page.
I created #29575 with the |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Closing in favor of #29575 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.