datedict 0.1.3__py3-none-any.whl → 0.1.4__py3-none-any.whl
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/DateDict.py +7 -3
- datedict/YearDict.py +8 -4
- {datedict-0.1.3.dist-info → datedict-0.1.4.dist-info}/METADATA +4 -4
- datedict-0.1.4.dist-info/RECORD +8 -0
- {datedict-0.1.3.dist-info → datedict-0.1.4.dist-info}/licenses/LICENSE +1 -1
- datedict-0.1.3.dist-info/RECORD +0 -8
- {datedict-0.1.3.dist-info → datedict-0.1.4.dist-info}/WHEEL +0 -0
datedict/DateDict.py
CHANGED
|
@@ -6,7 +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):
|
|
9
|
+
def __init__(self, data: Mapping[str, Decimable] = dict(), strict: bool = True):
|
|
10
10
|
if not data:
|
|
11
11
|
raise ValueError("Data cannot be empty.")
|
|
12
12
|
dates = sorted(data.keys())
|
|
@@ -109,7 +109,12 @@ class DateDict:
|
|
|
109
109
|
"""
|
|
110
110
|
Return a new DateDict with all negative values set to zero.
|
|
111
111
|
"""
|
|
112
|
-
return DateDict(
|
|
112
|
+
return DateDict(
|
|
113
|
+
{
|
|
114
|
+
k: (v if (not v.is_nan() and v >= ZERO) else ZERO)
|
|
115
|
+
for k, v in self.data.items()
|
|
116
|
+
}
|
|
117
|
+
)
|
|
113
118
|
|
|
114
119
|
def sum(
|
|
115
120
|
self: "DateDict", start: str | None = None, end: str | None = None
|
|
@@ -202,7 +207,6 @@ class DateDict:
|
|
|
202
207
|
"""
|
|
203
208
|
return dict(self.data)
|
|
204
209
|
|
|
205
|
-
|
|
206
210
|
def average(self) -> Decimal:
|
|
207
211
|
"""
|
|
208
212
|
Calculate the average of all values in the DateDict.
|
datedict/YearDict.py
CHANGED
|
@@ -5,7 +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):
|
|
8
|
+
def __init__(self, data: Mapping[int, Decimable] = dict(), strict: bool = True):
|
|
9
9
|
if not data:
|
|
10
10
|
raise ValueError("Data cannot be empty.")
|
|
11
11
|
years = sorted(data.keys())
|
|
@@ -56,8 +56,7 @@ class YearDict:
|
|
|
56
56
|
k: (self.get(k, to_decimal(initial_value)))
|
|
57
57
|
for k in range(
|
|
58
58
|
self.start_year if start is None else int(start),
|
|
59
|
-
self.end_year if end is None else int(end)
|
|
60
|
-
+1,
|
|
59
|
+
self.end_year if end is None else int(end) + 1,
|
|
61
60
|
)
|
|
62
61
|
}
|
|
63
62
|
)
|
|
@@ -66,7 +65,12 @@ class YearDict:
|
|
|
66
65
|
"""
|
|
67
66
|
Return a new YearDict with all negative values set to zero.
|
|
68
67
|
"""
|
|
69
|
-
return YearDict(
|
|
68
|
+
return YearDict(
|
|
69
|
+
{
|
|
70
|
+
y: (v if (not v.is_nan() and v >= ZERO) else ZERO)
|
|
71
|
+
for y, v in self.data.items()
|
|
72
|
+
}
|
|
73
|
+
)
|
|
70
74
|
|
|
71
75
|
def sum(self, start: int | None = None, end: int | None = None) -> Decimal:
|
|
72
76
|
"""
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: datedict
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.4
|
|
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
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
datedict/DateDict.py,sha256=2UdkSp-dVFqmbFMWnlK7Ol1Gixv2koiwjWw7tw79Zhs,7776
|
|
2
|
+
datedict/YearDict.py,sha256=EcVg4y8Tzfgr33KjCIdoKP4GUN1GDVOrxGpHDH0ZLGQ,5494
|
|
3
|
+
datedict/__init__.py,sha256=4QSCqCW_owSqD3k3Oz1WAsB4p_vvzUlINroAxxFCEWQ,201
|
|
4
|
+
datedict/common.py,sha256=aUCsMV6roKGQIQXSFIJIN0cxAXIlK_YyRDWS1EIBu8E,424
|
|
5
|
+
datedict-0.1.4.dist-info/METADATA,sha256=-SL17egrcvdh_MkOPa84wvJyFUeRNQ88tlw2tvYuYwE,1991
|
|
6
|
+
datedict-0.1.4.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
7
|
+
datedict-0.1.4.dist-info/licenses/LICENSE,sha256=GMmiaNfJSsljmGtIp9lCY6V-Dkc9NDZn0jSZuAbFe7Y,1070
|
|
8
|
+
datedict-0.1.4.dist-info/RECORD,,
|
datedict-0.1.3.dist-info/RECORD
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
datedict/DateDict.py,sha256=YsvCgsNGHKDaCya8KEb3KrTo98cxoiXZrr6xqsz2Mq8,7700
|
|
2
|
-
datedict/YearDict.py,sha256=YI6lE1SXYoK4R7LKLGLt75_ISNg0snBEJ_Uk4E-0c6c,5436
|
|
3
|
-
datedict/__init__.py,sha256=4QSCqCW_owSqD3k3Oz1WAsB4p_vvzUlINroAxxFCEWQ,201
|
|
4
|
-
datedict/common.py,sha256=aUCsMV6roKGQIQXSFIJIN0cxAXIlK_YyRDWS1EIBu8E,424
|
|
5
|
-
datedict-0.1.3.dist-info/METADATA,sha256=YW0NObrsMdZrHZE_plT8MEhw2lRSwzT3yontyIV8D2g,1985
|
|
6
|
-
datedict-0.1.3.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
7
|
-
datedict-0.1.3.dist-info/licenses/LICENSE,sha256=ULDgLM2c4o9DLMR-VEkeyuB-DRWBFX7VunJmlWShWxQ,1072
|
|
8
|
-
datedict-0.1.3.dist-info/RECORD,,
|
|
File without changes
|