PyPyNum 1.9.1__tar.gz → 1.9.2__tar.gz

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.
Files changed (44) hide show
  1. {PyPyNum-1.9.1 → pypynum-1.9.2}/PKG-INFO +91 -19
  2. {PyPyNum-1.9.1 → pypynum-1.9.2}/PyPyNum.egg-info/PKG-INFO +91 -19
  3. {PyPyNum-1.9.1 → pypynum-1.9.2}/pypynum/Array.py +60 -56
  4. {PyPyNum-1.9.1 → pypynum-1.9.2}/pypynum/Matrix.py +5 -0
  5. {PyPyNum-1.9.1 → pypynum-1.9.2}/pypynum/README.md +90 -18
  6. {PyPyNum-1.9.1 → pypynum-1.9.2}/pypynum/Tensor.py +7 -4
  7. {PyPyNum-1.9.1 → pypynum-1.9.2}/pypynum/Tree.py +43 -7
  8. {PyPyNum-1.9.1 → pypynum-1.9.2}/pypynum/__init__.py +3 -2
  9. {PyPyNum-1.9.1 → pypynum-1.9.2}/pypynum/equations.py +2 -2
  10. {PyPyNum-1.9.1 → pypynum-1.9.2}/pypynum/maths.py +21 -9
  11. {PyPyNum-1.9.1 → pypynum-1.9.2}/pypynum/numbers.py +58 -9
  12. {PyPyNum-1.9.1 → pypynum-1.9.2}/pypynum/polynomial.py +108 -4
  13. pypynum-1.9.2/pypynum/ufuncs.py +102 -0
  14. {PyPyNum-1.9.1 → pypynum-1.9.2}/setup.py +1 -1
  15. PyPyNum-1.9.1/pypynum/ufuncs.py +0 -26
  16. {PyPyNum-1.9.1 → pypynum-1.9.2}/PyPyNum.egg-info/SOURCES.txt +0 -0
  17. {PyPyNum-1.9.1 → pypynum-1.9.2}/PyPyNum.egg-info/dependency_links.txt +0 -0
  18. {PyPyNum-1.9.1 → pypynum-1.9.2}/PyPyNum.egg-info/top_level.txt +0 -0
  19. {PyPyNum-1.9.1 → pypynum-1.9.2}/pypynum/FourierT.py +0 -0
  20. {PyPyNum-1.9.1 → pypynum-1.9.2}/pypynum/Geometry.py +0 -0
  21. {PyPyNum-1.9.1 → pypynum-1.9.2}/pypynum/Graph.py +0 -0
  22. {PyPyNum-1.9.1 → pypynum-1.9.2}/pypynum/Group.py +0 -0
  23. {PyPyNum-1.9.1 → pypynum-1.9.2}/pypynum/Logic.py +0 -0
  24. {PyPyNum-1.9.1 → pypynum-1.9.2}/pypynum/NeuralN.py +0 -0
  25. {PyPyNum-1.9.1 → pypynum-1.9.2}/pypynum/PyPyNum.png +0 -0
  26. {PyPyNum-1.9.1 → pypynum-1.9.2}/pypynum/Quaternion.py +0 -0
  27. {PyPyNum-1.9.1 → pypynum-1.9.2}/pypynum/Symbolics.py +0 -0
  28. {PyPyNum-1.9.1 → pypynum-1.9.2}/pypynum/Vector.py +0 -0
  29. {PyPyNum-1.9.1 → pypynum-1.9.2}/pypynum/chars.py +0 -0
  30. {PyPyNum-1.9.1 → pypynum-1.9.2}/pypynum/cipher.py +0 -0
  31. {PyPyNum-1.9.1 → pypynum-1.9.2}/pypynum/constants.py +0 -0
  32. {PyPyNum-1.9.1 → pypynum-1.9.2}/pypynum/errors.py +0 -0
  33. {PyPyNum-1.9.1 → pypynum-1.9.2}/pypynum/file.py +0 -0
  34. {PyPyNum-1.9.1 → pypynum-1.9.2}/pypynum/plotting.py +0 -0
  35. {PyPyNum-1.9.1 → pypynum-1.9.2}/pypynum/probability.py +0 -0
  36. {PyPyNum-1.9.1 → pypynum-1.9.2}/pypynum/random.py +0 -0
  37. {PyPyNum-1.9.1 → pypynum-1.9.2}/pypynum/regression.py +0 -0
  38. {PyPyNum-1.9.1 → pypynum-1.9.2}/pypynum/sequence.py +0 -0
  39. {PyPyNum-1.9.1 → pypynum-1.9.2}/pypynum/test.py +0 -0
  40. {PyPyNum-1.9.1 → pypynum-1.9.2}/pypynum/this.py +0 -0
  41. {PyPyNum-1.9.1 → pypynum-1.9.2}/pypynum/tools.py +0 -0
  42. {PyPyNum-1.9.1 → pypynum-1.9.2}/pypynum/types.py +0 -0
  43. {PyPyNum-1.9.1 → pypynum-1.9.2}/pypynum/utils.py +0 -0
  44. {PyPyNum-1.9.1 → pypynum-1.9.2}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: PyPyNum
