ImperialCollegeLondon / ImperialCollegeLondon/virtual_ecosystem

Switch away from `pint` time units

Open
#307 0 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
Python
Stars
20
Forks
5
Avg merge
2d 1h
Merged PRs (30d)
34

Description

**Describe the bug**

The `pint` time units are not calendar aware and use _average_ lengths for months etc. The critical `update_interval` is stored as a `pint.Quantity`. We need calendar aware time calculations, which are probably most easily achieved using `np.datetime64`and `np.timedelta64`. There doesn't seem to be a simple conversion between `pint.Quantity` and `np` without writing some kind of interpreter.

**Expected behavior**

Months should not be 30.4375 days.

I think `pint` is _only_ currently used for the `update_interval`. It seems easiest to replace it with using `np.timedelta64` and a config like `[1, 'month']` , with a slim wrapper to convert a subset of time intervals to e.g. `np.timedelta64(1, 'M')`.

Contributor guide

Open the contributing guide

Research direction

Start by locating the update_interval configuration and every current use of pint in the repository, then inspect how intervals are parsed and consumed. Replace the existing time-unit handling with calendar-aware intervals while preserving the configuration shape described in the issue; done means months are not treated as 30.4375 days and update intervals continue to work.

Written by the indexing model from the issue text.

Assessment

Tech stack
numpy, python
Domain
backend
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.