Skip to content

Instantly share code, notes, and snippets.

Genevieve Buckley GenevieveBuckley

  • Monash University
  • Melbourne
Block or report user

Report or block GenevieveBuckley

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@GenevieveBuckley
GenevieveBuckley / process_wrapper.py
Created Sep 17, 2019 — forked from yunwilliamyu/process_wrapper.py
Redirect Python stderr/stdout for a block
View process_wrapper.py
import sys
import contextlib
@contextlib.contextmanager
def output_wrapper():
save_stdout = sys.stdout
save_stderr = sys.stderr
sys.stdout = open('stdout.log', 'a')
sys.stderr = open('stderr.log', 'a')
yield
sys.stdout = save_stdout
@GenevieveBuckley
GenevieveBuckley / tqdm_with_gooey.py
Last active Sep 17, 2019
Making gooey and tqdm play nice together
View tqdm_with_gooey.py
from contextlib import redirect_stderr
import io
import time
import sys
from tqdm import tqdm
from gooey import Gooey, GooeyParser
@Gooey(progress_regex=r"(\d+)%")
@GenevieveBuckley
GenevieveBuckley / foo.py
Last active Sep 12, 2019
Combining mock patch with pytest's tmpdir fixture
View foo.py
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 / .pre-commit-config.yaml
Last active Aug 23, 2019
Git pre-commit hooks with black and flake8
View .pre-commit-config.yaml
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 Aug 6, 2019
Save OpenSlide tiff image to zarr array
View save_as_zarr.ipynb
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 Aug 13, 2019
Monkeypatching user input with pytest
View test_monkeypatch.py
from io import StringIO
def double():
x = input("Enter an integer: ")
return int(x) * 2
def adding():
x = float(input('Enter the first number'))
View rectangle_selector_example.py
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
View beam_shift_limits.txt
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))
View auto_lamella_26June.py
import numpy as np
import matplotlib.pyplot as plt
import numpy as np
from autoscript_sdb_microscope_client import SdbMicroscopeClient
from autoscript_sdb_microscope_client.enumerations import *
from autoscript_sdb_microscope_client.structures import *
def select_point(image):
You can’t perform that action at this time.