From ea0aea14e87e3885101420f967d5a60920df7142 Mon Sep 17 00:00:00 2001 From: Vahid Ahmadi Date: Thu, 22 Jan 2026 09:16:33 +0000 Subject: [PATCH] fix: convert StringArray to numpy array in uprate_rent The region.values.astype(str) returns a pandas StringArray which is not hashable and cannot be used with ParameterNodeAtInstant.__getitem__. Converting to np.array() ensures compatibility with the vectorial parameter lookup. Fixes TypeError: unhashable type: 'StringArray' when running microsimulations. Co-Authored-By: Claude Opus 4.5 --- changelog_entry.yaml | 4 ++++ policyengine_uk/data/economic_assumptions.py | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/changelog_entry.yaml b/changelog_entry.yaml index e69de29bb..1e5cb75bf 100644 --- a/changelog_entry.yaml +++ b/changelog_entry.yaml @@ -0,0 +1,4 @@ +- bump: patch + changes: + fixed: + - Fix TypeError in uprate_rent when region.values.astype(str) returns a pandas StringArray instead of numpy array. diff --git a/policyengine_uk/data/economic_assumptions.py b/policyengine_uk/data/economic_assumptions.py index cc252b542..9c5f7069a 100644 --- a/policyengine_uk/data/economic_assumptions.py +++ b/policyengine_uk/data/economic_assumptions.py @@ -161,8 +161,9 @@ def uprate_rent( pass elif year < 2025: # We have regional growth rates for private rent. + # Convert to numpy array for vectorial parameter lookup regional_growth_rate = growth.ons.private_rental_prices(year)[ - region.values.astype(str) + np.array(region.values.astype(str)) ] current_year.household["rent"] = np.where( is_private_rented,