Skip to content

Instantly share code, notes, and snippets.

View mherkazandjian's full-sized avatar

Mher Kazandjian mherkazandjian

  • Freelance consultant
  • The Netherlands
View GitHub Profile
@mherkazandjian
mherkazandjian / parallel.py
Created February 14, 2017 02:03
pmap example
import numpy
from multiprocessing import Process, cpu_count, Queue
def pmap(func, items, func_args=(), func_kwargs={}, n_workers=cpu_count()):
"""Maps the function "func" to each item in "items" in parallel using
threads.
:param callable func: A callable that takes "array" as a first positional
argument and returns an array that is the same size the input "array".
@mherkazandjian
mherkazandjian / split_paths.py
Last active November 7, 2016 16:31
function that splits a path into all its components
def split_path(path):
"""split a path fully into its components
:param path: input path string
:return: list of the split path
.. todo:: see how to use generators with the yield statement
.. todo:: to replace the while loop
.. code-block:: python