type error with python 3.2 and version 1.1.1 of matplotlib (numpy error)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

type error with python 3.2 and version 1.1.1 of matplotlib (numpy error)

Paul Tremblay

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.

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: type error with python 3.2 and version 1.1.1 of matplotlib (numpy error)

Benjamin Root-2


On Tue, Sep 4, 2012 at 2:20 PM, Paul Tremblay <[hidden email]> 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?

Ben Root


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: type error with python 3.2 and version 1.1.1 of matplotlib (numpy error)

Eric Firing
On 2012/09/04 9:09 AM, Benjamin Root wrote:

>
>
> On Tue, Sep 4, 2012 at 2:20 PM, Paul Tremblay <[hidden email]
> <mailto:[hidden email]>> 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

>
> Ben Root


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: type error with python 3.2 and version 1.1.1 of matplotlib (numpy error)

Benjamin Root-2


On Tue, Sep 4, 2012 at 3:24 PM, Eric Firing <[hidden email]> wrote:
On 2012/09/04 9:09 AM, Benjamin Root wrote:
>
>
> On Tue, Sep 4, 2012 at 2:20 PM, Paul Tremblay <[hidden email]
> <mailto:[hidden email]>> 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


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: type error with python 3.2 and version 1.1.1 of matplotlib (numpy error)

Eric Firing
In reply to this post by Benjamin Root-2
On 2012/09/04 9:09 AM, Benjamin Root wrote:

>
>
> On Tue, Sep 4, 2012 at 2:20 PM, Paul Tremblay <[hidden email]
> <mailto:[hidden email]>> 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?

To clarify my previous message: I think we will remain mostly at the
mercy of numpy, which may change from version to version, to determine
what we can handle.  Apart from registered unit types, we fall back on
numpy, typically masked_invalid, to handle inputs.  If we really want to
handle Decimal reliably, then it probably has to be done within the
units framework.

Eric


>
> Ben Root


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: type error with python 3.2 and version 1.1.1 of matplotlib (numpy error)

Drain, Theodore R (343P)
In reply to this post by Eric Firing
Isn't that what the unit system is for?  It allows users to use whatever objects they want and register conversions to/from MPL types.  If Decimal is a common use-case, then perhaps MPL should provide those converters but the user would (and probably should) still need to activate them.

________________________________________
From: Eric Firing [[hidden email]]
Sent: Tuesday, September 04, 2012 12:24 PM
To: [hidden email]
Subject: Re: [Matplotlib-users] type error with python 3.2 and version 1.1.1 of matplotlib (numpy error)

On 2012/09/04 9:09 AM, Benjamin Root wrote:

>
>
> On Tue, Sep 4, 2012 at 2:20 PM, Paul Tremblay <[hidden email]
> <mailto:[hidden email]>> 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

>
> Ben Root


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: type error with python 3.2 and version 1.1.1 of matplotlib (numpy error)

Paul Tremblay
In reply to this post by Benjamin Root-2
I am using numpy 1.7, which I built myself (python3 setup.py build). I had a chance to look a bit deeper into matplotlib, which in turn forced me to learn a bit of numpy, and now I see that it probably makes more sense to use numpy arrays for my data. Since the default for an array is a float, most users won't encounter the problems I did, but a warning in a FAQ might solve a few headaches, regardless of how the developers decided to go.

Thanks for your help.

Paul

On Tue, Sep 4, 2012 at 3:09 PM, Benjamin Root <[hidden email]> wrote:


On Tue, Sep 4, 2012 at 2:20 PM, Paul Tremblay <[hidden email]> 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?

Ben Root



------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: type error with python 3.2 and version 1.1.1 of matplotlib (numpy error)

Eric Firing
On 2012/09/05 4:04 PM, Paul Tremblay wrote:
> I am using numpy 1.7, which I built myself (python3 setup.py build). I
> had a chance to look a bit deeper into matplotlib, which in turn forced
> me to learn a bit of numpy, and now I see that it probably makes more
> sense to use numpy arrays for my data. Since the default for an array is
> a float, most users won't encounter the problems I did, but a warning in
> a FAQ might solve a few headaches, regardless of how the developers
> decided to go.

Paul,

numpy 1.7 has a new datetime dtype which probably would be good for your
use--except that mpl doesn't support it yet.  That will be a project for
mpl v1.3.

Eric

>
> Thanks for your help.
>
> Paul
>
> On Tue, Sep 4, 2012 at 3:09 PM, Benjamin Root <[hidden email]
> <mailto:[hidden email]>> wrote:
>
>
>
>     On Tue, Sep 4, 2012 at 2:20 PM, Paul Tremblay
>     <[hidden email] <mailto:[hidden email]>> 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?
>
>     Ben Root
>
>
>
>
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
>
>
>
> _______________________________________________
> Matplotlib-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: type error with python 3.2 and version 1.1.1 of matplotlib (numpy error)

Paul Tremblay
Hmm. I found that mpl handled my datetime objects just fine:

# put the weeks on the x axis
# dates are datetime.datetime
ax.plot(dates, defects)
ax.xaxis.set_major_formatter(
    matplotlib.dates.DateFormatter('%W'))

# create an invisible line in order to
# create a secondary x axis below
# the first axis, which just has the month(s)
newax = fig.add_axes(ax.get_position())
newax.spines['bottom'].set_position(('outward', 25))
newax.patch.set_visible(False)
newax.yaxis.set_visible(False)
# months are also datetime. However, I filtered out
# all dates except the first date for each month
newax.plot_date(months, y,  visible=False)
newax.xaxis.set_major_locator(
    matplotlib.dates.MonthLocator()
)
newax.xaxis.set_major_formatter(
    matplotlib.dates.DateFormatter('%b')
)

