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

Add Qobj.get to obtain the data in common type #2141

Merged
merged 15 commits into from Apr 19, 2023

Conversation

Ericgig
Copy link
Member

@Ericgig Ericgig commented Mar 29, 2023

Description
I think that with the different data type a Qobj can contain, it would be useful to be able get the underlying data (ndarray, csr_matrix, jax.Array, etc.) easily from the Qobj. I added the method Qobj.get(copy) for that.

I allow direct access to the object in case it's needed for auto-differentiation or other advanced features.

I am open to a better name than get if it's too generic.

@coveralls
Copy link

coveralls commented Mar 29, 2023

Coverage Status

Coverage: 75.371% (+0.05%) from 75.317% when pulling fcd936e on Ericgig:feature.get into df08d96 on qutip:master.

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.

I like this new interface and I'm fairly happy with the name extract unless someone thinks of a better option.

The doc strings also need some updating.

qutip/core/data/extract.py Outdated Show resolved Hide resolved
qutip/core/data/extract.py Outdated Show resolved Hide resolved
qutip/core/data/extract.py Outdated Show resolved Hide resolved
Ericgig and others added 5 commits April 5, 2023 09:48
Co-authored-by: Simon Cross <hodgestar+github@gmail.com>
Co-authored-by: Simon Cross <hodgestar+github@gmail.com>
@AGaliciaMartinez
Copy link
Member

AGaliciaMartinez commented Apr 7, 2023

What about data_as, get_as or extract_as? I think adding as to any of the method names could facilitate understanding what this method does without reading documentation. I personally prefer data_as given that data is already an attrinute for qobj.

@Ericgig
Copy link
Member Author

Ericgig commented Apr 12, 2023

data_as feels more natural than extract... renamed.

@Ericgig
Copy link
Member Author

Ericgig commented Apr 19, 2023

@hodgestar, is the current naming fine for you? I

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.

Sorry, I think I missed the last commit. Happy with the new name.

@Ericgig Ericgig merged commit 3e39ba0 into qutip:master Apr 19, 2023
12 checks passed
@Ericgig Ericgig deleted the feature.get branch April 19, 2023 15:02
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

4 participants