math4u 0.2.2__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.5
2
2
  Name: math4u
3
- Version: 0.2.2
3
+ Version: 0.2.3
4
4
  Summary: Python Package สำหรับการคำนวณและเครื่องมือทางคณิตศาสตร์
5
5
  Project-URL: Homepage, https://github.com/username/my_package
6
6
  Project-URL: Documentation, https://github.com/username/my_package#readme
@@ -9,7 +9,7 @@ Project-URL: Bug Tracker, https://github.com/username/my_package/issues
9
9
  Author-email: Bunyasak Rakjing <boonyasuk1213@gmail.com>
10
10
  License: MIT
11
11
  License-File: LICENSE
12
- Keywords: calculus,linear-algebra,mathematics,numpy,scipy,sympy
12
+ Keywords: calculus,linear-algebra,mathematics,networkx,numpy,plotly,pyvista,scipy,seaborn,sympy
13
13
  Classifier: Development Status :: 3 - Alpha
14
14
  Classifier: Intended Audience :: Developers
15
15
  Classifier: License :: OSI Approved :: MIT License
@@ -20,11 +20,17 @@ Classifier: Programming Language :: Python :: 3.10
20
20
  Classifier: Programming Language :: Python :: 3.11
21
21
  Classifier: Programming Language :: Python :: 3.12
22
22
  Requires-Python: >=3.8
23
+ Requires-Dist: gmpy2
23
24
  Requires-Dist: matplotlib
24
25
  Requires-Dist: networkx
25
26
  Requires-Dist: numpy
27
+ Requires-Dist: plotly
28
+ Requires-Dist: pyvista
26
29
  Requires-Dist: scipy
30
+ Requires-Dist: seaborn
27
31
  Requires-Dist: sympy
32
+ Provides-Extra: pari
33
+ Requires-Dist: cypari2; extra == 'pari'
28
34
  Description-Content-Type: text/markdown
29
35
 
30
36
  # math4u
@@ -40,27 +46,21 @@ import math4u
40
46
  # Calculus
41
47
  # =========================
42
48
 
43
- # 1. Derivative
44
49
  print(math4u.derivative("x**3 + 2*x"))
45
50
  # 3*x**2 + 2
46
51
 
47
- # 2. Second Derivative
48
52
  print(math4u.second_derivative("x**3 + 2*x"))
49
53
  # 6*x
50
54
 
51
- # 3. Indefinite Integral
52
55
  print(math4u.integrate("x**2 + 2*x"))
53
56
  # x**3/3 + x**2
54
57
 
55
- # 4. Definite Integral
56
58
  print(math4u.definite_integral("x**2", 0, 2))
57
59
  # 8/3
58
60
 
59
- # 5. Limit
60
61
  print(math4u.limit("sin(x)/x", point=0))
61
62
  # 1
62
63
 
63
- # 6. Taylor Series
64
64
  print(math4u.taylor_series("exp(x)", point=0, order=5))
65
65
  # x**4/24 + x**3/6 + x**2/2 + x + 1
66
66
 
@@ -72,27 +72,21 @@ print(math4u.taylor_series("exp(x)", point=0, order=5))
72
72
  A = [[1, 2], [3, 4]]
73
73
  B = [[5, 6], [7, 8]]
74
74
 
75
- # 1. Matrix Addition
76
75
  print(math4u.matrix_add(A, B))
77
76
  # Matrix([[6, 8], [10, 12]])
78
77
 
79
- # 2. Matrix Multiplication
80
78
  print(math4u.matrix_multiply(A, B))
81
79
  # Matrix([[19, 22], [43, 50]])
82
80
 
83
- # 3. Determinant
84
81
  print(math4u.determinant(A))
85
82
  # -2
86
83
 
87
- # 4. Inverse Matrix
88
84
  print(math4u.inverse_matrix(A))
89
85
  # Matrix([[-2, 1], [3/2, -1/2]])
90
86
 
91
- # 5. Transpose
92
87
  print(math4u.transpose(A))
93
88
  # Matrix([[1, 3], [2, 4]])
94
89
 
