Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoInstallSign in
Socket

scqubits

Package Overview
Dependencies
Maintainers
2
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

scqubits - npm Package Compare versions

Comparing version
3.2.0
to
3.3.0
+1
-1
PKG-INFO
Metadata-Version: 2.1
Name: scqubits
Version: 3.2.0
Version: 3.3.0
Summary: scqubits: superconducting qubits in Python

@@ -5,0 +5,0 @@ Home-page: https://scqubits.readthedocs.io

Metadata-Version: 2.1
Name: scqubits
Version: 3.2.0
Version: 3.3.0
Summary: scqubits: superconducting qubits in Python

@@ -5,0 +5,0 @@ Home-page: https://scqubits.readthedocs.io

@@ -103,1 +103,13 @@ # scqubits: superconducting qubits in Python

)
# build a public API list by finding all names not starting with underscore
import scqubits as _scq
from scqubits.utils.misc import inspect_public_API as _inspect_public_API
__all__ = _inspect_public_API(
_scq,
public_names=[
"__version__",
],
private_names=["utils", "ui", "warnings", "io_utils", "version"],
)

@@ -457,2 +457,10 @@ # cos2phi_qubit.py

and `ParameterSweep`. If not provided, an id is auto-generated.
esys_method:
method for esys diagonalization, callable or string representation
esys_method_options:
dictionary with esys diagonalization options
evals_method:
method for evals diagonalization, callable or string representation
evals_method_options:
dictionary with evals diagonalization options
"""

@@ -488,6 +496,6 @@ EJ = descriptors.WatchedProperty(float, "QUANTUMSYSTEM_UPDATE")

id_str: Optional[str] = None,
evals_method: Optional[str] = None,
evals_method_options: Optional[dict] = None,
esys_method: Optional[str] = None,
esys_method_options: Optional[dict] = None,
evals_method: Union[Callable, str, None] = None,
evals_method_options: Union[dict, None] = None,
esys_method: Union[Callable, str, None] = None,
esys_method_options: Union[dict, None] = None,
) -> None:

@@ -494,0 +502,0 @@ base.QubitBaseClass.__init__(

@@ -338,3 +338,3 @@ # diag.py

except:
raise ImportError("Module primme is not installed.")
raise ImportError("Package primme is not installed.")

@@ -382,3 +382,3 @@ m = _cast_matrix(matrix, "sparse")

except:
raise ImportError("Module primme is not installed.")
raise ImportError("Package primme is not installed.")

@@ -434,3 +434,3 @@ m = _cast_matrix(matrix, "sparse")

except:
raise ImportError("Module cupy is not installed.")
raise ImportError("Package cupy is not installed.")

@@ -471,3 +471,3 @@ m = _cast_matrix(matrix, "dense")

except:
raise ImportError("Module cupy is not installed.")
raise ImportError("Package cupy is not installed.")

@@ -515,3 +515,3 @@ m = _cast_matrix(matrix, "dense")

except:
raise ImportError("Module cupyx (part of cupy) is not installed.")
raise ImportError("Package cupyx (part of cupy) is not installed.")

@@ -561,3 +561,3 @@ m = cp_csc_matrix(_cast_matrix(matrix, "sparse"))

except:
raise ImportError("Module cupyx (part of cupy) is not installed.")
raise ImportError("Package cupyx (part of cupy) is not installed.")

@@ -585,2 +585,92 @@ m = cp_csc_matrix(_cast_matrix(matrix, "sparse"))

### jax based routines ####
def evals_jax_dense(
matrix, evals_count, **kwargs
) -> Union[Tuple[ndarray, ndarray], Tuple[ndarray, QutipEigenstates]]:
"""
Diagonalization based on jax's (dense) jax.scipy.linalg.eigh function.
Only eigenvalues are returned.
If available, different backends/devics (e.g., particular GPUs) can be set
though jax's interface, see https://jax.readthedocs.io/en/latest/user_guides.html
Note, that jax's documentation is inconsistent, and `eigvals` and/or
`subset_by_index` seems not to be implemented. Hence, here we calculate all the
eigenvalues, but then only return the requested subset.
Parameters
----------
matrix:
ndarray or qutip.Qobj to be diagonalized
evals_count:
how many eigenvalues should be returned
kwargs:
optional settings that are passed onto the diagonalization routine
Returns
----------
eigenvalues of matrix
"""
try:
import jax
except:
raise ImportError("Package jax is not installed.")
m = _cast_matrix(matrix, "dense")
# We explicitly cast to a numpy array
evals = np.asarray(jax.scipy.linalg.eigh(m, eigvals_only=True, **kwargs))
return evals[:evals_count]
def esys_jax_dense(
matrix, evals_count, **kwargs
) -> Union[Tuple[ndarray, ndarray], Tuple[ndarray, QutipEigenstates]]:
"""
Diagonalization based on jax's (dense) jax.scipy.linalg.eigh function.
Both evals and evecs are returned.
If available, different backends/devics (e.g., particular GPUs) can be set
though jax's interface, see https://jax.readthedocs.io/en/latest/user_guides.html
Note, that jax's documentation is inconsistent, and `eigvals` and/or
`subset_by_index` seems not to be implemented. Hence, here we calculate all the
eigenvalues and eigenvectors, but then only return the requested subset.
Parameters
----------
matrix:
ndarray or qutip.Qobj to be diagonalized
evals_count:
how many eigenvalues/vectors should be returned
kwargs:
optional settings that are passed onto the diagonalization routine
Returns
----------
a tuple of eigenvalues and eigenvectors. Eigenvectors are Qobjs if matrix is a Qobj instance
"""
try:
import jax
except:
raise ImportError("Package jax is not installed.")
m = _cast_matrix(matrix, "dense")
evals, evecs = jax.scipy.linalg.eigh(m, eigvals_only=False, **kwargs)
# We explicitly cast to numpy arrays
evals, evecs = np.asarray(evals), np.asarray(evecs)
evecs = (
_convert_evecs_to_qobjs(evecs, matrix) if isinstance(matrix, Qobj) else evecs
)
return evals[:evals_count], evecs[:, :evals_count]
# Default values of various noise constants and parameters.

@@ -657,2 +747,5 @@ DIAG_METHODS = {

"esys_cupy_sparse": esys_cupy_sparse,
# jax dense
"evals_jax_dense": evals_jax_dense,
"esys_jax_dense": esys_jax_dense,
}

@@ -14,3 +14,3 @@ # flux_qubit.py

from abc import ABC, abstractmethod
from typing import Any, Dict, List, Optional, Tuple, Union
from typing import Any, Callable, Dict, List, Optional, Tuple, Union

@@ -308,2 +308,10 @@ import numpy as np

and `ParameterSweep`. If not provided, an id is auto-generated.
esys_method:
method for esys diagonalization, callable or string representation
esys_method_options:
dictionary with esys diagonalization options
evals_method:
method for evals diagonalization, callable or string representation
evals_method_options:
dictionary with evals diagonalization options
"""

