zmc
2023-08-08 e792e9a60d958b93aef96050644f369feb25d61b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
U
P±d‘aã)@sbdZddlZddlZddlZddlZddlZddlZddlZddlm    Z    m
Z
ddl Z ddl Z ddl mZmZddlmZddlmZddlZddlZddlmZmZmZmZmZmZmZmZddlZddl m!Z!d    d
d d d ddddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1g)Z"Gd2d%„d%e#ƒZ$e$Z%dZ&e '¡d3kZ(ej)j*d4kZ+e,ed5ƒZ-e.ed6dƒdk    ove- Z/ej0j1j2Z3d7d8„Z4d9d:„Z5dšd<d„Z6d=d>„Z7d?d@„Z8dAdB„Z9ej*dCkrÖd›dEdF„Z:dœdHd„Z;n6ejddI…dJkrdKe <¡›dLfdMd„Z;ndNd„Z;ejddI…dJkr<dKe <¡›dLgfdOd„Z=n gfdPd„Z=ddUd„Z>dždVd    „Z?dWd„Z@e A¡dŸdYd
„ƒZBe A¡d dZd „ƒZCe A¡d¡d\d]œd^d,„ƒZDd¢d\d]œd_d „ZEe A¡d£d`d„ƒZFd¤dad „ZGdbd„ZHdcd„ZId¥ddd„ZJded„ZKddlLZLGdfdg„dgeLjMƒZNeNdhƒZOdid„ZPdjd„ZQd¦dkd„ZRd§dmd„ZSdndo„ZTd¨dqd!„ZUd©drd„ZVdªdsd„ZWd«dtdu„ZXdvdw„ZYdxdy„ZZe j[d¬dzd{„ƒZ\d|d„Z]e j[d­d}d~„ƒZ^dd „Z_ed€dfd‚dƒ„Z`Gd„d"„d"e#ƒZae j[d…d'„ƒZbe j[d†d&„ƒZcGd‡d#„d#ejdƒZeGdˆd+„d+ƒZfe j[d®d‰dŠ„ƒZgd‹d-„ZhdŒd.„ZiddŽ„Zjdd„Zkd‘d’„Zld“d”„Zmd•d–„Znd—d˜„ZoeoƒZpd™d8„ZqdS)¯z*
Utility function to facilitate testing.
 
éN)ÚpartialÚwraps)ÚmkdtempÚmkstemp)ÚSkipTest)ÚWarningMessage)ÚintpÚfloat32ÚemptyÚarangeÚ
array_reprÚndarrayÚisnatÚarray)ÚStringIOÚ assert_equalÚassert_almost_equalÚassert_approx_equalÚassert_array_equalÚassert_array_lessÚassert_string_equalÚassert_array_almost_equalÚ assert_raisesÚ build_err_msgÚdecorate_methodsÚjiffiesÚmemusageÚprint_assert_equalÚraisesÚrundocsÚ    runstringÚverboseÚmeasureÚassert_Úassert_array_almost_equal_nulpÚassert_raises_regexÚassert_array_max_ulpÚ assert_warnsÚassert_no_warningsÚassert_allcloseÚIgnoreExceptionÚclear_and_catch_warningsrÚKnownFailureExceptionÚtemppathÚtempdirÚIS_PYPYÚ HAS_REFCOUNTÚIS_WASMÚsuppress_warningsÚassert_array_compareÚassert_no_gc_cyclesÚ break_cyclesÚ HAS_LAPACK64Ú    IS_PYSTONÚ_OLD_PROMOTIONc@seZdZdZdS)r,z<Raise this exception to mark a test as a known failing test.N©Ú__name__Ú
__module__Ú __qualname__Ú__doc__©r>r>úSd:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\numpy/testing/_private/utils.pyr,+s)Zwasm32Zwasm64ÚpypyZpyston_version_infoÚ getrefcountcCs t ¡dkS)NÚlegacy)ÚnpZ_get_promotion_stater>r>r>r?Ú<lambda>9órDcCsTd}d}z ddl}Wntk
r,d}YnX|j|kr<d}|sPd|}t|ƒ‚|S)z# Import nose only when needed.
    T)érrrNFzANeed nose >= %d.%d.%d for tests - see https://nose.readthedocs.io)ÚnoseÚ ImportErrorZ__versioninfo__)Z nose_is_goodZminimum_nose_versionrGÚmsgr>r>r?Ú import_nose<s 
 
þrJÚcCs8d}|s4z
|ƒ}Wntk
r*|}YnXt|ƒ‚dS)aI
    Assert that works in release mode.
    Accepts callable msg to allow deferring evaluation until failure.
 
    The Python built-in ``assert`` does not work when executing code in
    optimized mode (the ``-O`` flag) - no byte-code is generated for it.
 
    For documentation on usage, refer to the Python documentation.
 
    TN)Ú    TypeErrorÚAssertionError)ÚvalrIÚ__tracebackhide__Zsmsgr>r>r?r#Rs 
 
cCs.ddlm}||ƒ}t|ttƒƒr*tdƒ‚|S)alike isnan, but always raise an error if type not supported instead of
    returning a TypeError object.
 
    Notes
    -----
    isnan and other ufunc sometimes return a NotImplementedType object instead
    of raising any exception. This function is a wrapper to make sure an
    exception is always raised.
 
    This should be removed once this problem is solved at the Ufunc level.r)Úisnanz!isnan not supported for this type)Ú
numpy.corerPÚ
isinstanceÚtypeÚNotImplementedrL)ÚxrPÚstr>r>r?Úgisnanfs
rWc    CsHddlm}m}|dd$||ƒ}t|ttƒƒr:tdƒ‚W5QRX|S)a‡like isfinite, but always raise an error if type not supported instead
    of returning a TypeError object.
 
    Notes
    -----
    isfinite and other ufunc sometimes return a NotImplementedType object
    instead of raising any exception. This function is a wrapper to make sure
    an exception is always raised.
 
    This should be removed once this problem is solved at the Ufunc level.r)ÚisfiniteÚerrstateÚignore©Úinvalidz$isfinite not supported for this type)rQrXrYrRrSrTrL)rUrXrYrVr>r>r?Ú    gisfinitexs  r]c    CsHddlm}m}|dd$||ƒ}t|ttƒƒr:tdƒ‚W5QRX|S)alike isinf, but always raise an error if type not supported instead of
    returning a TypeError object.
 
    Notes
    -----
    isinf and other ufunc sometimes return a NotImplementedType object instead
    of raising any exception. This function is a wrapper to make sure an
    exception is always raised.
 
    This should be removed once this problem is solved at the Ufunc level.r)ÚisinfrYrZr[z!isinf not supported for this type)rQr^rYrRrSrTrL)rUr^rYrVr>r>r?Úgisinf‹s  r_Úntéÿÿÿÿc     CsŠddl}|dkr|j}| |||d||f¡}| ¡}zD| ||¡}    z&| |¡| |    |¡\}
} | W¢W¢S| |    ¡XW5| |¡XdS)Nr)    Úwin32pdhÚ PDH_FMT_LONGZMakeCounterPathZ    OpenQueryZ
CloseQueryZ
AddCounterZ RemoveCounterZCollectQueryDataZGetFormattedCounterValue) ÚobjectÚcounterÚinstanceZinumÚformatÚmachinerbÚpathZhqZhcrSrNr>r>r?ÚGetPerformanceAttributes s 
 ÿ 
 rjÚpythoncCsddl}tdd|||jdƒS)NrÚProcessz Virtual Bytes)rbrjrc)Ú processNamerfrbr>r>r?r»sþéÚlinuxz/proc/z/statc    CsNz2t|dƒ}| ¡ d¡}W5QRXt|dƒWStk
rHYdSXdS)zM
        Return virtual memory size in bytes of the running python.
 
        Úrú éN)ÚopenÚreadlineÚsplitÚintÚ    Exception)Ú_proc_pid_statÚfÚlr>r>r?rÃs  cCst‚dS)zK
        Return memory usage of running python. [Not implemented]
 
        N)ÚNotImplementedErrorr>r>r>r?rÏsc    Cs~ddl}|s| | ¡¡z2t|dƒ}| ¡ d¡}W5QRXt|dƒWStk
rxtd| ¡|dƒYSXdS)ú¸
        Return number of jiffies elapsed.
 
        Return number of jiffies (1/100ths of a second) that this
        process has been scheduled in user mode. See man 5 proc.
 
        rNrprqé éd)ÚtimeÚappendrsrtrurvrw)rxÚ
_load_timerryrzr>r>r?rØs cCs2ddl}|s| | ¡¡td| ¡|dƒS)r|rNr~)rr€rv)rrr>r>r?rísúItems are not equal:T©ZACTUALZDESIREDéc Csd|g}|rN| d¡dkrDt|ƒdt|ƒkrD|dd|g}n
| |¡|rt|ƒD]²\}}t|tƒr|tt|d}    nt}    z |    |ƒ}
Wn:t    k
rÆ} zdt
|ƒj ›d| ›d    }
W5d} ~ XYnX|
  d¡d
krôd  |
 ¡dd
…¡}
|
d 7}
| d||›d |
›¡q\d  |¡S) NÚ
raéOrrq)Ú    precisionz[repr failed for <z>: ú]éz...ú: )ÚfindÚlenr€Ú    enumeraterRr rr ÚreprrwrSr:ÚcountÚjoinÚ
splitlines) ZarraysÚerr_msgÚheaderr!Únamesr‡rIÚiÚaZr_funcrpÚexcr>r>r?rûs&
"
 
 *c
