io¶
- from_cache(cache_file, *, file_type='pickle', indices=None)¶
Helper function to read an object from a cache file using
pickle.
- from_yaml(file_name)¶
Helper function to read an object from a YAML file.
Note that all lists are loaded as tuples.
- load_data(data_file, data_path=None, exclude=None)¶
Loads data (
ndarrayor nesteddictofndarray) from an HDF5 file.
- load_dataset(dataset_name, *, directory='.', target, load_observations=True, categories=None, background_category, observation_suffix='annotations')¶
Load a dataset from a HDF5 file that was created with
save_dataset().- Parameters:
dataset_name (
str) – Name of the dataset.directory (
str|Path, default:'.') – Directory to load the dataset from.target (
Literal['individual','dyad']) – Target of the dataset.load_observations (
bool, default:True) – Whether to load observations.categories (
tuple[str,...] |None, default:None) – Categories (of the observations) to load.background_category (
str) – Background category (of the observations).observation_suffix (
str, default:'annotations') – Suffix for the observation file.
- Return type:
- Returns:
The loaded dataset.
- load_trajectories(trajectory_file, data_path=None, exclude=None)¶
Load trajectories from an HDF5 file that was created with
save_trajectories().- Parameters:
- Return type:
dict[str|int,Trajectory]- Returns:
A dictionary mapping individual identifiers to trajectories.
- remove_cache(cache_file)¶
Helper function to remove a cache file.
Returns whether the file was successfully removed (
Falseif the file does not exist).
- save_data(data_file, data, data_path=None, exclude=None)¶
Saves data (mapping of
strandndarray) to an HDF5 file.- Parameters:
- Return type:
- Returns:
None
- save_dataset(dataset, *, dataset_name, directory='.', observation_suffix='annotations')¶
Save a dataset to a HDF5 file.
- Parameters:
- Return type:
- Returns:
None
- save_trajectories(trajectory_file, trajectories, prefix=None, exclude=None)¶
Save trajectories to an HDF5 file.
- Parameters:
trajectory_file (
str|Path) – The name of the HDF5 file to save trajectories to.trajectories (
dict[int|str,Trajectory]) – A dictionary mapping individual identifiers to trajectories.prefix (
str|None, default:None) – An optional prefix to prepend to the trajectory paths.exclude (
list[str] |None, default:None) – An optional list of keys to exclude from saving.
- Return type:
- Returns:
None