-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #35 from smart-on-fhir/mikix/accuracy-ranges
feat: add chart range output to `accuracy`
- Loading branch information
Showing
10 changed files
with
105 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
/.idea/ | ||
/dist/ | ||
/site/ | ||
__pycache__/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
"""Helper methods for printing to the console.""" | ||
|
||
|
||
def pretty_note_range(notes: set[int]) -> str: | ||
""" | ||
Returns a pretty, human-readable string for a set of notes. | ||
If no notes, this returns an empty string. | ||
Example: | ||
pretty_note_range({1, 2, 3, 7, 9, 10}) | ||
-> "1–3, 7, 9–10" | ||
""" | ||
ranges = [] | ||
range_start = None | ||
prev_note = None | ||
|
||
def end_range() -> None: | ||
if prev_note is None: | ||
return | ||
if range_start == prev_note: | ||
ranges.append(str(prev_note)) | ||
else: | ||
ranges.append(f"{range_start}–{prev_note}") # en dash | ||
|
||
for note in sorted(notes): | ||
if prev_note is None or prev_note + 1 != note: | ||
end_range() | ||
range_start = note | ||
prev_note = note | ||
|
||
end_range() | ||
|
||
return ", ".join(ranges) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters