From aff40eb065794aa34af2cae957cc4c9eeaffcbdc Mon Sep 17 00:00:00 2001 From: William Jamieson Date: Wed, 26 Jul 2023 18:37:22 -0400 Subject: [PATCH] TEMPORARY: Fix for numpy 2.0 representation changes for testing Due to ASDF issues related to changes in how `numpy` 2.0 represents for the purposes of printing floats (used by ASDF), PyYAML can no longer handle the new representation gracefully. This change simply forces `numpy` 2.0.dev+ versions of numpy to use the `numpy` 1.25 representation format, which is supported by PyYAML. Note that this "fix" only works when running tests, not in general. --- romancal/conftest.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/romancal/conftest.py b/romancal/conftest.py index c295b14e3..2e15aa07b 100644 --- a/romancal/conftest.py +++ b/romancal/conftest.py @@ -3,7 +3,15 @@ import os import tempfile +import numpy as np import pytest +from astropy.utils import minversion + +# HACK: This is a temporary workaround for ASDF not being able to handle how +# numpy 2.0.dev+ represents (prints) floating point numbers. This simply +# forces numpy to use the old printing method while running the tests only. +if minversion(np, "2.0.dev"): + np.set_printoptions(legacy="1.25") @pytest.fixture