UniversalFunctions 2.0.0__tar.gz → 2.1.1__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-2.0.0 → universalfunctions-2.1.1}/PKG-INFO +1 -1
  2. {universalfunctions-2.0.0 → universalfunctions-2.1.1}/UF/ClassToDict.py +1 -0
  3. {universalfunctions-2.0.0 → universalfunctions-2.1.1}/UF/Trigonometry.py +12 -0
  4. {universalfunctions-2.0.0 → universalfunctions-2.1.1}/UF/Validators/Errors.py +28 -1
  5. {universalfunctions-2.0.0 → universalfunctions-2.1.1}/UF/Validators/QuantumValidators.py +0 -4
  6. {universalfunctions-2.0.0 → universalfunctions-2.1.1}/UF/Validators/ValidationClasses.py +0 -27
  7. {universalfunctions-2.0.0 → universalfunctions-2.1.1}/UF/Validators/__init__.py +2 -0
  8. {universalfunctions-2.0.0 → universalfunctions-2.1.1}/UF/__init__.py +1 -0
  9. {universalfunctions-2.0.0 → universalfunctions-2.1.1}/UniversalFunctions.egg-info/PKG-INFO +1 -1
  10. {universalfunctions-2.0.0 → universalfunctions-2.1.1}/pyproject.toml +1 -1
  11. {universalfunctions-2.0.0 → universalfunctions-2.1.1}/LICENSE +0 -0
  12. {universalfunctions-2.0.0 → universalfunctions-2.1.1}/README.md +0 -0
  13. {universalfunctions-2.0.0 → universalfunctions-2.1.1}/UF/DecoratorArchive.py +0 -0
  14. {universalfunctions-2.0.0 → universalfunctions-2.1.1}/UF/GetVariable.py +0 -0
  15. {universalfunctions-2.0.0 → universalfunctions-2.1.1}/UF/HelperFunctions.py +0 -0
  16. {universalfunctions-2.0.0 → universalfunctions-2.1.1}/UF/StringCheck.py +0 -0
  17. {universalfunctions-2.0.0 → universalfunctions-2.1.1}/UF/Validators/QuantumFuncValidators.py +0 -0
  18. {universalfunctions-2.0.0 → universalfunctions-2.1.1}/UniversalFunctions.egg-info/SOURCES.txt +0 -0
  19. {universalfunctions-2.0.0 → universalfunctions-2.1.1}/UniversalFunctions.egg-info/dependency_links.txt +0 -0
  20. {universalfunctions-2.0.0 → universalfunctions-2.1.1}/UniversalFunctions.egg-info/top_level.txt +0 -0
  21. {universalfunctions-2.0.0 → universalfunctions-2.1.1}/setup.cfg +0 -0
  22. {universalfunctions-2.0.0 → universalfunctions-2.1.1}/tests/test_ClassToDict.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: UniversalFunctions
3
- Version: 2.0.0
3
+ Version: 2.1.1
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
@@ -17,6 +17,7 @@ def classes_to_dict(*classes: type) -> dict[str, Callable]:
17
17
  >>> result = classes_to_dict(RandomClass)
18
18
  >>> list(result)
19
19
  ['get_item']
20
+
20
21
  :param classes: Classes from which the callables are extracted
21
22
  :return: Dictionary of callable names and their objects
22
23
  """
@@ -16,6 +16,10 @@ from .Validators import real_validate
16
16
  def sine(angle: Real) -> Real:
17
17
  """
18
18
  Calculates the sine of a given angle
19
+
20
+ >>> sin(0)
21
+ 0
22
+
19
23
  :param angle: value required in degrees
20
24
  :return: sine value
21
25
  """
@@ -25,6 +29,10 @@ def sine(angle: Real) -> Real:
25
29
  def cosine(angle: Real) -> Real:
26
30
  """
27
31
  Calculates the cosine of a given angle
32
+
33
+ >>> cosine(0)
34
+ 1
35
+
28
36
  :param angle: value required in degrees
29
37
  :return: cosine value
30
38
  """
@@ -34,6 +42,10 @@ def cosine(angle: Real) -> Real:
34
42
  def asine(value: Real) -> Real:
35
43
  """
36
44
  Calculates the asine of a given angle
45
+
46
+ >>> asine(0)
47
+ 0
48
+
37
49
  :param value: real value
38
50
  :return: asine value
39
51
  """
@@ -17,6 +17,8 @@ class ErrorDedent:
17
17
  way it would be printed otherwise.
18
18
 
19
19
  >>> print(ErrorDedent(TypeError)("This is a TypeError!"))
20
+ TypeError
21
+ <BLANKLINE>
20
22
  This is a TypeError!
21
23
  """
