4
4
from ufl import PermutationSymbol , as_matrix , as_vector , indices , product
5
5
from ufl .classes import Indexed
6
6
from ufl .constantvalue import ComplexValue , FloatValue , IntValue , Zero , as_ufl
7
+ import numpy
7
8
8
9
9
10
def test_zero (self ):
@@ -29,13 +30,15 @@ def test_float(self):
29
30
f4 = FloatValue (1.0 )
30
31
f5 = 3 - FloatValue (1 ) - 1
31
32
f6 = 3 * FloatValue (2 ) / 6
33
+ f7 = as_ufl (numpy .ones ((1 ,), dtype = "d" )[0 ])
32
34
33
35
assert f1 == f1
34
36
self .assertNotEqual (f1 , f2 ) # IntValue vs FloatValue, == compares representations!
35
37
assert f2 == f3
36
38
assert f2 == f4
37
39
assert f2 == f5
38
40
assert f2 == f6
41
+ assert f2 == f7
39
42
40
43
41
44
def test_int (self ):
@@ -45,13 +48,15 @@ def test_int(self):
45
48
f4 = IntValue (1.0 )
46
49
f5 = 3 - IntValue (1 ) - 1
47
50
f6 = 3 * IntValue (2 ) / 6
51
+ f7 = as_ufl (numpy .ones ((1 ,), dtype = "int" )[0 ])
48
52
49
53
assert f1 == f1
50
54
self .assertNotEqual (f1 , f2 ) # IntValue vs FloatValue, == compares representations!
51
55
assert f1 == f3
52
56
assert f1 == f4
53
57
assert f1 == f5
54
58
assert f2 == f6 # Division produces a FloatValue
59
+ assert f1 == f7
55
60
56
61
57
62
def test_complex (self ):
@@ -62,6 +67,7 @@ def test_complex(self):
62
67
f5 = ComplexValue (1.0 + 1.0j )
63
68
f6 = as_ufl (1.0 )
64
69
f7 = as_ufl (1.0j )
70
+ f8 = as_ufl (numpy .array ([1 + 1j ], dtype = "complex" )[0 ])
65
71
66
72
assert f1 == f1
67
73
assert f1 == f4
@@ -71,6 +77,7 @@ def test_complex(self):
71
77
assert f5 == f2 + f3
72
78
assert f4 == f5
73
79
assert f6 + f7 == f2 + f3
80
+ assert f4 == f8
74
81
75
82
76
83
def test_scalar_sums (self ):
0 commit comments