@@ -340,6 +348,6 @@

id_str: Optional[str] = None,
evals_method: Optional[str] = None,
evals_method_options: Optional[dict] = None,
esys_method: Optional[str] = None,
esys_method_options: Optional[dict] = None,
evals_method: Union[Callable, str, None] = None,
evals_method_options: Union[dict, None] = None,
esys_method: Union[Callable, str, None] = None,
esys_method_options: Union[dict, None] = None,
) -> None:

@@ -346,0 +354,0 @@ base.QubitBaseClass.__init__(

@@ -16,3 +16,3 @@ # fluxonium.py

from typing import TYPE_CHECKING, Any, Dict, List, Optional, Tuple, Union
from typing import TYPE_CHECKING, Any, Callable, Dict, List, Optional, Tuple, Union

@@ -64,2 +64,10 @@ import numpy as np

and `ParameterSweep`. If not provided, an id is auto-generated.
esys_method:
method for esys diagonalization, callable or string representation
esys_method_options:
dictionary with esys diagonalization options
evals_method:
method for evals diagonalization, callable or string representation
evals_method_options:
dictionary with evals diagonalization options
"""

@@ -81,6 +89,6 @@ EJ = descriptors.WatchedProperty(float, "QUANTUMSYSTEM_UPDATE")

id_str: Optional[str] = None,
evals_method: Optional[str] = None,
evals_method_options: Optional[dict] = None,
esys_method: Optional[str] = None,
esys_method_options: Optional[dict] = None,
evals_method: Union[Callable, str, None] = None,
evals_method_options: Union[dict, None] = None,
esys_method: Union[Callable, str, None] = None,
esys_method_options: Union[dict, None] = None,
) -> None:

@@ -87,0 +95,0 @@ base.QubitBaseClass.__init__(

@@ -37,3 +37,3 @@ # hilbert_space.py

from numpy import ndarray
from qutip.qobj import Qobj
from qutip import Qobj
from scipy.sparse import csc_matrix, dia_matrix

@@ -372,2 +372,10 @@

can be supplied here upon initialization of a `HilbertSpace` instance.
esys_method:
method for esys diagonalization, callable or string representation
esys_method_options:
dictionary with esys diagonalization options
evals_method:
method for evals diagonalization, callable or string representation
evals_method_options:
dictionary with evals diagonalization options
"""

@@ -387,6 +395,6 @@

ignore_low_overlap: bool = False,
evals_method: Optional[str] = None,
evals_method_options: Optional[dict] = None,
esys_method: Optional[str] = None,
esys_method_options: Optional[dict] = None,
evals_method: Union[Callable, str, None] = None,
evals_method_options: Union[dict, None] = None,
esys_method: Union[Callable, str, None] = None,
esys_method_options: Union[dict, None] = None,
) -> None:

