tvb-recon icon indicating copy to clipboard operation
tvb-recon copied to clipboard

Consider xarray for improved data handling

Open maedoc opened this issue 9 years ago • 0 comments

I usually avoided enhancements over standard ndarray, but I think xarray [1] makes a good case, in combining both Pandas like convenience with labeled dimensions. Specifically, it seems like a step forward in making it easy to write correct code, especially when we might want it to be agnostic to layout. A trivial example is summing over time: with a plain array, you have to know which axis is time, then it's data.sum(axis=time_axis), whereas a labeled array knows that for you, so it's just data.sum('time'). It also helps coordinate work between multiple arrays sharing one or more axes, see [1] for more.

The plain, typed alternative is to write a full wrapping class around every data type, and operations for all their interactions, but this is a lot of boilerplate code for the classes themselves and the tests.

[1] http://xarray.pydata.org/en/stable/why-xarray.html

maedoc avatar Feb 01 '17 08:02 maedoc