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
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
U
O±d‡9ãZ@sÂddlZddlZddlZddlZddlZddlZddlZddlm    Z    ddl    m
Z
m Z m Z m Z mZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z,m-Z-m.Z.m/Z/m0Z0m1Z1m2Z2m3Z3m4Z4m5Z5m6Z6m7Z7m8Z8m9Z9m:Z:ddlm;Z;ddlm<Z<ddlm=Z=ddl;m>Z>m?Z?dd    l<m@Z@mAZAmBZBmCZCmDZDdd
lmEZEdd lEmFZFmGZGmHZHmIZImJZJmKZKdd lLmMZMmNZNdd lOmPZPmQZQeAZReSeBƒZTdZUejVe;jWddZWddddddddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9d:d;d<d=d>d?d@dAdBdCdDdEdFdGdHdIdJdKdLdMdNdOdPdQdRdSdTdUdVdWdXdYdZd[d\d]d^d_d`dadbdcdddedfdgdhdigZZXe?dƒGdjd^„d^eYƒƒZZdÍdkdl„Z[eWe[ƒdÎdod2„ƒZ\dÏddpœdqdr„Z]e>e?dƒdÐddpœdtdI„ƒƒZ^eWe]dndue^ƒZ_dÑdvdw„Z`eWe`ƒdÒdxd3„ƒZadÓddpœdydz„Zbe>e?dƒdÔddpœd{d_„ƒƒZceWebdnduecƒZddÕd|d}„ZeeWeeƒdÖd~d`„ƒZfd×ddœd€d„ZgeWegƒdØd‚dœdƒd„ƒZhe?dƒd„d0„ƒZid…d†„ZjeWejƒd‡d&„ƒZkdˆd‰„ZleWelƒdŠdN„ƒZmdÙd‹dŒ„ZneWenƒdÚdŽd4„ƒZodÛdd„ZpeWepƒdÜd‘d5„ƒZqdÝd’d“„ZreWerƒdÞd”d8„ƒZsdßd•d–„ZteWetƒdàd˜d>„ƒZudád™dš„ZveWevƒdâd›d:„ƒZwdãdœd„ZxeWexƒdädžd;„ƒZydådŸd „Zzd¡d¢„Z{eWe{ƒd£d<„ƒZ|dæd¤d¥„Z}eWe}ƒdçd§d=„ƒZ~ejd¨kZ€e?dƒed‚fd©dC„ƒZ‚dddªœd«d¬„Zƒe>e?dƒe„ddªœd­dD„ƒƒZ…eWeƒdndue…ƒZ†d®d¯„Z‡e?dƒd°dF„ƒZˆe?dƒdèd±dG„ƒZ‰e?dƒdéd²dH„ƒZŠd³d´„Z‹dêddpœdµd¶„ZŒe>e?dƒdëddpœd·dJ„ƒƒZeWeŒdndueƒZŽdìd¸d¹„ZeWeƒdíd¼dK„ƒZdîd½d¾„Z‘eWe‘ƒdïd¿dE„ƒZ’dðdÀdÁ„Z“eWe“ƒdñdÂdA„ƒZ”dÃdĄZ•eWe•ƒdÅdB„ƒZ–eCZ—Z˜Z™ZšeDZ›ZœeKd‚ƒZeKdnƒZždÆdDŽZŸddÈl<TddÈlETddÉlm Z ddÈl TddÊlm¡Z¡ddÈl¡TddËlm¢Z¢ddÈl¢TddÌlmOZOddÈlOTeŸe ƒeŸe<ƒeŸeEƒeŸe¡ƒeŸe¢ƒeŸeOƒdS)òéNé)Ú
multiarray)1ÚfastCopyAndTransposeÚ ALLOW_THREADSÚBUFSIZEÚCLIPÚMAXDIMSÚMAY_SHARE_BOUNDSÚMAY_SHARE_EXACTÚRAISEÚWRAPÚarangeÚarrayÚasarrayÚ
asanyarrayÚascontiguousarrayÚasfortranarrayÚ    broadcastÚcan_castÚcompare_chararraysÚ concatenateÚcopytoÚdotÚdtypeÚemptyÚ
empty_likeÚflatiterÚ
frombufferÚ from_dlpackÚfromfileÚfromiterÚ
fromstringÚinnerÚlexsortÚmatmulÚmay_share_memoryÚmin_scalar_typeÚndarrayÚnditerÚ nested_itersÚ promote_typesÚputmaskÚ result_typeÚset_numeric_opsÚ shares_memoryÚvdotÚwhereÚzerosÚnormalize_axis_indexÚ_get_promotion_stateÚ_set_promotion_state)Ú    overrides)Úumath)Ú
shape_base)Úset_array_function_like_docÚ
set_module)ÚmultiplyÚinvertÚsinÚPINFÚNAN)Ú numerictypes)ÚlonglongÚintcÚint_Úfloat_Úcomplex_Úbool_)Ú TooHardErrorÚ    AxisError)ÚerrstateÚ_no_nep50_warningÚnumpy)ÚmoduleÚnewaxisr'rr(r)Úufuncr rrrrrr1Ú count_nonzerorrrr!rrrr0Úargwhererrrr#r-rr*r&r,Ú    isfortranrÚ
zeros_likeÚ    ones_likeÚ    correlateÚconvolver"rÚouterr/ÚrollÚrollaxisÚmoveaxisÚcrossÚ    tensordotÚ little_endianr Ú array_equalÚ array_equivÚindicesÚ fromfunctionÚiscloseÚisscalarÚ binary_reprÚ    base_reprÚonesÚidentityÚallcloserr+Ú flatnonzeroÚInfÚinfÚinftyÚInfinityÚnanÚNaNÚFalse_ÚTrue_Ú bitwise_notrr r rrrÚComplexWarningÚfullÚ    full_liker$r.r%r    r
rFrGr3r4c@seZdZdZdS)rqzß
    The warning raised when casting a complex dtype to a real dtype.
 
    As implemented, casting a complex number to a real discards its imaginary
    part, but this behavior may not be what the user actually wants.
 
    N)Ú__name__Ú
__module__Ú __qualname__Ú__doc__©rxrxúId:\z\workplace\vscode\pyvenv\venv\Lib\site-packages\numpy/core/numeric.pyrq=scCs|fS©Nrx©ÚarÚorderÚsubokÚshaperxrxryÚ_zeros_like_dispatcherIsr€ÚKTcCs4t|||||d}td|jd}tj||dd|S)a
    Return an array of zeros with the same shape and type as a given array.
 
    Parameters
    ----------
    a : array_like
        The shape and data-type of `a` define these same attributes of
        the returned array.
    dtype : data-type, optional
        Overrides the data type of the result.
 
        .. versionadded:: 1.6.0
    order : {'C', 'F', 'A', or 'K'}, optional
        Overrides the memory layout of the result. 'C' means C-order,
        'F' means F-order, 'A' means 'F' if `a` is Fortran contiguous,
        'C' otherwise. 'K' means match the layout of `a` as closely
        as possible.
 
        .. versionadded:: 1.6.0
    subok : bool, optional.
        If True, then the newly created array will use the sub-class
        type of `a`, otherwise it will be a base-class array. Defaults
        to True.
    shape : int or sequence of ints, optional.
        Overrides the shape of the result. If order='K' and the number of
        dimensions is unchanged, will try to keep order, otherwise,
        order='C' is implied.
 
        .. versionadded:: 1.17.0
 
    Returns
    -------
    out : ndarray
        Array of zeros with the same shape and type as `a`.
 
    See Also
    --------
    empty_like : Return an empty array with shape and type of input.
    ones_like : Return an array of ones with shape and type of input.
    full_like : Return a new array with shape of input filled with value.
    zeros : Return a new array setting values to zero.
 
    Examples
    --------
    >>> x = np.arange(6)
    >>> x = x.reshape((2, 3))
    >>> x
    array([[0, 1, 2],
           [3, 4, 5]])
    >>> np.zeros_like(x)
    array([[0, 0, 0],
           [0, 0, 0]])
 
    >>> y = np.arange(3, dtype=float)
    >>> y
    array([0., 1., 2.])
    >>> np.zeros_like(y)
    array([0.,  0.,  0.])
 
    ©rr}r~rr©rÚunsafe©Zcasting)rr1rrr)r|rr}r~rÚresÚzrxrxryrQMs>)ÚlikecCs|fSrzrx)rrr}rˆrxrxryÚ_ones_dispatcher’sr‰ÚCcCs8|dk    rt||||dSt|||ƒ}tj|ddd|S)aÈ
    Return a new array of given shape and type, filled with ones.
 
    Parameters
    ----------
    shape : int or sequence of ints
        Shape of the new array, e.g., ``(2, 3)`` or ``2``.
    dtype : data-type, optional
        The desired data-type for the array, e.g., `numpy.int8`.  Default is
        `numpy.float64`.
    order : {'C', 'F'}, optional, default: C
        Whether to store multi-dimensional data in row-major
        (C-style) or column-major (Fortran-style) order in
        memory.
    ${ARRAY_FUNCTION_LIKE}
 
        .. versionadded:: 1.20.0
 
    Returns
    -------
    out : ndarray
        Array of ones with the given shape, dtype, and order.
 
    See Also
    --------
    ones_like : Return an array of ones with shape and type of input.
    empty : Return a new uninitialized array.
    zeros : Return a new array setting values to zero.
    full : Return a new array of given shape filled with value.
 
 
    Examples
    --------
    >>> np.ones(5)
    array([1., 1., 1., 1., 1.])
 
    >>> np.ones((5,), dtype=int)
    array([1, 1, 1, 1, 1])
 
    >>> np.ones((2, 1))
    array([[1.],
           [1.]])
 
    >>> s = (2,2)
    >>> np.ones(s)
    array([[1.,  1.],
           [1.,  1.]])
 
    N©rr}rˆrr„r…)Ú_ones_with_likerrr)rrr}rˆr|rxrxryrd–s
