def replace_supranationals(self, values): """Replaces the values if it contains a supranational code.""" for i, (code, value) in enumerate(values[:]): for suprakey in SUPRANATIONAL.keys(): if suprakey == code: values.extend( [(country, value) for country in SUPRANATIONAL[code]]) values.remove((code, value)) return values
def replace_supranationals(self, values): """Replaces the values if it contains a supranational code.""" for i, (code, value) in enumerate(values[:]): for suprakey in SUPRANATIONAL.keys(): if suprakey == code: values.extend([(country, value) for country in SUPRANATIONAL[code]]) values.remove((code, value)) return values
def test_supranationalworldmap(): set_countries(_COUNTRIES, True) datas = {} for i, supra in enumerate(SUPRANATIONAL): datas[supra] = i + 1 wmap = SupranationalWorldmap() wmap.add('supra', datas) q = wmap.render_pyquery() assert len(q('.country.color-0')) == len( reduce(operator.or_, map(set, SUPRANATIONAL.values())))
def test_supranationalworldmap(): set_countries(_COUNTRIES, True) datas = {} for i, supra in enumerate(SUPRANATIONAL): datas[supra] = i + 1 wmap = SupranationalWorldmap() wmap.add('supra', datas) q = wmap.render_pyquery() assert len( q('.country.color-0') ) == len( reduce(operator.or_, map(set, SUPRANATIONAL.values())))
def enumerate_values(self, serie): """Replaces the values if it contains a supranational code.""" for i, (code, value) in enumerate(serie.values): for subcode in SUPRANATIONAL.get(code, []): yield i, (subcode, value)