@@ -25,7 +25,7 @@ def test_getB_dict1():
25
25
dic = {"polarization" : mag , "dimension" : dim , "position" : pos , "orientation" : rot }
26
26
B1 = magpy .getB ("Cylinder" , pos_obs , ** dic )
27
27
28
- assert np .allclose (B1 , B2 , rtol = 1e-12 , atol = 1e-12 )
28
+ np .testing . assert_allclose (B1 , B2 , rtol = 1e-12 , atol = 1e-12 )
29
29
30
30
31
31
def test_getB_dict2 ():
@@ -41,7 +41,7 @@ def test_getB_dict2():
41
41
pm = magpy .magnet .Cylinder (polarization = mag , dimension = dim , position = pos )
42
42
B2 = magpy .getB ([pm ], pos_obs )
43
43
44
- assert np .allclose (B1 , B2 , rtol = 1e-12 , atol = 1e-12 )
44
+ np .testing . assert_allclose (B1 , B2 , rtol = 1e-12 , atol = 1e-12 )
45
45
46
46
47
47
def test_getH_dict1 ():
@@ -56,7 +56,7 @@ def test_getH_dict1():
56
56
pm = magpy .magnet .Cylinder (polarization = mag , dimension = dim )
57
57
B2 = pm .getH (pos_obs )
58
58
59
- assert np .allclose (B1 , B2 , rtol = 1e-12 , atol = 1e-12 )
59
+ np .testing . assert_allclose (B1 , B2 , rtol = 1e-12 , atol = 1e-12 )
60
60
61
61
62
62
def test_getB_dict3 ():
@@ -81,7 +81,7 @@ def test_getB_dict3():
81
81
B2 += [pm .getB (pos_obs )]
82
82
B2 = np .array (B2 )
83
83
print (B1 - B2 )
84
- assert np .allclose (B1 , B2 , rtol = 1e-12 , atol = 1e-12 )
84
+ np .testing . assert_allclose (B1 , B2 , rtol = 1e-12 , atol = 1e-12 )
85
85
86
86
87
87
def test_getH_dict3 ():
@@ -99,7 +99,7 @@ def test_getH_dict3():
99
99
B2 += [magpy .getH ([pm ], pos_obs )]
100
100
B2 = np .array (B2 )
101
101
102
- assert np .allclose (B1 , B2 , rtol = 1e-12 , atol = 1e-12 )
102
+ np .testing . assert_allclose (B1 , B2 , rtol = 1e-12 , atol = 1e-12 )
103
103
104
104
105
105
def test_getB_dict4 ():
@@ -124,33 +124,33 @@ def test_getB_dict4():
124
124
B2 += [pm .getB (pos_obs )]
125
125
B2 = np .array (B2 )
126
126
print (B1 - B2 )
127
- assert np .allclose (B1 , B2 , rtol = 1e-12 , atol = 1e-12 )
127
+ np .testing . assert_allclose (B1 , B2 , rtol = 1e-12 , atol = 1e-12 )
128
128
129
129
130
130
def test_getBH_dipole ():
131
131
"""test if Dipole implementation gives correct output"""
132
132
B = magpy .getB ("Dipole" , (1 , 1 , 1 ), moment = (1 , 2 , 3 ))
133
133
Btest = np .array ([9.62250449e-08 , 7.69800359e-08 , 5.77350269e-08 ])
134
- assert np .allclose (B , Btest )
134
+ np .testing . assert_allclose (B , Btest )
135
135
136
136
H = magpy .getH ("Dipole" , (1 , 1 , 1 ), moment = (1 , 2 , 3 ))
137
137
Htest = np .array ([0.07657346 , 0.06125877 , 0.04594407 ])
138
- assert np .allclose (H , Htest )
138
+ np .testing . assert_allclose (H , Htest , rtol = 1e-05 , atol = 1e-08 )
139
139
140
140
141
141
def test_getBH_circle ():
142
142
"""test if Circle implementation gives correct output"""
143
143
B = magpy .getB ("Circle" , (0 , 0 , 0 ), current = 1 , diameter = 2 )
144
144
Btest = np .array ([0 , 0 , 0.6283185307179586 * 1e-6 ])
145
- assert np .allclose (B , Btest )
145
+ np .testing . assert_allclose (B , Btest )
146
146
147
147
H = magpy .getH ("Circle" , (0 , 0 , 0 ), current = 1 , diameter = 2 )
148
148
Htest = np .array ([0 , 0 , 0.6283185307179586 * 10 / 4 / np .pi ])
149
- assert np .allclose (H , Htest )
149
+ np .testing . assert_allclose (H , Htest )
150
150
151
151
with pytest .warns (MagpylibDeprecationWarning ):
152
152
B = magpy .getB ("Loop" , (0 , 0 , 0 ), current = 1 , diameter = 2 )
153
- assert np .allclose (B , Btest )
153
+ np .testing . assert_allclose (B , Btest )
154
154
155
155
156
156
def test_getBH_squeeze ():
@@ -181,7 +181,7 @@ def test_getBH_polyline():
181
181
/ 4
182
182
/ np .pi
183
183
)
184
- assert np .allclose (x , H )
184
+ np .testing . assert_allclose (x , H , rtol = 1e-05 , atol = 1e-08 )
185
185
186
186
187
187
def test_getBH_polyline2 ():
@@ -200,11 +200,11 @@ def getB_line(name):
200
200
201
201
B1 = getB_line ("Polyline" )
202
202
expected = np .array ([0 , - x , 0 ])
203
- assert np .allclose (B1 , expected )
203
+ np .testing . assert_allclose (B1 , expected , rtol = 1e-05 , atol = 1e-08 )
204
204
205
205
with pytest .warns (MagpylibDeprecationWarning ):
206
206
B1 = getB_line ("Line" )
207
- assert np .allclose (B1 , expected )
207
+ np .testing . assert_allclose (B1 , expected , rtol = 1e-05 , atol = 1e-08 )
208
208
209
209
# move z-line to x=-1
210
210
B2 = magpy .getB (
@@ -215,7 +215,7 @@ def getB_line(name):
215
215
segment_start = (1 , 0 , - 1 ),
216
216
segment_end = (1 , 0 , 1 ),
217
217
)
218
- assert np .allclose (B2 , np .array ([0 , x , 0 ]))
218
+ np .testing . assert_allclose (B2 , np .array ([0 , x , 0 ]), rtol = 1e-05 , atol = 1e-08 )
219
219
220
220
# rotate 1
221
221
rot = R .from_euler ("z" , 90 , degrees = True )
@@ -227,7 +227,7 @@ def getB_line(name):
227
227
segment_start = (1 , 0 , - 1 ),
228
228
segment_end = (1 , 0 , 1 ),
229
229
)
230
- assert np .allclose (B3 , np .array ([x , 0 , 0 ]))
230
+ np .testing . assert_allclose (B3 , np .array ([x , 0 , 0 ]), rtol = 1e-05 , atol = 1e-08 )
231
231
232
232
# rotate 2
233
233
rot = R .from_euler ("x" , 90 , degrees = True )
@@ -239,7 +239,7 @@ def getB_line(name):
239
239
segment_start = (1 , 0 , - 1 ),
240
240
segment_end = (1 , 0 , 1 ),
241
241
)
242
- assert np .allclose (B4 , np .array ([0 , 0 , - x ]))
242
+ np .testing . assert_allclose (B4 , np .array ([0 , 0 , - x ]), rtol = 1e-05 , atol = 1e-08 )
243
243
244
244
# rotate 3
245
245
rot = R .from_euler ("y" , 90 , degrees = True )
@@ -251,7 +251,7 @@ def getB_line(name):
251
251
segment_start = (1 , 0 , - 1 ),
252
252
segment_end = (1 , 0 , 1 ),
253
253
)
254
- assert np .allclose (B5 , np .array ([0 , - x , 0 ]))
254
+ np .testing . assert_allclose (B5 , np .array ([0 , - x , 0 ]), rtol = 1e-05 , atol = 1e-08 )
255
255
256
256
# "scalar" vertices tiling
257
257
B = magpy .getB (
@@ -374,8 +374,8 @@ def test_getBH_solid_cylinder():
374
374
polarization = (22 , 33 , 44 ),
375
375
)
376
376
377
- assert np .allclose (B1 , B2 )
378
- assert np .allclose (B1 , B3 )
377
+ np .testing . assert_allclose (B1 , B2 )
378
+ np .testing . assert_allclose (B1 , B3 )
379
379
380
380
381
381
def test_getB_dict_over_getB ():
@@ -403,7 +403,7 @@ def test_getB_dict_over_getB():
403
403
}
404
404
B1 = magpy .getB (** dic )
405
405
406
- assert np .allclose (B1 , B2 , rtol = 1e-12 , atol = 1e-12 )
406
+ np .testing . assert_allclose (B1 , B2 , rtol = 1e-12 , atol = 1e-12 )
407
407
408
408
# test for kwargs if sources is not a string
409
409
dic ["sources" ] = pm
0 commit comments