audformat 1.1.0__tar.gz → 1.1.2__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.
Files changed (99) hide show
  1. {audformat-1.1.0 → audformat-1.1.2}/.github/workflows/doc.yml +1 -1
  2. {audformat-1.1.0 → audformat-1.1.2}/.github/workflows/linter.yml +2 -2
  3. {audformat-1.1.0 → audformat-1.1.2}/.github/workflows/publish.yml +1 -1
  4. {audformat-1.1.0 → audformat-1.1.2}/.github/workflows/test.yml +3 -3
  5. {audformat-1.1.0 → audformat-1.1.2}/.pre-commit-config.yaml +4 -2
  6. {audformat-1.1.0 → audformat-1.1.2}/CHANGELOG.rst +23 -7
  7. {audformat-1.1.0 → audformat-1.1.2}/CONTRIBUTING.rst +3 -2
  8. {audformat-1.1.0 → audformat-1.1.2}/PKG-INFO +2 -2
  9. {audformat-1.1.0 → audformat-1.1.2}/audformat/__init__.py +1 -0
  10. {audformat-1.1.0 → audformat-1.1.2}/audformat/core/attachment.py +23 -23
  11. {audformat-1.1.0 → audformat-1.1.2}/audformat/core/column.py +53 -68
  12. {audformat-1.1.0 → audformat-1.1.2}/audformat/core/common.py +66 -71
  13. {audformat-1.1.0 → audformat-1.1.2}/audformat/core/conftest.py +3 -4
  14. {audformat-1.1.0 → audformat-1.1.2}/audformat/core/database.py +252 -284
  15. {audformat-1.1.0 → audformat-1.1.2}/audformat/core/define.py +45 -46
  16. {audformat-1.1.0 → audformat-1.1.2}/audformat/core/errors.py +11 -20
  17. {audformat-1.1.0 → audformat-1.1.2}/audformat/core/index.py +44 -45
  18. {audformat-1.1.0 → audformat-1.1.2}/audformat/core/media.py +18 -16
  19. {audformat-1.1.0 → audformat-1.1.2}/audformat/core/rater.py +6 -5
  20. {audformat-1.1.0 → audformat-1.1.2}/audformat/core/scheme.py +69 -71
  21. {audformat-1.1.0 → audformat-1.1.2}/audformat/core/split.py +6 -5
  22. {audformat-1.1.0 → audformat-1.1.2}/audformat/core/table.py +218 -263
  23. {audformat-1.1.0 → audformat-1.1.2}/audformat/core/testing.py +137 -149
  24. {audformat-1.1.0 → audformat-1.1.2}/audformat/core/typing.py +9 -5
  25. {audformat-1.1.0 → audformat-1.1.2}/audformat/core/utils.py +253 -286
  26. {audformat-1.1.0 → audformat-1.1.2}/audformat.egg-info/PKG-INFO +2 -2
  27. {audformat-1.1.0 → audformat-1.1.2}/audformat.egg-info/SOURCES.txt +0 -4
  28. {audformat-1.1.0 → audformat-1.1.2}/audformat.egg-info/requires.txt +1 -1
  29. audformat-1.1.2/benchmarks/benchmark_union.py +81 -0
  30. {audformat-1.1.0 → audformat-1.1.2}/docs/accessing-data.rst +4 -4
  31. {audformat-1.1.0 → audformat-1.1.2}/docs/combine-tables.rst +17 -17
  32. audformat-1.1.2/docs/conf.py +100 -0
  33. {audformat-1.1.0 → audformat-1.1.2}/docs/create-database.rst +13 -13
  34. {audformat-1.1.0 → audformat-1.1.2}/docs/data-conventions.rst +48 -48
  35. {audformat-1.1.0 → audformat-1.1.2}/docs/data-example.rst +6 -6
  36. {audformat-1.1.0 → audformat-1.1.2}/docs/data-header.rst +42 -42
  37. {audformat-1.1.0 → audformat-1.1.2}/docs/data-misc-tables.rst +14 -14
  38. {audformat-1.1.0 → audformat-1.1.2}/docs/data-tables.rst +29 -29
  39. {audformat-1.1.0 → audformat-1.1.2}/docs/emodb-example.rst +109 -109
  40. {audformat-1.1.0 → audformat-1.1.2}/docs/map-scheme.rst +30 -30
  41. {audformat-1.1.0 → audformat-1.1.2}/docs/requirements.txt +2 -0
  42. {audformat-1.1.0 → audformat-1.1.2}/docs/update-database.rst +19 -19
  43. {audformat-1.1.0 → audformat-1.1.2}/pyproject.toml +13 -11
  44. {audformat-1.1.0 → audformat-1.1.2}/tests/conftest.py +4 -6
  45. {audformat-1.1.0 → audformat-1.1.2}/tests/test_attachment.py +124 -125
  46. audformat-1.1.2/tests/test_column.py +754 -0
  47. {audformat-1.1.0 → audformat-1.1.2}/tests/test_common.py +58 -60
  48. {audformat-1.1.0 → audformat-1.1.2}/tests/test_database.py +208 -223
  49. audformat-1.1.2/tests/test_database_get.py +1487 -0
  50. {audformat-1.1.0 → audformat-1.1.2}/tests/test_eq.py +24 -27
  51. {audformat-1.1.0 → audformat-1.1.2}/tests/test_errors.py +24 -25
  52. {audformat-1.1.0 → audformat-1.1.2}/tests/test_index.py +78 -86
  53. {audformat-1.1.0 → audformat-1.1.2}/tests/test_misc_table.py +482 -476
  54. {audformat-1.1.0 → audformat-1.1.2}/tests/test_scheme.py +225 -250
  55. {audformat-1.1.0 → audformat-1.1.2}/tests/test_table.py +522 -529
  56. {audformat-1.1.0 → audformat-1.1.2}/tests/test_utils.py +721 -748
  57. audformat-1.1.2/tests/test_utils_concat.py +1829 -0
  58. audformat-1.1.0/.flake8 +0 -10
  59. audformat-1.1.0/benchmarks/benchmark_union.py +0 -85
  60. audformat-1.1.0/docs/_templates/autosummary/base.rst +0 -5
  61. audformat-1.1.0/docs/_templates/autosummary/class.rst +0 -19
  62. audformat-1.1.0/docs/_templates/autosummary/function.rst +0 -5
  63. audformat-1.1.0/docs/conf.py +0 -110
  64. audformat-1.1.0/tests/test_column.py +0 -750
  65. audformat-1.1.0/tests/test_database_get.py +0 -1560
  66. audformat-1.1.0/tests/test_utils_concat.py +0 -1841
  67. {audformat-1.1.0 → audformat-1.1.2}/.gitignore +0 -0
  68. {audformat-1.1.0 → audformat-1.1.2}/LICENSE +0 -0
  69. {audformat-1.1.0 → audformat-1.1.2}/README.rst +0 -0
  70. {audformat-1.1.0 → audformat-1.1.2}/audformat/core/__init__.py +0 -0
  71. {audformat-1.1.0 → audformat-1.1.2}/audformat/define/__init__.py +0 -0
  72. {audformat-1.1.0 → audformat-1.1.2}/audformat/errors/__init__.py +0 -0
  73. {audformat-1.1.0 → audformat-1.1.2}/audformat/testing/__init__.py +0 -0
  74. {audformat-1.1.0 → audformat-1.1.2}/audformat/utils/__init__.py +0 -0
  75. {audformat-1.1.0 → audformat-1.1.2}/audformat.egg-info/dependency_links.txt +0 -0
  76. {audformat-1.1.0 → audformat-1.1.2}/audformat.egg-info/top_level.txt +0 -0
  77. {audformat-1.1.0 → audformat-1.1.2}/docs/api/audformat.define.rst +0 -0
  78. {audformat-1.1.0 → audformat-1.1.2}/docs/api/audformat.errors.rst +0 -0
  79. {audformat-1.1.0 → audformat-1.1.2}/docs/api/audformat.rst +0 -0
  80. {audformat-1.1.0 → audformat-1.1.2}/docs/api/audformat.testing.rst +0 -0
  81. {audformat-1.1.0 → audformat-1.1.2}/docs/api/audformat.utils.rst +0 -0
  82. {audformat-1.1.0 → audformat-1.1.2}/docs/api-src/audformat.define.rst +0 -0
  83. {audformat-1.1.0 → audformat-1.1.2}/docs/api-src/audformat.errors.rst +0 -0
  84. {audformat-1.1.0 → audformat-1.1.2}/docs/api-src/audformat.rst +0 -0
  85. {audformat-1.1.0 → audformat-1.1.2}/docs/api-src/audformat.testing.rst +0 -0
  86. {audformat-1.1.0 → audformat-1.1.2}/docs/api-src/audformat.utils.rst +0 -0
  87. {audformat-1.1.0 → audformat-1.1.2}/docs/changelog.rst +0 -0
  88. {audformat-1.1.0 → audformat-1.1.2}/docs/contributing.rst +0 -0
  89. {audformat-1.1.0 → audformat-1.1.2}/docs/data-format.rst +0 -0
  90. {audformat-1.1.0 → audformat-1.1.2}/docs/data-introduction.rst +0 -0
  91. {audformat-1.1.0 → audformat-1.1.2}/docs/genindex.rst +0 -0
  92. {audformat-1.1.0 → audformat-1.1.2}/docs/index.rst +0 -0
  93. {audformat-1.1.0 → audformat-1.1.2}/docs/install.rst +0 -0
  94. {audformat-1.1.0 → audformat-1.1.2}/docs/pics/audformat-database.dot +0 -0
  95. {audformat-1.1.0 → audformat-1.1.2}/docs/pics/audformat-misc-table.dot +0 -0
  96. {audformat-1.1.0 → audformat-1.1.2}/docs/pics/audformat-table.dot +0 -0
  97. {audformat-1.1.0 → audformat-1.1.2}/requirements.txt +0 -0
  98. {audformat-1.1.0 → audformat-1.1.2}/setup.cfg +0 -0
  99. {audformat-1.1.0 → audformat-1.1.2}/tests/requirements.txt +0 -0
@@ -13,7 +13,7 @@ jobs:
13
13
  strategy:
14
14
  matrix:
15
15
  os: [ ubuntu-latest ]
16
- python-version: [ '3.8' ]
16
+ python-version: [ '3.10' ]
17
17
 
18
18
  steps:
19
19
  - uses: actions/checkout@v3
@@ -14,10 +14,10 @@ jobs:
14
14
  steps:
15
15
  - uses: actions/checkout@v3
16
16
 
17
- - name: Set up Python 3.8
17
+ - name: Set up Python
18
18
  uses: actions/setup-python@v4
19
19
  with:
20
- python-version: '3.8'
20
+ python-version: '3.10'
21
21
 
22
22
  - name: Install pre-commit hooks
23
23
  run: |
@@ -29,7 +29,7 @@ jobs:
29
29
  - name: Set up Python
30
30
  uses: actions/setup-python@v4
31
31
  with:
32
- python-version: '3.8'
32
+ python-version: '3.10'
33
33
 
34
34
  - name: Install dependencies
35
35
  run: |
@@ -13,12 +13,12 @@ jobs:
13
13
  strategy:
14
14
  matrix:
15
15
  os: [ ubuntu-20.04, windows-latest, macOS-latest ]
16
- python-version: [ '3.8' ]
16
+ python-version: [ '3.10' ]
17
17
  include:
18
18
  - os: ubuntu-latest
19
- python-version: '3.9'
19
+ python-version: '3.8'
20
20
  - os: ubuntu-latest
21
- python-version: '3.10'
21
+ python-version: '3.9'
22
22
  - os: ubuntu-latest
23
23
  python-version: '3.11'
24
24
 
@@ -9,13 +9,15 @@
9
9
  #
10
10
  #
11
11
  default_language_version:
12
- python: python3.8
12
+ python: python3.10
13
13
 
14
14
  repos:
15
15
  - repo: https://github.com/astral-sh/ruff-pre-commit
16
- rev: v0.0.276
16
+ rev: v0.1.8
17
17
  hooks:
18
18
  - id: ruff
19
+ args: [ --fix ]
20
+ - id: ruff-format
19
21
  - repo: https://github.com/codespell-project/codespell
20
22
  rev: v2.2.4
21
23
  hooks:
@@ -7,6 +7,22 @@ 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.2 (2024-02-02)
11
+ --------------------------
12
+
13
+ * Fixed: ``audformat.Database.load()``
14
+ when loading databases
15
+ with a misc table
16
+ that has an assigned split
17
+
18
+
19
+ Version 1.1.1 (2024-01-25)
20
+ --------------------------
21
+
22
+ * Changed: depend on ``audeer>=2.0.0``
23
+ * Fixed: ``pandas`` deprecation warnings
24
+
25
+
10
26
  Version 1.1.0 (2023-11-30)
