DnaChisel icon indicating copy to clipboard operation
DnaChisel copied to clipboard

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

Open bwvogler opened this issue 1 year ago • 2 comments

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 avatar Aug 20 '24 17:08 bwvogler