This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # | |
| # Python code (with IPython timing) for comparing rle implementations. | |
| # See: https://twitter.com/double_thunk/status/1358509387044827138?s=20 | |
| # | |
| import random | |
| import string | |
| import platform | |
| from itertools import groupby | |
| import numpy as np |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # -*- coding: utf-8 -*- | |
| import os | |
| import glob | |
| import numbers | |
| import warnings | |
| import dask.array as da | |
| import numpy as np | |
| import pims |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from itertools import starmap | |
| import numpy as np | |
| def closest_to_point(point, mask, mask_offset=None, voxel_size=None): | |
| """ | |
| Find the point in the mask that is closest to the given point. | |
| Args: | |
| point: | |
| The point to find the closest point to. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from collections.abc import Callable, Iterable | |
| from functools import partial | |
| # See discussion in https://news.ycombinator.com/item?id=44942936 | |
| def pipe(orig, *transforms): | |
| result = orig | |
| for transform in transforms: | |
| if isinstance(transform, Callable): | |
| result = transform(result) |
OlderNewer