Skip to content
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

test_has_names fails on info category checked main namespace, instead of class attributes #261

Open
oleksandr-pavlyk opened this issue May 11, 2024 · 1 comment

Comments

@oleksandr-pavlyk
Copy link
Contributor

__________________________________________________________________________________________ test_has_names[info-dtypes] __________________________________________________________________________________________

category = 'info', name = 'dtypes'

    @pytest.mark.parametrize("category, name", has_name_params)
    def test_has_names(category, name):
        if category in EXTENSIONS:
            ext_mod = getattr(xp, category)
            assert hasattr(ext_mod, name), f"{xp.__name__} is missing the {category} extension function {name}()"
        elif category.startswith('array_'):
            # TODO: This would fail if ones() is missing.
            arr = xp.ones((1, 1))
            if category == 'array_attribute':
                assert hasattr(arr, name), f"The {xp.__name__} array object is missing the attribute {name}"
            else:
                assert hasattr(arr, name), f"The {xp.__name__} array object is missing the method {name}()"
        else:
>           assert hasattr(xp, name), f"{xp.__name__} is missing the {category} function {name}()"
E           AssertionError: dpctl.tensor is missing the info function dtypes()
E           assert False
E            +  where False = hasattr(xp, 'dtypes')

array_api_tests/test_has_names.py:37: AssertionError
============================================================================================ short test summary info ============================================================================================
FAILED array_api_tests/test_has_names.py::test_has_names[info-capabilities] - AssertionError: dpctl.tensor is missing the info function capabilities()
FAILED array_api_tests/test_has_names.py::test_has_names[info-default_device] - AssertionError: dpctl.tensor is missing the info function default_device()
FAILED array_api_tests/test_has_names.py::test_has_names[info-default_dtypes] - AssertionError: dpctl.tensor is missing the info function default_dtypes()
FAILED array_api_tests/test_has_names.py::test_has_names[info-devices] - AssertionError: dpctl.tensor is missing the info function devices()
FAILED array_api_tests/test_has_names.py::test_has_names[info-dtypes] - AssertionError: dpctl.tensor is missing the info function dtypes()
========================================================================================= 5 failed, 192 passed in 0.42s =========================================================================================

The specification states that these must be attributes of Info class, not of the main namespace:


In [1]: import dpctl, dpctl.tensor as dpt

In [2]: info = dpt.__array_namespace_info__()

In [3]: hasattr(info, "capabilities")
Out[3]: True

In [4]: hasattr(info, "default_device")
Out[4]: True

In [5]: hasattr(info, "default_dtypes")
Out[5]: True

In [6]: hasattr(info, "devides")
Out[6]: False

In [7]: hasattr(info, "devices")
Out[7]: True

In [8]: hasattr(info,"dtypes")
Out[8]: True
@asmeurer
Copy link
Member

This is likely related to the issue with the stubs in the array-api repo as discussed at #259.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants