Skip to content

Commit 417e57e

Browse files
authored
docformatter on src
2 parents 48b3bbb + 3d81f89 commit 417e57e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+173
-490
lines changed

src/diffpy/srfit/equation/builder.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -259,9 +259,9 @@ def deRegisterBuilder(self, name):
259259
def wipeout(self, eq):
260260
"""Invalidate the specified equation and remove it from the factory.
261261
262-
This will remove the equation from the purview of the factory and
263-
also change its formula to return NaN. This ensures that eq does
264-
not observe any object in the factory and thus prevents its indirect
262+
This will remove the equation from the purview of the factory and also
263+
change its formula to return NaN. This ensures that eq does not
264+
observe any object in the factory and thus prevents its indirect
265265
pickling with the factory because of observer callback function.
266266
267267
No return value.
@@ -635,8 +635,7 @@ def getBuilder(name):
635635

636636
def __wrapNumpyOperators():
637637
"""Export all numpy operators as OperatorBuilder instances in the module
638-
namespace.
639-
"""
638+
namespace."""
640639
for name in dir(numpy):
641640
op = getattr(numpy, name)
642641
if isinstance(op, numpy.ufunc):
@@ -648,8 +647,7 @@ def __wrapNumpyOperators():
648647
def __wrapSrFitOperators():
649648
"""Export all non-base operators from the
650649
diffpy.srfit.equation.literals.operators module as OperatorBuilder
651-
instances in the module namespace.
652-
"""
650+
instances in the module namespace."""
653651
opmod = literals.operators
654652
excluded_types = set((opmod.CustomOperator, opmod.UFuncOperator))
655653
# check if opmod member should be wrapped as OperatorBuilder

src/diffpy/srfit/equation/equationmod.py

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,8 @@
2727
> b = Argument(name="b")
2828
> add.addLiteral(a)
2929
> add.addLiteral(b)
30-
> # make an Equation instance and pass the root
31-
> eq = Equation(root = add)
32-
> eq(a=3, b=4) # returns 7
33-
> eq(a=2) # remembers b=4, returns 6
30+
> # make an Equation instance and pass the root > eq = Equation(root = add)
31+
> eq(a=3, b=4) # returns 7 > eq(a=2) # remembers b=4, returns 6
3432
> eq.a.setValue(-3)
3533
> eq.b.setValue(3)
3634
> eq() # uses last assignment of a and b, returns 0
@@ -88,7 +86,6 @@ def __init__(self, name = None, root = None):
8886
root -- The root node of the Literal tree (default None). If root
8987
is not passed here, you must call the 'setRoot' method to
9088
set or change the root node.
91-
9289
"""
9390
# Operator stuff. We circumvent Operator.__init__ since we're using
9491
# args as a property. We cannot set it, as the Operator tries to do.
@@ -110,8 +107,8 @@ def symbol(self):
110107
def operation(self, *args, **kw):
111108
"""Evaluate this Equation object.
112109
113-
Same as the __call__ method. This method is used via
114-
the Operator interface.
110+
Same as the __call__ method. This method is used via the Operator
111+
interface.
115112
116113
Return the result of __call__(*args, **kw).
117114
"""
@@ -150,7 +147,6 @@ def setRoot(self, root):
150147
151148
Raises:
152149
ValueError if errors are found in the Literal tree.
153-
154150
"""
155151

156152
# Validate the new root
@@ -179,11 +175,10 @@ def __call__(self, *args, **kw):
179175
"""Call the equation.
180176
181177
New Argument values are acceped as arguments or keyword assignments (or
182-
both). The order of accepted arguments is given by the args
183-
attribute. The Equation will remember values set in this way.
178+
both). The order of accepted arguments is given by the args attribute.
179+
The Equation will remember values set in this way.
184180
185-
Raises
186-
ValueError when a passed argument cannot be found
181+
Raises ValueError when a passed argument cannot be found
187182
"""
188183
# Process args
189184
for idx, val in enumerate(args):
@@ -206,7 +201,6 @@ def swap(self, oldlit, newlit):
206201
"""Swap a literal in the equation for another.
207202
208203
Note that this may change the root and the operation interface
209-
210204
"""
211205
newroot = swap(self.root, oldlit, newlit)
212206
self.setRoot(newroot)

src/diffpy/srfit/equation/literals/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
"""Building blocks for defining a lazy evaluation network.
1717
1818
Literals are the building blocks of the evaluation network. An Argument holds
19-
the name and value of an equation variable. Operators are used to compose
20-
other Literals to produce a new value.
19+
the name and value of an equation variable. Operators are used to compose other
20+
Literals to produce a new value.
2121
2222
Literal networks can be evaluated or have other actions performed on them by
2323
Visitors (in diffpy.srfit.equation.visitors). The Literal-Visitor relationship

