From c1e69456aecc927ef9bde667c984ce4ae46bad78 Mon Sep 17 00:00:00 2001 From: Pey Lian Lim <2090236+pllim@users.noreply.github.com> Date: Fri, 19 Feb 2021 10:19:31 -0500 Subject: [PATCH 1/2] MNT: Replace fromstring with frombuffer to avoid DeprecationWarning --- ginga/AstroImage.py | 2 +- ginga/aggw/CanvasRenderAgg.py | 2 +- ginga/pilw/CanvasRenderPil.py | 2 +- ginga/pilw/PilHelp.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ginga/AstroImage.py b/ginga/AstroImage.py index 5a44f5542..962a5017d 100644 --- a/ginga/AstroImage.py +++ b/ginga/AstroImage.py @@ -182,7 +182,7 @@ def load_data(self, data_np, naxispath=None, metadata=None): def load_buffer(self, buf, dims, dtype, byteswap=False, naxispath=None, metadata=None): - data = np.fromstring(buf, dtype=dtype) + data = np.frombuffer(buf, dtype=dtype) if byteswap: data.byteswap(True) data = data.reshape(dims) diff --git a/ginga/aggw/CanvasRenderAgg.py b/ginga/aggw/CanvasRenderAgg.py index 719a36a57..0273a4afd 100644 --- a/ginga/aggw/CanvasRenderAgg.py +++ b/ginga/aggw/CanvasRenderAgg.py @@ -212,7 +212,7 @@ def get_surface_as_array(self, order=None): wd, ht = self.dims # Get agg surface as a numpy array - arr8 = np.fromstring(self.surface.tobytes(), dtype=np.uint8) + arr8 = np.frombuffer(self.surface.tobytes(), dtype=np.uint8) arr8 = arr8.reshape((ht, wd, len(self.rgb_order))) # adjust according to viewer's needed order diff --git a/ginga/pilw/CanvasRenderPil.py b/ginga/pilw/CanvasRenderPil.py index 71e38d509..e37e71264 100644 --- a/ginga/pilw/CanvasRenderPil.py +++ b/ginga/pilw/CanvasRenderPil.py @@ -197,7 +197,7 @@ def get_surface_as_array(self, order=None): wd, ht = self.dims[:2] # Get PIL surface as a numpy array - arr8 = np.fromstring(self.surface.tobytes(), dtype=np.uint8) + arr8 = np.frombuffer(self.surface.tobytes(), dtype=np.uint8) arr8 = arr8.reshape((ht, wd, 3)) # adjust according to viewer's needed order diff --git a/ginga/pilw/PilHelp.py b/ginga/pilw/PilHelp.py index 44159880d..1d85a2dc1 100644 --- a/ginga/pilw/PilHelp.py +++ b/ginga/pilw/PilHelp.py @@ -47,7 +47,7 @@ def text_to_array(text, font, rot_deg=0.0): d = ImageDraw.Draw(i, 'RGBA') d.text((0, 0), text, font=f, fill=color) i.rotate(rot_deg, expand=1) - arr8 = np.fromstring(i.tobytes(), dtype=np.uint8) + arr8 = np.frombuffer(i.tobytes(), dtype=np.uint8) arr8 = arr8.reshape((ht, wd, 4)) return arr8 From 7ec0bb345504bf94b48eee914d723b27e4bfae92 Mon Sep 17 00:00:00 2001 From: Pey Lian Lim <2090236+pllim@users.noreply.github.com> Date: Fri, 19 Feb 2021 14:17:53 -0500 Subject: [PATCH 2/2] MNT: Bump numpy minversion to 1.14 --- doc/install.rst | 2 +- setup.cfg | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/install.rst b/doc/install.rst index 110f69d64..953366774 100644 --- a/doc/install.rst +++ b/doc/install.rst @@ -21,7 +21,7 @@ REQUIRED * python (v. 3.7 or higher) * setuptools-scm -* numpy (v. 1.13 or higher) +* numpy (v. 1.14 or higher) * astropy Highly recommended, because some features will not be available without it: diff --git a/setup.cfg b/setup.cfg index c27627d64..99ce25b4f 100644 --- a/setup.cfg +++ b/setup.cfg @@ -40,7 +40,7 @@ classifiers = zip_safe = False packages = find: python_requires = >=3.7 -install_requires = numpy>=1.13; qtpy>=1.1; astropy>=3.2 +install_requires = numpy>=1.14; qtpy>=1.1; astropy>=3.2 setup_requires = setuptools_scm [options.extras_require]