@@ -1027,3 +1035,6 @@ if has_duplicate_id_str(subsystem_list):

self,
op: Union[Tuple[Union[np.ndarray, csc_matrix], QuantumSys], Callable],
op_callable_or_tuple: Union[
Tuple[Union[np.ndarray, csc_matrix], QuantumSys], Callable
],
truncated_dim: Optional[int] = None,
**kwargs,

@@ -1034,2 +1045,8 @@ ) -> Qobj:

(as opposed to both the "native basis" or "bare eigenbasis" of the subsystem).
The returned operator should not retain memory of the Hilbert-space sizes
of the underlying subsystems, thus we modify the dims of the returned operator.
truncated_dim should be set to the cutoff Hilbert-space size of the dressed system:
if it is set to the default value None, no cutoff of the resulting operator is made but
the dims of the resulting Qobj will be [[dimension], [dimension]]
`op_in_dressed_eigenbasis(...)` offers two different interfaces:

@@ -1041,3 +1058,3 @@

.op_in_dressed_eigenbasis(op=<Callable>)
.op_in_dressed_eigenbasis(op=<Callable>, truncated_dim=<int>)

@@ -1050,22 +1067,16 @@ 2. subsystem operators may be passed as arrays, along with the

.op_in_dressed_eigenbasis(op=(<ndarray>, <subsys>),
truncated_dim=<int>,
op_in_bare_eigenbasis=<Bool>)
"""
if isinstance(op, tuple):
op_matrix, subsys = op
if truncated_dim is None:
truncated_dim = self.dimension
if isinstance(op_callable_or_tuple, tuple):
op, subsys = op_callable_or_tuple
op_in_bare_eigenbasis = kwargs.pop("op_in_bare_eigenbasis", False)
subsys_index = self.get_subsys_index(subsys)
return self._op_matrix_to_dressed_eigenbasis(
op_matrix, subsys_index, op_in_bare_eigenbasis
)
assert callable(op)
subsys_index = self.get_subsys_index(op.__self__)
return self._op_callable_to_dressed_eigenbasis(op, subsys_index)
def _op_matrix_to_dressed_eigenbasis(
self,
op: Union[np.ndarray, csc_matrix],
subsys_index: int,
op_in_bare_eigenbasis,
) -> Qobj:
else:
assert callable(op_callable_or_tuple)
op = op_callable_or_tuple
op_in_bare_eigenbasis = False
subsys_index = self.get_subsys_index(op.__self__)
bare_evecs = self._data["bare_evecs"][subsys_index][0]

@@ -1080,18 +1091,8 @@ id_wrapped_op = spec_utils.identity_wrap(

dressed_evecs = self._data["evecs"][0]
dressed_op = id_wrapped_op.transform(dressed_evecs)
return dressed_op
def _op_callable_to_dressed_eigenbasis(
self, op: Callable, subsys_index: int
) -> Qobj:
bare_evecs = self._data["bare_evecs"][subsys_index][0]
id_wrapped_op = spec_utils.identity_wrap(
op,
self.subsystem_list[subsys_index],
self.subsystem_list,
evecs=bare_evecs,
dressed_op_data = id_wrapped_op.transform(dressed_evecs).data.toarray()
dressed_op_truncated = Qobj(
dressed_op_data[0:truncated_dim, 0:truncated_dim],
dims=[[truncated_dim], [truncated_dim]],
)
dressed_evecs = self._data["evecs"][0]
dressed_op = id_wrapped_op.transform(dressed_evecs)
return dressed_op
return dressed_op_truncated

@@ -1098,0 +1099,0 @@ ###################################################################################

@@ -1252,3 +1252,3 @@ # noise.py

References: Nguyen et al (2019), Smith et al (2020)
References: Smith et al (2020), see also Nguyen et al (2019).

@@ -1492,3 +1492,3 @@ Parameters

References: Nguyen et al (2019), Smith et al (2020)
References: Smith et al (2020), see also Nguyen et al (2019).

@@ -1495,0 +1495,0 @@ Parameters

@@ -967,3 +967,6 @@ # param_sweep.py

global _faulty_interactionterm_warning_issued
if self.faulty_interactionterm_suspected() and not _faulty_interactionterm_warning_issued:
if (
self.faulty_interactionterm_suspected()
and not _faulty_interactionterm_warning_issued
):
warnings.warn(

@@ -970,0 +973,0 @@ "The interactions specified for this HilbertSpace object involve coupling operators stored as fixed "

@@ -31,2 +31,4 @@ # qubit_base.py

overload,
TypeVar,
Type,
)

@@ -80,2 +82,5 @@

# annotate the types will inherit from Serializable
QuantumSystemType = TypeVar("QuantumSystemType", bound="QuantumSystem")
# -Generic quantum system container and Qubit base class------------------------------

@@ -101,3 +106,3 @@

def __new__(cls, *args, **kwargs) -> "QuantumSystem":
def __new__(cls: Type[QuantumSystemType], *args, **kwargs) -> QuantumSystemType:
QuantumSystem._quantumsystem_counter += 1

@@ -104,0 +109,0 @@

@@ -15,3 +15,3 @@ # transmon.py

from typing import Any, Dict, List, Optional, Tuple, Union
from typing import Any, Callable, Dict, List, Optional, Tuple, Union

@@ -69,2 +69,10 @@ import numpy as np

and `ParameterSweep`. If not provided, an id is auto-generated.
esys_method:
method for esys diagonalization, callable or string representation
esys_method_options:
dictionary with esys diagonalization options
evals_method:
method for evals diagonalization, callable or string representation
evals_method_options:
dictionary with evals diagonalization options
"""

