From 797994a11ac5ec6bee9ea01c092947d0c34115f1 Mon Sep 17 00:00:00 2001 From: Marcus Müller <marcus@hostalia.de> Date: Fri, 24 Aug 2018 23:00:55 +0200 Subject: Replace scipy/pylab where numpy/pyplot is sufficient This should reduce the number of times users are prompted to install pylab || scipy when they'd actually get away with functionality fully contained in numpy and matplotlib. This only solves the obvious cases. There's some usage of `pylab.mlab` that would need more than 20s of consideration. --- gr-utils/python/utils/plot_data.py | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) (limited to 'gr-utils/python/utils/plot_data.py') diff --git a/gr-utils/python/utils/plot_data.py b/gr-utils/python/utils/plot_data.py index a054147114..dc9346c484 100644 --- a/gr-utils/python/utils/plot_data.py +++ b/gr-utils/python/utils/plot_data.py @@ -26,18 +26,7 @@ from __future__ import print_function from __future__ import division from __future__ import unicode_literals -try: - import scipy -except ImportError: - print("Please install SciPy to run this script (http://www.scipy.org/)") - raise SystemExit(1) - -try: - from pylab import * -except ImportError: - print("Please install Matplotlib to run this script (http://matplotlib.sourceforge.net/)") - raise SystemExit(1) - +import numpy class plot_data(object): def __init__(self, datatype, filenames, options): @@ -88,12 +77,12 @@ class plot_data(object): def get_data(self, hfile): self.text_file_pos.set_text("File Position: %d" % (hfile.tell()//self.sizeof_data)) try: - f = scipy.fromfile(hfile, dtype=self.datatype, count=self.block_length) + f = numpy.fromfile(hfile, dtype=self.datatype, count=self.block_length) except MemoryError: print("End of File") else: - self.f = scipy.array(f) - self.time = scipy.array([i*(1 / self.sample_rate) for i in range(len(self.f))]) + self.f = numpy.array(f) + self.time = numpy.array([i*(1 / self.sample_rate) for i in range(len(self.f))]) def make_plots(self): self.sp_f = self.fig.add_subplot(2,1,1, position=[0.075, 0.2, 0.875, 0.6]) -- cgit v1.2.3