Skip to content

Commit

Permalink
shorten docstring
Browse files Browse the repository at this point in the history
  • Loading branch information
pbrubeck committed Oct 14, 2023
1 parent b2ece28 commit d1bbc30
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 24 deletions.
2 changes: 1 addition & 1 deletion FIAT/barycentric_interpolation.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,4 +95,4 @@ def get_expansion_set(ref_el, pts):
if ref_el.get_shape() == reference_element.LINE:
return LagrangeLineExpansionSet(ref_el, pts)
else:
raise Exception("Unknown reference element type.")
raise ValueError("Invalid reference element type.")
29 changes: 6 additions & 23 deletions FIAT/recursive_points.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,34 +25,17 @@

def multiindex_equal(d, k, interior=0):
"""A generator for :math:`d`-tuple multi-indices whose sum is :math:`k`.
Args:
d (int): The length of the tuples
k (int): The sum of the entries in the tuples
Yields:
tuple: tuples of length `d` whose entries sum to `k`, in lexicographic
order.
Example:
>>> for i in multiindex_equal(3, 2): print(i)
(0, 0, 2)
(0, 1, 1)
(0, 2, 0)
(1, 0, 1)
(1, 1, 0)
(2, 0, 0)
"""
if d <= 0:
return
kmin = interior
kmax = k - (d-1) * kmin
if kmax < kmin:
imin = interior
imax = k - (d-1) * imin
if imax < imin:
return
for i in range(kmin, kmax):
for a in multiindex_equal(d-1, k-i, interior=kmin):
for i in range(imin, imax):
for a in multiindex_equal(d-1, k-i, interior=imin):
yield (i,) + a
yield (kmax,) + (kmin,)*(d-1)
yield (imax,) + (imin,)*(d-1)


class NodeFamily:
Expand Down

0 comments on commit d1bbc30

Please sign in to comment.