Skip to content

Commit 845897d

Browse files
committed
use formulaize
1 parent 29343ca commit 845897d

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

pycuber/formula.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -395,7 +395,7 @@ def __setattr__(self, name, value):
395395
"""
396396
We don't allow user to set attribute.
397397
"""
398-
if name in dir(self) and name not in ["sort", "extend"]:
398+
if name in dir(self) and name != "sort" :
399399
raise AttributeError("'Formula' object attribute '{}' is read-only".format(name))
400400
else:
401401
raise AttributeError("'Formula' object has no attribute '{}'".format(name))
@@ -408,7 +408,7 @@ def _func(*args, **kwargs):
408408
return getattr(list, func.__name__)(*args, **kwargs)
409409
return _func
410410

411-
def _algify_input(func):
411+
def _formulaize_input(func):
412412
"""Makes last input a Formula object."""
413413
def _func(*args, **kwargs):
414414
args = list(args[:-1]) + [Formula(args[-1])]
@@ -417,7 +417,7 @@ def _func(*args, **kwargs):
417417
_func.__name__ = func.__name__ + " "
418418
return _func
419419

420-
def _algify_output(func):
420+
def _formulaize_output(func):
421421
"""Makes output a Formula object."""
422422
@wraps(getattr(list, func.__name__.strip()), assigned=("__name__", "__doc__"))
423423
def _func(*args, **kwargs):
@@ -441,20 +441,21 @@ def _func(*args, **kwargs):
441441
return args[0]
442442
return _func
443443

444-
@_algify_output
445-
@_algify_input
444+
@_formulaize_output
445+
@_formulaize_input
446446
def __add__(self, another): pass
447447
if sys.version_info.major == 2:
448-
@_algify_output
448+
@_formulaize_output
449449
def __getslice__(self, i, j): pass
450-
@_algify_input
450+
@_formulaize_input
451451
def __setslice__(self, i, j, value): pass
452-
@_algify_output
452+
@_formulaize_output
453453
def __mul__(self, i): pass
454454
def __iadd__(self, another):
455455
return self.__add__(another)
456456

457-
@_algify_input
457+
@_return_self
458+
@_formulaize_input
458459
def extend(self, another): pass
459460

460461
def __eq__(self, another):
@@ -831,6 +832,6 @@ def mirror(self, direction="LR"):
831832
self[i] = self[i].inverse()
832833
return self
833834

834-
del _stepify, _algify_input, _algify_output, _delattr, _return_self
835+
del _stepify, _formulaize_input, _formulaize_output, _delattr, _return_self
835836

836837

0 commit comments

Comments
 (0)