Skip to content

Commit

Permalink
ENH: Several features/fixes for version 5.1 (#280)
Browse files Browse the repository at this point in the history
* CLN: Fix line break in formats/seq/simple.py

* Import format classes at package level, fix #273

* Have SimpleSeq only map column names in `column_map`, fix #272

Inside `SimpleSeq.from_file`, when someone specifies a
`column_map` argument, we only do the mapping if a column
name in the loaded csv file is a key in `column_map`.
Otherwise we leave the column as-is, and if it's not one of
the columns we need for the annotations
("onset_s", "offset_s", "label"),
it gets thrown away.

* Make SimpleSeq work with csv that doesn't have labels, fix #271

Adds `default_label` argument to `from_file` method,
a string that defaults to `'-'`
and if the `pandas.DataFrame`
loaded from the csv file does not already have a
'label' column, adds that column with the
`default_label` value as the label in every row.

This makes it possible to load segmentations saved
in csv files that do not have labels,
just start and stop times of the segments.

* Add validation logic for `columns_map` to SimpleSeq

* Fix SimpleSeq to handle empty csv file, fixes #264

* Fixup add validation of columns_map to SimpleSeq.from_file

* Add fixture `jourjine_et_al_2023_csv_path` to fixtures/simple.py

* Write unit tests for new features added to SimpleSeq

* Fixup import format classes at package level

* Rewrite crowsetta.data as crowsetta.examples, fix #278

As described in issue, and also:
Add example data files to dir
Remove crowsetta.data
Rewrite tests/test_data.py as tests/test_example.py

* Add csv from Jourjine et al 2023 dataset in tests + examples, fix #274

* Add helpful error message in SimpleSeq.from_file for when columns don't have expected names.

* Fix examples in docstrings of format classes after changing data -> example

* Apply linting

* Squelch flake8 line-length warnings for examples

* Add how-to on how to work with unlabeled segmentations

* Use crowsetta.example not crowsetta.data in doc/index.md

* Use crowsetta.example not crowsetta.data in doc/api/core.md

* Fixup empty SimpleSeq unit test

* Add __len__ to Sequence, fix #276

* Fix unit test for empty SimpleSeq to just use pytest tempdir, not tempfile

* Add unit tests for Sequence.__len__

* Add assert in unit test for empty SimpleSeq that we can call to_seq and get a Sequence of length 0

* Fixup usage of  in index.md -- fix example names

* Put all of API onto one page in docs, fix how we show crowsetta.examples.show and crowsetta.example
  • Loading branch information
NickleDave authored Oct 12, 2024
1 parent 81b4e72 commit 2ae3df8
Show file tree
Hide file tree
Showing 70 changed files with 4,196 additions and 900 deletions.
129 changes: 0 additions & 129 deletions doc/api/core.md

This file was deleted.

20 changes: 0 additions & 20 deletions doc/api/formats.md

This file was deleted.

195 changes: 181 additions & 14 deletions doc/api/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,189 @@ This section documents the
[API](https://en.wikipedia.org/wiki/API)
of crowsetta.

```{list-table}
:widths: 30 70
(api-core)=

* - {ref}`Core <api-core>`
- The core data types, classes and modules of crowsetta
* - {ref}`Interface <api-interface>`
- Defines an interface for classes that represent annotation formats
* - {ref}`Formats <api-formats>`
- Modules with the classes representing annotation formats,
and functions for conveniently accessing them.
# Core

This section documents the core API of crowsetta,
including data types, other classes, and modules.

## Data types

### Annotation

```{eval-rst}
.. autosummary::
:toctree: generated
:template: class.rst
crowsetta.Annotation
```

### Sequence

```{eval-rst}
.. autosummary::
:toctree: generated
:template: class.rst
crowsetta.Sequence
```

### Segment

```{eval-rst}
.. autosummary::
:toctree: generated
:template: class.rst
crowsetta.Segment
```

### BBox

```{eval-rst}
.. autosummary::
:toctree: generated
:template: class.rst
crowsetta.BBox
```

## Classes

### Transcriber

```{eval-rst}
.. autosummary::
:toctree: generated
:template: class.rst
crowsetta.Transcriber
```

## Modules

### `crowsetta.interface`

For complete documentation of the interface,
please see {ref}`this page <api-interface>`.

```{eval-rst}
.. autosummary::
:toctree: generated
:template: module.rst
crowsetta.interface
```

```{toctree}
:hidden: true

core
interface
formats
### typing

```{eval-rst}
.. autosummary::
:toctree: generated
:template: module.rst
:recursive:
crowsetta.typing
```


### validation

```{eval-rst}
.. autosummary::
:toctree: generated
:template: module.rst
:recursive:
crowsetta.validation
```

## Decorators

### `crowsetta.register_format`

```{eval-rst}
.. autosummary::
:toctree: generated
crowsetta.register_format
```

## Example data

```{eval-rst}
.. autosummary::
:toctree: generated
crowsetta.example
crowsetta.examples.show
```

(api-formats)=

# Formats

This section documents the API of the :mod:`crowsetta.formats` module.
It is generated automatically.
If you are a crowsetta user looking for
more detail about the built-in formats,
please see: {ref}`formats-index`.

```{eval-rst}
.. autosummary::
:toctree: generated
:template: module.rst
:recursive:
crowsetta.formats
crowsetta.formats.bbox
crowsetta.formats.seq
```

(api-interface)=

# Interface

The section documents the API of the :mod:`crowsetta.interface` module.

```{eval-rst}
.. autosummary::
:toctree: generated
:template: module.rst
:recursive:
crowsetta.interface
```

## Base

```{eval-rst}
.. autosummary::
:toctree: generated
:template: class.rst
crowsetta.interface.base.BaseFormat
```

## Sequence-Like

```{eval-rst}
.. autosummary::
:toctree: generated
:template: class.rst
crowsetta.interface.seq.SeqLike
```

## Bounding Box-Like

```{eval-rst}
.. autosummary::
:toctree: generated
:template: class.rst
crowsetta.interface.bbox.BBoxLike
```
42 changes: 0 additions & 42 deletions doc/api/interface.md

This file was deleted.

Loading

0 comments on commit 2ae3df8

Please sign in to comment.