-
-
Notifications
You must be signed in to change notification settings - Fork 10.9k
DEP: Deprecate setting the strides attribute of a numpy array #28925
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
base: main
Are you sure you want to change the base?
Changes from all commits
18c02c8
687cf72
b32319e
0fda654
d7cfed3
730c9a9
5874636
2dad334
288690d
8502a2f
0c4929e
61eee97
141bbb7
88950f2
347b8d3
4bbbfbc
60df1f7
36a8ca0
bce4d22
423fd5a
d8c22e5
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
Setting the ``strides`` attribute is deprecated | ||
----------------------------------------------- | ||
Setting the strides attribute is now deprecated since mutating | ||
an array is unsafe if an array is shared, especially by multiple | ||
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. | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,7 +21,7 @@ class TestHalf: | |
def setup_method(self): | ||
# An array of all possible float16 values | ||
self.all_f16 = np.arange(0x10000, dtype=uint16) | ||
self.all_f16.dtype = float16 | ||
self.all_f16 = self.all_f16.view(float16) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These changes are not strictly related any more, though arguably improvements regardless. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Indeed not related. The idea was to add them so the diff for the other (more complex) PR for the dtype will be small. |
||
|
||
# NaN value can cause an invalid FP exception if HW is being used | ||
with np.errstate(invalid='ignore'): | ||
|
@@ -32,7 +32,7 @@ def setup_method(self): | |
self.nonan_f16 = np.concatenate( | ||
(np.arange(0xfc00, 0x7fff, -1, dtype=uint16), | ||
np.arange(0x0000, 0x7c01, 1, dtype=uint16))) | ||
self.nonan_f16.dtype = float16 | ||
self.nonan_f16 = self.nonan_f16.view(float16) | ||
self.nonan_f32 = np.array(self.nonan_f16, dtype=float32) | ||
self.nonan_f64 = np.array(self.nonan_f16, dtype=float64) | ||
|
||
|
@@ -218,7 +218,7 @@ def test_half_values(self): | |
0x0001, 0x8001, | ||
0x0000, 0x8000, | ||
0x7c00, 0xfc00], dtype=uint16) | ||
b.dtype = float16 | ||
b = b.view(dtype=float16) | ||
assert_equal(a, b) | ||
|
||
def test_half_rounding(self): | ||
|
Uh oh!
There was an error while loading. Please reload this page.