nbmath 0.2.4__tar.gz → 1.0.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 (24) hide show
  1. {nbmath-0.2.4 → nbmath-1.0.4}/PKG-INFO +21 -6
  2. {nbmath-0.2.4 → nbmath-1.0.4}/README.md +20 -5
  3. {nbmath-0.2.4 → nbmath-1.0.4}/nbmath/__init__.py +3 -3
  4. {nbmath-0.2.4 → nbmath-1.0.4}/nbmath/plots/core.py +23 -5
  5. {nbmath-0.2.4 → nbmath-1.0.4}/nbmath/plots/examples/cantor_stair.py +1 -1
  6. {nbmath-0.2.4 → nbmath-1.0.4}/nbmath/plots/examples/heart.py +1 -1
  7. {nbmath-0.2.4 → nbmath-1.0.4}/nbmath/plots/examples/lissajous.py +1 -1
  8. {nbmath-0.2.4 → nbmath-1.0.4}/nbmath/plots/examples/sin.py +1 -1
  9. {nbmath-0.2.4 → nbmath-1.0.4}/nbmath/utils.py +4 -0
  10. {nbmath-0.2.4 → nbmath-1.0.4}/nbmath.egg-info/PKG-INFO +21 -6
  11. {nbmath-0.2.4 → nbmath-1.0.4}/nbmath.egg-info/SOURCES.txt +1 -1
  12. {nbmath-0.2.4 → nbmath-1.0.4}/pyproject.toml +1 -1
  13. {nbmath-0.2.4 → nbmath-1.0.4}/LICENSE +0 -0
  14. {nbmath-0.2.4 → nbmath-1.0.4}/nbmath/const.py +0 -0
  15. {nbmath-0.2.4 → nbmath-1.0.4}/nbmath/equation.py +0 -0
  16. /nbmath-0.2.4/nbmath/geometry.py → /nbmath-1.0.4/nbmath/geo.py +0 -0
  17. {nbmath-0.2.4 → nbmath-1.0.4}/nbmath/optimize.py +0 -0
  18. {nbmath-0.2.4 → nbmath-1.0.4}/nbmath/plots/__init__.py +0 -0
  19. {nbmath-0.2.4 → nbmath-1.0.4}/nbmath/plots/examples/__init__.py +0 -0
  20. {nbmath-0.2.4 → nbmath-1.0.4}/nbmath/plots/examples/mandelbrot.py +0 -0
  21. {nbmath-0.2.4 → nbmath-1.0.4}/nbmath/stats.py +0 -0
  22. {nbmath-0.2.4 → nbmath-1.0.4}/nbmath.egg-info/dependency_links.txt +0 -0
  23. {nbmath-0.2.4 → nbmath-1.0.4}/nbmath.egg-info/top_level.txt +0 -0
  24. {nbmath-0.2.4 → nbmath-1.0.4}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nbmath
3
- Version: 0.2.4
3
+ Version: 1.0.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.3/nbmath-0.2.3-py3-none-any.whl
19
+ pip install https://ghproxy.net/https://github.com/tc0512/nbmath/releases/download/v1.0.4/nbmath-1.0.4-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
+ from nbmath.utils import is_odd
27
28
  import os
28
29
 
29
30
  #解方程
@@ -39,6 +40,9 @@ print(newton(lambda x: x**2+6*x+9, 1.5, TOL, MAX_ITER)) #x接近-3,y接近0(有
39
40
 
40
41
  #绘制康托尔阶梯
41
42
  os.system("python -m nbmath.plots.examples.cantor_stair")
