Skip to content

Store retirement_age as int16 to shrink the parameters object - #1230

Open
arihantlodha-cmd wants to merge 1 commit into
PSLmodels:masterfrom
arihantlodha-cmd:retirement-age-int16
Open

arihantlodha-cmd wants to merge 1 commit into
PSLmodels:masterfrom
arihantlodha-cmd:retirement-age-int16

Conversation

@arihantlodha-cmd

Copy link
Copy Markdown
Contributor

What this does

Addresses the data-type part of #1080. retirement_age is a whole number of years, bounded well under the int16 range, but it was stored as a float64 array of length T+S. Casting it to int16 (rounding first, which keeps behavior identical to how it is already consumed in the retire calculation) cuts that array from 8 to 2 bytes per element.

Behavior and testing

A baseline SS still solves to r = 0.0628 with pension outlays unchanged, retire is byte-for-byte the same (44 in the default calibration), and tests/test_parameters.py passes (16 passed). ruff check/format clean.

Scope

This is the safe, self-contained piece of #1080. The broader float32/float16 downcasting of other arrays suggested in the issue would change numerical results, and the T-dimension array truncation is a larger refactor; both are left for separate work and a maintainer decision on the accuracy/memory tradeoff.

Addresses the data-type part of PSLmodels#1080. retirement_age is a whole number of
years, bounded well under the int16 range, but it was stored as a float64
array of length T+S. Casting it to int16 (rounding first, which keeps
behavior identical to how it is already consumed in the retire calculation)
cuts that array from 8 to 2 bytes per element.

A baseline SS still solves to r = 0.0628 with pension outlays unchanged, and
tests/test_parameters.py passes. This is the safe, self-contained piece of
PSLmodels#1080; the broader float32/float16 downcasting of other arrays would change
numerical results and is left out.
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 75.18%. Comparing base (9baa4b2) to head (fe9d3f3).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1230   +/-   ##
=======================================
  Coverage   75.17%   75.18%           
=======================================
  Files          24       24           
  Lines        6031     6032    +1     
=======================================
+ Hits         4534     4535    +1     
  Misses       1497     1497           
Flag Coverage Δ
unittests 75.18% <100.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
ogcore/parameters.py 81.87% <100.00%> (+0.10%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants