Setting defaults#

FFTArray has two defaults to influence the Array creation functions. They can either be set globally or overridden locally with a context manager. Both defaults are always last priority in all creation functions. If their value is directly given or can be inferred from the input parameters those take precedence.

Eager#

get_default_eager() bool[source]#
Returns:

Current default value for eager in the array creation functions.

Return type:

bool

set_default_eager(eager: bool) None[source]#

Set the default value for the eager argument of array creation functions. If this is set within a context manager, it gets reset by the context manager on leaving to the value it had before the context manager was entered.

Parameters:

eager (bool) – Value to set as default for eager.

Return type:

None

default_eager(eager: bool) DefaultEagerContext[source]#

Create a context manager to override the default values for eager locally.

Parameters:

eager (bool)

Return type:

DefaultEagerContext

class DefaultEagerContext(eager: bool)[source]#

Context manager for overriding the default value for eager locally.

On exit it automatically sets the default back to the value that was set when the context was entered. Any changes to the global default are then overridden.

Parameters:

eager (bool)

Array Namespace#

get_default_xp()[source]#
Returns:

Current default Array API namespace in the array creation functions.

Return type:

Any

set_default_xp(xp) None[source]#

Set the default value for the xp argument of array creation functions. If this is set within a context manager, it gets reset by the context manager on leaving to the value it had before the context manager was entered.

Parameters:

xp – Array API namespace to set as default. It gets automatically wrapped with array-api-compat if necessary.

Return type:

None

default_xp(xp) DefaultArrayNamespaceContext[source]#

Create a context manager to override the default Array namespace locally.

Return type:

DefaultArrayNamespaceContext

class DefaultArrayNamespaceContext(xp)[source]#

Context manager for overriding the default Array API namespace locally.

On exit it automatically sets the default back to the value that was set when the context was entered. Any changes to the global default are then overridden.