[Numpy-discussion] GSoC proposal -- Numpy SciPy
pav at iki.fi
Tue Apr 30 16:02:24 EDT 2013
30.04.2013 22:37, Nathaniel Smith kirjoitti:
> How do you plan to go about this? The obvious option of just calling
> scipy.sparse.issparse() on ufunc entry raises some problems, since
> numpy can't depend on or even import scipy, and we might be reluctant
> to add such a special case for what's a rather more general problem.
> OTOH it might be possible to solve the problem in general, e.g., see
> the prototyped _ufunc_override_ special method in:
> but I don't know if you want to get into such a debate within the
> scope of your GSoC. What were you thinking?
To me it seems that the right thing to do here is the general solution.
Do you see immediate problems in e.g. just enabling something like your
The easy thing is that there are no backward compatibility problems
here, since if the magic is missing, the old logic is used. Currently,
the numpy dot() and ufuncs also most of the time do nothing sensible
with sparse matrix inputs even though they in some cases return values.
Which then makes writing generic sparse/dense code more painful than
just __mul__ being matrix multiplication.
IIRC, I seem to remember that also the quantities package had some
issues with operations involving ndarrays, to which being able to
override this could be a solution.
More information about the NumPy-Discussion