-
Notifications
You must be signed in to change notification settings - Fork 32
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
595 Allow using empty indices for datastub #605
base: master
Are you sure you want to change the base?
Conversation
@lawrence-mbf I would value your input here. The proposed fix works in the specific situation, but if you have ideas on how to improve this, or if there are things I have overlooked please let me know. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #605 +/- ##
==========================================
- Coverage 90.63% 90.42% -0.22%
==========================================
Files 106 106
Lines 4686 4698 +12
==========================================
+ Hits 4247 4248 +1
- Misses 439 450 +11
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
end | ||
|
||
|
||
function emptyInstance = getEmptyRepresentation(nonEmptyInstance) |
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.
@ehennestad Does this work with HDF5 reference types? Very clever, I did not know left-hand side colon assignment preserved types.
@@ -34,7 +34,14 @@ | |||
, iDimension, dimensionSize); | |||
end | |||
|
|||
if isscalar(userSelection) && ~ischar(userSelection{1}) | |||
if isscalar(userSelection) && isempty(userSelection{1}) |
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.
This conditional adds support for this syntax:
ds = types.untyped.DataStub(...);
emptytype = ds([]);
and
emptytype = ds('');
But not
emptytype = ds();
Is that the intention here?
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.
Yeah this should be updated.
emptytype = ds([]);
should be supported, but neither emptytype = ds('');
or emptytype = ds();
should be
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.
Based on MATLAB's builtin behavior, it should perhaps be kept the way it is:
>> s = struct('a', num2cell(1:10))
s =
1×10 struct array with fields:
a
>> s([])
ans =
0×0 empty struct array with fields:
a
>> s('')
ans =
0×0 empty struct array with fields:
a
>> s()
ans =
1×10 struct array with fields:
a
Fix #595
Motivation
Fix issue.
How to test the behavior?
See issue #595
Checklist
fix #XX
whereXX
is the issue number?