From 262671db0dee20258687fb563e62106ec7d05d86 Mon Sep 17 00:00:00 2001 From: Thomas Robitaille Date: Fri, 12 Jul 2024 13:56:42 +0100 Subject: [PATCH] Always include numpy in Python script exports as with Numpy 2.0 scalars are often represented as np.float64(...) --- glue/viewers/common/viewer.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/glue/viewers/common/viewer.py b/glue/viewers/common/viewer.py index 71703c8d5..ff289b3a8 100644 --- a/glue/viewers/common/viewer.py +++ b/glue/viewers/common/viewer.py @@ -457,6 +457,10 @@ def export_as_script(self, filename): imports = ['from glue.core.state import load'] + # Always include Numpy because as of Numpy 2.0, scalars are sometimes + # represented in string form as e.g. np.float64(...) + imports += ['import numpy as np'] + imports_header, header = self._script_header() imports.extend(imports_header)