|
From: John H. <jdh...@ac...> - 2006-10-12 14:03:14
|
>>>>> "Manuel" == Manuel Metz <mm...@as...> writes:
Manuel> There is a subtle but essential difference ;-) : for i in
Manuel> xrange(1,len(r), 2 ) ^^^ , i.e. every second value gets
Manuel> rescaled. But there is probably a more "pythonic" way to
Manuel> do that:
Manuel> r = 1.0/math.sqrt(math.pi) # unit area r = asarray(
Manuel> [r,0.5*r]*self.numsides )
Manuel> I'm not aware of a better way to do this with numerix :-(
Oops, sorry I missed that. I think what you want is then
scale = 0.5/math.sqrt(math.pi)
r = scale*ones(self.numsides*2)
r[1::2] *= 0.5
Manuel> The patch against the latest svn revision (2810) is
Manuel> attached.
OK, if I could make a few more suggestions (I feel like a customer at
a restaurant where every time the waiter brings me a cup of coffee I
ask "just one more thing"...)
+ old_ymin,old_ymax = self.get_ylim()
The matplotlib style guidelines are
UpperCase : classes
lower_underscore : functions and methods
lower or lowerUpper : variables or attributes
For shortish variable names, I prefer
oldymin, oldymax = self.get_ylim()
+ if isinstance(marker, str) or isinstance(marker, unicode):
+ # the standard way to define symbols using a string character
+ sym = syms.get(marker)
+ if isinstance(marker, tuple) or isinstance(marker, list):
+ # accept marker to be:
+ # (numsides, style, [angle])
+ if isinstance(marker[0], int) or isinstance(marker[0], long):
+ # (numsides, style, [angle])
Here you should use "duck typing" not "type checking" (google "duck
typing"). matplotlib.cbook provides several duck typing functions, eg
is_stringlike, iterable and is_numlike. Take a look at is_numlike
def is_numlike(obj):
try: obj+1
except TypeError: return False
else: return True
Ie, if it acts like a number (you can add one to it) then we'll treat
it as a number. This allows users to provide other integer like
classes which are not ints or longs. Everytime you use isinstance,
take a 2nd look. There may be a better way.
I'll await your updated patch :-)
JDH
|