Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix for matplotlib/ticker.py (python 3.3) #1991

Merged
merged 1 commit into from May 10, 2013

Conversation

mdboom
Copy link
Member

@mdboom mdboom commented May 10, 2013

(ref. current git version of mpl)

when I plot something with huge coordinate values, > 1E35, I get an error

File "matplotlib/ticker.py", line 550, in set_format
if np.abs(locs - np.round(locs, decimals=sigfigs)).max() < thresh:
File "/usr/lib64/python3.3/site-packages/numpy/core/fromnumeric.py", line 2402, in round

return round(decimals, out)
AttributeError: 'float' object has no attribute 'rint'

The problem is that the array becomes NoneType

ipdb> a
a = array([0.0, 1.0, 2.0, 3.0, 4.0, 5.0], dtype=object)
decimals = 3
out = None

because the representation in

matplotlib/ticker.py overflows

10 ** self.orderOfMagnitude

what can be done as regular integer, hence

locs = (np.asarray(_locs) - self.offset) / 10 ** self.orderOfMagnitude

returns dtype=object

The solution is the following patch (just make "10" float --- "10."):

--- matplotlib/ticker.py~ 2013-05-10 16:43:44.000000000 +1000
+++ matplotlib/ticker.py 2013-05-10 17:44:35.385288785 +1000
@@ -536,7 +536,7 @@
_locs = list(self.locs) + [vmin, vmax]
else:
_locs = self.locs

  •    locs = (np.asarray(_locs) - self.offset) / 10 *\* self.orderOfMagnitude
    
  •    locs = (np.asarray(_locs) - self.offset) / 10. *\* self.orderOfMagnitude
     loc_range = np.ptp(locs)
     if len(self.locs) < 2:
         # We needed the end points only for the loc_range calculation.
    

I hope you can change that.

-Alexander

@mdboom
Copy link
Member

mdboom commented May 10, 2013

Duplicate of #1828.

@mdboom
Copy link
Member

mdboom commented May 10, 2013

@2sn: Thanks for finding the solution!

@2sn
Copy link
Author

2sn commented May 10, 2013

Sorry about the duplicate. I did not find the original posting with Google.

On 10/05/13 23:10, Michael Droettboom wrote:

Duplicate of #1828.


Reply to this email directly or view it on GitHub:
#1991 (comment)

@mdboom
Copy link
Member

mdboom commented May 10, 2013

No worries about not finding it -- I'm just glad to have a solution.

Merging.

mdboom added a commit that referenced this pull request May 10, 2013
bugfix for matplotlib/ticker.py (python 3.3)
@mdboom mdboom merged commit dadb035 into matplotlib:v1.2.x May 10, 2013
@mdboom mdboom deleted the ticker-overflow branch August 7, 2014 13:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants