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

Deprecation throws ValueError #1596

Open
sanjayankur31 opened this issue Nov 11, 2024 · 2 comments
Open

Deprecation throws ValueError #1596

sanjayankur31 opened this issue Nov 11, 2024 · 2 comments
Milestone

Comments

@sanjayankur31
Copy link

While updating the package in Fedora to 0.13.4, I was testing the package dependencies and see that ephyviewer has a failing test now:

=================================== FAILURES ===================================
_______________________ test_traceviewer_cls_method_neo ________________________

interactive = False

    def test_traceviewer_cls_method_neo(interactive=False):
        sigs = np.random.rand(100000,16)
        sample_rate = 1000.
        t_start = 0.
    
>       neo_anasig = neo.AnalogSignal(sigs*pq.mV, sampling_rate=sample_rate*pq.Hz, t_start=0*pq.s, copy=True)

ephyviewer/tests/test_traceviewer.py:74: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

cls = <class 'neo.core.analogsignal.AnalogSignal'>
signal = array([[0.42289109, 0.87757422, 0.97128633, ..., 0.42063227, 0.33470735,
        0.57933975],
       [0.39828568, 0.78...       0.87677851],
       [0.38279604, 0.85713246, 0.43967717, ..., 0.69529369, 0.73503751,
        0.0068759 ]]) * mV
units = None, dtype = None, copy = True, t_start = array(0.) * s
sampling_rate = array(1000.) * Hz, sampling_period = None, name = None
file_origin = None, description = None, array_annotations = None
annotations = {}

    def __new__(
        cls,
        signal,
        units=None,
        dtype=None,
        copy=None,
        t_start=0 * pq.s,
        sampling_rate=None,
        sampling_period=None,
        name=None,
        file_origin=None,
        description=None,
        array_annotations=None,
        **annotations,
    ):
        """
        Constructs new :class:`AnalogSignal` from data.
    
        This is called whenever a new class:`AnalogSignal` is created from
        the constructor, but not when slicing.
    
        __array_finalize__ is called on the new object.
        """
        if copy is not None:
>           raise ValueError(
                "`copy` is now deprecated in Neo due to removal in NumPy 2.0 and will be removed in 0.15.0."
            )
E           ValueError: `copy` is now deprecated in Neo due to removal in NumPy 2.0 and will be removed in 0.15.0.

/usr/lib/python3.13/site-packages/neo/core/analogsignal.py:202: ValueError

Is the intention here to throw an error (that makes the code stop)? Or is it to inform the user that they need to update their code---in which case, the deprecation warning should not make code fail (using a DeprecationWarning perhaps: https://docs.python.org/3/library/exceptions.html#DeprecationWarning ?)

@sanjayankur31
Copy link
Author

Also filed NeuralEnsemble/ephyviewer#187

@zm711
Copy link
Contributor

zm711 commented Nov 13, 2024

hey @sanjayankur31, You're right in that it's a deprecation but that error is not clear. Basically you need to to put copy=None to prevent the code from stopping. The copy argument is now ignored so we don't want to accept True/False. Put we should make it clear that the user should stop using copy because it does nothing. Thanks for reporting that this isn't clear. Looking back over this I think I got too deep in fixing things and didn't think about how end-users would understand the error :)

@zm711 zm711 added this to the 0.14.0 milestone Dec 13, 2024
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

No branches or pull requests

2 participants