Skip to content

Conversation

@jokasimr
Copy link
Contributor

@jokasimr jokasimr commented Sep 15, 2023

Fixes #3176.

Is there a reason why float was excluded in the original arg_list?
Now I just added all type combinations between double, float, int32_t, int64_t.

@jokasimr jokasimr requested a review from nvaytet September 15, 2023 09:26
Copy link
Member

@SimonHeybrock SimonHeybrock left a comment

Choose a reason for hiding this comment

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

Is there a reason why float was excluded in the original arg_list?

No, just an oversight. Unfortunately Scipp's dtype handling mechanism requires being explicit about what is allowed. In many cases this is good, but we have also repeatedly run into "bugs" like these, where something that should work did not.

Comment on lines +19 to +26
arg_list<bin_range_arg<double, double>, bin_range_arg<double, float>,
bin_range_arg<double, int32_t>, bin_range_arg<double, int64_t>,
bin_range_arg<float, double>, bin_range_arg<float, float>,
bin_range_arg<float, int32_t>, bin_range_arg<float, int64_t>,
bin_range_arg<int32_t, double>, bin_range_arg<int32_t, float>,
bin_range_arg<int32_t, int32_t>, bin_range_arg<int32_t, int64_t>,
bin_range_arg<int64_t, double>, bin_range_arg<int64_t, float>,
bin_range_arg<int64_t, int32_t>, bin_range_arg<int64_t, int64_t>,
Copy link
Member

Choose a reason for hiding this comment

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

I think this is probably fine, but have you considered and checked if things can go wrong (such as comparisons) for certain type combinations, which might lead to, e.g., unintentionally dropping parts of the data?

arg_list<bin_range_arg<double, double>, bin_range_arg<int64_t, double>,
bin_range_arg<int64_t, int64_t>, bin_range_arg<int32_t, int32_t>,
bin_range_arg<int32_t, double>,
arg_list<bin_range_arg<double, double>, bin_range_arg<double, float>,
Copy link
Member

Choose a reason for hiding this comment

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

Can you also add a (or a couple of) unit test(s)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added a TYPED_TEST_SUITE, it doesn't account for all combinations.

Copy link
Member

Choose a reason for hiding this comment

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

I don't think this is testing much: The bin algorithm is quite complex, calling a whole series of functions like this one. So in this case this test is mostly just "noise", since it provides no guarantee that the higher-level functionality works.

At a minimum, we should add a (Python) test that tests the full case reported in the linked issue.

Comment on lines 79 to 87
x = array(
dims=['row'], unit='m', values=rng.random(nrow) * coord_max, dtype=coord_dtype
)
y = array(
dims=['row'], unit='m', values=rng.random(nrow) * coord_max, dtype=coord_dtype
)
z = array(
dims=['row'], unit='m', values=rng.random(nrow) * coord_max, dtype=coord_dtype
)
Copy link
Member

Choose a reason for hiding this comment

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

Not sure it matters much in practice, but now this function will be slower, even with the default coord_max. Unless you think this is more generally useful, maybe you can keep the scaling in the unit test where it is required?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think it might be useful when testing with integer coordinates.
But I'll change it so it doesn't increase the runtime when used without scaling.

@jokasimr jokasimr force-pushed the rebinning-float32-error branch from 6be69e7 to da4e811 Compare September 18, 2023 11:25
@jokasimr jokasimr force-pushed the rebinning-float32-error branch from da4e811 to 48409cb Compare September 20, 2023 08:26
@jokasimr jokasimr merged commit e368cd6 into main Sep 20, 2023
@jokasimr jokasimr deleted the rebinning-float32-error branch September 20, 2023 08:50
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.

Re-binning with float32 coords fails with unsupported dtype

4 participants