11
27
  --------------------------
12
28
 
@@ -71,7 +87,7 @@ Version 1.0.0 (2023-04-27)
71
87
  ``audformat.utils.to_filewise_index()``
72
88
  * Changed: convert dates to UTC timezone
73
89
  in ``audformat.Column.set()``
74
- when using a scheme of type ``'date'``
90
+ when using a scheme of type ``"date"``
75
91
  * Fixed: support ``pandas>=2.0.0``
76
92
  * Fixed: mention ``author``,
77
93
  ``license``,
@@ -111,7 +127,7 @@ Version 0.16.0 (2023-01-12)
111
127
  * Changed: require ``audeer>=1.19.0``
112
128
  * Changed: split API documentation into sub-pages
113
129
  for each function
114
- * Fixed: support ``'meta'`` as key in meta dictionaries
130
+ * Fixed: support ``"meta"`` as key in meta dictionaries
115
131
  like the one passed as ``meta`` argument
116
132
  to ``audformat.Database``
117
133
 
@@ -223,11 +239,11 @@ Version 0.15.0 (2022-08-05)
223
239
  that are contained
224
240
  in a filewise index
225
241
  * Changed: require ``pandas>=1.4.1``
226
- * Changed: use ``pandas`` dtype ``'string'``
227
- instead of ``'object'``
228
- for storing ``audformat`` dtype ``'str'`` entries
242
+ * Changed: use ``pandas`` dtype ``"string"``
243
+ instead of ``"object"``
244
+ for storing ``audformat`` dtype ``"str"`` entries
229
245
  * Changed: use a misc table
230
- to store the ``'speaker'`` scheme labels
246
+ to store the ``"speaker"`` scheme labels
231
247
  in the emodb example
232
248
  in the documentation
233
249
  * Changed: ``audformat.utils.join_labels()``
@@ -498,7 +514,7 @@ Version 0.9.6 (2021-01-28)
498
514
  Version 0.9.5 (2021-01-14)
499
515
  --------------------------
500
516
 
501
- * Changed: use nullable Pandas' type ``'boolean'`` for ``bool`` schemes
517
+ * Changed: use nullable Pandas' type ``"boolean"`` for ``bool`` schemes
502
518
  * Fixed: ``Scheme.draw()`` generates boolean values if scheme is ``bool``
503
519
 
504
520
 
@@ -41,7 +41,7 @@ Coding Convention
41
41
  -----------------
42
42
 
43
43
  We follow the PEP8_ convention for Python code
44
- and check for correct syntax with ruff_.
44
+ and use ruff_ as a linter and code formatter.
45
45
  In addition,
46
46
  we check for common spelling errors with codespell_.
47
47
  Both tools and possible exceptions
@@ -61,7 +61,8 @@ You can also install ruff_ and codespell_
61
61
  and call it directly::
62
62
 
63
63
  pip install ruff codespell # consider system wide installation
64
- ruff check .
64
+ ruff check --fix . # lint all Python files, and fix any fixable errors
65
+ ruff format . # format code of all Python files
65
66
  codespell
66
67
 
67
68
  It can be restricted to specific folders::
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: audformat
3
- Version: 1.1.0
3
+ Version: 1.1.2
4
4
  Summary: Python implementation of audformat
5
5
  Author: BahaEddine Abrougui
6
6
  Author-email: Hagen Wierstorf <hwierstorf@audeering.com>, Johannes Wagner <jwagner@audeering.com>
@@ -49,7 +49,7 @@ Classifier: Topic :: Scientific/Engineering
49
49
  Requires-Python: >=3.8
50
50
  Description-Content-Type: text/x-rst
51
51
  License-File: LICENSE
52
- Requires-Dist: audeer<2.0.0,>=1.19.0
52
+ Requires-Dist: audeer>=2.0.0
53
53
  Requires-Dist: audiofile>=0.4.0
54
54
  Requires-Dist: iso-639
55
55
  Requires-Dist: iso3166
@@ -26,6 +26,7 @@ __all__ = []
26
26
  # Dynamically get the version of the installed module
27
27
  try:
