This is a static copy of a profile report

Home

@categorical\private\reconcileCategories (Calls: 343805, Time: 1.976 s)
Generated 04-Jun-2021 04:11:26 using performance time.
function in file C:\Program Files\MATLAB\R2020b\toolbox\matlab\datatypes\categorical\@categorical\private\reconcileCategories.m
Copy to new window for comparing multiple runs

Parents (calling functions)

Function NameFunction TypeCalls
categorical.eqfunction74690
categorical.nefunction269115
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
17
if isequal(anames,bnames)
3438050.857 s43.4%
58
end
3438050.379 s19.2%
15
anames = a.categoryNames;
3438050.102 s5.1%
11
elseif a.isOrdinal ~= b.isOrdi...
3438050.081 s4.1%
16
bnames = b.categoryNames;
3438050.076 s3.8%
All other lines  0.481 s24.3%
Totals  1.976 s100% 
Children (called functions)
No children
Code Analyzer results
No Code Analyzer messages.
Coverage results
Show coverage for parent directory
Total lines in function58
Non-code lines (comments, blank lines)11
Code lines (lines that can run)47
Code lines that did run12
Code lines that did not run35
Coverage (did run/can run)25.53 %
Function listing
time 
Calls 
 line
   1 
function [acodes,bcodes,prototype] = reconcileCategories(a,b,requireOrdinal)
   2 
%RECONCILECATEGORIES Utility for logical comparison of categorical arrays.
   3 

   4 
%   Copyright 2013-2016 The MathWorks, Inc.
   5 

   6 
import matlab.internal.datatypes.isCharStrings
   7 

  0.024 
 343805 
   8
if isa(a,'categorical') && isa(b,'categorical') 
  0.017 
 343805 
   9
    if requireOrdinal && (~a.isOrdinal || ~b.isOrdinal) 
  10 
        throwAsCaller(MException(message('MATLAB:categorical:NotOrdinal')));
  0.081 
 343805 
  11
    elseif a.isOrdinal ~= b.isOrdinal 
  12 
        throwAsCaller(MException(message('MATLAB:categorical:OrdinalMismatchComparison')));
  0.011 
 343805 
  13
    end 
  0.041 
 343805 
  14
    acodes = a.codes; 
  0.102 
 343805 
  15
    anames = a.categoryNames; 
  0.076 
 343805 
  16
    bnames = b.categoryNames; 
  0.857 
 343805 
  17
    if isequal(anames,bnames) 
  0.046 
 343805 
  18
        bcodes = b.codes; 
  19 
        % Identical category names => same codes class => no cast needed for acodes
  20 
    elseif a.isOrdinal % && b.isOrdinal
  21 
        throwAsCaller(MException(message('MATLAB:categorical:InvalidOrdinalComparison')));
  22 
    else
  23 
        [bcodes,bnames] = convertCodes(b.codes,bnames,anames,a.isProtected,b.isProtected);
  24 
        if length(bnames) > length(anames)
  25 
            acodes = cast(acodes,'like',bcodes); % bcodes is always a higher or equivalent integer class as acodes
  26 
        end
  0.015 
 343805 
  27
    end 
  0.017 
 343805 
  28
    prototype = a; % preserve subclass 
  29 
    
  30 
elseif ischar(b) && (isrow(b) || isequal(b,'')) || isCharStrings(b) || (isstring(b) && isscalar(b)) % && isa(a,'categorical')
  31 
    if requireOrdinal && ~a.isOrdinal
  32 
        throwAsCaller(MException(message('MATLAB:categorical:NotOrdinal')));
  33 
    end
  34 
    acodes = a.codes;
  35 
    anames = a.categoryNames;
  36 
    [ib,ub] = strings2codes(b);
  37 
    [bcodes,bnames] = convertCodes(ib,ub,anames,a.isProtected,false);
  38 
    if length(bnames) > length(anames)
  39 
        acodes = cast(acodes,'like',bcodes); % bcodes is always a higher or equivalent integer class as acodes
  40 
    end
  41 
    prototype = a; % preserve subclass
  42 
    
  43 
elseif ischar(a) && (isrow(a) || isequal(a,'')) || isCharStrings(a) || (isstring(a) && isscalar(a)) % && isa(b,'categorical')
  44 
    if requireOrdinal && ~b.isOrdinal
  45 
        throwAsCaller(MException(message('MATLAB:categorical:NotOrdinal')));
  46 
    end
  47 
    bcodes = b.codes;
  48 
    bnames = b.categoryNames;
  49 
    [ia,ua] = strings2codes(a);
  50 
    [acodes,anames] = convertCodes(ia,ua,bnames,b.isProtected,false);
  51 
    if length(anames) > length(bnames)
  52 
        bcodes = cast(bcodes,'like',acodes); % acodes is always a higher or equivalent integer class as bcodes
  53 
    end
  54 
    prototype = b; % preserve subclass
  55 

  56 
else
  57 
    throwAsCaller(MException(message('MATLAB:categorical:InvalidComparisonTypes')));
  0.379 
 343805 
  58
end 

Other subfunctions in this file are not included in this listing.