>>> from mitjanes import normalitza_pesos >>> p = iter([0.3, 0.7, 0.45, 0.72, 1.35, 2.47]) >>> pn = normalitza_pesos(p) >>> list(round(x, 2) for x in pn) # doctesttag: +TAG=1_mitjanes [0.05, 0.12, 0.08, 0.12, 0.23, 0.41] >>> p = iter([4.2, 0.3, 7.4, 0.7, 0.45, 0.72, 0.69, 1.35, 2.47, 1.456, 2.974]) >>> pn = normalitza_pesos(p) >>> list(round(x, 2) for x in pn) # doctesttag: +TAG=1_mitjanes [0.18, 0.01, 0.33, 0.03, 0.02, 0.03, 0.03, 0.06, 0.11, 0.06, 0.13] >>> p = iter([4.2, 3.42, 0.3, 7.4, 4.3, 0.7, 0.45, 0.72, 6.7, 0.69, 1.1, 1.35, 2.47, 0.025, 1.456, 3.07, 2.974]) >>> pn = normalitza_pesos(p) >>> list(round(x, 2) for x in pn) # doctesttag: +TAG=1_mitjanes [0.1, 0.08, 0.01, 0.18, 0.1, 0.02, 0.01, 0.02, 0.16, 0.02, 0.03, 0.03, 0.06, 0.0, 0.04, 0.07, 0.07] >>> p = iter([5.5, 4.2, 3.42, 0.3, 7.4, 9.2, 4.3, 0.7, 0.45, 12.5, 0.72, 6.7, 0.69, 4.5, 1.1, 1.35, 2.47, 7.8, 0.025, 1.456, 9.4, 3.07, 2.974]) >>> pn = normalitza_pesos(p) >>> list(round(x, 4) for x in pn) # doctesttag: +TAG=1_mitjanes [0.061, 0.0466, 0.0379, 0.0033, 0.082, 0.102, 0.0477, 0.0078, 0.005, 0.1385, 0.008, 0.0743, 0.0076, 0.0499, 0.0122, 0.015, 0.0274, 0.0865, 0.0003, 0.0161, 0.1042, 0.034, 0.033] >>> p = iter([0.3, 0.05, 0.15, 0.35, 0.15]) >>> pn = normalitza_pesos(p) >>> list(round(x, 2) for x in pn) # doctesttag: +TAG=1_mitjanes [0.3, 0.05, 0.15, 0.35, 0.15] >>> p = iter([0.54, 0.67, 0.8, 0.88, 0.27, 0.19, 0.13, 0.73, 0.9, 0.35, 0.14, 0.49, 0.71, 0.58, 0.73, 0.01, 0.86, 0.01, 1.24, 0.08, 1.16, 0.01, 0.7, 0.44, 0.63, 0.67, 0.14, 0.96, 0.32, 0.07, 0.1, 0.82, 0.26, 0.67, 1.14]) >>> pn = normalitza_pesos(p) >>> list(round(x, 3) for x in pn) # doctesttag: +TAG=1_mitjanes [0.029, 0.036, 0.043, 0.048, 0.015, 0.01, 0.007, 0.04, 0.049, 0.019, 0.008, 0.027, 0.039, 0.032, 0.04, 0.001, 0.047, 0.001, 0.067, 0.004, 0.063, 0.001, 0.038, 0.024, 0.034, 0.036, 0.008, 0.052, 0.017, 0.004, 0.005, 0.045, 0.014, 0.036, 0.062] >>> p = iter([1.16, 0.07, 0.27, 0.07, 0.51]) >>> pn = normalitza_pesos(p) >>> list(round(x, 3) for x in pn) # doctesttag: +TAG=1_mitjanes [0.558, 0.034, 0.13, 0.034, 0.245] >>> p = iter([1.3, 0.48, 0.04, 0.54, 1.14, 0.28, 0.98, 1.2, 0.97, 0.9]) >>> pn = normalitza_pesos(p) >>> list(round(x, 3) for x in pn) # doctesttag: +TAG=1_mitjanes [0.166, 0.061, 0.005, 0.069, 0.146, 0.036, 0.125, 0.153, 0.124, 0.115] >>> p = iter([0.25, 1.03, 0.1, 0.85, 0.15, 1.17, 0.78, 0.06, 1.06, 0.55, 0.25, 0.66, 0.03, 0.08, 0.33]) >>> pn = normalitza_pesos(p) >>> list(round(x, 3) for x in pn) # doctesttag: +TAG=1_mitjanes [0.034, 0.14, 0.014, 0.116, 0.02, 0.159, 0.106, 0.008, 0.144, 0.075, 0.034, 0.09, 0.004, 0.011, 0.045] >>> p = iter([0.15, 0.6, 0.14, 0.27, 1.27, 1.11, 1.0, 1.26, 0.95, 0.6, 0.42, 1.13, 1.25, 1.23, 1.02, 0.11, 1.09, 0.54, 0.88, 1.24]) >>> pn = normalitza_pesos(p) >>> list(round(x, 3) for x in pn) # doctesttag: +TAG=1_mitjanes [0.009, 0.037, 0.009, 0.017, 0.078, 0.068, 0.062, 0.077, 0.058, 0.037, 0.026, 0.069, 0.077, 0.076, 0.063, 0.007, 0.067, 0.033, 0.054, 0.076] >>> from fraccions import suma_reciprocs >>> nbrs = iter((4, 2, 3)) >>> f = suma_reciprocs(nbrs) >>> f # doctesttag: +TAG=2_fraccions Fraction(13, 12) >>> nbrs = iter((5, 4, 8, 3)) >>> f = suma_reciprocs(nbrs) >>> f # doctesttag: +TAG=2_fraccions Fraction(109, 120) >>> nbrs = (4, 2, 3, 12, 5, 9, 23) >>> f = suma_reciprocs(nbrs) >>> f # doctesttag: +TAG=2_fraccions Fraction(3149, 2070) >>> nbrs = (7, 15, 4, 8, 2, 3, 12, 5, 9, 23) >>> f = suma_reciprocs(nbrs) >>> f # doctesttag: +TAG=2_fraccions Fraction(107561, 57960) >>> nbrs = [7, 15, 35, 4, 8, 41, 2, 3, 12, 64, 5, 9, 23, 37] >>> f = suma_reciprocs(nbrs) >>> f # doctesttag: +TAG=2_fraccions Fraction(1372615217, 703402560) >>> nbrs = [33, 59, 46, 52, 21, 54, 25, 91, 95] >>> f = suma_reciprocs(nbrs) >>> f # doctesttag: +TAG=2_fraccions Fraction(15042970069, 69683714100) >>> nbrs = [99, 3, 35, 26, 7, 72, 91, 18, 83, 54, 94, 58, 59, 29, 30] >>> f = suma_reciprocs(nbrs) >>> f # doctesttag: +TAG=2_fraccions Fraction(5606447852869, 7215788459880) >>> nbrs = [5, 13, 14, 17, 32, 35, 37, 38, 40, 45, 46, 55, 57, 68, 69, 79, 86, 87, 91] >>> f = suma_reciprocs(nbrs) >>> f # doctesttag: +TAG=2_fraccions Fraction(27361304531647337, 39032125074502560) >>> nbrs = [9, 11, 12, 13, 15, 17, 18, 19, 21, 22, 28, 37, 39, 57, 64, 65, 67, 71, 76, 79, 85, 86, 94] >>> f = suma_reciprocs(nbrs) >>> f # doctesttag: +TAG=2_fraccions Fraction(59995716965041219, 65581972111930560) >>> nbrs = [2, 4, 10, 12, 16, 17, 19, 20, 23, 43, 44, 46, 47, 48, 52, 58, 59, 60, 62, 66, 72, 73, 86, 91, 92, 95, 97] >>> f = suma_reciprocs(nbrs) >>> f # doctesttag: +TAG=2_fraccions Fraction(3035668730806792700117, 2032074134318027840040) >>> from datetime import timedelta >>> from pprint import pprint >>> from llistes_reproduccio import fins_on >>> lr1 = [ ... ("Una lluna a l'aigua", "Txarango", timedelta(minutes=4, seconds=27)), ... ("Volcans", "Buhos", timedelta(minutes=3, seconds=32)), ... ("Coti x Coti", "The Tyets", timedelta(minutes=2, seconds=27)), ... ("Al mar!", "Manel", timedelta(minutes=3, seconds=28)), ... ("In the night", "Oques Grasses", timedelta(minutes=2, seconds=56)), ... ("Pa amb oli i sal", "Blaumut", timedelta(minutes=3, seconds=47)), ... ("Ventiladors", "Zoo", timedelta(minutes=4, seconds=24)), ... ("Camins", "Sopa de Cabra", timedelta(minutes=3, seconds=16)), ... ("Vull estar amb tu", "Els Catarres", timedelta(minutes=3, seconds=3)), ... ("Caminem lluny", "Doctor Prats", timedelta(minutes=3, seconds=51)), ... ] >>> ilr1 = iter(lr1) >>> td1 = timedelta(minutes=5) >>> lrfao1 = fins_on(ilr1, td1) >>> r1 = list(lrfao1) >>> pprint(r1) # doctesttag: +TAG=3_llistes_reproduccio-no_buida [("Una lluna a l'aigua", 'Txarango', datetime.timedelta(seconds=267))] >>> ilr1 = iter(lr1) >>> td1 = timedelta(minutes=8) >>> lrfao1 = fins_on(ilr1, td1) >>> r1 = list(lrfao1) >>> pprint(r1) # doctesttag: +TAG=3_llistes_reproduccio-no_buida [("Una lluna a l'aigua", 'Txarango', datetime.timedelta(seconds=267)), ('Volcans', 'Buhos', datetime.timedelta(seconds=479))] >>> ilr1 = iter(lr1) >>> td1 = timedelta(minutes=11) >>> lrfao1 = fins_on(ilr1, td1) >>> r1 = list(lrfao1) >>> pprint(r1) # doctesttag: +TAG=3_llistes_reproduccio-no_buida [("Una lluna a l'aigua", 'Txarango', datetime.timedelta(seconds=267)), ('Volcans', 'Buhos', datetime.timedelta(seconds=479)), ('Coti x Coti', 'The Tyets', datetime.timedelta(seconds=626))] >>> ilr1 = iter(lr1) >>> td1 = timedelta(minutes=15) >>> lrfao1 = fins_on(ilr1, td1) >>> r1 = list(lrfao1) >>> pprint(r1) # doctesttag: +TAG=3_llistes_reproduccio-no_buida [("Una lluna a l'aigua", 'Txarango', datetime.timedelta(seconds=267)), ('Volcans', 'Buhos', datetime.timedelta(seconds=479)), ('Coti x Coti', 'The Tyets', datetime.timedelta(seconds=626)), ('Al mar!', 'Manel', datetime.timedelta(seconds=834))] >>> ilr1 = iter(lr1) >>> td1 = timedelta(minutes=20) >>> lrfao1 = fins_on(ilr1, td1) >>> r1 = list(lrfao1) >>> pprint(r1) # doctesttag: +TAG=3_llistes_reproduccio-no_buida [("Una lluna a l'aigua", 'Txarango', datetime.timedelta(seconds=267)), ('Volcans', 'Buhos', datetime.timedelta(seconds=479)), ('Coti x Coti', 'The Tyets', datetime.timedelta(seconds=626)), ('Al mar!', 'Manel', datetime.timedelta(seconds=834)), ('In the night', 'Oques Grasses', datetime.timedelta(seconds=1010))] >>> ilr1 = iter(lr1) >>> td1 = timedelta(seconds=1300) >>> lrfao1 = fins_on(ilr1, td1) >>> r1 = list(lrfao1) >>> pprint(r1) # doctesttag: +TAG=3_llistes_reproduccio-no_buida [("Una lluna a l'aigua", 'Txarango', datetime.timedelta(seconds=267)), ('Volcans', 'Buhos', datetime.timedelta(seconds=479)), ('Coti x Coti', 'The Tyets', datetime.timedelta(seconds=626)), ('Al mar!', 'Manel', datetime.timedelta(seconds=834)), ('In the night', 'Oques Grasses', datetime.timedelta(seconds=1010)), ('Pa amb oli i sal', 'Blaumut', datetime.timedelta(seconds=1237))] >>> ilr1 = iter(lr1) >>> td1 = timedelta(seconds=1510) >>> lrfao1 = fins_on(ilr1, td1) >>> r1 = list(lrfao1) >>> pprint(r1) # doctesttag: +TAG=3_llistes_reproduccio-no_buida [("Una lluna a l'aigua", 'Txarango', datetime.timedelta(seconds=267)), ('Volcans', 'Buhos', datetime.timedelta(seconds=479)), ('Coti x Coti', 'The Tyets', datetime.timedelta(seconds=626)), ('Al mar!', 'Manel', datetime.timedelta(seconds=834)), ('In the night', 'Oques Grasses', datetime.timedelta(seconds=1010)), ('Pa amb oli i sal', 'Blaumut', datetime.timedelta(seconds=1237)), ('Ventiladors', 'Zoo', datetime.timedelta(seconds=1501))] >>> ilr1 = iter(lr1) >>> td1 = timedelta(minutes=30) >>> lrfao1 = fins_on(ilr1, td1) >>> r1 = list(lrfao1) >>> pprint(r1) # doctesttag: +TAG=3_llistes_reproduccio-no_buida [("Una lluna a l'aigua", 'Txarango', datetime.timedelta(seconds=267)), ('Volcans', 'Buhos', datetime.timedelta(seconds=479)), ('Coti x Coti', 'The Tyets', datetime.timedelta(seconds=626)), ('Al mar!', 'Manel', datetime.timedelta(seconds=834)), ('In the night', 'Oques Grasses', datetime.timedelta(seconds=1010)), ('Pa amb oli i sal', 'Blaumut', datetime.timedelta(seconds=1237)), ('Ventiladors', 'Zoo', datetime.timedelta(seconds=1501)), ('Camins', 'Sopa de Cabra', datetime.timedelta(seconds=1697))] >>> ilr1 = iter(lr1) >>> td1 = timedelta(seconds=1885) >>> lrfao1 = fins_on(ilr1, td1) >>> r1 = list(lrfao1) >>> pprint(r1) # doctesttag: +TAG=3_llistes_reproduccio-no_buida [("Una lluna a l'aigua", 'Txarango', datetime.timedelta(seconds=267)), ('Volcans', 'Buhos', datetime.timedelta(seconds=479)), ('Coti x Coti', 'The Tyets', datetime.timedelta(seconds=626)), ('Al mar!', 'Manel', datetime.timedelta(seconds=834)), ('In the night', 'Oques Grasses', datetime.timedelta(seconds=1010)), ('Pa amb oli i sal', 'Blaumut', datetime.timedelta(seconds=1237)), ('Ventiladors', 'Zoo', datetime.timedelta(seconds=1501)), ('Camins', 'Sopa de Cabra', datetime.timedelta(seconds=1697)), ('Vull estar amb tu', 'Els Catarres', datetime.timedelta(seconds=1880))] >>> ilr1 = iter(lr1) >>> td1 = timedelta(minutes=50) >>> lrfao1 = fins_on(ilr1, td1) >>> r1 = list(lrfao1) >>> pprint(r1) # doctesttag: +TAG=3_llistes_reproduccio-no_buida [("Una lluna a l'aigua", 'Txarango', datetime.timedelta(seconds=267)), ('Volcans', 'Buhos', datetime.timedelta(seconds=479)), ('Coti x Coti', 'The Tyets', datetime.timedelta(seconds=626)), ('Al mar!', 'Manel', datetime.timedelta(seconds=834)), ('In the night', 'Oques Grasses', datetime.timedelta(seconds=1010)), ('Pa amb oli i sal', 'Blaumut', datetime.timedelta(seconds=1237)), ('Ventiladors', 'Zoo', datetime.timedelta(seconds=1501)), ('Camins', 'Sopa de Cabra', datetime.timedelta(seconds=1697)), ('Vull estar amb tu', 'Els Catarres', datetime.timedelta(seconds=1880)), ('Caminem lluny', 'Doctor Prats', datetime.timedelta(seconds=2111))] >>> ilr1 = iter(lr1) >>> td1 = timedelta(minutes=1) >>> lrfao1 = fins_on(ilr1, td1) >>> list(lrfao1) # doctesttag: +TAG=3_llistes_reproduccio-buida []