95
- # 6. Solve Linear System
96
90
  print(math4u.solve_linear_system(
97
91
  [[2, 1], [1, -1]],
98
92
  [5, 1]
@@ -104,27 +98,21 @@ print(math4u.solve_linear_system(
104
98
  # String Processing
105
99
  # =========================
106
100
 
107
- # 1. Reverse String
108
101
  print(math4u.reverse_string("Hello"))
109
102
  # olleH
110
103
 
111
- # 2. Count Words
112
104
  print(math4u.count_words("Hello Python World"))
113
105
  # 3
114
106
 
115
- # 3. Count Characters
116
107
  print(math4u.count_characters("Hello"))
117
108
  # 5
118
109
 
119
- # 4. Uppercase
120
110
  print(math4u.to_uppercase("hello"))
121
111
  # HELLO
122
112
 
123
- # 5. Lowercase
124
113
  print(math4u.to_lowercase("HELLO"))
125
114
  # hello
126
115
 
127
- # 6. Remove Spaces
128
116
  print(math4u.remove_spaces("Hello World"))
129
117
  # HelloWorld
130
118
 
@@ -133,28 +121,22 @@ print(math4u.remove_spaces("Hello World"))
133
121
  # Data Structures
134
122
  # =========================
135
123
 
136
- # List
137
124
  print(math4u.list_operations([10, 20, 30]))
138
125
 
139
- # Tuple
140
126
  print(math4u.tuple_operations((1, 2, 3)))
141
127
 
142
- # Dictionary Keys
143
128
  print(math4u.dictionary_keys({
144
129
  "a": 1,
145
130
  "b": 2
146
131
  }))
147
132
 
148
- # Dictionary Values
149
133
  print(math4u.dictionary_values({
150
134
  "a": 1,
151
135
  "b": 2
152
136
  }))
153
137
 
154
- # Set Union
155
138
  print(math4u.set_union({1, 2}, {2, 3}))
156
139
 
157
- # Set Intersection
158
140
  print(math4u.set_intersection({1, 2}, {2, 3}))
159
141
 
160
142
 
@@ -162,23 +144,18 @@ print(math4u.set_intersection({1, 2}, {2, 3}))
162
144
  # Recursive Functions
163
145
  # =========================
164
146
 
165
- # Factorial
166
147
  print(math4u.factorial(5))
167
148
  # 120
168
149
 
169
- # Fibonacci
170
150
  print(math4u.fibonacci(6))
171
151
  # 8
172
152
 
173
- # Power
174
153
  print(math4u.power_recursive(2, 5))
175
154
  # 32
176
155
 
177
- # Recursive Sum
178
156
  print(math4u.sum_recursive([1, 2, 3, 4]))
179
157
  # 10
180
158
 
181
- # Greatest Common Divisor
182
159
  print(math4u.gcd_recursive(48, 18))
183
160
  # 6
184
161
 
@@ -195,32 +172,26 @@ print(math4u.fibonacci_memo(10))
195
172
  # Object-Oriented Programming
196
173
  # =========================
197
174
 
198
- # Calculator
199
175
  calc = math4u.Calculator(10)
200
176
  print(calc.add(5))
201
177
  # 15
202
178
 
203
- # Single Inheritance
204
179
  scientific = math4u.ScientificCalculator(4)
205
180
  print(scientific.square())
206
181
  # 16
207
182
 
208
- # Multiple Inheritance
209
183
  advanced = math4u.AdvancedCalculator(3)
210
184
  print(advanced.cube())
211
185
  # 27
212
186
 
213
- # Multilevel Inheritance
214
187
  special = math4u.SpecialCalculator(2)
215
188
  print(special.fourth_power())
216
189
  # 16
217
190
 
218
- # Hierarchical Inheritance
219
191
  basic = math4u.BasicCalculator(5)
220
192
  print(basic.double())
221
193
  # 10
222
194
 
223
- # Hybrid Inheritance
224
195
  hybrid = math4u.HybridCalculator(2)
225
196
  print(hybrid.fifth_power())
226
197
  # 32
@@ -230,29 +201,24 @@ print(hybrid.fifth_power())
230
201
  # Exception Handling
231
202
  # =========================
232
203
 
233
- # Safe Division
234
204
  print(math4u.safe_divide(10, 2))
235
205
  # 5.0
236
206
 
237
207
  print(math4u.safe_divide(10, 0))
238
208
  # None
239
209
 
240
- # Safe Square Root
241
210
  print(math4u.safe_square_root(16))
242
211
  # 4.0
243
212
 
244
213
  print(math4u.safe_square_root(-1))
245
214
  # None
246
215
 
247
- # Validate Number
248
216
  print(math4u.validate_number("25"))
249
217
  # 25.0
250
218
 
251
- # Get List Item
252
219
  print(math4u.get_list_item([10, 20, 30], 1))
253
220
  # 20
254
221
 
255
- # Get Dictionary Value
256
222
  print(math4u.get_dictionary_value(
257
223
  {"name": "Math"},
258
224
  "name"
@@ -264,24 +230,19 @@ print(math4u.get_dictionary_value(
264
230
  # NumPy
265
231
  # =========================
266
232
 
267
- # Create Array
268
233
  print(math4u.create_array([1, 2, 3]))
269
234
 
270
- # Mean
271
235
  print(math4u.array_mean([1, 2, 3, 4]))
272
236
  # 2.5
273
237
 
274
- # Sum
275
238
  print(math4u.array_sum([1, 2, 3, 4]))
276
239
  # 10
277
240
 
278
- # Matrix Multiplication
279
241
  print(math4u.matrix_multiply_numpy(
280
242
  [[1, 2], [3, 4]],
281
243
  [[5, 6], [7, 8]]
282
244
  ))
283
245
 
284
- # Statistics
285
246
  print(math4u.array_statistics([1, 2, 3, 4, 5]))
286
247
 
287
248
 
@@ -293,19 +254,16 @@ import sympy as sp
293
254
 
294
255
  x = sp.Symbol("x")
295
256
 
296
- # Symbolic Simplify
297
257
  print(math4u.symbolic_simplify(
298
258
  (x**2 - 1) / (x - 1)
299
259
  ))
300
260
  # x + 1
301
261
 
302
- # Symbolic Expand
303
262
  print(math4u.symbolic_expand(
304
263
  (x + 1)**2
305
264
  ))
306
265
  # x**2 + 2*x + 1
307
266
 
308
- # Numerical Integral
309
267
  print(math4u.numerical_integral(
310
268
  lambda x: x**2,
311
269
  0,
@@ -314,6 +272,26 @@ print(math4u.numerical_integral(
314
272
  # 0.333333...
315
273
 
316
274
 
275
+ # =========================
276
+ # File I/O
277
+ # =========================
278
+
279
+ math4u.write_text(
280
+ "example.txt",
281
+ "Hello math4u"
282
+ )
283
+
284
+ print(math4u.read_text("example.txt"))
285
+ # Hello math4u
286
+
287
+ math4u.append_text(
288
+ "example.txt",
289
+ "\nPython Package"
290
+ )
291
+
292
+ print(math4u.read_lines("example.txt"))
293
+
294
+
317
295
  # =========================
318
296
  # Matplotlib
319
297
  # =========================
@@ -324,6 +302,26 @@ y = [1, 4, 9, 16]
324
302
  math4u.visualization.plot_function(x, y)
325
303
 
326
304
 
305
+ # =========================
306
+ # Seaborn
307
+ # =========================
308
+
309
+ math4u.seaborn_tools.plot_line(
310
+ [1, 2, 3, 4],
311
+ [1, 4, 9, 16]
312
+ )
313
+
314
+
315
+ # =========================
316
+ # Plotly
317
+ # =========================
318
+
319
+ math4u.plotly_tools.plot_bar(
320
+ ["A", "B", "C"],
321
+ [10, 20, 15]
322
+ )
323
+
324
+
327
325
  # =========================
328
326
  # NetworkX
329
327
  # =========================
@@ -336,4 +334,40 @@ edges = [
336
334
 
337
335
  graph = math4u.visualization.create_graph(edges)
338
336
 
339
- math4u.visualization.draw_graph(edges)
337
+ math4u.visualization.draw_graph(edges)
338
+
339
+
340
+ # =========================
341
+ # PyVista
342
+ # =========================
343
+
344
+ sphere = math4u.pyvista_tools.create_sphere(
345
+ radius=1
346
+ )
347
+
348
+ # Display the 3D object
349
+ # math4u.pyvista_tools.show_mesh(sphere)
350
+
351
+
352
+ # =========================
353
+ # GMPY2
354
+ # =========================
355
+
356
+ print(math4u.gmpy2_tools.big_integer(123456789))
357
+
358
+ print(math4u.gmpy2_tools.gmpy2_gcd(48, 18))
359
+ # 6
360
+
361
+
362
+ # =========================
363
+ # SageMath
364
+ # =========================
365
+
366
+ print(math4u.sage_tools.sage_available())
367
+
368
+
369
+ # =========================
370
+ # PARI/GP
371
+ # =========================
372
+
373
+ print(math4u.pari_tools.pari_available())
@@ -11,27 +11,21 @@ import math4u
11
11
  # Calculus
12
12
  # =========================
13
13
 
14
- # 1. Derivative
15
14
  print(math4u.derivative("x**3 + 2*x"))
16
15
  # 3*x**2 + 2
17
16
 
18
- # 2. Second Derivative
19
17
  print(math4u.second_derivative("x**3 + 2*x"))
20
18
  # 6*x
21
19
 
22
- # 3. Indefinite Integral
23
20
  print(math4u.integrate("x**2 + 2*x"))
24
21
  # x**3/3 + x**2
25
22
 
26
- # 4. Definite Integral
27
23
  print(math4u.definite_integral("x**2", 0, 2))
28
24
  # 8/3
29
25
 
30
- # 5. Limit
31
26
  print(math4u.limit("sin(x)/x", point=0))
32
27
  # 1
33
28
 
34
- # 6. Taylor Series
35
29
  print(math4u.taylor_series("exp(x)", point=0, order=5))
36
30
  # x**4/24 + x**3/6 + x**2/2 + x + 1
37
31
 
@@ -43,27 +37,21 @@ print(math4u.taylor_series("exp(x)", point=0, order=5))
43
37
  A = [[1, 2], [3, 4]]
44
38
  B = [[5, 6], [7, 8]]
45
39
 
46
- # 1. Matrix Addition
47
40
  print(math4u.matrix_add(A, B))
48
41
  # Matrix([[6, 8], [10, 12]])
49
42
 
50
- # 2. Matrix Multiplication
51
43
  print(math4u.matrix_multiply(A, B))
52
44
  # Matrix([[19, 22], [43, 50]])
53
45
 
54
- # 3. Determinant
55
46
  print(math4u.determinant(A))
56
47
  # -2
57
48
 
58
- # 4. Inverse Matrix
59
49
  print(math4u.inverse_matrix(A))
60
50
  # Matrix([[-2, 1], [3/2, -1/2]])
61
51
 
62
- # 5. Transpose
63
52
  print(math4u.transpose(A))
64
53
  # Matrix([[1, 3], [2, 4]])
65
54
 
66
- # 6. Solve Linear System
67
55
  print(math4u.solve_linear_system(
68
56
  [[2, 1], [1, -1]],
69
57
  [5, 1]
@@ -75,27 +63,21 @@ print(math4u.solve_linear_system(
75
63
  # String Processing
76
64
  # =========================
77
65
 
78
- # 1. Reverse String
79
66
  print(math4u.reverse_string("Hello"))
80
67
  # olleH
81
68
 
82
- # 2. Count Words
83
69
  print(math4u.count_words("Hello Python World"))
84
70
  # 3
85
71
 
86
- # 3. Count Characters
87
72
  print(math4u.count_characters("Hello"))
88
73
  # 5
89
74
 
90
- # 4. Uppercase
91
75
  print(math4u.to_uppercase("hello"))
92
76
  # HELLO
93
77
 
94
- # 5. Lowercase
95
78
  print(math4u.to_lowercase("HELLO"))
96
79
  # hello
97
80
 
98
- # 6. Remove Spaces
99
81
  print(math4u.remove_spaces("Hello World"))
100
82
  # HelloWorld
101
83
 
@@ -104,28 +86,22 @@ print(math4u.remove_spaces("Hello World"))
104
86
  # Data Structures
105
87
  # =========================
106
88
 
107
- # List
108
89
  print(math4u.list_operations([10, 20, 30]))
109
90
 
110
- # Tuple
111
91
  print(math4u.tuple_operations((1, 2, 3)))
112
92
 
113
- # Dictionary Keys
114
93
  print(math4u.dictionary_keys({
115
94
  "a": 1,
116
95
  "b": 2
117
96
  }))
118
97
 
119
- # Dictionary Values
120
98
  print(math4u.dictionary_values({
121
99
  "a": 1,
122
100
  "b": 2
123
101
  }))
124
102
 
125
- # Set Union
126
103
  print(math4u.set_union({1, 2}, {2, 3}))
127
104
 
128
- # Set Intersection
129
105
  print(math4u.set_intersection({1, 2}, {2, 3}))
130
106
 
131
107
 
@@ -133,23 +109,18 @@ print(math4u.set_intersection({1, 2}, {2, 3}))
133
109
  # Recursive Functions
134
110
  # =========================
135
111
 
136
- # Factorial
137
112
  print(math4u.factorial(5))
138
113
  # 120
139
114
 
140
- # Fibonacci
141
115
  print(math4u.fibonacci(6))
142
116
  # 8
143
117
 
144
- # Power
145
118
  print(math4u.power_recursive(2, 5))
146
119
  # 32
147
120
 
148
- # Recursive Sum
149
121
  print(math4u.sum_recursive([1, 2, 3, 4]))
150
122
  # 10
151
123
 
152
- # Greatest Common Divisor
153
124
  print(math4u.gcd_recursive(48, 18))
154
125
  # 6
155
126
 
@@ -166,32 +137,26 @@ print(math4u.fibonacci_memo(10))
166
137
  # Object-Oriented Programming
167
138
  # =========================
168
139
 
169
- # Calculator
170
140
  calc = math4u.Calculator(10)
171
141
  print(calc.add(5))
172
142
  # 15
173
143
 
174
- # Single Inheritance
175
144
  scientific = math4u.ScientificCalculator(4)
176
145
  print(scientific.square())
177
146
  # 16
178
147
 
179
- # Multiple Inheritance
180
148
  advanced = math4u.AdvancedCalculator(3)
181
149
  print(advanced.cube())
182
150
  # 27
183
151
 
184
- # Multilevel Inheritance
185
152
  special = math4u.SpecialCalculator(2)
186
153
  print(special.fourth_power())
187
154
  # 16
188
155
 
189
- # Hierarchical Inheritance
190
156
  basic = math4u.BasicCalculator(5)
191
157
  print(basic.double())
192
158
  # 10
193
159
 
194
- # Hybrid Inheritance
195
160
  hybrid = math4u.HybridCalculator(2)
196
161
  print(hybrid.fifth_power())
197
162
  # 32
@@ -201,29 +166,24 @@ print(hybrid.fifth_power())
201
166
  # Exception Handling
202
167
  # =========================
203
168
 
204
- # Safe Division
205
169
  print(math4u.safe_divide(10, 2))
206
170
  # 5.0
207
171
 
208
172
  print(math4u.safe_divide(10, 0))
209
173
  # None
210
174
 
211
- # Safe Square Root
212
175
  print(math4u.safe_square_root(16))
213
176
  # 4.0
214
177
 
215
178
  print(math4u.safe_square_root(-1))
216
179
  # None
217
180
 
218
- # Validate Number
219
181
  print(math4u.validate_number("25"))
220
182
  # 25.0
221
183
 
222
- # Get List Item
223
184
  print(math4u.get_list_item([10, 20, 30], 1))
224
185
  # 20
225
186
 
226
- # Get Dictionary Value
227
187
  print(math4u.get_dictionary_value(
228
188
  {"name": "Math"},
229
189
  "name"
@@ -235,24 +195,19 @@ print(math4u.get_dictionary_value(
235
195
  # NumPy
236
196
  # =========================
237
197
 
238
- # Create Array
239
198
  print(math4u.create_array([1, 2, 3]))
240
199
 
241
- # Mean
242
200
  print(math4u.array_mean([1, 2, 3, 4]))
243
201
  # 2.5
244
202
 
245
- # Sum
246
203
  print(math4u.array_sum([1, 2, 3, 4]))
247
204
  # 10
248
205
 
249
- # Matrix Multiplication
250
206
  print(math4u.matrix_multiply_numpy(
251
207
  [[1, 2], [3, 4]],
252
208
  [[5, 6], [7, 8]]
253
209
  ))
254
210
 
255
- # Statistics
256
211
  print(math4u.array_statistics([1, 2, 3, 4, 5]))
257
212
 
258
213
 
@@ -264,19 +219,16 @@ import sympy as sp
264
219
 
265
220
  x = sp.Symbol("x")
266
221
 
267
- # Symbolic Simplify
268
222
  print(math4u.symbolic_simplify(
269
223
  (x**2 - 1) / (x - 1)
270
224
  ))
271
225
  # x + 1
272
226
 
273
- # Symbolic Expand
274
227
  print(math4u.symbolic_expand(
275
228
  (x + 1)**2
276
229
  ))
277
230
  # x**2 + 2*x + 1
278
231
 
279
- # Numerical Integral
280
232
  print(math4u.numerical_integral(
281
233
  lambda x: x**2,
282
234
  0,
@@ -285,6 +237,26 @@ print(math4u.numerical_integral(
285
237
  # 0.333333...
286
238
 
287
239
 
240
+ # =========================
241
+ # File I/O
242
+ # =========================
243
+
244
+ math4u.write_text(
245
+ "example.txt",
246
+ "Hello math4u"
247
+ )
248
+
249
+ print(math4u.read_text("example.txt"))
250
+ # Hello math4u
251
+
252
+ math4u.append_text(
253
+ "example.txt",
254
+ "\nPython Package"
255
+ )
256
+
257
+ print(math4u.read_lines("example.txt"))
258
+
259
+
288
260
  # =========================
289
261
  # Matplotlib
290
262
  # =========================
@@ -295,6 +267,26 @@ y = [1, 4, 9, 16]
295
267
  math4u.visualization.plot_function(x, y)
296
268
 
297
269
 
270
+ # =========================
271
+ # Seaborn
272
+ # =========================
273
+
274
+ math4u.seaborn_tools.plot_line(
275
+ [1, 2, 3, 4],
276
+ [1, 4, 9, 16]
277
+ )
278
+
279
+
280
+ # =========================
281
+ # Plotly
282
+ # =========================
283
+
284
+ math4u.plotly_tools.plot_bar(
285
+ ["A", "B", "C"],
286
+ [10, 20, 15]
287
+ )
288
+
289
+
298
290
  # =========================
299
291
  # NetworkX
300
292
  # =========================
@@ -307,4 +299,40 @@ edges = [
307
299
 
308
300
  graph = math4u.visualization.create_graph(edges)
309
301
 
310
- math4u.visualization.draw_graph(edges)
302
+ math4u.visualization.draw_graph(edges)
303
+
304
+
305
+ # =========================
306
+ # PyVista
307
+ # =========================
308
+
309
+ sphere = math4u.pyvista_tools.create_sphere(
310
+ radius=1
311
+ )
312
+
313
+ # Display the 3D object
314
+ # math4u.pyvista_tools.show_mesh(sphere)
315
+
316
+
317
+ # =========================
318
+ # GMPY2
319
+ # =========================
320
+
321
+ print(math4u.gmpy2_tools.big_integer(123456789))
322
+
323
+ print(math4u.gmpy2_tools.gmpy2_gcd(48, 18))
324
+ # 6
325
+
326
+
327
+ # =========================
328
+ # SageMath
329
+ # =========================
330
+
331
+ print(math4u.sage_tools.sage_available())
332
+
333
+
334
+ # =========================
335
+ # PARI/GP
336
+ # =========================
337
+
338
+ print(math4u.pari_tools.pari_available())
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "math4u"
7
- version = "0.2.2"
7
+ version = "0.2.3"
8
8
  description = "Python Package สำหรับการคำนวณและเครื่องมือทางคณิตศาสตร์"
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.8"
@@ -21,6 +21,10 @@ keywords = [
21
21
  "numpy",
22
22
  "scipy",
23
23
  "sympy",
24
+ "seaborn",
25
+ "plotly",
26
+ "pyvista",
27
+ "networkx",
24
28
  ]
25
29
 
26
30
  classifiers = [
@@ -41,10 +45,22 @@ dependencies = [
41
45
  "scipy",
42
46
  "matplotlib",
43
47
  "networkx",
48
+ "seaborn",
49
+ "plotly",
50
+ "pyvista",
51
+ "gmpy2",
52
+ ]
53
+
54
+ [project.optional-dependencies]
55
+ pari = [
56
+ "cypari2",
44
57
  ]
45
58
 
46
59
  [project.urls]
47
60
  Homepage = "https://github.com/username/my_package"
48
61
  Documentation = "https://github.com/username/my_package#readme"
49
62
  Repository = "https://github.com/username/my_package.git"
50
- "Bug Tracker" = "https://github.com/username/my_package/issues"
63
+ "Bug Tracker" = "https://github.com/username/my_package/issues"
64
+
65
+ [tool.hatch.build.targets.wheel]
66
+ packages = ["src/math4u"]
@@ -0,0 +1,109 @@
1
+ """
2
+ math4u - Calculus, Linear Algebra and Mathematical Tools
3
+ """
4
+
5
+ from .calculus import (
6
+ derivative, second_derivative, integrate,
7
+ definite_integral, limit, taylor_series
8
+ )
9
+
10
+ from .linear_algebra import (
11
+ matrix_add, matrix_multiply, determinant,
12
+ inverse_matrix, transpose, solve_linear_system
13
+ )
14
+
15
+ from .string_processing import (
16
+ reverse_string, count_words, count_characters,
17
+ to_uppercase, to_lowercase, remove_spaces
18
+ )
19
+
20
+ from .data_structures import (
21
+ list_operations, tuple_operations,
22
+ dictionary_keys, dictionary_values,
23
+ set_union, set_intersection
24
+ )
25
+
26
+ from .recursion import (
27
+ factorial, fibonacci, fibonacci_memo,
28
+ power_recursive, sum_recursive, gcd_recursive
29
+ )
30
+
31
+ from .oop import (
32
+ Calculator, ScientificCalculator,
33
+ AdvancedCalculator, SpecialCalculator,
34
+ BasicCalculator, HybridCalculator
35
+ )
36
+
37
+ from .exceptions import (
38
+ safe_divide, safe_square_root,
39
+ validate_number, get_list_item,
40
+ get_dictionary_value
41
+ )
42
+
43
+ from .numerical import (
44
+ create_array, array_mean, array_sum,
45
+ matrix_multiply_numpy, array_statistics
46
+ )
47
+
48
+ from .scipy_tools import (
49
+ symbolic_simplify, symbolic_expand,
50
+ numerical_integral
51
+ )
52
+
53
+ from .file_io import (
54
+ write_text, read_text,
55
+ append_text, write_lines, read_lines
56
+ )
57
+
58
+ from . import visualization
59
+ from . import seaborn_tools
60
+ from . import plotly_tools
61
+ from . import pyvista_tools
62
+ from . import sage_tools
63
+ from . import pari_tools
64
+ from . import gmpy2_tools
65
+
66
+ __version__ = "0.2.3"
67
+
68
+ __all__ = [
69
+ "derivative", "second_derivative", "integrate",
70
+ "definite_integral", "limit", "taylor_series",
71
+
72
+ "matrix_add", "matrix_multiply", "determinant",
73
+ "inverse_matrix", "transpose", "solve_linear_system",
74
+
75
+ "reverse_string", "count_words", "count_characters",
76
+ "to_uppercase", "to_lowercase", "remove_spaces",
77
+
78
+ "list_operations", "tuple_operations",
79
+ "dictionary_keys", "dictionary_values",
80
+ "set_union", "set_intersection",
81
+
82
+ "factorial", "fibonacci", "fibonacci_memo",
83
+ "power_recursive", "sum_recursive", "gcd_recursive",
84
+
85
+ "Calculator", "ScientificCalculator",
86
+ "AdvancedCalculator", "SpecialCalculator",
87
+ "BasicCalculator", "HybridCalculator",
88
+
89
+ "safe_divide", "safe_square_root",
90
+ "validate_number", "get_list_item",
91
+ "get_dictionary_value",
92
+
93
+ "create_array", "array_mean", "array_sum",
94
+ "matrix_multiply_numpy", "array_statistics",
95
+
96
+ "symbolic_simplify", "symbolic_expand",
97
+ "numerical_integral",
98
+
99
+ "write_text", "read_text",
100
+ "append_text", "write_lines", "read_lines",
101
+
102
+ "visualization",
103
+ "seaborn_tools",
104
+ "plotly_tools",
105
+ "pyvista_tools",
106
+ "sage_tools",
107
+ "pari_tools",
108
+ "gmpy2_tools",
109
+ ]
@@ -0,0 +1,28 @@
1
+ def write_text(filename, text):
2
+ """Write text to a file."""
3
+ with open(filename, "w", encoding="utf-8") as file:
4
+ file.write(text)
5
+
6
+
7
+ def read_text(filename):
8
+ """Read text from a file."""
9
+ with open(filename, "r", encoding="utf-8") as file:
10
+ return file.read()
11
+
12
+
13
+ def append_text(filename, text):
14
+ """Append text to a file."""
15
+ with open(filename, "a", encoding="utf-8") as file:
16
+ file.write(text)
17
+
18
+
19
+ def write_lines(filename, lines):
20
+ """Write a list of lines to a file."""
21
+ with open(filename, "w", encoding="utf-8") as file:
22
+ file.writelines(lines)
23
+
24
+
25
+ def read_lines(filename):
26
+ """Read all lines from a file."""
27
+ with open(filename, "r", encoding="utf-8") as file:
28
+ return file.readlines()
@@ -0,0 +1,31 @@
1
+ def gmpy2_available():
2
+ """Check whether GMPY2 is available."""
3
+ try:
4
+ import gmpy2
5
+ return True
6
+ except ImportError:
7
+ return False
8
+
9
+
10
+ def big_integer(value):
11
+ """Create a GMPY2 multiple-precision integer."""
12
+ import gmpy2
13
+ return gmpy2.mpz(value)
14
+
15
+
16
+ def big_float(value):
17
+ """Create a GMPY2 multiple-precision floating-point number."""
18
+ import gmpy2
19
+ return gmpy2.mpfr(value)
20
+
21
+
22
+ def gmpy2_gcd(a, b):
23
+ """Calculate GCD using GMPY2."""
24
+ import gmpy2
25
+ return gmpy2.gcd(a, b)
26
+
27
+
28
+ def gmpy2_factorial(n):
29
+ """Calculate factorial using GMPY2."""
30
+ import gmpy2
31
+ return gmpy2.fac(n)
@@ -0,0 +1,38 @@
1
+ import importlib
2
+
3
+
4
+ def pari_available():
5
+ """Check whether PARI/GP is available through cypari2."""
6
+ try:
7
+ importlib.import_module("cypari2")
8
+ return True
9
+ except ImportError:
10
+ return False
11
+
12
+
13
+ def pari_factorial(n):
14
+ """Calculate factorial using PARI/GP."""
15
+ cypari2 = importlib.import_module("cypari2")
16
+ pari = cypari2.Pari()
17
+ return pari(f"factorial({n})")
18
+
19
+
20
+ def pari_gcd(a, b):
21
+ """Calculate GCD using PARI/GP."""
22
+ cypari2 = importlib.import_module("cypari2")
23
+ pari = cypari2.Pari()
24
+ return pari(f"gcd({a}, {b})")
25
+
26
+
27
+ def pari_is_prime(n):
28
+ """Check whether a number is prime using PARI/GP."""
29
+ cypari2 = importlib.import_module("cypari2")
30
+ pari = cypari2.Pari()
31
+ return bool(pari(f"isprime({n})"))
32
+
33
+
34
+ def pari_factor(n):
35
+ """Factor an integer using PARI/GP."""
36
+ cypari2 = importlib.import_module("cypari2")
37
+ pari = cypari2.Pari()
38
+ return pari(f"factor({n})")
@@ -0,0 +1,31 @@
1
+ import plotly.express as px
2
+
3
+
4
+ def plot_line(x, y):
5
+ """Create a line plot using Plotly."""
6
+ fig = px.line(x=x, y=y, title="Plotly Line Plot")
7
+ fig.show()
8
+
9
+
10
+ def plot_scatter(x, y):
11
+ """Create a scatter plot using Plotly."""
12
+ fig = px.scatter(x=x, y=y, title="Plotly Scatter Plot")
13
+ fig.show()
14
+
15
+
16
+ def plot_bar(categories, values):
17
+ """Create a bar chart using Plotly."""
18
+ fig = px.bar(x=categories, y=values, title="Plotly Bar Chart")
19
+ fig.show()
20
+
21
+
22
+ def plot_histogram(data):
23
+ """Create a histogram using Plotly."""
24
+ fig = px.histogram(x=data, title="Plotly Histogram")
25
+ fig.show()
26
+
27
+
28
+ def plot_pie(labels, values):
29
+ """Create a pie chart using Plotly."""
30
+ fig = px.pie(names=labels, values=values, title="Plotly Pie Chart")
31
+ fig.show()
@@ -0,0 +1,38 @@
1
+ import pyvista as pv
2
+
3
+
4
+ def create_sphere(radius=1):
5
+ """Create a sphere using PyVista."""
6
+ return pv.Sphere(radius=radius)
7
+
8
+
9
+ def create_cube(x_length=1, y_length=1, z_length=1):
10
+ """Create a cube using PyVista."""
11
+ return pv.Cube(
12
+ x_length=x_length,
13
+ y_length=y_length,
14
+ z_length=z_length
15
+ )
16
+
17
+
18
+ def create_cylinder(radius=1, height=2):
19
+ """Create a cylinder using PyVista."""
20
+ return pv.Cylinder(
21
+ radius=radius,
22
+ height=height
23
+ )
24
+
25
+
26
+ def create_plane(i_size=1, j_size=1):
27
+ """Create a plane using PyVista."""
28
+ return pv.Plane(
29
+ i_size=i_size,
30
+ j_size=j_size
31
+ )
32
+
33
+
34
+ def show_mesh(mesh):
35
+ """Display a PyVista mesh."""
36
+ plotter = pv.Plotter()
37
+ plotter.add_mesh(mesh)
38
+ plotter.show()
@@ -0,0 +1,34 @@
1
+ import importlib
2
+
3
+
4
+ def sage_available():
5
+ """Check whether SageMath is available."""
6
+ try:
7
+ importlib.import_module("sageall")
8
+ return True
9
+ except ImportError:
10
+ return False
11
+
12
+
13
+ def sage_factorial(n):
14
+ """Calculate factorial using SageMath."""
15
+ sage = importlib.import_module("sageall")
16
+ return sage.factorial(n)
17
+
18
+
19
+ def sage_gcd(a, b):
20
+ """Calculate GCD using SageMath."""
21
+ sage = importlib.import_module("sageall")
22
+ return sage.gcd(a, b)
23
+
24
+
25
+ def sage_prime_check(n):
26
+ """Check whether a number is prime using SageMath."""
27
+ sage = importlib.import_module("sageall")
28
+ return sage.is_prime(n)
29
+
30
+
31
+ def sage_factor(n):
32
+ """Factor an integer using SageMath."""
33
+ sage = importlib.import_module("sageall")
34
+ return sage.factor(n)
@@ -0,0 +1,41 @@
1
+ import seaborn as sns
2
+ import matplotlib.pyplot as plt
3
+
4
+
5
+ def plot_line(x, y):
6
+ """Create a line plot using Seaborn."""
7
+ sns.lineplot(x=x, y=y)
8
+ plt.xlabel("x")
9
+ plt.ylabel("y")
10
+ plt.title("Seaborn Line Plot")
11
+ plt.show()
12
+
13
+
14
+ def plot_scatter(x, y):
15
+ """Create a scatter plot using Seaborn."""
16
+ sns.scatterplot(x=x, y=y)
17
+ plt.xlabel("x")
18
+ plt.ylabel("y")
19
+ plt.title("Seaborn Scatter Plot")
20
+ plt.show()
21
+
22
+
23
+ def plot_histogram(data):
24
+ """Create a histogram using Seaborn."""
25
+ sns.histplot(data, kde=True)
26
+ plt.title("Seaborn Histogram")
27
+ plt.show()
28
+
29
+
30
+ def plot_boxplot(data):
31
+ """Create a box plot using Seaborn."""
32
+ sns.boxplot(y=data)
33
+ plt.title("Seaborn Box Plot")
34
+ plt.show()
35
+
36
+
37
+ def plot_heatmap(data):
38
+ """Create a heatmap using Seaborn."""
39
+ sns.heatmap(data, annot=True)
40
+ plt.title("Seaborn Heatmap")
41
+ plt.show()
Binary file
@@ -1,157 +0,0 @@
1
- """
2
- math4u - Calculus, Linear Algebra and Mathematical Tools
3
- """
4
-
5
- from .calculus import (
6
- derivative,
7
- second_derivative,
8
- integrate,
9
- definite_integral,
10
- limit,
11
- taylor_series,
12
- )
13
-
14
- from .linear_algebra import (
15
- matrix_add,
16
- matrix_multiply,
17
- determinant,
18
- inverse_matrix,
19
- transpose,
20
- solve_linear_system,
21
- )
22
-
23
- from .string_processing import (
24
- reverse_string,
25
- count_words,
26
- count_characters,
27
- to_uppercase,
28
- to_lowercase,
29
- remove_spaces,
30
- )
31
-
32
- from .data_structures import (
33
- list_operations,
34
- tuple_operations,
35
- dictionary_keys,
36
- dictionary_values,
37
- set_union,
38
- set_intersection,
39
- )
40
-
41
- from .recursion import (
42
- factorial,
43
- fibonacci,
44
- fibonacci_memo,
45
- power_recursive,
46
- sum_recursive,
47
- gcd_recursive,
48
- )
49
-
50
- from .oop import (
51
- Calculator,
52
- ScientificCalculator,
53
- AdvancedCalculator,
54
- SpecialCalculator,
55
- BasicCalculator,
56
- HybridCalculator,
57
- )
58
-
59
- from .exceptions import (
60
- safe_divide,
61
- safe_square_root,
62
- validate_number,
63
- get_list_item,
64
- get_dictionary_value,
65
- )
66
-
67
- from .numerical import (
68
- create_array,
69
- array_mean,
70
- array_sum,
71
- matrix_multiply_numpy,
72
- array_statistics,
73
- )
74
-
75
- from .scipy_tools import (
76
- symbolic_simplify,
77
- symbolic_expand,
78
- numerical_integral,
79
- )
80
-
81
- from . import visualization
82
-
83
-
84
- __version__ = "0.2.2"
85
-
86
-
87
- __all__ = [
88
- # Calculus
89
- "derivative",
90
- "second_derivative",
91
- "integrate",
92
- "definite_integral",
93
- "limit",
94
- "taylor_series",
95
-
96
- # Linear Algebra
97
- "matrix_add",
98
- "matrix_multiply",
99
- "determinant",
100
- "inverse_matrix",
101
- "transpose",
102
- "solve_linear_system",
103
-
104
- # String Processing
105
- "reverse_string",
106
- "count_words",
107
- "count_characters",
108
- "to_uppercase",
109
- "to_lowercase",
110
- "remove_spaces",
111
-
112
- # Data Structures
113
- "list_operations",
114
- "tuple_operations",
115
- "dictionary_keys",
116
- "dictionary_values",
117
- "set_union",
118
- "set_intersection",
119
-
120
- # Recursion
121
- "factorial",
122
- "fibonacci",
123
- "fibonacci_memo",
124
- "power_recursive",
125
- "sum_recursive",
126
- "gcd_recursive",
127
-
128
- # OOP
129
- "Calculator",
130
- "ScientificCalculator",
131
- "AdvancedCalculator",
132
- "SpecialCalculator",
133
- "BasicCalculator",
134
- "HybridCalculator",
135
-
136
- # Exception Handling
137
- "safe_divide",
138
- "safe_square_root",
139
- "validate_number",
140
- "get_list_item",
141
- "get_dictionary_value",
142
-
143
- # NumPy
144
- "create_array",
145
- "array_mean",
146
- "array_sum",
147
- "matrix_multiply_numpy",
148
- "array_statistics",
149
-
150
- # SciPy and SymPy
151
- "symbolic_simplify",
152
- "symbolic_expand",
153
- "numerical_integral",
154
-
155
- # Visualization
156
- "visualization",
157
- ]
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes