-
Notifications
You must be signed in to change notification settings - Fork 68
Add element stride calculation and alignment methods #1406
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
base: develop
Are you sure you want to change the base?
Conversation
This change adds three new methods to the DataType class that help with element-based stride calculations and alignment checks: 1. element_stride(): Returns stride in elements instead of bytes 2. is_stride_element_aligned(): Tests if stride is aligned with element boundaries 3. is_stride_aligned(nbytes): Tests if stride is a multiple of given bytes Fixes issue #1207 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
dt.set(DataType::FLOAT64_ID, | ||
10, // 10 elements | ||
0, // 0 offset | ||
sizeof(float64)*2, // stride = 16 bytes (2 elements) |
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.
comments here are wrong
Added Python bindings and tests for: - element_stride() - is_stride_element_aligned() - is_stride_aligned() Part of #1207 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
Added C bindings and tests for: - element_stride() - is_stride_element_aligned() - is_stride_aligned() Part of #1207 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
Added Fortran bindings and tests for: - element_stride() - is_stride_element_aligned() - is_stride_aligned() Part of #1207 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
@@ -144,6 +144,14 @@ subroutine t_node_datatype_ids | |||
call assert_true( conduit_datatype_element_bytes(dataType) == 8) | |||
call assert_true( conduit_datatype_stride(dataType) == 8) | |||
call assert_true( conduit_datatype_offset(dataType) == 0) | |||
|
|||
! Test the new element stride methods |
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.
! Test the new element stride methods | |
! Test the element stride methods |
@@ -257,7 +257,57 @@ def test_to_string_and_friends(self): | |||
self.assertEqual(d.to_string("yaml"),d.to_yaml()) | |||
self.assertEqual(d.to_string("json"),d.to_json()) | |||
|
|||
|
|||
def test_stride_methods(self): |
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.
def test_stride_methods(self): | |
def test_element_stride_methods(self): |
return cpp_datatype_ref(cdatatype).is_stride_element_aligned() ? 1 : 0; | ||
} | ||
|
||
int conduit_datatype_is_stride_aligned(const conduit_datatype *cdatatype, conduit_index_t nbytes) |
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.
int
return is consistent with other c api functions that provide boolean answers
|
Give the state of the world today, |
I want to respond with |
This change adds three new methods to the DataType class that help with element-based stride calculations and alignment checks:
Fixes issue #1207
🤖 Generated with Claude Code