22
24
  name: Final[Literal["ErrorDedent"]] = "ErrorDedent"
@@ -40,13 +42,19 @@ class ErrorDedent:
40
42
  expected: str
41
43
  received: {text}
42
44
  """).strip())
43
- return self.error_func(dedent(text).strip())
45
+ return self.error_func(dedent(f"""
46
+ {self.error_func.__name__}
47
+
48
+ {text}
49
+ """).strip())
44
50
 
45
51
  def type_error() -> Callable:
46
52
  """
47
53
  This function returns a callable type error function.
48
54
 
49
55
  >>> print(type_error()("This is a TypeError!"))
56
+ TypeError
57
+ <BLANKLINE>
50
58
  This is a TypeError!
51
59
 
52
60
  :return: ErrorDedent function
@@ -58,6 +66,8 @@ def value_error() -> Callable:
58
66
  This function returns a callable value error function.
59
67
 
60
68
  >>> print(value_error()("This is a ValueError!"))
69
+ ValueError
70
+ <BLANKLINE>
61
71
  This is a ValueError!
62
72
 
63
73
  :return: ErrorDedent function
@@ -69,6 +79,8 @@ def item_count_error() -> Callable:
69
79
  This function returns a callable item count error function.
70
80
 
71
81
  >>> print(item_count_error()("This is an Item Count Error!"))
82
+ ItemCountError
83
+ <BLANKLINE>
72
84
  This is an Item Count Error!
73
85
 
74
86
  :return: ErrorDedent function
@@ -80,12 +92,27 @@ def constraint_error() -> Callable:
80
92
  This function returns a callable constraint error function.
81
93
 
82
94
  >>> print(constraint_error()("This is a Constraint Error!"))
95
+ ConstraintError
96
+ <BLANKLINE>
83
97
  This is a Constraint Error!
84
98
 
85
99
  :return: ErrorDedent function
86
100
  """
87
101
  return ErrorDedent(ConstraintError)
88
102
 
103
+ def attribute_error() -> Callable:
104
+ """
105
+ This function returns a callable attribute error function.
106
+
107
+ >>> print(attribute_error()("This is an Attribute Error!"))
108
+ AttributeError
109
+ <BLANKLINE>
110
+ This is an Attribute Error!
111
+
112
+ :return: ErrorDedent function
113
+ """
114
+ return ErrorDedent(AttributeError)
115
+
89
116
  class ItemCountError(Exception):
90
117
  """
91
118
  This exception is raised when an item count does not match the expected count.
@@ -23,8 +23,6 @@ def qtm_lt_validator(value: list[Any] | tuple[Any, ...], TYPE: Any, name: str) -
23
23
  origin = get_origin(TYPE)
24
24
  if origin not in (list, tuple):
