Skip to content

Commit 420c598

Browse files
committed
__eval_binary
1 parent 776651a commit 420c598

1 file changed

Lines changed: 19 additions & 15 deletions

File tree

src/diffpy/srfit/equation/builder.py

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -332,7 +332,7 @@ def _prepare_builders(self, eqstr, buildargs, argclass, argkw):
332332
Returns a dictionary of the name, BaseBuilder pairs.
333333
"""
334334

335-
eqargs = self._getUndefinedArgs(eqstr)
335+
eqargs = self._get_undefined_args(eqstr)
336336

337337
# Raise an error if there are arguments that need to be created, but
338338
# this is disallowed.
@@ -353,7 +353,7 @@ def _prepare_builders(self, eqstr, buildargs, argclass, argkw):
353353

354354
return
355355

356-
def _getUndefinedArgs(self, eqstr):
356+
def _get_undefined_args(self, eqstr):
357357
"""Get the undefined arguments from eqstr.
358358
359359
This tokenizes eqstr and extracts undefined arguments. An
@@ -441,7 +441,7 @@ def getEquation(self):
441441
eq = Equation(name, self.literal)
442442
return eq
443443

444-
def __evalBinary(self, other, OperatorClass, onleft=True):
444+
def __eval_binary(self, other, OperatorClass, onleft=True):
445445
"""Evaluate a binary function.
446446
447447
Other can be an BaseBuilder or a constant.
@@ -488,28 +488,30 @@ def __evalUnary(self, OperatorClass):
488488
return opbuilder
489489

490490
def __add__(self, other):
491-
return self.__evalBinary(other, literals.AdditionOperator)
491+
return self.__eval_binary(other, literals.AdditionOperator)
492492

493493
def __radd__(self, other):
494-
return self.__evalBinary(other, literals.AdditionOperator, False)
494+
return self.__eval_binary(other, literals.AdditionOperator, False)
495495

496496
def __sub__(self, other):
497-
return self.__evalBinary(other, literals.SubtractionOperator)
497+
return self.__eval_binary(other, literals.SubtractionOperator)
498498

499499
def __rsub__(self, other):
500-
return self.__evalBinary(other, literals.SubtractionOperator, False)
500+
return self.__eval_binary(other, literals.SubtractionOperator, False)
501501

502502
def __mul__(self, other):
503-
return self.__evalBinary(other, literals.MultiplicationOperator)
503+
return self.__eval_binary(other, literals.MultiplicationOperator)
504504

505505
def __rmul__(self, other):
506-
return self.__evalBinary(other, literals.MultiplicationOperator, False)
506+
return self.__eval_binary(
507+
other, literals.MultiplicationOperator, False
508+
)
507509

508510
def __truediv__(self, other):
509-
return self.__evalBinary(other, literals.DivisionOperator)
511+
return self.__eval_binary(other, literals.DivisionOperator)
510512

511513
def __rtruediv__(self, other):
512-
return self.__evalBinary(other, literals.DivisionOperator, False)
514+
return self.__eval_binary(other, literals.DivisionOperator, False)
513515

514516
# Python 2 Compatibility -------------------------------------------------
515517

@@ -520,16 +522,18 @@ def __rtruediv__(self, other):
520522
# ------------------------------------------------------------------------
521523

522524
def __pow__(self, other):
523-
return self.__evalBinary(other, literals.ExponentiationOperator)
525+
return self.__eval_binary(other, literals.ExponentiationOperator)
524526

525527
def __rpow__(self, other):
526-
return self.__evalBinary(other, literals.ExponentiationOperator, False)
528+
return self.__eval_binary(
529+
other, literals.ExponentiationOperator, False
530+
)
527531

528532
def __mod__(self, other):
529-
return self.__evalBinary(other, literals.RemainderOperator)
533+
return self.__eval_binary(other, literals.RemainderOperator)
530534

531535
def __rmod__(self, other):
532-
return self.__evalBinary(other, literals.RemainderOperator, False)
536+
return self.__eval_binary(other, literals.RemainderOperator, False)
533537

534538
def __neg__(self):
535539
return self.__evalUnary(literals.NegationOperator)

0 commit comments

Comments
 (0)