File tree Expand file tree Collapse file tree 2 files changed +6
-5
lines changed Expand file tree Collapse file tree 2 files changed +6
-5
lines changed Original file line number Diff line number Diff line change 8181 try
8282 val = types .util .correctType(val , type );
8383 catch ME
84- keyboard ;
8584 error(' MATNWB:CASTERROR' , ' Could not cast type `%s ` to `%s ` for property `%s `' ,...
8685 class(val ), type , name );
8786 end
Original file line number Diff line number Diff line change 22% CORRECTTYPE upcasts if type is smaller than minimum
33% Will error if type is simply incompatible
44% Will throw if casting is impossible
5-
5+ if nargin < 3
6+ allowDowncast = false ;
7+ end
68% check different types and correct
79
810if startsWith(type , ' float' ) && ~isfloat(val )
1820end
1921
2022% check different types sizes and upcast to meet minimum (if applicable)
21- if any(strcmp(type , {' float64' ' float32' })
22- if issingle (val )
23+ if any(strcmp(type , {' float64' ' float32' }))
24+ if isa (val , ' single ' )
2325 val = double(val );
2426 elseif allowDowncast && strcmp(type , ' float32' )
2527 val = single(val );
3335 typsz = sscanf(type , pattern );
3436 valsz = sscanf(class(val ), pattern );
3537
36- if valsz < typsz || ( nargin > 2 && allowDowncast )
38+ if valsz < typsz || allowDowncast
3739 val = eval([type ' (val)' ]);
3840 end
3941end
You can’t perform that action at this time.
0 commit comments