Skip to content

Commit

Permalink
Merge pull request #55 from FastTrackiverse/dev
Browse files Browse the repository at this point in the history
v0.3.1
  • Loading branch information
JoFrhwld authored Feb 16, 2024
2 parents ed02a93 + defe0b3 commit 194a506
Show file tree
Hide file tree
Showing 9 changed files with 122 additions and 30 deletions.
42 changes: 42 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/python
{
"name": "Python 3",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/python:1-3.11",
"features": {
"ghcr.io/rocker-org/devcontainer-features/quarto-cli:1": {
"version": "latest"
},
"ghcr.io/devcontainers-contrib/features/poetry:2": {
"version": "latest"
}
},

// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "poetry install",

// Configure tool-specific properties.
"customizations": {
"vscode": {
"extensions":
["ms-toolsai.jupyter",
"ms-python.vscode-pylance",
"njpwerner.autodocstring"],
"settings": {"python.testing.pytestArgs": [
"tests"
],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true}
}
}

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}
4 changes: 2 additions & 2 deletions .github/workflows/test-and-run.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: "pip"
Expand All @@ -41,6 +41,6 @@ jobs:
run: |
python -m pytest --cov=./ --cov-report=xml tests/
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
uses: codecov/codecov-action@v4
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -160,4 +160,5 @@ cython_debug/
#.idea/

.vscode
poetry.lock
poetry.lock
.DS_Store
26 changes: 26 additions & 0 deletions CITATION.cff
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# This CITATION.cff file was generated with cffinit.
# Visit https://bit.ly/cffinit to generate yours today!

cff-version: 1.2.0
title: fasttrackpy
message: >-
If you use this software, please cite it using the
metadata from this file.
type: software
authors:
- given-names: Josef
family-names: Fruehwald
orcid: 'https://orcid.org/0000-0001-8480-9461'
affiliation: University of Kentucky
- given-names: Santiago
family-names: Barreda
affiliation: UC Davis
orcid: 'https://orcid.org/0000-0002-1552-083X'
identifiers:
- type: doi
value: 10.5281/zenodo.10212100
description: zenodo
repository-code: 'https://github.com/FastTrackiverse/fasttrackpy'
url: 'https://fasttrackiverse.github.io/fasttrackpy/'
abstract: A python implementation of FastTrack
license: MIT
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# FastTrackPy
[![PyPI](https://img.shields.io/pypi/v/fasttrackpy)](https://pypi.org/project/fasttrackpy/)
[![Python CI](https://github.com/JoFrhwld/fasttrackpy/actions/workflows/test-and-run.yml/badge.svg)](https://github.com/JoFrhwld/fasttrackpy/actions/workflows/test-and-run.yml) [![codecov](https://codecov.io/gh/FastTrackiverse/fasttrackpy/graph/badge.svg?token=GOAWY4B5C8)](https://codecov.io/gh/FastTrackiverse/fasttrackpy) <a href="https://codeclimate.com/github/JoFrhwld/fasttrackpy/maintainability"><img src="https://api.codeclimate.com/v1/badges/6725fded174b21a3c59f/maintainability" /></a>
[![Python CI](https://github.com/JoFrhwld/fasttrackpy/actions/workflows/test-and-run.yml/badge.svg)](https://github.com/JoFrhwld/fasttrackpy/actions/workflows/test-and-run.yml) [![codecov](https://codecov.io/gh/FastTrackiverse/fasttrackpy/graph/badge.svg?token=GOAWY4B5C8)](https://codecov.io/gh/FastTrackiverse/fasttrackpy) <a href="https://codeclimate.com/github/JoFrhwld/fasttrackpy/maintainability"><img src="https://api.codeclimate.com/v1/badges/6725fded174b21a3c59f/maintainability" /></a> [![DOI](https://zenodo.org/badge/580169086.svg)](https://zenodo.org/doi/10.5281/zenodo.10212099)


Goal: A FastTrack python implementation with importable modules

Expand All @@ -14,4 +15,4 @@ pip install fasttrackpy

```bash
fasttrack --file audio.wav --output formants.csv
```
```
2 changes: 2 additions & 0 deletions poetry.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[virtualenvs]
in-project = true
9 changes: 5 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ homepage = "https://fasttrackiverse.github.io/fasttrackpy/"
repository = "https://github.com/FastTrackiverse/fasttrackpy"

[tool.poetry.dependencies]
python = ">=3.10,<3.13"
python = ">=3.10,<3.12"
praat-parselmouth = "^0.4.3"
scipy = {version = "^1.11.3", python = ">=3.10,<3.13"}
numpy = {version = "^1.26.1", python = ">=3.10,<3.13"}
scipy = {version = "^1.11.3", python = ">=3.10,<3.12"}
numpy = {version = "^1.26.1", python = ">=3.10,<3.12"}
polars = "^0.19.16"
pytest-cov = "^4.1.0"
pytest = "^7.4.3"
Expand Down Expand Up @@ -59,7 +59,8 @@ addopts = [
"--import-mode=importlib",
"--cov-config=tests/.coveragerc",
"--cov-report=xml",
"--cov"
"--cov",
"--log-cli-level=INFO"
]
filterwarnings =[
"ignore::UserWarning"
Expand Down
6 changes: 4 additions & 2 deletions src/fasttrackpy/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,8 @@ def audio(
n_formants: int = 4,
window_length: float = 0.025,
time_step: float = 0.002,
pre_emphasis_from: float = 50
pre_emphasis_from: float = 50,
**kwargs
):
"""Run fasttrack.
Expand Down Expand Up @@ -392,7 +393,8 @@ def audio_textgrid(
n_formants: int = 4,
window_length: float = 0.025,
time_step: float = 0.002,
pre_emphasis_from: float = 50
pre_emphasis_from: float = 50,
**kwargs
):
"""Run fasttrack.
Expand Down
55 changes: 36 additions & 19 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from click.testing import CliRunner
import pytest
import yaml
import logging

class TestCLI:
sound_path = Path("tests", "test_data", "ay.wav")
Expand All @@ -16,17 +17,21 @@ def test_file_usage(self):
out_dir.mkdir()

runner = CliRunner()
runner.invoke(
result = runner.invoke(
fasttrack,
f"audio --file {str(self.sound_path)} --dest {str(out_dir)}"
["audio",
"--file", self.sound_path,
"--dest", out_dir]
)

assert result.exit_code == 0, result.output
out_files = list(out_dir.glob("*"))
assert all([x.is_file() for x in out_files])
[x.unlink() for x in out_files]
out_dir.rmdir()

def test_config_file(self):
with open("tests/test_data/config.yml") as file:
config_path = Path("tests", "test_data", "config.yml")
with config_path.open() as file:
params = yaml.safe_load(file)

sound_path = Path(params["file"])
Expand All @@ -35,12 +40,14 @@ def test_config_file(self):
dest.mkdir()

runner = CliRunner()
runner.invoke(
result = runner.invoke(
fasttrack,
f"audio --config tests/test_data/config.yml"
["audio",
"--config", config_path]
)

assert result.exit_code == 0, result.output
out_files = list(dest.glob("*"))
assert all([x.is_file() for x in out_files])
[x.unlink() for x in out_files]
dest.rmdir()

Expand All @@ -51,14 +58,15 @@ def test_dir_usage(self):
out_dir.mkdir()

runner = CliRunner()
runner.invoke(
result = runner.invoke(
fasttrack,
f"audio --dir {str(self.sound_path.parent)} --dest {str(out_dir)}"
["audio",
"--dir", self.sound_path.parent,
"--dest", out_dir]
)

out_files = list(out_dir.glob("*"))
assert all([x.is_file() for x in out_files])

assert result.exit_code == 0, result.output
out_files = out_dir.glob("*")
[x.unlink() for x in out_files]
out_dir.rmdir()

Expand All @@ -67,13 +75,18 @@ def test_audio_tg(self):
if not out_dir.is_dir():
out_dir.mkdir()
runner = CliRunner()
runner.invoke(
result = runner.invoke(
fasttrack,
f"audio-textgrid --audio {str(self.audio_path)} --textgrid {str(self.tg_path)} --target-tier Phone --target-labels AY --dest {str(out_dir)}"
["audio-textgrid",
"--audio", self.audio_path,
"--textgrid", self.tg_path,
"--target-tier", "Phone",
"--target-labels", "AY",
"--dest", out_dir]
)

assert result.exit_code == 0, result.output
out_files = list(out_dir.glob("*"))
assert all([x.is_file() for x in out_files])

[x.unlink() for x in out_files]
out_dir.rmdir()
Expand All @@ -83,14 +96,18 @@ def test_corpus(self):
if not out_dir.is_dir():
out_dir.mkdir()
runner = CliRunner()
runner.invoke(
result = runner.invoke(
fasttrack,
f"corpus --corpus {str(self.corpus_path)} --target-labels AY --dest {str(out_dir)} --separate-output"
["corpus",
"--corpus", self.corpus_path,
"--target-labels", "AY",
"--dest", out_dir,
"--separate-output"]
)

assert result.exit_code == 0, result.output
out_files = list(out_dir.iterdir())
assert all([x.is_file() for x in out_files])
#assert len(out_files) > 1
assert len(out_files) > 1

[x.unlink() for x in out_files]
out_dir.rmdir()

0 comments on commit 194a506

Please sign in to comment.