-
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
Fix: Make inherited read-only datasets from schema read-only properties in matnwb #640
Merged
ehennestad
merged 2 commits into
master
from
fix/izeroclampseries-props-should-be-read-only
Nov 28, 2024
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ | |
methods | ||
function obj = IZeroClampSeries(varargin) | ||
% IZEROCLAMPSERIES Constructor for IZeroClampSeries | ||
varargin = [{'stimulus_description' 'N/A'} varargin]; | ||
varargin = [{'bias_current' types.util.correctType(0, 'single') 'bridge_balance' types.util.correctType(0, 'single') 'capacitance_compensation' types.util.correctType(0, 'single') 'stimulus_description' 'N/A'} varargin]; | ||
obj = [email protected](varargin{:}); | ||
|
||
|
||
|
@@ -33,58 +33,25 @@ | |
%% VALIDATORS | ||
|
||
function val = validate_bias_current(obj, val) | ||
val = types.util.checkDtype('bias_current', 'single', val); | ||
if isa(val, 'types.untyped.DataStub') | ||
if 1 == val.ndims | ||
valsz = [val.dims 1]; | ||
else | ||
valsz = val.dims; | ||
end | ||
elseif istable(val) | ||
valsz = [height(val) 1]; | ||
elseif ischar(val) | ||
valsz = [size(val, 1) 1]; | ||
if isequal(val, 0) | ||
val = 0; | ||
else | ||
valsz = size(val); | ||
error('NWB:Type:ReadOnlyProperty', 'Unable to set the ''bias_current'' property of class ''<a href="matlab:doc types.core.IZeroClampSeries">IZeroClampSeries</a>'' because it is read-only.') | ||
end | ||
validshapes = {[1]}; | ||
types.util.checkDims(valsz, validshapes); | ||
end | ||
function val = validate_bridge_balance(obj, val) | ||
val = types.util.checkDtype('bridge_balance', 'single', val); | ||
if isa(val, 'types.untyped.DataStub') | ||
if 1 == val.ndims | ||
valsz = [val.dims 1]; | ||
else | ||
valsz = val.dims; | ||
end | ||
elseif istable(val) | ||
valsz = [height(val) 1]; | ||
elseif ischar(val) | ||
valsz = [size(val, 1) 1]; | ||
if isequal(val, 0) | ||
val = 0; | ||
else | ||
valsz = size(val); | ||
error('NWB:Type:ReadOnlyProperty', 'Unable to set the ''bridge_balance'' property of class ''<a href="matlab:doc types.core.IZeroClampSeries">IZeroClampSeries</a>'' because it is read-only.') | ||
end | ||
validshapes = {[1]}; | ||
types.util.checkDims(valsz, validshapes); | ||
end | ||
function val = validate_capacitance_compensation(obj, val) | ||
val = types.util.checkDtype('capacitance_compensation', 'single', val); | ||
if isa(val, 'types.untyped.DataStub') | ||
if 1 == val.ndims | ||
valsz = [val.dims 1]; | ||
else | ||
valsz = val.dims; | ||
end | ||
elseif istable(val) | ||
valsz = [height(val) 1]; | ||
elseif ischar(val) | ||
valsz = [size(val, 1) 1]; | ||
if isequal(val, 0) | ||
val = 0; | ||
else | ||
valsz = size(val); | ||
error('NWB:Type:ReadOnlyProperty', 'Unable to set the ''capacitance_compensation'' property of class ''<a href="matlab:doc types.core.IZeroClampSeries">IZeroClampSeries</a>'' because it is read-only.') | ||
end | ||
validshapes = {[1]}; | ||
types.util.checkDims(valsz, validshapes); | ||
end | ||
function val = validate_stimulus_description(obj, val) | ||
if isequal(val, 'N/A') | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I don't know if "read-only" is quite right. That would imply that it has already been written and is being read, which isn't quite true. How about "because it is a fixed value"
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.
I am following the convention In MATLAB where properties that are Constant or has SetAccess = private/protected (i.e., users cannot set the value), are "read-only".
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.
So with this classdef:
You will have this error if you try to set the Name property:
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.
ah, ok. I'm not crazy about that language but it's fine if it's consistent with existing MATLAB usage