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
For the whole repository: | |
$ 2to3 --output-dir=python3-version/mycode -W -n python2-version/mycode | |
For a single file: | |
$ 2to3 filename.py | |
# See details at: | |
# https://docs.python.org/2/library/2to3.html | |
# Stack overflow |
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
# Installing a python wheel | |
pip install some-package.whl | |
# Creating a python wheel | |
pip wheel --wheel-dir=path/to/save/wheel wheel_filename | |
# See https://python101.pythonlibrary.org/chapter39_wheels.html | |
# PEP427 (describes the wheel format) |
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
# Sphinx docs | |
docs/_build | |
# Logging | |
logs/* | |
!logs/.gitkeep | |
# Testing and coverage | |
cov.xml | |
.pytest_cache/ |
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
# Build a wheel (outputs to dist/ directory) | |
python setup.py sdist bdist_wheel | |
# Build with pyinstaller | |
pyinstaller myfile.spec -w -F -y | |
## If no spec file currently exists | |
pyinstaller mypackage/main.py |
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
"""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 |
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 autoscript_toolkit.vision as vision_toolkit | |
def cut_crosshair_patch(center_coordinate_pixels, image): | |
"""Returns cropped image region with crosshair drift correction reference. | |
Parameters | |
---------- |
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 [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)) |
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 os | |
import logging | |
import sys | |
import time | |
import traceback | |
from mypackage import __version__ | |
def _exception_handler(error_type, error_value, error_traceback): |
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
{ | |
"editor.rulers": [ | |
80 | |
], | |
"autoDocstring.docstringFormat": "numpy", | |
"python.linting.pylintEnabled": false, | |
"python.linting.flake8Enabled": true, | |
"window.zoomLevel": 0, | |
"python.formatting.provider": "autopep8", | |
"editor.formatOnSave": true, |
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
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 |