-
Notifications
You must be signed in to change notification settings - Fork 35
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
base: main
Are you sure you want to change the base?
Address issue #1105 #1164
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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); | ||
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. 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 |
||
let rpolars_raw_list = binding | ||
.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) | ||
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 increment the reference counter and convert into an Robj for compatibility with this function. I did not want to modify the function itself. |
||
} | ||
|
||
Rtype::List if x.inherits("rpolars_raw_list") => { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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() | ||
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. Increment reference counter to go from |
||
}), | ||
_ => Err(pl::PolarsError::InvalidOperation( | ||
"`int64_conversion ` must be one of 'float', 'string', 'bit64'".into(), | ||
|
@@ -109,6 +110,7 @@ pub fn pl_series_to_list( | |
.into_robj() | ||
.set_class(["rpolars_raw_list", "list"]) | ||
.expect("this class label is always valid") | ||
.clone() | ||
}), | ||
Enum(_, _) => s | ||
.categorical() | ||
|
@@ -181,7 +183,8 @@ pub fn pl_series_to_list( | |
.into_iter() | ||
.collect_robj() | ||
.set_class(&["Date"]) | ||
.expect("internal error: class label Date failed")), | ||
.expect("internal error: class label Date failed") | ||
.clone()), | ||
Null => Ok((extendr_api::NULL).into_robj()), | ||
Time => s | ||
.cast(&Int64)? | ||
|
@@ -195,8 +198,9 @@ pub fn pl_series_to_list( | |
.map(|mut robj| { | ||
robj.set_class(&["PTime"]) | ||
.expect("internal error: class label PTime failed") | ||
.clone() | ||
}) | ||
.map(|mut robj| robj.set_attrib("tu", "ns")) | ||
.map(|mut robj| robj.set_attrib("tu", "ns").cloned()) | ||
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. Similarly from Result<&mut Robj, E> to Result<Robj, E> |
||
.expect("internal error: attr tu failed") | ||
.map_err(|err| { | ||
pl_error::ComputeError( | ||
|
@@ -248,9 +252,12 @@ pub fn pl_series_to_list( | |
.map(|mut robj| { | ||
robj.set_class(&["POSIXct", "POSIXt"]) | ||
.expect("internal error: class POSIXct label failed") | ||
.clone() | ||
}) | ||
.map(|mut robj| { | ||
robj.set_attrib("tzone", opt_tz.as_ref().map(|s| s.as_str()).unwrap_or("")) | ||
let res = robj | ||
.set_attrib("tzone", opt_tz.as_ref().map(|s| s.as_str()).unwrap_or("")); | ||
res.cloned() | ||
}) | ||
.expect("internal error: attr tzone failed") | ||
.map_err(|err| { | ||
|
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.
Note that
FromRobj
was removed in favor ofTryFrom