|
From: Benjamin R. <ben...@ou...> - 2012-09-04 19:30:38
|
On Tue, Sep 4, 2012 at 3:24 PM, Eric Firing <ef...@ha...> wrote:
> On 2012/09/04 9:09 AM, Benjamin Root wrote:
> >
> >
> > On Tue, Sep 4, 2012 at 2:20 PM, Paul Tremblay <pau...@gm...
> > <mailto:pau...@gm...>> wrote:
> >
> >
> > The following Python code:
> >
> > >>ax.fill_between(dates, lower, upper, facecolor='gray', alpha=0.5)
> >
> > Produces this error with Python 3.2:
> >
> > Traceback (most recent call last):
> > File "scripts/audit_reports_weekly.py", line 150, in <module>
> > ax.fill_between(dates, lower, upper, facecolor='gray',
> alpha=0.5)
> > File
> >
> "/home/local/ANT/ptrembl/.local/lib/python3.2/site-packages/matplotlib/axes.py",
> > line 6741, in fill_between
> > y1 = ma.masked_invalid(self.convert_yunits(y1))
> > File
> >
> "/home/local/ANT/ptrembl/.local/lib/python3.2/site-packages/numpy/ma/core.py",
> > line 2241, in masked_invalid
> > condition = ~(np.isfinite(a))
> > TypeError: ufunc 'isfinite' not supported for the input types, and
> > the inputs could not be safely coerced to any supported types
> > according to the casting rule ''safe''
> >
> >
> > [Decimal('3619.900530366609820157812617'), .....]
> >
> > If I change the list from type Decimal to type float, then I don't
> > get the error. Likewise, if I use Python 2.7, I also don't get an
> error.
> >
> > After reading over the error message, I realize that this error
> > really results because of numpy, not matplotlib. But I'll go ahead
> > and post this message, in case you are unaware of the problem.
> >
> >
> > Just a quick note, mpl v1.1.x is not officially supported for py3k. The
> > upcoming release of v1.2.0 will be the first official release with such
> > support.
> >
> > That being said, it probably would be a good idea to make sure where the
> > bug lies for this one (numpy or matplotlib). Which version of numpy are
> > you using?
>
> Should this be considered a bug? Or should we say that we don't support
> Decimal inputs? If we are going to support Decimal inputs, then we need
> to put in filters to force conversion to float. Do you want to have to
> check every entry in every list input to see if it Decimal?
>
> Eric
>
>
Looking at the message, it is saying that the np.isfinite() function fails
on Decimal inputs. From our perspective, a Decimal input should look just
the same as integer and floats (following the duck-typing paradigm).
Therefore, I think this problem lies squarely at the feet of numpy.
However, I am doubtful of just how quickly to expect this issue to be
solved by them.
Ben Root
|