Improve array conversion from Java & add a test for nan and inf values from Java
I couldn't reproduce the reported issue @rdemaria, and have added tests to confirm that it is doing as expected.
Just in case, I also went through the whole Japc machinery with the following test, and also couldn't find the issue:
def test_get_value_double(japc, japc_mock):
param = 'TEST/TestProperty'
mock = japc_mock.mockParameter(param)
japc_mock.whenGetValueThen(
mock, japc_mock.sel('LHC.USER.TEST'), japc_mock.acqVal(param, np.inf, 0))
japc.setSelector('LHC.USER.TEST')
assert np.isinf(japc.getParam('TEST/TestProperty'))
and:
def test_get_value_double(japc, japc_mock):
param = 'TEST/TestProperty'
mock = japc_mock.mockParameter(param)
japc_mock.whenGetValueThen(
mock, japc_mock.sel('LHC.USER.TEST'), japc_mock.acqVal(param, np.nan, 0))
japc.setSelector('LHC.USER.TEST')
assert np.isnan(japc.getParam('TEST/TestProperty'))
Merge request reports
Activity
added 1 commit
- bb4d582f - Improve the conversion from java to numpy dtypes for arrays. This is a...
added 1 commit
- bd45789a - Improve the conversion from java to numpy dtypes for arrays. This is a...
added 1 commit
- 365cc98e - Add the benchmarks I used to determine *how* slow the supposed slowdown would...
added 1 commit
- 922d2fef - Add the benchmarks I used to determine *how* slow the supposed slowdown would...
This MR has morphed a little bit following my investigation. It turns out that
float32
values were being converted tofloat64
in all cases. Under the hood, the JAPC change which fixed the problem, I believe was https://gitlab.cern.ch/acc-co/japc/japc-core/-/compare/japc-value%2Fv7.8.5...japc-value%2Fv7.8.6#e0e59828d4009c8fd6da59e221bc1d986c21e971_1897_1895, but I confess I cannot get the exception to raise in PyJapc using the old version.In order to fix the further type conversion, I have removed a bunch of code which was an optimisation based on how the old JPype worked. This is now far simpler, and actually results in a faster conversion (benchmark test added).
mentioned in commit 715d0df5