-
Notifications
You must be signed in to change notification settings - Fork 321
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
Change filter_blank_rows when_any parameter to have a more user-friendly type #7935
Merged
mergify
merged 15 commits into
develop
from
7931-change-filter_blank_rows-when_any-parameter-to-have-a-more-user-friendly-type
Nov 1, 2023
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
7d4d3a6
Added Blank_Selector constructor
Cassandra-Clark ed0c96f
Update CHANGELOG.md
Cassandra-Clark a422e35
Update distribution/lib/Standard/Table/0.0.0-dev/src/Data/Blank_Selec…
Cassandra-Clark 5fc95a0
Update CHANGELOG.md
Cassandra-Clark 1e4d688
Corrected Table and Table_Helpers
Cassandra-Clark bf75072
Updated docs and fixed some missing changes for blank_selector
Cassandra-Clark 6bff47d
Fixed comment formatting
Cassandra-Clark b1e543b
Added Blank_Selector constructor
Cassandra-Clark f7fa690
Update CHANGELOG.md
Cassandra-Clark e415a95
Update Table.enso
Cassandra-Clark 7171d7f
Updated godegen_spec and table_spec tests
Cassandra-Clark 5da1361
replaced when_any with updated when parameter
Cassandra-Clark f3e93c1
Final correction for when_any to when in Codegen_Spec
Cassandra-Clark 885564e
fix CHANGELOG
hubertp 514ae3e
one more revert
hubertp File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
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
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
6 changes: 6 additions & 0 deletions
6
distribution/lib/Standard/Table/0.0.0-dev/src/Data/Blank_Selector.enso
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,6 @@ | ||
## TODO Documents | ||
type Blank_Selector | ||
## Blank_Selector is used as a constructor for other functions. | ||
Any_Cell_Blank | ||
|
||
All_Cells_Blank | ||
Cassandra-Clark marked this conversation as resolved.
Show resolved
Hide resolved
|
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 |
---|---|---|
|
@@ -3,6 +3,7 @@ import Standard.Base.Errors.Illegal_Argument.Illegal_Argument | |
import Standard.Base.Errors.Illegal_State.Illegal_State | ||
|
||
import project.Data.Aggregate_Column.Aggregate_Column | ||
import project.Data.Blank_Selector.Blank_Selector | ||
import project.Data.Column.Column | ||
import project.Data.Position.Position | ||
import project.Data.Set_Mode.Set_Mode | ||
|
@@ -196,14 +197,15 @@ type Table_Column_Helper | |
completely blank or have some blanks. | ||
|
||
Arguments: | ||
- when_any: By default, only columns consisting of all blank cells are | ||
selected. If set to `True`, columns with one or more blank values are | ||
-TODO docs | ||
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. The |
||
- when: By default, only columns consisting of all blank cells are | ||
selected. If set to Blank_Selector.Any_Cell_Blank, columns with one or more blank values are | ||
selected. | ||
- treat_nans_as_blank: If `True`, then `Number.nan` is considered as | ||
blank. | ||
- invert_selection: If `True`, then the selection is inverted. | ||
select_blank_columns_helper : Boolean -> Boolean -> Boolean -> Vector | ||
select_blank_columns_helper self when_any:Boolean treat_nans_as_blank:Boolean invert_selection:Boolean=False = | ||
select_blank_columns_helper : Blank_Selector -> Boolean -> Boolean -> Vector | ||
select_blank_columns_helper self (when:Blank_Selector = Blank_Selector.All_Cells_Blank) treat_nans_as_blank:Boolean invert_selection:Boolean=False = | ||
Cassandra-Clark marked this conversation as resolved.
Show resolved
Hide resolved
|
||
blanks = self.internal_columns.map_with_index ix-> internal_column-> | ||
column = self.make_column internal_column | ||
blank_indicator = column.is_blank treat_nans_as_blank | ||
|
@@ -222,7 +224,9 @@ type Table_Column_Helper | |
just_indicators = table_with_blank_indicators.select_columns (blanks.map .name) on_problems=Problem_Behavior.Report_Error | ||
|
||
# Maximum is equivalent to Exists and Minimum is equivalent to Forall. | ||
col_aggregate = if when_any then Aggregate_Column.Maximum _ else Aggregate_Column.Minimum _ | ||
col_aggregate = case when of | ||
Blank_Selector.Any_Cell_Blank -> Aggregate_Column.Maximum _ | ||
Blank_Selector.All_Cells_Blank -> Aggregate_Column.Minimum _ | ||
aggregates = blanks.map blanks_col-> col_aggregate blanks_col.name | ||
|
||
aggregate_result = just_indicators.aggregate aggregates on_problems=Problem_Behavior.Report_Error | ||
|
@@ -440,14 +444,15 @@ resolve_order_by internal_columns column_selectors problem_builder = | |
## PRIVATE | ||
A helper method gathering the common logic for constructing expressions that | ||
can filter out blank rows. | ||
filter_blank_rows : Table -> Boolean -> Boolean -> Table | ||
filter_blank_rows table when_any treat_nans_as_blank = | ||
filter_blank_rows : Table -> Blank_Selector -> Boolean -> Table | ||
filter_blank_rows table when treat_nans_as_blank = | ||
cols = table.columns | ||
case cols.not_empty of | ||
True -> | ||
merge = if when_any then (||) else (&&) | ||
missing_mask = cols.map (_.is_blank treat_nans_as_blank) . reduce col1-> col2-> | ||
merge col1 col2 . rename "blank_indicator" | ||
merge = case when of | ||
Blank_Selector.Any_Cell_Blank -> (||) | ||
Blank_Selector.All_Cells_Blank -> (&&) | ||
missing_mask = cols.map (_.is_blank treat_nans_as_blank) . reduce merge | ||
non_missing_mask = missing_mask.not | ||
table.filter non_missing_mask Filter_Condition.Is_True | ||
False -> table | ||
|
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.
I think we should add a piece of docs here.