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
# Colors for the prompt | |
blue="\033[0;34m" | |
white="\033[0;37m" | |
green="\033[0;32m" | |
# Brackets needed around non-printable characters in PS1 | |
ps1_blue='\['"$blue"'\]' | |
ps1_green='\['"$green"'\]' | |
ps1_white='\['"$white"'\]' |
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 | |
original_labels = None | |
mapping = None | |
# TODO: Ensure that all labels are present in mapping dict | |
# because none of these functions work otherwise. | |
def using_index_array(): | |
consecutivized_labels = numpy.searchsorted( sorted( mapping.iterkeys() ), original_labels ) |
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 PyQt4.QtCore import Qt, QPointF, QRectF | |
from PyQt4.QtGui import QApplication, QWidget, QGraphicsView, QGraphicsScene, QGraphicsItem, QVBoxLayout, QSpacerItem, QSizePolicy, QCursor | |
class DraggableBox( QGraphicsItem ): | |
""" | |
A simple QGraphicsItem that can be dragged around the scene. | |
Of course, this behavior is easier to achieve if you simply use the default | |
event handler implementations in place and call | |
QGraphicsItem.setFlags( QGraphicsItem.ItemIsMovable ) | |
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 PyQt4.QtCore import QRect | |
from PyQt4.QtGui import QApplication, QWidget, QLabel | |
class DraggableLabel( QLabel ): | |
""" | |
A QLabel subclass that can be dragged around within its parent widget. | |
Note: Not intended to work if the parent widget has a layout (e.g. QVBoxLayout). | |
""" | |
def __init__(self, *args, **kwargs): |
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
# License: public domain | |
class SimpleView(object): | |
""" | |
Simple view-like object of an array-like object. | |
Slices taken with __getitem__ are combined and stored for later use, | |
but the actual data is not extracted from the underlying array-like | |
object until __array__ is called. | |
Warnings about the current implementation: |
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
""" | |
Utility function relabel_superpixels_to_bodies(), along with a main() function providing a command-line interface. | |
See usage documentation in main(), below. | |
""" | |
from __future__ import print_function | |
import collections | |
import numpy as np | |
import vigra | |
def main(): |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
Normally, if you create an app bundle with py2app, it will copy the files from your | |
conda environment into the app bundle, but it will completely reorganize the | |
directory structure that you started with. That has various downsides. | |
But there's a way to avoid that: You can exploit py2app's "alias mode" to create an | |
app bundle that doesn't actually change the directory structure of your conda environment. | |
Just place the environment inside the app bundle, wholesale! Instructions below, | |
with links to a real project that uses this method. | |
--- |
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
In [20]: import numpy as np | |
...: import lz4.frame | |
...: | |
...: a = np.random.randint(2**16, size=1_000_000, dtype=int) | |
...: buf = lz4.frame.compress(a) | |
...: print("Compressed size without shuffling:", len(buf)) | |
...: | |
...: shuffled = a.view(np.uint8).reshape(-1, 8).transpose().copy(order='C') | |
...: buf2 = lz4.frame.compress(shuffled) | |
...: print("Compressed size with shuffling: ", len(buf2)) |
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 scipy | |
def fill_hull(image): | |
""" | |
Compute the convex hull of the given binary image and | |
return a mask of the filled hull. | |
Adapted from: | |
https://stackoverflow.com/a/46314485/162094 |
OlderNewer