def _sar_ear_inner(patch, cols, splits, divs, y_func):
(spp_col, count_col, x_col, y_col), patch =_get_cols(['<STR_LIT>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>'], cols, patch)<EOL>result_list = []<EOL>for substring, subpatch in _yield_subpatches(patch, splits):<EOL><INDENT>A0 = _patch_area(subpatch, x_col, y_col)<EOL>all_spp = np.unique(subpatch.table[spp_col])<EOL>subresultx = []<EOL>subresulty = []<EOL>subresultnspp = []<EOL>subresultnindivids = []<EOL>subdivlist = _split_divs(divs)<EOL>for subdiv in subdivlist:<EOL><INDENT>spatial_table = _yield_spatial_table(subpatch, subdiv, spp_col,<EOL>count_col, x_col, y_col)<EOL>subresulty.append(y_func(spatial_table, all_spp))<EOL>subresultx.append(A0 / eval(subdiv.replace('<STR_LIT:U+002C>', '<STR_LIT:*>')))<EOL>subresultnspp.append(np.mean(spatial_table['<STR_LIT>']))<EOL>subresultnindivids.append(np.mean(spatial_table['<STR_LIT>']))<EOL><DEDENT>subresult = pd.DataFrame({'<STR_LIT>': subdivlist, '<STR_LIT:x>': subresultx,<EOL>'<STR_LIT:y>': subresulty, '<STR_LIT>': subresultnspp,<EOL>'<STR_LIT>': subresultnindivids})<EOL>result_list.append((substring, subresult))<EOL><DEDENT>return result_list<EOL>
y_func is function calculating the mean number of species or endemics,
respectively, for the SAR or EAR