On Thu, Jun 12, 2008 at 8:20 AM, Michael Droettboom <[EMAIL PROTECTED]> wrote:

>> Both `np.float_` and the Python `float` are interpreted as
>> `np.float64`.  The only time you really need something other than
>> `float` is if you require a width other than 64 (like in the first
>> line you showed).

One rule to remember is don't cast user input to float unless there is
no alternative.
Consider that input might be dates::

  In [9]: import numpy as np

  In [10]: import datetime

  In [11]: x = [datetime.date(2007,1,1), datetime.date(2008,1,1),,
datetime.date(2009,1,1)]

  In [12]: xa = np.asarray(x)

  In [13]: print xa[1:]-xa[:-1]
  [365 days, 0:00:00 366 days, 0:00:00]

So many operations may be valid w/o an explicit cast to floats.  Since
we are supporting custom user types, albeit imperfectly, this is
something to bear in mind.  In particular, I find the native datetime
plotting invaluable, and the JPL uses custom unit types extensively.
All of this happens via the unit converter infrastructure in
matplotlib.units and there is machinery there to do the case to
floats.  Last time this came up, Eric I think requested a document
specifying what operations can be assumed on input sequences.  I
haven't done that yet, but I am mentioning this again here as a
reminder.  When I have some time I'll try to get a document together
as well as some test code to test custom input types.

JDH

-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://sourceforge.net/services/buy/index.php
_______________________________________________
Matplotlib-devel mailing list
Matplotlib-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-devel

Reply via email to