Function call reports 0 arguments were given despite passing valid arguments

Viewed 60
    @classmethod
    def attribute_filter(
            cls,
            struct_arr: np.ndarray,
            attr: str,
            lb: Union[int, float, np.number, type(None)] = None,
            ub: Union[int, float, np.number, type(None)] = None,
            mode: str = 'fill'
    ):
        if lb is None:
            lb = struct_arr[attr].min()
        if ub is None:
            ub = struct_arr[attr].max()
        cond1 = (struct_arr[attr] >= lb)
        cond2 = (struct_arr[attr] <= ub)
        print(cond1, cond2) # Prints as expected
        condition = np.logical_and(x1=cond1, x2=cond2) # Fails
        ...
        ...

I have classmethod as shown above. This method is being used in a multiprocessing environment. Upon execution I get:

condition = np.logical_and(x1=cond1, x2=cond2)
TypeError: logical_and() takes from 2 to 3 positional arguments but 0 were given

What are the plausible causes of this? How can I go about resolving this?

1 Answers

Emphasis mine

TypeError: logical_and() takes from 2 to 3 positional arguments but 0 were given

you did

condition = np.logical_and(x1=cond1, x2=cond2)

i.e. used keyword arguments instead of positional, please try doing

condition = np.logical_and(x1, x2)
Related