API reference¶
Public objects are imported from locata_torch. The reference below is generated
from the package source by mkdocstrings; private parsing helpers are excluded.
Read getting started for constructor defaults and selection, data model for shapes and missing values, time and windows for clock semantics, and I/O and DataLoader for caching, collation, and worker behavior.
locata_torch ¶
Read LOCATA using map-style PyTorch datasets and explicit clock contracts.
LocataDataset ¶
LocataDataset(
root: str | Path | None = None,
*,
split: str | Sequence[str] = "dev",
tasks: Sequence[int] = (1, 2, 3, 4, 5, 6),
recordings: Sequence[int] | None = None,
arrays: Sequence[str] | None = None,
dtype: dtype = torch.float32,
load_source_audio: bool = False,
cache_size: int = 16,
cache_bytes: int = 16777216,
)
Bases: Dataset[LocataSample]
One item per existing (split, task, recording, array) WAV.
Payloads are read lazily. Source audio is opt-in; geometry and available VAD are returned independently. All returned tensors are on the CPU. See the data model and time-and-windows guides for detailed shapes and clock contracts.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
root
|
str | Path | None
|
Existing LOCATA root, or None to use LOCATA_ROOT then managed storage. User-home expansion is supported. Never triggers a download. |
None
|
split
|
str | Sequence[str]
|
One split name, or a sequence selecting dev and/or eval. |
'dev'
|
tasks
|
Sequence[int]
|
Task numbers from 1 through 6. |
(1, 2, 3, 4, 5, 6)
|
recordings
|
Sequence[int] | None
|
Positive recording numbers across selected tasks, or all. |
None
|
arrays
|
Sequence[str] | None
|
Supported array names, or all available arrays. |
None
|
dtype
|
dtype
|
Waveform dtype, either torch.float32 or torch.float64. |
float32
|
load_source_audio
|
bool
|
Read available source WAV payloads when true. |
False
|
cache_size
|
int
|
Maximum cached sparse TXT indexes per worker. |
16
|
cache_bytes
|
int
|
Maximum estimated cached index bytes per worker. |
16777216
|
Attributes:
| Name | Type | Description |
|---|---|---|
index |
tuple[RecordingInfo, ...]
|
Immutable recording information, sorted by split, numeric task, numeric recording, and array name. |
missing_audio |
tuple[Path, ...]
|
Existing selected array directories without an array WAV. |
Raises:
| Type | Description |
|---|---|
LocataError
|
The root, a WAV header, or a mandatory input is invalid. |
ValueError
|
A selection, dtype, or cache limit is invalid. |
Source code in src/locata_torch/dataset.py
208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 | |
windows ¶
windows(
*,
num_samples: int,
hop_samples: int | None = None,
drop_last: bool = True,
) -> LocataWindowDataset
Create a partial-read window view with the recording's time origin.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
num_samples
|
int
|
Positive window length in WAV frames. |
required |
hop_samples
|
int | None
|
Positive hop in frames, or the window length if omitted. |
None
|
drop_last
|
bool
|
Keep only complete windows when true; retain short tails without padding when false. |
True
|
Returns:
| Type | Description |
|---|---|
LocataWindowDataset
|
A map-style view cropping independent annotations to half-open |
LocataWindowDataset
|
window time bounds. |
Source code in src/locata_torch/dataset.py
LocataWindowDataset ¶
LocataWindowDataset(
dataset: LocataDataset,
*,
num_samples: int,
hop_samples: int | None = None,
drop_last: bool = True,
)
Bases: Dataset[LocataSample]
Fixed-frame view; every waveform read seeks directly to its window.
Prefer constructing this view with LocataDataset.windows.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dataset
|
LocataDataset
|
Parent recording dataset and its I/O options. |
required |
num_samples
|
int
|
Positive window length in WAV frames. |
required |
hop_samples
|
int | None
|
Positive frame hop, or the window length if omitted. |
None
|
drop_last
|
bool
|
Exclude incomplete tails when true. Otherwise return each start inside the recording, with the final frames left unpadded. |
True
|
Raises:
| Type | Description |
|---|---|
ValueError
|
The window length or hop is not a positive integer. |
Source code in src/locata_torch/dataset.py
hop_samples
instance-attribute
¶
LocataError ¶
Bases: RuntimeError
Invalid LOCATA input, configuration, or preparation, with its path and cause.
MissingAudioWarning ¶
Bases: UserWarning
An existing array directory has no matching array WAV.
RecordingInfo
dataclass
¶
RecordingInfo(
split: str,
task: int,
recording: int,
array: str,
path: Path,
num_frames: int,
sample_rate: int,
num_channels: int,
)
One existing array WAV, indexed without loading its payload.
RecordingMetadata ¶
Bases: TypedDict
Recording identity and half-open frame and relative-time boundaries.
LocataSample ¶
Bases: TypedDict
One recording or window, preserving independent annotation clocks.
LocataBatch ¶
Bases: TypedDict
Padded audio and masks with original annotation lists per sample.
RequiredTime ¶
Pose ¶
Bases: TypedDict
Timed world pose: xyz, reference vector, and local-to-world rotation.
ArrayPose ¶
Source ¶
SourceAudio ¶
Bases: TypedDict
Optional source waveform and its independent, shared-origin clock.
SourceVAD ¶
TimedVAD ¶
DOA ¶
download_locata ¶
download_locata(
split: str | Sequence[str] = "dev",
*,
data_dir: str | Path | None = None,
) -> Path
Install dev/eval from the pinned official release and return its root.
Storage lookup is data_dir, then LOCATA_DATA_DIR, then the platform
user-data directory. LOCATA_ROOT does not affect downloads. Each split
is verified and installed independently. Existing managed data is checked
and reused; unknown or altered data raises :class:LocataError.
Requires locata-torch[download]. This explicit operation performs network
I/O; Dataset construction never downloads. Call it before starting workers.
Source code in src/locata_torch/_download.py
collate_locata ¶
Right-pad audio; retain annotations and optional sources per sample.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
samples
|
Sequence[LocataSample]
|
Nonempty samples sharing array, sample rate, channels, and dtype. |
required |
Returns:
| Type | Description |
|---|---|
LocataBatch
|
CPU audio |
LocataBatch
|
and lists of unmodified clocks, annotations, sources, and metadata. |
Raises:
| Type | Description |
|---|---|
ValueError
|
Samples are empty, heterogeneous, or have non-CPU waveforms. |
Source code in src/locata_torch/collate.py
world_to_array ¶
world_to_array(
source_position: Tensor,
array_position: Tensor,
array_rotation: Tensor,
) -> Tensor
Apply R.T @ (h - p) to simultaneous, broadcastable Cartesian positions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source_position
|
Tensor
|
World xyz in metres, with trailing shape |
required |
array_position
|
Tensor
|
Array origin in world metres, with trailing shape |
required |
array_rotation
|
Tensor
|
Local-to-world rotation with trailing shape |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Float64 array-frame vectors with broadcast leading dimensions. |
Raises:
| Type | Description |
|---|---|
ValueError
|
Shapes, finiteness, or proper-rotation checks fail. |
Source code in src/locata_torch/geometry.py
locata_doa ¶
Derive angles only for poses sharing exactly the same origin and times.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
array_pose
|
Pose
|
Array world position and local-to-world rotation. |
required |
source_pose
|
Pose
|
Source world position at exactly matching timestamps. |
required |
Returns:
| Type | Description |
|---|---|
DOA
|
Float64 vectors in metres, azimuth in |
DOA
|
inclination in |
DOA
|
Angles use radians; no temporal interpolation is performed. |
Raises:
| Type | Description |
|---|---|
ValueError
|
Clocks or shapes differ, geometry is invalid, or distance is zero. |