Skip to content

linalg.cholesky not tested for complex dtypes #228

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

Closed
lucascolley opened this issue Jan 3, 2024 · 5 comments
Closed

linalg.cholesky not tested for complex dtypes #228

lucascolley opened this issue Jan 3, 2024 · 5 comments

Comments

@lucascolley
Copy link
Member

As reported in data-apis/array-api-compat#61 (comment), linalg.cholesky is only tested on real arrays, hence some bugs slipped through into both array-api-compat and numpy.array_api.

@lucascolley
Copy link
Member Author

relevant lines:

@given(
x=positive_definite_matrices(),
kw=kwargs(upper=booleans())
)
def test_cholesky(x, kw):

def positive_definite_matrices(draw, dtypes=floating_dtypes):

@ev-br
Copy link
Member

ev-br commented Nov 13, 2024

Are complex dtypes really skipped for new enough spec levels?

floating_dtypes are defined as floating_dtypes = sampled_from(dh.all_float_dtypes) at
https://github.com/data-apis/array-api-tests/blob/master/array_api_tests/hypothesis_helpers.py#L187

and all_float_dtypes include complex ones if the standard is above 2022.12:
https://github.com/data-apis/array-api-tests/blob/master/array_api_tests/hypothesis_helpers.py#L195

This me is eyeballing the code though, not sure how to check it.

@ev-br
Copy link
Member

ev-br commented Nov 13, 2024

This me is eyeballing the code though, not sure how to check it.

Actually,

$ git diff
diff --git a/array_api_tests/test_linalg.py b/array_api_tests/test_linalg.py
index 40fe035..5f39da0 100644
--- a/array_api_tests/test_linalg.py
+++ b/array_api_tests/test_linalg.py
@@ -130,6 +130,8 @@ def _test_namedtuple(res, fields, func_name):
 def test_cholesky(x, kw):
     res = linalg.cholesky(x, **kw)
 
+    print(f"{x.dtype = }")
+
     ph.assert_dtype("cholesky", in_dtype=x.dtype, out_dtype=res.dtype)
     ph.assert_result_shape("cholesky", in_shapes=[x.shape],
                            out_shape=res.shape, expected=x.shape)

prints (on several reruns)

$ pytest array_api_tests/test_linalg.py::test_cholesky -v -s
============================================ test session starts ============================================
platform linux -- Python 3.11.0, pytest-8.3.3, pluggy-1.5.0 -- /home/br/miniforge3/envs/array-api-tests/bin/python3.11
cachedir: .pytest_cache
hypothesis profile 'array-api-tests' -> deadline=timedelta(milliseconds=800), database=DirectoryBasedExampleDatabase(PosixPath('/home/br/repos/array-api-tests/.hypothesis/examples'))
metadata: {'Python': '3.11.0', 'Platform': 'Linux-5.15.0-76-generic-x86_64-with-glibc2.31', 'Packages': {'pytest': '8.3.3', 'pluggy': '1.5.0'}, 'Plugins': {'json-report': '1.5.0', 'hypothesis': '6.118.8', 'metadata': '3.1.1'}, 'array_api_tests_module': 'array_api_tests._array_module', 'array_api_tests_version': '2022.09.30+406.g9db56ec.dirty'}
Array API Tests Module: numpy (2.1.3). API Version: 2023.12. Enabled Extensions: fft, linalg
rootdir: /home/br/repos/array-api-tests
configfile: pytest.ini
plugins: json-report-1.5.0, hypothesis-6.118.8, metadata-3.1.1
collected 1 item                                                                                            

array_api_tests/test_linalg.py::test_cholesky x.dtype = dtype('float32')
x.dtype = dtype('float32')
x.dtype = dtype('float32')
x.dtype = dtype('float32')
x.dtype = dtype('complex128')
x.dtype = dtype('float32')
x.dtype = dtype('float64')
x.dtype = dtype('float32')
x.dtype = dtype('complex64')
x.dtype = dtype('float32')
PASSED

@lucascolley
Copy link
Member Author

okay cool, so it seems like Ralf's initial diagnosis was incorrect. I don't know why the linked bug was able to slip through, then.

@asmeurer
Copy link
Member

I think this is something that I fixed a few months ago.

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

3 participants