Eric Firing wrote:

>
> Regarding the clip line, I think that your test for mask is None is 
> not the right solution because it knocks out the clipping operation, 
> but the clipping is intended regardless of the state of the mask.  I 
> had expected it to be a very fast operation, so I am surprised it is a 
> bottleneck; in any case I can take a look to see how it can be sped 
> up, or whether it can be bypassed in some cases.  Maybe it is also 
> using "where" internally.
(again, sorry for the double posting, I always forget that some ML do 
not reply automatically to the ML)

My wordings were vague at best :) The clipping operation is *not* 
removed, and it was not the culprit (it becomes a bottleneck once you 
get the 4x speed issue, though). What I did was:

if self.clip:
               mask = ma.getmaskorNone(val)
               if mask == None:
                   val = ma.array(clip(val.filled(vmax), vmin, vmax))
               else:
                   val = ma.array(clip(val.filled(vmax), vmin, vmax),
                               mask=mask)

Actually, the problem is in ma.array: with a value of mask to None, it 
should not make a difference between mask = None or no mask arg, right ? 
I didn't change ma.array to keep my change as local as possible. To 
change only this operation as above gives a speed up from 1.8 s to ~ 1.0 
s for to_rgba, which means calling show goes from ~ 2.2 s to ~1.4 s. I 
also changed
 
result = (val-vmin)/float(vmax-vmin)

to

invcache    = 1.0 / (vmax - vmin)
result = (val-vmin) * invcache

which gives a moderate speed up (around 100 ms for a 8000x256 points 
array, still in the 5-10 % range of the whole cost, though, and is not 
likely to cause any hidden bug). Once you make both those changes, the 
clip call is by far the most expensive operation in normalize functor, 
but the functor is not really expensive anymore compared to the rest, so 
this is not where I looked at after.

For the where calls in Colormap functor, I was wondering if they are 
necessary in all cases: some of those calls seem redundant, and it may 
be possible to detect that before calling them. This should be both 
easier and faster, at least in this case, than having a fast where ?

I understand that support of multiple array backend, support of mask 
arrays have cost consequences. But it looks like it may be possible to 
speed things up for cases where an array has only meaningful values/no 
mask.

cheers,

David


-------------------------------------------------------------------------
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

Reply via email to