Testing Utilities#

assert_subdirectory_structure(
*,
directory: Path,
expected_structure: dict[Path, dict[str, set[str]]],
) None[source]#

Assert that the subdirectory structure matches the expected structure.

Parameters:
  • directory (directory path) – The path to the directory whose structure is to be checked.

  • expected_structure (dict) – A dictionary representing the expected structure of the subdirectory. Keys are the full paths per expected subdirectory. Values are dictionaries with required ‘directories’ and ‘files’ keys whose values are sets of string names for all expected entities at that level.

create_file_tree(directory: Path, structure: dict[str, dict | str]) None[source]#

Creates a directory and file tree based on a dictionary structure.

Each key in the dictionary represents a file or directory name. If the value is a dictionary, it represents a subdirectory with its own structure. If the value is a string, the key is taken to represent a file with this value as its content.

Parameters:
  • directory (pathlib.Path) – The root directory where the tree will be created.

  • structure (dict) – A nested dictionary representing the directory and file structure.

get_tutorial_directory() Path[source]#
generate_ephys_tutorial(
*,
mode=typing.Literal['file', 'dataset'],
output_directory: Annotated[Path, PathType(path_type=dir)] | None = None,
modality: Literal['ecephys', 'icephys'] = 'ecephys',
) Path[source]#
mock_epochs_table() TimeIntervals[source]#

Generate a mock epochs table.

These are longer than trials and encompass several of them in a qualitative manner.

mock_time_intervals() TimeIntervals[source]#

Generate a mock time intervals table.

mock_trials_table(
nwbfile: NWBFile | None = None,
) TimeIntervals[source]#

Generate a mock trials table.

These are shorter than epochs and fit neatly within them in a qualitative manner. If a NWBFile is provided, a TimeSeriesReference to a mock TimeSeries will be added to each trial.

mock_trials_table_with_numpy_column() TimeIntervals[source]#

Generate a mock trials table with a numpy array-valued column.

Reproduces the scenario from https://github.com/con/nwb2bids/issues/338, where a column stores a fixed-size array per trial (e.g. multi-pulse optogenetics data). Without serialization, numpy’s __str__ inserts line-breaks into wide arrays, breaking TSV rows.