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

Update load_mat_style.m #602

Merged
merged 8 commits into from
Nov 4, 2024
5 changes: 3 additions & 2 deletions +tests/+unit/PynwbTutorialTest.m
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand Down
24 changes: 24 additions & 0 deletions +types/+untyped/@DataStub/load_mat_style.m
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,22 @@
end

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
end
ehennestad marked this conversation as resolved.
Show resolved Hide resolved

[points{:}] = ind2sub(dataDimensions, orderedSelection);
readSpaceId = H5S.copy(spaceId);
H5S.select_none(readSpaceId);
Expand Down Expand Up @@ -187,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
ehennestad marked this conversation as resolved.
Show resolved Hide resolved
end
4 changes: 2 additions & 2 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand Down