109109class EquationFactory (object ):
110110 """A Factory for equations.
111111
112- builders -- A dictionary of BaseBuilders registered with the
113- factory, indexed by name.
114- newargs -- A set of new arguments created by makeEquation. This is
115- redefined whenever makeEquation is called.
116- equations -- Set of equations that have been built by the
117- EquationFactory.
112+ Attributes
113+ ----------
114+ builders
115+ A dictionary of BaseBuilders registered with the
116+ factory, indexed by name.
117+ newargs
118+ A set of new arguments created by makeEquation. This is
119+ redefined whenever makeEquation is called.
120+ equations
121+ Set of equations that have been built by the
122+ EquationFactory.
118123 """
119124
120125 symbols = ("+" , "-" , "*" , "/" , "**" , "%" , "|" )
@@ -138,20 +143,25 @@ def makeEquation(
138143 """Make an equation from an equation string.
139144
140145 Arguments
141- eqstr -- An equation in string form using standard python
142- syntax. The equation string can use any function
143- registered literal or function, including numpy ufuncs
144- that are automatically registered.
145- buildargs -- A flag indicating whether missing arguments can be
146- created by the Factory (default True). If False, then
147- the a ValueError will be raised if there are undefined
148- arguments in the eqstr. Built arguments will be of type
149- argclass.
150- argclass -- Class to use when creating new Arguments (default
151- diffpy.srfit.equation.literals.Argument). The class
152- constructor must accept the 'name' key word.
153- argkw -- Key word dictionary to pass to the argclass constructor
154- (default {}).
146+ ---------
147+ eqstr
148+ An equation in string form using standard python
149+ syntax. The equation string can use any function
150+ registered literal or function, including numpy ufuncs
151+ that are automatically registered.
152+ buildargs
153+ A flag indicating whether missing arguments can be
154+ created by the Factory (default True). If False, then
155+ the a ValueError will be raised if there are undefined
156+ arguments in the eqstr. Built arguments will be of type
157+ argclass.
158+ argclass
159+ Class to use when creating new Arguments (default
160+ diffpy.srfit.equation.literals.Argument). The class
161+ constructor must accept the 'name' key word.
162+ argkw
163+ Key word dictionary to pass to the argclass constructor
164+ (default {}).
155165
156166 Returns a callable Literal representing the equation string.
157167 """
@@ -202,11 +212,16 @@ def registerFunction(self, name, func, argnames):
202212
203213 This will register a builder for the function.
204214
205- name -- The name of the function
206- func -- A callable python object
207- argnames-- The argument names for func. If these names do not
208- correspond to builders, then new constants with value 0
209- will be created for each name.
215+ Attributes
216+ ----------
217+ name
218+ The name of the function
219+ func
220+ A callable python object
221+ argnames
222+ The argument names for func. If these names do not
223+ correspond to builders, then new constants with value 0
224+ will be created for each name.
210225
211226 Returns the registered builder.
212227 """
@@ -294,16 +309,21 @@ def _prepareBuilders(self, eqstr, buildargs, argclass, argkw):
294309 rebuilds the newargs attribute.
295310
296311 Arguments
297- eqstr -- An equation in string as specified in the makeEquation
298- method.
299- buildargs -- A flag indicating whether missing arguments can be
300- created by the factory. If False, then the a ValueError
301- will be raised if there are undefined arguments in the
302- eqstr.
303- argclass -- Class to use when creating new Arguments. The class
304- constructor must accept the 'name' key word.
305- argkw -- Key word dictionary to pass to the argclass
306- constructor.
312+ ---------
313+ eqstr
314+ An equation in string as specified in the makeEquation
315+ method.
316+ buildargs
317+ A flag indicating whether missing arguments can be
318+ created by the factory. If False, then the a ValueError
319+ will be raised if there are undefined arguments in the
320+ eqstr.
321+ argclass
322+ Class to use when creating new Arguments. The class
323+ constructor must accept the 'name' key word.
324+ argkw
325+ Key word dictionary to pass to the argclass
326+ constructor.
307327
308328 Raises ValueError if new arguments must be created, but this is
309329 disallowed due to the buildargs flag.
@@ -392,7 +412,9 @@ class BaseBuilder(object):
392412 arguments can be other BaseBuilder instances or constants.
393413
394414 Attributes
395- literal -- The equation Literal being built by this instance.
415+ ----------
416+ literal
417+ The equation Literal being built by this instance.
396418 """
397419
398420 def __init__ (self ):
@@ -424,8 +446,11 @@ def __evalBinary(self, other, OperatorClass, onleft=True):
424446
425447 Other can be an BaseBuilder or a constant.
426448
427- onleft -- Indicates that the operator was passed on the left side
428- (default True).
449+ Attributes
450+ ----------
451+ onleft
452+ Indicates that the operator was passed on the left side
453+ (default True).
429454 """
430455 # Create the Operator
431456 op = OperatorClass ()
@@ -520,20 +545,27 @@ class ArgumentBuilder(BaseBuilder):
520545 arguments can be other BaseBuilder instances or constants.
521546
522547 Attributes
523- literal -- The Argument wrapped by this instance.
548+ ----------
549+ literal
550+ The Argument wrapped by this instance.
524551 """
525552
526553 def __init__ (self , value = None , name = None , const = False , arg = None ):
527554 """Create an ArgumentBuilder instance, containing a new Argument.
528555
529556 Arguments
530- value -- The value of the wrapped Argument (float, default None)
531- name -- The name of the wrapped Argument (string, default None)
532- const -- Flag indicating whether the Argument is constant (bool,
533- default False)
534- arg -- A pre-defined Argument to use. If this is None (default),
535- then a new Argument will be created from value, name and
536- const.
557+ ---------
558+ value
559+ The value of the wrapped Argument (float, default None)
560+ name
561+ The name of the wrapped Argument (string, default None)
562+ const
563+ Flag indicating whether the Argument is constant (bool,
564+ default False)
565+ arg
566+ A pre-defined Argument to use. If this is None (default),
567+ then a new Argument will be created from value, name and
568+ const.
537569 """
538570 BaseBuilder .__init__ (self )
539571 if arg is None :
@@ -552,19 +584,25 @@ class OperatorBuilder(BaseBuilder):
552584 """BaseBuilder wrapper around an Operator literal.
553585
554586 Attributes
555- literal -- The Operator wrapped by this instance.
556- name -- The name of the operator to be wrapped
587+ ----------
588+ literal
589+ The Operator wrapped by this instance.
590+ name
591+ The name of the operator to be wrapped
557592 """
558593
559594 def __init__ (self , name , op = None ):
560595 """Wrap an Operator or a function by name.
561596
562597 Arguments
563- name -- The name of the wrapped Operator
564- op -- If specified, this sets the literal attribute as this
565- operator (default None). Otherwise, the name is assumed to
566- be that of a numpy ufunc, which is used to specify the
567- Operator.
598+ ---------
599+ name
600+ The name of the wrapped Operator
601+ op
602+ If specified, this sets the literal attribute as this
603+ operator (default None). Otherwise, the name is assumed to
604+ be that of a numpy ufunc, which is used to specify the
605+ Operator.
568606 """
569607 BaseBuilder .__init__ (self )
570608 self .name = name
@@ -576,7 +614,10 @@ def __call__(self, *args):
576614
577615 This creates a new builder that encapsulates the operation.
578616
579- args -- Arguments of the operation.
617+ Attributes
618+ ----------
619+ args
620+ Arguments of the operation.
580621
581622 Raises ValueError if self.literal.nin >= 0 and len(args) != op.nin
582623 """
@@ -637,10 +678,16 @@ def wrapOperator(name, op):
637678def wrapFunction (name , func , nin = 2 , nout = 1 ):
638679 """Wrap a function in an OperatorBuilder instance.
639680
640- name -- The name of the function
641- func -- A callable python object
642- nin -- The number of input arguments (default 2)
643- nout -- The number of return values (default 1)
681+ Attributes
682+ ----------
683+ name
684+ The name of the function
685+ func
686+ A callable python object
687+ nin
688+ The number of input arguments (default 2)
689+ nout
690+ The number of return values (default 1)
644691
645692 Returns the OperatorBuilder instance that wraps the function.
646693 """
@@ -661,7 +708,8 @@ def getBuilder(name):
661708
662709def __wrapNumpyOperators ():
663710 """Export all numpy operators as OperatorBuilder instances in the module
664- namespace."""
711+ namespace.
712+ """
665713 for name in dir (numpy ):
666714 op = getattr (numpy , name )
667715 if isinstance (op , numpy .ufunc ):
@@ -676,7 +724,8 @@ def __wrapNumpyOperators():
676724def __wrapSrFitOperators ():
677725 """Export all non-base operators from the
678726 diffpy.srfit.equation.literals.operators module as OperatorBuilder
679- instances in the module namespace."""
727+ instances in the module namespace.
728+ """
680729 opmod = literals .operators
681730 excluded_types = set ((opmod .CustomOperator , opmod .UFuncOperator ))
682731
0 commit comments