Skip to content
Snippets Groups Projects
Verified Commit 91bdb0b1 authored by Anton Akhmerov's avatar Anton Akhmerov
Browse files

move a value range check to the place before the value is used

parent 451a6031
No related branches found
No related tags found
No related merge requests found
...@@ -195,6 +195,9 @@ class SpectralDensity: ...@@ -195,6 +195,9 @@ class SpectralDensity:
# store this vector for reproducibility # store this vector for reproducibility
self._v0 = np.exp(2j * np.pi * rng.random_sample(hamiltonian.shape[0])) self._v0 = np.exp(2j * np.pi * rng.random_sample(hamiltonian.shape[0]))
if eps <= 0:
raise ValueError("'eps' must be positive")
# Hamiltonian rescaled as in Eq. (24) # Hamiltonian rescaled as in Eq. (24)
self.hamiltonian, (self._a, self._b) = _rescale(hamiltonian, self.hamiltonian, (self._a, self._b) = _rescale(hamiltonian,
eps=self.eps, eps=self.eps,
...@@ -209,8 +212,6 @@ class SpectralDensity: ...@@ -209,8 +212,6 @@ class SpectralDensity:
if num_moments <= 0 or num_moments != int(num_moments): if num_moments <= 0 or num_moments != int(num_moments):
raise ValueError("'num_moments' must be a positive integer") raise ValueError("'num_moments' must be a positive integer")
if eps <= 0:
raise ValueError("'eps' must be positive")
if vector_factory is None: if vector_factory is None:
self._vector_factory = _VectorFactory( self._vector_factory = _VectorFactory(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment