MingMath
MingMath is a Python package for undergraduate mathematics and mathematical computing.
Installation
pip install mingmath
import mingmath
1. String Processing
ใช้สำหรับจัดการข้อความ เช่น การกลับข้อความและการนับจำนวนสระ
print(mingmath.reverse_string("MingMath"))
print(mingmath.count_vowels("MingMath"))
# Output:
# htaMgniM
# 2
2. List
ใช้สำหรับจัดการข้อมูลแบบ List และคำนวณผลรวมของสมาชิก
numbers = [1, 2, 3, 4, 5]
print(mingmath.list_sum(numbers))
# Output:
# 15
3. Tuple
ใช้สำหรับจัดการข้อมูลแบบ Tuple และสามารถแปลง Tuple เป็น List ได้
data = (1, 2, 3)
print(mingmath.tuple_to_list(data))
# Output:
# [1, 2, 3]
4. Dictionary
ใช้สำหรับจัดการข้อมูลแบบ Dictionary ซึ่งเก็บข้อมูลในรูปแบบ key-value
student = {"name": "Ming", "year": 2}
print(mingmath.dictionary_keys(student))
# Output:
# ['name', 'year']
5. Set
ใช้สำหรับจัดการข้อมูลแบบ Set และดำเนินการ Union และ Intersection
a = {1, 2, 3}
b = {3, 4, 5}
print(mingmath.set_union(a, b))
print(mingmath.set_intersection(a, b))
# Output:
# {1, 2, 3, 4, 5}
# {3}
6. Positional Arguments
แสดงการส่งค่าให้ฟังก์ชันตามลำดับของพารามิเตอร์
print(mingmath.positional_arguments(10, 20))
# Output:
# 30
7. Keyword Arguments
แสดงการส่งค่าให้ฟังก์ชันโดยระบุชื่อพารามิเตอร์
print(mingmath.keyword_arguments(name="Ming", age=20))
# Output:
# Ming is 20 years old.
8. Default Arguments
ใช้ค่าเริ่มต้นของพารามิเตอร์เมื่อผู้ใช้ไม่ได้กำหนดค่าเอง
print(mingmath.default_arguments(5))
print(mingmath.default_arguments(5, 3))
# Output:
# 25
# 125
9. Variable-length Arguments
ใช้สำหรับรับจำนวนอาร์กิวเมนต์ได้หลายค่าในฟังก์ชันเดียว
print(mingmath.variable_length_args(1, 2, 3, 4, 5))
# Output:
# 15
10. Recursive Function
ใช้ฟังก์ชันเรียกตัวเองเพื่อแก้ปัญหา เช่น Factorial และ Fibonacci
print(mingmath.factorial_recursive(5))
print(mingmath.fibonacci_recursive(6))
# Output:
# 120
# 8
11. Memoization
ใช้เก็บผลลัพธ์ที่คำนวณไว้แล้ว เพื่อลดการคำนวณซ้ำใน Recursive Function
print(mingmath.fibonacci_memo(10))
# Output:
# 55
12. Algorithm Comparison
เปรียบเทียบการหาเส้นทางสั้นที่สุดด้วย BFS สำหรับกราฟไม่มีน้ำหนัก และ Dijkstra สำหรับกราฟที่มีน้ำหนัก
edges = [
("A", "B"),
("B", "C"),
("A", "C")
]
print(mingmath.shortest_path_bfs(edges, "A", "C"))
# Output:
# ['A', 'C']
weighted_edges = [
("A", "B", 4),
("B", "C", 2),
("A", "C", 10)
]
print(mingmath.shortest_path_dijkstra(
weighted_edges, "A", "C"
))
# Output:
# ['A', 'B', 'C']
13. Class
ใช้ Class และ Object เพื่อสร้างโครงสร้างข้อมูลสำหรับตัวเลข
number = mingmath.Number(10)
print(number.value)
print(number)
# Output:
# 10
# Number(10)
14. Magic Methods
ใช้ Magic Methods เช่น __add__ เพื่อกำหนดพฤติกรรมของ Object เมื่อใช้เครื่องหมาย +
a = mingmath.Number(10)
b = mingmath.Number(5)
print(a + b)
# Output:
# Number(15)
15. Inheritance
แสดงการสืบทอดคุณสมบัติจาก Class แม่ไปยัง Class ลูก
number = mingmath.PositiveNumber(10)
print(number.value)
print(number.is_positive())
# Output:
# 10
# True
MingMath also demonstrates multiple, multilevel, hierarchical, and hybrid inheritance.
16. File I/O
ใช้สำหรับเขียนและอ่านข้อมูลจากไฟล์ข้อความ
mingmath.write_text_file(
"example.txt",
"Hello MingMath!"
)
print(mingmath.read_text_file("example.txt"))
# Output:
# Hello MingMath!
17. Exception Handling
ใช้จัดการข้อผิดพลาดที่อาจเกิดขึ้นระหว่างการทำงานของโปรแกรม
try:
mingmath.factorial_recursive(-1)
except ValueError as error:
print(error)
# Output:
# n must be non-negative
18. NumPy
ใช้ NumPy สำหรับการคำนวณข้อมูลเชิงตัวเลข
numbers = [1, 2, 3, 4, 5]
print(mingmath.numpy_mean(numbers))
# Output:
# 3.0
19. Pandas
ใช้ Pandas สำหรับสร้างและจัดการข้อมูลในรูปแบบ DataFrame
data = {
"score": [80, 90, 70],
"age": [19, 20, 19]
}
df = mingmath.create_dataframe(data)
print(df)
# Output:
# score age
# 0 80 19
# 1 90 20
# 2 70 19
20. SciPy
ใช้ SciPy สำหรับการคำนวณทางวิทยาศาสตร์และคณิตศาสตร์
print(mingmath.scipy_mean([1, 2, 3, 4, 5]))
# Output:
# 3.0
21. SymPy
ใช้ SymPy สำหรับการคำนวณทางคณิตศาสตร์เชิงสัญลักษณ์ เช่น การหาอนุพันธ์
print(mingmath.sympy_derivative("x**3 + 2*x"))
# Output:
# 3*x**2 + 2
22. SageMath
ใช้ตรวจสอบและเรียกใช้งานความสามารถของ SageMath
print(mingmath.sage_available())
# Output:
# True
SageMath must be installed separately.
23. PARI/GP
ใช้ PARI/GP สำหรับการคำนวณทางทฤษฎีจำนวน เช่น Factorial และ GCD
print(mingmath.pari_factorial(5))
print(mingmath.pari_gcd(24, 18))
# Output:
# 120
# 6
24. GMPY2
ใช้ GMPY2 สำหรับการคำนวณจำนวนเต็มและเลขความแม่นยำสูง
print(mingmath.high_precision_factorial(10))
# Output:
# 3628800
25. Matplotlib
ใช้ Matplotlib สำหรับสร้างกราฟทางคณิตศาสตร์
x = [1, 2, 3, 4]
y = [1, 4, 9, 16]
mingmath.plot_line(x, y)
# Output:
# Creates a line graph.
26. Seaborn
ใช้ Seaborn สำหรับสร้างกราฟและแสดงความสัมพันธ์ของข้อมูล
x = [1, 2, 3, 4]
y = [2, 4, 3, 5]
mingmath.plot_scatter(x, y)
# Output:
# Creates a scatter plot.
27. Plotly
ใช้ Plotly สำหรับสร้างกราฟแบบ Interactive
x = ["A", "B", "C"]
y = [10, 20, 15]
mingmath.plot_bar(x, y)
# Output:
# Creates an interactive bar chart.
28. NetworkX
ใช้ NetworkX สำหรับสร้างและวิเคราะห์กราฟและเครือข่าย
edges = [
("A", "B"),
("B", "C")
]
graph = mingmath.create_graph(edges)
print(mingmath.graph_degrees(edges))
# Output:
# {'A': 1, 'B': 2, 'C': 1}
29. PyVista
ใช้ PyVista สำหรับสร้างและแสดงผลข้อมูลสามมิติ
import numpy as np
x = np.linspace(-2, 2, 10)
y = np.linspace(-2, 2, 10)
X, Y = np.meshgrid(x, y)
Z = X**2 + Y**2
mingmath.show_3d_surface(X, Y, Z)
# Output:
# Creates a 3D mathematical surface.
Version
0.4.1
License
MIT License
Metadata
Release files for mingmath 0.4.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| mingmath-0.4.1.tar.gz | 9.6 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| mingmath-0.4.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 22.9 kB
Release files / mingmath-0.4.1.tar.gz
| Download URL | mingmath-0.4.1.tar.gz |
|---|---|
| Size | 9.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
11c1f11908b279f16b4413dfe0f98d2e1472f13ef51761952db4cc75f222d7df
|
|
BLAKE2b-256 checksum How to use checksums |
bc61c229d25709f922d678b3cca7d759c3bbe6582d3b88ae39c0f4b5ddadc6fc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|
Release files / mingmath-0.4.1-py3-none-any.whl
| Download URL | mingmath-0.4.1-py3-none-any.whl |
|---|---|
| Size | 13.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
aad726c521b0deecc4cc524a43a8a4eee4fdc8173962ee5deed13a229f563782
|
|
BLAKE2b-256 checksum How to use checksums |
80cc92f3eac91a164198fec6fef05df9620639e22ad8863ed5c612b872cab639
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|