Skip to content

Functions obtained from get_params_to_statetensor_func silently fail when given too few parameters #122

Description

@tlaakkonen

A function that was obtained from get_params_to_statetensor_func will return NaN when given too few parameters, rather than erroring out or assuming the extra parameters to be zero. Is this the expected behaviour?

Minimum working example:

f = qujax.get_params_to_statetensor_func(['Rx', 'Ry'], [[0], [0]], [[0], [1]])
f(np.array([1.0]))
# returns: Array([nan+nanj, nan+nanj], dtype=complex64)

I would expect either an error, since:

np.array([1.0, 0.0])[2]
# throws: "IndexError: index 2 is out of bounds for axis 0 with size 2"

or for the extra parameters to be assumed to be zero, since:

jax.numpy.array([1.0, 0.0])[2]
# returns: Array(0., dtype=float32)

I think throwing an error would be the ideal behaviour here.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions