PyPyNum 1.17.1__tar.gz → 1.17.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 (52) hide show
  1. {pypynum-1.17.1 → pypynum-1.17.2}/PKG-INFO +43 -63
  2. {pypynum-1.17.1 → pypynum-1.17.2}/PyPyNum.egg-info/PKG-INFO +43 -63
  3. {pypynum-1.17.1 → pypynum-1.17.2}/pypynum/README.md +41 -61
  4. {pypynum-1.17.1 → pypynum-1.17.2}/pypynum/__init__.py +4 -4
  5. {pypynum-1.17.1 → pypynum-1.17.2}/pypynum/dists.py +16 -14
  6. {pypynum-1.17.1 → pypynum-1.17.2}/pypynum/files.py +8 -8
  7. {pypynum-1.17.1 → pypynum-1.17.2}/pypynum/maths.py +13 -11
  8. {pypynum-1.17.1 → pypynum-1.17.2}/pypynum/multiprec.py +4 -3
  9. {pypynum-1.17.1 → pypynum-1.17.2}/pypynum/tools.py +2 -2
  10. {pypynum-1.17.1 → pypynum-1.17.2}/pypynum/utils.py +82 -0
  11. {pypynum-1.17.1 → pypynum-1.17.2}/pypynum/zh_cn.py +2 -2
  12. {pypynum-1.17.1 → pypynum-1.17.2}/setup.py +5 -5
  13. {pypynum-1.17.1 → pypynum-1.17.2}/PyPyNum.egg-info/SOURCES.txt +0 -0
  14. {pypynum-1.17.1 → pypynum-1.17.2}/PyPyNum.egg-info/dependency_links.txt +0 -0
  15. {pypynum-1.17.1 → pypynum-1.17.2}/PyPyNum.egg-info/top_level.txt +0 -0
  16. {pypynum-1.17.1 → pypynum-1.17.2}/pypynum/PyPyNum.png +0 -0
  17. {pypynum-1.17.1 → pypynum-1.17.2}/pypynum/arrays.py +0 -0
  18. {pypynum-1.17.1 → pypynum-1.17.2}/pypynum/chars.py +0 -0
  19. {pypynum-1.17.1 → pypynum-1.17.2}/pypynum/ciphers.py +0 -0
  20. {pypynum-1.17.1 → pypynum-1.17.2}/pypynum/consts.py +0 -0
  21. {pypynum-1.17.1 → pypynum-1.17.2}/pypynum/crandom.py +0 -0
  22. {pypynum-1.17.1 → pypynum-1.17.2}/pypynum/dataproc.py +0 -0
  23. {pypynum-1.17.1 → pypynum-1.17.2}/pypynum/equations.py +0 -0
  24. {pypynum-1.17.1 → pypynum-1.17.2}/pypynum/fft.py +0 -0
  25. {pypynum-1.17.1 → pypynum-1.17.2}/pypynum/geoms.py +0 -0
  26. {pypynum-1.17.1 → pypynum-1.17.2}/pypynum/graphs.py +0 -0
  27. {pypynum-1.17.1 → pypynum-1.17.2}/pypynum/groups.py +0 -0
  28. {pypynum-1.17.1 → pypynum-1.17.2}/pypynum/hypcmpnms.py +0 -0
  29. {pypynum-1.17.1 → pypynum-1.17.2}/pypynum/images.py +0 -0
  30. {pypynum-1.17.1 → pypynum-1.17.2}/pypynum/interp.py +0 -0
  31. {pypynum-1.17.1 → pypynum-1.17.2}/pypynum/kernels.py +0 -0
  32. {pypynum-1.17.1 → pypynum-1.17.2}/pypynum/logics.py +0 -0
  33. {pypynum-1.17.1 → pypynum-1.17.2}/pypynum/matrices.py +0 -0
  34. {pypynum-1.17.1 → pypynum-1.17.2}/pypynum/networks.py +0 -0
  35. {pypynum-1.17.1 → pypynum-1.17.2}/pypynum/numbers.py +0 -0
  36. {pypynum-1.17.1 → pypynum-1.17.2}/pypynum/plotting.py +0 -0
  37. {pypynum-1.17.1 → pypynum-1.17.2}/pypynum/polys.py +0 -0
  38. {pypynum-1.17.1 → pypynum-1.17.2}/pypynum/pprinters.py +0 -0
  39. {pypynum-1.17.1 → pypynum-1.17.2}/pypynum/random.py +0 -0
  40. {pypynum-1.17.1 → pypynum-1.17.2}/pypynum/regs.py +0 -0
  41. {pypynum-1.17.1 → pypynum-1.17.2}/pypynum/seqs.py +0 -0
  42. {pypynum-1.17.1 → pypynum-1.17.2}/pypynum/special.py +0 -0
  43. {pypynum-1.17.1 → pypynum-1.17.2}/pypynum/stattest.py +0 -0
  44. {pypynum-1.17.1 → pypynum-1.17.2}/pypynum/symbols.py +0 -0
  45. {pypynum-1.17.1 → pypynum-1.17.2}/pypynum/tensors.py +0 -0
  46. {pypynum-1.17.1 → pypynum-1.17.2}/pypynum/test.py +0 -0
  47. {pypynum-1.17.1 → pypynum-1.17.2}/pypynum/this.py +0 -0
  48. {pypynum-1.17.1 → pypynum-1.17.2}/pypynum/trees.py +0 -0
  49. {pypynum-1.17.1 → pypynum-1.17.2}/pypynum/types.py +0 -0
  50. {pypynum-1.17.1 → pypynum-1.17.2}/pypynum/ufuncs.py +0 -0
  51. {pypynum-1.17.1 → pypynum-1.17.2}/pypynum/vectors.py +0 -0
  52. {pypynum-1.17.1 → pypynum-1.17.2}/setup.cfg +0 -0
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: PyPyNum
3
- Version: 1.17.1
4
- Summary: PyPyNum is a Python library for math & science computations, covering algebra, calculus, stats, with data structures like matrices, vectors, tensors. It offers numerical tools, programs, and supports computational ops, functions, processing, simulation, & visualization in data science & ML, crucial for research, engineering, & data processing.
3
+ Version: 1.17.2
4
+ Summary: PyPyNum is a multifunctional Python math lib. It includes modules for math, data analysis, array ops, crypto, physics, randomness, data prep, stats, solving eqns, image processing, interp, matrix calc, and high-precision math. Designed for scientific computing, data science, and machine learning, PyPyNum provides efficient and versatile tools.
5
5
  Home-page: https://github.com/PythonSJL/PyPyNum