Cs¢d}t|tƒrŠt|tƒs(ttt|ƒƒƒ‚tt|ƒt|ƒ||ƒ| ¡D]>\}}||krbtt|ƒƒ‚t||||d|›d|›|ƒqFdSt|tt    fƒrôt|tt    fƒrôtt|ƒt|ƒ||ƒt
t|ƒƒD]&}t||||d|›d|›|ƒqÈdSddl m }m }m}    ddlm}
m} m} t||ƒs4t||ƒrBt||||ƒSt||g||d    } z|
|ƒpf|
|ƒ}Wnttfk
rˆd
}YnX|r|
|ƒr¬| |ƒ}| |ƒ}n|}d}|
|ƒrÐ| |ƒ}| |ƒ}n|}d}zt||ƒt||ƒWntk
rt| ƒ‚YnX||ƒ||ƒkr*t| ƒ‚zPt|ƒ}t|ƒ}t |¡jjt |¡jjk}|rx|rx|rpWdSt| ƒ‚Wntttfk
r–YnXzŒt|ƒ}t|ƒ}|r¼|r¼WdSt |¡}t |¡}|jjd ksì|jjd krôtd ƒ‚|dkr"|dkr"|    |ƒ|    |ƒks"t| ƒ‚Wntttfk
r@YnXz||ksVt| ƒ‚WnDttfk
rœ}z d |j dkrŠt| ƒ‚n‚W5d}~XYnXdS)a
    Raises an AssertionError if two objects are not equal.
 
    Given two objects (scalars, lists, tuples, dictionaries or numpy arrays),
    check that all elements of these objects are equal. An exception is raised
    at the first conflicting values.
 
    When one of `actual` and `desired` is a scalar and the other is array_like,
    the function checks that each element of the array_like object is equal to
    the scalar.
 
    This function handles NaN comparisons as if NaN was a "normal" number.
    That is, AssertionError is not raised if both objects have NaNs in the same
    positions.  This is in contrast to the IEEE standard on NaNs, which says
    that NaN compared to anything must return False.
 
    Parameters
    ----------
    actual : array_like
        The object to check.
    desired : array_like
        The expected object.
    err_msg : str, optional
        The error message to be printed in case of failure.
    verbose : bool, optional
        If True, the conflicting values are appended to the error message.
 
    Raises
    ------
    AssertionError
        If actual and desired are not equal.
 
    Examples
    --------
    >>> np.testing.assert_equal([4,5], [4,6])
    Traceback (most recent call last):
        ...
    AssertionError:
    Items are not equal:
    item=1
     ACTUAL: 5
     DESIRED: 6
 
    The following comparison does not raise an exception.  There are NaNs
    in the inputs, but they are in the same positions.
 
    >>> np.testing.assert_equal(np.array([1.0, 2.0, np.nan]), [1, 2, np.nan])
 
    Tzkey=r…Nzitem=r)r ÚisscalarÚsignbit©Ú iscomplexobjÚrealÚimag©r!FÚMmz0cannot compare to a scalar with a different typezelementwise == comparison)!rRÚdictrMrŽrSrrŒÚitemsÚlistÚtupleÚrangerQr r˜r™Ú    numpy.libr›rœrrrÚ
ValueErrorrLrrCÚasarrayÚdtyper{rWÚcharÚDeprecationWarningÚ FutureWarningÚargs)ÚactualÚdesiredr’r!rOÚkr•r r˜r™r›rœrrIÚ
usecomplexÚactualrÚactualiÚdesiredrÚdesirediZisdesnatZisactnatZ dtypes_matchZisdesnanZisactnanZ array_actualZ array_desiredÚer>r>r?rs¢2
 
 ÿÿ
 
 
 
 
 
  ÿ   
 
 
ÿ 
 
