datedict 0.1.3__py3-none-any.whl → 0.1.5__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 CHANGED
@@ -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({k: (v if (not v.is_nan() and v >= ZERO) else ZERO) for k, v in self.data.items()})
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.
datedict/YearDict.py CHANGED
@@ -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({y: (v if (not v.is_nan() and v >= ZERO) else ZERO) for y, v in self.data.items()})
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
  """
@@ -1,13 +1,13 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: datedict
3
- Version: 0.1.3
3
+ Version: 0.1.5
4
4
  Summary: DateDict and YearDict: date-aware dictionary structures
5
- Project-URL: Homepage, https://github.com/you/datedict
6
- Project-URL: Issues, https://github.com/you/datedict/issues
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 Lorenzo Guideri
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=E697A7QgjQMwwHqcMsRVTCjWzZLw8sovHZG9caOw5CQ,7701
2
+ datedict/YearDict.py,sha256=xwVhMLklo7RjCChPsmSQ63pXaqbeAfIVe_zDnGZOIcQ,5419
3
+ datedict/__init__.py,sha256=4QSCqCW_owSqD3k3Oz1WAsB4p_vvzUlINroAxxFCEWQ,201
4
+ datedict/common.py,sha256=aUCsMV6roKGQIQXSFIJIN0cxAXIlK_YyRDWS1EIBu8E,424
5
+ datedict-0.1.5.dist-info/METADATA,sha256=RVL0i2_rKRaDv7aTLHnvDVnPK0SjWm7VrAZ7s7pQV90,1991
6
+ datedict-0.1.5.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
7
+ datedict-0.1.5.dist-info/licenses/LICENSE,sha256=GMmiaNfJSsljmGtIp9lCY6V-Dkc9NDZn0jSZuAbFe7Y,1070
8
+ datedict-0.1.5.dist-info/RECORD,,
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2025 Lorenzo Guideri
3
+ Copyright (c) 2025 DEC Energy SA
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -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,,