Skip to content

Commit

Permalink
change the order of the funtion places
Browse files Browse the repository at this point in the history
  • Loading branch information
to24toro committed Nov 15, 2023
1 parent 64cbf56 commit 8dccad1
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 20 deletions.
8 changes: 4 additions & 4 deletions qiskit_dynamics/arraylias/register_functions/asarray.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ def register_asarray(alias):
def _(arr):
return np.asarray(arr)

@alias.register_fallback(path="asarray")
def _(arr):
return np.asarray(arr)

@alias.register_function(lib="scipy_sparse", path="asarray")
def _(arr):
if issparse(arr):
Expand All @@ -44,7 +48,3 @@ def _(arr):

except ImportError:
pass

@alias.register_fallback(path="asarray")
def _(arr):
return np.asarray(arr)
8 changes: 4 additions & 4 deletions qiskit_dynamics/arraylias/register_functions/multiply.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@
def register_multiply(alias):
"""Register multiply functions to each array library."""

@alias.register_fallback(path="multiply")
def _(x, y):
return x * y

@alias.register_function(lib="scipy_sparse", path="multiply")
def _(x, y):
return x.multiply(y)
Expand All @@ -36,7 +40,3 @@ def _(x, y):

except ImportError:
pass

@alias.register_fallback(path="multiply")
def _(x, y):
return x * y
8 changes: 4 additions & 4 deletions qiskit_dynamics/arraylias/register_functions/to_dense.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ def _(arr):
return None
return np.asarray(arr)

@alias.register_fallback(path="to_dense")
def _(arr):
return np.asarray(arr)

@alias.register_function(lib="numpy", path="to_dense")
def _(arr):
return arr
Expand All @@ -49,7 +53,3 @@ def _(arr):
@alias.register_function(lib="scipy_sparse", path="to_dense")
def _(arr):
return arr.toarray()

@alias.register_fallback(path="to_dense")
def _(arr):
return np.asarray(arr)
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ def _(arr):
return alias().to_sparse(arr.data)
return arr

@alias.register_fallback(path="to_numeric_matrix_type")
def _(arr):
return arr

@alias.register_function(lib="numpy", path="to_numeric_matrix_type")
def _(arr):
return arr
Expand All @@ -51,7 +55,3 @@ def _(arr):
@alias.register_function(lib="scipy_sparse", path="to_numeric_matrix_type")
def _(arr):
return arr

@alias.register_fallback(path="to_numeric_matrix_type")
def _(arr):
return arr
8 changes: 4 additions & 4 deletions qiskit_dynamics/arraylias/register_functions/to_sparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ def _(arr):
return arr.data
return arr

@alias.register_fallback(path="to_sparse")
def _(arr):
return csr_matrix(arr)

@alias.register_function(lib="numpy", path="to_sparse")
def _(arr):
if arr.ndim < 3:
Expand All @@ -55,7 +59,3 @@ def _(arr):
@alias.register_function(lib="scipy_sparse", path="to_sparse")
def _(arr):
return arr

@alias.register_fallback(path="to_sparse")
def _(arr):
return csr_matrix(arr)

0 comments on commit 8dccad1

Please sign in to comment.