cCs`d}ddl}||ks\tƒ}| |¡| d¡| ||¡| d¡| ||¡t| ¡ƒ‚dS)aµ
    Test if two objects are equal, and print an error message if test fails.
 
    The test is performed with ``actual == desired``.
 
    Parameters
    ----------
    test_string : str
        The message supplied to AssertionError.
    actual : object
        The object to test for equality against `desired`.
    desired : object
        The expected result.
 
    Examples
    --------
    >>> np.testing.print_assert_equal('Test XYZ of func xyz', [0, 1], [0, 1])
    >>> np.testing.print_assert_equal('Test XYZ of func xyz', [0, 1], [0, 2])
    Traceback (most recent call last):
    ...
    AssertionError: Test XYZ of func xyz failed
    ACTUAL:
    [0, 1]
    DESIRED:
    [0, 2]
 
    TrNz failed
ACTUAL: 
z
DESIRED: 
)ÚpprintrÚwriterMÚgetvalue)Ú test_stringr­r®rOr¶rIr>r>r?r·s
 
 
 éc    sÒd}ddlm}ddlm}m}m}    z|ˆƒp4|ˆƒ}
Wntk
rPd}
YnX‡‡‡‡‡fdd„} |
rî|ˆƒr„|ˆƒ} |    ˆƒ} nˆ} d} |ˆƒr¦|ˆƒ}|    ˆƒ}nˆ}d}z t| |ˆdt| |ˆdWntk
rìt| ƒƒ‚YnXt    ˆ|t
t fƒst    ˆ|t
t fƒr t ˆˆˆˆƒSzft ˆƒr6t ˆƒs„tˆƒsJtˆƒrjtˆƒr^tˆƒs~t| ƒƒ‚nˆˆks~t| ƒƒ‚Wd    SWnttfk
r YnXtˆˆƒt d
d ˆ ¡krÎt| ƒƒ‚d    S) a$    
    Raises an AssertionError if two items are not equal up to desired
    precision.
 
    .. note:: It is recommended to use one of `assert_allclose`,
              `assert_array_almost_equal_nulp` or `assert_array_max_ulp`
              instead of this function for more consistent floating point
              comparisons.
 
    The test verifies that the elements of `actual` and `desired` satisfy.
 
        ``abs(desired-actual) < float64(1.5 * 10**(-decimal))``
 
    That is a looser test than originally documented, but agrees with what the
    actual implementation in `assert_array_almost_equal` did up to rounding
    vagaries. An exception is raised at conflicting values. For ndarrays this
    delegates to assert_array_almost_equal
 
    Parameters
    ----------
    actual : array_like
        The object to check.
    desired : array_like
        The expected object.
    decimal : int, optional
        Desired precision, default is 7.
    err_msg : str, optional
        The error message to be printed in case of failure.
    verbose : bool, optional
        If True, the conflicting values are appended to the error message.
 
    Raises
    ------
    AssertionError
      If actual and desired are not equal up to specified precision.
 
    See Also
    --------
    assert_allclose: Compare two array_like objects for equality with desired
                     relative and/or absolute precision.
    assert_array_almost_equal_nulp, assert_array_max_ulp, assert_equal
 
    Examples
    --------
    >>> from numpy.testing import assert_almost_equal
    >>> assert_almost_equal(2.3333333333333, 2.33333334)
    >>> assert_almost_equal(2.3333333333333, 2.33333334, decimal=10)
    Traceback (most recent call last):
        ...
    AssertionError:
    Arrays are not almost equal to 10 decimals
     ACTUAL: 2.3333333333333
     DESIRED: 2.33333334
 
    >>> assert_almost_equal(np.array([1.0,2.3333333333333]),
    ...                     np.array([1.0,2.33333334]), decimal=9)
    Traceback (most recent call last):
        ...
    AssertionError:
    Arrays are not almost equal to 9 decimals
    <BLANKLINE>
    Mismatched elements: 1 / 2 (50%)
    Max absolute difference: 6.66669964e-09
    Max relative difference: 2.85715698e-09
     x: array([1.         , 2.333333333])
     y: array([1.        , 2.33333334])
 
    Tr)r ršFcsdˆ}tˆˆgˆˆ|dS)Nú*Arrays are not almost equal to %d decimals)r!r“)r)r“©r­Údecimalr®r’r!r>r?Ú_build_err_msg2s ÿz+assert_almost_equal.<locals>._build_err_msg)r½Nçø?ç$@)rQr r¥r›rœrr¦rrMrRr£r¢rr]rWr{rLÚabsrCÚfloat64)r­r®r½r’r!rOr r›rœrr°r¾r±r²r³r´r>r¼r?ràsPF 
 
 
ÿ 
 
 
"c     Cs~d}ddl}tt||fƒ\}}||kr*dS|jdd6d| |¡| |¡}| d| | |¡¡¡}W5QRXz ||}Wntk
r–d}YnXz ||}    Wntk
r¼d}    YnXt    ||g|d    ||d
}
z^t
|ƒrêt
|ƒs2t |ƒsüt |ƒrt |ƒrt |ƒs,t |
ƒ‚n||ks,t |
ƒ‚WdSWnt tfk
rNYnX| ||    ¡| d |d  ¡krzt |
ƒ‚dS) aa
    Raises an AssertionError if two items are not equal up to significant
    digits.
 
    .. note:: It is recommended to use one of `assert_allclose`,
              `assert_array_almost_equal_nulp` or `assert_array_max_ulp`
              instead of this function for more consistent floating point
              comparisons.
 
    Given two numbers, check that they are approximately equal.
    Approximately equal is defined as the number of significant digits
    that agree.
 
    Parameters
    ----------
    actual : scalar
        The object to check.
    desired : scalar
        The expected object.
    significant : int, optional
        Desired precision, default is 7.
    err_msg : str, optional
        The error message to be printed in case of failure.
    verbose : bool, optional
        If True, the conflicting values are appended to the error message.
 
    Raises
    ------
    AssertionError
      If actual and desired are not equal up to specified precision.
 
    See Also
    --------
    assert_allclose: Compare two array_like objects for equality with desired
                     relative and/or absolute precision.
    assert_array_almost_equal_nulp, assert_array_max_ulp, assert_equal
 
    Examples
    --------
    >>> np.testing.assert_approx_equal(0.12345677777777e-20, 0.1234567e-20)
    >>> np.testing.assert_approx_equal(0.12345670e-20, 0.12345671e-20,
    ...                                significant=8)
    >>> np.testing.assert_approx_equal(0.12345670e-20, 0.12345672e-20,
    ...                                significant=8)
    Traceback (most recent call last):
        ...
    AssertionError:
    Items are not equal to 8 significant digits:
     ACTUAL: 1.234567e-21
     DESIRED: 1.2345672e-21
 
    the evaluated condition that raises the exception is
 
    >>> abs(0.12345670e-20/1e-21 - 0.12345672e-20/1e-21) >= 10**-(8-1)
    True
 
    TrNrZr[gà?é
gz-Items are not equal to %d significant digits:)r“r!rÀrF)ÚnumpyÚmapÚfloatrYrÁÚpowerÚfloorÚlog10ÚZeroDivisionErrorrr]rWrMrLr{) r­r®Z significantr’r!rOrCZscaleZ
sc_desiredZ    sc_actualrIr>r>r?r_sD;" 
 
ý
 
 
"éF)Ústrictc    ( s>d}
ddlm} m} m} m‰m‰m}m}m}m    }t
  |¡}t
  |¡}||}}dd„}dd„}| df‡‡‡‡‡fd    d
„    }zh|    rš|j |j ko–|j |j k}n |j d kp¸|j d kp¸|j |j k}|s|j |j kräd |j ›d |j ›d}nd|j ›d |j ›d}t||gˆ|ˆˆdˆd}t|ƒ‚ˆdƒ}||ƒr||ƒr|rP|||| dd}|rÌ||||‡fdd„ddO}||||‡fdd„ddO}n<||ƒrÌ||ƒrÌ|rÌ|j j|j jkrÌ|||tdd}|jdkr||||}}|jdkrWdSn |rWdS|||ƒ}t|tƒr4|}| |gƒ}n| ¡}| ¡}|dkrà|j|jtd}|jdkrr|jn|j}d||}d |||¡g} |ddt t¡òt||ƒ}!t
 |j t
j¡rèt||ƒ}"t
j |!|"|!d||!ƒ}#t!|!d |ƒ|kr|  "d!t#|#ƒ¡n|  "d!| |#ƒ¡ˆ|dkƒ}$||$ƒrJ| ˆƒ}%n||!|$t||$ƒƒ}%t!|!d |ƒ|krˆ|  "d"t#|%ƒ¡n|  "d"| |%ƒ¡W5QRXW5QRXˆd#d# $| ¡7‰t||gˆˆˆdˆd}t|ƒ‚WnVt%k
r8ddl&}&|& '¡}'d$|'›d%ˆ›‰t||gˆˆˆdˆd}t%|ƒ‚YnXdS)&NTr)    rÚ array2stringrPÚinfÚbool_rYÚallÚmaxÚobject_cSs |jjdkS)Nz?bhilqpBHILQPefdgFDG©r¨r©©rUr>r>r?ÚisnumberÐsz&assert_array_compare.<locals>.isnumbercSs |jjdkS)NrŸrÓrÔr>r>r?ÚistimeÓsz$assert_array_compare.<locals>.istimeÚnancsd}||ƒ}||ƒ}ˆ||kƒ ¡dkrPt||gˆd|ˆˆdˆd}t|ƒ‚t|tƒsd|jdkrlˆ|ƒSt|tƒs€|jdkrˆˆ|ƒS|SdS)z‹Handling nan/inf.
 
        Combine results of running func on x and y, checking that they are True
        at the same locations.
 
        Tz
x and y %s location mismatch:©rUÚy©r!r“r”r‡rN)rÐrrMrRÚboolÚndim)rUrÙÚfuncÚhasvalrOZx_idZy_idrI)rÏr’r“r‡r!r>r?Úfunc_assert_same_posÖs& ÿýz2assert_array_compare.<locals>.func_assert_same_posr>z    
(shapes z, z
 mismatch)z    
(dtypes rØrÚF)rÝrÞcs
kS©Nr>©Zxy©rÎr>r?rDrEz&assert_array_compare.<locals>.<lambda>z+infcs
|ˆ kSràr>rárâr>r?rDrEz-infZNaT©r¨r~z&Mismatched elements: {} / {} ({:.3g}%)rZ)rЩÚoutr¨zMax absolute difference: zMax relative difference: r…zerror during assertion:
 
z
 
)(rQrrÍrPrÎrÏrYrÐrÑrÒrCÚ
asanyarrayÚshaper¨rrMrSrrÜÚsizerRrÛZravelÚsumrrgÚ
contextlibÚsuppressrLrÁÚ
issubdtypeZunsignedintegerZminimumÚgetattrr€Ústrrr¦Ú    tracebackÚ
format_exc)(Z
comparisonrUrÙr’r!r“r‡Ú    equal_nanÚ    equal_infrÌrOrrÍrPrYrÐrÑrÒZoxZoyrÕrÖrßZcondÚreasonrIZflaggedrNZreducedZ
n_mismatchZ
n_elementsZpercent_mismatchZremarksÚerrorZerror2Z max_abs_errorZnonzeroZ max_rel_errorrïZefmtr>)rÏr’r“rÎr‡r!r?r3ÃsÔ,
 
 
%  ÿü
þ
þ
 
 
 ÿÿ   ÿÿ  
ÿÿ
þ ÿc    Cs d}ttj||||d|ddS)aß
    Raises an AssertionError if two array_like objects are not equal.
 
    Given two array_like objects, check that the shape is equal and all
    elements of these objects are equal (but see the Notes for the special
    handling of a scalar). An exception is raised at shape mismatch or
    conflicting values. In contrast to the standard usage in numpy, NaNs
    are compared like numbers, no assertion is raised if both objects have
    NaNs in the same positions.
 
    The usual caution for verifying equality with floating point numbers is
    advised.
 
    Parameters
    ----------
    x : array_like
        The actual object to check.
    y : array_like
        The desired, expected object.
    err_msg : str, optional
        The error message to be printed in case of failure.
    verbose : bool, optional
        If True, the conflicting values are appended to the error message.
    strict : bool, optional
        If True, raise an AssertionError when either the shape or the data
        type of the array_like objects does not match. The special
        handling for scalars mentioned in the Notes section is disabled.
 
        .. versionadded:: 1.24.0
 
    Raises
    ------
    AssertionError
        If actual and desired objects are not equal.
 
    See Also
    --------
    assert_allclose: Compare two array_like objects for equality with desired
                     relative and/or absolute precision.
    assert_array_almost_equal_nulp, assert_array_max_ulp, assert_equal
 
    Notes
    -----
    When one of `x` and `y` is a scalar and the other is array_like, the
    function checks that each element of the array_like object is equal to
    the scalar. This behaviour can be disabled with the `strict` parameter.
 
    Examples
    --------
    The first assert does not raise an exception:
 
    >>> np.testing.assert_array_equal([1.0,2.33333,np.nan],
    ...                               [np.exp(0),2.33333, np.nan])
 
    Assert fails with numerical imprecision with floats:
 
    >>> np.testing.assert_array_equal([1.0,np.pi,np.nan],
    ...                               [1, np.sqrt(np.pi)**2, np.nan])
    Traceback (most recent call last):
        ...
    AssertionError:
    Arrays are not equal
    <BLANKLINE>
    Mismatched elements: 1 / 3 (33.3%)
    Max absolute difference: 4.4408921e-16
    Max relative difference: 1.41357986e-16
     x: array([1.      , 3.141593,      nan])
     y: array([1.      , 3.141593,      nan])
 
    Use `assert_allclose` or one of the nulp (number of floating point values)
    functions for these cases instead:
 
    >>> np.testing.assert_allclose([1.0,np.pi,np.nan],
    ...                            [1, np.sqrt(np.pi)**2, np.nan],
    ...                            rtol=1e-10, atol=0)
 
    As mentioned in the Notes section, `assert_array_equal` has special
    handling for scalars. Here the test checks that each value in `x` is 3:
 
    >>> x = np.full((2, 5), fill_value=3)
    >>> np.testing.assert_array_equal(x, 3)
 
    Use `strict` to raise an AssertionError when comparing a scalar with an
    array:
 
    >>> np.testing.assert_array_equal(x, 3, strict=True)
    Traceback (most recent call last):
        ...
    AssertionError:
    Arrays are not equal
    <BLANKLINE>
    (shapes (2, 5), () mismatch)
     x: array([[3, 3, 3, 3, 3],
           [3, 3, 3, 3, 3]])
     y: array(3)
 
    The `strict` parameter also ensures that the array data types match:
 
    >>> x = np.array([2, 2, 2])
    >>> y = np.array([2., 2., 2.], dtype=np.float32)
    >>> np.testing.assert_array_equal(x, y, strict=True)
    Traceback (most recent call last):
        ...
    AssertionError:
    Arrays are not equal
    <BLANKLINE>
    (dtypes int64, float32 mismatch)
     x: array([2, 2, 2])
     y: array([2., 2., 2.], dtype=float32)
    TzArrays are not equal)r’r!r“rÌN)r3ÚoperatorÚ__eq__)rUrÙr’r!rÌrOr>r>r?ris o þc    shd}ddlm‰m‰m‰m}ddlm‰ddlm‰‡‡‡‡‡‡fdd„}t    |||||dˆˆd    d
S) a€
 
    Raises an AssertionError if two objects are not equal up to desired
    precision.
 
    .. note:: It is recommended to use one of `assert_allclose`,
              `assert_array_almost_equal_nulp` or `assert_array_max_ulp`
              instead of this function for more consistent floating point
              comparisons.
 
    The test verifies identical shapes and that the elements of ``actual`` and
    ``desired`` satisfy.
 
        ``abs(desired-actual) < 1.5 * 10**(-decimal)``
 
    That is a looser test than originally documented, but agrees with what the
    actual implementation did up to rounding vagaries. An exception is raised
    at shape mismatch or conflicting values. In contrast to the standard usage
    in numpy, NaNs are compared like numbers, no assertion is raised if both
    objects have NaNs in the same positions.
 
    Parameters
    ----------
    x : array_like
        The actual object to check.
    y : array_like
        The desired, expected object.
    decimal : int, optional
        Desired precision, default is 6.
    err_msg : str, optional
      The error message to be printed in case of failure.
    verbose : bool, optional
        If True, the conflicting values are appended to the error message.
 
    Raises
    ------
    AssertionError
        If actual and desired are not equal up to specified precision.
 
    See Also
    --------
    assert_allclose: Compare two array_like objects for equality with desired
                     relative and/or absolute precision.
    assert_array_almost_equal_nulp, assert_array_max_ulp, assert_equal
 
    Examples
    --------
    the first assert does not raise an exception
 
    >>> np.testing.assert_array_almost_equal([1.0,2.333,np.nan],
    ...                                      [1.0,2.333,np.nan])
 
    >>> np.testing.assert_array_almost_equal([1.0,2.33333,np.nan],
    ...                                      [1.0,2.33339,np.nan], decimal=5)
    Traceback (most recent call last):
        ...
    AssertionError:
    Arrays are not almost equal to 5 decimals
    <BLANKLINE>
    Mismatched elements: 1 / 3 (33.3%)
    Max absolute difference: 6.e-05
    Max relative difference: 2.57136612e-05
     x: array([1.     , 2.33333,     nan])
     y: array([1.     , 2.33339,     nan])
 
    >>> np.testing.assert_array_almost_equal([1.0,2.33333,np.nan],
    ...                                      [1.0,2.33333, 5], decimal=5)
    Traceback (most recent call last):
        ...
    AssertionError:
    Arrays are not almost equal to 5 decimals
    <BLANKLINE>
    x and y nan location mismatch:
     x: array([1.     , 2.33333,     nan])
     y: array([1.     , 2.33333, 5.     ])
 
    Tr)ÚnumberÚfloat_Ú result_typer)rì)Úanyc    sÜzxˆt|ƒƒsˆt|ƒƒrvt|ƒ}t|ƒ}||k ¡s<WdS|j|jkrTdkrbnn
||kWS||}||}Wnttfk
rYnXˆ|dƒ}t ||¡}t||ƒ}ˆ|jˆƒsÊ|     ˆ¡}|ddˆ kS)NFrFgð?r¿rÀ)
r_rÐrèrLr{rCrærÁr¨Zastype)rUrÙZxinfidZyinfidr¨Úz©r½rørìZnpanyr÷rùr>r?Úcompare1s$ 
 
 
 
z*assert_array_almost_equal.<locals>.comparer»)r’r!r“r‡N)
rQr÷rørùrZnumpy.core.numerictypesrìZnumpy.core.fromnumericrúr3)rUrÙr½r’r!rOrrýr>rür?rÞsN   þc    Cs d}ttj||||ddddS)ag
    Raises an AssertionError if two array_like objects are not ordered by less
    than.
 
    Given two array_like objects, check that the shape is equal and all
    elements of the first object are strictly smaller than those of the
    second object. An exception is raised at shape mismatch or incorrectly
    ordered values. Shape mismatch does not raise if an object has zero
    dimension. In contrast to the standard usage in numpy, NaNs are
    compared, no assertion is raised if both objects have NaNs in the same
    positions.
 
 
 
    Parameters
    ----------
    x : array_like
      The smaller object to check.
    y : array_like
      The larger object to compare.
    err_msg : string
      The error message to be printed in case of failure.
    verbose : bool
        If True, the conflicting values are appended to the error message.
 
    Raises
    ------
    AssertionError
      If actual and desired objects are not equal.
 
    See Also
    --------
    assert_array_equal: tests objects for equality
    assert_array_almost_equal: test objects for equality up to precision
 
 
 
    Examples
    --------
    >>> np.testing.assert_array_less([1.0, 1.0, np.nan], [1.1, 2.0, np.nan])
    >>> np.testing.assert_array_less([1.0, 1.0, np.nan], [1, 2.0, np.nan])
    Traceback (most recent call last):
        ...
    AssertionError:
    Arrays are not less-ordered
    <BLANKLINE>
    Mismatched elements: 1 / 3 (33.3%)
    Max absolute difference: 1.
    Max relative difference: 0.5
     x: array([ 1.,  1., nan])
     y: array([ 1.,  2., nan])
 
    >>> np.testing.assert_array_less([1.0, 4.0], 3)
    Traceback (most recent call last):
        ...
    AssertionError:
    Arrays are not less-ordered
    <BLANKLINE>
    Mismatched elements: 1 / 2 (50%)
    Max absolute difference: 2.
    Max relative difference: 0.66666667
     x: array([1., 4.])
     y: array(3)
 
    >>> np.testing.assert_array_less([1.0, 2.0, 3.0], [4])
    Traceback (most recent call last):
        ...
    AssertionError:
    Arrays are not less-ordered
    <BLANKLINE>
    (shapes (3,), (1,) mismatch)
     x: array([1., 2., 3.])
     y: array([4])
 
    TzArrays are not less-orderedF)r’r!r“ròN)r3rõÚ__lt__)rUrÙr’r!rOr>r>r?rPs L ýcCst||ƒdSrà)Úexec)Zastrr r>r>r?r £sc Cs„d}ddl}t|tƒs&ttt|ƒƒƒ‚t|tƒs@ttt|ƒƒƒ‚||krLdSt| ¡ |     d¡|     d¡¡ƒ}g}|rP| 
d¡}|  d¡rŒqp|  d¡rB|g}| 
d¡}|  d¡rÆ|  |¡| 
d¡}|  d¡sÜtt|ƒƒ‚|  |¡|r| 
d¡}    |      d¡r|  |    ¡n |  d|    ¡|dd…|dd…kr6qp| |¡qptt|ƒƒ‚qp|sZdSd    d
 |¡ ¡›}
||kr€t|
ƒ‚dS) až
    Test if two strings are equal.
 
    If the given strings are equal, `assert_string_equal` does nothing.
    If they are not equal, an AssertionError is raised, and the diff
    between the strings is shown.
 
    Parameters
    ----------
    actual : str
        The string to test for equality against the expected string.
    desired : str
        The expected string.
 
    Examples
    --------
    >>> np.testing.assert_string_equal('abc', 'abc')
    >>> np.testing.assert_string_equal('abc', 'abcd')
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    ...
    AssertionError: Differences in strings:
    - abc+ abcd?    +
 
    TrNz  z- z? z+ ézDifferences in strings:
rK)ÚdifflibrRrîrMrŽrSr¢ZDifferrýr‘ÚpopÚ
startswithr€ÚinsertÚextendrÚrstrip) r­r®rOrÚdiffZ    diff_listÚd1rzZd2Zd3rIr>r>r?r§sP
 
ÿ
 
 
 
 
 
 
 
 
 
 
c sÂddlm}ddl}|dkr0t d¡}|jd}tj tj     |¡¡d}|||ƒ}| 
¡  |¡}|j dd}g‰|r‚‡fdd    „}    nd}    |D]}
|j |
|    d
qŠ|jdkr¾|r¾td d  ˆ¡ƒ‚dS) aV
    Run doctests found in the given file.
 
    By default `rundocs` raises an AssertionError on failure.
 
    Parameters
    ----------
    filename : str
        The path to the file for which the doctests are run.
    raise_on_error : bool
        Whether to raise an AssertionError when a doctest fails. Default is
        True.
 
    Notes
    -----
    The doctests can be run by the user/developer by adding the ``doctests``
    argument to the ``test()`` call. For example, to run all tests (including
    doctests) for `numpy.lib`:
 
    >>> np.lib.test(doctests=True)  # doctest: +SKIP
    r)Úexec_mod_from_locationNrFÚ__file__Fržcs
ˆ |¡Srà)r€)Ús©rIr>r?rDrEzrundocs.<locals>.<lambda>räzSome doctests failed:
%sr…)Znumpy.distutils.misc_utilr    ÚdoctestÚsysÚ    _getframeÚ    f_globalsÚosriÚsplitextÚbasenameZ DocTestFinderr‹Z DocTestRunnerÚrunZfailuresrMr) ÚfilenameZraise_on_errorr    r ryÚnameÚmÚtestsÚrunnerråÚtestr>r r?rîs" 
 
 
 cGstƒ}|jj|ŽS)aDecorator to check for raised exceptions.
 
    The decorated test function must raise one of the passed exceptions to
    pass.  If you want to test many assertions about exceptions in a single
    test, you may want to use `assert_raises` instead.
 
    .. warning::
       This decorator is nose specific, do not use it if you are using a
       different test framework.
 
    Parameters
    ----------
    args : exceptions
        The test passes if any of the passed exceptions is raised.
 
    Raises
    ------
    AssertionError
 
    Examples
    --------
 
    Usage::
 
        @raises(TypeError, ValueError)
        def test_raises_type_error():
            raise TypeError("This test passes")
 
        @raises(Exception)
        def test_that_fails_by_passing():
            pass
 
    )rJZtoolsr)r¬rGr>r>r?rs"c@seZdZdd„ZdS)Ú_DummycCsdSràr>)Úselfr>r>r?ÚnopHsz
_Dummy.nopN)r:r;r<rr>r>r>r?rGsrrcOsd}tj||ŽS)aá
    assert_raises(exception_class, callable, *args, **kwargs)
    assert_raises(exception_class)
 
    Fail unless an exception of class exception_class is thrown
    by callable when invoked with arguments args and keyword
    arguments kwargs. If a different type of exception is
    thrown, it will not be caught, and the test case will be
    deemed to have suffered an error, exactly as for an
    unexpected exception.
 
    Alternatively, `assert_raises` can be used as a context manager:
 
    >>> from numpy.testing import assert_raises
    >>> with assert_raises(ZeroDivisionError):
    ...     1 / 0
 
    is equivalent to
 
    >>> def div(x, y):
    ...     return x / y
    >>> assert_raises(ZeroDivisionError, div, 1, 0)
 
    T)Ú_dÚ assertRaises)r¬ÚkwargsrOr>r>r?rMscOsd}tj||f|ž|ŽS)aë
    assert_raises_regex(exception_class, expected_regexp, callable, *args,
                        **kwargs)
    assert_raises_regex(exception_class, expected_regexp)
 
    Fail unless an exception of class exception_class and with message that
    matches expected_regexp is thrown by callable when invoked with arguments
    args and keyword arguments kwargs.
 
    Alternatively, can be used as a context manager like `assert_raises`.
 
    Notes
    -----
    .. versionadded:: 1.9.0
 
    T)rÚassertRaisesRegex)Zexception_classZexpected_regexpr¬r rOr>r>r?r%jsc    s´|dkrt dtj¡}n
t |¡}|j}ddlm‰‡fdd„| ¡Dƒ}|D]^}zt|dƒrh|j    }n|j
}Wnt k
rˆYqPYnX|  |¡rP|  d¡sPt||||ƒƒqPdS)    a 
    Apply a decorator to all methods in a class matching a regular expression.
 
    The given decorator is applied to all public methods of `cls` that are
    matched by the regular expression `testmatch`
    (``testmatch.search(methodname)``). Methods that are private, i.e. start
    with an underscore, are ignored.
 
    Parameters
    ----------
    cls : class
        Class whose methods to decorate.
    decorator : function
        Decorator to apply to methods
    testmatch : compiled regexp or str, optional
        The regular expression. Default value is None, in which case the
        nose default (``re.compile(r'(?:^|[\b_\.%s-])[Tt]est' % os.sep)``)
        is used.
        If `testmatch` is a string, it is compiled to a regular expression
        first.
 
    Nz(?:^|[\\b_\\.%s-])[Tt]estr©Ú
isfunctioncsg|]}ˆ|ƒr|‘qSr>r>)Ú.0Ú_mr"r>r?Ú
<listcomp>Ÿsz$decorate_methods.<locals>.<listcomp>Úcompat_func_nameÚ_)ÚreÚcompilerÚsepÚ__dict__Úinspectr#ÚvaluesÚhasattrr'r:ÚAttributeErrorÚsearchrÚsetattr)ÚclsÚ    decoratorZ    testmatchZcls_attrÚmethodsÚfunctionÚfuncnamer>r"r?rs 
 
 
 
rFc    Csft d¡}|j|j}}t|d|›ddƒ}d}tƒ}||krT|d7}t|||ƒq6tƒ|}d|S)aG
    Return elapsed time for executing code in the namespace of the caller.
 
    The supplied code string is compiled with the Python builtin ``compile``.
    The precision of the timing is 10 milli-seconds. If the code will execute
    fast on this timescale, it can be executed many times to get reasonable
    timing accuracy.
 
    Parameters
    ----------
    code_str : str
        The code to be timed.
    times : int, optional
        The number of times the code is executed. Default is 1. The code is
        only compiled once.
    label : str, optional
        A label to identify `code_str` with. This is passed into ``compile``
        as the second argument (for run-time error messages).
 
    Returns
    -------
    elapsed : float
        Total elapsed time in seconds for executing `code_str` `times` times.
 
    Examples
    --------
    >>> times = 10
    >>> etime = np.testing.measure('for i in range(1000): np.sqrt(i**2)', times=times)
    >>> print("Time for a single execution : ", etime / times, "s")  # doctest: +SKIP
    Time for a single execution :  0.005 s
 
    rFz Test name: rqrÿrg{®Gáz„?)rrÚf_localsrr*rrÿ)    Zcode_strÚtimesÚlabelÚframeZlocsZglobsÚcoder•Úelapsedr>r>r?r"®s!
 
c    Cs„tsdSddl}ddl}| d¡ dd¡}|}d}| ¡z8t |¡}t    dƒD]}|||ƒ}qNt
t |¡|kƒW5| ¡X~dS)zg
    Check that ufuncs don't mishandle refcount of object `1`.
    Used in a few regression tests.
    TrNi'r~rFé) r0ÚgcrÄr ZreshapeÚdisableÚenablerrAr¤r#)    Úopr?rCÚbÚcr•ÚrcÚjÚdr>r>r?Ú_assert_valid_refcountÜs
 
rHçH¯¼šò×z>c
    sfd}ddl‰‡‡‡‡fdd„}ˆ |¡ˆ |¡}}dˆd›dˆd›}    t|||t|ƒ||    ˆd    dS)
añ
    Raises an AssertionError if two objects are not equal up to desired
    tolerance.
 
    Given two array_like objects, check that their shapes and all elements
    are equal (but see the Notes for the special handling of a scalar). An
    exception is raised if the shapes mismatch or any values conflict. In 
    contrast to the standard usage in numpy, NaNs are compared like numbers,
    no assertion is raised if both objects have NaNs in the same positions.
 
    The test is equivalent to ``allclose(actual, desired, rtol, atol)`` (note
    that ``allclose`` has different default values). It compares the difference
    between `actual` and `desired` to ``atol + rtol * abs(desired)``.
 
    .. versionadded:: 1.5.0
 
    Parameters
    ----------
    actual : array_like
        Array obtained.
    desired : array_like
        Array desired.
    rtol : float, optional
        Relative tolerance.
    atol : float, optional
        Absolute tolerance.
    equal_nan : bool, optional.
        If True, NaNs will compare equal.
    err_msg : str, optional
        The error message to be printed in case of failure.
    verbose : bool, optional
        If True, the conflicting values are appended to the error message.
 
    Raises
    ------
    AssertionError
        If actual and desired are not equal up to specified precision.
 
    See Also
    --------
    assert_array_almost_equal_nulp, assert_array_max_ulp
 
    Notes
    -----
    When one of `actual` and `desired` is a scalar and the other is
    array_like, the function checks that each element of the array_like
    object is equal to the scalar.
 
    Examples
    --------
    >>> x = [1e-5, 1e-3, 1e-1]
    >>> y = np.arccos(np.cos(x))
    >>> np.testing.assert_allclose(x, y, rtol=1e-5, atol=0)
 
    TrNcsˆjjj||ˆˆˆdS)N)ÚrtolÚatolrñ)ÚcoreÚnumericÚiscloserØ©rKrñrCrJr>r?rý2sÿz assert_allclose.<locals>.comparezNot equal to tolerance rtol=Úgz, atol=)r’r!r“rñ)rÄrær3rî)
r­r®rJrKrñr’r!rOrýr“r>rOr?r)ös9ÿc
Csšd}ddl}| |¡}| |¡}|| | ||k||¡¡}| | ||¡|k¡s–| |¡sh| |¡rrd|}n| t||ƒ¡}    d||    f}t|ƒ‚dS)aÚ
    Compare two arrays relatively to their spacing.
 
    This is a relatively robust method to compare two arrays whose amplitude
    is variable.
 
    Parameters
    ----------
    x, y : array_like
        Input arrays.
    nulp : int, optional
        The maximum number of unit in the last place for tolerance (see Notes).
        Default is 1.
 
    Returns
    -------
    None
 
    Raises
    ------
    AssertionError
        If the spacing between `x` and `y` for one or more elements is larger
        than `nulp`.
 
    See Also
    --------
    assert_array_max_ulp : Check that all items of arrays differ in at most
        N Units in the Last Place.
    spacing : Return the distance between x and the nearest adjacent number.
 
    Notes
    -----
    An assertion is raised if the following condition is not met::
 
        abs(x - y) <= nulp * spacing(maximum(abs(x), abs(y)))
 
    Examples
    --------
    >>> x = np.array([1., 1e-10, 1e-20])
    >>> eps = np.finfo(x.dtype).eps
    >>> np.testing.assert_array_almost_equal_nulp(x, x*eps/2 + x)
 
    >>> np.testing.assert_array_almost_equal_nulp(x, x*eps + x)
    Traceback (most recent call last):
      ...
    AssertionError: X and Y are not equal to 1 ULP (max is 2)
 
    TrNzX and Y are not equal to %d ULPz+X and Y are not equal to %d ULP (max is %g))    rÄrÁÚspacingÚwhererÐr›rÑÚ    nulp_diffrM)
rUrÙZnulprOrCZaxZayÚrefrIZmax_nulpr>r>r?r$<s1
 
 
 cCs@d}ddl}t|||ƒ}| ||k¡s<td|| |¡fƒ‚|S)ai
    Check that all items of arrays differ in at most N Units in the Last Place.
 
    Parameters
    ----------
    a, b : array_like
        Input arrays to be compared.
    maxulp : int, optional
        The maximum number of units in the last place that elements of `a` and
        `b` can differ. Default is 1.
    dtype : dtype, optional
        Data-type to convert `a` and `b` to if given. Default is None.
 
    Returns
    -------
    ret : ndarray
        Array containing number of representable floating point numbers between
        items in `a` and `b`.
 
    Raises
    ------
    AssertionError
        If one or more elements differ by more than `maxulp`.
 
    Notes
    -----
    For computing the ULP difference, this API does not differentiate between
    various representations of NAN (ULP difference between 0x7fc00000 and 0xffc00000
    is zero).
 
    See Also
    --------
    assert_array_almost_equal_nulp : Compare two arrays relatively to their
        spacing.
 
    Examples
    --------
    >>> a = np.linspace(0., 1., 100)
    >>> res = np.testing.assert_array_max_ulp(a, np.arcsin(np.sin(a)))
 
    TrNzCArrays are not almost equal up to %g ULP (max difference is %g ULP))rÄrSrÐrMrÑ)r–rCZmaxulpr¨rOrCÚretr>r>r?r&{s*  þcsîddl‰|r*ˆj||d}ˆj||d}nˆ |¡}ˆ |¡}ˆ ||¡}ˆ |¡s^ˆ |¡rftdƒ‚ˆj|g|d}ˆj|g|d}ˆj|ˆ |¡<ˆj|ˆ |¡<|j|jksÆt    d|j|jfƒ‚‡fdd„}t
|ƒ}t
|ƒ}||||ƒS)anFor each item in x and y, return the number of representable floating
    points between them.
 
    Parameters
    ----------
    x : array_like
        first input array
    y : array_like
        second input array
    dtype : dtype, optional
        Data-type to convert `x` and `y` to if given. Default is None.
 
    Returns
    -------
    nulp : array_like
        number of representable floating point numbers between each item in x
        and y.
 
    Notes
    -----
    For computing the ULP difference, this API does not differentiate between
    various representations of NAN (ULP difference between 0x7fc00000 and 0xffc00000
    is zero).
 
    Examples
    --------
    # By definition, epsilon is the smallest number such as 1 + eps != 1, so
    # there should be exactly one ULP between 1 and 1 + eps
    >>> nulp_diff(1, 1 + np.finfo(x.dtype).eps)
    1.0
    rNrãz'_nulp not implemented for complex arrayz+x and y do not have the same shape: %s - %scsˆj|||d}ˆ |¡S©Nrã)r§rÁ)ÚrxÚryÚvdtr©rCr>r?Ú_diffåsznulp_diff.<locals>._diff) rÄr§Z common_typer›r{rr×rPrçr¦Ú integer_repr)rUrÙr¨Útr[rWrXr>rZr?rS¯s* 
 
 
ÿ rScCsB| |¡}|jdks.|||dk||dk<n|dkr>||}|S)NrFr)Úviewrè)rUrYÚcomprWr>r>r?Ú _integer_reprîs 
 
r`cCs|ddl}|j|jkr(t||j| d¡ƒS|j|jkrHt||j| d¡ƒS|j|jkrht||j| d¡ƒSt    d|j›ƒ‚dS)zQReturn the signed-magnitude interpretation of the binary representation
    of x.rNi€ÿÿi€lûÿÿÿzUnsupported dtype )
rÄr¨Úfloat16r`Úint16r    Úint32rÂÚint64r¦)rUrCr>r>r?r\ýs   r\c    csXd}tƒD}| |¡}dVt|ƒdksJ|dk    r:d|›nd}td|ƒ‚W5QRXdS)NTrú when calling rKzNo warning raised)r2ÚrecordrŒrM)Ú warning_classrrOÚsuprzÚname_strr>r>r?Ú_assert_warns_context s
 rjc
OsP|s t|ƒS|d}|dd…}t||jd|||ŽW5QR£SQRXdS)a+
    Fail unless the given callable throws the specified warning.
 
    A warning of class warning_class should be thrown by the callable when
    invoked with arguments args and keyword arguments kwargs.
    If a different type of warning is thrown, it will not be caught.
 
    If called with all arguments other than the warning class omitted, may be
    used as a context manager:
 
        with assert_warns(SomeWarning):
            do_something()
 
    The ability to be used as a context manager is new in NumPy v1.11.0.
 
    .. versionadded:: 1.4.0
 
    Parameters
    ----------
    warning_class : class
        The class defining the warning that `func` is expected to throw.
    func : callable, optional
        Callable to test
    *args : Arguments
        Arguments for `func`.
    **kwargs : Kwargs
        Keyword arguments for `func`.
 
    Returns
    -------
    The value returned by `func`.
 
    Examples
    --------
    >>> import warnings
    >>> def deprecated_func(num):
    ...     warnings.warn("Please upgrade", DeprecationWarning)
    ...     return num*num
    >>> with np.testing.assert_warns(DeprecationWarning):
    ...     assert deprecated_func(4) == 16
    >>> # or passing a func
    >>> ret = np.testing.assert_warns(DeprecationWarning, deprecated_func, 4)
    >>> assert ret == 16
    rrFN©r)rjr:)rgr¬r rÝr>r>r?r's - c    csfd}tjddL}t d¡dVt|ƒdkrX|dk    r@d|›nd}td|›d|›ƒ‚W5QRXdS)    NT©rfÚalwaysrrerKz Got warningsrŠ)ÚwarningsÚcatch_warningsÚ simplefilterrŒrM)rrOrzrir>r>r?Ú_assert_no_warnings_contextLs
 rqc
OsL|s
tƒS|d}|dd…}t|jd|||ŽW5QR£SQRXdS)a:
    Fail if the given callable produces any warnings.
 
    If called with all arguments omitted, may be used as a context manager:
 
        with assert_no_warnings():
            do_something()
 
    The ability to be used as a context manager is new in NumPy v1.11.0.
 
    .. versionadded:: 1.7.0
 
    Parameters
    ----------
    func : callable
        The callable to test.
    \*args : Arguments
        Arguments passed to `func`.
    \*\*kwargs : Kwargs
        Keyword arguments passed to `func`.
 
    Returns
    -------
    The value returned by `func`.
 
    rrFNrk)rqr:©r¬r rÝr>r>r?r(Ws  Úbinaryéc
#sºd}d}tdƒD]¢‰tˆdtˆd|ƒƒD]‚‰|dkrt‡‡‡fdd„}tˆfˆdˆd    …}||ƒ|ˆˆˆˆd
ffV|ƒ}|||ˆˆˆˆd ffV|d d    …|ƒd    d …|ˆd ˆˆd ˆd
ffV|d    d …|ƒd d    …|ˆˆd ˆd ˆd
ffV|ƒd    d …|ƒd d    …|ˆˆd ˆd ˆdffV|ƒd d    …|ƒd    d …|ˆd ˆˆd ˆdffV|dkr.‡‡‡fdd„}‡‡‡fdd„}    tˆfˆdˆd    …}||ƒ|    ƒ|ˆˆˆˆˆd
ffV|ƒ}|||    ƒ|ˆˆˆˆˆdffV|    ƒ}||ƒ||ˆˆˆˆˆdffV|d d    …|ƒd    d …|    ƒd    d …|ˆd ˆˆˆd ˆd
ffV|d    d …|ƒd d    …|    ƒd    d …|ˆˆd ˆˆd ˆd
ffV|d    d …|ƒd    d …|    ƒd d    …|ˆˆˆd ˆd ˆd
ffV|ƒd d    …|ƒd    d …|    ƒd    d …|ˆd ˆˆˆd ˆdffV|ƒd    d …|ƒd d    …|    ƒd    d …|ˆˆd ˆˆd ˆdffV|ƒd    d …|ƒd    d …|    ƒd d    …|ˆˆˆd ˆd ˆdffVq.qd    S)aÓ
    generator producing data with different alignment and offsets
    to test simd vectorization
 
    Parameters
    ----------
    dtype : dtype
        data type to produce
    type : string
        'unary': create data for unary operations, creates one input
                 and output array
        'binary': create data for unary operations, creates two input
                 and output array
    max_size : integer
        maximum size of data to produce
 
    Returns
    -------
    if type is 'unary' yields one output, one input array and a message
    containing information on the data
    if type is 'binary' yields one output array, two input array and a message
    containing information on the data
 
    z,unary offset=(%d, %d), size=%d, dtype=%r, %sz1binary offset=(%d, %d, %d), size=%d, dtype=%r, %sr‰rZunarycstˆˆdˆd…SrV©r r>©r¨Úor r>r?rD™rEz%_gen_alignment_data.<locals>.<lambda>rãNz out of placezin placerFraÚaliasedrscstˆˆdˆd…SrVrur>rvr>r?rD§rEcstˆˆdˆd…SrVrur>rvr>r?rD¨rEz    in place1z    in place2)r¤rÑr
)
r¨rSÚmax_sizeZufmtZbfmtÚinprårGZinp1Zinp2r>rvr?Ú_gen_alignment_data{sn
ÿÿÿÿ ÿ
ÿ
ÿ$ÿ$ÿ$ÿ&ÿ&ÿ&ÿr{c@seZdZdZdS)r*z/Ignoring this exception due to disabled featureNr9r>r>r>r?r*Àsc    os&t||Ž}z
|VW5t |¡XdS)zContext manager to provide a temporary test folder.
 
    All arguments are passed as this to the underlying tempfile.mkdtemp
    function.
 
    N)rÚshutilÚrmtree)r¬r Ztmpdirr>r>r?r.Ås
 
c    os4t||Ž\}}t |¡z
|VW5t |¡XdS)açContext manager for temporary files.
 
    Context manager that returns the path to a closed temporary file. Its
    parameters are the same as for tempfile.mkstemp and are passed directly
    to that function. The underlying file is removed when the context is
    exited, so it should be closed at that time.
 
    Windows does not allow a temporary file to be opened if it is already
    open, so the underlying file must be closed after opening before it
    can be opened again.
 
    N)rrÚcloseÚremove)r¬r Úfdrir>r>r?r-Ôs
 
 
cs>eZdZdZdZd
‡fdd„    Z‡fdd„Z‡fdd    „Z‡ZS) r+a< Context manager that resets warning registry for catching warnings
 
    Warnings can be slippery, because, whenever a warning is triggered, Python
    adds a ``__warningregistry__`` member to the *calling* module.  This makes
    it impossible to retrigger the warning in this module, whatever you put in
    the warnings filters.  This context manager accepts a sequence of `modules`
    as a keyword argument to its constructor and:
 
    * stores and removes any ``__warningregistry__`` entries in given `modules`
      on entry;
    * resets ``__warningregistry__`` to its previous state on exit.
 
    This makes it possible to trigger any warning afresh inside the context
    manager without disturbing the state of warnings outside.
 
    For compatibility with Python 3.0, please consider all arguments to be
    keyword-only.
 
    Parameters
    ----------
    record : bool, optional
        Specifies whether warnings should be captured by a custom
        implementation of ``warnings.showwarning()`` and be appended to a list
        returned by the context manager. Otherwise None is returned by the
        context manager. The objects appended to the list are arguments whose
        attributes mirror the arguments to ``showwarning()``.
    modules : sequence, optional
        Sequence of modules for which to reset warnings registry on entry and
        restore on exit. To work correctly, all 'ignore' filters should
        filter by one of these modules.
 
    Examples
    --------
    >>> import warnings
    >>> with np.testing.clear_and_catch_warnings(
    ...         modules=[np.core.fromnumeric]):
    ...     warnings.simplefilter('always')
    ...     warnings.filterwarnings('ignore', module='np.core.fromnumeric')
    ...     # do something that raises a warning but ignore those in
    ...     # np.core.fromnumeric
    r>Fcs*t|ƒ |j¡|_i|_tƒj|ddS)Nrl)ÚsetÚunionÚ class_modulesÚmodulesÚ_warnreg_copiesÚsuperÚ__init__)rrfr„©Ú    __class__r>r?r‡sz!clear_and_catch_warnings.__init__cs<|jD]*}t|dƒr|j}| ¡|j|<| ¡qtƒ ¡S©NÚ__warningregistry__)r„r/r‹Úcopyr…Úclearr†Ú    __enter__)rÚmodZmod_regrˆr>r?rŽs 
 
 
z"clear_and_catch_warnings.__enter__csLtƒj|Ž|jD]4}t|dƒr*|j ¡||jkr|j |j|¡qdSrŠ)r†Ú__exit__r„r/r‹rr…Úupdate)rÚexc_inforrˆr>r?r#s  
 
 
 
z!clear_and_catch_warnings.__exit__)Fr>)    r:r;r<r=rƒr‡rŽrÚ __classcell__r>r>rˆr?r+ês
) c@szeZdZdZddd„Zdd„Zeddd    fd
d „Zeddfd d „Zeddfdd„Z    dd„Z
dd„Z ddœdd„Z dd„Z dS)r2aÙ
    Context manager and decorator doing much the same as
    ``warnings.catch_warnings``.
 
    However, it also provides a filter mechanism to work around
    https://bugs.python.org/issue4180.
 
    This bug causes Python before 3.4 to not reliably show warnings again
    after they have been ignored once (even within catch_warnings). It
    means that no "ignore" filter can be used easily, since following
    tests might need to see the warning. Additionally it allows easier
    specificity for testing warnings and can be nested.
 
    Parameters
    ----------
    forwarding_rule : str, optional
        One of "always", "once", "module", or "location". Analogous to
        the usual warnings module filter mode, it is useful to reduce
        noise mostly on the outmost level. Unsuppressed and unrecorded
        warnings will be forwarded based on this rule. Defaults to "always".
        "location" is equivalent to the warnings "default", match by exact
        location the warning warning originated from.
 
    Notes
    -----
    Filters added inside the context manager will be discarded again
    when leaving it. Upon entering all filters defined outside a
    context will be applied automatically.
 
    When a recording filter is added, matching warnings are stored in the
    ``log`` attribute as well as in the list returned by ``record``.
 
    If filters are added and the ``module`` keyword is given, the
    warning registry of this module will additionally be cleared when
    applying it, entering the context, or exiting it. This could cause
    warnings to appear a second time after leaving the context if they
    were configured to be printed once (default) and were already
    printed before the context was entered.
 
    Nesting this context manager will work as expected when the
    forwarding rule is "always" (default). Unfiltered and unrecorded
    warnings will be passed out and be matched by the outer level.
    On the outmost level they will be printed (or caught by another
    warnings context). The forwarding rule argument can modify this
    behaviour.
 
    Like ``catch_warnings`` this context manager is not threadsafe.
 
    Examples
    --------
 
    With a context manager::
 
        with np.testing.suppress_warnings() as sup:
            sup.filter(DeprecationWarning, "Some text")
            sup.filter(module=np.ma.core)
            log = sup.record(FutureWarning, "Does this occur?")
            command_giving_warnings()
            # The FutureWarning was given once, the filtered warnings were
            # ignored. All other warnings abide outside settings (may be
            # printed/error)
            assert_(len(log) == 1)
            assert_(len(sup.log) == 1)  # also stored in log attribute
 
    Or as a decorator::
 
        sup = np.testing.suppress_warnings()
        sup.filter(module=np.ma.core)  # module must match exactly
        @sup
        def some_function():
            # do something which causes a warning in np.ma.core
            pass
    rmcCs&d|_g|_|dkrtdƒ‚||_dS)NF>ÚmodulermÚonceÚlocationzunsupported forwarding rule.)Ú_enteredÚ _suppressionsr¦Ú_forwarding_rule)rZforwarding_ruler>r>r?r‡vs
zsuppress_warnings.__init__cCs:ttdƒrt ¡dS|jD]}t|dƒr|j ¡qdS)NÚ_filters_mutatedr‹)r/rnršÚ _tmp_modulesr‹r)rr”r>r>r?Ú_clear_registries€s 
 
 
z#suppress_warnings._clear_registriesrKNFcCs¬|r
g}nd}|jrˆ|dkr.tjd||dn8|j dd¡d}tjd|||d|j |¡| ¡|j     ||t
  |t
j ¡||f¡n |j      ||t
  |t
j ¡||f¡|S)Nrm©ÚcategoryÚmessageÚ.ú\.ú$©ržrŸr”)r—rnÚfilterwarningsr:Úreplacer›ÚaddrœÚ_tmp_suppressionsr€r)r*ÚIr˜)rržrŸr”rfÚ module_regexr>r>r?Ú_filterŒs4ÿþ ÿÿzsuppress_warnings._filtercCs|j|||dddS)a§
        Add a new suppressing filter or apply it if the state is entered.
 
        Parameters
        ----------
        category : class, optional
            Warning class to filter
        message : string, optional
            Regular expression matching the warning message.
        module : module, optional
            Module to filter for. Note that the module (and its file)
            must match exactly and cannot be a submodule. This may make
            it unreliable for external modules.
 
        Notes
        -----
        When added within a context, filters are only added inside
        the context and will be forgotten when the context is exited.
        F©ržrŸr”rfN©rª©rržrŸr”r>r>r?Úfilter¥s
ÿzsuppress_warnings.filtercCs|j|||ddS)ai
        Append a new recording filter or apply it if the state is entered.
 
        All warnings matching will be appended to the ``log`` attribute.
 
        Parameters
        ----------
        category : class, optional
            Warning class to filter
        message : string, optional
            Regular expression matching the warning message.
        module : module, optional
            Module to filter for. Note that the module (and its file)
            must match exactly and cannot be a submodule. This may make
            it unreliable for external modules.
 
        Returns
        -------
        log : list
            A list which will be filled with all matched warnings.
 
        Notes
        -----
        When added within a context, filters are only added inside
        the context and will be forgotten when the context is exited.
        Tr«r¬r­r>r>r?rf¼s
ÿzsuppress_warnings.recordcCsÖ|jrtdƒ‚tj|_tj|_|jdd…t_d|_g|_tƒ|_    tƒ|_
g|_ |j D]j\}}}}}|dk    rv|dd…=|dkrtj d||dqV|j dd¡d}tj d|||d|j     |¡qV|jt_| ¡|S)    Nz%cannot enter suppress_warnings twice.Trmrr r¡r¢r£)r—Ú RuntimeErrorrnÚ showwarningÚ
_orig_showÚfiltersÚ_filtersr§rr›Ú
_forwardedÚlogr˜r¤r:r¥r¦Ú _showwarningrœ)rÚcatZmessr(rrµr©r>r>r?rŽÚs<
ÿþzsuppress_warnings.__enter__cGs*|jt_|jt_| ¡d|_|`|`dS)NF)r±rnr°r³r²rœr—)rr’r>r>r?rús zsuppress_warnings.__exit__)Ú use_warnmsgcOsš|j|jddd…D]¬\}}    }
} } t||ƒr|
 |jd¡dk    r| dkr€| dk    rzt||||f|Ž} |j | ¡|  | ¡dS| j     |¡r| dk    r¼t||||f|Ž} |j | ¡|  | ¡dSq|j
dkr|dkrò|j ||||f|ž|Žn
|  |¡dS|j
dkr|j|f}n4|j
dkr2|j||f}n|j
dkrL|j|||f}||j kr\dS|j  |¡|dkrŒ|j ||||f|ž|Žn
|  |¡dS)Nrarrmr•r”r–)r˜r§Ú
issubclassÚmatchr¬rrµr€r
rr™r±Z _orig_showmsgr´r¦)rrŸržrÚlinenor¸r¬r r·r(ÚpatternrZrecrIÚ    signaturer>r>r?r¶    sd
ÿÿ
ÿÿÿ 
 ÿÿ 
 ÿÿ
 
ÿzsuppress_warnings._showwarningcstˆƒ‡‡fdd„ƒ}|S)z_
        Function decorator to apply certain suppressions to a whole
        function.
        c
s&ˆˆ||ŽW5QR£SQRXdSràr>)r¬r ©rÝrr>r?Únew_func:    sz,suppress_warnings.__call__.<locals>.new_func©r)rrÝr¿r>r¾r?Ú__call__5    szsuppress_warnings.__call__)rm)r:r;r<r=r‡rœÚWarningrªr®rfrŽrr¶rÁr>r>r>r?r2,sI
 
      ÿ 3c
csèd}tsdVdStt ¡ƒt ¡t ¡}zRt    dƒD]}t 
¡dkr8qVq8t dƒ‚t tj ¡dVt 
¡}tjdd…}W5tjdd…=t |¡t ¡X|rä|dk    r¸d|›nd}t d ||t|ƒd dd    „|Dƒ¡¡ƒ‚dS)
NTr~rz]Unable to fully collect garbage - perhaps a __del__ method is creating more reference cycles?rerKzXReference cycles were found{}: {} objects were collected, of which {} are shown below:{}c    ss4|],}d t|ƒjt|ƒt |¡ dd¡¡VqdS)z
  {} object with id={}:
    {}r…z
    N)rgrSr:Úidr¶Úpformatr¥)r$rwr>r>r?Ú    <genexpr>k    s üýz/_assert_no_gc_cycles_context.<locals>.<genexpr>)r0r#r?Ú    isenabledr@Z    get_debugÚgarbageZ    set_debugrAr¤Úcollectr¯Z DEBUG_SAVEALLrMrgrŒr)rrOZgc_debugr•Zn_objects_in_cyclesZobjects_in_cyclesrir>r>r?Ú_assert_no_gc_cycles_contextB    sB   ÿ  
 
 
ûúÿrÉc    OsD|s
tƒS|d}|dd…}t|jd|||ŽW5QRXdS)a3
    Fail if the given callable produces any reference cycles.
 
    If called with all arguments omitted, may be used as a context manager:
 
        with assert_no_gc_cycles():
            do_something()
 
    .. versionadded:: 1.15.0
 
    Parameters
    ----------
    func : callable
        The callable to test.
    \*args : Arguments
        Arguments passed to `func`.
    \*\*kwargs : Kwargs
        Keyword arguments passed to `func`.
 
    Returns
    -------
    Nothing. The result is deliberately discarded to ensure that all cycles
    are found.
 
    rrFNrk)rÉr:rrr>r>r?r4v    s  cCs0t ¡tr,t ¡t ¡t ¡t ¡dS)a1
    Break reference cycles by calling gc.collect
    Objects can call other objects' methods (for instance, another object's
     __del__) inside their own __del__. On PyPy, the interpreter only runs
    between calls to gc.collect, so multiple calls are needed to completely
    release all cycles.
    N)r?rÈr/r>r>r>r?r5˜    s     csddl‰‡‡fdd„}|S)z:Decorator to skip a test if not enough memory is availablerNcstˆƒ‡‡‡fdd„ƒ}|S)NcsJtˆƒ}|dk    rˆ |¡z ˆ||ŽWStk
rDˆ d¡YnXdS)NzMemoryError raised)Úcheck_free_memoryÚskipÚ MemoryErrorZxfail)r–ÚkwrI)Ú
free_bytesrÝÚpytestr>r?Úwrapper¯    s
 z3requires_memory.<locals>.decorator.<locals>.wrapperrÀ©rÝrЩrÎrÏ©rÝr?r4®    s z"requires_memory.<locals>.decorator)rÏ)rÎr4r>rÒr?Úrequires_memoryª    srÔc
Cs²d}tj |¡}|dk    rrz t|ƒ}Wn6tk
rZ}ztd|›d|›ƒ‚W5d}~XYnX|d›d|›d}n0tƒ}|dkrŠd}d    }n|d›d
|d›d }||kr®|SdS) zŽ
    Check whether `free_bytes` amount of memory is currently free.
    Returns: None if enough memory available, otherwise error message
    ZNPY_AVAILABLE_MEMNzInvalid environment variable rŠgeÍÍAz@ GB memory required, but environment variable NPY_AVAILABLE_MEM=z setzCould not determine available memory; set NPY_AVAILABLE_MEM environment variable (e.g. NPY_AVAILABLE_MEM=16GB) to run the test.raz GB memory required, but z  GB available)rÚenvironÚgetÚ _parse_sizer¦Ú_get_mem_available)rÎÚenv_varZ    env_valueZmem_freer—rIr>r>r?rÊÀ    s  &rÊcCsdddddddddddddd    d
œ}t d  d  | ¡¡¡tj¡}| | ¡¡}|r`| d ¡|krpt    d|›dƒ‚t
t | d¡ƒ|| d ¡ƒS)z3Convert memory size strings ('12 GB' etc.) to floatrFièi@Biʚ;lJ)£éii@l)rKrCr¯rrPr]ÚkbÚmbÚgbÚtbZkibZmibZgibZtibz^\s*(\d+|\d+\.\d+)\s*({0})\s*$ú|rzvalue z not a valid size) r)r*rgrÚkeysr¨rºÚlowerÚgroupr¦rvrÆ)Zsize_strÚsuffixesZsize_rerr>r>r?r×Ý    s.ý ÿÿr×c    Cs¬zddl}| ¡jWSttfk
r,YnXtj d¡r¨i}tddƒ:}|D].}|     ¡}t
|dƒd||d  d¡  ¡<qNW5QRXd    |kr˜|d    S|d
|d SdS) z5Return available memory in bytes, or None if unknown.rNroz /proc/meminforprFrÚú:Z memavailableZmemfreeÚcached) ÚpsutilZvirtual_memoryÚ    availablerHr0rÚplatformrrsrurvÚstriprá)ræÚinforyÚlineÚpr>r>r?rØí    s   .rØcs*ttdƒsˆStˆƒ‡fdd„ƒ}|SdS)zµ
    Decorator to temporarily turn off tracing for the duration of a test.
    Needed in tests that check refcounting, otherwise the tracing itself
    influences the refcounts
    Úgettracec    s2t ¡}zt d¡ˆ||ŽW¢St |¡XdSrà)rríÚsettrace)r¬r Zoriginal_tracerÓr>r?rÐ
s
 
z_no_tracing.<locals>.wrapperN)r/rrrÑr>rÓr?Ú _no_tracing
s
 
rïc
CsDzt d¡ d¡d}Wn&tk
r>}zd}W5d}~XYnX|S)NÚCS_GNU_LIBC_VERSIONrqrFú0.0)rÚconfstrÚrsplitrw)ÚverÚinstr>r>r?Ú_get_glibc_version
s
röcCstdkot|kS)Nrñ)Ú    _glibcverrÔr>r>r?rD#
rE)rK)NraNN)rkr)r‚Trƒr„)rKT)rºrKT)rºrKT)rKTrKrËTT)rKT)rËrKT)rKT)NT)N)rFN)rIrTrKT)rF)rFN)N)N)N)N)rr=rrrèr)r?rõrnÚ    functoolsrrr|rêÚtempfilerrZ unittest.caserrr¶rÄrCrQrr    r
r r r rrZnumpy.linalg.lapack_liteÚiorÚ__all__rwr,ZKnownFailureTestr!rhr1Úimplementationrr/r/r7rír0ZlinalgZ lapack_liteZ_ilp64r6r8rJr#rWr]r_rjrÚgetpidrrrrZ_no_nep50_warningrrr3rrrr rrrZunittestZTestCaserrrr%rr"rHr)r$r&rSr`r\Úcontextmanagerrjr'rqr(r{r*r.r-ror+r2rÉr4r5rÔrÊr×rØrïrör÷Z_glibc_older_thanr>r>r>r?Ú<module>sB  ( ô  
 
 
 ÿ
   ÿ
 
!) ~ cÿþ&u q
SG
.(
/
.ÿ
F
?
4
?
6
$E
 
B 3"