kwgoodman / la

Meet larry, the labeled numpy array
http://pypi.python.org/pypi/la
Other
44 stars 20 forks source link

Add dot method #37

Open kwgoodman opened 12 years ago

kwgoodman commented 12 years ago

I think a good addition to la would be la.dot() and/or a dot method:

lar1.dot(lar2, join='inner', fill=np.nan)

where fill is used when the join method ('outer', 'left', 'right') creates new data.

stroxler commented 12 years ago

This sounds quite nice. There should be no need for a join, at least depending on what we mean by "join"... the axis that would need the same label would be the axis we are multiplying on, which doesn't exist in the output.

We might need to join on that axis (actually, it would be different axes unless both larrys are 1d) before dotting, but then allowing a fill value seems to be confusing and unlikely to be useful. I would think we would just want to either do an inner join or, if the user requests it, raise an error whenever there is not an exact match on the labels.

If we went ahead and did some other join and filled using nans, every single entry in the output would be nan. Filling with zeros would give the exact same answer as an inner join. And filling with anything else, while it would do something, seems unlikely to be useful.

I might not be thinking through all the possibilities, though.

kwgoodman commented 12 years ago

That sounds good.