src/diffpy/srfit/equation/literals/abcs.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@
2525

2626
@six.add_metaclass(ABCMeta)
2727
class LiteralABC(object):
28-
"""Abstract Base Class for Literal. See Literal for usage."""
28+
"""Abstract Base Class for Literal.
29+
30+
See Literal for usage.
31+
"""
2932

3033
@abstractmethod
3134
def identify(self, visitor): pass
@@ -39,7 +42,10 @@ def getValue(self): pass
3942

4043

4144
class ArgumentABC(LiteralABC):
42-
"""Abstract Base Class for Argument. See Argument for usage."""
45+
"""Abstract Base Class for Argument.
46+
47+
See Argument for usage.
48+
"""
4349

4450
@abstractmethod
4551
def setValue(self, value): pass
@@ -51,7 +57,10 @@ def setValue(self, value): pass
5157

5258

5359
class OperatorABC(LiteralABC):
54-
"""Abstract Base Class for Operator. See Operator for usage."""
60+
"""Abstract Base Class for Operator.
61+
62+
See Operator for usage.
63+
"""
5564

5665
@abstractmethod
5766
def addLiteral(self, literal): pass

src/diffpy/srfit/equation/literals/argument.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ class Argument(Literal, ArgumentABC):
3434
Constants may be given special treatment by the Visitors.
3535
_value -- The value of the Argument. Modified with 'setValue'.
3636
value -- Property for 'getValue' and 'setValue'.
37-
3837
"""
3938

4039
const = None
@@ -58,7 +57,6 @@ def setValue(self, val):
5857
"""Set the value of the Literal.
5958
6059
val -- The value to assign
61-
6260
"""
6361
if isinstance(self._value, ndarray) or isinstance(val, ndarray):
6462
notequiv = not array_equal(self._value, val)

src/diffpy/srfit/equation/literals/literal.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ class Literal(Observable,LiteralABC):
3333
Attributes
3434
name -- A name for this Literal (default None).
3535
_value -- The value of the Literal.
36-
3736
"""
3837

3938
name = None

src/diffpy/srfit/equation/literals/operators.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,9 @@
2121
2222
The Operator class contains all the information necessary to be identified and
2323
evaluated by a Visitor. Thus, a single onOperator method exists in the Visitor
24-
base class. Other Operators can be derived from Operator (see AdditionOperator),
25-
but they all identify themselves with the Visitor.onOperator method.
24+
base class. Other Operators can be derived from Operator (see
25+
AdditionOperator), but they all identify themselves with the Visitor.onOperator
26+
method.
2627
"""
2728

2829
__all__ = ["Operator", "AdditionOperator", "SubtractionOperator",
@@ -103,7 +104,6 @@ def addLiteral(self, literal):
103104
leftmost argument. The last is the rightmost.
104105
105106
Raises ValueError if the literal causes a self-reference.
106-
107107
"""
108108
# Make sure we don't have self-reference
109109
self._loopCheck(literal)
@@ -134,8 +134,7 @@ def _loopCheck(self, literal):
134134

135135

136136
class UnaryOperator(Operator):
137-
"""
138-
Abstract class for an unary operator with one input and one result.
137+
"""Abstract class for an unary operator with one input and one result.
139138
140139
This base class defines the `nin` and `nout` attributes. The derived
141140
concrete operator must provide the remaining abstract attributes
@@ -148,8 +147,7 @@ class UnaryOperator(Operator):
148147

149148

150149
class BinaryOperator(Operator):
151-
"""
152-
Abstract class for a binary operator with two inputs and one result.
150+
"""Abstract class for a binary operator with two inputs and one result.
153151
154152
This base class defines the `nin` and `nout` attributes. The derived
155153
concrete operator must define the remaining abstract attributes
@@ -162,8 +160,7 @@ class BinaryOperator(Operator):
162160

163161

164162
class CustomOperator(Operator):
165-
"""
166-
Concrete class for a user-defined Operator.
163+
"""Concrete class for a user-defined Operator.
167164
168165
Use the `makeOperator` factory function to create an instance.
169166
"""

src/diffpy/srfit/equation/visitors/argfinder.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ class ArgFinder(Visitor):
2929
Attributes
3030
args -- The list of collected Arguments
3131
getconsts -- Flag indicating whether to grab constant arguments.
32-
3332
"""
3433

3534
def __init__(self, getconsts = True):
@@ -38,7 +37,6 @@ def __init__(self, getconsts = True):
3837
Arguments
3938
getconsts -- Flag indicating whether to grap constant arguments
4039
(default True).
41-
4240
"""
4341
self.args = []
4442
self.getconsts = getconsts

src/diffpy/srfit/equation/visitors/swapper.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@
1313
#
1414
##############################################################################
1515

16-
"""Swapper for replacing a Literal in an equation with another Literals.
17-
"""
16+
"""Swapper for replacing a Literal in an equation with another Literals."""
1817

1918
__all__ = ["Swapper"]
2019

@@ -29,7 +28,6 @@ class Swapper(Visitor):
2928
Attributes:
3029
newlit -- The literal to be placed into the literal tree.
3130
oldlit -- The literal to be replaced.
32-
3331
"""
3432

3533
def __init__(self, oldlit, newlit):
@@ -38,7 +36,6 @@ def __init__(self, oldlit, newlit):
3836
oldlit -- The literal to be replaced.
3937
newlit -- The literal to be placed into the literal tree. See the
4038
class for how the replacement takes place.
41-
4239
"""
4340

4441
self.newlit = newlit
@@ -52,7 +49,6 @@ def onArgument(self, arg):
5249
"""Process an Argument node.
5350
5451
Tell the parent to swap the old Argument with the replacement Literal.
55-
5652
"""
5753

5854
if arg is self.oldlit:
@@ -64,7 +60,6 @@ def onOperator(self, op):
6460
"""Process an Operator node.
6561
6662
Tell the parent to swap the old Operator with the replacement Literal.
67-
6863
"""
6964

7065
# Check to see if we need to swap out this Operator. If so, then we
@@ -122,7 +117,6 @@ def onEquation(self, eq):
122117
"""Process an Equation node.
123118
124119
This looks at the equation itself as well as the root.
125-
126120
"""
127121
if eq is self.oldlit:
128122
self._swap = True

src/diffpy/srfit/equation/visitors/validator.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ class Validator(Visitor):
3939
errors -- List of strings describing errors.
4040
_nin -- Variable for counting the number input arguments for an
4141
operator.
42-
4342
"""
4443

4544
def __init__(self):
@@ -58,7 +57,6 @@ def onArgument(self, arg):
5857
5958
The Argument must be an instance of ArgumentABC from
6059
diffpy.srfit.equation.literals.abcs
61-
6260
"""
6361
if not isinstance(arg, ArgumentABC):
6462
m = msg%(arg, ArgumentABC.__name__)
@@ -71,7 +69,6 @@ def onOperator(self, op):
7169
7270
The Operator must be an instance of OperatorABC from
7371
diffpy.srfit.equation.literals.abcs
74-
7572
"""
7673

7774
if not isinstance(op, OperatorABC):

0 commit comments

Comments
 (0)