harbor run -t openthoughts/tasktrove-exp-rpt-curriculum-medium-curriculum-medium-0278harbor download openthoughts/tasktrove-exp-rpt-curriculum-medium-curriculum-medium-0278MEDIUM: Lightweight toy extractor package (spikeinterface.extractors)
Goal
spikeinterface.extractors.toy_example(num_segments: int = 2, num_units: int = 10, num_channels: int | None = None, num_columns: int | None = None) -> tuple(rec, sorting) where:
rec is a recording-like objectsorting is a sorting-like objectWhat to implement
/app/spikeinterface with an __init__.py file./app/spikeinterface/extractors.py containing the function toy_example.import spikeinterface.extractorsfrom spikeinterface.extractors import toy_exampleSignature: def toy_example(num_segments: int = 2, num_units: int = 10, num_channels: int | None = None, num_columns: int | None = None):
(rec, sorting)Behavior and minimal API (as used by tests)
get_num_segments() -> int
num_segments.get_probe() -> Probe
Probe object. The test prints the probe, so __str__/__repr__ should be meaningful, but the exact content is not asserted.__str__ / __repr__ should produce a readable representation.get_num_segments() -> int
num_segments.get_num_units() -> int
num_units.__str__ / __repr__ should produce a readable representation.rec.get_probe())
__str__ / __repr__. No additional behavior is required by tests.num_segments must be an integer >= 1.num_units must be an integer >= 0.num_channels and num_columns must be positive integers.toy_example(num_segments=0, num_units=5) should raise a ValueError.toy_example(num_segments=2, num_units=-1) should raise a ValueError.num_channels and num_columns are provided, treat them as simple metadata for the Probe (e.g., store and display), but do not affect the required test assertions beyond ensuring they’re accepted when positive integers.num_channels or num_columns is provided, allow it (and use a sensible default/derived value for the other if needed) without breaking the interface.@dataclass if you like) to model:
ProbeRec (recording-like object)Sorting (sorting-like object)spikeinterface.extractors./app/ as a package (i.e., the path should be /app/spikeinterface/extractors.py with __init__.py at /app/spikeinterface/__init__.py).rec.get_num_segments()rec.get_probe()sorting.get_num_segments()sorting.get_num_units()rec, sorting, and rec.get_probe() should work, so implement readable __str__ / __repr__.toy_example and raise ValueError with clear messages on invalid input.What the tests will verify
toy_example(num_segments=2, num_units=10) returns:
rec.get_num_segments() == 2sorting.get_num_segments() == 2sorting.get_num_units() == 10toy_example(num_segments=1, num_channels=16, num_columns=2) returns:
rec.get_num_segments() == 1sorting.get_num_segments() == 1rec, sorting, and rec.get_probe() should succeed (contents not asserted).ValueError for invalid inputs as described above.Example usage
Notes