Would anyone object to, at least temporarily, tightening up the default ufunc casting rule to 'same_kind' in NumPy master? It's a one line change, so would be easy to undo, but such a change is very desirable in my opinion.<div>
<br></div><div>This would raise an exception, since it's np.add(a, 1.9, out=a), converting a float to an int:</div><div><meta http-equiv="content-type" content="text/html; charset=utf-8"><div><div style="background-color: transparent; margin-top: 0px; margin-left: 0px; margin-bottom: 0px; margin-right: 0px; ">
<p id="internal-source-marker_0.38523564022034407" style="font-family: 'Times New Roman'; font-size: medium; margin-left: 36pt; margin-top: 0pt; margin-bottom: 0pt; "><span style="font-size: 11pt; font-family: 'Courier New'; color: rgb(0, 0, 0); background-color: transparent; font-weight: normal; font-style: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; ">>>> a = np.arange(3, dtype=np.int32)</span></p>
<p id="internal-source-marker_0.38523564022034407" style="font-family: 'Times New Roman'; font-size: medium; margin-left: 36pt; margin-top: 0pt; margin-bottom: 0pt; "><span style="font-size: 11pt; font-family: 'Courier New'; color: rgb(0, 0, 0); background-color: transparent; font-weight: normal; font-style: normal; text-decoration: none; vertical-align: baseline; white-space: pre-wrap; "></span><span class="Apple-style-span" style="font-family: 'Courier New'; font-size: 15px; white-space: pre-wrap; ">>>> a += 1.9</span></p>
<p id="internal-source-marker_0.38523564022034407" style="margin-left: 36pt; margin-top: 0pt; margin-bottom: 0pt; "><font class="Apple-style-span" face="'Courier New'"><span class="Apple-style-span" style="font-size: 15px; white-space: pre-wrap;"><br>
</span></font><span class="Apple-style-span" style="font-family: 'Courier New'; font-size: 15px; white-space: pre-wrap; "></span></p></div></div></div><div>It's also relevant to the discussion of nonlinear datetime units and datetime in general. Currently, it will silently convert a months or years delta to a days delta. I've made the conversions between non-linear metadata not satisfy the 'same_kind' rule, so they would be disallowed by default as well (but easily enabled with a casting='unsafe' parameter).</div>
<div><br></div><div>By doing this change, we can see what other code it affects, such as scipy, and patch that code to be safe for this convention whether or not it is adopted in the next release.</div><div><br></div><div>
-Mark</div>