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

Implement functions from np.random #46

Closed
wants to merge 8 commits into from

Conversation

prasunanand
Copy link
Contributor

WIP

@prasunanand
Copy link
Contributor Author

Currently I get following error:

(uarray) prasun@prasun-xps:~/dev/labs/unumpy$ pytest -vv -x
============================= test session starts ==============================
platform linux -- Python 3.7.5, pytest-5.3.2, py-1.8.0, pluggy-0.13.1 -- /home/prasun/anaconda3/envs/uarray/bin/python
cachedir: .pytest_cache
rootdir: /home/prasun/dev/labs/unumpy, inifile: pytest.ini, testpaths: unumpy
plugins: mypy-0.4.2, flake8-1.0.4, cov-2.8.1, black-0.3.7
collected 25 items / 1 error / 24 selected                                     

==================================== ERRORS ====================================
_________________ ERROR collecting unumpy/tests/test_numpy.py __________________
unumpy/tests/test_numpy.py:289: in <module>
    (np.random.rand, (1, 2), {}),
E   AttributeError: 'uarray._Function' object has no attribute 'rand'

Copy link
Collaborator

@hameerabbasi hameerabbasi left a comment

Choose a reason for hiding this comment

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

A lot of these don't take in array_like arguments at all. Most of them (not all) should just be return () paired with identity_argreplacer.

Try to be a bit more careful with your dispatcher and arg-replacer. The dispatcher extracts array_like arguments and dtypes.

unumpy/random/_multimethods.py Outdated Show resolved Hide resolved
unumpy/random/_multimethods.py Outdated Show resolved Hide resolved
unumpy/random/_multimethods.py Outdated Show resolved Hide resolved
unumpy/random/_multimethods.py Outdated Show resolved Hide resolved
unumpy/random/_multimethods.py Show resolved Hide resolved
unumpy/random/_multimethods.py Show resolved Hide resolved
@@ -24,11 +24,13 @@ def __ua_function__(method, args, kwargs):
if method in _implementations:
return _implementations[method](*args, **kwargs)

if not hasattr(np, method.__name__):
if hasattr(np, method.__name__):
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should be replaced by checking the __module__ of the method.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure about this :/

Copy link
Collaborator

Choose a reason for hiding this comment

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

You have to check method.__module__. It will be different depending on the submodule that the method is in.

For simplicity, you can also move everything in _multimethods.py to __init__.py.

@prasunanand prasunanand marked this pull request as ready for review March 7, 2020 12:19
@hameerabbasi
Copy link
Collaborator

hameerabbasi commented Jun 9, 2020

Superceded by #73.

@hameerabbasi hameerabbasi reopened this Jun 9, 2020
@joaosferreira
Copy link
Collaborator

Might take over this eventually if that's okay.

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.

None yet

3 participants