View docker_terminal.sh
This file contains 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 a directory with a Dockerfile | |
# Example Dockerfile with "Dockerfile" as filename | |
FROM python:3.10-slim-buster | |
RUN pip install numpy | |
# Then, run the following | |
docker build -t your_image_name . |
View cmap.py
This file contains 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 matplotlib.colors import LinearSegmentedColormap | |
def black_to_color(high_color: tuple, low_color: tuple = (0,0,0), name: str = "my_color", steps=256): | |
"Get linear colormap from one rgb color to another, defaulting from black" | |
r1,g1,b1 = low_color | |
r2,g2,b2 = high_color | |
cdict = { | |
'red': [(0.0, r1, r1), |
View gist:4c63d9f15a6895a4153e9bfa98f75360
This file contains 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
cat /root/.jupyter/lab/user-settings/@jupyterlab/notebook-extension/tracker.jupyterlab-settings | |
{ | |
// Notebook | |
// @jupyterlab/notebook-extension:tracker | |
// Notebook settings. | |
// ************************************** | |
// Code Cell Configuration | |
// The configuration for all code cells. | |
"codeCellConfig": { |
View check_docker_running.sh
This file contains 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
if docker info > /dev/null 2>&1; then | |
: # pass | |
else | |
echo "Docker Daemon is not running. Please open it and retry." | |
exit -1 | |
fi |
View dask_inv_bench.py
This file contains 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
import numpy as np | |
import dask.array as da | |
x = da.random.random((120,500,500), chunks=(40, 500, 500)) # 80 MB chunks | |
X = x.compute() | |
@da.as_gufunc(signature="(n,n)->(n,n)", output_dtypes=float, vectorize=True) | |
def gufunc(x): | |
return np.linalg.inv(x) |
View gufunc.py
This file contains 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
--------------------------------------------------------------------------- | |
ValueError Traceback (most recent call last) | |
/var/folders/yt/z22_f0896l74f8gs3_20vc_00000gn/T/ipykernel_88946/1449311839.py in <module> | |
7 return np.linalg.inv(x) | |
8 | |
----> 9 y = gufoo(b) | |
~/mambaforge/envs/py/lib/python3.9/site-packages/dask/array/gufunc.py in __call__(self, *args, **kwargs) | |
659 | |
660 def __call__(self, *args, **kwargs): |
View bilinear_interpolate.py
This file contains 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
def bilinear_interpolate(img, points, clipped_nan=True): | |
"""Bilinearly interpolate points from an image using NumPy or CuPy | |
Args: | |
img: Image of shape (Y, X) to interpolate from. | |
points: array of shape (2, N) of (y, x) coordinates | |
clipped_nan: If True, the value of coordinates outside the image shape | |
are set to nan. Otherwise they are clipped to the image edge. | |
Returns: |
View bilinear_binning.py
This file contains 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
def bilinear_binning(points, intensities, subpixel=1, gaussian_blur=False): | |
"""Bilinear weighting of points onto a grid. | |
Extent of grid given by min and max of points in each dimension | |
points should be an array of shape (N, 2) | |
intensity should be an array of shape (N,) | |
subpixel will increase the gridsize by its factor | |
gaussian_blur: blur the binned intensity and weighting images before they are divided, avoiding divide-by-zero warnings | |
TODO: Give a known grid as input | |
""" |
View bilinear_bincount_cupy.py
This file contains 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
def bilinear_bincount_cupy(points, intensities, subpixel=1): | |
"""Bilinear weighting of points onto a grid. | |
Extent of grid given by min and max of points in each dimension | |
points should be a cupy array of shape (N, 2) | |
intensity should be a cupy array of shape (N,) | |
""" | |
points = subpixel * points | |
floor = cp.floor(points) | |
ceil = floor + 1 |
View bilinear_bincount_numpy.py
This file contains 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
def bilinear_bincount_numpy(points, intensities): | |
"""Bilinear weighting of points onto a grid. | |
Extent of grid given by min and max of points in each dimension | |
points should have shape (N, 2) | |
intensity should have shape (N,) | |
""" | |
floor = np.floor(points) | |
ceil = floor + 1 | |
floored_indices = np.array(floor, dtype=int) | |
low0, low1 = floored_indices.min(0) |
NewerOlder