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
TST: astropy.units completion tests behave differently for functions with unique names #15692
While working on #15690, I think I found a "vulnerability" in how we test for test completion for NEP 18 (array function) wrapping.
Specifically, the issue is that astropy.units.tests.test_quantity_non_ufuncs.CoverageMeta is currently not able to distinguish tests aim to cover np.linalg.outer from the ones that are targeted at np.outer because it only care about the function name, not the exact namespace it lives in.
By construction, this will not show up in tests, but I believe it'd be a good idea to make this meta test more robust.
Alright I think I got it now:
In #15469, @mhvk already added a mechanism to handle name collisions for the completion test. Specifically this was done as an edit in astropy/units/tests/test_quantity_non_ufuncs.py::get_wrapped_functions. However, I didn't initially understand the way it works, so here how it goes:
for each numpy function, assume we have a test named "test_{function_name}" ...
unless if we've already seen a function with the same name, in which case the test needs to be named test_{module_name}_{function_name}
This worked fine for all cases known until this week, but it was somewhat confusing to discover this behaviour while working on #15691 (see d4d366b)
I think we could make it more straightforward if we can rename all tests targeted at functions that live in sub-namespaces but share a name with another function living in the root numpy namespace. Or we could also close this as "won't fix" since it's not 100% clear it would be worth the effort. I'll let @mhvk be the judge here !
I think you are right, we should go to test_{module_name}_{function_name} generally (if we really want to be clever, the module name could be an attribute of the test class, but that's an implementation detail).
changed the title [-]TST: astropy.units NEP18 completion tests now have blindspots (colliding function names)[/-][+]TST: astropy.units completion tests behave differently for functions with unique names[/+]on Dec 12, 2023
Activity
neutrinoceros commentedon Dec 8, 2023
I was wrong, it does show up. Now let's see why.
neutrinoceros commentedon Dec 8, 2023
related: #15469
neutrinoceros commentedon Dec 8, 2023
Alright I think I got it now:
In #15469, @mhvk already added a mechanism to handle name collisions for the completion test. Specifically this was done as an edit in
astropy/units/tests/test_quantity_non_ufuncs.py::get_wrapped_functions. However, I didn't initially understand the way it works, so here how it goes:"test_{function_name}"...test_{module_name}_{function_name}This worked fine for all cases known until this week, but it was somewhat confusing to discover this behaviour while working on #15691 (see d4d366b)
I think we could make it more straightforward if we can rename all tests targeted at functions that live in sub-namespaces but share a name with another function living in the root
numpynamespace. Or we could also close this as "won't fix" since it's not 100% clear it would be worth the effort. I'll let @mhvk be the judge here !mhvk commentedon Dec 8, 2023
I think you are right, we should go to
test_{module_name}_{function_name}generally (if we really want to be clever, the module name could be an attribute of the test class, but that's an implementation detail).neutrinoceros commentedon Dec 8, 2023
I'm not sure making the test code more clever will help, but I do think it would help to make it consistent. I'll pick it up soon. Thanks !
neutrinoceros commentedon Dec 12, 2023
This is not critical but as I'm neck-deep into the units module these days, I might as well pick it up now !
[-]TST: astropy.units NEP18 completion tests now have blindspots (colliding function names)[/-][+]TST: astropy.units completion tests behave differently for functions with unique names[/+]neutrinoceros commentedon Dec 12, 2023
retitled the issue for posterity