Function/method 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(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.