On Thu, Sep 6, 2012 at 12:02 AM, Eric Firing <[hidden email]> wrote:
On 2012/09/05 4:04 PM, Paul Tremblay wrote:
> I am using numpy 1.7, which I built myself (python3 setup.py build). I
> had a chance to look a bit deeper into matplotlib, which in turn forced
> me to learn a bit of numpy, and now I see that it probably makes more
> sense to use numpy arrays for my data. Since the default for an array is
> a float, most users won't encounter the problems I did, but a warning in
> a FAQ might solve a few headaches, regardless of how the developers
> decided to go.

Paul,

numpy 1.7 has a new datetime dtype which probably would be good for your
use--except that mpl doesn't support it yet.  That will be a project for
mpl v1.3.

Eric

>
> Thanks for your help.
>
> Paul
>
> On Tue, Sep 4, 2012 at 3:09 PM, Benjamin Root <[hidden email]
> <mailto:[hidden email]>> wrote:
>
>
>
>     On Tue, Sep 4, 2012 at 2:20 PM, Paul Tremblay
>     <[hidden email] <mailto:[hidden email]>> 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?
>
>     Ben Root
>
>
>
>
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
>
>
>
> _______________________________________________
> Matplotlib-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: type error with python 3.2 and version 1.1.1 of matplotlib (numpy error)

Eric Firing
On 2012/09/05 6:17 PM, Paul Tremblay wrote:
> Hmm. I found that mpl handled my datetime objects just fine:

Right, mpl has handled python datetime objects for a long time, but the
numpy array with a datetime dtype is a new and different object, and it
will take a bit of work to support it properly.

Eric

>
> # put the weeks on the x axis
> # dates are datetime.datetime
> ax.plot(dates, defects)
> ax.xaxis.set_major_formatter(
>      matplotlib.dates.DateFormatter('%W'))
>
> # create an invisible line in order to
> # create a secondary x axis below
> # the first axis, which just has the month(s)
> newax = fig.add_axes(ax.get_position())
> newax.spines['bottom'].set_position(('outward', 25))
> newax.patch.set_visible(False)
> newax.yaxis.set_visible(False)
> # months are also datetime. However, I filtered out
> # all dates except the first date for each month
> newax.plot_date(months, y,  visible=False)
> newax.xaxis.set_major_locator(
>      matplotlib.dates.MonthLocator()
> )
> newax.xaxis.set_major_formatter(
>      matplotlib.dates.DateFormatter('%b')
> )
>
> On Thu, Sep 6, 2012 at 12:02 AM, Eric Firing <[hidden email]
> <mailto:[hidden email]>> wrote:
>
>     On 2012/09/05 4:04 PM, Paul Tremblay wrote:
>      > I am using numpy 1.7, which I built myself (python3 setup.py
>     build). I
>      > had a chance to look a bit deeper into matplotlib, which in turn
>     forced
>      > me to learn a bit of numpy, and now I see that it probably makes more
>      > sense to use numpy arrays for my data. Since the default for an
>     array is
>      > a float, most users won't encounter the problems I did, but a
>     warning in
>      > a FAQ might solve a few headaches, regardless of how the developers
>      > decided to go.
>
>     Paul,
>
>     numpy 1.7 has a new datetime dtype which probably would be good for your
>     use--except that mpl doesn't support it yet.  That will be a project for
>     mpl v1.3.
>
>     Eric
>
>      >
>      > Thanks for your help.
>      >
>      > Paul
>      >
>      > On Tue, Sep 4, 2012 at 3:09 PM, Benjamin Root <[hidden email]
>     <mailto:[hidden email]>
>      > <mailto:[hidden email] <mailto:[hidden email]>>> wrote:
>      >
>      >
>      >
>      >     On Tue, Sep 4, 2012 at 2:20 PM, Paul Tremblay
>      >     <[hidden email] <mailto:[hidden email]>
>     <mailto:[hidden email] <mailto:[hidden email]>>>
>     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?
>      >
>      >     Ben Root
>      >
>      >
>      >
>      >
>      >
>     ------------------------------------------------------------------------------
>      > Live Security Virtual Conference
>      > Exclusive live event will cover all the ways today's security and
>      > threat landscape has changed and how IT managers can respond.
>     Discussions
>      > will include endpoint security, mobile security and the latest in
>     malware
>      > threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
>      >
>      >
>      >
>      > _______________________________________________
>      > Matplotlib-users mailing list
>      > [hidden email]
>     <mailto:[hidden email]>
>      > https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>      >
>
>
>     ------------------------------------------------------------------------------
>     Live Security Virtual Conference
>     Exclusive live event will cover all the ways today's security and
>     threat landscape has changed and how IT managers can respond.
>     Discussions
>     will include endpoint security, mobile security and the latest in
>     malware
>     threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
>     _______________________________________________
>     Matplotlib-users mailing list
>     [hidden email]
>     <mailto:[hidden email]>
>     https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
>
>
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
>
>
>
> _______________________________________________
> Matplotlib-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: type error with python 3.2 and version 1.1.1 of matplotlib (numpy error)

Benjamin Root-2


On Thu, Sep 6, 2012 at 2:24 AM, Eric Firing <[hidden email]> wrote:
On 2012/09/05 6:17 PM, Paul Tremblay wrote:
> Hmm. I found that mpl handled my datetime objects just fine:

Right, mpl has handled python datetime objects for a long time, but the
numpy array with a datetime dtype is a new and different object, and it
will take a bit of work to support it properly.

Eric


Pedantic: numpy's datetime64 dtype, not datetime.

Ben Root


------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Matplotlib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users
Loading...