Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove pylab #35

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

Remove pylab #35

wants to merge 5 commits into from

Conversation

duboism
Copy link
Contributor

@duboism duboism commented Apr 4, 2025

This PR replaces pylab by matlplotlib.pyplot as pointed out in #30, #31 and #32.

It also adds some warnings about the loading time of gwpy and matplotlib as pointed in the same issues.

@duboism duboism marked this pull request as ready for review April 7, 2025 15:35
@duboism duboism requested a review from DrKentB April 7, 2025 16:43
@DrKentB
Copy link

DrKentB commented Apr 7, 2025

  1. Replace pylab by matplotlib.pyplot in Tutorial 1.4:
    Results in error:
---------------------------------------------------------------------------

ValueError                                Traceback (most recent call last)

[<ipython-input-3-224a3e5ff6e1>](https://localhost:8080/#) in <cell line: 0>()
----> 1 from pycbc.waveform import get_td_waveform, fd_approximants
      2 import matplotlib.pyplot as plt

22 frames

[/usr/local/lib/python3.11/dist-packages/numpy/random/_pickle.py](https://localhost:8080/#) in <module>
----> 1 from .mtrand import RandomState
      2 from ._philox import Philox
      3 from ._pcg64 import PCG64, PCG64DXSM
      4 from ._sfc64 import SFC64
      5 

numpy/random/mtrand.pyx in init numpy.random.mtrand()

ValueError: numpy.dtype size changed, may indicate binary incompatibility. Expected 96 from C header, got 88 from PyObject

Had to restart the runtime session and rerun the full tutorial and then it worked ...

@DrKentB
Copy link

DrKentB commented Apr 7, 2025

  1. Tutorial 2.1
    Results in Error:
---------------------------------------------------------------------------

ValueError                                Traceback (most recent call last)

[<ipython-input-3-d18dbc6bf9cd>](https://localhost:8080/#) in <cell line: 0>()
     11 
     12 # Generate a long stretch of white noise: the data series and the time series.
---> 13 data = numpy.random.normal(size=[sample_rate * data_length])
     14 times = numpy.arange(len(data)) / float(sample_rate)

2 frames

[/usr/local/lib/python3.11/dist-packages/numpy/random/_pickle.py](https://localhost:8080/#) in <module>
----> 1 from .mtrand import RandomState
      2 from ._philox import Philox
      3 from ._pcg64 import PCG64, PCG64DXSM
      4 from ._sfc64 import SFC64
      5

There is no warning documenting that the import of numpy might fail and you have to restart the runtime!!
Restarting runtime works.

@DrKentB
Copy link

DrKentB commented Apr 7, 2025

  1. Tutorial 2.2
    Runtime Error:
---------------------------------------------------------------------------

ModuleNotFoundError                       Traceback (most recent call last)

[<ipython-input-3-b3c1adda1c63>](https://localhost:8080/#) in <cell line: 0>()
      2 import matplotlib.pyplot as plt
      3 from pycbc.catalog import Merger
----> 4 from pycbc.filter import resample_to_delta_t, highpass
      5 
      6 # As an example we use the GW150914 data

14 frames

[/usr/local/lib/python3.11/dist-packages/numpy/__init__.py](https://localhost:8080/#) in __getattr__(attr)
    362         try:
    363             x = ones(2, dtype=float32)
--> 364             if not abs(x.dot(x) - float32(2.0)) < 1e-5:
    365                 raise AssertionError()
    366         except AssertionError:

ModuleNotFoundError: No module named 'numpy.rec'

Again, there is no warning documenting that the import of numpy might fail and you have to restart the runtime!!
Restarting runtime DID NOT fix this:

---------------------------------------------------------------------------

NotImplementedError                       Traceback (most recent call last)

[<ipython-input-11-eb0c86cb6889>](https://localhost:8080/#) in <cell line: 0>()
      6                     (subtracted, 'Signal Subtracted from H1 Data')]:
      7 
----> 8     t, f, p = data.whiten(4, 4).qtransform(.001, logfsteps=100, qrange=(8, 8), frange=(20, 512))
      9     plt.figure(figsize=[15, 3])
     10     plt.title(title)

1 frames

[/usr/local/lib/python3.11/dist-packages/scipy/interpolate/_interpolate.py](https://localhost:8080/#) in __init__(self, x, y, z, kind, copy, bounds_error, fill_value)
    127     def __init__(self, x, y, z, kind='linear', copy=True, bounds_error=False,
    128                  fill_value=None):
--> 129         raise NotImplementedError(err_mesg)
    130 
    131 

NotImplementedError: `interp2d` has been removed in SciPy 1.14.0.

For legacy code, nearly bug-for-bug compatible replacements are
`RectBivariateSpline` on regular grids, and `bisplrep`/`bisplev` for
scattered 2D data.

In new code, for regular grids use `RegularGridInterpolator` instead.
For scattered data, prefer `LinearNDInterpolator` or
`CloughTocher2DInterpolator`.

For more details see
https://scipy.github.io/devdocs/tutorial/interpolate/interp_transition_guide.html

Restarting yet again DID NOT fix.

@DrKentB
Copy link

DrKentB commented Apr 7, 2025

  1. Tutorial 2.3
    Results in Error:
---------------------------------------------------------------------------

ModuleNotFoundError                       Traceback (most recent call last)

[<ipython-input-3-3f438791c08f>](https://localhost:8080/#) in <cell line: 0>()
      2 import matplotlib.pyplot as plt
      3 
----> 4 from pycbc.filter import resample_to_delta_t, highpass
      5 from pycbc.catalog import Merger
      6 from pycbc.psd import interpolate, inverse_spectrum_truncation

14 frames

[/usr/local/lib/python3.11/dist-packages/numpy/__init__.py](https://localhost:8080/#) in __getattr__(attr)
    362         try:
    363             x = ones(2, dtype=float32)
--> 364             if not abs(x.dot(x) - float32(2.0)) < 1e-5:
    365                 raise AssertionError()
    366         except AssertionError:

ModuleNotFoundError: No module named 'numpy.rec'

Restarting Runtime session and rerunning ... it worked!

@DrKentB
Copy link

DrKentB commented Apr 7, 2025

For the tutorials that worked after restarting and running again, there is no information posted that this might happen for the particular cells where it dies. In some cases there are warning but for other cells.

@duboism
Copy link
Contributor Author

duboism commented Apr 8, 2025

Hi Kent,

Thanks for your time.

I think the errors on Colab are similar to what you reported (see #33). Those need to be tackled independently. I'm rather confident that there is no errors with the conda environment since we test it in CI but could you test this or with MyBinder ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants