joschu / cgt

Computation Graph Toolkit
Other
628 stars 87 forks source link

Fixed casting errors in _nu_iceil and _nu_ifloor #46

Closed sbos closed 8 years ago

sbos commented 8 years ago

Tests are now passing and the NTM demo is running. See #38 for discussion

joschu commented 8 years ago

By the way, for best performance, you should use the native backend In ~/.cgtrc, add a line backend = native

sbos commented 8 years ago

I'm using 1.10.1, the latest that pip installed for me. I agree that allocation of a temporary array is undesirable, but don't know how to avoid it.

f0k commented 8 years ago

I'm using 1.10.1, the latest that pip installed for me.

Ah, it's actually a change introduced in numpy 1.10: https://github.com/numpy/numpy/blob/master/doc/release/1.10.0-notes.rst#default-casting-rule-change

I agree that allocation of a temporary array is undesirable, but don't know how to avoid it.

The solution would be to use np.ceil(x, out, casting='unsafe'). The ufunc keyword arguments are documented here: http://docs.scipy.org/doc/numpy/reference/ufuncs.html#optional-keyword-arguments