Skip to content

Commit

Permalink
Merge pull request #44 from bootphon/packaging-update
Browse files Browse the repository at this point in the history
Packaging update
  • Loading branch information
hadware authored Jan 11, 2024
2 parents af04d93 + 83b5a43 commit 71df2d3
Show file tree
Hide file tree
Showing 9 changed files with 95 additions and 16 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/test-pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ jobs:
strategy:
fail-fast: true
matrix:
python-version: [3.7, 3.8, 3.9, "3.10"]
python-version: [3.7, 3.8, 3.9, "3.10", "3.11"]

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install dependencies
Expand Down
3 changes: 0 additions & 3 deletions MANIFEST.in

This file was deleted.

16 changes: 14 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ Optionally, to allow `pygamma-agreement` to display visual representations of
our API's objects in Jupyter Notebooks, [Matplotlib](https://matplotlib.org/>)
is needed.

pygamma-agreement is a Python 3 package and is currently tested for Python 3.7, 3.8, 3.9 and 3.10.
pygamma-agreement does not work with Python 2.7.
`pygamma-agreement` is a Python 3 package and is currently tested for Python 3.7 to 3.11.
`pygamma-agreement` does not work with Python 2.7.


## Installation
Expand Down Expand Up @@ -69,6 +69,18 @@ After that, tests are ready to be launched (they take ~2m on a recent laptop) :

$ pytest tests/

## Documentation

The documentation for this package has been written using Sphinx. To build the documentation locally, run:

$ pip install "pygamma-agreement[docs]"
$ cd docs/
$ make html

After that, you can view the documentation by running

$ firefox build/html/index.html

## Submitting and issue or contributing

Please read `CONTRIBUTING.md` before submitting and issue or writing some contribution
Expand Down
4 changes: 2 additions & 2 deletions docs/source/quickstart.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ tuple of 3 information:
* Segment end (at 7.2s)

Obviously, our annotators sometimes disagree on who might be talking,
or when exactly each person's speech turn is starting or ending. Luckily, the Gamma
inter-annotator agreement enables us to measure that.
or when exactly each person's speech turn is starting or ending. The Gamma
inter-annotator agreement enables us to obtain a measure of that disagreement.

