API Reference / APIリファレンス¶
The API reference is generated from the Google-style docstrings of the public
symbols exported by Wandas. The top-level wandas.__all__ is the primary stable
entry surface; module pages expose the corresponding module exports.
WandasのAPIリファレンスは、公開symbolのGoogle style docstringから生成されます。
最上位のwandas.__all__が主要な安定公開面で、各モジュールのページは対応するexportを
公開します。
wandas.inspect(source, *, file_type=None, source_name=None)
¶
Inspect an audio header before constructing a Frame or decoding samples.
This synchronous preflight supports the built-in SoundFile audio reader
(WAV, W64, RF64, FLAC, OGG/OGA, Opus, MP3, AIFF/AIF, SND/AU and CAF). It neither constructs a Dask graph nor
decodes PCM. CSV, WDF, URL downloads and custom readers are deliberately
unsupported: CSV metadata requires parsing the sampled table, while custom
readers cannot guarantee header-only inspection. Use read or load
for those workflows.
In-memory format inference matches read: explicit file_type, then
a stream's .name suffix, then source_name, then anonymous WAV.
Local paths use their suffix unless file_type is explicit. A seekable
binary stream is inspected from position zero and its original position is
restored on success or failure. A borrowed stream is never closed. Local
handles opened internally are closed by the reader. This is a snapshot;
reading the source later inspects it again and does not reuse this result.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
str | Path | bytes | bytearray | memoryview | BinaryIO
|
Local path, bytes-like value, or seekable readable binary stream. |
required |
file_type
|
str | None
|
Optional audio extension, case-insensitive with or without a dot. |
None
|
source_name
|
str | None
|
Optional in-memory format hint; never another resource to open. |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
A dictionary with |
dict[str, Any]
|
|
dict[str, Any]
|
describe the complete original recording, without channel or time slicing. |
Raises:
| Type | Description |
|---|---|
TypeError
|
The source type is unsupported or the stream is text. |
ValueError
|
The format is unsupported, a URL is supplied, or a stream cannot be rewound and restored without consuming input. |
FileNotFoundError
|
A local path does not exist. |
OSError
|
A filesystem operation fails for an inaccessible local source. |
RuntimeError
|
SoundFile raises |
Examples:
>>> import wandas as wd
>>> info = wd.inspect("recording.wav")
>>> if info["channels"] <= 8 and info["duration"] <= 180:
... recording = wd.read("recording.wav")
Source code in wandas/io/inspect.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | |
wandas.from_files(paths, *, base_dir=None, dtype=None)
¶
Create a lazy recording collection from ordered local file paths.
No folder scan, header read, or sample decode occurs during construction.
Duplicates remain separate items. Sources must remain available through
deferred computation. Sampled-signal CSV sources parse the full table on
item access for metadata and again at materialization; failures in the first
pass cache None. See ChannelFrameDataset.from_files for the contract.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
paths
|
Iterable[str | Path]
|
Finite iterable of local strings or Paths. |
required |
base_dir
|
str | Path | None
|
Relative path base; defaults to the construction-time directory. |
None
|
dtype
|
DTypeLike | None
|
|
None
|
Returns:
| Type | Description |
|---|---|
ChannelFrameDataset
|
ChannelFrameDataset preserving input order and duplicate paths. |
Raises:
| Type | Description |
|---|---|
TypeError
|
Input is not a collection of local paths. |
ValueError
|
Empty, null-containing, or URL paths are supplied. |
Source code in wandas/__init__.py
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 | |
wandas.from_table(table, *, path_column, base_dir=None, metadata_columns=None, dtype=None)
¶
Create a lazy recording collection from a DataFrame or CSV catalog.
Each row remains an independent observation. CSV metadata remains strings;
DataFrame basic scalar types are retained and missing values become None.
This reads a recording catalog, not the sampled-signal CSV used by read.
If a source item is itself a signal CSV, item access parses its full table for
metadata; the Dask sample graph parses it again on materialization.
See ChannelFrameDataset.from_table for validation and source-lifetime rules.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
table
|
DataFrame | str | Path
|
pandas DataFrame or local UTF-8/BOM comma-separated CSV catalog. |
required |
path_column
|
str
|
Explicit audio-location column; never inferred. |
required |
base_dir
|
str | Path | None
|
Audio path base; defaults to CSV parent or DataFrame call-time cwd. |
None
|
metadata_columns
|
Sequence[str] | None
|
Included metadata columns; defaults to all except path_column. |
None
|
dtype
|
DTypeLike | None
|
|
None
|
Returns:
| Type | Description |
|---|---|
ChannelFrameDataset
|
ChannelFrameDataset preserving row order, duplicates, and metadata snapshots. |
Raises:
| Type | Description |
|---|---|
TypeError
|
Unsupported table, source cell, or selected metadata type. |
ValueError
|
Invalid schema, paths, or selected metadata values. |
OSError
|
The CSV catalog cannot be read. |
UnicodeError
|
The CSV catalog is not valid UTF-8. |
Source code in wandas/__init__.py
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 | |
wandas.supported_formats()
¶
Return file extensions supported by the registered readers.
Source code in wandas/__init__.py
64 65 66 67 68 | |
wandas.get_default_dtype()
¶
Return the dtype Wandas uses for data it reads or generates.
Returns:
| Type | Description |
|---|---|
dtype[Any]
|
|
dtype[Any]
|
func: |
Source code in wandas/core/default_dtype.py
29 30 31 32 33 34 35 36 | |
wandas.set_default_dtype(dtype)
¶
Set the dtype Wandas uses for data it reads or generates.
The setting applies to :func:wandas.read, :meth:ChannelFrame.from_file,
the dataset loaders and :func:wandas.generate_sin when they are called
without dtype. It is process-wide and not stored in Recipes or WDF files.
A dataset keeps the value in effect when it is created, and
:meth:RecipePlan.apply_files sends the value in effect when it is called
to its worker processes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dtype
|
DTypeLike
|
|
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in wandas/core/default_dtype.py
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 | |
wandas.default_dtype(dtype)
¶
Use dtype as the default inside a with block, then restore the previous one.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
dtype
|
DTypeLike
|
|
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in wandas/core/default_dtype.py
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | |
The tutorials and how-to guides cover workflows that combine several APIs. The learning path is for executable, task-oriented examples.