Skip to content

Commit

Permalink
add tests for mathics#251
Browse files Browse the repository at this point in the history
  • Loading branch information
sn6uv committed Jun 20, 2015
1 parent 1a9dc43 commit 591035f
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions mathics/builtin/structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -466,8 +466,23 @@ class Flatten(Builtin):
= Flatten[{{1, 2}, {3, 4}}, {{-1, 2}}, List]
#> Flatten[{a, b}, {{1}, {2}}]
: Level 2 specified in {{1}, {2}} exceeds the levels, 1, which can be flattened together in {a, b}
: Level 2 specified in {{1}, {2}} exceeds the levels, 1, which can be flattened together in {a, b}.
= Flatten[{a, b}, {{1}, {2}}, List]
## #251 tests
#> m = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
#> Flatten[m, {1}]
= {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}
#> Flatten[m, {2}]
= {{1, 4, 7}, {2, 5, 8}, {3, 6, 9}}
#> Flatten[m, {3}]
: Level 3 specified in {3} exceeds the levels, 2, which can be flattened together in {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}.
= Flatten[{{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}, {3}, List]
#> Flatten[m, {2, 1}]
= {1, 4, 7, 2, 5, 8, 3, 6, 9}
"""

rules = {
Expand All @@ -483,7 +498,7 @@ class Flatten(Builtin):
"Level `1` specified in `2` should not be repeated."),
'fldep': (
"Level `1` specified in `2` exceeds the levels, `3`, "
"which can be flattened together in `4`"),
"which can be flattened together in `4`."),
}

@staticmethod
Expand Down

0 comments on commit 591035f

Please sign in to comment.