@@ -249,7 +249,7 @@ def test_apply_ufunc(self):
249
249
np .square ,
250
250
a ,
251
251
new_name = "squared temperature" ,
252
- new_unit = a .units ** 2 ,
252
+ new_unit = a .units ** 2 ,
253
253
in_place = False ,
254
254
)
255
255
self .assertCMLApproxData (a , ("analysis" , "apply_ufunc_original.cml" ))
@@ -259,14 +259,14 @@ def test_apply_ufunc(self):
259
259
np .square ,
260
260
a ,
261
261
new_name = "squared temperature" ,
262
- new_unit = a .units ** 2 ,
262
+ new_unit = a .units ** 2 ,
263
263
in_place = True ,
264
264
)
265
265
self .assertCMLApproxData (b , ("analysis" , "apply_ufunc.cml" ))
266
266
self .assertCMLApproxData (a , ("analysis" , "apply_ufunc.cml" ))
267
267
268
268
def vec_mag (u , v ):
269
- return math .sqrt (u ** 2 + v ** 2 )
269
+ return math .sqrt (u ** 2 + v ** 2 )
270
270
271
271
c = a .copy () + 2
272
272
@@ -295,7 +295,7 @@ def test_apply_ufunc_fail(self):
295
295
def test_ifunc (self ):
296
296
a = self .cube
297
297
298
- my_ifunc = iris .analysis .maths .IFunc (np .square , lambda a : a .units ** 2 )
298
+ my_ifunc = iris .analysis .maths .IFunc (np .square , lambda a : a .units ** 2 )
299
299
b = my_ifunc (a , new_name = "squared temperature" , in_place = False )
300
300
301
301
self .assertCMLApproxData (a , ("analysis" , "apply_ifunc_original.cml" ))
@@ -307,7 +307,7 @@ def test_ifunc(self):
307
307
self .assertCMLApproxData (a , ("analysis" , "apply_ifunc.cml" ))
308
308
309
309
def vec_mag (u , v ):
310
- return math .sqrt (u ** 2 + v ** 2 )
310
+ return math .sqrt (u ** 2 + v ** 2 )
311
311
312
312
c = a .copy () + 2
313
313
@@ -347,7 +347,7 @@ def test_ifunc_init_fail(self):
347
347
def test_ifunc_call_fail (self ):
348
348
a = self .cube
349
349
350
- my_ifunc = iris .analysis .maths .IFunc (np .square , lambda a : a .units ** 2 )
350
+ my_ifunc = iris .analysis .maths .IFunc (np .square , lambda a : a .units ** 2 )
351
351
352
352
# should now NOT fail because giving 2 arguments to an ifunc that
353
353
# expects only one will now ignore the surplus argument and raise
@@ -367,7 +367,7 @@ def test_ifunc_call_fail(self):
367
367
my_ifunc (a )
368
368
369
369
my_ifunc = iris .analysis .maths .IFunc (
370
- lambda a : (a , a ** 2.0 ), lambda cube : cf_units .Unit ("1" )
370
+ lambda a : (a , a ** 2.0 ), lambda cube : cf_units .Unit ("1" )
371
371
)
372
372
373
373
# should fail because data function returns a tuple
@@ -553,9 +553,9 @@ def test_square_root(self):
553
553
a .data = abs (a .data )
554
554
a .units **= 2
555
555
556
- e = a ** 0.5
556
+ e = a ** 0.5
557
557
558
- self .assertArrayAllClose (e .data , a .data ** 0.5 )
558
+ self .assertArrayAllClose (e .data , a .data ** 0.5 )
559
559
self .assertCML (e , ("analysis" , "sqrt.cml" ), checksum = False )
560
560
self .assertRaises (ValueError , iris .analysis .maths .exponentiate , a , 0.3 )
561
561
@@ -585,26 +585,26 @@ def test_apply_ufunc(self):
585
585
np .square ,
586
586
a ,
587
587
new_name = "more_thingness" ,
588
- new_unit = a .units ** 2 ,
588
+ new_unit = a .units ** 2 ,
589
589
in_place = False ,
590
590
)
591
591
592
- ans = a .data ** 2
592
+ ans = a .data ** 2
593
593
594
594
self .assertArrayEqual (b .data , ans )
595
595
self .assertEqual (b .name (), "more_thingness" )
596
596
self .assertEqual (b .units , cf_units .Unit ("m^2" ))
597
597
598
598
def vec_mag (u , v ):
599
- return math .sqrt (u ** 2 + v ** 2 )
599
+ return math .sqrt (u ** 2 + v ** 2 )
600
600
601
601
c = a .copy () + 2
602
602
603
603
vec_mag_ufunc = np .frompyfunc (vec_mag , 2 , 1 )
604
604
b = iris .analysis .maths .apply_ufunc (vec_mag_ufunc , a , c )
605
605
606
- ans = a .data ** 2 + c .data ** 2
607
- b2 = b ** 2
606
+ ans = a .data ** 2 + c .data ** 2
607
+ b2 = b ** 2
608
608
609
609
self .assertArrayAlmostEqual (b2 .data , ans )
610
610
@@ -617,17 +617,17 @@ def test_ifunc(self):
617
617
a = self .cube
618
618
a .units = cf_units .Unit ("meters" )
619
619
620
- my_ifunc = iris .analysis .maths .IFunc (np .square , lambda x : x .units ** 2 )
620
+ my_ifunc = iris .analysis .maths .IFunc (np .square , lambda x : x .units ** 2 )
621
621
b = my_ifunc (a , new_name = "more_thingness" , in_place = False )
622
622
623
- ans = a .data ** 2
623
+ ans = a .data ** 2
624
624
625
625
self .assertArrayEqual (b .data , ans )
626
626
self .assertEqual (b .name (), "more_thingness" )
627
627
self .assertEqual (b .units , cf_units .Unit ("m^2" ))
628
628
629
629
def vec_mag (u , v ):
630
- return math .sqrt (u ** 2 + v ** 2 )
630
+ return math .sqrt (u ** 2 + v ** 2 )
631
631
632
632
c = a .copy () + 2
633
633
@@ -637,12 +637,12 @@ def vec_mag(u, v):
637
637
)
638
638
b = my_ifunc (a , c )
639
639
640
- ans = (a .data ** 2 + c .data ** 2 ) ** 0.5
640
+ ans = (a .data ** 2 + c .data ** 2 ) ** 0.5
641
641
642
642
self .assertArrayAlmostEqual (b .data , ans )
643
643
644
644
def vec_mag_data_func (u_data , v_data ):
645
- return np .sqrt (u_data ** 2 + v_data ** 2 )
645
+ return np .sqrt (u_data ** 2 + v_data ** 2 )
646
646
647
647
vec_mag_ifunc = iris .analysis .maths .IFunc (
648
648
vec_mag_data_func , lambda a , b : (a + b ).units
0 commit comments