6
6
  Author: Shen Jiayi
7
7
  Author-email: 2261748025@qq.com
@@ -692,7 +692,7 @@ scientific computing, data science, and machine learning, PyPyNum provides effic
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.17.1 | PyPI -> https://pypi.org/project/PyPyNum/ | Gitee -> https://www.gitee.com/PythonSJL/PyPyNum | GitHub -> https://github.com/PythonSJL/PyPyNum
695
+ ## Version -> 1.17.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
 
@@ -824,71 +824,51 @@ Python interpreter and run it!
824
824
  ```
825
825
  !=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=
826
826
 
827
- The `pypynum.images` module
828
- now encompasses three classes,
829
- expanding its image processing functionality.
830
- The original `PNG` class
831
- has been transformed to be based on
832
- the `BaseImage` class.
833
- This update includes a specific fix
834
- for the `read` method in `PNG`,
835
- addressing issues with reading
836
- large images.
837
- 1. `BaseImage`: A foundational class
838
- for image processing, offering
839
- basic methods like image creation,
840
- pixel access, and metadata retrieval.
841
- 2. `BMP`: A subclass of `BaseImage`,
842
- tailored for BMP image handling,
843
- providing specialized BMP functionalities.
844
- 3. `PNG`: The `PNG` class, now built on
845
- `BaseImage`, with an improved `read`
846
- method that solves the problem of
847
- reading large PNG files.
848
- This fix to the `read` method in `PNG`
849
- ensures efficient processing of large images,
850
- maintaining image quality and integrity.
851
- The module's enhanced capabilities
852
- make it more robust and user-friendly
853
- for handling substantial PNG files.
827
+ Fixed some known issues.
828
+
829
+ !=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=
830
+
831
+ The pypynum.utils module has recently introduced a new class
832
+ called RadixInt. This class is designed to facilitate the
833
+ representation and manipulation of integers in various bases,
834
+ ranging from base 2 to base 36.
835
+
836
+ The RadixInt class within the pypynum.utils module provides a
837
+ robust way to work with integers in custom bases. It allows
838
+ users to initialize instances with either a decimal number or a
839
+ string representation of a number in the desired base. The class
840
+ supports conversion between different bases, as well as basic
841
+ arithmetic operations that can be performed on integers
842
+ represented in various bases.
854
843
 
855
844
 
856
845
  <<< The following are some usage examples >>>
857
846
 
858
847
 
859
- # Import BMP and PNG classes
860
- from pypynum import BMP, PNG
861
-
862
- # Instantiate BMP class
863
- bmp_image = BMP()
864
- # Instantiate a BMP image with specified dimensions and color
865
- bmp_image.new(width=100, height=100, color=(255, 0, 0), color_mode="RGB", bit_depth=8)
866
- # Set pixel color at (50, 50) to blue
867
- bmp_image[50, 50] = (0, 0, 255)
868
- # Save the BMP image
869
- bmp_image.write("output_bmp.bmp")
870
- # Instantiate PNG class
871
- png_image = PNG()
872
- # Instantiate a PNG image with specified dimensions and color
873
- png_image.new(width=100, height=100, color=(0, 255, 0), color_mode="RGB", bit_depth=8)
874
- # Set pixel color at (50, 50) to yellow
875
- png_image[50, 50] = (255, 255, 0)
876
- # Save the PNG image
877
- png_image.write("output_png.png")
878
- # Create BMP reader to read the BMP image
879
- bmp_reader = BMP()
880
- # Read the BMP image from the file
881
- bmp_reader.read("output_bmp.bmp")
882
- # Print the BMP image and pixel at (50, 50)
883
- print("BMP Image:", bmp_reader)
884
- print("BMP Pixel at (50, 50):", bmp_reader[50, 50])
885
- # Create PNG reader to read the PNG image
886
- png_reader = PNG()
887
- # Read the PNG image from the file
888
- png_reader.read("output_png.png")
889
- # Print the PNG image and pixel at (50, 50)
890
- print("PNG Image:", png_reader)
891
- print("PNG Pixel at (50, 50):", png_reader[50, 50])
848
+ from pypynum import RadixInt
849
+
850
+ # Base-2 and base-10 numbers
851
+ binary_num = RadixInt("1010", 2)
852
+ decimal_num = RadixInt(10, 10)
853
+ print(binary_num) # Output: (1010)_{2}
854
+ print(decimal_num) # Output: (10)_{10}
855
+ binary_to_octal = RadixInt("1010", 2).to_base(8)
856
+ print(binary_to_octal) # Output: (12)_{8}
857
+ # Addition
858
+ result_add = binary_num + decimal_num
859
+ print(result_add) # Output: (20)_{10}
860
+ # Base-8 and base-10 numbers
861
+ octal_num = RadixInt("123", 8)
862
+ decimal_num = RadixInt(5, 10)
863
+ # Subtraction
864
+ result_sub = octal_num - decimal_num
865
+ print(result_sub) # Output: (78)_{10}
866
+ # Base-16 and base-2 numbers
867
+ hex_num = RadixInt("1A", 16)
868
+ binary_num = RadixInt("11", 2)
869
+ # Multiplication
870
+ result_mul = hex_num * binary_num
871
+ print(result_mul) # Output: (78)_{10}
892
872
 
893
873
  !=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=
894
874
  ```
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: PyPyNum
3
- Version: 1.17.1
4
- Summary: PyPyNum is a Python library for math & science computations, covering algebra, calculus, stats, with data structures like matrices, vectors, tensors. It offers numerical tools, programs, and supports computational ops, functions, processing, simulation, & visualization in data science & ML, crucial for research, engineering, & data processing.
3
+ Version: 1.17.2
4
+ Summary: PyPyNum is a multifunctional Python math lib. It includes modules for math, data analysis, array ops, crypto, physics, randomness, data prep, stats, solving eqns, image processing, interp, matrix calc, and high-precision math. Designed for scientific computing, data science, and machine learning, PyPyNum provides efficient and versatile tools.
5
5
  Home-page: https://github.com/PythonSJL/PyPyNum
