audformat 1.1.2__tar.gz → 1.1.4__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {audformat-1.1.2 → audformat-1.1.4}/.github/workflows/doc.yml +3 -3
- {audformat-1.1.2 → audformat-1.1.4}/.github/workflows/linter.yml +2 -2
- {audformat-1.1.2 → audformat-1.1.4}/.github/workflows/publish.yml +5 -5
- {audformat-1.1.2 → audformat-1.1.4}/.github/workflows/test.yml +4 -4
- {audformat-1.1.2 → audformat-1.1.4}/CHANGELOG.rst +19 -0
- {audformat-1.1.2 → audformat-1.1.4}/PKG-INFO +1 -1
- {audformat-1.1.2 → audformat-1.1.4}/audformat/core/database.py +5 -3
- {audformat-1.1.2 → audformat-1.1.4}/audformat/core/utils.py +37 -12
- {audformat-1.1.2 → audformat-1.1.4}/audformat.egg-info/PKG-INFO +1 -1
- {audformat-1.1.2 → audformat-1.1.4}/tests/test_database_get.py +70 -0
- {audformat-1.1.2 → audformat-1.1.4}/tests/test_utils.py +72 -0
- {audformat-1.1.2 → audformat-1.1.4}/.gitignore +0 -0
- {audformat-1.1.2 → audformat-1.1.4}/.pre-commit-config.yaml +0 -0
- {audformat-1.1.2 → audformat-1.1.4}/CONTRIBUTING.rst +0 -0
- {audformat-1.1.2 → audformat-1.1.4}/LICENSE +0 -0
- {audformat-1.1.2 → audformat-1.1.4}/README.rst +0 -0
- {audformat-1.1.2 → audformat-1.1.4}/audformat/__init__.py +0 -0
- {audformat-1.1.2 → audformat-1.1.4}/audformat/core/__init__.py +0 -0
- {audformat-1.1.2 → audformat-1.1.4}/audformat/core/attachment.py +0 -0
- {audformat-1.1.2 → audformat-1.1.4}/audformat/core/column.py +0 -0
- {audformat-1.1.2 → audformat-1.1.4}/audformat/core/common.py +0 -0
- {audformat-1.1.2 → audformat-1.1.4}/audformat/core/conftest.py +0 -0
- {audformat-1.1.2 → audformat-1.1.4}/audformat/core/define.py +0 -0
- {audformat-1.1.2 → audformat-1.1.4}/audformat/core/errors.py +0 -0
- {audformat-1.1.2 → audformat-1.1.4}/audformat/core/index.py +0 -0
- {audformat-1.1.2 → audformat-1.1.4}/audformat/core/media.py +0 -0
- {audformat-1.1.2 → audformat-1.1.4}/audformat/core/rater.py +0 -0
- {audformat-1.1.2 → audformat-1.1.4}/audformat/core/scheme.py +0 -0
- {audformat-1.1.2 → audformat-1.1.4}/audformat/core/split.py +0 -0
- {audformat-1.1.2 → audformat-1.1.4}/audformat/core/table.py +0 -0
- {audformat-1.1.2 → audformat-1.1.4}/audformat/core/testing.py +0 -0
- {audformat-1.1.2 → audformat-1.1.4}/audformat/core/typing.py +0 -0
- {audformat-1.1.2 → audformat-1.1.4}/audformat/define/__init__.py +0 -0
- {audformat-1.1.2 → audformat-1.1.4}/audformat/errors/__init__.py +0 -0
- {audformat-1.1.2 → audformat-1.1.4}/audformat/testing/__init__.py +0 -0
- {audformat-1.1.2 → audformat-1.1.4}/audformat/utils/__init__.py +0 -0
- {audformat-1.1.2 → audformat-1.1.4}/audformat.egg-info/SOURCES.txt +0 -0
- {audformat-1.1.2 → audformat-1.1.4}/audformat.egg-info/dependency_links.txt +0 -0
- {audformat-1.1.2 → audformat-1.1.4}/audformat.egg-info/requires.txt +0 -0
- {audformat-1.1.2 → audformat-1.1.4}/audformat.egg-info/top_level.txt +0 -0
- {audformat-1.1.2 → audformat-1.1.4}/benchmarks/benchmark_union.py +0 -0
- {audformat-1.1.2 → audformat-1.1.4}/docs/accessing-data.rst +0 -0
- {audformat-1.1.2 → audformat-1.1.4}/docs/api/audformat.define.rst +0 -0
- {audformat-1.1.2 → audformat-1.1.4}/docs/api/audformat.errors.rst +0 -0
- {audformat-1.1.2 → audformat-1.1.4}/docs/api/audformat.rst +0 -0
- {audformat-1.1.2 → audformat-1.1.4}/docs/api/audformat.testing.rst +0 -0
- {audformat-1.1.2 → audformat-1.1.4}/docs/api/audformat.utils.rst +0 -0
- {audformat-1.1.2 → audformat-1.1.4}/docs/api-src/audformat.define.rst +0 -0
- {audformat-1.1.2 → audformat-1.1.4}/docs/api-src/audformat.errors.rst +0 -0
- {audformat-1.1.2 → audformat-1.1.4}/docs/api-src/audformat.rst +0 -0
- {audformat-1.1.2 → audformat-1.1.4}/docs/api-src/audformat.testing.rst +0 -0
- {audformat-1.1.2 → audformat-1.1.4}/docs/api-src/audformat.utils.rst +0 -0
- {audformat-1.1.2 → audformat-1.1.4}/docs/changelog.rst +0 -0
- {audformat-1.1.2 → audformat-1.1.4}/docs/combine-tables.rst +0 -0
- {audformat-1.1.2 → audformat-1.1.4}/docs/conf.py +0 -0
- {audformat-1.1.2 → audformat-1.1.4}/docs/contributing.rst +0 -0
- {audformat-1.1.2 → audformat-1.1.4}/docs/create-database.rst +0 -0
- {audformat-1.1.2 → audformat-1.1.4}/docs/data-conventions.rst +0 -0
- {audformat-1.1.2 → audformat-1.1.4}/docs/data-example.rst +0 -0
- {audformat-1.1.2 → audformat-1.1.4}/docs/data-format.rst +0 -0
- {audformat-1.1.2 → audformat-1.1.4}/docs/data-header.rst +0 -0
- {audformat-1.1.2 → audformat-1.1.4}/docs/data-introduction.rst +0 -0
- {audformat-1.1.2 → audformat-1.1.4}/docs/data-misc-tables.rst +0 -0
- {audformat-1.1.2 → audformat-1.1.4}/docs/data-tables.rst +0 -0
- {audformat-1.1.2 → audformat-1.1.4}/docs/emodb-example.rst +0 -0
- {audformat-1.1.2 → audformat-1.1.4}/docs/genindex.rst +0 -0
- {audformat-1.1.2 → audformat-1.1.4}/docs/index.rst +0 -0
- {audformat-1.1.2 → audformat-1.1.4}/docs/install.rst +0 -0
- {audformat-1.1.2 → audformat-1.1.4}/docs/map-scheme.rst +0 -0
- {audformat-1.1.2 → audformat-1.1.4}/docs/pics/audformat-database.dot +0 -0
- {audformat-1.1.2 → audformat-1.1.4}/docs/pics/audformat-misc-table.dot +0 -0
- {audformat-1.1.2 → audformat-1.1.4}/docs/pics/audformat-table.dot +0 -0
- {audformat-1.1.2 → audformat-1.1.4}/docs/requirements.txt +0 -0
- {audformat-1.1.2 → audformat-1.1.4}/docs/update-database.rst +0 -0
- {audformat-1.1.2 → audformat-1.1.4}/pyproject.toml +0 -0
- {audformat-1.1.2 → audformat-1.1.4}/requirements.txt +0 -0
- {audformat-1.1.2 → audformat-1.1.4}/setup.cfg +0 -0
- {audformat-1.1.2 → audformat-1.1.4}/tests/conftest.py +0 -0
- {audformat-1.1.2 → audformat-1.1.4}/tests/requirements.txt +0 -0
- {audformat-1.1.2 → audformat-1.1.4}/tests/test_attachment.py +0 -0
- {audformat-1.1.2 → audformat-1.1.4}/tests/test_column.py +0 -0
- {audformat-1.1.2 → audformat-1.1.4}/tests/test_common.py +0 -0
- {audformat-1.1.2 → audformat-1.1.4}/tests/test_database.py +0 -0
- {audformat-1.1.2 → audformat-1.1.4}/tests/test_eq.py +0 -0
- {audformat-1.1.2 → audformat-1.1.4}/tests/test_errors.py +0 -0
- {audformat-1.1.2 → audformat-1.1.4}/tests/test_index.py +0 -0
- {audformat-1.1.2 → audformat-1.1.4}/tests/test_misc_table.py +0 -0
- {audformat-1.1.2 → audformat-1.1.4}/tests/test_scheme.py +0 -0
- {audformat-1.1.2 → audformat-1.1.4}/tests/test_table.py +0 -0
- {audformat-1.1.2 → audformat-1.1.4}/tests/test_utils_concat.py +0 -0
|
@@ -16,16 +16,16 @@ jobs:
|
|
|
16
16
|
python-version: [ '3.10' ]
|
|
17
17
|
|
|
18
18
|
steps:
|
|
19
|
-
- uses: actions/checkout@
|
|
19
|
+
- uses: actions/checkout@v4
|
|
20
20
|
|
|
21
21
|
- name: Cache emodb
|
|
22
|
-
uses: actions/cache@
|
|
22
|
+
uses: actions/cache@v4
|
|
23
23
|
with:
|
|
24
24
|
path: emodb-src
|
|
25
25
|
key: emodb-ubuntu
|
|
26
26
|
|
|
27
27
|
- name: Set up Python ${{ matrix.python-version }}
|
|
28
|
-
uses: actions/setup-python@
|
|
28
|
+
uses: actions/setup-python@v5
|
|
29
29
|
with:
|
|
30
30
|
python-version: ${{ matrix.python-version }}
|
|
31
31
|
|
|
@@ -16,18 +16,18 @@ jobs:
|
|
|
16
16
|
group: ${{ github.workflow }}-${{ github.ref }}
|
|
17
17
|
|
|
18
18
|
steps:
|
|
19
|
-
- uses: actions/checkout@
|
|
19
|
+
- uses: actions/checkout@v4
|
|
20
20
|
with:
|
|
21
21
|
fetch-depth: 2
|
|
22
22
|
|
|
23
23
|
- name: Cache emodb
|
|
24
|
-
uses: actions/cache@
|
|
24
|
+
uses: actions/cache@v4
|
|
25
25
|
with:
|
|
26
26
|
path: emodb-src
|
|
27
27
|
key: emodb-ubuntu
|
|
28
28
|
|
|
29
29
|
- name: Set up Python
|
|
30
|
-
uses: actions/setup-python@
|
|
30
|
+
uses: actions/setup-python@v5
|
|
31
31
|
with:
|
|
32
32
|
python-version: '3.10'
|
|
33
33
|
|
|
@@ -59,7 +59,7 @@ jobs:
|
|
|
59
59
|
python -m sphinx docs/ docs/_build/ -b html
|
|
60
60
|
|
|
61
61
|
- name: Deploy documentation to Github pages
|
|
62
|
-
uses: peaceiris/actions-gh-pages@
|
|
62
|
+
uses: peaceiris/actions-gh-pages@v4
|
|
63
63
|
with:
|
|
64
64
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
|
65
65
|
publish_dir: ./docs/_build
|
|
@@ -81,7 +81,7 @@ jobs:
|
|
|
81
81
|
|
|
82
82
|
- name: Create release on Github
|
|
83
83
|
id: create_release
|
|
84
|
-
uses: softprops/action-gh-release@
|
|
84
|
+
uses: softprops/action-gh-release@v2
|
|
85
85
|
env:
|
|
86
86
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
87
87
|
with:
|
|
@@ -23,17 +23,17 @@ jobs:
|
|
|
23
23
|
python-version: '3.11'
|
|
24
24
|
|
|
25
25
|
steps:
|
|
26
|
-
- uses: actions/checkout@
|
|
26
|
+
- uses: actions/checkout@v4
|
|
27
27
|
|
|
28
28
|
- name: Cache emodb
|
|
29
|
-
uses: actions/cache@
|
|
29
|
+
uses: actions/cache@v4
|
|
30
30
|
with:
|
|
31
31
|
path: emodb-src
|
|
32
32
|
key: emodb-ubuntu
|
|
33
33
|
if: matrix.os == 'ubuntu-20.04'
|
|
34
34
|
|
|
35
35
|
- name: Set up Python ${{ matrix.python-version }}
|
|
36
|
-
uses: actions/setup-python@
|
|
36
|
+
uses: actions/setup-python@v5
|
|
37
37
|
with:
|
|
38
38
|
python-version: ${{ matrix.python-version }}
|
|
39
39
|
|
|
@@ -55,7 +55,7 @@ jobs:
|
|
|
55
55
|
python -m pytest
|
|
56
56
|
|
|
57
57
|
- name: Upload coverage to Codecov
|
|
58
|
-
uses: codecov/codecov-action@
|
|
58
|
+
uses: codecov/codecov-action@v4
|
|
59
59
|
with:
|
|
60
60
|
token: ${{ secrets.CODECOV_TOKEN }}
|
|
61
61
|
file: ./coverage.xml
|
|
@@ -7,6 +7,25 @@ The format is based on `Keep a Changelog`_,
|
|
|
7
7
|
and this project adheres to `Semantic Versioning`_.
|
|
8
8
|
|
|
9
9
|
|
|
10
|
+
Version 1.1.4 (2024-05-15)
|
|
11
|
+
--------------------------
|
|
12
|
+
|
|
13
|
+
* Fixed: ``audformat.Database.get()``,
|
|
14
|
+
if its argument ``additional_schemes``
|
|
15
|
+
contains a non-existent scheme
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
Version 1.1.3 (2024-04-26)
|
|
19
|
+
--------------------------
|
|
20
|
+
|
|
21
|
+
* Added: ``as_dataframe`` argument
|
|
22
|
+
to ``audformat.utils.read_csv()``
|
|
23
|
+
* Fixed: ``audformat.utils.read_csv()``
|
|
24
|
+
now treats float/integer values
|
|
25
|
+
in ``start``, ``end`` columns
|
|
26
|
+
as seconds
|
|
27
|
+
|
|
28
|
+
|
|
10
29
|
Version 1.1.2 (2024-02-02)
|
|
11
30
|
--------------------------
|
|
12
31
|
|
|
@@ -856,16 +856,18 @@ class Database(HeaderBase):
|
|
|
856
856
|
objs = [obj]
|
|
857
857
|
for scheme in additional_schemes:
|
|
858
858
|
if len(obj) == 0:
|
|
859
|
-
|
|
859
|
+
# Skip searching for additional schemes,
|
|
860
|
+
# if main scheme does return empty frame
|
|
861
|
+
additional_obj = empty_frame(scheme)
|
|
860
862
|
else:
|
|
861
|
-
|
|
863
|
+
additional_obj = self.get(
|
|
862
864
|
scheme,
|
|
863
865
|
strict=strict,
|
|
864
866
|
map=map,
|
|
865
867
|
original_column_names=original_column_names,
|
|
866
868
|
aggregate_function=aggregate_function,
|
|
867
869
|
)
|
|
868
|
-
objs.append(
|
|
870
|
+
objs.append(additional_obj)
|
|
869
871
|
if len(objs) > 1:
|
|
870
872
|
obj = utils.concat(objs)
|
|
871
873
|
obj = obj.loc[index]
|
|
@@ -1261,6 +1261,7 @@ def map_language(language: str) -> str:
|
|
|
1261
1261
|
|
|
1262
1262
|
def read_csv(
|
|
1263
1263
|
*args,
|
|
1264
|
+
as_dataframe: bool = False,
|
|
1264
1265
|
**kwargs,
|
|
1265
1266
|
) -> typing.Union[pd.Index, pd.Series, pd.DataFrame]:
|
|
1266
1267
|
r"""Read object from CSV file.
|
|
@@ -1269,11 +1270,18 @@ def read_csv(
|
|
|
1269
1270
|
conform to :ref:`table specifications <data-tables:Tables>`.
|
|
1270
1271
|
If conversion is not possible, an error is raised.
|
|
1271
1272
|
|
|
1272
|
-
|
|
1273
|
+
Time values for the ``start`` and ``end`` column
|
|
1274
|
+
are converted using :func:`pandas.to_timedelta`,
|
|
1275
|
+
whereby float and integers are treated as seconds.
|
|
1276
|
+
|
|
1273
1277
|
|
|
1274
1278
|
Args:
|
|
1275
|
-
*args: arguments
|
|
1276
|
-
|
|
1279
|
+
*args: arguments passed on to :func:`pandas.read_csv`
|
|
1280
|
+
as_dataframe: if ``False``,
|
|
1281
|
+
a dataframe is only returned for data with two or more columns,
|
|
1282
|
+
a series for data with one column,
|
|
1283
|
+
an index for data with zero columns
|
|
1284
|
+
**kwargs: keyword arguments passed on to :func:`pandas.read_csv`
|
|
1277
1285
|
|
|
1278
1286
|
Returns:
|
|
1279
1287
|
object conform to :ref:`table specifications <data-tables:Tables>`
|
|
@@ -1283,19 +1291,36 @@ def read_csv(
|
|
|
1283
1291
|
:ref:`table specifications <data-tables:Tables>`
|
|
1284
1292
|
|
|
1285
1293
|
Examples:
|
|
1286
|
-
>>>
|
|
1287
|
-
>>> string = StringIO(
|
|
1288
|
-
... '''file,start,end,value
|
|
1294
|
+
>>> string = '''file,start,end,value
|
|
1289
1295
|
... f1,00:00:00,00:00:01,0.0
|
|
1290
1296
|
... f1,00:00:01,00:00:02,1.0
|
|
1291
1297
|
... f2,00:00:02,00:00:03,2.0'''
|
|
1292
|
-
|
|
1293
|
-
|
|
1298
|
+
>>> with open("file.csv", "w") as file:
|
|
1299
|
+
... _ = file.write(string)
|
|
1300
|
+
>>> read_csv("file.csv")
|
|
1301
|
+
file start end
|
|
1302
|
+
f1 0 days 00:00:00 0 days 00:00:01 0.0
|
|
1303
|
+
0 days 00:00:01 0 days 00:00:02 1.0
|
|
1304
|
+
f2 0 days 00:00:02 0 days 00:00:03 2.0
|
|
1305
|
+
Name: value, dtype: float64
|
|
1306
|
+
>>> string = '''file,start,end,value
|
|
1307
|
+
... f1,0,1,0.0
|
|
1308
|
+
... f1,1,2,1.0
|
|
1309
|
+
... f2,2,3,2.0'''
|
|
1310
|
+
>>> with open("file.csv", "w") as file:
|
|
1311
|
+
... _ = file.write(string)
|
|
1312
|
+
>>> read_csv("file.csv")
|
|
1294
1313
|
file start end
|
|
1295
1314
|
f1 0 days 00:00:00 0 days 00:00:01 0.0
|
|
1296
1315
|
0 days 00:00:01 0 days 00:00:02 1.0
|
|
1297
1316
|
f2 0 days 00:00:02 0 days 00:00:03 2.0
|
|
1298
1317
|
Name: value, dtype: float64
|
|
1318
|
+
>>> read_csv("file.csv", as_dataframe=True)
|
|
1319
|
+
value
|
|
1320
|
+
file start end
|
|
1321
|
+
f1 0 days 00:00:00 0 days 00:00:01 0.0
|
|
1322
|
+
0 days 00:00:01 0 days 00:00:02 1.0
|
|
1323
|
+
f2 0 days 00:00:02 0 days 00:00:03 2.0
|
|
1299
1324
|
|
|
1300
1325
|
"""
|
|
1301
1326
|
frame = pd.read_csv(*args, **kwargs)
|
|
@@ -1308,12 +1333,12 @@ def read_csv(
|
|
|
1308
1333
|
|
|
1309
1334
|
starts = None
|
|
1310
1335
|
if define.IndexField.START in frame.columns:
|
|
1311
|
-
starts =
|
|
1336
|
+
starts = frame[define.IndexField.START]
|
|
1312
1337
|
drop.append(define.IndexField.START)
|
|
1313
1338
|
|
|
1314
1339
|
ends = None
|
|
1315
1340
|
if define.IndexField.END in frame.columns:
|
|
1316
|
-
ends =
|
|
1341
|
+
ends = frame[define.IndexField.END]
|
|
1317
1342
|
drop.append(define.IndexField.END)
|
|
1318
1343
|
|
|
1319
1344
|
if starts is None and ends is None:
|
|
@@ -1322,11 +1347,11 @@ def read_csv(
|
|
|
1322
1347
|
index = segmented_index(files, starts=starts, ends=ends)
|
|
1323
1348
|
frame.drop(drop, axis="columns", inplace=True)
|
|
1324
1349
|
|
|
1325
|
-
if len(frame.columns) == 0:
|
|
1350
|
+
if len(frame.columns) == 0 and not as_dataframe:
|
|
1326
1351
|
return index
|
|
1327
1352
|
|
|
1328
1353
|
frame = frame.set_index(index)
|
|
1329
|
-
if len(frame.columns) == 1:
|
|
1354
|
+
if len(frame.columns) == 1 and not as_dataframe:
|
|
1330
1355
|
return frame[frame.columns[0]]
|
|
1331
1356
|
else:
|
|
1332
1357
|
return frame
|
|
@@ -387,6 +387,76 @@ def wrong_scheme_labels_db(tmpdir):
|
|
|
387
387
|
axis=1,
|
|
388
388
|
),
|
|
389
389
|
),
|
|
390
|
+
# Ensure that requesting a non-existing scheme
|
|
391
|
+
# before an existing scheme
|
|
392
|
+
# does return values for existing schemes.
|
|
393
|
+
# https://github.com/audeering/audformat/issues/426
|
|
394
|
+
(
|
|
395
|
+
"mono_db",
|
|
396
|
+
"gender",
|
|
397
|
+
["non-existing", "sex"],
|
|
398
|
+
pd.concat(
|
|
399
|
+
[
|
|
400
|
+
pd.Series(
|
|
401
|
+
["female", "", "male"],
|
|
402
|
+
index=audformat.filewise_index(["f1.wav", "f2.wav", "f3.wav"]),
|
|
403
|
+
dtype="string",
|
|
404
|
+
name="gender",
|
|
405
|
+
),
|
|
406
|
+
pd.Series(
|
|
407
|
+
[],
|
|
408
|
+
index=audformat.filewise_index(),
|
|
409
|
+
dtype="object",
|
|
410
|
+
name="non-existing",
|
|
411
|
+
),
|
|
412
|
+
pd.Series(
|
|
413
|
+
["female", np.NaN, "male"],
|
|
414
|
+
index=audformat.filewise_index(["f1.wav", "f2.wav", "f3.wav"]),
|
|
415
|
+
dtype="object",
|
|
416
|
+
name="sex",
|
|
417
|
+
),
|
|
418
|
+
],
|
|
419
|
+
axis=1,
|
|
420
|
+
),
|
|
421
|
+
),
|
|
422
|
+
# Ensure that requesting a non-existing scheme
|
|
423
|
+
# before an existing scheme
|
|
424
|
+
# does return values for existing schemes.
|
|
425
|
+
# https://github.com/audeering/audformat/issues/426
|
|
426
|
+
(
|
|
427
|
+
"mono_db",
|
|
428
|
+
"gender",
|
|
429
|
+
["numbers", "non-existing", "sex"],
|
|
430
|
+
pd.concat(
|
|
431
|
+
[
|
|
432
|
+
pd.Series(
|
|
433
|
+
["female", "", "male"],
|
|
434
|
+
index=audformat.filewise_index(["f1.wav", "f2.wav", "f3.wav"]),
|
|
435
|
+
dtype="string",
|
|
436
|
+
name="gender",
|
|
437
|
+
),
|
|
438
|
+
pd.Series(
|
|
439
|
+
[0, 1, 2],
|
|
440
|
+
index=audformat.filewise_index(["f1.wav", "f2.wav", "f3.wav"]),
|
|
441
|
+
dtype="Int64",
|
|
442
|
+
name="numbers",
|
|
443
|
+
),
|
|
444
|
+
pd.Series(
|
|
445
|
+
[],
|
|
446
|
+
index=audformat.filewise_index(),
|
|
447
|
+
dtype="object",
|
|
448
|
+
name="non-existing",
|
|
449
|
+
),
|
|
450
|
+
pd.Series(
|
|
451
|
+
["female", np.NaN, "male"],
|
|
452
|
+
index=audformat.filewise_index(["f1.wav", "f2.wav", "f3.wav"]),
|
|
453
|
+
dtype="object",
|
|
454
|
+
name="sex",
|
|
455
|
+
),
|
|
456
|
+
],
|
|
457
|
+
axis=1,
|
|
458
|
+
),
|
|
459
|
+
),
|
|
390
460
|
(
|
|
391
461
|
"mono_db",
|
|
392
462
|
"winner",
|
|
@@ -1461,6 +1461,23 @@ f2,00:00:02,2.0"""
|
|
|
1461
1461
|
name="value",
|
|
1462
1462
|
),
|
|
1463
1463
|
),
|
|
1464
|
+
(
|
|
1465
|
+
StringIO(
|
|
1466
|
+
"""file,start,value
|
|
1467
|
+
f1,0,0.0
|
|
1468
|
+
f1,1,1.0
|
|
1469
|
+
f2,2,2.0"""
|
|
1470
|
+
),
|
|
1471
|
+
pd.Series(
|
|
1472
|
+
[0.0, 1.0, 2.0],
|
|
1473
|
+
index=audformat.segmented_index(
|
|
1474
|
+
["f1", "f1", "f2"],
|
|
1475
|
+
starts=["0s", "1s", "2s"],
|
|
1476
|
+
ends=pd.to_timedelta([pd.NaT, pd.NaT, pd.NaT]),
|
|
1477
|
+
),
|
|
1478
|
+
name="value",
|
|
1479
|
+
),
|
|
1480
|
+
),
|
|
1464
1481
|
(
|
|
1465
1482
|
StringIO(
|
|
1466
1483
|
"""file,end,value
|
|
@@ -1491,6 +1508,19 @@ f2,00:00:02,00:00:03"""
|
|
|
1491
1508
|
["1s", "2s", "3s"],
|
|
1492
1509
|
),
|
|
1493
1510
|
),
|
|
1511
|
+
(
|
|
1512
|
+
StringIO(
|
|
1513
|
+
"""file,start,end
|
|
1514
|
+
f1,0,1
|
|
1515
|
+
f1,1,2
|
|
1516
|
+
f2,2,3"""
|
|
1517
|
+
),
|
|
1518
|
+
audformat.segmented_index(
|
|
1519
|
+
["f1", "f1", "f2"],
|
|
1520
|
+
["0s", "1s", "2s"],
|
|
1521
|
+
["1s", "2s", "3s"],
|
|
1522
|
+
),
|
|
1523
|
+
),
|
|
1494
1524
|
(
|
|
1495
1525
|
StringIO(
|
|
1496
1526
|
"""file,start,end,value
|
|
@@ -1508,6 +1538,40 @@ f2,00:00:02,00:00:03,2.0"""
|
|
|
1508
1538
|
name="value",
|
|
1509
1539
|
),
|
|
1510
1540
|
),
|
|
1541
|
+
(
|
|
1542
|
+
StringIO(
|
|
1543
|
+
"""file,start,end,value
|
|
1544
|
+
f1,0,1,0.0
|
|
1545
|
+
f1,1,2,1.0
|
|
1546
|
+
f2,2,3,2.0"""
|
|
1547
|
+
),
|
|
1548
|
+
pd.Series(
|
|
1549
|
+
[0.0, 1.0, 2.0],
|
|
1550
|
+
index=audformat.segmented_index(
|
|
1551
|
+
["f1", "f1", "f2"],
|
|
1552
|
+
starts=["0s", "1s", "2s"],
|
|
1553
|
+
ends=["1s", "2s", "3s"],
|
|
1554
|
+
),
|
|
1555
|
+
name="value",
|
|
1556
|
+
),
|
|
1557
|
+
),
|
|
1558
|
+
(
|
|
1559
|
+
StringIO(
|
|
1560
|
+
"""file,start,end,value
|
|
1561
|
+
f1,0.0,1.0,0.0
|
|
1562
|
+
f1,1.0,2.0,1.0
|
|
1563
|
+
f2,2.0,3.0,2.0"""
|
|
1564
|
+
),
|
|
1565
|
+
pd.Series(
|
|
1566
|
+
[0.0, 1.0, 2.0],
|
|
1567
|
+
index=audformat.segmented_index(
|
|
1568
|
+
["f1", "f1", "f2"],
|
|
1569
|
+
starts=["0s", "1s", "2s"],
|
|
1570
|
+
ends=["1s", "2s", "3s"],
|
|
1571
|
+
),
|
|
1572
|
+
name="value",
|
|
1573
|
+
),
|
|
1574
|
+
),
|
|
1511
1575
|
(
|
|
1512
1576
|
StringIO(
|
|
1513
1577
|
"""file,start,end,value1,value2
|
|
@@ -1548,6 +1612,14 @@ def test_read_csv(csv, result):
|
|
|
1548
1612
|
pd.testing.assert_series_equal(obj, result)
|
|
1549
1613
|
else:
|
|
1550
1614
|
pd.testing.assert_frame_equal(obj, result)
|
|
1615
|
+
# Request dataframe as return type
|
|
1616
|
+
csv.seek(0) # rewind string file object
|
|
1617
|
+
obj = audformat.utils.read_csv(csv, as_dataframe=True)
|
|
1618
|
+
if isinstance(result, pd.Index):
|
|
1619
|
+
result = pd.DataFrame([], columns=[], index=result)
|
|
1620
|
+
elif isinstance(result, pd.Series):
|
|
1621
|
+
result = result.to_frame()
|
|
1622
|
+
pd.testing.assert_frame_equal(obj, result)
|
|
1551
1623
|
|
|
1552
1624
|
|
|
1553
1625
|
@pytest.mark.parametrize(
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|