From a5d4d063dc6da1249a69da6ff6caf2623ba5c947 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Tue, 28 May 2024 20:20:01 +0000 Subject: [PATCH] Committing clang-format changes --- docs/source/conf.py | 39 ++++++------------- scripts/equations/generate_gmbe.py | 21 ++++++---- scripts/equations/index.py | 2 + scripts/equations/intersection.py | 15 ++++--- scripts/equations/set_base.py | 2 + scripts/equations/tests/test_index.py | 3 ++ scripts/equations/tests/test_intersection.py | 17 ++++---- scripts/equations/tests/test_union.py | 12 +++--- scripts/equations/union.py | 9 +++-- tests/python/integration_tests/test_cap.py | 2 + .../integration_tests/test_ghostfragment.py | 3 +- 11 files changed, 63 insertions(+), 62 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index 1ca57599..6a9b9a18 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -13,7 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. - import os # -- Project information ----------------------------------------------------- @@ -40,15 +39,9 @@ # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. extensions = [ - 'sphinx.ext.autodoc', - 'sphinx.ext.doctest', - 'sphinx.ext.intersphinx', - 'sphinx.ext.todo', - 'sphinx.ext.coverage', - 'sphinx.ext.mathjax', - 'sphinx.ext.githubpages', - 'sphinx_togglebutton', - 'sphinxcontrib.bibtex', + 'sphinx.ext.autodoc', 'sphinx.ext.doctest', 'sphinx.ext.intersphinx', + 'sphinx.ext.todo', 'sphinx.ext.coverage', 'sphinx.ext.mathjax', + 'sphinx.ext.githubpages', 'sphinx_togglebutton', 'sphinxcontrib.bibtex', 'sphinx_rtd_theme' ] @@ -90,7 +83,7 @@ pygments_style = 'sphinx' # Enable/disable numbered figures -numfig = True +numfig = True # -- Options for HTML output ------------------------------------------------- @@ -103,15 +96,13 @@ # further. For a list of options available for each theme, see the # documentation. # -html_theme_options = { - 'vcs_pageview_mode' : 'edit' -} +html_theme_options = {'vcs_pageview_mode': 'edit'} html_context = { - 'display_github': True, - 'github_user': 'rmrresearch', - 'github_repo': 'ghostfragment', - 'github_version': 'master/docs/source/', + 'display_github': True, + 'github_user': 'rmrresearch', + 'github_repo': 'ghostfragment', + 'github_version': 'master/docs/source/', } # Add any paths that contain custom static files (such as style sheets) here, @@ -129,13 +120,11 @@ # # html_sidebars = {} - # -- Options for HTMLHelp output --------------------------------------------- # Output file base name for HTML help builder. htmlhelp_basename = project + 'doc' - # -- Options for LaTeX output ------------------------------------------------ latex_elements = { @@ -160,17 +149,13 @@ # (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'), ] - - - # -- Extension configuration ------------------------------------------------- # -- Options for intersphinx extension --------------------------------------- # Example configuration for intersphinx: refer to the Python standard library. -intersphinx_mapping = {'python' : ('https://docs.python.org/', None) } - - +intersphinx_mapping = {'python': ('https://docs.python.org/', None)} diff --git a/scripts/equations/generate_gmbe.py b/scripts/equations/generate_gmbe.py index 848c065d..3639a6b7 100644 --- a/scripts/equations/generate_gmbe.py +++ b/scripts/equations/generate_gmbe.py @@ -19,6 +19,7 @@ class Term: + def __init__(self, coeff, value): self.coeff = coeff self.value = value @@ -48,6 +49,7 @@ def make_fragments(n_fragments): fragments.append(Index(some_letters[i])) return fragments + def make_nmers(trunc_order, frags): nmers = [] if trunc_order == 1: @@ -76,13 +78,15 @@ def make_intersections(nmers): return ovps + def diff_ovps(old_nmers, new_nmer): old_ovps = make_intersections(old_nmers) new_nmers = old_nmers + [new_nmer] new_ovps = make_intersections(new_nmers) return [x for x in new_ovps if x not in old_ovps] -def print_equation(nmers, ovps, clean_up = False): + +def print_equation(nmers, ovps, clean_up=False): rv = "" for nmer in nmers: rv += str(nmer) @@ -93,20 +97,23 @@ def print_equation(nmers, ovps, clean_up = False): rv += str(ovp) return rv + if __name__ == "__main__": n_fragments = 4 trunc_order = 2 frags = make_fragments(n_fragments) nmers = make_nmers(trunc_order, frags) - ovps = make_intersections(nmers) + ovps = make_intersections(nmers) for x in ovps: if len(x.value.associate()) == 3: print(x, x.clean_up()) #print(print_equation(nmers, ovps, True)) - nmers = [Term(1.0, Union(Index("I"), Index("J"))), - Term(1.0, Union(Index("I"), Index("K"))), - Term(1.0, Union(Index("J"), Index("K"))), - Term(1.0, Union(Index("I"), Index("L"))), - Term(1.0, Union(Index("J"), Index("L")))] + nmers = [ + Term(1.0, Union(Index("I"), Index("J"))), + Term(1.0, Union(Index("I"), Index("K"))), + Term(1.0, Union(Index("J"), Index("K"))), + Term(1.0, Union(Index("I"), Index("L"))), + Term(1.0, Union(Index("J"), Index("L"))) + ] diff = diff_ovps(nmers, Term(1.0, Union(Index("K"), Index("L")))) #print(print_equation(nmers, diff, True)) diff --git a/scripts/equations/index.py b/scripts/equations/index.py index b0788b76..1738acb2 100644 --- a/scripts/equations/index.py +++ b/scripts/equations/index.py @@ -12,7 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. + class Index: + def __init__(self, value): self.value = value diff --git a/scripts/equations/intersection.py b/scripts/equations/intersection.py index 41446347..404ea713 100644 --- a/scripts/equations/intersection.py +++ b/scripts/equations/intersection.py @@ -14,6 +14,8 @@ from set_base import SetBase from union import Union + + class Intersection(SetBase): """ Class representing a symbolic intersection of indices. """ @@ -36,11 +38,11 @@ def is_proper_subset(self, rhs): return self.count(rhs) == 1 elif rhs.is_union(): for x in self.terms: - if rhs.count(x): - return True + if rhs.count(x): + return True return False elif rhs.is_intersection(): - if len(rhs) >= len(self): + if len(rhs) >= len(self): return False # Every term in rhs, must be in us for x in rhs.terms: @@ -48,8 +50,6 @@ def is_proper_subset(self, rhs): return False return True - - def clean_up(self): new_terms = [x.clean_up() for x in self.terms] final_terms = new_terms @@ -71,7 +71,6 @@ def associate(self): new_terms.append(new_term) return Intersection(*new_terms) - def distribute(self): new_terms = self.associate() nterms = len(new_terms) @@ -80,8 +79,8 @@ def distribute(self): newi = new_terms[i].distribute() if newi.is_union(): lhs = rv - rhs = new_terms[i + 1 : nterms] - rv = [ ] + rhs = new_terms[i + 1:nterms] + rv = [] for x in new_terms[i].terms: rv.append(Intersection(*lhs, x, *rhs).distribute()) return Union(*rv).associate() diff --git a/scripts/equations/set_base.py b/scripts/equations/set_base.py index 19470d3a..c954b27f 100644 --- a/scripts/equations/set_base.py +++ b/scripts/equations/set_base.py @@ -12,7 +12,9 @@ # See the License for the specific language governing permissions and # limitations under the License. + class SetBase: + def __init__(self, *args): self.terms = [] # This makes sure we only add unique elements diff --git a/scripts/equations/tests/test_index.py b/scripts/equations/tests/test_index.py index 5d878110..ae7ab386 100644 --- a/scripts/equations/tests/test_index.py +++ b/scripts/equations/tests/test_index.py @@ -15,13 +15,16 @@ import unittest import sys import os + sys.path.insert(0, os.path.join(os.getcwd(), "..")) from union import Union from intersection import Intersection from index import Index + class IndexTest(unittest.TestCase): + def setUp(self): self.i = Index("I") self.j = Index("J") diff --git a/scripts/equations/tests/test_intersection.py b/scripts/equations/tests/test_intersection.py index 03f4ed41..34009a9a 100644 --- a/scripts/equations/tests/test_intersection.py +++ b/scripts/equations/tests/test_intersection.py @@ -15,6 +15,7 @@ import unittest import sys import os + sys.path.insert(0, os.path.join(os.getcwd(), "..")) from union import Union @@ -23,6 +24,7 @@ class IntersectionTest(unittest.TestCase): + def setUp(self): i, j, k, l = Index("I"), Index("J"), Index("K"), Index("L") self.icj = Intersection(i, j) @@ -35,7 +37,7 @@ def test_is_union(self): self.assertFalse(self.icjck.is_union()) self.assertFalse(self.icjckcl.is_union()) self.assertFalse(self.icjk.is_union()) - + def test_is_intersection(self): self.assertTrue(self.icj.is_intersection()) self.assertTrue(self.icjck.is_intersection()) @@ -48,12 +50,12 @@ def test_is_index(self): self.assertFalse(self.icjckcl.is_index()) self.assertFalse(self.icjk.is_index()) - def test_associate(self): + def test_associate(self): i, j, k, l = Index("I"), Index("J"), Index("K"), Index("L") corr = Intersection(i, j) self.assertEqual(self.icj.associate(), corr) - + corr = Intersection(i, j, k) self.assertEqual(self.icjck.associate(), corr) @@ -75,7 +77,7 @@ def test_distribute(self): corr = Intersection(i, j) self.assertEqual(self.icj.distribute(), corr) - + corr = Intersection(i, j, k) self.assertEqual(self.icjck.distribute(), corr) @@ -94,13 +96,12 @@ def test_distribute(self): self.assertEqual(i_jck_jk.distribute(), corr) ijcikcjk = Intersection(Union(i, j), Union(i, k), Union(j, k)) - corr = Union(Intersection(i, i, j), Intersection(i, i, k), + corr = Union(Intersection(i, i, j), Intersection(i, i, k), Intersection(i, k, j), Intersection(i, k, k), - Intersection(j, i, j), Intersection(j, i, k), + Intersection(j, i, j), Intersection(j, i, k), Intersection(j, k, j), Intersection(j, k, k)) self.assertEqual(ijcikcjk.distribute(), corr) - def test_equal(self): i, j, k, l = Index("I"), Index("J"), Index("K"), Index("L") self.assertEqual(self.icj, Intersection(i, j)) @@ -116,4 +117,4 @@ def test_str(self): if __name__ == "__main__": - unittest.main() \ No newline at end of file + unittest.main() diff --git a/scripts/equations/tests/test_union.py b/scripts/equations/tests/test_union.py index 8d63d3f2..a7e09d28 100644 --- a/scripts/equations/tests/test_union.py +++ b/scripts/equations/tests/test_union.py @@ -15,6 +15,7 @@ import unittest import sys import os + sys.path.insert(0, os.path.join(os.getcwd(), "..")) from union import Union @@ -23,6 +24,7 @@ class UnionTest(unittest.TestCase): + def setUp(self): i, j, k, l = Index("I"), Index("J"), Index("K"), Index("L") self.ij = Union(i, j) @@ -35,7 +37,7 @@ def test_is_union(self): self.assertTrue(self.ijk.is_union()) self.assertTrue(self.ijkl.is_union()) self.assertTrue(self.i_jck.is_union()) - + def test_is_intersection(self): self.assertFalse(self.ij.is_intersection()) self.assertFalse(self.ijk.is_intersection()) @@ -48,12 +50,12 @@ def test_is_index(self): self.assertFalse(self.ijkl.is_index()) self.assertFalse(self.i_jck.is_index()) - def test_associate(self): + def test_associate(self): i, j, k, l = Index("I"), Index("J"), Index("K"), Index("L") corr = Union(i, j) self.assertEqual(self.ij.associate(), corr) - + corr = Union(i, j, k) self.assertEqual(self.ijk.associate(), corr) @@ -70,13 +72,12 @@ def test_associate(self): i_jck_jk = Union(i, jck, Union(j, k)) self.assertEqual(i_jck_jk.associate(), Union(i, jck, j, k)) - def test_distribute(self): i, j, k, l = Index("I"), Index("J"), Index("K"), Index("L") corr = Union(i, j) self.assertEqual(self.ij.distribute(), corr) - + corr = Union(i, j, k) self.assertEqual(self.ijk.distribute(), corr) @@ -97,7 +98,6 @@ def test_distribute(self): corr = Union(i, Intersection(j, l), Intersection(k, l)) self.assertEqual(i_jkcl.distribute(), corr) - def test_equal(self): i, j, k, l = Index("I"), Index("J"), Index("K"), Index("L") self.assertEqual(self.ij, Union(i, j)) diff --git a/scripts/equations/union.py b/scripts/equations/union.py index 9aaf6475..fc76d967 100644 --- a/scripts/equations/union.py +++ b/scripts/equations/union.py @@ -13,10 +13,13 @@ # limitations under the License. from set_base import SetBase + + class Union(SetBase): """ Class representing a set which has been formed by taking the symbolic union of one or more objects. """ + def print_type(self): rv = "Union(" for x in self.terms: @@ -51,7 +54,6 @@ def is_proper_subset(self, rhs): # Getting here means we have an index or an intersection return False - def clean_up(self): new_terms = [x.clean_up() for x in self.terms] final_terms = [] @@ -90,9 +92,8 @@ def distribute(self): new_terms.append(x.distribute()) return Union(*new_terms).associate() - def __lt__(self, rhs): - if rhs.is_index(): + if rhs.is_index(): return False elif rhs.is_intersection(): return True @@ -109,7 +110,7 @@ def __str__(self): x_str = str(self.terms[i]) if self.terms[i].is_intersection(): - x_str = "(" + x_str + ")" + x_str = "(" + x_str + ")" if i == 0: rv = x_str diff --git a/tests/python/integration_tests/test_cap.py b/tests/python/integration_tests/test_cap.py index 046df875..4ea63cca 100644 --- a/tests/python/integration_tests/test_cap.py +++ b/tests/python/integration_tests/test_cap.py @@ -18,7 +18,9 @@ import ghostfragment import unittest + class TestCapping(unittest.TestCase): + def setUp(self): mm = pluginplay.ModuleManager() ghostfragment.load_modules(mm) diff --git a/tests/python/integration_tests/test_ghostfragment.py b/tests/python/integration_tests/test_ghostfragment.py index 9a06e933..5932c6c4 100644 --- a/tests/python/integration_tests/test_ghostfragment.py +++ b/tests/python/integration_tests/test_ghostfragment.py @@ -19,14 +19,13 @@ import sys import unittest - if __name__ == '__main__': rv = pz.runtime.RuntimeView() my_dir = os.path.dirname(os.path.realpath(__file__)) loader = unittest.TestLoader() - tests = loader.discover(my_dir) + tests = loader.discover(my_dir) testrunner = unittest.runner.TextTestRunner() ret = not testrunner.run(tests).wasSuccessful() sys.exit(ret)