-
Notifications
You must be signed in to change notification settings - Fork 25
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
Pytest is broken on my computer #166
Comments
I just started getting lots of errors like
|
@PhilipVinc I'm experiencing the same issue. Haven't yet figured out what's wrong. |
I think a doctest is the culprit: $ pytest docs/comparison.md
<the above error> |
For some reason, the below refuses to run as a doctest and now throws an error: from plum import dispatch, parametric
from typing import Any, Optional, Tuple, Union
import numpy as np
class NDArrayMeta(type):
def __instancecheck__(self, x):
if self.concrete:
shape, dtype = self.type_parameter
else:
shape, dtype = None, None
return (
isinstance(x, np.ndarray)
and (shape is None or x.shape == shape)
and (dtype is None or x.dtype == dtype)
)
@parametric
class NDArray(np.ndarray, metaclass=NDArrayMeta):
@classmethod
@dispatch
def __init_type_parameter__(
cls,
shape: Optional[Tuple[int, ...]],
dtype: Optional[Any],
):
"""Validate the type parameter."""
return shape, dtype
@classmethod
@dispatch
def __le_type_parameter__(
cls,
left: Tuple[Optional[Tuple[int, ...]], Optional[Any]],
right: Tuple[Optional[Tuple[int, ...]], Optional[Any]],
):
"""Define an order on type parameters. That is, check whether
`left <= right` or not."""
shape_left, dtype_left = left
shape_right, dtype_right = right
return (
(shape_right is None or shape_left == shape_right)
and (dtype_right is None or dtype_left == dtype_right)
)
@dispatch
def f(x: np.ndarray):
print("Any NP array!")
@dispatch
def f(x: NDArray[(2, 2), None]):
print("A 2x2 array!")
@dispatch
def f(x: NDArray[None, int]):
print("An int array!")
@dispatch
def f(x: NDArray[(2, 2), int]):
print("A 2x2 int array!")
f(np.ones((3, 3))) # Any NP array!
f(np.ones((3, 3), int)) # An int array!
f(np.ones((2, 2))) # A 2x2 array!
f(np.ones((2, 2), int)) # A 2x2 int array! |
Upgrading |
(Numpy 2.0 was released today and I guess that might cause some breakage) |
yep |
@nstarman Are you still experiencing issues? |
Yes. I just opened GalacticDynamics/galax#357, which works on my un-upgraded plum/numpy/etc. |
I went lower down the stack. I'm seeing the same thing in GalacticDynamics/quaxed#56 |
@nstarman I can confirm that I’m also seeing double registrations in some packages of mine. This seems to be a separate issue from the current thread, and revealed by the recently added warning. Do the registrations only pollute your output or actually break something? I will keep investigating on my end. |
Let's move this do a different thread, but the issue seems to be that plum is trying to register the same function twice! E.g. I'm seeing this and both
|
Since some recent changes in the testing infrastructure, I keep getting those errors
Does anyone know why?
The text was updated successfully, but these errors were encountered: