diff --git a/src/clumerge.m b/src/clumerge.m index cd58f26..4fb6ae2 100644 --- a/src/clumerge.m +++ b/src/clumerge.m @@ -215,15 +215,9 @@ function t = common_supertype(type1, type2) type_set = { type1, type2 }; - validtypes = {'logical', 'int8', 'uint8', 'int16', 'uint16', ... - 'int32', 'uint32', 'int64', 'uint64', 'char', 'single', 'double'}; if strcmp(type1, type2) t = type1; - elseif ~string_in(type1, validtypes) - error(['Unsupported type `', type1 ,'`']); - elseif ~string_in(type2, validtypes) - error(['Unsupported type `', type2 ,'`']); elseif string_in('char', type_set) error('No common supertype between char and numerical type') elseif string_in('double', type_set) diff --git a/tests/tests_all.m b/tests/tests_all.m index 8c0a988..5219dcd 100644 --- a/tests/tests_all.m +++ b/tests/tests_all.m @@ -1775,42 +1775,33 @@ fn = @() clumerge({1, 2, 3}); assertError(fn); - % Invalid type in one of the data sets - nd = 5; - ds1 = struct(... - 'points', rand(npts, nd), ... - 'clusters', cell(npts, 1)); - ds2 = struct(... - 'points', rand(npts, nd), ... - 'clusters', int64(randi(10, npts, 1))); - fn = @() clumerge({ds1, ds2}); - assertError(fn); - fn = @() clumerge({ds2, ds1}); - assertError(fn); - % No common supertype between char and numerical type nd = 6; + npts1 = randi([10 100]); + npts2 = randi([10 100]); ds1 = struct(... - 'points', rand(npts, nd), ... - 'clusters', int64(randi(10, npts, 1))); + 'points', rand(npts1, nd), ... + 'clusters', int64(randi(10, npts1, 1))); ds2 = struct(... - 'points', char(randi(255, npts, nd)), ... - 'clusters', int64(randi(10, npts, 1))); + 'points', char(randi(255, npts2, nd)), ... + 'clusters', int64(randi(10, npts2, 1))); fn = @() clumerge({ds1, ds2}); assertError(fn); % There should be no problem with different compatible types nd = 4; + npts1 = randi([10 100]); + npts2 = randi([10 100]); ds1 = struct(... - 'points', single(rand(npts, nd)), ... - 'another', int16(randi(1000, npts, 1)), ... - 'and_another', int16(randi(500, npts, 1)), ... - 'clusters', int64(randi(10, npts, 1))); + 'points', single(rand(npts1, nd)), ... + 'another', int16(randi(1000, npts1, 1)), ... + 'and_another', int16(randi(500, npts1, 1)), ... + 'clusters', int64(randi(10, npts1, 1))); ds2 = struct(... - 'points', rand(npts, nd), ... - 'another', single(randi(1000, npts, 1)), ... - 'and_another', int32(randi(500, npts, 1)), ... - 'clusters', int32(randi(10, npts, 1))); + 'points', rand(npts2, nd), ... + 'another', single(randi(1000, npts2, 1)), ... + 'and_another', int32(randi(500, npts2, 1)), ... + 'clusters', int32(randi(10, npts2, 1))); lastwarn(''); mds = clumerge({ds1, ds2}, ... 'fields', {'points', 'another', 'and_another'});