1
- from .highpymath import sum as _sum
2
- from .highpymath import sub as _sub
3
- from .highpymath import mul as _mul
4
- from .highpymath import div as _div
5
- from .highpymath import exp as _exp
6
- from .highpymath import sqrt as _sqrt
7
- from .highpymath import log as _log
8
1
from .highpymath import MathValueError as _mve
9
- from .highpymath import factorial as _factorial
10
- from .highpymath import reciprocal as _reciprocal
11
2
12
- __all__ = ['sum' , 'sub' , 'mul' , 'div' , 'MathValueError' , 'exp' , 'sqrt' , 'log' , 'reciprocal' ]
3
+ __all__ = ['sum' , 'sub' , 'mul' , 'div' , 'MathValueError' , 'exp' , 'sqrt' , 'log' , 'reciprocal' , 'factorial' , 'linear' ]
13
4
14
5
class MathValueError (_mve ):
15
6
"""
@@ -27,6 +18,7 @@ def sum(a: any, b: any, return_int: bool = False, return_string: bool = False):
27
18
"""
28
19
Create the Summary of 2 Numbers.
29
20
"""
21
+ from .highpymath import sum as _sum
30
22
return_float = True
31
23
if return_int :
32
24
return_float = False
@@ -51,6 +43,7 @@ def sub(a: any, b: any, return_int: bool = False, return_string: bool = False):
51
43
"""
52
44
Create the Subtraction of 2 Numbers.
53
45
"""
46
+ from .highpymath import sub as _sub
54
47
return_float = True
55
48
if return_int :
56
49
return_float = False
@@ -75,6 +68,7 @@ def mul(a: any, b: any, return_int: bool = False, return_string: bool = False):
75
68
"""
76
69
Create the Multiplication of 2 Numbers.
77
70
"""
71
+ from .highpymath import mul as _mul
78
72
return_float = True
79
73
if return_int :
80
74
return_float = False
@@ -99,6 +93,7 @@ def div(a: any, b: any, return_int: bool = False, return_string: bool = False):
99
93
"""
100
94
Create the Division of 2 Numbers.
101
95
"""
96
+ from .highpymath import div as _div
102
97
return_float = True
103
98
if return_int :
104
99
return_float = False
@@ -123,6 +118,7 @@ def exp(base: any, power: any, return_int: bool = False, return_string: bool = F
123
118
"""
124
119
Create the Exponentiation of 2 Numbers.
125
120
"""
121
+ from .highpymath import exp as _exp
126
122
return_float = True
127
123
if return_int :
128
124
return_float = False
@@ -147,6 +143,7 @@ def sqrt(base: any, power: any = 2, return_int: bool = False, return_string: boo
147
143
"""
148
144
Create the Square Root of a Number.
149
145
"""
146
+ from .highpymath import sqrt as _sqrt
150
147
return_float = True
151
148
if return_int :
152
149
return_float = False
@@ -171,6 +168,7 @@ def log(base: any, power: any = 10, return_int: bool = False, return_string: boo
171
168
"""
172
169
Create the Logarithm of a Number.
173
170
"""
171
+ from .highpymath import log as _log
174
172
return_float = True
175
173
if return_int :
176
174
return_float = False
@@ -195,6 +193,7 @@ def reciprocal(a: any, return_int: bool = False, return_string: bool = False):
195
193
"""
196
194
Create the Reciprocal of a Number.
197
195
"""
196
+ from .highpymath import reciprocal as _reciprocal
198
197
return_float = True
199
198
if return_int :
200
199
return_float = False
@@ -215,12 +214,69 @@ def factorial(a: int, return_int: bool = False, return_string: bool = False):
215
214
"""
216
215
Get the Factorial from a Number.
217
216
"""
217
+ from .highpymath import factorial as _factorial
218
218
return_float = True
219
219
if return_int :
220
220
return_float = False
221
221
if not isinstance (a , int ):
222
222
raise MathValueError ("a must be an integer" )
223
223
_result = _factorial (a = a )
224
+ if return_int :
225
+ _result = int (_result )
226
+ elif return_float :
227
+ _result = float (_result )
228
+ if return_string :
229
+ _result = str (_result )
230
+ return _result
231
+
232
+ def linear (a : any = None , b : any = None , c : any = None , search_a : bool = False , search_b : bool = False , search_c : bool = False , return_int : bool = False , return_string : bool = False ):
233
+ """
234
+ Solve the Linear Function from type: a + b = c
235
+ """
236
+ from .highpymath import linear_base_a as _linear_base_a
237
+ from .highpymath import linear_base_b as _linear_base_b
238
+ from .highpymath import linear_base_c as _linear_base_c
239
+ return_float = True
240
+ if return_int :
241
+ return_float = False
242
+ if search_a and search_b and search_c :
243
+ raise MathValueError ("You need to specify one of the 3 arguments" )
244
+ if search_a and search_b :
245
+ raise MathValueError ("You need to specify one of the 3 arguments" )
246
+ if search_a and search_c :
247
+ raise MathValueError ("You need to specify one of the 3 arguments" )
248
+ if search_b and search_c :
249
+ raise MathValueError ("You need to specify one of the 3 arguments" )
250
+ if search_a :
251
+ if not isinstance (b , (int , float )):
252
+ raise MathValueError ("b must be a number" )
253
+ if not isinstance (c , (int , float )):
254
+ raise MathValueError ("c must be a number" )
255
+ if isinstance (b , int ):
256
+ b = float (b )
257
+ if isinstance (c , int ):
258
+ c = float (c )
259
+ _result = _linear_base_a (b = b , c = c )
260
+ elif search_b :
261
+ if not isinstance (a , (int , float )):
262
+ raise MathValueError ("a must be a number" )
263
+ if not isinstance (c , (int , float )):
264
+ raise MathValueError ("c must be a number" )
265
+ if isinstance (a , int ):
266
+ a = float (a )
267
+ if isinstance (c , int ):
268
+ c = float (c )
269
+ _result = _linear_base_b (a = a , c = c )
270
+ elif search_c :
271
+ if not isinstance (a , (int , float )):
272
+ raise MathValueError ("a must be a number" )
273
+ if not isinstance (b , (int , float )):
274
+ raise MathValueError ("b must be a number" )
275
+ if isinstance (a , int ):
276
+ a = float (a )
277
+ if isinstance (b , int ):
278
+ b = float (b )
279
+ _result = _linear_base_c (a = a , b = b )
224
280
if return_int :
225
281
_result = int (_result )
226
282
elif return_float :
0 commit comments