Skip to content

Instantly share code, notes, and snippets.

View GenevieveBuckley's full-sized avatar

Genevieve Buckley GenevieveBuckley

  • Monash University
  • Melbourne
View GitHub Profile
@GenevieveBuckley
GenevieveBuckley / foo.py
Last active September 12, 2019 14:51
Combining mock patch with pytest's tmpdir fixture
import argparse
def bar():
parser = argparse.ArgumentParser()
parser.add_argument('a')
parser.add_argument('b')
parser.add_argument('c')
args = parser.parse_args()
return args
@GenevieveBuckley
GenevieveBuckley / modern-geospatial-python.md
Created September 9, 2019 09:47 — forked from jqtrde/modern-geospatial-python.md
Modern remote sensing image processing with Python
@GenevieveBuckley
GenevieveBuckley / .pre-commit-config.yaml
Last active August 23, 2019 03:36
Git pre-commit hooks with black and flake8
repos:
- repo: https://github.com/ambv/black
rev: stable
hooks:
- id: black
language_version: python3.7
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v1.2.3
hooks:
- id: flake8
@GenevieveBuckley
GenevieveBuckley / save_as_zarr.ipynb
Created August 6, 2019 04:52
Save OpenSlide tiff image to zarr array
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@GenevieveBuckley
GenevieveBuckley / test_monkeypatch.py
Last active February 6, 2025 16:19
Monkeypatching user input with pytest
from io import StringIO
def double():
x = input("Enter an integer: ")
return int(x) * 2
def adding():
x = float(input('Enter the first number'))
@GenevieveBuckley
GenevieveBuckley / rectangle_selector_example.py
Last active June 14, 2020 23:25
Matplotlib RectangleSelector
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.widgets import RectangleSelector
def _select_rectangle_callback(eclick, erelease):
"""eclick and erelease are the press and release events"""
x1, y1 = eclick.xdata, eclick.ydata
x2, y2 = erelease.xdata, erelease.ydata
In [60]: microscope.beams.electron_beam.beam_shift.limits
Out[60]: Limits2d(limits_x=Limits(min=-2.0009707e-05,max=2.0009707e-05),limits_y
=Limits(min=-2.0009707e-05,max=2.0009707e-05))
In [61]: microscope.beams.ion_beam.beam_shift.limits
Out[61]: Limits2d(limits_x=Limits(min=-5e-05,max=5e-05),limits_y=Limits(min=-5e-
05,max=5e-05))
@GenevieveBuckley
GenevieveBuckley / crosshairs_for_drift_correction.py
Last active June 25, 2019 06:50
Autoscript crosshair pattern for drift correction reference
import numpy as np
import autoscript_toolkit.vision as vision_toolkit
def cut_crosshair_patch(center_coordinate_pixels, image):
"""Returns cropped image region with crosshair drift correction reference.
Parameters
----------
@GenevieveBuckley
GenevieveBuckley / QImageViewer.py
Created June 13, 2019 07:13 — forked from acbetter/QImageViewer.py
Image Viewer Example by PyQt5 and Python 3
#!/usr/bin/python3
# -*- coding: utf-8 -*-
from PyQt5.QtCore import Qt
from PyQt5.QtGui import QImage, QPixmap, QPalette, QPainter
from PyQt5.QtPrintSupport import QPrintDialog, QPrinter
from PyQt5.QtWidgets import QLabel, QSizePolicy, QScrollArea, QMessageBox, QMainWindow, QMenu, QAction, \
qApp, QFileDialog
@GenevieveBuckley
GenevieveBuckley / app.py
Created June 13, 2019 06:49
Non-blocking PyQt while loop callback using threading
"""Example of a non-blocking PyQt while loop callback using threading
Example adapted from this StackOverflow answer:
https://stackoverflow.com/questions/22340230/python-pyqt-how-run-while-loop-without-locking-main-dialog-window?answertab=votes#tab-top
Ported from PyQt4 to PyQt5 using the tool pyqt4topyqt5:
https://github.com/rferrazz/pyqt4topyqt5
"""
import os