Welcome to arsenal’s documentation!¶
API Reference¶
This page contains auto-generated API reference documentation 1.
arsenal
¶
Subpackages¶
Submodules¶
arsenal.collections
¶
Module Contents¶
-
arsenal.collections.
intersperse
(ls, elem, first=False, last=False)[source]¶ - Parameters
ls – A list of elements
elem – The element to insert in between each element
first – Whether to add the element at the beginning of the sequence
last – Whether to add the element at the end of the sequence
- Returns
ls
interspersed withelem`
Examples
>>> intersperse([1, 2, 3], 0) [1, 0, 2, 0, 3] >>> intersperse([1, 2, 3], 0, first=True) [0, 1, 0, 2, 0, 3] >>> intersperse([1, 2, 3], 0, first=True, last=True) [0, 1, 0, 2, 0, 3, 0]
arsenal.debug
¶
Module Contents¶
-
arsenal.debug.
extract
(source=None)[source]¶ Copies the variables of the caller up to iPython. Useful for debugging.
In a Jupyter notebook, create a cell after an exception has occurred with
%%debug from arsenal.debug import extract; extract()
- Parameters
source – A method or module from which to extract local variables. If not specified the current scope’s locals will be used.
Notes
Taken from Andy Jones’ personal library https://github.com/andyljones/aljpy/blob/master/aljpy/debugging.py All rights go to him.
See also
Andy wrote a blog post explaining how he uses this code: https://andyljones.com/posts/post-mortem-plotting.html
def f(): x = 'hello world' extract() f() # raises an error print(x) # prints 'hello world'
arsenal.image
¶
Module Contents¶
-
arsenal.image.
_default_sep_color
= [100, 100, 100]¶
-
arsenal.image.
Color
¶
-
arsenal.image.
resize_image
(image: np.ndarray, *, height: Optional[int] = None, width: Optional[int] = None, resample=Image.NEAREST) → np.ndarray[source]¶ Resize image.
-
arsenal.image.
vstack_with_sep
(rows: List[np.ndarray], sep_width: int = 3, sep_color: Color = _default_sep_color, **kwargs) → np.ndarray[source]¶ Stack images on-top of one another with separator
arsenal.numpy
¶
Module Contents¶
-
arsenal.numpy.
select
(xs: np.ndarray, xs_ids: np.ndarray, selection_ids: np.ndarray) → np.ndarray[source]¶ - Parameters
xs – Array to select elements from
xs_ids – Array of ids for each element in xs
selection_ids – Array of ids to select
- Returns
A selection of elements from
xs
Examples
>>> select( np.array([1, 2, 3]), np.array(['a', 'b', 'c']), np.array(['a']) ) array([1]) >>> select( np.array([1, 2, 3]), np.array(['a', 'b', 'c']), np.array(['a', 'c']) ) array([1, 3]) >>> select( np.array([1, 2, 3]), np.array(['a', 'b', 'c']), np.array(['a', 'c', 'a']) ) array([1, 3, 1])
arsenal.pickle
¶
arsenal.video
¶
Module Contents¶
-
arsenal.video.
clip_to_html
(clip: Union[VideoClip, np.ndarray], verbose=False, fps=24, **kwargs) → str[source]¶ Convert a MoviePy clip to an HTML string.
from IPython.display import display clip = ImageSequenceClip(list(np_video)) display(clip_to_html(clip))
- Parameters
clip – MoviePy clip.
verbose – Whether to print out FFmpeg information during encoding
fps – FPS of clip
**kwargs – Any kwargs to pass down to
html_embed()
- Returns
String of HTML with a
<video>
tag and base64 encoded media. Useful for use withIPython.display.display
to show videos.
- 1
Created with sphinx-autoapi
Installation¶
$ pip install git+https://github.com/willprice/arsenal.git