28
28
  import importlib.metadata
29
+
29
30
  __version__ = importlib.metadata.version(__name__)
30
31
  except Exception: # pragma: no cover
31
32
  importlib = None # pragma: no cover
@@ -33,16 +33,17 @@ class Attachment(HeaderBase):
33
33
  compared to the current attachment path
34
34
 
35
35
  Examples:
36
- >>> Attachment('file.txt', description='Attached file')
36
+ >>> Attachment("file.txt", description="Attached file")
37
37
  {description: Attached file, path: file.txt}
38
38
 
39
39
  """
40
+
40
41
  def __init__(
41
- self,
42
- path: str,
43
- *,
44
- description: str = None,
45
- meta: dict = None,
42
+ self,
43
+ path: str,
44
+ *,
45
+ description: str = None,
46
+ meta: dict = None,
46
47
  ):
47
48
  super().__init__(description=description, meta=meta)
48
49
 
@@ -60,7 +61,7 @@ class Attachment(HeaderBase):
60
61
 
61
62
  @property
62
63
  def files(
63
- self,
64
+ self,
64
65
  ) -> typing.List[str]:
65
66
  r"""List all files that are part of the attachment.
66
67
 
@@ -83,13 +84,13 @@ class Attachment(HeaderBase):
83
84
  """
84
85
  if not self._db:
85
86
  raise RuntimeError(
86
- 'The attachment needs to be assigned to a database '
87
- 'before attached files can be listed.'
87
+ "The attachment needs to be assigned to a database "
88
+ "before attached files can be listed."
88
89
  )
89
90
  if not self._db.root:
90
91
  raise RuntimeError(
91
- 'The database needs to be saved to disk '
92
- 'before attachment files can be listed.'
92
+ "The database needs to be saved to disk "
93
+ "before attachment files can be listed."
93
94
  )
94
95
  self._check_path(self._db.root)
95
96
 
@@ -118,33 +119,32 @@ class Attachment(HeaderBase):
118
119
  files = [path]
119
120
 
120
121
  # Remove absolute path
121
- files = [f.replace(f'{self._db.root}{os.path.sep}', '') for f in files]
122
+ files = [f.replace(f"{self._db.root}{os.path.sep}", "") for f in files]
122
123
  # Make sure we use `/` as sep
123
- files = [f.replace(os.path.sep, '/') for f in files]
124
+ files = [f.replace(os.path.sep, "/") for f in files]
124
125
 
125
126
  return files
126
127
 
127
128
  def _check_overlap(
128
- self,
129
- other: str,
129
+ self,
130
+ other: str,
130
131
  ):
131
132
  r"""Check if two attachment paths are nested."""
132
133
  if (
133
- self.path == other.path
134
- or self.path.startswith(other.path)
135
- or other.path.startswith(self.path)
134
+ self.path == other.path
135
+ or self.path.startswith(other.path)
136
+ or other.path.startswith(self.path)
136
137
  ):
137
138
  raise RuntimeError(
138
- f"Attachments '{self.path}' and '{other.path}' "
139
- "are nested."
139
+ f"Attachments '{self.path}' and '{other.path}' " "are nested."
140
140
  )
141
141
 
142
142
  def _check_path(
143
- self,
144
- root: str,
143
+ self,
144
+ root: str,
145
145
  ):
146
146
  r"""Check if path exists and is not a symlink."""
147
- if not os.path.exists(audeer.path(root, self.path)):
147
+ if not os.path.exists(audeer.path(root, self.path, follow_symlink=True)):
148
148
  raise FileNotFoundError(
149
149
  f"The provided path '{self.path}' "
150
150
  f"of attachment '{self._id}' "
@@ -25,18 +25,17 @@ if typing.TYPE_CHECKING:
25
25
 
26
26
 
27
27
  def assert_values(
28
- values: Values,
29
- scheme: Scheme,
28
+ values: Values,
29
+ scheme: Scheme,
30
30
  ):
31
31
  r"""Raise error if values do not match scheme."""
32
32
  bad_values = []
33
33
 
34
34
  if (
35
- scheme.labels is not None
36
- or scheme.minimum is not None
37
- or scheme.maximum is not None
35
+ scheme.labels is not None
36
+ or scheme.minimum is not None
37
+ or scheme.maximum is not None
38
38
  ):
39
-
40
39
  if is_scalar(values):
41
40
  values = [values]
42
41
  elif isinstance(values, pd.Series):
@@ -59,11 +58,11 @@ def assert_values(
59
58
  max_display = 10
60
59
  values = str(bad_values[:max_display])[1:-1]
61
60
  if len(bad_values) > max_display:
62
- values += ', ...'
61
+ values += ", ..."
63
62
  raise ValueError(
64
63
  f"Some value(s) do not match scheme\n{scheme}\n"
65
64
  f"with scheme ID '{scheme._id}':\n"
66
- f'{values}'
65
+ f"{values}"
67
66
  )
68
67
 
69
68
 
@@ -81,17 +80,18 @@ class Column(HeaderBase):
81
80
  meta: additional meta fields
82
81
 
83
82
  Examples:
84
- >>> Column(scheme_id='emotion')
83
+ >>> Column(scheme_id="emotion")
85
84
  {scheme_id: emotion}
86
85
 
87
86
  """
