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

Data Explorer: Add support for date summary stats #388

Merged
merged 11 commits into from
Jun 20, 2024
Merged

Conversation

dfalbel
Copy link
Contributor

@dfalbel dfalbel commented Jun 7, 2024

This also refactors the summary stats support so it's easier to test it idependently.
Addresses posit-dev/positron#2161

@dfalbel dfalbel force-pushed the feature/date-stats branch from 3bcd7ff to 0e6345e Compare June 12, 2024 23:00
@dfalbel dfalbel marked this pull request as ready for review June 13, 2024 17:57
@dfalbel dfalbel requested a review from lionel- June 13, 2024 17:57
Comment on lines 670 to 673
Some(indices) => RFunction::from("col_filter_indices")
.add(column)
.add(RObject::try_from(indices)?)
.call_in(ARK_ENVS.positron_ns)?,
Copy link
Contributor

Choose a reason for hiding this comment

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

Might be worth extracting this sort of calls to R in Rust functions for readability?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done in 31db335

number_summary_stats <- function(column, filtered_indices) {
col <- col_filter_indices(column, filtered_indices)

summary_stats_number <- function(col) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I like the new naming scheme.

crates/ark/src/modules/positron/r_data_explorer.R Outdated Show resolved Hide resolved
crates/ark/src/data_explorer/summary_stats.rs Outdated Show resolved Hide resolved
}

fn robj_to_string(robj: &RObject) -> String {
let string: Option<String> = unwrap!(robj.clone().try_into(), Err(e) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Add a conversion method for &RObject? The moving one could call the borrowing one.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We actually don't need this any longer: 75dd37b


fn robj_to_string(robj: &RObject) -> String {
let string: Option<String> = unwrap!(robj.clone().try_into(), Err(e) => {
log::error!("Date stats: Error converting RObject to String: {e}");
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are errors here logged instead of being propagated like the other errors.? If intended, probably worth a comment?

.call_in(ARK_ENVS.positron_ns)?)
}

macro_rules! impl_summary_stats_conversion {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this macro necessary? It obfuscates what's going on quite a lot.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are right, I think this is simpler: c191c3a

@dfalbel dfalbel force-pushed the feature/date-stats branch from 75dd37b to c03486c Compare June 18, 2024 17:07
@dfalbel dfalbel requested a review from lionel- June 18, 2024 17:20
@dfalbel dfalbel merged commit dc876ad into main Jun 20, 2024
1 check passed
@dfalbel dfalbel deleted the feature/date-stats branch June 20, 2024 12:09
@github-actions github-actions bot locked and limited conversation to collaborators Jun 20, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants