Skip to content

Commit

Permalink
Merge branch 'stable'
Browse files Browse the repository at this point in the history
  • Loading branch information
YannickJadoul committed Dec 12, 2024
2 parents 122cafc + 99ca620 commit 5ecf8aa
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 10 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,17 @@ jobs:
fail-fast: false
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11']
os: [ubuntu-latest, macos-13, windows-latest]
os: [ubuntu-latest, macos-latest, macos-13, windows-latest]

name: Test • Python ${{ matrix.python-version }} • ${{ matrix.os }}
runs-on: ${{ matrix.os }}

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
filter: tree:0

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/packaging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ jobs:
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
fetch-depth: 0
filter: tree:0

- name: Set up Python 3.11
uses: actions/setup-python@v5
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ dynamic = ["version"]
music_notation = [
"abjad ; python_version > '3.9'",
"abjad<=3.4 ; python_version <= '3.9'",
"lilypond"
"lilypond; sys_platform != 'darwin' or platform_machine != 'arm64'"
]

[tool.setuptools]
Expand Down
3 changes: 3 additions & 0 deletions tests/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
pytest
pytest-mpl
pyarrow

numpy>=2; python_version>="3.9"
numpy<2; python_version<"3.9"
4 changes: 2 additions & 2 deletions thebeat/music.py
Original file line number Diff line number Diff line change
Expand Up @@ -820,7 +820,7 @@ class Melody(thebeat.core.sequence.BaseSequence):
def __init__(
self,
rhythm: thebeat.music.Rhythm,
pitch_names: npt.NDArray[str] | list[str] | str,
pitch_names: npt.NDArray[np.str_] | list[str] | str,
octave: int | None = None,
key: str | None = None,
is_played: list | None = None,
Expand Down Expand Up @@ -874,7 +874,7 @@ def __init__(
else:
pitch_names_list = pitch_names

self.pitch_names = pitch_names_list
self.pitch_names = [str(pitch_name) for pitch_name in pitch_names_list]

# Add initial events
self.events = self._make_namedtuples(
Expand Down
12 changes: 6 additions & 6 deletions thebeat/stats.py
Original file line number Diff line number Diff line change
Expand Up @@ -779,7 +779,7 @@ def ks_test(
Either 'normal' or 'uniform'. The distribution against which the distribution of inter-onset intervals (IOIs)
is compared.
alternative
Either two-sided’, ‘less or greater. See :func:`scipy.stats.kstest` for more information.
Either 'two-sided', 'less', or 'greater'. See :func:`scipy.stats.kstest` for more information.
Returns
-------
Expand All @@ -796,9 +796,9 @@ def ks_test(
--------
>>> rng = np.random.default_rng(seed=123)
>>> seq = thebeat.core.Sequence.generate_random_normal(n_events=100,mu=500,sigma=25,rng=rng)
>>> print(ks_test(seq))
KstestResult(statistic=0.07176677141846549, pvalue=0.6608009345687911, statistic_location=496.3505526721194, \
statistic_sign=1)
>>> ks_result = ks_test(seq)
>>> print(round(ks_result.pvalue, 5))
0.6608
"""

Expand Down Expand Up @@ -1094,7 +1094,7 @@ def get_npvi(sequence: thebeat.core.Sequence) -> np.float64:
>>> rng = np.random.default_rng(seed=123)
>>> seq = thebeat.core.Sequence.generate_random_normal(n_events=10,mu=500,sigma=50,rng=rng)
>>> print(get_npvi(seq))
4.703289681619325
9.40657936323865
"""

if isinstance(sequence, (thebeat.core.Sequence, thebeat.core.SoundSequence)):
Expand All @@ -1106,7 +1106,7 @@ def get_npvi(sequence: thebeat.core.Sequence) -> np.float64:

for i in range(1, len(iois)):
diff = iois[i] - iois[i - 1]
mean = np.mean(iois[i] + iois[i - 1])
mean = np.mean([iois[i], iois[i - 1]])
npvi_values.append(np.abs(diff / mean))

npvi = (100 / (len(iois) - 1)) * np.sum(npvi_values)
Expand Down

0 comments on commit 5ecf8aa

Please sign in to comment.