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

Address issue #1105 #1164

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Address issue #1105 #1164

wants to merge 1 commit into from

Conversation

JosiahParry
Copy link

This PR bumps the version of extendr used to address R-devel changes. It also requires a specific revision that was merged in extendr/extendr#824.

CC @etiennebacher

@etiennebacher
Copy link
Collaborator

Thanks, but how does it compare to #1154? Is this an addition or a duplicate?

@@ -11,8 +11,9 @@ pub enum RArrowArrayClass {
NanoArrowArray,
}

impl<'a> FromRobj<'a> for RArrowArrayClass {
fn from_robj(robj: &Robj) -> std::result::Result<Self, &'static str> {
impl TryFrom<&Robj> for RArrowArrayClass {
Copy link
Author

Choose a reason for hiding this comment

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

Note that FromRobj was removed in favor of TryFrom

@@ -153,10 +153,11 @@ fn recursive_robjname2series_tree(x: &Robj, name: &str) -> pl::PolarsResult<Seri
}

Rtype::Raw => {
let rpolars_raw_list = list!(x)
let mut binding = list!(x);
Copy link
Author

Choose a reason for hiding this comment

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

modifying attributes modifies in place. Previously, this didn't require a mutable reference giving false confidence. Now it requires a mutable reference. Additionally, the same type is returned after modifying the attributes. So if you use set_class() or set_attrib() on a List it will return a mut List.

.set_class(["rpolars_raw_list", "list"])
.map_err(|err| pl::polars_err!(ComputeError: err.to_string()))?;
recursive_robjname2series_tree(&rpolars_raw_list, name)
recursive_robjname2series_tree(&rpolars_raw_list.clone().into_robj(), name)
Copy link
Author

Choose a reason for hiding this comment

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

We increment the reference counter and convert into an Robj for compatibility with this function. I did not want to modify the function itself.

@@ -49,6 +49,7 @@ pub fn pl_series_to_list(
.collect_robj()
.set_class(&["integer64"])
.expect("internal error could not set class label 'integer64'")
.clone()
Copy link
Author

Choose a reason for hiding this comment

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

Increment reference counter to go from &mut Robj to Robj and likewise below.

})
.map(|mut robj| robj.set_attrib("tu", "ns"))
.map(|mut robj| robj.set_attrib("tu", "ns").cloned())
Copy link
Author

Choose a reason for hiding this comment

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

Similarly from Result<&mut Robj, E> to Result<Robj, E>

@JosiahParry
Copy link
Author

Thanks, but how does it compare to #1154? Is this an addition or a duplicate?

#1154 was the inspiration for extendr/extendr#824. This PR requires fewer LOC changed.

I hope these are helpful for you! I left comments in this PR to indicate why the changes were necessary. You can choose which, if either, you want to merge.

@JosiahParry
Copy link
Author

I think it is fair to say that you have 2 PRs because each of us were asked independently to take a look at this 😆

@etiennebacher
Copy link
Collaborator

Sorry, I thought you had seen the linked PR in #1105. Since our feedback in #1154 looks important (#1154 (comment)) I guess we'll prioritize it over this one, but the comments here are much appreciated!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants