Skip to content
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

Improve Column Renaming for Selected Columns #9282

Merged

Conversation

N-thony
Copy link
Collaborator

@N-thony N-thony commented Nov 27, 2024

Fixes partially #9265
@rdstern this PR tempts to fix the issue when renaming selected columns. It completes issue #9265. Have a look

@rdstern
Copy link
Collaborator

rdstern commented Nov 27, 2024

@N-thony I can't see what has changed here. Can you add more details.

@N-thony
Copy link
Collaborator Author

N-thony commented Nov 27, 2024

@rdstern, do column selection first and try to rename column from the current column selection with any option from the Rename dialogue

@N-thony
Copy link
Collaborator Author

N-thony commented Nov 29, 2024

@rdstern have you re-tested this?

Copy link
Collaborator

@rdstern rdstern left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@N-thony I think your change may be working. But there are various problems, either from the changes, or perhaps always there?
a) whenever I click on rename I get the developer error.
b) When I did the select shown below I only got 2 columns visible out of the 3. I got the first column to be visible, by scrolling left, so no big deal. But whern I now do a new select, only the 2 columns appear. Of course I'd like them all, not just those in the current select, because I'm doing a new select. Maybe when new select is chosen there should be an unselect first?

@N-thony
Copy link
Collaborator Author

N-thony commented Dec 3, 2024

@N-thony I think your change may be working. But there are various problems, either from the changes, or perhaps always there? a) whenever I click on rename I get the developer error. b) When I did the select shown below I only got 2 columns visible out of the 3. I got the first column to be visible, by scrolling left, so no big deal. But whern I now do a new select, only the 2 columns appear. Of course I'd like them all, not just those in the current select, because I'm doing a new select. Maybe when new select is chosen there should be an unselect first?

@rdstern, this is solved now.

@N-thony
Copy link
Collaborator Author

N-thony commented Dec 9, 2024

@N-thony I think your change may be working. But there are various problems, either from the changes, or perhaps always there? a) whenever I click on rename I get the developer error. b) When I did the select shown below I only got 2 columns visible out of the 3. I got the first column to be visible, by scrolling left, so no big deal. But whern I now do a new select, only the 2 columns appear. Of course I'd like them all, not just those in the current select, because I'm doing a new select. Maybe when new select is chosen there should be an unselect first?

@rdstern, this is solved now.

@rdstern @lilyclements this needs your review.

@rdstern
Copy link
Collaborator

rdstern commented Jan 9, 2025

@N-thony not for this release, but could you resolve the conflicts? Then I'll check again.

rdstern
rdstern previously approved these changes Jan 11, 2025
Copy link
Collaborator

@rdstern rdstern left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@N-thony looks fine now.
@Patowhiz over to you to check and merge

Copy link
Contributor

@Patowhiz Patowhiz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


Let me know if further refinements are needed!

Copy link
Contributor

@lilyclements lilyclements left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@N-thony just some very minor bits


column_names <- self$get_column_names()

if (any(is.na(column_names))) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@N-thony can you change the any(is.na(...)) to anyNA as per @Patowhiz's suggestion?
It should perform the same, but be a fraction quicker and easier to read

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -1018,6 +1075,16 @@ DataSheet$set("public", "rename_column_in_data", function(curr_col_name = "", ne
for (i in seq_along(new_col_names)) {
self$append_to_variables_metadata(new_col_names[i], name_label, new_col_names[i])
}

column_names <- self$get_column_names()
if (any(is.na(column_names))) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

similarly here

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


column_names <- self$get_column_names()

if (any(is.na(column_names))) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and here

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment on lines 925 to 930
if(missing(new_values)) stop("new_values is required")

# Find the column selection to update
if (is.null(column_selection_name)) {
stop("A column selection name must be provided to update the selection.")
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some inconsistency here. In the first instance you refer to the parameter name which is missing, in the second you refer to the objective of the missing parameter name.

Can you be consistent with this error message between them both (e.g., either say "Parameter for new values is missing", or "column_selection_name is required").

If this is code that the user wouldn't look at, then saying the parameter name makes sense. If this is code that the user (who may not be versed in R) will look at, then saying a statement like your second one makes more sense?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -921,6 +921,40 @@ DataSheet$set("public", "cor", function(x_col_names, y_col_name, use = "everythi
}
)

DataSheet$set("public", "update_selection", function(new_values, column_selection_name = NULL) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you set it to be an error if column_selection_name = NULL, then you can just set column_selection_name here, and run it like you have run new_values (i.e., with if(missing(column_selection_name)) ... - unless I'm missing something?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Contributor

@lilyclements lilyclements left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rdstern over to you

@N-thony N-thony added enhancement Consistency The dialogue has been examined and the code is consistent, also label length, etc labels Jan 23, 2025
@rdstern
Copy link
Collaborator

rdstern commented Jan 23, 2025

@Patowhiz can you check and merge?

Copy link
Contributor

@Patowhiz Patowhiz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @rdstern and @lilyclements for reviewing this.

@Patowhiz Patowhiz merged commit 830680e into IDEMSInternational:master Jan 24, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Consistency The dialogue has been examined and the code is consistent, also label length, etc enhancement
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants