Skip to content

Commit

Permalink
Committing clang-format changes
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions[bot] committed May 28, 2024
1 parent 6c08fe6 commit a5d4d06
Show file tree
Hide file tree
Showing 11 changed files with 63 additions and 62 deletions.
39 changes: 12 additions & 27 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.


import os

# -- Project information -----------------------------------------------------
Expand All @@ -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'
]

Expand Down Expand Up @@ -90,7 +83,7 @@
pygments_style = 'sphinx'

# Enable/disable numbered figures
numfig = True
numfig = True

# -- Options for HTML output -------------------------------------------------

Expand All @@ -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,
Expand All @@ -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 = {
Expand All @@ -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)}
21 changes: 14 additions & 7 deletions scripts/equations/generate_gmbe.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@


class Term:

def __init__(self, coeff, value):
self.coeff = coeff
self.value = value
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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)
Expand All @@ -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))
2 changes: 2 additions & 0 deletions scripts/equations/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
15 changes: 7 additions & 8 deletions scripts/equations/intersection.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

from set_base import SetBase
from union import Union


class Intersection(SetBase):
""" Class representing a symbolic intersection of indices.
"""
Expand All @@ -36,20 +38,18 @@ 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:
if self.count(x) == 0:
return False
return True



def clean_up(self):
new_terms = [x.clean_up() for x in self.terms]
final_terms = new_terms
Expand All @@ -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)
Expand All @@ -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()
Expand Down
2 changes: 2 additions & 0 deletions scripts/equations/set_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions scripts/equations/tests/test_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
17 changes: 9 additions & 8 deletions scripts/equations/tests/test_intersection.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import unittest
import sys
import os

sys.path.insert(0, os.path.join(os.getcwd(), ".."))

from union import Union
Expand All @@ -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)
Expand All @@ -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())
Expand All @@ -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)

Expand All @@ -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)

Expand All @@ -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))
Expand All @@ -116,4 +117,4 @@ def test_str(self):


if __name__ == "__main__":
unittest.main()
unittest.main()
12 changes: 6 additions & 6 deletions scripts/equations/tests/test_union.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import unittest
import sys
import os

sys.path.insert(0, os.path.join(os.getcwd(), ".."))

from union import Union
Expand All @@ -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)
Expand All @@ -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())
Expand All @@ -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)

Expand All @@ -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)

Expand All @@ -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))
Expand Down
Loading

0 comments on commit a5d4d06

Please sign in to comment.