@@ -1085,20 +1085,40 @@ def integrate(arg, spaces=None):
10851085 arg = Integrate (arg , space )
10861086 return arg
10871087
1088-
1088+ @ alias ( "integ" )
10891089class Integrate (LinearOperator , metaclass = MultiClass ):
10901090 """
1091- Integration along one dimension .
1091+ Definite integration over operand bases .
10921092
10931093 Parameters
10941094 ----------
10951095 operand : number or Operand object
1096- space : Space object
1097-
1096+ coords : Coordinate or CoordinateSystem object, or list of these
10981097 """
10991098
11001099 name = "Integrate"
11011100
1101+ @classmethod
1102+ def _preprocess_args (cls , operand , coord = None ):
1103+ # Handle zeros
1104+ if operand == 0 :
1105+ raise SkipDispatchException (output = 0 )
1106+ # Integrate over all operand bases by default
1107+ if coord is None :
1108+ coord = [basis .coordsystem for basis in operand .domain .bases ]
1109+ # Recurse over multiple coordinates
1110+ if isinstance (coord , (tuple , list )):
1111+ if len (coord ) > 1 :
1112+ operand = Integrate (operand , coord [:- 1 ])
1113+ coord = coord [- 1 ]
1114+ # Resolve strings to coordinates
1115+ if isinstance (coord , str ):
1116+ coord = operand .domain .get_coord (coord )
1117+ # Check coordinate type
1118+ if not isinstance (coord , (coords .Coordinate , coords .CoordinateSystem )):
1119+ raise ValueError ("coords must be Coordinate or str" )
1120+ return (operand , coord ), {}
1121+
11021122 @classmethod
11031123 def _check_args (cls , operand , coords ):
11041124 # Dispatch by operand basis
@@ -1109,18 +1129,6 @@ def _check_args(cls, operand, coords):
11091129 return True
11101130 return False
11111131
1112- @classmethod
1113- def _preprocess_args (cls , operand , coord ):
1114- if isinstance (operand , Number ):
1115- raise SkipDispatchException (output = operand )
1116- if isinstance (coord , (coords .Coordinate , coords .CoordinateSystem )):
1117- pass
1118- elif isinstance (coord , str ):
1119- coord = operand .domain .get_coord (coord )
1120- else :
1121- raise ValueError ("coord must be Coordinate or str" )
1122- return (operand , coord ), {}
1123-
11241132 def __init__ (self , operand , coord ):
11251133 SpectralOperator .__init__ (self , operand )
11261134 # Require integrand is a scalar
0 commit comments