diff --git a/.clang-format b/.clang-format index 1c27bb27a..a9b825916 100644 --- a/.clang-format +++ b/.clang-format @@ -34,7 +34,7 @@ AlwaysBreakBeforeMultilineStrings: false AlwaysBreakTemplateDeclarations: true BinPackArguments: true BinPackParameters: true -BraceWrapping: +BraceWrapping: AfterClass: false AfterControlStatement: false AfterEnum: false @@ -65,7 +65,7 @@ DisableFormat: false ExperimentalAutoDetectBinPacking: false FixNamespaceComments: true ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ] -IncludeCategories: +IncludeCategories: - Regex: '^"' Priority: 1 - Regex: '^<' diff --git a/.github/workflows/pull_request.yaml b/.github/workflows/pull_request.yaml index 7ff47b345..b7efd31d7 100644 --- a/.github/workflows/pull_request.yaml +++ b/.github/workflows/pull_request.yaml @@ -24,7 +24,7 @@ jobs: check_formatting: uses: NWChemEx/.github/.github/workflows/check_formatting.yaml@master with: - license_config: ".github/.licenserc.yaml" + license_config: ".licenserc.yaml" test_nwx_docs: uses: NWChemEx/.github/.github/workflows/test_nwx_docs.yaml@master diff --git a/.github/.licenserc.yaml b/.licenserc.yaml similarity index 96% rename from .github/.licenserc.yaml rename to .licenserc.yaml index 9d2b257b2..c27474597 100644 --- a/.github/.licenserc.yaml +++ b/.licenserc.yaml @@ -24,5 +24,6 @@ header: - cmake/generate_module_docs.cpp.in - LICENSE - version.txt + - build/ - comment: never \ No newline at end of file + comment: never diff --git a/LICENSE b/LICENSE index 4947287f7..f433b1a53 100644 --- a/LICENSE +++ b/LICENSE @@ -174,4 +174,4 @@ incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. - END OF TERMS AND CONDITIONS \ No newline at end of file + END OF TERMS AND CONDITIONS diff --git a/docs/requirements.txt b/docs/requirements.txt index a287c9352..c1e11bf8b 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -1,4 +1,4 @@ sphinx==v7.2.6 sphinx_rtd_theme==1.3.0 -sphinxcontrib-bibtex sphinx_tabs +sphinxcontrib-bibtex diff --git a/docs/source/background/scientific_software.rst b/docs/source/background/scientific_software.rst index 6ade870ad..6811965e7 100644 --- a/docs/source/background/scientific_software.rst +++ b/docs/source/background/scientific_software.rst @@ -145,7 +145,7 @@ software. With regards to why scientific software is unique: #. Performance - Scientific software is among the most computationally expensive software - in the world. The high computational complexity of many algorithms means + in the world. The high computational complexity of many algorithms means that even a small degradation in performance can result in a simulation becoming intractable. - Often requires high-performance computing @@ -158,7 +158,7 @@ software. With regards to why scientific software is unique: the scientists themselves. - Benefit to cost ratio of dependencies must be large, i.e., dependencies are usually only considered if they save a lot of time, or are very performant. - In addition, the scientists need to have some level of assurance that the + In addition, the scientists need to have some level of assurance that the dependency will continue to be supported in the future. - Most scientists prefer to do as little software development as possible. @@ -170,7 +170,7 @@ software. With regards to why scientific software is unique: - Users may come up with use cases beyond the scope of the original software. - Research leads to new quantities of interest, and software needs to be extensible to support these new properties. - - New algorithms for computing a property emerge. The software architecture + - New algorithms for computing a property emerge. The software architecture needs to be able to use these algorithms throughout the code. #. Complex nature of scientific research @@ -190,10 +190,10 @@ software. With regards to why scientific software is unique: - Developers are typically spread out across the world, making synchronization difficult. - - The scientific software community encapsulates an entire range of software - engineering capabilities. Therefore, the quality of contributions and + - The scientific software community encapsulates an entire range of software + engineering capabilities. Therefore, the quality of contributions and software products can vary widely. - - There is a need to protect unpublished research to ensure publication + - There is a need to protect unpublished research to ensure publication rights. Decentralized development allows you to keep your unpublished research separate. diff --git a/docs/source/conf.py b/docs/source/conf.py index f8802db95..cc912f437 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -24,9 +24,9 @@ # -- Project information ----------------------------------------------------- -project = u'PluginPlay' -copyright = u'2020, NWChemEx Team' -author = u'NWChemEx Team' +project = "PluginPlay" +copyright = "2020, NWChemEx Team" +author = "NWChemEx Team" # Get the version from version.txt version = "1.0.0" @@ -40,15 +40,20 @@ # -- General configuration --------------------------------------------------- # We use numref which is introduced in Sphinx 1.3 -needs_sphinx = '1.3' +needs_sphinx = "1.3" # 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.mathjax', 'sphinx.ext.githubpages', - 'sphinx.ext.autosummary', 'sphinx_rtd_theme', 'sphinxcontrib.bibtex', - 'sphinx.ext.githubpages', 'sphinx_tabs.tabs' + "sphinx.ext.autodoc", + "sphinx.ext.mathjax", + "sphinx.ext.githubpages", + "sphinx.ext.autosummary", + "sphinx_rtd_theme", + "sphinxcontrib.bibtex", + "sphinx.ext.githubpages", + "sphinx_tabs.tabs", ] dir_path = os.path.dirname(os.path.realpath(__file__)) doc_path = os.path.dirname(dir_path) @@ -58,17 +63,17 @@ # 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" # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. # # This is also used if you do content translation via gettext catalogs. # Usually you set "language" from the command line for these cases. -language = 'en' +language = "en" # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. @@ -76,7 +81,7 @@ exclude_patterns = [] # The name of the Pygments (syntax highlighting) style to use. -pygments_style = 'sphinx' +pygments_style = "sphinx" # Should figures be numbered? numfig = True @@ -86,7 +91,7 @@ # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. # -html_theme = 'sphinx_rtd_theme' +html_theme = "sphinx_rtd_theme" html_logo = "assets/full_logo.png" @@ -94,12 +99,12 @@ # further. For a list of options available for each theme, see the # documentation. # -html_theme_options = {'logo_only': True} +html_theme_options = {"logo_only": True} # 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'] # Custom sidebar templates, must be a dictionary that maps document names # to template names. @@ -114,7 +119,7 @@ # -- Options for HTMLHelp output --------------------------------------------- # Output file base name for HTML help builder. -htmlhelp_basename = project + 'doc' +htmlhelp_basename = project + "doc" # -- Options for LaTeX output ------------------------------------------------ @@ -122,15 +127,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', @@ -140,16 +142,22 @@ # (source start file, target name, title, # author, documentclass [howto, manual, or own class]). latex_documents = [ - (master_doc, project + '.tex', project + ' Documentation', author, - 'manual'), + ( + master_doc, + project + ".tex", + project + " Documentation", + author, + "manual", + ), ] # -- Options for manual page output ------------------------------------------ # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). -man_pages = [(master_doc, project.lower(), project + ' Documentation', - [author], 1)] +man_pages = [ + (master_doc, project.lower(), project + " Documentation", [author], 1) +] # -- Options for Texinfo output ---------------------------------------------- @@ -157,8 +165,15 @@ # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ - (master_doc, project, project + ' Documentation', author, project, - 'One line description of project.', 'Miscellaneous'), + ( + master_doc, + project, + project + " Documentation", + author, + project, + "One line description of project.", + "Miscellaneous", + ), ] # -- Extension configuration ------------------------------------------------- @@ -166,13 +181,14 @@ # -- Options for intersphinx extension --------------------------------------- # Example configuration for intersphinx: refer to the Python standard library. -intersphinx_mapping = {'https://docs.python.org/': None} +intersphinx_mapping = {"https://docs.python.org/": None} # -- Options for bibtex -------------------------------------------------------- bibtex_bibfiles = [ - 'bibliography/background.bib', 'bibliography/design.bib', - 'bibliography/pluginplay.bib' + "bibliography/background.bib", + "bibliography/design.bib", + "bibliography/pluginplay.bib", ] -bibtex_reference_style = 'super' -bibtex_default_style = 'plain' +bibtex_reference_style = "super" +bibtex_default_style = "plain" diff --git a/docs/source/developer/design/field.rst b/docs/source/developer/design/field.rst index 3be9178af..57cb7a0e3 100644 --- a/docs/source/developer/design/field.rst +++ b/docs/source/developer/design/field.rst @@ -18,14 +18,14 @@ Designing the Field Component ############################# -:ref:`property_type_design` and :ref:`module_design` both called for a +:ref:`property_type_design` and :ref:`module_design` both called for a mechanism to handle fields. **************************** What is the Field Component? **************************** -Modules are meant to be black-box functions which take all the input (inputs +Modules are meant to be black-box functions which take all the input (inputs and callbacks) they will need to compute their results. The inputs and results are the fields. Since callbacks are passed as inputs we consider how they are passed to be part of the field component, while the actual callback @@ -55,7 +55,7 @@ Field Component Considerations - Associating checks with the field avoids waiting until the module runs to ensure the field's value is valid. - Used to prevent users from setting a field to an incorrect value (before - the module tries to unwrap the input). + the module tries to unwrap the input). #. Leverage metadata to generate documentation. @@ -77,13 +77,13 @@ Field Component Design to/from a module and SubmoduleRequest is used to manage callback hooks. :numref:`fig_field_design` shows the architecture of the field component. -The three major components, ``ModuleInput``, ``ModuleResult``, and +The three major components, ``ModuleInput``, ``ModuleResult``, and ``SubmoduleRequest`` correspond to three major items passed into/from modules. ``ModuleInput`` manages an input to a module (the set of inputs passed to a module will be a container of ``ModuleInput`` objects). In addition to the type-erased input, which lives in the ``AnyField`` object, the ``ModuleInput`` also holds metadata (*e.g.*, a description, if the user set the value, is -the value :ref:`opaque`) and any bounds checks (*e.g.*, can the value be null, +the value :ref:`opaque`) and any bounds checks (*e.g.*, can the value be null, is there a maximum/minimum for the value, what are the allowed strings). The ``ModuleResult`` is similar except it does not have bounds checks (the module developer presumably is not trying to return invalid results). The @@ -117,4 +117,4 @@ Summary #. Leverage metadata to generate documentation. - Not strictly part of the field component, but the field component exposes - enough information for another component to generate the documentation. \ No newline at end of file + enough information for another component to generate the documentation. diff --git a/docs/source/developer/design/property_type.rst b/docs/source/developer/design/property_type.rst index c9bc27c94..937ff004d 100644 --- a/docs/source/developer/design/property_type.rst +++ b/docs/source/developer/design/property_type.rst @@ -28,7 +28,7 @@ What is the Property Type Component? At the lowest level all modules have the same :ref:`api`: take a series of type-erased inputs and return a set of type-erased outputs. In strongly typed languages like C++, type-erased objects are cumbersome to work with. The -property type component facilitates the wrapping/unwrapping of +property type component facilitates the wrapping/unwrapping of typed/type-erased objects while also enforcing a standardized :ref:`api`. **************************** @@ -62,7 +62,7 @@ While not explicitly called for at this point we also want: - Many properties are related via "is-a-type-of" relationships. - Inheritance captures "is-a-type-of" relationships and can be used for - avoiding duplication + avoiding duplication ****************************** Property Type Component Design @@ -81,7 +81,7 @@ Property Type Component Design Fig :numref:`fig_property_type_design` shows the architecture of the property type component. The ``PropertyType`` class holds the bulk of the implementation. Users derive their property types from ``PropertyType``, using the curiously- -recursive template pattern (CRTP). CRTP facilitates PluginPlay implementing +recursive template pattern (CRTP). CRTP facilitates PluginPlay implementing features on behalf of the user, without PluginPlay knowing the types. *N.B.*, normal inheritance would not allow the ``PropertyType`` class to access the types defined in the derived class. In our implementation ``PropertyType`` is @@ -91,7 +91,7 @@ will implement four functions ``wrap_inputs``, ``wrap_results``, un-type-erase data on behalf of the user. In the derived class, users fill in two ``FieldTuple`` objects, one for the -inputs and one for the results. The process of doing this is wrapped by +inputs and one for the results. The process of doing this is wrapped by "virtual" functions (since we're using CRTP they're not actually virtual) ``inputs_`` and ``results_`` respectively. The ``FieldTuple`` objects are responsible for storing not only the types of the inputs, but also the default @@ -105,19 +105,19 @@ Our design addresses the above considerations by: #. Dynamic determine module :ref:`api` - - ``unwrap_inputs`` / ``unwrap_results`` and - ``wrap_inputs`` / ``wrap_results`` functions can be used at runtime to go + - ``unwrap_inputs`` / ``unwrap_results`` and + ``wrap_inputs`` / ``wrap_results`` functions can be used at runtime to go from/to type-erased inputs/results. #. Domain agnostic - CRTP allows the ``PropertyType`` class to access derived class's types through "inheritance". - - Derived classes, and their types, live in downstream code. + - Derived classes, and their types, live in downstream code. #. Avoid exposing templates to the user (to the extent possible) - - Largely falls to ``FieldTuple`` component. + - Largely falls to ``FieldTuple`` component. - Macros further de-template the :ref:`api`. #. Use property types to factor out input/result provenance @@ -128,4 +128,3 @@ Our design addresses the above considerations by: #. Allow property type inheritance - ``PropertyType`` is templated on base property types. - diff --git a/docs/source/tutorials/modules/basics.rst b/docs/source/tutorials/modules/basics.rst index 851a24727..40c28c33a 100644 --- a/docs/source/tutorials/modules/basics.rst +++ b/docs/source/tutorials/modules/basics.rst @@ -122,7 +122,7 @@ For some modules, inputs that are not defined by the property type(s) may be needed. Additional inputs can be specified in the constructor with the ``add_inputs`` method. A similar option for added results exist, though it is less common. Additional inputs have to be set before the module is run, either -with a default value or by calling the ``change_input`` method. Here are +with a default value or by calling the ``change_input`` method. Here are examples for adding a screening threshold to our ``ScreenedCoulombsLaw`` module: .. tabs:: @@ -182,7 +182,7 @@ returns a result map with the type-erased results. If a module has additional inputs beyond those specified by the property type, they will have to be specifically unpacked from the ``inputs``. In the - case of the ``ScreenedCoulombsLaw`` module, the screening threshold is + case of the ``ScreenedCoulombsLaw`` module, the screening threshold is acquired as: .. tabs:: @@ -199,7 +199,7 @@ returns a result map with the type-erased results. :language: python :lines: 53-56 -The full definition of the ``run_`` member for the ``CoulombsLaw`` module +The full definition of the ``run_`` member for the ``CoulombsLaw`` module (including the source code for computing the electric field) is: .. tabs:: diff --git a/docs/source/tutorials/plugins/index.rst b/docs/source/tutorials/plugins/index.rst index 126511ecf..fd8c8c1c2 100644 --- a/docs/source/tutorials/plugins/index.rst +++ b/docs/source/tutorials/plugins/index.rst @@ -19,18 +19,18 @@ Module Collections Typically developers write more than one module. When modules share some common theme (for example they all relate to computing electric fields) developers will often choose to distribute/bundle these modules together. We term such -distributions "module collections". The grouping of modules into collections is -purely arbitary and for the developer's convenience. Come runtime, the set of -modules available to the user wil be the union of all module collections that +distributions "module collections". The grouping of modules into collections is +purely arbitary and for the developer's convenience. Come runtime, the set of +modules available to the user wil be the union of all module collections that have been loaded. The sections in this chapter focus on best practices for maintaining a module -collection. +collection. .. toctree:: :maxdepth: 2 :caption: Contents: - + overview load_modules document_modules diff --git a/docs/source/tutorials/property_types/advanced.rst b/docs/source/tutorials/property_types/advanced.rst index 9ebb3cda0..60a1f2bdf 100644 --- a/docs/source/tutorials/property_types/advanced.rst +++ b/docs/source/tutorials/property_types/advanced.rst @@ -26,4 +26,4 @@ purposes: code factorization and expressing relationships among property types. Templated Property Types ======================== -TODO: Write me!!! \ No newline at end of file +TODO: Write me!!! diff --git a/docs/source/tutorials/property_types/index.rst b/docs/source/tutorials/property_types/index.rst index 13c6774a3..4c17d00b7 100644 --- a/docs/source/tutorials/property_types/index.rst +++ b/docs/source/tutorials/property_types/index.rst @@ -16,10 +16,10 @@ Property Type Development ######################### -The topics in this chapter will walk you through writing and designing property -types. Needing to design a property type is common when a project starts and -becomes less common when an established set of property types already exists -(because the likelihood that a property type already exists for your property +The topics in this chapter will walk you through writing and designing property +types. Needing to design a property type is common when a project starts and +becomes less common when an established set of property types already exists +(because the likelihood that a property type already exists for your property increases). We continue the electric field example started in the modules chapter, here diff --git a/include/pluginplay/any/detail_/any_field_base.hpp b/include/pluginplay/any/detail_/any_field_base.hpp index 0eb71702c..38152aee1 100644 --- a/include/pluginplay/any/detail_/any_field_base.hpp +++ b/include/pluginplay/any/detail_/any_field_base.hpp @@ -317,9 +317,9 @@ class AnyFieldBase { private: /// Deleted to avoid slicing ///@{ - AnyFieldBase(AnyFieldBase&& other) = delete; + AnyFieldBase(AnyFieldBase&& other) = delete; AnyFieldBase& operator=(const AnyFieldBase&) = delete; - AnyFieldBase& operator=(AnyFieldBase&&) = delete; + AnyFieldBase& operator=(AnyFieldBase&&) = delete; ///@} /// To be overriddent to implement clone diff --git a/include/pluginplay/module/facade_module.hpp b/include/pluginplay/module/facade_module.hpp index 2bacc381a..ad28db4b7 100644 --- a/include/pluginplay/module/facade_module.hpp +++ b/include/pluginplay/module/facade_module.hpp @@ -71,10 +71,10 @@ class FacadeModule : public ModuleBase { template explicit FacadeModule(Args&&... args); - FacadeModule(const FacadeModule&) = delete; - FacadeModule(FacadeModule&&) = delete; + FacadeModule(const FacadeModule&) = delete; + FacadeModule(FacadeModule&&) = delete; FacadeModule& operator=(const FacadeModule&) = delete; - FacadeModule& operator=(FacadeModule&&) = delete; + FacadeModule& operator=(FacadeModule&&) = delete; /** @brief Implements the `run_as` function for the `Module` class. * diff --git a/include/pluginplay/module/lambda_module.hpp b/include/pluginplay/module/lambda_module.hpp index 116226e96..9736273b4 100644 --- a/include/pluginplay/module/lambda_module.hpp +++ b/include/pluginplay/module/lambda_module.hpp @@ -96,10 +96,10 @@ class LambdaModule : public ModuleBase { template explicit LambdaModule(FxnType&& fxn); - LambdaModule(const LambdaModule&) = delete; - LambdaModule(LambdaModule&&) = delete; + LambdaModule(const LambdaModule&) = delete; + LambdaModule(LambdaModule&&) = delete; LambdaModule& operator=(const LambdaModule&) = delete; - LambdaModule& operator=(LambdaModule&&) = delete; + LambdaModule& operator=(LambdaModule&&) = delete; /** @brief Implements the `run_as` function for the `Module` class. * diff --git a/src/pluginplay/config/config_impl.hpp b/src/pluginplay/config/config_impl.hpp index 1ba011697..8de1d972e 100644 --- a/src/pluginplay/config/config_impl.hpp +++ b/src/pluginplay/config/config_impl.hpp @@ -22,7 +22,7 @@ namespace pluginplay { #ifdef BUILD_ROCKS_DB static constexpr bool with_rocksdb_v = true; #else -static constexpr bool with_rocksdb_v = false; +static constexpr bool with_rocksdb_v = false; #endif /// Used throughout PluginPlay to enable/disable pybind11 support at compiletime diff --git a/src/pluginplay/module_manager/detail_/module_manager_pimpl.ipp b/src/pluginplay/module_manager/detail_/module_manager_pimpl.ipp index cb43d932f..15f7a74df 100644 --- a/src/pluginplay/module_manager/detail_/module_manager_pimpl.ipp +++ b/src/pluginplay/module_manager/detail_/module_manager_pimpl.ipp @@ -129,4 +129,4 @@ inline ModuleManager::key_container_type ModuleManagerPIMPL::keys() const { return keys; } -} // namespace pluginplay::detail_ \ No newline at end of file +} // namespace pluginplay::detail_ diff --git a/src/pluginplay/module_manager/module_manager_class.cpp b/src/pluginplay/module_manager/module_manager_class.cpp index 23294778e..ed83cd81d 100644 --- a/src/pluginplay/module_manager/module_manager_class.cpp +++ b/src/pluginplay/module_manager/module_manager_class.cpp @@ -32,7 +32,7 @@ ModuleManager::ModuleManager() : pimpl_(std::make_unique()) {} ModuleManager::ModuleManager(runtime_ptr runtime, cache_pointer cache) : pimpl_(std::make_unique(runtime, cache)) {} -ModuleManager::ModuleManager(ModuleManager&& rhs) noexcept = default; +ModuleManager::ModuleManager(ModuleManager&& rhs) noexcept = default; ModuleManager& ModuleManager::operator=(ModuleManager&& rhs) noexcept = default; ModuleManager::~ModuleManager() noexcept = default; diff --git a/src/python/printing/export_printing.hpp b/src/python/printing/export_printing.hpp index 66e9f3c00..40558dbc8 100644 --- a/src/python/printing/export_printing.hpp +++ b/src/python/printing/export_printing.hpp @@ -25,4 +25,4 @@ inline void export_printing(py_module_reference m) { export_document_modules(m); } -} // namespace pluginplay \ No newline at end of file +} // namespace pluginplay diff --git a/tests/cxx/unit_tests/pluginplay/catch.hpp b/tests/cxx/unit_tests/pluginplay/catch.hpp index 73d7d0e99..42e8ef612 100644 --- a/tests/cxx/unit_tests/pluginplay/catch.hpp +++ b/tests/cxx/unit_tests/pluginplay/catch.hpp @@ -17,4 +17,4 @@ #pragma once #include #include -#include \ No newline at end of file +#include diff --git a/tests/cxx/unit_tests/pluginplay/examples/writing_a_module.hpp b/tests/cxx/unit_tests/pluginplay/examples/writing_a_module.hpp index 7404595ac..79209c5d9 100644 --- a/tests/cxx/unit_tests/pluginplay/examples/writing_a_module.hpp +++ b/tests/cxx/unit_tests/pluginplay/examples/writing_a_module.hpp @@ -337,4 +337,4 @@ class Prism : public pluginplay::ModuleBase { auto out = results(); return PrismVolume::wrap_results(out, area, volume); } // end run_() -}; // end Prism +}; // end Prism diff --git a/tests/cxx/unit_tests/pluginplay/examples/writing_a_property_type.hpp b/tests/cxx/unit_tests/pluginplay/examples/writing_a_property_type.hpp index 2831c2b4f..56d659a77 100644 --- a/tests/cxx/unit_tests/pluginplay/examples/writing_a_property_type.hpp +++ b/tests/cxx/unit_tests/pluginplay/examples/writing_a_property_type.hpp @@ -145,7 +145,7 @@ class Area : public pluginplay::PropertyType { rv["Area"].set_description("The area of the shape"); return rv; } // end results_() -}; // end Area +}; // end Area /* This concludes the property type tutorial. We leave you with the * definition of the ``Perimeter`` and ``PrismVolume`` classes which we will @@ -173,7 +173,7 @@ class Perimeter : public pluginplay::PropertyType { rv["Perimeter"].set_description("The perimeter of the shape"); return rv; } // end results_() -}; // end Perimeter +}; // end Perimeter class PrismVolume : public pluginplay::PropertyType { public: @@ -193,4 +193,4 @@ class PrismVolume : public pluginplay::PropertyType { rv["Volume"].set_description("The volume of the prism"); return rv; } // end results_() -}; // end PrismVolume +}; // end PrismVolume diff --git a/tests/python/doc_snippets/coulombslaw_force.py b/tests/python/doc_snippets/coulombslaw_force.py index 9b566430e..321e41263 100644 --- a/tests/python/doc_snippets/coulombslaw_force.py +++ b/tests/python/doc_snippets/coulombslaw_force.py @@ -12,13 +12,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -import pluginplay as pp +from math import inf, sqrt + import pluginplay_examples as ppe -from math import sqrt, inf +import pluginplay as pp -class CoulombsLaw(pp.ModuleBase): +class CoulombsLaw(pp.ModuleBase): def __init__(self): pp.ModuleBase.__init__(self) self.description("Electric Field From Coulomb's Law") @@ -31,20 +32,19 @@ def run_(self, inputs, submods): for charge in charges: q = charge.m_charge ri = charge.m_r - ri2 = ri[0]**2 + ri[1]**2 + ri[2]**2 + ri2 = ri[0] ** 2 + ri[1] ** 2 + ri[2] ** 2 mag_ri = sqrt(ri2) rij = [i for i in r] for i in range(3): rij[i] -= charge.m_r[i] - rij2 = rij[0]**2 + rij[1]**2 + rij[2]**2 + rij2 = rij[0] ** 2 + rij[1] ** 2 + rij[2] ** 2 for i in range(3): - E[i] += (q * ri[i] / (mag_ri * rij2)) + E[i] += q * ri[i] / (mag_ri * rij2) rv = self.results() return pt.wrap_results(rv, E) class ScreenedCoulombsLaw(pp.ModuleBase): - def __init__(self): pp.ModuleBase.__init__(self) self.description("Screened Electric Field From Coulomb's Law") @@ -62,33 +62,35 @@ def run_(self, inputs, submods): rij = [i for i in r] for i in range(3): rij[i] -= charge.m_r[i] - rij2 = rij[0]**2 + rij[1]**2 + rij[2]**2 + rij2 = rij[0] ** 2 + rij[1] ** 2 + rij[2] ** 2 if sqrt(rij2) >= thresh: continue - ri2 = ri[0]**2 + ri[1]**2 + ri[2]**2 + ri2 = ri[0] ** 2 + ri[1] ** 2 + ri[2] ** 2 mag_ri = sqrt(ri2) for i in range(3): - E[i] += (q * ri[i] / (mag_ri * rij2)) + E[i] += q * ri[i] / (mag_ri * rij2) rv = self.results() return pt.wrap_results(rv, E) class ClassicalForce(pp.ModuleBase): - def __init__(self): pp.ModuleBase.__init__(self) self.description("Classical Force Field") self.satisfies_property_type(ppe.Force()) self.add_submodule( - ppe.ElectricField(), "electric field").set_description( - "Used to compute the electric field of the point charges") + ppe.ElectricField(), "electric field" + ).set_description( + "Used to compute the electric field of the point charges" + ) def run_(self, inputs, submods): pt = ppe.Force() [q, m, a, charges] = pt.unwrap_inputs(inputs) F = [0.0, 0.0, 0.0] - E = submods["electric field"].run_as(ppe.ElectricField(), q.m_r, - charges) + E = submods["electric field"].run_as( + ppe.ElectricField(), q.m_r, charges + ) for i in range(3): F[i] = m * a[i] + q.m_charge * E[i] rv = self.results() diff --git a/tests/python/doc_snippets/test_doc_snippets.py b/tests/python/doc_snippets/test_doc_snippets.py index c9833d6dc..09d51353c 100644 --- a/tests/python/doc_snippets/test_doc_snippets.py +++ b/tests/python/doc_snippets/test_doc_snippets.py @@ -14,11 +14,12 @@ # limitations under the License. # import os -import parallelzone as pz import sys import unittest -if __name__ == '__main__': +import parallelzone as pz + +if __name__ == "__main__": # Make a RuntimeView and hold it until all tests run so MPI isn't shut # down rv = pz.runtime.RuntimeView() diff --git a/tests/python/doc_snippets/test_modules.py b/tests/python/doc_snippets/test_modules.py index 7a3cef6f7..20a55ef9b 100644 --- a/tests/python/doc_snippets/test_modules.py +++ b/tests/python/doc_snippets/test_modules.py @@ -13,23 +13,24 @@ # See the License for the specific language governing permissions and # limitations under the License. # -import parallelzone as pz import unittest -import pluginplay as pp + import pluginplay_examples as ppe +import pluginplay as pp -class TestTutorialModules(unittest.TestCase): +class TestTutorialModules(unittest.TestCase): def test_modules(self): - rv = pz.runtime.RuntimeView() mm = pp.ModuleManager() ppe.load_modules(mm) self.assertEqual(mm.size(), 4) module_names = [ - "Coulomb's Law", "Classical Force", "Coulomb's Law with screening", - "Single-precision Coulomb's law" + "Coulomb's Law", + "Classical Force", + "Coulomb's Law with screening", + "Single-precision Coulomb's law", ] for name in module_names: self.assertTrue(mm.count(name)) diff --git a/tests/python/doc_snippets/test_python_modules.py b/tests/python/doc_snippets/test_python_modules.py index 59cbb151c..3939d697a 100644 --- a/tests/python/doc_snippets/test_python_modules.py +++ b/tests/python/doc_snippets/test_python_modules.py @@ -12,14 +12,15 @@ # See the License for the specific language governing permissions and # limitations under the License. -import pluginplay as pp -import pluginplay_examples as ppe -import coulombslaw_force as clf import unittest +import coulombslaw_force as clf +import pluginplay_examples as ppe -class TestNewPythonModules(unittest.TestCase): +import pluginplay as pp + +class TestNewPythonModules(unittest.TestCase): def test_modules(self): p1 = ppe.PointCharge(1.0, [1.0, 0.0, 0.0]) p2 = ppe.PointCharge(2.0, [2.0, 0.0, 0.0]) diff --git a/tests/python/unit_tests/any/test_any_field.py b/tests/python/unit_tests/any/test_any_field.py index cfc8d806f..649e6ef4c 100644 --- a/tests/python/unit_tests/any/test_any_field.py +++ b/tests/python/unit_tests/any/test_any_field.py @@ -12,13 +12,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -import pluginplay as pp -import py_test_pluginplay.test_any_field as test_pp import unittest +import py_test_pluginplay.test_any_field as test_pp + +import pluginplay as pp -class TestAnyField(unittest.TestCase): +class TestAnyField(unittest.TestCase): def test_reset(self): self.assertFalse(self.defaulted.has_value()) self.defaulted.reset() diff --git a/tests/python/unit_tests/fields/test_module_input.py b/tests/python/unit_tests/fields/test_module_input.py index cf220d112..858463461 100644 --- a/tests/python/unit_tests/fields/test_module_input.py +++ b/tests/python/unit_tests/fields/test_module_input.py @@ -12,13 +12,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -import pluginplay as pp -import py_test_pluginplay.test_module_input as test_pp import unittest +import py_test_pluginplay.test_module_input as test_pp + +import pluginplay as pp -class TestModuleInput(unittest.TestCase): +class TestModuleInput(unittest.TestCase): def test_has_type(self): self.assertFalse(self.defaulted.has_type()) self.assertTrue(self.ifloat.has_type()) @@ -101,7 +102,7 @@ def test_set_default(self): # Sanity check self.assertFalse(self.ilist.has_value()) - x = self.ilist.set_default([1, 2, 3]) + self.ilist.set_default([1, 2, 3]) self.assertTrue(self.ilist.has_value()) self.assertEqual(self.ilist.value(), [1, 2, 3]) diff --git a/tests/python/unit_tests/fields/test_module_result.py b/tests/python/unit_tests/fields/test_module_result.py index 53dee6ccf..dac8290dd 100644 --- a/tests/python/unit_tests/fields/test_module_result.py +++ b/tests/python/unit_tests/fields/test_module_result.py @@ -12,13 +12,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -import pluginplay as pp -import py_test_pluginplay.test_module_result as test_pp import unittest +import py_test_pluginplay.test_module_result as test_pp + +import pluginplay as pp -class TestModuleResult(unittest.TestCase): +class TestModuleResult(unittest.TestCase): def test_has_type(self): self.assertFalse(self.defaulted.has_type()) self.assertTrue(self.rfloat.has_type()) diff --git a/tests/python/unit_tests/module/test_module.py b/tests/python/unit_tests/module/test_module.py index 85a29e9d2..5f442b67a 100644 --- a/tests/python/unit_tests/module/test_module.py +++ b/tests/python/unit_tests/module/test_module.py @@ -12,13 +12,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -import pluginplay as pp -import py_test_pluginplay as test_pp import unittest +import py_test_pluginplay as test_pp + +import pluginplay as pp -class TestModule(unittest.TestCase): +class TestModule(unittest.TestCase): def test_unlocked_copy(self): other_defaulted = self.defaulted.unlocked_copy() self.assertEqual(self.defaulted, other_defaulted) @@ -38,7 +39,7 @@ def test_has_module(self): def test_has_description(self): # See issue #301 - #self.assertFalse(self.defaulted.has_description()) + # self.assertFalse(self.defaulted.has_description()) self.assertTrue(self.has_desc.has_description()) self.assertFalse(self.has_cite.has_description()) @@ -65,18 +66,18 @@ def test_list_not_ready(self): self.assertEqual(self.has_cite.list_not_ready(), {}) # Has two inputs that aren't set - corr = {'Inputs': {'Option 2', 'Option 1'}} + corr = {"Inputs": {"Option 2", "Option 1"}} self.assertEqual(self.not_ready.list_not_ready(), corr) # If one input comes from say a property type - corr = {'Inputs': {'Option 2'}} + corr = {"Inputs": {"Option 2"}} inps = test_pp.OneIn().inputs() self.assertEqual(self.not_ready.list_not_ready(inps), corr) # Not ready b/c of an unset submodule corr = { - 'Submodules': { - 'Submodule 1', + "Submodules": { + "Submodule 1", } } self.assertEqual(self.need_submod.list_not_ready(), corr) @@ -178,7 +179,7 @@ def test_submods(self): self.assertEqual(self.has_desc.submods(), {}) self.assertEqual(self.has_cite.submods(), {}) self.assertEqual(self.not_ready.submods(), {}) - self.assertIn('Submodule 1', self.need_submod.submods()) + self.assertIn("Submodule 1", self.need_submod.submods()) self.assertEqual(self.ready_mod.submods(), {}) def test_property_types(self): @@ -186,31 +187,46 @@ def test_property_types(self): self.assertRaises(Exception, self.defaulted.property_types) null_pt = test_pp.NullPT().type() - self.assertEqual(self.has_desc.property_types(), { - null_pt, - }) - self.assertEqual(self.has_cite.property_types(), { - null_pt, - }) - self.assertEqual(self.need_submod.property_types(), { - null_pt, - }) + self.assertEqual( + self.has_desc.property_types(), + { + null_pt, + }, + ) + self.assertEqual( + self.has_cite.property_types(), + { + null_pt, + }, + ) + self.assertEqual( + self.need_submod.property_types(), + { + null_pt, + }, + ) one_in_pt = test_pp.OneIn().type() - self.assertEqual(self.not_ready.property_types(), { - one_in_pt, - }) + self.assertEqual( + self.not_ready.property_types(), + { + one_in_pt, + }, + ) opt_pt = test_pp.OptionalInput().type() - self.assertEqual(self.ready_mod.property_types(), { - opt_pt, - }) + self.assertEqual( + self.ready_mod.property_types(), + { + opt_pt, + }, + ) def test_description(self): # Throws if there's no implementation self.assertRaises(Exception, self.defaulted.description) - self.assertEqual(self.has_desc.description(), 'A description') + self.assertEqual(self.has_desc.description(), "A description") # Throws if there's no description self.assertRaises(Exception, self.has_cite.description) @@ -223,7 +239,7 @@ def test_citations(self): self.assertRaises(Exception, self.defaulted.citations) self.assertEqual(self.has_desc.citations(), []) - self.assertEqual(self.has_cite.citations(), ['A citation']) + self.assertEqual(self.has_cite.citations(), ["A citation"]) self.assertEqual(self.not_ready.citations(), []) self.assertEqual(self.need_submod.citations(), []) self.assertEqual(self.ready_mod.citations(), []) @@ -239,28 +255,28 @@ def test_set_name(self): def test_change_input(self): # Throws if there's no implementation - self.assertRaises(Exception, self.defaulted.change_input, 'hello') + self.assertRaises(Exception, self.defaulted.change_input, "hello") # Throws if there's no input w/ provided name not_ready = self.not_ready - self.assertRaises(Exception, not_ready.change_input, 'nope', 3) + self.assertRaises(Exception, not_ready.change_input, "nope", 3) # Throws if input is not convertible - self.assertRaises(Exception, not_ready.change_input, 'Option 2', []) + self.assertRaises(Exception, not_ready.change_input, "Option 2", []) # Can change an input - self.not_ready.change_input('Option 2', 3) - self.assertEqual(not_ready.inputs()['Option 2'].value(), 3) + self.not_ready.change_input("Option 2", 3) + self.assertEqual(not_ready.inputs()["Option 2"].value(), 3) def test_change_submod(self): # Throws if there's not implementation - self.assertRaises(Exception, self.defaulted.change_submod, 'hello') + self.assertRaises(Exception, self.defaulted.change_submod, "hello") # Throws if there's no submodule with the key submod = self.has_desc has_submod = self.need_submod - key = 'Submodule 1' - self.assertRaises(Exception, has_submod.change_submod, 'nope', submod) + key = "Submodule 1" + self.assertRaises(Exception, has_submod.change_submod, "nope", submod) # Throws if submod is wrong PT wrong_pt = self.not_ready @@ -294,19 +310,19 @@ def test_run(self): # Can call ready module rv = self.ready_mod.run({}) - self.assertEqual(rv['Result 1'].value(), 1) + self.assertEqual(rv["Result 1"].value(), 1) def test_profile_info(self): # No implementation means no profile info - self.assertEqual(self.defaulted.profile_info(), '') + self.assertEqual(self.defaulted.profile_info(), "") # Module which hasn't run, has no profile info - self.assertEqual(self.ready_mod.profile_info(), '') + self.assertEqual(self.ready_mod.profile_info(), "") # A run module has profile info rv = self.ready_mod.run_as(test_pp.OptionalInput()) self.assertEqual(rv, 1) - self.assertNotEqual(self.ready_mod.profile_info(), '') + self.assertNotEqual(self.ready_mod.profile_info(), "") def test_submod_uuids(self): # Throws if no module is set @@ -319,8 +335,8 @@ def test_submod_uuids(self): self.assertRaises(Exception, self.need_submod.submod_uuids) # Module has a set submodule - self.need_submod.change_submod('Submodule 1', self.has_desc) - corr = {'Submodule 1': self.has_desc.uuid()} + self.need_submod.change_submod("Submodule 1", self.has_desc) + corr = {"Submodule 1": self.has_desc.uuid()} self.assertEqual(self.need_submod.submod_uuids(), corr) def test_uuid(self): @@ -349,16 +365,15 @@ def test_comparisons(self): def setUp(self): mm = test_pp.get_mm() self.defaulted = pp.Module() - self.has_desc = mm.at('C++ with description') - self.has_cite = mm.at('C++ with a citation') - self.not_ready = mm.at('C++ module which also isn\'t ready') - self.need_submod = mm.at('C++ module needing a submodule') - self.ready_mod = mm.at('C++ module which is ready to run') - self.real_deal = mm.at('C++ module using every feature') + self.has_desc = mm.at("C++ with description") + self.has_cite = mm.at("C++ with a citation") + self.not_ready = mm.at("C++ module which also isn't ready") + self.need_submod = mm.at("C++ module needing a submodule") + self.ready_mod = mm.at("C++ module which is ready to run") + self.real_deal = mm.at("C++ module using every feature") class TestPrintNotReady(unittest.TestCase): - def test_print_not_ready(self): # Raises an error if module has no implementation self.assertRaises(Exception, pp.print_not_ready, pp.Module()) diff --git a/tests/python/unit_tests/module/test_module_base.py b/tests/python/unit_tests/module/test_module_base.py index 6a35fcbed..a75ac1945 100644 --- a/tests/python/unit_tests/module/test_module_base.py +++ b/tests/python/unit_tests/module/test_module_base.py @@ -12,14 +12,15 @@ # See the License for the specific language governing permissions and # limitations under the License. -import pluginplay as pp +import unittest + import parallelzone as pz import py_test_pluginplay as test_pp -import unittest +import pluginplay as pp -class APythonModule(pp.ModuleBase): +class APythonModule(pp.ModuleBase): def __init__(self): pp.ModuleBase.__init__(self) self.satisfies_property_type(test_pp.OneInOneOut()) @@ -31,34 +32,33 @@ def __init__(self): def run_(self, inputs, submods): pt = test_pp.OneInOneOut() - i0, = pt.unwrap_inputs(inputs) + (i0,) = pt.unwrap_inputs(inputs) i1 = inputs["An extra input"].value() - assert (self.get_runtime() == pz.runtime.RuntimeView()) + assert self.get_runtime() == pz.runtime.RuntimeView() r0 = submods["A submodule"].run_as(pt, i0 + i1) rv = self.results() rv = pt.wrap_results(rv, r0) - rv['An extra result'].change(42) + rv["An extra result"].change(42) return rv class TestModuleBase(unittest.TestCase): - def test_results(self): self.assertEqual(self.defaulted.results(), {}) self.assertNotEqual(self.py_mod.results(), {}) def test_run_as(self): - self.mm.change_input(self.mod_key, 'An extra input', 2) + self.mm.change_input(self.mod_key, "An extra input", 2) r = self.mm.run_as(test_pp.OneInOneOut(), self.mod_key, 1) self.assertEqual(r, 3) def setUp(self): self.defaulted = pp.ModuleBase() self.mm = test_pp.get_mm() - self.mod_key = 'Python module' + self.mod_key = "Python module" self.py_mod = APythonModule() self.mm.add_module(self.mod_key, self.py_mod) - submod_key = 'C++ module using every feature' + submod_key = "C++ module using every feature" self.mm.change_submod(self.mod_key, "A submodule", submod_key) diff --git a/tests/python/unit_tests/module_manager/test_module_manager_class.py b/tests/python/unit_tests/module_manager/test_module_manager_class.py index 621b3c382..3995310f4 100644 --- a/tests/python/unit_tests/module_manager/test_module_manager_class.py +++ b/tests/python/unit_tests/module_manager/test_module_manager_class.py @@ -12,27 +12,27 @@ # See the License for the specific language governing permissions and # limitations under the License. -import pluginplay as pp +import unittest + import parallelzone import py_test_pluginplay as test_pp -import unittest +import pluginplay as pp -class APythonModule(pp.ModuleBase): +class APythonModule(pp.ModuleBase): def __init__(self): pp.ModuleBase.__init__(self) self.satisfies_property_type(test_pp.OneInOneOut()) def run_(self, inputs, submods): pt = test_pp.OneInOneOut() - i0, = pt.unwrap_inputs(inputs) + (i0,) = pt.unwrap_inputs(inputs) rv = self.results() return pt.wrap_results(rv, i0) # class TestModuleManager(unittest.TestCase): - def test_ctor(self): rv = parallelzone.runtime.RuntimeView() has_runtime_and_cache = pp.ModuleManager(rv) @@ -45,13 +45,13 @@ def test_ctor(self): def test_count(self): # Defaulted is always false - self.assertFalse(self.defaulted.count('not a key')) + self.assertFalse(self.defaulted.count("not a key")) # False if we don't have a mod - self.assertFalse(self.has_mods.count('not a key')) + self.assertFalse(self.has_mods.count("not a key")) # True if we do - self.assertTrue(self.has_mods.count('C++ no PT')) + self.assertTrue(self.has_mods.count("C++ no PT")) def test_size(self): # Defaulted MMs are empty @@ -60,41 +60,41 @@ def test_size(self): def test_at(self): # Throws if there's no implementation - self.assertRaises(Exception, self.defaulted.at, 'not a key') + self.assertRaises(Exception, self.defaulted.at, "not a key") # Throws if the key is invalid - self.assertRaises(Exception, self.has_mods.at, 'not a key') + self.assertRaises(Exception, self.has_mods.at, "not a key") # Can actually get a module - self.assertNotEqual(self.has_mods.at('C++ no PT'), None) + self.assertNotEqual(self.has_mods.at("C++ no PT"), None) # at returns reference - self.assertTrue(self.has_mods.at('C++ no PT').is_memoizable()) - mod = self.has_mods.at('C++ no PT') + self.assertTrue(self.has_mods.at("C++ no PT").is_memoizable()) + mod = self.has_mods.at("C++ no PT") mod.turn_off_memoization() - self.assertFalse(self.has_mods.at('C++ no PT').is_memoizable()) + self.assertFalse(self.has_mods.at("C++ no PT").is_memoizable()) def test_copy_module(self): # Throws if there's no implementation - self.assertRaises(Exception, self.defaulted.copy_module, 'foo', 'bar') + self.assertRaises(Exception, self.defaulted.copy_module, "foo", "bar") # Throws if the module to copy does not exist has_mods = self.has_mods - self.assertRaises(Exception, has_mods.copy_module, 'not a key', 'foo') + self.assertRaises(Exception, has_mods.copy_module, "not a key", "foo") # Throws if the to key is in use - from_key = 'C++ no PT' - to_key = 'C++ Null PT' + from_key = "C++ no PT" + to_key = "C++ Null PT" self.assertRaises(Exception, has_mods.copy_module, from_key, to_key) # Can actually copy module - has_mods.copy_module(from_key, 'foo') + has_mods.copy_module(from_key, "foo") self.assertEqual(has_mods.size(), self.corr_total + 1) - self.assertTrue(has_mods.count('foo')) + self.assertTrue(has_mods.count("foo")) def test_erase(self): # Is a no-op if defaulted - bad_key = 'not a key' + bad_key = "not a key" self.defaulted.erase(bad_key) self.assertEqual(self.defaulted.count(bad_key), 0) @@ -103,43 +103,45 @@ def test_erase(self): self.assertEqual(self.defaulted.count(bad_key), 0) # Can actually erase - self.has_mods.erase('C++ no PT') + self.has_mods.erase("C++ no PT") self.assertEqual(self.has_mods.size(), self.corr_total - 1) - self.assertFalse(self.has_mods.count('C++ no PT')) + self.assertFalse(self.has_mods.count("C++ no PT")) def test_rename_module(self): # Throws if there's not implementation - self.assertRaises(Exception, self.defaulted.rename_module, 'foo', - 'bar') + self.assertRaises( + Exception, self.defaulted.rename_module, "foo", "bar" + ) # Throws if from is not a valid key has_mods = self.has_mods - self.assertRaises(Exception, has_mods.rename_module, 'not a key', - 'bar') + self.assertRaises( + Exception, has_mods.rename_module, "not a key", "bar" + ) # Throws if to key is in use - from_key = 'C++ no PT' - to_key = 'C++ Null PT' + from_key = "C++ no PT" + to_key = "C++ Null PT" self.assertRaises(Exception, has_mods.rename_module, from_key, to_key) # Can actually rename - has_mods.rename_module(from_key, 'key not in use') + has_mods.rename_module(from_key, "key not in use") self.assertEqual(has_mods.size(), self.corr_total) self.assertFalse(has_mods.count(from_key)) - self.assertTrue(has_mods.count('key not in use')) + self.assertTrue(has_mods.count("key not in use")) def test_change_input(self): # Throws if there's no modules - self.assertRaises(Exception, self.defaulted.change_input, 'a', 'b', 1) + self.assertRaises(Exception, self.defaulted.change_input, "a", "b", 1) # Throws if module does not exist has_mods_fxn = self.has_mods.change_input - opt_key = 'Option 1' - bad_key = 'not a key' + opt_key = "Option 1" + bad_key = "not a key" self.assertRaises(Exception, has_mods_fxn, bad_key, opt_key, 1) # Throws if option does not exist - mod_key = 'C++ module which isn\'t ready' + mod_key = "C++ module which isn't ready" self.assertRaises(Exception, has_mods_fxn, mod_key, bad_key, 1) # Throws if a bad value @@ -152,14 +154,14 @@ def test_change_input(self): def test_change_submod(self): # Throws if there's no modules - bad_key = 'not a key' + bad_key = "not a key" fxn2test = self.defaulted.change_submod self.assertRaises(Exception, fxn2test, bad_key, bad_key, bad_key) - #Throws if the module's key is invalid - mod_key = 'C++ module needing a submodule' - submod_key = 'Submodule 1' - to_key = 'C++ Null PT' + # Throws if the module's key is invalid + mod_key = "C++ module needing a submodule" + submod_key = "Submodule 1" + to_key = "C++ Null PT" fxn2test = self.has_mods.change_submod self.assertRaises(Exception, fxn2test, bad_key, submod_key, to_key) @@ -177,11 +179,11 @@ def test_change_submod(self): def test_run_as(self): # Throws if there's no modules pt = test_pp.OneInOneOut() - bad_key = 'not a key' + bad_key = "not a key" self.assertRaises(Exception, self.defaulted.run_as, pt, bad_key) # Throws if it's the wrong PT - mod_key = 'C++ module using every feature' + mod_key = "C++ module using every feature" fxn2test = self.has_mods.run_as self.assertRaises(Exception, fxn2test, test_pp.NullPT(), mod_key, 1) @@ -196,23 +198,23 @@ def test_run_as(self): self.assertEqual(rv, 1) def test_pluginplay_309(self): - ''' This regression test is in response to issue #309. + """This regression test is in response to issue #309. - The problem behind #309 was that we weren't keeping the Python part - of modules written in Python alive when they were added to the - ModuleManager. Without the fix to #309 this test should fail. - ''' + The problem behind #309 was that we weren't keeping the Python part + of modules written in Python alive when they were added to the + ModuleManager. Without the fix to #309 this test should fail. + """ mm = pp.ModuleManager() - mm.add_module('Issue 309', APythonModule()) + mm.add_module("Issue 309", APythonModule()) pt = test_pp.OneInOneOut() - rv = mm.run_as(pt, 'Issue 309', 1) + rv = mm.run_as(pt, "Issue 309", 1) self.assertEqual(rv, 1) def test_get_item(self): - module_with_description = self.has_mods['C++ with description'] + module_with_description = self.has_mods["C++ with description"] self.assertTrue(module_with_description.has_description()) - self.assertNotEqual(self.has_mods['C++ no PT'], None) + self.assertNotEqual(self.has_mods["C++ no PT"], None) def test_set_runtime(self): new_rv = parallelzone.runtime.RuntimeView() @@ -225,7 +227,7 @@ def test_get_runtime(self): def test_keys(self): self.assertEqual(len(self.defaulted.keys()), self.defaulted.size()) self.assertEqual(len(self.has_mods.keys()), self.has_mods.size()) - self.assertTrue('C++ Null PT' in self.has_mods.keys()) + self.assertTrue("C++ Null PT" in self.has_mods.keys()) def setUp(self): self.defaulted = pp.defaulted_mm() diff --git a/tests/python/unit_tests/printing/test_document_modules.py b/tests/python/unit_tests/printing/test_document_modules.py index aa841d1fe..18a542029 100644 --- a/tests/python/unit_tests/printing/test_document_modules.py +++ b/tests/python/unit_tests/printing/test_document_modules.py @@ -12,23 +12,22 @@ # See the License for the specific language governing permissions and # limitations under the License. -import unittest -import pluginplay as pp import os -import tempfile import shutil +import unittest +import pluginplay as pp -class TestDocumentModules(unittest.TestCase): +class TestDocumentModules(unittest.TestCase): def test_export_printing(self): - # Get the current directory current_dir_path = os.getcwd() # Get the docs directory docs_dir_path = os.path.abspath( - os.path.join(current_dir_path, "../docs/test_document_modules")) + os.path.join(current_dir_path, "../docs/test_document_modules") + ) # Empty docs directory try: diff --git a/tests/python/unit_tests/property_type/test_property_type.py b/tests/python/unit_tests/property_type/test_property_type.py index 477b932af..de5ac17f2 100644 --- a/tests/python/unit_tests/property_type/test_property_type.py +++ b/tests/python/unit_tests/property_type/test_property_type.py @@ -12,14 +12,13 @@ # See the License for the specific language governing permissions and # limitations under the License. -import pluginplay as pp +import unittest + import py_test_pluginplay as test_pp import py_test_pluginplay.test_property_type as test_pt -import unittest class TestPropertyType(unittest.TestCase): - def test_ctor(self): self.assertNotEqual(self.null_pt, None) self.assertNotEqual(self.one_in, None) @@ -72,10 +71,10 @@ def test_results(self): def test_unwrap_inputs(self): # Expects one integer inp = test_pt.one_in_inputs(True) - i0, = self.one_in.unwrap_inputs(inp) + (i0,) = self.one_in.unwrap_inputs(inp) self.assertEqual(i0, 1) - #N.B. Because ThreeIn inherits from TwoIn which inherits from OneIn the + # N.B. Because ThreeIn inherits from TwoIn which inherits from OneIn the # order the inputs are unwrapped is reverse what the input keys # suggest, i.e, Option 3 is unwrapped first, then 2, then 1. @@ -96,12 +95,13 @@ def test_wrap_inputs(self): new_inp = self.one_in.wrap_inputs(test_pt.one_in_inputs(True), 42) self.assertEqual(new_inp["Option 1"].value(), 42) - #N.B. Because ThreeIn inherits from TwoIn which inherits from OneIn the + # N.B. Because ThreeIn inherits from TwoIn which inherits from OneIn the # order the inputs are wrapped in reverse what the input keys # suggest, i.e, Option 3 is wrapped first, then 2, then 1. - new_inp = self.two_in.wrap_inputs(test_pt.two_in_inputs(True), 1.23, - 42) + new_inp = self.two_in.wrap_inputs( + test_pt.two_in_inputs(True), 1.23, 42 + ) self.assertEqual(new_inp["Option 1"].value(), 42) self.assertEqual(new_inp["Option 2"].value(), 1.23) @@ -115,19 +115,19 @@ def test_wrap_results(self): outs = self.one_out.wrap_results(test_pt.result_map_one(), 1) self.assertEqual(outs["Result 1"].value(), 1) - outs = self.two_out.wrap_results(test_pt.result_map_two(), 1, 'c') + outs = self.two_out.wrap_results(test_pt.result_map_two(), 1, "c") self.assertEqual(outs["Result 1"].value(), 1) - self.assertEqual(outs["Result 2"].value(), 'c') + self.assertEqual(outs["Result 2"].value(), "c") def test_unwrap_results(self): outs = self.one_out.wrap_results(test_pt.result_map_one(), 1) - i0, = self.one_out.unwrap_results(outs) + (i0,) = self.one_out.unwrap_results(outs) self.assertEqual(i0, 1) - outs = self.two_out.wrap_results(test_pt.result_map_two(), 1, 'c') + outs = self.two_out.wrap_results(test_pt.result_map_two(), 1, "c") i0, i1 = self.two_out.unwrap_results(outs) self.assertEqual(i0, 1) - self.assertEqual(i1, 'c') + self.assertEqual(i1, "c") def setUp(self): self.null_pt = test_pp.NullPT() diff --git a/tests/python/unit_tests/python/test_py_type_info.py b/tests/python/unit_tests/python/test_py_type_info.py index eba825ba5..d3ce5eeab 100644 --- a/tests/python/unit_tests/python/test_py_type_info.py +++ b/tests/python/unit_tests/python/test_py_type_info.py @@ -12,24 +12,25 @@ # See the License for the specific language governing permissions and # limitations under the License. -import pluginplay as pp -import py_test_pluginplay.test_py_test_info as test_pp import unittest +import py_test_pluginplay.test_py_test_info as test_pp + +import pluginplay as pp -class TestPyTestInfo(unittest.TestCase): +class TestPyTestInfo(unittest.TestCase): def test_has_value(self): self.assertFalse(self.defaulted.has_value()) self.assertTrue(self.wrap_int.has_value()) self.assertTrue(self.wrap_double.has_value()) def test_str(self): - self.assertEqual(str(self.defaulted), '') + self.assertEqual(str(self.defaulted), "") # Actual string is implementation dependent - self.assertNotEqual(str(self.wrap_int), '') - self.assertNotEqual(str(self.wrap_double), '') + self.assertNotEqual(str(self.wrap_int), "") + self.assertNotEqual(str(self.wrap_double), "") def test_hash(self): self.assertEqual(hash(self.defaulted), 0) diff --git a/tests/python/unit_tests/python/test_python_wrapper.py b/tests/python/unit_tests/python/test_python_wrapper.py index d8b1e3343..04e416131 100644 --- a/tests/python/unit_tests/python/test_python_wrapper.py +++ b/tests/python/unit_tests/python/test_python_wrapper.py @@ -12,13 +12,14 @@ # See the License for the specific language governing permissions and # limitations under the License. -import pluginplay as pp -import py_test_pluginplay.test_python_wrapper as test_pp import unittest +import py_test_pluginplay.test_python_wrapper as test_pp + +import pluginplay as pp -class TestPythonWrapper(unittest.TestCase): +class TestPythonWrapper(unittest.TestCase): def test_has_value(self): self.assertTrue(self.list.has_value()) self.assertTrue(self.dict.has_value()) diff --git a/tests/python/unit_tests/test_pluginplay.py b/tests/python/unit_tests/test_pluginplay.py index a38026135..66d96475f 100644 --- a/tests/python/unit_tests/test_pluginplay.py +++ b/tests/python/unit_tests/test_pluginplay.py @@ -15,11 +15,12 @@ # import os -import parallelzone as pz import sys import unittest -if __name__ == '__main__': +import parallelzone as pz + +if __name__ == "__main__": # Make a RuntimeView to ensure MPI isn't finalized early rv = pz.runtime.RuntimeView() diff --git a/tests/python/unit_tests/test_submodule_request.py b/tests/python/unit_tests/test_submodule_request.py index c8c6aafd0..14c56778d 100644 --- a/tests/python/unit_tests/test_submodule_request.py +++ b/tests/python/unit_tests/test_submodule_request.py @@ -12,14 +12,15 @@ # See the License for the specific language governing permissions and # limitations under the License. -import pluginplay as pp +import unittest + import py_test_pluginplay as test_pp import py_test_pluginplay.test_submodule_request as test_sr -import unittest +import pluginplay as pp -class TestSubmoduleRequest(unittest.TestCase): +class TestSubmoduleRequest(unittest.TestCase): def test_has_type(self): self.assertFalse(self.defaulted.has_type()) self.assertTrue(self.expects_null.has_type()) @@ -60,8 +61,9 @@ def test_set_type(self): def test_satisfies_property_type(self): pt1 = test_pp.NullPT() pt2 = test_pp.OneIn() - self.assertRaises(RuntimeError, self.defaulted.satisfies_property_type, - pt1) + self.assertRaises( + RuntimeError, self.defaulted.satisfies_property_type, pt1 + ) self.defaulted.set_type(pt1) self.assertTrue(self.defaulted.satisfies_property_type(pt1)) self.assertFalse(self.defaulted.satisfies_property_type(pt2)) diff --git a/tests/python/unit_tests/tox.ini b/tests/python/unit_tests/tox.ini index 12e347848..547ec2db2 100644 --- a/tests/python/unit_tests/tox.ini +++ b/tests/python/unit_tests/tox.ini @@ -13,7 +13,7 @@ ; limitations under the License. [tox] -envlist = +envlist = skipsdist = True [testenv]