Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
12 changes: 12 additions & 0 deletions dev_tools/conf/.pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@ score=no
reports=no
enable=
anomalous-backslash-in-string,
assert-on-tuple,
bad-indentation,
bad-option-value,
bad-reversed-sequence,
bad-super-call,
consider-merging-isinstance,
continue-in-finally,
dangerous-default-value,
duplicate-argument-name,
expression-not-assigned,
function-redefined,
inconsistent-mro,
trailing-whitespace,
unused-variable,
wrong-import-order,
Expand Down
2 changes: 1 addition & 1 deletion src/openfermion/hamiltonians/_plane_wave_hamiltonian.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def dual_basis_external_potential(grid, geometry, spinless,
"""
prefactor = -4.0 * numpy.pi / grid.volume_scale()
if non_periodic and period_cutoff is None:
period_cutoff = grid.volume_scale() ** (1. / grid.dimensions)
period_cutoff = grid.volume_scale()**(1. / grid.dimensions)
operator = None
if spinless:
spins = [None]
Expand Down
2 changes: 1 addition & 1 deletion src/openfermion/ops/_binary_polynomial.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def __init__(self, term=None):
return

# Sequence input: list of tuples of tuples
elif isinstance(term, tuple) or isinstance(term, list):
elif isinstance(term, (list, tuple)):
self._parse_sequence(list(term))

# String input
Expand Down
2 changes: 1 addition & 1 deletion src/openfermion/ops/_symbolic_operator.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ def __init__(self, term=None, coefficient=1.):

# Parse the term
# Sequence input
if isinstance(term, tuple) or isinstance(term, list):
if isinstance(term, (list, tuple)):
term = self._parse_sequence(term)
# String input
elif isinstance(term, string_types):
Expand Down
2 changes: 1 addition & 1 deletion src/openfermion/utils/_operator_utils_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def test_is_identity_double_of_unit_bosonoperator(self):
def test_is_identity_unit_quadoperator(self):
self.assertTrue(is_identity(QuadOperator(())))

def test_is_identity_double_of_unit_bosonoperator(self):
def test_is_identity_double_of_unit_quadoperator(self):
self.assertTrue(is_identity(2. * QuadOperator(())))

def test_is_identity_unit_qubitoperator(self):
Expand Down
19 changes: 0 additions & 19 deletions src/openfermion/utils/_special_operators.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,6 @@

from openfermion.ops import BosonOperator, FermionOperator, down_index, up_index


def up_index(index):
"""Function to return up-orbital index given a spatial orbital index.

Args:
index (Int): spatial orbital index
"""
return 2 * index


def down_index(index):
"""Function to return down-orbital index given a spatial orbital index.

Args:
index (Int): spatial orbital index
"""
return 2 * index + 1


def s_plus_operator(n_spatial_orbitals):
r"""Return the s+ operator.

Expand Down
29 changes: 19 additions & 10 deletions src/openfermion/utils/_trotter_exp_to_qgates_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,31 +32,40 @@ def test_exceptions(self):
# Test exceptions in trotter_operator_grouping()

with self.assertRaises(ValueError):
[i for i in trotter_operator_grouping(self.qo1, trotter_order=0)]
_ = [
i for i in trotter_operator_grouping(self.qo1, trotter_order=0)
]

with self.assertRaises(ValueError):
[i for i in trotter_operator_grouping(self.qo1, trotter_order=4)]
_ = [
i for i in trotter_operator_grouping(self.qo1, trotter_order=4)
]

with self.assertRaises(TypeError):
[i for i in trotter_operator_grouping(42)]
_ = [i for i in trotter_operator_grouping(42)]

emptyQO = QubitOperator()
with self.assertRaises(TypeError):
[i for i in trotter_operator_grouping(emptyQO)]
_ = [i for i in trotter_operator_grouping(emptyQO)]

emptyTO = []
with self.assertRaises(TypeError):
[i for i in trotter_operator_grouping(self.qo1,
term_ordering=emptyTO)]
_ = [
i for i in trotter_operator_grouping(self.qo1,
term_ordering=emptyTO)
]

# Too few ops for 2nd-order
with self.assertRaises(ValueError):
[i for i in trotter_operator_grouping(self.opA, trotter_order=2)]
_ = [
i for i in trotter_operator_grouping(self.opA, trotter_order=2)
]

# Too few ops for 3rd-order
with self.assertRaises(ValueError):
[i for i in trotter_operator_grouping(self.opA,
trotter_order=3)]
_ = [
i for i in trotter_operator_grouping(self.opA, trotter_order=3)
]

def compare_qubop_lists(self, gold, res):
# Compare lists of operators. Used in most test functions.
Expand Down Expand Up @@ -163,7 +172,7 @@ def test_trott_ordering_2nd_ord(self):
op_b = QubitOperator('Z2', 1.)
op_c = QubitOperator('Z3', 1.)
ham = op_a + op_b + op_c
[op for op in trotter_operator_grouping(ham, trotter_order=2)]
_ = [op for op in trotter_operator_grouping(ham, trotter_order=2)]
gold = []
gold.append(op_a * 0.5)
gold.append(op_b * 0.5)
Expand Down