datedict 0.1.3__tar.gz → 0.1.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.
Potentially problematic release.
This version of datedict might be problematic. Click here for more details.
- {datedict-0.1.3 → datedict-0.1.5}/.gitignore +1 -1
- {datedict-0.1.3 → datedict-0.1.5}/LICENSE +1 -1
- {datedict-0.1.3 → datedict-0.1.5}/PKG-INFO +4 -4
- {datedict-0.1.3 → datedict-0.1.5}/pyproject.toml +3 -3
- {datedict-0.1.3 → datedict-0.1.5}/src/datedict/DateDict.py +7 -5
- {datedict-0.1.3 → datedict-0.1.5}/src/datedict/YearDict.py +8 -6
- {datedict-0.1.3 → datedict-0.1.5}/.gitlab-ci.yml +0 -0
- {datedict-0.1.3 → datedict-0.1.5}/README.md +0 -0
- {datedict-0.1.3 → datedict-0.1.5}/pytest.ini +0 -0
- {datedict-0.1.3 → datedict-0.1.5}/src/datedict/__init__.py +0 -0
- {datedict-0.1.3 → datedict-0.1.5}/src/datedict/common.py +0 -0
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: datedict
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.5
|
|
4
4
|
Summary: DateDict and YearDict: date-aware dictionary structures
|
|
5
|
-
Project-URL: Homepage, https://
|
|
6
|
-
Project-URL: Issues, https://
|
|
5
|
+
Project-URL: Homepage, https://gitlab.com/grisus/datedict
|
|
6
|
+
Project-URL: Issues, https://gitlab.com/grisus/datedict/-/issues
|
|
7
7
|
Author-email: Lorenzo Guideri <lorenzo.guideri@dec-energy.ch>
|
|
8
8
|
License: MIT License
|
|
9
9
|
|
|
10
|
-
Copyright (c) 2025
|
|
10
|
+
Copyright (c) 2025 DEC Energy SA
|
|
11
11
|
|
|
12
12
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
13
13
|
of this software and associated documentation files (the "Software"), to deal
|
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "datedict"
|
|
7
|
-
version = "0.1.
|
|
7
|
+
version = "0.1.5"
|
|
8
8
|
description = "DateDict and YearDict: date-aware dictionary structures"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.10"
|
|
@@ -19,8 +19,8 @@ classifiers = [
|
|
|
19
19
|
dependencies = []
|
|
20
20
|
|
|
21
21
|
[project.urls]
|
|
22
|
-
Homepage = "https://
|
|
23
|
-
Issues = "https://
|
|
22
|
+
Homepage = "https://gitlab.com/grisus/datedict"
|
|
23
|
+
Issues = "https://gitlab.com/grisus/datedict/-/issues"
|
|
24
24
|
|
|
25
25
|
[tool.hatch.build.targets.wheel]
|
|
26
26
|
packages = ["src/datedict"]
|
|
@@ -6,9 +6,7 @@ from .common import NAN, ONE, Decimable, to_decimal, ZERO
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
class DateDict:
|
|
9
|
-
def __init__(self, data: Mapping[str, Decimable], strict: bool = True):
|
|
10
|
-
if not data:
|
|
11
|
-
raise ValueError("Data cannot be empty.")
|
|
9
|
+
def __init__(self, data: Mapping[str, Decimable] = dict(), strict: bool = True):
|
|
12
10
|
dates = sorted(data.keys())
|
|
13
11
|
if strict:
|
|
14
12
|
# enforce contiguous coverage
|
|
@@ -109,7 +107,12 @@ class DateDict:
|
|
|
109
107
|
"""
|
|
110
108
|
Return a new DateDict with all negative values set to zero.
|
|
111
109
|
"""
|
|
112
|
-
return DateDict(
|
|
110
|
+
return DateDict(
|
|
111
|
+
{
|
|
112
|
+
k: (v if (not v.is_nan() and v >= ZERO) else ZERO)
|
|
113
|
+
for k, v in self.data.items()
|
|
114
|
+
}
|
|
115
|
+
)
|
|
113
116
|
|
|
114
117
|
def sum(
|
|
115
118
|
self: "DateDict", start: str | None = None, end: str | None = None
|
|
@@ -202,7 +205,6 @@ class DateDict:
|
|
|
202
205
|
"""
|
|
203
206
|
return dict(self.data)
|
|
204
207
|
|
|
205
|
-
|
|
206
208
|
def average(self) -> Decimal:
|
|
207
209
|
"""
|
|
208
210
|
Calculate the average of all values in the DateDict.
|
|
@@ -5,9 +5,7 @@ from .common import NAN, ONE, Decimable, to_decimal, ZERO
|
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
class YearDict:
|
|
8
|
-
def __init__(self, data: Mapping[int, Decimable], strict: bool = True):
|
|
9
|
-
if not data:
|
|
10
|
-
raise ValueError("Data cannot be empty.")
|
|
8
|
+
def __init__(self, data: Mapping[int, Decimable] = dict(), strict: bool = True):
|
|
11
9
|
years = sorted(data.keys())
|
|
12
10
|
if strict:
|
|
13
11
|
# enforce contiguous coverage
|
|
@@ -56,8 +54,7 @@ class YearDict:
|
|
|
56
54
|
k: (self.get(k, to_decimal(initial_value)))
|
|
57
55
|
for k in range(
|
|
58
56
|
self.start_year if start is None else int(start),
|
|
59
|
-
self.end_year if end is None else int(end)
|
|
60
|
-
+1,
|
|
57
|
+
self.end_year if end is None else int(end) + 1,
|
|
61
58
|
)
|
|
62
59
|
}
|
|
63
60
|
)
|
|
@@ -66,7 +63,12 @@ class YearDict:
|
|
|
66
63
|
"""
|
|
67
64
|
Return a new YearDict with all negative values set to zero.
|
|
68
65
|
"""
|
|
69
|
-
return YearDict(
|
|
66
|
+
return YearDict(
|
|
67
|
+
{
|
|
68
|
+
y: (v if (not v.is_nan() and v >= ZERO) else ZERO)
|
|
69
|
+
for y, v in self.data.items()
|
|
70
|
+
}
|
|
71
|
+
)
|
|
70
72
|
|
|
71
73
|
def sum(self, start: int | None = None, end: int | None = None) -> Decimal:
|
|
72
74
|
"""
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|