parse_mesh_params

parse_mesh_params#

parse_mesh_params(func)[source]#

Decorator that promotes positional coordinate arguments to 1-D arrays.

Wraps each positional argument of the decorated method with atleast_1dnull(), converting scalar values to length-1 arrays while leaving None sentinels intact.

Apply this decorator to any mixin method whose first positional arguments are r, t, p coordinate arrays so that downstream parsing code can always assume array inputs.

Parameters:
funcCallable

The method to wrap. Its positional arguments (after self) will be promoted.

Returns:
outCallable

The wrapped method with the same signature as func.

Examples

>>> from pyvisual.core.parsers import parse_mesh_params
>>> class Foo:
...     @parse_mesh_params
...     def bar(self, r, t, p):
...         return r.ndim, t.ndim, p.ndim
>>> Foo().bar(1.0, 2.0, 3.0)
(1, 1, 1)