Edinburgh-Genome-Foundry / DnaChisel

:pencil2: A versatile DNA sequence optimizer
https://edinburgh-genome-foundry.github.io/DnaChisel/
MIT License
218 stars 40 forks source link

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

Open bwvogler opened 3 weeks ago

bwvogler commented 3 weeks ago

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 commented 3 weeks ago

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 commented 2 weeks ago

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