[Numpy-discussion] 1.10.0rc1

Antoine Pitrou solipsis at pitrou.net
Thu Aug 27 07:44:24 EDT 2015


The change also seems to have made datetime64 computations stricter:

>>> np.datetime64('2010') - np.datetime64('2000-01-01')
numpy.timedelta64(3653,'D')

>>> np.datetime64('2010') - np.datetime64('2000-01-01T00:00:00Z')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: Cannot cast ufunc subtract input from dtype('<M8[Y]') to dtype('<M8[s]') with casting rule 'same_kind'

Regards

Antoine.


On Wed, 26 Aug 2015 07:52:09 -0600
Charles R Harris <charlesr.harris at gmail.com> wrote:
> On Wed, Aug 26, 2015 at 7:32 AM, Charles R Harris <charlesr.harris at gmail.com
> > wrote:
> 
> >
> >
> > On Wed, Aug 26, 2015 at 7:31 AM, Charles R Harris <
> > charlesr.harris at gmail.com> wrote:
> >
> >>
> >>
> >> On Wed, Aug 26, 2015 at 7:11 AM, Antoine Pitrou <solipsis at pitrou.net>
> >> wrote:
> >>
> >>> On Tue, 25 Aug 2015 10:26:02 -0600
> >>> Charles R Harris <charlesr.harris at gmail.com> wrote:
> >>> > Hi All,
> >>> >
> >>> > The silence after the 1.10 beta has been eerie. Consequently, I'm
> >>> thinking
> >>> > of making a first release candidate this weekend. If you haven't yet
> >>> tested
> >>> > the beta, please do so. It would be good to discover as many problems
> >>> as we
> >>> > can before the first release.
> >>>
> >>> Has typing of ufunc parameters become much stricter? I can't find
> >>> anything in the release notes, but see (1.10b1):
> >>>
> >>> >>> arr = np.linspace(0, 5, 10)
> >>> >>> out = np.empty_like(arr, dtype=np.intp)
> >>> >>> np.round(arr, out=out)
> >>> Traceback (most recent call last):
> >>>   File "<stdin>", line 1, in <module>
> >>>   File
> >>> "/home/antoine/np110/lib/python3.4/site-packages/numpy/core/fromnumeric.py",
> >>> line 2778, in round_
> >>>     return round(decimals, out)
> >>> TypeError: ufunc 'rint' output (typecode 'd') could not be coerced to
> >>> provided output parameter (typecode 'l') according to the casting rule
> >>> ''same_kind''
> >>>
> >>>
> >>> It used to work (1.9):
> >>>
> >>> >>> arr = np.linspace(0, 5, 10)
> >>> >>> out = np.empty_like(arr, dtype=np.intp)
> >>> >>> np.round(arr, out=out)
> >>> array([0, 1, 1, 2, 2, 3, 3, 4, 4, 5])
> >>> >>> out
> >>> array([0, 1, 1, 2, 2, 3, 3, 4, 4, 5])
> >>>
> >>
> >> The default casting mode has been changed. I think this has been raising
> >> a warning since 1.7 and was mentioned as a future change in 1.10, but you
> >> are right, it needs to be mentioned in the 1.10  release notes.
> >>
> >
> > Make that warned of in the 1.9.0 release notes.
> >
> >
> Here it is in 1.9.0 with deprecation warning made visible.
> ```
> In [3]: import warnings
> 
> In [4]: warnings.simplefilter('always')
> 
> In [5]: arr = np.linspace(0, 5, 10)
> 
> In [6]: out = np.empty_like(arr, dtype=np.intp)
> 
> In [7]: np.round(arr, out=out)
> /home/charris/.local/lib/python2.7/site-packages/numpy/core/fromnumeric.py:2640:
> DeprecationWarning: Implicitly casting between incompatible kinds. In a
> future numpy release, this will raise an error. Use casting="unsafe" if
> this is intentional.
>   return round(decimals, out)
> Out[7]: array([0, 1, 1, 2, 2, 3, 3, 4, 4, 5])
> ```
> 
> Chuck
> 





More information about the NumPy-Discussion mailing list