Skip to content
Draft
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions dev_tools/conf/.pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@

[MAIN]

# Analyse import fallback blocks. This can be used to support both Python 2 and
# 3 compatible code, which means that the block might have code that exists
# only in one or another interpreter, leading to false positives when analysed.
# Analyse import fallback blocks.
analyse-fallback-blocks=no

# Clear in-memory caches upon conclusion of linting. Useful if running pylint
Expand Down Expand Up @@ -1027,4 +1025,4 @@ init-import=yes

# List of qualified module names which can have objects that can redefine
# builtins.
redefining-builtins-modules=six.moves,past.builtins,future.builtins,builtins,io
redefining-builtins-modules=builtins,io
4 changes: 2 additions & 2 deletions src/openfermion/chem/molecular_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ def spinorb_from_spatial(one_body_integrals, two_body_integrals):
return one_body_coefficients, two_body_coefficients


class MolecularData(object):
class MolecularData:
"""Class for storing molecule data from a fixed basis set at a fixed
geometry that is obtained from classical electronic structure
packages. Not every field is filled in every calculation. All data
Expand Down Expand Up @@ -859,7 +859,7 @@ def load(self):
# Load charge:
self.charge = int(f["charge"][...])
# Load description:
self.description = f["description"][...].tobytes().decode('utf-8').rstrip(u'\x00')
self.description = f["description"][...].tobytes().decode('utf-8').rstrip('\x00')
# Load name:
self.name = f["name"][...].tobytes().decode('utf-8')
# Load n_atoms:
Expand Down
4 changes: 2 additions & 2 deletions src/openfermion/contrib/representability/_dualbasis.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import copy


class DualBasisElement(object):
class DualBasisElement:
"""
This object is named after the algebraic dual space or dual vector space

Expand Down Expand Up @@ -154,7 +154,7 @@ def __add__(self, other):
raise TypeError("DualBasisElement can be added to same type or DualBasis")


class DualBasis(object):
class DualBasis:
def __init__(self, elements: Optional[Union[None, List[DualBasisElement]]] = None):
"""
A collection of DualBasisElements
Expand Down
4 changes: 2 additions & 2 deletions src/openfermion/contrib/representability/_multitensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from openfermion.contrib.representability._dualbasis import DualBasisElement, DualBasis


class TMap(object):
class TMap:
def __init__(self, tensors):
"""
provide a map of tensor name to tensors
Expand All @@ -22,7 +22,7 @@ def __iter__(self):
yield tt