6
6
  Author: Shen Jiayi
7
7
  Author-email: 2261748025@qq.com
@@ -692,7 +692,7 @@ scientific computing, data science, and machine learning, PyPyNum provides effic
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.17.1 | PyPI -> https://pypi.org/project/PyPyNum/ | Gitee -> https://www.gitee.com/PythonSJL/PyPyNum | GitHub -> https://github.com/PythonSJL/PyPyNum
695
+ ## Version -> 1.17.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
 
@@ -824,71 +824,51 @@ Python interpreter and run it!
824
824
  ```
825
825
  !=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=
826
826
 
827
- The `pypynum.images` module
828
- now encompasses three classes,
829
- expanding its image processing functionality.
830
- The original `PNG` class
831
- has been transformed to be based on
832
- the `BaseImage` class.
833
- This update includes a specific fix
834
- for the `read` method in `PNG`,
835
- addressing issues with reading
836
- large images.
837
- 1. `BaseImage`: A foundational class
838
- for image processing, offering
839
- basic methods like image creation,
840
- pixel access, and metadata retrieval.
841
- 2. `BMP`: A subclass of `BaseImage`,
842
- tailored for BMP image handling,
843
- providing specialized BMP functionalities.
844
- 3. `PNG`: The `PNG` class, now built on
845
- `BaseImage`, with an improved `read`
846
- method that solves the problem of
847
- reading large PNG files.
848
- This fix to the `read` method in `PNG`
849
- ensures efficient processing of large images,
850
- maintaining image quality and integrity.
851
- The module's enhanced capabilities
852
- make it more robust and user-friendly
853
- for handling substantial PNG files.
827
+ Fixed some known issues.
828
+
829
+ !=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=
830
+
831
+ The pypynum.utils module has recently introduced a new class
832
+ called RadixInt. This class is designed to facilitate the
833
+ representation and manipulation of integers in various bases,
834
+ ranging from base 2 to base 36.
835
+
836
+ The RadixInt class within the pypynum.utils module provides a
837
+ robust way to work with integers in custom bases. It allows
838
+ users to initialize instances with either a decimal number or a
839
+ string representation of a number in the desired base. The class
840
+ supports conversion between different bases, as well as basic
841
+ arithmetic operations that can be performed on integers
842
+ represented in various bases.
854
843
 
855
844
 
856
845
  <<< The following are some usage examples >>>
857
846
 
858
847
 
859
- # Import BMP and PNG classes
860
- from pypynum import BMP, PNG
861
-
862
- # Instantiate BMP class
863
- bmp_image = BMP()
864
- # Instantiate a BMP image with specified dimensions and color
865
- bmp_image.new(width=100, height=100, color=(255, 0, 0), color_mode="RGB", bit_depth=8)
866
- # Set pixel color at (50, 50) to blue
867
- bmp_image[50, 50] = (0, 0, 255)
868
- # Save the BMP image
869
- bmp_image.write("output_bmp.bmp")
870
- # Instantiate PNG class
871
- png_image = PNG()
872
- # Instantiate a PNG image with specified dimensions and color
873
- png_image.new(width=100, height=100, color=(0, 255, 0), color_mode="RGB", bit_depth=8)
874
- # Set pixel color at (50, 50) to yellow
875
- png_image[50, 50] = (255, 255, 0)
876
- # Save the PNG image
877
- png_image.write("output_png.png")
878
- # Create BMP reader to read the BMP image
879
- bmp_reader = BMP()
880
- # Read the BMP image from the file
881
- bmp_reader.read("output_bmp.bmp")
882
- # Print the BMP image and pixel at (50, 50)
883
- print("BMP Image:", bmp_reader)
884
- print("BMP Pixel at (50, 50):", bmp_reader[50, 50])
885
- # Create PNG reader to read the PNG image
886
- png_reader = PNG()
887
- # Read the PNG image from the file
888
- png_reader.read("output_png.png")
889
- # Print the PNG image and pixel at (50, 50)
890
- print("PNG Image:", png_reader)
891
- print("PNG Pixel at (50, 50):", png_reader[50, 50])
848
+ from pypynum import RadixInt
849
+
850
+ # Base-2 and base-10 numbers
851
+ binary_num = RadixInt("1010", 2)
852
+ decimal_num = RadixInt(10, 10)
853
+ print(binary_num) # Output: (1010)_{2}
854
+ print(decimal_num) # Output: (10)_{10}
855
+ binary_to_octal = RadixInt("1010", 2).to_base(8)
856
+ print(binary_to_octal) # Output: (12)_{8}
857
+ # Addition
858
+ result_add = binary_num + decimal_num
859
+ print(result_add) # Output: (20)_{10}
860
+ # Base-8 and base-10 numbers
861
+ octal_num = RadixInt("123", 8)
862
+ decimal_num = RadixInt(5, 10)
863
+ # Subtraction
864
+ result_sub = octal_num - decimal_num
865
+ print(result_sub) # Output: (78)_{10}
866
+ # Base-16 and base-2 numbers
867
+ hex_num = RadixInt("1A", 16)
868
+ binary_num = RadixInt("11", 2)
869
+ # Multiplication
870
+ result_mul = hex_num * binary_num
871
+ print(result_mul) # Output: (78)_{10}
892
872
 
893
873
  !=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=
894
874
  ```
@@ -19,7 +19,7 @@ scientific computing, data science, and machine learning, PyPyNum provides effic
19
19
  [![Downloads](https://static.pepy.tech/badge/pypynum/month)](https://pepy.tech/project/pypynum)
20
20
  [![Downloads](https://static.pepy.tech/badge/pypynum/week)](https://pepy.tech/project/pypynum)
21
21
 
22
- ## Version -> 1.17.1 | PyPI -> https://pypi.org/project/PyPyNum/ | Gitee -> https://www.gitee.com/PythonSJL/PyPyNum | GitHub -> https://github.com/PythonSJL/PyPyNum
22
+ ## Version -> 1.17.2 | PyPI -> https://pypi.org/project/PyPyNum/ | Gitee -> https://www.gitee.com/PythonSJL/PyPyNum | GitHub -> https://github.com/PythonSJL/PyPyNum
23
23
 
24
24
  ![LOGO](PyPyNum.png)
25
25
 
@@ -151,71 +151,51 @@ Python interpreter and run it!
151
151
  ```
152
152
  !=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=
153
153
 
154
- The `pypynum.images` module
155
- now encompasses three classes,
156
- expanding its image processing functionality.
157
- The original `PNG` class
158
- has been transformed to be based on
159
- the `BaseImage` class.
160
- This update includes a specific fix
161
- for the `read` method in `PNG`,
162
- addressing issues with reading
163
- large images.
164
- 1. `BaseImage`: A foundational class
165
- for image processing, offering
166
- basic methods like image creation,
167
- pixel access, and metadata retrieval.
168
- 2. `BMP`: A subclass of `BaseImage`,
169
- tailored for BMP image handling,
170
- providing specialized BMP functionalities.
171
- 3. `PNG`: The `PNG` class, now built on
172
- `BaseImage`, with an improved `read`
173
- method that solves the problem of
174
- reading large PNG files.
175
- This fix to the `read` method in `PNG`
176
- ensures efficient processing of large images,
177
- maintaining image quality and integrity.
178
- The module's enhanced capabilities
179
- make it more robust and user-friendly
180
- for handling substantial PNG files.
154
+ Fixed some known issues.
155
+
156
+ !=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=
157
+
158
+ The pypynum.utils module has recently introduced a new class
159
+ called RadixInt. This class is designed to facilitate the
160
+ representation and manipulation of integers in various bases,
161
+ ranging from base 2 to base 36.
162
+
163
+ The RadixInt class within the pypynum.utils module provides a
164
+ robust way to work with integers in custom bases. It allows
165
+ users to initialize instances with either a decimal number or a
166
+ string representation of a number in the desired base. The class
167
+ supports conversion between different bases, as well as basic
168
+ arithmetic operations that can be performed on integers
169
+ represented in various bases.
181
170
 
182
171
 
183
172
  <<< The following are some usage examples >>>
184
173
 
185
174
 
186
- # Import BMP and PNG classes
187
- from pypynum import BMP, PNG
188
-
189
- # Instantiate BMP class
190
- bmp_image = BMP()
191
- # Instantiate a BMP image with specified dimensions and color
192
- bmp_image.new(width=100, height=100, color=(255, 0, 0), color_mode="RGB", bit_depth=8)
193
- # Set pixel color at (50, 50) to blue
194
- bmp_image[50, 50] = (0, 0, 255)
195
- # Save the BMP image
196
- bmp_image.write("output_bmp.bmp")
197
- # Instantiate PNG class
198
- png_image = PNG()
199
- # Instantiate a PNG image with specified dimensions and color
200
- png_image.new(width=100, height=100, color=(0, 255, 0), color_mode="RGB", bit_depth=8)
201
- # Set pixel color at (50, 50) to yellow
202
- png_image[50, 50] = (255, 255, 0)
203
- # Save the PNG image
204
- png_image.write("output_png.png")
205
- # Create BMP reader to read the BMP image
206
- bmp_reader = BMP()
207
- # Read the BMP image from the file
208
- bmp_reader.read("output_bmp.bmp")
209
- # Print the BMP image and pixel at (50, 50)
210
- print("BMP Image:", bmp_reader)
211
- print("BMP Pixel at (50, 50):", bmp_reader[50, 50])
212
- # Create PNG reader to read the PNG image
213
- png_reader = PNG()
214
- # Read the PNG image from the file
215
- png_reader.read("output_png.png")
216
- # Print the PNG image and pixel at (50, 50)
217
- print("PNG Image:", png_reader)
218
- print("PNG Pixel at (50, 50):", png_reader[50, 50])
175
+ from pypynum import RadixInt
176
+
177
+ # Base-2 and base-10 numbers
178
+ binary_num = RadixInt("1010", 2)
179
+ decimal_num = RadixInt(10, 10)
180
+ print(binary_num) # Output: (1010)_{2}
181
+ print(decimal_num) # Output: (10)_{10}
182
+ binary_to_octal = RadixInt("1010", 2).to_base(8)
183
+ print(binary_to_octal) # Output: (12)_{8}
184
+ # Addition
185
+ result_add = binary_num + decimal_num
186
+ print(result_add) # Output: (20)_{10}
187
+ # Base-8 and base-10 numbers
188
+ octal_num = RadixInt("123", 8)
189
+ decimal_num = RadixInt(5, 10)
190
+ # Subtraction
191
+ result_sub = octal_num - decimal_num
192
+ print(result_sub) # Output: (78)_{10}
193
+ # Base-16 and base-2 numbers
194
+ hex_num = RadixInt("1A", 16)
195
+ binary_num = RadixInt("11", 2)
196
+ # Multiplication
197
+ result_mul = hex_num * binary_num
198
+ print(result_mul) # Output: (78)_{10}
219
199
 
220
200
  !=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=!=
221
201
  ```
@@ -11,9 +11,9 @@ r"""
11
11
  PyPyNum
12
12
  ==========
13
13
 
14
- PyPyNum is a Python library for math & science computations, covering algebra, calculus, stats, with data structures
15
- like matrices, vectors, tensors. It offers numerical tools, programs, and supports computational ops, functions,
16
- processing, simulation, & visualization in data science & ML, crucial for research, engineering, & data processing.
14
+ PyPyNum is a multifunctional Python math lib. It includes modules for math, data analysis, array ops, crypto,
15
+ physics, randomness, data prep, stats, solving eqns, image processing, interp, matrix calc, and high-precision math.
16
+ Designed for scientific computing, data science, and machine learning, PyPyNum provides efficient and versatile tools.
17
17
 
18
18
  Copyright
19
19
  ==========
@@ -68,7 +68,7 @@ from .ufuncs import *
68
68
  from .utils import *
69
69
  from .vectors import *
70
70
 
71
- __version__ = "1.17.1"
71
+ __version__ = "1.17.2"
72
72
  print("PyPyNum", "Version -> " + __version__, "PyPI -> https://pypi.org/project/PyPyNum/",
73
73
  "Gitee -> https://www.gitee.com/PythonSJL/PyPyNum", "GitHub -> https://github.com/PythonSJL/PyPyNum", sep=" | ")
74
74
  for key, value in tuple(globals().items()):
@@ -57,7 +57,7 @@ def cauchy_pdf(x, x0, gamma):
57
57
  Cauchy probability density function
58
58
 
59
59
  Example
60
- =========
60
+ ==========
61
61
  >>> cauchy_pdf(0, 0, 1)
62
62
  0.3183098861837907
63
63
  >>>
@@ -74,10 +74,12 @@ def cauchy_pdf(x, x0, gamma):
74
74
 
75
75
  def cauchy_cdf(x, x0, gamma):
76
76
  """
77
+ Introduction
78
+ ==========
77
79
  Cauchy cumulative distribution function
78
80
 
79
81
  Example
80
- =========
82
+ ==========
81
83
  >>> cauchy_cdf(0, 0, 1)
82
84
  0.5
83
85
  >>>
@@ -133,8 +135,8 @@ def chi2_cdf(x, df=1):
133
135
  :return: The probability density at x for the Chi-squared distribution with df degrees of freedom.
134
136
  """
135
137
  from math import gamma
136
- from .maths import lower_gamma
137
- return lower_gamma(df / 2, x / 2) / gamma(df / 2)
138
+ from .maths import lowergamma
139
+ return lowergamma(df / 2, x / 2) / gamma(df / 2)
138
140
 
139
141
 
140
142
  def expon_pdf(x, scale=1.0):
@@ -291,7 +293,7 @@ def invgauss_pdf(x, mu, lambda_, alpha):
291
293
  Inverse Gaussian (inverse normal) probability density function
292
294
 
293
295
  Example
294
- =========
296
+ ==========
295
297
  >>> invgauss_pdf(1, 1, 1, 1)
296
298
  0.3989422804014327
297
299
  >>>
@@ -317,7 +319,7 @@ def levy_pdf(x, c):
317
319
  Lévy probability density function
318
320
 
319
321
  Example
320
- =========
322
+ ==========
321
323
  >>> levy_pdf(1, 1)
322
324
  0.24197072451914337
323
325
  >>>
@@ -339,7 +341,7 @@ def log_logistic_pdf(x, alpha, beta):
339
341
  Log-logistic probability density function
340
342
 
341
343
  Example
342
- =========
344
+ ==========
343
345
  >>> log_logistic_pdf(1, 1, 1)
344
346
  0.25
345
347
  >>>
@@ -363,7 +365,7 @@ def log_logistic_cdf(x, alpha, beta):
363
365
  Log-logistic cumulative distribution function
364
366
 
365
367
  Example
366
- =========
368
+ ==========
367
369
  >>> log_logistic_cdf(1, 1, 1)
368
370
  0.5906161091496412
369
371
  >>>
@@ -387,7 +389,7 @@ def logistic_pdf(x, mu=0, s=1):
387
389
  Logistic probability density function
388
390
 
389
391
  Example
390
- =========
392
+ ==========
391
393
  >>> logistic_pdf(0, 0, 1)
392
394
  0.25
393
395
  >>>
@@ -409,7 +411,7 @@ def logistic_cdf(x, mu=0, s=1):
409
411
  Logistic cumulative distribution function
410
412
 
411
413
  Example
412
- =========
414
+ ==========
413
415
  >>> logistic_cdf(0, 0, 1)
414
416
  0.5
415
417
  >>>
@@ -502,7 +504,7 @@ def multinomial_pmf(k, n, p):
502
504
  Multinomial probability mass function
503
505
 
504
506
  Example
505
- =========
507
+ ==========
506
508
  >>> multinomial_pmf([2, 1, 0], 3, [0.5, 0.4, 0.1])
507
509
  0.30000000000000004
508
510
  >>>
@@ -636,7 +638,7 @@ def pareto_pdf(x, k, m):
636
638
  Pareto probability density function
637
639
 
638
640
  Example
639
- =========
641
+ ==========
640
642
  >>> pareto_pdf(10, 2, 5)
641
643
  0.00040000000000000013
642
644
  >>>
@@ -679,7 +681,7 @@ def rayleigh_pdf(x, sigma):
679
681
  Rayleigh probability density function
680
682
 
681
683
  Example
682
- =========
684
+ ==========
683
685
  >>> rayleigh_pdf(1, 1)
684
686
  0.6065306597126334
685
687
  >>>
@@ -840,7 +842,7 @@ def zipf_pmf(k, s, n):
840
842
  Zipf probability mass function
841
843
 
842
844
  Example
843
- =========
845
+ ==========
844
846
  >>> zipf_pmf(1, 1, 10)
845
847
  0.34141715214740553
846
848
  >>>
@@ -1,6 +1,6 @@
1
1
  def read(file: str) -> list:
2
2
  """
3
- Read and parse files with the suffix ".pypynum"
3
+ Read and parse files with the suffix ".ppn"
4
4
  :param file: string
5
5
  :return:
6
6
  """
@@ -11,15 +11,15 @@ def read(file: str) -> list:
11
11
  "from .vectors import Vector",
12
12
  "from .geoms import Point, Line, Triangle, Quadrilateral, Polygon, Circle",
13
13
  "from .groups import Group",
14
- "from .quats import Quaternion, Euler",
14
+ "from .hypcmpnms import Quaternion, Euler, Octonion",
15
15
  "from .polys import Polynomial"
16
16
  ]))
17
- suffix = ".pypynum"
17
+ suffix = ".ppn"
18
18
  if not file.endswith(suffix):
19
19
  raise FileExistsError("The file extension can only be '{}'".format(suffix))
20
20
  result = []
21
21
  with open(file, "r") as r:
22
- data = [item.split("\\") for item in r.read().split("\n") if item]
22
+ data = [item.split("\\", 1) for item in r.read().split("\n") if item]
23
23
  for item in data:
24
24
  try:
25
25
  result.append(eval("{}(*{})".format(item[0], item[1])))
@@ -30,7 +30,7 @@ def read(file: str) -> list:
30
30
 
31
31
  def write(file: str, *cls: object):
32
32
  """
33
- Save data to a file with the suffix ".pypynum"
33
+ Save data to a file with the suffix ".ppn"
34
34
  :param file: string
35
35
  :param cls: instance
36
36
  :return:
@@ -38,9 +38,9 @@ def write(file: str, *cls: object):
38
38
  from .arrays import Array
39
39
  from .geoms import Point, Line, Triangle, Quadrilateral, Polygon, Circle
40
40
  from .groups import Group
41
- from .quats import Quaternion, Euler
41
+ from .hypcmpnms import Quaternion, Euler, Octonion
42
42
  from .polys import Polynomial
43
- suffix = ".pypynum"
43
+ suffix = ".ppn"
44
44
  if not file.endswith(suffix):
45
45
  raise FileExistsError("The file extension can only be '{}'".format(suffix))
46
46
  with open(file, "w") as w:
@@ -65,7 +65,7 @@ def write(file: str, *cls: object):
65
65
  w.write("{}\\{}\n".format(prefix, str([item.center, item.radius]).replace(" ", "")))
66
66
  elif isinstance(item, Group):
67
67
  w.write("{}\\{}\n".format(prefix, str([item.elements()]).replace(" ", "")))
68
- elif isinstance(item, (Quaternion, Euler)):
68
+ elif isinstance(item, (Quaternion, Euler, Octonion)):
69
69
  w.write("{}\\{}\n".format(prefix, str(item.data()).replace(" ", "")))
70
70
  elif isinstance(item, Polynomial):
71
71
  w.write("{}\\{}\n".format(prefix, str([item.terms]).replace(" ", "")))
@@ -59,7 +59,7 @@ def uppergamma(s: num, x: num) -> num:
59
59
  return math.gamma(s) - lowergamma(s, x)
60
60
 
61
61
 
62
- def sumprod(*arrays: arr) -> num:
62
+ def sumprod(*arrays: arr, floating: bool = False) -> num:
63
63
  """
64
64
  Introduction
65
65
  ==========
@@ -70,10 +70,12 @@ def sumprod(*arrays: arr) -> num:
70
70
  >>> sumprod([1, 2, 3], [4, 5, 6], [7, 8, 9])
71
71
  270.0
72
72
  >>>
73
- :param arrays: list | tuple
74
- :return:
73
+ :param arrays: A variable number of sequences.
74
+ :param floating: If True, use math.fsum for summing the products. Defaults to False.
75
+ :return: The sum of the product of corresponding elements.
75
76
  """
76
- return math.fsum(map(product, zip(*arrays)))
77
+ f = math.fsum if floating else sum
78
+ return f(map(product, zip(*arrays)))
77
79
 
78
80
 
79
81
  def xlogy(x: num, y: num) -> num:
@@ -537,7 +539,7 @@ def mode(data: arr):
537
539
  def mean(numbers: arr) -> num:
538
540
  """
539
541
  Introduction
540
- ===========
542
+ ==========
541
543
  Calculate the arithmetic mean of a sequence of numbers.
542
544
 
543
545
  The arithmetic mean is the sum of the numbers divided by the count of numbers.
@@ -556,7 +558,7 @@ def mean(numbers: arr) -> num:
556
558
  def geom_mean(numbers: arr) -> num:
557
559
  """
558
560
  Introduction
559
- ===========
561
+ ==========
560
562
  Calculate the geometric mean of a sequence of numbers.
561
563
 
562
564
  The geometric mean is the nth root of the product of the numbers, where n is the count of numbers.
@@ -575,7 +577,7 @@ def geom_mean(numbers: arr) -> num:
575
577
  def square_mean(numbers: arr) -> num:
576
578
  """
577
579
  Introduction
578
- ===========
580
+ ==========
579
581
  Calculate the square mean of a sequence of numbers.
580
582
 
581
583
  The square mean is the square root of the average of the squares of the numbers.
@@ -594,7 +596,7 @@ def square_mean(numbers: arr) -> num:
594
596
  def harm_mean(numbers: arr) -> num:
595
597
  """
596
598
  Introduction
597
- ===========
599
+ ==========
598
600
  Calculate the harmonic mean of a sequence of numbers.
599
601
 
600
602
  The harmonic mean is the reciprocal of the arithmetic mean of the reciprocals of the numbers.
@@ -613,7 +615,7 @@ def harm_mean(numbers: arr) -> num:
613
615
  def power_mean(numbers: arr, p: num) -> num:
614
616
  """
615
617
  Introduction
616
- ===========
618
+ ==========
617
619
  Calculate the power mean of a sequence of numbers with an exponent p.
618
620
 
619
621
  The power mean is the p-th root of the average of the numbers raised to the power p.
@@ -1514,8 +1516,8 @@ def is_square(n: int) -> bool:
1514
1516
  """
1515
1517
  if is_possibly_square(n):
1516
1518
  try:
1517
- from math import isqrt as f
1518
- except ImportError:
1519
+ f = math.isqrt
1520
+ except AttributeError:
1519
1521
  f = isqrt
1520
1522
  sqrt = f(n)
1521
1523
  return sqrt * sqrt == n
@@ -507,10 +507,11 @@ class MPComplex:
507
507
  return MPComplex(self.real, -self.imag, self.sigfigs)
508
508
 
509
509
  def modulus(self, sigfigs=None):
510
- if sigfigs is not None:
511
- _setprec(sigfigs)
510
+ if sigfigs is None:
511
+ sigfigs = self.sigfigs
512
+ _setprec(sigfigs + 5)
512
513
  mod = (self.real ** 2 + self.imag ** 2).sqrt()
513
- _setprec(self.sigfigs)
514
+ _setprec(sigfigs)
514
515
  return +mod
515
516
 
516
517
  def __abs__(self):
@@ -601,7 +601,7 @@ def kmp_table(pattern: ite) -> list:
601
601
  comparisons after a mismatch. This table determines how many characters can be skipped after a mismatch.
602
602
 
603
603
  Example
604
- ========
604
+ ==========
605
605
  >>> kmp_table("AGCTGATCGTACGTAAGCTAGCTA")
606
606
  [0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 1, 1, 2, 3, 4, 1, 2, 3, 4, 1]
607
607
  >>>
@@ -634,7 +634,7 @@ def findall(seq: ite, pat: ite) -> list:
634
634
  of specified subsequences. It allows overlapping matches.
635
635
 
636
636
  Example
637
- ========
637
+ ==========
638
638
  >>> findall([2, 1, 2, 1, 2, 1, 2, 1], [1, 2, 1, 2])
639
639
  [1, 3]
640
640
  >>>
@@ -633,3 +633,85 @@ class IntervalSet:
633
633
  formatted_intervals = [format_interval(*interval) for interval in intervals]
634
634
  union = " \\cup " if use_latex else " ∪ " if config.use_unicode else " U "
635
635
  return union.join(formatted_intervals)
636
+
637
+
638
+ class RadixInt:
639
+ __digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
640
+
641
+ def __init__(self, number, base):
642
+ """
643
+ Represents an integer in a specified base.
644
+ :param number: The integer or string representation of the number to be converted.
645
+ :param base: The base of the number, which must be an integer between 2 and 36.
646
+ """
647
+ self.base = int(base)
648
+ if not 2 <= self.base <= 36:
649
+ raise ValueError("Base must be between 2 and 36.")
650
+ number = str(number)
651
+ self.negative = number[0] == "-"
652
+ if self.negative:
653
+ number = number[1:]
654
+ self.number = number.upper()
655
+ valid = self.__digits[:self.base]
656
+ if not all([char in valid for char in self.number]):
657
+ raise ValueError("The number {} is not valid in base {}.".format(self.number, self.base))
658
+
659
+ def __repr__(self):
660
+ return "({})_{{{}}}".format("-" + self.number if self.negative else self.number, self.base)
661
+
662
+ def to_decimal(self):
663
+ return (-1 if self.negative else 1) * int(self.number, self.base)
664
+
665
+ def to_base(self, new_base):
666
+ if new_base == self.base:
667
+ return RadixInt(self.number, self.base)
668
+ decimal_value = self.to_decimal()
669
+ if new_base == 10:
670
+ return RadixInt(decimal_value, 10)
671
+ else:
672
+ result = ""
673
+ is_negative = self.negative
674
+ decimal_value = abs(decimal_value)
675
+ while decimal_value > 0:
676
+ remainder = decimal_value % new_base
677
+ result = self.__digits[remainder] + result
678
+ decimal_value //= new_base
679
+ result = result or "0"
680
+ if is_negative:
681
+ result = "-" + result
682
+ return RadixInt(result, new_base)
683
+
684
+ def __calculate(self, other, operation):
685
+ if not isinstance(other, RadixInt):
686
+ other = RadixInt(other, 10)
687
+ decimal_result = operation(self.to_decimal(), other.to_decimal())
688
+ result_base = self.base if self.base == other.base else 10
689
+ return RadixInt(decimal_result, 10).to_base(result_base)
690
+
691
+ def __add__(self, other):
692
+ return self.__calculate(other, lambda x, y: x + y)
693
+
694
+ def __sub__(self, other):
695
+ return self.__calculate(other, lambda x, y: x - y)
696
+
697
+ def __mul__(self, other):
698
+ return self.__calculate(other, lambda x, y: x * y)
699
+
700
+ def __floordiv__(self, other):
701
+ return self.__calculate(other, lambda x, y: x // y)
702
+
703
+ def __mod__(self, other):
704
+ return self.__calculate(other, lambda x, y: x % y)
705
+
706
+ def __truediv__(self, other):
707
+ return NotImplemented
708
+
709
+ def __pow__(self, power, modulo=None):
710
+ if isinstance(power, RadixInt):
711
+ power = power.to_decimal()
712
+ if power < 0:
713
+ return NotImplemented
714
+ result = self.__calculate(power, lambda x, y: x ** y)
715
+ if modulo is not None:
716
+ result = result % modulo
717
+ return result
@@ -217,11 +217,11 @@ def 转为多精度复数(实部: Union[int, float, str, Decimal, complex, MPCom
217
217
 
218
218
 
219
219
  def 下伽玛(s: num, x: num) -> num:
220
- return lower_gamma(s, x)
220
+ return lowergamma(s, x)
221
221
 
222
222
 
223
223
  def 上伽玛(s: num, x: num) -> num:
224
- return upper_gamma(s, x)
224
+ return uppergamma(s, x)
225
225
 
226
226
 
227
227
  def 贝塞尔函数J0(x: num) -> num:
@@ -19,16 +19,16 @@ with open("AGPLv3", "r", encoding="UTF-8") as r:
19
19
 
20
20
  setup(
21
21
  name="PyPyNum",
22
- version="1.17.1",
22
+ version="1.17.2",
23
23
  packages=find_packages(),
24
24
  url="https://github.com/PythonSJL/PyPyNum",
25
25
  license=LICENSE,
26
26
  author="Shen Jiayi",
27
27
  author_email="2261748025@qq.com",
28
- description="PyPyNum is a Python library for math & science computations, covering algebra, calculus, stats, "
29
- "with data structures like matrices, vectors, tensors. It offers numerical tools, programs, "
30
- "and supports computational ops, functions, processing, simulation, & visualization in data science & "
31
- "ML, crucial for research, engineering, & data processing.",
28
+ description="PyPyNum is a multifunctional Python math lib. It includes modules for math, data analysis, array ops, "
29
+ "crypto, physics, randomness, data prep, stats, solving eqns, image processing, interp, matrix calc, "
30
+ "and high-precision math. Designed for scientific computing, data science, and machine learning, "
31
+ "PyPyNum provides efficient and versatile tools.",
32
32
  python_requires=">=3.4",
33
33
  package_data={"pypynum": ["*"]},
34
34
  long_description=md,
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
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