-
Notifications
You must be signed in to change notification settings - Fork 841
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
Refine documentation for unary_mut
and binary_mut
#5798
Conversation
@@ -480,6 +480,19 @@ pub use crate::types::ArrowPrimitiveType; | |||
/// assert_eq!(array.values(), &[1, 0, 2]); | |||
/// assert!(array.is_null(1)); | |||
/// ``` | |||
/// | |||
/// # Example: Get a `PrimitiveArray` from an [`ArrayRef`] |
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 don't think it is obvious how to go from Arc<dyn Array>
back to PrimitiveArray
so I documented that too
/// # fn main() { | ||
/// let array = Int32Array::from(vec![Some(5), Some(7), None]); | ||
/// let c = array.unary(|x| x * 2 + 1); | ||
/// assert_eq!(c, Int32Array::from(vec![Some(11), Some(15), None])); | ||
/// // Create a new array with the value of applying sqrt |
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.
changed this to show you can make a different type
/// assert_eq!(c, Int32Array::from(vec![Some(11), Some(15), None])); | ||
/// ``` | ||
/// | ||
/// # Example: modify [`ArrayRef`] in place, if not shared |
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.
This is an example I imagine someone might be looking for (like I would be)
I think this PR is ready for review I have filed #5770 to track the "binary_mut" type check |
I believe CI is failing due to #5815 |
I plan to merge this PR in the next day or two unless there is any additional commentary. It adds test coverage and changes docs -- if we find issues or additional improvements we can do them as follow on PRs |
Which issue does this PR close?
N/A
Rationale for this change
I ran into someone at a conference yesterday who was saying they hadn't been
able to figure out how to modify arrays in place. @tustvold pointed out to me it
is possible but the documentation for
binary_mut
andunary_mut
wasnot as clear as it could be,
I had the code up for #5792 anyways so I figured I would bang out this improvement as well
What changes are included in this PR?
This ended up being larger than I expected as I opened the docs and was imaginging "how would a random person who didn't understand the details of arrow-rs use this feature"
Are there any user-facing changes?
Doc changes only, no code changes