sympde package¶
Subpackages¶
- sympde.calculus package
- Submodules
- sympde.calculus.core module
- Generic properties
- 2D specific properties
- 3D specific properties
AverageBasicOperatorBasicOperatorAddBracketConvectConvolutionCrossCurlDDiffOperatorDivDnDotGradHessianInnerJumpLaplaceMinusInterfaceOperatorNormalDerivativeOuterPlusInterfaceOperatorRotStrainTensoradd_basicop()avgbracketconvconvectcrosscurldivdotgradhas()hessianinneris_constant()is_scalar()is_zero()jumplaplaceminusouterplusrot
- sympde.calculus.errors module
- sympde.calculus.matrices module
- Module contents
- sympde.core package
- sympde.expr package
- sympde.exterior package
- sympde.printing package
- sympde.topology package
- Submodules
- sympde.topology.analytical_mapping module
- sympde.topology.basic module
- sympde.topology.callable_mapping module
- sympde.topology.datatype module
- sympde.topology.derivatives module
BracketBasicBracket_2dCrossBasicCross_2dCross_3dCurlBasicCurl_2dCurl_3dDifferentialOperatorDivBasicDiv_1dDiv_2dDiv_3dDotBasicDot_1dDot_2dDot_3dGradBasicGrad_1dGrad_2dGrad_3dHessianBasicHessian_1dHessian_2dHessian_3dLaplaceBasicLaplace_1dLaplace_2dLaplace_3dLogicalBracket_2dLogicalCurl_2dLogicalCurl_3dLogicalDiv_1dLogicalDiv_2dLogicalDiv_3dLogicalGrad_1dLogicalGrad_2dLogicalGrad_3dLogicalHessian_1dLogicalHessian_2dLogicalHessian_3dLogicalLaplace_1dLogicalLaplace_2dLogicalLaplace_3dLogicalRot_2dRot_2ddxdx1dx2dx3dydzfind_partial_derivatives()get_atom_derivatives()get_atom_logical_derivatives()get_index_derivatives()get_index_derivatives_atom()get_index_logical_derivatives()get_index_logical_derivatives_atom()get_max_logical_partial_derivatives()get_max_partial_derivatives()get_number_derivatives()sort_partial_derivatives()
- sympde.topology.domain module
- sympde.topology.mapping module
- sympde.topology.measure module
- sympde.topology.space module
- Module contents
- sympde.utilities package
Submodules¶
sympde.old_sympy_utilities module¶
Reimplementations of constructs introduced in later versions of Python than we support. Also some functions that are needed SymPy-wide and are located here for easy import.
- class sympde.old_sympy_utilities.NotIterable[source]¶
Bases:
objectUse this as mixin when creating a class which is not supposed to return true when iterable() is called on its instances because calling list() on the instance, for example, would result in an infinite loop.
- sympde.old_sympy_utilities.is_sequence(i, include=None, *, vector=False)[source]¶
Return a boolean indicating whether
iis a sequence in the SymPy sense. If anything that fails the test below should be included as being a sequence for your application, set ‘include’ to that object’s type; multiple types should be passed as a tuple of types.Note: although generators can generate a sequence, they often need special handling to make sure their elements are captured before the generator is exhausted, so these are not included by default in the definition of a sequence.
See also: iterable
Examples¶
>>> from sympy.utilities.iterables import is_sequence >>> from types import GeneratorType >>> is_sequence([]) True >>> is_sequence(set()) False >>> is_sequence('abc') False >>> is_sequence('abc', include=str) True >>> generator = (c for c in 'abc') >>> is_sequence(generator) False >>> is_sequence(generator, include=(str, GeneratorType)) True
- sympde.old_sympy_utilities.iterable(i, exclude=(<class 'str'>, <class 'dict'>, <class 'sympde.old_sympy_utilities.NotIterable'>), vector=False)[source]¶
Return a boolean indicating whether
iis SymPy iterable. True also indicates that the iterator is finite, e.g. you can call list(…) on the instance.When SymPy is working with iterables, it is almost always assuming that the iterable is not a string or a mapping, so those are excluded by default. If you want a pure Python definition, make exclude=None. To exclude multiple items, pass them as a tuple.
You can also set the _iterable attribute to True or False on your class, which will override the checks here, including the exclude test.
As a rule of thumb, some SymPy functions use this to check if they should recursively map over an object. If an object is technically iterable in the Python sense but does not desire this behavior (e.g., because its iteration is not finite, or because iteration might induce an unwanted computation), it should disable it by setting the _iterable attribute to False.
See also: is_sequence
Examples¶
>>> from sympy.utilities.iterables import iterable >>> from sympy import Tuple >>> things = [[1], (1,), set([1]), Tuple(1), (j for j in [1, 2]), {1:2}, '1', 1] >>> for i in things: ... print('%s %s' % (iterable(i), type(i))) True <... 'list'> True <... 'tuple'> True <... 'set'> True <class 'sympy.core.containers.Tuple'> True <... 'generator'> False <... 'dict'> False <... 'str'> False <... 'int'>
>>> iterable({}, exclude=None) True >>> iterable({}, exclude=str) True >>> iterable("no", exclude=str) False
- sympde.old_sympy_utilities.with_metaclass(meta, *bases)[source]¶
Create a base class with a metaclass.
For example, if you have the metaclass
>>> class Meta(type): ... pass
Use this as the metaclass by doing
>>> from sympde.old_sympy_utilities import with_metaclass >>> class MyClass(with_metaclass(Meta, object)): ... pass
This is equivalent to the Python 2:
class MyClass(object): __metaclass__ = Meta
or Python 3:
class MyClass(object, metaclass=Meta): pass
That is, the first argument is the metaclass, and the remaining arguments are the base classes. Note that if the base class is just
object, you may omit it.>>> MyClass.__mro__ (<class '...MyClass'>, <... 'object'>) >>> type(MyClass) <class '...Meta'>