|
1 | 1 | # -*- coding: utf-8 -*- |
2 | 2 |
|
3 | | -from test.helper import check_evaluation, evaluate_value |
| 3 | +from test.helper import check_evaluation |
4 | 4 |
|
5 | | -import pytest |
6 | | - |
7 | | -from mathics.core.builtin import check_requires_list |
8 | 5 | from mathics.core.expression import Expression |
9 | 6 | from mathics.core.symbols import Symbol, SymbolPlus, SymbolTimes |
10 | 7 |
|
11 | 8 |
|
12 | | -def test_canonical_sort(): |
13 | | - check_evaluation( |
14 | | - """ |
15 | | - Sort[{ |
16 | | - "a","b", 1, |
17 | | - ByteArray[{1,2,4,1}], |
18 | | - 2, 1.2, I, 2I-3, A, |
19 | | - a+b, a*b, a+1, a*2, b^3, 2/3, |
20 | | - A[x], F[2], F[x], F[x_], F[x___], F[x,t], F[x__], |
21 | | - Condition[A,b>2], Pattern[expr, A] |
22 | | - }] |
23 | | - """, |
24 | | - """{ -3 + 2*I, I, 2 / 3, 1, 1.2, 2, |
25 | | - "a", "b", A, 2*a, a*b, b^3, |
26 | | - A[x], F[2], F[x], F[x_], F[x___], F[x__], F[x, t], |
27 | | - ByteArray["AQIEAQ=="], A /; b > 2, |
28 | | - expr:A, 1 + a, a + b}""", |
29 | | - ) |
30 | | - # The right canonical order should be, according to WMA: |
31 | | - # -3 + 2*I, I, 2/3, 1, 1.2, 2, |
32 | | - # "a", "b", 2*a, |
33 | | - # 1 + a, A, a*b, b^3, a + b, |
34 | | - # A[x], A /; b > 2, |
35 | | - # F[2], F[x], F[x_], F[x___], F[x__], F[x, t], |
36 | | - # ByteArray["AQIEAQ=="], expr:A |
37 | | - |
38 | | - check_evaluation( |
39 | | - r"Sort[Table[IntegerDigits[2^n], {n, 10}]]", |
40 | | - r"{{2}, {4}, {8}, {1, 6}, {3, 2}, {6, 4}, {1, 2, 8}, {2, 5, 6}, {5, 1, 2}, {1, 0, 2, 4}}", |
41 | | - ) |
42 | | - check_evaluation( |
43 | | - r"SortBy[Table[IntegerDigits[2^n], {n, 10}], First]", |
44 | | - r"{{1, 6}, {1, 2, 8}, {1, 0, 2, 4}, {2}, {2, 5, 6}, {3, 2}, {4}, {5, 1, 2}, {6, 4}, {8}}", |
45 | | - ) |
46 | | - |
47 | | - |
48 | | -# FIXME: come up with an example that doesn't require skimage. |
49 | | -@pytest.mark.skipif( |
50 | | - not check_requires_list(["skimage"]), |
51 | | - reason="Right now need scikit-image for this to work", |
52 | | -) |
53 | | -def test_canonical_sort_images(): |
54 | | - check_evaluation( |
55 | | - r'Sort[{Import["ExampleData/Einstein.jpg"], 5}]', |
56 | | - r'{5, Import["ExampleData/Einstein.jpg"]}', |
57 | | - ) |
58 | | - |
59 | | - |
60 | 9 | def test_Expression_sameQ(): |
61 | 10 | """ |
62 | 11 | Test Expression.SameQ |
|
0 commit comments