PyPyNum 1.5.1__tar.gz → 1.5.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 (38) hide show
  1. {PyPyNum-1.5.1 → PyPyNum-1.5.2}/PKG-INFO +84 -19
  2. {PyPyNum-1.5.1 → PyPyNum-1.5.2}/PyPyNum.egg-info/PKG-INFO +84 -19
  3. {PyPyNum-1.5.1 → PyPyNum-1.5.2}/pypynum/Matrix.py +2 -4
  4. {PyPyNum-1.5.1 → PyPyNum-1.5.2}/pypynum/README.md +82 -17
  5. {PyPyNum-1.5.1 → PyPyNum-1.5.2}/pypynum/__init__.py +1 -1
  6. {PyPyNum-1.5.1 → PyPyNum-1.5.2}/pypynum/maths.py +80 -9
  7. {PyPyNum-1.5.1 → PyPyNum-1.5.2}/pypynum/sequence.py +37 -9
  8. PyPyNum-1.5.2/pypynum/this.py +9 -0
  9. {PyPyNum-1.5.1 → PyPyNum-1.5.2}/pypynum/tools.py +2 -1
  10. {PyPyNum-1.5.1 → PyPyNum-1.5.2}/setup.py +2 -2
  11. PyPyNum-1.5.1/pypynum/this.py +0 -9
  12. {PyPyNum-1.5.1 → PyPyNum-1.5.2}/PyPyNum.egg-info/SOURCES.txt +0 -0
  13. {PyPyNum-1.5.1 → PyPyNum-1.5.2}/PyPyNum.egg-info/dependency_links.txt +0 -0
  14. {PyPyNum-1.5.1 → PyPyNum-1.5.2}/PyPyNum.egg-info/top_level.txt +0 -0
  15. {PyPyNum-1.5.1 → PyPyNum-1.5.2}/pypynum/Array.py +0 -0
  16. {PyPyNum-1.5.1 → PyPyNum-1.5.2}/pypynum/FourierT.py +0 -0
  17. {PyPyNum-1.5.1 → PyPyNum-1.5.2}/pypynum/Geometry.py +0 -0
  18. {PyPyNum-1.5.1 → PyPyNum-1.5.2}/pypynum/Group.py +0 -0
  19. {PyPyNum-1.5.1 → PyPyNum-1.5.2}/pypynum/Logic.py +0 -0
  20. {PyPyNum-1.5.1 → PyPyNum-1.5.2}/pypynum/NeuralN.py +0 -0
  21. {PyPyNum-1.5.1 → PyPyNum-1.5.2}/pypynum/PyPyNum.png +0 -0
  22. {PyPyNum-1.5.1 → PyPyNum-1.5.2}/pypynum/Quaternion.py +0 -0
  23. {PyPyNum-1.5.1 → PyPyNum-1.5.2}/pypynum/Symbolics.py +0 -0
  24. {PyPyNum-1.5.1 → PyPyNum-1.5.2}/pypynum/Tensor.py +0 -0
  25. {PyPyNum-1.5.1 → PyPyNum-1.5.2}/pypynum/Vector.py +0 -0
  26. {PyPyNum-1.5.1 → PyPyNum-1.5.2}/pypynum/__temporary.py +0 -0
  27. {PyPyNum-1.5.1 → PyPyNum-1.5.2}/pypynum/cipher.py +0 -0
  28. {PyPyNum-1.5.1 → PyPyNum-1.5.2}/pypynum/constants.py +0 -0
  29. {PyPyNum-1.5.1 → PyPyNum-1.5.2}/pypynum/equations.py +0 -0
  30. {PyPyNum-1.5.1 → PyPyNum-1.5.2}/pypynum/errors.py +0 -0
  31. {PyPyNum-1.5.1 → PyPyNum-1.5.2}/pypynum/file.py +0 -0
  32. {PyPyNum-1.5.1 → PyPyNum-1.5.2}/pypynum/plotting.py +0 -0
  33. {PyPyNum-1.5.1 → PyPyNum-1.5.2}/pypynum/probability.py +0 -0
  34. {PyPyNum-1.5.1 → PyPyNum-1.5.2}/pypynum/random.py +0 -0
  35. {PyPyNum-1.5.1 → PyPyNum-1.5.2}/pypynum/regression.py +0 -0
  36. {PyPyNum-1.5.1 → PyPyNum-1.5.2}/pypynum/test.py +0 -0
  37. {PyPyNum-1.5.1 → PyPyNum-1.5.2}/pypynum/types.py +0 -0
  38. {PyPyNum-1.5.1 → PyPyNum-1.5.2}/setup.cfg +0 -0
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: PyPyNum
3
- Version: 1.5.1
4
- Summary: A Python math package written in pure Python programming language [python_requires >= 3.5]
3
+ Version: 1.5.2
4
+ Summary: A multifunctional mathematical calculation package written in pure Python programming language [Python>=3.5]
5
5
  Home-page: https://www.gitee.com/PythonSJL/PyPyNum
6
6
  Author: Shen Jiayi
7
7
  Author-email: 2261748025@qq.com
@@ -687,10 +687,14 @@ Description-Content-Type: text/markdown
687
687
  \|___|/ \|___|/