43
+
44
+ #判断是否为奇数
45
+ print(is_odd(99999)) #True
42
46
  ```
43
47
 
44
48
  ## 模块介绍
@@ -50,7 +54,7 @@ os.system("python -m nbmath.plots.examples.cantor_stair")
50
54
  - 牛顿迭代法解高次方程
51
55
  - 不等式
52
56
  - 统一接口`solve`
53
- ### 几何模块`nbmath.geometry`
57
+ ### 几何模块`nbmath.geo`
54
58
  - 点`Point`
55
59
  - 线段`Line`
56
60
  - 圆`Circle`
@@ -65,6 +69,7 @@ os.system("python -m nbmath.plots.examples.cantor_stair")
65
69
  - `np.linspace`纯python实现
66
70
  - `polyval`多项式代入求值
67
71
  - `timer`计时器
72
+ - `is_even` `is_odd`奇偶数判断
68
73
  ### 优化算法模块`nbmath.optimize`
69
74
  - `brute`咆哮算法
70
75
  - `golden_section`黄金分割法
@@ -73,7 +78,8 @@ os.system("python -m nbmath.plots.examples.cantor_stair")
73
78
  - `simulated_annealing`模拟退火
74
79
  ### 绘图模块`nbmath.plots`
75
80
  - `point`描点 `scatter`散点图
76
- - `line`线段 `plot_function`绘制函数F(x)
81
+ - `line`线段 `fun`绘制函数F(x)
82
+ - `rect`矩形
77
83
  - `mandelbrot` `heart`等共5个示例图案
78
84
 
79
85
  ## 示例代码
@@ -81,7 +87,8 @@ os.system("python -m nbmath.plots.examples.cantor_stair")
81
87
  from nbmath.equation import solve
82
88
  from nbmath.stats import mode
83
89
  from nbmath.optimize import simulated_annealing
84
- from nbmath.plots import plot_function as pf
90
+ from nbmath import plots as plt
91
+ import math
85
92
 
86
93
  #求解x^4-10x^2+9=0
87
94
  roots = solve(1, 0, -10, 0, 9)
@@ -100,8 +107,16 @@ TOL = 1e-6
100
107
  print(simulated_annealing(F, -5, 5, TEMP, COOLING, STEPS, TOL)) #{'x': -1.581998612252256, 'fun': -2.249992603725974}
101
108
 
102
109
  #绘制y=cos(x)
103
- pf()
110
+ plt.window(800, 600)
111
+ plt.setax(-2*math.pi, -1.5*math.pi, 2*math.pi, 1.5*math.pi)
112
+ plt.drawaxhline()
113
+ plt.plot_function(lambda x: math.sin(x), -2*math.pi, 2*math.pi)
114
+ plt.rect(1, 1, 1.5, 0.5, "red") #绘制一个左下角(1,1),长1.5,宽0.5的红色矩形
115
+ plt.keep_window()
104
116
  ```
105
117
 
106
118
  ## 许可证
107
119
  MIT
120
+
121
+ **警告**
122
+ nbmath-1.0.0有bug,请下载nbmath-1.0.3
@@ -4,7 +4,7 @@
4
4
 
5
5
  ## 安装
6
6
  ```bash
7
- pip install https://ghproxy.net/https://github.com/tc0512/nbmath/releases/download/v0.2.3/nbmath-0.2.3-py3-none-any.whl
7
+ pip install https://ghproxy.net/https://github.com/tc0512/nbmath/releases/download/v1.0.4/nbmath-1.0.4-py3-none-any.whl
8
8
  ```
9
9
 
10
10
  ## 快速开始
@@ -12,6 +12,7 @@ pip install https://ghproxy.net/https://github.com/tc0512/nbmath/releases/downlo
12
12
  from nbmath.equation import solve
13
13
  from nbmath.const import pi
14
14
  from nbmath.optimize import newton
15
+ from nbmath.utils import is_odd
15
16
  import os
16
17
 
17
18
  #解方程
@@ -27,6 +28,9 @@ print(newton(lambda x: x**2+6*x+9, 1.5, TOL, MAX_ITER)) #x接近-3,y接近0(有
27
28
 
28
29
  #绘制康托尔阶梯
29
30
  os.system("python -m nbmath.plots.examples.cantor_stair")
