Skip to content

score.py - ValueError: math domain error #5

@kjcole

Description

@kjcole

I was revisiting code that I don't recall giving this error before. I recently updated to SCAMP version 0.8.9.5.

You may recall helping me with a pseudo-Celtic random song generator. That's what's crapping out. It plays the tune, but upon finishing it yields the following when trying to generate the score:

Traceback (most recent call last):
  File "./celtic.py", line 99, in <module>
    main()
  File "./celtic.py", line 93, in main
    performance.to_score(title="Beating the Cat",
  File "/home/kjcole/.local/lib/python3.8/site-packages/scamp/performance.py", line 1094, in to_score
    return Score.from_performance(
  File "/home/kjcole/.local/lib/python3.8/site-packages/scamp/score.py", line 934, in from_performance
    return Score.from_quantized_performance(
  File "/home/kjcole/.local/lib/python3.8/site-packages/scamp/score.py", line 956, in from_quantized_performance
    staff_group = StaffGroup.from_quantized_performance_part(part)
  File "/home/kjcole/.local/lib/python3.8/site-packages/scamp/score.py", line 1344, in from_quantized_performance_part
    return StaffGroup._from_measure_voice_grid(
  File "/home/kjcole/.local/lib/python3.8/site-packages/scamp/score.py", line 1559, in _from_measure_voice_grid
    [
  File "/home/kjcole/.local/lib/python3.8/site-packages/scamp/score.py", line 1560, in <listcomp>
    Staff._from_measure_bins_of_voice_lists(
  File "/home/kjcole/.local/lib/python3.8/site-packages/scamp/score.py", line 1654, in _from_measure_bins_of_voice_lists
    return cls([Measure.from_list_of_performance_voices(measure_content, time_signature, show_time_signature)
  File "/home/kjcole/.local/lib/python3.8/site-packages/scamp/score.py", line 1654, in <listcomp>
    return cls([Measure.from_list_of_performance_voices(measure_content, time_signature, show_time_signature)
  File "/home/kjcole/.local/lib/python3.8/site-packages/scamp/score.py", line 1762, in from_list_of_performance_voices
    voices.append(Voice.from_performance_voice(*voice_content))
  File "/home/kjcole/.local/lib/python3.8/site-packages/scamp/score.py", line 1926, in from_performance_voice
    processed_contents = Voice._recombine_processed_beats(processed_beats, measure_quantization)
  File "/home/kjcole/.local/lib/python3.8/site-packages/scamp/score.py", line 2163, in _recombine_processed_beats
    recombined_division_points = Voice._try_all_sub_recombinations(
  File "/home/kjcole/.local/lib/python3.8/site-packages/scamp/score.py", line 2185, in _try_all_sub_recombinations
    recombo, _ = _get_best_recombination_given_beat_hierarchy(
  File "/home/kjcole/.local/lib/python3.8/site-packages/scamp/score.py", line 216, in _get_best_recombination_given_beat_hierarchy
    best_subgroup_option, best_subgroup_score = _get_best_subgroup_recombination_option(
  File "/home/kjcole/.local/lib/python3.8/site-packages/scamp/score.py", line 242, in _get_best_subgroup_recombination_option
    assert all(_is_single_note_viable_grouping(x, max_dots=engraving_settings.max_dots_allowed)
  File "/home/kjcole/.local/lib/python3.8/site-packages/scamp/score.py", line 242, in <genexpr>
    assert all(_is_single_note_viable_grouping(x, max_dots=engraving_settings.max_dots_allowed)
  File "/home/kjcole/.local/lib/python3.8/site-packages/scamp/score.py", line 175, in _is_single_note_viable_grouping
    if Fraction(math.log2(length_in_subdivisions / dot_multiplier)).limit_denominator().denominator == 1:
ValueError: math domain error

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions