nbmath 0.2.3__tar.gz → 0.2.4__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 (25) hide show
  1. {nbmath-0.2.3/nbmath.egg-info → nbmath-0.2.4}/PKG-INFO +14 -2
  2. nbmath-0.2.3/PKG-INFO → nbmath-0.2.4/README.md +13 -13
  3. {nbmath-0.2.3 → nbmath-0.2.4}/nbmath/__init__.py +1 -1
  4. nbmath-0.2.4/nbmath/plots/examples/__init__.py +7 -0
  5. nbmath-0.2.4/nbmath/plots/examples/cantor_stair.py +20 -0
  6. nbmath-0.2.4/nbmath/plots/examples/mandelbrot.py +38 -0
  7. nbmath-0.2.3/README.md → nbmath-0.2.4/nbmath.egg-info/PKG-INFO +25 -1
  8. {nbmath-0.2.3 → nbmath-0.2.4}/nbmath.egg-info/SOURCES.txt +2 -0
  9. {nbmath-0.2.3 → nbmath-0.2.4}/pyproject.toml +1 -1
  10. nbmath-0.2.3/nbmath/plots/examples/__init__.py +0 -5
  11. {nbmath-0.2.3 → nbmath-0.2.4}/LICENSE +0 -0
  12. {nbmath-0.2.3 → nbmath-0.2.4}/nbmath/const.py +0 -0
  13. {nbmath-0.2.3 → nbmath-0.2.4}/nbmath/equation.py +0 -0
  14. {nbmath-0.2.3 → nbmath-0.2.4}/nbmath/geometry.py +0 -0
  15. {nbmath-0.2.3 → nbmath-0.2.4}/nbmath/optimize.py +0 -0
  16. {nbmath-0.2.3 → nbmath-0.2.4}/nbmath/plots/__init__.py +0 -0
  17. {nbmath-0.2.3 → nbmath-0.2.4}/nbmath/plots/core.py +0 -0
  18. {nbmath-0.2.3 → nbmath-0.2.4}/nbmath/plots/examples/heart.py +0 -0
  19. {nbmath-0.2.3 → nbmath-0.2.4}/nbmath/plots/examples/lissajous.py +0 -0
  20. {nbmath-0.2.3 → nbmath-0.2.4}/nbmath/plots/examples/sin.py +0 -0
  21. {nbmath-0.2.3 → nbmath-0.2.4}/nbmath/stats.py +0 -0
  22. {nbmath-0.2.3 → nbmath-0.2.4}/nbmath/utils.py +0 -0
  23. {nbmath-0.2.3 → nbmath-0.2.4}/nbmath.egg-info/dependency_links.txt +0 -0
  24. {nbmath-0.2.3 → nbmath-0.2.4}/nbmath.egg-info/top_level.txt +0 -0
  25. {nbmath-0.2.3 → nbmath-0.2.4}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nbmath
3
- Version: 0.2.3
3
+ Version: 0.2.4
4
4
  Summary: python零依赖数学库
5
5
  Author-email: tc0512 <tancheng_0812@qq.com>
6
6
  License: MIT
@@ -16,7 +16,7 @@ Dynamic: license-file
16
16
 
17
17
  ## 安装
18
18
  ```bash
19
- pip install https://ghproxy.net/https://github.com/tc0512/nbmath/releases/download/v0.2.0/nbmath-0.2.0-py3-none-any.whl
19
+ pip install https://ghproxy.net/https://github.com/tc0512/nbmath/releases/download/v0.2.3/nbmath-0.2.3-py3-none-any.whl
20
20
  ```
21
21
 
22
22
  ## 快速开始
@@ -24,6 +24,7 @@ pip install https://ghproxy.net/https://github.com/tc0512/nbmath/releases/downlo
24
24
  from nbmath.equation import solve
25
25
  from nbmath.const import pi
26
26
  from nbmath.optimize import newton
27
+ import os
27
28
 
28
29
  #解方程
29
30
  print(solve(1, -3, 2)) #[(2+0j), (1+0j)]
@@ -35,6 +36,9 @@ print(pi()) #3.141592653589793
35
36
  TOL = 1e-6
36
37
  MAX_ITER = 100
37
38
  print(newton(lambda x: x**2+6*x+9, 1.5, TOL, MAX_ITER)) #x接近-3,y接近0(有浮点误差)
39
+
40
+ #绘制康托尔阶梯
41
+ os.system("python -m nbmath.plots.examples.cantor_stair")
38
42
  ```
39
43
 
40
44
  ## 模块介绍
@@ -67,12 +71,17 @@ print(newton(lambda x: x**2+6*x+9, 1.5, TOL, MAX_ITER)) #x接近-3,y接近0(有
67
71
  - `newton`牛顿法
68
72
  - `gradient_descent`梯度下降
69
73
  - `simulated_annealing`模拟退火
74
+ ### 绘图模块`nbmath.plots`
75
+ - `point`描点 `scatter`散点图
76
+ - `line`线段 `plot_function`绘制函数F(x)
77
+ - `mandelbrot` `heart`等共5个示例图案
70
78
 
71
79
  ## 示例代码
72
80
  ```python
73
81
  from nbmath.equation import solve
74
82
  from nbmath.stats import mode
75
83
  from nbmath.optimize import simulated_annealing
84
+ from nbmath.plots import plot_function as pf
76
85
 
77
86
  #求解x^4-10x^2+9=0
78
87
  roots = solve(1, 0, -10, 0, 9)
@@ -89,6 +98,9 @@ COOLING = 0.95
89
98
  STEPS = 1000
90
99
  TOL = 1e-6
91
100
  print(simulated_annealing(F, -5, 5, TEMP, COOLING, STEPS, TOL)) #{'x': -1.581998612252256, 'fun': -2.249992603725974}
101
+
102
+ #绘制y=cos(x)
103
+ pf()
92
104
  ```
93
105
 
94
106
  ## 许可证
@@ -1,22 +1,10 @@
1
- Metadata-Version: 2.4
2
- Name: nbmath
3
- Version: 0.2.3
4
- Summary: python零依赖数学库
5
- Author-email: tc0512 <tancheng_0812@qq.com>
6
- License: MIT
7
- Project-URL: Homepage, https://github.com/tc0512/nbmath
8
- Requires-Python: >=3.8
9
- Description-Content-Type: text/markdown
10
- License-File: LICENSE
11
- Dynamic: license-file
12
-
13
1
  # nbmath
14
2
 
15
3
  一个实用的数学工具包,支持方程求解、几何计算、统计分析等功能。
16
4
 
17
5
  ## 安装
18
6
  ```bash
19
- pip install https://ghproxy.net/https://github.com/tc0512/nbmath/releases/download/v0.2.0/nbmath-0.2.0-py3-none-any.whl
7
+ pip install https://ghproxy.net/https://github.com/tc0512/nbmath/releases/download/v0.2.3/nbmath-0.2.3-py3-none-any.whl
20
8
  ```
21
9
 
22
10
  ## 快速开始
@@ -24,6 +12,7 @@ pip install https://ghproxy.net/https://github.com/tc0512/nbmath/releases/downlo
24
12
  from nbmath.equation import solve
25
13
  from nbmath.const import pi
26
14
  from nbmath.optimize import newton
15
+ import os
27
16
 
28
17
  #解方程
29
18
  print(solve(1, -3, 2)) #[(2+0j), (1+0j)]
@@ -35,6 +24,9 @@ print(pi()) #3.141592653589793
35
24
  TOL = 1e-6
36
25
  MAX_ITER = 100
37
26
  print(newton(lambda x: x**2+6*x+9, 1.5, TOL, MAX_ITER)) #x接近-3,y接近0(有浮点误差)
27
+
28
+ #绘制康托尔阶梯
29
+ os.system("python -m nbmath.plots.examples.cantor_stair")
38
30
  ```
39
31
 
40
32
  ## 模块介绍
@@ -67,12 +59,17 @@ print(newton(lambda x: x**2+6*x+9, 1.5, TOL, MAX_ITER)) #x接近-3,y接近0(有
67
59
  - `newton`牛顿法
68
60
  - `gradient_descent`梯度下降
69
61
  - `simulated_annealing`模拟退火
62
+ ### 绘图模块`nbmath.plots`
63
+ - `point`描点 `scatter`散点图
64
+ - `line`线段 `plot_function`绘制函数F(x)
65
+ - `mandelbrot` `heart`等共5个示例图案
70
66
 
71
67
  ## 示例代码
72
68
  ```python
73
69
  from nbmath.equation import solve
74
70
  from nbmath.stats import mode
75
71
  from nbmath.optimize import simulated_annealing
72
+ from nbmath.plots import plot_function as pf
76
73
 
77
74
  #求解x^4-10x^2+9=0
78
75
  roots = solve(1, 0, -10, 0, 9)
@@ -89,6 +86,9 @@ COOLING = 0.95
89
86
  STEPS = 1000
90
87
  TOL = 1e-6
91
88
  print(simulated_annealing(F, -5, 5, TEMP, COOLING, STEPS, TOL)) #{'x': -1.581998612252256, 'fun': -2.249992603725974}
89
+
90
+ #绘制y=cos(x)
91
+ pf()
92
92
  ```
93
93
 
94
94
  ## 许可证
@@ -13,4 +13,4 @@ __all__ = [
13
13
  'stats',
14
14
  'utils'
15
15
  ]
16
- __version__ = "0.2.3"
16
+ __version__ = "0.2.4"
@@ -0,0 +1,7 @@
1
+ from . import sin
2
+ from . import heart
3
+ from . import lissajous
4
+ from . import cantor_stair
5
+ from . import mandelbrot
6
+
7
+ __all__ = ['sin', 'heart', 'lissajous', 'cantor_stair', 'mandelbrot']
@@ -0,0 +1,20 @@
1
+ #!/usr/bin/env python3
2
+ import math
3
+ from nbmath.plots import core as plt
4
+ def F(x, depth=20):
5
+ if depth == 0:
6
+ return x
7
+ if x < 1/3:
8
+ return 0.5 * F(3*x, depth-1)
9
+ elif x <= 2/3:
10
+ return 0.5
11
+ else:
12
+ return 0.5 + 0.5 * F(3*x - 2, depth-1)
13
+ def main():
14
+ plt.window(720, 720)
15
+ plt.setax(-0.5, -0.5, 1.5, 1.5)
16
+ plt.drawaxhline()
17
+ plt.plot_function(F, 0, 1, "blue", 2, 800)
18
+ plt.keep_window()
19
+ if __name__ == "__main__":
20
+ main()
@@ -0,0 +1,38 @@
1
+ #!/usr/bin/env python3
2
+ import sys
3
+ import math
4
+ from nbmath.plots import core as plt
5
+ def mandelbrot(c, max_iter=100):
6
+ z = 0
7
+ for n in range(max_iter):
8
+ if abs(z) > 2:
9
+ return n
10
+ z = z*z + c
11
+ return max_iter
12
+ def main():
13
+ width, height = 800, 600
14
+ xmin, xmax = -2.5, 1.5
15
+ ymin, ymax = -1.5, 1.5
16
+ plt.window(width, height)
17
+ plt.setax(xmin, ymin, xmax, ymax)
18
+ plt.drawaxhline()
19
+ total = width * height
20
+ points = []
21
+ for i in range(height):
22
+ for j in range(width):
23
+ x = xmin + (xmax - xmin) * j / width
24
+ y = ymin + (ymax - ymin) * i / height
25
+ c = complex(x, y)
26
+ iter_count = mandelbrot(c)
27
+ if iter_count == 100:
28
+ color = "black"
29
+ else:
30
+ brightness = int(255 * iter_count / 100)
31
+ color = f"#{brightness:02x}{brightness:02x}{brightness:02x}"
32
+ points.append((j, i))
33
+ plt.point(j, i, color, 1, "")
34
+ print(f"\rplotting...{i*width+j}/{total}", end="")
35
+ print("Ok,done.")
36
+ plt.keep_window()
37
+ if __name__ == "__main__":
38
+ main()
@@ -1,10 +1,22 @@
1
+ Metadata-Version: 2.4
2
+ Name: nbmath
3
+ Version: 0.2.4
4
+ Summary: python零依赖数学库
5
+ Author-email: tc0512 <tancheng_0812@qq.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/tc0512/nbmath
8
+ Requires-Python: >=3.8
9
+ Description-Content-Type: text/markdown
10
+ License-File: LICENSE
11
+ Dynamic: license-file
12
+
1
13
  # nbmath
2
14
 
3
15
  一个实用的数学工具包,支持方程求解、几何计算、统计分析等功能。
4
16
 
5
17
  ## 安装
6
18
  ```bash
7
- pip install https://ghproxy.net/https://github.com/tc0512/nbmath/releases/download/v0.2.0/nbmath-0.2.0-py3-none-any.whl
19
+ pip install https://ghproxy.net/https://github.com/tc0512/nbmath/releases/download/v0.2.3/nbmath-0.2.3-py3-none-any.whl
8
20
  ```
9
21
 
10
22
  ## 快速开始
@@ -12,6 +24,7 @@ pip install https://ghproxy.net/https://github.com/tc0512/nbmath/releases/downlo
12
24
  from nbmath.equation import solve
13
25
  from nbmath.const import pi
14
26
  from nbmath.optimize import newton
27
+ import os
15
28
 
16
29
  #解方程
17
30
  print(solve(1, -3, 2)) #[(2+0j), (1+0j)]
@@ -23,6 +36,9 @@ print(pi()) #3.141592653589793
23
36
  TOL = 1e-6
24
37
  MAX_ITER = 100
25
38
  print(newton(lambda x: x**2+6*x+9, 1.5, TOL, MAX_ITER)) #x接近-3,y接近0(有浮点误差)
39
+
40
+ #绘制康托尔阶梯
41
+ os.system("python -m nbmath.plots.examples.cantor_stair")
26
42
  ```
27
43
 
28
44
  ## 模块介绍
@@ -55,12 +71,17 @@ print(newton(lambda x: x**2+6*x+9, 1.5, TOL, MAX_ITER)) #x接近-3,y接近0(有
55
71
  - `newton`牛顿法
56
72
  - `gradient_descent`梯度下降
57
73
  - `simulated_annealing`模拟退火
74
+ ### 绘图模块`nbmath.plots`
75
+ - `point`描点 `scatter`散点图
76
+ - `line`线段 `plot_function`绘制函数F(x)
77
+ - `mandelbrot` `heart`等共5个示例图案
58
78
 
59
79
  ## 示例代码
60
80
  ```python
61
81
  from nbmath.equation import solve
62
82
  from nbmath.stats import mode
63
83
  from nbmath.optimize import simulated_annealing
84
+ from nbmath.plots import plot_function as pf
64
85
 
65
86
  #求解x^4-10x^2+9=0
66
87
  roots = solve(1, 0, -10, 0, 9)
@@ -77,6 +98,9 @@ COOLING = 0.95
77
98
  STEPS = 1000
78
99
  TOL = 1e-6
79
100
  print(simulated_annealing(F, -5, 5, TEMP, COOLING, STEPS, TOL)) #{'x': -1.581998612252256, 'fun': -2.249992603725974}
101
+
102
+ #绘制y=cos(x)
103
+ pf()
80
104
  ```
81
105
 
82
106
  ## 许可证
@@ -15,6 +15,8 @@ nbmath.egg-info/top_level.txt
15
15
  nbmath/plots/__init__.py
16
16
  nbmath/plots/core.py
17
17
  nbmath/plots/examples/__init__.py
18
+ nbmath/plots/examples/cantor_stair.py
18
19
  nbmath/plots/examples/heart.py
19
20
  nbmath/plots/examples/lissajous.py
21
+ nbmath/plots/examples/mandelbrot.py
20
22
  nbmath/plots/examples/sin.py
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "nbmath"
7
- version = "0.2.3"
7
+ version = "0.2.4"
8
8
  description = "python零依赖数学库"
9
9
  authors = [
10
10
  {name = "tc0512", email = "tancheng_0812@qq.com"}
@@ -1,5 +0,0 @@
1
- from . import sin
2
- from . import heart
3
- from . import lissajous
4
-
5
- __all__ = ['sin', 'heart', 'lissajous']
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