class MultiTensor(object):
class MultiTensor:
def __init__(self, tensors, dual_basis=DualBasis()):
"""
A collection of tensor objects with maps from name to tensor
Expand Down
2 changes: 1 addition & 1 deletion src/openfermion/contrib/representability/_namedtensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from openfermion.contrib.representability._bijections import Bijection, index_index_basis


class Tensor(object):
class Tensor:
"""
Instantiation of named tensor
"""
Expand Down
2 changes: 1 addition & 1 deletion src/openfermion/hamiltonians/special_operators_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def test_init(self):
# Test 'c' operator
op1 = majorana_operator((2, 0))
op2 = majorana_operator('c2')
op3 = majorana_operator(u'c2')
op3 = majorana_operator('c2')
correct = FermionOperator('2^') + FermionOperator('2')
self.assertEqual(op1, op2)
self.assertEqual(op1, op3)
Expand Down
10 changes: 4 additions & 6 deletions src/openfermion/linalg/davidson.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class DavidsonError(Exception):
pass


class DavidsonOptions(object):
class DavidsonOptions:
"""Davidson algorithm iteration options."""

def __init__(self, max_subspace=100, max_iterations=300, eps=1e-6, real_only=False):
Expand Down Expand Up @@ -68,7 +68,7 @@ def set_dimension(self, dimension):
self.max_subspace = min(self.max_subspace, dimension + 1)


class Davidson(object):
class Davidson:
"""Davidson algorithm to get the n states with smallest eigenvalues."""

def __init__(self, linear_operator, linear_operator_diagonal, options=None):
Expand Down Expand Up @@ -350,7 +350,7 @@ def __init__(self, qubit_operator, n_qubits=None, options=None):
n_qubits(int): Number of qubits.
options(DavidsonOptions): Iteration options.
"""
super(QubitDavidson, self).__init__(
super().__init__(
generate_linear_qubit_operator(qubit_operator, n_qubits, options),
get_linear_qubit_operator_diagonal(qubit_operator, n_qubits),
options=options,
Expand All @@ -366,9 +366,7 @@ def __init__(self, sparse_matrix, options=None):
sparse_matrix(scipy.sparse.spmatrix): A sparse matrix in scipy.
options(DavidsonOptions): Iteration options.
"""
super(SparseDavidson, self).__init__(
sparse_matrix, sparse_matrix.diagonal(), options=options
)
super().__init__(sparse_matrix, sparse_matrix.diagonal(), options=options)


def generate_random_vectors(row, col, real_only=False):
Expand Down
8 changes: 3 additions & 5 deletions src/openfermion/linalg/linear_qubit_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from openfermion.utils.operator_utils import count_qubits


class LinearQubitOperatorOptions(object):
class LinearQubitOperatorOptions:
"""Options for LinearQubitOperator."""

def __init__(self, processes=10, pool=None):
Expand Down Expand Up @@ -94,7 +94,7 @@ def __init__(self, qubit_operator, n_qubits=None):
)

n_hilbert = 2**n_qubits
super(LinearQubitOperator, self).__init__(shape=(n_hilbert, n_hilbert), dtype=complex)
super().__init__(shape=(n_hilbert, n_hilbert), dtype=complex)
self.qubit_operator = qubit_operator
self.n_qubits = n_qubits

Expand Down Expand Up @@ -156,9 +156,7 @@ def __init__(self, qubit_operator, n_qubits=None, options=None):
"""
n_qubits = n_qubits or count_qubits(qubit_operator)
n_hilbert = 2**n_qubits
super(ParallelLinearQubitOperator, self).__init__(
shape=(n_hilbert, n_hilbert), dtype=complex
)
super().__init__(shape=(n_hilbert, n_hilbert), dtype=complex)

self.qubit_operator = qubit_operator
self.n_qubits = n_qubits
Expand Down
2 changes: 1 addition & 1 deletion src/openfermion/ops/operators/binary_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class BinaryCodeError(Exception):
pass


class BinaryCode(object):
class BinaryCode:
r"""The BinaryCode class provides a representation of an encoding-decoding
pair for binary vectors of different lengths, where the decoding is allowed
to be non-linear.
Expand Down
2 changes: 1 addition & 1 deletion src/openfermion/ops/operators/binary_polynomial.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class BinaryPolynomialError(Exception):
pass


class BinaryPolynomial(object):
class BinaryPolynomial:
r"""The BinaryPolynomial class provides an analytic representation
of non-linear binary functions. An instance of this class describes
a term of binary variables (variables of the values {0,1}, indexed
Expand Down
2 changes: 1 addition & 1 deletion src/openfermion/ops/operators/binary_polynomial_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def test_init_string(self):
self.assertEqual(operator1.terms, [(1,)])
operator1 = BinaryPolynomial('9 w1 w2 + 5')
self.assertEqual(str(operator1), '[W1 W2] + [1]')
operator1 = BinaryPolynomial(u'9 w1 w2 + 5')
operator1 = BinaryPolynomial('9 w1 w2 + 5')
self.assertEqual(str(operator1), '[W1 W2] + [1]')

def test_none_init(self):
Expand Down
2 changes: 1 addition & 1 deletion src/openfermion/ops/operators/symbolic_operator_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def test_many_body_order(self):

op1 = DummyOperator1('0^ 3 5^ 6')
op2 = op1 + DummyOperator1('8^ 3')
op3 = op2 + DummyOperator1(u'1^ 2 3^ 4 5 ')
op3 = op2 + DummyOperator1('1^ 2 3^ 4 5 ')

op4 = DummyOperator2('X0 X1 Y3')
op5 = op4 - DummyOperator2('Z0')
Expand Down
2 changes: 1 addition & 1 deletion src/openfermion/ops/representations/doci_hamiltonian.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def __init__(self, constant, hc, hr1, hr2):
hr2: The coefficients of ($h^{(r2)}_{p, q}$).
This is an n_qubits x n_qubits array of floats.
"""
super(DOCIHamiltonian, self).__init__(None)
super().__init__(None)

self._n_qubits = hc.shape[0]
self._constant = constant
Expand Down
4 changes: 1 addition & 3 deletions src/openfermion/ops/representations/interaction_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,7 @@ def __init__(self, constant, one_body_tensor, two_body_tensor):
n_qubits numpy array of floats.
"""
# Make sure nonzero elements are only for normal ordered terms.
super(InteractionOperator, self).__init__(
{(): constant, (1, 0): one_body_tensor, (1, 1, 0, 0): two_body_tensor}
)
super().__init__({(): constant, (1, 0): one_body_tensor, (1, 1, 0, 0): two_body_tensor})

@property
def one_body_tensor(self):
Expand Down
4 changes: 1 addition & 3 deletions src/openfermion/ops/representations/interaction_rdm.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ def __init__(self, one_body_tensor, two_body_tensor):
two_body_tensor: Expectation values
<a^\dagger_p a^\dagger_q a_r a_s>.
"""
super(InteractionRDM, self).__init__(
{(1, 0): one_body_tensor, (1, 1, 0, 0): two_body_tensor}
)
super().__init__({(1, 0): one_body_tensor, (1, 1, 0, 0): two_body_tensor})

@property
def one_body_tensor(self):
Expand Down
2 changes: 1 addition & 1 deletion src/openfermion/ops/representations/polynomial_tensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def general_basis_change(general_tensor, rotation_matrix, key):
return transformed_general_tensor


class PolynomialTensor(object):
class PolynomialTensor:
r"""Class for storing tensor representations of operators that correspond
with multilinear polynomials in the fermionic ladder operators.
For instance, in a quadratic Hamiltonian (degree 2 polynomial) which
Expand Down
6 changes: 2 additions & 4 deletions src/openfermion/ops/representations/quadratic_hamiltonian.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,9 @@ def __init__(

# Initialize the PolynomialTensor
if antisymmetric_part is None:
super(QuadraticHamiltonian, self).__init__(
{(): constant, (1, 0): combined_hermitian_part}
)
super().__init__({(): constant, (1, 0): combined_hermitian_part})
else:
super(QuadraticHamiltonian, self).__init__(
super().__init__(
{
(): constant,
(1, 0): combined_hermitian_part,
Expand Down
Binary file not shown.
Binary file modified src/openfermion/resource_estimates/integrals/eri_reiher.h5
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"""


class KMeansCVT(object):
class KMeansCVT:
def __init__(self, grid: npt.NDArray, max_iteration: int = 100, threshold: float = 1e-6):
"""Initialize k-means solver to find interpolating points for ISDF.

Expand Down
2 changes: 1 addition & 1 deletion src/openfermion/resource_estimates/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def power_two(m: int) -> int:
return 0


class RunSilent(object):
class RunSilent:
"""Context manager to prevent function writing to stdout/stderr
e.g. for noisy_function(), wrap it like so

Expand Down
4 changes: 2 additions & 2 deletions src/openfermion/testing/testing_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ def random_quadratic_hamiltonian(
return QuadraticHamiltonian(hermitian_mat, antisymmetric_mat, constant, chemical_potential)


class EqualsTester(object):
class EqualsTester:
"""Tests equality against user-provided disjoint equivalence groups."""

def __init__(self, test_case):
Expand Down Expand Up @@ -315,7 +315,7 @@ def make_equality_pair(self, factory):
self.add_equality_group(factory(), factory())


class _ClassUnknownToSubjects(object):
class _ClassUnknownToSubjects:
"""Equality methods should be able to deal with the unexpected."""

def __eq__(self, other):
Expand Down
14 changes: 7 additions & 7 deletions src/openfermion/testing/testing_utils_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def test_add_equality_group_not_disjoint(self):
eq.add_equality_group(1)

def test_add_equality_group_bad_hash(self):
class KeyHash(object):
class KeyHash:
def __init__(self, k, h):
self._k = k
self._h = h
Expand All @@ -124,7 +124,7 @@ def __hash__(self):
eq.add_equality_group(KeyHash('c', 2), KeyHash('c', 3))

def test_add_equality_group_exception_hash(self):
class FailHash(object):
class FailHash:
def __hash__(self):
raise ValueError('injected failure')

Expand All @@ -135,7 +135,7 @@ def __hash__(self):
def test_can_fail_when_forgot_type_check(self):
eq = EqualsTester(self)

class NoTypeCheckEqualImplementation(object):
class NoTypeCheckEqualImplementation:
def __init__(self):
self.x = 1

Expand All @@ -151,7 +151,7 @@ def __ne__(self, other):
def test_fails_hash_is_default_and_inconsistent(self):
eq = EqualsTester(self)

class DefaultHashImplementation(object):
class DefaultHashImplementation:
__hash__ = object.__hash__

def __init__(self):
Expand All @@ -171,7 +171,7 @@ def __ne__(self, other):
def test_fails_when_ne_is_inconsistent(self):
eq = EqualsTester(self)

class InconsistentNeImplementation(object):
class InconsistentNeImplementation:
def __init__(self):
self.x = 1

Expand All @@ -187,7 +187,7 @@ def __ne__(self, other):
def test_fails_when_not_reflexive(self):
eq = EqualsTester(self)

class NotReflexiveImplementation(object):
class NotReflexiveImplementation:
def __init__(self):
self.x = 1

Expand All @@ -200,7 +200,7 @@ def __eq__(self, other):
def test_fails_when_not_commutative(self):
eq = EqualsTester(self)

class NotCommutativeImplementation(object):
class NotCommutativeImplementation:
def __init__(self, x):
self.x = x

Expand Down
1 change: 0 additions & 1 deletion src/openfermion/utils/operator_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
# limitations under the License.
"""This module provides generic tools for classes in ops/"""

from builtins import map, zip
import marshal
import os

Expand Down
Loading