This file contains hidden or 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
# Source this into your ~/.bashrc or ~/.zshrc to add a simple "venv" command for | |
# creating/activating python environments. | |
# venv | |
# Show available environments. | |
# venv name | |
# Activates the environment in ~/.venv/name | |
# venv -n[3.x] name [packages...] | |
# Creates an environment using python 3.x (default 3.8). | |
# rm -r ~/.venv/name |
This file contains hidden or 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
## Add this text to the top of your notebook to define '%title' magic. | |
## Use it to put an H3 title in the cell output, with the title shown | |
## in the JupyterLab Table-of-Contents sidebar: | |
## %title Cell title $some_local_variable | |
from IPython.core.magic import register_line_magic | |
@register_line_magic | |
def title(msg): | |
"""Add a markdown title (level 3) to the current cell output stream.""" | |
from IPython.display import display, Markdown | |
display(Markdown("### "+msg)) |
This file contains hidden or 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
# This code is in the public domain | |
# Author: Paul Kienzle | |
from contextlib import contextmanager | |
try: | |
import torch | |
except ImportError: | |
pass | |
_gtimer_block = [] |
This file contains hidden or 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
""" | |
Get commit id from the git repo. | |
Drop the file rev.py into directory PACKAGE_PATH of your application. From | |
within that package you can then do:: | |
from . import rev | |
rev.print_revision() # print the repo version | |
commit = rev.revision_info() # return commit id |
This file contains hidden or 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
#!/usr/bin/env python | |
from __future__ import print_function | |
import sys | |
import os | |
import glob | |
import shutil | |
import sqlite3 | |
from os.path import join as joinpath, expanduser, exists, isabs, realpath |
This file contains hidden or 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
r""" | |
Explore different integration schemes for slit smearing. | |
Introduction | |
============ | |
Slit smearing evaluates the following integral: | |
.. math:: |
This file contains hidden or 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 refl1d.names import * | |
D2O = Material('D2O',natural_density=1) | |
polymer = SLD('polymer',rho=2.4) | |
solvated_poly = Mixture.byvolume(D2O,polymer,40) | |
sample = silicon(0,4) | solvated_poly(100,20) | D2O | |
T = numpy.linspace(0, 5, 100) | |
probe = NeutronProbe(T=T, dT=0.01, L=4.75, dL=0.0475) |