Skip to content

Commit

Permalink
Python 3 syntax for print calls
Browse files Browse the repository at this point in the history
  • Loading branch information
TheChymera committed Jan 3, 2021
1 parent 78edec9 commit 39a72e3
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 26 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ The following python code:
from matrix2latex import matrix2latex
m = [[1, 1], [2, 4], [3, 9]] # python nested list
t = matrix2latex(m)
print t
print(t)
```
or equivalent matlab code:
```matlab
Expand Down
4 changes: 2 additions & 2 deletions archiver.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
import os

def callSystem(command):
print '>' + command
print('>' + command)
ret = os.system(command)
if ret != 0:
print 'Command failed, exiting'
print('Command failed, exiting')
exit(1)

version = '1.0.0'
Expand Down
2 changes: 1 addition & 1 deletion doc_sphinx/sphinxext/apigen.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ def generate_api_doc(self, uri):
# get the names of all classes and functions
functions, classes = self._parse_module(uri)
if not len(functions) and not len(classes):
print 'WARNING: Empty -',uri # dbg
print('WARNING: Empty -',uri) # dbg
return ''

# Make a shorter version of the uri that omits the package name for
Expand Down
13 changes: 5 additions & 8 deletions doc_sphinx/sphinxext/docscrape.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,12 +414,9 @@ def __init__(self, func, role='func', doc=None):
try:
NumpyDocString.__init__(self, doc)
except ValueError, e:
print '*'*78
print "ERROR: '%s' while parsing `%s`" % (e, self._f)
print '*'*78
#print "Docstring follows:"
#print doclines
#print '='*78
print('*'*78)
print("ERROR: '%s' while parsing `%s`" % (e, self._f))
print('*'*78)

if not self['Signature']:
func, func_name = self.get_func()
Expand Down Expand Up @@ -452,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 Expand Up @@ -488,7 +485,7 @@ def __str__(self):
out += "\n\n"

#for m in self.methods:
# print "Parsing `%s`" % m
# print("Parsing `%s`" % m)
# out += str(self._func_doc(getattr(self._cls,m), 'meth')) + '\n\n'
# out += '.. index::\n single: %s; %s\n\n' % (self._name, m)

Expand Down
2 changes: 1 addition & 1 deletion doc_sphinx/sphinxext/ipython_console_highlighting.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class IPythonConsoleLexer(Lexer):
In [2]: a
Out[2]: 'foo'
In [3]: print a
In [3]: print(a)
foo
In [4]: 1 / 0
Expand Down
4 changes: 2 additions & 2 deletions doc_sphinx/sphinxext/numpydoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def mangle_docstrings(app, what, name, obj, options, lines,
try:
references.append(int(l[len('.. ['):l.index(']')]))
except ValueError:
print "WARNING: invalid reference in %s docstring" % name
print("WARNING: invalid reference in %s docstring" % name)

# Start renaming from the biggest number, otherwise we may
# overwrite references.
Expand Down Expand Up @@ -104,7 +104,7 @@ def monkeypatch_sphinx_ext_autodoc():
if sphinx.ext.autodoc.format_signature is our_format_signature:
return

print "[numpydoc] Monkeypatching sphinx.ext.autodoc ..."
print("[numpydoc] Monkeypatching sphinx.ext.autodoc ...")
_original_format_signature = sphinx.ext.autodoc.format_signature
sphinx.ext.autodoc.format_signature = our_format_signature

Expand Down
2 changes: 1 addition & 1 deletion matrix2latex/matrix2latex.py
Original file line number Diff line number Diff line change
Expand Up @@ -450,4 +450,4 @@ def matrix2latex(matr, filename=None, *environments, **keywords):

# TODO:
# m = [[1], [2,2,1], [2,1,2]]
# print matrix2latex(m, transpose=True)
# print(matrix2latex(m, transpose=True))
2 changes: 1 addition & 1 deletion matrix2latex/render.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ def matrix2image(matr, filename=None, *args, **kwargs):
if not(os.path.exists(output_filename_tmp)):
raise IOError('Expected %s to exist after calling %s' % (output_filename_tmp, cmd))

print output_filename_tmp, output_filename_final
print(output_filename_tmp, output_filename_final)
shutil.copyfile(output_filename_tmp, output_filename_final)

if clean_latex:
Expand Down
16 changes: 8 additions & 8 deletions test/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,8 @@ def test_pandas_dataframe():
m = [[1, 1], [2, 4], [3, 9]] # python nested list
m = pd.DataFrame(m)
#m = pd.DataFrame.from_csv('http://chymera.eu/data/test/r_data.csv', parse_dates=False, index_col=False)
# print 'PANDAS\n', m
# print 'PANDAS\n', m.to_records()
# print('PANDAS\n', m)
# print('PANDAS\n', m.to_records())
t = matrix2latex(m)
assertEqual(t, "pandas_dataframe")
except ImportError:
Expand All @@ -213,12 +213,12 @@ def test_pandas_series():
import pandas as pd
import numpy as np
s = pd.Series([2, 4, 2, 42, 5], index=['a', 'b', 'c', 'd', 'e'])
# print 'PANDAS\n', s
# print 'PANDAS\n', s.to_dict(), s.tolist(), hasattr(s, 'to_dict')
# print('PANDAS\n', s)
# print('PANDAS\n', s.to_dict(), s.tolist(), hasattr(s, 'to_dict'))
t = matrix2latex(s)
# print 'pandas Series', t
# print('pandas Series', t)
t2 = matrix2latex(pd.DataFrame(s))
# print 'pandas DataFrame', t2
# print('pandas DataFrame', t2)
assertEqual(t, "pandas_series")
assertEqual(t2, "pandas_series_dataFrame")
except ImportError:
Expand All @@ -232,7 +232,7 @@ def test_pandas_columns():
'two' : pd.Series([1., 2., 3., 4.], index=['a', 'b', 'c', 'd'])}
df = pd.DataFrame(d)
t = matrix2latex(df)
# print 'pandas', t, df.to_records()
# print('pandas', t, df.to_records())
assertEqual(t, "pandas_columns")

t = matrix2latex(df, headerRow=None, headerColumn=None)
Expand All @@ -250,7 +250,7 @@ def test_pandas_Panel():
frame = panel.to_frame()
# TODO: Needs support for multiple headerColumns
#t = matrix2latex(frame)
#print t
#print(t)
#assert False
except ImportError:
pass
Expand Down
2 changes: 1 addition & 1 deletion test/testVersionCompatibility.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,4 @@ def test(python, table, pythonVersions):
compatibleTable = matrix2latex(table, '../doc/compatibleTable',
headerColumn=pythonVersions, headerRow=['Compatible'],
caption=c)
print compatibleTable
print(compatibleTable)

0 comments on commit 39a72e3

Please sign in to comment.