nbmath 0.2.0__tar.gz → 0.2.3__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nbmath
3
- Version: 0.2.0
3
+ Version: 0.2.3
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://github.com/tc0512/nbmath/releases/download/v0.1.7/nbmath-0.1.7-py3-none-any.whl
19
+ pip install https://ghproxy.net/https://github.com/tc0512/nbmath/releases/download/v0.2.0/nbmath-0.2.0-py3-none-any.whl
20
20
  ```
21
21
 
22
22
  ## 快速开始
@@ -4,7 +4,7 @@
4
4
 
5
5
  ## 安装
6
6
  ```bash
7
- pip install https://github.com/tc0512/nbmath/releases/download/v0.1.7/nbmath-0.1.7-py3-none-any.whl
7
+ pip install https://ghproxy.net/https://github.com/tc0512/nbmath/releases/download/v0.2.0/nbmath-0.2.0-py3-none-any.whl
8
8
  ```
9
9
 
10
10
  ## 快速开始
@@ -13,4 +13,4 @@ __all__ = [
13
13
  'stats',
14
14
  'utils'
15
15
  ]
16
- __version__ = "0.1.6"
16
+ __version__ = "0.2.3"
@@ -9,7 +9,8 @@ def brute(f, x_min, x_max, steps: int): #咆哮算法
9
9
  x+=step_length
10
10
  fun = min(results)
11
11
  ind = results.index(fun)
12
- return {"x": results[ind], "fun": fun}
12
+ x_opt = x_min+ind*step_length
13
+ return {"x": x_opt, "fun": fun}
13
14
  def golden_section(f, x_min, x_max, tol): #黄金分割法
14
15
  phi = (math.sqrt(5)-1)/2
15
16
  x1 = x_max-phi*(x_max-x_min)
@@ -0,0 +1,2 @@
1
+ from .core import *
2
+ from . import examples
@@ -15,6 +15,7 @@ def setax(llx, lly, urx, ury): #设置坐标系范围(t.setworldcoordinates)
15
15
  _llx, _lly, _urx , _ury = llx, lly, urx, ury
16
16
  t.setworldcoordinates(llx, lly, urx, ury)
17
17
  def drawaxhline(): #绘制坐标轴
18
+ t.hideturtle()
18
19
  global _length, _height, _llx, _lly, _urx , _ury
19
20
  if None in (_length, _height):
20
21
  raise ValueError("please use 'window' first to create a window")
@@ -35,6 +36,7 @@ def drawaxhline(): #绘制坐标轴
35
36
  t.penup()
36
37
  t.update()
37
38
  def point(x, y, color: str, size: int, label: str): #描点
39
+ t.hideturtle()
38
40
  t.penup()
39
41
  t.goto(x, y)
40
42
  t.pencolor(color)
@@ -43,6 +45,7 @@ def point(x, y, color: str, size: int, label: str): #描点
43
45
  t.penup()
44
46
  t.update()
45
47
  def line(x: list, y: list, color: str, linewidth: int): #绘制线段
48
+ t.hideturtle()
46
49
  t.penup()
47
50
  t.goto(x[0], y[0])
48
51
  t.pendown()
@@ -52,6 +55,7 @@ def line(x: list, y: list, color: str, linewidth: int): #绘制线段
52
55
  t.pensize(1)
53
56
  t.update()
54
57
  def plot_function(f, x_min, x_max, color: str, linewidth: int, steps: int): #函数图像y=f(x)
58
+ t.hideturtle()
55
59
  t.penup()
56
60
  dx = (x_max-x_min)/steps
57
61
  for i in range(steps+1):
@@ -64,12 +68,13 @@ def plot_function(f, x_min, x_max, color: str, linewidth: int, steps: int): #函
64
68
  t.pensize(linewidth)
65
69
  t.penup()
66
70
  t.update()
67
- def scatter(points: list, color: str): #散点图
71
+ def scatter(points: list, color: str, size: int): #散点图
72
+ t.hideturtle()
68
73
  t.penup()
69
74
  t.pencolor(color)
70
75
  for i in points:
71
76
  t.goto(i)
72
- t.dot(5)
77
+ t.dot(size)
73
78
  t.update()
74
79
  def keep_window():
75
80
  t.done()
@@ -0,0 +1,5 @@
1
+ from . import sin
2
+ from . import heart
3
+ from . import lissajous
4
+
5
+ __all__ = ['sin', 'heart', 'lissajous']
@@ -0,0 +1,30 @@
1
+ #!/usr/bin/env python3
2
+ import math
3
+ from nbmath.plots import core as plt
4
+ def linspace(start, end, steps):
5
+ if steps==0:
6
+ return []
7
+ elif steps==1:
8
+ return [start]
9
+ dx = (end-start)/steps
10
+ result = []
11
+ for i in range(steps+1):
12
+ x = start+i*dx
13
+ result.append(x)
14
+ return result
15
+ def main():
16
+ plt.window(720, 720)
17
+ plt.setax(-3, -3, 3, 3)
18
+ plt.drawaxhline()
19
+ A = 1
20
+ theta = linspace(-2*math.pi, 2*math.pi, 2000)
21
+ p = []
22
+ for i in theta:
23
+ r = A*(1-math.cos(i))
24
+ x = r*math.cos(i)
25
+ y = r*math.sin(i)
26
+ p.append((x, y))
27
+ plt.scatter(p, "red", 2)
28
+ plt.keep_window()
29
+ if __name__ == "__main__":
30
+ main()
@@ -0,0 +1,33 @@
1
+ #!/usr/bin/env python3
2
+ import math
3
+ from nbmath.plots import core as plt
4
+ def linspace(start, end, steps):
5
+ if steps==0:
6
+ return []
7
+ elif steps==1:
8
+ return [start]
9
+ dx = (end-start)/steps
10
+ result = []
11
+ for i in range(steps+1):
12
+ x = start+i*dx
13
+ result.append(x)
14
+ return result
15
+ def main():
16
+ plt.window(720, 720)
17
+ plt.setax(-1.5, -1.5, 1.5, 1.5)
18
+ plt.drawaxhline()
19
+ ALPHA = 1
20
+ BETA = 1
21
+ A = 5
22
+ B = 4
23
+ DELTA = math.pi/2
24
+ t = linspace(0, 2*math.pi, 5000)
25
+ p = []
26
+ for i in t:
27
+ x = ALPHA*math.sin(A*i+DELTA)
28
+ y = BETA*math.sin(B*i)
29
+ p.append((x, y))
30
+ plt.scatter(p, "green", 1)
31
+ plt.keep_window()
32
+ if __name__ == "__main__":
33
+ main()
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env python3
2
+ import math
3
+ from nbmath.plots import core as plt
4
+ def main():
5
+ plt.window(800, 600)
6
+ plt.setax(-2*math.pi, -1.5*math.pi, 2*math.pi, 1.5*math.pi)
7
+ plt.drawaxhline()
8
+ plt.plot_function(lambda x:math.sin(x), -2*math.pi, 2*math.pi, "blue", 2, 800)
9
+ plt.keep_window()
10
+ if __name__ == "__main__":
11
+ main()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nbmath
3
- Version: 0.2.0
3
+ Version: 0.2.3
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://github.com/tc0512/nbmath/releases/download/v0.1.7/nbmath-0.1.7-py3-none-any.whl
19
+ pip install https://ghproxy.net/https://github.com/tc0512/nbmath/releases/download/v0.2.0/nbmath-0.2.0-py3-none-any.whl
20
20
  ```
21
21
 
22
22
  ## 快速开始
@@ -6,10 +6,15 @@ nbmath/const.py
6
6
  nbmath/equation.py
7
7
  nbmath/geometry.py
8
8
  nbmath/optimize.py
9
- nbmath/plots.py
10
9
  nbmath/stats.py
11
10
  nbmath/utils.py
12
11
  nbmath.egg-info/PKG-INFO
13
12
  nbmath.egg-info/SOURCES.txt
14
13
  nbmath.egg-info/dependency_links.txt
15
- nbmath.egg-info/top_level.txt
14
+ nbmath.egg-info/top_level.txt
15
+ nbmath/plots/__init__.py
16
+ nbmath/plots/core.py
17
+ nbmath/plots/examples/__init__.py
18
+ nbmath/plots/examples/heart.py
19
+ nbmath/plots/examples/lissajous.py
20
+ 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.0"
7
+ version = "0.2.3"
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