tpt === tpt_sumup --------- >>> from tpt import tpt_sumup >>> estL = ['Gi', 'A', 'O', 'F'] >>> tempL = [ ... ['09', [(0.7, -6.4, 11.7)]], ... ['08', [(0.9, -7.2, 13.5)]], ... ['07', [(3.2, -4.8, 16.1)]], ... ] >>> tmo_corr = [ ... ['09', 0.7, (-6.4, 'Gi'), (11.7, 'Gi')], ... ['08', 0.9, (-7.2, 'Gi'), (13.5, 'Gi')], ... ['07', 3.2, (-4.8, 'Gi'), (16.1, 'Gi')], ... ] >>> tmo = tpt_sumup(estL, tempL) >>> tmo == tmo_corr # doctesttag: +TAG=1_tpt_sumup True >>> tempL = [ ... ['09', [(0.7, -6.4, 11.7), (3.3, -3.9, 10.2), (0.9, -6.7, 10.8), (2.6, -3.0, 11.3)]], ... ['08', [(0.9, -7.2, 13.5), (2.3, -5.2, 13.0), (1.2, -6.1, 11.3), (3.3, -3.3, 13.0)]], ... ['07', [(3.2, -4.8, 16.1), (3.9, -3.5, 14.5), (5.0, -1.9, 11.7), (4.8, -1.5, 17.4)]], ... ] >>> tmo_corr = [ ... ['09', 1.88, (-6.7, 'O'), (11.7, 'Gi')], ... ['08', 1.92, (-7.2, 'Gi'), (13.5, 'Gi')], ... ['07', 4.22, (-4.8, 'Gi'), (17.4, 'F')], ... ] >>> tmo = tpt_sumup(estL, tempL) >>> tmo == tmo_corr # doctesttag: +TAG=1_tpt_sumup True >>> tempL = [ ... ['10:01:2024', [(4.2, 2.2, 15.5), (4.6, 3.2, 12.5), (2.0, 0.7, 12.8), (4.5, 2.8, 18.3)] ], ... ['09', [(0.7, -6.4, 11.7), (3.3, -3.9, 10.2), (0.9, -6.7, 10.8), (2.6, -3.0, 11.3)]], ... ['08', [(0.9, -7.2, 13.5), (2.3, -5.2, 13.0), (1.2, -6.1, 11.3), (3.3, -3.3, 13.0)]], ... ['07', [(3.2, -4.8, 16.1), (3.9, -3.5, 14.5), (5.0, -1.9, 11.7), (4.8, -1.5, 17.4)]], ... ['06:01:2024', [(6.5, -1.5, 15.0), (7.1, -1.7, 14.0), (5.1, -0.8, 13.6), (6.7, 0.3, 14.0)]], ... ] >>> tmo_corr = [ ... ['10:01:2024', 3.83, (0.7, 'O'), (18.3, 'F')], ... ['09', 1.88, (-6.7, 'O'), (11.7, 'Gi')], ... ['08', 1.92, (-7.2, 'Gi'), (13.5, 'Gi')], ... ['07', 4.22, (-4.8, 'Gi'), (17.4, 'F')], ... ['06:01:2024', 6.35, (-1.7, 'A'), (15.0, 'Gi')] ... ] >>> tmo = tpt_sumup(estL, tempL) >>> tmo == tmo_corr # doctesttag: +TAG=1_tpt_sumup True >>> tempL = [ ... ['10:01:2024', [(0.7, -6.4, 11.7), (3.3, -3.9, 10.2), (0.9, -6.7, 10.8), (2.6, -3.0, 11.3)] ], ... ] >>> tmo_corr = [ ... ['10:01:2024', 1.88, (-6.7, 'O'), (11.7, 'Gi')] ... ] >>> tmo = tpt_sumup(estL, tempL) >>> tmo == tmo_corr # doctesttag: +TAG=1_tpt_sumup True >>> tempL = [] >>> tmo_corr = [] >>> tmo = tpt_sumup(estL, tempL) >>> tmo == tmo_corr # doctesttag: +TAG=1_tpt_sumup True Dancers ======= gen_dances_D ------------ >>> from dancers import gen_dances_D >>> dni_D = { ... '678S': ('Inma', 'BCN'), ... '557D': ('Zoe', 'SC'), ... '778K': ('Eva', 'BCN'), ... '441K': ('Xavier', 'SC'), ... '779N': ('Adamo', 'BCN'), ... } >>> dni_dan_D = { ... '678S': ['B', 'LH'], ... '557D': ['LH', 'B'], ... '666Z': ['LH'], ... '779N': ['B'], ... } >>> ddan_corr = { ... 'B': [('Inma', 'BCN'), ('Zoe', 'SC'), ('Adamo', 'BCN')], ... 'LH': [('Inma', 'BCN'), ('Zoe', 'SC'), ('666Z', '?')], ... } >>> ddan = gen_dances_D(dni_D, dni_dan_D) >>> ddan == ddan_corr # doctesttag: +TAG=2_dancers-1_gen_dances_D True >>> dni_dan_D = { ... '666E': ['RR'], ... '678S': ['B', 'LH', 'RR'], ... '557D': ['LH', 'RR', 'B'], ... '441K': ['LH'], ... '666Z': ['LH'], ... '779N': ['B'], ... } >>> ddan_corr = { ... 'B': [('Inma', 'BCN'), ('Zoe', 'SC'), ('Adamo', 'BCN')], ... 'LH': [('Inma', 'BCN'), ('Zoe', 'SC'), ('Xavier', 'SC'), ('666Z', '?')], ... 'RR': [('666E', '?'), ('Inma', 'BCN'), ('Zoe', 'SC')], ... } >>> ddan = gen_dances_D(dni_D, dni_dan_D) >>> ddan == ddan_corr # doctesttag: +TAG=2_dancers-1_gen_dances_D True >>> dni_dan_D = { ... '678S': ['B', 'LH', 'RR', 'Shag'], ... '666E': ['B', 'LH', 'RR', 'Shag'], ... } >>> ddan_corr = { ... 'B': [('Inma', 'BCN'), ('666E', '?')], ... 'LH': [('Inma', 'BCN'), ('666E', '?')], ... 'RR': [('Inma', 'BCN'), ('666E', '?')], ... 'Shag': [('Inma', 'BCN'), ('666E', '?')], ... } >>> ddan = gen_dances_D(dni_D, dni_dan_D) >>> ddan == ddan_corr # doctesttag: +TAG=2_dancers-1_gen_dances_D True >>> dni_dan_D = {} >>> ddan_corr = {} >>> ddan = gen_dances_D(dni_D, dni_dan_D) >>> ddan == ddan_corr # doctesttag: +TAG=2_dancers-1_gen_dances_D True sort_dances_D ------------- >>> from dancers import sort_dances_D >>> D = { ... 'LH': [('Zoe', 'SC'), ('Inma', 'BCN'), ('Xavier', 'SC'), ('666Z', '?')], ... } >>> Dcorr = { ... 'LH': [('666Z', '?'), ('Inma', 'BCN'), ('Xavier', 'SC'), ('Zoe', 'SC')], ... } >>> sort_dances_D(D) >>> D == Dcorr # doctesttag: +TAG=2_dancers-2_sort_dances_D True >>> D = { ... 'Blues': [('Inma', 'BCN'), ('Zoe', 'SC'), ('Adamo', 'BCN')], ... 'LH': [('Zoe', 'SC'), ('Inma', 'BCN'), ('Xavier', 'SC'), ('666Z', '?')], ... } >>> Dcorr = { ... 'Blues': [('Adamo', 'BCN'), ('Inma', 'BCN'), ('Zoe', 'SC')], ... 'LH': [('666Z', '?'), ('Inma', 'BCN'), ('Xavier', 'SC'), ('Zoe', 'SC')], ... } >>> sort_dances_D(D) >>> D == Dcorr # doctesttag: +TAG=2_dancers-2_sort_dances_D True >>> D = { ... 'Blues': [('Inma', 'BCN'), ('Zoe', 'SC'), ('Adamo', 'BCN')], ... 'LH': [('Inma', 'BCN'), ('Zoe', 'SC'), ('Xavier', 'SC'), ('666Z', '?')], ... 'Rock&Roll': [('666E', '?'), ('Inma', 'BCN'), ('Zoe', 'SC')], ... } >>> Dcorr = { ... 'Blues': [('Adamo', 'BCN'), ('Inma', 'BCN'), ('Zoe', 'SC')], ... 'LH': [('666Z', '?'), ('Inma', 'BCN'), ('Xavier', 'SC'), ('Zoe', 'SC')], ... 'Rock&Roll': [('666E', '?'), ('Inma', 'BCN'), ('Zoe', 'SC')], ... } >>> sort_dances_D(D) >>> D == Dcorr # doctesttag: +TAG=2_dancers-2_sort_dances_D True >>> d = {} >>> sort_dances_D(d) >>> d == {} # doctesttag: +TAG=2_dancers-2_sort_dances_D True solargen ======== solargen_sum ------------ >>> from solargen2 import solargen_sum >>> inlines = [ ... 'grpD;3-13;on;2.0', ... 'grpC;2-19;on;2.4;*;*;3.0;4.1', ... 'grpB;1-13;on;*;3.9', ... 'grpA;1-15;on;3.5;2.5;4.0;*;7.0;3.2;4.0', ... ] >>> with open('in.txt', 'w') as f: ... for lin in inlines: ... f.write(lin+'\n') 17 29 19 39 >>> outlines_corr = [ ... 'grpD;3-13;1;2.0', ... 'grpC;2-19;3;9.5', ... 'grpB;1-13;1;3.9', ... 'grpA;1-15;6;24.2', ... ] >>> solargen_sum('in.txt', 'out.txt') >>> outlines = [] >>> with open('out.txt', 'r') as f: ... for lin in f: ... outlines.append(lin.strip()) >>> outlines == outlines_corr # doctesttag: +TAG=3_solargen-1_solargen_sum True >>> inlines = [ ... 'grpA;1-15;on;3.5;2.5;4.0;*;7.0;3.2;4.0', ... 'grpA;2-16;off;0.0;0.2;0.0;*;0.3;*', ... 'grpA;3-17;on;3.0;3.3;4.4;2.0;7.0;3.0;4.0;5.0', ... 'grpB;3-11;on;2.3;3.5', ... 'grpB;1-13;on;*;3.9', ... 'grpC;1-18;on;*;3.6;4.0;7.0;4.5;3.0', ... 'grpC;2-19;on;2.4;*;*;3.0;4.1', ... 'grpC;2-18;off;0.0;0.0;0.2;0.3;0.0', ... 'grpC;3-19;on;3.1;4.0;3.9;*;3.2', ... 'grpB;2-11;on;4.1;4.1;4.0', ... 'grpB;2-12;off;0.1;0.0;0.3', ... 'grpB;3-13;on;3.2;2.0;4.3', ... ] >>> with open('in.txt', 'w') as f: ... for lin in inlines: ... f.write(lin+'\n') 39 34 45 21 19 35 29 34 31 25 26 25 >>> outlines_corr = [ ... 'grpA;1-15;6;24.2', ... 'grpA;3-17;8;31.7', ... 'grpB;3-11;2;5.8', ... 'grpB;1-13;1;3.9', ... 'grpC;1-18;5;22.1', ... 'grpC;2-19;3;9.5', ... 'grpC;3-19;4;14.2', ... 'grpB;2-11;3;12.2', ... 'grpB;3-13;3;9.5', ... ] >>> solargen_sum('in.txt', 'out.txt') >>> outlines = [] >>> with open('out.txt', 'r') as f: ... for lin in f: ... outlines.append(lin.strip()) >>> outlines == outlines_corr # doctesttag: +TAG=3_solargen-1_solargen_sum True >>> inlines = [ ... 'grpA;1-15;on;*;*;*;*', ... 'grpA;2-16;on;0.0;0.0;0.0;0.0', ... ] >>> with open('in.txt', 'w') as f: ... for lin in inlines: ... f.write(lin+'\n') 21 29 >>> outlines_corr = [ ... 'grpA;1-15;0;0.0', ... 'grpA;2-16;4;0.0', ... ] >>> solargen_sum('in.txt', 'out.txt') >>> outlines = [] >>> with open('out.txt', 'r') as f: ... for lin in f: ... outlines.append(lin.strip()) >>> outlines == outlines_corr # doctesttag: +TAG=3_solargen-1_solargen_sum True >>> inlines = [ ... 'grpA;1-15;on;*', ... 'grpA;2-16;on;0.0', ... ] >>> with open('in.txt', 'w') as f: ... for lin in inlines: ... f.write(lin+'\n') 15 17 >>> outlines_corr = [ ... 'grpA;1-15;0;0.0', ... 'grpA;2-16;1;0.0', ... ] >>> solargen_sum('in.txt', 'out.txt') >>> outlines = [] >>> with open('out.txt', 'r') as f: ... for lin in f: ... outlines.append(lin.strip()) >>> outlines == outlines_corr # doctesttag: +TAG=3_solargen-1_solargen_sum True >>> import os >>> os.remove('in.txt') >>> os.remove('out.txt') solargen_sum_ordered -------------------- >>> from solargen2 import solargen_sum_ordered >>> inlines = [ ... 'gB;3-11;on;2.3;3.5', ... 'gB;1-13;on;*;3.9', ... 'gB;2-11;on;4.1;4.1;4.0', ... 'gB;2-12;on;0.1;0.0;0.3', ... 'gB;3-13;on;3.2;2.0;4.3', ... ] --input-fi >>> with open('in.txt', 'w') as f: ... for lin in inlines: ... f.write(lin+'\n') 19 17 23 23 23 >>> outlines_corr = [ ... 'gB;2-11;3;12.2', ... 'gB;3-13;3;9.5', ... 'gB;3-11;2;5.8', ... 'gB;1-13;1;3.9', ... 'gB;2-12;3;0.4', ... ] >>> solargen_sum_ordered('in.txt', 'out.txt') >>> outlines = [] >>> with open('out.txt', 'r') as f: ... for lin in f: ... outlines.append(lin.strip()) >>> outlines == outlines_corr # doctesttag: +TAG=3_solargen-2_solargen_sum_ordered True >>> inlines = [ ... 'gA;1-15;on;3.5;2.5;4.0;*;7.0;3.2;4.0', ... 'gA;2-16;off;0.0;0.2;0.0;*;0.3;*', ... 'gA;3-17;on;3.0;3.3;4.4;2.0;7.0;3.0;4.0;5.0', ... 'gB;3-11;on;2.3;3.5', ... 'gB;1-13;on;*;3.9', ... 'gC;1-18;on;*;3.6;4.0;7.0;4.5;3.0', ... 'gC;2-19;on;2.4;*;*;3.0;4.1', ... 'gC;2-18;off;0.0;0.0;0.2;0.3;0.0', ... 'gC;3-19;on;3.1;4.0;3.9;*;3.2', ... 'gB;2-11;on;4.1;4.1;4.0', ... 'gB;2-12;off;0.1;0.0;0.3', ... 'gB;3-13;on;3.2;2.0;4.3', ... ] >>> with open('in.txt', 'w') as f: ... for lin in inlines: ... f.write(lin+'\n') 37 32 43 19 17 33 27 32 29 23 24 23 >>> outlines_corr = [ ... 'gA;3-17;8;31.7', ... 'gA;1-15;6;24.2', ... 'gB;2-11;3;12.2', ... 'gB;3-13;3;9.5', ... 'gB;3-11;2;5.8', ... 'gB;1-13;1;3.9', ... 'gC;1-18;5;22.1', ... 'gC;3-19;4;14.2', ... 'gC;2-19;3;9.5', ... ] --output-fi >>> solargen_sum_ordered('in.txt', 'out.txt') >>> outlines = [] >>> with open('out.txt', 'r') as f: ... for lin in f: ... outlines.append(lin.strip()) >>> outlines == outlines_corr # doctesttag: +TAG=3_solargen-2_solargen_sum_ordered True >>> inlines = [ ... 'grpD;3-13;on;2.0', ... 'grpC;2-19;on;2.4;*;*;3.0;4.1', ... 'grpB;1-13;on;*;3.9', ... 'grpA;1-15;on;3.5;2.5;4.0;*;7.0;3.2;4.0', ... ] >>> with open('in.txt', 'w') as f: ... for lin in inlines: ... f.write(lin+'\n') 17 29 19 39 >>> outlines_corr = [ ... 'grpA;1-15;6;24.2', ... 'grpB;1-13;1;3.9', ... 'grpC;2-19;3;9.5', ... 'grpD;3-13;1;2.0', ... ] >>> solargen_sum_ordered('in.txt', 'out.txt') >>> outlines = [] >>> with open('out.txt', 'r') as f: ... for lin in f: ... outlines.append(lin.strip()) >>> outlines == outlines_corr # doctesttag: +TAG=3_solargen-2_solargen_sum_ordered True >>> inlines = [ ... 'grpA;1-15;on;*;*;*;*', ... 'grpA;2-16;on;0.0;0.0;0.0;0.0', ... ] >>> with open('in.txt', 'w') as f: ... for lin in inlines: ... f.write(lin+'\n') 21 29 >>> outlines_corr = [ ... 'grpA;1-15;0;0.0', ... 'grpA;2-16;4;0.0', ... ] >>> solargen_sum_ordered('in.txt', 'out.txt') >>> outlines = [] >>> with open('out.txt', 'r') as f: ... for lin in f: ... outlines.append(lin.strip()) >>> outlines == outlines_corr # doctesttag: +TAG=3_solargen-2_solargen_sum_ordered True >>> inlines = [ ... 'grpA;1-15;on;*', ... 'grpA;2-16;on;0.0', ... ] >>> with open('in.txt', 'w') as f: ... for lin in inlines: ... f.write(lin+'\n') 15 17 >>> outlines_corr = [ ... 'grpA;1-15;0;0.0', ... 'grpA;2-16;1;0.0', ... ] >>> solargen_sum_ordered('in.txt', 'out.txt') >>> outlines = [] >>> with open('out.txt', 'r') as f: ... for lin in f: ... outlines.append(lin.strip()) >>> outlines == outlines_corr # doctesttag: +TAG=3_solargen-2_solargen_sum_ordered True >>> import os >>> os.remove('in.txt') >>> os.remove('out.txt') gen_palindromes --------------- >>> from palindromes import gen_palindromes >>> l = ['ab', 'a', 'ba'] >>> lcorr = ['aba', 'abba', 'baab'] >>> lsol = gen_palindromes(l) >>> eq = True >>> for w in lsol: ... eq = eq and (w in lcorr) >>> len(lsol) == len(lcorr) and eq # doctesttag: +TAG=4_gen_palindromes True >>> l = ['ab', 'bala', 'ba', 'lab', 'ol', 'al', 'lal'] >>> lsol = gen_palindromes(l) >>> lcorr = ['abba', 'baab', 'balalab', 'balab', 'labal', 'lalal'] >>> eq = True >>> for w in lsol: ... eq = eq and (w in lcorr) >>> len(lsol) == len(lcorr) and eq # doctesttag: +TAG=4_gen_palindromes True >>> l = ['a', 'ab', 'aba', 'abab', 'ababa'] >>> lsol = gen_palindromes(l) >>> lcorr = ['aba', 'ababa', 'abababa', 'ababababa'] >>> eq = True >>> for w in lsol: ... eq = eq and (w in lcorr) >>> len(lsol) == len(lcorr) and eq # doctesttag: +TAG=4_gen_palindromes True >>> l = ['aba'] >>> gen_palindromes(l) # doctesttag: +TAG=4_gen_palindromes [] >>> l = [] >>> gen_palindromes(l) # doctesttag: +TAG=4_gen_palindromes []