Skip to content

Commit dce9130

Browse files
MaxGhenisclaude
andcommitted
Apply ruff formatting and add changelog fragment
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 450f89e commit dce9130

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Optimize simulation calculate with fast cache and vectorial parameter lookups.

policyengine_core/parameters/vectorial_parameter_node_at_instant.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -215,9 +215,7 @@ def __getitem__(self, key: str) -> Any:
215215
self._enum_lut_cache[cache_key] = lut
216216
idx = lut[numpy.asarray(key)]
217217
elif (
218-
key.dtype == object
219-
and len(key) > 0
220-
and issubclass(type(key[0]), Enum)
218+
key.dtype == object and len(key) > 0 and issubclass(type(key[0]), Enum)
221219
):
222220
# Object array of Enum instances
223221
enum = type(key[0])
@@ -371,19 +369,15 @@ def __getitem__(self, key: str) -> Any:
371369
v0 = numpy.asarray(values[0])
372370
if v0.ndim == 0 or v0.shape[0] <= 1:
373371
# Scalar per child: 1D lookup
374-
scalar_vals = numpy.empty(
375-
len(values) + 1, dtype=numpy.float64
376-
)
372+
scalar_vals = numpy.empty(len(values) + 1, dtype=numpy.float64)
377373
for i, v in enumerate(values):
378374
scalar_vals[i] = float(v)
379375
scalar_vals[-1] = numpy.nan
380376
result = scalar_vals[idx]
381377
else:
382378
# N-element vectors: stack into (K+1, N) matrix
383379
m = v0.shape[0]
384-
stacked = numpy.empty(
385-
(len(values) + 1, m), dtype=numpy.float64
386-
)
380+
stacked = numpy.empty((len(values) + 1, m), dtype=numpy.float64)
387381
for i, v in enumerate(values):
388382
stacked[i] = v
389383
stacked[-1] = numpy.nan

0 commit comments

Comments
 (0)