From c86141bf340890bdc1cb84c84cf616d98cf2473a Mon Sep 17 00:00:00 2001 From: ehennestad Date: Wed, 16 Oct 2024 23:45:32 +0200 Subject: [PATCH 1/5] Update load_mat_style.m --- +types/+untyped/@DataStub/load_mat_style.m | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/+types/+untyped/@DataStub/load_mat_style.m b/+types/+untyped/@DataStub/load_mat_style.m index a6fa1f16..6e97a868 100644 --- a/+types/+untyped/@DataStub/load_mat_style.m +++ b/+types/+untyped/@DataStub/load_mat_style.m @@ -46,6 +46,17 @@ end points = cell(length(dataDimensions), 1); + + if isscalar(dataDimensions) && ~isMATLABReleaseOlderThan('R2024b') + % Starting from MATLAB R2024, the input argument for the size + % of an array must be a vector of positive integers with two or + % more elements. This fix replicates the behavior of older + % MATLAB versions, which automatically assumed that the size + % referred to the number of rows. For scalar dimensions + % (i.e., row or column vectors), this should be acceptable. + dataDimensions = [dataDimensions, 1]; + end + [points{:}] = ind2sub(dataDimensions, orderedSelection); readSpaceId = H5S.copy(spaceId); H5S.select_none(readSpaceId); From c92bda0c01eff19f12688f29388a823d9170b9d3 Mon Sep 17 00:00:00 2001 From: ehennestad Date: Thu, 17 Oct 2024 00:09:07 +0200 Subject: [PATCH 2/5] Update task version for MATLAB extension on azure pipelines --- azure-pipelines.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 33b11d33..68504239 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -5,7 +5,7 @@ pool: vmImage: 'ubuntu-latest' steps: - - task: InstallMATLAB@0 + - task: InstallMATLAB@1 # default to latest version of Matlab installed #inputs: # release: R2017a @@ -24,7 +24,7 @@ steps: echo "##vso[task.setvariable variable=pynwb_path]$(python -c "import pynwb; print(pynwb.__path__[0])")" displayName: 'Install PyNWB' - - task: RunMATLABCommand@0 + - task: RunMATLABCommand@1 inputs: command: "results = assertSuccess(nwbtest); assert(~isempty(results), 'No tests ran');" env: From 6f47030efd7fb7cef6fbdf2bb4751a1c30f21d5c Mon Sep 17 00:00:00 2001 From: ehennestad Date: Thu, 17 Oct 2024 10:25:53 +0200 Subject: [PATCH 3/5] Update PynwbTutorialTest.m Add plot_read_basics to list of tutorials to skip. This tutorial does not produce NWB files that can be read with matnwb. --- +tests/+unit/PynwbTutorialTest.m | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/+tests/+unit/PynwbTutorialTest.m b/+tests/+unit/PynwbTutorialTest.m index 946661be..0c84778d 100644 --- a/+tests/+unit/PynwbTutorialTest.m +++ b/+tests/+unit/PynwbTutorialTest.m @@ -21,6 +21,7 @@ properties (Constant) % SkippedTutorials - Tutorials from pynwb to skip SkippedTutorials = {... + 'plot_read_basics.py', ... % Downloads file from dandi archive, does not export nwb file 'streaming.py', ... % Requires that HDF5 library is installed with the ROS3 driver enabled which is not a given 'object_id.py', ... % Does not export nwb file 'plot_configurator.py', ... % Does not export nwb file @@ -31,7 +32,7 @@ SkippedFiles = {'family_nwb_file_0.nwb'} % requires family driver from h5py % PythonDependencies - Package dependencies for running pynwb tutorials - PythonDependencies = {'hdmf-zarr', 'dataframe-image', 'matplotlib', 'dandi'} + PythonDependencies = {'hdmf-zarr', 'dataframe-image', 'matplotlib'} end properties (Access = private) @@ -101,7 +102,7 @@ function testTutorial(testCase, tutorialFile) pythonPath = tests.util.getPythonPath(); - cmd = sprintf('"%s" %s', pythonPath, tutorialFile ); + cmd = sprintf('%s %s', pythonPath, tutorialFile); [status, cmdout] = system(cmd); if status == 1 From 89055c2d3779e2633fcdf7ad598c792ba0e97a54 Mon Sep 17 00:00:00 2001 From: ehennestad Date: Sat, 2 Nov 2024 19:20:00 +0100 Subject: [PATCH 4/5] Ensure fix will not throw errors in releases predating R2020b --- +types/+untyped/@DataStub/load_mat_style.m | 29 ++++++++++++++++------ 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/+types/+untyped/@DataStub/load_mat_style.m b/+types/+untyped/@DataStub/load_mat_style.m index 6e97a868..6b4545f6 100644 --- a/+types/+untyped/@DataStub/load_mat_style.m +++ b/+types/+untyped/@DataStub/load_mat_style.m @@ -47,14 +47,19 @@ points = cell(length(dataDimensions), 1); - if isscalar(dataDimensions) && ~isMATLABReleaseOlderThan('R2024b') - % Starting from MATLAB R2024, the input argument for the size - % of an array must be a vector of positive integers with two or - % more elements. This fix replicates the behavior of older - % MATLAB versions, which automatically assumed that the size - % referred to the number of rows. For scalar dimensions - % (i.e., row or column vectors), this should be acceptable. - dataDimensions = [dataDimensions, 1]; + if isscalar(dataDimensions) + if isMATLABReleaseOlderThanR2024b() + % Pass. Scalar size input to ind2sub was supported until R2024b. + else + % Starting in MATLAB R2024b, the input argument for the size + % of an array in ind2sub must be a vector of positive integers + % with two or more elements. This fix replicates the behavior of + % older MATLAB versions, where it was assumed that the a scalar + % size referred to the row dimension. For scalar dimensions + % (i.e., row or column vectors), we can still assume this + % to be true in matnwb. + dataDimensions = [dataDimensions, 1]; + end end [points{:}] = ind2sub(dataDimensions, orderedSelection); @@ -198,4 +203,12 @@ indexKeyIndex(indexKeyIndexNextIndex) = indexKeyIndex(indexKeyIndexNextIndex) + 1; indexKeyIndex((indexKeyIndexNextIndex+1):end) = 1; end +end + +function tf = isMATLABReleaseOlderThanR2024b() + if exist('isMATLABReleaseOlderThan', 'file') == 2 + tf = isMATLABReleaseOlderThan('R2024b'); + else + tf = true; % isMATLABReleaseOlderThan was introduced in R2020b + end end \ No newline at end of file From 387a51f3fdd5905f3e10e7b4cfc88d37f6690fd2 Mon Sep 17 00:00:00 2001 From: ehennestad Date: Sat, 2 Nov 2024 20:28:01 +0100 Subject: [PATCH 5/5] Simplify fix for load_mat_style --- +types/+untyped/@DataStub/load_mat_style.m | 28 +++++++--------------- 1 file changed, 8 insertions(+), 20 deletions(-) diff --git a/+types/+untyped/@DataStub/load_mat_style.m b/+types/+untyped/@DataStub/load_mat_style.m index 6b4545f6..f32312c0 100644 --- a/+types/+untyped/@DataStub/load_mat_style.m +++ b/+types/+untyped/@DataStub/load_mat_style.m @@ -48,18 +48,14 @@ points = cell(length(dataDimensions), 1); if isscalar(dataDimensions) - if isMATLABReleaseOlderThanR2024b() - % Pass. Scalar size input to ind2sub was supported until R2024b. - else - % Starting in MATLAB R2024b, the input argument for the size - % of an array in ind2sub must be a vector of positive integers - % with two or more elements. This fix replicates the behavior of - % older MATLAB versions, where it was assumed that the a scalar - % size referred to the row dimension. For scalar dimensions - % (i.e., row or column vectors), we can still assume this - % to be true in matnwb. - dataDimensions = [dataDimensions, 1]; - end + % Starting in MATLAB R2024b, the input argument for the size + % of an array in ind2sub must be a vector of positive integers + % with two or more elements. This fix replicates the behavior of + % older MATLAB versions, where it was assumed that the a scalar + % size referred to the row dimension. For scalar dimensions + % (i.e., row or column vectors), we can still assume this + % to be true in matnwb. + dataDimensions = [dataDimensions, 1]; end [points{:}] = ind2sub(dataDimensions, orderedSelection); @@ -204,11 +200,3 @@ indexKeyIndex((indexKeyIndexNextIndex+1):end) = 1; end end - -function tf = isMATLABReleaseOlderThanR2024b() - if exist('isMATLABReleaseOlderThan', 'file') == 2 - tf = isMATLABReleaseOlderThan('R2024b'); - else - tf = true; % isMATLABReleaseOlderThan was introduced in R2020b - end -end \ No newline at end of file