688
688
  ```
689
689
 
690
- ## Version -> 1.5.1 | PyPI -> https://pypi.org/project/PyPyNum/ | Gitee -> https://www.gitee.com/PythonSJL/PyPyNum
690
+ ## Version -> 1.5.2 | PyPI -> https://pypi.org/project/PyPyNum/ | Gitee -> https://www.gitee.com/PythonSJL/PyPyNum
691
691
 
692
692
  ![LOGO](PyPyNum.png)
693
693
 
694
+ PyPI上无法显示logo,可以在Gitee中查看。
695
+
696
+ The logo cannot be displayed on PyPI, it can be viewed in Gitee.
697
+
694
698
  ### 介绍
695
699
 
696
700
  #### Introduction
@@ -702,20 +706,27 @@ Description-Content-Type: text/markdown
702
706
  + 如需联系,QQ 2261748025 (Py𝙿𝚢𝚝𝚑𝚘𝚗-水晶兰)
703
707
  + If you need to contact, QQ 2261748025 (Py𝙿𝚢𝚝𝚑𝚘𝚗-水晶兰)
704
708
 
705
- ### PyPyNum的Zen
709
+ ### PyPyNum的Zen(预览)
706
710
 
707
- #### The Zen of PyPyNum
711
+ #### The Zen of PyPyNum (Preview)
708
712
 
709
713
  ```
710
714
  The Zen of PyPyNum, by Shen Jiayi
711
715
 
712
716
  This is a math package written purely in Python.
713
717
 
714
- ... (Do you want to see the entire content?
715
- Then enter "from pypynum import this" on your
718
+ Elegant is superior to clunky.
719
+ Clarity trumps obscurity.
720
+ Straightforwardness is preferred over convolution.
721
+ Sophisticated is better than overcomplicated.
722
+ Flat structure beats nested hierarchies.
723
+ Sparse code wins over bloated ones.
724
+
725
+ ... (Do you want to view all the content?
726
+ Enter "from pypynum import this" in your
716
727
  Python interpreter and run it!)
717
728
 
718
- December 27, 2023
729
+ February 27, 2024
719
730
  ```
720
731
 
721
732
  ### 与上一个版本相比新增功能
@@ -723,21 +734,71 @@ Python interpreter and run it!)
723
734
  #### New features compared to the previous version
724
735
 
725
736
  ```
737
+ !=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=
738
+
739
+ 重写了PyPyNum的Zen。
740
+
741
+ Rewrote the Zen of PyPyNum.
742
+
743
+ !=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=
744
+
745
+ “maths”模块的一些功能已经进行了优化,
746
+ 以实现更快的运行速度。
747
+
748
+ Some functions of the "maths"
749
+ module have been optimized to
750
+ achieve faster running speed.
751
+
752
+ !=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=
753
+
754
+ 修复了“tools”模块中的“split”函数导致
755
+ 的字符串分割错误。
756
+
757
+ Fixed string splitting error
758
+ caused by the "split" function
759
+ in the "tools" module.
760
+
761
+ !=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=
762
+
763
+ “sequence”模块设置为每个序列返回单独
764
+ 的第n项或包含第0到第n项的列表的功能。
765
+
766
+ The "sequence" module sets the
767
+ function of returning a separate
768
+ nth item or a list containing
769
+ 0th to nth items for each
770
+ sequence.
771
+
772
+
773
+ “geometric_sequence”函数补充了一个
774
+ 情况的求解函数,并且已经证实,其余两个情
775
+ 况没有解析解,需要使用多项式方程来求解。
776
+
777
+ The "geometric_sequence"
778
+ function supplements the solving
779
+ function for one scenario, and
780
+ it has been confirmed that there
781
+ are no analytical solutions for
782
+ the remaining two scenarios,
783
+ which need to be solved using
784
+ polynomial equations for
785
+ implementation.
786
+
787
+ !=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=
788
+
726
789
  <<<The "+" indicates the newly added method>>>
727
790
 
728
791
  maths [Mathematical functions]
729
792
  ...
730
- cov(x: arr, y: arr) -> num +
731
- corr_coeff(x: arr, y: arr) -> num +
732
- coeff_det(x: arr, y: arr) -> num +
793
+ geom_mean(numbers: arr) -> num +
794
+ square_mean(numbers: arr) -> num +
795
+ harm_mean(numbers: arr) -> num +
733
796
  ...
734
797
 
735
798
  sequence [Various sequences]
736
799
  ...
737
- arithmetic_sequence(*, a1=None, an=None, d=None, n=None, s=None) +
738
- geometric_sequence(*, a1=None, an=None, r=None, n=None, s=None) +
739
-
740
- <<<There are three situations in the "geometric_sequence" function that have not been implemented>>>
800
+ recaman(n: int, single: bool = True) -> Union[int, list] +
801
+ ...
741
802
  ```
742
803
 
743
804
  ### 运行用时测试
@@ -978,6 +1039,9 @@ PyPyNum
978
1039
  freq(data: arr) -> dict
979
1040
  mode(data: arr)
980
1041
  mean(numbers: arr) -> num
1042
+ geom_mean(numbers: arr) -> num
1043
+ square_mean(numbers: arr) -> num
1044
+ harm_mean(numbers: arr) -> num
981
1045
  var(numbers: arr) -> num
982
1046
  std(numbers: arr) -> num
983
1047
  cov(x: arr, y: arr) -> num
@@ -1030,11 +1094,12 @@ PyPyNum
1030
1094
  polynomial_regression(x: Union[list, tuple], y: Union[list, tuple], n: int = None) -> list
1031
1095
  ★ sequence [Various sequences]
1032
1096
  FUNCTIONS
1033
- fibonacci(n: int) -> int
1034
- catalan(n: int) -> int
1097
+ fibonacci(n: int, single: bool = True) -> Union[int, list]
1098
+ catalan(n: int, single: bool = True) -> Union[int, list]
1035
1099
  bernoulli(n: int, single: bool = True) -> list
1036
- arithmetic_sequence(*, a1=None, an=None, d=None, n=None, s=None)
1037
- geometric_sequence(*, a1=None, an=None, r=None, n=None, s=None)
1100
+ recaman(n: int, single: bool = True) -> Union[int, list]
1101
+ arithmetic_sequence(*, a1: real = None, an: real = None, d: real = None, n: real = None, s: real = None) -> dict
1102
+ geometric_sequence(*, a1: real = None, an: real = None, r: real = None, n: real = None, s: real = None) -> dict
1038
1103
  ★ tools [Other useful tools]
1039
1104
  FUNCTIONS
1040
1105
  classify(array: Union[list, tuple]) -> dict
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: PyPyNum
3
- Version: 1.5.1
4
- Summary: A Python math package written in pure Python programming language [python_requires >= 3.5]
3
+ Version: 1.5.2
4
+ Summary: A multifunctional mathematical calculation package written in pure Python programming language [Python>=3.5]
5
5
  Home-page: https://www.gitee.com/PythonSJL/PyPyNum
6
6
  Author: Shen Jiayi
7
7
  Author-email: 2261748025@qq.com
@@ -687,10 +687,14 @@ Description-Content-Type: text/markdown
687
687
  \|___|/ \|___|/
688
688
  ```
689
689
 
690
- ## Version -> 1.5.1 | PyPI -> https://pypi.org/project/PyPyNum/ | Gitee -> https://www.gitee.com/PythonSJL/PyPyNum
690
+ ## Version -> 1.5.2 | PyPI -> https://pypi.org/project/PyPyNum/ | Gitee -> https://www.gitee.com/PythonSJL/PyPyNum
691
691
 
692
692
  ![LOGO](PyPyNum.png)
693
693
 
694
+ PyPI上无法显示logo,可以在Gitee中查看。
695
+
696
+ The logo cannot be displayed on PyPI, it can be viewed in Gitee.
697
+
694
698
  ### 介绍
695
699
 
696
700
  #### Introduction
@@ -702,20 +706,27 @@ Description-Content-Type: text/markdown
702
706
  + 如需联系,QQ 2261748025 (Py𝙿𝚢𝚝𝚑𝚘𝚗-水晶兰)
703
707
  + If you need to contact, QQ 2261748025 (Py𝙿𝚢𝚝𝚑𝚘𝚗-水晶兰)
704
708
 
705
- ### PyPyNum的Zen
709
+ ### PyPyNum的Zen(预览)
706
710
 
707
- #### The Zen of PyPyNum
711
+ #### The Zen of PyPyNum (Preview)
708
712
 
709
713
  ```
710
714
  The Zen of PyPyNum, by Shen Jiayi
711
715
 
712
716
  This is a math package written purely in Python.
713
717
 
714
- ... (Do you want to see the entire content?
715
- Then enter "from pypynum import this" on your
718
+ Elegant is superior to clunky.
719
+ Clarity trumps obscurity.
720
+ Straightforwardness is preferred over convolution.
721
+ Sophisticated is better than overcomplicated.
722
+ Flat structure beats nested hierarchies.
723
+ Sparse code wins over bloated ones.
724
+
725
+ ... (Do you want to view all the content?
726
+ Enter "from pypynum import this" in your
716
727
  Python interpreter and run it!)
717
728
 
718
- December 27, 2023
729
+ February 27, 2024
719
730
  ```
720
731
 
721
732
  ### 与上一个版本相比新增功能
@@ -723,21 +734,71 @@ Python interpreter and run it!)
723
734
  #### New features compared to the previous version
