[SciPy-dev] feedback on scipy.sparse

Stefan van der Walt stefan@sun.ac...
Fri Dec 14 05:59:23 CST 2007


On Thu, Dec 13, 2007 at 01:17:22PM -0600, Nathan Bell wrote:
> > Concerning the Stefan's idea of static methods for spidentity etc., we
> > could use only one method for all of them, e.g.
> >
> > class spmatrix:
> >
> >      def special( name, format = ... ):
> >         if name = 'identity':
> >              return spidentity(n,format=format)
> >          ...
> >
> > to prevent cluttering od the class you mentioned.
> 
> Good idea, I hadn't considered that option.

If we do this, we are still merging functionality belonging in
different classes together.  Say we'd like to refactor lil_matrix into
another package, for some reason.  If we use "special", then
extracting the functionality pertaining only to lil_matrix becomes a
problem.  I think functionality that requires insight into the
entrails of an object belongs with that object.

Furthermore,

LilMatrix.special('eye',(3,4)) looks very verbose, compared to

LilMatrix.eye([3,4])

How many of these functions do we have?  If we have in the order of 5
to 10, then cluttering isn't really a problem.

Also, not all of these function need to be re-implemented from
spmatrix (can we rename this to SparseMatrix for consistency?).  For
example, LilMatrix inherits .eye, which can simply defined in terms
of .diag.

Regards
Stéfan


More information about the Scipy-dev mailing list