Godtone
Joined 17 December 2020
→My Python 3 code: fix |
m →My Python 3 code: argument name unclear (confused me more than once) |
||
| Line 1,553: | Line 1,553: | ||
# there is only finitely many EDOs which provide some simplification of a set of intervals as contrasted to all-distinct | # there is only finitely many EDOs which provide some simplification of a set of intervals as contrasted to all-distinct | ||
def efficient_edos( | def efficient_edos( ivs, inconsistencies=0, min_simplifications=1, edos=range(1,1000) ): | ||
if type( | if type(ivs)==int: | ||
ivs = odd_lim(ivs) | |||
elif type( | elif type(ivs)==list and type(ivs[0])==int: | ||
ivs = odd_lim(1,[],ivs) | |||
results = [] | results = [] | ||
for edo in edos: | for edo in edos: | ||
v = edo | v = edo | ||
if type(v)==int: | if type(v)==int: | ||
v = val( lim(max([ prime_idx(len(fact(x))-1) for x in | v = val( lim(max([ prime_idx(len(fact(x))-1) for x in ivs ])), ed(edo) ) | ||
# else v is assumed to be a mapping | # else v is assumed to be a mapping | ||
m = dict() | m = dict() | ||
for x in | for x in ivs: # collect mappings of intervals | ||
sedo = map_iv(v,x) | sedo = map_iv(v,x) | ||
if sedo in m: | if sedo in m: | ||
| Line 1,571: | Line 1,571: | ||
else: | else: | ||
m[sedo] = [x] | m[sedo] = [x] | ||
if len(inconsistent_ivs_by_val( | if len(inconsistent_ivs_by_val(ivs,v)) <= inconsistencies: | ||
if len( | if len(ivs) - len([ sedo for sedo in m ]) >= min_simplifications: | ||
results.append(edo) | results.append(edo) | ||
return results | return results | ||