Skip to content

Commit a772f46

Browse files
committed
Fix many TODOs
1 parent 1c4eb73 commit a772f46

12 files changed

+39
-14
lines changed

README.md

+3
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ https://github.com/DIDONEproject/music_symbolic_features
3535

3636
## Changelog
3737

38+
#### v1.1.6
39+
* fix bug on previoous release and add jsimbollic remove repetitions
40+
3841
#### v1.1.5
3942
* fix minor bug that caused very unnecesary large memory usage
4043

config_postprocess_example.yml

-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ separate_intrumentation_column: False
4040
instruments_to_keep: []
4141
# Possible values are from abbreviations from musif.musicxml.constants.SOUND_TO_ABBREVIATION
4242
# Note that if an abbreviation is not available, the full instrument name is used
43-
# TODO: why these instrument names are not capitalized?
4443
# Example:
4544
# - vnI
4645
# - bs

docs/source/Configuration.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,4 +52,4 @@ def update_part_objects(
5252

5353
Also, have a look the [Configuration API page](./API/musif.config.html) to understand how
5454
the `Configuration` class works. You can subclass it for advanced handling of
55-
configurations; see, for instance, the [Didone feature project](//TODO).
55+
configurations; see, for instance, the [Didone feature project](./Custom_Configuration.html).

docs/source/Custom_Configuration.md

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Custom Configuration for DIDONE PROJECT
2+
Here we present an example of using ExtracConfiguration class by subclassing it to create our own CustomConf class following specific needs.
3+
4+
In DIDONE project's case, It was needed to load many *.csv files contatining metadata information and include this inofrmation into the DataFrame that musif extracts. This metadata information loaded in our Custom conf, was later used by our custom modules to include it in the final DataFrame. Check how we inherit parent class 'ExtractConfiguration' and add some customized methods:
5+
6+
## Code
7+
from glob import glob
8+
from os import path
9+
10+
from musif.common._utils import read_dicts_from_csv
11+
from musif.config import ExtractConfiguration
12+
13+
14+
class CustomConf(ExtractConfiguration):
15+
def __init__(self, *args, **kwargs):
16+
super().__init__(*args, **kwargs)
17+
self._load_metadata()
18+
19+
def _load_metadata(self) -> None:
20+
self.scores_metadata = {
21+
path.basename(file): read_dicts_from_csv(file)
22+
for file in glob(path.join(self.metadata_dir, "score", "*.csv"))
23+
}
24+
if not self.scores_metadata:
25+
print(
26+
"\nMetadata could not be loaded properly!! Check metadata path in config file.\n"
27+
)
28+
self.characters_gender = read_dicts_from_csv(
29+
path.join(self.internal_data_dir, "characters_gender.csv")
30+
)

docs/source/index.md

+1
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,4 @@ repo](https://github.com/DIDONEproject/musif/).
5050
<a href="https://www.uc3m.es" target="_blank"><img src="./_static/imgs/uc3m.png" alt="Logo UC3M" align="middle"></a>
5151
<a href="https://erc.europa.eu/" target="_blank"><img src="./_static/imgs/erc.jpg" alt="Logo DIDONE ERC" align="middle"></a>
5252
</p>
53+
<link rel="icon" type="image/png" href="./_static/imgs/logo.png" alt="Logo DIDONE"/>

musif/config.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from musif.common._utils import read_object_from_yaml_file
55
from musif.extract.constants import REQUIRE_MSCORE
66

7-
# TODO: add documentation for these variables
7+
"""Check config_extraction_example.yml file for the purpose of these variables, if needed."""
88
LOGGER_NAME = "musif"
99
LOG = "log"
1010
LOG_FILE_PATH = "log_file"

musif/extract/constants.py

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
HARMONY_FEATURES = "harmony"
1818
SCALE_RELATIVE_FEATURES = "scale_relative"
1919
REQUIRE_MSCORE = [HARMONY_FEATURES, SCALE_RELATIVE_FEATURES]
20+
2021
"""Names of modules taht require harmonic analysis in a .mscx file"""
2122

2223
VOICES_LIST = ["sop", "ten", "alt", "bar", "bbar", "bass"]

musif/extract/features/core/handler.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,7 @@ def update_score_objects(
8888
score_key = key.Key(tonality_ms3)
8989
mode, key_name = get_name_from_key(score_key)
9090

91-
# score_features[FILE_NAME] = path.abspath(score_data[DATA_FILE])
92-
score_features[FILE_NAME] = path.basename(score_data[DATA_FILE]) # TODO: KMore like this maybe???
91+
score_features[FILE_NAME] = path.basename(score_data[DATA_FILE])
9392
num_measures = len(score.parts[0].getElementsByClass(Measure))
9493
key_signature = _get_key_signature(score_key)
9594

musif/extract/features/density/handler.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,11 @@ def update_part_objects(
5555

5656
time_signatures = part_data[TIME_SIGNATURES]
5757

58-
## TODO: cuando haya repeticiones, revisar esto. Lo hice por un error en la numeracion cuando hay 70x1 (celdillas)
5958
sounding_time_signatures = [time_signatures[i] for i in sounding_measures]
6059

6160
part_features.update(
6261
{
63-
SOUNDING_DENSITY: len(notes)
64-
/ _calculate_total_number_of_beats(sounding_time_signatures)
62+
SOUNDING_DENSITY: len(notes) / _calculate_total_number_of_beats(sounding_time_signatures)
6563
if len(sounding_time_signatures) > 0
6664
else 0,
6765
DENSITY: len(notes)

musif/extract/features/jsymbolic/handler.py

-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@ def update_score_objects(
4141
# 1. create a temporary directory (if Linux, force RAM usig /dev/shm)
4242
with get_tmpdir() as tmpdirname:
4343
# 2. convert the score to MEI usiing music21
44-
# TODO: if music21 implements export to MEI, use it
4544
midi_path = os.path.abspath(os.path.join(tmpdirname, "score.midi"))
4645
if cfg.jsymbolic_remove_repeats:
4746
score_without_repeats, _ = _remove_repetitions_from_score(score)

musif/musicxml/common.py

-1
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,6 @@ def _get_degrees_and_accidentals(key: str, notes: List[Note]) -> List[Tuple[str,
197197

198198

199199
def _get_intervals(notes: List[Note]) -> List[Interval]:
200-
# TODO: this takes > 6% of the time
201200
return [
202201
Interval(notes[i].pitches[0], notes[i + 1].pitches[0])
203202
for i in range(len(notes) - 1)

musif/musicxml/repeat.py

-4
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111

1212
from musif.logs import ldebug
1313

14-
# TODO: document this module
15-
1614

1715
def measure_ranges(
1816
instrument_measures,
@@ -83,7 +81,6 @@ def measure_ranges(
8381
return measures
8482

8583

86-
# TODO: This function is too long
8784
def expand_repeat_bars(score):
8885
final_score = Score()
8986
final_score.metadata = score.metadata
@@ -254,7 +251,6 @@ def expand_score_repetitions(score, repeat_elements):
254251
return final_score
255252

256253

257-
# TODO: this function seems alittle long as well
258254
def get_expanded_measures(part_measures, repeat_elements):
259255
repeat_bracket = (
260256
sum([1 if "repeat bracket" in item[1] else 0 for item in repeat_elements]) > 0

0 commit comments

Comments
 (0)