landlab.grid.decorators¶
This module defines decorators used with ModelGrid objects.
Grid decorators¶
Decorator that calls a grid method after setting array values. |
|
|
Decorate a function to return an array of ids. |
|
Decorate a function to return a read-only array of ids. |
- class override_array_setitem_and_reset[source]¶
Bases:
object
Decorator that calls a grid method after setting array values.
This decorator wraps ModelGrid methods that return a numpy array so that it returns a wrapped array that overrides the numpy array __setitem__, __setslice__, and itemset methods. The wrapped methods set values in the array but then also call a grid method that resets some state variables of the grid.
- Parameters:
reset (str) – The name of the grid method to call after setting values. The corresponding method must take no arguments.
Initialize the decorator with an argument.
- Parameters:
reset (str) – The name of the grid method to call after setting values. The corresponding method must take no arguments.
- __call__(func)[source]¶
Get a wrapped version of the method.
- Parameters:
func (function) – The grid method to wrap.
- Returns:
The wrapped function.
- Return type:
function
- __init__(reset)[source]¶
Initialize the decorator with an argument.
- Parameters:
reset (str) – The name of the grid method to call after setting values. The corresponding method must take no arguments.
- __new__(**kwargs)¶