31
+
32
+ #判断是否为奇数
33
+ print(is_odd(99999)) #True
30
34
  ```
31
35
 
32
36
  ## 模块介绍
@@ -38,7 +42,7 @@ os.system("python -m nbmath.plots.examples.cantor_stair")
38
42
  - 牛顿迭代法解高次方程
39
43
  - 不等式
40
44
  - 统一接口`solve`
41
- ### 几何模块`nbmath.geometry`
45
+ ### 几何模块`nbmath.geo`
42
46
  - 点`Point`
43
47
  - 线段`Line`
44
48
  - 圆`Circle`
@@ -53,6 +57,7 @@ os.system("python -m nbmath.plots.examples.cantor_stair")
53
57
  - `np.linspace`纯python实现
54
58
  - `polyval`多项式代入求值
55
59
  - `timer`计时器
60
+ - `is_even` `is_odd`奇偶数判断
56
61
  ### 优化算法模块`nbmath.optimize`
57
62
  - `brute`咆哮算法
58
63
  - `golden_section`黄金分割法
@@ -61,7 +66,8 @@ os.system("python -m nbmath.plots.examples.cantor_stair")
61
66
  - `simulated_annealing`模拟退火
62
67
  ### 绘图模块`nbmath.plots`
63
68
  - `point`描点 `scatter`散点图
64
- - `line`线段 `plot_function`绘制函数F(x)
69
+ - `line`线段 `fun`绘制函数F(x)
70
+ - `rect`矩形
65
71
  - `mandelbrot` `heart`等共5个示例图案
66
72
 
67
73
  ## 示例代码
@@ -69,7 +75,8 @@ os.system("python -m nbmath.plots.examples.cantor_stair")
69
75
  from nbmath.equation import solve
70
76
  from nbmath.stats import mode
71
77
  from nbmath.optimize import simulated_annealing
72
- from nbmath.plots import plot_function as pf
78
+ from nbmath import plots as plt
79
+ import math
73
80
 
74
81
  #求解x^4-10x^2+9=0
75
82
  roots = solve(1, 0, -10, 0, 9)
@@ -88,8 +95,16 @@ TOL = 1e-6
88
95
  print(simulated_annealing(F, -5, 5, TEMP, COOLING, STEPS, TOL)) #{'x': -1.581998612252256, 'fun': -2.249992603725974}
89
96
 
90
97
  #绘制y=cos(x)
91
- pf()
98
+ plt.window(800, 600)
99
+ plt.setax(-2*math.pi, -1.5*math.pi, 2*math.pi, 1.5*math.pi)
100
+ plt.drawaxhline()
101
+ plt.plot_function(lambda x: math.sin(x), -2*math.pi, 2*math.pi)
102
+ plt.rect(1, 1, 1.5, 0.5, "red") #绘制一个左下角(1,1),长1.5,宽0.5的红色矩形
103
+ plt.keep_window()
92
104
  ```
93
105
 
94
106
  ## 许可证
95
107
  MIT
108
+
109
+ **警告**
110
+ nbmath-1.0.0有bug,请下载nbmath-1.0.3
@@ -1,6 +1,6 @@
1
1
  from . import const
2
2
  from . import equation
3
- from . import geometry
3
+ from . import geo
4
4
  from . import plots
5
5
  from . import stats
6
6
  from . import utils
@@ -8,9 +8,9 @@ from . import utils
8
8
  __all__ = [
9
9
  'const',
10
10
  'equation',
11
- 'geometry',
11
+ 'geo',
12
12
  'plots',
13
13
  'stats',
14
14
  'utils'
15
15
  ]
16
- __version__ = "0.2.4"
16
+ __version__ = "1.0.4"
@@ -1,4 +1,6 @@
1
1
  import turtle as t
2
+ import platform
3
+ python_version = platform.python_version()
2
4
  _length = _height = None
3
5
  _llx = _lly = _urx = _ury = None
4
6
  def window(length, height): #窗口(t.setup)
@@ -10,6 +12,8 @@ def window(length, height): #窗口(t.setup)
10
12
  t.speed(0)
11
13
  t.tracer(0)
12
14
  t.penup()
15
+ print(f"Python{python_version} nbmath1.0.4")
16
+ print("enjoy plotting!")
13
17
  def setax(llx, lly, urx, ury): #设置坐标系范围(t.setworldcoordinates)
14
18
  global _llx, _lly, _urx , _ury
15
19
  _llx, _lly, _urx , _ury = llx, lly, urx, ury
@@ -54,7 +58,7 @@ def line(x: list, y: list, color: str, linewidth: int): #绘制线段
54
58
  t.goto(x[1], y[1])
55
59
  t.pensize(1)
56
60
  t.update()
57
- def plot_function(f, x_min, x_max, color: str, linewidth: int, steps: int): #函数图像y=f(x)
61
+ def fun(f, x_min, x_max, color: str, linewidth: int, steps: int): #函数图像y=f(x)
58
62
  t.hideturtle()
59
63
  t.penup()
60
64
  dx = (x_max-x_min)/steps
@@ -68,13 +72,27 @@ def plot_function(f, x_min, x_max, color: str, linewidth: int, steps: int): #函
68
72
  t.pensize(linewidth)
69
73
  t.penup()
70
74
  t.update()
71
- def scatter(points: list, color: str, size: int): #散点图
75
+ def scatter(points: list, color: str, size: list): #散点图
76
+ n = len(points)
77
+ if n!=len(size):
78
+ raise ValueError("length of points and size is not equal")
72
79
  t.hideturtle()
73
80
  t.penup()
74
81
  t.pencolor(color)
75
- for i in points:
76
- t.goto(i)
77
- t.dot(size)
82
+ for i in range(n):
83
+ t.goto(points[i])
84
+ t.dot(size[i])
85
+ t.update()
86
+ def rect(llx, lly, width, height, color):
87
+ t.hideturtle()
88
+ t.penup()
89
+ t.pencolor(color)
90
+ t.goto(llx, lly)
91
+ for i in range(2):
92
+ t.fd(width)
93
+ t.lt(90)
94
+ t.fd(height)
95
+ t.lt(90)
78
96
  t.update()
79
97
  def keep_window():
80
98
  t.done()
@@ -14,7 +14,7 @@ def main():
14
14
  plt.window(720, 720)
15
15
  plt.setax(-0.5, -0.5, 1.5, 1.5)
16
16
  plt.drawaxhline()
17
- plt.plot_function(F, 0, 1, "blue", 2, 800)
17
+ plt.fun(F, 0, 1, "blue", 2, 800)
18
18
  plt.keep_window()
19
19
  if __name__ == "__main__":
20
20
  main()
@@ -24,7 +24,7 @@ def main():
24
24
  x = r*math.cos(i)
25
25
  y = r*math.sin(i)
26
26
  p.append((x, y))
27
- plt.scatter(p, "red", 2)
27
+ plt.scatter(p, "red", [2]*len(p))
28
28
  plt.keep_window()
29
29
  if __name__ == "__main__":
30
30
  main()
@@ -27,7 +27,7 @@ def main():
27
27
  x = ALPHA*math.sin(A*i+DELTA)
28
28
  y = BETA*math.sin(B*i)
29
29
  p.append((x, y))
30
- plt.scatter(p, "green", 1)
30
+ plt.scatter(p, "green", [1]*len(p))
31
31
  plt.keep_window()
32
32
  if __name__ == "__main__":
33
33
  main()
@@ -5,7 +5,7 @@ def main():
5
5
  plt.window(800, 600)
6
6
  plt.setax(-2*math.pi, -1.5*math.pi, 2*math.pi, 1.5*math.pi)
7
7
  plt.drawaxhline()
8
- plt.plot_function(lambda x:math.sin(x), -2*math.pi, 2*math.pi, "blue", 2, 800)
8
+ plt.fun(lambda x:math.sin(x), -2*math.pi, 2*math.pi, "blue", 2, 800)
9
9
  plt.keep_window()
10
10
  if __name__ == "__main__":
11
11
  main()
@@ -58,3 +58,7 @@ def fac(x): #阶乘
58
58
  elif x<0 and int(x)==x:
59
59
  return float('nan')
60
60
  return math.gamma(x+1)
61
+ def is_even(x: int): #偶数判断
62
+ return x%2==0
63
+ def is_odd(x: int): #奇数判断
64
+ return x%2==1
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nbmath
3
- Version: 0.2.4
3
+ Version: 1.0.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.3/nbmath-0.2.3-py3-none-any.whl
19
+ pip install https://ghproxy.net/https://github.com/tc0512/nbmath/releases/download/v1.0.4/nbmath-1.0.4-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
+ from nbmath.utils import is_odd
27
28
  import os
