Skip to content

Commit

Permalink
checkerboard ui
Browse files Browse the repository at this point in the history
  • Loading branch information
lehner committed Jun 15, 2024
1 parent 9e95579 commit 59c66f4
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/gpt/core/checkerboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,13 @@ def str_to_cb(s):
assert 0


def pick_checkerboard(cb, dst, src):
def pick_checkerboard(cb, dst, src = None):

Check failure on line 56 in lib/gpt/core/checkerboard.py

View workflow job for this annotation

GitHub Actions / lint

E251:unexpected spaces around keyword / parameter equals

Check failure on line 56 in lib/gpt/core/checkerboard.py

View workflow job for this annotation

GitHub Actions / lint

E251:unexpected spaces around keyword / parameter equals
if src is None:
src = dst
dst = gpt.lattice(src.grid.checkerboarded(gpt.redblack), src.otype)
pick_checkerboard(cb, dst, src)
return dst

Check failure on line 62 in lib/gpt/core/checkerboard.py

View workflow job for this annotation

GitHub Actions / lint

W293:blank line contains whitespace
assert len(src.v_obj) == len(dst.v_obj)
for i in src.otype.v_idx:
cgpt.lattice_pick_checkerboard(cb.tag, src.v_obj[i], dst.v_obj[i])
Expand Down
15 changes: 15 additions & 0 deletions tests/core/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,22 @@ def correlate_test_4d(a, b, x):
g.message(f"Test sparse slice: {eps}")
assert eps < l.grid.precision.eps * 1e3

################################################################################
# Test checkerboard
################################################################################
a = a[0]
b = b[0]
a_even = g.pick_checkerboard(g.even, a)
a_odd = g.pick_checkerboard(g.odd, a)
b[:] = 0
g.set_checkerboard(b, a_even)
g.set_checkerboard(b, a_odd)
eps2 = g.norm2(a-b)
g.message(f"Checkerboard: {eps2}")
assert eps2 == 0.0

################################################################################
# Test mem_report
################################################################################
g.mem_report()

0 comments on commit 59c66f4

Please sign in to comment.