Skip to content

Commit

Permalink
fix perferred_lib
Browse files Browse the repository at this point in the history
  • Loading branch information
to24toro committed Nov 2, 2023
1 parent 7333814 commit 586d682
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions qiskit_dynamics/arraylias/alias.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
ArrayLike = Union[Union[DYNAMICS_NUMPY_ALIAS.registered_types()], list]


def _preferred_lib(*args, **kwargs):
def _preferred_lib(*args):
"""Given a list of args and kwargs with potentially mixed array types, determine the appropriate
library to dispatch to.
Expand All @@ -48,18 +48,17 @@ def _preferred_lib(*args, **kwargs):
Args:
*args: Positional arguments.
**kwargs: Keyword arguments.
Returns:
str
Raises:
QiskitError: if none of the rules apply.
"""
args = list(args) + list(kwargs.values())
args = list(args)
if len(args) == 1:
return DYNAMICS_NUMPY_ALIAS.infer_libs(args[0])

lib0 = DYNAMICS_NUMPY_ALIAS.infer_libs(args[0])[0]
lib1 = _preferred_lib(args[1:])[0]
lib1 = _preferred_lib(*args[1:])[0]

if lib0 == "numpy" and lib1 == "numpy":
return "numpy"
Expand All @@ -82,5 +81,5 @@ def _numpy_multi_dispatch(*args, path, **kwargs):
Returns:
Result of evaluating the function at path on the arguments using the preferred library.
"""
lib = _preferred_lib(*args, **kwargs)
lib = _preferred_lib(*args)
return DYNAMICS_NUMPY_ALIAS(like=lib, path=path)(*args, **kwargs)

0 comments on commit 586d682

Please sign in to comment.