Python future_builtins.map() Examples
The following are 18
code examples of future_builtins.map().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
future_builtins
, or try the search function
.
Example #1
Source File: ptr.py From pytest-runner with MIT License | 6 votes |
def run(self): """ Override run to ensure requirements are available in this session (but don't install them anywhere). """ self._warn_old_setuptools() dist = CustomizedDist() for attr in 'allow_hosts index_url'.split(): setattr(dist, attr, getattr(self, attr)) for attr in ( 'dependency_links install_requires ' 'tests_require extras_require ' ).split(): setattr(dist, attr, getattr(self.distribution, attr)) installed_dists = self.install_dists(dist) if self.dry_run: self.announce('skipping tests (dry run)') return paths = map(_operator.attrgetter('location'), installed_dists) with self.paths_on_pythonpath(paths): with self.project_on_sys_path(): return self.run_tests()
Example #2
Source File: ptr.py From pytest-runner with MIT License | 6 votes |
def install_extra_dists(self, dist): """ Install extras that are indicated by markers or install all extras if '--extras' is indicated. """ extras_require = dist.extras_require or {} spec_extras = ( (spec.partition(':'), reqs) for spec, reqs in extras_require.items() ) matching_extras = ( reqs for (name, sep, marker), reqs in spec_extras # include unnamed extras or all if self.extras indicated if (not name or self.extras) # never include extras that fail to pass marker eval and self.marker_passes(marker) ) results = list(map(dist.fetch_build_eggs, matching_extras)) return _itertools.chain.from_iterable(results)
Example #3
Source File: ptr.py From matrixcli with GNU General Public License v3.0 | 6 votes |
def install_extra_dists(self, dist): """ Install extras that are indicated by markers or install all extras if '--extras' is indicated. """ extras_require = dist.extras_require or {} spec_extras = ( (spec.partition(':'), reqs) for spec, reqs in extras_require.items() ) matching_extras = ( reqs for (name, sep, marker), reqs in spec_extras # include unnamed extras or all if self.extras indicated if (not name or self.extras) # never include extras that fail to pass marker eval and self.marker_passes(marker) ) results = list(map(dist.fetch_build_eggs, matching_extras)) return _itertools.chain.from_iterable(results)
Example #4
Source File: ptr.py From matrixcli with GNU General Public License v3.0 | 6 votes |
def run(self): """ Override run to ensure requirements are available in this session (but don't install them anywhere). """ self._warn_old_setuptools() dist = CustomizedDist() for attr in 'allow_hosts index_url'.split(): setattr(dist, attr, getattr(self, attr)) for attr in ( 'dependency_links install_requires ' 'tests_require extras_require ' ).split(): setattr(dist, attr, getattr(self.distribution, attr)) installed_dists = self.install_dists(dist) if self.dry_run: self.announce('skipping tests (dry run)') return paths = map(_operator.attrgetter('location'), installed_dists) with self.paths_on_pythonpath(paths): with self.project_on_sys_path(): return self.run_tests()
Example #5
Source File: segy.py From segyio with GNU Lesser General Public License v3.0 | 6 votes |
def test_traces_raw(openfn, kwargs): with openfn(**kwargs) as f: gen_traces = np.array(list(map(np.copy, f.trace)), dtype=np.single) raw_traces = f.trace.raw[:] assert np.array_equal(gen_traces, raw_traces) assert len(gen_traces) == f.tracecount assert len(raw_traces) == f.tracecount assert gen_traces[0][49] == raw_traces[0][49] assert gen_traces[1][49] == f.trace.raw[1][49] assert gen_traces[2][49] == raw_traces[2][49] assert np.array_equal(f.trace[10], f.trace.raw[10]) for raw, gen in zip(f.trace.raw[::2], f.trace[::2]): assert np.array_equal(raw, gen) for raw, gen in zip(f.trace.raw[::-1], f.trace[::-1]): assert np.array_equal(raw, gen)
Example #6
Source File: ptr.py From Brancher with MIT License | 6 votes |
def install_extra_dists(self, dist): """ Install extras that are indicated by markers or install all extras if '--extras' is indicated. """ extras_require = dist.extras_require or {} spec_extras = ( (spec.partition(':'), reqs) for spec, reqs in extras_require.items() ) matching_extras = ( reqs for (name, sep, marker), reqs in spec_extras # include unnamed extras or all if self.extras indicated if (not name or self.extras) # never include extras that fail to pass marker eval and self.marker_passes(marker) ) results = list(map(dist.fetch_build_eggs, matching_extras)) return _itertools.chain.from_iterable(results)
Example #7
Source File: ptr.py From Brancher with MIT License | 6 votes |
def run(self): """ Override run to ensure requirements are available in this session (but don't install them anywhere). """ self._warn_old_setuptools() dist = CustomizedDist() for attr in 'allow_hosts index_url'.split(): setattr(dist, attr, getattr(self, attr)) for attr in ( 'dependency_links install_requires ' 'tests_require extras_require ' ).split(): setattr(dist, attr, getattr(self.distribution, attr)) installed_dists = self.install_dists(dist) if self.dry_run: self.announce('skipping tests (dry run)') return paths = map(_operator.attrgetter('location'), installed_dists) with self.paths_on_pythonpath(paths): with self.project_on_sys_path(): return self.run_tests()
Example #8
Source File: segy.py From segyio with GNU Lesser General Public License v3.0 | 6 votes |
def test_traces_slicing(openfn, kwargs): with openfn(**kwargs) as f: traces = list(map(np.copy, f.trace[0:6:2])) assert len(traces) == 3 assert traces[0][49] == f.trace[0][49] assert traces[1][49] == f.trace[2][49] assert traces[2][49] == f.trace[4][49] rev_traces = list(map(np.copy, f.trace[4::-2])) assert rev_traces[0][49] == f.trace[4][49] assert rev_traces[1][49] == f.trace[2][49] assert rev_traces[2][49] == f.trace[0][49] # make sure buffers can be reused for i, trace in enumerate(f.trace[0:6:2]): assert np.array_equal(trace, traces[i])
Example #9
Source File: test_future_builtins.py From gcblue with BSD 3-Clause "New" or "Revised" License | 5 votes |
def test_itertools(self): from itertools import imap, izip, ifilter # We will assume that the itertools functions work, so provided # that we've got identical coppies, we will work! self.assertEqual(map, imap) self.assertEqual(zip, izip) self.assertEqual(filter, ifilter) # Testing that filter(None, stuff) raises a warning lives in # test_py3kwarn.py
Example #10
Source File: test_future_builtins.py From CTFCrackTools with GNU General Public License v3.0 | 5 votes |
def test_itertools(self): from itertools import imap, izip, ifilter # We will assume that the itertools functions work, so provided # that we've got identical coppies, we will work! self.assertEqual(map, imap) self.assertEqual(zip, izip) self.assertEqual(filter, ifilter) # Testing that filter(None, stuff) raises a warning lives in # test_py3kwarn.py
Example #11
Source File: segy.py From segyio with GNU Lesser General Public License v3.0 | 5 votes |
def test_traces_subslicing(openfn, kwargs): with openfn(**kwargs) as f: # test all sign permutations using full slice assert np.array_equal(f.trace[0, 0:6:2], f.trace[0][0:6:2]) assert np.array_equal(f.trace[0, 0:-2:2], f.trace[0][0:-2:2]) assert np.array_equal(f.trace[0, 10:2:-3], f.trace[0][10:2:-3]) assert np.array_equal(f.trace[0, -10:50:1], f.trace[0][-10:50:1]) assert np.array_equal(f.trace[0, -4:-2:1], f.trace[0][-4:-2:1]) assert np.array_equal(f.trace[0, -4:0:-2], f.trace[0][-4:0:-2]) assert np.array_equal(f.trace[0, 50:-50:-3], f.trace[0][50:-50:-3]) # test all sign permutations using start:stop assert np.array_equal(f.trace[0, 0:6], f.trace[0][0:6]) assert np.array_equal(f.trace[0, 0:-3], f.trace[0][0:-3]) assert np.array_equal(f.trace[0, -4:-2], f.trace[0][-4:-2]) assert np.array_equal(f.trace[0, -4:50], f.trace[0][-4:50]) assert np.array_equal(f.trace[0, -4:-2], f.trace[0][-4:-2]) # test all sign permutations using start::step assert np.array_equal(f.trace[0, 0::2], f.trace[0][0::2]) assert np.array_equal(f.trace[0, 10::-1], f.trace[0][10::-1]) assert np.array_equal(f.trace[0, -5::3], f.trace[0][-5::3]) assert np.array_equal(f.trace[0, -5::-1], f.trace[0][-5::-1]) # test all sign permutations using :stop:step assert np.array_equal(f.trace[0, :6:2], f.trace[0][:6:2]) assert np.array_equal(f.trace[0, :6:-1], f.trace[0][:6:-1]) assert np.array_equal(f.trace[0, :-6:2], f.trace[0][:-6:2]) assert np.array_equal(f.trace[0, :-6:-2], f.trace[0][:-6:-2]) # test all sign permutations using start:, :stop, and ::step assert np.array_equal(f.trace[0, 1:], f.trace[0][1:]) assert np.array_equal(f.trace[0, -3:], f.trace[0][-3:]) assert np.array_equal(f.trace[0, :3], f.trace[0][:3]) assert np.array_equal(f.trace[0, :-1], f.trace[0][:-1]) assert np.array_equal(f.trace[0, ::-1], f.trace[0][::-1]) assert np.array_equal(f.trace[0, ::2], f.trace[0][::2]) # test getting single element assert f.trace[0, 1] == f.trace[0][1] assert f.trace[0, -3] == f.trace[0][-3] # Combining trace and sub-trace slicing traces = list(map(np.copy, f.trace[0:6:2, 0:6])) assert len(traces) == 3 assert traces[0].shape[0] == 6
Example #12
Source File: test_future_builtins.py From CTFCrackTools-V2 with GNU General Public License v3.0 | 5 votes |
def test_itertools(self): from itertools import imap, izip, ifilter # We will assume that the itertools functions work, so provided # that we've got identical coppies, we will work! self.assertEqual(map, imap) self.assertEqual(zip, izip) self.assertEqual(filter, ifilter) # Testing that filter(None, stuff) raises a warning lives in # test_py3kwarn.py
Example #13
Source File: test_future_builtins.py From ironpython2 with Apache License 2.0 | 5 votes |
def test_itertools(self): from itertools import imap, izip, ifilter # We will assume that the itertools functions work, so provided # that we've got identical coppies, we will work! self.assertEqual(map, imap) self.assertEqual(zip, izip) self.assertEqual(filter, ifilter) # Testing that filter(None, stuff) raises a warning lives in # test_py3kwarn.py
Example #14
Source File: installer.py From kitty with GNU General Public License v3.0 | 5 votes |
def run(*args): if len(args) == 1: args = shlex.split(args[0]) args = list(map(encode_for_subprocess, args)) ret = subprocess.Popen(args).wait() if ret != 0: raise SystemExit(ret)
Example #15
Source File: __init__.py From build-calibre with GNU General Public License v3.0 | 5 votes |
def initialize_constants(): src = read_cal_file('constants.py') nv = re.search(r'numeric_version\s+=\s+\((\d+), (\d+), (\d+)\)', src) calibre_constants['version'] = '%s.%s.%s' % (nv.group(1), nv.group(2), nv.group(3)) calibre_constants['appname'] = re.search(r'__appname__\s+=\s+(u{0,1})[\'"]([^\'"]+)[\'"]', src).group(2) epsrc = re.compile(r'entry_points = (\{.*?\})', re.DOTALL).search(read_cal_file('linux.py')).group(1) entry_points = eval(epsrc, {'__appname__': calibre_constants['appname']}) def e2b(ep): return re.search(r'\s*(.*?)\s*=', ep).group(1).strip() def e2s(ep, base='src'): return (base + os.path.sep + re.search(r'.*=\s*(.*?):', ep).group(1).replace('.', '/') + '.py').strip() def e2m(ep): return re.search(r'.*=\s*(.*?)\s*:', ep).group(1).strip() def e2f(ep): return ep[ep.rindex(':') + 1:].strip() calibre_constants['basenames'] = basenames = {} calibre_constants['functions'] = functions = {} calibre_constants['modules'] = modules = {} calibre_constants['scripts'] = scripts = {} for x in ('console', 'gui'): y = x + '_scripts' basenames[x] = list(map(e2b, entry_points[y])) functions[x] = list(map(e2f, entry_points[y])) modules[x] = list(map(e2m, entry_points[y])) scripts[x] = list(map(e2s, entry_points[y])) src = read_cal_file('ebooks/__init__.py') be = re.search(r'^BOOK_EXTENSIONS\s*=\s*(\[.+?\])', src, flags=re.DOTALL | re.MULTILINE).group(1) calibre_constants['book_extensions'] = json.loads(be.replace("'", '"'))
Example #16
Source File: test_future_builtins.py From oss-ftp with MIT License | 5 votes |
def test_itertools(self): from itertools import imap, izip, ifilter # We will assume that the itertools functions work, so provided # that we've got identical coppies, we will work! self.assertEqual(map, imap) self.assertEqual(zip, izip) self.assertEqual(filter, ifilter) # Testing that filter(None, stuff) raises a warning lives in # test_py3kwarn.py
Example #17
Source File: test_future_builtins.py From BinderFilter with MIT License | 5 votes |
def test_itertools(self): from itertools import imap, izip, ifilter # We will assume that the itertools functions work, so provided # that we've got identical coppies, we will work! self.assertEqual(map, imap) self.assertEqual(zip, izip) self.assertEqual(filter, ifilter) # Testing that filter(None, stuff) raises a warning lives in # test_py3kwarn.py
Example #18
Source File: segy.py From segyio with GNU Lesser General Public License v3.0 | 4 votes |
def test_attributes(openfn, kwargs): with openfn(**kwargs) as f: il = kwargs.get('iline', TraceField.INLINE_3D) xl = kwargs.get('xline', TraceField.CROSSLINE_3D) assert 1 == f.attributes(il)[0] assert 20 == f.attributes(xl)[0] assert f.tracecount == len(f.attributes(il)) assert iter(f.attributes(il)) ils = [(i // 5) + 1 for i in range(25)] attrils = list(map(int, f.attributes(il)[:])) assert ils == attrils xls = [(i % 5) + 20 for i in range(25)] attrxls = list(map(int, f.attributes(xl)[:])) assert xls == attrxls ils = [(i // 5) + 1 for i in range(25)][::-1] attrils = list(map(int, f.attributes(il)[::-1])) assert ils == attrils xls = [(i % 5) + 20 for i in range(25)][::-1] attrxls = list(map(int, f.attributes(xl)[::-1])) assert xls == attrxls assert f.header[0][il] == f.attributes(il)[0] f.mmap() assert f.header[0][il] == f.attributes(il)[0] ils = [(i // 5) + 1 for i in range(25)][1:21:3] attrils = list(map(int, f.attributes(il)[1:21:3])) assert ils == attrils xls = [(i % 5) + 20 for i in range(25)][2:17:5] attrxls = list(map(int, f.attributes(xl)[2:17:5])) assert xls == attrxls ils = [1, 2, 3, 4, 5] attrils = list(map(int, f.attributes(il)[[0, 5, 11, 17, 23]])) assert ils == attrils ils = [1, 2, 3, 4, 5] indices = np.asarray([0, 5, 11, 17, 23]) attrils = list(map(int, f.attributes(il)[indices])) assert ils == attrils