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

Cast times and amplitude inputs to np array in case they are supplied as list. #88

Merged
merged 1 commit into from
Oct 4, 2022

Conversation

btasdelen
Copy link
Collaborator

Sometimes it is more convenient to supply times and amplitudes as Python list instead of np.array to avoid boilerplate. In fact, it is what is done in "Tong et al. A framework for validating open-source pulse sequences. MRM. 2022. (https://doi.org/10.1016/j.mri.2021.11.014)", so IRSE and TSE sequences are currently failing in PyPulseq 1.4. This PR aims to introduce this convenience, and make this branch more "backwards compatible".

Usage of np.asarray is almost free in this context, because:

  1. It does nothing if the input is already numpy array, so no funny business or slowdown.
  2. If the input is a list, it automatically does what the user would do manually for average use case: ie. np.array([1, 2, 3 .....]).

PS: IMHO, every function that gets an ArrayLike, should have asarray casts for their respective inputs.

@sravan953 sravan953 self-assigned this Oct 4, 2022
@sravan953 sravan953 added the enhancement New feature or request label Oct 4, 2022
@sravan953 sravan953 merged commit 6a54e7a into imr-framework:dev Oct 4, 2022
@btasdelen btasdelen deleted the asarray_ext_trap branch November 23, 2022 20:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants