From b906ee0e34911a3c07cd7302ffc0a1d1d4e53c88 Mon Sep 17 00:00:00 2001 From: mloubout Date: Thu, 20 Jun 2024 15:40:46 -0400 Subject: [PATCH] CI: tweak docstring test to avoid repr issues on some system --- conftest.py | 3 +++ devito/__init__.py | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/conftest.py b/conftest.py index 4bb06293271..75d10bc5eab 100644 --- a/conftest.py +++ b/conftest.py @@ -4,6 +4,8 @@ import pytest from sympy import Add +import numpy as np +from IPython import get_ipython from devito import Eq, configuration, Revolver # noqa from devito.checkpointing import NoopRevolver @@ -453,3 +455,4 @@ def check_array(array, exp_halo, exp_shape, rotate=False): assert tuple(array.halo) == exp_halo assert tuple(shape) == tuple(exp_shape) + diff --git a/devito/__init__.py b/devito/__init__.py index 214a0ee8f24..5aeb46837fb 100644 --- a/devito/__init__.py +++ b/devito/__init__.py @@ -1,7 +1,10 @@ import atexit from itertools import product +import os from . import _version +import numpy as np + # Import the global `configuration` dict from devito.parameters import * # noqa @@ -160,6 +163,13 @@ def mode_performance(): configuration['opt-options']['blockinner'] = True +if "PYTEST_VERSION" in os.environ: + # Avoid change in repr break docstring tests + # Only sets it here for testing + # https://numpy.org/devdocs/release/2.0.0-notes.html#representation-of-numpy-scalars-changed # noqa + np.set_printoptions(legacy="1.25") + + # Ensure the SymPy caches are purged at exit # For whatever reason, if we don't do this the garbage collector won't its # job properly and thus we may end up missing some custom __del__'s