Eric Firing wrote: > Robert Cimrman wrote: >> John Hunter wrote: >>>>>>>> "Robert" == Robert Cimrman <[EMAIL PROTECTED]> writes: >>> Robert> BTW would you consider changing the definition of spy(2) >>> Robert> as shown below, so that one could specify what 'to be a >>> Robert> zero' means? >>> >>> I added these enhancement, and a couple more, and an >>> examples/spy_demos.py. >>> >>> On reflection, it might be better to allow the user to simply pass a >>> sparsity function rather than a precision >>> >>> def not_zero(Z): >>> return Z!=0. >>> >>> class not_near_zero: >>> def __init__(self, precision): >>> self.precision = precision >>> def __call__(self, Z): >>> return absolute(asarray(Z))>self.precision >>> >>> def spy(Z, element=not_zero): >>> mask = element(Z) >>> >>> Then you could do: >>> >>> spy(Z, issparse=not_near_zero(1e-6)) >>> >>> >>> >>> The precision implementation you suggested is in svn, but if there is >>> any consensus that either of these approaches is better, speak up. >> I was thinking about passing directly a function (or an expression?) >> too. But I would not remove the precision argument, since it's usage is >> simpler, and is usually all one needs. The best would be to have both >> possibilities :) (function, if present, taking precedence?) > > I agree--and in fact my uninformed view is that even the precision > option is taking spy beyond the realm of showing true sparcity. If this > is genuinely useful to people, then fine. But if it (mainly the > function option) is something that merely might be useful to someone > someday, then I suggest it be left out until there is a clear need. (My > 2 cents-worth, or less.)
Well, the precision argument is useful mainly because of unsafe comparison of floating point values (what is exactly zero?), so it can be used, in fact, to show the true sparsity, and I for one would use it :) > Curiosity questions about implementation: > > 1) What is the "tocoo" method, and what objects have it? a scipy sparse matrix method, to make spy compatible with the sparse matrix module. > 2) Is there a reason why one shouldn't simply default precision to 0 and > use the condition "absolute(asarray(Z)) <= precision"? just a little (full matrix case) and not so little (sparse matrix case) performance penalty. > One more miscellaneous thought: perhaps spy and spy2 should be > consolidated into a single function with a kwarg to select the marker > version or the image version? Their purpose is identical (isn't it?), > and it would reduce namespace clutter. that would be good! r. ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users