Skip to content

Fixes for SNRPy import issues in 2026 (fixes included) #7

Open

Description

@BrysonLawton

Hello all, so I just had to do a few things to get SNRPy to run in 2026 with the outdated imports SNRPy uses. To save others the hassle, I got AI to write a summary of these changes, which I'll share below. Hope this helps those who come after 👍

Running SNRPy with Modern SciPy, NumPy, and Matplotlib

SNRPy 2.0 uses several APIs that have since been removed from SciPy, NumPy, and Matplotlib. The following changes allow the Python version of SNRPy to start with current library releases.

These issues were encountered with:

  • Python 3.11
  • SciPy 1.17.1
  • NumPy 2.4.6
  • Matplotlib 3.11.1

1. Install the dependencies

From the PythonVersion directory, create a virtual environment and install the required packages:

py -3.11 -m venv .venv
.\.venv\Scripts\python.exe -m pip install --upgrade pip
.\.venv\Scripts\python.exe -m pip install numpy scipy matplotlib

2. Update the SciPy import

Open PythonVersion/snr_calc.py.

Replace:

from scipy.integrate import quad, cumtrapz, nquad

with:

from scipy.integrate import quad, cumulative_trapezoid as cumtrapz, nquad

SciPy removed cumtrapz in version 1.14. Its replacement, cumulative_trapezoid, provides the same functionality needed by SNRPy.

3. Replace the removed NumPy type alias

In PythonVersion/snr_calc.py, replace both occurrences of:

np.float

with:

float

The occurrences are near lines 2208 and 2276 in SNRPy 2.0.

For example:

np.fromiter(values, np.float)

becomes:

np.fromiter(values, float)

4. Update Matplotlib canvas drawing

Open PythonVersion/snr_plot.py.

Replace both occurrences of:

self.canvas.show()

with:

self.canvas.draw()

The occurrences are near lines 51 and 94.

5. Update plot clearing

In PythonVersion/snr_plot.py, find the clear_plot method:

def clear_plot(self):
    """Remove all lines from plot."""

    self.graph.lines = []

Replace it with:

def clear_plot(self):
    """Remove all lines from plot."""

    for line in list(self.graph.lines):
        line.remove()

Modern Matplotlib treats Axes.lines as a read-only collection. Individual line artists must instead be removed using their remove() method.

6. Run SNRPy

Keep all SNRPy files and the data directory together. From the PythonVersion directory, run:

.\.venv\Scripts\python.exe snr.py

The graphical interface should then open.

Summary of changes

--- a/PythonVersion/snr_calc.py
+++ b/PythonVersion/snr_calc.py
@@
-from scipy.integrate import quad, cumtrapz, nquad
+from scipy.integrate import quad, cumulative_trapezoid as cumtrapz, nquad
@@
-                                     points=self._s_point(b_val))[0] for b_val in b), np.float)
+                                     points=self._s_point(b_val))[0] for b_val in b), float)
@@
-                                      args=(edt,), opts=[self._opt_dict, {}])[0] for edt in edt_array), np.float)
+                                      args=(edt,), opts=[self._opt_dict, {}])[0] for edt in edt_array), float)

--- a/PythonVersion/snr_plot.py
+++ b/PythonVersion/snr_plot.py
@@
-        self.canvas.show()
+        self.canvas.draw()
@@
-        self.canvas.show()
+        self.canvas.draw()
@@
-        self.graph.lines = []
+        for line in list(self.graph.lines):
+            line.remove()

These changes preserve the intended behavior of SNRPy while replacing APIs that are no longer available in current scientific Python libraries.

Activity

  1. BrysonLawton commented on Aug 19, 2026

    @BrysonLawton
    Author

    Also, found a fix for the bug that occurs with the Emissivity button. which I'll share below too:

    Fix for SNREmissivity Missing widgets

    If clicking Emissivity produces:

    AttributeError: 'SNREmissivity' object has no attribute 'widgets'
    

    Open PythonVersion/snr_calc.py and find this line inside SNREmissivity.__init__:

    self.root = root

    Add the following line beneath it:

    self.widgets = snr.widgets

    The result should be:

    self.root = root
    self.widgets = snr.widgets
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions