Skip to content

[RF][PyROOT] Fix RooDataSet.from_numpy() for contiguous input arrays#13609

Merged
guitargeek merged 1 commit into
root-project:masterfrom
guitargeek:issue-13605
Sep 7, 2023
Merged

[RF][PyROOT] Fix RooDataSet.from_numpy() for contiguous input arrays#13609
guitargeek merged 1 commit into
root-project:masterfrom
guitargeek:issue-13605

Conversation

@guitargeek

Copy link
Copy Markdown
Contributor

Closes #13605.

@phsft-bot

Copy link
Copy Markdown

Starting build on ROOT-performance-centos8-multicore/soversion, ROOT-ubuntu2204/nortcxxmod, ROOT-ubuntu2004/python3, mac11/noimt, mac12arm/cxx20, windows10/default
How to customize builds

@phsft-bot

Copy link
Copy Markdown

Build failed on ROOT-ubuntu2204/nortcxxmod.
Running on root-ubuntu-2204-1.cern.ch:/home/sftnight/build/workspace/root-pullrequests-build
See console output.

Failing tests:

@phsft-bot

Copy link
Copy Markdown

Build failed on ROOT-ubuntu2004/python3.
Running on root-ubuntu-2004-1.cern.ch:/home/sftnight/build/workspace/root-pullrequests-build
See console output.

Failing tests:

@guitargeek guitargeek added the bug label Sep 5, 2023
@github-actions

github-actions Bot commented Sep 5, 2023

Copy link
Copy Markdown

Test Results

       10 files         10 suites   2d 7h 34m 3s ⏱️
  2 484 tests   2 476 ✔️ 0 💤   8
23 777 runs  23 751 ✔️ 0 💤 26

For more details on these failures, see this check.

Results for commit bff178d.

♻️ This comment has been updated with latest results.

@phsft-bot

Copy link
Copy Markdown

@vepadulano vepadulano left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good overall, thanks! Left a couple of minor comments

void_p = ctypes.cast(beg, ctypes.c_voidp).value + 4 * len(arr)
end = ctypes.cast(void_p, ctypes.POINTER(ctypes.c_int))
ROOT.std.copy(beg, end, vec.begin())
# Make sure that the array is contiguous to we can std::copy() it.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
# Make sure that the array is contiguous to we can std::copy() it.
# Make sure that the array is contiguous so we can std::copy() it.


vec.resize(len(arr))

beg = arr.ctypes.data_as(ctypes.POINTER(c_type))

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Possibly add comment here

Suggested change
beg = arr.ctypes.data_as(ctypes.POINTER(c_type))
# The next part works because arr is guaranteed to be C-contiguous
beg = arr.ctypes.data_as(ctypes.POINTER(c_type))


def test_non_contiguous_arrays(self):
"""Test whether the import also works with non-continguous arrays.
Covers GitHub issue #1360.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
Covers GitHub issue #1360.
Covers GitHub issue #13605.

@phsft-bot

Copy link
Copy Markdown

Starting build on ROOT-performance-centos8-multicore/soversion, ROOT-ubuntu2204/nortcxxmod, ROOT-ubuntu2004/python3, mac11/noimt, mac12arm/cxx20, windows10/default
How to customize builds

@guitargeek

Copy link
Copy Markdown
Contributor Author

Thanks a lot for your review, @vepadulano! I have addressed the comments.

@phsft-bot

Copy link
Copy Markdown

Build failed on ROOT-ubuntu2204/nortcxxmod.
See console output.

@phsft-bot

Copy link
Copy Markdown

Build failed on ROOT-performance-centos8-multicore/soversion.
Running on olbdw-01.cern.ch:/data/sftnight/workspace/root-pullrequests-build
See console output.

Failing tests:

@phsft-bot

Copy link
Copy Markdown

Build failed on mac11/noimt.
Running on macphsft23.dyndns.cern.ch:/Users/sftnight/build/workspace/root-pullrequests-build
See console output.

Failing tests:

@phsft-bot

Copy link
Copy Markdown

Build failed on ROOT-ubuntu2004/python3.
Running on root-ubuntu-2004-3.cern.ch:/home/sftnight/build/workspace/root-pullrequests-build
See console output.

Failing tests:

@phsft-bot

Copy link
Copy Markdown

Build failed on windows10/default.
Running on null:C:\build\workspace\root-pullrequests-build
See console output.

Failing tests:

@guitargeek guitargeek merged commit 45230e3 into root-project:master Sep 7, 2023
@guitargeek guitargeek deleted the issue-13605 branch September 7, 2023 12:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[RF] RooDataSet.from_numpy gives wrong result when the input arrays are not c-contiguous

3 participants