gazpar2haws 0.3.0b23__py3-none-any.whl → 0.3.0b24__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.
- gazpar2haws/date_array.py +20 -18
- gazpar2haws/gazpar.py +1 -1
- gazpar2haws/model.py +2 -1
- gazpar2haws/pricer.py +9 -1
- {gazpar2haws-0.3.0b23.dist-info → gazpar2haws-0.3.0b24.dist-info}/METADATA +1 -1
- {gazpar2haws-0.3.0b23.dist-info → gazpar2haws-0.3.0b24.dist-info}/RECORD +8 -8
- {gazpar2haws-0.3.0b23.dist-info → gazpar2haws-0.3.0b24.dist-info}/LICENSE +0 -0
- {gazpar2haws-0.3.0b23.dist-info → gazpar2haws-0.3.0b24.dist-info}/WHEEL +0 -0
gazpar2haws/date_array.py
CHANGED
@@ -11,6 +11,7 @@ from pydantic import BaseModel, ConfigDict, model_validator
|
|
11
11
|
class DateArray(BaseModel): # pylint: disable=too-few-public-methods
|
12
12
|
model_config = ConfigDict(arbitrary_types_allowed=True)
|
13
13
|
|
14
|
+
name: Optional[str] = None
|
14
15
|
start_date: dt.date
|
15
16
|
end_date: dt.date
|
16
17
|
array: Optional[np.ndarray] = None
|
@@ -39,7 +40,7 @@ class DateArray(BaseModel): # pylint: disable=too-few-public-methods
|
|
39
40
|
if self.array is None:
|
40
41
|
raise ValueError("Array is not initialized")
|
41
42
|
|
42
|
-
result = DateArray(start_date=self.start_date, end_date=self.end_date)
|
43
|
+
result = DateArray(name=f"cumsum_{self.name}", start_date=self.start_date, end_date=self.end_date)
|
43
44
|
result.array = np.cumsum(self.array)
|
44
45
|
return result
|
45
46
|
|
@@ -77,7 +78,10 @@ class DateArray(BaseModel): # pylint: disable=too-few-public-methods
|
|
77
78
|
f"Date slice [{start_date}:{end_date}] is out of range [{self.start_date}:{self.end_date}]"
|
78
79
|
)
|
79
80
|
return DateArray(
|
80
|
-
|
81
|
+
name=self.name,
|
82
|
+
start_date=start_date,
|
83
|
+
end_date=end_date + timedelta(-1),
|
84
|
+
array=self.array[start_index:end_index],
|
81
85
|
)
|
82
86
|
raise TypeError("Key must be a date or a slice of dates")
|
83
87
|
|
@@ -110,8 +114,6 @@ class DateArray(BaseModel): # pylint: disable=too-few-public-methods
|
|
110
114
|
raise ValueError(
|
111
115
|
f"Date slice [{start_date}:{end_date}] is out of range [{self.start_date}:{self.end_date}]"
|
112
116
|
)
|
113
|
-
self.start_date = start_date
|
114
|
-
self.end_date = end_date + timedelta(-1)
|
115
117
|
if isinstance(value, float):
|
116
118
|
self.array[start_index:end_index] = value
|
117
119
|
elif isinstance(value, DateArray):
|
@@ -156,15 +158,15 @@ class DateArray(BaseModel): # pylint: disable=too-few-public-methods
|
|
156
158
|
raise ValueError("Array is not initialized")
|
157
159
|
|
158
160
|
if isinstance(other, (int, float)):
|
159
|
-
result = DateArray(start_date=self.start_date, end_date=self.end_date)
|
161
|
+
result = DateArray(name=self.name, start_date=self.start_date, end_date=self.end_date)
|
160
162
|
result.array = self.array + other
|
161
163
|
return result
|
162
164
|
if isinstance(other, DateArray):
|
163
165
|
if other.array is None:
|
164
166
|
raise ValueError("Array is not initialized")
|
165
167
|
if not self.is_aligned_with(other):
|
166
|
-
raise ValueError("Date arrays are not aligned")
|
167
|
-
result = DateArray(start_date=self.start_date, end_date=self.end_date)
|
168
|
+
raise ValueError(f"Date arrays {self} and {other} are not aligned")
|
169
|
+
result = DateArray(name=self.name, start_date=self.start_date, end_date=self.end_date)
|
168
170
|
result.array = self.array + other.array # pylint: disable=protected-access
|
169
171
|
return result
|
170
172
|
|
@@ -183,15 +185,15 @@ class DateArray(BaseModel): # pylint: disable=too-few-public-methods
|
|
183
185
|
raise ValueError("Array is not initialized")
|
184
186
|
|
185
187
|
if isinstance(other, (int, float)):
|
186
|
-
result = DateArray(start_date=self.start_date, end_date=self.end_date)
|
188
|
+
result = DateArray(name=self.name, start_date=self.start_date, end_date=self.end_date)
|
187
189
|
result.array = self.array - other
|
188
190
|
return result
|
189
191
|
if isinstance(other, DateArray):
|
190
192
|
if other.array is None:
|
191
193
|
raise ValueError("Array is not initialized")
|
192
194
|
if not self.is_aligned_with(other):
|
193
|
-
raise ValueError("Date arrays are not aligned")
|
194
|
-
result = DateArray(start_date=self.start_date, end_date=self.end_date)
|
195
|
+
raise ValueError(f"Date arrays {self} and {other} are not aligned")
|
196
|
+
result = DateArray(name=self.name, start_date=self.start_date, end_date=self.end_date)
|
195
197
|
result.array = self.array - other.array # pylint: disable=protected-access
|
196
198
|
return result
|
197
199
|
|
@@ -210,15 +212,15 @@ class DateArray(BaseModel): # pylint: disable=too-few-public-methods
|
|
210
212
|
raise ValueError("Array is not initialized")
|
211
213
|
|
212
214
|
if isinstance(other, (int, float)):
|
213
|
-
result = DateArray(start_date=self.start_date, end_date=self.end_date)
|
215
|
+
result = DateArray(name=self.name, start_date=self.start_date, end_date=self.end_date)
|
214
216
|
result.array = self.array * other
|
215
217
|
return result
|
216
218
|
if isinstance(other, DateArray):
|
217
219
|
if other.array is None:
|
218
220
|
raise ValueError("Array is not initialized")
|
219
221
|
if not self.is_aligned_with(other):
|
220
|
-
raise ValueError("Date arrays are not aligned")
|
221
|
-
result = DateArray(start_date=self.start_date, end_date=self.end_date)
|
222
|
+
raise ValueError(f"Date arrays {self} and {other} are not aligned")
|
223
|
+
result = DateArray(name=self.name, start_date=self.start_date, end_date=self.end_date)
|
222
224
|
result.array = self.array * other.array # pylint: disable=protected-access
|
223
225
|
return result
|
224
226
|
|
@@ -237,21 +239,21 @@ class DateArray(BaseModel): # pylint: disable=too-few-public-methods
|
|
237
239
|
raise ValueError("Array is not initialized")
|
238
240
|
|
239
241
|
if isinstance(other, (int, float)):
|
240
|
-
result = DateArray(start_date=self.start_date, end_date=self.end_date)
|
242
|
+
result = DateArray(name=self.name, start_date=self.start_date, end_date=self.end_date)
|
241
243
|
result.array = self.array / other
|
242
244
|
return result
|
243
245
|
if isinstance(other, DateArray):
|
244
246
|
if other.array is None:
|
245
247
|
raise ValueError("Array is not initialized")
|
246
248
|
if not self.is_aligned_with(other):
|
247
|
-
raise ValueError("Date arrays are not aligned")
|
248
|
-
result = DateArray(start_date=self.start_date, end_date=self.end_date)
|
249
|
+
raise ValueError(f"Date arrays {self} and {other} are not aligned")
|
250
|
+
result = DateArray(name=self.name, start_date=self.start_date, end_date=self.end_date)
|
249
251
|
result.array = self.array / other.array # pylint: disable=protected-access
|
250
252
|
return result
|
251
253
|
|
252
254
|
raise TypeError("Other must be a date array or a number")
|
253
255
|
|
254
256
|
# ----------------------------------
|
255
|
-
def
|
257
|
+
def __str__(self) -> str:
|
256
258
|
|
257
|
-
return f"DateArray(start_date={self.start_date}, end_date={self.end_date}, array={self.array})"
|
259
|
+
return f"DateArray(name={self.name}, start_date={self.start_date}, end_date={self.end_date}, array={self.array}, slots={(self.end_date - self.start_date).days + 1}, length={len(self)})"
|
gazpar2haws/gazpar.py
CHANGED
@@ -260,7 +260,7 @@ class Gazpar:
|
|
260
260
|
# Fill the quantity array.
|
261
261
|
if reading[property_name] is not None:
|
262
262
|
if res is None:
|
263
|
-
res = DateArray(start_date=start_date, end_date=end_date)
|
263
|
+
res = DateArray(name=property_name, start_date=start_date, end_date=end_date)
|
264
264
|
res[reading_date] = reading[property_name]
|
265
265
|
|
266
266
|
return res
|
gazpar2haws/model.py
CHANGED
@@ -104,13 +104,14 @@ class Value(Period):
|
|
104
104
|
|
105
105
|
# ----------------------------------
|
106
106
|
class ValueArray(Period):
|
107
|
+
name: Optional[str] = None
|
107
108
|
value_array: Optional[DateArray] = None
|
108
109
|
|
109
110
|
@model_validator(mode="after")
|
110
111
|
def set_value_array(self):
|
111
112
|
if self.value_array is None:
|
112
113
|
self.value_array = DateArray(
|
113
|
-
start_date=self.start_date, end_date=self.end_date
|
114
|
+
name=self.name, start_date=self.start_date, end_date=self.end_date
|
114
115
|
) # pylint: disable=attribute-defined-outside-init
|
115
116
|
return self
|
116
117
|
|
gazpar2haws/pricer.py
CHANGED
@@ -105,6 +105,7 @@ class Pricer:
|
|
105
105
|
)
|
106
106
|
else:
|
107
107
|
subscription_price_array = SubscriptionPriceArray(
|
108
|
+
name="subscription_prices",
|
108
109
|
start_date=start_date,
|
109
110
|
end_date=end_date,
|
110
111
|
value_unit=price_unit,
|
@@ -121,6 +122,7 @@ class Pricer:
|
|
121
122
|
)
|
122
123
|
else:
|
123
124
|
transport_price_array = TransportPriceArray(
|
125
|
+
name="transport_prices",
|
124
126
|
start_date=start_date,
|
125
127
|
end_date=end_date,
|
126
128
|
value_unit=price_unit,
|
@@ -137,6 +139,7 @@ class Pricer:
|
|
137
139
|
)
|
138
140
|
else:
|
139
141
|
energy_taxes_price_array = EnergyTaxesPriceArray(
|
142
|
+
name="energy_taxes",
|
140
143
|
start_date=start_date,
|
141
144
|
end_date=end_date,
|
142
145
|
value_unit=price_unit,
|
@@ -144,6 +147,7 @@ class Pricer:
|
|
144
147
|
)
|
145
148
|
|
146
149
|
res = CostArray(
|
150
|
+
name="costs",
|
147
151
|
start_date=start_date,
|
148
152
|
end_date=end_date,
|
149
153
|
value_unit=price_unit,
|
@@ -167,7 +171,7 @@ class Pricer:
|
|
167
171
|
res = dict[str, VatRateArray]()
|
168
172
|
vat_rate_by_id = dict[str, list[VatRate]]()
|
169
173
|
for vat_rate in vat_rates:
|
170
|
-
res[vat_rate.id] = VatRateArray(id=vat_rate.id, start_date=start_date, end_date=end_date)
|
174
|
+
res[vat_rate.id] = VatRateArray(name="vats", id=vat_rate.id, start_date=start_date, end_date=end_date)
|
171
175
|
if vat_rate.id not in vat_rate_by_id:
|
172
176
|
vat_rate_by_id[vat_rate.id] = list[VatRate]()
|
173
177
|
vat_rate_by_id[vat_rate.id].append(vat_rate)
|
@@ -193,6 +197,7 @@ class Pricer:
|
|
193
197
|
first_consumption_price = consumption_prices[0]
|
194
198
|
|
195
199
|
res = ConsumptionPriceArray(
|
200
|
+
name="consumption_prices",
|
196
201
|
start_date=start_date,
|
197
202
|
end_date=end_date,
|
198
203
|
value_unit=first_consumption_price.value_unit,
|
@@ -220,6 +225,7 @@ class Pricer:
|
|
220
225
|
first_subscription_price = subscription_prices[0]
|
221
226
|
|
222
227
|
res = SubscriptionPriceArray(
|
228
|
+
name="subscription_prices",
|
223
229
|
start_date=start_date,
|
224
230
|
end_date=end_date,
|
225
231
|
value_unit=first_subscription_price.value_unit,
|
@@ -247,6 +253,7 @@ class Pricer:
|
|
247
253
|
first_transport_price = transport_prices[0]
|
248
254
|
|
249
255
|
res = TransportPriceArray(
|
256
|
+
name="transport_prices",
|
250
257
|
start_date=start_date,
|
251
258
|
end_date=end_date,
|
252
259
|
value_unit=first_transport_price.value_unit,
|
@@ -274,6 +281,7 @@ class Pricer:
|
|
274
281
|
first_energy_taxes_price = energy_taxes_prices[0]
|
275
282
|
|
276
283
|
res = EnergyTaxesPriceArray(
|
284
|
+
name="energy_taxes",
|
277
285
|
start_date=start_date,
|
278
286
|
end_date=end_date,
|
279
287
|
value_unit=first_energy_taxes_price.value_unit,
|
@@ -3,13 +3,13 @@ gazpar2haws/__main__.py,sha256=wD28dqa3weiz5cj9--hgLLN7FnW0eeA9ZmlIvriKXNk,3125
|
|
3
3
|
gazpar2haws/bridge.py,sha256=VEl22xt2Szgk_FVrxSvZNxp3T5Q2JXc9ulfrunHHkmo,3685
|
4
4
|
gazpar2haws/config_utils.py,sha256=yT2G-naMA2Vst6bQdm1bD2oVsPTU3Q_RuukCs-dZ6Ak,2280
|
5
5
|
gazpar2haws/configuration.py,sha256=24q8FUBMS1vpqU6RYAv5Au179HbiBk1CZIEMiBGuXq0,722
|
6
|
-
gazpar2haws/date_array.py,sha256=
|
7
|
-
gazpar2haws/gazpar.py,sha256=
|
6
|
+
gazpar2haws/date_array.py,sha256=q3xTX-KS2KOtFSB042OJVerZFtS-Jw9Iin5RHKnobPs,10108
|
7
|
+
gazpar2haws/gazpar.py,sha256=yNLjQvef39CRMXIRpvPf_i1fErW7nyiEeTY-Y-fQX1M,14244
|
8
8
|
gazpar2haws/haws.py,sha256=1ELdompdACNf5XkpjCN6Bdiw7stPfzar3x8OjoBmhxQ,7969
|
9
|
-
gazpar2haws/model.py,sha256
|
10
|
-
gazpar2haws/pricer.py,sha256=
|
9
|
+
gazpar2haws/model.py,sha256=rn6gP8z5OVCQO3BZsExD68BaOExumiCv36wuPyOvS5M,7103
|
10
|
+
gazpar2haws/pricer.py,sha256=7xlLlPU6pXQcOnyaeoR_UEQOwuPwUG_V17FvPgSxzmM,22434
|
11
11
|
gazpar2haws/version.py,sha256=9Iq5Jm63Ev7QquCjhDqa9_KAgHdKl9FJHynq8M6JNrY,83
|
12
|
-
gazpar2haws-0.3.
|
13
|
-
gazpar2haws-0.3.
|
14
|
-
gazpar2haws-0.3.
|
15
|
-
gazpar2haws-0.3.
|
12
|
+
gazpar2haws-0.3.0b24.dist-info/LICENSE,sha256=ajApZPyhVx8AU9wN7DXeRGhoWFqY2ylBZUa5GRhTmok,1073
|
13
|
+
gazpar2haws-0.3.0b24.dist-info/METADATA,sha256=6M20J0acDl6wMhU_Q3g1XmqFujsU-zqAtZccodMVXhE,17406
|
14
|
+
gazpar2haws-0.3.0b24.dist-info/WHEEL,sha256=RaoafKOydTQ7I_I3JTrPCg6kUmTgtm4BornzOqyEfJ8,88
|
15
|
+
gazpar2haws-0.3.0b24.dist-info/RECORD,,
|
File without changes
|
File without changes
|