724
735
 
725
736
  ```
737
+ !=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=
738
+
739
+ 重写了PyPyNum的Zen。
740
+
741
+ Rewrote the Zen of PyPyNum.
742
+
743
+ !=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=
744
+
745
+ “maths”模块的一些功能已经进行了优化,
746
+ 以实现更快的运行速度。
747
+
748
+ Some functions of the "maths"
749
+ module have been optimized to
750
+ achieve faster running speed.
751
+
752
+ !=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=
753
+
754
+ 修复了“tools”模块中的“split”函数导致
755
+ 的字符串分割错误。
756
+
757
+ Fixed string splitting error
758
+ caused by the "split" function
759
+ in the "tools" module.
760
+
761
+ !=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=
762
+
763
+ “sequence”模块设置为每个序列返回单独
764
+ 的第n项或包含第0到第n项的列表的功能。
765
+
766
+ The "sequence" module sets the
767
+ function of returning a separate
768
+ nth item or a list containing
769
+ 0th to nth items for each
770
+ sequence.
771
+
772
+
773
+ “geometric_sequence”函数补充了一个
774
+ 情况的求解函数,并且已经证实,其余两个情
775
+ 况没有解析解,需要使用多项式方程来求解。
776
+
777
+ The "geometric_sequence"
778
+ function supplements the solving
779
+ function for one scenario, and
780
+ it has been confirmed that there
781
+ are no analytical solutions for
782
+ the remaining two scenarios,
783
+ which need to be solved using
784
+ polynomial equations for
785
+ implementation.
786
+
787
+ !=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=
788
+
726
789
  <<<The "+" indicates the newly added method>>>
727
790
 
728
791
  maths [Mathematical functions]
729
792
  ...
730
- cov(x: arr, y: arr) -> num +
731
- corr_coeff(x: arr, y: arr) -> num +
732
- coeff_det(x: arr, y: arr) -> num +
793
+ geom_mean(numbers: arr) -> num +
794
+ square_mean(numbers: arr) -> num +
795
+ harm_mean(numbers: arr) -> num +
733
796
  ...
734
797
 
735
798
  sequence [Various sequences]
736
799
  ...
737
- arithmetic_sequence(*, a1=None, an=None, d=None, n=None, s=None) +
738
- geometric_sequence(*, a1=None, an=None, r=None, n=None, s=None) +
739
-
740
- <<<There are three situations in the "geometric_sequence" function that have not been implemented>>>
800
+ recaman(n: int, single: bool = True) -> Union[int, list] +
801
+ ...
741
802
  ```
742
803
 
