Skip to content

Instantly share code, notes, and snippets.

View GenevieveBuckley's full-sized avatar

Genevieve Buckley GenevieveBuckley

  • Monash University
  • Melbourne
View GitHub Profile

Useful Slurm commands

Slurm provides a variety of tools that allow a user to manage and understand their jobs. This tutorial will introduce these tools, as well as provide details on how to use them.

Finding queuing information with squeue

The squeue command is a tool we use to pull up information about the jobs in queue. By default, the squeue command will print out the

from __future__ import print_function
import cv2 as cv
import argparse
parser = argparse.ArgumentParser(description='This program shows how to use background subtraction methods provided by \
OpenCV. You can process both videos and images.')
parser.add_argument('--input', type=str, help='Path to a video or a sequence of image.', default='vtest.avi')
parser.add_argument('--algo', type=str, help='Background subtraction method (KNN, MOG2).', default='MOG2')
args = parser.parse_args()
@GenevieveBuckley
GenevieveBuckley / test_vispy_big_images.py
Last active April 3, 2020 22:45
Screenshot introspection tests
def test_screenshot_introspection(viewer_factory):
view, viewer = viewer_factory(show=True)
from skimage.data import camera
_ = viewer.add_image(camera())
screenshot = viewer.screenshot()
# the screenshot should NOT be completely black
assert not (screenshot == np.array([0, 0, 0, 255])).all()
@GenevieveBuckley
GenevieveBuckley / QTree_example.py
Last active May 20, 2020 02:48
napari LayerGroup discussion
# https://stackoverflow.com/questions/27898718/multi-level-qtreeview
import sys
from qtpy.QtGui import QStandardItemModel, QStandardItem
from qtpy.QtWidgets import QApplication, QWidget, QTreeView, QHBoxLayout
import skimage.data
from napari.components.layergroup import LayerGroup
from napari.layers import *
@GenevieveBuckley
GenevieveBuckley / mount_smbfs.sh
Created March 19, 2020 01:39 — forked from natritmeyer/mount_smbfs.sh
How to mount and unmount a SMB share on Mac OS X (using mount_smbfs)
#Mounting the share is a 2 stage process:
# 1. Create a directory that will be the mount point
# 2. Mount the share to that directory
#Create the mount point:
mkdir share_name
#Mount the share:
mount_smbfs //username:[email protected]/share_name share_name/
@GenevieveBuckley
GenevieveBuckley / cookiecutter_setup
Created March 17, 2020 04:47
Set up scientific projects
pip install cookiecutter
cookiecutter https://github.com/NSLS-II/scientific-python-cookiecutter
@GenevieveBuckley
GenevieveBuckley / qapp_vs_qtbot.md
Created March 6, 2020 01:54
Talley Lambert's (@tlambert03) explanation of qapp vs qtbot in pytest-qt

Writing Tests

Writing tests for new code is a critical part of keeping napari maintainable as it grows. Tests are written in files whose names begin with test_* and which are contained in one of the _tests directories.

There are a few things to keep in mind when writing a test where a Qt event loop or a napari.Viewer is required. The important thing is that any widgets you create during testing are cleaned up at the end of each test:

@GenevieveBuckley
GenevieveBuckley / table_format.md
Last active February 6, 2020 01:45
points to csv

Points csv

coord_id dim_0 dim_1 ... dim_n
0
1
...
n

Shapes csv

@GenevieveBuckley
GenevieveBuckley / process_wrapper.py
Created September 17, 2019 02:33 — forked from yunwilliamyu/process_wrapper.py
Redirect Python stderr/stdout for a block
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 March 4, 2020 03:30
Making gooey and tqdm play nice together
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+)%")