Skip to content

Commit

Permalink
feat: Add better docstring
Browse files Browse the repository at this point in the history
  • Loading branch information
antscloud committed Jan 23, 2024
1 parent d00afeb commit 3890c53
Showing 1 changed file with 31 additions and 12 deletions.
43 changes: 31 additions & 12 deletions fretboardgtr/fretboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,20 +286,28 @@ def add_notes(self, scale: NotesContainer) -> None:
self.add_note(string_no, note, scale.root)

def add_fingering(
self,
fingering: List[Optional[int]],
root: Optional[str] = None,
self, fingering: List[Optional[int]], root: Optional[str] = None
) -> None:
"""Add fingering starting with upper string to lower string.
This function automatically calculate the note names or
intervals if the root is given Display them in the way described
in configuration
Parameters
----------
fingering : List[Optional[int]]
List of finger positions for each string.
root : Optional[str], optional
The root note to use for calculating note names or intervals,
by default None.
Raises
------
ValueError
If the size of the fingering list is not the same as the size of
the tuning list.
"""
if len(fingering) != len(self.tuning):
raise ValueError(
f"Fingering has not the same size as tuning."
f" Got {len(fingering)} expected {len(self.tuning)}"
f"Fingering size does not match tuning size. Got {len(fingering)}"
f", expected {len(self.tuning)}"
)
for string_no, finger_position in enumerate(
self.fretboard.get_list_in_good_order(fingering)
Expand All @@ -312,11 +320,22 @@ def add_scale(
root: Optional[str] = None,
repeat_over_fretboard: bool = False,
) -> None:
"""Add scale starting with upper string to lower string.
"""Add scale to the fretboard.
Parameters
----------
scale : List[List[Optional[int]]]
The scale to be added.
root : Optional[str], optional
The root note of the scale, by default None.
repeat_over_fretboard : bool, optional
Whether to repeat the scale over the entire fretboard,
by default False.
This function automatically calculate the note names or
intervals if the root is given Display them in the way described
in configuration
Raises
------
ValueError
If the scale has a different size than the tuning.
"""
if len(scale) != len(self.tuning):
raise ValueError(
Expand Down

0 comments on commit 3890c53

Please sign in to comment.