pydata / sparse

Sparse multi-dimensional arrays for the PyData ecosystem

Home Page:https://sparse.pydata.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

fill_value is implicitly assumed to be a subscriptable numpy type

mangecoeur opened this issue · comments

fill_value is described as a scalar but in is assumed to be a subscriptable numpy type in_Elemwise._get_fill_value, leads to errors if you supply your own fill value.

e.g.

        zero_args = tuple(
            arg.fill_value[...] if isinstance(arg, COO) else arg
            for arg in self.args
        )

fails with a normal float fill_value

Can we raise a typeerror exception here . and if it is raised put the varible inside a list like

try: 
   zero_args = tuple(
              arg.fill_value[...] if isinstance(arg, COO) else arg
              for arg in self.args
          )
except TypeError:
     arg.fillvalue = [arg.fillvalue]
   zero_args = tuple(
              arg.fill_value[...] if isinstance(arg, COO) else arg
              for arg in self.args
          )

I would suggest making self.fill_value a read-only property, that can only be set in the ctor.

I feel this is unsupported utilization of an internal API based on the comments. Closing as wontfix.