87
+
88
88
  def __init__(
89
- self,
90
- *,
91
- scheme_id: str = None,
92
- rater_id: str = None,
93
- description: str = None,
94
- meta: dict = None,
89
+ self,
90
+ *,
91
+ scheme_id: str = None,
92
+ rater_id: str = None,
93
+ description: str = None,
94
+ meta: dict = None,
95
95
  ):
96
96
  super().__init__(description=description, meta=meta)
97
97
 
@@ -111,11 +111,9 @@ class Column(HeaderBase):
111
111
 
112
112
  """
113
113
  if (
114
- self.rater_id is not None
115
- ) and (
116
- self.table is not None
117
- ) and (
118
- self.table.db is not None
114
+ (self.rater_id is not None)
115
+ and (self.table is not None)
116
+ and (self.table.db is not None)
119
117
  ):
120
118
  return self.table.db.raters[self.rater_id]
121
119
 
@@ -128,11 +126,9 @@ class Column(HeaderBase):
128
126
 
129
127
  """
130
128
  if (
131
- self.scheme_id is not None
132
- ) and (
133
- self.table is not None
134
- ) and (
135
- self.table.db is not None
129
+ (self.scheme_id is not None)
130
+ and (self.table is not None)
131
+ and (self.table.db is not None)
136
132
  ):
137
133
  return self.table.db.schemes[self.scheme_id]
138
134
 
@@ -147,16 +143,16 @@ class Column(HeaderBase):
147
143
  return self._table
148
144
 
149
145
  def get(
150
- self,
151
- index: pd.Index = None,
152
- *,
153
- map: str = None,
154
- copy: bool = True,
155
- as_segmented: bool = False,
156
- allow_nat: bool = True,
157
- root: str = None,
158
- num_workers: typing.Optional[int] = 1,
159
- verbose: bool = False,
146
+ self,
147
+ index: pd.Index = None,
148
+ *,
149
+ map: str = None,
150
+ copy: bool = True,
151
+ as_segmented: bool = False,
152
+ allow_nat: bool = True,
153
+ root: str = None,
154
+ num_workers: typing.Optional[int] = 1,
155
+ verbose: bool = False,
160
156
  ) -> pd.Series:
161
157
  r"""Get labels.
162
158
 
@@ -210,11 +206,9 @@ class Column(HeaderBase):
210
206
 
211
207
  """
212
208
  if self._table is None:
213
- raise RuntimeError(
214
- 'Column is not assigned to a table.'
215
- )
209
+ raise RuntimeError("Column is not assigned to a table.")
216
210
 
217
- if hasattr(self._table, 'type'):
211
+ if hasattr(self._table, "type"):
218
212
  result = self._table.get(
219
213
  index,
220
214
  copy=False,
@@ -232,26 +226,20 @@ class Column(HeaderBase):
232
226
  result = result[self._id]
233
227
 
234
228
  if map is not None:
235
-
236
229
  copy = False # to avoid another copy
237
230
 
238
231
  if self.scheme_id is None:
239
- raise ValueError(
240
- f"Column '{self._id}' is not assigned to a scheme."
241
- )
232
+ raise ValueError(f"Column '{self._id}' is not assigned to a scheme.")
242
233
 
243
234
  scheme = self._table._db.schemes[self.scheme_id]
244
235
  labels = scheme._labels_to_dict()
245
236
 
246
237
  if labels is None:
247
- raise ValueError(
248
- f"Scheme '{self.scheme_id}' has no labels."
249
- )
238
+ raise ValueError(f"Scheme '{self.scheme_id}' has no labels.")
250
239
 
251
240
  if not any(labels.values()):
252
241
  raise ValueError(
253
- f"Scheme '{self.scheme_id}' provides no mapping "
254
- "for its labels."
242
+ f"Scheme '{self.scheme_id}' provides no mapping " "for its labels."
255
243
  )
256
244
 
257
245
  # Check that at least one key is available for map
@@ -284,10 +272,10 @@ class Column(HeaderBase):
284
272
  result.name = map
285
273
 
286
274
  if (
287
- scheme.uses_table
288
- and self._table._db[scheme.labels][map].scheme is not None
289
- # ^ ^
290
- # misc table column
275
+ scheme.uses_table
276
+ and self._table._db[scheme.labels][map].scheme is not None
277
+ # ^ ^
278
+ # misc table column
291
279
  ):
292
280
  # Infer dtype from misc table
293
281
  misc_table_id = scheme.labels
@@ -303,10 +291,10 @@ class Column(HeaderBase):
303
291
  return result.copy() if copy else result
304
292
 
305
293
  def set(
306
- self,
307
- values: Values,
308
- *,
309
- index: pd.Index = None,
294
+ self,
295
+ values: Values,
296
+ *,
297
+ index: pd.Index = None,
310
298
  ):
311
299
  r"""Set labels.
312
300
 
@@ -333,9 +321,7 @@ class Column(HeaderBase):
333
321
 
334
322
  """
335
323
  if self._table is None:
336
- raise RuntimeError(
337
- 'Column is not assigned to a table.'
338
- )
324
+ raise RuntimeError("Column is not assigned to a table.")
339
325
 
340
326
  column_id = self._id
341
327
  df = self._table.df
@@ -350,8 +336,7 @@ class Column(HeaderBase):
350
336
  else:
351
337
  dtype = df[column_id].dtype
352
338
 
353
- if hasattr(self._table, 'type') and \
354
- self._table.type != index_type(index):
339
+ if hasattr(self._table, "type") and self._table.type != index_type(index):
355
340
  # special case where a filewise / segmented table
356
341
  # is requested with an index of the other type
357
342
  if not self._table.is_filewise:
@@ -360,19 +345,19 @@ class Column(HeaderBase):
360
345
  return self.set(values, index=index)
361
346
  else:
362
347
  raise ValueError(
363
- 'Cannot set values of a filewise column '
364
- 'using a segmented index.'
348
+ "Cannot set values of a filewise column " "using a segmented index."
365
349
  )
366
350
  else:
367
351
  if is_scalar(values):
368
352
  values = [values] * len(index)
369
353
  values = to_array(values)
370
- if dtype == 'datetime64[ns]':
354
+ if dtype == "datetime64[ns]":
371
355
  # Ensure all date values are timezone unaware,
372
356
  # see https://github.com/audeering/audformat/issues/364
373
357
  values = [
374
358
  pd.to_datetime(value).tz_localize(None)
375
- if value is not None else value
359
+ if value is not None
360
+ else value
376
361
  for value in values
377
362
  ]
378
363
  with warnings.catch_warnings():
@@ -383,7 +368,7 @@ class Column(HeaderBase):
383
368
  # https://pandas.pydata.org/docs/dev/whatsnew/v1.5.0.html#inplace-operation-when-setting-values-with-loc-and-iloc
384
369
  # For pandas >=2.0.0 values are always set in place
385
370
  for warning in [FutureWarning, DeprecationWarning]:
386
- warnings.simplefilter(action='ignore', category=warning)
371
+ warnings.simplefilter(action="ignore", category=warning)
387
372
  df.loc[index, column_id] = pd.Series(
388
373
  values,
389
374
  index=index,
@@ -391,8 +376,8 @@ class Column(HeaderBase):
391
376
  )
392
377
 
393
378
  def __eq__(
394
- self,
395
- other: 'Column',
379
+ self,
380
+ other: "Column",
396
381
  ) -> bool:
397
382
  r"""Compare if column equals another column."""
398
383
  if self.dump() != other.dump():