PyPyNum 1.3.0__tar.gz → 1.3.1__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.
- {PyPyNum-1.3.0 → PyPyNum-1.3.1}/PKG-INFO +32 -56
- {PyPyNum-1.3.0 → PyPyNum-1.3.1}/PyPyNum.egg-info/PKG-INFO +32 -56
- {PyPyNum-1.3.0 → PyPyNum-1.3.1}/pypynum/Array.py +36 -7
- {PyPyNum-1.3.0 → PyPyNum-1.3.1}/pypynum/Matrix.py +1 -1
- {PyPyNum-1.3.0 → PyPyNum-1.3.1}/pypynum/README.md +31 -55
- {PyPyNum-1.3.0 → PyPyNum-1.3.1}/pypynum/__init__.py +4 -4
- PyPyNum-1.3.1/pypynum/equations.py +14 -0
- {PyPyNum-1.3.0 → PyPyNum-1.3.1}/pypynum/file.py +4 -4
- PyPyNum-1.3.1/pypynum/regression.py +59 -0
- {PyPyNum-1.3.0 → PyPyNum-1.3.1}/setup.py +1 -1
- PyPyNum-1.3.0/pypynum/equations.py +0 -17
- PyPyNum-1.3.0/pypynum/regression.py +0 -36
- {PyPyNum-1.3.0 → PyPyNum-1.3.1}/PyPyNum.egg-info/SOURCES.txt +0 -0
- {PyPyNum-1.3.0 → PyPyNum-1.3.1}/PyPyNum.egg-info/dependency_links.txt +0 -0
- {PyPyNum-1.3.0 → PyPyNum-1.3.1}/PyPyNum.egg-info/top_level.txt +0 -0
- {PyPyNum-1.3.0 → PyPyNum-1.3.1}/pypynum/Geometry.py +0 -0
- {PyPyNum-1.3.0 → PyPyNum-1.3.1}/pypynum/Group.py +0 -0
- {PyPyNum-1.3.0 → PyPyNum-1.3.1}/pypynum/Logic.py +0 -0
- {PyPyNum-1.3.0 → PyPyNum-1.3.1}/pypynum/PyPyNum.png +0 -0
- {PyPyNum-1.3.0 → PyPyNum-1.3.1}/pypynum/Quaternion.py +0 -0
- {PyPyNum-1.3.0 → PyPyNum-1.3.1}/pypynum/Symbolics.py +0 -0
- {PyPyNum-1.3.0 → PyPyNum-1.3.1}/pypynum/Tensor.py +0 -0
- {PyPyNum-1.3.0 → PyPyNum-1.3.1}/pypynum/Vector.py +0 -0
- {PyPyNum-1.3.0 → PyPyNum-1.3.1}/pypynum/cipher.py +0 -0
- {PyPyNum-1.3.0 → PyPyNum-1.3.1}/pypynum/constants.py +0 -0
- {PyPyNum-1.3.0 → PyPyNum-1.3.1}/pypynum/errors.py +0 -0
- {PyPyNum-1.3.0 → PyPyNum-1.3.1}/pypynum/mathematics.py +0 -0
- {PyPyNum-1.3.0 → PyPyNum-1.3.1}/pypynum/neuralnetwork.py +0 -0
- {PyPyNum-1.3.0 → PyPyNum-1.3.1}/pypynum/plotting.py +0 -0
- {PyPyNum-1.3.0 → PyPyNum-1.3.1}/pypynum/random.py +0 -0
- {PyPyNum-1.3.0 → PyPyNum-1.3.1}/pypynum/test.py +0 -0
- {PyPyNum-1.3.0 → PyPyNum-1.3.1}/pypynum/this.py +0 -0
- {PyPyNum-1.3.0 → PyPyNum-1.3.1}/pypynum/tools.py +0 -0
- {PyPyNum-1.3.0 → PyPyNum-1.3.1}/pypynum/types.py +0 -0
- {PyPyNum-1.3.0 → PyPyNum-1.3.1}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: PyPyNum
|
|
3
|
-
Version: 1.3.
|
|
3
|
+
Version: 1.3.1
|
|
4
4
|
Summary: A Python math package written in pure Python programming language [python_requires >= 3.5]
|
|
5
5
|
Home-page: https://www.gitee.com/PythonSJL/PyPyNum
|
|
6
6
|
Author: Shen Jiayi
|
|
@@ -687,7 +687,7 @@ python_requires >= 3.5)</font>
|
|
|
687
687
|
\|___|/ \|___|/
|
|
688
688
|
```
|
|
689
689
|
|
|
690
|
-
## Version -> 1.3.
|
|
690
|
+
## Version -> 1.3.1 | PyPI -> https://pypi.org/project/PyPyNum/ | Gitee -> https://www.gitee.com/PythonSJL/PyPyNum
|
|
691
691
|
|
|
692
692
|

|
|
693
693
|
|
|
@@ -724,30 +724,6 @@ Python interpreter and run it!)
|
|
|
724
724
|
|
|
725
725
|
```
|
|
726
726
|
PyPyNum
|
|
727
|
-
Group
|
|
728
|
-
CLASSES
|
|
729
|
-
Group
|
|
730
|
-
| __eq__(self, other)
|
|
731
|
-
| __init__(self, data)
|
|
732
|
-
| __ne__(self, other)
|
|
733
|
-
| __repr__(self)
|
|
734
|
-
| has_identity(self, operation=<function multiply at ...>)
|
|
735
|
-
| has_inverses(self, operation=<function multiply at ...>)
|
|
736
|
-
| is_associative(self, operation=<function multiply at ...>, modulus=None)
|
|
737
|
-
| is_closed(self, operation=<function multiply at ...>, modulus=None)
|
|
738
|
-
| is_group(self, operation=<function multiply at ...>, modulus=None)
|
|
739
|
-
| is_semigroup(self, operation=<function multiply at ...>, modulus=None)
|
|
740
|
-
| order(self)
|
|
741
|
-
FUNCTIONS
|
|
742
|
-
add(x, y)
|
|
743
|
-
divide(x, y)
|
|
744
|
-
group(data)
|
|
745
|
-
multiply(x, y)
|
|
746
|
-
subtract(x, y)
|
|
747
|
-
file
|
|
748
|
-
FUNCTIONS
|
|
749
|
-
read(file: str) -> list
|
|
750
|
-
write(file: str, *cls: object)
|
|
751
727
|
|
|
752
728
|
[Additionally, revise and supplement the original code]
|
|
753
729
|
```
|
|
@@ -758,38 +734,39 @@ PyPyNum
|
|
|
758
734
|
|
|
759
735
|
```
|
|
760
736
|
PyPyNum
|
|
761
|
-
__init__
|
|
737
|
+
★ __init__
|
|
762
738
|
[Import some features from other modules in this package]
|
|
763
|
-
errors [Special errors]
|
|
739
|
+
★ errors [Special errors]
|
|
764
740
|
CLASSES
|
|
765
741
|
LogicError
|
|
766
742
|
RandomError
|
|
767
743
|
ShapeError
|
|
768
|
-
file [Reading and saving instance data]
|
|
744
|
+
★ file [Reading and saving instance data]
|
|
769
745
|
FUNCTIONS
|
|
770
746
|
read(file: str) -> list
|
|
771
747
|
write(file: str, *cls: object)
|
|
772
|
-
test
|
|
748
|
+
★ test
|
|
773
749
|
[A code test file]
|
|
774
|
-
this
|
|
750
|
+
★ this
|
|
775
751
|
[The Zen of PyPyNum]
|
|
776
|
-
types [Special types]
|
|
752
|
+
★ types [Special types]
|
|
777
753
|
DATA
|
|
778
754
|
arr = typing.Union[list, tuple]
|
|
779
755
|
ite = typing.Union[list, tuple, str]
|
|
780
756
|
num = typing.Union[int, float, complex]
|
|
781
757
|
real = typing.Union[int, float]
|
|
782
|
-
Array [N-dimensional array]
|
|
758
|
+
★ Array [N-dimensional array]
|
|
783
759
|
CLASSES
|
|
784
760
|
Array
|
|
785
761
|
FUNCTIONS
|
|
786
762
|
array(data=None)
|
|
763
|
+
fill(shape, sequence=None)
|
|
787
764
|
function(_array, _function, args=None)
|
|
788
765
|
get_shape(data)
|
|
789
766
|
is_valid_array(_array, _shape)
|
|
790
|
-
zeros(
|
|
767
|
+
zeros(shape)
|
|
791
768
|
zeros_like(_nested_list)
|
|
792
|
-
Geometry [Planar geometry]
|
|
769
|
+
★ Geometry [Planar geometry]
|
|
793
770
|
CLASSES
|
|
794
771
|
Circle
|
|
795
772
|
Line
|
|
@@ -799,7 +776,7 @@ PyPyNum
|
|
|
799
776
|
Triangle
|
|
800
777
|
FUNCTIONS
|
|
801
778
|
distance(g1, g2, error: int | float = 0) -> float
|
|
802
|
-
Group [Group theory]
|
|
779
|
+
★ Group [Group theory]
|
|
803
780
|
CLASSES
|
|
804
781
|
Group
|
|
805
782
|
FUNCTIONS
|
|
@@ -808,7 +785,7 @@ PyPyNum
|
|
|
808
785
|
group(data)
|
|
809
786
|
multiply(x, y)
|
|
810
787
|
subtract(x, y)
|
|
811
|
-
Logic [Logic circuit simulation]
|
|
788
|
+
★ Logic [Logic circuit simulation]
|
|
812
789
|
CLASSES
|
|
813
790
|
Basic
|
|
814
791
|
Binary
|
|
@@ -832,7 +809,7 @@ PyPyNum
|
|
|
832
809
|
DFF
|
|
833
810
|
NOT
|
|
834
811
|
TFF
|
|
835
|
-
Matrix [Matrix calculation]
|
|
812
|
+
★ Matrix [Matrix calculation]
|
|
836
813
|
CLASSES
|
|
837
814
|
Matrix
|
|
838
815
|
FUNCTIONS
|
|
@@ -846,7 +823,7 @@ PyPyNum
|
|
|
846
823
|
tril_indices(n, k=0, m=None)
|
|
847
824
|
zeros(_dimensions)
|
|
848
825
|
zeros_like(_nested_list)
|
|
849
|
-
Quaternion [Quaternion calculation]
|
|
826
|
+
★ Quaternion [Quaternion calculation]
|
|
850
827
|
CLASSES
|
|
851
828
|
Euler
|
|
852
829
|
Quaternion
|
|
@@ -854,7 +831,7 @@ PyPyNum
|
|
|
854
831
|
change(data: Euler | Quaternion) -> Quaternion | Euler
|
|
855
832
|
euler(yaw: int | float = 0, pitch: int | float = 0, roll: int | float = 0) -> Euler
|
|
856
833
|
quat(w: int | float = 0, x: int | float = 0, y: int | float = 0, z: int | float = 0) -> Quaternion
|
|
857
|
-
Symbolics [Symbol calculation]
|
|
834
|
+
★ Symbolics [Symbol calculation]
|
|
858
835
|
FUNCTIONS
|
|
859
836
|
interpreter(expr: str) -> list
|
|
860
837
|
DATA
|
|
@@ -863,7 +840,7 @@ PyPyNum
|
|
|
863
840
|
greek = 'ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟ∏ΡΣΤΥΦΧΨΩβγδεζηθικλμνξοπρστυφχψω'
|
|
864
841
|
operators = ['**', '*', '//', '/', '%', '+', '-']
|
|
865
842
|
valid = '%()*+-./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcd...yzΑΒΓΔΕΖΗΘ...'
|
|
866
|
-
Tensor [Tensor calculation]
|
|
843
|
+
★ Tensor [Tensor calculation]
|
|
867
844
|
CLASSES
|
|
868
845
|
Tensor
|
|
869
846
|
FUNCTIONS
|
|
@@ -872,7 +849,7 @@ PyPyNum
|
|
|
872
849
|
tolist(_nested_list)
|
|
873
850
|
zeros(_dimensions)
|
|
874
851
|
zeros_like(_nested_list)
|
|
875
|
-
Vector [Vector calculation]
|
|
852
|
+
★ Vector [Vector calculation]
|
|
876
853
|
CLASSES
|
|
877
854
|
Vector
|
|
878
855
|
FUNCTIONS
|
|
@@ -880,10 +857,10 @@ PyPyNum
|
|
|
880
857
|
vec(data)
|
|
881
858
|
zeros(_dimensions)
|
|
882
859
|
zeros_like(_nested_list)
|
|
883
|
-
cipher [String encryption and decryption algorithms]
|
|
860
|
+
★ cipher [String encryption and decryption algorithms]
|
|
884
861
|
FUNCTIONS
|
|
885
862
|
dna(string: str, decrypt: bool = False) -> str
|
|
886
|
-
constants [Constants in mathematics and science]
|
|
863
|
+
★ constants [Constants in mathematics and science]
|
|
887
864
|
DATA
|
|
888
865
|
AMU = 1.6605402e-27
|
|
889
866
|
EB = 1152921504606846976
|
|
@@ -925,13 +902,11 @@ PyPyNum
|
|
|
925
902
|
yotta = 1e+24
|
|
926
903
|
zepto = 1e-21
|
|
927
904
|
zetta = 1e+21
|
|
928
|
-
equations [Solving specific forms of equations]
|
|
905
|
+
★ equations [Solving specific forms of equations]
|
|
929
906
|
FUNCTIONS
|
|
930
|
-
|
|
931
|
-
multivariate_linear_equation_system(left: list, right: list) -> None | list
|
|
932
|
-
pe = polynomial_equation(coefficients: list) -> list
|
|
907
|
+
linear_equation(left: list, right: list) -> list
|
|
933
908
|
polynomial_equation(coefficients: list) -> list
|
|
934
|
-
mathematics [Mathematical functions]
|
|
909
|
+
★ mathematics [Mathematical functions]
|
|
935
910
|
FUNCTIONS
|
|
936
911
|
A = arrangement(n: int, r: int) -> int
|
|
937
912
|
C = combination(n: int, r: int) -> int
|
|
@@ -984,17 +959,17 @@ PyPyNum
|
|
|
984
959
|
tanh(x: int | float) -> int | float
|
|
985
960
|
var(numbers: list | tuple) -> int | float | complex
|
|
986
961
|
zeta(alpha: int | float) -> float
|
|
987
|
-
neuralnetwork [A simple neural network model]
|
|
962
|
+
★ neuralnetwork [A simple neural network model]
|
|
988
963
|
CLASSES
|
|
989
964
|
NeuralNetwork
|
|
990
|
-
plotting [Draw a graph of equations using characters]
|
|
965
|
+
★ plotting [Draw a graph of equations using characters]
|
|
991
966
|
FUNCTIONS
|
|
992
967
|
background(right: int | float = 5, left: int | float = -5, top: int | float = 5, bottom: int | float = -5, complexity: int | float = 5, ratio: int | float = 3, merge: bool = False) -> list | str
|
|
993
968
|
binary(function, right: int | float = 5, left: int | float = -5, top: int | float = 5, bottom: int | float = -5, complexity: int | float = 5, ratio: int | float = 3, error=0, compare='==', merge: bool = True, basic: list = None, character: str = '.', data: bool = False) -> list | str
|
|
994
969
|
c_unary(function, start: int | float, end: int | float, interval: int | float = 5, projection: str = 'ri', right: int | float = 5, left: int | float = -5, top: int | float = 5, bottom: int | float = -5, complexity: int | float = 5, ratio: int | float = 3, merge: bool = True, basic: list = None, character: str = '.', data: bool = False) -> list | str
|
|
995
970
|
change(data: list | str) -> list | str
|
|
996
971
|
unary(function, right: int | float = 5, left: int | float = -5, top: int | float = 5, bottom: int | float = -5, complexity: int | float = 5, ratio: int | float = 3, merge: bool = True, basic: list = None, character: str = '.', data: bool = False) -> list | str
|
|
997
|
-
random [Generate random numbers or random arrays]
|
|
972
|
+
★ random [Generate random numbers or random arrays]
|
|
998
973
|
FUNCTIONS
|
|
999
974
|
choice(seq: list | tuple | str, shape: list | tuple = None)
|
|
1000
975
|
gauss(mu: int | float = 0, sigma: int | float = 1, shape: list | tuple = None) -> float | list
|
|
@@ -1002,11 +977,12 @@ PyPyNum
|
|
|
1002
977
|
rand(shape: list | tuple = None) -> float | list
|
|
1003
978
|
randint(a: int, b: int, shape: list | tuple = None) -> int | list
|
|
1004
979
|
uniform(a: int | float, b: int | float, shape: list | tuple = None) -> float | list
|
|
1005
|
-
regression [
|
|
980
|
+
★ regression [Formula based polynomial regression]
|
|
1006
981
|
FUNCTIONS
|
|
1007
|
-
linear_regression(x, y)
|
|
1008
|
-
parabolic_regression(x, y)
|
|
1009
|
-
|
|
982
|
+
linear_regression(x: Union[list, tuple], y: Union[list, tuple]) -> list
|
|
983
|
+
parabolic_regression(x: Union[list, tuple], y: Union[list, tuple]) -> list
|
|
984
|
+
polynomial_regression(x: Union[list, tuple], y: Union[list, tuple], n: int = None) -> list
|
|
985
|
+
★ tools [Other useful tools]
|
|
1010
986
|
FUNCTIONS
|
|
1011
987
|
classify(array: list | tuple) -> dict
|
|
1012
988
|
deduplicate(iterable: list | tuple | str) -> list | tuple | str
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: PyPyNum
|
|
3
|
-
Version: 1.3.
|
|
3
|
+
Version: 1.3.1
|
|
4
4
|
Summary: A Python math package written in pure Python programming language [python_requires >= 3.5]
|
|
5
5
|
Home-page: https://www.gitee.com/PythonSJL/PyPyNum
|
|
6
6
|
Author: Shen Jiayi
|
|
@@ -687,7 +687,7 @@ python_requires >= 3.5)</font>
|
|
|
687
687
|
\|___|/ \|___|/
|
|
688
688
|
```
|
|
689
689
|
|
|
690
|
-
## Version -> 1.3.
|
|
690
|
+
## Version -> 1.3.1 | PyPI -> https://pypi.org/project/PyPyNum/ | Gitee -> https://www.gitee.com/PythonSJL/PyPyNum
|
|
691
691
|
|
|
692
692
|

|
|
693
693
|
|
|
@@ -724,30 +724,6 @@ Python interpreter and run it!)
|
|
|
724
724
|
|
|
725
725
|
```
|
|
726
726
|
PyPyNum
|
|
727
|
-
Group
|
|
728
|
-
CLASSES
|
|
729
|
-
Group
|
|
730
|
-
| __eq__(self, other)
|
|
731
|
-
| __init__(self, data)
|
|
732
|
-
| __ne__(self, other)
|
|
733
|
-
| __repr__(self)
|
|
734
|
-
| has_identity(self, operation=<function multiply at ...>)
|
|
735
|
-
| has_inverses(self, operation=<function multiply at ...>)
|
|
736
|
-
| is_associative(self, operation=<function multiply at ...>, modulus=None)
|
|
737
|
-
| is_closed(self, operation=<function multiply at ...>, modulus=None)
|
|
738
|
-
| is_group(self, operation=<function multiply at ...>, modulus=None)
|
|
739
|
-
| is_semigroup(self, operation=<function multiply at ...>, modulus=None)
|
|
740
|
-
| order(self)
|
|
741
|
-
FUNCTIONS
|
|
742
|
-
add(x, y)
|
|
743
|
-
divide(x, y)
|
|
744
|
-
group(data)
|
|
745
|
-
multiply(x, y)
|
|
746
|
-
subtract(x, y)
|
|
747
|
-
file
|
|
748
|
-
FUNCTIONS
|
|
749
|
-
read(file: str) -> list
|
|
750
|
-
write(file: str, *cls: object)
|
|
751
727
|
|
|
752
728
|
[Additionally, revise and supplement the original code]
|
|
753
729
|
```
|
|
@@ -758,38 +734,39 @@ PyPyNum
|
|
|
758
734
|
|
|
759
735
|
```
|
|
760
736
|
PyPyNum
|
|
761
|
-
__init__
|
|
737
|
+
★ __init__
|
|
762
738
|
[Import some features from other modules in this package]
|
|
763
|
-
errors [Special errors]
|
|
739
|
+
★ errors [Special errors]
|
|
764
740
|
CLASSES
|
|
765
741
|
LogicError
|
|
766
742
|
RandomError
|
|
767
743
|
ShapeError
|
|
768
|
-
file [Reading and saving instance data]
|
|
744
|
+
★ file [Reading and saving instance data]
|
|
769
745
|
FUNCTIONS
|
|
770
746
|
read(file: str) -> list
|
|
771
747
|
write(file: str, *cls: object)
|
|
772
|
-
test
|
|
748
|
+
★ test
|
|
773
749
|
[A code test file]
|
|
774
|
-
this
|
|
750
|
+
★ this
|
|
775
751
|
[The Zen of PyPyNum]
|
|
776
|
-
types [Special types]
|
|
752
|
+
★ types [Special types]
|
|
777
753
|
DATA
|
|
778
754
|
arr = typing.Union[list, tuple]
|
|
779
755
|
ite = typing.Union[list, tuple, str]
|
|
780
756
|
num = typing.Union[int, float, complex]
|
|
781
757
|
real = typing.Union[int, float]
|
|
782
|
-
Array [N-dimensional array]
|
|
758
|
+
★ Array [N-dimensional array]
|
|
783
759
|
CLASSES
|
|
784
760
|
Array
|
|
785
761
|
FUNCTIONS
|
|
786
762
|
array(data=None)
|
|
763
|
+
fill(shape, sequence=None)
|
|
787
764
|
function(_array, _function, args=None)
|
|
788
765
|
get_shape(data)
|
|
789
766
|
is_valid_array(_array, _shape)
|
|
790
|
-
zeros(
|
|
767
|
+
zeros(shape)
|
|
791
768
|
zeros_like(_nested_list)
|
|
792
|
-
Geometry [Planar geometry]
|
|
769
|
+
★ Geometry [Planar geometry]
|
|
793
770
|
CLASSES
|
|
794
771
|
Circle
|
|
795
772
|
Line
|
|
@@ -799,7 +776,7 @@ PyPyNum
|
|
|
799
776
|
Triangle
|
|
800
777
|
FUNCTIONS
|
|
801
778
|
distance(g1, g2, error: int | float = 0) -> float
|
|
802
|
-
Group [Group theory]
|
|
779
|
+
★ Group [Group theory]
|
|
803
780
|
CLASSES
|
|
804
781
|
Group
|
|
805
782
|
FUNCTIONS
|
|
@@ -808,7 +785,7 @@ PyPyNum
|
|
|
808
785
|
group(data)
|
|
809
786
|
multiply(x, y)
|
|
810
787
|
subtract(x, y)
|
|
811
|
-
Logic [Logic circuit simulation]
|
|
788
|
+
★ Logic [Logic circuit simulation]
|
|
812
789
|
CLASSES
|
|
813
790
|
Basic
|
|
814
791
|
Binary
|
|
@@ -832,7 +809,7 @@ PyPyNum
|
|
|
832
809
|
DFF
|
|
833
810
|
NOT
|
|
834
811
|
TFF
|
|
835
|
-
Matrix [Matrix calculation]
|
|
812
|
+
★ Matrix [Matrix calculation]
|
|
836
813
|
CLASSES
|
|
837
814
|
Matrix
|
|
838
815
|
FUNCTIONS
|
|
@@ -846,7 +823,7 @@ PyPyNum
|
|
|
846
823
|
tril_indices(n, k=0, m=None)
|
|
847
824
|
zeros(_dimensions)
|
|
848
825
|
zeros_like(_nested_list)
|
|
849
|
-
Quaternion [Quaternion calculation]
|
|
826
|
+
★ Quaternion [Quaternion calculation]
|
|
850
827
|
CLASSES
|
|
851
828
|
Euler
|
|
852
829
|
Quaternion
|
|
@@ -854,7 +831,7 @@ PyPyNum
|
|
|
854
831
|
change(data: Euler | Quaternion) -> Quaternion | Euler
|
|
855
832
|
euler(yaw: int | float = 0, pitch: int | float = 0, roll: int | float = 0) -> Euler
|
|
856
833
|
quat(w: int | float = 0, x: int | float = 0, y: int | float = 0, z: int | float = 0) -> Quaternion
|
|
857
|
-
Symbolics [Symbol calculation]
|
|
834
|
+
★ Symbolics [Symbol calculation]
|
|
858
835
|
FUNCTIONS
|
|
859
836
|
interpreter(expr: str) -> list
|
|
860
837
|
DATA
|
|
@@ -863,7 +840,7 @@ PyPyNum
|
|
|
863
840
|
greek = 'ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟ∏ΡΣΤΥΦΧΨΩβγδεζηθικλμνξοπρστυφχψω'
|
|
864
841
|
operators = ['**', '*', '//', '/', '%', '+', '-']
|
|
865
842
|
valid = '%()*+-./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcd...yzΑΒΓΔΕΖΗΘ...'
|
|
866
|
-
Tensor [Tensor calculation]
|
|
843
|
+
★ Tensor [Tensor calculation]
|
|
867
844
|
CLASSES
|
|
868
845
|
Tensor
|
|
869
846
|
FUNCTIONS
|
|
@@ -872,7 +849,7 @@ PyPyNum
|
|
|
872
849
|
tolist(_nested_list)
|
|
873
850
|
zeros(_dimensions)
|
|
874
851
|
zeros_like(_nested_list)
|
|
875
|
-
Vector [Vector calculation]
|
|
852
|
+
★ Vector [Vector calculation]
|
|
876
853
|
CLASSES
|
|
877
854
|
Vector
|
|
878
855
|
FUNCTIONS
|
|
@@ -880,10 +857,10 @@ PyPyNum
|
|
|
880
857
|
vec(data)
|
|
881
858
|
zeros(_dimensions)
|
|
882
859
|
zeros_like(_nested_list)
|
|
883
|
-
cipher [String encryption and decryption algorithms]
|
|
860
|
+
★ cipher [String encryption and decryption algorithms]
|
|
884
861
|
FUNCTIONS
|
|
885
862
|
dna(string: str, decrypt: bool = False) -> str
|
|
886
|
-
constants [Constants in mathematics and science]
|
|
863
|
+
★ constants [Constants in mathematics and science]
|
|
887
864
|
DATA
|
|
888
865
|
AMU = 1.6605402e-27
|
|
889
866
|
EB = 1152921504606846976
|
|
@@ -925,13 +902,11 @@ PyPyNum
|
|
|
925
902
|
yotta = 1e+24
|
|
926
903
|
zepto = 1e-21
|
|
927
904
|
zetta = 1e+21
|
|
928
|
-
equations [Solving specific forms of equations]
|
|
905
|
+
★ equations [Solving specific forms of equations]
|
|
929
906
|
FUNCTIONS
|
|
930
|
-
|
|
931
|
-
multivariate_linear_equation_system(left: list, right: list) -> None | list
|
|
932
|
-
pe = polynomial_equation(coefficients: list) -> list
|
|
907
|
+
linear_equation(left: list, right: list) -> list
|
|
933
908
|
polynomial_equation(coefficients: list) -> list
|
|
934
|
-
mathematics [Mathematical functions]
|
|
909
|
+
★ mathematics [Mathematical functions]
|
|
935
910
|
FUNCTIONS
|
|
936
911
|
A = arrangement(n: int, r: int) -> int
|
|
937
912
|
C = combination(n: int, r: int) -> int
|
|
@@ -984,17 +959,17 @@ PyPyNum
|
|
|
984
959
|
tanh(x: int | float) -> int | float
|
|
985
960
|
var(numbers: list | tuple) -> int | float | complex
|
|
986
961
|
zeta(alpha: int | float) -> float
|
|
987
|
-
neuralnetwork [A simple neural network model]
|
|
962
|
+
★ neuralnetwork [A simple neural network model]
|
|
988
963
|
CLASSES
|
|
989
964
|
NeuralNetwork
|
|
990
|
-
plotting [Draw a graph of equations using characters]
|
|
965
|
+
★ plotting [Draw a graph of equations using characters]
|
|
991
966
|
FUNCTIONS
|
|
992
967
|
background(right: int | float = 5, left: int | float = -5, top: int | float = 5, bottom: int | float = -5, complexity: int | float = 5, ratio: int | float = 3, merge: bool = False) -> list | str
|
|
993
968
|
binary(function, right: int | float = 5, left: int | float = -5, top: int | float = 5, bottom: int | float = -5, complexity: int | float = 5, ratio: int | float = 3, error=0, compare='==', merge: bool = True, basic: list = None, character: str = '.', data: bool = False) -> list | str
|
|
994
969
|
c_unary(function, start: int | float, end: int | float, interval: int | float = 5, projection: str = 'ri', right: int | float = 5, left: int | float = -5, top: int | float = 5, bottom: int | float = -5, complexity: int | float = 5, ratio: int | float = 3, merge: bool = True, basic: list = None, character: str = '.', data: bool = False) -> list | str
|
|
995
970
|
change(data: list | str) -> list | str
|
|
996
971
|
unary(function, right: int | float = 5, left: int | float = -5, top: int | float = 5, bottom: int | float = -5, complexity: int | float = 5, ratio: int | float = 3, merge: bool = True, basic: list = None, character: str = '.', data: bool = False) -> list | str
|
|
997
|
-
random [Generate random numbers or random arrays]
|
|
972
|
+
★ random [Generate random numbers or random arrays]
|
|
998
973
|
FUNCTIONS
|
|
999
974
|
choice(seq: list | tuple | str, shape: list | tuple = None)
|
|
1000
975
|
gauss(mu: int | float = 0, sigma: int | float = 1, shape: list | tuple = None) -> float | list
|
|
@@ -1002,11 +977,12 @@ PyPyNum
|
|
|
1002
977
|
rand(shape: list | tuple = None) -> float | list
|
|
1003
978
|
randint(a: int, b: int, shape: list | tuple = None) -> int | list
|
|
1004
979
|
uniform(a: int | float, b: int | float, shape: list | tuple = None) -> float | list
|
|
1005
|
-
regression [
|
|
980
|
+
★ regression [Formula based polynomial regression]
|
|
1006
981
|
FUNCTIONS
|
|
1007
|
-
linear_regression(x, y)
|
|
1008
|
-
parabolic_regression(x, y)
|
|
1009
|
-
|
|
982
|
+
linear_regression(x: Union[list, tuple], y: Union[list, tuple]) -> list
|
|
983
|
+
parabolic_regression(x: Union[list, tuple], y: Union[list, tuple]) -> list
|
|
984
|
+
polynomial_regression(x: Union[list, tuple], y: Union[list, tuple], n: int = None) -> list
|
|
985
|
+
★ tools [Other useful tools]
|
|
1010
986
|
FUNCTIONS
|
|
1011
987
|
classify(array: list | tuple) -> dict
|
|
1012
988
|
deduplicate(iterable: list | tuple | str) -> list | tuple | str
|
|
@@ -41,9 +41,6 @@ class Array:
|
|
|
41
41
|
def __ne__(self, other):
|
|
42
42
|
return not self.data == other.data
|
|
43
43
|
|
|
44
|
-
def __truediv__(self, other):
|
|
45
|
-
raise NotImplementedError
|
|
46
|
-
|
|
47
44
|
def __getitem__(self, item):
|
|
48
45
|
return self.data[item]
|
|
49
46
|
|
|
@@ -53,6 +50,15 @@ class Array:
|
|
|
53
50
|
def __hash__(self):
|
|
54
51
|
return hash(repr(self.data))
|
|
55
52
|
|
|
53
|
+
def flatten(self):
|
|
54
|
+
data = self.data
|
|
55
|
+
while isinstance(data[0], list):
|
|
56
|
+
data = sum(data, [])
|
|
57
|
+
return data
|
|
58
|
+
|
|
59
|
+
def reshape(self, shape):
|
|
60
|
+
return type(self)(fill(shape, self.flatten()))
|
|
61
|
+
|
|
56
62
|
def copy(self):
|
|
57
63
|
from copy import deepcopy
|
|
58
64
|
return deepcopy(self)
|
|
@@ -86,13 +92,13 @@ def array(data=None):
|
|
|
86
92
|
return Array(data)
|
|
87
93
|
|
|
88
94
|
|
|
89
|
-
def zeros(
|
|
90
|
-
if len(
|
|
95
|
+
def zeros(shape):
|
|
96
|
+
if len(shape) == 0:
|
|
91
97
|
return 0
|
|
92
98
|
else:
|
|
93
99
|
_array = []
|
|
94
|
-
for i in range(
|
|
95
|
-
_row = zeros(
|
|
100
|
+
for i in range(shape[0]):
|
|
101
|
+
_row = zeros(shape[1:])
|
|
96
102
|
_array.append(_row)
|
|
97
103
|
return _array
|
|
98
104
|
|
|
@@ -107,6 +113,29 @@ def zeros_like(_nested_list):
|
|
|
107
113
|
return 0
|
|
108
114
|
|
|
109
115
|
|
|
116
|
+
def fill(shape, sequence=None):
|
|
117
|
+
pointer = -1
|
|
118
|
+
length = 1
|
|
119
|
+
for item in shape:
|
|
120
|
+
length *= item
|
|
121
|
+
if sequence is None:
|
|
122
|
+
sequence = list(range(length))
|
|
123
|
+
|
|
124
|
+
def inner(_shape):
|
|
125
|
+
nonlocal pointer
|
|
126
|
+
if len(_shape) == 0:
|
|
127
|
+
pointer += 1
|
|
128
|
+
return sequence[pointer % len(sequence)]
|
|
129
|
+
else:
|
|
130
|
+
_array = []
|
|
131
|
+
for i in range(_shape[0]):
|
|
132
|
+
_row = inner(_shape[1:])
|
|
133
|
+
_array.append(_row)
|
|
134
|
+
return _array
|
|
135
|
+
|
|
136
|
+
return inner(shape)
|
|
137
|
+
|
|
138
|
+
|
|
110
139
|
def function(_array, _function, args=None):
|
|
111
140
|
_type = str(type(_function))
|
|
112
141
|
if not isinstance(_array, Array) or not (_type.startswith("<function ") or _type.startswith("<class ")):
|
|
@@ -14,7 +14,7 @@ python_requires >= 3.5)</font>
|
|
|
14
14
|
\|___|/ \|___|/
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
-
## Version -> 1.3.
|
|
17
|
+
## Version -> 1.3.1 | PyPI -> https://pypi.org/project/PyPyNum/ | Gitee -> https://www.gitee.com/PythonSJL/PyPyNum
|
|
18
18
|
|
|
19
19
|

|
|
20
20
|
|
|
@@ -51,30 +51,6 @@ Python interpreter and run it!)
|
|
|
51
51
|
|
|
52
52
|
```
|
|
53
53
|
PyPyNum
|
|
54
|
-
Group
|
|
55
|
-
CLASSES
|
|
56
|
-
Group
|
|
57
|
-
| __eq__(self, other)
|
|
58
|
-
| __init__(self, data)
|
|
59
|
-
| __ne__(self, other)
|
|
60
|
-
| __repr__(self)
|
|
61
|
-
| has_identity(self, operation=<function multiply at ...>)
|
|
62
|
-
| has_inverses(self, operation=<function multiply at ...>)
|
|
63
|
-
| is_associative(self, operation=<function multiply at ...>, modulus=None)
|
|
64
|
-
| is_closed(self, operation=<function multiply at ...>, modulus=None)
|
|
65
|
-
| is_group(self, operation=<function multiply at ...>, modulus=None)
|
|
66
|
-
| is_semigroup(self, operation=<function multiply at ...>, modulus=None)
|
|
67
|
-
| order(self)
|
|
68
|
-
FUNCTIONS
|
|
69
|
-
add(x, y)
|
|
70
|
-
divide(x, y)
|
|
71
|
-
group(data)
|
|
72
|
-
multiply(x, y)
|
|
73
|
-
subtract(x, y)
|
|
74
|
-
file
|
|
75
|
-
FUNCTIONS
|
|
76
|
-
read(file: str) -> list
|
|
77
|
-
write(file: str, *cls: object)
|
|
78
54
|
|
|
79
55
|
[Additionally, revise and supplement the original code]
|
|
80
56
|
```
|
|
@@ -85,38 +61,39 @@ PyPyNum
|
|
|
85
61
|
|
|
86
62
|
```
|
|
87
63
|
PyPyNum
|
|
88
|
-
__init__
|
|
64
|
+
★ __init__
|
|
89
65
|
[Import some features from other modules in this package]
|
|
90
|
-
errors [Special errors]
|
|
66
|
+
★ errors [Special errors]
|
|
91
67
|
CLASSES
|
|
92
68
|
LogicError
|
|
93
69
|
RandomError
|
|
94
70
|
ShapeError
|
|
95
|
-
file [Reading and saving instance data]
|
|
71
|
+
★ file [Reading and saving instance data]
|
|
96
72
|
FUNCTIONS
|
|
97
73
|
read(file: str) -> list
|
|
98
74
|
write(file: str, *cls: object)
|
|
99
|
-
test
|
|
75
|
+
★ test
|
|
100
76
|
[A code test file]
|
|
101
|
-
this
|
|
77
|
+
★ this
|
|
102
78
|
[The Zen of PyPyNum]
|
|
103
|
-
types [Special types]
|
|
79
|
+
★ types [Special types]
|
|
104
80
|
DATA
|
|
105
81
|
arr = typing.Union[list, tuple]
|
|
106
82
|
ite = typing.Union[list, tuple, str]
|
|
107
83
|
num = typing.Union[int, float, complex]
|
|
108
84
|
real = typing.Union[int, float]
|
|
109
|
-
Array [N-dimensional array]
|
|
85
|
+
★ Array [N-dimensional array]
|
|
110
86
|
CLASSES
|
|
111
87
|
Array
|
|
112
88
|
FUNCTIONS
|
|
113
89
|
array(data=None)
|
|
90
|
+
fill(shape, sequence=None)
|
|
114
91
|
function(_array, _function, args=None)
|
|
115
92
|
get_shape(data)
|
|
116
93
|
is_valid_array(_array, _shape)
|
|
117
|
-
zeros(
|
|
94
|
+
zeros(shape)
|
|
118
95
|
zeros_like(_nested_list)
|
|
119
|
-
Geometry [Planar geometry]
|
|
96
|
+
★ Geometry [Planar geometry]
|
|
120
97
|
CLASSES
|
|
121
98
|
Circle
|
|
122
99
|
Line
|
|
@@ -126,7 +103,7 @@ PyPyNum
|
|
|
126
103
|
Triangle
|
|
127
104
|
FUNCTIONS
|
|
128
105
|
distance(g1, g2, error: int | float = 0) -> float
|
|
129
|
-
Group [Group theory]
|
|
106
|
+
★ Group [Group theory]
|
|
130
107
|
CLASSES
|
|
131
108
|
Group
|
|
132
109
|
FUNCTIONS
|
|
@@ -135,7 +112,7 @@ PyPyNum
|
|
|
135
112
|
group(data)
|
|
136
113
|
multiply(x, y)
|
|
137
114
|
subtract(x, y)
|
|
138
|
-
Logic [Logic circuit simulation]
|
|
115
|
+
★ Logic [Logic circuit simulation]
|
|
139
116
|
CLASSES
|
|
140
117
|
Basic
|
|
141
118
|
Binary
|
|
@@ -159,7 +136,7 @@ PyPyNum
|
|
|
159
136
|
DFF
|
|
160
137
|
NOT
|
|
161
138
|
TFF
|
|
162
|
-
Matrix [Matrix calculation]
|
|
139
|
+
★ Matrix [Matrix calculation]
|
|
163
140
|
CLASSES
|
|
164
141
|
Matrix
|
|
165
142
|
FUNCTIONS
|
|
@@ -173,7 +150,7 @@ PyPyNum
|
|
|
173
150
|
tril_indices(n, k=0, m=None)
|
|
174
151
|
zeros(_dimensions)
|
|
175
152
|
zeros_like(_nested_list)
|
|
176
|
-
Quaternion [Quaternion calculation]
|
|
153
|
+
★ Quaternion [Quaternion calculation]
|
|
177
154
|
CLASSES
|
|
178
155
|
Euler
|
|
179
156
|
Quaternion
|
|
@@ -181,7 +158,7 @@ PyPyNum
|
|
|
181
158
|
change(data: Euler | Quaternion) -> Quaternion | Euler
|
|
182
159
|
euler(yaw: int | float = 0, pitch: int | float = 0, roll: int | float = 0) -> Euler
|
|
183
160
|
quat(w: int | float = 0, x: int | float = 0, y: int | float = 0, z: int | float = 0) -> Quaternion
|
|
184
|
-
Symbolics [Symbol calculation]
|
|
161
|
+
★ Symbolics [Symbol calculation]
|
|
185
162
|
FUNCTIONS
|
|
186
163
|
interpreter(expr: str) -> list
|
|
187
164
|
DATA
|
|
@@ -190,7 +167,7 @@ PyPyNum
|
|
|
190
167
|
greek = 'ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟ∏ΡΣΤΥΦΧΨΩβγδεζηθικλμνξοπρστυφχψω'
|
|
191
168
|
operators = ['**', '*', '//', '/', '%', '+', '-']
|
|
192
169
|
valid = '%()*+-./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcd...yzΑΒΓΔΕΖΗΘ...'
|
|
193
|
-
Tensor [Tensor calculation]
|
|
170
|
+
★ Tensor [Tensor calculation]
|
|
194
171
|
CLASSES
|
|
195
172
|
Tensor
|
|
196
173
|
FUNCTIONS
|
|
@@ -199,7 +176,7 @@ PyPyNum
|
|
|
199
176
|
tolist(_nested_list)
|
|
200
177
|
zeros(_dimensions)
|
|
201
178
|
zeros_like(_nested_list)
|
|
202
|
-
Vector [Vector calculation]
|
|
179
|
+
★ Vector [Vector calculation]
|
|
203
180
|
CLASSES
|
|
204
181
|
Vector
|
|
205
182
|
FUNCTIONS
|
|
@@ -207,10 +184,10 @@ PyPyNum
|
|
|
207
184
|
vec(data)
|
|
208
185
|
zeros(_dimensions)
|
|
209
186
|
zeros_like(_nested_list)
|
|
210
|
-
cipher [String encryption and decryption algorithms]
|
|
187
|
+
★ cipher [String encryption and decryption algorithms]
|
|
211
188
|
FUNCTIONS
|
|
212
189
|
dna(string: str, decrypt: bool = False) -> str
|
|
213
|
-
constants [Constants in mathematics and science]
|
|
190
|
+
★ constants [Constants in mathematics and science]
|
|
214
191
|
DATA
|
|
215
192
|
AMU = 1.6605402e-27
|
|
216
193
|
EB = 1152921504606846976
|
|
@@ -252,13 +229,11 @@ PyPyNum
|
|
|
252
229
|
yotta = 1e+24
|
|
253
230
|
zepto = 1e-21
|
|
254
231
|
zetta = 1e+21
|
|
255
|
-
equations [Solving specific forms of equations]
|
|
232
|
+
★ equations [Solving specific forms of equations]
|
|
256
233
|
FUNCTIONS
|
|
257
|
-
|
|
258
|
-
multivariate_linear_equation_system(left: list, right: list) -> None | list
|
|
259
|
-
pe = polynomial_equation(coefficients: list) -> list
|
|
234
|
+
linear_equation(left: list, right: list) -> list
|
|
260
235
|
polynomial_equation(coefficients: list) -> list
|
|
261
|
-
mathematics [Mathematical functions]
|
|
236
|
+
★ mathematics [Mathematical functions]
|
|
262
237
|
FUNCTIONS
|
|
263
238
|
A = arrangement(n: int, r: int) -> int
|
|
264
239
|
C = combination(n: int, r: int) -> int
|
|
@@ -311,17 +286,17 @@ PyPyNum
|
|
|
311
286
|
tanh(x: int | float) -> int | float
|
|
312
287
|
var(numbers: list | tuple) -> int | float | complex
|
|
313
288
|
zeta(alpha: int | float) -> float
|
|
314
|
-
neuralnetwork [A simple neural network model]
|
|
289
|
+
★ neuralnetwork [A simple neural network model]
|
|
315
290
|
CLASSES
|
|
316
291
|
NeuralNetwork
|
|
317
|
-
plotting [Draw a graph of equations using characters]
|
|
292
|
+
★ plotting [Draw a graph of equations using characters]
|
|
318
293
|
FUNCTIONS
|
|
319
294
|
background(right: int | float = 5, left: int | float = -5, top: int | float = 5, bottom: int | float = -5, complexity: int | float = 5, ratio: int | float = 3, merge: bool = False) -> list | str
|
|
320
295
|
binary(function, right: int | float = 5, left: int | float = -5, top: int | float = 5, bottom: int | float = -5, complexity: int | float = 5, ratio: int | float = 3, error=0, compare='==', merge: bool = True, basic: list = None, character: str = '.', data: bool = False) -> list | str
|
|
321
296
|
c_unary(function, start: int | float, end: int | float, interval: int | float = 5, projection: str = 'ri', right: int | float = 5, left: int | float = -5, top: int | float = 5, bottom: int | float = -5, complexity: int | float = 5, ratio: int | float = 3, merge: bool = True, basic: list = None, character: str = '.', data: bool = False) -> list | str
|
|
322
297
|
change(data: list | str) -> list | str
|
|
323
298
|
unary(function, right: int | float = 5, left: int | float = -5, top: int | float = 5, bottom: int | float = -5, complexity: int | float = 5, ratio: int | float = 3, merge: bool = True, basic: list = None, character: str = '.', data: bool = False) -> list | str
|
|
324
|
-
random [Generate random numbers or random arrays]
|
|
299
|
+
★ random [Generate random numbers or random arrays]
|
|
325
300
|
FUNCTIONS
|
|
326
301
|
choice(seq: list | tuple | str, shape: list | tuple = None)
|
|
327
302
|
gauss(mu: int | float = 0, sigma: int | float = 1, shape: list | tuple = None) -> float | list
|
|
@@ -329,11 +304,12 @@ PyPyNum
|
|
|
329
304
|
rand(shape: list | tuple = None) -> float | list
|
|
330
305
|
randint(a: int, b: int, shape: list | tuple = None) -> int | list
|
|
331
306
|
uniform(a: int | float, b: int | float, shape: list | tuple = None) -> float | list
|
|
332
|
-
regression [
|
|
307
|
+
★ regression [Formula based polynomial regression]
|
|
333
308
|
FUNCTIONS
|
|
334
|
-
linear_regression(x, y)
|
|
335
|
-
parabolic_regression(x, y)
|
|
336
|
-
|
|
309
|
+
linear_regression(x: Union[list, tuple], y: Union[list, tuple]) -> list
|
|
310
|
+
parabolic_regression(x: Union[list, tuple], y: Union[list, tuple]) -> list
|
|
311
|
+
polynomial_regression(x: Union[list, tuple], y: Union[list, tuple], n: int = None) -> list
|
|
312
|
+
★ tools [Other useful tools]
|
|
337
313
|
FUNCTIONS
|
|
338
314
|
classify(array: list | tuple) -> dict
|
|
339
315
|
deduplicate(iterable: list | tuple | str) -> list | tuple | str
|
|
@@ -8,10 +8,10 @@ r"""
|
|
|
8
8
|
\|__| |\___/ / \|__| |\___/ / \|__| \|__| \|_______| \|__| \|__|
|
|
9
9
|
\|___|/ \|___|/
|
|
10
10
|
"""
|
|
11
|
-
from .Array import array, function
|
|
11
|
+
from .Array import array, fill, function, zeros, zeros_like
|
|
12
12
|
from .cipher import *
|
|
13
13
|
from . import constants
|
|
14
|
-
from .equations import
|
|
14
|
+
from .equations import *
|
|
15
15
|
from . import errors
|
|
16
16
|
from .file import read, write
|
|
17
17
|
from .Geometry import *
|
|
@@ -30,7 +30,7 @@ from .tools import *
|
|
|
30
30
|
from . import types
|
|
31
31
|
from .Vector import vec
|
|
32
32
|
|
|
33
|
-
__version__ = "1.3.
|
|
33
|
+
__version__ = "1.3.1"
|
|
34
34
|
print("PyPyNum", "Version -> " + __version__, "PyPI -> https://pypi.org/project/PyPyNum/",
|
|
35
35
|
"Gitee -> https://www.gitee.com/PythonSJL/PyPyNum", sep=" | ")
|
|
36
|
-
del math, arr, ite, num, real, geom, RandomError, LogicError, InputError, FullError
|
|
36
|
+
del math, arr, ite, num, real, geom, RandomError, LogicError, InputError, FullError, Union
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
def linear_equation(left: list, right: list) -> list:
|
|
2
|
+
from .Matrix import mat
|
|
3
|
+
d = mat(left).det()
|
|
4
|
+
if d != 0:
|
|
5
|
+
return [mat([left[_][:item] + [right[_]] + left[_][item + 1:] for _ in range(len(left))]).det() / d
|
|
6
|
+
for item in range(len(left))]
|
|
7
|
+
return [None] * len(right)
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def polynomial_equation(coefficients: list) -> list:
|
|
11
|
+
from .Matrix import mat, eig
|
|
12
|
+
p = [_ / coefficients[0] for _ in coefficients[1:]]
|
|
13
|
+
return eig(mat([[-p[i] if j == 0 else 1 if i + 1 == j else 0
|
|
14
|
+
for j in range(len(p))] for i in range(len(p))]))[0].data[0]
|
|
@@ -11,7 +11,7 @@ def read(file: str) -> list:
|
|
|
11
11
|
"from .Vector import Vector",
|
|
12
12
|
"from .Geometry import Point, Line, Triangle, Quadrilateral, Polygon, Circle",
|
|
13
13
|
"from .Group import Group",
|
|
14
|
-
"from .Quaternion import Quaternion"
|
|
14
|
+
"from .Quaternion import Quaternion, Euler"
|
|
15
15
|
]))
|
|
16
16
|
suffix = ".pypynum"
|
|
17
17
|
if not file.endswith(suffix):
|
|
@@ -37,7 +37,7 @@ def write(file: str, *cls: object):
|
|
|
37
37
|
from .Array import Array
|
|
38
38
|
from .Geometry import Point, Line, Triangle, Quadrilateral, Polygon, Circle
|
|
39
39
|
from .Group import Group
|
|
40
|
-
from .Quaternion import Quaternion
|
|
40
|
+
from .Quaternion import Quaternion, Euler
|
|
41
41
|
suffix = ".pypynum"
|
|
42
42
|
if not file.endswith(suffix):
|
|
43
43
|
raise FileExistsError("The file extension can only be '{}'".format(suffix))
|
|
@@ -46,7 +46,7 @@ def write(file: str, *cls: object):
|
|
|
46
46
|
_type = str(type(item))
|
|
47
47
|
if "." not in _type:
|
|
48
48
|
raise TypeError("Type '{}' does not support saving".format(type(item)))
|
|
49
|
-
prefix = _type[_type.
|
|
49
|
+
prefix = _type[_type.rfind(".") + 1:-2]
|
|
50
50
|
if isinstance(item, Array):
|
|
51
51
|
w.write("{}\\{}\n".format(prefix, str([item.data]).replace(" ", "")))
|
|
52
52
|
elif isinstance(item, Point):
|
|
@@ -63,7 +63,7 @@ def write(file: str, *cls: object):
|
|
|
63
63
|
w.write("{}\\{}\n".format(prefix, str([item.center, item.radius]).replace(" ", "")))
|
|
64
64
|
elif isinstance(item, Group):
|
|
65
65
|
w.write("{}\\{}\n".format(prefix, str([item.data()]).replace(" ", "")))
|
|
66
|
-
elif isinstance(item, Quaternion):
|
|
66
|
+
elif isinstance(item, (Quaternion, Euler)):
|
|
67
67
|
w.write("{}\\{}\n".format(prefix, str(item.data()).replace(" ", "")))
|
|
68
68
|
else:
|
|
69
69
|
raise TypeError("Type '{}' does not support saving".format(type(item)))
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
from .types import arr
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def linear_regression(x: arr, y: arr) -> list:
|
|
5
|
+
from .mathematics import mean
|
|
6
|
+
if len(x) != len(y):
|
|
7
|
+
raise ValueError("The array length of the independent and dependent variables must be equal")
|
|
8
|
+
x_mean = mean(x)
|
|
9
|
+
y_mean = mean(y)
|
|
10
|
+
numerator = sum([(x - x_mean) * (y - y_mean) for x, y in zip(x, y)])
|
|
11
|
+
denominator = sum([(x - x_mean) ** 2 for x in x])
|
|
12
|
+
alpha = numerator / denominator
|
|
13
|
+
beta = y_mean - alpha * x_mean
|
|
14
|
+
return [alpha, beta]
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def parabolic_regression(x: arr, y: arr) -> list:
|
|
18
|
+
from .mathematics import mean, var
|
|
19
|
+
if len(x) != len(y):
|
|
20
|
+
raise ValueError("The array length of the independent and dependent variables must be equal")
|
|
21
|
+
|
|
22
|
+
def solve_equations(a1, b1, c1, a2, b2, c2):
|
|
23
|
+
denominator = a1 * b2 - a2 * b1
|
|
24
|
+
if denominator == 0:
|
|
25
|
+
return None
|
|
26
|
+
return [(c1 * b2 - c2 * b1) / denominator, (a1 * c2 - a2 * c1) / denominator]
|
|
27
|
+
|
|
28
|
+
x2 = [_ ** 2 for _ in x]
|
|
29
|
+
xy = [a + b for a, b in zip(x, y)]
|
|
30
|
+
x2x = [a ** 2 + a for a in x]
|
|
31
|
+
x2y = [a ** 2 + b for a, b in zip(x, y)]
|
|
32
|
+
vx2 = var(x2)
|
|
33
|
+
vxy = var(xy)
|
|
34
|
+
vx2x = var(x2x)
|
|
35
|
+
vx2y = var(x2y)
|
|
36
|
+
v1y = (vxy - var(x) - var(y)) / 2
|
|
37
|
+
v2y = (vx2y - vx2 - var(y)) / 2
|
|
38
|
+
v12 = (vx2x - vx2 - var(x)) / 2
|
|
39
|
+
o = [var(x), v12, v1y, v12, vx2, v2y]
|
|
40
|
+
b, a = solve_equations(o[0], o[1], o[2], o[3], o[4], o[5])
|
|
41
|
+
c = mean(y) - b * mean(x) - a * mean([_ ** 2 for _ in x])
|
|
42
|
+
return [a, b, c]
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
def polynomial_regression(x: arr, y: arr, n: int = None) -> list:
|
|
46
|
+
from .Matrix import mat
|
|
47
|
+
if len(x) != len(y):
|
|
48
|
+
raise ValueError("The array length of the independent and dependent variables must be equal")
|
|
49
|
+
if n is None:
|
|
50
|
+
n = len(x) - 1
|
|
51
|
+
if not isinstance(n, int) or n <= 0:
|
|
52
|
+
raise ValueError("The degree of a polynomial must be a natural number")
|
|
53
|
+
m = len(x)
|
|
54
|
+
_x = [[_ ** n for _ in x]]
|
|
55
|
+
for i in range(n - 1):
|
|
56
|
+
_x += [[_ ** (n - i - 1) for _ in x]]
|
|
57
|
+
_x += [[1] * m]
|
|
58
|
+
_x = mat(_x)
|
|
59
|
+
return ((_x @ _x.t()).inv() @ _x @ mat([y]).t()).flatten()
|
|
@@ -669,7 +669,7 @@ 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.3.
|
|
672
|
+
version="1.3.1",
|
|
673
673
|
packages=find_packages(),
|
|
674
674
|
url="https://www.gitee.com/PythonSJL/PyPyNum",
|
|
675
675
|
license=LICENSE,
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
def polynomial_equation(coefficients: list) -> list:
|
|
2
|
-
from .Matrix import mat, eig
|
|
3
|
-
p = [_ / coefficients[0] for _ in coefficients[1:]]
|
|
4
|
-
return [complex(round(_.real, 12), round(_.imag, 12)) if isinstance(_, complex) else round(_, 12) for _ in eig(mat(
|
|
5
|
-
[[-p[i] if j == 0 else 1 if i + 1 == j else 0 for j in range(len(p))] for i in range(len(p))]))[0].data[0]]
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
def multivariate_linear_equation_system(left: list, right: list) -> list:
|
|
9
|
-
from .Matrix import mat
|
|
10
|
-
d = mat(left).det()
|
|
11
|
-
if d != 0:
|
|
12
|
-
return [round(_, 12) for _ in [mat([left[_][:item] + [right[_]] + left[_][item + 1:]
|
|
13
|
-
for _ in range(len(left))]).det() / d for item in range(len(left))]]
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
pe = polynomial_equation
|
|
17
|
-
mles = multivariate_linear_equation_system
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
def linear_regression(x, y):
|
|
2
|
-
from .mathematics import mean
|
|
3
|
-
x_mean = mean(x)
|
|
4
|
-
y_mean = mean(y)
|
|
5
|
-
numerator = sum([(x - x_mean) * (y - y_mean) for x, y in zip(x, y)])
|
|
6
|
-
denominator = sum([(x - x_mean) ** 2 for x in x])
|
|
7
|
-
alpha = numerator / denominator
|
|
8
|
-
beta = y_mean - alpha * x_mean
|
|
9
|
-
print("f(x) = {} * x + {}".format(round(alpha, 9), round(beta, 9)))
|
|
10
|
-
return [round(alpha, 9), round(beta, 9)]
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
def parabolic_regression(x, y):
|
|
14
|
-
def solve_equations(a1, b1, c1, a2, b2, c2):
|
|
15
|
-
denominator = a1 * b2 - a2 * b1
|
|
16
|
-
if denominator == 0:
|
|
17
|
-
return None
|
|
18
|
-
return [(c1 * b2 - c2 * b1) / denominator, (a1 * c2 - a2 * c1) / denominator]
|
|
19
|
-
|
|
20
|
-
from .mathematics import mean, var
|
|
21
|
-
x2 = [_ ** 2 for _ in x]
|
|
22
|
-
xy = [round(a + b, 12) for a, b in zip(x, y)]
|
|
23
|
-
x2x = [round(a ** 2 + a, 12) for a in x]
|
|
24
|
-
x2y = [round(a ** 2 + b, 12) for a, b in zip(x, y)]
|
|
25
|
-
vx2 = var(x2)
|
|
26
|
-
vxy = var(xy)
|
|
27
|
-
vx2x = var(x2x)
|
|
28
|
-
vx2y = var(x2y)
|
|
29
|
-
v1y = (vxy - var(x) - var(y)) / 2
|
|
30
|
-
v2y = (vx2y - vx2 - var(y)) / 2
|
|
31
|
-
v12 = (vx2x - vx2 - var(x)) / 2
|
|
32
|
-
o = [var(x), v12, v1y, v12, vx2, v2y]
|
|
33
|
-
b, a = solve_equations(o[0], o[1], o[2], o[3], o[4], o[5])
|
|
34
|
-
c = mean(y) - b * mean(x) - a * mean([_ ** 2 for _ in x])
|
|
35
|
-
print("f(x) = {} * x ** 2 + {} * x + {}".format(round(a, 9), round(b, 9), round(c, 9)))
|
|
36
|
-
return [round(a, 9), round(b, 9), round(c, 9)]
|
|
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
|