Skip to content

override generated __eq__ to work with numpy fields #409

Closed
@chobeat

Description

@chobeat

I would like to know how to override generated methods in attrs. From the documentation is not clear.

My problem is that if I put some numpy arrays as values, the regular "==" operator fails because np.array_equal should be used instead.

The error is the following:

    def __eq__(self, other):
        if other.__class__ is not self.__class__:
            return NotImplemented
        return  (
            self.raw,
            self.processed,
        ) == (
            other.raw,
>           other.processed,
        )
E       ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions