nisl/tutorial — pull request #42 by pgervais (2013-04-02 13:04:06+00:00)
Title: Unmask

I profiled the memory usage of unmask, and found that it was _really_ unefficient. The usage of numpy.concatenate at the end of the function requires almost three times the memory that will be required at the end of unmask().

I solved this problem by writing two functions for the special cases of the 3D and N-D arrays, which use much less memory (almost three times less) than the original unmask().

At the same time, **the signature of the function was modified**. The input array is now shaped like in scikit-learn, meaning than the first dimension is time and the second is features (if d is the input array, the value at for the n-th instant for the p-th feature is d[n, p]). It was the opposite by default. The "transpose" option has been removed as well, because it is though to be unclear and useless. Instead of writing something like:

data = unmask(timeseries, transpose=True)

write

data = unmask(timeseries.T).T

which is both shorter and clearer (transpose=True doesn't tell you which matrix is transposed, and when. You'll have to test or read the code to know).