743
804
  ### 运行用时测试
@@ -978,6 +1039,9 @@ PyPyNum
978
1039
  freq(data: arr) -> dict
979
1040
  mode(data: arr)
980
1041
  mean(numbers: arr) -> num
1042
+ geom_mean(numbers: arr) -> num
1043
+ square_mean(numbers: arr) -> num
1044
+ harm_mean(numbers: arr) -> num
981
1045
  var(numbers: arr) -> num
982
1046
  std(numbers: arr) -> num
983
1047
  cov(x: arr, y: arr) -> num
@@ -1030,11 +1094,12 @@ PyPyNum
1030
1094
  polynomial_regression(x: Union[list, tuple], y: Union[list, tuple], n: int = None) -> list
1031
1095
  ★ sequence [Various sequences]
1032
1096
  FUNCTIONS
1033
- fibonacci(n: int) -> int
1034
- catalan(n: int) -> int
1097
+ fibonacci(n: int, single: bool = True) -> Union[int, list]
1098
+ catalan(n: int, single: bool = True) -> Union[int, list]
1035
1099
  bernoulli(n: int, single: bool = True) -> list
1036
- arithmetic_sequence(*, a1=None, an=None, d=None, n=None, s=None)
1037
- geometric_sequence(*, a1=None, an=None, r=None, n=None, s=None)
1100
+ recaman(n: int, single: bool = True) -> Union[int, list]
1101
+ arithmetic_sequence(*, a1: real = None, an: real = None, d: real = None, n: real = None, s: real = None) -> dict
1102
+ geometric_sequence(*, a1: real = None, an: real = None, r: real = None, n: real = None, s: real = None) -> dict
1038
1103
  ★ tools [Other useful tools]
1039
1104
  FUNCTIONS
1040
1105
  classify(array: Union[list, tuple]) -> dict
@@ -168,10 +168,8 @@ class Matrix(Array):
168
168
  if len(item) == 2:
169
169
  if isinstance(item[0], int) and isinstance(item[1], (int, slice)):
170
170
  return self.data[item[0]][item[1]]
171
- elif isinstance(item[0], slice) and isinstance(item[1], int):
172
- return self.t().data[item[1]][item[0]]
173
- elif isinstance(item[0], slice) and isinstance(item[1], slice):
174
- return Matrix(Matrix(self.data[item[0]]).t().data[item[1]]).t()
171
+ elif isinstance(item[0], slice) and isinstance(item[1], (int, slice)):
172
+ return [row[item[1]] for row in self.data[item[0]]]
175
173
  else:
176
174
  return []
177
175
  else:
@@ -14,10 +14,14 @@
14
14
  \|___|/ \|___|/
15
15
  ```
16
16
 
17
- ## Version -> 1.5.1 | PyPI -> https://pypi.org/project/PyPyNum/ | Gitee -> https://www.gitee.com/PythonSJL/PyPyNum
17
+ ## Version -> 1.5.2 | PyPI -> https://pypi.org/project/PyPyNum/ | Gitee -> https://www.gitee.com/PythonSJL/PyPyNum
18
18
 
19
19
  ![LOGO](PyPyNum.png)
20
20
 
21
+ PyPI上无法显示logo,可以在Gitee中查看。
22
+
23
+ The logo cannot be displayed on PyPI, it can be viewed in Gitee.
24
+
21
25
  ### 介绍
22
26
 
23
27
  #### Introduction
@@ -29,20 +33,27 @@
29
33
  + 如需联系,QQ 2261748025 (Py𝙿𝚢𝚝𝚑𝚘𝚗-水晶兰)
30
34
  + If you need to contact, QQ 2261748025 (Py𝙿𝚢𝚝𝚑𝚘𝚗-水晶兰)
31
35
 
32
- ### PyPyNum的Zen
36
+ ### PyPyNum的Zen(预览)
33
37
 
34
- #### The Zen of PyPyNum
38
+ #### The Zen of PyPyNum (Preview)
35
39
 
36
40
  ```
37
41
  The Zen of PyPyNum, by Shen Jiayi
38
42
 
39
43
  This is a math package written purely in Python.
40
44
 
