Skip to content

Configuration

Global settings that change how operations behave. They are reached through the config module, as pld.config.<setting>. Each setting is a function that returns the current value when called without arguments, and returns a context manager when called with a boolean, so you can scope a change to a block. See Alignment and Lazy arrays for where these matter.

auto_align

auto_align() -> bool
auto_align(enable: bool) -> _GeneratorContextManager[None, None, None]
auto_align(enable: bool | None = None) -> bool | _GeneratorContextManager[None, None, None]

When performing operations with eager arrays, alignment is performed automatically if this setting is true.

When called without arguments, returns the current auto_align value. When called with an argument, returns a context manager during which the setting has the provided value.

Parameters:

Name Type Description Default
enable bool | None

Whether to enable or disable automatic alignment of arrays in binary operations. When False, alignment is only checked but not performed. When None (the default), the current value is returned instead.

None

Returns:

Type Description
bool | _GeneratorContextManager[None, None, None]

The current setting as a bool when enable is None, otherwise a context manager

bool | _GeneratorContextManager[None, None, None]

during which the setting has the provided value.

Example
import polder as pld

# Get current setting
current = pld.config.auto_align()

# Disable auto-alignment temporarily
with pld.config.auto_align(False):
    result = arr1 + arr2  # Only checks if alignment is needed

use_eager_evaluation_for_lazy_arrays

use_eager_evaluation_for_lazy_arrays() -> bool
use_eager_evaluation_for_lazy_arrays(enable: bool) -> _GeneratorContextManager[None, None, None]
use_eager_evaluation_for_lazy_arrays(enable: bool | None = None) -> bool | _GeneratorContextManager[None, None, None]

Use DataFrames instead of LazyFrames for lazy arrays. This can be useful for testing purposes, because errors will surface more quickly and closer to where they originate.

Note that some errors will still only surface lazily. For example an "invalid shape" error may only arise when the shape is extracted, not on the operation that produces the invalid shape.

When called without arguments, returns the current setting value. When called with an argument, returns a context manager during which the setting has the provided value.

Parameters:

Name Type Description Default
enable bool | None

Whether to enable eager evaluation for lazy arrays. When None (the default), the current value is returned instead.

None

Returns:

Type Description
bool | _GeneratorContextManager[None, None, None]

The current setting as a bool when enable is None, otherwise a context manager

bool | _GeneratorContextManager[None, None, None]

during which the setting has the provided value.

Example
import polder as pld

with pld.config.use_eager_evaluation_for_lazy_arrays(True):
    lazy_array = pld.from_values_and_labels(values, labels, implementation=LAZY)