-
Notifications
You must be signed in to change notification settings - Fork 1
Refactor datatype mapping #94
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
Conversation
|
||
function obj = fromTensorstoreType(tensorstoreType) | ||
% Create a datatype object based on Tensorstore datatype name | ||
arguments |
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.
You don't need the arguments block and validatestrings
. You could either remove the args block (which BTW means you will accept any inputs that are convertable to string, like double and datetime) or use the mustBeMember
validator function. Nothing specifically wrong with this pattern, but it's a mix of two paradigms and feels weird. I'd prefer the more modern approach.
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.
That was my initial impulse as well! Unfortunately there seems to be a limitation:
MATLABType (1,1) string {mustBeMember(MATLABType, ZarrDatatype.MATLABTypes)}
results in:
Line 59: For input arguments, validation functions must only use previously declared positional arguments, the argument being validated, or literals.
And it felt worse to me to have to re-list valid types again as a literal
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.
Ooof.
You can call mustBeMember
directly. You could write a local function in the class that calls it with the right arguments.
function mustBeMATLABType(type)
mustBeMember(type, ZarrDatatype.MATLABTypes);
end
And then use
MATLABType (1,1) string {mustBeTextScalar, mustBeMATLABType}
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.
Good point!
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.
Please make sure that the changes have been qualified locally before merging the same.
classdef ZarrDatatype | ||
%ZARRDATATYPE Datatype of Zarr data | ||
% Represents the datatype mapping between MATLAB, Tensorstore, and Zarr | ||
|
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.
Missing copyright
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.
Added!
…for unsupported datatype in tZarrCreate
Yup, ran the tests when creating the PR and now with the new changes too! |
Move the logic of mapping between datatypes into a separate class, ZarrDatatype (instead of using dictionaries in Zarr class)
Fixes #14