You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
yield_namespace_device_dtype_combinations parametrization ID confusing for 'device1' #31042
In yield_namespace_device_dtype_combinations, for array_api_strict we yield CPU_DEVICE first, then device1. This results in the confusing pytest parametrization IDs:
array_api_strict-device2-float32 - where 'device2' actually refers to Device("device1") and not Device("device2")
array_api_strict-device1-float64 - where 'device1' actually refers to Device("CPU_DEVICE") and not Device("device1")
Not sure if there is an good fix for this / or if a fix is needed.
We could yield Device("device1") first but then the id "device2" would refer to Device("CPU_DEVICE") and not Device("device2")
The only way to completely avoid confusion would be to write a function that takes a params and amends the names e.g.,
Actually I've just realised that the ID 'device' depends on the number of namespaces supported in the environment, but the above does seem to be the case for a few of the azure workflows.
This also tripped me up a while back. So it is probably worth fixing.
We use the "generate IDs" approach for other tests and it is really nice, so maybe we should just do that here as well. The other approach that could be nice, but not sure if it is feasible, is to modify array-api-strict's Device class so that it "automatically" gets represented nicer in tests. That would solve the problem for all people who use array-api-strict which would be nice.
Activity
lucyleeow commentedon Mar 21, 2025
Actually I've just realised that the ID 'device' depends on the number of namespaces supported in the environment, but the above does seem to be the case for a few of the azure workflows.
betatim commentedon Mar 21, 2025
This also tripped me up a while back. So it is probably worth fixing.
We use the "generate IDs" approach for other tests and it is really nice, so maybe we should just do that here as well. The other approach that could be nice, but not sure if it is feasible, is to modify
array-api-strict'sDeviceclass so that it "automatically" gets represented nicer in tests. That would solve the problem for all people who usearray-api-strictwhich would be nice.lucyleeow commentedon Mar 21, 2025
I don't think this is possible. If it's not Numbers, strings, booleans and None, then pytest will use the argument name:
https://docs.pytest.org/en/stable/example/parametrize.html#different-options-for-test-ids
I was naively hoping a
__str__or__repr__would do it but no. It actually may be a nice pytest feature to add.Happy to add a 'generate ID' function, if others don't think its adding too much complexity
ogrisel commentedon Mar 21, 2025
I don't have a better solution to propose... and the current status quo is really misleading, so probably worth fixing.