Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9eb343e

Browse files
committed
BUG: Fix #27256 and #27257
1 parent 83cd89b commit 9eb343e

File tree

4 files changed

+15
-12
lines changed

4 files changed

+15
-12
lines changed
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
* `numpy.fix` now won't perform casting to a floating data-type for integer
2+
and boolean data-type input arrays.

numpy/_core/fromnumeric.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -207,13 +207,13 @@ def take(a, indices, axis=None, out=None, mode='raise'):
207207
return _wrapfunc(a, 'take', indices, axis=axis, out=out, mode=mode)
208208

209209

210-
def _reshape_dispatcher(a, /, shape=None, *, newshape=None, order=None,
210+
def _reshape_dispatcher(a, /, shape=None, order=None, *, newshape=None,
211211
copy=None):
212212
return (a,)
213213

214214

215215
@array_function_dispatch(_reshape_dispatcher)
216-
def reshape(a, /, shape=None, *, newshape=None, order='C', copy=None):
216+
def reshape(a, /, shape=None, order='C', *, newshape=None, copy=None):
217217
"""
218218
Gives a new shape to an array without changing its data.
219219
@@ -226,10 +226,6 @@ def reshape(a, /, shape=None, *, newshape=None, order='C', copy=None):
226226
an integer, then the result will be a 1-D array of that length.
227227
One shape dimension can be -1. In this case, the value is
228228
inferred from the length of the array and remaining dimensions.
229-
newshape : int or tuple of ints
230-
.. deprecated:: 2.1
231-
Replaced by ``shape`` argument. Retained for backward
232-
compatibility.
233229
order : {'C', 'F', 'A'}, optional
234230
Read the elements of ``a`` using this index order, and place the
235231
elements into the reshaped array using this index order. 'C'
@@ -243,6 +239,10 @@ def reshape(a, /, shape=None, *, newshape=None, order='C', copy=None):
243239
'A' means to read / write the elements in Fortran-like index
244240
order if ``a`` is Fortran *contiguous* in memory, C-like order
245241
otherwise.
242+
newshape : int or tuple of ints
243+
.. deprecated:: 2.1
244+
Replaced by ``shape`` argument. Retained for backward
245+
compatibility.
246246
copy : bool, optional
247247
If ``True``, then the array data is copied. If ``None``, a copy will
248248
only be made if it's required by ``order``. For ``False`` it raises

numpy/_core/tests/test_numeric.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ def test_reshape_shape_arg(self):
184184

185185
assert_equal(np.reshape(arr, shape), expected)
186186
assert_equal(np.reshape(arr, shape, order="C"), expected)
187+
assert_equal(np.reshape(arr, shape, "C"), expected)
187188
assert_equal(np.reshape(arr, shape=shape), expected)
188189
assert_equal(np.reshape(arr, shape=shape, order="C"), expected)
189190
with pytest.warns(DeprecationWarning):

numpy/lib/_ufunclike_impl.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ def fix(x, out=None):
2121
Round to nearest integer towards zero.
2222
2323
Round an array of floats element-wise to nearest integer towards zero.
24-
The rounded values are returned as floats.
24+
The rounded values have the same data-type as the input.
2525
2626
Parameters
2727
----------
2828
x : array_like
29-
An array of floats to be rounded
29+
An array to be rounded
3030
out : ndarray, optional
3131
A location into which the result is stored. If provided, it must have
3232
a shape that the input broadcasts to. If not provided or None, a
@@ -35,12 +35,12 @@ def fix(x, out=None):
3535
Returns
3636
-------
3737
out : ndarray of floats
38-
A float array with the same dimensions as the input.
39-
If second argument is not supplied then a float array is returned
38+
An array with the same dimensions and data-type as the input.
39+
If second argument is not supplied then a new array is returned
4040
with the rounded values.
4141
4242
If a second argument is supplied the result is stored there.
43-
The return value `out` is then a reference to that array.
43+
The return value ``out`` is then a reference to that array.
4444
4545
See Also
4646
--------
@@ -53,7 +53,7 @@ def fix(x, out=None):
5353
>>> np.fix(3.14)
5454
3.0
5555
>>> np.fix(3)
56-
3.0
56+
3
5757
>>> np.fix([2.1, 2.9, -2.1, -2.9])
5858
array([ 2., 2., -2., -2.])
5959

0 commit comments

Comments
 (0)