@@ -213,6 +213,44 @@ and so the collapsing process only continues so long as it encounters other
213
213
``matrix `` objects. It considers ``c ``, ``b ``, and ``a `` in that order, and
214
214
``b `` is the last entry in that list which is a ``matrix `` object.
215
215
216
+ Casting Rules
217
+ -------------
218
+
219
+ Casting rules have undergone some changes in corner cases, due to the
220
+ NA-related work. In particular for combinations of scalar+scalar:
221
+
222
+ * the `longlong ` type (`q `) now stays `longlong ` for operations with any other
223
+ number (`? b h i l q p B H I `), previously it was cast as `int_ ` (`l `). The
224
+ `ulonglong ` type (`Q `) now stays as `ulonglong ` instead of `uint ` (`L `).
225
+
226
+ * the `timedelta64 ` type (`m `) can now be mixed with any integer type (`b h i l
227
+ q p B H I L Q P `), previously it raised `TypeError `.
228
+
229
+ For array + scalar, the above rules just broadcast except the case when
230
+ the array and scalars are unsigned/signed integers, then the result gets
231
+ converted to the array type (of possibly larger size) as illustrated by the
232
+ following examples::
233
+
234
+ >>> (np.zeros((2,), dtype=np.uint8) + np.int16(257)).dtype
235
+ dtype('uint16')
236
+ >>> (np.zeros((2,), dtype=np.int8) + np.uint16(257)).dtype
237
+ dtype('int16')
238
+ >>> (np.zeros((2,), dtype=np.int16) + np.uint32(2**17)).dtype
239
+ dtype('int32')
240
+
241
+ Whether the size gets increased depends on the size of the scalar, for
242
+ example::
243
+
244
+ >>> (np.zeros((2,), dtype=np.uint8) + np.int16(255)).dtype
245
+ dtype('uint8')
246
+ >>> (np.zeros((2,), dtype=np.uint8) + np.int16(256)).dtype
247
+ dtype('uint16')
248
+
249
+ Also a ``complex128 `` scalar + ``float32 `` array is cast to ``complex64 ``.
250
+
251
+ In NumPy 1.7 the `datetime64 ` type (`M `) must be constructed by explicitly
252
+ specifying the type as the second argument (e.g. ``np.datetime64(2000, 'Y') ``).
253
+
216
254
217
255
Deprecations
218
256
============
0 commit comments