[yt-dev] Issue #1144: numpy and typecasting for in place operations (yt_analysis/yt)

Giovi Pelle issues-reply at bitbucket.org
Thu Nov 19 10:34:08 PST 2015


New issue 1144: numpy and typecasting for in place operations
https://bitbucket.org/yt_analysis/yt/issues/1144/numpy-and-typecasting-for-in-place

Giovi Pelle:

Python 3.4
Numpy 1.10.1

The example for loading [generic array data](http://yt-project.org/doc/examining/generic_array_data.html) fails with the following traceback:

```Python
--------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-17-91acb99a6f75> in <module>()
      1 data = dict(density = (arr, "g/cm**3"))
      2 bbox = np.array([[-1.5, 1.5], [-1.5, 1.5], [-1.5, 1.5]])
----> 3 ds = yt.load_uniform_grid(data, arr.shape, length_unit="Mpc", bbox=bbox, nprocs=64)

/home/giovi/anaconda3/lib/python3.4/site-packages/yt/frontends/stream/data_structures.py in load_uniform_grid(data, domain_dimensions, length_unit, bbox, nprocs, sim_time, mass_unit, time_unit, velocity_unit, magnetic_unit, periodicity, geometry)
    638         new_data = {}
    639         for key in data.keys():
--> 640             psize = get_psize(np.array(data[key].shape), nprocs)
    641             grid_left_edges, grid_right_edges, shapes, slices = \
    642                              decompose_array(data[key].shape, psize, bbox)

/home/giovi/anaconda3/lib/python3.4/site-packages/yt/utilities/decompose.py in get_psize(n_d, pieces)
     93             i = fac[nfac, 1] - i
     94             j = fac[nfac, 1] - (i + k)
---> 95             ldom *= fac[nfac, 0] ** np.array([i, j, k])
     96 
     97         quality = evaluate_domain_decomposition(n_d, pieces, ldom)

TypeError: Cannot cast ufunc multiply output from dtype('float64') to dtype('int64') with casting rule 'same_kind'
```

I guess it can be attributed to the new numpy typecasting rule for in-place operation. Probably it is a simple fix for you.

Best

Giovanni

Responsible: yt_analysis



More information about the yt-dev mailing list