Skip to content

Instantly share code, notes, and snippets.

View matthewfeickert's full-sized avatar

Matthew Feickert matthewfeickert

View GitHub Profile
@matthewfeickert
matthewfeickert / README.md
Last active November 20, 2024 11:06
Examples of non-interactive matplotlib backends with or without GUIs

Examples of non-interactive matplotlib backends with or without GUIs

It is first worth reading about backends in the matplotlib Usage Guide.

Non-interactive with GUI

Running

$ python with_gui.py
@matthewfeickert
matthewfeickert / generator.py
Created April 27, 2021 16:06
Python tricks and patterns
# Use the generator .next method to quickly get the first non-None item in a list
if __name__ == "__main__":
item_list = [None, None, "non-None-A", "non-None-B", None]
item = next(item for item in item_list if item is not None)
assert item == "non-None-A"
print(item)
# - axes = next(
# - artist
@matthewfeickert
matthewfeickert / README.md
Last active October 7, 2021 18:55
X11 Forwarding to Docker for Linux and macOS

X11 Forwarding to Docker

Examples of X11 forwarding to Docker for Linux and macOS. In both situations:

  • xhost is used to set the host and/or user names allowed to make connections to the X server
  • The DISPLAY Docker environment variable must be set
  • The directory /tmp/.X11-unix/ directory must be volume mounted into the container at /tmp/.X11-unix/

Linux

@matthewfeickert
matthewfeickert / README.md
Last active March 4, 2024 06:24
Motivation for using Python virtual environments for easy sharing
@matthewfeickert
matthewfeickert / README.md
Created September 25, 2021 18:40
Regular expressions help

If you enclose a regex in parentheses () whatever is enclosed can be used in a search and replace by a number that is indexed starting with 1. So for example

\section{\sc Research Interests}

can be found with the regex

@matthewfeickert
matthewfeickert / README.md
Created September 27, 2021 21:31
Simple cProfile example with snakeviz

Simple cProfile example with snakeviz

Environment Setup

Make a Python virtual environment and install the dependencies

python -m pip install --upgrade pip setuptools wheel
python -m pip install -r requirements.txt
@matthewfeickert
matthewfeickert / README.md
Created October 1, 2021 20:11
PyTorch Geometric Setup on DGX

PyTorch Geometric Setup on DGX

Steps

  1. Create a Python virtual enviroment and activate it
[user@hal-dgx]$ pyenv virtualenv 3.9.6 pytorch-geometric-example
[user@hal-dgx]$ pyenv activate pytorch-geometric-example
(pytorch-geometric-example) [user@hal-dgx]$ python -m pip install --upgrade pip setuptools wheel
@matthewfeickert
matthewfeickert / README.md
Last active November 11, 2021 07:00
floating point deviation in jax.numpy.percentile between v0.2.20 and v0.2.21

Hi. There is some (very minor) deviations in the output of jax.numpy.percentile between jax v0.2.20 and v0.2.21 in the case that linear interpolation is used (the default). Interestingly, it is really in jax.numpy.percentile and not in jax.numpy.quantile as can be shown in the included example (for convenience this Issue also exists as a GitHub Gist).

Minimal failing example

# example.py
import jax
import jax.numpy as jnp
@matthewfeickert
matthewfeickert / Dockerfile
Last active January 9, 2022 00:16
Minimal example of xrootd Python wheel failing with setuptools v60.0.0+
ARG BASE_IMAGE=python:3.9-slim-bullseye
FROM ${BASE_IMAGE} as base
SHELL [ "/bin/bash", "-c" ]
COPY packages.txt packages.txt
# Set PATH to pickup virtualenv by default
ENV PATH=/usr/local/venv/bin:"${PATH}"
RUN apt-get -qq -y update && \
DEBIAN_FRONTEND=noninteractive apt-get -qq -y install --no-install-recommends $(cat packages.txt) && \
@matthewfeickert
matthewfeickert / README.md
Created February 8, 2022 20:32
Collections of examples of how to deal with the multi-hat aspects of being a maintainer of an open source project.

Advice for Open Source Maintainers

Collections of examples of how to deal with the multi-hat aspects of being a maintainer of an open source project.

Code of Conduct Issues

Refusal to accept Code of Conduct