-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUGFIX] Remove counts when showing a sample #9638
Merged
anthonyburdi
merged 13 commits into
develop
from
b/zel-559/dont-show-counts-if-not-accurate-v1
Mar 22, 2024
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
107cf9e
WIP Prototype
anthonyburdi 59a738a
Refactor
anthonyburdi 7027c35
Update tests
anthonyburdi faf977d
mypy
anthonyburdi b985c29
mypy
anthonyburdi 945ed15
Update fixture
anthonyburdi 2453b73
Update fixture
anthonyburdi 029f0c9
Update fixture
anthonyburdi 0e75dff
Merge branch 'develop' into b/zel-559/dont-show-counts-if-not-accurat…
anthonyburdi 70cd0ee
Refactor
anthonyburdi 43754d0
Merge remote-tracking branch 'origin/b/zel-559/dont-show-counts-if-no…
anthonyburdi 271e72e
Line length
anthonyburdi acfaa1b
Fix fixture
anthonyburdi File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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 |
---|---|---|
|
@@ -241,6 +241,37 @@ def handle_strict_min_max(params: dict) -> tuple[str, str]: | |
return at_least_str, at_most_str | ||
|
||
|
||
def _get_value_to_render(value_: Any) -> Any: | ||
if value_ is not None and value_ != "": | ||
return value_ | ||
if value_ == "": | ||
return "EMPTY" | ||
return "null" | ||
|
||
|
||
def _get_header_row(all_unexpected_in_samples: bool) -> list[str]: | ||
# Check to see if we have *all* of the unexpected values accounted for. If so, | ||
# we show counts. If not then we show Sampled Unexpected Values only. | ||
if all_unexpected_in_samples: | ||
header_row = ["Unexpected Value", "Count"] | ||
else: | ||
header_row = ["Sampled Unexpected Values"] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We also remove "Count" from the header (otherwise an empty column would render). |
||
return header_row | ||
|
||
|
||
def _are_all_unexpected_values_in_samples( | ||
partial_unexpected_counts: list[dict], unexpected_count: int | ||
) -> bool: | ||
total_count: int = 0 | ||
|
||
for unexpected_count_dict in partial_unexpected_counts: | ||
count: int | None = unexpected_count_dict.get("count") | ||
if count: | ||
total_count += count | ||
|
||
return total_count == unexpected_count | ||
|
||
|
||
def build_count_table( | ||
partial_unexpected_counts: list[dict], unexpected_count: int | ||
) -> tuple[list[str], list[list[Any]]]: | ||
|
@@ -257,26 +288,21 @@ def build_count_table( | |
|
||
""" | ||
table_rows: list[list[str | int | None]] = [] | ||
total_count: int = 0 | ||
all_unexpected_in_samples: bool = _are_all_unexpected_values_in_samples( | ||
partial_unexpected_counts, unexpected_count | ||
) | ||
|
||
for unexpected_count_dict in partial_unexpected_counts: | ||
value: Any | None = unexpected_count_dict.get("value") | ||
count: int | None = unexpected_count_dict.get("count") | ||
if count: | ||
total_count += count | ||
if value is not None and value != "": | ||
value = _get_value_to_render(unexpected_count_dict.get("value")) | ||
count = unexpected_count_dict.get("count") | ||
if all_unexpected_in_samples: | ||
table_rows.append([value, count]) | ||
elif value == "": | ||
table_rows.append(["EMPTY", count]) | ||
else: | ||
table_rows.append(["null", count]) | ||
# Since accurate counts for the full dataset are not available, | ||
# we show Sampled Unexpected Values only. | ||
table_rows.append([value]) | ||
|
||
# Check to see if we have *all* of the unexpected values accounted for. If so, | ||
# we show counts. If not then we show Sampled Unexpected Values | ||
if total_count == unexpected_count: | ||
header_row = ["Unexpected Value", "Count"] | ||
else: | ||
header_row = ["Sampled Unexpected Values", "Count"] | ||
header_row = _get_header_row(all_unexpected_in_samples) | ||
return header_row, table_rows | ||
|
||
|
||
|
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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
❤️