def _indices(cls, **kwargs):
"""Return the default dimension indices for a given data shape
:param grid: :class:`Grid` that defines the spatial domain.
:param dimensions: Optional, list of :class:`Dimension`
objects that defines data layout.
:return: Dimension indices used for each axis.
..note::
Only one of :param grid: or :param dimensions: is required.
"""
grid = kwargs.get('grid', None)
dimensions = kwargs.get('dimensions', None)
if grid is None:
if dimensions is None:
error("Creating a Function object requries either "
"a 'grid' or the 'dimensions' argument.")
raise ValueError("Unknown symbol dimensions or shape")
else:
if dimensions is not None:
warning("Creating Function with 'grid' and 'dimensions' "
"argument; ignoring the 'dimensions' and using 'grid'.")
dimensions = grid.dimensions
return dimensions
评论列表
文章目录