UniversalFunctions 1.2.0__tar.gz → 1.3.0__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.
- {universalfunctions-1.2.0/UniversalFunctions.egg-info → universalfunctions-1.3.0}/PKG-INFO +1 -1
- {universalfunctions-1.2.0 → universalfunctions-1.3.0}/UF/ClassToDict.py +10 -3
- {universalfunctions-1.2.0 → universalfunctions-1.3.0}/UF/DecoratorArchive.py +6 -6
- {universalfunctions-1.2.0 → universalfunctions-1.3.0}/UF/GetVariable.py +8 -1
- {universalfunctions-1.2.0 → universalfunctions-1.3.0}/UF/HelperFunctions.py +7 -6
- {universalfunctions-1.2.0 → universalfunctions-1.3.0}/UF/StringCheck.py +1 -1
- {universalfunctions-1.2.0 → universalfunctions-1.3.0}/UF/Trigonometry.py +7 -7
- universalfunctions-1.3.0/UF/Validators/__init__.py +58 -0
- {universalfunctions-1.2.0 → universalfunctions-1.3.0}/UF/__init__.py +18 -15
- {universalfunctions-1.2.0 → universalfunctions-1.3.0/UniversalFunctions.egg-info}/PKG-INFO +1 -1
- {universalfunctions-1.2.0 → universalfunctions-1.3.0}/pyproject.toml +1 -1
- universalfunctions-1.2.0/UF/Validators/__init__.py +0 -16
- {universalfunctions-1.2.0 → universalfunctions-1.3.0}/LICENSE +0 -0
- {universalfunctions-1.2.0 → universalfunctions-1.3.0}/README.md +0 -0
- {universalfunctions-1.2.0 → universalfunctions-1.3.0}/UF/Validators/QuantumFuncValidators.py +0 -0
- {universalfunctions-1.2.0 → universalfunctions-1.3.0}/UF/Validators/QuantumValidators.py +0 -0
- {universalfunctions-1.2.0 → universalfunctions-1.3.0}/UF/Validators/ValidationClasses.py +0 -0
- {universalfunctions-1.2.0 → universalfunctions-1.3.0}/UniversalFunctions.egg-info/SOURCES.txt +0 -0
- {universalfunctions-1.2.0 → universalfunctions-1.3.0}/UniversalFunctions.egg-info/dependency_links.txt +0 -0
- {universalfunctions-1.2.0 → universalfunctions-1.3.0}/UniversalFunctions.egg-info/top_level.txt +0 -0
- {universalfunctions-1.2.0 → universalfunctions-1.3.0}/setup.cfg +0 -0
- {universalfunctions-1.2.0 → universalfunctions-1.3.0}/tests/__init__.py +0 -0
- {universalfunctions-1.2.0 → universalfunctions-1.3.0}/tests/test_ClassToDict.py +0 -0
|
@@ -3,17 +3,24 @@ This module contains a function that takes all functions in a class and make a d
|
|
|
3
3
|
"""
|
|
4
4
|
|
|
5
5
|
from collections.abc import Callable
|
|
6
|
-
from .Validators
|
|
6
|
+
from .Validators import SequenceValidate
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
def classes_to_dict(*classes: tuple[type, ...]) -> dict[str, Callable]:
|
|
9
|
+
def classes_to_dict(*classes: type) -> dict[str, Callable]:
|
|
11
10
|
"""
|
|
12
11
|
Extracts callable objects from the given classes and returns them
|
|
13
12
|
as a dictionary mapping their names to the corresponding objects
|
|
13
|
+
|
|
14
|
+
>>> class RandomClass:
|
|
15
|
+
... def get_item(self):
|
|
16
|
+
... pass
|
|
17
|
+
>>> result = classes_to_dict(RandomClass)
|
|
18
|
+
>>> list(result)
|
|
19
|
+
['get_item']
|
|
14
20
|
:param classes: Classes from which the callables are extracted
|
|
15
21
|
:return: Dictionary of callable names and their objects
|
|
16
22
|
"""
|
|
23
|
+
SequenceValidate(type, ...)(classes, name="classes")
|
|
17
24
|
dictionary = {}
|
|
18
25
|
for cls in classes:
|
|
19
26
|
dictionary.update({
|
|
@@ -3,16 +3,16 @@ This module contains decorators which take any number of decorators and apply th
|
|
|
3
3
|
"""
|
|
4
4
|
|
|
5
5
|
from collections.abc import Callable
|
|
6
|
-
from .Validators
|
|
6
|
+
from .Validators import SequenceValidate
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
def cls_deco_superposition(*decorators: tuple[Callable, ...]) -> Callable:
|
|
9
|
+
def cls_deco_superposition(*decorators: Callable) -> Callable:
|
|
11
10
|
"""
|
|
12
11
|
DECORATOR!! Creates a class decorator that applies the given decorator to every user defined function
|
|
13
|
-
:param
|
|
12
|
+
:param decorators: provided decorator functions
|
|
14
13
|
:return: a class decorator that transforms the class (& it's functions) and returns it
|
|
15
14
|
"""
|
|
15
|
+
SequenceValidate(Callable, ...)(decorators, name="decorators")
|
|
16
16
|
deco_composer = deco_superposition(*decorators)
|
|
17
17
|
|
|
18
18
|
def inner(cls):
|
|
@@ -22,13 +22,13 @@ def cls_deco_superposition(*decorators: tuple[Callable, ...]) -> Callable:
|
|
|
22
22
|
return cls
|
|
23
23
|
return inner
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
def deco_superposition(*decorators: tuple[Callable, ...]) -> Callable:
|
|
25
|
+
def deco_superposition(*decorators: Callable) -> Callable:
|
|
27
26
|
"""
|
|
28
27
|
DECORATOR! this decorator takes multiple decorators and applies them to the given function the same way python would naturally
|
|
29
28
|
:param decorators: decorator functions
|
|
30
29
|
:return: supplied function
|
|
31
30
|
"""
|
|
31
|
+
SequenceValidate(Callable, ...)(decorators, name="decorators")
|
|
32
32
|
def inner_deco(func):
|
|
33
33
|
for decorator in reversed(decorators):
|
|
34
34
|
func = decorator(func)
|
|
@@ -5,7 +5,14 @@ This module contains an extremely important function: get_num, which takes a num
|
|
|
5
5
|
from time import sleep as rest
|
|
6
6
|
from typing import overload, Literal
|
|
7
7
|
from numbers import Real
|
|
8
|
-
from .Validators
|
|
8
|
+
from .Validators import (
|
|
9
|
+
LessThan,
|
|
10
|
+
str_validate,
|
|
11
|
+
real_validate,
|
|
12
|
+
TypeValidate,
|
|
13
|
+
GreaterOrEqual,
|
|
14
|
+
LessOrEqual
|
|
15
|
+
)
|
|
9
16
|
|
|
10
17
|
|
|
11
18
|
type int_type = type[int]
|
|
@@ -15,14 +15,13 @@ from math import sqrt
|
|
|
15
15
|
from .GetVariable import get_num
|
|
16
16
|
from .DecoratorArchive import cls_deco_superposition
|
|
17
17
|
from .ClassToDict import classes_to_dict
|
|
18
|
-
from .Validators
|
|
19
|
-
from .Validators.ValidationClasses import LessThan, Positive
|
|
18
|
+
from .Validators import qtm_validation_decorator, LessThan, Positive
|
|
20
19
|
from numbers import Real
|
|
21
20
|
|
|
22
21
|
|
|
23
22
|
@cls_deco_superposition(staticmethod)
|
|
24
23
|
class HelperFunctions:
|
|
25
|
-
|
|
24
|
+
"""This class provides a collection of reusable helper functions"""
|
|
26
25
|
def intervals_f() -> Real:
|
|
27
26
|
"""Asks the user for rational intervals"""
|
|
28
27
|
interval_num: float = get_num(float, "Enter intervals(ℚ>0): ", MIN=0)
|
|
@@ -64,8 +63,6 @@ class HelperFunctions:
|
|
|
64
63
|
Calculates the diameter of a square with given length
|
|
65
64
|
:return: diameter, diameter/2
|
|
66
65
|
"""
|
|
67
|
-
if length <= 0:
|
|
68
|
-
raise ValueError("Length must be greater than 0")
|
|
69
66
|
|
|
70
67
|
diameter: float = length*sqrt(2); d_half: Real = diameter / 2
|
|
71
68
|
return diameter, d_half
|
|
@@ -90,7 +87,11 @@ class HelperFunctions:
|
|
|
90
87
|
helper = HelperFunctions
|
|
91
88
|
|
|
92
89
|
@qtm_validation_decorator
|
|
93
|
-
def range_f(
|
|
90
|
+
def range_f(
|
|
91
|
+
start: Real,
|
|
92
|
+
stop: Real,
|
|
93
|
+
step: Annotated[Real, Positive()]
|
|
94
|
+
) -> Generator[Real,Any,None]:
|
|
94
95
|
"""
|
|
95
96
|
Lets the user choose Real inputs for start, stop and step
|
|
96
97
|
:param start: start value; Real number
|
|
@@ -3,7 +3,7 @@ This module contains an extremely important function: get_str, which takes a str
|
|
|
3
3
|
"""
|
|
4
4
|
|
|
5
5
|
from time import sleep as rest
|
|
6
|
-
from .Validators
|
|
6
|
+
from .Validators import TypeValidate, str_validate
|
|
7
7
|
|
|
8
8
|
|
|
9
9
|
def get_str(str_input: str, *check_values) -> str:
|
|
@@ -6,32 +6,32 @@ from math import (
|
|
|
6
6
|
asin,
|
|
7
7
|
)
|
|
8
8
|
from numbers import Real
|
|
9
|
-
from .Validators
|
|
9
|
+
from .Validators import real_validate
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
@qtm_validation_decorator
|
|
13
12
|
def sine(angle: Real) -> Real:
|
|
14
13
|
"""
|
|
15
14
|
Calculates the sine of a given angle
|
|
16
15
|
:param angle: value required in degrees
|
|
17
16
|
:return: sine value
|
|
18
17
|
"""
|
|
18
|
+
real_validate()(angle, name="angle")
|
|
19
19
|
return sin(radians(angle))
|
|
20
20
|
|
|
21
|
-
@qtm_validation_decorator
|
|
22
21
|
def cosine(angle: Real) -> Real:
|
|
23
22
|
"""
|
|
24
23
|
Calculates the cosine of a given angle
|
|
25
24
|
:param angle: value required in degrees
|
|
26
25
|
:return: cosine value
|
|
27
26
|
"""
|
|
27
|
+
real_validate()(angle, name="angle")
|
|
28
28
|
return cos(radians(angle))
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
def asine(angle: Real) -> Real:
|
|
30
|
+
def asine(value: Real) -> Real:
|
|
32
31
|
"""
|
|
33
32
|
Calculates the asine of a given angle
|
|
34
|
-
:param
|
|
33
|
+
:param value: real value
|
|
35
34
|
:return: asine value
|
|
36
35
|
"""
|
|
37
|
-
|
|
36
|
+
real_validate()(value, name="value")
|
|
37
|
+
return degrees(asin(value))
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Welcome to the Quantum/Classical Dimension!
|
|
3
|
+
|
|
4
|
+
Here you will find some of the most sensitive pieces of code, however you may gladly use the validators,
|
|
5
|
+
no matter quantum or classic.
|
|
6
|
+
But whatever you do, DO NOT change the actual functions, otherwise, the entire
|
|
7
|
+
software will cease to function.
|
|
8
|
+
Almost every single other module in this software relies on the quantum validation centers, if anything is changed
|
|
9
|
+
inappropriately, the user shall face serious consequences.
|
|
10
|
+
|
|
11
|
+
Abbreviations:
|
|
12
|
+
qtm = Quantum Turtle Mechanics
|
|
13
|
+
ctm = Classical Turtle Mechanics
|
|
14
|
+
|
|
15
|
+
All functions with qtm belong to the Quantum Dimension whereas all functions with ctm belong to the Classical Dimension
|
|
16
|
+
"""
|
|
17
|
+
|
|
18
|
+
from .QuantumFuncValidators import qtm_validation_decorator, qtm_func_validator
|
|
19
|
+
from .QuantumValidators import qtm_lt_validator, qtm_constr_validator
|
|
20
|
+
from .ValidationClasses import (
|
|
21
|
+
TypeValidate,
|
|
22
|
+
int_validate,
|
|
23
|
+
str_validate,
|
|
24
|
+
real_validate,
|
|
25
|
+
Positive,
|
|
26
|
+
LessThan,
|
|
27
|
+
LessOrEqual,
|
|
28
|
+
GreaterThan,
|
|
29
|
+
GreaterOrEqual,
|
|
30
|
+
SequenceValidate,
|
|
31
|
+
RealValidationParent,
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
from . import QuantumFuncValidators
|
|
35
|
+
from . import QuantumValidators
|
|
36
|
+
from . import ValidationClasses
|
|
37
|
+
|
|
38
|
+
__all__ = [
|
|
39
|
+
"qtm_validation_decorator",
|
|
40
|
+
"qtm_func_validator",
|
|
41
|
+
"qtm_lt_validator",
|
|
42
|
+
"qtm_constr_validator",
|
|
43
|
+
"TypeValidate",
|
|
44
|
+
"int_validate",
|
|
45
|
+
"str_validate",
|
|
46
|
+
"real_validate",
|
|
47
|
+
"Positive",
|
|
48
|
+
"LessThan",
|
|
49
|
+
"LessOrEqual",
|
|
50
|
+
"GreaterThan",
|
|
51
|
+
"GreaterOrEqual",
|
|
52
|
+
"SequenceValidate",
|
|
53
|
+
"RealValidationParent",
|
|
54
|
+
|
|
55
|
+
"QuantumFuncValidators",
|
|
56
|
+
"QuantumValidators",
|
|
57
|
+
"ValidationClasses",
|
|
58
|
+
]
|
|
@@ -28,20 +28,15 @@ from .HelperFunctions import (
|
|
|
28
28
|
)
|
|
29
29
|
from .StringCheck import get_str
|
|
30
30
|
from .Trigonometry import sine, cosine, asine
|
|
31
|
-
from .Validators
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
GreaterOrEqual,
|
|
41
|
-
SequenceValidate,
|
|
42
|
-
)
|
|
43
|
-
from .Validators.QuantumFuncValidators import qtm_validation_decorator, qtm_func_validator
|
|
44
|
-
from .Validators.QuantumValidators import qtm_constr_validator, qtm_lt_validator
|
|
31
|
+
from .Validators import *
|
|
32
|
+
|
|
33
|
+
from . import ClassToDict
|
|
34
|
+
from . import DecoratorArchive
|
|
35
|
+
from . import GetVariable
|
|
36
|
+
from . import HelperFunctions as HelperFunctionsModule
|
|
37
|
+
from . import StringCheck
|
|
38
|
+
from . import Trigonometry
|
|
39
|
+
from . import Validators
|
|
45
40
|
|
|
46
41
|
__all__ = [
|
|
47
42
|
"classes_to_dict",
|
|
@@ -68,5 +63,13 @@ __all__ = [
|
|
|
68
63
|
"qtm_validation_decorator",
|
|
69
64
|
"qtm_func_validator",
|
|
70
65
|
"qtm_constr_validator",
|
|
71
|
-
"qtm_lt_validator"
|
|
66
|
+
"qtm_lt_validator",
|
|
67
|
+
|
|
68
|
+
"ClassToDict",
|
|
69
|
+
"DecoratorArchive",
|
|
70
|
+
"GetVariable",
|
|
71
|
+
"HelperFunctionsModule",
|
|
72
|
+
"StringCheck",
|
|
73
|
+
"Trigonometry",
|
|
74
|
+
"Validators",
|
|
72
75
|
]
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "UniversalFunctions"
|
|
7
|
-
version = "1.
|
|
7
|
+
version = "1.3.0"
|
|
8
8
|
description = "A Python utility library providing foundational functions, validators, and infrastructure."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.14"
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Welcome to the Quantum/Classical Dimension!
|
|
3
|
-
|
|
4
|
-
Here you will find some of the most sensitive pieces of code, however you may gladly use the validators,
|
|
5
|
-
no matter quantum or classic.
|
|
6
|
-
But whatever you do, DO NOT change the actual functions, otherwise, the entire
|
|
7
|
-
software will cease to function.
|
|
8
|
-
Almost every single other module in this software relies on the quantum validation centers, if anything is changed
|
|
9
|
-
inappropriately, the user shall face serious consequences.
|
|
10
|
-
|
|
11
|
-
Abbreviations:
|
|
12
|
-
qtm = Quantum Turtle Mechanics
|
|
13
|
-
ctm = Classical Turtle Mechanics
|
|
14
|
-
|
|
15
|
-
All functions with qtm belong to the Quantum Dimension whereas all functions with ctm belong to the Classical Dimension
|
|
16
|
-
"""
|
|
File without changes
|
|
File without changes
|
{universalfunctions-1.2.0 → universalfunctions-1.3.0}/UF/Validators/QuantumFuncValidators.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{universalfunctions-1.2.0 → universalfunctions-1.3.0}/UniversalFunctions.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
{universalfunctions-1.2.0 → universalfunctions-1.3.0}/UniversalFunctions.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|