@@ -48,7 +48,7 @@ class TestInitFromVector(unittest.TestCase):
48
48
def runTest (self ):
49
49
n = 5
50
50
nvals = n * (n + 1 )// 2
51
- x = np .arange (nvals , dtype = np . float )
51
+ x = np .arange (nvals , dtype = float )
52
52
hess = Hessian (n , vals = x )
53
53
self .assertEqual (hess .shape (), (nvals ,), 'Wrong shape for initialisation' )
54
54
self .assertEqual (hess .dim (), n , 'Wrong dimension' )
@@ -60,7 +60,7 @@ class TestInitFromMatrix(unittest.TestCase):
60
60
def runTest (self ):
61
61
n = 3
62
62
nvals = n * (n + 1 )// 2
63
- A = np .arange (n ** 2 , dtype = np . float ).reshape ((n ,n ))
63
+ A = np .arange (n ** 2 , dtype = float ).reshape ((n ,n ))
64
64
hess = Hessian (n , vals = A + A .T ) # force symmetric
65
65
self .assertEqual (hess .shape (), (nvals ,), 'Wrong shape for initialisation' )
66
66
self .assertEqual (hess .dim (), n , 'Wrong dimension' )
@@ -72,7 +72,7 @@ def runTest(self):
72
72
class TestToFull (unittest .TestCase ):
73
73
def runTest (self ):
74
74
n = 7
75
- A = np .arange (n ** 2 , dtype = np . float ).reshape ((n , n ))
75
+ A = np .arange (n ** 2 , dtype = float ).reshape ((n , n ))
76
76
H = A + A .T # force symmetric
77
77
hess = Hessian (n , vals = H )
78
78
self .assertTrue (np .all (hess .as_full () == H ), 'Wrong values' )
@@ -81,7 +81,7 @@ def runTest(self):
81
81
class TestGetElementGood (unittest .TestCase ):
82
82
def runTest (self ):
83
83
n = 3
84
- A = np .arange (n ** 2 , dtype = np . float ).reshape ((n , n ))
84
+ A = np .arange (n ** 2 , dtype = float ).reshape ((n , n ))
85
85
H = A + A .T # force symmetric
86
86
hess = Hessian (n , vals = H )
87
87
for i in range (n ):
@@ -93,7 +93,7 @@ def runTest(self):
93
93
class TestGetElementBad (unittest .TestCase ):
94
94
def runTest (self ):
95
95
n = 4
96
- A = np .arange (n ** 2 , dtype = np . float ).reshape ((n , n ))
96
+ A = np .arange (n ** 2 , dtype = float ).reshape ((n , n ))
97
97
H = A + A .T # force symmetric
98
98
hess = Hessian (n , vals = H )
99
99
# When testing for assertion errors, need lambda to stop assertion from actually happening
@@ -114,7 +114,7 @@ def runTest(self):
114
114
class TestSetElementGood (unittest .TestCase ):
115
115
def runTest (self ):
116
116
n = 3
117
- A = np .arange (n ** 2 , dtype = np . float ).reshape ((n , n ))
117
+ A = np .arange (n ** 2 , dtype = float ).reshape ((n , n ))
118
118
H = A + A .T # force symmetric
119
119
hess = Hessian (n , vals = H )
120
120
H2 = np .sin (H )
@@ -130,7 +130,7 @@ def runTest(self):
130
130
class TestSetElementBad (unittest .TestCase ):
131
131
def runTest (self ):
132
132
n = 5
133
- A = np .arange (n ** 2 , dtype = np . float ).reshape ((n , n ))
133
+ A = np .arange (n ** 2 , dtype = float ).reshape ((n , n ))
134
134
H = A + A .T # force symmetric
135
135
hess = Hessian (n , vals = H )
136
136
# When testing for assertion errors, need lambda to stop assertion from actually happening
@@ -151,32 +151,32 @@ def runTest(self):
151
151
class TestMultGood (unittest .TestCase ):
152
152
def runTest (self ):
153
153
n = 5
154
- A = np .arange (n ** 2 , dtype = np . float ).reshape ((n , n ))
154
+ A = np .arange (n ** 2 , dtype = float ).reshape ((n , n ))
155
155
H = np .sin (A + A .T ) # force symmetric
156
156
hess = Hessian (n , vals = H )
157
- vec = np .exp (np .arange (n , dtype = np . float ))
157
+ vec = np .exp (np .arange (n , dtype = float ))
158
158
hs = np .dot (H , vec )
159
159
self .assertTrue (array_compare (hess * vec , hs , thresh = 1e-12 ), 'Wrong values' )
160
160
161
161
162
162
class TestMultBad (unittest .TestCase ):
163
163
def runTest (self ):
164
164
n = 5
165
- A = np .arange (n ** 2 , dtype = np . float ).reshape ((n , n ))
165
+ A = np .arange (n ** 2 , dtype = float ).reshape ((n , n ))
166
166
H = A + A .T # force symmetric
167
167
hess = Hessian (n , vals = H )
168
168
# When testing for assertion errors, need lambda to stop assertion from actually happening
169
169
self .assertRaises (AssertionError , lambda : hess * 1.0 )
170
170
self .assertRaises (AssertionError , lambda : hess * None )
171
171
self .assertRaises (AssertionError , lambda : hess * [float (i ) for i in range (n )])
172
- self .assertRaises (AssertionError , lambda : hess * np .arange (n - 1 , dtype = np . float ))
173
- self .assertRaises (AssertionError , lambda : hess * np .arange (n + 1 , dtype = np . float ))
172
+ self .assertRaises (AssertionError , lambda : hess * np .arange (n - 1 , dtype = float ))
173
+ self .assertRaises (AssertionError , lambda : hess * np .arange (n + 1 , dtype = float ))
174
174
175
175
176
176
class TestNeg (unittest .TestCase ):
177
177
def runTest (self ):
178
178
n = 5
179
- A = np .arange (n ** 2 , dtype = np . float ).reshape ((n , n ))
179
+ A = np .arange (n ** 2 , dtype = float ).reshape ((n , n ))
180
180
H = A + A .T # force symmetric
181
181
hess = Hessian (n , vals = H )
182
182
neghess = - hess
0 commit comments