apexdevkit 1.18.4__tar.gz → 1.18.5__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.
- {apexdevkit-1.18.4 → apexdevkit-1.18.5}/PKG-INFO +1 -1
- apexdevkit-1.18.5/apexdevkit/value.py +52 -0
- {apexdevkit-1.18.4 → apexdevkit-1.18.5}/pyproject.toml +1 -1
- apexdevkit-1.18.4/apexdevkit/value.py +0 -29
- {apexdevkit-1.18.4 → apexdevkit-1.18.5}/LICENSE +0 -0
- {apexdevkit-1.18.4 → apexdevkit-1.18.5}/README.md +0 -0
- {apexdevkit-1.18.4 → apexdevkit-1.18.5}/apexdevkit/__init__.py +0 -0
- {apexdevkit-1.18.4 → apexdevkit-1.18.5}/apexdevkit/annotation/__init__.py +0 -0
- {apexdevkit-1.18.4 → apexdevkit-1.18.5}/apexdevkit/annotation/deprecate.py +0 -0
- {apexdevkit-1.18.4 → apexdevkit-1.18.5}/apexdevkit/environment.py +0 -0
- {apexdevkit-1.18.4 → apexdevkit-1.18.5}/apexdevkit/error.py +0 -0
- {apexdevkit-1.18.4 → apexdevkit-1.18.5}/apexdevkit/fastapi/__init__.py +0 -0
- {apexdevkit-1.18.4 → apexdevkit-1.18.5}/apexdevkit/fastapi/builder.py +0 -0
- {apexdevkit-1.18.4 → apexdevkit-1.18.5}/apexdevkit/fastapi/dependable.py +0 -0
- {apexdevkit-1.18.4 → apexdevkit-1.18.5}/apexdevkit/fastapi/docs.py +0 -0
- {apexdevkit-1.18.4 → apexdevkit-1.18.5}/apexdevkit/fastapi/name.py +0 -0
- {apexdevkit-1.18.4 → apexdevkit-1.18.5}/apexdevkit/fastapi/request.py +0 -0
- {apexdevkit-1.18.4 → apexdevkit-1.18.5}/apexdevkit/fastapi/resource.py +0 -0
- {apexdevkit-1.18.4 → apexdevkit-1.18.5}/apexdevkit/fastapi/response.py +0 -0
- {apexdevkit-1.18.4 → apexdevkit-1.18.5}/apexdevkit/fastapi/router.py +0 -0
- {apexdevkit-1.18.4 → apexdevkit-1.18.5}/apexdevkit/fastapi/schema.py +0 -0
- {apexdevkit-1.18.4 → apexdevkit-1.18.5}/apexdevkit/fastapi/service.py +0 -0
- {apexdevkit-1.18.4 → apexdevkit-1.18.5}/apexdevkit/fluent.py +0 -0
- {apexdevkit-1.18.4 → apexdevkit-1.18.5}/apexdevkit/formatter.py +0 -0
- {apexdevkit-1.18.4 → apexdevkit-1.18.5}/apexdevkit/http/__init__.py +0 -0
- {apexdevkit-1.18.4 → apexdevkit-1.18.5}/apexdevkit/http/fake.py +0 -0
- {apexdevkit-1.18.4 → apexdevkit-1.18.5}/apexdevkit/http/fluent.py +0 -0
- {apexdevkit-1.18.4 → apexdevkit-1.18.5}/apexdevkit/http/httpx.py +0 -0
- {apexdevkit-1.18.4 → apexdevkit-1.18.5}/apexdevkit/http/json.py +0 -0
- {apexdevkit-1.18.4 → apexdevkit-1.18.5}/apexdevkit/http/url.py +0 -0
- {apexdevkit-1.18.4 → apexdevkit-1.18.5}/apexdevkit/key_fn.py +0 -0
- {apexdevkit-1.18.4 → apexdevkit-1.18.5}/apexdevkit/py.typed +0 -0
- {apexdevkit-1.18.4 → apexdevkit-1.18.5}/apexdevkit/query/__init__.py +0 -0
- {apexdevkit-1.18.4 → apexdevkit-1.18.5}/apexdevkit/query/generator.py +0 -0
- {apexdevkit-1.18.4 → apexdevkit-1.18.5}/apexdevkit/query/query.py +0 -0
- {apexdevkit-1.18.4 → apexdevkit-1.18.5}/apexdevkit/repository/__init__.py +0 -0
- {apexdevkit-1.18.4 → apexdevkit-1.18.5}/apexdevkit/repository/base.py +0 -0
- {apexdevkit-1.18.4 → apexdevkit-1.18.5}/apexdevkit/repository/connector.py +0 -0
- {apexdevkit-1.18.4 → apexdevkit-1.18.5}/apexdevkit/repository/database.py +0 -0
- {apexdevkit-1.18.4 → apexdevkit-1.18.5}/apexdevkit/repository/decorator.py +0 -0
- {apexdevkit-1.18.4 → apexdevkit-1.18.5}/apexdevkit/repository/in_memory.py +0 -0
- {apexdevkit-1.18.4 → apexdevkit-1.18.5}/apexdevkit/repository/interface.py +0 -0
- {apexdevkit-1.18.4 → apexdevkit-1.18.5}/apexdevkit/repository/mongo.py +0 -0
- {apexdevkit-1.18.4 → apexdevkit-1.18.5}/apexdevkit/repository/mssql.py +0 -0
- {apexdevkit-1.18.4 → apexdevkit-1.18.5}/apexdevkit/repository/sql.py +0 -0
- {apexdevkit-1.18.4 → apexdevkit-1.18.5}/apexdevkit/repository/sqlite.py +0 -0
- {apexdevkit-1.18.4 → apexdevkit-1.18.5}/apexdevkit/server.py +0 -0
- {apexdevkit-1.18.4 → apexdevkit-1.18.5}/apexdevkit/synchronization.py +0 -0
- {apexdevkit-1.18.4 → apexdevkit-1.18.5}/apexdevkit/testing/__init__.py +0 -0
- {apexdevkit-1.18.4 → apexdevkit-1.18.5}/apexdevkit/testing/database.py +0 -0
- {apexdevkit-1.18.4 → apexdevkit-1.18.5}/apexdevkit/testing/fake.py +0 -0
- {apexdevkit-1.18.4 → apexdevkit-1.18.5}/apexdevkit/testing/rest.py +0 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import math
|
|
4
|
+
from dataclasses import dataclass
|
|
5
|
+
from decimal import Decimal
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@dataclass(frozen=True)
|
|
9
|
+
class Value:
|
|
10
|
+
value: int = 0
|
|
11
|
+
exponent: int = 1
|
|
12
|
+
|
|
13
|
+
def as_decimal(self) -> Decimal:
|
|
14
|
+
return Decimal(self.value) / Decimal(self.exponent)
|
|
15
|
+
|
|
16
|
+
@classmethod
|
|
17
|
+
def from_string(cls, decimal_str: str) -> Value:
|
|
18
|
+
integer_part, _, fractional_part = decimal_str.partition(".")
|
|
19
|
+
value = int(integer_part + fractional_part)
|
|
20
|
+
exponent = 10 ** len(fractional_part)
|
|
21
|
+
return cls(value, exponent)
|
|
22
|
+
|
|
23
|
+
def add(self, other: Value) -> Value:
|
|
24
|
+
exponent = self.exponent * other.exponent
|
|
25
|
+
value = self.value * other.exponent + self.exponent * other.value
|
|
26
|
+
gcd = int(math.gcd(exponent, value))
|
|
27
|
+
return Value(int(value / gcd), int(exponent / gcd))
|
|
28
|
+
|
|
29
|
+
def subtract(self, other: Value) -> Value:
|
|
30
|
+
exponent = self.exponent * other.exponent
|
|
31
|
+
value = self.value * other.exponent - self.exponent * other.value
|
|
32
|
+
gcd = int(math.gcd(exponent, value))
|
|
33
|
+
return Value(int(value / gcd), int(exponent / gcd))
|
|
34
|
+
|
|
35
|
+
def multiply(self, other: Value) -> Value:
|
|
36
|
+
exponent = self.exponent * other.exponent
|
|
37
|
+
value = self.value * other.value
|
|
38
|
+
gcd = int(math.gcd(exponent, value))
|
|
39
|
+
return Value(int(value / gcd), int(exponent / gcd))
|
|
40
|
+
|
|
41
|
+
def divide(self, other: Value) -> Value:
|
|
42
|
+
exponent = self.exponent * other.value
|
|
43
|
+
value = self.value * other.exponent
|
|
44
|
+
gcd = int(math.gcd(exponent, value))
|
|
45
|
+
return Value(int(value / gcd), int(exponent / gcd))
|
|
46
|
+
|
|
47
|
+
def __eq__(self, other: object) -> bool:
|
|
48
|
+
if isinstance(other, Value):
|
|
49
|
+
return self.as_decimal() == other.as_decimal()
|
|
50
|
+
elif isinstance(other, Decimal):
|
|
51
|
+
return self.as_decimal() == other
|
|
52
|
+
return False
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
from __future__ import annotations
|
|
2
|
-
|
|
3
|
-
from dataclasses import dataclass
|
|
4
|
-
from decimal import Decimal
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
@dataclass(frozen=True)
|
|
8
|
-
class Value:
|
|
9
|
-
value: int = 0
|
|
10
|
-
exponent: int = 1
|
|
11
|
-
|
|
12
|
-
def as_decimal(self) -> Decimal:
|
|
13
|
-
return Decimal(self.value) / Decimal(self.exponent)
|
|
14
|
-
|
|
15
|
-
@classmethod
|
|
16
|
-
def from_string(cls, decimal_str: str) -> Value:
|
|
17
|
-
integer_part, _, fractional_part = decimal_str.partition(".")
|
|
18
|
-
value = int(integer_part + fractional_part)
|
|
19
|
-
exponent = 10 ** len(fractional_part)
|
|
20
|
-
return cls(value, exponent)
|
|
21
|
-
|
|
22
|
-
def add(self, other: Value) -> Value:
|
|
23
|
-
return Value(self.value + self._adjusted(other), self.exponent)
|
|
24
|
-
|
|
25
|
-
def subtract(self, other: Value) -> Value:
|
|
26
|
-
return Value(self.value - self._adjusted(other), self.exponent)
|
|
27
|
-
|
|
28
|
-
def _adjusted(self, other: Value) -> int:
|
|
29
|
-
return int(Decimal(other.value) / Decimal(other.exponent) * self.exponent)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|