We'll first load the annotation into ``pygamma-agreement``'s base data structure,
the ``Continuum``, made to store this kind of annotated data.
Expand Down
2 changes: 2 additions & 0 deletions pygamma_agreement/cst.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,15 @@ def category_shuffle(self, continuum: Continuum,
"""
Shuffles the categories of the annotations in the given continuum using the process described in
section 3.3.5 of https://hal.archives-ouvertes.fr/hal-00769639/.
Parameters
----------
overlapping_fun:
gives the "categorical distance" between two annotations, which is taken into account when provided.
(the lower the distance between categories, the higher the chance one will be changed into the other).
prevalence:
specify whether or not to consider the proportion of presence of each category in the reference.
"""
category_weights = self._reference_continuum.category_weights
# matrix "A"
Expand Down
14 changes: 9 additions & 5 deletions pygamma_agreement/dissimilarity.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ def __init__(self, categories: Optional[SortedSet] = None, delta_empty: float =
@abc.abstractmethod
def compile_d_mat(self) -> Callable[[np.ndarray, np.ndarray], float]:
"""
Must set self.d_mat to the the cfunc (decorated with @dissimilarity_dec) function that corresponds to the
unit-to-unit, (in arrays form) disorder given by the dissimilarity.
Must set self.d_mat to the cfunc (decorated with @dissimilarity_dec) function that corresponds to the
unit-to-unit (in arrays form) disorder given by the dissimilarity.
"""
raise NotImplemented()

Expand Down Expand Up @@ -283,9 +283,11 @@ class PositionalSporadicDissimilarity(AbstractDissimilarity):
"""
Positional-sporadic dissimilarity. Takes only the position of annotations into account.
This distance is :
* 0 when segments are equal
* < delta_empty when segments completely overlap :math:`A \cup B = A` or :math:`B`)
* < delta_empty when segments completely overlap (:math:`A \cup B = A` or :math:`B`)
* > delta_empty when segments are separated (:math:`A \cap B = \emptyset`)
"""
def __init__(self, delta_empty: float = 1.0):
super().__init__(delta_empty=delta_empty)
Expand Down Expand Up @@ -415,7 +417,7 @@ def cat_dissim_func(str1: str, str2: str) -> float:
class OrdinalCategoricalDissimilarity(PrecomputedCategoricalDissimilarity):
"""
Categorical dissimilarity where each label is given a position on the real axis, and the disorder between
categories of positions 'a' and 'b' being |a - b|/m * delta_empty with m the maximum position. If not provided,
categories of positions 'a' and 'b' being \|a - b\|/m * delta_empty with m the maximum position. If not provided,
positions are 0, 1, 2...
"""
def __init__(self, labels: Iterable[str], p: Iterable[float] = None, delta_empty=1.0):
Expand Down Expand Up @@ -453,7 +455,7 @@ def __init__(self, labels: Iterable[str], p: Iterable[float] = None, delta_empty
class NumericalCategoricalDissimilarity(OrdinalCategoricalDissimilarity):
"""
Categorical dissimilarity made for numerical categories (i.e a category is a float or int literal).
The disorder between categories 'a' and 'b' being |a - b|/m * delta_empty with m the maximum category.
The disorder between categories 'a' and 'b' being \|a - b\|/m * delta_empty with m the maximum category.
"""
def __init__(self, labels: Iterable[str], delta_empty: float = 1.0):
try:
Expand All @@ -468,6 +470,7 @@ class CombinedCategoricalDissimilarity(AbstractDissimilarity):
"""
This dissimilarity takes both positioning and categorizing of annotations into account.
Combined categorical dissimilarity constructor.
Parameters
----------
delta_empty : optional, float
Expand All @@ -479,6 +482,7 @@ class CombinedCategoricalDissimilarity(AbstractDissimilarity):
coefficient weighting the categorical dissimilarity value. Defaults to 1.
cat_dissim : optional, CategoricalDissimilarity
Categorical-only dissimilarity to be used. If not set, defaults to the absolute categorical dissimilarity.
"""
def __init__(self,
alpha: float = 1.0,
Expand Down
1 change: 1 addition & 0 deletions pygamma_agreement/sampler.py
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ class StatisticalContinuumSampler(AbstractContinuumSampler):
- The number of annotations per annotator
- The gap between two of an annotator's annotations
- The duration of the annotations' segments
The sample is thus created by computing normal distributions using these parameters.
It also requires the probability of occurence of each annotations category. You can either initalize sampling with
Expand Down
63 changes: 63 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
[project]
name = "pygamma-agreement"
readme = "README.md"
version = "0.5.7"
description = 'Inter-annotator agreement measure and alignment written in python'

authors = [
{ name = "Hadrien Titeux", email = "[email protected]" },
{ name = "Rachid Riad", email = "[email protected]" },
{ name = "Léopold Favre", email = "[email protected]" },
]
maintainers = [
{ name = "Hadrien Titeux", email = "[email protected]" },
]


license = { text = "MIT" }
requires-python = ">=3.7"
keywords = []
classifiers = [
"Development Status :: 4 - Beta",
"Intended Audience :: Science/Research",
"License :: OSI Approved :: MIT License",
"Topic :: Scientific/Engineering",
"Topic :: Text Processing :: Linguistic",
"Topic :: Multimedia :: Sound/Audio :: Speech",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
]
dynamic = ["dependencies"]

[project.urls]
Documentation = "https://pygamma-agreement.readthedocs.io/en/latest/"
Homepage = "https://github.com/bootphon/pygamma-agreement"
Repository = "https://github.com/bootphon/pygamma-agreement"


[tool.setuptools.dynamic]
dependencies = { file = ["requirements.txt"] }

[project.optional-dependencies]
notebook = ["matplotlib"]
CBC = ["cylp"]
testing = ["pytest", "cylp"]
docs = ["sphinx", "sphinx_rtd_theme"]

[build-system]
requires = ["setuptools>=45", "setuptools_scm[toml]>=6.2"]
build-backend = "setuptools.build_meta"

[project.scripts]
pygamma-agreement = "pygamma_agreement.cli_apps:pygamma_cmd"

[tool.setuptools.packages.find]
where = ["."]
include = ["adfluo*"]
exclude = ["docs*", "tests*"]

2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ sortedcontainers>= 2.0.4
numpy>= 1.10.4
pyannote.core>=4.1
cvxpy>= 1.0.25
cvxopt== 1.2.7
cvxopt== 1.3.2
tqdm>= 4.46.0
numba>= 0.54.0
typing_extensions>= 3.7.4.3
Expand Down

0 comments on commit 71df2d3

Please sign in to comment.