Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
zoomlogo committed Mar 11, 2024
1 parent 36d0dec commit 8d8b1ee
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion flax/atoms.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@
"ŒB": attrdict(arity=1, call=lambda x: iterable(x) + iterable(x)[::-1]),
"ŒP": attrdict(arity=1, dx=1, call=lambda x: x == x[::-1]),
"ŒĠ": attrdict(arity=1, dx=1, call=get_req),
"ŒE": attrdict(arity=1, call=enumerate_md),
"ŒE": attrdict(arity=1, call=lambda x: list(enumerate_md(x))),
"ŒG": attrdict(arity=1, call=lambda x: group_indicies(x, md=True)),
"ŒM": attrdict(arity=1, call=maximal_indicies_md),
"ŒṪ": attrdict(arity=1, call=lambda x: [i for i, e in enumerate_md(x) if e]),
Expand Down
17 changes: 14 additions & 3 deletions test/test_funcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,20 @@ def test_digits_i():
assert digits_i([mpc(1, 4), mpc(2, 5), mpc(3, 6)]) == mpc(123, 456)


"test_enumerate_md"
"test_ensure_square"
"test_fibonacci"
def test_enumerate_md():
assert list(enumerate_md([])) == []
assert list(enumerate_md([1,2,3,4,5])) == [[[0], 1], [[1], 2], [[2], 3], [[3], 4], [[4], 5]]
assert list(enumerate_md([1,2,3,[4,5]])) == [[[0], 1], [[1], 2], [[2], 3], [[3, 0], 4], [[3, 1], 5]]

def test_ensure_square():
assert ensure_square([]) == []
assert ensure_square(1) == [[1]]
assert ensure_square([1,2]) == [[1,1],[2,2]]
assert ensure_square([1,2,[3,4],[5,6,7]]) == [[1, 1, 1, 1], [2, 2, 2, 2], [3, 4, 3, 4], [5, 6, 7, 5]]

def test_fibonacci():
assert [fibonacci(i) for i in range(50)] == [0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946, 17711, 28657, 46368, 75025, 121393, 196418, 317811, 514229, 832040, 1346269, 2178309, 3524578, 5702887, 9227465, 14930352, 24157817, 39088169, 63245986, 102334155, 165580141, 267914296, 433494437, 701408733, 1134903170, 1836311903, 2971215073, 4807526976, 7778742049]

"test_find"
"test_find_md"
"test_find_all"
Expand Down

0 comments on commit 8d8b1ee

Please sign in to comment.