You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Apply local workaround for scmdata + numpy 2.x StringDtype bug (blocking Python 3.12 support) #6
PR #4 added Python 3.12 compat fixes (distutils removal, numpy 2.x scalar handling) but deliberately did not declare 3.12 support in pyproject.toml classifiers because one test still fails on 3.12:
tests/unit/test_fair1x_utils.py::test_emissions_to_ignore
-> scmdata/groupby.py:61: np.issubdtype on a pandas StringDtype -> TypeError
This is reached via ScmRun.convert_unit, which is called from _scmdf_to_emissions._get_fair_col_unit_context. So the FaIR 1.6 adapter is effectively broken on Python 3.12 until the upstream bug is fixed.
When we decide we need Python 3.12 support before the upstream scmdata fix is released, apply a local workaround so we are not blocked. Options:
Pin scmdata to the last known-good version (or to a version with the fix once released).
Cast StringDtype meta to object at the point where openscm-runner constructs an ScmRun from CSV, in _scmdf_to_emissions.HistoricalWorldEmms.values_fair_units. Pre-normalises the dtype so the eventual convert_unit -> groupby call inside scmdata does not trip the bug.
Avoid convert_unit in this adapter and do the unit conversion via openscm_units directly. Larger refactor; aligns with the longer-term direction of leaning less on scmdata.
Drop the workaround once scmdata#318 ships in a release we depend on.
When
Not urgent for current AR7 work since we are on Python 3.9 fine today and IIASA climate-assessment is likely on similar versions for the next year+. Revisit when:
We need 3.12 for a real use case, or
scmdata releases the fix (upstream issue is likely to sit for months given the project's maintenance state)
Update: there's a second upstream bug behind this one. With openscm/scmdata#319 (StringDtype fix) applied, convert_unit advances and then trips on openscm/scmdata#320 (ValueError: assignment destination is read-only from apply_units doing in-place writes via df.values[:] under pandas 3.x copy-on-write).
So the path to 3.12 support is:
Wait-for-upstream: both #319 and #320 need to ship, or
Local workaround: would need to address both bugs, not just the StringDtype one. Workaround options 2 and 3 in the issue description (StringDtype cast / avoid convert_unit) cover both cases because they bypass convert_unit entirely. Option 1 (pin scmdata) only works once a fixed version is released.
Still not urgent; revisit when 3.12 becomes a real need or when both upstream PRs land.
Activity
benmsanderson commentedon May 22, 2026
Update: there's a second upstream bug behind this one. With openscm/scmdata#319 (StringDtype fix) applied,
convert_unitadvances and then trips on openscm/scmdata#320 (ValueError: assignment destination is read-onlyfromapply_unitsdoing in-place writes viadf.values[:]under pandas 3.x copy-on-write).So the path to 3.12 support is:
convert_unit) cover both cases because they bypassconvert_unitentirely. Option 1 (pin scmdata) only works once a fixed version is released.Still not urgent; revisit when 3.12 becomes a real need or when both upstream PRs land.
Joint FaIRv2 + CICEROSCMPY2 RCMIP smoke test (4 SSPs x 20 members)
Joint FaIRv2 + CICEROSCMPY2 RCMIP smoke test (4 SSPs x 20 members)