28
29
 
29
30
  #解方程
@@ -39,6 +40,9 @@ print(newton(lambda x: x**2+6*x+9, 1.5, TOL, MAX_ITER)) #x接近-3,y接近0(有
39
40
 
40
41
  #绘制康托尔阶梯
41
42
  os.system("python -m nbmath.plots.examples.cantor_stair")
43
+
44
+ #判断是否为奇数
45
+ print(is_odd(99999)) #True
42
46
  ```
43
47
 
44
48
  ## 模块介绍
@@ -50,7 +54,7 @@ os.system("python -m nbmath.plots.examples.cantor_stair")
50
54
  - 牛顿迭代法解高次方程
51
55
  - 不等式
52
56
  - 统一接口`solve`
53
- ### 几何模块`nbmath.geometry`
57
+ ### 几何模块`nbmath.geo`
54
58
  - 点`Point`
55
59
  - 线段`Line`
56
60
  - 圆`Circle`
@@ -65,6 +69,7 @@ os.system("python -m nbmath.plots.examples.cantor_stair")
65
69
  - `np.linspace`纯python实现
66
70
  - `polyval`多项式代入求值
67
71
  - `timer`计时器
72
+ - `is_even` `is_odd`奇偶数判断
68
73
  ### 优化算法模块`nbmath.optimize`
69
74
  - `brute`咆哮算法
70
75
  - `golden_section`黄金分割法
@@ -73,7 +78,8 @@ os.system("python -m nbmath.plots.examples.cantor_stair")
73
78
  - `simulated_annealing`模拟退火
74
79
  ### 绘图模块`nbmath.plots`
75
80
  - `point`描点 `scatter`散点图
76
- - `line`线段 `plot_function`绘制函数F(x)
81
+ - `line`线段 `fun`绘制函数F(x)
82
+ - `rect`矩形
77
83
  - `mandelbrot` `heart`等共5个示例图案
78
84
 
79
85
  ## 示例代码
@@ -81,7 +87,8 @@ os.system("python -m nbmath.plots.examples.cantor_stair")
81
87
  from nbmath.equation import solve
82
88
  from nbmath.stats import mode
83
89
  from nbmath.optimize import simulated_annealing
84
- from nbmath.plots import plot_function as pf
90
+ from nbmath import plots as plt
91
+ import math
85
92
 
86
93
  #求解x^4-10x^2+9=0
87
94
  roots = solve(1, 0, -10, 0, 9)
@@ -100,8 +107,16 @@ TOL = 1e-6
100
107
  print(simulated_annealing(F, -5, 5, TEMP, COOLING, STEPS, TOL)) #{'x': -1.581998612252256, 'fun': -2.249992603725974}
101
108
 
102
109
  #绘制y=cos(x)
103
- pf()
110
+ plt.window(800, 600)
111
+ plt.setax(-2*math.pi, -1.5*math.pi, 2*math.pi, 1.5*math.pi)
112
+ plt.drawaxhline()
113
+ plt.plot_function(lambda x: math.sin(x), -2*math.pi, 2*math.pi)
114
+ plt.rect(1, 1, 1.5, 0.5, "red") #绘制一个左下角(1,1),长1.5,宽0.5的红色矩形
115
+ plt.keep_window()
104
116
  ```
105
117
 
106
118
  ## 许可证
107
119
  MIT
120
+
121
+ **警告**
122
+ nbmath-1.0.0有bug,请下载nbmath-1.0.3
@@ -4,7 +4,7 @@ pyproject.toml
4
4
  nbmath/__init__.py
5
5
  nbmath/const.py
6
6
  nbmath/equation.py
7
- nbmath/geometry.py
7
+ nbmath/geo.py
8
8
  nbmath/optimize.py
9
9
  nbmath/stats.py
10
10
  nbmath/utils.py
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "nbmath"
7
- version = "0.2.4"
7
+ version = "1.0.4"
8
8
  description = "python零依赖数学库"
9
9
  authors = [
10
10
  {name = "tc0512", email = "tancheng_0812@qq.com"}
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes