Skip to content

Commit

Permalink
TEMPORARY: Fix for numpy 2.0 representation changes for testing
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
WilliamJamieson committed Jul 26, 2023
1 parent e4e4c9a commit aff40eb
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions romancal/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit aff40eb

Please sign in to comment.