-
Notifications
You must be signed in to change notification settings - Fork 82
Open
Description
def initialize_state( # noqa: C901, PLR0911
system: StateLike,
device: torch.device | None = None,
dtype: torch.dtype | None = None,
) -> SimState:
# TODO: create a way to pass velocities from pmg and ase
if isinstance(system, SimState):
return system.clone().to(device, dtype)
if isinstance(system, list | tuple):
if len(system) == 0:
raise ValueError("Cannot initialize state from an empty list.")
states = [s for s in system if isinstance(s, SimState)]
**if len(states) == len(system) and not all(s.n_systems == 1 for s in states):
raise ValueError(
"When providing a list of states, to the initialize_state function, "
"all states must have n_systems == 1. To fix this, you can split the "
"states into individual states with the split_state function."
)**
if len(states) == len(system):
return ts.concatenate_states(states)
Why does this function impose this constraint? Not sure it's a problem for anyone in practise, but this seems quite arbitrary. Actually concatenate_states handle list of state with arbitrary system sizes.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels