Skip to content

Commit

Permalink
Format documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
hagenw committed Jan 23, 2024
1 parent e60d9d5 commit e1e74f3
Show file tree
Hide file tree
Showing 8 changed files with 102 additions and 102 deletions.
6 changes: 3 additions & 3 deletions docs/caching.rst
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ There are four ways to change the default locations:

.. code-block:: python
audb.load('emodb', ..., cache_root='/cache/root/audb')
audb.load("emodb", ..., cache_root="/cache/root/audb")
2. System-wide by setting the following system variables

Expand All @@ -83,12 +83,12 @@ There are four ways to change the default locations:

.. jupyter-execute::

audb.config.SHARED_CACHE_ROOT = '/new/shared/cache/audb'
audb.config.SHARED_CACHE_ROOT = "/new/shared/cache/audb"
audb.default_cache_root(shared=True)

.. jupyter-execute::

audb.config.CACHE_ROOT = '/new/local/cache/audb'
audb.config.CACHE_ROOT = "/new/local/cache/audb"
audb.default_cache_root(shared=False)

4. System wide by
Expand Down
2 changes: 1 addition & 1 deletion docs/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,5 @@ using :class:`audb.config`.

.. jupyter-execute::

audb.config.CACHE_ROOT = '/user/cache'
audb.config.CACHE_ROOT = "/user/cache"
audb.config.CACHE_ROOT
26 changes: 13 additions & 13 deletions docs/dependencies.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

audb.config.REPOSITORIES = [
audb.Repository(
name='data-public',
host='https://audeering.jfrog.io/artifactory',
backend='artifactory',
name="data-public",
host="https://audeering.jfrog.io/artifactory",
backend="artifactory",
)
]

Expand All @@ -20,7 +20,7 @@

import pandas as pd

pd.set_option('display.max_columns', 7)
pd.set_option("display.max_columns", 7)


.. _database-dependencies:
Expand All @@ -45,7 +45,7 @@ You request a :class:`audb.Dependencies` object with

.. jupyter-execute::

deps = audb.dependencies('emodb', version='1.4.1')
deps = audb.dependencies("emodb", version="1.4.1")

You can see all entries by calling the returned object.

Expand All @@ -58,7 +58,7 @@ You can also use it to request certain aspects, e.g.

.. jupyter-execute::

deps.duration('wav/03a01Fa.wav')
deps.duration("wav/03a01Fa.wav")

See :class:`audb.Dependencies` for all available methods.

Expand All @@ -72,7 +72,7 @@ in the database dependency table.

.. jupyter-execute::

deps = audb.dependencies('emodb', version='1.4.1')
deps = audb.dependencies("emodb", version="1.4.1")
df = deps()
df.duration[:10]

Expand All @@ -81,7 +81,7 @@ you can get their overall duration with:

.. jupyter-execute::

audb.info.duration('emodb', version='1.4.1')
audb.info.duration("emodb", version="1.4.1")

The duration of parts of a database
can be calculated
Expand All @@ -95,10 +95,10 @@ of the emodb database.

import numpy as np

df = audb.load_table('emodb', 'emotion', version='1.4.1', verbose=False)
df = audb.load_table("emodb", "emotion", version="1.4.1", verbose=False)
files = df.index[:10]
duration_in_sec = np.sum([deps.duration(f) for f in files])
pd.to_timedelta(duration_in_sec, unit='s')
pd.to_timedelta(duration_in_sec, unit="s")

If your table is a segmented table,
and you would like to get the duration
Expand All @@ -110,14 +110,14 @@ from the ``start`` and ``end`` entries.

.. code-block:: python
df = audb.load_table('database-with-segmented-tables', 'segmented-table')
df = audb.load_table("database-with-segmented-tables", "segmented-table")
audformat.utils.duration(df.dropna())
Or you can count the duration of all segments within your database.

.. code-block:: python
db = audb.load('database-with-segmented-tables', only_metadata=True)
db = audb.load("database-with-segmented-tables", only_metadata=True)
audformat.utils.duration(db.segments)
If your database contains files
Expand All @@ -130,5 +130,5 @@ to calculate the duration on the fly.

.. code-block:: python
db = audb.load('database-with-videos')
db = audb.load("database-with-videos")
audformat.utils.duration(db.files, num_workers=4)
4 changes: 2 additions & 2 deletions docs/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Under Ubuntu you can install it with

.. code-block:: bash
$ sudo apt-get install libsndfile1
$ sudo apt install libsndfile1
In order to handle all possible audio files,
please make sure ffmpeg_,
Expand All @@ -29,7 +29,7 @@ Under Ubuntu this can be achieved with

.. code-block:: bash
$ sudo apt-get install ffmpeg mediainfo sox libsox-fmt-mp3
$ sudo apt install ffmpeg mediainfo sox libsox-fmt-mp3
Under Windows you have to install those libraries manually,
and ensure that they are added to the ``PATH`` variable.
Expand Down
80 changes: 40 additions & 40 deletions docs/load.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@

audb.config.REPOSITORIES = [
audb.Repository(
name='data-public',
host='https://audeering.jfrog.io/artifactory',
backend='artifactory',
name="data-public",
host="https://audeering.jfrog.io/artifactory",
backend="artifactory",
)
]

Expand All @@ -23,17 +23,17 @@

def series_to_html(self):
df = self.to_frame()
df.columns = ['']
df.columns = [""]
return df._repr_html_()


def index_to_html(self):
return self.to_frame(index=False)._repr_html_()


setattr(pd.Series, '_repr_html_', series_to_html)
setattr(pd.Index, '_repr_html_', index_to_html)
pd.set_option('display.max_rows', 6)
setattr(pd.Series, "_repr_html_", series_to_html)
setattr(pd.Index, "_repr_html_", index_to_html)
pd.set_option("display.max_rows", 6)


.. _load:
Expand All @@ -55,17 +55,17 @@ even if a new version of the database is published.
:hide-code:

db = audb.load(
'emodb',
version='1.4.1',
"emodb",
version="1.4.1",
only_metadata=True,
verbose=False,
)

.. code-block:: python
db = audb.load(
'emodb',
version='1.4.1',
"emodb",
version="1.4.1",
verbose=False,
)
Expand All @@ -84,13 +84,13 @@ and can be requested as a :class:`pandas.DataFrame`.

.. jupyter-execute::

db['emotion'].get()
db["emotion"].get()

Or you can directly request single columns as :class:`pandas.Series`.

.. jupyter-execute::

db['files']['duration'].get()
db["files"]["duration"].get()

As you can see the index of the returned object
holds the path to the corresponding media files.
Expand Down Expand Up @@ -153,9 +153,9 @@ inside the :ref:`cache <caching>`.
:hide-code:

db = audb.load(
'emodb',
version='1.4.1',
format='flac',
"emodb",
version="1.4.1",
format="flac",
sampling_rate=44100,
only_metadata=True,
verbose=False,
Expand All @@ -164,28 +164,28 @@ inside the :ref:`cache <caching>`.
.. code-block:: python
db = audb.load(
'emodb',
version='1.4.1',
format='flac',
"emodb",
version="1.4.1",
format="flac",
sampling_rate=44100,
verbose=False,
)
The flavor information of a database is stored
inside the ``db.meta['audb']`` dictionary.
inside the ``db.meta["audb"]`` dictionary.

.. jupyter-execute::

db.meta['audb']['flavor']
db.meta["audb"]["flavor"]

You can list all available flavors and their locations in the cache with:

.. jupyter-execute::

df = audb.cached()
df[['name', 'version', 'complete', 'format', 'sampling_rate']]
df[["name", "version", "complete", "format", "sampling_rate"]]

The entry ``'complete'`` tells you if a database flavor is completely cached,
The entry ``"complete"`` tells you if a database flavor is completely cached,
or if some table or media files are still missing.


Expand All @@ -203,8 +203,8 @@ but all the tables and the header.
.. jupyter-execute::

db = audb.load(
'emodb',
version='1.4.1',
"emodb",
version="1.4.1",
only_metadata=True,
verbose=False,
)
Expand All @@ -221,17 +221,17 @@ It can list all table definitions.
.. jupyter-execute::

audb.info.tables(
'emodb',
version='1.4.1',
"emodb",
version="1.4.1",
)

Or get the total duration of all media files.

.. jupyter-execute::

audb.info.duration(
'emodb',
version='1.4.1',
"emodb",
version="1.4.1",
)

See :mod:`audb.info` for a list of all available options.
Expand All @@ -255,14 +255,14 @@ but only the table(s) and media of the *test* set.
Or, if we want the data of a specific speaker,
we can do the following.
First, we download the table with information
about the speakers (here ``db['files']``):
about the speakers (here ``db["files"]``):

.. jupyter-execute::

db = audb.load(
'emodb',
version='1.4.1',
tables=['files'],
"emodb",
version="1.4.1",
tables=["files"],
only_metadata=True,
full_path=False,
verbose=False,
Expand All @@ -279,7 +279,7 @@ and therefore match the paths on the backend.

.. jupyter-execute::

speaker = db['files']['speaker'].get()
speaker = db["files"]["speaker"].get()
speaker

Now, we use the column with speaker IDs
Expand All @@ -288,7 +288,7 @@ that belong to speaker 3.

.. jupyter-execute::

media = db['files'].files[speaker == 3]
media = db["files"].files[speaker == 3]
media

Finally, we load the database again
Expand All @@ -300,8 +300,8 @@ only the data of this speaker.
:hide-code:

db = audb.load(
'emodb',
version='1.4.1',
"emodb",
version="1.4.1",
media=media,
full_path=False,
only_metadata=True,
Expand All @@ -311,8 +311,8 @@ only the data of this speaker.
.. code-block:: python
db = audb.load(
'emodb',
version='1.4.1',
"emodb",
version="1.4.1",
media=media,
full_path=False,
verbose=False,
Expand All @@ -324,7 +324,7 @@ from the tables.

.. jupyter-execute::

db['emotion'].get()
db["emotion"].get()


.. _corresponding audformat documentation: https://audeering.github.io/audformat/accessing-data.html
Expand Down
6 changes: 3 additions & 3 deletions docs/overview.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ you would use the following repository.
.. jupyter-execute::

repository = audb.Repository(
name='data-local',
host='/data',
backend='file-system',
name="data-local",
host="/data",
backend="file-system",
)

The default repositories are configured in :attr:`audb.config.REPOSITORIES`
Expand Down
Loading

0 comments on commit e1e74f3

Please sign in to comment.