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

Balance only seems to work for float properties #1406

Closed
narnolddd opened this issue Dec 4, 2023 · 0 comments · Fixed by #1898
Closed

Balance only seems to work for float properties #1406

narnolddd opened this issue Dec 4, 2023 · 0 comments · Fixed by #1898
Assignees

Comments

@narnolddd
Copy link
Collaborator

Was working with the python version, it returns 0.0 for balance if the property is an integer. I think the problem is when it casts into_f64 it only works if the property is an f64 one. I guess the tricky part is if you're doing things with integers you need to worry about signed/unsigned etc.

            .flat_map(|prop| {
                prop.temporal().get(name).map(|val| {
                    val.values()
                        .into_iter()
                        .map(|valval| valval.into_f64().unwrap_or(0.0f64))
                        .sum::<f64>()
                })

where into_f64 is

    fn into_f64(self) -> Option<f64> {
        if let Prop::F64(v) = self {
            Some(v)
        } else {
            None
        }
    }

(not a problem for me right now as I can just cast the column as float before)

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 a pull request may close this issue.

3 participants