41
- ... (Do you want to see the entire content?
42
- Then enter "from pypynum import this" on your
45
+ Elegant is superior to clunky.
46
+ Clarity trumps obscurity.
47
+ Straightforwardness is preferred over convolution.
48
+ Sophisticated is better than overcomplicated.
49
+ Flat structure beats nested hierarchies.
50
+ Sparse code wins over bloated ones.
51
+
52
+ ... (Do you want to view all the content?
53
+ Enter "from pypynum import this" in your
43
54
  Python interpreter and run it!)
44
55
 
45
- December 27, 2023
56
+ February 27, 2024
46
57
  ```
47
58
 
48
59
  ### 与上一个版本相比新增功能
@@ -50,21 +61,71 @@ Python interpreter and run it!)
50
61
  #### New features compared to the previous version
51
62
 
52
63
  ```
64
+ !=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=
65
+
66
+ 重写了PyPyNum的Zen。
67
+
68
+ Rewrote the Zen of PyPyNum.
69
+
70
+ !=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=
71
+
72
+ “maths”模块的一些功能已经进行了优化,
73
+ 以实现更快的运行速度。
74
+
75
+ Some functions of the "maths"
76
+ module have been optimized to
77
+ achieve faster running speed.
78
+
79
+ !=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=
80
+
81
+ 修复了“tools”模块中的“split”函数导致
82
+ 的字符串分割错误。
83
+
84
+ Fixed string splitting error
85
+ caused by the "split" function
86
+ in the "tools" module.
87
+
88
+ !=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=
89
+
90
+ “sequence”模块设置为每个序列返回单独
91
+ 的第n项或包含第0到第n项的列表的功能。
92
+
93
+ The "sequence" module sets the
94
+ function of returning a separate
95
+ nth item or a list containing
96
+ 0th to nth items for each
97
+ sequence.
98
+
99
+
100
+ “geometric_sequence”函数补充了一个
101
+ 情况的求解函数,并且已经证实,其余两个情
102
+ 况没有解析解,需要使用多项式方程来求解。
103
+
104
+ The "geometric_sequence"
105
+ function supplements the solving
106
+ function for one scenario, and
107
+ it has been confirmed that there
108
+ are no analytical solutions for
109
+ the remaining two scenarios,
110
+ which need to be solved using
111
+ polynomial equations for
112
+ implementation.
113
+
114
+ !=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=
115
+
53
116
  <<<The "+" indicates the newly added method>>>
54
117
 
55
118
  maths [Mathematical functions]
56
119
  ...
57
- cov(x: arr, y: arr) -> num +
58
- corr_coeff(x: arr, y: arr) -> num +
59
- coeff_det(x: arr, y: arr) -> num +
120
+ geom_mean(numbers: arr) -> num +
121
+ square_mean(numbers: arr) -> num +
122
+ harm_mean(numbers: arr) -> num +
60
123
  ...
61
124
 
62
125
  sequence [Various sequences]
63
126
  ...
64
- arithmetic_sequence(*, a1=None, an=None, d=None, n=None, s=None) +
65
- geometric_sequence(*, a1=None, an=None, r=None, n=None, s=None) +
66
-
67
- <<<There are three situations in the "geometric_sequence" function that have not been implemented>>>
127
+ recaman(n: int, single: bool = True) -> Union[int, list] +
128
+ ...
68
129
  ```
69
130
 
70
131
  ### 运行用时测试
@@ -305,6 +366,9 @@ PyPyNum
305
366
  freq(data: arr) -> dict
306
367
  mode(data: arr)
307
368
  mean(numbers: arr) -> num
369
+ geom_mean(numbers: arr) -> num
370
+ square_mean(numbers: arr) -> num
371
+ harm_mean(numbers: arr) -> num
308
372
  var(numbers: arr) -> num
309
373
  std(numbers: arr) -> num
310
374
  cov(x: arr, y: arr) -> num
@@ -357,11 +421,12 @@ PyPyNum
357
421
  polynomial_regression(x: Union[list, tuple], y: Union[list, tuple], n: int = None) -> list
358
422
  ★ sequence [Various sequences]
359
423
  FUNCTIONS
360
- fibonacci(n: int) -> int
361
- catalan(n: int) -> int
424
+ fibonacci(n: int, single: bool = True) -> Union[int, list]
425
+ catalan(n: int, single: bool = True) -> Union[int, list]
362
426
  bernoulli(n: int, single: bool = True) -> list
363
- arithmetic_sequence(*, a1=None, an=None, d=None, n=None, s=None)
364
- geometric_sequence(*, a1=None, an=None, r=None, n=None, s=None)
427
+ recaman(n: int, single: bool = True) -> Union[int, list]
428
+ arithmetic_sequence(*, a1: real = None, an: real = None, d: real = None, n: real = None, s: real = None) -> dict
429
+ geometric_sequence(*, a1: real = None, an: real = None, r: real = None, n: real = None, s: real = None) -> dict
365
430
  ★ tools [Other useful tools]
366
431
  FUNCTIONS
367
432
  classify(array: Union[list, tuple]) -> dict
@@ -33,7 +33,7 @@ from .tools import *
33
33
  from . import types
34
34
  from .Vector import vec
35
35
 
36
- __version__ = "1.5.1"
36
+ __version__ = "1.5.2"
37
37
  print("PyPyNum", "Version -> " + __version__, "PyPI -> https://pypi.org/project/PyPyNum/",
38
38
  "Gitee -> https://www.gitee.com/PythonSJL/PyPyNum", sep=" | ")
39
39
  del math, arr, ite, num, real, geom, RandomError, LogicError, InputError, FullError, Union
@@ -424,6 +424,57 @@ def mean(numbers: arr) -> num:
424
424
  return sum(numbers) / len(numbers)
425
425
 
426
426
 
427
+ def geom_mean(numbers: arr) -> num:
428
+ """
429
+ introduction
430
+ ==========
431
+ The geometric mean of numbers
432
+
433
+ example
434
+ ==========
435
+ >>> geom_mean([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
436
+ 4.528728688116765
437
+ >>>
438
+ :param numbers: list | tuple
439
+ :return:
440
+ """
441
+ return root(product(numbers), len(numbers))
442
+
443
+
444
+ def square_mean(numbers: arr) -> num:
445
+ """
446
+ introduction
447
+ ==========
448
+ Square mean of numbers
449
+
450
+ example
451
+ ==========
452
+ >>> square_mean([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
453
+ 6.2048368229954285
454
+ >>>
455
+ :param numbers: list | tuple
456
+ :return:
457
+ """
458
+ return (sum(map(lambda n: n * n, numbers)) / len(numbers)) ** 0.5
459
+
460
+
461
+ def harm_mean(numbers: arr) -> num:
462
+ """
463
+ introduction
464
+ ==========
465
+ The harmonic mean of numbers
466
+
467
+ example
468
+ ==========
469
+ >>> harm_mean([1, 2, 3, 4, 5, 6, 7, 8, 9, 10])
470
+ 3.414171521474055
471
+ >>>
472
+ :param numbers: list | tuple
473
+ :return:
474
+ """
475
+ return 0 if 0 in numbers else len(numbers) / sum(map(lambda n: 1 / n, numbers))
476
+
477
+
427
478
  def var(numbers: arr) -> num:
428
479
  """
429
480
  introduction
@@ -537,10 +588,29 @@ def product(numbers: arr) -> num:
537
588
  :param numbers: list | tuple
538
589
  :return:
539
590
  """
540
- result = 1
541
- for _ in numbers:
542
- result *= _
543
- return result
591
+ if len(numbers) == 0:
592
+ return 1
593
+ elif 0 in numbers:
594
+ return 0
595
+ elif len(numbers) == 1:
596
+ return numbers[0]
597
+ elif len(numbers) <= 4096:
598
+ result = numbers[0]
599
+ for i in numbers[1:]:
600
+ result *= i
601
+ return result
602
+
603
+ def prod(n):
604
+ if len(n) == 1:
605
+ return n[0]
606
+ mid = len(n) // 2
607
+ left_half = n[:mid]
608
+ right_half = n[mid:]
609
+ left_product = prod(left_half)
610
+ right_product = prod(right_half)
611
+ return left_product * right_product
612
+
613
+ return prod(numbers)
544
614
 
545
615
 
546
616
  def sigma(i: int, n: int, f) -> num:
@@ -716,6 +786,8 @@ def combination(n: int, r: int) -> int:
716
786
  :param r: integer
717
787
  :return:
718
788
  """
789
+ if r > n >> 1:
790
+ return combination(n, n - r)
719
791
  return product(list(range(n, n - r, -1))) // product(list(range(r, 0, -1)))
720
792
 
721
793
 
@@ -728,13 +800,13 @@ def zeta(alpha: real) -> float:
728
800
 
729
801
  example
730
802
  ==========
731
- >>> zeta(2)
732
- 1.6449339668472496
803
+ >>> zeta(3)
804
+ 1.202056903150321
733
805
  >>>
734
806
  :param alpha: integer | float
735
807
  :return:
736
808
  """
737
- return sum([1 / _ ** alpha for _ in range(1, 10000000)])
809
+ return sum(map(lambda _: _ ** (-alpha), range(1, 1000000)))
738
810
 
739
811
 
740
812
  def gaussian(x: real, _mu: real = 0, _sigma: real = 1) -> float:
@@ -909,7 +981,6 @@ def iroot(y: int, n: int) -> int:
909
981
  :param n: integer
910
982
  :return:
911
983
  """
912
- from math import log as _log
913
984
  i = False
914
985
  if y < 0 and n & 1:
915
986
  y = abs(y)
@@ -921,7 +992,7 @@ def iroot(y: int, n: int) -> int:
921
992
  try:
922
993
  g = int(y ** (1 / n) + 0.5)
923
994
  except OverflowError:
924
- e = _log(y, 2) / n
995
+ e = math.log(y, 2) / n
925
996
  if e > 53:
926
997
  s = int(e - 53)
927
998
  g = int(2 ** (e - s) + 1) << s
@@ -1,6 +1,16 @@
1
- def fibonacci(n: int) -> int:
1
+ from .types import Union, real
2
+
3
+
4
+ def fibonacci(n: int, single: bool = True) -> Union[int, list]:
2
5
  if isinstance(n, float):
3
6
  n = int(n)
7
+ if not single:
8
+ if n == 0:
9
+ return [0]
10
+ res = [0, 1]
11
+ for i in range(2, n + 1):
12
+ res.append(res[i - 1] + res[i - 2])
13
+ return res
4
14
 
5
15
  def mul(_a, _b):
6
16
  c = [[0, 0], [0, 0]]
@@ -22,12 +32,14 @@ def fibonacci(n: int) -> int:
22
32
  return res[0][1]
23
33
 
24
34
 
25
- def catalan(n: int) -> int:
35
+ def catalan(n: int, single: bool = True) -> Union[int, list]:
26
36
  try:
27
37
  from math import comb
28
38
  except ImportError:
29
39
  from .maths import combination as comb
30
- return comb(2 * n, n) // (n + 1)
40
+ if isinstance(n, float):
41
+ n = int(n)
42
+ return comb(2 * n, n) // (n + 1) if single else [comb(2 * x, x) // (x + 1) for x in range(n + 1)]
31
43
 
32
44
 
33
45
  def bernoulli(n: int, single: bool = True) -> list:
@@ -49,15 +61,31 @@ def bernoulli(n: int, single: bool = True) -> list:
49
61
  return [result[n].numerator, result[n].denominator] if single else [[n.numerator, n.denominator] for n in result]
50
62
 
51
63
 
52
- def arithmetic_sequence(*, a1=None, an=None, d=None, n=None, s=None):
64
+ def recaman(n: int, single: bool = True) -> Union[int, list]:
65
+ if isinstance(n, float):
66
+ n = int(n)
67
+ seq = []
68
+ for i in range(n + 1):
69
+ if i == 0:
70
+ x = 0
71
+ else:
72
+ x = seq[i - 1] - i
73
+ if x >= 0 and x not in seq:
74
+ seq += [x]
75
+ else:
76
+ seq += [seq[i - 1] + i]
77
+ return seq[n] if single else seq
78
+
79
+
80
+ def arithmetic_sequence(*, a1: real = None, an: real = None, d: real = None, n: real = None, s: real = None) -> dict:
53
81
  if [a1, an, d, n, s].count(None) != 2:
54
82
  raise ValueError("Must provide exactly three valid parameters")
55
83
 
56
84
  def solve_quadratic_equation(a, b, c):
57
85
  delta = b ** 2 - 4 * a * c
58
86
  if delta > 0:
59
- x1 = (-b + (delta ** 0.5)) / (2 * a)
60
- x2 = (-b - (delta ** 0.5)) / (2 * a)
87
+ x1 = (-b + delta ** 0.5) / (2 * a)
88
+ x2 = (-b - delta ** 0.5) / (2 * a)
61
89
  return [x1, x2]
62
90
  elif delta == 0:
63
91
  x = -b / (2 * a)
@@ -106,7 +134,7 @@ def arithmetic_sequence(*, a1=None, an=None, d=None, n=None, s=None):
106
134
  return {"a1": a1, "an": an, "d": d, "n": n, "s": s}
107
135
 
108
136
 
109
- def geometric_sequence(*, a1=None, an=None, r=None, n=None, s=None):
137
+ def geometric_sequence(*, a1: real = None, an: real = None, r: real = None, n: real = None, s: real = None) -> dict:
110
138
  from math import log
111
139
  if [a1, an, r, n, s].count(None) != 2:
112
140
  raise ValueError("Must provide exactly three valid parameters")
@@ -134,8 +162,8 @@ def geometric_sequence(*, a1=None, an=None, r=None, n=None, s=None):
134
162
  a1 = an / r ** (n - 1)
135
163
  s = a1 * (r ** n - 1) / (r - 1) if r != 1 else a1 * n
136
164
  elif an is not None and r is not None and s is not None:
137
- a1 = NotImplemented
138
- n = NotImplemented
165
+ a1 = s * (1 - r) + an * r
166
+ n = log(an / a1, r) + 1
139
167
  elif an is not None and n is not None and s is not None:
140
168
  a1 = NotImplemented
141
169
  r = NotImplemented
@@ -0,0 +1,9 @@
1
+ """
2
+ The Zen of PyPyNum
3
+ """
4
+
5
+ Zen = "\x9a¤¢\xa0¢°¼§¢°éâñåâòõÖ°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°°\x9a\x9a±äù°õóñâòýõ°ã·äõü½äàõóþÿó°äåÿôþñäã°ñ°ãù°þ÷ùãõô°âñüåôÿÝ\x9a¾÷þùãùýÿâà°õò°äø÷ùý°äù°¼ôâñçâÿöäø÷ùñâäã°ãù°þÿùäñäþõýõüàýù°õøä°öÙ\x9a¾äù°âõôùãþÿóõâ°¼ôþõøõâàýÿó°ÿä°÷þù÷þõüüñøó°ãù°þÿùäñäþõýõüàýù°õøä°öÙ\x9a¾÷þùøãåâ°ÿä°âÿùâõàåã°ãù°÷þùäùñç°ãõýùäõýÿã°¼âõæõçÿØ\x9a¾þÿùäñþùäãñâóÿâà°þñøä°âõääõò°ãù°éüäàýÿâà°÷þùäóÑ\x9a¾øóñÿâààñ°ãåÿùæòÿ½õþÿ°éüþÿ°õøä°¼éüüñõôù½õþÿ°õò°äãåý°õâõøÄ\x9a¾õäñüåóõàã°ÿä°õ÷âå°õøä°äãùãõâ°¼ããõþõå÷ñæ°öÿ°õóþõãõâà°õøä°þÙ\x9a¾ôõäåý°éüäùóùüàèõ°ããõüþÅ\x9a¾ôõóþõüùã°äÿþ°¼þõûÿàã°õò°äãåý°ãâÿââÕ\x9a¾éäùâåà°âõæÿ°ãøàýåùâä°þõäöÿ°éäùüñóùäóñâÀ\x9a¾ãýâÿþ°õøä°õôùââõæÿ°äÿþ°ôüåÿøã°ãõãñó°üñùóõàÃ\x9a¾äþåÿýñâñà°ãù°éäùüùòñôñõÂ\x9a¾ãõþÿ°ôõäñÿüò°âõæÿ°ãþùç°õôÿó°õãâñàÃ\x9a¾ãõùøóâñâõùø°ôõäãõþ°ãäñõò°õâåäóåâäã°äñüÖ\x9a¾ôõäñóùüàýÿóâõæÿ°þñøä°âõääõò°ãù°ôõäñóùäãùøàÿÃ\x9a¾þÿùäåüÿæþÿó°âõæÿ°ôõââõöõâà°ãù°ããõþôâñçâÿöäø÷ùñâäÃ\x9a¾éäùâåóãòÿ°ãàýåâä°éäùâñüÓ\x9a¾éûþåüó°ÿä°âÿùâõàåã°ãù°äþñ÷õüÕ\x9a\x9a¾þÿøäéÀ°þù°éüõâåà°þõääùâç°õ÷ñûóñà°øäñý°ñ°ãù°ãùøÄ\x9a\x9aùéñùÚ°þõøÃ°éò°¼ýåÞéÀéÀ°öÿ°þõʰõøÄ°°°°\x9a"
6
+ print("".join([chr(ord(_) ^ 144) for _ in Zen[::-1]]))
7
+ for _ in list(globals().keys()):
8
+ del globals()[_]
9
+ del _
@@ -160,6 +160,7 @@ def split(iterable: ite, key: arr, retain: bool = False) -> list:
160
160
  if indexes:
161
161
  index = min(indexes)
162
162
  result.append(iterable[pointer:index])
163
+ pointer = index
163
164
  if retain is True:
164
165
  result.append(indexes[index])
165
166
  pointer += len(indexes[index])
@@ -173,7 +174,7 @@ def split(iterable: ite, key: arr, retain: bool = False) -> list:
173
174
  if isinstance(iterable, (list, tuple)):
174
175
  pointer = item + 1
175
176
  if retain is True:
176
- result.append(iterable[item])
177
+ result.append([iterable[item]])
177
178
  result.append(iterable[pointer:])
178
179
  else:
179
180
  raise TypeError("Iterable can only be a list, tuple or str")
@@ -669,14 +669,14 @@ For more information on this, and how to apply and follow the GNU AGPL, see
669
669
 
670
670
  setup(
671
671
  name="PyPyNum",
672
- version="1.5.1",
672
+ version="1.5.2",
673
673
  packages=find_packages(),
674
674
  url="https://www.gitee.com/PythonSJL/PyPyNum",
675
675
  license=LICENSE,
676
676
  author="Shen Jiayi",
677
677
  author_email="2261748025@qq.com",
678
678
  description="""
679
- A Python math package written in pure Python programming language [python_requires >= 3.5]
679
+ A multifunctional mathematical calculation package written in pure Python programming language [Python>=3.5]
680
680
  """,
681
681
  python_requires=">=3.5",
682
682
  package_data={"pypynum": ["*"]},
@@ -1,9 +0,0 @@
1
- """
2
- The Zen of PyPyNum
3
- """
4
-
5
- Zen = 'rKJHJXTOJX\n\x1d\x1a\x15\x1d\x1b\x1d<XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXrrV\n\x19\x1d\x01X\x19X\x16\x11\x10\x0c\x11\x0fX\x14\x19\x17\x1fX\x0b\x11\x10\x0cX\x0b\x0b\x19\x08\n\r\x0bX\x16\x19\x1bX1rT\x10\x1f\r\x17\x16\x1dX\x0c\x0b\x19\x1eX\x0b\x11X\x1c\x1d\x1d\x08\x0bX\x1d\x0c\x19\x1c\x08\rX\x1d\x10\x0cX\x1e1rT\x0c\x1e\x1d\x14X\x0b\n\x19\x1d\x01X\x1e\x14\x19\x10X\x19X\x1c\x16\x19X\x1d\x16\x17X\x14\x14\x11\x0c\x0bX\x0b\x11X\x1d\n\x1d\x10,rrV\x14\x17\x17\x10\x1b\x0bX\x10\x1f\x11\x10X\x15\x17\n\x1eX\x1c\x1d\x0c\x19\r\x1c\x19\n\x1fX\x01\x1c\x19\x1d\n\x14\x19X\x1d\x0e\x19\x10X1X\x0b\x08\x19\x10\n\x1d(rT\x0b\x14\x19\x17\x1fX\x1f\x16\x11\x0e\x1d\x11\x10\x1b\x19X\x16\x1d\x10\x0fXT\x1d\x0b\n\r\x17\x1bX\x1e7rT\x1d\x1c\x17\x1bX\x1e\x17X\x0b\x1d\x16\x11\x14XHHHHIX\x1c\x1d\x1d\x1b\x00\x1dX\x17\x0cX\x0b\x15\x11\x19X\x1d\x1f\x19\x13\x1b\x19\x08X\x10\x0c\x19\x15X\x0b\x11\x10,rrV\x0c\x11X\x1d\x13\x11\x14X\x16\x19\x1bX\x1d\x16\x17\x01\n\x1d\x0e\x1dX\x1d\x08\x17\x10X1rT\x01(\x11\x1b+X\x1c\x16\x19X\x01(\x15\r6X\x0b\x19X\x10\x1b\r\x0bX\x0b\x1d\x1f\x19\x13\x1b\x19\x08r\x14\x19\x1b\x11\x0c\x19\x15\x1d\x10\x0c\x19\x15X\x1e\x17X\x16\x17\x11\x0c\n\x17\x08X\x14\x14\x19\x15\x0bX\x19X\x1d\x1b\x19\x14\x08\x1d\nX\x16\x19\x1bX\x0c1rT\x1d\x1f\x19\r\x1f\x16\x19\x14X;X\x1d\x0c\r\x1b\x1d\x00\x1dX\x0c\x17\x16\x16\x19\x1bX\x0b\n\x1d\x0c\x1d\n\x08\n\x1d\x0c\x16\x11X\x01(\x01(r\x0c\x19\x10\x0cX\x1d\x1f\x19\x0c\x16\x19\x0e\x1c\x19\x0b\x11\x1cX\x1d\x10\x0cX\n\x17\x1eX\x1d\x0c\x19\x0b\x16\x1d\x08\x15\x17\x1bX\x16\x19\x1bX\x0c\x11X\x0c\r:rT\x1d\x1f\x19\r\x1f\x16\x19\x14X;X\x0b\x19X\x0c\x0b\x19\x1eX\x0b\x19X\x0c\x17\x16X\x0b\x11X\x16\x17\x10\x0c\x01(X\x1d\n\r\x08X\x10\x1f\r\x17\x10\x0c\x149rrV\x1d\x16\x17\x14\x19X\x1d\x15X\x01\x1aX\x16\x1d\x0c\x0c\x11\n\x0fX\x1c\x1d\x1d\x1c\x16\x11X\x0b\x19\x0fX\x0c\x11XT\n\x1d\x0e\x1d\x0f\x170rrG\x0c\x16\x1d\x1c\r\x0c\x0br\x14\x17\x17\x10\x1b\x0bX\x10\x1f\x11\x10X\x19X\x01\x1aX\x16\x1d\x0c\x0c\x11\n\x0fX\x0b\x19\x0fX\x0b\x11\x10\x0cX\x1d\x0e\x1d\x11\x14\x1d\x1aX\r\x17\x01X\x17<rrV\x16\x17\x10\x0c\x01(X\x16\x11X\x01\x14\x1d\n\r\x08X\x16\x1d\x0c\x0c\x11\n\x0fX\x1d\x1f\x19\x13\x1b\x19\x08X\x10\x0c\x19\x15X\x19X\x0b\x11X\x0b\x11\x10,rr\x11\x01\x19\x112X\x16\x1d\x10+X\x01\x1aXT\x15\r6\x01(\x01(X\x1e\x17X\x16\x1d"X\x1d\x10,XXXXr'
6
- print("".join([chr(ord(_) ^ 120) for _ in Zen[::-1]]))
7
- for _ in list(globals().keys()):
8
- del globals()[_]
9
- del _
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes