Skip to content

Commit

Permalink
Revert "add length test for points in p types hidden"
Browse files Browse the repository at this point in the history
This reverts commit 00d818e.
  • Loading branch information
RichardFreedman committed Aug 3, 2023
1 parent 00d818e commit a019b4d
Showing 1 changed file with 54 additions and 56 deletions.
110 changes: 54 additions & 56 deletions intervals/main_objs.py
Original file line number Diff line number Diff line change
Expand Up @@ -2909,8 +2909,7 @@ def presentationTypes(self, melodic_ngram_length=4, limit_to_entries=True,
# df = df.reset_index()
temp = self._temp_dict_of_details(df, det, matches)
points = points.append(temp, ignore_index=True)
if len(points) >= 1:
points['Presentation_Type'] = points['Time_Entry_Intervals'].apply(ImportedPiece._classify_by_offset)
points['Presentation_Type'] = points['Time_Entry_Intervals'].apply(ImportedPiece._classify_by_offset)
# points.drop_duplicates(subset=["First_Offset"], keep='first', inplace = True)
# points = points[points['Offsets'].apply(len) > 1]
# this return is just for testing
Expand All @@ -2934,14 +2933,14 @@ def presentationTypes(self, melodic_ngram_length=4, limit_to_entries=True,
points2 = points2.append(temp, ignore_index=True)

points_combined = points.append(points2, ignore_index=True)
points_combined["Offsets_Key"] = points_combined["Offsets"].apply(self._offset_joiner)
points_combined['Flexed_Entries'] = points_combined["Soggetti"].apply(len) > 1
points_combined["Number_Entries"] = points_combined["Offsets"].apply(len)
points_combined["Count_Offsets"] = points_combined["Offsets"].apply(set).apply(len)
points_combined = points_combined[points_combined["Count_Offsets"] > 1]
if len(points_combined) == 0:
print("No Presentation Types Found in " + self.metadata['composer'] + ":" + self.metadata['title'])
else:
points_combined["Offsets_Key"] = points_combined["Offsets"].apply(self._offset_joiner)
points_combined['Flexed_Entries'] = points_combined["Soggetti"].apply(len) > 1
points_combined["Number_Entries"] = points_combined["Offsets"].apply(len)
points_combined["Count_Offsets"] = points_combined["Offsets"].apply(set).apply(len)
points_combined = points_combined[points_combined["Count_Offsets"] > 1]
# points_combined = points_combined.sort_values("First_Offset").reset_index(drop=True)
points_combined = points_combined.reindex(columns=col_order).sort_values("First_Offset").reset_index(drop=True)
points_combined.drop_duplicates(subset=["Offsets_Key"], keep='first', inplace=True)
Expand All @@ -2953,56 +2952,55 @@ def presentationTypes(self, melodic_ngram_length=4, limit_to_entries=True,
points_combined.drop(['Count_Offsets', 'Offsets_Key', 'Entry_Durs', 'Overlaps'], axis=1, inplace=True)
points_combined["Progress"] = (points_combined["First_Offset"] / self.notes().index[-1])
# NIM test. Here we check for interlocking fugas that are really nims:
if len(points_combined) >= 1:
fugas = points_combined[points_combined["Presentation_Type"] == 'FUGA']
fuga_index_list = fugas.index.tolist()
temporary_nim_list = []
for this_item in fuga_index_list:
if fuga_index_list.index(this_item) != len(fuga_index_list)- 1:
next_item_index = fuga_index_list.index(this_item) + 1
next_item = fuga_index_list[next_item_index]
# check time entry intervals of the two fugas match
if fugas.loc[this_item]['Time_Entry_Intervals'] == fugas.loc[next_item]['Time_Entry_Intervals']:
# check if the first offsets interlock
if fugas.loc[this_item]['Offsets'][0] <= fugas.loc[next_item]['Offsets'][0]:
# get data for melodic intervals between the NIMS
voices_for_melodic_ints = fugas.loc[this_item]['Voices']
offsets_for_melodic_ints = fugas.loc[this_item]['Offsets']
coordinates = list(zip(offsets_for_melodic_ints, voices_for_melodic_ints))
melodic_intervals_between_nims = self._find_entry_int_distance(coordinates)
temp_nim_details = {"Composer": fugas.loc[this_item]['Composer'],
"Title": fugas.loc[this_item]['Title'],
'First_Offset': fugas.loc[this_item]['First_Offset'],
# here we need to combine and sort lists of offsets
'Offsets': sorted(fugas.loc[this_item]['Offsets'] + fugas.loc[next_item]['Offsets']),
# here we need to combine and sort lists of meas and beats
'Measures_Beats': sorted(fugas.loc[this_item]['Measures_Beats'] + fugas.loc[next_item]['Measures_Beats']),
# here we need to combine and sort lists of soggette
"Soggetti": [val for pair in zip(fugas.loc[this_item]['Soggetti'], fugas.loc[next_item]['Soggetti']) for val in pair],
# here we need to combine and sort lists of voices
'Voices': [val for pair in zip(fugas.loc[this_item]['Voices'], fugas.loc[next_item]['Voices']) for val in pair],
'Time_Entry_Intervals': fugas.loc[this_item]['Time_Entry_Intervals'],
'Melodic_Entry_Intervals': melodic_intervals_between_nims,
'Number_Entries': fugas.loc[this_item]['Number_Entries'] + fugas.loc[next_item]['Number_Entries'],
'Presentation_Type' : 'NIM',
'Flexed_Entries': True if fugas.loc[this_item]['Flexed_Entries'] == True | fugas.loc[next_item]['Flexed_Entries'] == True else False,
'Parallel_Entries': True if fugas.loc[this_item]['Parallel_Entries'] == True | fugas.loc[next_item]['Parallel_Entries'] == True else False,
'Parallel_Voice': self._parallel_voice_check(fugas.loc[this_item]['Parallel_Voice'], fugas.loc[next_item]['Parallel_Voice']),
'Count_Non_Overlaps': fugas.loc[this_item]['Count_Non_Overlaps'] + fugas.loc[next_item]['Count_Non_Overlaps'],
'Progress' : fugas.loc[this_item]['Progress']
}
temporary_nim_list.append(temp_nim_details)
points_combined = points_combined.drop(this_item)
points_combined = points_combined.drop(next_item)

for nim in temporary_nim_list:
points_combined = points_combined.append(nim, ignore_index=True)
if len(points_combined) == 0:
print("No Presentation Types Found in " + self.metadata['composer'] + ":" + self.metadata['title'])
else:
points_combined = points_combined.sort_values("Progress")
points_combined = points_combined.reset_index(drop=True)
fugas = points_combined[points_combined["Presentation_Type"] == 'FUGA']
fuga_index_list = fugas.index.tolist()
temporary_nim_list = []
for this_item in fuga_index_list:
if fuga_index_list.index(this_item) != len(fuga_index_list)- 1:
next_item_index = fuga_index_list.index(this_item) + 1
next_item = fuga_index_list[next_item_index]
# check time entry intervals of the two fugas match
if fugas.loc[this_item]['Time_Entry_Intervals'] == fugas.loc[next_item]['Time_Entry_Intervals']:
# check if the first offsets interlock
if fugas.loc[this_item]['Offsets'][0] <= fugas.loc[next_item]['Offsets'][0]:
# get data for melodic intervals between the NIMS
voices_for_melodic_ints = fugas.loc[this_item]['Voices']
offsets_for_melodic_ints = fugas.loc[this_item]['Offsets']
coordinates = list(zip(offsets_for_melodic_ints, voices_for_melodic_ints))
melodic_intervals_between_nims = self._find_entry_int_distance(coordinates)
temp_nim_details = {"Composer": fugas.loc[this_item]['Composer'],
"Title": fugas.loc[this_item]['Title'],
'First_Offset': fugas.loc[this_item]['First_Offset'],
# here we need to combine and sort lists of offsets
'Offsets': sorted(fugas.loc[this_item]['Offsets'] + fugas.loc[next_item]['Offsets']),
# here we need to combine and sort lists of meas and beats
'Measures_Beats': sorted(fugas.loc[this_item]['Measures_Beats'] + fugas.loc[next_item]['Measures_Beats']),
# here we need to combine and sort lists of soggette
"Soggetti": [val for pair in zip(fugas.loc[this_item]['Soggetti'], fugas.loc[next_item]['Soggetti']) for val in pair],
# here we need to combine and sort lists of voices
'Voices': [val for pair in zip(fugas.loc[this_item]['Voices'], fugas.loc[next_item]['Voices']) for val in pair],
'Time_Entry_Intervals': fugas.loc[this_item]['Time_Entry_Intervals'],
'Melodic_Entry_Intervals': melodic_intervals_between_nims,
'Number_Entries': fugas.loc[this_item]['Number_Entries'] + fugas.loc[next_item]['Number_Entries'],
'Presentation_Type' : 'NIM',
'Flexed_Entries': True if fugas.loc[this_item]['Flexed_Entries'] == True | fugas.loc[next_item]['Flexed_Entries'] == True else False,
'Parallel_Entries': True if fugas.loc[this_item]['Parallel_Entries'] == True | fugas.loc[next_item]['Parallel_Entries'] == True else False,
'Parallel_Voice': self._parallel_voice_check(fugas.loc[this_item]['Parallel_Voice'], fugas.loc[next_item]['Parallel_Voice']),
'Count_Non_Overlaps': fugas.loc[this_item]['Count_Non_Overlaps'] + fugas.loc[next_item]['Count_Non_Overlaps'],
'Progress' : fugas.loc[this_item]['Progress']
}
temporary_nim_list.append(temp_nim_details)
points_combined = points_combined.drop(this_item)
points_combined = points_combined.drop(next_item)

for nim in temporary_nim_list:
points_combined = points_combined.append(nim, ignore_index=True)
if len(points_combined) == 0:
print("No Presentation Types Found in " + self.metadata['composer'] + ":" + self.metadata['title'])
else:
points_combined = points_combined.sort_values("Progress")
points_combined = points_combined.reset_index(drop=True)

self.analyses[memo_key] = points_combined
return points_combined

Expand Down

0 comments on commit a019b4d

Please sign in to comment.