Skip to content

Commit e88dd2e

Browse files
committed
2 parents 0717429 + 31e307c commit e88dd2e

File tree

7 files changed

+55
-4
lines changed

7 files changed

+55
-4
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,7 @@ docs/_build/
99
**/*.h5
1010
**/iframe_figures/
1111
.idea
12+
.env
13+
.venv
1214
.vscode
1315
venv

CHANGELOG.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,24 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [2.21.2] - 2024-05-08 08:44:48
9+
10+
### Fixed
11+
12+
- Generation of enum-typed variables
13+
14+
## [2.21.1] - 2024-05-07 15:44:58
15+
16+
### Fixed
17+
18+
- Bug in macro caching logic.
19+
20+
## [2.21.0] - 2024-05-07 12:16:05
21+
22+
### Added
23+
24+
- Ability to turn off read and write features in the macro cache.
25+
826
## [2.20.0] - 2024-05-06 14:24:08
927

1028
### Added
@@ -628,6 +646,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
628646

629647

630648

649+
[2.21.2]: https://github.com/PolicyEngine/policyengine-core/compare/2.21.1...2.21.2
650+
[2.21.1]: https://github.com/PolicyEngine/policyengine-core/compare/2.21.0...2.21.1
651+
[2.21.0]: https://github.com/PolicyEngine/policyengine-core/compare/2.20.0...2.21.0
631652
[2.20.0]: https://github.com/PolicyEngine/policyengine-core/compare/2.19.2...2.20.0
632653
[2.19.2]: https://github.com/PolicyEngine/policyengine-core/compare/2.19.1...2.19.2
633654
[2.19.1]: https://github.com/PolicyEngine/policyengine-core/compare/2.19.0...2.19.1

changelog.yaml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,3 +524,18 @@
524524
fixed:
525525
- Uprating bugs.
526526
date: 2024-05-06 14:24:08
527+
- bump: minor
528+
changes:
529+
added:
530+
- Ability to turn off read and write features in the macro cache.
531+
date: 2024-05-07 12:16:05
532+
- bump: patch
533+
changes:
534+
fixed:
535+
- Bug in macro caching logic.
536+
date: 2024-05-07 15:44:58
537+
- bump: patch
538+
changes:
539+
fixed:
540+
- Generation of enum-typed variables
541+
date: 2024-05-08 08:44:48

policyengine_core/enums/enum.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,18 @@ def encode(cls, array: Union[EnumArray, np.ndarray]) -> EnumArray:
4949
if isinstance(array, EnumArray):
5050
return array
5151

52-
if array.dtype.kind == "b":
52+
# if array.dtype.kind == "b":
53+
if isinstance(array == 0, bool):
5354
# Convert boolean array to string array
5455
array = array.astype(str)
5556

56-
if array.dtype.kind in {"U", "S"}:
57+
if isinstance(array, np.ndarray) and array.dtype.kind in {"U", "S"}:
5758
# String array
5859
indices = np.select(
5960
[array == item.name for item in cls],
6061
[item.index for item in cls],
6162
)
62-
elif array.dtype.kind == "O":
63+
elif isinstance(array, np.ndarray) and array.dtype.kind == "O":
6364
# Enum items array
6465
if len(array) > 0:
6566
first_item = array[0]

policyengine_core/parameters/parameter.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,8 @@ def update(self, period=None, start=None, stop=None, value=None):
210210

211211
self.parent.clear_parent_cache()
212212

213+
self.mark_as_modified()
214+
213215
def mark_as_modified(self):
214216
self.modified = True
215217
self.parent.mark_as_modified()

policyengine_core/simulations/simulation.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,12 @@ class Simulation:
6969
is_over_dataset: bool = False
7070
"""Whether this simulation is built over a dataset."""
7171

72+
macro_cache_read: bool = True
73+
"""Whether to read from the macro cache."""
74+
75+
macro_cache_write: bool = True
76+
"""Whether to write to the macro cache."""
77+
7278
def __init__(
7379
self,
7480
tax_benefit_system: "TaxBenefitSystem" = None,
@@ -1367,6 +1373,8 @@ def _get_macro_cache_value(
13671373
"""
13681374
Get the value of a variable from a cache file.
13691375
"""
1376+
if not self.macro_cache_read:
1377+
return None
13701378
with h5py.File(cache_file_path, "r") as f:
13711379
return f["values"][()]
13721380

@@ -1378,6 +1386,8 @@ def _set_macro_cache_value(
13781386
"""
13791387
Set the value of a variable in a cache file.
13801388
"""
1389+
if not self.macro_cache_write:
1390+
return None
13811391
with h5py.File(cache_file_path, "w") as f:
13821392
f.create_dataset("values", data=value)
13831393

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949

5050
setup(
5151
name="policyengine-core",
52-
version="2.20.0",
52+
version="2.21.2",
5353
author="PolicyEngine",
5454
author_email="[email protected]",
5555
classifiers=[

0 commit comments

Comments
 (0)