Skip to content

Commit

Permalink
Bump to 0.5.2, attempt to fix docs, fix very deprecated pandas and nu…
Browse files Browse the repository at this point in the history
…mpy usage
  • Loading branch information
vladh committed Nov 27, 2020
1 parent b69766d commit 4617a12
Show file tree
Hide file tree
Showing 24 changed files with 19 additions and 10,597 deletions.
6 changes: 3 additions & 3 deletions doc/sphinxext/numpy_ext/docscrape.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import textwrap
import re
import pydoc
from StringIO import StringIO
from io import StringIO
from warnings import warn

class Reader(object):
Expand Down Expand Up @@ -426,7 +426,7 @@ def __init__(self, func, role='func', doc=None, config={}):
argspec = inspect.formatargspec(*argspec)
argspec = argspec.replace('*','\*')
signature = '%s%s' % (func_name, argspec)
except TypeError, e:
except:
signature = '%s()' % func_name
self['Signature'] = signature

Expand All @@ -449,7 +449,7 @@ def __str__(self):

if self._role:
if not roles.has_key(self._role):
print "Warning: invalid role %s" % self._role
print("Warning: invalid role %s" % self._role)
out += '.. %s:: %s\n \n\n' % (roles.get(self._role,''),
func_name)

Expand Down
2 changes: 1 addition & 1 deletion doc/sphinxext/numpy_ext/docscrape_sphinx.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import re, inspect, textwrap, pydoc
import sphinx
from docscrape import NumpyDocString, FunctionDoc, ClassDoc
from .docscrape import NumpyDocString, FunctionDoc, ClassDoc

class SphinxDocString(NumpyDocString):
def __init__(self, docstring, config=None):
Expand Down
10 changes: 5 additions & 5 deletions doc/sphinxext/numpy_ext/numpydoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
"""

import os, re, pydoc
from docscrape_sphinx import get_doc_object, SphinxDocString
from sphinx.util.compat import Directive
from .docscrape_sphinx import get_doc_object, SphinxDocString
from docutils.parsers.rst import Directive
import inspect

def mangle_docstrings(app, what, name, obj, options, lines,
Expand All @@ -29,7 +29,7 @@ def mangle_docstrings(app, what, name, obj, options, lines,

if what == 'module':
# Strip top title
title_re = re.compile(ur'^\s*[#*=]{4,}\n[a-z0-9 -]+\n[#*=]{4,}\s*',
title_re = re.compile(r'^\s*[#*=]{4,}\n[a-z0-9 -]+\n[#*=]{4,}\s*',
re.I|re.S)
lines[:] = title_re.sub(u'', u"\n".join(lines)).split(u"\n")
else:
Expand All @@ -50,7 +50,7 @@ def mangle_docstrings(app, what, name, obj, options, lines,
references = []
for line in lines:
line = line.strip()
m = re.match(ur'^.. \[([a-z0-9_.-])\]', line, re.I)
m = re.match(r'^.. \[([a-z0-9_.-])\]', line, re.I)
if m:
references.append(m.group(1))

Expand All @@ -59,7 +59,7 @@ def mangle_docstrings(app, what, name, obj, options, lines,
if references:
for i, line in enumerate(lines):
for r in references:
if re.match(ur'^\d+$', r):
if re.match(r'^\d+$', r):
new_r = u"R%d" % (reference_offset[0] + int(r))
else:
new_r = u"%s%d" % (r, reference_offset[0])
Expand Down
4 changes: 2 additions & 2 deletions doc/sphinxext/plot_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ def extract_docstring(self):

docstring = ''
first_par = ''
tokens = tokenize.generate_tokens(lines.__iter__().next)
tokens = tokenize.generate_tokens(lines.pop)
for tok_type, tok_content, _, (erow, _), _ in tokens:
tok_type = token.tok_name[tok_type]
if tok_type in ('NEWLINE', 'COMMENT', 'NL', 'INDENT', 'DEDENT'):
Expand All @@ -287,7 +287,7 @@ def exec_file(self):
plt.close('all')
my_globals = {'pl': plt,
'plt': plt}
execfile(self.filename, my_globals)
exec(compile(open(self.filename, "rb").read(), self.filename, 'exec'), my_globals)

fig = plt.gcf()
self.html = mpld3.fig_to_html(fig)
Expand Down
2 changes: 1 addition & 1 deletion examples/html_tooltips.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@

labels = []
for i in range(N):
label = df.ix[[i], :].T
label = df.iloc[[i], :].T
label.columns = ['Row {0}'.format(i)]
# .to_html() is unicode; so make leading 'u' go away with str()
labels.append(str(label.to_html()))
Expand Down
2 changes: 1 addition & 1 deletion examples/mpld3_logo.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
[0.95, 0.44, 0.34],
[0.92, 0.51, 0.29],
[0.68, 0.21, 0.20]])
mesh = ax.pcolormesh(X, Y, C, cmap=cmap, shading='gourand', zorder=0)
mesh = ax.pcolormesh(X, Y, C, cmap=cmap, shading='auto', zorder=0)
mesh.set_clip_path(clip_path)

# cut-off the background to form the "D" and "3" using white patches
Expand Down
2 changes: 1 addition & 1 deletion mpld3/__about__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
"""Metadata for the mpld3 package."""
__version__ = '0.5.1'
__version__ = '0.5.2'
2 changes: 1 addition & 1 deletion mpld3/_display.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ def default(self, obj):
else:
return [self.default(item) for item in iterable]
if isinstance(obj, numpy.generic):
return numpy.asscalar(obj)
return obj.item()
elif isinstance(obj, (numpy.ndarray,)):
return obj.tolist()
return json.JSONEncoder.default(self, obj)
Expand Down

0 comments on commit 4617a12

Please sign in to comment.