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

ENH: test vecdot values, incl complex conj #314

Merged
merged 2 commits into from
Nov 23, 2024
Merged

Conversation

ev-br
Copy link
Contributor

@ev-br ev-br commented Nov 20, 2024

Add a value test for vecdot for real and complex fp types: this is a matching test for data-apis/array-api-compat#201 and data-apis/array-api-strict#98

A weird thing is that the test should fail without data-apis/array-api-strict#98 but locally it does not. Probably I'm not generating enough examples---is there a way to bump the number with a cmdline switch? Tried several variations of python --max-examples=100 but no luck so far.

closes gh-312

Preferred as long as xp.isdtype is not universally available
(looking at you pytorch)
@ev-br
Copy link
Contributor Author

ev-br commented Nov 23, 2024

Let's get this in and see if this causes any issues going forward.

@ev-br ev-br merged commit a71b4c0 into data-apis:master Nov 23, 2024
4 checks passed
else:
true_val = None
def true_val(x, y, axis=-1):
return xp.sum(xp.multiply(_conj(x), y), dtype=res.dtype)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately, if you look here, there is no approximate testing done at all for floating-point values https://github.com/data-apis/array-api-tests/pull/314/files?diff=unified#diff-6056c0b3af9cd3ba66387432a17f5f36bbd54220419656441a8b01bcdc4df44bR57.

We should probably add a flag to that helper to allow approximate testing to be enabled. Some functions are impossible to do approximate testing for because they don't even have a single possible output (e.g., eigh could pick completely different eigenvectors and still be correct).

There are helpers used in the elementwise functions that could be reused here for testing floating-point (and complex) closeness. Basically, they test with very large epsilons. Even that would be enough to detect that a library isn't conjugating, which is the real concern for this test specifically.

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

Successfully merging this pull request may close these issues.

test_vecdot does not test for conjugation in the first parameter
2 participants