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

creates cupydense in the data layer to be available as a Qobj #41

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

MrRobot2211
Copy link
Collaborator

This lines were missing in order to be able to call operations from a Qobj and test all the functionality directly oin Qobjs.

@coveralls
Copy link

coveralls commented Aug 17, 2021

Pull Request Test Coverage Report for Build 1182844552

Warning: This coverage report may be inaccurate.

This pull request's base commit is no longer the HEAD commit of its target branch. This means it includes changes from outside the original pull request, including, potentially, unrelated coverage changes.

Details

  • 3 of 5 (60.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.4%) to 87.619%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/qutip_cupy/init.py 3 5 60.0%
Totals Coverage Status
Change from base Build 1127753560: -0.4%
Covered Lines: 276
Relevant Lines: 315

💛 - Coveralls

Copy link
Contributor

@hodgestar hodgestar left a comment

Choose a reason for hiding this comment

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

This changes in this PR are probably unnecessary as they are:

  • register_aliases already allows one to specify the dtype when creating a Qobj, although I would recommend adding "CuPyDense" to the list of aliases in the call to register_aliases.
  • it's unnecessary to add a creator for a data layer type, but as @AGaliciaMartinez pointed out, it probably would be useful to add one for the cupy array type.

I think a setup similar to the one in https://github.com/qutip/qutip-tensorflow/blob/main/src/qutip_tensorflow/core/data/convert.py would make more sense.

@MrRobot2211
Copy link
Collaborator Author

@hodgestar I checked the diff and this one is ready.

Copy link
Contributor

@hodgestar hodgestar left a comment

Choose a reason for hiding this comment

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

Left two small comments, but looking much better.



def is_cupy(data):
return isinstance(data, cp.ndarray) # noqa: F821
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the noqa really needed now that we import cupy as cp at the top?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The thing is that as the import is inside a try it fails to detect it

Copy link
Contributor

Choose a reason for hiding this comment

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

Could you double check?

When I do:

$ cat  foo.py
try:
    import math
except ImportError:
    raise


def f():
    print(math.pi)
$ flake8 foo.py

It doesn't print an error and in the code in this PR it doesn't print an error for del cp either.

src/qutip_cupy/__init__.py Outdated Show resolved Hide resolved
@MrRobot2211
Copy link
Collaborator Author

Looks like there were some breaking changes on dev.major

@hodgestar
Copy link
Contributor

Looks like there were some breaking changes on dev.major

Yep. Importantly data layer objects no longer support arithmetic operations via *, +, -, etc. For now I would pin the dependency of dev.major to the last working commit and then fix this in a later PR.

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.

4 participants