Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Update mpl_toolkits.gtktools. #6554

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

Merged
merged 1 commit into from
Jun 20, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Update & deprecate mpl_toolkits.{gtk,excel}tools.
- On Py2, np.rec.fromarrays cannot take a unicode string as names (but
this module __future__-imports unicode_strings).

- CallbackRegistry ctor signature has changed.
  • Loading branch information
anntzer committed Jun 20, 2016
commit 9572d60be2945da2532600e44c30bcc4993ba02c
4 changes: 4 additions & 0 deletions lib/mpl_toolkits/exceltools.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@
import matplotlib.mlab as mlab


cbook.warn_deprecated("2.0", name="mpl_toolkits.exceltools",
alternative="openpyxl", obj_type="module")


def xlformat_factory(format):
"""
copy the format, perform any overrides, and attach an xlstyle instance
Expand Down
19 changes: 8 additions & 11 deletions lib/mpl_toolkits/gtktools.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,15 @@

import copy
import gtk, gobject
import numpy as npy
import numpy as np
import matplotlib.cbook as cbook
from matplotlib.cbook import warn_deprecated
import matplotlib.mlab as mlab


warn_deprecated("2.0", name="mpl_toolkits.gtktools", obj_type="module")


def error_message(msg, parent=None, title=None):
"""
create an error message dialog with string msg. Optionally set
Expand Down Expand Up @@ -164,7 +168,7 @@ def __call__(self, column):
val = model.get_value(thisiter, self.i)
try: val = float(val.strip().rstrip('%'))
except ValueError: pass
if mlab.safe_isnan(val): val = npy.inf # force nan to sort uniquely
if mlab.safe_isnan(val): val = np.inf # force nan to sort uniquely
dsu.append((val, rownum))
dsu.sort()
if not self.num%2: dsu.reverse()
Expand Down Expand Up @@ -326,19 +330,15 @@ def rec2gtk(r, formatd=None, rownum=0, autowin=True):
format = formatd.get(name)
if format is None:
format = mlab.defaultformatd.get(dt.type, mlab.FormatObj())
#print 'gtk fmt factory', i, name, format, type(format)
format = gtkformat_factory(format, i)
formatd[name] = format


colheaders = r.dtype.names
scroll = SortedStringsScrolledWindow(colheaders, formatd)

ind = npy.arange(len(r.dtype.names))
for row in r:
scroll.add_row(row)


if autowin:
win = gtk.Window()
win.set_default_size(800,600)
Expand Down Expand Up @@ -387,7 +387,7 @@ def __init__(self, r, formatd=None, stringd=None):
formatd = mlab.get_formatd(r)

self.stringd = stringd
self.callbacks = cbook.CallbackRegistry(['cell_changed'])
self.callbacks = cbook.CallbackRegistry()

self.r = r

Expand Down Expand Up @@ -586,9 +586,6 @@ def edit_recarray(r, formatd=None, stringd=None, constant=None, autowin=True):
if __name__=='__main__':

import datetime
import gtk
import numpy as np
import matplotlib.mlab as mlab
N = 10
today = datetime.date.today()
dates = [today+datetime.timedelta(days=i) for i in range(N)] # datetimes
Expand All @@ -599,7 +596,7 @@ def edit_recarray(r, formatd=None, stringd=None, constant=None, autowin=True):
clientid = list(xrange(N)) # ints

r = np.rec.fromarrays([clientid, dates, weekdays, gains, prices, up],
names='clientid,date,weekdays,gains,prices,up')
names=str('clientid,date,weekdays,gains,prices,up'))

# some custom formatters
formatd = mlab.get_formatd(r)
Expand Down