@@ -84,6 +92,6 @@ EJ = descriptors.WatchedProperty(float, "QUANTUMSYSTEM_UPDATE")

id_str: Optional[str] = None,
evals_method: Optional[str] = None,
evals_method_options: Optional[dict] = None,
esys_method: Optional[str] = None,
esys_method_options: Optional[dict] = None,
evals_method: Union[Callable, str, None] = None,
evals_method_options: Union[dict, None] = None,
esys_method: Union[Callable, str, None] = None,
esys_method_options: Union[dict, None] = None,
) -> None:

@@ -628,2 +636,10 @@ base.QubitBaseClass.__init__(

and `ParameterSweep`. If not provided, an id is auto-generated.
esys_method:
method for esys diagonalization, callable or string representation
esys_method_options:
dictionary with esys diagonalization options
evals_method:
method for evals diagonalization, callable or string representation
evals_method_options:
dictionary with evals diagonalization options
"""

@@ -630,0 +646,0 @@ EJmax = descriptors.WatchedProperty(float, "QUANTUMSYSTEM_UPDATE")

@@ -13,4 +13,5 @@ # zeropi_full.py

from typing import Any, Dict, List, Optional, Tuple, Union
from typing import Any, Dict, List, Optional, Tuple, Union, Callable
import numpy as np

@@ -104,2 +105,10 @@

and `ParameterSweep`. If not provided, an id is auto-generated.
esys_method:
method for esys diagonalization, callable or string representation
esys_method_options:
dictionary with esys diagonalization options
evals_method:
method for evals diagonalization, callable or string representation
evals_method_options:
dictionary with evals diagonalization options
"""

@@ -167,2 +176,6 @@ EJ = descriptors.WatchedProperty(

id_str: Optional[str] = None,
evals_method: Union[Callable, str, None] = None,
evals_method_options: Union[dict, None] = None,
esys_method: Union[Callable, str, None] = None,
esys_method_options: Union[dict, None] = None,
) -> None:

@@ -185,2 +198,6 @@ base.QuantumSystem.__init__(self, id_str=id_str)

id_str=self._id_str + " [interior ZeroPi]",
evals_method=evals_method,
evals_method_options=evals_method_options,
esys_method=esys_method,
esys_method_options=esys_method_options,
)

