UniversalFunctions 1.0.0__tar.gz → 1.1.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.
Files changed (22) hide show
  1. {universalfunctions-1.0.0/UniversalFunctions.egg-info → universalfunctions-1.1.0}/PKG-INFO +1 -1
  2. {universalfunctions-1.0.0 → universalfunctions-1.1.0}/UF/HelperFunctions.py +1 -28
  3. universalfunctions-1.1.0/UF/Trigonometry.py +37 -0
  4. {universalfunctions-1.0.0 → universalfunctions-1.1.0}/UF/Validators/ValidationClasses.py +57 -23
  5. {universalfunctions-1.0.0 → universalfunctions-1.1.0}/UF/__init__.py +1 -3
  6. {universalfunctions-1.0.0 → universalfunctions-1.1.0/UniversalFunctions.egg-info}/PKG-INFO +1 -1
  7. {universalfunctions-1.0.0 → universalfunctions-1.1.0}/UniversalFunctions.egg-info/SOURCES.txt +1 -0
  8. {universalfunctions-1.0.0 → universalfunctions-1.1.0}/pyproject.toml +1 -1
  9. {universalfunctions-1.0.0 → universalfunctions-1.1.0}/LICENSE +0 -0
  10. {universalfunctions-1.0.0 → universalfunctions-1.1.0}/README.md +0 -0
  11. {universalfunctions-1.0.0 → universalfunctions-1.1.0}/UF/ClassToDict.py +0 -0
  12. {universalfunctions-1.0.0 → universalfunctions-1.1.0}/UF/DecoratorArchive.py +0 -0
  13. {universalfunctions-1.0.0 → universalfunctions-1.1.0}/UF/GetVariable.py +0 -0
  14. {universalfunctions-1.0.0 → universalfunctions-1.1.0}/UF/StringCheck.py +0 -0
  15. {universalfunctions-1.0.0 → universalfunctions-1.1.0}/UF/Validators/QuantumFuncValidators.py +0 -0
  16. {universalfunctions-1.0.0 → universalfunctions-1.1.0}/UF/Validators/QuantumValidators.py +0 -0
  17. {universalfunctions-1.0.0 → universalfunctions-1.1.0}/UF/Validators/__init__.py +0 -0
  18. {universalfunctions-1.0.0 → universalfunctions-1.1.0}/UniversalFunctions.egg-info/dependency_links.txt +0 -0
  19. {universalfunctions-1.0.0 → universalfunctions-1.1.0}/UniversalFunctions.egg-info/top_level.txt +0 -0
  20. {universalfunctions-1.0.0 → universalfunctions-1.1.0}/setup.cfg +0 -0
  21. {universalfunctions-1.0.0 → universalfunctions-1.1.0}/tests/__init__.py +0 -0
  22. {universalfunctions-1.0.0 → universalfunctions-1.1.0}/tests/test_ClassToDict.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: UniversalFunctions
3
- Version: 1.0.0
3
+ Version: 1.1.0
4
4
  Summary: A Python utility library providing foundational functions, validators, and infrastructure.
5
5
  Author-email: "Miah M. Sabiq" <miah.sabiq@gibs.at>
6
6
  Requires-Python: >=3.14
@@ -11,7 +11,7 @@ range_f -> acts like the conventional range function except for that this takes
11
11
 
12
12
  from typing import Any, Annotated
13
13
  from collections.abc import Generator
14
- from math import sqrt, sin, radians, cos, asin, degrees
14
+ 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
@@ -89,33 +89,6 @@ class HelperFunctions:
89
89
 
90
90
  helper = HelperFunctions
91
91
 
92
- @qtm_validation_decorator
93
- def sine(angle: Real) -> Real:
94
- """
95
- Calculates the sine of a given angle
96
- :param angle: value required in degrees
97
- :return: sine value
98
- """
99
- return sin(radians(angle))
100
-
101
- @qtm_validation_decorator
102
- def cosine(angle: Real) -> Real:
103
- """
104
- Calculates the cosine of a given angle
105
- :param angle: value required in degrees
106
- :return: cosine value
107
- """
108
- return cos(radians(angle))
109
-
110
- @qtm_validation_decorator
111
- def asine(angle: Real) -> Real:
112
- """
113
- Calculates the asine of a given angle
114
- :param angle: real value
115
- :return: asine value
116
- """
117
- return degrees(asin(angle))
118
-
119
92
  @qtm_validation_decorator
120
93
  def range_f(start: Real, stop: Real, step: Annotated[Real, Positive()]) -> Generator[Real,Any,None]:
