Skip to content

Commit 91e0d57

Browse files
authored
Merge pull request #222 from giovana-morais/migrate_ci
Migrate CI to GitHub Actions (v2)
2 parents 58a24d5 + 5a8dfd8 commit 91e0d57

9 files changed

+60
-99
lines changed

.github/workflows/ci.yml

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: JSON Annotated Music Specification for Reproducible MIR Research
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
branches:
9+
- master
10+
11+
jobs:
12+
install:
13+
runs-on: ubuntu-latest
14+
strategy:
15+
matrix:
16+
python-version:
17+
- "3.9"
18+
- "3.10"
19+
- "3.11"
20+
- "3.12"
21+
timeout-minutes: 5
22+
steps:
23+
- uses: actions/checkout@v4
24+
- name: Setup Python ${{ matrix.python-version }}
25+
uses: actions/setup-python@v5
26+
with:
27+
python-version: ${{ matrix.python-version }}
28+
- name: Install jams
29+
run: pip install -e .[display,tests]
30+
- name: Run tests
31+
run: |
32+
pytest -v --cov-report term-missing --cov jams

.gitignore

+4
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ var
1212
sdist
1313
develop-eggs
1414
.installed.cfg
15+
lib
16+
share
17+
pyvenv.cfg
18+
1519

1620
# Installer logs
1721
pip-log.txt

.travis.yml

-34
This file was deleted.

.travis_dependencies.sh

-40
This file was deleted.

jams/__init__.py

+10-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"""Top-level module for JAMS"""
33

44
import os
5+
import sys
56
from importlib import resources
67
from itertools import chain
78

@@ -19,11 +20,17 @@
1920

2021

2122
# Populate the namespace mapping
22-
for ns in chain(*map(lambda p: p.rglob('*.json'), resources.files('jams.schemata.namespaces').iterdir())):
23-
schema.add_namespace(ns)
23+
if sys.version_info < (3, 10):
24+
from pkg_resources import resource_filename
2425

25-
# Populate local namespaces
26+
for _ in util.find_with_extension(resource_filename(__name__, schema.NS_SCHEMA_DIR), 'json'):
27+
schema.add_namespace(_)
28+
29+
else:
30+
for ns in chain(*map(lambda p: p.rglob('*.json'), resources.files('jams.schemata.namespaces').iterdir())):
31+
schema.add_namespace(ns)
2632

33+
# Populate local namespaces
2734
if 'JAMS_SCHEMA_DIR' in os.environ:
2835
for ns in util.find_with_extension(os.environ['JAMS_SCHEMA_DIR'], 'json'):
2936
schema.add_namespace(ns)

jams/sonify.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ def piano_roll(annotation, sr=22050, length=None, **kwargs):
169169
gram[pitch_map[f], col] = 1
170170

171171
return filter_kwargs(mir_eval.sonify.time_frequency,
172-
gram, pitches, intervals,
172+
gram, np.asarray(pitches), np.asarray(intervals),
173173
sr, length=length, **kwargs)
174174

175175

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def load_source(modname, filename):
4949
'numpy>=1.8.0',
5050
'six',
5151
'decorator',
52-
'mir_eval>0.7',
52+
'mir_eval>=0.8.2'
5353
],
5454
extras_require={
5555
'display': ['matplotlib>=1.5.0'],

tests/test_jams.py

+10-14
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@
1717
import jams
1818

1919

20-
parametrize = pytest.mark.parametrize
21-
2220

2321
# Borrowed from sklearn
2422
def clean_warning_registry():
@@ -73,8 +71,8 @@ def test_jobject_deserialize():
7371
assert J == jams.JObject.loads(json_jobject)
7472

7573

76-
@parametrize('d1', [dict(key1='value 1', key2='value 2')])
77-
@parametrize('d2, match',
74+
@pytest.mark.parametrize('d1', [dict(key1='value 1', key2='value 2')])
75+
@pytest.mark.parametrize('d2, match',
7876
[(dict(key1='value 1', key2='value 2'), True),
7977
(dict(key1='value 1', key2='value 3'), False)])
8078
def test_jobject_eq(d1, d2, match):
@@ -94,7 +92,7 @@ def test_jobject_eq(d1, d2, match):
9492
assert not J1 == J3
9593

9694

97-
@parametrize('data, value', [({'key': True}, True), ({}, False)])
95+
@pytest.mark.parametrize('data, value', [({'key': True}, True), ({}, False)])
9896
def test_jobject_nonzero(data, value):
9997

10098
J = jams.JObject(**data)
@@ -155,9 +153,9 @@ def ann_meta_dummy():
155153
data_source='null')
156154

157155

158-
@parametrize('curator', [None, jams.Curator(name='nobody',
156+
@pytest.mark.parametrize('curator', [None, jams.Curator(name='nobody',
159157
email='[email protected]')])
160-
@parametrize('annotator', [None, jams.Sandbox(description='desc')])
158+
@pytest.mark.parametrize('annotator', [None, jams.Sandbox(description='desc')])
161159
def test_annotation_metadata(ann_meta_dummy, curator, annotator):
162160

163161
md = jams.AnnotationMetadata(curator=curator, annotator=annotator,
@@ -192,7 +190,7 @@ def ann_metadata():
192190
return jams.AnnotationMetadata(corpus='test collection')
193191

194192

195-
@parametrize('namespace', ['tag_open'])
193+
@pytest.mark.parametrize('namespace', ['tag_open'])
196194
def test_annotation(namespace, tag_data, ann_metadata, ann_sandbox):
197195
ann = jams.Annotation(namespace, data=tag_data,
198196
annotation_metadata=ann_metadata,
@@ -482,7 +480,7 @@ def test_jams_add(tag_data):
482480
assert jam.annotations[-1] == jam2.annotations[0]
483481

484482

485-
@parametrize('on_conflict',
483+
@pytest.mark.parametrize('on_conflict',
486484
['overwrite', 'ignore'])
487485
def test_jams_add_conflict(on_conflict):
488486
fn = 'tests/fixtures/valid.jams'
@@ -504,7 +502,7 @@ def test_jams_add_conflict(on_conflict):
504502
assert jam.file_metadata == jam_orig.file_metadata
505503

506504

507-
@parametrize('on_conflict,exception', [
505+
@pytest.mark.parametrize('on_conflict,exception', [
508506
('fail', jams.JamsError),
509507
('bad_fail_mdoe', jams.ParameterError)
510508
])
@@ -525,7 +523,8 @@ def test_jams_add_conflict_exceptions(on_conflict, exception):
525523
jam = jams.load('tests/fixtures/valid.jams', validate=False)
526524
jam.annotations[0].sandbox.foo = None
527525

528-
@parametrize('query, expected',
526+
527+
@pytest.mark.parametrize('query, expected',
529528
[(dict(corpus='SMC_MIREX'), jam.annotations),
530529
(dict(), []),
531530
(dict(namespace='beat'), jam.annotations[:1]),
@@ -535,8 +534,6 @@ def test_jams_add_conflict_exceptions(on_conflict, exception):
535534
def test_jams_search(query, expected):
536535
result = jam.search(**query)
537536

538-
assert result == expected
539-
540537

541538
def test_jams_validate_good():
542539

@@ -1266,4 +1263,3 @@ def test_annotation_to_samples_fail_shape():
12661263

12671264
with pytest.raises(jams.ParameterError):
12681265
values = ann.to_samples([[0.2, 0.4, 0.75, 1.25, 1.75, 1.4]])
1269-

tests/test_schema.py

+2-6
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,12 @@
1313

1414
@pytest.mark.parametrize('ns_key', ['pitch_hz', 'beat'])
1515
def test_schema_namespace(ns_key):
16-
1716
# Get the schema
1817
schema = jams.schema.namespace(ns_key)
19-
2018
# Make sure it has the correct properties
2119
valid_keys = set(['time', 'duration', 'value', 'confidence'])
2220
for key in schema['properties']:
2321
assert key in valid_keys
24-
2522
for key in ['time', 'duration']:
2623
assert key in schema['properties']
2724

@@ -31,9 +28,8 @@ def test_schema_namespace_exception(ns_key):
3128
jams.schema.namespace(ns_key)
3229

3330

34-
@pytest.mark.parametrize('ns, dense',
35-
[('pitch_hz', True),
36-
('beat', False)])
31+
32+
@pytest.mark.parametrize('ns, dense', [('pitch_hz', True), ('beat', False)])
3733
def test_schema_is_dense(ns, dense):
3834
assert dense == jams.schema.is_dense(ns)
3935

0 commit comments

Comments
 (0)