mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-04 18:15:06 +08:00
Merge pull request #586 from sciunto/print
MIN: use print() instead of print
This commit is contained in:
@@ -62,12 +62,12 @@ def remove_common_extensions(cy_bento, cy_setup):
|
||||
|
||||
def print_results(cy_bento, cy_setup):
|
||||
def info(text):
|
||||
print
|
||||
print('')
|
||||
print(text)
|
||||
print('-' * len(text))
|
||||
|
||||
if not (cy_bento or cy_setup):
|
||||
print "bento.info and setup.py files match."
|
||||
print("bento.info and setup.py files match.")
|
||||
|
||||
if cy_bento:
|
||||
info("Extensions found in 'bento.info' but not in any 'setup.py:")
|
||||
@@ -80,8 +80,8 @@ def print_results(cy_bento, cy_setup):
|
||||
info("Consider adding the following to the 'bento.info' Library:")
|
||||
for dir_path in cy_setup:
|
||||
module_path = dir_path.replace('/', '.')
|
||||
print BENTO_TEMPLATE.format(module_path=module_path,
|
||||
dir_path=dir_path)
|
||||
print(BENTO_TEMPLATE.format(module_path=module_path,
|
||||
dir_path=dir_path))
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
+12
-12
@@ -187,7 +187,7 @@ def generate_example_galleries(app):
|
||||
def generate_examples_and_gallery(example_dir, rst_dir, cfg):
|
||||
"""Generate rst from examples and create gallery to showcase examples."""
|
||||
if not example_dir.exists:
|
||||
print "No example directory found at", example_dir
|
||||
print("No example directory found at", example_dir)
|
||||
return
|
||||
rst_dir.makedirs()
|
||||
|
||||
@@ -225,12 +225,12 @@ def write_gallery(gallery_index, src_dir, rst_dir, cfg, depth=0):
|
||||
index_name = cfg.plot2rst_index_name + cfg.source_suffix
|
||||
gallery_template = src_dir.pjoin(index_name)
|
||||
if not os.path.exists(gallery_template):
|
||||
print src_dir
|
||||
print 80*'_'
|
||||
print ('Example directory %s does not have a %s file'
|
||||
print(src_dir)
|
||||
print(80*'_')
|
||||
print('Example directory %s does not have a %s file'
|
||||
% (src_dir, index_name))
|
||||
print 'Skipping this directory'
|
||||
print 80*'_'
|
||||
print('Skipping this directory')
|
||||
print(80*'_')
|
||||
return
|
||||
|
||||
gallery_description = file(gallery_template).read()
|
||||
@@ -252,11 +252,11 @@ def write_gallery(gallery_index, src_dir, rst_dir, cfg, depth=0):
|
||||
try:
|
||||
write_example(src_name, src_dir, rst_dir, cfg)
|
||||
except Exception:
|
||||
print "Exception raised while running:"
|
||||
print "%s in %s" % (src_name, src_dir)
|
||||
print '~' * 60
|
||||
print("Exception raised while running:")
|
||||
print("%s in %s" % (src_name, src_dir))
|
||||
print('~' * 60)
|
||||
traceback.print_exc()
|
||||
print '~' * 60
|
||||
print('~' * 60)
|
||||
continue
|
||||
|
||||
link_name = sub_dir.pjoin(src_name)
|
||||
@@ -354,8 +354,8 @@ def write_example(src_name, src_dir, rst_dir, cfg):
|
||||
|
||||
if not thumb_path.exists:
|
||||
if cfg.plot2rst_default_thumb is None:
|
||||
print "WARNING: No plots found and default thumbnail not defined."
|
||||
print "Specify 'plot2rst_default_thumb' in Sphinx config file."
|
||||
print("WARNING: No plots found and default thumbnail not defined.")
|
||||
print("Specify 'plot2rst_default_thumb' in Sphinx config file.")
|
||||
else:
|
||||
shutil.copy(cfg.plot2rst_default_thumb, thumb_path)
|
||||
|
||||
|
||||
+5
-5
@@ -48,7 +48,7 @@ def sh2(cmd):
|
||||
out = p.communicate()[0]
|
||||
retcode = p.returncode
|
||||
if retcode:
|
||||
print out.rstrip()
|
||||
print(out.rstrip())
|
||||
raise CalledProcessError(retcode, cmd)
|
||||
else:
|
||||
return out.rstrip()
|
||||
@@ -123,12 +123,12 @@ if __name__ == '__main__':
|
||||
sh('git add %s' % tag)
|
||||
sh2('git commit -m"Updated doc release: %s"' % tag)
|
||||
|
||||
print 'Most recent commit:'
|
||||
print('Most recent commit:')
|
||||
sys.stdout.flush()
|
||||
sh('git --no-pager log --oneline HEAD~1..')
|
||||
finally:
|
||||
cd(startdir)
|
||||
|
||||
print
|
||||
print 'Now verify the build in: %r' % dest
|
||||
print "If everything looks good, run 'git push' inside doc/gh-pages."
|
||||
print('')
|
||||
print('Now verify the build in: %r' % dest)
|
||||
print("If everything looks good, run 'git push' inside doc/gh-pages.")
|
||||
|
||||
@@ -8,7 +8,7 @@ Original snake image from pixabay [1]_
|
||||
"""
|
||||
import sys
|
||||
if len(sys.argv) != 2 or sys.argv[1] != '--no-plot':
|
||||
print "Run with '--no-plot' flag to generate logo silently."
|
||||
print("Run with '--no-plot' flag to generate logo silently.")
|
||||
else:
|
||||
import matplotlib as mpl
|
||||
mpl.use('Agg')
|
||||
|
||||
@@ -49,13 +49,13 @@ def calculate_coverage(reader):
|
||||
partial_items,
|
||||
total_items - (partial_items + done_items + na_items),
|
||||
na_items)
|
||||
|
||||
|
||||
return list(i / total_items for i in counts)
|
||||
|
||||
def read_table_titles(reader):
|
||||
r"""Create a dictionary with keys as section names and values as a list of
|
||||
table names
|
||||
|
||||
|
||||
return (dict)
|
||||
"""
|
||||
section_titles = []
|
||||
@@ -69,39 +69,39 @@ def read_table_titles(reader):
|
||||
# Extract names of the tables
|
||||
for name in row[1:]:
|
||||
if len(name) > 0:
|
||||
names.append(name)
|
||||
names.append(name)
|
||||
else:
|
||||
break
|
||||
section_titles.append(row[0])
|
||||
table_names[row[0]] = names
|
||||
except csv.Error, e:
|
||||
sys.exit('line %d: %s' % (reader.line_num, e))
|
||||
|
||||
|
||||
return section_titles,table_names
|
||||
|
||||
def table_seperator(stream,lengths,character="-"):
|
||||
r"""Write out table row seperator
|
||||
|
||||
|
||||
:Input:
|
||||
- *stream* (io/stream) Stream where output is put
|
||||
- *lengths* (list) A list of the lengths of the columns
|
||||
- *character* (string) Character to be filled between +, defaults to "-".
|
||||
|
||||
|
||||
"""
|
||||
stream.write("+")
|
||||
stream.write('+'.join([character*(length+2) for length in lengths]))
|
||||
stream.write("+")
|
||||
|
||||
|
||||
def table_row(stream,data,lengths,num_columns=None):
|
||||
r"""Write out table row data
|
||||
|
||||
|
||||
:Input:
|
||||
- *stream* (io/stream) Stream where output is put
|
||||
- *data* (list) List of strings containing data
|
||||
- *lengths* (list) A list of the lengths of the columns
|
||||
- *num_columns* (string) Number of columns, defaults to the length of the
|
||||
- *num_columns* (string) Number of columns, defaults to the length of the
|
||||
data array
|
||||
|
||||
|
||||
"""
|
||||
if num_columns is None:
|
||||
num_columns = len(data)
|
||||
@@ -115,11 +115,11 @@ def table_row(stream,data,lengths,num_columns=None):
|
||||
else:
|
||||
entry = MISSING_STRING
|
||||
stream.write(" " + entry + " "*(lengths[i] - len(entry)) + " |")
|
||||
|
||||
|
||||
def generate_table(reader,stream,table_name=None,
|
||||
column_titles=["Functionality","Matlab","Scipy","Scipy"]):
|
||||
r"""Generate a reST grid table based on the CSV data in reader
|
||||
|
||||
|
||||
Reads CSV data from *reader* until an empty line is found and generates a
|
||||
reST table based on the data into *stream*. A table name can be given for
|
||||
a section and table label. All rows are read in and checked for maximum
|
||||
@@ -127,13 +127,13 @@ def generate_table(reader,stream,table_name=None,
|
||||
widths so that the table can be constructed. If a row contains less than
|
||||
the maximum number of columns a string is inserted that defaults to the
|
||||
string *MISSING_STRING* which is a global parameter.
|
||||
|
||||
|
||||
:Input:
|
||||
- reader (csv.reader) The CSV reader to read in from
|
||||
- stream (iostream) Output target
|
||||
- table_name (string) Optional name of table, defaults to *None*
|
||||
- column_titles (list) List of column titles
|
||||
|
||||
|
||||
"""
|
||||
# Find number of columns and column widths, base number of columns is
|
||||
# determined by the headers
|
||||
@@ -141,7 +141,6 @@ def generate_table(reader,stream,table_name=None,
|
||||
data = [column_titles]
|
||||
try:
|
||||
for row in reader:
|
||||
# print row
|
||||
if len(row[0]) == 0:
|
||||
break
|
||||
data.append([entry.expandtabs() for entry in row])
|
||||
@@ -153,7 +152,7 @@ def generate_table(reader,stream,table_name=None,
|
||||
for row in data:
|
||||
for i in xrange(len(row)):
|
||||
column_lengths[i] = max(column_lengths[i],len(row[i]))
|
||||
|
||||
|
||||
# Output table header
|
||||
stream.write(table_name + "\n")
|
||||
if table_name is not None:
|
||||
@@ -167,7 +166,7 @@ def generate_table(reader,stream,table_name=None,
|
||||
stream.write("\n")
|
||||
table_seperator(stream,column_lengths,character="=")
|
||||
stream.write("\n")
|
||||
|
||||
|
||||
# Output table data
|
||||
for row in data[1:]:
|
||||
table_row(stream,row,column_lengths,num_columns)
|
||||
@@ -175,28 +174,28 @@ def generate_table(reader,stream,table_name=None,
|
||||
table_seperator(stream,column_lengths,character='-')
|
||||
stream.write("\n")
|
||||
stream.write("\n\n")
|
||||
|
||||
|
||||
def generate_page(csv_path,stream,page_title="Coverage Tables"):
|
||||
r"""Generate coverage table page
|
||||
|
||||
|
||||
Generates all reST for all tables contained in the CSV file at *csv_path*
|
||||
and output it to *stream*.
|
||||
|
||||
|
||||
:Input:
|
||||
- *csv_path* (path) Path to CSV file
|
||||
- *stream* (iostream) Output stream
|
||||
- *page_title* (string) Optional page title, defaults to
|
||||
- *page_title* (string) Optional page title, defaults to
|
||||
``Coverage Tables``.
|
||||
"""
|
||||
# Open reader
|
||||
csv_file = open(csv_path,'U')
|
||||
|
||||
|
||||
# Sniffer does not seem to work all the time even when an Excel
|
||||
# spread sheet is being used
|
||||
# dialect = csv.Sniffer().sniff(csv_file.read(1024))
|
||||
# csv_file.seek(0)
|
||||
# reader = csv.reader(csv_file, dialect)
|
||||
|
||||
|
||||
reader = csv.reader(csv_file)
|
||||
item_counts = calculate_coverage(reader)
|
||||
csv_file.seek(0)
|
||||
@@ -254,21 +253,21 @@ if __name__ == "__main__":
|
||||
output_path = './coverage_table.txt'
|
||||
if len(sys.argv) > 1:
|
||||
if sys.argv[1][:5].lower() == "help":
|
||||
print "Coverage Table Generator: coverage_generator.py"
|
||||
print " Usage: coverage_generator.py [csv] [output]"
|
||||
print " csv - Path to csv file, defaults to ./coverage.csv"
|
||||
print " output - Ouput path, defaults to ./coverage_table.txt"
|
||||
print ""
|
||||
print("Coverage Table Generator: coverage_generator.py")
|
||||
print(" Usage: coverage_generator.py [csv] [output]")
|
||||
print(" csv - Path to csv file, defaults to ./coverage.csv")
|
||||
print(" output - Ouput path, defaults to ./coverage_table.txt")
|
||||
print('')
|
||||
sys.exit(0)
|
||||
if len(sys.argv) == 2:
|
||||
csv_path = os.path.abspath(sys.argv[1])
|
||||
if len(sys.argv) == 3:
|
||||
output_path = os.path.abspath(sys.argv[2])
|
||||
|
||||
|
||||
output = open(output_path,'w')
|
||||
generate_page(csv_path,output)
|
||||
output.close()
|
||||
|
||||
|
||||
print("Generated %s from %s." % (output_path,csv_path))
|
||||
|
||||
|
||||
|
||||
@@ -34,9 +34,9 @@ violates these assumptions about the dtype range::
|
||||
|
||||
>>> from skimage import img_as_float
|
||||
>>> image = np.arange(0, 50, 10, dtype=np.uint8)
|
||||
>>> print image.astype(np.float) # These float values are out of range.
|
||||
>>> print(image.astype(np.float)) # These float values are out of range.
|
||||
[ 0. 10. 20. 30. 40.]
|
||||
>>> print img_as_float(image)
|
||||
>>> print(img_as_float(image))
|
||||
[ 0. 0.03921569 0.07843137 0.11764706 0.15686275]
|
||||
|
||||
|
||||
|
||||
+3
-3
@@ -176,7 +176,7 @@ class ApiDocWriter(object):
|
||||
''' Parse module defined in *uri* '''
|
||||
filename = self._uri2path(uri)
|
||||
if filename is None:
|
||||
print filename, 'erk'
|
||||
print(filename, 'erk')
|
||||
# nothing that we could handle here.
|
||||
return ([],[])
|
||||
f = open(filename, 'rt')
|
||||
@@ -260,7 +260,7 @@ class ApiDocWriter(object):
|
||||
# get the names of all classes and functions
|
||||
functions, classes = self._parse_module_with_import(uri)
|
||||
if not len(functions) and not len(classes) and DEBUG:
|
||||
print 'WARNING: Empty -', uri # dbg
|
||||
print('WARNING: Empty -', uri) # dbg
|
||||
return ''
|
||||
|
||||
# Make a shorter version of the uri that omits the package name for
|
||||
@@ -449,7 +449,7 @@ class ApiDocWriter(object):
|
||||
relpath = (outdir + os.path.sep).replace(relative_to + os.path.sep, '')
|
||||
else:
|
||||
relpath = outdir
|
||||
print "outdir: ", relpath
|
||||
print("outdir: ", relpath)
|
||||
idx = open(path,'wt')
|
||||
w = idx.write
|
||||
w('.. AUTO-GENERATED FILE -- DO NOT EDIT!\n\n')
|
||||
|
||||
@@ -13,7 +13,7 @@ from distutils.version import LooseVersion as V
|
||||
#*****************************************************************************
|
||||
|
||||
def abort(error):
|
||||
print '*WARNING* API documentation not generated: %s'%error
|
||||
print('*WARNING* API documentation not generated: %s' % error)
|
||||
exit()
|
||||
|
||||
if __name__ == '__main__':
|
||||
@@ -54,4 +54,4 @@ if __name__ == '__main__':
|
||||
]
|
||||
docwriter.write_api_docs(outdir)
|
||||
docwriter.write_index(outdir, 'api', relative_to='source/api')
|
||||
print '%d files written' % len(docwriter.written_modules)
|
||||
print('%d files written' % len(docwriter.written_modules))
|
||||
|
||||
@@ -48,7 +48,7 @@ def fetch_PRs(user='scikit-image', repo='scikit-image', state='open'):
|
||||
|
||||
fetch_status = 'Fetching page %(page)d (state=%(state)s)' % params + \
|
||||
' from %(user)s/%(repo)s...' % config
|
||||
print fetch_status
|
||||
print(fetch_status)
|
||||
|
||||
f = urllib.urlopen(
|
||||
'https://api.github.com/repos/%(user)s/%(repo)s/pulls?%(params)s' \
|
||||
@@ -61,7 +61,7 @@ def fetch_PRs(user='scikit-image', repo='scikit-image', state='open'):
|
||||
|
||||
if 'message' in page_data and page_data['message'] == "Not Found":
|
||||
page_data = []
|
||||
print 'Warning: Repo not found (%(user)s/%(repo)s)' % config
|
||||
print('Warning: Repo not found (%(user)s/%(repo)s)' % config)
|
||||
else:
|
||||
data.extend(page_data)
|
||||
|
||||
@@ -69,7 +69,7 @@ def fetch_PRs(user='scikit-image', repo='scikit-image', state='open'):
|
||||
|
||||
try:
|
||||
PRs = json.loads(open(cache, 'r').read())
|
||||
print 'Loaded PRs from cache...'
|
||||
print('Loaded PRs from cache...')
|
||||
|
||||
except IOError:
|
||||
PRs = fetch_PRs(user='stefanv', repo='scikits.image', state='closed')
|
||||
@@ -81,7 +81,7 @@ except IOError:
|
||||
cf.flush()
|
||||
|
||||
nrs = [pr['number'] for pr in PRs]
|
||||
print 'Processing %d pull requests...' % len(nrs)
|
||||
print('Processing %d pull requests...' % len(nrs))
|
||||
|
||||
dates = [dateutil.parser.parse(pr['created_at']) for pr in PRs]
|
||||
|
||||
|
||||
@@ -34,14 +34,14 @@ def match_template(image, template, pad_input=False):
|
||||
--------
|
||||
>>> template = np.zeros((3, 3))
|
||||
>>> template[1, 1] = 1
|
||||
>>> print template
|
||||
>>> print(template)
|
||||
[[ 0. 0. 0.]
|
||||
[ 0. 1. 0.]
|
||||
[ 0. 0. 0.]]
|
||||
>>> image = np.zeros((6, 6))
|
||||
>>> image[1, 1] = 1
|
||||
>>> image[4, 4] = -1
|
||||
>>> print image
|
||||
>>> print(image)
|
||||
[[ 0. 0. 0. 0. 0. 0.]
|
||||
[ 0. 1. 0. 0. 0. 0.]
|
||||
[ 0. 0. 0. 0. 0. 0.]
|
||||
@@ -49,13 +49,13 @@ def match_template(image, template, pad_input=False):
|
||||
[ 0. 0. 0. 0. -1. 0.]
|
||||
[ 0. 0. 0. 0. 0. 0.]]
|
||||
>>> result = match_template(image, template)
|
||||
>>> print np.round(result, 3)
|
||||
>>> print(np.round(result, 3))
|
||||
[[ 1. -0.125 0. 0. ]
|
||||
[-0.125 -0.125 0. 0. ]
|
||||
[ 0. 0. 0.125 0.125]
|
||||
[ 0. 0. 0.125 -1. ]]
|
||||
>>> result = match_template(image, template, pad_input=True)
|
||||
>>> print np.round(result, 3)
|
||||
>>> print(np.round(result, 3))
|
||||
[[-0.125 -0.125 -0.125 0. 0. 0. ]
|
||||
[-0.125 1. -0.125 0. 0. 0. ]
|
||||
[-0.125 -0.125 -0.125 0. 0. 0. ]
|
||||
|
||||
@@ -6,13 +6,13 @@ try:
|
||||
# gui's pyos_inputhook.
|
||||
window_manager.acquire('gtk')
|
||||
except GuiLockError, gle:
|
||||
print gle
|
||||
print(gle)
|
||||
else:
|
||||
try:
|
||||
import gtk
|
||||
except ImportError:
|
||||
print 'pygtk libraries not installed.'
|
||||
print 'plugin not loaded.'
|
||||
print('pygtk libraries not installed.')
|
||||
print('plugin not loaded.')
|
||||
window_manager._release('gtk')
|
||||
else:
|
||||
|
||||
@@ -51,4 +51,4 @@ else:
|
||||
window_manager.register_callback(gtk.main_quit)
|
||||
gtk.main()
|
||||
else:
|
||||
print 'no images to display'
|
||||
print('no images to display')
|
||||
|
||||
@@ -52,8 +52,8 @@ def _scan_plugins():
|
||||
|
||||
for p in provides:
|
||||
if not p in plugin_store:
|
||||
print "Plugin `%s` wants to provide non-existent `%s`." \
|
||||
" Ignoring." % (name, p)
|
||||
print("Plugin `%s` wants to provide non-existent `%s`." \
|
||||
" Ignoring." % (name, p))
|
||||
|
||||
plugin_provides[name] = valid_provides
|
||||
plugin_module_name[name] = os.path.basename(f)[:-4]
|
||||
@@ -208,8 +208,8 @@ def _load(plugin):
|
||||
provides = plugin_provides[plugin]
|
||||
for p in provides:
|
||||
if not hasattr(plugin_module, p):
|
||||
print "Plugin %s does not provide %s as advertised. Ignoring." % \
|
||||
(plugin, p)
|
||||
print("Plugin %s does not provide %s as advertised. Ignoring." % \
|
||||
(plugin, p))
|
||||
else:
|
||||
store = plugin_store[p]
|
||||
func = getattr(plugin_module, p)
|
||||
|
||||
@@ -144,7 +144,7 @@ def _app_show():
|
||||
if app and window_manager.has_windows():
|
||||
app.exec_()
|
||||
else:
|
||||
print 'No images to show. See `imshow`.'
|
||||
print('No images to show. See `imshow`.')
|
||||
|
||||
|
||||
def imsave(filename, img, format_str=None):
|
||||
|
||||
@@ -76,8 +76,8 @@ class WindowManager(object):
|
||||
try:
|
||||
self._windows.remove(win)
|
||||
except ValueError:
|
||||
print 'Unable to find referenced window in tracked windows.'
|
||||
print 'Ignoring...'
|
||||
print('Unable to find referenced window in tracked windows.')
|
||||
print('Ignoring...')
|
||||
else:
|
||||
if len(self._windows) == 0:
|
||||
self._exec_callback()
|
||||
|
||||
@@ -98,7 +98,7 @@ class MultiImage(object):
|
||||
>>> len(img)
|
||||
2
|
||||
>>> for frame in img:
|
||||
... print frame.shape
|
||||
... print(frame.shape)
|
||||
(15, 10)
|
||||
(15, 10)
|
||||
|
||||
|
||||
@@ -118,17 +118,17 @@ def label(input, DTYPE_t neighbors=8, DTYPE_t background=-1, return_num=False):
|
||||
Examples
|
||||
--------
|
||||
>>> x = np.eye(3).astype(int)
|
||||
>>> print x
|
||||
>>> print(x)
|
||||
[[1 0 0]
|
||||
[0 1 0]
|
||||
[0 0 1]]
|
||||
|
||||
>>> print m.label(x, neighbors=4)
|
||||
>>> print(m.label(x, neighbors=4))
|
||||
[[0 1 1]
|
||||
[2 3 1]
|
||||
[2 2 4]]
|
||||
|
||||
>>> print m.label(x, neighbors=8)
|
||||
>>> print(m.label(x, neighbors=8))
|
||||
[[0 1 1]
|
||||
[1 0 1]
|
||||
[1 1 0]]
|
||||
@@ -137,7 +137,7 @@ def label(input, DTYPE_t neighbors=8, DTYPE_t background=-1, return_num=False):
|
||||
... [1, 1, 5],
|
||||
... [0, 0, 0]])
|
||||
|
||||
>>> print m.label(x, background=0)
|
||||
>>> print(m.label(x, background=0))
|
||||
[[ 0 -1 -1]
|
||||
[ 0 0 1]
|
||||
[-1 -1 -1]]
|
||||
|
||||
@@ -6,7 +6,7 @@ def main():
|
||||
import sys
|
||||
|
||||
if len(sys.argv) != 2:
|
||||
print "Usage: skivi <image-file>"
|
||||
print("Usage: skivi <image-file>")
|
||||
sys.exit(-1)
|
||||
|
||||
io.use_plugin('qt')
|
||||
|
||||
@@ -50,7 +50,7 @@ def montage2d(arr_in, fill='mean', rescale_intensity=False):
|
||||
>>> import numpy as np
|
||||
>>> from skimage.util.montage import montage2d
|
||||
>>> arr_in = np.arange(3 * 2 * 2).reshape(3, 2, 2)
|
||||
>>> print arr_in # doctest: +NORMALIZE_WHITESPACE
|
||||
>>> print(arr_in) # doctest: +NORMALIZE_WHITESPACE
|
||||
[[[ 0 1]
|
||||
[ 2 3]]
|
||||
[[ 4 5]
|
||||
@@ -58,20 +58,20 @@ def montage2d(arr_in, fill='mean', rescale_intensity=False):
|
||||
[[ 8 9]
|
||||
[10 11]]]
|
||||
>>> arr_out = montage2d(arr_in)
|
||||
>>> print arr_out.shape
|
||||
>>> print(arr_out.shape)
|
||||
(4, 4)
|
||||
>>> print arr_out
|
||||
>>> print(arr_out)
|
||||
[[ 0. 1. 4. 5. ]
|
||||
[ 2. 3. 6. 7. ]
|
||||
[ 8. 9. 5.5 5.5]
|
||||
[ 10. 11. 5.5 5.5]]
|
||||
>>> print arr_in.mean()
|
||||
>>> print(arr_in.mean())
|
||||
5.5
|
||||
"""
|
||||
assert arr_in.ndim == 3
|
||||
|
||||
n_images, height, width = arr_in.shape
|
||||
|
||||
|
||||
arr_in = arr_in.copy()
|
||||
|
||||
# -- rescale intensity if necessary
|
||||
|
||||
@@ -60,7 +60,7 @@ class LineTool(CanvasToolBase):
|
||||
if on_enter is None:
|
||||
def on_enter(pts):
|
||||
x, y = np.transpose(pts)
|
||||
print "length = %0.2f" % np.sqrt(np.diff(x)**2 + np.diff(y)**2)
|
||||
print("length = %0.2f" % np.sqrt(np.diff(x)**2 + np.diff(y)**2))
|
||||
self.callback_on_enter = on_enter
|
||||
|
||||
self.connect_event('button_press_event', self.on_mouse_press)
|
||||
|
||||
Reference in New Issue
Block a user