larray-project / larray

N-dimensional labelled arrays in Python
https://larray.readthedocs.io/
GNU General Public License v3.0
8 stars 6 forks source link

implement fill_value for shift #1003

Open gdementen opened 2 years ago

gdementen commented 2 years ago

Currently shift reduce the axis size.

There are some cases were you do not want this. I have seen this several times but I am unsure whether or not it's more frequent than the need for the current behavior. I propose adding a fill_value argument, which would default to None (not nan), which would keep the current behavior of reducing the axis. However, if the fill_value argument is given a value (usually 0 or nan), the axis is kept intact, but the labels which would have been dropped with the current behavior are set to the fill_value instead.

Also supporting an array fill_value (eg, to specify the new "column", would feel natural and make some workflows easier.