diff --git a/src/highspy/highs.py b/src/highspy/highs.py index 91144d37de..80255b15d6 100644 --- a/src/highspy/highs.py +++ b/src/highspy/highs.py @@ -1,4 +1,5 @@ from __future__ import annotations +import sys import numpy as np from numbers import Integral from itertools import product @@ -15,6 +16,11 @@ kHighsInf, ) +# backwards typing support information for HighspyArray +if sys.version_info >= (3, 9): + ndarray_object_type = np.ndarray[Any, np.dtype[np.object_]] +else: + ndarray_object_type = np.ndarray class Highs(_Highs): """ @@ -1471,7 +1477,7 @@ def fire( fn(e) -class HighspyArray(np.ndarray[Any, np.dtype[np.object_]]): +class HighspyArray(ndarray_object_type): """ A numpy array wrapper for highs_var/highs_linear_expression objects.