Skip to content

phyelds.data

phyelds.data

Internal classes used to manage the state and the neighborhood of the system (namely rep and nbr of field calculus).

NeighborhoodField

Bases: Generic[T], Iterator[T]

NeighborhoodField class used to manage the interactions of between nodes (namely nbr of neighborhood calculus). It provides methods to perform operations on the neighborhood, such as addition, subtraction, multiplication, and division. You should never use it directly, but rather use the neighbors function

exclude_self()

Exclude the current node from the neighborhood.

Returns:

Type Description
Dict[int, T]

A dictionary with the current node excluded.

local()

Get the local value of the current node.

Returns:

Type Description
Optional[T]

The local value or None if not present.

select(neighborhood)

Select the values from the neighborhood that are present in the current neighborhood.

Parameters:

Name Type Description Default
neighborhood NeighborhoodField[Any]

The neighborhood to select from (acts as a filter).

required

Returns:

Type Description
List[T]

A list of values from the current neighborhood that are present in the given neighborhood.

any()

Check if any value in the neighborhood is truthy.

Returns:

Type Description
bool

True if at least one value in the neighborhood is truthy, False otherwise.

all()

Check if all values in the neighborhood are truthy.

Returns:

Type Description
bool

True if all values in the neighborhood are truthy, False otherwise.

map(func)

Map a function to the neighborhood.

Parameters:

Name Type Description Default
func Callable[[T], U]

The function to map.

required

Returns:

Type Description
NeighborhoodField[U]

A new Neighborhood object with the mapped values.

__str__()

String representation of the neighborhood.

__repr__()

String representation of the neighborhood.

State

Bases: ObjectProxy, Generic[S]

A wrapper class that delegates operations to the underlying value while maintaining state management functionality.

value property

Get the current value.

update_fn property

Get the update function.

___update(new_value)

Update the stored value.

forget()

Forget the stored value.

__str__()

String representation of the state.

__repr__()

String representation of the state.

__copy__()

Create a shallow copy of the state.

__deepcopy__(memo)

Create a deep copy of the state.

__reduce__()

Reduce the state for pickling.

__reduce_ex__(protocol)

Reduce the state for pickling.