-
Notifications
You must be signed in to change notification settings - Fork 33
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
Stats use ScalarValues and not Scalars #2069
base: develop
Are you sure you want to change the base?
Conversation
ScalarValues
9c9c488
to
ab2e76c
Compare
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.
Really like this. Couple of doc strings to write, and not sure about all the TryFrom impls , but I'll leave that up to you.
let encoded = match_each_integer_ptype!(array.ptype(), |$T| { | ||
if shift == <$T>::PTYPE.bit_width() as u8 { | ||
assert_eq!(min, Scalar::zero::<$T>(array.dtype().nullability())); | ||
assert_eq!(min, Scalar::zero::<$T>(array.dtype().nullability()).into_value()); |
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.
Seems a shame to create a scalar with a DType then throw it away? Can you just do ScalarValue::from(0usize)
?
@@ -225,7 +226,7 @@ where | |||
} | |||
|
|||
impl dyn Statistics + '_ { | |||
pub fn get_as<U: for<'a> TryFrom<&'a Scalar, Error = VortexError>>( | |||
pub fn get_as<U: for<'a> TryFrom<&'a ScalarValue, Error = VortexError>>( |
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.
Can you add a doc string to this? Before get_as and get_as_cast had different behaviour, I think get_as will now always cast? But it's not clear with the docs.
use crate::scalarvalue::InnerScalarValue; | ||
use crate::ScalarValue; | ||
|
||
impl<'a> TryFrom<&'a ScalarValue> for String { |
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'm not necessarily a fan of all of these "helper" impls, given it's not that hard to do value.as_buffer().into_string()
or equivalent.
Don't feel too strongly, it's just a lot of code that's not obviously used anywhere.
I think this leads to simpler stats api where for a scalarvalue you have to extract it as a type you desire but we seldom care about a precise dtype of a stats, where we do I have preserved the semantic and wrapped the scalarvalue back up into scalar