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

NumPy 2.0 and up are not compatible with the use of nonzero function in some evaluate methods #83

Open
bwvogler opened this issue Aug 20, 2024 · 2 comments

Comments

@bwvogler
Copy link

bwvogler commented Aug 20, 2024

Should limit numpy requirement to <2 until this is fixed in each specification. Even at 1.26 it gives warnings

def evaluate(self, problem):
        """Return the sum of breaches extent for all windowed breaches."""
        wstart, wend = self.location.start, self.location.end
        sequence = self.location.extract_sequence(problem.sequence)
        gc = gc_content(sequence, window_size=self.window)
        breaches = np.maximum(0, self.mini - gc) + np.maximum(
            0, gc - self.maxi
        )
        score = -breaches.sum()
>       breaches_starts = wstart + (breaches > 0).nonzero()[0]
E       ValueError: Calling nonzero on 0d arrays is not allowed. Use np.atleast_1d(scalar).nonzero() instead. If the context of this error is of the form `arr[nonzero(cond)]`, just use `arr[cond]`.
@bwvogler
Copy link
Author

This actually only fully broke in NumPy 2.1, released August 18
https://numpy.org/devdocs/release/2.1.0-notes.html#expired-deprecations

@veghp
Copy link
Member

veghp commented Aug 29, 2024

Thank you -- it's now addressed in above merged PRs.

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