Remove unnecessary use of setattr()

If an attribute is referenced using a string literal, there is no reason
to use setattr().
This commit is contained in:
Jeremy Saklad 2021-07-06 11:27:13 -05:00
parent 3a97dba0cb
commit 0c08586f24
Signed by: Jeremy Saklad
GPG Key ID: 9CA2149583EDBF84
1 changed files with 3 additions and 3 deletions

View File

@ -336,7 +336,7 @@ def NewIntermediateBoolVar(self, name, expression, domain):
self.AddLinearExpressionInDomain(expression, domain.Complement()).OnlyEnforceIf(intermediate.Not())
return intermediate
setattr(cp_model.CpModel, 'NewIntermediateBoolVar', NewIntermediateBoolVar)
cp_model.CpModel.NewIntermediateBoolVar = NewIntermediateBoolVar
del NewIntermediateBoolVar
@ -347,7 +347,7 @@ def AddApproximateExponentiationEquality(self, target, var, exp, upto):
"""
return self.AddAllowedAssignments([target, var], [(int(base**exp), base) for base in range(upto + 1)])
setattr(cp_model.CpModel, 'AddApproximateExponentiationEquality', AddApproximateExponentiationEquality)
cp_model.CpModel.AddApproximateExponentiationEquality = AddApproximateExponentiationEquality
del AddApproximateExponentiationEquality
@ -367,7 +367,7 @@ def AddGeneralMultiplicationEquality(self, target, *variables):
product = reduce(function, variables)
return self.Add(target == product)
setattr(cp_model.CpModel, 'AddGeneralMultiplicationEquality', AddGeneralMultiplicationEquality)
cp_model.CpModel.AddGeneralMultiplicationEquality = AddGeneralMultiplicationEquality
del AddGeneralMultiplicationEquality