@@ -195,9 +212,2 @@ self.dC = dC

# This class does not yet support custom diagonalization options, but these
# still have to be defined
self.evals_method = None
self.evals_method_options = None
self.esys_method = None
self.esys_method_options = None
dispatch.CENTRAL_DISPATCH.register("GRID_UPDATE", self)

@@ -299,2 +309,34 @@

@property
def esys_method(self) -> Union[Callable, str, None]:
return self._zeropi.esys_method
@esys_method.setter
def esys_method(self, value: Union[Callable, str, None] = None) -> None:
self._zeropi.esys_method = value
@property
def esys_method_options(self) -> Union[dict, None]:
return self._zeropi.esys_method_options
@esys_method_options.setter
def esys_method_options(self, value: Union[dict, None] = None) -> None:
self._zeropi.esys_merthod_options = value
@property
def evals_method(self) -> Union[Callable, str, None]:
return self._zeropi.evals_method
@evals_method.setter
def evals_method(self, value: Union[Callable, str, None] = None) -> None:
self._zeropi.evals_method = value
@property
def evals_method_options(self) -> Union[dict, None]:
return self._zeropi.evals_method_options
@evals_method_options.setter
def evals_method_options(self, value: Union[dict, None] = None) -> None:
self._zeropi.evals_merthod_options = value
def hamiltonian(

@@ -301,0 +343,0 @@ self,

@@ -15,3 +15,3 @@ # zeropi.py

from typing import Any, Dict, List, Optional, Tuple, Union
from typing import Any, Callable, Dict, List, Optional, Tuple, Union

@@ -102,2 +102,10 @@ import numpy as np

and `ParameterSweep`. If not provided, an id is auto-generated.
esys_method:
method for esys diagonalization, callable or string representation
esys_method_options:
dictionary with esys diagonalization options
evals_method:
method for evals diagonalization, callable or string representation
evals_method_options:
dictionary with evals diagonalization options
"""

@@ -128,6 +136,6 @@ EJ = descriptors.WatchedProperty(float, "QUANTUMSYSTEM_UPDATE")

id_str: Optional[str] = None,
evals_method: Optional[str] = None,
evals_method_options: Optional[dict] = None,
esys_method: Optional[str] = None,
esys_method_options: Optional[dict] = None,
evals_method: Union[Callable, str, None] = None,
evals_method_options: Union[dict, None] = None,
esys_method: Union[Callable, str, None] = None,
esys_method_options: Union[dict, None] = None,
) -> None:

@@ -134,0 +142,0 @@ base.QubitBaseClass.__init__(

@@ -21,3 +21,3 @@ # fileio_serializers.py

from numbers import Number
from typing import TYPE_CHECKING, Any, Callable, Dict, List, Tuple, Union
from typing import TYPE_CHECKING, Any, Callable, Dict, List, Tuple, Union, TypeVar, Type

@@ -39,3 +39,6 @@ import numpy as np

# annotate the types will inherit from Serializable
SerializableType = TypeVar("SerializableType", bound="Serializable")
@runtime_checkable

@@ -47,3 +50,3 @@ class Serializable(Protocol):

def __new__(cls: Any, *args, **kwargs) -> "Serializable":
def __new__(cls: Type[SerializableType], *args, **kwargs) -> SerializableType:
"""Modified `__new__` to set up `cls._init_params`. The latter is used to

@@ -63,3 +66,3 @@ record which of the `__init__` parameters are to be stored/read in file IO."""

@classmethod
def deserialize(cls, io_data: "IOData") -> "Serializable":
def deserialize(cls: Type[SerializableType], io_data: "IOData") -> SerializableType:
"""

@@ -66,0 +69,0 @@ Take the given IOData and return an instance of the described class,

@@ -428,9 +428,9 @@ # test_hilbertspace.py

op1 = qt.Qobj(
hilbert_space.op_in_dressed_eigenbasis(op=osc_a.annihilation_operator)[
0:10, 0:10
]
hilbert_space.op_in_dressed_eigenbasis(
op_callable_or_tuple=osc_a.annihilation_operator
)[0:10, 0:10]
)
op2 = qt.Qobj(
hilbert_space.op_in_dressed_eigenbasis(
op=(osc_a.annihilation_operator(), osc_a)
op_callable_or_tuple=(osc_a.annihilation_operator(), osc_a)
)[0:10, 0:10]

@@ -440,3 +440,4 @@ )

hilbert_space.op_in_dressed_eigenbasis(
op=(osc_a.annihilation_operator(), osc_a), op_in_bare_eigenbasis=True
op_callable_or_tuple=(osc_a.annihilation_operator(), osc_a),
op_in_bare_eigenbasis=True,
)[0:10, 0:10]

@@ -446,3 +447,4 @@ )

hilbert_space.op_in_dressed_eigenbasis(
op=(osc_a.annihilation_operator(), osc_a), op_in_bare_eigenbasis=False
op_callable_or_tuple=(osc_a.annihilation_operator(), osc_a),
op_in_bare_eigenbasis=False,
)[0:10, 0:10]

@@ -471,7 +473,10 @@ )

hilbert_space.generate_lookup()
op1 = hilbert_space.op_in_dressed_eigenbasis(op=tmon.n_operator)
op1 = hilbert_space.op_in_dressed_eigenbasis(
op_callable_or_tuple=tmon.n_operator
)
n_op_bare_eigenbasis_v2 = tmon.n_operator(energy_esys=True)
op2 = hilbert_space.op_in_dressed_eigenbasis(
op=(n_op_bare_eigenbasis_v2, tmon), op_in_bare_eigenbasis=True
op_callable_or_tuple=(n_op_bare_eigenbasis_v2, tmon),
op_in_bare_eigenbasis=True,
)
assert op1 == op2

@@ -18,2 +18,3 @@ # misc.py

import inspect
from collections.abc import Sequence

@@ -453,3 +454,32 @@ from distutils.version import StrictVersion

def inspect_public_API(
module: Any,
public_names: List[str] = [],
private_names: List[str] = [],
) -> List[str]:
"""
Find all public names in a module.
Parameters
----------
module:
Module to be inspected
public_names:
Names that have already been found / manually be set to public
private_names:
Names that should be excluded from the public API
"""
for name, obj in inspect.getmembers(module):
if name.startswith("_") or name in public_names or name in private_names:
continue
if inspect.isclass(obj) or inspect.isfunction(obj) or inspect.ismodule(obj):
public_names.append(name)
elif not callable(obj) and name.isupper(): # constants
public_names.append(name)
return public_names
MATPLOTLIB_WIDGET_BACKEND = "module://ipympl.backend_nbagg"
_HAS_WIDGET_BACKEND = get_matplotlib_backend() == MATPLOTLIB_WIDGET_BACKEND
# THIS FILE IS GENERATED FROM scqubits SETUP.PY
short_version = '3.2.0'
version = '3.2.0'
short_version = '3.3.0'
version = '3.3.0'
release = True

@@ -55,3 +55,3 @@ """scqubits: superconducting qubits in Python

MAJOR = 3
MINOR = 2
MINOR = 3
MICRO = 0

@@ -71,3 +71,3 @@ ISRELEASED = True

"h5-support": ["h5py (>=2.10)"],
"pathos": ["pathos", "dill"]
"pathos": ["pathos", "dill"],
}

@@ -74,0 +74,0 @@

Sorry, the diff of this file is too big to display