121
94
  """
@@ -0,0 +1,37 @@
1
+ from math import (
2
+ radians,
3
+ degrees,
4
+ sin,
5
+ cos,
6
+ asin,
7
+ )
8
+ from numbers import Real
9
+ from .Validators.QuantumFuncValidators import qtm_validation_decorator
10
+
11
+
12
+ @qtm_validation_decorator
13
+ def sine(angle: Real) -> Real:
14
+ """
15
+ Calculates the sine of a given angle
16
+ :param angle: value required in degrees
17
+ :return: sine value
18
+ """
19
+ return sin(radians(angle))
20
+
21
+ @qtm_validation_decorator
22
+ def cosine(angle: Real) -> Real:
23
+ """
24
+ Calculates the cosine of a given angle
25
+ :param angle: value required in degrees
26
+ :return: cosine value
27
+ """
28
+ return cos(radians(angle))
29
+
30
+ @qtm_validation_decorator
31
+ def asine(angle: Real) -> Real:
32
+ """
33
+ Calculates the asine of a given angle
34
+ :param angle: real value
35
+ :return: asine value
36
+ """
37
+ return degrees(asin(angle))
@@ -1,5 +1,8 @@
1
1
  from typing import Any
2
2
  from numbers import Real
3
+ from types import EllipsisType
4
+ from itertools import cycle
5
+ from collections.abc import Callable
3
6
 
4
7
 
5
8
  class TypeValidate:
@@ -17,7 +20,7 @@ class TypeValidate:
17
20
 
18
21
  else:
19
22
  raise TypeError(f"Parameter 'expected' MUST be a type object or a tuple of type objects!")
20
- def __call__(self, value: Any, name: str | None = None) -> bool:
23
+ def __call__(self, value: Any, name: str | None = None) -> Any:
21
24
  """Validates the entered value, expected to be of expected type"""
22
25
  if name is not None and not isinstance(name, str):
23
26
  raise TypeError(f"Parameter 'name' MUST be a string object!")
@@ -31,7 +34,7 @@ class TypeValidate:
31
34
  if name is not None:
32
35
  raise TypeError(f"{name} is not of expected type {self.expected!r}!")
33
36
  raise TypeError(f"{value!r} is not of expected type {self.expected!r}!")
34
- return True
37
+ return value
35
38
 
36
39
  def int_validate() -> TypeValidate:
37
40
  """Makes sure the entered value is an integer with TypeValidate"""
@@ -53,7 +56,7 @@ class RealValidationParent:
53
56
 
54
57
  class Positive:
55
58
  """Makes sure the entered value is positive"""
56
- def __call__(self, value: Real, name: str|None = None) -> bool:
59
+ def __call__(self, value: Real, name: str|None = None) -> Real:
57
60
  """Validates the entered value, expected to be positive (0 included)"""
58
61
  if name is not None:
59
62
  real_validate()(value, name)
@@ -61,68 +64,99 @@ class Positive:
61
64
  real_validate()(value)
62
65
  if value <= 0:
63
66
  raise ValueError(f"Entered value is expected to be greater than 0!")
64
- return True
67
+ return value
65
68
 
66
69
  class LessThan(RealValidationParent):
67
70
  """Makes sure the entered value is less than expected value"""
68
- def __call__(self, value: Real, name: str|None = None) -> bool:
71
+ def __call__(self, value: Real, name: str|None = None) -> Real:
69
72
  """Validates the entered value, expected to be less than expected value"""
70
73
  self._validator(value)
71
74
  if name is not None:
72
75
  str_validate()(name, "name")
73
76
  if value >= self.expected:
74
77
  raise ValueError(f"Entered value ({name}) is expected to be less than {self.expected!r}!")
75
- return True
78
+ return value
76
79
 
77
80
  class LessOrEqual(RealValidationParent):
78
81
  """Makes sure the entered value is less than or equal to expected value"""
79
- def __call__(self, value: Real, name: str|None = None) -> bool:
82
+ def __call__(self, value: Real, name: str|None = None) -> Real:
80
83
  """Validates the entered value, expected to be less than or equal to expected value"""
81
84
  self._validator(value)
82
85
  if name is not None:
83
86
  str_validate()(name, "name")
84
87
  if value > self.expected:
85
88
  raise ValueError(f"Entered value ({name}) is expected to be less than or equal to {self.expected!r}!")
86
- return True
89
+ return value
87
90
 
88
91
 
89
92
  class GreaterThan(RealValidationParent):
90
93
  """Makes sure the entered value is greater than expected value"""
91
- def __call__(self, value: Real, name: str|None = None) -> bool:
94
+ def __call__(self, value: Real, name: str|None = None) -> Real:
92
95
  """Validates the entered value, expected to be greater than expected value"""
93
96
  self._validator(value)
94
97
  if name is not None:
95
98
  str_validate()(name, "name")
96
99
  if self.expected >= value:
97
100
  raise ValueError(f"Entered value ({name}) is expected to be greater than {self.expected!r}!")
98
- return True
101
+ return value
99
102
 
100
103
  class GreaterOrEqual(RealValidationParent):
101
104
  """Makes sure the entered value is greater than or equal to expected value"""
102
- def __call__(self, value: Real, name: str|None = None) -> bool:
105
+ def __call__(self, value: Real, name: str|None = None) -> Real:
103
106
  """Validates the entered value, expected to be greater than or equal to expected value"""
104
107
  self._validator(value)
105
108
  if name is not None:
106
109
  str_validate()(name, "name")
107
110
  if self.expected > value:
108
111
  raise ValueError(f"Entered value ({name}) is expected to be greater than or equal to {self.expected!r}!")
109
- return True
112
+ return value
110
113
 
111
- class TupleValidate:
112
- """Makes sure the entered value is a tuple of any value"""
113
- def __init__(self, *expected: type) -> None:
114
+ class SequenceValidate:
115
+ """Makes sure the entered value is a sequence of any value"""
116
+ def __init__(self, *expected: type | EllipsisType, **kwargs) -> None:
114
117
  """Validates and sets the tuple to a variable"""
115
118
  for item in expected:
116
- TypeValidate(type)(item)
119
+ if item is not Ellipsis:
120
+ TypeValidate(type)(item)
121
+ else:
122
+ if expected[-1] is not Ellipsis:
123
+ raise ValueError(f"Entered value ({expected[-1]}) is expected to be an ellipsis type!")
124
+
117
125
  self.expected = expected
118
126
 
119
- def __call__(self, value: tuple, name: str|None = None) -> bool:
127
+ callable_name = "callable_items"
128
+ self.callables = ()
129
+
130
+ if callable_name in kwargs:
131
+ TypeValidate(tuple)(kwargs[callable_name], callable_name)
132
+ for func in kwargs[callable_name]:
133
+ TypeValidate(Callable)(func)
134
+
135
+ self.callables = kwargs[callable_name]
136
+
137
+ def __call__(self, value: tuple|list, name: str|None = None) -> tuple|list:
120
138
  """Validates the entered value, expected to be a tuple of expected value/s"""
121
- TypeValidate(tuple)(value)
139
+ if not isinstance(value, (tuple, list)):
140
+ raise TypeError(f"Entered value ({name}) is expected to be a tuple or list!")
141
+
122
142
  if name is not None:
123
143
  str_validate()(name, "name")
124
- if len(self.expected) != len(value):
125
- raise ValueError(f"Entered value ({name}) must have the same number of elements as the provided expected tuple!")
126
- for expected_type, actual_value in zip(self.expected, value):
127
- TypeValidate(expected_type)(actual_value)
128
- return True
144
+ type_store = []
145
+ if isinstance(self.expected[-1], EllipsisType):
146
+ for item in self.expected:
147
+ if not isinstance(item, EllipsisType):
148
+ type_store.append(item)
149
+
150
+ for given_obj, expected_type in zip(value, cycle(type_store)):
151
+ TypeValidate(expected_type)(given_obj)
152
+ for func in self.callables:
153
+ func(given_obj)
154
+
155
+ else:
156
+ if len(self.expected) != len(value):
157
+ raise ValueError(f"Entered value ({name}) must have the same number of elements as the provided expected tuple!")
158
+ for expected_type, actual_value in zip(self.expected, value):
159
+ TypeValidate(expected_type)(actual_value)
160
+ for func in self.callables:
161
+ func(actual_value)
162
+ return value
@@ -24,12 +24,10 @@ from .GetVariable import get_num
24
24
  from .HelperFunctions import (
25
25
  helper,
26
26
  HelperFunctions,
27
- sine,
28
- cosine,
29
- asine,
30
27
  range_f,
31
28
  )
32
29
  from .StringCheck import get_str
30
+ from .Trigonometry import sine, cosine, asine
33
31
  from .Validators.ValidationClasses import (
34
32
  TypeValidate,
35
33
  Positive,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: UniversalFunctions
3
- Version: 1.0.0
3
+ Version: 1.1.0
4
4
  Summary: A Python utility library providing foundational functions, validators, and infrastructure.
5
5
  Author-email: "Miah M. Sabiq" <miah.sabiq@gibs.at>
6
6
  Requires-Python: >=3.14
@@ -6,6 +6,7 @@ UF/DecoratorArchive.py
6
6
  UF/GetVariable.py
7
7
  UF/HelperFunctions.py
8
8
  UF/StringCheck.py
9
+ UF/Trigonometry.py
9
10
  UF/__init__.py
10
11
  UF/Validators/QuantumFuncValidators.py
11
12
  UF/Validators/QuantumValidators.py
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "UniversalFunctions"
7
- version = "1.0.0"
7
+ version = "1.1.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"