landlab

Function/method decorators

This module defines decorators used with ModelGrid objects.

Grid decorators

override_array_setitem_and_reset(reset) Decorator that calls a grid method after setting array values.
return_id_array(func) Decorate a function to return an array of ids.
return_readonly_id_array(func) 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.

return_id_array(func)[source]

Decorate a function to return an array of ids.

Parameters:

func : function

A function that returns a numpy array.

Returns:

func

A wrapped function that returns an id array.

return_readonly_id_array(func)[source]

Decorate a function to return a read-only array of ids.

Parameters:

func : function

A function that returns a numpy array.

Returns:

func

A wrapped function that returns an id array.