From 121ea0317f1138959229b543adc390ce3af5e4b1 Mon Sep 17 00:00:00 2001 From: William Patton Date: Fri, 29 Dec 2023 13:36:17 -0500 Subject: [PATCH] formatting fixes --- affogato_comparison.py | 3 +- docs/conf.py | 64 +++++++++++++++++++--------------------- fun.py | 26 ++++++++++++++++ tests/test_mwatershed.py | 1 - 4 files changed, 58 insertions(+), 36 deletions(-) create mode 100644 fun.py diff --git a/affogato_comparison.py b/affogato_comparison.py index d66e01b..a9058e1 100644 --- a/affogato_comparison.py +++ b/affogato_comparison.py @@ -1,5 +1,4 @@ import numpy as np -import pytest import mwatershed @@ -22,4 +21,4 @@ components = compute_mws_segmentation_from_affinities(affinities, offsets, 0) t4 = time.time() -print(f"AFFOGATO: {len(np.unique(components))} components in {t4-t3} seconds") \ No newline at end of file +print(f"AFFOGATO: {len(np.unique(components))} components in {t4-t3} seconds") diff --git a/docs/conf.py b/docs/conf.py index 184c534..af3e9f5 100755 --- a/docs/conf.py +++ b/docs/conf.py @@ -20,7 +20,8 @@ # import os import sys -sys.path.insert(0, os.path.abspath('..')) + +sys.path.insert(0, os.path.abspath("..")) import mwatershed @@ -32,24 +33,24 @@ # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom ones. -extensions = ['sphinx.ext.autodoc', 'sphinx.ext.viewcode'] +extensions = ["sphinx.ext.autodoc", "sphinx.ext.viewcode"] # Add any paths that contain templates here, relative to this directory. -templates_path = ['_templates'] +templates_path = ["_templates"] # The suffix(es) of source filenames. # You can specify multiple suffix as a list of string: # # source_suffix = ['.rst', '.md'] -source_suffix = '.rst' +source_suffix = ".rst" # The master toctree document. -master_doc = 'index' +master_doc = "index" # General information about the project. -project = u"""mwatershed""" -copyright = u"""2023, William Hunter Patton""" -author = u"""William Hunter Patton""" +project = """mwatershed""" +copyright = """2023, William Hunter Patton""" +author = """William Hunter Patton""" # The version info for the project you're documenting, acts as replacement # for |version| and |release|, also used in various other places throughout @@ -70,10 +71,10 @@ # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. # This patterns also effect to html_static_path and html_extra_path -exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] +exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"] # The name of the Pygments (syntax highlighting) style to use. -pygments_style = 'sphinx' +pygments_style = "sphinx" # If true, `todo` and `todoList` produce output, else they produce nothing. todo_include_todos = False @@ -84,7 +85,7 @@ # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. # -html_theme = 'alabaster' +html_theme = "alabaster" # Theme options are theme-specific and customize the look and feel of a # theme further. For a list of options available for each theme, see the @@ -95,13 +96,13 @@ # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ['_static'] +html_static_path = ["_static"] # -- Options for HTMLHelp output --------------------------------------- # Output file base name for HTML help builder. -htmlhelp_basename = 'mwatersheddoc' +htmlhelp_basename = "mwatersheddoc" # -- Options for LaTeX output ------------------------------------------ @@ -110,15 +111,12 @@ # The paper size ('letterpaper' or 'a4paper'). # # 'papersize': 'letterpaper', - # The font size ('10pt', '11pt' or '12pt'). # # 'pointsize': '10pt', - # Additional stuff for the LaTeX preamble. # # 'preamble': '', - # Latex figure (float) alignment # # 'figure_align': 'htbp', @@ -128,9 +126,13 @@ # (source start file, target name, title, author, documentclass # [howto, manual, or own class]). latex_documents = [ - (master_doc, """mwatershed.tex""", - u"""mwatershed Documentation""", - u"""William Hunter Patton""", 'manual'), + ( + master_doc, + """mwatershed.tex""", + """mwatershed Documentation""", + """William Hunter Patton""", + "manual", + ), ] @@ -138,11 +140,7 @@ # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). -man_pages = [ - (master_doc, 'mwatershed', - u'mwatershed Documentation', - [author], 1) -] +man_pages = [(master_doc, "mwatershed", "mwatershed Documentation", [author], 1)] # -- Options for Texinfo output ---------------------------------------- @@ -151,13 +149,13 @@ # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ - (master_doc, 'mwatershed', - u'mwatershed Documentation', - author, - 'mwatershed', - 'One line description of project.', - 'Miscellaneous'), + ( + master_doc, + "mwatershed", + "mwatershed Documentation", + author, + "mwatershed", + "One line description of project.", + "Miscellaneous", + ), ] - - - diff --git a/fun.py b/fun.py new file mode 100644 index 0000000..84b1de2 --- /dev/null +++ b/fun.py @@ -0,0 +1,26 @@ +import numpy as np +import matplotlib.pyplot as plt +import mwatershed + +# Generate an empty ndarray of labels +labels = np.zeros((100, 100)) + +# Add circles with different labels +labels[25:40, 25:40] = 1 +labels[60:75, 60:75] = 2 +labels[50:70, 10:30] = 3 + +affs = np.zeros((2, 100, 100)) +# affs[0] = labels > 0 +# affs[1] = labels > 0 +affs[0, 0, 0] = 1 + +result = mwatershed.agglom(affs - 0.5, [[0, 1], [1, 0]]).astype(np.uint32) +print(result.min(), result.max()) + +fig, ax = plt.subplots(1, 3, figsize=(10, 5)) +# Plot the labels using imshow +ax[0].imshow(labels) +ax[1].imshow(affs[0]) +ax[2].imshow(result) +plt.show() diff --git a/tests/test_mwatershed.py b/tests/test_mwatershed.py index 002ea25..41198e5 100644 --- a/tests/test_mwatershed.py +++ b/tests/test_mwatershed.py @@ -1,5 +1,4 @@ import numpy as np -import pytest import mwatershed