3
- Version: 1.9.1
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
  [![Downloads](https://static.pepy.tech/badge/pypynum/month)](https://pepy.tech/project/pypynum)
693
693
  [![Downloads](https://static.pepy.tech/badge/pypynum/week)](https://pepy.tech/project/pypynum)
694
694
 
695
- ## Version -> 1.9.1 | PyPI -> https://pypi.org/project/PyPyNum/ | Gitee -> https://www.gitee.com/PythonSJL/PyPyNum | GitHub -> https://github.com/PythonSJL/PyPyNum
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
  ![LOGO](PyPyNum.png)
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,11 +790,74 @@ Python interpreter and run it!
789
790
  ```
790
791
  !=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=
791
792
 
792
- 修复了一些功能问题
793
+ 新增代码行数大约三百行
793
794
 
794
- Fixed some functional issues
795
+ Approximately 300 new lines of
796
+ code added
795
797
 
796
798
  !=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=
799
+
800
+ 修改过的函数
801
+
802
+ Modified functions
803
+
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
808
+
809
+ !=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=
810
+
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)
833
+
834
+ PyPyNum
835
+ ├── Array
836
+ │ └── FUNCTION
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
842
+ │ └── FUNCTION
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
797
861
  ```
798
862
 
799
863
  ### 运行用时测试
@@ -823,12 +887,15 @@ PyPyNum
823
887
  │ │ └── Array(object)/__init__(self: Any, data: Any, check: Any) -> Any
824
888
  │ └── FUNCTION
825
889
  │ ├── array(data: Any) -> Any
826
- │ ├── fill(shape: Any, sequence: Any, repeat: Any, pad: Any) -> Any
827
- │ ├── function(_array: Any, _function: Any, args: Any) -> Any
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
828
893
  │ ├── get_shape(data: Any) -> Any
829
894
  │ ├── is_valid_array(_array: Any, _shape: Any) -> Any
830
- │ ├── zeros(shape: Any) -> Any
831
- └── zeros_like(_nested_list: Any) -> Any
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
832
899
  ├── FourierT
833
900
  │ ├── CLASS
834
901
  │ │ └── FT1D(object)/__init__(self: Any, data: Any) -> Any
@@ -1046,12 +1113,13 @@ PyPyNum
1046
1113
  │ ├── sech(x: typing.Union[int, float]) -> typing.Union[int, float]
1047
1114
  │ ├── sigma(i: int, n: int, f: Any) -> typing.Union[int, float, complex]
1048
1115
  │ ├── sigmoid(x: typing.Union[int, float]) -> float
1049
- │ ├── sign(x: typing.Union[int, float]) -> int
1116
+ │ ├── sign(x: typing.Union[int, float, complex]) -> typing.Union[int, float, complex]
1050
1117
  │ ├── sin(x: typing.Union[int, float]) -> typing.Union[int, float]
1051
1118
  │ ├── sinh(x: typing.Union[int, float]) -> typing.Union[int, float]
1052
1119
  │ ├── skew(data: typing.Union[list, tuple]) -> float
1053
1120
  │ ├── square_mean(numbers: typing.Union[list, tuple]) -> typing.Union[int, float, complex]
1054
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]
1055
1123
  │ ├── tan(x: typing.Union[int, float]) -> typing.Union[int, float]
1056
1124
  │ ├── tanh(x: typing.Union[int, float]) -> typing.Union[int, float]
1057
1125
  │ ├── totient(n: int) -> int
@@ -1062,6 +1130,7 @@ PyPyNum
1062
1130
  │ └── FUNCTION
1063
1131
  │ ├── float2fraction(number: float, mixed: bool, error: float) -> tuple
1064
1132
  │ ├── int2roman(integer: int, overline: bool) -> str
1133
+ │ ├── int2words(integer: int) -> str
1065
1134
  │ ├── roman2int(roman_num: str) -> int
1066
1135
  │ └── str2int(string: str) -> int
1067
1136
  ├── plotting
@@ -1077,6 +1146,9 @@ PyPyNum
1077
1146
  │ ├── CLASS
1078
1147
  │ │ └── Polynomial(object)/__init__(self: Any, terms: Any) -> Any
1079
1148
  │ └── FUNCTION
1149
+ │ ├── from_coeffs(coeffs: Any) -> Any
1150
+ │ ├── leggauss(polynomial: Any) -> Any
1151
+ │ ├── legpoly(n: Any) -> Any
1080
1152
  │ └── poly(terms: Any) -> Any
1081
1153
  ├── probability
1082
1154
  │ ├── CLASS
@@ -1138,12 +1210,14 @@ PyPyNum
1138
1210
  │ ├── CLASS
1139
1211
  │ └── FUNCTION
1140
1212
  │ ├── add(x: Any, y: Any) -> Any
1213
+ │ ├── base_ufunc(arrays: Any, func: Any, args: Any, rtype: Any) -> Any
1141
1214
  │ ├── divide(x: Any, y: Any) -> Any
1142
1215
  │ ├── floor_divide(x: Any, y: Any) -> Any
1143
1216
  │ ├── modulo(x: Any, y: Any) -> Any
1144
1217
  │ ├── multiply(x: Any, y: Any) -> Any
1145
1218
  │ ├── power(x: Any, y: Any, m: Any) -> Any
1146
- └── subtract(x: Any, y: Any) -> Any
1219
+ ├── subtract(x: Any, y: Any) -> Any
1220
+ │ └── ufunc_helper(x: Any, y: Any, func: Any) -> Any
1147
1221
  └── utils
1148
1222
  ├── CLASS
1149
1223
  │ ├── InfIterator(object)/__init__(self: Any, start: typing.Union[int, float, complex], mode: str, common: typing.Union[int, float, complex]) -> Any
@@ -1364,9 +1438,7 @@ print(equations.polynomial_equation(p))
1364
1438
  print(equations.linear_equation(*m))
1365
1439
 
1366
1440
  """
1367
- [[(-1.5615528128088307-6.5209667308287455e-24j) 0 0]
1368
- [ 0 (2.5615528128088294+4.456233626665941e-24j) 0]
1369
- [ 0 0 (1.0000000000000007+3.241554513744382e-25j)]]
1441
+ [(-1.5615528128088307-6.5209667308287455e-24j) (1.0000000000000007+3.241554513744382e-25j) (2.5615528128088294+4.456233626665941e-24j)]
1370
1442
  [ 1.6666666666666667 -0.6666666666666666 -0.4444444444444444]
1371
1443
  """
1372
1444
 
@@ -1467,10 +1539,10 @@ print(random.randint(0, 9, [2, 3, 4]))
1467
1539
  print(random.uniform(0, 9, [2, 3, 4]))
1468
1540
 
1469
1541
  """
1470
- [[[0.4604088962341266, -1.7729143777833498, -1.027113249139529, -1.367335972424437], [1.5152952392963814, 0.1143532276512219, -2.2478367353916626, 0.770010737736378], [-0.4126751204277065, -2.5483288418244814, -0.8493985529797649, -0.5563319772201964]], [[1.9010219123281087, 0.44289739103266357, -0.7148439667426828, -0.742966218100922], [0.21210379525283574, 1.5466635593995341, -0.4536304781981763, 0.5978046752778463], [-0.802299453332161, -1.0295309618075863, 0.5960990076298143, -0.7956578324150254]]]
1471
- [[[0.6378288221898551, 0.5667742466043126, 0.4656215108828976, 0.15042085420645113], [0.17290475960349394, 0.7286971110875379, 0.645886619551428, 0.6328537921605502], [0.5626377160935252, 0.41015810474249603, 0.9951566294215863, 0.21679108443018347]], [[0.7747392018966252, 0.5885873225687281, 0.4305122635955937, 0.1102178686782671], [0.6823600514076231, 0.919946966200235, 0.9010988477920265, 0.9324975541841414], [0.026520946245817467, 0.7483826867189314, 0.25799134110551736, 0.7231613737350734]]]
1472
- [[[5, 5, 4, 2], [2, 0, 9, 6], [9, 2, 0, 0]], [[0, 3, 9, 2], [2, 5, 5, 3], [9, 2, 5, 1]]]
1473
- [[[4.661185893580614, 6.263504213542613, 1.5982048879385133, 4.592524740685044], [5.915777961319595, 0.7073727896327806, 2.6233256174392263, 4.980453415047565], [2.257336580759053, 8.299789041235444, 5.839322602213961, 3.1890466264933925]], [[8.498155134210208, 4.722625882838601, 4.4036516933236705, 4.313235000904077], [3.7418534910533126, 2.7783464437089305, 8.884554145257127, 3.860087039759355], [4.430653527343895, 0.9625175276439548, 6.813933725727357, 7.910773669181097]]]
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]]]
1474
1546
  """
1475
1547
 
1476
1548
  print(regression.linear_regression(list(range(5)), [2, 4, 6, 7, 8]))
@@ -1480,7 +1552,7 @@ print(regression.polynomial_regression(list(range(5)), [2, 4, 6, 7, 8], 4))
1480
1552
  """
1481
1553
  [1.5, 2.4000000000000004]
1482
1554
  [-0.21428571428571563, 2.3571428571428625, 1.971428571428569]
1483
- [0.08333333334800574, -0.6666666668092494, 1.4166666678382942, 1.1666666648311956, 2.0000000002900613]
1555
+ [0.0833333333480164, -0.6666666668091551, 1.416666667838451, 1.1666666648311779, 2.0000000002900586]
1484
1556
  """
1485
1557
 
1486
1558
  print(tools.classify([1, 2.3, 4 + 5j, "string", list, True, 3.14, False, tuple, tools]))
@@ -1489,7 +1561,7 @@ print(tools.frange(0, 3, 0.4))
1489
1561
  print(tools.linspace(0, 2.8, 8))
1490
1562
 
1491
1563
  """
1492
- {<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 'F:\\PyPyproject\\PyPyproject1\\pypynum\\tools.py'>]}
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'>]}
1493
1565
  ['Python', 6, 'NumPy', <class 'int'>, 'PyPyNum', 9, 'pypynum', True]
1494
1566
  [0.0, 0.4, 0.8, 1.2000000000000002, 1.6, 2.0, 2.4000000000000004, 2.8000000000000003]
1495
1567
  [0.0, 0.39999999999999997, 0.7999999999999999, 1.2, 1.5999999999999999, 1.9999999999999998, 2.4, 2.8]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: PyPyNum
3
- Version: 1.9.1
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
  [![Downloads](https://static.pepy.tech/badge/pypynum/month)](https://pepy.tech/project/pypynum)
693
693
  [![Downloads](https://static.pepy.tech/badge/pypynum/week)](https://pepy.tech/project/pypynum)
694
694
 
695
- ## Version -> 1.9.1 | PyPI -> https://pypi.org/project/PyPyNum/ | Gitee -> https://www.gitee.com/PythonSJL/PyPyNum | GitHub -> https://github.com/PythonSJL/PyPyNum
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
  ![LOGO](PyPyNum.png)
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,11 +790,74 @@ Python interpreter and run it!
789
790
  ```
790
791
  !=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=
791
792
 
792
- 修复了一些功能问题
793
+ 新增代码行数大约三百行
793
794
 
794
- Fixed some functional issues
795
+ Approximately 300 new lines of
796
+ code added
795
797
 
796
798
  !=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=
799
+
800
+ 修改过的函数
801
+
802
+ Modified functions
803
+
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
808
+
809
+ !=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=
810
+
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)
833
+
834
+ PyPyNum
835
+ ├── Array
836
+ │ └── FUNCTION
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
842
+ │ └── FUNCTION
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
797
861
  ```
798
862
 
799
863
  ### 运行用时测试
@@ -823,12 +887,15 @@ PyPyNum
823
887
  │ │ └── Array(object)/__init__(self: Any, data: Any, check: Any) -> Any
824
888
  │ └── FUNCTION
825
889
  │ ├── array(data: Any) -> Any
826
- │ ├── fill(shape: Any, sequence: Any, repeat: Any, pad: Any) -> Any
827
- │ ├── function(_array: Any, _function: Any, args: Any) -> Any
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
828
893
  │ ├── get_shape(data: Any) -> Any
829
894
  │ ├── is_valid_array(_array: Any, _shape: Any) -> Any
830
- │ ├── zeros(shape: Any) -> Any
831
- └── zeros_like(_nested_list: Any) -> Any
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
832
899
  ├── FourierT
833
900
  │ ├── CLASS
834
901
  │ │ └── FT1D(object)/__init__(self: Any, data: Any) -> Any
@@ -1046,12 +1113,13 @@ PyPyNum
1046
1113
  │ ├── sech(x: typing.Union[int, float]) -> typing.Union[int, float]
1047
1114
  │ ├── sigma(i: int, n: int, f: Any) -> typing.Union[int, float, complex]
1048
1115
  │ ├── sigmoid(x: typing.Union[int, float]) -> float
1049
- │ ├── sign(x: typing.Union[int, float]) -> int
1116
+ │ ├── sign(x: typing.Union[int, float, complex]) -> typing.Union[int, float, complex]
1050
1117
  │ ├── sin(x: typing.Union[int, float]) -> typing.Union[int, float]
1051
1118
  │ ├── sinh(x: typing.Union[int, float]) -> typing.Union[int, float]
1052
1119
  │ ├── skew(data: typing.Union[list, tuple]) -> float
1053
1120
  │ ├── square_mean(numbers: typing.Union[list, tuple]) -> typing.Union[int, float, complex]
1054
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]
1055
1123
  │ ├── tan(x: typing.Union[int, float]) -> typing.Union[int, float]
1056
1124
  │ ├── tanh(x: typing.Union[int, float]) -> typing.Union[int, float]
1057
1125
  │ ├── totient(n: int) -> int
@@ -1062,6 +1130,7 @@ PyPyNum
1062
1130
  │ └── FUNCTION
1063
1131
  │ ├── float2fraction(number: float, mixed: bool, error: float) -> tuple
1064
1132
  │ ├── int2roman(integer: int, overline: bool) -> str
1133
+ │ ├── int2words(integer: int) -> str
1065
1134
  │ ├── roman2int(roman_num: str) -> int
1066
1135
  │ └── str2int(string: str) -> int
1067
1136
  ├── plotting
@@ -1077,6 +1146,9 @@ PyPyNum
1077
1146
  │ ├── CLASS
1078
1147
  │ │ └── Polynomial(object)/__init__(self: Any, terms: Any) -> Any
1079
1148
  │ └── FUNCTION
1149
+ │ ├── from_coeffs(coeffs: Any) -> Any
1150
+ │ ├── leggauss(polynomial: Any) -> Any
1151
+ │ ├── legpoly(n: Any) -> Any
1080
1152
  │ └── poly(terms: Any) -> Any
1081
1153
  ├── probability
1082
1154
  │ ├── CLASS
@@ -1138,12 +1210,14 @@ PyPyNum
1138
1210
  │ ├── CLASS
1139
1211
  │ └── FUNCTION
1140
1212
  │ ├── add(x: Any, y: Any) -> Any
1213
+ │ ├── base_ufunc(arrays: Any, func: Any, args: Any, rtype: Any) -> Any
1141
1214
  │ ├── divide(x: Any, y: Any) -> Any
1142
1215
  │ ├── floor_divide(x: Any, y: Any) -> Any
1143
1216
  │ ├── modulo(x: Any, y: Any) -> Any
1144
1217
  │ ├── multiply(x: Any, y: Any) -> Any
1145
1218
  │ ├── power(x: Any, y: Any, m: Any) -> Any
1146
- └── subtract(x: Any, y: Any) -> Any
1219
+ ├── subtract(x: Any, y: Any) -> Any
1220
+ │ └── ufunc_helper(x: Any, y: Any, func: Any) -> Any
1147
1221
  └── utils
1148
1222
  ├── CLASS
1149
1223
  │ ├── InfIterator(object)/__init__(self: Any, start: typing.Union[int, float, complex], mode: str, common: typing.Union[int, float, complex]) -> Any
@@ -1364,9 +1438,7 @@ print(equations.polynomial_equation(p))
1364
1438
  print(equations.linear_equation(*m))
1365
1439
 
1366
1440
  """
1367
- [[(-1.5615528128088307-6.5209667308287455e-24j) 0 0]
1368
- [ 0 (2.5615528128088294+4.456233626665941e-24j) 0]
1369
- [ 0 0 (1.0000000000000007+3.241554513744382e-25j)]]
1441
+ [(-1.5615528128088307-6.5209667308287455e-24j) (1.0000000000000007+3.241554513744382e-25j) (2.5615528128088294+4.456233626665941e-24j)]
1370
1442
  [ 1.6666666666666667 -0.6666666666666666 -0.4444444444444444]
1371
1443
  """
1372
1444
 
@@ -1467,10 +1539,10 @@ print(random.randint(0, 9, [2, 3, 4]))
1467
1539
  print(random.uniform(0, 9, [2, 3, 4]))
1468
1540
 
1469
1541
  """
1470
- [[[0.4604088962341266, -1.7729143777833498, -1.027113249139529, -1.367335972424437], [1.5152952392963814, 0.1143532276512219, -2.2478367353916626, 0.770010737736378], [-0.4126751204277065, -2.5483288418244814, -0.8493985529797649, -0.5563319772201964]], [[1.9010219123281087, 0.44289739103266357, -0.7148439667426828, -0.742966218100922], [0.21210379525283574, 1.5466635593995341, -0.4536304781981763, 0.5978046752778463], [-0.802299453332161, -1.0295309618075863, 0.5960990076298143, -0.7956578324150254]]]
1471
- [[[0.6378288221898551, 0.5667742466043126, 0.4656215108828976, 0.15042085420645113], [0.17290475960349394, 0.7286971110875379, 0.645886619551428, 0.6328537921605502], [0.5626377160935252, 0.41015810474249603, 0.9951566294215863, 0.21679108443018347]], [[0.7747392018966252, 0.5885873225687281, 0.4305122635955937, 0.1102178686782671], [0.6823600514076231, 0.919946966200235, 0.9010988477920265, 0.9324975541841414], [0.026520946245817467, 0.7483826867189314, 0.25799134110551736, 0.7231613737350734]]]
1472
- [[[5, 5, 4, 2], [2, 0, 9, 6], [9, 2, 0, 0]], [[0, 3, 9, 2], [2, 5, 5, 3], [9, 2, 5, 1]]]
1473
- [[[4.661185893580614, 6.263504213542613, 1.5982048879385133, 4.592524740685044], [5.915777961319595, 0.7073727896327806, 2.6233256174392263, 4.980453415047565], [2.257336580759053, 8.299789041235444, 5.839322602213961, 3.1890466264933925]], [[8.498155134210208, 4.722625882838601, 4.4036516933236705, 4.313235000904077], [3.7418534910533126, 2.7783464437089305, 8.884554145257127, 3.860087039759355], [4.430653527343895, 0.9625175276439548, 6.813933725727357, 7.910773669181097]]]
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]]]
1474
1546
  """
1475
1547
 
1476
1548
  print(regression.linear_regression(list(range(5)), [2, 4, 6, 7, 8]))
@@ -1480,7 +1552,7 @@ print(regression.polynomial_regression(list(range(5)), [2, 4, 6, 7, 8], 4))
1480
1552
  """
