PyPyNum 1.9.0__py3-none-any.whl → 1.9.2__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {PyPyNum-1.9.0.dist-info → PyPyNum-1.9.2.dist-info}/METADATA +126 -90
- {PyPyNum-1.9.0.dist-info → PyPyNum-1.9.2.dist-info}/RECORD +19 -18
- {PyPyNum-1.9.0.dist-info → PyPyNum-1.9.2.dist-info}/WHEEL +1 -1
- pypynum/Array.py +93 -50
- pypynum/Matrix.py +5 -0
- pypynum/README.md +125 -89
- pypynum/Tensor.py +7 -4
- pypynum/Tree.py +43 -7
- pypynum/__init__.py +3 -2
- pypynum/cipher.py +67 -0
- pypynum/equations.py +2 -2
- pypynum/maths.py +51 -36
- pypynum/numbers.py +58 -9
- pypynum/plotting.py +10 -27
- pypynum/polynomial.py +108 -4
- pypynum/regression.py +2 -4
- pypynum/test.py +2 -3
- pypynum/ufuncs.py +102 -0
- {PyPyNum-1.9.0.dist-info → PyPyNum-1.9.2.dist-info}/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: PyPyNum
|
|
3
|
-
Version: 1.9.
|
|
3
|
+
Version: 1.9.2
|
|
4
4
|
Summary: A multifunctional mathematical calculation package written in pure Python programming language [Python>=3.4]
|
|
5
5
|
Home-page: https://github.com/PythonSJL/PyPyNum
|
|
6
6
|
Author: Shen Jiayi
|
|
@@ -692,7 +692,7 @@ Description-Content-Type: text/markdown
|
|
|
692
692
|
[](https://pepy.tech/project/pypynum)
|
|
693
693
|
[](https://pepy.tech/project/pypynum)
|
|
694
694
|
|
|
695
|
-
## Version -> 1.9.
|
|
695
|
+
## Version -> 1.9.2 | PyPI -> https://pypi.org/project/PyPyNum/ | Gitee -> https://www.gitee.com/PythonSJL/PyPyNum | GitHub -> https://github.com/PythonSJL/PyPyNum
|
|
696
696
|
|
|
697
697
|

|
|
698
698
|
|
|
@@ -748,6 +748,7 @@ The logo cannot be displayed on PyPI, it can be viewed in Gitee or GitHub.
|
|
|
748
748
|
| `pypynum.tools` | 辅助函数 Auxiliary functions |
|
|
749
749
|
| `pypynum.Tree` | 树形数据结构 Tree data structure |
|
|
750
750
|
| `pypynum.types` | 特殊类型 Special types |
|
|
751
|
+
| `pypynum.ufuncs` | 通用函数 Universal functions |
|
|
751
752
|
| `pypynum.utils` | 实用工具 Utility |
|
|
752
753
|
| `pypynum.Vector` | 向量运算 Vector operation |
|
|
753
754
|
|
|
@@ -789,61 +790,74 @@ Python interpreter and run it!
|
|
|
789
790
|
```
|
|
790
791
|
!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=
|
|
791
792
|
|
|
792
|
-
|
|
793
|
+
新增代码行数大约三百行
|
|
793
794
|
|
|
794
|
-
|
|
795
|
-
|
|
795
|
+
Approximately 300 new lines of
|
|
796
|
+
code added
|
|
796
797
|
|
|
797
798
|
!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=
|
|
798
799
|
|
|
799
|
-
|
|
800
|
+
修改过的函数
|
|
800
801
|
|
|
801
|
-
|
|
802
|
-
been renamed, please be careful
|
|
803
|
-
when using them.
|
|
802
|
+
Modified functions
|
|
804
803
|
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
804
|
+
├── Array
|
|
805
|
+
fill(shape: Any, sequence: Any, repeat: Any, pad: Any, rtype: Any) -> Any
|
|
806
|
+
zeros(shape: Any, rtype: Any) -> Any
|
|
807
|
+
zeros_like(a: Any, rtype: Any) -> Any
|
|
809
808
|
|
|
810
809
|
!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=
|
|
811
810
|
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
811
|
+
新增加的函数
|
|
812
|
+
|
|
813
|
+
Newly added functions
|
|
814
|
+
|
|
815
|
+
class Polynomial(builtins.object)
|
|
816
|
+
<以下为新增加的方法>
|
|
817
|
+
<The following are the newly added methods>
|
|
818
|
+
__divmod__ = __truediv__(self, other)
|
|
819
|
+
__float__(self)
|
|
820
|
+
__int__(self)
|
|
821
|
+
__round__(self, n=None)
|
|
822
|
+
coeffs(self, reverse=False)
|
|
823
|
+
degs(self, reverse=False)
|
|
824
|
+
deriv(self)
|
|
825
|
+
evaluate(self, x)
|
|
826
|
+
gcd(self, other)
|
|
827
|
+
integ(self, constant=0)
|
|
828
|
+
is_zero(self)
|
|
829
|
+
latex(self)
|
|
830
|
+
lcm(self, other)
|
|
831
|
+
roots(self)
|
|
832
|
+
sqrt(self)
|
|
827
833
|
|
|
828
834
|
PyPyNum
|
|
829
|
-
├──
|
|
835
|
+
├── Array
|
|
830
836
|
│ └── FUNCTION
|
|
831
|
-
│ ├──
|
|
832
|
-
│ ├──
|
|
833
|
-
│ ├──
|
|
834
|
-
│ ├──
|
|
835
|
-
|
|
836
|
-
│ ├── rot13(text: str) -> str
|
|
837
|
-
│ ├── substitution(text: str, sub_map: dict, decrypt: bool) -> str
|
|
838
|
-
│ └── vigenere(text: str, key: str, decrypt: bool) -> str
|
|
839
|
-
├── probability
|
|
837
|
+
│ ├── full(shape: Any, fill_value: Any, rtype: Any) -> Any
|
|
838
|
+
│ ├── full_like(a: Any, fill_value: Any, rtype: Any) -> Any
|
|
839
|
+
│ ├── ones(shape: Any, rtype: Any) -> Any
|
|
840
|
+
│ ├── ones_like(a: Any, rtype: Any) -> Any
|
|
841
|
+
├── maths
|
|
840
842
|
│ └── FUNCTION
|
|
841
|
-
│ ├──
|
|
842
|
-
|
|
843
|
-
└──
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
843
|
+
│ ├── sumprod(arrays: typing.Union[list, tuple]) -> typing.Union[int, float, complex]
|
|
844
|
+
├── polynomial
|
|
845
|
+
│ └── FUNCTION
|
|
846
|
+
│ ├── from_coeffs(coeffs: Any) -> Any
|
|
847
|
+
│ ├── leggauss(polynomial: Any) -> Any
|
|
848
|
+
│ ├── legpoly(n: Any) -> Any
|
|
849
|
+
├── ufuncs
|
|
850
|
+
│ ├── CLASS
|
|
851
|
+
│ └── FUNCTION
|
|
852
|
+
│ ├── add(x: Any, y: Any) -> Any
|
|
853
|
+
│ ├── base_ufunc(arrays: Any, func: Any, args: Any, rtype: Any) -> Any
|
|
854
|
+
│ ├── divide(x: Any, y: Any) -> Any
|
|
855
|
+
│ ├── floor_divide(x: Any, y: Any) -> Any
|
|
856
|
+
│ ├── modulo(x: Any, y: Any) -> Any
|
|
857
|
+
│ ├── multiply(x: Any, y: Any) -> Any
|
|
858
|
+
│ ├── power(x: Any, y: Any, m: Any) -> Any
|
|
859
|
+
│ ├── subtract(x: Any, y: Any) -> Any
|
|
860
|
+
│ └── ufunc_helper(x: Any, y: Any, func: Any) -> Any
|
|
847
861
|
```
|
|
848
862
|
|
|
849
863
|
### 运行用时测试
|
|
@@ -873,12 +887,15 @@ PyPyNum
|
|
|
873
887
|
│ │ └── Array(object)/__init__(self: Any, data: Any, check: Any) -> Any
|
|
874
888
|
│ └── FUNCTION
|
|
875
889
|
│ ├── array(data: Any) -> Any
|
|
876
|
-
│ ├── fill(shape: Any, sequence: Any, repeat: Any) -> Any
|
|
877
|
-
│ ├──
|
|
890
|
+
│ ├── fill(shape: Any, sequence: Any, repeat: Any, pad: Any, rtype: Any) -> Any
|
|
891
|
+
│ ├── full(shape: Any, fill_value: Any, rtype: Any) -> Any
|
|
892
|
+
│ ├── full_like(a: Any, fill_value: Any, rtype: Any) -> Any
|
|
878
893
|
│ ├── get_shape(data: Any) -> Any
|
|
879
894
|
│ ├── is_valid_array(_array: Any, _shape: Any) -> Any
|
|
880
|
-
│ ├──
|
|
881
|
-
│
|
|
895
|
+
│ ├── ones(shape: Any, rtype: Any) -> Any
|
|
896
|
+
│ ├── ones_like(a: Any, rtype: Any) -> Any
|
|
897
|
+
│ ├── zeros(shape: Any, rtype: Any) -> Any
|
|
898
|
+
│ └── zeros_like(a: Any, rtype: Any) -> Any
|
|
882
899
|
├── FourierT
|
|
883
900
|
│ ├── CLASS
|
|
884
901
|
│ │ └── FT1D(object)/__init__(self: Any, data: Any) -> Any
|
|
@@ -1001,8 +1018,12 @@ PyPyNum
|
|
|
1001
1018
|
│ ├── atbash(text: str) -> str
|
|
1002
1019
|
│ ├── base_64(text: str, decrypt: bool) -> str
|
|
1003
1020
|
│ ├── caesar(text: str, shift: int, decrypt: bool) -> str
|
|
1021
|
+
│ ├── hill256(text: bytes, key: list, decrypt: bool) -> bytes
|
|
1022
|
+
│ ├── ksa(key: bytes) -> list
|
|
1004
1023
|
│ ├── morse(text: str, decrypt: bool) -> str
|
|
1005
1024
|
│ ├── playfair(text: str, key: str, decrypt: bool) -> str
|
|
1025
|
+
│ ├── prga(s: list) -> Any
|
|
1026
|
+
│ ├── rc4(text: bytes, key: bytes) -> bytes
|
|
1006
1027
|
│ ├── rot13(text: str) -> str
|
|
1007
1028
|
│ ├── substitution(text: str, sub_map: dict, decrypt: bool) -> str
|
|
1008
1029
|
│ └── vigenere(text: str, key: str, decrypt: bool) -> str
|
|
@@ -1092,22 +1113,24 @@ PyPyNum
|
|
|
1092
1113
|
│ ├── sech(x: typing.Union[int, float]) -> typing.Union[int, float]
|
|
1093
1114
|
│ ├── sigma(i: int, n: int, f: Any) -> typing.Union[int, float, complex]
|
|
1094
1115
|
│ ├── sigmoid(x: typing.Union[int, float]) -> float
|
|
1095
|
-
│ ├── sign(x: typing.Union[int, float]) -> int
|
|
1116
|
+
│ ├── sign(x: typing.Union[int, float, complex]) -> typing.Union[int, float, complex]
|
|
1096
1117
|
│ ├── sin(x: typing.Union[int, float]) -> typing.Union[int, float]
|
|
1097
1118
|
│ ├── sinh(x: typing.Union[int, float]) -> typing.Union[int, float]
|
|
1098
1119
|
│ ├── skew(data: typing.Union[list, tuple]) -> float
|
|
1099
1120
|
│ ├── square_mean(numbers: typing.Union[list, tuple]) -> typing.Union[int, float, complex]
|
|
1100
1121
|
│ ├── std(numbers: typing.Union[list, tuple], dof: int) -> typing.Union[int, float, complex]
|
|
1122
|
+
│ ├── sumprod(arrays: typing.Union[list, tuple]) -> typing.Union[int, float, complex]
|
|
1101
1123
|
│ ├── tan(x: typing.Union[int, float]) -> typing.Union[int, float]
|
|
1102
1124
|
│ ├── tanh(x: typing.Union[int, float]) -> typing.Union[int, float]
|
|
1103
1125
|
│ ├── totient(n: int) -> int
|
|
1104
1126
|
│ ├── var(numbers: typing.Union[list, tuple], dof: int) -> typing.Union[int, float, complex]
|
|
1105
|
-
│ └── zeta(alpha: typing.Union[int, float]) -> float
|
|
1127
|
+
│ └── zeta(alpha: typing.Union[int, float, complex]) -> typing.Union[int, float, complex]
|
|
1106
1128
|
├── numbers
|
|
1107
1129
|
│ ├── CLASS
|
|
1108
1130
|
│ └── FUNCTION
|
|
1109
1131
|
│ ├── float2fraction(number: float, mixed: bool, error: float) -> tuple
|
|
1110
1132
|
│ ├── int2roman(integer: int, overline: bool) -> str
|
|
1133
|
+
│ ├── int2words(integer: int) -> str
|
|
1111
1134
|
│ ├── roman2int(roman_num: str) -> int
|
|
1112
1135
|
│ └── str2int(string: str) -> int
|
|
1113
1136
|
├── plotting
|
|
@@ -1115,7 +1138,7 @@ PyPyNum
|
|
|
1115
1138
|
│ └── FUNCTION
|
|
1116
1139
|
│ ├── background(right: typing.Union[int, float], left: typing.Union[int, float], top: typing.Union[int, float], bottom: typing.Union[int, float], complexity: typing.Union[int, float], ratio: typing.Union[int, float], string: bool) -> typing.Union[list, str]
|
|
1117
1140
|
│ ├── binary(function: Any, right: typing.Union[int, float], left: typing.Union[int, float], top: typing.Union[int, float], bottom: typing.Union[int, float], complexity: typing.Union[int, float], ratio: typing.Union[int, float], error: Any, compare: Any, string: bool, basic: list, character: str, data: bool, coloration: Any) -> typing.Union[list, str]
|
|
1118
|
-
│ ├── c_unary(function: Any,
|
|
1141
|
+
│ ├── c_unary(function: Any, projection: str, right: typing.Union[int, float], left: typing.Union[int, float], top: typing.Union[int, float], bottom: typing.Union[int, float], complexity: typing.Union[int, float], ratio: typing.Union[int, float], string: bool, basic: list, character: str, data: bool, coloration: Any) -> typing.Union[list, str]
|
|
1119
1142
|
│ ├── change(data: typing.Union[list, str]) -> typing.Union[list, str]
|
|
1120
1143
|
│ ├── color(text: str, rgb: typing.Union[list, tuple]) -> str
|
|
1121
1144
|
│ └── unary(function: Any, right: typing.Union[int, float], left: typing.Union[int, float], top: typing.Union[int, float], bottom: typing.Union[int, float], complexity: typing.Union[int, float], ratio: typing.Union[int, float], string: bool, basic: list, character: str, data: bool, coloration: Any) -> typing.Union[list, str]
|
|
@@ -1123,6 +1146,9 @@ PyPyNum
|
|
|
1123
1146
|
│ ├── CLASS
|
|
1124
1147
|
│ │ └── Polynomial(object)/__init__(self: Any, terms: Any) -> Any
|
|
1125
1148
|
│ └── FUNCTION
|
|
1149
|
+
│ ├── from_coeffs(coeffs: Any) -> Any
|
|
1150
|
+
│ ├── leggauss(polynomial: Any) -> Any
|
|
1151
|
+
│ ├── legpoly(n: Any) -> Any
|
|
1126
1152
|
│ └── poly(terms: Any) -> Any
|
|
1127
1153
|
├── probability
|
|
1128
1154
|
│ ├── CLASS
|
|
@@ -1180,6 +1206,18 @@ PyPyNum
|
|
|
1180
1206
|
├── types
|
|
1181
1207
|
│ ├── CLASS
|
|
1182
1208
|
│ └── FUNCTION
|
|
1209
|
+
├── ufuncs
|
|
1210
|
+
│ ├── CLASS
|
|
1211
|
+
│ └── FUNCTION
|
|
1212
|
+
│ ├── add(x: Any, y: Any) -> Any
|
|
1213
|
+
│ ├── base_ufunc(arrays: Any, func: Any, args: Any, rtype: Any) -> Any
|
|
1214
|
+
│ ├── divide(x: Any, y: Any) -> Any
|
|
1215
|
+
│ ├── floor_divide(x: Any, y: Any) -> Any
|
|
1216
|
+
│ ├── modulo(x: Any, y: Any) -> Any
|
|
1217
|
+
│ ├── multiply(x: Any, y: Any) -> Any
|
|
1218
|
+
│ ├── power(x: Any, y: Any, m: Any) -> Any
|
|
1219
|
+
│ ├── subtract(x: Any, y: Any) -> Any
|
|
1220
|
+
│ └── ufunc_helper(x: Any, y: Any, func: Any) -> Any
|
|
1183
1221
|
└── utils
|
|
1184
1222
|
├── CLASS
|
|
1185
1223
|
│ ├── InfIterator(object)/__init__(self: Any, start: typing.Union[int, float, complex], mode: str, common: typing.Union[int, float, complex]) -> Any
|
|
@@ -1400,9 +1438,7 @@ print(equations.polynomial_equation(p))
|
|
|
1400
1438
|
print(equations.linear_equation(*m))
|
|
1401
1439
|
|
|
1402
1440
|
"""
|
|
1403
|
-
[
|
|
1404
|
-
[ 0 (2.5615528128088294+4.456233626665941e-24j) 0]
|
|
1405
|
-
[ 0 0 (1.0000000000000007+3.241554513744382e-25j)]]
|
|
1441
|
+
[(-1.5615528128088307-6.5209667308287455e-24j) (1.0000000000000007+3.241554513744382e-25j) (2.5615528128088294+4.456233626665941e-24j)]
|
|
1406
1442
|
[ 1.6666666666666667 -0.6666666666666666 -0.4444444444444444]
|
|
1407
1443
|
"""
|
|
1408
1444
|
|
|
@@ -1425,7 +1461,7 @@ print(maths.var([2, 3, 5, 7, 11, 13, 17, 19, 23, 29]))
|
|
|
1425
1461
|
plt = plotting.unary(lambda x: x ** 2, top=10, bottom=0, character="+")
|
|
1426
1462
|
print(plt)
|
|
1427
1463
|
print(plotting.binary(lambda x, y: x ** 2 + y ** 2 - 10, right=10, left=0, compare="<=", basic=plotting.change(plt)))
|
|
1428
|
-
print(plotting.c_unary(lambda x: x ** x,
|
|
1464
|
+
print(plotting.c_unary(lambda x: x ** x, right=2, left=-2, top=2, bottom=-2, complexity=20, character="-"))
|
|
1429
1465
|
|
|
1430
1466
|
"""
|
|
1431
1467
|
1.00e+01| + +
|
|
@@ -1466,34 +1502,34 @@ print(plotting.c_unary(lambda x: x ** x, start=-10, end=10, interval=100, right=
|
|
|
1466
1502
|
| +++ +++
|
|
1467
1503
|
0.00e+00|________________________+++________________________
|
|
1468
1504
|
-5.00e+00 0.00e+00 5.00e+00
|
|
1469
|
-
2.00e+00|
|
|
1470
|
-
|
|
|
1471
|
-
|
|
|
1472
|
-
|
|
1473
|
-
|
|
|
1474
|
-
|
|
|
1475
|
-
|
|
|
1476
|
-
|
|
|
1477
|
-
|
|
|
1478
|
-
|
|
|
1479
|
-
|
|
|
1480
|
-
|
|
|
1481
|
-
|
|
|
1482
|
-
0.00e+00|_ _ _ _ _ _ _ _
|
|
1483
|
-
|
|
|
1484
|
-
|
|
|
1485
|
-
|
|
|
1486
|
-
|
|
|
1487
|
-
|
|
|
1488
|
-
|
|
|
1489
|
-
|
|
|
1490
|
-
|
|
|
1491
|
-
|
|
|
1492
|
-
|
|
|
1493
|
-
|
|
1494
|
-
|
|
|
1495
|
-
|
|
|
1496
|
-
-2.00e+00|
|
|
1505
|
+
2.00e+00| - - - - - -
|
|
1506
|
+
| - - - - - - -
|
|
1507
|
+
| - - - - - -
|
|
1508
|
+
|- - - - - - -
|
|
1509
|
+
| - - - - -- - - - -
|
|
1510
|
+
| - - - - - - - - -
|
|
1511
|
+
| - - - - -- - --- -- - -- - - - - -
|
|
1512
|
+
| - - - -- -- - - - -- - - -
|
|
1513
|
+
| - - - - - - - -- - --- --- - - --- -- - -
|
|
1514
|
+
| - - - - - -- ----- -- -- --- -- -- --- -- - -
|
|
1515
|
+
| - - - ------------ ---- - -- -- - --- - - -
|
|
1516
|
+
| - - - - - ----- - -- ----------------------- -- ---- - -- --
|
|
1517
|
+
| - - - - - ---- --------------------------------- - - - - - -
|
|
1518
|
+
0.00e+00|_ _ _ _ _ _ _ _-_-_-_-_---- ------------------------------------_-- _ _ _ _ _ _ _
|
|
1519
|
+
| - - - - ----------------------------------------- -- - - - -
|
|
1520
|
+
| - -- - - -- - - --------------------------------- - - -
|
|
1521
|
+
| - - ---- - - -- --------------------- ----- ---- - -- -
|
|
1522
|
+
| - - -- --------- -- -- - ----- --- -- - - - -
|
|
1523
|
+
| - - - - - - - ---- --- --- --- -- -- --- - - -
|
|
1524
|
+
| - - - - - -- -- -- - - -- -- --
|
|
1525
|
+
| - - - -- - -- -- - - -- - -
|
|
1526
|
+
| - - - - - - - -- - - -- - -
|
|
1527
|
+
| - - - - -- -- - - - - -
|
|
1528
|
+
| - - - - - - - -
|
|
1529
|
+
|- - - - - - - -
|
|
1530
|
+
| - - - - - -
|
|
1531
|
+
| - - - - -
|
|
1532
|
+
-2.00e+00|___________-_________________-___________-_____________________-____________-____
|
|
1497
1533
|
-2.00e+00 0.00e+00 2.00e+00
|
|
1498
1534
|
"""
|
|
1499
1535
|
|
|
@@ -1503,10 +1539,10 @@ print(random.randint(0, 9, [2, 3, 4]))
|
|
|
1503
1539
|
print(random.uniform(0, 9, [2, 3, 4]))
|
|
1504
1540
|
|
|
1505
1541
|
"""
|
|
1506
|
-
[[[
|
|
1507
|
-
[[[0.
|
|
1508
|
-
[[[
|
|
1509
|
-
[[[
|
|
1542
|
+
[[[2.0337109813389342, 0.07828151434838644, 0.5770175491332994, -0.45862437785903776], [-0.5647580909376742, 0.04013315334953438, -1.4415329001085142, 0.21063309355876483], [-0.13079032580688052, -0.12269092226721959, -1.0486596849517071, 0.33707912556088127]], [[1.0924880424965842, -0.2904666571377903, -0.8147193339820543, -0.12425697574808597], [-0.9431495143889028, 1.6993259508582454, 2.459143670684122, 0.6706774051649211], [-0.2067467760214054, -1.335666880934244, -0.06604610266464511, 1.4659516633001894]]]
|
|
1543
|
+
[[[0.5056293647418786, 0.41138133426895374, 0.1116780669974381, 0.5421022799938007], [0.8529591223803364, 0.7967626494191837, 0.6778986058446654, 0.7966034784840031], [0.8226174224158366, 0.6882274477983558, 0.2043768498847348, 0.20649565416723548]], [[0.7858708880353261, 0.293208591223893, 0.9713037501099235, 0.1277647867709274], [0.5310738736523741, 0.3775394394569467, 0.6618665928287699, 0.7813821035754579], [0.41759114496811056, 0.8741519554894022, 0.8325056303107449, 0.8127323540413558]]]
|
|
1544
|
+
[[[5, 9, 7, 5], [9, 9, 9, 8], [6, 2, 0, 3]], [[4, 7, 5, 8], [5, 7, 2, 4], [9, 9, 2, 2]]]
|
|
1545
|
+
[[[7.666875196011509, 4.2629925536138815, 6.269304350870346, 6.1616482850575816], [8.736107228623906, 4.050564635824004, 8.719616126170123, 8.241460211008127], [2.2965292897567497, 2.3960057526618233, 2.406429664045121, 7.644380154396355]], [[3.8027437908649793, 5.075197041264121, 3.778237396690295, 0.9427794634466875], [1.9182768078467933, 6.926954119152528, 2.5353235396092666, 3.0648655668955422], [8.538065261473607, 7.652025295242501, 4.086320910353441, 7.457914057699455]]]
|
|
1510
1546
|
"""
|
|
1511
1547
|
|
|
1512
1548
|
print(regression.linear_regression(list(range(5)), [2, 4, 6, 7, 8]))
|
|
@@ -1515,8 +1551,8 @@ print(regression.polynomial_regression(list(range(5)), [2, 4, 6, 7, 8], 4))
|
|
|
1515
1551
|
|
|
1516
1552
|
"""
|
|
1517
1553
|
[1.5, 2.4000000000000004]
|
|
1518
|
-
[-0.
|
|
1519
|
-
[0.
|
|
1554
|
+
[-0.21428571428571563, 2.3571428571428625, 1.971428571428569]
|
|
1555
|
+
[0.0833333333480164, -0.6666666668091551, 1.416666667838451, 1.1666666648311779, 2.0000000002900586]
|
|
1520
1556
|
"""
|
|
1521
1557
|
|
|
1522
1558
|
print(tools.classify([1, 2.3, 4 + 5j, "string", list, True, 3.14, False, tuple, tools]))
|
|
@@ -1525,7 +1561,7 @@ print(tools.frange(0, 3, 0.4))
|
|
|
1525
1561
|
print(tools.linspace(0, 2.8, 8))
|
|
1526
1562
|
|
|
1527
1563
|
"""
|
|
1528
|
-
{<class 'int'>: [1], <class 'float'>: [2.3, 3.14], <class 'complex'>: [(4+5j)], <class 'str'>: ['string'], <class 'type'>: [<class 'list'>, <class 'tuple'>], <class 'bool'>: [True, False], <class 'module'>: [<module 'pypynum.tools' from '
|
|
1564
|
+
{<class 'int'>: [1], <class 'float'>: [2.3, 3.14], <class 'complex'>: [(4+5j)], <class 'str'>: ['string'], <class 'type'>: [<class 'list'>, <class 'tuple'>], <class 'bool'>: [True, False], <class 'module'>: [<module 'pypynum.tools' from 'C:\\Users\\Administrator\\PycharmProjects\\pythonProject\\pypynum\\tools.py'>]}
|
|
1529
1565
|
['Python', 6, 'NumPy', <class 'int'>, 'PyPyNum', 9, 'pypynum', True]
|
|
1530
1566
|
[0.0, 0.4, 0.8, 1.2000000000000002, 1.6, 2.0, 2.4000000000000004, 2.8000000000000003]
|
|
1531
1567
|
[0.0, 0.39999999999999997, 0.7999999999999999, 1.2, 1.5999999999999999, 1.9999999999999998, 2.4, 2.8]
|
|
@@ -1,39 +1,40 @@
|
|
|
1
|
-
pypynum/Array.py,sha256=
|
|
1
|
+
pypynum/Array.py,sha256=izB5QfStvpRmYLdlqYl-N3GO0P6m4Ub6E23deKj2-HE,8604
|
|
2
2
|
pypynum/FourierT.py,sha256=AtG0tESykzEs4gDsXhcizW7qhQnmw0gjcWcXefBqzhs,1401
|
|
3
3
|
pypynum/Geometry.py,sha256=bJCuif-wHO-t7oHFEE7ntzIdQwzUEbT3mcKgmBV6Wps,13982
|
|
4
4
|
pypynum/Graph.py,sha256=m9iTCNYRCZmAexDzwJ8Y6J7v1aweT-6TZkqh4fOtZDE,10131
|
|
5
5
|
pypynum/Group.py,sha256=m39OZNRoG9b3p_7sS1u50A0rJl0aYqYPVvnttkYQ_gw,2944
|
|
6
6
|
pypynum/Logic.py,sha256=IJAv59ECHU0HmG9lYCAQ_puqeL6Zor3-IDIVH48KBWE,11000
|
|
7
|
-
pypynum/Matrix.py,sha256=
|
|
7
|
+
pypynum/Matrix.py,sha256=b2op-7V-6OQJLeHqFFRbZ2766ZdueZ485t04UeGQrLc,18248
|
|
8
8
|
pypynum/NeuralN.py,sha256=iSOvC9JW1h4AFGokGGOTkKie5hAYN_YT9H4f3apI9b8,3275
|
|
9
9
|
pypynum/PyPyNum.png,sha256=t96tJPWfHxT8kcXm_qZI2z5W36TgOqjCU9qdgbmlFws,11623
|
|
10
10
|
pypynum/Quaternion.py,sha256=-BW_crP_i-veHN0_pD3Z1dipFNUX198oZDrUYTsoZw0,8017
|
|
11
|
-
pypynum/README.md,sha256=
|
|
11
|
+
pypynum/README.md,sha256=4ZmUnLvcZM3JzhKH_cV3_ry6LGavjY8Pbymo8GV0kDM,56625
|
|
12
12
|
pypynum/Symbolics.py,sha256=u-Dig3OLs6qoLzxMpTAYJGq5uSWDMvgU13TAHKLyjMY,2768
|
|
13
|
-
pypynum/Tensor.py,sha256=
|
|
14
|
-
pypynum/Tree.py,sha256=
|
|
13
|
+
pypynum/Tensor.py,sha256=gi7OjrGgP5BSJS9Oma1B2EdX9qSpMNIP2BnKLojdT78,3930
|
|
14
|
+
pypynum/Tree.py,sha256=BYnlb2kKNJ8kkuq8BAHIcLvPZw5KHxbvM7YuVGhQVMk,4330
|
|
15
15
|
pypynum/Vector.py,sha256=0GSLDmUE0ZWB4JELB4rL6xHhf767wJlSIIdLt2ZpO9M,3526
|
|
16
|
-
pypynum/__init__.py,sha256=
|
|
16
|
+
pypynum/__init__.py,sha256=dfbbZv0z8rF8t-zfg9aA6QaSSUFZa3N6eE49o-N2LkA,1964
|
|
17
17
|
pypynum/chars.py,sha256=VcK9w0i73FMCzc-9aIibjdHqyMsofJXdoBq0d8L7Vr0,1001
|
|
18
|
-
pypynum/cipher.py,sha256=
|
|
18
|
+
pypynum/cipher.py,sha256=DaitY3DCoTuzyrXtD8Ap3IYDLhlMc7-o4AJfLlicvB4,10011
|
|
19
19
|
pypynum/constants.py,sha256=xELv4DIKEqBdwF9tUqCmTQVbgVrlrj385ht5eawvshU,1406
|
|
20
|
-
pypynum/equations.py,sha256=
|
|
20
|
+
pypynum/equations.py,sha256=jwdW2eKBEkL5sMJQINtTycushz6ng3gKrL3aEDECSf4,770
|
|
21
21
|
pypynum/errors.py,sha256=I3nh5YD5F_sBoa7hjPJi81goRflbVAZcjtmW7O2BhJk,220
|
|
22
22
|
pypynum/file.py,sha256=rqrPdcX0NOEPM8s40-ymgPKsTn0HKABW-VEh1OtPnsk,3188
|
|
23
|
-
pypynum/maths.py,sha256=
|
|
24
|
-
pypynum/numbers.py,sha256=
|
|
25
|
-
pypynum/plotting.py,sha256=
|
|
26
|
-
pypynum/polynomial.py,sha256=
|
|
23
|
+
pypynum/maths.py,sha256=3DA3TV8gON4A2Cp_Tt6wwbFPWQLJIniUxOKnt1OfROg,27602
|
|
24
|
+
pypynum/numbers.py,sha256=S49O4z_uO2FKLdOpAhDtKSVRbG8_xB8ihVDoPYiVlcE,7880
|
|
25
|
+
pypynum/plotting.py,sha256=mbIYK5TpY1qvuMJrqz4d8bxJEiZww3AI684vSKV-DgU,7781
|
|
26
|
+
pypynum/polynomial.py,sha256=B4HN_H3V_Ffcg3RQOY_c3SBZvAYhSkCe_u5PCmPSMHk,9362
|
|
27
27
|
pypynum/probability.py,sha256=aUHaS7NMIJJWI8vZktgvn1zQKLtjdBiY5d-qwbJ6fGM,3778
|
|
28
28
|
pypynum/random.py,sha256=vfTtyH5yOSKJoSI_-NT_Tg8wC-ZXT0wt34f87oaSpJY,4610
|
|
29
|
-
pypynum/regression.py,sha256=
|
|
29
|
+
pypynum/regression.py,sha256=HNGifq9rhS7JWFO12nvbP978IZaOOAmgibJURpqYV_0,2070
|
|
30
30
|
pypynum/sequence.py,sha256=7NSZm_p_B00KFj5XZrtSm2FXhsowxs0qg_Q_P4pAA8o,7194
|
|
31
|
-
pypynum/test.py,sha256=
|
|
31
|
+
pypynum/test.py,sha256=ph9oBFjwT1DNUAqdEivJfhIaysDsgWxwLFi8Ekx733U,9119
|
|
32
32
|
pypynum/this.py,sha256=oRX1OpMa4NJmQSdEjJxfszEo5FRYlxRiF8OTDRIcdMA,2154
|
|
33
33
|
pypynum/tools.py,sha256=jv-R0fXJ0ptszAyaFwwakyCMFL835p8T20ihvzL4vbc,12665
|
|
34
34
|
pypynum/types.py,sha256=CVWPZo_ACr_QGH5gAOhoG3jK35peiqipu3PH8ScEYHE,181
|
|
35
|
+
pypynum/ufuncs.py,sha256=g2tewdsGa4VrIq2khR-0SWJoXBitVRN87DulOnTxxDA,2572
|
|
35
36
|
pypynum/utils.py,sha256=oeHpAMFItWXfKjb0UQITPwMVKZBd3H5JT3R-jBgn2_w,14466
|
|
36
|
-
PyPyNum-1.9.
|
|
37
|
-
PyPyNum-1.9.
|
|
38
|
-
PyPyNum-1.9.
|
|
39
|
-
PyPyNum-1.9.
|
|
37
|
+
PyPyNum-1.9.2.dist-info/METADATA,sha256=228Hjzw5LqRYU5RmkjteaDMn4MoJ-4RA-sSHeYP-syo,98069
|
|
38
|
+
PyPyNum-1.9.2.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
|
39
|
+
PyPyNum-1.9.2.dist-info/top_level.txt,sha256=4wW_Xb4bRglmiMsdPAe9f75MkXhNpuN88H17g_Cr5u8,8
|
|
40
|
+
PyPyNum-1.9.2.dist-info/RECORD,,
|
pypynum/Array.py
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
from .errors import ShapeError
|
|
2
2
|
|
|
3
3
|
ArrayError = ShapeError("The shape of the array is invalid")
|
|
4
|
+
MatchError = ShapeError("The shapes of the two arrays do not match")
|
|
4
5
|
|
|
5
6
|
|
|
6
7
|
class Array:
|
|
7
8
|
"""
|
|
8
|
-
It is the base class of vectors, matrices, and tensors,
|
|
9
|
-
which does not support operations but has many statistical functions.
|
|
9
|
+
It is the base class of vectors, matrices, and tensors, supporting operations and many statistical functions.
|
|
10
10
|
:param data: An array in the form of a list
|
|
11
11
|
:param check: Check the rationality of the input array
|
|
12
12
|
"""
|
|
@@ -20,7 +20,7 @@ class Array:
|
|
|
20
20
|
self.data = data
|
|
21
21
|
|
|
22
22
|
def __repr__(self):
|
|
23
|
-
return
|
|
23
|
+
return "{}({})".format(self.__class__.__name__, self.data)
|
|
24
24
|
|
|
25
25
|
def __str__(self):
|
|
26
26
|
if not self.data:
|
|
@@ -51,26 +51,68 @@ class Array:
|
|
|
51
51
|
return self.data == other.data
|
|
52
52
|
|
|
53
53
|
def __ne__(self, other):
|
|
54
|
-
return
|
|
54
|
+
return self.data != other.data
|
|
55
55
|
|
|
56
56
|
def __getitem__(self, item):
|
|
57
57
|
return self.data[item]
|
|
58
58
|
|
|
59
59
|
def __round__(self, n=None):
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
from .ufuncs import base_ufunc
|
|
61
|
+
return base_ufunc(self, func=lambda number, digits: round(number.real, digits) + round(
|
|
62
|
+
number.imag, digits) * 1j if isinstance(number, complex) else round(number, digits), args=[n])
|
|
62
63
|
|
|
63
64
|
def __hash__(self):
|
|
64
65
|
return hash(repr(self.data))
|
|
65
66
|
|
|
67
|
+
def __truediv__(self, other):
|
|
68
|
+
if isinstance(other, Array):
|
|
69
|
+
if self.shape != other.shape:
|
|
70
|
+
raise MatchError
|
|
71
|
+
return type(self)(fill(self.shape, [t1 / t2 for t1, t2 in zip(self.flatten(), other.flatten())]))
|
|
72
|
+
elif isinstance(other, (int, float, complex)):
|
|
73
|
+
from .ufuncs import divide
|
|
74
|
+
return divide(self, other)
|
|
75
|
+
else:
|
|
76
|
+
raise ValueError("Another must be an array or number")
|
|
77
|
+
|
|
78
|
+
def __floordiv__(self, other):
|
|
79
|
+
if isinstance(other, Array):
|
|
80
|
+
if self.shape != other.shape:
|
|
81
|
+
raise MatchError
|
|
82
|
+
return type(self)(fill(self.shape, [t1 // t2 for t1, t2 in zip(self.flatten(), other.flatten())]))
|
|
83
|
+
elif isinstance(other, (int, float, complex)):
|
|
84
|
+
from .ufuncs import floor_divide
|
|
85
|
+
return floor_divide(self, other)
|
|
86
|
+
else:
|
|
87
|
+
raise ValueError("Another must be an array or number")
|
|
88
|
+
|
|
89
|
+
def __mod__(self, other):
|
|
90
|
+
if isinstance(other, Array):
|
|
91
|
+
if self.shape != other.shape:
|
|
92
|
+
raise MatchError
|
|
93
|
+
return type(self)(fill(self.shape, [t1 % t2 for t1, t2 in zip(self.flatten(), other.flatten())]))
|
|
94
|
+
elif isinstance(other, (int, float, complex)):
|
|
95
|
+
from .ufuncs import modulo
|
|
96
|
+
return modulo(self, other)
|
|
97
|
+
else:
|
|
98
|
+
raise ValueError("Another must be an array or number")
|
|
99
|
+
|
|
100
|
+
def __pow__(self, _exp, _mod=None):
|
|
101
|
+
if isinstance(_exp, (int, float, complex, Array)) and isinstance(_mod,
|
|
102
|
+
(int, float, complex, Array, type(None))):
|
|
103
|
+
from .ufuncs import power
|
|
104
|
+
return power(self, _exp, _mod)
|
|
105
|
+
else:
|
|
106
|
+
raise ValueError()
|
|
107
|
+
|
|
66
108
|
def flatten(self):
|
|
67
109
|
data = self.data
|
|
68
110
|
while isinstance(data[0], list):
|
|
69
111
|
data = sum(data, [])
|
|
70
112
|
return data
|
|
71
113
|
|
|
72
|
-
def reshape(self, shape):
|
|
73
|
-
return type(self)(fill(shape, self.flatten()))
|
|
114
|
+
def reshape(self, shape, repeat=True, pad=0):
|
|
115
|
+
return type(self)(fill(shape, self.flatten(), repeat, pad))
|
|
74
116
|
|
|
75
117
|
def copy(self):
|
|
76
118
|
from copy import deepcopy
|
|
@@ -140,7 +182,7 @@ def get_shape(data):
|
|
|
140
182
|
while isinstance(_sub, list):
|
|
141
183
|
_shape.append(len(_sub))
|
|
142
184
|
_sub = _sub[0]
|
|
143
|
-
return _shape
|
|
185
|
+
return tuple(_shape)
|
|
144
186
|
|
|
145
187
|
|
|
146
188
|
def is_valid_array(_array, _shape):
|
|
@@ -160,28 +202,45 @@ def array(data=None):
|
|
|
160
202
|
return Array(data)
|
|
161
203
|
|
|
162
204
|
|
|
163
|
-
def
|
|
164
|
-
|
|
165
|
-
return 0
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
def
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
205
|
+
def full(shape, fill_value, rtype=Array):
|
|
206
|
+
def inner(data):
|
|
207
|
+
return fill_value if len(data) == 0 else [(inner(data[1:])) for _ in range(data[0])]
|
|
208
|
+
|
|
209
|
+
if isinstance(fill_value, list):
|
|
210
|
+
raise TypeError("The filled value cannot be a list")
|
|
211
|
+
result = inner(shape)
|
|
212
|
+
return result if rtype is list else rtype(result)
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
def full_like(a, fill_value, rtype=Array):
|
|
216
|
+
def inner(data):
|
|
217
|
+
return [inner(item) for item in data] if isinstance(data, list) else fill_value
|
|
218
|
+
|
|
219
|
+
if isinstance(fill_value, list):
|
|
220
|
+
raise TypeError("The filled value cannot be a list")
|
|
221
|
+
if isinstance(a, Array):
|
|
222
|
+
a = a.data
|
|
223
|
+
result = inner(a)
|
|
224
|
+
return result if rtype is list else rtype(result)
|
|
225
|
+
|
|
182
226
|
|
|
227
|
+
def zeros(shape, rtype=Array):
|
|
228
|
+
return full(shape, 0, rtype)
|
|
183
229
|
|
|
184
|
-
|
|
230
|
+
|
|
231
|
+
def zeros_like(a, rtype=Array):
|
|
232
|
+
return full_like(a, 0, rtype)
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
def ones(shape, rtype=Array):
|
|
236
|
+
return full(shape, 1, rtype)
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
def ones_like(a, rtype=Array):
|
|
240
|
+
return full_like(a, 1, rtype)
|
|
241
|
+
|
|
242
|
+
|
|
243
|
+
def fill(shape, sequence=None, repeat=True, pad=0, rtype=Array):
|
|
185
244
|
pointer = -1
|
|
186
245
|
length = 1
|
|
187
246
|
for item in shape:
|
|
@@ -189,12 +248,13 @@ def fill(shape, sequence=None, repeat=True):
|
|
|
189
248
|
if sequence is None:
|
|
190
249
|
sequence = list(range(length))
|
|
191
250
|
total = len(sequence)
|
|
251
|
+
last = total - 1
|
|
192
252
|
|
|
193
253
|
def inner(_shape):
|
|
194
254
|
nonlocal pointer
|
|
195
255
|
if len(_shape) == 0:
|
|
196
|
-
if pointer ==
|
|
197
|
-
return
|
|
256
|
+
if pointer == last and not repeat:
|
|
257
|
+
return pad
|
|
198
258
|
pointer += 1
|
|
199
259
|
return sequence[pointer % total]
|
|
200
260
|
else:
|
|
@@ -204,22 +264,5 @@ def fill(shape, sequence=None, repeat=True):
|
|
|
204
264
|
_array.append(_row)
|
|
205
265
|
return _array
|
|
206
266
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
def function(_array, _function, args=None):
|
|
211
|
-
_type = str(type(_function))
|
|
212
|
-
if not isinstance(_array, Array) or not (_type.startswith("<function ") or _type.startswith("<class ")):
|
|
213
|
-
raise TypeError("The input parameter type is incorrect")
|
|
214
|
-
data = _array.data
|
|
215
|
-
|
|
216
|
-
def inner(_array):
|
|
217
|
-
if isinstance(_array, list):
|
|
218
|
-
_copy = []
|
|
219
|
-
for item in _array:
|
|
220
|
-
_copy.append(inner(item))
|
|
221
|
-
return _copy
|
|
222
|
-
else:
|
|
223
|
-
return _function(_array) if args is None else _function(_array, *args)
|
|
224
|
-
|
|
225
|
-
return type(_array)(inner(data))
|
|
267
|
+
result = inner(shape)
|
|
268
|
+
return result if rtype is list else rtype(result)
|