Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Aug 28, 2024
1 parent c11cfa5 commit e725f83
Show file tree
Hide file tree
Showing 7 changed files with 107 additions and 258 deletions.
3 changes: 3 additions & 0 deletions conda_classic_solver/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright (C) 2022 Anaconda, Inc
# Copyright (C) 2023 conda
# SPDX-License-Identifier: BSD-3-Clause
# Copyright (C) 2012 Anaconda, Inc
# Copyright (C) 2023 conda
# SPDX-License-Identifier: BSD-3-Clause
Expand Down
11 changes: 5 additions & 6 deletions conda_classic_solver/_logic.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright (C) 2022 Anaconda, Inc
# Copyright (C) 2023 conda
# SPDX-License-Identifier: BSD-3-Clause
# Copyright (C) 2012 Anaconda, Inc
# Copyright (C) 2023 conda
# SPDX-License-Identifier: BSD-3-Clause
Expand Down Expand Up @@ -578,9 +581,7 @@ def BDD(self, lits, coeffs, nterms, lo, hi, polarity):
# avoid calling self.assign here via add_new_clauses=True.
# If we want to translate parts of the code to a compiled language,
# self.BDD (+ its downward call stack) is the prime candidate!
ret[call_stack_pop()] = ITE(
abs(LA), thi, tlo, polarity, add_new_clauses=True
)
ret[call_stack_pop()] = ITE(abs(LA), thi, tlo, polarity, add_new_clauses=True)
return ret[target]

def LinearBound(self, lits, coeffs, lo, hi, preprocess, polarity):
Expand All @@ -591,9 +592,7 @@ def LinearBound(self, lits, coeffs, lo, hi, preprocess, polarity):
nterms = len(coeffs)
if nterms and coeffs[-1] > hi:
nprune = sum(c > hi for c in coeffs)
log.log(
TRACE, "Eliminating %d/%d terms for bound violation", nprune, nterms
)
log.log(TRACE, "Eliminating %d/%d terms for bound violation", nprune, nterms)
nterms -= nprune
else:
nprune = 0
Expand Down
29 changes: 9 additions & 20 deletions conda_classic_solver/logic.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Copyright (C) 2022 Anaconda, Inc
# Copyright (C) 2023 conda
# SPDX-License-Identifier: BSD-3-Clause
# Copyright (C) 2012 Anaconda, Inc
# Copyright (C) 2023 conda
# SPDX-License-Identifier: BSD-3-Clause
Expand Down Expand Up @@ -166,14 +169,10 @@ def Any(self, vals, polarity=None, name=None):
return self._eval(self._clauses.Any, (list(vals),), (), polarity, name)

def AtMostOne_NSQ(self, vals, polarity=None, name=None):
return self._eval(
self._clauses.AtMostOne_NSQ, (list(vals),), (), polarity, name
)
return self._eval(self._clauses.AtMostOne_NSQ, (list(vals),), (), polarity, name)

def AtMostOne_BDD(self, vals, polarity=None, name=None):
return self._eval(
self._clauses.AtMostOne_BDD, (list(vals),), (), polarity, name
)
return self._eval(self._clauses.AtMostOne_BDD, (list(vals),), (), polarity, name)

def AtMostOne(self, vals, polarity=None, name=None):
vals = list(vals)
Expand All @@ -185,14 +184,10 @@ def AtMostOne(self, vals, polarity=None, name=None):
return self._eval(what, (vals,), (), polarity, name)

def ExactlyOne_NSQ(self, vals, polarity=None, name=None):
return self._eval(
self._clauses.ExactlyOne_NSQ, (list(vals),), (), polarity, name
)
return self._eval(self._clauses.ExactlyOne_NSQ, (list(vals),), (), polarity, name)

def ExactlyOne_BDD(self, vals, polarity=None, name=None):
return self._eval(
self._clauses.ExactlyOne_BDD, (list(vals),), (), polarity, name
)
return self._eval(self._clauses.ExactlyOne_BDD, (list(vals),), (), polarity, name)

def ExactlyOne(self, vals, polarity=None, name=None):
vals = list(vals)
Expand Down Expand Up @@ -231,17 +226,11 @@ def sat(self, additional=None, includeIf=False, names=False, limit=0):
return set() if names else []
if additional:
additional = (tuple(self.names.get(c, c) for c in cc) for cc in additional)
solution = self._clauses.sat(
additional=additional, includeIf=includeIf, limit=limit
)
solution = self._clauses.sat(additional=additional, includeIf=includeIf, limit=limit)
if solution is None:
return None
if names:
return {
nm
for nm in (self.indices.get(s) for s in solution)
if nm and nm[0] != "!"
}
return {nm for nm in (self.indices.get(s) for s in solution) if nm and nm[0] != "!"}
return solution

def itersolve(self, constraints=None, m=None):
Expand Down
Loading

0 comments on commit e725f83

Please sign in to comment.