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

DataView should check the dimensionality of offset and count #786

Closed
achilleas-k opened this issue Sep 25, 2019 · 3 comments · Fixed by #787
Closed

DataView should check the dimensionality of offset and count #786

achilleas-k opened this issue Sep 25, 2019 · 3 comments · Fixed by #787

Comments

@achilleas-k
Copy link
Member

I could be wrong but I think we don't check the dimensionality of offset and count when creating DataView objects. DataViews are only created internally (users aren't expected to create them manually), so this is probably not strictly necessary, but might be a good bug catcher.

@gicmo
Copy link
Member

gicmo commented Sep 25, 2019

I think that is implicitly done (DataView.hpp):

if (this->offset + this->count > array.dataExtent()) {
    throw OutOfBounds("Trying to create DataView which is out of bounds");
}

Because comparing the NDSize (offset + count) with dataExtent() will check the dimensionality:

template<typename T>
inline bool NDSize::operator<(const NDSizeBase<T> &lhs, const NDSizeBase<T> &rhs)
{
    if (lhs.size() != rhs.size()) {
        throw IncompatibleDimensions("size must agree to compare",
                                     "NDSizeBase < NDSizeBase ");
    }

@achilleas-k
Copy link
Member Author

You're right. Didn't think to check that.
Would you like to add an explicit check? If you think the check in the comparison is enough, just close the issue.

@gicmo
Copy link
Member

gicmo commented Sep 25, 2019

Would you like to add an explicit check? If you think the check in the comparison is enough, just close the issue.

I think that would be better, yeah, an IncompatibleDimensions with a more specific error message.

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.

2 participants