1481
1553
  [1.5, 2.4000000000000004]
1482
1554
  [-0.21428571428571563, 2.3571428571428625, 1.971428571428569]
1483
- [0.08333333334800574, -0.6666666668092494, 1.4166666678382942, 1.1666666648311956, 2.0000000002900613]
1555
+ [0.0833333333480164, -0.6666666668091551, 1.416666667838451, 1.1666666648311779, 2.0000000002900586]
1484
1556
  """
1485
1557
 
1486
1558
  print(tools.classify([1, 2.3, 4 + 5j, "string", list, True, 3.14, False, tuple, tools]))
@@ -1489,7 +1561,7 @@ print(tools.frange(0, 3, 0.4))
1489
1561
  print(tools.linspace(0, 2.8, 8))
1490
1562
 
1491
1563
  """
1492
- {<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 'F:\\PyPyproject\\PyPyproject1\\pypynum\\tools.py'>]}
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'>]}
1493
1565
  ['Python', 6, 'NumPy', <class 'int'>, 'PyPyNum', 9, 'pypynum', True]
1494
1566
  [0.0, 0.4, 0.8, 1.2000000000000002, 1.6, 2.0, 2.4000000000000004, 2.8000000000000003]
1495
1567
  [0.0, 0.39999999999999997, 0.7999999999999999, 1.2, 1.5999999999999999, 1.9999999999999998, 2.4, 2.8]
@@ -1,5 +1,4 @@
1
1
  from .errors import ShapeError
2
- from .ufuncs import *
3
2
 
4
3
  ArrayError = ShapeError("The shape of the array is invalid")
5
4
  MatchError = ShapeError("The shapes of the two arrays do not match")
@@ -7,8 +6,7 @@ MatchError = ShapeError("The shapes of the two arrays do not match")
7
6
 
8
7
  class Array:
9
8
  """
10
- It is the base class of vectors, matrices, and Arrays,
11
- 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.
12
10
  :param data: An array in the form of a list
13
11
  :param check: Check the rationality of the input array
14
12
  """
@@ -22,7 +20,7 @@ class Array:
22
20
  self.data = data
23
21
 
24
22
  def __repr__(self):
25
- return self.__class__.__name__ + "({})".format(self.data)
23
+ return "{}({})".format(self.__class__.__name__, self.data)
26
24
 
27
25
  def __str__(self):
28
26
  if not self.data:
@@ -59,8 +57,9 @@ class Array:
59
57
  return self.data[item]
60
58
 
61
59
  def __round__(self, n=None):
62
- return function(self, lambda number, digits: round(number.real, digits) + round(
63
- number.imag, digits) * 1j if isinstance(number, complex) else round(number, digits), [n])
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])
64
63
 
65
64
  def __hash__(self):
66
65
  return hash(repr(self.data))
@@ -69,9 +68,10 @@ class Array:
69
68
  if isinstance(other, Array):
70
69
  if self.shape != other.shape:
71
70
  raise MatchError
72
- return Array(fill(self.shape, [t1 / t2 for t1, t2 in zip(self.flatten(), other.flatten())]), False)
71
+ return type(self)(fill(self.shape, [t1 / t2 for t1, t2 in zip(self.flatten(), other.flatten())]))
73
72
  elif isinstance(other, (int, float, complex)):
74
- return function(self, divide, [other])
73
+ from .ufuncs import divide
74
+ return divide(self, other)
75
75
  else:
76
76
  raise ValueError("Another must be an array or number")
77
77
 
@@ -79,9 +79,10 @@ class Array:
79
79
  if isinstance(other, Array):
80
80
  if self.shape != other.shape:
81
81
  raise MatchError
82
- return Array(fill(self.shape, [t1 // t2 for t1, t2 in zip(self.flatten(), other.flatten())]), False)
82
+ return type(self)(fill(self.shape, [t1 // t2 for t1, t2 in zip(self.flatten(), other.flatten())]))
83
83
  elif isinstance(other, (int, float, complex)):
84
- return function(self, floor_divide, [other])
84
+ from .ufuncs import floor_divide
85
+ return floor_divide(self, other)
85
86
  else:
86
87
  raise ValueError("Another must be an array or number")
87
88
 
@@ -89,15 +90,18 @@ class Array:
89
90
  if isinstance(other, Array):
90
91
  if self.shape != other.shape:
91
92
  raise MatchError
92
- return Array(fill(self.shape, [t1 % t2 for t1, t2 in zip(self.flatten(), other.flatten())]), False)
93
+ return type(self)(fill(self.shape, [t1 % t2 for t1, t2 in zip(self.flatten(), other.flatten())]))
93
94
  elif isinstance(other, (int, float, complex)):
94
- return function(self, modulo, [other])
95
+ from .ufuncs import modulo
96
+ return modulo(self, other)
95
97
  else:
96
98
  raise ValueError("Another must be an array or number")
97
99
 
98
100
  def __pow__(self, _exp, _mod=None):
99
- if isinstance(_exp, (int, float, complex)) and isinstance(_mod, (int, float, complex, type(None))):
100
- return function(self, power, [_exp, _mod])
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)
101
105
  else:
102
106
  raise ValueError()
103
107
 
@@ -107,8 +111,8 @@ class Array:
107
111
  data = sum(data, [])
108
112
  return data
109
113
 
110
- def reshape(self, shape):
111
- 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))
112
116
 
113
117
  def copy(self):
114
118
  from copy import deepcopy
@@ -178,7 +182,7 @@ def get_shape(data):
178
182
  while isinstance(_sub, list):
179
183
  _shape.append(len(_sub))
180
184
  _sub = _sub[0]
181
- return _shape
185
+ return tuple(_shape)
182
186
 
183
187
 
184
188
  def is_valid_array(_array, _shape):
@@ -198,28 +202,45 @@ def array(data=None):
198
202
  return Array(data)
199
203
 
200
204
 
201
- def zeros(shape):
202
- if len(shape) == 0:
203
- return 0
204
- else:
205
- _array = []
206
- for i in range(shape[0]):
207
- _row = zeros(shape[1:])
208
- _array.append(_row)
209
- return _array
210
-
211
-
212
- def zeros_like(_nested_list):
213
- if isinstance(_nested_list, list):
214
- _copy = []
215
- for item in _nested_list:
216
- _copy.append(zeros_like(item))
217
- return _copy
218
- else:
219
- return 0
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
+
226
+
227
+ def zeros(shape, rtype=Array):
228
+ return full(shape, 0, rtype)
229
+
230
+
231
+ def zeros_like(a, rtype=Array):
232
+ return full_like(a, 0, rtype)
220
233
 
221
234
 
222
- def fill(shape, sequence=None, repeat=True, pad=0):
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):
223
244
  pointer = -1
224
245
  length = 1
225
246
  for item in shape:
@@ -243,22 +264,5 @@ def fill(shape, sequence=None, repeat=True, pad=0):
243
264
  _array.append(_row)
244
265
  return _array
245
266
 
246
- return inner(shape)
247
-
248
-
249
- def function(_array, _function, args=None):
250
- _type = str(type(_function))
251
- if not isinstance(_array, Array) or not (_type.startswith("<function ") or _type.startswith("<class ")):
252
- raise TypeError("The input parameter type is incorrect")
253
- data = _array.data
254
-
255
- def inner(_array):
256
- if isinstance(_array, list):
257
- _copy = []
258
- for item in _array:
259
- _copy.append(inner(item))
260
- return _copy
261
- else:
262
- return _function(_array) if args is None else _function(_array, *args)
263
-
264
- return type(_array)(inner(data), False)
267
+ result = inner(shape)
268
+ return result if rtype is list else rtype(result)
@@ -92,6 +92,11 @@ class Matrix(Array):
92
92
  matrix[k][j] -= matrix[i][j] * matrix[k][i]
93
93
  return determinant
94
94
 
95
+ def slogdet(self):
96
+ from math import log
97
+ det_value = self.det()
98
+ return (0.0, float("-inf")) if det_value == 0 else (det_value / abs(det_value), log(abs(det_value)))
99
+
95
100
  def inv(self):
96
101
  if self.rows != self.cols:
97
102
  raise SquareError