25
25
  raise type_error()(f"""
26
- TypeError
27
-
28
26
  Validator: {func_name}
29
27
  Parameter TYPE must be a list/tuple of elements!
30
28
  Expected: type object
@@ -49,8 +47,6 @@ def qtm_constr_validator(value: Any, annotation, name: str) -> Any:
49
47
  func_name: Final[Literal["qtm_constr_validator"]] = "qtm_constr_validator"
50
48
  if get_origin(annotation) is not Annotated:
51
49
  raise type_error()(f"""
52
- TypeError
53
-
54
50
  Validator: {func_name}
55
51
  Parameter annotation is not an Annotated type!
56
52
  Expected: Annotated object
@@ -34,8 +34,6 @@ class TypeValidate:
34
34
  for item in expected:
35
35
  if not isinstance(item, type):
36
36
  raise type_error()(f"""
37
- TypeError
38
-
39
37
  Validator: {self.name}
40
38
  Entered value {item!r} is not a type object!
41
39
  Expected: type object
@@ -50,8 +48,6 @@ class TypeValidate:
50
48
 
51
49
  else:
52
50
  raise type_error()(f"""
53
- TypeError
54
-
55
51
  Validator: {self.name}
56
52
  Parameter 'expected' MUST be a type object or a tuple of type objects!
57
53
  Expected: type|tuple
@@ -64,8 +60,6 @@ class TypeValidate:
64
60
  """Validates the entered value, expected to be of expected type"""
65
61
  if name is not None and not isinstance(name, str):
66
62
  raise type_error()(f"""
67
- TypeError
68
-
69
63
  Validator: {self.name}
70
64
  Parameter 'name' MUST be a string object!
71
65
  Expected: str (name of value)
@@ -82,8 +76,6 @@ class TypeValidate:
82
76
 
83
77
  if name is not None:
84
78
  raise type_error()(f"""
85
- TypeError
86
-
87
79
  Validator: {self.name}
88
80
  Parameter {name!r} is not of expected type {expected_type!r}!
89
81
  Expected: {expected_type}
@@ -93,7 +85,6 @@ class TypeValidate:
93
85
  Type: {value_type}
94
86
  """)
95
87
  raise type_error()(f"""
96
- TypeError
97
88
  Validator: {self.name}
98
89
  Parameter value is not of expected type {expected_type!r}!
99
90
  Expected: {expected_type}
@@ -107,8 +98,6 @@ class TypeValidate:
107
98
 
108
99
  if name is not None:
109
100
  raise type_error()(f"""
110
- TypeError
111
-
112
101
  Validator: {self.name}
113
102
  Parameter {name!r} is not of expected type {expected_type!r}!
114
103
  Expected: {expected_type}
@@ -118,8 +107,6 @@ class TypeValidate:
118
107
  Type: {value_type}
119
108
  """)
120
109
  raise type_error()(f"""
121
- TypeError
122
-
123
110
  Validator: {self.name}
124
111
  Parameter value is not of expected type {expected_type!r}!
125
112
  Expected: {expected_type}
@@ -185,8 +172,6 @@ class Positive:
185
172
 
186
173
  if value <= 0:
187
174
  raise constraint_error()(f"""
188
- ConstraintError
189
-
190
175
  Validator: {self.name}
191
176
  Parameter value is expected to be greater than 0!
192
177
  Expected: value > 0
@@ -216,8 +201,6 @@ class LessThan(RealValidationParent):
216
201
 
217
202
  if value >= self.expected:
218
203
  raise constraint_error()(f"""
219
- ConstraintError
220
-
221
204
  Validator: {self.name}
222
205
  Parameter value is expected to be less than {self.expected!r}!
223
206
  Expected: {self.expected}
@@ -249,8 +232,6 @@ class LessOrEqual(RealValidationParent):
249
232
 
250
233
  if value > self.expected:
251
234
  raise constraint_error()(f"""
252
- ConstraintError
253
-
254
235
  Validator: {self.name}
255
236
  Parameter value is expected to be less than or equal to {self.expected!r}!
256
237
  Expected: {self.expected}
@@ -281,8 +262,6 @@ class GreaterThan(RealValidationParent):
281
262
 
282
263
  if self.expected >= value:
283
264
  raise constraint_error()(f"""
284
- ConstraintError
285
-
286
265
  Validator: {self.name}
287
266
  Parameter value is expected to be greater than {self.expected!r}!
288
267
  Expected: {self.expected}
@@ -314,8 +293,6 @@ class GreaterOrEqual(RealValidationParent):
314
293
 
315
294
  if self.expected > value:
316
295
  raise constraint_error()(f"""
317
- ConstraintError
318
-
319
296
  Validator: {self.name}
320
297
  Parameter value is expected to be greater than or equal to {self.expected!r}!
321
298
  Expected: {self.expected}
@@ -346,8 +323,6 @@ class SequenceValidate:
346
323
  else:
347
324
  if expected[-1] is not Ellipsis:
348
325
  raise type_error()(f"""
349
- TypeError
350
-
351
326
  Validator: {self.name}
352
327
  The last item in 'expected' is expected to be an ellipsis type!
353
328
  Expected: ellipsis type
@@ -389,8 +364,6 @@ class SequenceValidate:
389
364
  else:
390
365
  if len(self.expected) != len(value):
391
366
  raise item_count_error()(f"""
392
- ItemCountError
393
-
394
367
  Validator: {self.name}
395
368
  Parameter value ({name}) must have the same number of elements as the provided expected tuple!
396
369
  Expected number of items: {len(self.expected)}
@@ -21,6 +21,7 @@ from .Errors import (
21
21
  value_error,
22
22
  item_count_error,
23
23
  constraint_error,
24
+ attribute_error,
24
25
  ItemCountError,
25
26
  ConstraintError,
26
27
  )
@@ -50,6 +51,7 @@ __all__ = [
50
51
  "value_error",
51
52
  "item_count_error",
52
53
  "constraint_error",
54
+ "attribute_error",
53
55
  "ItemCountError",
54
56
  "ConstraintError",
55
57
 
@@ -56,6 +56,7 @@ __all__ = [
56
56
  "value_error",
57
57
  "item_count_error",
58
58
  "constraint_error",
59
+ "attribute_error",
59
60
  "ItemCountError",
60
61
  "ConstraintError",
61
62
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: UniversalFunctions
3
- Version: 2.0.0
3
+ Version: 2.1.1
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
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "UniversalFunctions"
7
- version = "2.0.0"
7
+ version = "2.1.1"
8
8
  description = "A Python utility library providing foundational functions, validators, and infrastructure."
9
9
  readme = "README.md"
10
10
  requires-python = ">=3.14"