4 )Zuse_likecCs|fSrzrxr{rxrxryÚ_ones_like_dispatcher×srcCs&t|||||d}tj|ddd|S)a
    Return an array of ones with the same shape and type as a given array.
 
    Parameters
    ----------
    a : array_like
        The shape and data-type of `a` define these same attributes of
        the returned array.
    dtype : data-type, optional
        Overrides the data type of the result.
 
        .. versionadded:: 1.6.0
    order : {'C', 'F', 'A', or 'K'}, optional
        Overrides the memory layout of the result. 'C' means C-order,
        'F' means F-order, 'A' means 'F' if `a` is Fortran contiguous,
        'C' otherwise. 'K' means match the layout of `a` as closely
        as possible.
 
        .. versionadded:: 1.6.0
    subok : bool, optional.
        If True, then the newly created array will use the sub-class
        type of `a`, otherwise it will be a base-class array. Defaults
        to True.
    shape : int or sequence of ints, optional.
        Overrides the shape of the result. If order='K' and the number of
        dimensions is unchanged, will try to keep order, otherwise,
        order='C' is implied.
 
        .. versionadded:: 1.17.0
 
    Returns
    -------
    out : ndarray
        Array of ones with the same shape and type as `a`.
 
    See Also
    --------
    empty_like : Return an empty array with shape and type of input.
    zeros_like : Return an array of zeros with shape and type of input.
    full_like : Return a new array with shape of input filled with value.
    ones : Return a new array setting values to one.
 
    Examples
    --------
    >>> x = np.arange(6)
    >>> x = x.reshape((2, 3))
    >>> x
    array([[0, 1, 2],
           [3, 4, 5]])
    >>> np.ones_like(x)
    array([[1, 1, 1],
           [1, 1, 1]])
 
    >>> y = np.arange(3, dtype=float)
    >>> y
    array([0., 1., 2.])
    >>> np.ones_like(y)
    array([1.,  1.,  1.])
 
    r‚rr„r…©rrr)r|rr}r~rr†rxrxryrRÛs>cCs|fSrzrx)rÚ
fill_valuerr}rˆrxrxryÚ_full_dispatchersrcCsP|dk    rt|||||dS|dkr0t|ƒ}|j}t|||ƒ}tj||dd|S)aØ
    Return a new array of given shape and type, filled with `fill_value`.
 
    Parameters
    ----------
    shape : int or sequence of ints
        Shape of the new array, e.g., ``(2, 3)`` or ``2``.
    fill_value : scalar or array_like
        Fill value.
    dtype : data-type, optional
        The desired data-type for the array  The default, None, means
         ``np.array(fill_value).dtype``.
    order : {'C', 'F'}, optional
        Whether to store multidimensional data in C- or Fortran-contiguous
        (row- or column-wise) order in memory.
    ${ARRAY_FUNCTION_LIKE}
 
        .. versionadded:: 1.20.0
 
    Returns
    -------
    out : ndarray
        Array of `fill_value` with the given shape, dtype, and order.
 
    See Also
    --------
    full_like : Return a new array with shape of input filled with value.
    empty : Return a new uninitialized array.
    ones : Return a new array setting values to one.
    zeros : Return a new array setting values to zero.
 
    Examples
    --------
    >>> np.full((2, 2), np.inf)
    array([[inf, inf],
           [inf, inf]])
    >>> np.full((2, 2), 10)
    array([[10, 10],
           [10, 10]])
 
    >>> np.full((2, 2), [1, 2])
    array([[1, 2],
           [1, 2]])
 
    Nr‹r„r…)Ú_full_with_likerrrrr)rrrr}rˆr|rxrxryrr"s0 cCs|fSrzrx)r|rrr}r~rrxrxryÚ_full_like_dispatcherbsr’cCs&t|||||d}tj||dd|S)af
    Return a full array with the same shape and type as a given array.
 
    Parameters
    ----------
    a : array_like
        The shape and data-type of `a` define these same attributes of
        the returned array.
    fill_value : array_like
        Fill value.
    dtype : data-type, optional
        Overrides the data type of the result.
    order : {'C', 'F', 'A', or 'K'}, optional
        Overrides the memory layout of the result. 'C' means C-order,
        'F' means F-order, 'A' means 'F' if `a` is Fortran contiguous,
        'C' otherwise. 'K' means match the layout of `a` as closely
        as possible.
    subok : bool, optional.
        If True, then the newly created array will use the sub-class
        type of `a`, otherwise it will be a base-class array. Defaults
        to True.
    shape : int or sequence of ints, optional.
        Overrides the shape of the result. If order='K' and the number of
        dimensions is unchanged, will try to keep order, otherwise,
        order='C' is implied.
 
        .. versionadded:: 1.17.0
 
    Returns
    -------
    out : ndarray
        Array of `fill_value` with the same shape and type as `a`.
 
    See Also
    --------
    empty_like : Return an empty array with shape and type of input.
    ones_like : Return an array of ones with shape and type of input.
    zeros_like : Return an array of zeros with shape and type of input.
    full : Return a new array of given shape filled with value.
 
    Examples
    --------
    >>> x = np.arange(6, dtype=int)
    >>> np.full_like(x, 1)
    array([1, 1, 1, 1, 1, 1])
    >>> np.full_like(x, 0.1)
    array([0, 0, 0, 0, 0, 0])
    >>> np.full_like(x, 0.1, dtype=np.double)
    array([0.1, 0.1, 0.1, 0.1, 0.1, 0.1])
    >>> np.full_like(x, np.nan, dtype=np.double)
    array([nan, nan, nan, nan, nan, nan])
 
    >>> y = np.arange(6, dtype=np.double)
    >>> np.full_like(y, 0.1)
    array([0.1, 0.1, 0.1, 0.1, 0.1, 0.1])
 
    >>> y = np.zeros([2, 2, 3], dtype=int)
    >>> np.full_like(y, [0, 0, 255])
    array([[[  0,   0, 255],
            [  0,   0, 255]],
           [[  0,   0, 255],
            [  0,   0, 255]]])
    r‚r„r…rŽ)r|rrr}r~rr†rxrxryrsfsA)ÚkeepdimscCs|fSrzrx)r|Úaxisr“rxrxryÚ_count_nonzero_dispatcher¬sr•FcCs`|dkr|st |¡St|ƒ}t |jtj¡r>||j ¡k}n|jtj    dd}|j
|tj |dS)a\
    Counts the number of non-zero values in the array ``a``.
 
    The word "non-zero" is in reference to the Python 2.x
    built-in method ``__nonzero__()`` (renamed ``__bool__()``
    in Python 3.x) of Python objects that tests an object's
    "truthfulness". For example, any number is considered
    truthful if it is nonzero, whereas any string is considered
    truthful if it is not the empty string. Thus, this function
    (recursively) counts how many elements in ``a`` (and in
    sub-arrays thereof) have their ``__nonzero__()`` or ``__bool__()``
    method evaluated to ``True``.
 
    Parameters
    ----------
    a : array_like
        The array for which to count non-zeros.
    axis : int or tuple, optional
        Axis or tuple of axes along which to count non-zeros.
        Default is None, meaning that non-zeros will be counted
        along a flattened version of ``a``.
 
        .. versionadded:: 1.12.0
 
    keepdims : bool, optional
        If this is set to True, the axes that are counted are left
        in the result as dimensions with size one. With this option,
        the result will broadcast correctly against the input array.
 
        .. versionadded:: 1.19.0
 
    Returns
    -------
    count : int or array of int
        Number of non-zero values in the array along a given axis.
        Otherwise, the total number of non-zero values in the array
        is returned.
 
    See Also
    --------
    nonzero : Return the coordinates of all the non-zero values.
 
    Examples
    --------
    >>> np.count_nonzero(np.eye(4))
    4
    >>> a = np.array([[0, 1, 7, 0],
    ...               [3, 0, 2, 19]])
    >>> np.count_nonzero(a)
    5
    >>> np.count_nonzero(a, axis=0)
    array([1, 1, 2, 1])
    >>> np.count_nonzero(a, axis=1)
    array([2, 3])
    >>> np.count_nonzero(a, axis=1, keepdims=True)
    array([[2],
           [3]])
    NF)Úcopy)r”rr“) rrNrÚnpZ
issubdtyperÚ    characterÚtypeÚastyperEÚsumZintp)r|r”r“Za_boolrxrxryrN°s< 
cCs|jjS)a
    Check if the array is Fortran contiguous but *not* C contiguous.
 
    This function is obsolete and, because of changes due to relaxed stride
    checking, its return value for the same array may differ for versions
    of NumPy >= 1.10.0 and previous versions. If you only want to check if an
    array is Fortran contiguous use ``a.flags.f_contiguous`` instead.
 
    Parameters
    ----------
    a : ndarray
        Input array.
 
    Returns
    -------
    isfortran : bool
        Returns True if the array is Fortran contiguous but *not* C contiguous.
 
 
    Examples
    --------
 
    np.array allows to specify whether the array is written in C-contiguous
    order (last index varies the fastest), or FORTRAN-contiguous order in
    memory (first index varies the fastest).
 
    >>> a = np.array([[1, 2, 3], [4, 5, 6]], order='C')
    >>> a
    array([[1, 2, 3],
           [4, 5, 6]])
    >>> np.isfortran(a)
    False
 
    >>> b = np.array([[1, 2, 3], [4, 5, 6]], order='F')
    >>> b
    array([[1, 2, 3],
           [4, 5, 6]])
    >>> np.isfortran(b)
    True
 
 
    The transpose of a C-ordered array is a FORTRAN-ordered array.
 
    >>> a = np.array([[1, 2, 3], [4, 5, 6]], order='C')
    >>> a
    array([[1, 2, 3],
           [4, 5, 6]])
    >>> np.isfortran(a)
    False
    >>> b = a.T
    >>> b
    array([[1, 4],
           [2, 5],
           [3, 6]])
    >>> np.isfortran(b)
    True
 
    C-ordered arrays evaluate as False even if they are also FORTRAN-ordered.
 
    >>> np.isfortran(np.array([1, 2], order='F'))
    False
 
    )ÚflagsZfnc©r|rxrxryrPúsAcCs|fSrzrxrrxrxryÚ_argwhere_dispatcher>sržcCs<t |¡dkr0t |¡}t|ƒdd…dd…fStt|ƒƒS)a´
    Find the indices of array elements that are non-zero, grouped by element.
 
    Parameters
    ----------
    a : array_like
        Input data.
 
    Returns
    -------
    index_array : (N, a.ndim) ndarray
        Indices of elements that are non-zero. Indices are grouped by element.
        This array will have shape ``(N, a.ndim)`` where ``N`` is the number of
        non-zero items.
 
    See Also
    --------
    where, nonzero
 
    Notes
    -----
    ``np.argwhere(a)`` is almost the same as ``np.transpose(np.nonzero(a))``,
    but produces a result of the correct shape for a 0D array.
 
    The output of ``argwhere`` is not suitable for indexing arrays.
    For this purpose use ``nonzero(a)`` instead.
 
    Examples
    --------
    >>> x = np.arange(6).reshape(2,3)
    >>> x
    array([[0, 1, 2],
           [3, 4, 5]])
    >>> np.argwhere(x>1)
    array([[0, 2],
           [1, 0],
           [1, 1],
           [1, 2]])
 
    rN)r—Úndimr7Z
atleast_1drOÚ    transposeÚnonzerorrxrxryrOBs+
cCs|fSrzrxrrxrxryÚ_flatnonzero_dispatchertsr¢cCst t |¡¡dS)aH
    Return indices that are non-zero in the flattened version of a.
 
    This is equivalent to ``np.nonzero(np.ravel(a))[0]``.
 
    Parameters
    ----------
    a : array_like
        Input data.
 
    Returns
    -------
    res : ndarray
        Output array, containing the indices of the elements of ``a.ravel()``
        that are non-zero.
 
    See Also
    --------
    nonzero : Return the indices of the non-zero elements of the input array.
    ravel : Return a 1-D array containing the elements of the input array.
 
    Examples
    --------
    >>> x = np.arange(-2, 3)
    >>> x
    array([-2, -1,  0,  1,  2])
    >>> np.flatnonzero(x)
    array([0, 1, 3, 4])
 
    Use the indices of the non-zero elements as an index array to extract
    these elements:
 
    >>> x.ravel()[np.flatnonzero(x)]
    array([-2, -1,  1,  2])
 
    r)r—r¡Úravelrrxrxryrgxs&cCs||fSrzrx©r|ÚvÚmoderxrxryÚ_correlate_dispatcher¡sr§ÚvalidcCst |||¡S)aå
    Cross-correlation of two 1-dimensional sequences.
 
    This function computes the correlation as generally defined in signal
    processing texts:
 
    .. math:: c_k = \sum_n a_{n+k} \cdot \overline{v}_n
 
    with a and v sequences being zero-padded where necessary and
    :math:`\overline x` denoting complex conjugation.
 
    Parameters
    ----------
    a, v : array_like
        Input sequences.
    mode : {'valid', 'same', 'full'}, optional
        Refer to the `convolve` docstring.  Note that the default
        is 'valid', unlike `convolve`, which uses 'full'.
    old_behavior : bool
        `old_behavior` was removed in NumPy 1.10. If you need the old
        behavior, use `multiarray.correlate`.
 
    Returns
    -------
    out : ndarray
        Discrete cross-correlation of `a` and `v`.
 
    See Also
    --------
    convolve : Discrete, linear convolution of two one-dimensional sequences.
    multiarray.correlate : Old, no conjugate, version of correlate.
    scipy.signal.correlate : uses FFT which has superior performance on large arrays. 
 
    Notes
    -----
    The definition of correlation above is not unique and sometimes correlation
    may be defined differently. Another common definition is:
 
    .. math:: c'_k = \sum_n a_{n} \cdot \overline{v_{n+k}}
 
    which is related to :math:`c_k` by :math:`c'_k = c_{-k}`.
 
    `numpy.correlate` may perform slowly in large arrays (i.e. n = 1e5) because it does
    not use the FFT to compute the convolution; in that case, `scipy.signal.correlate` might
    be preferable.
    
 
    Examples
    --------
    >>> np.correlate([1, 2, 3], [0, 1, 0.5])
    array([3.5])
    >>> np.correlate([1, 2, 3], [0, 1, 0.5], "same")
    array([2. ,  3.5,  3. ])
    >>> np.correlate([1, 2, 3], [0, 1, 0.5], "full")
    array([0.5,  2. ,  3.5,  3. ,  0. ])
 
    Using complex sequences:
 
    >>> np.correlate([1+1j, 2, 3-1j], [0, 1, 0.5j], 'full')
    array([ 0.5-0.5j,  1.0+0.j ,  1.5-1.5j,  3.0-1.j ,  0.0+0.j ])
 
    Note that you get the time reversed, complex conjugated result
    (:math:`\overline{c_{-k}}`) when the two input sequences a and v change 
    places:
 
    >>> np.correlate([0, 1, 0.5j], [1+1j, 2, 3-1j], 'full')
    array([ 0.0+0.j ,  3.0+1.j ,  1.5+1.5j,  1.0+0.j ,  0.5+0.5j])
 
    )rZ
correlate2r¤rxrxryrS¥sGcCs||fSrzrxr¤rxrxryÚ_convolve_dispatcherïsr©cCsxt|dddt|ddd}}t|ƒt|ƒkr8||}}t|ƒdkrLtdƒ‚t|ƒdkr`tdƒ‚t ||ddd…|¡S)    a
    Returns the discrete, linear convolution of two one-dimensional sequences.
 
    The convolution operator is often seen in signal processing, where it
    models the effect of a linear time-invariant system on a signal [1]_.  In
    probability theory, the sum of two independent random variables is
    distributed according to the convolution of their individual
    distributions.
 
    If `v` is longer than `a`, the arrays are swapped before computation.
 
    Parameters
    ----------
    a : (N,) array_like
        First one-dimensional input array.
    v : (M,) array_like
        Second one-dimensional input array.
    mode : {'full', 'valid', 'same'}, optional
        'full':
          By default, mode is 'full'.  This returns the convolution
          at each point of overlap, with an output shape of (N+M-1,). At
          the end-points of the convolution, the signals do not overlap
          completely, and boundary effects may be seen.
 
        'same':
          Mode 'same' returns output of length ``max(M, N)``.  Boundary
          effects are still visible.
 
        'valid':
          Mode 'valid' returns output of length
          ``max(M, N) - min(M, N) + 1``.  The convolution product is only given
          for points where the signals overlap completely.  Values outside
          the signal boundary have no effect.
 
    Returns
    -------
    out : ndarray
        Discrete, linear convolution of `a` and `v`.
 
    See Also
    --------
    scipy.signal.fftconvolve : Convolve two arrays using the Fast Fourier
                               Transform.
    scipy.linalg.toeplitz : Used to construct the convolution operator.
    polymul : Polynomial multiplication. Same output as convolve, but also
              accepts poly1d objects as input.
 
    Notes
    -----
    The discrete convolution operation is defined as
 
    .. math:: (a * v)_n = \sum_{m = -\infty}^{\infty} a_m v_{n - m}
 
    It can be shown that a convolution :math:`x(t) * y(t)` in time/space
    is equivalent to the multiplication :math:`X(f) Y(f)` in the Fourier
    domain, after appropriate padding (padding is necessary to prevent
    circular convolution).  Since multiplication is more efficient (faster)
    than convolution, the function `scipy.signal.fftconvolve` exploits the
    FFT to calculate the convolution of large data-sets.
 
    References
    ----------
    .. [1] Wikipedia, "Convolution",
        https://en.wikipedia.org/wiki/Convolution
 
    Examples
    --------
    Note how the convolution operator flips the second array
    before "sliding" the two across one another:
 
    >>> np.convolve([1, 2, 3], [0, 1, 0.5])
    array([0. , 1. , 2.5, 4. , 1.5])
 
    Only return the middle values of the convolution.
    Contains boundary effects, where zeros are taken
    into account:
 
    >>> np.convolve([1,2,3],[0,1,0.5], 'same')
    array([1. ,  2.5,  4. ])
 
    The two arrays are of the same length, so there
    is only one position where they completely overlap:
 
    >>> np.convolve([1,2,3],[0,1,0.5], 'valid')
    array([2.5])
 
    Fr)r–Zndminrza cannot be emptyzv cannot be emptyNéÿÿÿÿ)rÚlenÚ
ValueErrorrrSr¤rxrxryrTósY
  cCs
|||fSrzrx©r|ÚbÚoutrxrxryÚ_outer_dispatcherVsr°cCs<t|ƒ}t|ƒ}t| ¡dd…tf| ¡tdd…f|ƒS)a
 
    Compute the outer product of two vectors.
 
    Given two vectors, ``a = [a0, a1, ..., aM]`` and
    ``b = [b0, b1, ..., bN]``,
    the outer product [1]_ is::
 
      [[a0*b0  a0*b1 ... a0*bN ]
       [a1*b0    .
       [ ...          .
       [aM*b0            aM*bN ]]
 
    Parameters
    ----------
    a : (M,) array_like
        First input vector.  Input is flattened if
        not already 1-dimensional.
    b : (N,) array_like
        Second input vector.  Input is flattened if
        not already 1-dimensional.
    out : (M, N) ndarray, optional
        A location where the result is stored
 
        .. versionadded:: 1.9.0
 
    Returns
    -------
    out : (M, N) ndarray
        ``out[i, j] = a[i] * b[j]``
 
    See also
    --------
    inner
    einsum : ``einsum('i,j->ij', a.ravel(), b.ravel())`` is the equivalent.
    ufunc.outer : A generalization to dimensions other than 1D and other
                  operations. ``np.multiply.outer(a.ravel(), b.ravel())``
                  is the equivalent.
    tensordot : ``np.tensordot(a.ravel(), b.ravel(), axes=((), ()))``
                is the equivalent.
 
    References
    ----------
    .. [1] : G. H. Golub and C. F. Van Loan, *Matrix Computations*, 3rd
             ed., Baltimore, MD, Johns Hopkins University Press, 1996,
             pg. 8.
 
    Examples
    --------
    Make a (*very* coarse) grid for computing a Mandelbrot set:
 
    >>> rl = np.outer(np.ones((5,)), np.linspace(-2, 2, 5))
    >>> rl
    array([[-2., -1.,  0.,  1.,  2.],
           [-2., -1.,  0.,  1.,  2.],
           [-2., -1.,  0.,  1.,  2.],
           [-2., -1.,  0.,  1.,  2.],
           [-2., -1.,  0.,  1.,  2.]])
    >>> im = np.outer(1j*np.linspace(2, -2, 5), np.ones((5,)))
    >>> im
    array([[0.+2.j, 0.+2.j, 0.+2.j, 0.+2.j, 0.+2.j],
           [0.+1.j, 0.+1.j, 0.+1.j, 0.+1.j, 0.+1.j],
           [0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j, 0.+0.j],
           [0.-1.j, 0.-1.j, 0.-1.j, 0.-1.j, 0.-1.j],
           [0.-2.j, 0.-2.j, 0.-2.j, 0.-2.j, 0.-2.j]])
    >>> grid = rl + im
    >>> grid
    array([[-2.+2.j, -1.+2.j,  0.+2.j,  1.+2.j,  2.+2.j],
           [-2.+1.j, -1.+1.j,  0.+1.j,  1.+1.j,  2.+1.j],
           [-2.+0.j, -1.+0.j,  0.+0.j,  1.+0.j,  2.+0.j],
           [-2.-1.j, -1.-1.j,  0.-1.j,  1.-1.j,  2.-1.j],
           [-2.-2.j, -1.-2.j,  0.-2.j,  1.-2.j,  2.-2.j]])
 
    An example using a "vector" of letters:
 
    >>> x = np.array(['a', 'b', 'c'], dtype=object)
    >>> np.outer(x, [1, 2, 3])
    array([['a', 'aa', 'aaa'],
           ['b', 'bb', 'bbb'],
           ['c', 'cc', 'ccc']], dtype=object)
 
    N)rr:r£rLr­rxrxryrUZsScCs||fSrzrx)r|r®ÚaxesrxrxryÚ_tensordot_dispatcher²sr²écsvz t|ƒWn2tk
r>tt| dƒƒ‰ttd|ƒƒ‰Yn
X|\‰‰ztˆƒ}tˆƒ‰Wntk
rzˆg‰d}YnXztˆƒ}tˆƒ‰Wntk
r®ˆg‰d}YnXt|ƒt|ƒ}}|j‰|j}|j‰|j}d}||krìd}nlt|ƒD]b}ˆˆ|ˆˆ|krd}qXˆ|dkr:ˆ||7<ˆ|dkrôˆ||7<qô|sft    dƒ‚‡fdd„t|ƒDƒ}    |    ˆ}
d} ˆD]} | ˆ| 9} qŒt
t   ‡fdd„|    Dƒ¡ƒ| f} ‡fd    d„|    Dƒ}‡fd
d„t|ƒDƒ}    ˆ|    }d} ˆD]} | ˆ| 9} qø| t
t   ‡fd d„|    Dƒ¡ƒf}‡fd d„|    Dƒ}|  |
¡ | ¡}|  |¡ |¡}t||ƒ}| ||¡S) a«
    Compute tensor dot product along specified axes.
 
    Given two tensors, `a` and `b`, and an array_like object containing
    two array_like objects, ``(a_axes, b_axes)``, sum the products of
    `a`'s and `b`'s elements (components) over the axes specified by
    ``a_axes`` and ``b_axes``. The third argument can be a single non-negative
    integer_like scalar, ``N``; if it is such, then the last ``N`` dimensions
    of `a` and the first ``N`` dimensions of `b` are summed over.
 
    Parameters
    ----------
    a, b : array_like
        Tensors to "dot".
 
    axes : int or (2,) array_like
        * integer_like
          If an int N, sum over the last N axes of `a` and the first N axes
          of `b` in order. The sizes of the corresponding axes must match.
        * (2,) array_like
          Or, a list of axes to be summed over, first sequence applying to `a`,
          second to `b`. Both elements array_like must be of the same length.
 
    Returns
    -------
    output : ndarray
        The tensor dot product of the input.
 
    See Also
    --------
    dot, einsum
 
    Notes
    -----
    Three common use cases are:
        * ``axes = 0`` : tensor product :math:`a\otimes b`
        * ``axes = 1`` : tensor dot product :math:`a\cdot b`
        * ``axes = 2`` : (default) tensor double contraction :math:`a:b`
 
    When `axes` is integer_like, the sequence for evaluation will be: first
    the -Nth axis in `a` and 0th axis in `b`, and the -1th axis in `a` and
    Nth axis in `b` last.
 
    When there is more than one axis to sum over - and they are not the last
    (first) axes of `a` (`b`) - the argument `axes` should consist of
    two sequences of the same length, with the first axis to sum over given
    first in both sequences, the second axis second, and so forth.
 
    The shape of the result consists of the non-contracted axes of the
    first tensor, followed by the non-contracted axes of the second.
 
    Examples
    --------
    A "traditional" example:
 
    >>> a = np.arange(60.).reshape(3,4,5)
    >>> b = np.arange(24.).reshape(4,3,2)
    >>> c = np.tensordot(a,b, axes=([1,0],[0,1]))
    >>> c.shape
    (5, 2)
    >>> c
    array([[4400., 4730.],
           [4532., 4874.],
           [4664., 5018.],
           [4796., 5162.],
           [4928., 5306.]])
    >>> # A slower but equivalent way of computing the same...
    >>> d = np.zeros((5,2))
    >>> for i in range(5):
    ...   for j in range(2):
    ...     for k in range(3):
    ...       for n in range(4):
    ...         d[i,j] += a[k,n,i] * b[n,k,j]
    >>> c == d
    array([[ True,  True],
           [ True,  True],
           [ True,  True],
           [ True,  True],
           [ True,  True]])
 
    An extended example taking advantage of the overloading of + and \*:
 
    >>> a = np.array(range(1, 9))
    >>> a.shape = (2, 2, 2)
    >>> A = np.array(('a', 'b', 'c', 'd'), dtype=object)
    >>> A.shape = (2, 2)
    >>> a; A
    array([[[1, 2],
            [3, 4]],
           [[5, 6],
            [7, 8]]])
    array([['a', 'b'],
           ['c', 'd']], dtype=object)
 
    >>> np.tensordot(a, A) # third argument default is 2 for double-contraction
    array(['abbcccdddd', 'aaaaabbbbbbcccccccdddddddd'], dtype=object)
 
    >>> np.tensordot(a, A, 1)
    array([[['acc', 'bdd'],
            ['aaacccc', 'bbbdddd']],
           [['aaaaacccccc', 'bbbbbdddddd'],
            ['aaaaaaacccccccc', 'bbbbbbbdddddddd']]], dtype=object)
 
    >>> np.tensordot(a, A, 0) # tensor product (result too long to incl.)
    array([[[[['a', 'b'],
              ['c', 'd']],
              ...
 
    >>> np.tensordot(a, A, (0, 1))
    array([[['abbbbb', 'cddddd'],
            ['aabbbbbb', 'ccdddddd']],
           [['aaabbbbbbb', 'cccddddddd'],
            ['aaaabbbbbbbb', 'ccccdddddddd']]], dtype=object)
 
    >>> np.tensordot(a, A, (2, 1))
    array([[['abb', 'cdd'],
            ['aaabbbb', 'cccdddd']],
           [['aaaaabbbbbb', 'cccccdddddd'],
            ['aaaaaaabbbbbbbb', 'cccccccdddddddd']]], dtype=object)
 
    >>> np.tensordot(a, A, ((0, 1), (0, 1)))
    array(['abbbcccccddddddd', 'aabbbbccccccdddddddd'], dtype=object)
 
    >>> np.tensordot(a, A, ((2, 1), (1, 0)))
    array(['acccbbdddd', 'aaaaacccccccbbbbbbdddddddd'], dtype=object)
 
    rrTFzshape-mismatch for sumcsg|]}|ˆkr|‘qSrxrx©Ú.0Úk)Úaxes_arxryÚ
<listcomp>asztensordot.<locals>.<listcomp>csg|] }ˆ|‘qSrxrx©rµÚax©Úas_rxryr¸fscsg|] }ˆ|‘qSrxrx©rµr”r»rxryr¸gscsg|]}|ˆkr|‘qSrxrxr´)Úaxes_brxryr¸iscsg|] }ˆ|‘qSrxrxr¹©Úbsrxryr¸nscsg|] }ˆ|‘qSrxrxr½r¿rxryr¸os)ÚiterÚ    ExceptionÚlistÚranger«Ú    TypeErrorrrrŸr¬Úintr:Úreducer Úreshaper)r|r®r±ÚnaÚnbZndaZndbÚequalr¶ÚnotinZ    newaxes_aZN2r”Z
newshape_aZoldaZ    newaxes_bZ
newshape_bZoldbÚatZbtr†rx)r¼r·r¾rÀryrZ¶sn  
 
    
cCs|fSrzrx)r|Úshiftr”rxrxryÚ_roll_dispatcherwsrÏc Cs2t|ƒ}|dkr(t| ¡|dƒ |j¡St||jdd}t||ƒ}|jdkrTtdƒ‚dd„t    |jƒDƒ}|D]\}}|||7<qlt
dƒt
dƒffg|j}|  ¡D]N\}}||j|p¾d;}|r¨t
d| ƒt
|dƒft
| dƒt
d|ƒff||<q¨t |ƒ}    t j|ŽD]}
t|
Ž\} } || |    | <q
|    SdS)    a)
    Roll array elements along a given axis.
 
    Elements that roll beyond the last position are re-introduced at
    the first.
 
    Parameters
    ----------
    a : array_like
        Input array.
    shift : int or tuple of ints
        The number of places by which elements are shifted.  If a tuple,
        then `axis` must be a tuple of the same size, and each of the
        given axes is shifted by the corresponding number.  If an int
        while `axis` is a tuple of ints, then the same value is used for
        all given axes.
    axis : int or tuple of ints, optional
        Axis or axes along which elements are shifted.  By default, the
        array is flattened before shifting, after which the original
        shape is restored.
 
    Returns
    -------
    res : ndarray
        Output array, with the same shape as `a`.
 
    See Also
    --------
    rollaxis : Roll the specified axis backwards, until it lies in a
               given position.
 
    Notes
    -----
    .. versionadded:: 1.12.0
 
    Supports rolling over multiple dimensions simultaneously.
 
    Examples
    --------
    >>> x = np.arange(10)
    >>> np.roll(x, 2)
    array([8, 9, 0, 1, 2, 3, 4, 5, 6, 7])
    >>> np.roll(x, -2)
    array([2, 3, 4, 5, 6, 7, 8, 9, 0, 1])
 
    >>> x2 = np.reshape(x, (2, 5))
    >>> x2
    array([[0, 1, 2, 3, 4],
           [5, 6, 7, 8, 9]])
    >>> np.roll(x2, 1)
    array([[9, 0, 1, 2, 3],
           [4, 5, 6, 7, 8]])
    >>> np.roll(x2, -1)
    array([[1, 2, 3, 4, 5],
           [6, 7, 8, 9, 0]])
    >>> np.roll(x2, 1, axis=0)
    array([[5, 6, 7, 8, 9],
           [0, 1, 2, 3, 4]])
    >>> np.roll(x2, -1, axis=0)
    array([[5, 6, 7, 8, 9],
           [0, 1, 2, 3, 4]])
    >>> np.roll(x2, 1, axis=1)
    array([[4, 0, 1, 2, 3],
           [9, 5, 6, 7, 8]])
    >>> np.roll(x2, -1, axis=1)
    array([[1, 2, 3, 4, 0],
           [6, 7, 8, 9, 5]])
    >>> np.roll(x2, (1, 1), axis=(1, 0))
    array([[9, 5, 6, 7, 8],
           [4, 0, 1, 2, 3]])
    >>> np.roll(x2, (2, 1), axis=(1, 0))
    array([[8, 9, 5, 6, 7],
           [3, 4, 0, 1, 2]])
 
    NrT)Úallow_duplicaterz4'shift' and 'axis' should be scalars or 1D sequencescSsi|]
}|d“qS©rrxr¹rxrxryÚ
<dictcomp>Òszroll.<locals>.<dictcomp>)rrVr£rÈrÚnormalize_axis_tuplerŸrr¬rÄÚsliceÚitemsrÚ    itertoolsÚproductÚzip) r|rÎr”Z broadcastedZshiftsÚshrºZrollsÚoffsetÚresultr^Z    arr_indexZ    res_indexrxrxryrV{s0M
 
ÿ ÿ
 cCs|fSrzrx)r|r”ÚstartrxrxryÚ_rollaxis_dispatcheræsrÝcCs¨|j}t||ƒ}|dkr ||7}d}d|kr<|dksZnt|d| d|d|fƒ‚||krj|d8}||krz|dSttd|ƒƒ}| |¡| ||¡| |¡S)a+
 
    Roll the specified axis backwards, until it lies in a given position.
 
    This function continues to be supported for backward compatibility, but you
    should prefer `moveaxis`. The `moveaxis` function was added in NumPy
    1.11.
 
    Parameters
    ----------
    a : ndarray
        Input array.
    axis : int
        The axis to be rolled. The positions of the other axes do not
        change relative to one another.
    start : int, optional
        When ``start <= axis``, the axis is rolled back until it lies in
        this position. When ``start > axis``, the axis is rolled until it
        lies before this position. The default, 0, results in a "complete"
        roll. The following table describes how negative values of ``start``
        are interpreted:
 
        .. table::
           :align: left
 
           +-------------------+----------------------+
           |     ``start``     | Normalized ``start`` |
           +===================+======================+
           | ``-(arr.ndim+1)`` | raise ``AxisError``  |
           +-------------------+----------------------+
           | ``-arr.ndim``     | 0                    |
           +-------------------+----------------------+
           | |vdots|           | |vdots|              |
           +-------------------+----------------------+
           | ``-1``            | ``arr.ndim-1``       |
           +-------------------+----------------------+
           | ``0``             | ``0``                |
           +-------------------+----------------------+
           | |vdots|           | |vdots|              |
           +-------------------+----------------------+
           | ``arr.ndim``      | ``arr.ndim``         |
           +-------------------+----------------------+
           | ``arr.ndim + 1``  | raise ``AxisError``  |
           +-------------------+----------------------+
           
        .. |vdots|   unicode:: U+22EE .. Vertical Ellipsis
 
    Returns
    -------
    res : ndarray
        For NumPy >= 1.10.0 a view of `a` is always returned. For earlier
        NumPy versions a view of `a` is returned only if the order of the
        axes is changed, otherwise the input array is returned.
 
    See Also
    --------
    moveaxis : Move array axes to new positions.
    roll : Roll the elements of an array by a number of positions along a
        given axis.
 
    Examples
    --------
    >>> a = np.ones((3,4,5,6))
    >>> np.rollaxis(a, 3, 1).shape
    (3, 6, 4, 5)
    >>> np.rollaxis(a, 2).shape
    (5, 3, 4, 6)
    >>> np.rollaxis(a, 1, 4).shape
    (3, 5, 6, 4)
 
    rz5'%s' arg requires %d <= %s < %d, but %d was passed inrrÜ.)rŸr2rGrÃrÄÚremoveÚinsertr )r|r”rÜÚnÚmsgr±rxrxryrWêsH
 
 cs†t|ƒttfkr6zt |¡g}Wntk
r4YnXt‡‡fdd„|Dƒƒ}|s‚tt|ƒƒt|ƒkr‚ˆrztd     ˆ¡ƒ‚ntdƒ‚|S)aÄ
    Normalizes an axis argument into a tuple of non-negative integer axes.
 
    This handles shorthands such as ``1`` and converts them to ``(1,)``,
    as well as performing the handling of negative indices covered by
    `normalize_axis_index`.
 
    By default, this forbids axes from being specified multiple times.
 
    Used internally by multi-axis-checking logic.
 
    .. versionadded:: 1.13.0
 
    Parameters
    ----------
    axis : int, iterable of int
        The un-normalized index or indices of the axis.
    ndim : int
        The number of dimensions of the array that `axis` should be normalized
        against.
    argname : str, optional
        A prefix to put before the error message, typically the name of the
        argument.
    allow_duplicate : bool, optional
        If False, the default, disallow an axis from being specified twice.
 
    Returns
    -------
    normalized_axes : tuple of int
        The normalized axis index, such that `0 <= normalized_axis < ndim`
 
    Raises
    ------
    AxisError
        If any axis provided is out of range
    ValueError
        If an axis is repeated
 
    See also
    --------
    normalize_axis_index : normalizing a single scalar axis
    csg|]}t|ˆˆƒ‘qSrx)r2r¹©ÚargnamerŸrxryr¸vsz(normalize_axis_tuple.<locals>.<listcomp>zrepeated axis in `{}` argumentz repeated axis)
r™ÚtuplerÃÚoperatorÚindexrÅr«Úsetr¬Úformat)r”rŸrãrÐrxrâryrÓDs,rÓcCs|fSrzrx)r|ÚsourceÚ destinationrxrxryÚ_moveaxis_dispatchersrëcsªz
|j}Wn"tk
r,t|ƒ}|j}YnXtˆ|jdƒ‰t||jdƒ}tˆƒt|ƒkrbtdƒ‚‡fdd„t|jƒDƒ}tt    |ˆƒƒD]\}}| 
||¡qˆ||ƒ}|S)aw
    Move axes of an array to new positions.
 
    Other axes remain in their original order.
 
    .. versionadded:: 1.11.0
 
    Parameters
    ----------
    a : np.ndarray
        The array whose axes should be reordered.
    source : int or sequence of int
        Original positions of the axes to move. These must be unique.
    destination : int or sequence of int
        Destination positions for each of the original axes. These must also be
        unique.
 
    Returns
    -------
    result : np.ndarray
        Array with moved axes. This array is a view of the input array.
 
    See Also
    --------
    transpose : Permute the dimensions of an array.
    swapaxes : Interchange two axes of an array.
 
    Examples
    --------
    >>> x = np.zeros((3, 4, 5))
    >>> np.moveaxis(x, 0, -1).shape
    (4, 5, 3)
    >>> np.moveaxis(x, -1, 0).shape
    (5, 3, 4)
 
    These all achieve the same result:
 
    >>> np.transpose(x).shape
    (5, 4, 3)
    >>> np.swapaxes(x, 0, -1).shape
    (5, 4, 3)
    >>> np.moveaxis(x, [0, 1], [-1, -2]).shape
    (5, 4, 3)
    >>> np.moveaxis(x, [0, 1, 2], [-1, -2, -3]).shape
    (5, 4, 3)
 
    rérêzJ`source` and `destination` arguments must have the same number of elementscsg|]}|ˆkr|‘qSrxrx)rµrà©rérxryr¸Ászmoveaxis.<locals>.<listcomp>) r ÚAttributeErrorrrÓrŸr«r¬rÄÚsortedrØrß)r|rérêr r}ÚdestÚsrcrÛrxrìryrXƒs1
 cCs||fSrzrx)r|r®ÚaxisaÚaxisbÚaxiscr”rxrxryÚ_cross_dispatcherÊsrôrªcCs
|dk    r|fd\}}}t|ƒ}t|ƒ}t||jdd}t||jdd}t||dƒ}t||dƒ}d}|jddks€|jddkrˆt|ƒ‚t|d    |d    ƒj}|jddks¸|jddkrÒ|d
7}t|t|ƒd d}t|j    |j    ƒ}t
||ƒ}    |  |¡}|  |¡}|d    }
|d } |jddkr&|d } |d    } |d }|jddkrN|d }|    jdkr‚|    jddkr‚|    d    }|    d }|    d }|jddkr|jddkrÀt |
||    d|    | | 8}    |    S|jddksÔt ‚t | ||dt |
||dt||dt |
||d|| | 8}næ|jddks,t ‚|jddkr¨t | ||dt| |ƒ}||8}t | | |dt |
||d||8}t |
||dt | | |d||8}nV|jddks¼t ‚t | ||dt||dt | | |dt |
||d|| | 8}t|    d|ƒS)a 
    Return the cross product of two (arrays of) vectors.
 
    The cross product of `a` and `b` in :math:`R^3` is a vector perpendicular
    to both `a` and `b`.  If `a` and `b` are arrays of vectors, the vectors
    are defined by the last axis of `a` and `b` by default, and these axes
    can have dimensions 2 or 3.  Where the dimension of either `a` or `b` is
    2, the third component of the input vector is assumed to be zero and the
    cross product calculated accordingly.  In cases where both input vectors
    have dimension 2, the z-component of the cross product is returned.
 
    Parameters
    ----------
    a : array_like
        Components of the first vector(s).
    b : array_like
        Components of the second vector(s).
    axisa : int, optional
        Axis of `a` that defines the vector(s).  By default, the last axis.
    axisb : int, optional
        Axis of `b` that defines the vector(s).  By default, the last axis.
    axisc : int, optional
        Axis of `c` containing the cross product vector(s).  Ignored if
        both input vectors have dimension 2, as the return is scalar.
        By default, the last axis.
    axis : int, optional
        If defined, the axis of `a`, `b` and `c` that defines the vector(s)
        and cross product(s).  Overrides `axisa`, `axisb` and `axisc`.
 
    Returns
    -------
    c : ndarray
        Vector cross product(s).
 
    Raises
    ------
    ValueError
        When the dimension of the vector(s) in `a` and/or `b` does not
        equal 2 or 3.
 
    See Also
    --------
    inner : Inner product
    outer : Outer product.
    ix_ : Construct index arrays.
 
    Notes
    -----
    .. versionadded:: 1.9.0
 
    Supports full broadcasting of the inputs.
 
    Examples
    --------
    Vector cross-product.
 
    >>> x = [1, 2, 3]
    >>> y = [4, 5, 6]
    >>> np.cross(x, y)
    array([-3,  6, -3])
 
    One vector with dimension 2.
 
    >>> x = [1, 2]
    >>> y = [4, 5, 6]
    >>> np.cross(x, y)
    array([12, -6, -3])
 
    Equivalently:
 
    >>> x = [1, 2, 0]
    >>> y = [4, 5, 6]
    >>> np.cross(x, y)
    array([12, -6, -3])
 
    Both vectors with dimension 2.
 
    >>> x = [1,2]
    >>> y = [4,5]
    >>> np.cross(x, y)
    array(-3)
 
    Multiple vector cross-products. Note that the direction of the cross
    product vector is defined by the *right-hand rule*.
 
    >>> x = np.array([[1,2,3], [4,5,6]])
    >>> y = np.array([[4,5,6], [1,2,3]])
    >>> np.cross(x, y)
    array([[-3,  6, -3],
           [ 3, -6,  3]])
 
    The orientation of `c` can be changed using the `axisc` keyword.
 
    >>> np.cross(x, y, axisc=0)
    array([[-3,  3],
           [ 6, -6],
           [-3,  3]])
 
    Change the vector definition of `x` and `y` using `axisa` and `axisb`.
 
    >>> x = np.array([[1,2,3], [4,5,6], [7, 8, 9]])
    >>> y = np.array([[7, 8, 9], [4,5,6], [1,2,3]])
    >>> np.cross(x, y)
    array([[ -6,  12,  -6],
           [  0,   0,   0],
           [  6, -12,   6]])
    >>> np.cross(x, y, axisa=0, axisb=0)
    array([[-24,  48, -24],
           [-30,  60, -30],
           [-36,  72, -36]])
 
    Nérñ)Z
msg_prefixròrªzDincompatible dimensions for cross product
(dimension must be 2 or 3))r³rõ).r)rõró).r).r³rr³)r¯)rr2rŸrXrr¬rr«r*rrršr:ÚAssertionErrorÚnegativer)r|r®rñròrór”rárrÚcpZa0Úa1Úa2Zb0Zb1Zb2Zcp0Zcp1Zcp2ÚtmprxrxryrYÎsxr  
 
 
 
  Úlittlec    Cs”t|ƒ}t|ƒ}d|}|r$tƒ}nt|f||d}t|ƒD]P\}}t||d |d|…|f||dd…¡}|r†||f}q>|||<q>|S)aû
    Return an array representing the indices of a grid.
 
    Compute an array where the subarrays contain index values 0, 1, ...
    varying only along the corresponding axis.
 
    Parameters
    ----------
    dimensions : sequence of ints
        The shape of the grid.
    dtype : dtype, optional
        Data type of the result.
    sparse : boolean, optional
        Return a sparse representation of the grid instead of a dense
        representation. Default is False.
 
        .. versionadded:: 1.17
 
    Returns
    -------
    grid : one ndarray or tuple of ndarrays
        If sparse is False:
            Returns one array of grid indices,
            ``grid.shape = (len(dimensions),) + tuple(dimensions)``.
        If sparse is True:
            Returns a tuple of arrays, with
            ``grid[i].shape = (1, ..., 1, dimensions[i], 1, ..., 1)`` with
            dimensions[i] in the ith place
 
    See Also
    --------
    mgrid, ogrid, meshgrid
 
    Notes
    -----
    The output shape in the dense case is obtained by prepending the number
    of dimensions in front of the tuple of dimensions, i.e. if `dimensions`
    is a tuple ``(r0, ..., rN-1)`` of length ``N``, the output shape is
    ``(N, r0, ..., rN-1)``.
 
    The subarrays ``grid[k]`` contains the N-D array of indices along the
    ``k-th`` axis. Explicitly::
 
        grid[k, i0, i1, ..., iN-1] = ik
 
    Examples
    --------
    >>> grid = np.indices((2, 3))
    >>> grid.shape
    (2, 2, 3)
    >>> grid[0]        # row indices
    array([[0, 0, 0],
           [1, 1, 1]])
    >>> grid[1]        # column indices
    array([[0, 1, 2],
           [0, 1, 2]])
 
    The indices can be used as an index into an array.
 
    >>> x = np.arange(20).reshape(5, 4)
    >>> row, col = np.indices((2, 3))
    >>> x[row, col]
    array([[0, 1, 2],
           [4, 5, 6]])
 
    Note that it would be more straightforward in the above example to
    extract the required elements directly with ``x[:2, :3]``.
 
    If sparse is set to true, the grid will be returned in a sparse
    representation.
 
    >>> i, j = np.indices((2, 3), sparse=True)
    >>> i.shape
    (2, 1)
    >>> j.shape
    (1, 3)
    >>> i        # row indices
    array([[0],
           [1]])
    >>> j        # column indices
    array([[0, 1, 2]])
 
    )rrƒNr)rär«rÚ    enumerater rÈ)    Z
dimensionsrÚsparseÚNrr†ÚiZdimÚidxrxrxryr^›sU  ÿ 
©rrˆcKs|fSrzrx)ÚfunctionrrrˆÚkwargsrxrxryÚ_fromfunction_dispatchersrcKs6|dk    r t||f||dœ|—ŽSt||d}|||ŽS)a
    Construct an array by executing a function over each coordinate.
 
    The resulting array therefore has a value ``fn(x, y, z)`` at
    coordinate ``(x, y, z)``.
 
    Parameters
    ----------
    function : callable
        The function is called with N parameters, where N is the rank of
        `shape`.  Each parameter represents the coordinates of the array
        varying along a specific axis.  For example, if `shape`
        were ``(2, 2)``, then the parameters would be
        ``array([[0, 0], [1, 1]])`` and ``array([[0, 1], [0, 1]])``
    shape : (N,) tuple of ints
        Shape of the output array, which also determines the shape of
        the coordinate arrays passed to `function`.
    dtype : data-type, optional
        Data-type of the coordinate arrays passed to `function`.
        By default, `dtype` is float.
    ${ARRAY_FUNCTION_LIKE}
 
        .. versionadded:: 1.20.0
 
    Returns
    -------
    fromfunction : any
        The result of the call to `function` is passed back directly.
        Therefore the shape of `fromfunction` is completely determined by
        `function`.  If `function` returns a scalar value, the shape of
        `fromfunction` would not match the `shape` parameter.
 
    See Also
    --------
    indices, meshgrid
 
    Notes
    -----
    Keywords other than `dtype` and `like` are passed to `function`.
 
    Examples
    --------
    >>> np.fromfunction(lambda i, j: i, (2, 2), dtype=float)
    array([[0., 0.],
           [1., 1.]])
           
    >>> np.fromfunction(lambda i, j: j, (2, 2), dtype=float)    
    array([[0., 1.],
           [0., 1.]])
           
    >>> np.fromfunction(lambda i, j: i == j, (3, 3), dtype=int)
    array([[ True, False, False],
           [False,  True, False],
           [False, False,  True]])
 
    >>> np.fromfunction(lambda i, j: i + j, (3, 3), dtype=int)
    array([[0, 1, 2],
           [1, 2, 3],
           [2, 3, 4]])
 
    Nrrƒ)Ú_fromfunction_with_liker^)rrrrˆrÚargsrxrxryr_s@ cCst||dj||dS)Nrƒ)r})rrÈ)Úbufrrr}rxrxryÚ _frombufferRsr    cCs"t|tƒp t|ƒtkp t|tjƒS)aè
    Returns True if the type of `element` is a scalar type.
 
    Parameters
    ----------
    element : any
        Input argument, can be of any type and shape.
 
    Returns
    -------
    val : bool
        True if `element` is a scalar type, False if it is not.
 
    See Also
    --------
    ndim : Get the number of dimensions of an array
 
    Notes
    -----
    If you need a stricter way to identify a *numerical* scalar, use
    ``isinstance(x, numbers.Number)``, as that returns ``False`` for most
    non-numerical elements such as strings.
 
    In most cases ``np.ndim(x) == 0`` should be used instead of this function,
    as that will also return true for 0d arrays. This is how numpy overloads
    functions in the style of the ``dx`` arguments to `gradient` and the ``bins``
    argument to `histogram`. Some key differences:
 
    +--------------------------------------+---------------+-------------------+
    | x                                    |``isscalar(x)``|``np.ndim(x) == 0``|
    +======================================+===============+===================+
    | PEP 3141 numeric objects (including  | ``True``      | ``True``          |
    | builtins)                            |               |                   |
    +--------------------------------------+---------------+-------------------+
    | builtin string and buffer objects    | ``True``      | ``True``          |
    +--------------------------------------+---------------+-------------------+
    | other builtin objects, like          | ``False``     | ``True``          |
    | `pathlib.Path`, `Exception`,         |               |                   |
    | the result of `re.compile`           |               |                   |
    +--------------------------------------+---------------+-------------------+
    | third-party objects like             | ``False``     | ``True``          |
    | `matplotlib.figure.Figure`           |               |                   |
    +--------------------------------------+---------------+-------------------+
    | zero-dimensional numpy arrays        | ``False``     | ``True``          |
    +--------------------------------------+---------------+-------------------+
    | other numpy arrays                   | ``False``     | ``False``         |
    +--------------------------------------+---------------+-------------------+
    | `list`, `tuple`, and other sequence  | ``False``     | ``False``         |
    | objects                              |               |                   |
    +--------------------------------------+---------------+-------------------+
 
    Examples
    --------
    >>> np.isscalar(3.1)
    True
    >>> np.isscalar(np.array(3.1))
    False
    >>> np.isscalar([3.1])
    False
    >>> np.isscalar(False)
    True
    >>> np.isscalar('numpy')
    True
 
    NumPy supports PEP 3141 numbers:
 
    >>> from fractions import Fraction
    >>> np.isscalar(Fraction(5, 17))
    True
    >>> from numbers import Number
    >>> np.isscalar(Number())
    True
 
    )Ú
isinstanceZgenericr™Z
ScalarTypeÚnumbersÚNumber)ÚelementrxrxryraVs
L
 
ÿ
þcCsdd„}t |¡}|dkr&d|p"dS|dkrpt|ƒdd…}t|ƒ}|dkrR|nt||ƒ}|||ƒ| |¡S|dkrŽdt| ƒdd…Stt| ƒdd…ƒ}d|d| kr¾|d8}d|d|}t|ƒdd…}t|ƒ}t||ƒ}|||ƒd    |||SdS)
aÆ
    Return the binary representation of the input number as a string.
 
    For negative numbers, if width is not given, a minus sign is added to the
    front. If width is given, the two's complement of the number is
    returned, with respect to that width.
 
    In a two's-complement system negative numbers are represented by the two's
    complement of the absolute value. This is the most common method of
    representing signed integers on computers [1]_. A N-bit two's-complement
    system can represent every integer in the range
    :math:`-2^{N-1}` to :math:`+2^{N-1}-1`.
 
    Parameters
    ----------
    num : int
        Only an integer decimal number can be used.
    width : int, optional
        The length of the returned string if `num` is positive, or the length
        of the two's complement if `num` is negative, provided that `width` is
        at least a sufficient number of bits for `num` to be represented in the
        designated form.
 
        If the `width` value is insufficient, it will be ignored, and `num` will
        be returned in binary (`num` > 0) or two's complement (`num` < 0) form
        with its width equal to the minimum number of bits needed to represent
        the number in the designated form. This behavior is deprecated and will
        later raise an error.
 
        .. deprecated:: 1.12.0
 
    Returns
    -------
    bin : str
        Binary representation of `num` or two's complement of `num`.
 
    See Also
    --------
    base_repr: Return a string representation of a number in the given base
               system.
    bin: Python's built-in binary representation generator of an integer.
 
    Notes
    -----
    `binary_repr` is equivalent to using `base_repr` with base 2, but about 25x
    faster.
 
    References
    ----------
    .. [1] Wikipedia, "Two's complement",
        https://en.wikipedia.org/wiki/Two's_complement
 
    Examples
    --------
    >>> np.binary_repr(3)
    '11'
    >>> np.binary_repr(-3)
    '-11'
    >>> np.binary_repr(3, width=4)
    '0011'
 
    The two's complement is returned when the input number is negative and
    width is specified:
 
    >>> np.binary_repr(-3, width=3)
    '101'
    >>> np.binary_repr(-3, width=5)
    '11101'
 
    cSs$|dk    r ||kr tjdtdddS)NzQInsufficient bit width provided. This behavior will raise an error in the future.rõ)Ú
stacklevel)ÚwarningsÚwarnÚDeprecationWarning)ÚwidthÚbinwidthrxrxryÚwarn_if_insufficientïs ýz)binary_repr.<locals>.warn_if_insufficientrÚ0rr³Nú-Ú1)råræÚbinr«ÚmaxÚzfill)ÚnumrrÚbinaryrZoutwidthZposwidthZtwocomprxrxryrb§s.H    
  ÿ
 
 
 
cCsŒd}|t|ƒkrtdƒ‚n|dkr*tdƒ‚t|ƒ}g}|rV| |||¡||}q6|rh| d|¡|dkrz| d¡d t|p†dƒ¡S)    aZ
    Return a string representation of a number in the given base system.
 
    Parameters
    ----------
    number : int
        The value to convert. Positive and negative values are handled.
    base : int, optional
        Convert `number` to the `base` number system. The valid range is 2-36,
        the default value is 2.
    padding : int, optional
        Number of zeros padded on the left. Default is 0 (no padding).
 
    Returns
    -------
    out : str
        String representation of `number` in `base` system.
 
    See Also
    --------
    binary_repr : Faster version of `base_repr` for base 2.
 
    Examples
    --------
    >>> np.base_repr(5)
    '101'
    >>> np.base_repr(6, 5)
    '11'
    >>> np.base_repr(7, base=5, padding=3)
    '00012'
 
    >>> np.base_repr(10, base=16)
    'A'
    >>> np.base_repr(32, base=16)
    '20'
 
    Z$0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZz/Bases greater than 36 not handled in base_repr.r³z+Bases less than 2 not handled in base_repr.rrrÚ)r«r¬ÚabsÚappendÚjoinÚreversed)ÚnumberÚbaseÚpaddingÚdigitsrr†rxrxryrcs' 
 
 
cs<t|ƒ}|j‰ˆdkrˆS‡‡fdd„|jDƒ}t|ƒSdS)Ncsg|]}tˆ|dˆƒ‘qSrÑ)Ú_maketup)rµÚname©ÚfieldsÚvalrxryr¸^sz_maketup.<locals>.<listcomp>)rr)Únamesrä)Údescrr*Údtr†rxr(ryr&Ws r&cCs|fSrzrx)ràrrˆrxrxryÚ_identity_dispatcherbsr.cCs0|dk    rt|||dSddlm}||||dS)az
    Return the identity array.
 
    The identity array is a square array with ones on
    the main diagonal.
 
    Parameters
    ----------
    n : int
        Number of rows (and columns) in `n` x `n` output.
    dtype : data-type, optional
        Data-type of the output.  Defaults to ``float``.
    ${ARRAY_FUNCTION_LIKE}
 
        .. versionadded:: 1.20.0
 
    Returns
    -------
    out : ndarray
        `n` x `n` array with its main diagonal set to one,
        and all other elements 0.
 
    Examples
    --------
    >>> np.identity(3)
    array([[1.,  0.,  0.],
           [0.,  1.,  0.],
           [0.,  0.,  1.]])
 
    Nrr)Úeye)Ú_identity_with_likerJr/)ràrrˆr/rxrxryrefs! cCs||fSrzrx©r|r®ÚrtolÚatolÚ    equal_nanrxrxryÚ_allclose_dispatcher“sr5çñh㈵øä>ç:Œ0âŽyE>cCstt|||||dƒ}t|ƒS)aw
    Returns True if two arrays are element-wise equal within a tolerance.
 
    The tolerance values are positive, typically very small numbers.  The
    relative difference (`rtol` * abs(`b`)) and the absolute difference
    `atol` are added together to compare against the absolute difference
    between `a` and `b`.
 
    NaNs are treated as equal if they are in the same place and if
    ``equal_nan=True``.  Infs are treated as equal if they are in the same
    place and of the same sign in both arrays.
 
    Parameters
    ----------
    a, b : array_like
        Input arrays to compare.
    rtol : float
        The relative tolerance parameter (see Notes).
    atol : float
        The absolute tolerance parameter (see Notes).
    equal_nan : bool
        Whether to compare NaN's as equal.  If True, NaN's in `a` will be
        considered equal to NaN's in `b` in the output array.
 
        .. versionadded:: 1.10.0
 
    Returns
    -------
    allclose : bool
        Returns True if the two arrays are equal within the given
        tolerance; False otherwise.
 
    See Also
    --------
    isclose, all, any, equal
 
    Notes
    -----
    If the following equation is element-wise True, then allclose returns
    True.
 
     absolute(`a` - `b`) <= (`atol` + `rtol` * absolute(`b`))
 
    The above equation is not symmetric in `a` and `b`, so that
    ``allclose(a, b)`` might be different from ``allclose(b, a)`` in
    some rare cases.
 
    The comparison of `a` and `b` uses standard broadcasting, which
    means that `a` and `b` need not have the same shape in order for
    ``allclose(a, b)`` to evaluate to True.  The same is true for
    `equal` but not `array_equal`.
 
    `allclose` is not defined for non-numeric data types.
    `bool` is considered a numeric data-type for this purpose.
 
    Examples
    --------
    >>> np.allclose([1e10,1e-7], [1.00001e10,1e-8])
    False
    >>> np.allclose([1e10,1e-8], [1.00001e10,1e-9])
    True
    >>> np.allclose([1e10,1e-8], [1.0001e10,1e-9])
    False
    >>> np.allclose([1.0, np.nan], [1.0, np.nan])
    False
    >>> np.allclose([1.0, np.nan], [1.0, np.nan], equal_nan=True)
    True
 
    )r2r3r4)Úallr`Úbool)r|r®r2r3r4r†rxrxryrf—sGcCs||fSrzrxr1rxrxryÚ_isclose_dispatcherâsr:cCsödd„}t|ƒ}t|ƒ}|jjdkr<t |d¡}t||d}t|ƒ}    t|ƒ}
t|    ƒrjt|
ƒrj|||||ƒS|    |
@} t| dd} |t| ƒ}|t| ƒ}||| || ||ƒ| | <|| || k| | <|rêt    |ƒt    |ƒ@} | | | | <| dSd    S)
aW
    Returns a boolean array where two arrays are element-wise equal within a
    tolerance.
 
    The tolerance values are positive, typically very small numbers.  The
    relative difference (`rtol` * abs(`b`)) and the absolute difference
    `atol` are added together to compare against the absolute difference
    between `a` and `b`.
 
    .. warning:: The default `atol` is not appropriate for comparing numbers
                 that are much smaller than one (see Notes).
 
    Parameters
    ----------
    a, b : array_like
        Input arrays to compare.
    rtol : float
        The relative tolerance parameter (see Notes).
    atol : float
        The absolute tolerance parameter (see Notes).
    equal_nan : bool
        Whether to compare NaN's as equal.  If True, NaN's in `a` will be
        considered equal to NaN's in `b` in the output array.
 
    Returns
    -------
    y : array_like
        Returns a boolean array of where `a` and `b` are equal within the
        given tolerance. If both `a` and `b` are scalars, returns a single
        boolean value.
 
    See Also
    --------
    allclose
    math.isclose
 
    Notes
    -----
    .. versionadded:: 1.7.0
 
    For finite values, isclose uses the following equation to test whether
    two floating point values are equivalent.
 
     absolute(`a` - `b`) <= (`atol` + `rtol` * absolute(`b`))
 
    Unlike the built-in `math.isclose`, the above equation is not symmetric
    in `a` and `b` -- it assumes `b` is the reference value -- so that
    `isclose(a, b)` might be different from `isclose(b, a)`. Furthermore,
    the default value of atol is not zero, and is used to determine what
    small values should be considered close to zero. The default value is
    appropriate for expected values of order unity: if the expected values
    are significantly smaller than one, it can result in false positives.
    `atol` should be carefully selected for the use case at hand. A zero value
    for `atol` will result in `False` if either `a` or `b` is zero.
 
    `isclose` is not defined for non-numeric data types.
    `bool` is considered a numeric data-type for this purpose.
 
    Examples
    --------
    >>> np.isclose([1e10,1e-7], [1.00001e10,1e-8])
    array([ True, False])
    >>> np.isclose([1e10,1e-8], [1.00001e10,1e-9])
    array([ True, True])
    >>> np.isclose([1e10,1e-8], [1.0001e10,1e-9])
    array([False,  True])
    >>> np.isclose([1.0, np.nan], [1.0, np.nan])
    array([ True, False])
    >>> np.isclose([1.0, np.nan], [1.0, np.nan], equal_nan=True)
    array([ True, True])
    >>> np.isclose([1e-8, 1e-7], [0.0, 0.0])
    array([ True, False])
    >>> np.isclose([1e-100, 1e-7], [0.0, 0.0], atol=0.0)
    array([False, False])
    >>> np.isclose([1e-10, 1e-10], [1e-20, 0.0])
    array([ True,  True])
    >>> np.isclose([1e-10, 1e-10], [1e-20, 0.999999e-10], atol=0.0)
    array([False,  True])
    c Ss^tddJtƒ8tt||ƒ||t|ƒƒW5QR£W5QR£SQRXW5QRXdS)NÚignore)Úinvalid)rHrIZ
less_equalr)ÚxÚyr3r2rxrxryÚ
within_tol7    szisclose.<locals>.within_tolÚmgð?rƒT)r~rxN)
rrÚkindrr,Úisfiniter8rQrRÚisnan)r|r®r2r3r4r?r=r>r-ZxfinZyfinZfiniteZcondZboth_nanrxrxryr`æs(Q           cCs||fSrzrx)rùrúr4rxrxryÚ_array_equal_dispatcherc    srDcCs˜zt|ƒt|ƒ}}Wntk
r,YdSX|j|jkr>dS|sVtt||kƒ ¡ƒSt|ƒt|ƒ}}||k ¡sxdStt||||kƒ ¡ƒS)a
    True if two arrays have the same shape and elements, False otherwise.
 
    Parameters
    ----------
    a1, a2 : array_like
        Input arrays.
    equal_nan : bool
        Whether to compare NaN's as equal. If the dtype of a1 and a2 is
        complex, values will be considered equal if either the real or the
        imaginary component of a given value is ``nan``.
 
        .. versionadded:: 1.19.0
 
    Returns
    -------
    b : bool
        Returns True if the arrays are equal.
 
    See Also
    --------
    allclose: Returns True if two arrays are element-wise equal within a
              tolerance.
    array_equiv: Returns True if input arrays are shape consistent and all
                 elements equal.
 
    Examples
    --------
    >>> np.array_equal([1, 2], [1, 2])
    True
    >>> np.array_equal(np.array([1, 2]), np.array([1, 2]))
    True
    >>> np.array_equal([1, 2], [1, 2, 3])
    False
    >>> np.array_equal([1, 2], [1, 4])
    False
    >>> a = np.array([1, np.nan])
    >>> np.array_equal(a, a)
    False
    >>> np.array_equal(a, a, equal_nan=True)
    True
 
    When ``equal_nan`` is True, complex values with nan components are
    considered equal if either the real *or* the imaginary components are nan.
 
    >>> a = np.array([1 + 1j])
    >>> b = a.copy()
    >>> a.real = np.nan
    >>> b.imag = np.nan
    >>> np.array_equal(a, b, equal_nan=True)
    True
    F)rrÂrr9r8rC)rùrúr4Za1nanZa2nanrxrxryr\g    s6  cCs||fSrzrx©rùrúrxrxryÚ_array_equiv_dispatcher®    srFcCsjzt|ƒt|ƒ}}Wntk
r,YdSXzt ||¡Wntk
rTYdSXtt||kƒ ¡ƒS)aå
    Returns True if input arrays are shape consistent and all elements equal.
 
    Shape consistent means they are either the same shape, or one input array
    can be broadcasted to create the same shape as the other one.
 
    Parameters
    ----------
    a1, a2 : array_like
        Input arrays.
 
    Returns
    -------
    out : bool
        True if equivalent, False otherwise.
 
    Examples
    --------
    >>> np.array_equiv([1, 2], [1, 2])
    True
    >>> np.array_equiv([1, 2], [1, 3])
    False
 
    Showing the shape equivalence:
 
    >>> np.array_equiv([1, 2], [[1, 2], [1, 2]])
    True
    >>> np.array_equiv([1, 2], [[1, 2, 1, 2], [1, 2, 1, 2]])
    False
 
    >>> np.array_equiv([1, 2], [[1, 2], [1, 3]])
    False
 
    F)rrÂrrr9r8rErxrxryr]²    s$cCs2ttƒ}t|dƒ}|D]}||krt |¡qdS)NÚ__all__)rçrGÚgetattrr)rKÚexistingZmallr|rxrxryÚ
extend_allè    s
 
rJ)Ú*)Ú fromnumeric)Ú
arrayprint)Ú_asarray)Ú _ufunc_config)NNNN)NrTN)NN)NrŠ)NNNN)NrTN)NN)NrŠ)NNNN)NrTN)N)N)N)r¨)N)rr)N)N)N)r³)N)N)N)r)NF)NNNN)rªrªrªN)N)r³r)N)N)NNN)r6r7F)NNN)r6r7F)N)F)£Ú    functoolsrÖråÚsysrr rJr—rrrrrrrr    r
r r r rrrrrrrrrrrrrrrrrrr r!r"r#r$r%r&r'r(r)r*r+r,r-r.r/r0r1r2r3r4r5r6r7r8r9r:r;r<r=r>r?r@rArBrCrDrEÚ _exceptionsrFrGrOrHrIrpr™rMrLÚpartialZarray_function_dispatchrGÚRuntimeWarningrqr€rQr‰rdrŒrrRrrrr‘r’rsr•rNrPržrOr¢rgr§rSr©rTr°rUr²rZrÏrVrÝrWrÓrërXrôrYÚ    byteorderr[rÆr^rÚfloatr_rr    rarbrcr&r.rer0r5rfr:r`rDr\rFr]rhrirjrkrlrmrnrorJrLrMrNrxrxrxryÚ<module>sð Ì     ÿî
 D:ÿþ
 B9ÿþ
 EI
C
1
(
 I
 b
 W
 A
 j
 Y
;
F
 J
fEÿþ
P r < &ÿþ
 J
 |
 F
/