MAINT: Check essential data functions
Hi @ev-br,
As discussed in #379, here's a PR that introduces has_setup_funcs mark.
I applied it to the first batch of tests that use .draw() calls, which underneath uses do_draw, so at least one of the asarray, isnan, reshape, zeros is used (which has_setup_funcs checks).
I still need to find all tests that use draw.
This is a great start!
I think it's best to generalize it from the onset to address https://github.com/data-apis/array-api-tests/issues/51
Ideally, there's a decorator (or a specific pytest mark, whichever is easier) with arguments. Tentatively calling this decorator def require(*args: str),
@require('sin', 'zeros_like')
@given(....)
def test_func(...):
....
so this would skip the test unless xp.sin and xp.zeros_like are available.
Whether the list dependencies of draw (your essential_functions) should be automatically added or needs listed explicitly --- so that the above example is @require(draw_deps, 'sin', 'zeros_like') --- this can go both ways. I'd lean towards explicit is better than implicit, but it's a mild preference.
Also do you think it'd be useful to add a knob to turn the check off, say, with env variable? The reason is if a library does not implement anything at all, is the test suite all green (everything is skipped) or all red (nothing works).