-
Notifications
You must be signed in to change notification settings - Fork 4
Smoke valid args for binary ufunc tests #18
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
Conversation
Try to duck-type NumPy, only without array scalars, so that * dtype('float32').type --> np.float32 and * np.float32(3) --> array(3.0, dtype='float32) IOW, the attempt is to only have zero-dim arrays (we have them anyway) and have them everywhere where NumPy creates a scalar.
Try to duck-type NumPy, only without array scalars, so that * dtype('float32').type --> np.float32 and * np.float32(3) --> array(3.0, dtype='float32) IOW, the attempt is to only have zero-dim arrays (we have them anyway) and have them everywhere where NumPy creates a scalar.
So that current tests pass. This involves fixing a slew of small issues all around but hey.
This is a stub, will need to decide and clearly articulate what exactly is a scalar.
Structured dtypes, longdoubles and all that.
Also make test_numerictypes from numpy pass. Remove weird things, xfail the "scalar does not upcast array" test, fix up the rest.
The largest difference is that our type promotions are way simpler and more straighforward. No "weak promotion", no values.
These smoke tests certainly do not need to be generated by a script anymore, so please feel free to fix them! Also cf gh-17, which add a bunch of tests for this. |
try: | ||
other_instance = dtype(other) | ||
except TypeError: | ||
return False |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure why it is better than raising? (Uhm, that was me. Meaning this code is not right, long tern)
return asarray(self._tensor >= asarray(other).get()) | ||
|
||
def __le__(self, other): | ||
return asarray(self._tensor <= asarray(other).get()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NB: this will need to be redone similar to gh-17
from ..testing import assert_allclose | ||
|
||
|
||
def test_add(): | ||
assert_allclose(np.add(0.5, 0.6), | ||
add(0.5, 0.6), atol=1e-7, check_dtype=False) | ||
np.add(0.5, 0.6), atol=1e-7, check_dtype=False) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assert_allclose(np.add(0.5, 0.5), np.add(0.5, 0.6))
?
Looks like the test inputs have now been fixed, so closing. |
This PR is WIP, and starts from #12 as it contains a critical fix.
The binary ufunc smoke tests were passing floats to functions that didn't accept them, which this PR fixes... kinda. Running
autogen/gen_ufuncs.py
as-is does not produce the same file structure as it exists fortorch_np
, and moving things over still breaks due to invalid import references.So I can work on fixing these things generally, although IMO it looks like these smoke tests don't need to be generated by a script, but instead could be both generated and ran on runtime with
pytest.mark.parametrize
. Mind if I have a go exploring that?