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 livereload import Server, shell | |
package = "<package name>" | |
server = Server() | |
server.watch('docs/*.rst', shell('make html', cwd='docs')) | |
server.watch('docs/**/*.rst', shell('make html', cwd='docs')) | |
server.watch(f'{package}/**/*.py', shell('make html', cwd='docs')) | |
server.watch(f'{package}/*.py', shell('make html', cwd='docs')) | |
server.serve(root='docs/_build/html') |
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 python3 | |
# -*- coding: utf-8 -*- | |
""" | |
This file is execfile()d with the current directory set to its | |
containing dir. | |
Note that not all possible configuration values are present in this | |
autogenerated file. | |
All configuration values have a default; values that are commented out | |
serve to show the default. | |
requirements: |
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
"""How to use line profiler [1]_ programatically. Code adapted from [2]_. | |
.. [1] https://github.com/rkern/line_profiler | |
.. [2] https://nvbn.github.io/2017/05/29/complexity/ | |
""" | |
from line_profiler import LineProfiler | |
def main(*args, **kwargs): | |
"""Function to be profiled""" |
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
# Pytest | |
def test_$NAME$(): | |
assert True$END$ | |
# Traitlets | |
@default('$NAME$') | |
def _default_$NAME$(self): | |
return $END$ |
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
"""Convert shapely geometries to other objects | |
Other interfaces | |
- matplotlib: PathPatch | |
- pyqtgraph: PlotItem | |
- bokeh: Glyph | |
- scikit-image: Indices on a grid | |
References |
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
def generator(): return range(10) | |
# Here f and g does the exactly same thing | |
# Generator delegation | |
def f(): | |
yield from generator() | |
# Legacy python syntax |
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
adult | male | female | child | eldery | Unit | explanation | ||
---|---|---|---|---|---|---|---|---|
radius | 0.255 | 0.27 | 0.24 | 0.21 | 0.25 | m | Total radius of the agent | |
radius_scale | 0.035 | 0.02 | 0.02 | 0.015 | 0.02 | m | Difference bound for total radius | |
ratio_rt | 0.5882 | 0.5926 | 0.5833 | 0.5714 | 0.6 | 1 | Ratio of total radius and radius torso | |
ratio_rs | 0.3725 | 0.3704 | 0.375 | 0.3333 | 0.36 | 1 | Ratio of total radius and radius shoulder | |
ratio_ts | 0.6275 | 0.6296 | 0.625 | 0.6667 | 0.64 | 1 | Ratio of total radius and distance from torso to shoulder | |
velocity | 1.25 | 1.35 | 1.15 | 0.9 | 0.8 | m/s | Walking speed of agent | |
velocity_scale | 0.3 | 0.2 | 0.2 | 0.3 | 0.3 | m/s | Difference bound for walking speed | |
mass | 73.5 | 80 | 67 | 57 | 70 | kg | Mass of an agent | |
mass_scale | 8 | 8 | 6.7 | 5.7 | 7 | kg | Standard deviation of mass of the agent |
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
def format_numpy(precision=5, threshold=6, edgeitems=3, linewidth=None, | |
suppress=False, nanstr=None, infstr=None, formatter=None): | |
try: | |
import numpy as np | |
np.set_printoptions(precision, threshold, edgeitems, linewidth, | |
suppress, nanstr, infstr, formatter) | |
except ImportError: | |
return |
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
name | symbol | value | unit | explanation | source | |
---|---|---|---|---|---|---|
size | :math:`N` | Number of agents (N) | ||||
shape | :math:`(N, 2)` | Shape for arrays | ||||
three_circles_flag | Boolean indicating if agent is modeled with three circle model | |||||
orientable_flag | Boolean indicating if agent is orientable | |||||
active | Boolean indicating if agent is active | |||||
goal_reached | Boolean indicating if goal is reahed | |||||
mass | :math:`m` | kg | Mass | fds+evac | ||
radius | :math:`r` | m | Radius | fds+evac | ||
r_t | :math:`r_t` | m | Radius of torso | fds+evac |
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
# Adapted from a comment from: | |
# https://mathieularose.com/function-composition-in-python/ | |
import functools | |
def compose(*funcs): | |
"""Compose functions f, g, h, ... into ...(f(g(h(x)))) | |
Args: | |
*funcs: Functions to be composed. Fuctions must take only one argument. |