From 993f5629860230cd056ed8ebcdd2e90d4494e4f3 Mon Sep 17 00:00:00 2001 From: Luke Marshall <52978038+mathgeekcoder@users.noreply.github.com> Date: Thu, 26 Sep 2024 16:27:13 -0700 Subject: [PATCH] Fixed python 3.8 typing issue. --- src/highspy/highs.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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.