Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- .launchpadlib/api.launchpad.net/cache/api.launchpad.net,devel,~deadsnakes,name=%22ppa%22&ws.op=getPPAByName-application,json,bca461ac71b1143128b6fbebfcd56851 +22 -0
- .local/share/jupyter/nbextensions/rubberband/main.css +12 -0
- .local/share/jupyter/nbextensions/ruler/icon.png +0 -0
- .local/share/jupyter/nbextensions/ruler/ruler_editor.yaml +29 -0
- .local/share/jupyter/nbextensions/runtools/annotations.odg +0 -0
- .local/share/jupyter/nbextensions/runtools/main.css +27 -0
- .local/share/jupyter/nbextensions/runtools/readme.md +119 -0
- .local/share/jupyter/nbextensions/runtools/runtools_marker.png +0 -0
- .local/share/jupyter/nbextensions/scratchpad/scratchpad.yaml +6 -0
- .local/share/jupyter/nbextensions/scroll_down/icon.png +0 -0
- .local/share/jupyter/nbextensions/scroll_down/main.js +57 -0
- .local/share/jupyter/nbextensions/scroll_down/readme.md +13 -0
- .local/share/jupyter/nbextensions/select_keymap/README.md +14 -0
- .local/share/jupyter/nbextensions/select_keymap/main.js +371 -0
- .local/share/jupyter/nbextensions/select_keymap/select_keymap.png +0 -0
- .local/share/jupyter/nbextensions/skill/README.md +15 -0
- .local/share/jupyter/nbextensions/skill/skill.yaml +6 -0
- .local/share/jupyter/nbextensions/skip-traceback/icon.png +0 -0
- .local/share/jupyter/nbextensions/skip-traceback/main.js +204 -0
- .local/share/jupyter/nbextensions/skip-traceback/skip-traceback.png +0 -0
- .local/share/jupyter/nbextensions/skip-traceback/traceback.png +0 -0
- .local/share/jupyter/nbextensions/snippets/README.md +61 -0
- .local/share/jupyter/nbextensions/snippets/main.js +70 -0
- .local/share/jupyter/nbextensions/snippets/snippets-demo.gif +0 -0
- .local/share/jupyter/nbextensions/snippets_menu/config.yaml +123 -0
- .local/share/jupyter/nbextensions/snippets_menu/examples_for_custom.js +187 -0
- .local/share/jupyter/nbextensions/snippets_menu/main.js +292 -0
- .local/share/jupyter/nbextensions/snippets_menu/readme.md +633 -0
- .local/share/jupyter/nbextensions/snippets_menu/screenshot1.png +0 -0
- .local/share/jupyter/nbextensions/snippets_menu/screenshot3.png +0 -0
- .local/share/jupyter/nbextensions/snippets_menu/snippets_menu.css +72 -0
- .local/share/jupyter/nbextensions/snippets_menu/snippets_submenus_python/numba.js +51 -0
- .local/share/jupyter/nbextensions/snippets_menu/snippets_submenus_python/numpy.js +618 -0
- .local/share/jupyter/nbextensions/snippets_menu/snippets_submenus_python/numpy_polynomial.js +129 -0
- .local/share/jupyter/nbextensions/snippets_menu/snippets_submenus_python/numpy_ufuncs.js +1068 -0
- .local/share/jupyter/nbextensions/snippets_menu/thumbnail.png +0 -0
- .local/share/jupyter/nbextensions/spellchecker/__pycache__/download_new_dict.cpython-310.pyc +0 -0
- .local/share/jupyter/nbextensions/splitcell/icon.png +0 -0
- .local/share/jupyter/nbextensions/splitcell/readme.md +3 -0
- .local/share/jupyter/nbextensions/splitcell/splitcell.yaml +8 -0
- .local/share/jupyter/nbextensions/table_beautifier/table_beautifier.yaml +6 -0
- .local/share/jupyter/nbextensions/toc2/demo3.gif +0 -0
- .local/share/jupyter/nbextensions/toc2/main.css +183 -0
- .local/share/jupyter/nbextensions/tree-filter/index.js +132 -0
- .local/share/jupyter/nbextensions/tree-filter/readme.md +8 -0
- .local/share/jupyter/nbextensions/tree-filter/tree-filter.yaml +12 -0
- .local/share/jupyter/nbextensions/varInspector/tablesorter_LICENSE.txt +21 -0
- .local/share/jupyter/nbextensions/zenmode/images/back1.jpg +0 -0
- .local/share/jupyter/nbextensions/zenmode/images/back12.jpg +0 -0
- .local/share/jupyter/nbextensions/zenmode/images/back2.jpg +0 -0
.launchpadlib/api.launchpad.net/cache/api.launchpad.net,devel,~deadsnakes,name=%22ppa%22&ws.op=getPPAByName-application,json,bca461ac71b1143128b6fbebfcd56851
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
status: 200
|
2 |
+
date: Mon, 05 Feb 2024 23:25:35 GMT
|
3 |
+
server: gunicorn
|
4 |
+
x-powered-by: Zope (www.zope.org), Python (www.python.org)
|
5 |
+
content-security-policy: frame-ancestors 'self';
|
6 |
+
content-type: application/json
|
7 |
+
strict-transport-security: max-age=15552000
|
8 |
+
vary: Accept,Accept-Encoding
|
9 |
+
x-content-type-options: nosniff
|
10 |
+
x-frame-options: SAMEORIGIN
|
11 |
+
x-launchpad-revision: 9643586c585856148a18782148972ae9c1179d06
|
12 |
+
x-lazr-notifications: []
|
13 |
+
x-xss-protection: 1; mode=block
|
14 |
+
x-vcs-revision: 9643586c585856148a18782148972ae9c1179d06
|
15 |
+
x-request-id: ee5c3fda-04a1-41df-8644-2766d8c98b27
|
16 |
+
content-length: 4377
|
17 |
+
-content-encoding: gzip
|
18 |
+
content-location: https://api.launchpad.net/devel/~deadsnakes?name=%22ppa%22&ws.op=getPPAByName
|
19 |
+
-varied-accept: application/json
|
20 |
+
-varied-accept-encoding: gzip, deflate
|
21 |
+
|
22 |
+
{"self_link": "https://api.launchpad.net/devel/~deadsnakes/+archive/ubuntu/ppa", "web_link": "https://launchpad.net/~deadsnakes/+archive/ubuntu/ppa", "resource_type_link": "https://api.launchpad.net/devel/#archive", "owner_link": "https://api.launchpad.net/devel/~deadsnakes", "name": "ppa", "displayname": "New Python Versions", "reference": "~deadsnakes/ubuntu/ppa", "distribution_link": "https://api.launchpad.net/devel/ubuntu", "private": false, "suppress_subscription_notifications": false, "dependencies_collection_link": "https://api.launchpad.net/devel/~deadsnakes/+archive/ubuntu/ppa/dependencies", "description": "This PPA contains more recent Python versions packaged for Ubuntu.\n\nDisclaimer: there's no guarantee of timely updates in case of security problems or other issues. If you want to use them in a security-or-otherwise-critical environment (say, on a production server), you do so at your own risk.\n\nUpdate Note\n===========\nPlease use this repository instead of ppa:fkrull/deadsnakes.\n\nReporting Issues\n================\n\nIssues can be reported in the master issue tracker at:\nhttps://github.com/deadsnakes/issues/issues\n\nSupported Ubuntu and Python Versions\n====================================\n\n- Ubuntu 20.04 (focal) Python3.5 - Python3.7, Python3.9 - Python3.13\n- Ubuntu 22.04 (jammy) Python3.7 - Python3.9, Python3.11 - Python3.13\n- Note: Python2.7 (all), Python 3.8 (focal), Python 3.10 (jammy) are not provided by deadsnakes as upstream ubuntu provides those packages.\n\nWhy some packages aren't built:\n- Note: for focal, older python versions require libssl\u003c1.1 so they are not currently built\n- Note: for jammy, older python versions requre libssl\u003c3 so they are not currently built\n- If you need these, reach out to asottile to set up a private ppa\n\nThe packages may also work on other versions of Ubuntu or Debian, but that is not tested or supported.\n\nPackages\n========\n\nThe packages provided here are loosely based on the debian upstream packages with some modifications to make them more usable as non-default pythons and on ubuntu. As such, the packages follow debian's patterns and often do not include a full python distribution with just `apt install python#.#`. Here is a list of packages that may be useful along with the default install:\n\n- `python#.#-dev`: includes development headers for building C extensions\n- `python#.#-venv`: provides the standard library `venv` module\n- `python#.#-distutils`: provides the standard library `distutils` module\n- `python#.#-lib2to3`: provides the `2to3-#.#` utility as well as the standard library `lib2to3` module\n- `python#.#-gdbm`: provides the standard library `dbm.gnu` module\n- `python#.#-tk`: provides the standard library `tkinter` module\n\nThird-Party Python Modules\n==========================\n\nPython modules in the official Ubuntu repositories are packaged to work with the Python interpreters from the official repositories. Accordingly, they generally won't work with the Python interpreters from this PPA. As an exception, pure-Python modules for Python 3 will work, but any compiled extension modules won't.\n\nTo install 3rd-party Python modules, you should use the common Python packaging tools. For an introduction into the Python packaging ecosystem and its tools, refer to the Python Packaging User Guide:\nhttps://packaging.python.org/installing/\n\nSources\n=======\nThe package sources are available at:\nhttps://github.com/deadsnakes/\n\nNightly Builds\n==============\n\nFor nightly builds, see ppa:deadsnakes/nightly https://launchpad.net/~deadsnakes/+archive/ubuntu/nightly", "signing_key_fingerprint": "F23C5A6CF475977595C89F51BA6932366A755776", "require_virtualized": true, "build_debug_symbols": false, "publish_debug_symbols": false, "permit_obsolete_series_uploads": false, "authorized_size": 10240, "status": "Active", "external_dependencies": null, "processors_collection_link": "https://api.launchpad.net/devel/~deadsnakes/+archive/ubuntu/ppa/processors", "enabled_restricted_processors_collection_link": "https://api.launchpad.net/devel/~deadsnakes/+archive/ubuntu/ppa/enabled_restricted_processors", "publishing_method": "Local", "repository_format": "Debian", "publish": true, "relative_build_score": 0, "http_etag": "\"e23cc285682ec6a9eb87828016a9b36731e6dc4d-841a2599806ee01fd2d7dc9450f94c9cd2dba95c\""}
|
.local/share/jupyter/nbextensions/rubberband/main.css
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.highlight-drag
|
2 |
+
{
|
3 |
+
background-color: transparent;
|
4 |
+
border: dashed #ff3333 3px;
|
5 |
+
position: absolute;
|
6 |
+
display: none;
|
7 |
+
}
|
8 |
+
|
9 |
+
.cell.selected
|
10 |
+
{
|
11 |
+
background-color: #fcfcfc;
|
12 |
+
}
|
.local/share/jupyter/nbextensions/ruler/icon.png
ADDED
.local/share/jupyter/nbextensions/ruler/ruler_editor.yaml
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Type: IPython Notebook Extension
|
2 |
+
Name: Ruler in Editor
|
3 |
+
Description: This extension enables the Ruler feature in the editor
|
4 |
+
Link: readme.md
|
5 |
+
Icon: icon.png
|
6 |
+
Main: edit.js
|
7 |
+
Compatibility: 4.x, 5.x
|
8 |
+
Parameters:
|
9 |
+
|
10 |
+
- name: ruler_column
|
11 |
+
input_type: list
|
12 |
+
list_element:
|
13 |
+
input_type: number
|
14 |
+
description: Column where ruler is displayed
|
15 |
+
default: [78]
|
16 |
+
|
17 |
+
- name: ruler_color
|
18 |
+
input_type: list
|
19 |
+
list_element:
|
20 |
+
input_type: color
|
21 |
+
description: Ruler color
|
22 |
+
default: ["#ff0000"]
|
23 |
+
|
24 |
+
- name: ruler_linestyle
|
25 |
+
description: 'Ruler style, e.g. solid, dashed'
|
26 |
+
input_type: list
|
27 |
+
default: ['dashed']
|
28 |
+
|
29 |
+
Section: edit
|
.local/share/jupyter/nbextensions/runtools/annotations.odg
ADDED
Binary file (19.8 kB). View file
|
|
.local/share/jupyter/nbextensions/runtools/main.css
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
.icon-run-from:before{content:"\f10c\f04b"}
|
2 |
+
.icon-run-to:before{content:"\f04b\f10c"}
|
3 |
+
.icon-run-all:before{content:"\f04b\f01e"}
|
4 |
+
.icon-run-all-forced:before{content:"\f04b\f12a"}
|
5 |
+
.icon-run-marked:before{content:"\f04b\f08d"}
|
6 |
+
|
7 |
+
.icon-mark-all:before{content:"\f111"}
|
8 |
+
.icon-mark-none:before{content:"\f10c"}
|
9 |
+
.icon-mark-toggle:before{content:"\f08d"}
|
10 |
+
|
11 |
+
.icon-hide-input:before{content:"\f039\f068"}
|
12 |
+
.icon-hide-output:before{content:"\f02f\f068"}
|
13 |
+
.icon-show-input:before{content:"\f039\f067"}
|
14 |
+
.icon-show-output:before{content:"\f02f\f067"}
|
15 |
+
|
16 |
+
#runtools-wrapper {
|
17 |
+
position: absolute;
|
18 |
+
width:340px;
|
19 |
+
top: 100px;
|
20 |
+
right: 0px;
|
21 |
+
float: right;
|
22 |
+
opacity: 1;
|
23 |
+
z-index: 100;
|
24 |
+
font-size: 12px;
|
25 |
+
font-weight: bold;
|
26 |
+
background-color: lightgrey;
|
27 |
+
}
|
.local/share/jupyter/nbextensions/runtools/readme.md
ADDED
@@ -0,0 +1,119 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Runtools
|
2 |
+
========
|
3 |
+
Runtools provide a number of additional functions for working with code cells in the IPython notebook:
|
4 |
+
|
5 |
+
Code Cell Execution
|
6 |
+
-------------------
|
7 |
+
|
8 |
+
* Execute a single cell
|
9 |
+
* Execute from top cell to currently selected cell
|
10 |
+
* Execute from currently selected cell to bottom cell
|
11 |
+
* Execute all cells
|
12 |
+
* Execute all cells, ignore exceptions (requires [ipython/pull/6521](https://github.com/ipython/ipython/pull/6521))
|
13 |
+
* Execute marked code cells (cells with green gutter area are marked)
|
14 |
+
* Stop execution (duplicate to standard toolbar button)
|
15 |
+
|
16 |
+
When executing marked cells, they are put in a execution list, and
|
17 |
+
executed in order. The execution list can be modified by unmarking
|
18 |
+
a cell not yet run. The execution list can be stopped by clicking on
|
19 |
+
`stop execution`. Execution of the currently running cell can be stopped
|
20 |
+
by pressing `stop execution` twice.
|
21 |
+
|
22 |
+
Code Cell Marking
|
23 |
+
-----------------
|
24 |
+
|
25 |
+
* Mark one or more code cell
|
26 |
+
|
27 |
+
|
28 |
+
Code Cell Display
|
29 |
+
-----------------
|
30 |
+
|
31 |
+
* Hide or show input (i.e. the source code) of marked code cells
|
32 |
+
* Hide or show output of marked code cells
|
33 |
+
|
34 |
+
|
35 |
+
Description
|
36 |
+
-----------
|
37 |
+
|
38 |
+
The *runtools* extension adds a button to turn on/off a floating toolbar:
|
39 |
+
![](icon.png)
|
40 |
+
|
41 |
+
This adds Code execution buttons:
|
42 |
+
![](runtools_execute.png)
|
43 |
+
|
44 |
+
Codecells can be marked by clicking on the gutter of a codecell or by clicking on the markers toolbar:
|
45 |
+
![](runtools_marker.png)
|
46 |
+
|
47 |
+
Marked codecells can be locked to read-only mode and moved upd and down:
|
48 |
+
![](runtools_lock.png)
|
49 |
+
|
50 |
+
The input and output areas of marked codecells can be hidden:
|
51 |
+
![](runtools_show_hide.png)
|
52 |
+
|
53 |
+
A IPython notebook with marked cells looks like this:
|
54 |
+
![](runtools_nb.png)
|
55 |
+
|
56 |
+
|
57 |
+
Demo
|
58 |
+
----
|
59 |
+
|
60 |
+
![](demo.gif)
|
61 |
+
|
62 |
+
|
63 |
+
Internals
|
64 |
+
---------
|
65 |
+
|
66 |
+
New metadata elements added to each cell:
|
67 |
+
* `cell.metadata.hide_input` - hide input field of the cell
|
68 |
+
* `cell.metadata.hide_output` - hide output field of the cell
|
69 |
+
* `cell.metadata.run_control.marked` - mark a codecell
|
70 |
+
|
71 |
+
To export a notebook with hidden input/output fields, the custom template `hide_input_output.tpl` is required.
|
72 |
+
It should have been installed in the `templates` folder.
|
73 |
+
You can find the `templates` folder of `jupyter_contrib_nbextensions` from python using
|
74 |
+
|
75 |
+
```python
|
76 |
+
from jupyter_contrib_nbextensions.nbconvert_support import templates_directory
|
77 |
+
print(templates_directory())
|
78 |
+
```
|
79 |
+
|
80 |
+
The template needs to be in a path where nbconvert can find it. This can be your local path or specified in
|
81 |
+
`jupyter_nbconvert_config` or `jupyter_notebook_config` as `c.Exporter.extra_template_paths`, see [Jupyter docs](https://jupyter-notebook.readthedocs.io/en/latest/config.html).
|
82 |
+
|
83 |
+
For HTML export a template is provided as `nbextensions.tpl` in the `jupyter_contrib_nbextensions` templates directory. Alternatively you can create your own template:
|
84 |
+
```
|
85 |
+
{%- extends 'full.tpl' -%}
|
86 |
+
|
87 |
+
{% block input_group -%}
|
88 |
+
{%- if cell.metadata.hide_input -%}
|
89 |
+
{%- else -%}
|
90 |
+
{{ super() }}
|
91 |
+
{%- endif -%}
|
92 |
+
{% endblock input_group %}
|
93 |
+
|
94 |
+
{% block output_group -%}
|
95 |
+
{%- if cell.metadata.hide_output -%}
|
96 |
+
{%- else -%}
|
97 |
+
{{ super() }}
|
98 |
+
{%- endif -%}
|
99 |
+
{% endblock output_group %}
|
100 |
+
```
|
101 |
+
|
102 |
+
For LaTeX export a different template is required, which is included as `nbextensions.tplx` in the `jupyter_contrib_nbextensions` templates directory. Alternatively you can create your own template:
|
103 |
+
```
|
104 |
+
((- extends 'report.tplx' -))
|
105 |
+
|
106 |
+
((* block input_group -))
|
107 |
+
((- if cell.metadata.hide_input -))
|
108 |
+
((- else -))
|
109 |
+
((( super() )))
|
110 |
+
((- endif -))
|
111 |
+
(( endblock input_group *))
|
112 |
+
|
113 |
+
((* block output_group -))
|
114 |
+
((- if cell.metadata.hide_output -))
|
115 |
+
((- else -))
|
116 |
+
((( super() )))
|
117 |
+
((- endif -))
|
118 |
+
(( endblock output_group *))
|
119 |
+
```
|
.local/share/jupyter/nbextensions/runtools/runtools_marker.png
ADDED
.local/share/jupyter/nbextensions/scratchpad/scratchpad.yaml
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Type: Jupyter Notebook Extension
|
2 |
+
Name: Scratchpad
|
3 |
+
Description: Adds a scratchpad cell to Jupyter notebook.
|
4 |
+
Link: README.md
|
5 |
+
Main: main.js
|
6 |
+
Compatibility: 4.x, 5.x
|
.local/share/jupyter/nbextensions/scroll_down/icon.png
ADDED
.local/share/jupyter/nbextensions/scroll_down/main.js
ADDED
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
define([
|
2 |
+
'jquery',
|
3 |
+
'base/js/namespace',
|
4 |
+
], function (
|
5 |
+
$,
|
6 |
+
Jupyter
|
7 |
+
) {
|
8 |
+
'use strict';
|
9 |
+
|
10 |
+
var params = {
|
11 |
+
scrollDownIsEnabled: false
|
12 |
+
};
|
13 |
+
|
14 |
+
var initialize = function () {
|
15 |
+
$.extend(true, params, Jupyter.notebook.config.data);
|
16 |
+
setButtonColor();
|
17 |
+
};
|
18 |
+
|
19 |
+
function toggleScrollDown() {
|
20 |
+
params.scrollDownIsEnabled = !params.scrollDownIsEnabled;
|
21 |
+
Jupyter.notebook.config.update(params);
|
22 |
+
setButtonColor();
|
23 |
+
}
|
24 |
+
|
25 |
+
function setButtonColor() {
|
26 |
+
$("#toggle_scroll_down").toggleClass('active', params.scrollDownIsEnabled);
|
27 |
+
}
|
28 |
+
|
29 |
+
function load_extension() {
|
30 |
+
$(Jupyter.toolbar.add_buttons_group([
|
31 |
+
Jupyter.keyboard_manager.actions.register({
|
32 |
+
help : 'toggle automatic scrolling down',
|
33 |
+
icon : 'fa-angle-double-down ',
|
34 |
+
handler: toggleScrollDown
|
35 |
+
}, 'toggle-auto-scroll-down', 'scroll_down')
|
36 |
+
])).find('.btn').attr('id', 'toggle_scroll_down');
|
37 |
+
|
38 |
+
console.log("[ScrollDown] is loaded");
|
39 |
+
|
40 |
+
// the event was renamed from 'resize' to 'resizeOutput' in
|
41 |
+
// https://github.com/jupyter/notebook/commit/b4928d481abd9f7cd996fd4b24078a55880d21e6
|
42 |
+
$(document).on("resize resizeOutput", ".output", function () {
|
43 |
+
if (!params.scrollDownIsEnabled) return;
|
44 |
+
var output = $(this);
|
45 |
+
setTimeout(function () {
|
46 |
+
output.scrollTop(output.prop("scrollHeight"));
|
47 |
+
}, 0);
|
48 |
+
});
|
49 |
+
|
50 |
+
return Jupyter.notebook.config.loaded.then(initialize);
|
51 |
+
}
|
52 |
+
|
53 |
+
return {
|
54 |
+
load_jupyter_extension: load_extension,
|
55 |
+
load_ipython_extension: load_extension
|
56 |
+
};
|
57 |
+
});
|
.local/share/jupyter/nbextensions/scroll_down/readme.md
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# ScrollDown
|
2 |
+
|
3 |
+
When enabled, this nbextension scrolls cells' outputs down automatically as
|
4 |
+
they are enlarged. It can be enabled and disabled using the toolbar button:
|
5 |
+
|
6 |
+
![](icon.png)
|
7 |
+
|
8 |
+
|
9 |
+
Options
|
10 |
+
-------
|
11 |
+
|
12 |
+
The enabled status is toggleable with the toolbar button, which sets the option
|
13 |
+
option `scrollDownIsEnabled` in the notebook config section.
|
.local/share/jupyter/nbextensions/select_keymap/README.md
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Select CodeMirror Keymap
|
2 |
+
=======
|
3 |
+
|
4 |
+
This extension lets you choose between the available CodeMirror keymaps: default, emacs, vim, and sublime.
|
5 |
+
|
6 |
+
There's a chance that this might cause key conflicts, especially with other extensions.
|
7 |
+
|
8 |
+
Most browsers consume some of the global keybindings like `Ctrl+n`. [The Menu Wizard add-on for Firefox](https://addons.mozilla.org/en-US/firefox/addon/s3menu-wizard/) allows you to disable some of the global key shortcuts, thus passing the keys through to CodeMirror.
|
9 |
+
|
10 |
+
![Demo](select_keymap.png)
|
11 |
+
|
12 |
+
Based on:
|
13 |
+
* [jupyter-emacskeys](https://github.com/rmcgibbo/jupyter-emacskeys)
|
14 |
+
* [notebook_input_mode](https://github.com/asford/notebook_input_mode)
|
.local/share/jupyter/nbextensions/select_keymap/main.js
ADDED
@@ -0,0 +1,371 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
// change the mode of all current and future CodeMirror instances
|
2 |
+
|
3 |
+
define([
|
4 |
+
"base/js/namespace",
|
5 |
+
"notebook/js/cell",
|
6 |
+
"codemirror/lib/codemirror",
|
7 |
+
"codemirror/keymap/emacs",
|
8 |
+
"codemirror/keymap/vim",
|
9 |
+
"codemirror/keymap/sublime",
|
10 |
+
"codemirror/mode/meta",
|
11 |
+
"codemirror/addon/comment/comment",
|
12 |
+
"codemirror/addon/dialog/dialog",
|
13 |
+
"codemirror/addon/edit/closebrackets",
|
14 |
+
"codemirror/addon/edit/matchbrackets",
|
15 |
+
"codemirror/addon/search/searchcursor",
|
16 |
+
"codemirror/addon/search/search",
|
17 |
+
], function(
|
18 |
+
Jupyter,
|
19 |
+
Cell,
|
20 |
+
CodeMirror
|
21 |
+
// other stuff is loaded, but not used
|
22 |
+
) {
|
23 |
+
"use_strict";
|
24 |
+
|
25 |
+
var previous_mode = "";
|
26 |
+
|
27 |
+
var available_keymaps = [
|
28 |
+
"default",
|
29 |
+
"emacs",
|
30 |
+
"vim",
|
31 |
+
"sublime"
|
32 |
+
];
|
33 |
+
|
34 |
+
/* Values to use for config keys that are note defined in server config */
|
35 |
+
var default_config = {
|
36 |
+
line_wrap: true,
|
37 |
+
local_storage: true,
|
38 |
+
};
|
39 |
+
|
40 |
+
var starting_state = {
|
41 |
+
extraKeys: {},
|
42 |
+
edit_shortcuts: {},
|
43 |
+
command_shortcuts: {}
|
44 |
+
};
|
45 |
+
|
46 |
+
var cm_default = Cell.Cell.options_default.cm_config;
|
47 |
+
var edit_shortcuts = Jupyter.keyboard_manager.edit_shortcuts;
|
48 |
+
var command_shortcuts = Jupyter.keyboard_manager.command_shortcuts;
|
49 |
+
|
50 |
+
var mods = {
|
51 |
+
vim: {
|
52 |
+
add: {
|
53 |
+
extraKeys: {
|
54 |
+
"Esc": "leave_current_mode",
|
55 |
+
"Ctrl-[": "leave_current_mode"
|
56 |
+
},
|
57 |
+
command_shortcuts: {
|
58 |
+
"Ctrl-c": "jupyter-notebook:interrupt-kernel",
|
59 |
+
"Ctrl-z": "jupyter-notebook:restart-kernel",
|
60 |
+
|
61 |
+
"d,d": "jupyter-notebook:cut-cell",
|
62 |
+
"y,y": "jupyter-notebook:copy-cell",
|
63 |
+
"u": "jupyter-notebook:undo-cell-deletion",
|
64 |
+
|
65 |
+
"p": "jupyter-notebook:paste-cell-below",
|
66 |
+
"Shift-P": "jupyter-notebook:paste-cell-above",
|
67 |
+
|
68 |
+
"o": "jupyter-notebook:insert-cell-below",
|
69 |
+
"Shift-O": "jupyter-notebook:insert-cell-above",
|
70 |
+
|
71 |
+
"i": "jupyter-notebook:enter-edit-mode",
|
72 |
+
"Enter": "jupyter-notebook:enter-edit-mode",
|
73 |
+
|
74 |
+
"Shift-J": "jupyter-notebook:move-cell-down",
|
75 |
+
"Shift-K": "jupyter-notebook:move-cell-up",
|
76 |
+
|
77 |
+
"Shift-/": "jupyter-notebook:show-keyboard-shortcuts",
|
78 |
+
"h": "jupyter-notebook:toggle-cell-output-collapsed",
|
79 |
+
"Shift-H": "jupyter-notebook:toggle-cell-output-scrolled",
|
80 |
+
|
81 |
+
"`": "jupyter-notebook:change-cell-to-code",
|
82 |
+
"0": "jupyter-notebook:change-cell-to-markdown"
|
83 |
+
},
|
84 |
+
edit_shortcuts: {
|
85 |
+
"Shift-Esc": "jupyter-notebook:enter-command-mode"
|
86 |
+
}
|
87 |
+
},
|
88 |
+
remove: {
|
89 |
+
edit_shortcuts: ["Esc"]
|
90 |
+
},
|
91 |
+
custom: function() {
|
92 |
+
disable_keyboard_manager_in_dialog(this);
|
93 |
+
},
|
94 |
+
custom_teardown: function() {
|
95 |
+
reenable_keyboard_manager_in_dialog(this);
|
96 |
+
}
|
97 |
+
},
|
98 |
+
emacs: {
|
99 |
+
add: {
|
100 |
+
extraKeys: {
|
101 |
+
"Ctrl-Y": "yank_no_selection"
|
102 |
+
},
|
103 |
+
command_shortcuts: {
|
104 |
+
"Ctrl-N": "jupyter-notebook:select-next-cell",
|
105 |
+
"Ctrl-P": "jupyter-notebook:select-previous-cell",
|
106 |
+
"Alt-X": "jupyter-notebook:show-command-palette"
|
107 |
+
|
108 |
+
},
|
109 |
+
edit_shortcuts: {
|
110 |
+
"Alt-X": "jupyter-notebook:show-command-palette"
|
111 |
+
}
|
112 |
+
},
|
113 |
+
remove: {
|
114 |
+
edit_shortcuts: ["Ctrl-Shift-Minus"],
|
115 |
+
keyMap: ["Ctrl-V"]
|
116 |
+
},
|
117 |
+
custom: function() {
|
118 |
+
disable_keyboard_manager_in_dialog(this);
|
119 |
+
},
|
120 |
+
custom_teardown: function() {
|
121 |
+
reenable_keyboard_manager_in_dialog(this);
|
122 |
+
}
|
123 |
+
}
|
124 |
+
};
|
125 |
+
|
126 |
+
function disable_keyboard_manager_in_dialog(_this) {
|
127 |
+
// Disable keyboard manager for code mirror dialogs, handles ':'
|
128 |
+
// triggered ex-mode dialog box in vim mode.
|
129 |
+
// Manager is re-enabled by re-entry into notebook edit mode +
|
130 |
+
// cell normal mode after dialog closes
|
131 |
+
_this.openDialog = CodeMirror.prototype.openDialog;
|
132 |
+
|
133 |
+
function openDialog_keymap_wrapper(target, template, callback, options) {
|
134 |
+
Jupyter.keyboard_manager.disable();
|
135 |
+
return target.call(this, template, callback, options);
|
136 |
+
}
|
137 |
+
|
138 |
+
CodeMirror.defineExtension("openDialog", _.wrap(_this.openDialog,
|
139 |
+
openDialog_keymap_wrapper));
|
140 |
+
}
|
141 |
+
|
142 |
+
function reenable_keyboard_manager_in_dialog(_this) {
|
143 |
+
CodeMirror.defineExtension("openDialog", _this.openDialog);
|
144 |
+
}
|
145 |
+
|
146 |
+
var server_config = Jupyter.notebook.config;
|
147 |
+
// make sure config is loaded before making initial changes
|
148 |
+
var initialize = function () {
|
149 |
+
save_starting_state();
|
150 |
+
// initialize last stored value or default
|
151 |
+
switch_keymap(get_stored_keymap());
|
152 |
+
};
|
153 |
+
|
154 |
+
function get_config(key) {
|
155 |
+
if (server_config.data.hasOwnProperty("select_keymap_" + key)) {
|
156 |
+
return server_config.data["select_keymap_" + key];
|
157 |
+
}
|
158 |
+
return default_config[key];
|
159 |
+
}
|
160 |
+
|
161 |
+
function get_stored_keymap() {
|
162 |
+
var keymap;
|
163 |
+
if (get_config("local_storage")) {
|
164 |
+
keymap = window.localStorage.getItem("jupyter_keymap");
|
165 |
+
} else {
|
166 |
+
keymap = server_config.data.stored_keymap;
|
167 |
+
}
|
168 |
+
return keymap || "default";
|
169 |
+
}
|
170 |
+
|
171 |
+
function store_keymap(mode) {
|
172 |
+
if (get_config("local_storage")) {
|
173 |
+
window.localStorage.setItem("jupyter_keymap", mode);
|
174 |
+
} else {
|
175 |
+
server_config.update({
|
176 |
+
stored_keymap: mode
|
177 |
+
});
|
178 |
+
}
|
179 |
+
}
|
180 |
+
|
181 |
+
function flatten_shortcuts(shortcut_tree) {
|
182 |
+
var result = {};
|
183 |
+
for (var p in shortcut_tree) {
|
184 |
+
if (typeof(shortcut_tree[p]) == "string") {
|
185 |
+
result[p] = shortcut_tree[p];
|
186 |
+
} else {
|
187 |
+
var subresult = flatten_shortcuts(shortcut_tree[p]);
|
188 |
+
for (var subp in subresult) {
|
189 |
+
result[p + "," + subp] = subresult[subp];
|
190 |
+
}
|
191 |
+
}
|
192 |
+
}
|
193 |
+
return result;
|
194 |
+
}
|
195 |
+
|
196 |
+
function update_shortcuts(shortcut_manager, updated_shortcuts) {
|
197 |
+
var current_shortcuts = _.invert(flatten_shortcuts(shortcut_manager._shortcuts));
|
198 |
+
|
199 |
+
for (var shortcut_action in _.invert(updated_shortcuts)) {
|
200 |
+
if (_.has(current_shortcuts, shortcut_action) &&
|
201 |
+
shortcut_manager.get_shortcut(current_shortcuts[shortcut_action])) {
|
202 |
+
|
203 |
+
shortcut_manager.remove_shortcut(current_shortcuts[shortcut_action]);
|
204 |
+
}
|
205 |
+
}
|
206 |
+
|
207 |
+
shortcut_manager.add_shortcuts(updated_shortcuts);
|
208 |
+
}
|
209 |
+
|
210 |
+
// start custom CodeMirror command definitions
|
211 |
+
function leave_current_mode(cm) {
|
212 |
+
if (cm.state.vim.insertMode) {
|
213 |
+
// Move from insert mode into command mode.
|
214 |
+
CodeMirror.keyMap["vim-insert"].call("Esc", cm);
|
215 |
+
} else if (cm.state.vim.visualMode) {
|
216 |
+
// Move from visual mode to command mode.
|
217 |
+
CodeMirror.keyMap["vim"].call("Esc", cm);
|
218 |
+
} else {
|
219 |
+
// Move to notebook command mode.
|
220 |
+
Jupyter.notebook.command_mode();
|
221 |
+
Jupyter.notebook.focus_cell();
|
222 |
+
}
|
223 |
+
};
|
224 |
+
|
225 |
+
var orig_ctrl_y = CodeMirror.keyMap.emacs["Ctrl-Y"];
|
226 |
+
|
227 |
+
function yank_no_selection(cm) {
|
228 |
+
orig_ctrl_y(cm);
|
229 |
+
// remove selection after yank
|
230 |
+
cm.setSelection(cm.getCursor(), cm.getCursor());
|
231 |
+
};
|
232 |
+
|
233 |
+
CodeMirror.commands.yank_no_selection = yank_no_selection;
|
234 |
+
CodeMirror.commands.leave_current_mode = leave_current_mode;
|
235 |
+
// end custom CodeMirror command definitions
|
236 |
+
|
237 |
+
function create_menu() {
|
238 |
+
var menu = [
|
239 |
+
"<li class='divider''></li>",
|
240 |
+
"<li class='dropdown-submenu'>",
|
241 |
+
"<a href='#'>Keymaps</a>",
|
242 |
+
"<ul class='dropdown-menu'' id='keymap_menu'>"
|
243 |
+
];
|
244 |
+
|
245 |
+
available_keymaps.forEach(function(keymap) {
|
246 |
+
menu.push(`<li><a id="keymap-${keymap}" href="#" title="Toggle ${keymap} keybindings" onClick="switch_keymap('${keymap}')" style="text-transform: capitalize;">${keymap}</a></li>`);
|
247 |
+
});
|
248 |
+
|
249 |
+
menu.push("</ul></li>");
|
250 |
+
|
251 |
+
$("#move_cell_down").after(menu.join("\n"));
|
252 |
+
}
|
253 |
+
|
254 |
+
function update_cm_instance_to_defaults(cell) {
|
255 |
+
var cm = cell.code_mirror;
|
256 |
+
cm.setOption("vimMode", cm_default["vimMode"]);
|
257 |
+
cm.setOption("lineWrapping", cm_default["lineWrapping"]);
|
258 |
+
cm.setOption("keyMap", cm_default["keyMap"]);
|
259 |
+
cm.setOption("extraKeys", cm_default["extraKeys"]);
|
260 |
+
};
|
261 |
+
|
262 |
+
function highlight_selection(mode) {
|
263 |
+
$("[id^=keymap]").css("font-weight", "normal");
|
264 |
+
$("[id=keymap-" + mode + "]").css("font-weight", "bold");
|
265 |
+
}
|
266 |
+
|
267 |
+
function reset_state() {
|
268 |
+
// FIXME: if this extension loads before other extensions that alter
|
269 |
+
// key shortcuts, this will probably reset those as well
|
270 |
+
cm_default.extraKeys = _.clone(starting_state.extraKeys);
|
271 |
+
update_shortcuts(edit_shortcuts, starting_state.edit_shortcuts);
|
272 |
+
update_shortcuts(command_shortcuts, starting_state.command_shortcuts);
|
273 |
+
|
274 |
+
// if changing from another mode, run the teardown function
|
275 |
+
var prev_mode_mods = mods[previous_mode];
|
276 |
+
if (prev_mode_mods && prev_mode_mods.custom_teardown) {
|
277 |
+
prev_mode_mods.custom_teardown();
|
278 |
+
}
|
279 |
+
}
|
280 |
+
|
281 |
+
function save_starting_state() {
|
282 |
+
starting_state.extraKeys = _.clone(cm_default.extraKeys);
|
283 |
+
starting_state.edit_shortcuts = flatten_shortcuts(edit_shortcuts._shortcuts);
|
284 |
+
starting_state.command_shortcuts = flatten_shortcuts(command_shortcuts._shortcuts);
|
285 |
+
}
|
286 |
+
|
287 |
+
function add_bindings(add, mode) {
|
288 |
+
_.extend(CodeMirror.keyMap[mode], add.keyMap);
|
289 |
+
_.extend(cm_default.extraKeys, add.extraKeys);
|
290 |
+
|
291 |
+
if (add.command_shortcuts) {
|
292 |
+
update_shortcuts(command_shortcuts, add.command_shortcuts);
|
293 |
+
}
|
294 |
+
|
295 |
+
if (add.edit_shortcuts) {
|
296 |
+
update_shortcuts(edit_shortcuts, add.edit_shortcuts);
|
297 |
+
}
|
298 |
+
}
|
299 |
+
|
300 |
+
function remove_bindings(remove, mode) {
|
301 |
+
_.forEach(remove.keyMap, function(key) {
|
302 |
+
delete CodeMirror.keyMap[mode][key];
|
303 |
+
});
|
304 |
+
|
305 |
+
_.forEach(remove.extraKeys, function(key) {
|
306 |
+
delete cm_default.extraKeys[key];
|
307 |
+
});
|
308 |
+
|
309 |
+
_.forEach(remove.edit_shortcuts, function(key) {
|
310 |
+
edit_shortcuts.remove_shortcut(key);
|
311 |
+
});
|
312 |
+
|
313 |
+
_.forEach(remove.command_shortcuts, function(key) {
|
314 |
+
command_shortcuts.remove_shortcut(key);
|
315 |
+
});
|
316 |
+
}
|
317 |
+
|
318 |
+
function change_notebook_defaults(mode) {
|
319 |
+
// make changes to cm defaults
|
320 |
+
cm_default.keyMap = mode;
|
321 |
+
cm_default.vimMode = mode == "vim";
|
322 |
+
cm_default.lineWrapping = get_config('line_wrap');
|
323 |
+
|
324 |
+
var mode_mods = mods[mode];
|
325 |
+
if (mode_mods) {
|
326 |
+
if (mode_mods.add) {
|
327 |
+
add_bindings(mode_mods.add, mode);
|
328 |
+
}
|
329 |
+
|
330 |
+
if (mode_mods.remove) {
|
331 |
+
remove_bindings(mode_mods.remove, mode);
|
332 |
+
}
|
333 |
+
|
334 |
+
if (mode_mods.custom) {
|
335 |
+
mode_mods.custom();
|
336 |
+
}
|
337 |
+
}
|
338 |
+
}
|
339 |
+
|
340 |
+
function change_cells_to_defaults() {
|
341 |
+
Jupyter.notebook.get_cells().map(update_cm_instance_to_defaults);
|
342 |
+
}
|
343 |
+
|
344 |
+
function switch_keymap(mode) {
|
345 |
+
// don't run if selecting currently selected mode
|
346 |
+
if (mode == previous_mode) return;
|
347 |
+
|
348 |
+
// store selection only when it changes
|
349 |
+
if (previous_mode) store_keymap(mode);
|
350 |
+
|
351 |
+
reset_state();
|
352 |
+
|
353 |
+
change_notebook_defaults(mode);
|
354 |
+
|
355 |
+
change_cells_to_defaults();
|
356 |
+
|
357 |
+
highlight_selection(mode);
|
358 |
+
|
359 |
+
previous_mode = mode;
|
360 |
+
}
|
361 |
+
|
362 |
+
window.switch_keymap = switch_keymap;
|
363 |
+
|
364 |
+
return {
|
365 |
+
load_ipython_extension: function () {
|
366 |
+
return Jupyter.notebook.config.loaded
|
367 |
+
.then(initialize)
|
368 |
+
.then(create_menu);
|
369 |
+
}
|
370 |
+
};
|
371 |
+
});
|
.local/share/jupyter/nbextensions/select_keymap/select_keymap.png
ADDED
.local/share/jupyter/nbextensions/skill/README.md
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# SKILL for Codemirror
|
2 |
+
This extension provides a *SKILL* mode for CodeMirror editor.
|
3 |
+
|
4 |
+
The extension adds a MIME type `x-skill` and a mode `skill` that can be
|
5 |
+
used with CodeMirror.
|
6 |
+
|
7 |
+
## About SKILL
|
8 |
+
From [Wikipedia](https://en.wikipedia.org/wiki/Cadence_SKILL):
|
9 |
+
SKILL is a Lisp dialect used as a scripting language and PCell (parameterized
|
10 |
+
cells) description language used in many EDA software suites by Cadence Design
|
11 |
+
Systems (e.g. Cadence Allegro and Cadence Virtuoso)
|
12 |
+
|
13 |
+
## Notes
|
14 |
+
This extension was written to enhance the Virtuoso kernel for Jupyter
|
15 |
+
(https://github.com/benvarkey/JuVi).
|
.local/share/jupyter/nbextensions/skill/skill.yaml
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Type: IPython Notebook Extension
|
2 |
+
Name: SKILL Syntax
|
3 |
+
Description: Enable SKILL syntax support for CodeMirror
|
4 |
+
Link: README.md
|
5 |
+
Main: main.js
|
6 |
+
Compatibility: 4.x, 5.x
|
.local/share/jupyter/nbextensions/skip-traceback/icon.png
ADDED
.local/share/jupyter/nbextensions/skip-traceback/main.js
ADDED
@@ -0,0 +1,204 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
// Copyright (c) IPython-Contrib Team.
|
2 |
+
// Distributed under the terms of the Modified BSD License.
|
3 |
+
|
4 |
+
define([
|
5 |
+
'base/js/namespace',
|
6 |
+
'jquery',
|
7 |
+
'require',
|
8 |
+
'notebook/js/outputarea',
|
9 |
+
], function (
|
10 |
+
Jupyter,
|
11 |
+
$,
|
12 |
+
requirejs,
|
13 |
+
outputarea
|
14 |
+
) {
|
15 |
+
"use strict";
|
16 |
+
|
17 |
+
var mod_name = 'skip-traceback';
|
18 |
+
var log_prefix = '[' + mod_name + ']';
|
19 |
+
|
20 |
+
var cfg = {
|
21 |
+
enable: true,
|
22 |
+
use_toolbar_button: false,
|
23 |
+
button_icon: 'fa-warning',
|
24 |
+
animation_duration: 100,
|
25 |
+
show_copy_buttons: true,
|
26 |
+
};
|
27 |
+
|
28 |
+
// this will be filled as they're registered
|
29 |
+
var actions = {};
|
30 |
+
|
31 |
+
var apply_patches = function () {
|
32 |
+
|
33 |
+
outputarea.OutputArea.prototype.append_error = function (json) {
|
34 |
+
// firts part is just a copy of the original, but keeping a reference to inserted_text
|
35 |
+
var inserted_text;
|
36 |
+
var tb = json.traceback;
|
37 |
+
if (tb !== undefined && tb.length > 0) {
|
38 |
+
var s = '';
|
39 |
+
var len = tb.length;
|
40 |
+
for (var i = 0; i < len; i++) {
|
41 |
+
s = s + tb[i] + '\n';
|
42 |
+
}
|
43 |
+
s = s + '\n';
|
44 |
+
var toinsert = this.create_output_area();
|
45 |
+
var append_text = outputarea.OutputArea.append_map['text/plain'];
|
46 |
+
if (append_text) {
|
47 |
+
inserted_text = append_text.apply(this, [s, {}, toinsert]).addClass('output_error');
|
48 |
+
}
|
49 |
+
this._safe_append(toinsert);
|
50 |
+
|
51 |
+
// now we add our header at the top of the inserted_text
|
52 |
+
if (!inserted_text) {
|
53 |
+
return;
|
54 |
+
}
|
55 |
+
var copy_btn = $('<i class="fa fa-fw fa-copy" title="Copy full traceback to clipboard"/>')
|
56 |
+
.on('click', function (evt) {
|
57 |
+
// prevent event bubbling up to collapse/uncollapse traceback
|
58 |
+
evt.stopPropagation();
|
59 |
+
var $copy_btn = $(this)
|
60 |
+
.tooltip({track: false, trigger: 'manual', placement: 'bottom'});
|
61 |
+
// create temporary off-screen textarea for copying text
|
62 |
+
var $copy_txt_area = $('<textarea>')
|
63 |
+
.css({position: 'absolute', left: '-10000px', top: '-10000px'})
|
64 |
+
.appendTo('body');
|
65 |
+
// remember this for later
|
66 |
+
var was_focussed = document.activeElement;
|
67 |
+
var msg = 'Failed to copy traceback to clipboard';
|
68 |
+
try {
|
69 |
+
$copy_txt_area[0].value = $copy_btn.closest('.skip-traceback-summary').siblings().text();
|
70 |
+
$copy_txt_area[0].select();
|
71 |
+
var successful = document.execCommand('copy');
|
72 |
+
if (successful) {
|
73 |
+
msg = 'Copied traceback to clipboard!';
|
74 |
+
console.log(log_prefix, msg);
|
75 |
+
}
|
76 |
+
else {
|
77 |
+
console.warn(log_prefix, msg);
|
78 |
+
}
|
79 |
+
}
|
80 |
+
catch (err) {
|
81 |
+
console.warn(log_prefix, msg + ':', err);
|
82 |
+
}
|
83 |
+
finally {
|
84 |
+
$copy_txt_area.remove();
|
85 |
+
was_focussed.focus();
|
86 |
+
// this tooltip bit relies on jqueryui tooltip, but
|
87 |
+
// it may have been overwritten by bootstrap tooltip (if loaded).
|
88 |
+
try {
|
89 |
+
$copy_btn
|
90 |
+
.tooltip('option', 'content', msg)
|
91 |
+
.tooltip('open');
|
92 |
+
setTimeout(function () {
|
93 |
+
$copy_btn.tooltip('disable');
|
94 |
+
}, 1000);
|
95 |
+
}
|
96 |
+
catch (err) {
|
97 |
+
console.warn(log_prefix, err);
|
98 |
+
}
|
99 |
+
}
|
100 |
+
});
|
101 |
+
var sum = $('<pre/>')
|
102 |
+
.addClass('skip-traceback-summary')
|
103 |
+
.css('cursor', 'pointer')
|
104 |
+
.text(': ' + json.evalue + ' ')
|
105 |
+
.prepend($('<span class=ansired/>').text(json.ename));
|
106 |
+
|
107 |
+
if (cfg.show_copy_buttons) {
|
108 |
+
sum.prepend(' ').prepend(copy_btn);
|
109 |
+
}
|
110 |
+
sum
|
111 |
+
.append('<i class="fa fa-caret-right" title="Expand traceback"/>')
|
112 |
+
.append('\n')
|
113 |
+
.on('click', function (evt) {
|
114 |
+
var summary = $(this);
|
115 |
+
var icon = summary.find('.fa-caret-right,.fa-caret-down');
|
116 |
+
var show = icon.hasClass('fa-caret-right');
|
117 |
+
icon
|
118 |
+
.toggleClass('fa-caret-down', show)
|
119 |
+
.toggleClass('fa-caret-right', !show)
|
120 |
+
.attr('title', show ? 'Collapse traceback' : 'Expand traceback');
|
121 |
+
summary.siblings()[show ? 'slideDown' : 'slideUp'](cfg.animation_duration || 100);
|
122 |
+
})
|
123 |
+
.prependTo(inserted_text);
|
124 |
+
if (cfg.enable) {
|
125 |
+
sum.siblings().css('display', 'none');
|
126 |
+
}
|
127 |
+
else {
|
128 |
+
sum.css('display', 'none');
|
129 |
+
}
|
130 |
+
}
|
131 |
+
};
|
132 |
+
};
|
133 |
+
|
134 |
+
var toggle_traceback = function (set_on) {
|
135 |
+
if (set_on === undefined) {
|
136 |
+
set_on = !cfg.enable;
|
137 |
+
}
|
138 |
+
// update config
|
139 |
+
if (set_on !== cfg.enable) {
|
140 |
+
cfg.enable = set_on;
|
141 |
+
var conf_update = {};
|
142 |
+
conf_update[mod_name] = {enable: set_on};
|
143 |
+
Jupyter.notebook.config.update(conf_update);
|
144 |
+
console.log(log_prefix, 'toggled', set_on ? 'on' : 'off');
|
145 |
+
}
|
146 |
+
// update button looks
|
147 |
+
$('#toggle_traceback_btns > .btn').toggleClass('active', set_on).blur();
|
148 |
+
// update existing OutputAreas
|
149 |
+
$('.cell .output_area .output_error .skip-traceback-summary').each(function (idx, el) {
|
150 |
+
var $summary = $(el);
|
151 |
+
$summary.css('display', set_on ? '' : 'none');
|
152 |
+
if ($summary.find('.fa').hasClass(set_on ? 'fa-caret-down' : 'fa-caret-right')) {
|
153 |
+
$summary.click();
|
154 |
+
}
|
155 |
+
});
|
156 |
+
};
|
157 |
+
|
158 |
+
var register_new_actions = function () {
|
159 |
+
actions.toggle = {
|
160 |
+
help : 'Toggle Hiding Traceback',
|
161 |
+
help_index: 'zz',
|
162 |
+
icon : cfg.button_icon || 'fa-warning',
|
163 |
+
handler : function (env) { toggle_traceback(); },
|
164 |
+
};
|
165 |
+
actions.toggle.name = Jupyter.keyboard_manager.actions.register(
|
166 |
+
actions.toggle, 'toggle', mod_name);
|
167 |
+
};
|
168 |
+
|
169 |
+
var add_toolbar_button = function () {
|
170 |
+
if (cfg.use_toolbar_button) {
|
171 |
+
Jupyter.toolbar.add_buttons_group([actions.toggle.name], 'toggle_traceback_btns');
|
172 |
+
}
|
173 |
+
};
|
174 |
+
|
175 |
+
var load_ipython_extension = function () {
|
176 |
+
apply_patches();
|
177 |
+
|
178 |
+
Jupyter.notebook.config.loaded
|
179 |
+
.then(function () {
|
180 |
+
$.extend(true, cfg, Jupyter.notebook.config.data[mod_name]);
|
181 |
+
register_new_actions();
|
182 |
+
add_toolbar_button();
|
183 |
+
toggle_traceback(cfg.enable);
|
184 |
+
// update any OutputArea created before our patch)
|
185 |
+
$('.cell .output_area .output_error').each(function (idx, el) {
|
186 |
+
var $el = $(el);
|
187 |
+
if ($el.children('.skip-traceback-summary').length < 1) {
|
188 |
+
var oa = $el.closest('.cell').data('cell').output_area;
|
189 |
+
var json_outputs = oa.toJSON();
|
190 |
+
// clear; do not wait, ignore queue
|
191 |
+
oa.clear_output(false, true);
|
192 |
+
oa.fromJSON(json_outputs);
|
193 |
+
}
|
194 |
+
});
|
195 |
+
})
|
196 |
+
.catch(function (reason) {
|
197 |
+
console.error(log_prefix, 'Error loading:', reason);
|
198 |
+
});
|
199 |
+
};
|
200 |
+
|
201 |
+
return {
|
202 |
+
load_ipython_extension : load_ipython_extension
|
203 |
+
};
|
204 |
+
});
|
.local/share/jupyter/nbextensions/skip-traceback/skip-traceback.png
ADDED
.local/share/jupyter/nbextensions/skip-traceback/traceback.png
ADDED
.local/share/jupyter/nbextensions/snippets/README.md
ADDED
@@ -0,0 +1,61 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Snippets
|
2 |
+
========
|
3 |
+
|
4 |
+
Code cell snippets.
|
5 |
+
|
6 |
+
This extension adds a drop-down menu to the IPython toolbar that allows easy
|
7 |
+
insertion of code snippet cells into the current notebook. The code snippets
|
8 |
+
are defined in a JSON file in `nbextensions/snippets/snippets.json` and an
|
9 |
+
example snippet is included with this extension.
|
10 |
+
|
11 |
+
![](snippets-demo.gif)
|
12 |
+
|
13 |
+
Adding new snippets
|
14 |
+
-------------------
|
15 |
+
|
16 |
+
Snippets are specified by adding a new JSON block to the list of existing snippets in `$(jupyter --data-dir)/nbextensions/snippets/snippets.json`. For example, to add a new snippet that imports numpy, matplotlib, and a print statement, the JSON file should be modified from:
|
17 |
+
|
18 |
+
```json
|
19 |
+
{
|
20 |
+
"snippets" : [
|
21 |
+
{
|
22 |
+
"name" : "example",
|
23 |
+
"code" : [
|
24 |
+
"# This is an example snippet!",
|
25 |
+
"# To create your own, add a new snippet block to the",
|
26 |
+
"# snippets.json file in your jupyter data directory under nbextensions:",
|
27 |
+
"# $(jupyter --data-dir)/nbextensions/snippets/snippets.json",
|
28 |
+
"import this"
|
29 |
+
]
|
30 |
+
}
|
31 |
+
]
|
32 |
+
}
|
33 |
+
```
|
34 |
+
|
35 |
+
to this:
|
36 |
+
|
37 |
+
```json
|
38 |
+
{
|
39 |
+
"snippets" : [
|
40 |
+
{
|
41 |
+
"name" : "example",
|
42 |
+
"code" : [
|
43 |
+
"# This is an example snippet!",
|
44 |
+
"# To create your own, add a new snippet block to the",
|
45 |
+
"# snippets.json file in your jupyter data directory under nbextensions:",
|
46 |
+
"# $(jupyter --data-dir)/nbextensions/snippets/snippets.json",
|
47 |
+
"import this"
|
48 |
+
]
|
49 |
+
},
|
50 |
+
{
|
51 |
+
"name" : "some imports",
|
52 |
+
"code" : [
|
53 |
+
"import numpy as np",
|
54 |
+
"import matplotlib as mpl",
|
55 |
+
"print('spam')"
|
56 |
+
]
|
57 |
+
}
|
58 |
+
]
|
59 |
+
}
|
60 |
+
```
|
61 |
+
You may need to restart your notebook for the changes to take effect.
|
.local/share/jupyter/nbextensions/snippets/main.js
ADDED
@@ -0,0 +1,70 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
// Code cell snippets
|
2 |
+
|
3 |
+
define([
|
4 |
+
'jquery',
|
5 |
+
'base/js/namespace',
|
6 |
+
'base/js/dialog'
|
7 |
+
], function(
|
8 |
+
$,
|
9 |
+
Jupyter,
|
10 |
+
dialog
|
11 |
+
) {
|
12 |
+
"use strict";
|
13 |
+
|
14 |
+
var initialize = function () {
|
15 |
+
var dropdown = $("<select></select>").attr("id", "snippet_picker")
|
16 |
+
.css("margin-left", "0.75em")
|
17 |
+
.attr("class", "form-control select-xs")
|
18 |
+
.change(insert_cell);
|
19 |
+
Jupyter.toolbar.element.append(dropdown);
|
20 |
+
};
|
21 |
+
|
22 |
+
// will be called when the nbextension is loaded
|
23 |
+
function load_extension() {
|
24 |
+
Jupyter.notebook.config.loaded.then(initialize); // trigger loading config parameters
|
25 |
+
|
26 |
+
$.getJSON(Jupyter.notebook.base_url+"nbextensions/snippets/snippets.json", function(data) {
|
27 |
+
// Add the header as the top option, does nothing on click
|
28 |
+
var option = $("<option></option>")
|
29 |
+
.attr("id", "snippet_header")
|
30 |
+
.text("Snippets");
|
31 |
+
$("select#snippet_picker").append(option);
|
32 |
+
|
33 |
+
// Add options for each code snippet in the snippets.json file
|
34 |
+
$.each(data['snippets'], function(key, snippet) {
|
35 |
+
var option = $("<option></option>")
|
36 |
+
.attr("value", snippet['name'])
|
37 |
+
.text(snippet['name'])
|
38 |
+
.attr("code", snippet['code'].join('\n'));
|
39 |
+
$("select#snippet_picker").append(option);
|
40 |
+
});
|
41 |
+
})
|
42 |
+
.error(function(jqXHR, textStatus, errorThrown) {
|
43 |
+
// Add an error message if the JSON fails to load
|
44 |
+
var option = $("<option></option>")
|
45 |
+
.attr("value", 'ERROR')
|
46 |
+
.text('Error: failed to load snippets!')
|
47 |
+
.attr("code", "");
|
48 |
+
$("select#snippet_picker").append(option);
|
49 |
+
});
|
50 |
+
|
51 |
+
};
|
52 |
+
|
53 |
+
var insert_cell = function() {
|
54 |
+
var selected_snippet = $("select#snippet_picker").find(":selected");
|
55 |
+
|
56 |
+
if (selected_snippet.attr("name") != 'header') {
|
57 |
+
var code = selected_snippet.attr("code");
|
58 |
+
var new_cell = Jupyter.notebook.insert_cell_above('code');
|
59 |
+
new_cell.set_text(code);
|
60 |
+
new_cell.focus_cell();
|
61 |
+
|
62 |
+
$("option#snippet_header").prop("selected",true);
|
63 |
+
}
|
64 |
+
};
|
65 |
+
|
66 |
+
// return public methods
|
67 |
+
return {
|
68 |
+
load_ipython_extension : load_extension
|
69 |
+
};
|
70 |
+
});
|
.local/share/jupyter/nbextensions/snippets/snippets-demo.gif
ADDED
.local/share/jupyter/nbextensions/snippets_menu/config.yaml
ADDED
@@ -0,0 +1,123 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Type: Jupyter Notebook Extension
|
2 |
+
Name: Snippets Menu
|
3 |
+
Link: readme.md
|
4 |
+
Description: |
|
5 |
+
Add a customizable menu item to insert code and markdown snippets.
|
6 |
+
Comes with extensive defaults for popular python modules, including fairly
|
7 |
+
complete listings of many important functions and constants, to save
|
8 |
+
searching through documentation.
|
9 |
+
Main: main.js
|
10 |
+
Icon: thumbnail.png
|
11 |
+
Compatibility: 4.x, 5.x
|
12 |
+
Parameters:
|
13 |
+
|
14 |
+
- name: snippets.insert_as_new_cell
|
15 |
+
description: "Insert snippets as new cells, rather than at cursor inside current cell"
|
16 |
+
input_type: checkbox
|
17 |
+
default: false
|
18 |
+
|
19 |
+
- name: snippets.include_custom_menu
|
20 |
+
description: "Include custom menu content parsed from JSON string below"
|
21 |
+
input_type: checkbox
|
22 |
+
default: false
|
23 |
+
|
24 |
+
- name: snippets.custom_menu_content
|
25 |
+
description: |
|
26 |
+
JSON string parsed to define custom menus (only used if the option above is
|
27 |
+
checked)
|
28 |
+
input_type: textarea
|
29 |
+
default: |
|
30 |
+
{
|
31 |
+
"name" : "My favorites",
|
32 |
+
"sub-menu" : [
|
33 |
+
{
|
34 |
+
"name" : "Menu item text",
|
35 |
+
"snippet" : ["import something",
|
36 |
+
"",
|
37 |
+
"new_command(3.14)",
|
38 |
+
"other_new_code_on_new_line('with a string!')",
|
39 |
+
"stringy(\"if you need them, escape double quotes with a single backslash\")",
|
40 |
+
"backslashy('This \\ appears as just one backslash in the output')",
|
41 |
+
"backslashy2('Here \\\\ are two backslashes')"]
|
42 |
+
},
|
43 |
+
{
|
44 |
+
"name" : "TeX can be written in menu labels $\\alpha_W e\\int_0 \\mu \\epsilon$",
|
45 |
+
"snippet" : ["another_new_command(2.78)"]
|
46 |
+
}
|
47 |
+
]
|
48 |
+
}
|
49 |
+
|
50 |
+
- name: snippets.sibling_selector
|
51 |
+
description: |
|
52 |
+
A JQuery selector for a sibling element next to whose parent element the
|
53 |
+
new menu(s) will be inserted. Other suitable examples include '#file_menu',
|
54 |
+
'#edit_menu', '#view_menu', '#insert_menu', '#cell_menu', and
|
55 |
+
'#kernel_menu'. To append the new menu as a submenu to the 'insert' menu
|
56 |
+
itself, you could use '#insert_menu>:last-child'.
|
57 |
+
input_type: text
|
58 |
+
default: '#help_menu'
|
59 |
+
|
60 |
+
- name: snippets.insert_before_sibling
|
61 |
+
description: |
|
62 |
+
Insert the new menu(s) before their sibling (the default value of false
|
63 |
+
means they are inserted after the sibling)
|
64 |
+
input_type: checkbox
|
65 |
+
default: false
|
66 |
+
|
67 |
+
- name: snippets.top_level_submenu_goes_left
|
68 |
+
description: |
|
69 |
+
Snippets menus are often quite big, and positioned at the right side of the
|
70 |
+
menu bar, so by default they open to the left of the menu. Set this to
|
71 |
+
false to get them to open to the right as normal.
|
72 |
+
input_type: checkbox
|
73 |
+
default: true
|
74 |
+
|
75 |
+
- name: snippets.include_submenu.numpy
|
76 |
+
description: "Include numpy sub-menu"
|
77 |
+
input_type: checkbox
|
78 |
+
default: true
|
79 |
+
|
80 |
+
- name: snippets.include_submenu.scipy
|
81 |
+
description: "Include scipy sub-menu"
|
82 |
+
input_type: checkbox
|
83 |
+
default: true
|
84 |
+
|
85 |
+
- name: snippets.include_submenu.matplotlib
|
86 |
+
description: "Include matplotlib sub-menu"
|
87 |
+
input_type: checkbox
|
88 |
+
default: true
|
89 |
+
|
90 |
+
- name: snippets.include_submenu.sympy
|
91 |
+
description: "Include sympy sub-menu"
|
92 |
+
input_type: checkbox
|
93 |
+
default: true
|
94 |
+
|
95 |
+
- name: snippets.include_submenu.pandas
|
96 |
+
description: "Include pandas sub-menu"
|
97 |
+
input_type: checkbox
|
98 |
+
default: true
|
99 |
+
|
100 |
+
- name: snippets.include_submenu.astropy
|
101 |
+
description: "Include astropy sub-menu"
|
102 |
+
input_type: checkbox
|
103 |
+
default: true
|
104 |
+
|
105 |
+
- name: snippets.include_submenu.h5py
|
106 |
+
description: "Include h5py sub-menu"
|
107 |
+
input_type: checkbox
|
108 |
+
default: true
|
109 |
+
|
110 |
+
- name: snippets.include_submenu.numba
|
111 |
+
description: "Include numba sub-menu"
|
112 |
+
input_type: checkbox
|
113 |
+
default: true
|
114 |
+
|
115 |
+
- name: snippets.include_submenu.python
|
116 |
+
description: "Include python sub-menu"
|
117 |
+
input_type: checkbox
|
118 |
+
default: true
|
119 |
+
|
120 |
+
- name: snippets.include_submenu.markdown
|
121 |
+
description: "Include markdown sub-menu"
|
122 |
+
input_type: checkbox
|
123 |
+
default: true
|
.local/share/jupyter/nbextensions/snippets_menu/examples_for_custom.js
ADDED
@@ -0,0 +1,187 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
// The following are various examples taken from README.md. Each section
|
2 |
+
// contains code that you could place into your own custom.js file. Note that
|
3 |
+
// only one of these should be used, though you might want to combine ideas
|
4 |
+
// from the various examples.
|
5 |
+
|
6 |
+
|
7 |
+
//// 1. Simple "My favorites" menu inserted at the *bottom* of "Snippets", with horizontal-line separator
|
8 |
+
requirejs(["nbextensions/snippets_menu/main"], function (snippets_menu) {
|
9 |
+
console.log('Loading `snippets_menu` customizations from `custom.js`');
|
10 |
+
var horizontal_line = '---';
|
11 |
+
var my_favorites = {
|
12 |
+
'name' : 'My favorites',
|
13 |
+
'sub-menu' : [
|
14 |
+
{
|
15 |
+
'name' : 'Menu item text',
|
16 |
+
'snippet' : ['new_command(3.14)',],
|
17 |
+
},
|
18 |
+
{
|
19 |
+
'name' : 'Another menu item',
|
20 |
+
'snippet' : ['another_new_command(2.78)',],
|
21 |
+
},
|
22 |
+
],
|
23 |
+
};
|
24 |
+
snippets_menu.options['menus'] = snippets_menu.default_menus;
|
25 |
+
snippets_menu.options['menus'][0]['sub-menu'].push(horizontal_line);
|
26 |
+
snippets_menu.options['menus'][0]['sub-menu'].push(my_favorites);
|
27 |
+
console.log('Loaded `snippets_menu` customizations from `custom.js`');
|
28 |
+
});
|
29 |
+
|
30 |
+
|
31 |
+
//// 2. "My favorites" menu with lots of stringy goodness
|
32 |
+
requirejs(["nbextensions/snippets_menu/main"], function (snippets_menu) {
|
33 |
+
console.log('Loading `snippets_menu` customizations from `custom.js`');
|
34 |
+
var horizontal_line = '---';
|
35 |
+
var my_favorites = {
|
36 |
+
'name' : 'My $\\nu$ favorites',
|
37 |
+
'sub-menu' : [
|
38 |
+
{
|
39 |
+
'name' : 'Multi-line snippet',
|
40 |
+
'snippet' : ['new_command(3.14)',
|
41 |
+
'other_new_code_on_new_line("with a string!")',
|
42 |
+
'stringy(\'escape single quotes once\')',
|
43 |
+
"stringy2('or use single quotes inside of double quotes')",
|
44 |
+
'backslashy("This \\ appears as just one backslash in the output")',
|
45 |
+
'backslashy2("Here are \\\\ two backslashes")',],
|
46 |
+
},
|
47 |
+
{
|
48 |
+
'name' : 'TeX appears correctly $\\alpha_W e\\int_0 \\mu \\epsilon$',
|
49 |
+
'snippet' : ['another_new_command(2.78)',],
|
50 |
+
},
|
51 |
+
],
|
52 |
+
};
|
53 |
+
snippets_menu.options['menus'].push(snippets_menu.default_menus[0]);
|
54 |
+
snippets_menu.options['menus'][0]['sub-menu'].push(horizontal_line);
|
55 |
+
snippets_menu.options['menus'][0]['sub-menu'].push(my_favorites);
|
56 |
+
console.log('Loaded `snippets_menu` customizations from `custom.js`');
|
57 |
+
});
|
58 |
+
|
59 |
+
|
60 |
+
|
61 |
+
//// 3. Delete "Matplotlib"'s "Setup for scripts" item
|
62 |
+
requirejs(["nbextensions/snippets_menu/main"], function (snippets_menu) {
|
63 |
+
console.log('Loading `snippets_menu` customizations from `custom.js`');
|
64 |
+
snippets_menu.python.matplotlib['sub-menu'].splice(1, 1); // Delete 1 element starting at position 1 of the sub-menu
|
65 |
+
console.log('Loaded `snippets_menu` customizations from `custom.js`');
|
66 |
+
});
|
67 |
+
|
68 |
+
|
69 |
+
|
70 |
+
//// 4. Swap setup items in "Matplotlib" sub-menu
|
71 |
+
requirejs(["nbextensions/snippets_menu/main"], function (snippets_menu) {
|
72 |
+
console.log('Loading `snippets_menu` customizations from `custom.js`');
|
73 |
+
var tmp = snippets_menu.python.matplotlib['sub-menu'][0];
|
74 |
+
snippets_menu.python.matplotlib['sub-menu'][0] = snippets_menu.python.matplotlib['sub-menu'][1];
|
75 |
+
snippets_menu.python.matplotlib['sub-menu'][1] = tmp;
|
76 |
+
console.log('Loaded `snippets_menu` customizations from `custom.js`');
|
77 |
+
});
|
78 |
+
|
79 |
+
|
80 |
+
|
81 |
+
//// 5. Insert "My favorites" as a new top-level menu before "Snippets", instead of inside "Snippets"
|
82 |
+
requirejs(["nbextensions/snippets_menu/main"], function (snippets_menu) {
|
83 |
+
console.log('Loading `snippets_menu` customizations from `custom.js`');
|
84 |
+
var my_favorites = {
|
85 |
+
'name' : 'My favorites',
|
86 |
+
'sub-menu' : [
|
87 |
+
{
|
88 |
+
'name' : 'Menu item text',
|
89 |
+
'snippet' : ['new_command(3.14)',],
|
90 |
+
},
|
91 |
+
{
|
92 |
+
'name' : 'Another menu item',
|
93 |
+
'snippet' : ['another_new_command(2.78)',],
|
94 |
+
},
|
95 |
+
],
|
96 |
+
};
|
97 |
+
snippets_menu.options['menus'].push(my_favorites);
|
98 |
+
snippets_menu.options['menus'].push(snippets_menu.default_menus[0]);
|
99 |
+
console.log('Loaded `snippets_menu` customizations from `custom.js`');
|
100 |
+
});
|
101 |
+
|
102 |
+
|
103 |
+
|
104 |
+
//// 6. Insert "My favorites" as a new top-level menu after "Snippets", instead of inside "Snippets"
|
105 |
+
requirejs(["nbextensions/snippets_menu/main"], function (snippets_menu) {
|
106 |
+
console.log('Loading `snippets_menu` customizations from `custom.js`');
|
107 |
+
var my_favorites = {
|
108 |
+
'name' : 'My favorites',
|
109 |
+
'sub-menu' : [
|
110 |
+
{
|
111 |
+
'name' : 'Menu item text',
|
112 |
+
'snippet' : ['new_command(3.14)',],
|
113 |
+
},
|
114 |
+
{
|
115 |
+
'name' : 'Another menu item',
|
116 |
+
'snippet' : ['another_new_command(2.78)',],
|
117 |
+
},
|
118 |
+
],
|
119 |
+
};
|
120 |
+
snippets_menu.options['menus'].push(snippets_menu.default_menus[0]);
|
121 |
+
snippets_menu.options['menus'].push(my_favorites);
|
122 |
+
console.log('Loaded `snippets_menu` customizations from `custom.js`');
|
123 |
+
});
|
124 |
+
|
125 |
+
|
126 |
+
|
127 |
+
//// 7. Place "Snippets" before "Help" menu
|
128 |
+
requirejs(["nbextensions/snippets_menu/main"], function (snippets_menu) {
|
129 |
+
console.log('Loading `snippets_menu` customizations from `custom.js`');
|
130 |
+
snippets_menu.options['insert_before_sibling'] = true;
|
131 |
+
console.log('Loaded `snippets_menu` customizations from `custom.js`');
|
132 |
+
});
|
133 |
+
|
134 |
+
|
135 |
+
|
136 |
+
//// 8. Move SymPy and Numpy to navbar and delete pandas
|
137 |
+
requirejs(["nbextensions/snippets_menu/main"], function (snippets_menu) {
|
138 |
+
console.log('Loading `snippets_menu` customizations from `custom.js`');
|
139 |
+
snippets_menu.default_menus[0]['sub-menu'].splice(3, 2); // Remove SymPy and pandas
|
140 |
+
snippets_menu.python.sympy['sub-menu-direction'] = 'left'; // Point new SymPy menus to left
|
141 |
+
snippets_menu.python.numpy['sub-menu-direction'] = 'left'; // Point new Numpy menus to left
|
142 |
+
snippets_menu.options['menus'].push(snippets_menu.default_menus[0]); // Start with the remaining "Snippets" menu
|
143 |
+
snippets_menu.options['menus'].push(snippets_menu.python.sympy); // Follow that with a new SymPy menu
|
144 |
+
snippets_menu.options['menus'].push(snippets_menu.python.numpy); // Follow that with a new Numpy menu
|
145 |
+
console.log('Loaded `snippets_menu` customizations from `custom.js`');
|
146 |
+
});
|
147 |
+
|
148 |
+
|
149 |
+
|
150 |
+
//// 9. Change direction of sub-menus under "Snippets"
|
151 |
+
requirejs(["nbextensions/snippets_menu/main"], function (snippets_menu) {
|
152 |
+
console.log('Loading `snippets_menu` customizations from `custom.js`');
|
153 |
+
snippets_menu.options['direction_of_top_level_submenu'] = 'right';
|
154 |
+
console.log('Loaded `snippets_menu` customizations from `custom.js`');
|
155 |
+
});
|
156 |
+
|
157 |
+
|
158 |
+
|
159 |
+
//// 10. Place "Snippets" inside "Insert" menu
|
160 |
+
requirejs(["nbextensions/snippets_menu/main"], function (snippets_menu) {
|
161 |
+
console.log('Loading `snippets_menu` customizations from `custom.js`');
|
162 |
+
snippets_menu.default_menus[0]['menu-direction'] = 'left'; // Open top-level menu to the left...
|
163 |
+
snippets_menu.default_menus[0]['sub-menu-direction'] = 'right'; // ...and sub-menus to the right.
|
164 |
+
snippets_menu.options['menus'].push('---', snippets_menu.default_menus[0]); // Add horizontal line and default menus
|
165 |
+
snippets_menu.options['sibling'] = $("#insert_cell_below"); // Find the place at which to insert the new menus
|
166 |
+
console.log('Loaded `snippets_menu` customizations from `custom.js`');
|
167 |
+
});
|
168 |
+
|
169 |
+
|
170 |
+
|
171 |
+
//// 11. Multiple menus in different places
|
172 |
+
requirejs(["nbextensions/snippets_menu/main"], function (snippets_menu) {
|
173 |
+
console.log('Loading `snippets_menu` customizations from `custom.js`');
|
174 |
+
var sympy_menu = [snippets_menu.python.sympy,];
|
175 |
+
sympy_menu[0]['sub-menu-direction'] = 'left';
|
176 |
+
snippets_menu.options['menus'] = sympy_menu;
|
177 |
+
snippets_menu.default_menus[0]['sub-menu'].splice(3, 1); // Remove SymPy from defaults
|
178 |
+
snippets_menu.default_menus[0]['menu-direction'] = 'left';
|
179 |
+
snippets_menu.default_menus[0]['sub-menu-direction'] = 'right';
|
180 |
+
var sibling = $("#insert_cell_below");
|
181 |
+
var inserted_menu = [
|
182 |
+
'---',
|
183 |
+
snippets_menu.default_menus[0],
|
184 |
+
];
|
185 |
+
snippets_menu.menu_setup(inserted_menu, sibling, false);
|
186 |
+
console.log('Loaded `snippets_menu` customizations from `custom.js`');
|
187 |
+
});
|
.local/share/jupyter/nbextensions/snippets_menu/main.js
ADDED
@@ -0,0 +1,292 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
define([
|
2 |
+
"require",
|
3 |
+
"jquery",
|
4 |
+
"base/js/namespace",
|
5 |
+
"./snippets_submenu_python",
|
6 |
+
"./snippets_submenu_markdown",
|
7 |
+
], function (requirejs, $, Jupyter, python, markdown) {
|
8 |
+
"use strict";
|
9 |
+
|
10 |
+
var mod_name = 'snippets_menu';
|
11 |
+
var mod_log_prefix = mod_name + '[' + mod_name + ']';
|
12 |
+
|
13 |
+
var python_menus = [
|
14 |
+
python.numpy,
|
15 |
+
python.scipy,
|
16 |
+
python.matplotlib,
|
17 |
+
python.sympy,
|
18 |
+
python.pandas,
|
19 |
+
python.astropy,
|
20 |
+
python.h5py,
|
21 |
+
python.numba,
|
22 |
+
python.python,
|
23 |
+
];
|
24 |
+
|
25 |
+
var default_menus = [
|
26 |
+
{
|
27 |
+
'name' : 'Snippets',
|
28 |
+
'sub-menu-direction' : 'left',
|
29 |
+
'sub-menu' : python_menus.concat([markdown]),
|
30 |
+
},
|
31 |
+
];
|
32 |
+
var options = {
|
33 |
+
sibling: undefined, // if undefined, set by cfg.sibling_selector
|
34 |
+
menus : [],
|
35 |
+
hooks: {
|
36 |
+
pre_config: undefined,
|
37 |
+
post_config: undefined,
|
38 |
+
}
|
39 |
+
};
|
40 |
+
|
41 |
+
var includable_submenu_keys = [
|
42 |
+
"numpy",
|
43 |
+
"scipy",
|
44 |
+
"matplotlib",
|
45 |
+
"sympy",
|
46 |
+
"pandas",
|
47 |
+
"astropy",
|
48 |
+
"h5py",
|
49 |
+
"numba",
|
50 |
+
"python",
|
51 |
+
"markdown",
|
52 |
+
];
|
53 |
+
// default parameters
|
54 |
+
var cfg = {
|
55 |
+
insert_as_new_cell: false,
|
56 |
+
insert_before_sibling: false,
|
57 |
+
include_custom_menu: false,
|
58 |
+
include_submenu: {}, // default set after this definition
|
59 |
+
sibling_selector: '#help_menu',
|
60 |
+
top_level_submenu_goes_left: true,
|
61 |
+
// The default has to be included here as well as config.yaml
|
62 |
+
// because the configurator will not store the default given
|
63 |
+
// in config.yaml unless it is changed. That means that this
|
64 |
+
// should be kept up-to-date with whatever goes in
|
65 |
+
// config.yaml.
|
66 |
+
custom_menu_content: JSON.stringify({
|
67 |
+
"name" : "My favorites",
|
68 |
+
"sub-menu" : [{
|
69 |
+
"name" : "Menu item text",
|
70 |
+
"snippet" : [
|
71 |
+
"import something",
|
72 |
+
"",
|
73 |
+
"new_command(3.14)",
|
74 |
+
"other_new_code_on_new_line('with a string!')",
|
75 |
+
"stringy(\"if you need them, escape double quotes with a single backslash\")",
|
76 |
+
"backslashy('This \\ appears as just one backslash in the output')",
|
77 |
+
"backslashy2('Here \\\\ are two backslashes')"
|
78 |
+
]}, {
|
79 |
+
"name" : "TeX can be written in menu labels $\\alpha_W e\\int_0 \\mu \\epsilon$",
|
80 |
+
"snippet" : [
|
81 |
+
"another_new_command(2.78)"
|
82 |
+
]
|
83 |
+
}
|
84 |
+
]
|
85 |
+
})
|
86 |
+
};
|
87 |
+
for (var ii=0; ii< includable_submenu_keys.length; ii++) {
|
88 |
+
cfg.include_submenu[includable_submenu_keys[ii]] = true;
|
89 |
+
}
|
90 |
+
|
91 |
+
function config_loaded_callback () {
|
92 |
+
if (options['pre_config_hook'] !== undefined) {
|
93 |
+
options['pre_config_hook']();
|
94 |
+
}
|
95 |
+
|
96 |
+
// true => deep
|
97 |
+
cfg = $.extend(true, cfg, Jupyter.notebook.config.data.snippets);
|
98 |
+
|
99 |
+
if (cfg.insert_as_new_cell) {
|
100 |
+
console.log(mod_log_prefix, "Insertions will insert new cell");
|
101 |
+
}
|
102 |
+
|
103 |
+
// If `options.menus` had elements added in custom.js, skip all of this and ignore all remaining options
|
104 |
+
if (options.menus.length > 0) {
|
105 |
+
console.log(mod_log_prefix, '`options.menus` was created in custom.js; skipping all other configuration.');
|
106 |
+
}
|
107 |
+
else {
|
108 |
+
options.menus = [
|
109 |
+
{
|
110 |
+
'name' : 'Snippets',
|
111 |
+
'sub-menu-direction' : cfg.top_level_submenu_goes_left ? 'left' : 'right',
|
112 |
+
'sub-menu' : [],
|
113 |
+
},
|
114 |
+
];
|
115 |
+
|
116 |
+
if (cfg.include_custom_menu) {
|
117 |
+
var custom_menu_content = JSON.parse(cfg.custom_menu_content);
|
118 |
+
console.log(mod_log_prefix,
|
119 |
+
"Inserting custom", custom_menu_content.name, "sub-menu");
|
120 |
+
options.menus[0]['sub-menu'].push(custom_menu_content);
|
121 |
+
}
|
122 |
+
|
123 |
+
for (var ii=0; ii < includable_submenu_keys.length; ii++) {
|
124 |
+
var key = includable_submenu_keys[ii];
|
125 |
+
if (cfg.include_submenu[key]) {
|
126 |
+
console.log(mod_log_prefix,
|
127 |
+
"Inserting default", key, "sub-menu");
|
128 |
+
options.menus[0]['sub-menu'].push(key === "markdown" ? markdown : python[key]);
|
129 |
+
}
|
130 |
+
}
|
131 |
+
}
|
132 |
+
|
133 |
+
if (options.hooks.post_config !== undefined) {
|
134 |
+
options.hooks.post_config();
|
135 |
+
}
|
136 |
+
|
137 |
+
// select correct sibling
|
138 |
+
if (options.sibling === undefined) {
|
139 |
+
options.sibling = $(cfg.sibling_selector).parent();
|
140 |
+
if (options.sibling.length < 1) {
|
141 |
+
options.sibling = $("#help_menu").parent();
|
142 |
+
}
|
143 |
+
}
|
144 |
+
}
|
145 |
+
|
146 |
+
function insert_snippet_code (snippet_code) {
|
147 |
+
if (cfg.insert_as_new_cell) {
|
148 |
+
var new_cell = Jupyter.notebook.insert_cell_above('code');
|
149 |
+
new_cell.set_text(snippet_code);
|
150 |
+
new_cell.focus_cell();
|
151 |
+
}
|
152 |
+
else {
|
153 |
+
var selected_cell = Jupyter.notebook.get_selected_cell();
|
154 |
+
Jupyter.notebook.edit_mode();
|
155 |
+
selected_cell.code_mirror.replaceSelection(snippet_code, 'around');
|
156 |
+
}
|
157 |
+
}
|
158 |
+
|
159 |
+
function callback_insert_snippet (evt) {
|
160 |
+
// this (or event.currentTarget, see below) always refers to the DOM
|
161 |
+
// element the listener was attached to - see
|
162 |
+
// http://stackoverflow.com/questions/12077859
|
163 |
+
insert_snippet_code($(evt.currentTarget).data('snippet-code'));
|
164 |
+
}
|
165 |
+
|
166 |
+
function build_menu_element (menu_item_spec, direction) {
|
167 |
+
// Create the menu item html element
|
168 |
+
var element = $('<li/>');
|
169 |
+
|
170 |
+
if (typeof menu_item_spec == 'string') {
|
171 |
+
if (menu_item_spec != '---') {
|
172 |
+
console.log(mod_log_prefix,
|
173 |
+
'Don\'t understand sub-menu string "' + menu_item_spec + '"');
|
174 |
+
return null;
|
175 |
+
}
|
176 |
+
return element.addClass('divider');
|
177 |
+
}
|
178 |
+
|
179 |
+
var a = $('<a/>')
|
180 |
+
.attr('href', '#')
|
181 |
+
.html(menu_item_spec.name)
|
182 |
+
.appendTo(element);
|
183 |
+
if (menu_item_spec.hasOwnProperty('snippet')) {
|
184 |
+
var snippet = menu_item_spec.snippet;
|
185 |
+
if (typeof snippet == 'string' || snippet instanceof String) {
|
186 |
+
snippet = [snippet];
|
187 |
+
}
|
188 |
+
a.attr({
|
189 |
+
'title' : "", // Do not remove this, even though it's empty!
|
190 |
+
'data-snippet-code' : snippet.join('\n'),
|
191 |
+
})
|
192 |
+
.on('click', callback_insert_snippet)
|
193 |
+
.addClass('snippet');
|
194 |
+
}
|
195 |
+
else if (menu_item_spec.hasOwnProperty('internal-link')) {
|
196 |
+
a.attr('href', menu_item_spec['internal-link']);
|
197 |
+
}
|
198 |
+
else if (menu_item_spec.hasOwnProperty('external-link')) {
|
199 |
+
a.empty();
|
200 |
+
a.attr({
|
201 |
+
'target' : '_blank',
|
202 |
+
'title' : 'Opens in a new window',
|
203 |
+
'href' : menu_item_spec['external-link'],
|
204 |
+
});
|
205 |
+
$('<i class="fa fa-external-link menu-icon pull-right"/>').appendTo(a);
|
206 |
+
$('<span/>').html(menu_item_spec.name).appendTo(a);
|
207 |
+
}
|
208 |
+
|
209 |
+
if (menu_item_spec.hasOwnProperty('sub-menu')) {
|
210 |
+
element
|
211 |
+
.addClass('dropdown-submenu')
|
212 |
+
.toggleClass('dropdown-submenu-left', direction === 'left');
|
213 |
+
var sub_element = $('<ul class="dropdown-menu"/>')
|
214 |
+
.toggleClass('dropdown-menu-compact', menu_item_spec.overlay === true) // For space-saving menus
|
215 |
+
.appendTo(element);
|
216 |
+
|
217 |
+
var new_direction = (menu_item_spec['sub-menu-direction'] === 'left') ? 'left' : 'right';
|
218 |
+
for (var j=0; j<menu_item_spec['sub-menu'].length; ++j) {
|
219 |
+
var sub_menu_item_spec = build_menu_element(menu_item_spec['sub-menu'][j], new_direction);
|
220 |
+
if(sub_menu_item_spec !== null) {
|
221 |
+
sub_menu_item_spec.appendTo(sub_element);
|
222 |
+
}
|
223 |
+
}
|
224 |
+
}
|
225 |
+
|
226 |
+
return element;
|
227 |
+
}
|
228 |
+
|
229 |
+
function menu_setup (menu_item_specs, sibling, insert_before_sibling) {
|
230 |
+
for (var i=0; i<menu_item_specs.length; ++i) {
|
231 |
+
var menu_item_spec;
|
232 |
+
if (insert_before_sibling) {
|
233 |
+
menu_item_spec = menu_item_specs[i];
|
234 |
+
} else {
|
235 |
+
menu_item_spec = menu_item_specs[menu_item_specs.length-1-i];
|
236 |
+
}
|
237 |
+
var direction = (menu_item_spec['menu-direction'] == 'left') ? 'left' : 'right';
|
238 |
+
var menu_element = build_menu_element(menu_item_spec, direction);
|
239 |
+
// We need special properties if this item is in the navbar
|
240 |
+
if ($(sibling).parent().is('ul.nav.navbar-nav')) {
|
241 |
+
menu_element
|
242 |
+
.addClass('dropdown')
|
243 |
+
.removeClass('dropdown-submenu dropdown-submenu-left');
|
244 |
+
menu_element.children('a')
|
245 |
+
.addClass('dropdown-toggle')
|
246 |
+
.attr({
|
247 |
+
'data-toggle' : 'dropdown',
|
248 |
+
'aria-expanded' : 'false'
|
249 |
+
});
|
250 |
+
}
|
251 |
+
|
252 |
+
// Insert the menu element into DOM
|
253 |
+
menu_element[insert_before_sibling ? 'insertBefore': 'insertAfter'](sibling);
|
254 |
+
|
255 |
+
// Make sure MathJax will typeset this menu
|
256 |
+
window.MathJax.Hub.Queue(["Typeset", window.MathJax.Hub, menu_element[0]]);
|
257 |
+
}
|
258 |
+
}
|
259 |
+
|
260 |
+
function load_ipython_extension () {
|
261 |
+
// Add our css to the notebook's head
|
262 |
+
$('<link/>', {
|
263 |
+
rel: 'stylesheet',
|
264 |
+
type:'text/css',
|
265 |
+
href: requirejs.toUrl('./snippets_menu.css')
|
266 |
+
}).appendTo('head');
|
267 |
+
|
268 |
+
// Arrange the menus as given by the configuration
|
269 |
+
Jupyter.notebook.config.loaded.then(
|
270 |
+
config_loaded_callback
|
271 |
+
).then(function () {
|
272 |
+
// Parse and insert the menu items
|
273 |
+
menu_setup(options.menus, options.sibling, cfg.insert_before_sibling);
|
274 |
+
});
|
275 |
+
}
|
276 |
+
|
277 |
+
return {
|
278 |
+
// Handy functions
|
279 |
+
load_ipython_extension : load_ipython_extension,
|
280 |
+
menu_setup : menu_setup,
|
281 |
+
|
282 |
+
// Default menus
|
283 |
+
python : python,
|
284 |
+
python_menus : python_menus,
|
285 |
+
markdown : markdown,
|
286 |
+
default_menus : default_menus,
|
287 |
+
|
288 |
+
// Items that could be useful for customization
|
289 |
+
options : options,
|
290 |
+
};
|
291 |
+
|
292 |
+
});
|
.local/share/jupyter/nbextensions/snippets_menu/readme.md
ADDED
@@ -0,0 +1,633 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Jupyter notebook snippets menu
|
2 |
+
==============================
|
3 |
+
|
4 |
+
Adds a customizable menu item to Jupyter notebooks to insert
|
5 |
+
snippets, boilerplate, and examples of code.
|
6 |
+
|
7 |
+
![Open snippets menu](screenshot1.png)
|
8 |
+
|
9 |
+
This notebook extension adds a menu item (or multiple menu items, if
|
10 |
+
desired) after the `Help` menu in Jupyter notebooks. This new menu
|
11 |
+
contains little snippets of code that we all forget from time to time
|
12 |
+
but don't want to google, or are just too lazy to type, or simply
|
13 |
+
didn't know about. It can also be helpful for people just starting
|
14 |
+
out with a programming language, who need some ideas for what to do
|
15 |
+
next — like importing a module, defining variables, or calling
|
16 |
+
functions.
|
17 |
+
|
18 |
+
The new menu comes with a default value relevant for python
|
19 |
+
programming — especially scientific computing — though this is fully
|
20 |
+
user-configurable as detailed below. The default menu is named
|
21 |
+
`Snippets`, and contains sub-menus with snippets for a few popular
|
22 |
+
python packages, as well as python itself, and some notebook markdown.
|
23 |
+
(Note that some of the menus are so large that it is necessary to move
|
24 |
+
the first-level menus to the left so that lower-level menus will fit
|
25 |
+
on the screen. This behavior is also user-configurable, as discussed
|
26 |
+
in detail [below](#change-direction-of-sub-menus).)
|
27 |
+
|
28 |
+
So, for example, if you are editing a code cell and want to import
|
29 |
+
matplotlib for use in the notebook, you can just click the `Snippets`
|
30 |
+
menu, then mouse over "Matplotlib". This will open up a new sub-menu,
|
31 |
+
with an item "Setup for notebook". Clicking on that item will insert
|
32 |
+
the code snippet at the point where your cursor was just before you
|
33 |
+
clicked on the menu. In particular, for this `matplotlib` example,
|
34 |
+
the following code gets inserted:
|
35 |
+
|
36 |
+
```python
|
37 |
+
import numpy as np
|
38 |
+
import matplotlib as mpl
|
39 |
+
import matplotlib.pyplot as plt
|
40 |
+
%matplotlib inline
|
41 |
+
```
|
42 |
+
|
43 |
+
The inserted text will be selected, so that you can delete it by
|
44 |
+
pressing backspace or delete, or you can just select another snippet
|
45 |
+
to replace it -- and just to highlight what was inserted.
|
46 |
+
|
47 |
+
Note that many of the snippets involve variable names prefixed with
|
48 |
+
`bp_`. For example, a new numpy array is created as `bp_new_array`.
|
49 |
+
These are intentionally dumb names that you really should replace.
|
50 |
+
Failing to do so could lead to ugly bugs in your code if you use
|
51 |
+
multiple boilerplate snippets with clashing variable names.
|
52 |
+
|
53 |
+
Similarly, some strings are intended to be replaced, such as the axis
|
54 |
+
labels in plots. These are there to show you what can be done, and to
|
55 |
+
remind you to put informative labels in your plots. If you don't
|
56 |
+
want, e.g., a title on your plot, just remove that line.
|
57 |
+
|
58 |
+
|
59 |
+
Installation
|
60 |
+
------------
|
61 |
+
To install this extension alone (without the [main collection of nbextensions](https://github.com/ipython-contrib/jupyter_contrib_nbextensions)), run the following from the command line:
|
62 |
+
|
63 |
+
```bash
|
64 |
+
git clone git://github.com/moble/jupyter_boilerplate
|
65 |
+
jupyter nbextension install jupyter_boilerplate
|
66 |
+
jupyter nbextension enable jupyter_boilerplate/main
|
67 |
+
```
|
68 |
+
|
69 |
+
You can then disable the extension if you want with
|
70 |
+
```bash
|
71 |
+
jupyter nbextension disable jupyter_boilerplate/main
|
72 |
+
```
|
73 |
+
|
74 |
+
|
75 |
+
Basic menu customization
|
76 |
+
------------------------
|
77 |
+
|
78 |
+
The default menu might have too many irrelevant items for you, or may
|
79 |
+
not have something you would find useful. You can easily customize it
|
80 |
+
in the
|
81 |
+
[jupyter_nbextensions_configurator](https://github.com/Jupyter-contrib/jupyter_nbextensions_configurator#usage),
|
82 |
+
which you almost certainly have if you installed this extension the
|
83 |
+
normal way,
|
84 |
+
through
|
85 |
+
[jupyter_contrib_nbextensions](https://github.com/ipython-contrib/jupyter_contrib_nbextensions).
|
86 |
+
Usually, you can get to the configurator by pointing your browser to
|
87 |
+
http://127.0.0.1:8888/nbextensions, though you may have to modify the
|
88 |
+
URL if you use a more complicated jupyter server.
|
89 |
+
|
90 |
+
On the configurator page, you will see a number of options (as well as
|
91 |
+
this README) that should be fairly self-explanatory, allowing you to
|
92 |
+
remove any of the default menu items, or add a custom menu within the
|
93 |
+
"Snippets" menu. The custom menu is written in JSON, and a simple
|
94 |
+
(and useless) example is given that should be easy to modify as
|
95 |
+
needed.
|
96 |
+
|
97 |
+
|
98 |
+
|
99 |
+
Advanced menu customization
|
100 |
+
---------------------------
|
101 |
+
|
102 |
+
It is also possible to extensively customize the menus in far more
|
103 |
+
complex ways using your `custom.js` file. For example, you can change
|
104 |
+
the order of menu items, add more custom sub-menus under the
|
105 |
+
"Snippets" menu, and custom menus alongside "Snippets" in the menu
|
106 |
+
bar, or even add menus in other places, like inside the "Insert" menu.
|
107 |
+
|
108 |
+
You can find the path to `custom.js` by running the command
|
109 |
+
|
110 |
+
```bash
|
111 |
+
echo $(jupyter --config-dir)/custom/custom.js
|
112 |
+
```
|
113 |
+
|
114 |
+
For Mac and linux users, the result is probably
|
115 |
+
`~/.jupyter/custom/custom.js`. If this file or the directory
|
116 |
+
containing it do not exist, you can simply create them.
|
117 |
+
|
118 |
+
The customization process is best explained through examples, which
|
119 |
+
are available in the `examples_for_custom.js` file in this directory.
|
120 |
+
Note that there's a lot of explanation here, but it's all actually
|
121 |
+
pretty simple. Give it a try, and you'll pick it up quickly. Note
|
122 |
+
that using this method can make it so that options selected in the
|
123 |
+
configurator are ignored.
|
124 |
+
|
125 |
+
The theory behind this customization is that the menu is represented
|
126 |
+
by a nested JavaScript array (which is just like a python list). So
|
127 |
+
to change the menu, you just need to change that array. And each menu
|
128 |
+
*item* inside this array is represented by
|
129 |
+
a [JavaScript "object"](https://api.jquery.com/Types/#Object) (which is
|
130 |
+
just like a python dictionary). So to change a menu item, you just
|
131 |
+
have to change that object.
|
132 |
+
|
133 |
+
Again, this makes more sense when looking at example, as follows.
|
134 |
+
|
135 |
+
|
136 |
+
### Add a custom sub-menu with simple snippets
|
137 |
+
|
138 |
+
Suppose you want to make a new sub-menu with your favorite snippets at
|
139 |
+
the bottom of `Snippets`. You create a new object for the menu item,
|
140 |
+
and then just "push" it onto the default menu. Do this by inserting
|
141 |
+
some lines into your `custom.js`, so that it looks like this:
|
142 |
+
|
143 |
+
```javascript
|
144 |
+
require(["nbextensions/snippets_menu/main"], function (snippets_menu) {
|
145 |
+
console.log('Loading `snippets_menu` customizations from `custom.js`');
|
146 |
+
var horizontal_line = '---';
|
147 |
+
var my_favorites = {
|
148 |
+
'name' : 'My favorites',
|
149 |
+
'sub-menu' : [
|
150 |
+
{
|
151 |
+
'name' : 'Menu item text',
|
152 |
+
'snippet' : ['new_command(3.14)',],
|
153 |
+
},
|
154 |
+
{
|
155 |
+
'name' : 'Another menu item',
|
156 |
+
'snippet' : ['another_new_command(2.78)',],
|
157 |
+
},
|
158 |
+
],
|
159 |
+
};
|
160 |
+
snippets_menu.options['menus'] = snippets_menu.default_menus;
|
161 |
+
snippets_menu.options['menus'][0]['sub-menu'].push(horizontal_line);
|
162 |
+
snippets_menu.options['menus'][0]['sub-menu'].push(my_favorites);
|
163 |
+
console.log('Loaded `snippets_menu` customizations from `custom.js`');
|
164 |
+
});
|
165 |
+
```
|
166 |
+
|
167 |
+
Now, if you refresh your notebook, you'll see a new menu item named "My
|
168 |
+
favorites". Hover over it, and it will pop up a sub-menu with two more
|
169 |
+
options. Click the first one, and it will insert `new_command(3.14)` into
|
170 |
+
your notebook wherever the cursor was.
|
171 |
+
|
172 |
+
We discuss how all this works below. But first, we need to slightly generalize
|
173 |
+
the example above to work with more complicated snippets.
|
174 |
+
|
175 |
+
|
176 |
+
### More complicated snippets
|
177 |
+
|
178 |
+
The example above inserted simple one-line snippets of code. Those snippets
|
179 |
+
didn't have any quotation marks (single or double), backslashes, or newlines,
|
180 |
+
which made everything easy. Unfortunately, JavaScript doesn't deal too well
|
181 |
+
with strings. (There are no raw triple-quoted strings, like in python.) So
|
182 |
+
there are just three things to remember when writing snippets.
|
183 |
+
|
184 |
+
1. Quotation marks can be a tiny bit tricky. There are a few options:
|
185 |
+
1. The obvious option is to enclose your snippets in single quotation marks
|
186 |
+
(`'`), and use only double quotation marks (`"`) within the snippet
|
187 |
+
itself.
|
188 |
+
2. Just as easy is to enclose your snippets in double quotation marks
|
189 |
+
(`"`), and use only single quotation marks (`'`) within the snippet
|
190 |
+
itself.
|
191 |
+
3. You can also escape single quotation marks inside single quotation marks
|
192 |
+
as `\'`.
|
193 |
+
|
194 |
+
2. Newlines are even trickier, but the extension takes care of this for you
|
195 |
+
as long as you put separate lines of code as separate elements of the
|
196 |
+
`snippet` array. Generally, there's no reason to put a literal newline in
|
197 |
+
your snippets.
|
198 |
+
|
199 |
+
3. JavaScript will treat backslashes as if they're trying to escape whatever
|
200 |
+
comes after them. So if you want one backslash in your output code,
|
201 |
+
you'll need to put two backslashes in.
|
202 |
+
|
203 |
+
This is all best described with another example. Let's change the first
|
204 |
+
function above, to give it some more lines and some quotes:
|
205 |
+
|
206 |
+
```javascript
|
207 |
+
require(["nbextensions/snippets_menu/main"], function (snippets_menu) {
|
208 |
+
console.log('Loading `snippets_menu` customizations from `custom.js`');
|
209 |
+
var horizontal_line = '---';
|
210 |
+
var my_favorites = {
|
211 |
+
'name' : 'My $\\nu$ favorites',
|
212 |
+
'sub-menu' : [
|
213 |
+
{
|
214 |
+
'name' : 'Multi-line snippet',
|
215 |
+
'snippet' : ['new_command(3.14)',
|
216 |
+
'other_new_code_on_new_line("with a string!")',
|
217 |
+
'stringy(\'escape single quotes once\')',
|
218 |
+
"stringy2('or use single quotes inside of double quotes')",
|
219 |
+
'backslashy("This \\ appears as just one backslash in the output")',
|
220 |
+
'backslashy2("Here are \\\\ two backslashes")',],
|
221 |
+
},
|
222 |
+
{
|
223 |
+
'name' : 'TeX appears correctly $\\alpha_W e\\int_0 \\mu \\epsilon$',
|
224 |
+
'snippet' : ['another_new_command(2.78)',],
|
225 |
+
},
|
226 |
+
],
|
227 |
+
};
|
228 |
+
snippets_menu.options['menus'].push(snippets_menu.default_menus[0]);
|
229 |
+
snippets_menu.options['menus'][0]['sub-menu'].push(horizontal_line);
|
230 |
+
snippets_menu.options['menus'][0]['sub-menu'].push(my_favorites);
|
231 |
+
console.log('Loaded `snippets_menu` customizations from `custom.js`');
|
232 |
+
});
|
233 |
+
```
|
234 |
+
|
235 |
+
Note the code output by the first item contains all sorts of interesting
|
236 |
+
strings. Also, the menu title of the second item contains TeX, which will
|
237 |
+
display correctly, and is used in some of the default menus to show the
|
238 |
+
standard symbols for physical constants. For more examples, look at the
|
239 |
+
default menus stored in the `snippets_menu` directory -- mostly under `python`.
|
240 |
+
|
241 |
+
|
242 |
+
### How it works: Creating new menu items
|
243 |
+
|
244 |
+
Each of the menu items above is a JavaScript object (like a python `dict`),
|
245 |
+
with some attributes -- `name` and `sub-menu` for the main menu item, and
|
246 |
+
`name` and `snippet` for the sub-menu items. In general, any menu object can
|
247 |
+
have any of the following properties:
|
248 |
+
|
249 |
+
1. `name`: Text that appears in the menu. Note that this can include latex,
|
250 |
+
as the menus are processed by MathJax after being loaded.
|
251 |
+
2. `sub-menu`: An array of more menu items
|
252 |
+
3. `snippet`: An array of strings turned into code when the menu item is
|
253 |
+
clicked
|
254 |
+
4. `internal-link`: Link to some place on the present page. For example,
|
255 |
+
this could be `#References`, to link to the `References` section of any
|
256 |
+
notebook you're in.
|
257 |
+
5. `external-link`: This just a link to some external web page, which will be
|
258 |
+
identified with a little icon, just like in the standard notebook "Help"
|
259 |
+
menu. When clicked, the link will open in a new window/tab.
|
260 |
+
6. `menu-direction`: If the value of this property is `left`, this menu's
|
261 |
+
sub-menus open on the left. This is useful when the top-level menu is
|
262 |
+
inserted as an item within other menu items. See
|
263 |
+
[below](#change-direction-of-sub-menus) for examples.
|
264 |
+
7. `sub-menu-direction`: If the value of this property is `left`, sub-menus
|
265 |
+
within this menu's sub-menus open on the left. This is used by default
|
266 |
+
for items under the `Snippets` menu to help ensure that nested menus
|
267 |
+
don't become too large to fit on the screen. See
|
268 |
+
[below](#change-direction-of-sub-menus) for examples.
|
269 |
+
|
270 |
+
The `name` property is the only required one, though you'll probably want at
|
271 |
+
least one other property. The `sub-menu` contains menu objects that again may
|
272 |
+
have any of these properties, so you can easily nest menus. You can also
|
273 |
+
combine a `snippet` with a `sub-menu`, so that there's a default value as well
|
274 |
+
as a sub-menu. However, the last three are mutually exclusive: `snippet` will
|
275 |
+
override any `-link`; an `internal-link` will override an `external-link`.
|
276 |
+
|
277 |
+
|
278 |
+
### How it works: Splicing new menu items into the old
|
279 |
+
|
280 |
+
Besides just creating the menu items, we may want to join together previously
|
281 |
+
created items. That's the purpose of this line in the code above:
|
282 |
+
|
283 |
+
```javascript
|
284 |
+
snippets_menu.options['menus'][0]['sub-menu'].push(my_favorites);
|
285 |
+
```
|
286 |
+
|
287 |
+
This uses
|
288 |
+
the [JavaScript `push`](https://www.w3schools.com/jsref/jsref_push.asp)
|
289 |
+
function to insert the new menu `my_favorites` menu into the last slot
|
290 |
+
of `snippets_menu.options['menus'][0]['sub-menu']`, which is the set
|
291 |
+
of menus under the heading `Snippets`.
|
292 |
+
|
293 |
+
If you think about this last point, you'll realize that `Snippets` is
|
294 |
+
just the `0` slot of an array of menus. If you want a new menu right
|
295 |
+
in the menu bar, you could add `my_favorites` right to that top-level
|
296 |
+
array, with something like this:
|
297 |
+
|
298 |
+
```javascript
|
299 |
+
snippets_menu.options['menus'].push(snippets_menu.default_menus[0]);
|
300 |
+
snippets_menu.options['menus'].push(my_favorites);
|
301 |
+
```
|
302 |
+
|
303 |
+
This would place your favorites after the default `Snippets` menu; to
|
304 |
+
put it before, just swap the order in which you `push`:
|
305 |
+
|
306 |
+
```javascript
|
307 |
+
snippets_menu.options['menus'].push(my_favorites);
|
308 |
+
snippets_menu.options['menus'].push(snippets_menu.default_menus[0]);
|
309 |
+
```
|
310 |
+
|
311 |
+
(In general, to add a new element at a given index of an array, you
|
312 |
+
could also just use
|
313 |
+
the [splice](https://www.w3schools.com/jsref/jsref_splice.asp)
|
314 |
+
function.)
|
315 |
+
|
316 |
+
This might be useful if you have one set of very frequently used
|
317 |
+
commands, and want immediate access, without going through various
|
318 |
+
levels of the usual menu. A useful example of this is
|
319 |
+
shown [below](#starting-over-with-the-menus). The `splice` function
|
320 |
+
can also be used to delete items from the array, as
|
321 |
+
described [next](#deleting-menu-items).
|
322 |
+
|
323 |
+
|
324 |
+
### Other menu manipulations
|
325 |
+
|
326 |
+
To rearrange menu items, just use standard JavaScript techniques. The two most
|
327 |
+
likely examples are deleting and rearranging menu items, but we'll also see
|
328 |
+
that other manipulations are easy. We can also change where the new menus go,
|
329 |
+
and what they look like.
|
330 |
+
|
331 |
+
#### Deleting menu items
|
332 |
+
|
333 |
+
To delete an item, just `splice` nothing into it. Let's suppose, for example,
|
334 |
+
that you want to remove the option to set up matplotlib for a script, which is
|
335 |
+
the `1` item of the "Matplotlib" menu:
|
336 |
+
|
337 |
+
```javascript
|
338 |
+
snippets_menu.python.matplotlib['sub-menu']
|
339 |
+
```
|
340 |
+
|
341 |
+
Remember that `[1]` is the second element of "Matplotlib"'s sub-menu
|
342 |
+
list. So the following code will do the trick
|
343 |
+
|
344 |
+
|
345 |
+
```javascript
|
346 |
+
require(["nbextensions/snippets_menu/main"], function (snippets_menu) {
|
347 |
+
console.log('Loading `snippets_menu` customizations from `custom.js`');
|
348 |
+
snippets_menu.python.matplotlib['sub-menu'].splice(1, 1); // Delete 1 element starting at position 1 of the sub-menu
|
349 |
+
console.log('Loaded `snippets_menu` customizations from `custom.js`');
|
350 |
+
});
|
351 |
+
```
|
352 |
+
|
353 |
+
The first `1` in the argument to `splice` says to work on the element at
|
354 |
+
position 1; the second `1` says to delete 1 element of the array.
|
355 |
+
|
356 |
+
|
357 |
+
#### Rearranging menu items
|
358 |
+
|
359 |
+
Following the example above, suppose you don't want to delete the second setup
|
360 |
+
item under "Matplotlib", but instead want to swap those first two items. To
|
361 |
+
make this swap, you need to do the usual trick of storing one element in a
|
362 |
+
temporary variable, and then reassign appropriately. The following code
|
363 |
+
achieves this purpose:
|
364 |
+
|
365 |
+
```javascript
|
366 |
+
require(["nbextensions/snippets_menu/main"], function (snippets_menu) {
|
367 |
+
console.log('Loading `snippets_menu` customizations from `custom.js`');
|
368 |
+
var tmp = snippets_menu.python.matplotlib['sub-menu'][0];
|
369 |
+
snippets_menu.python.matplotlib['sub-menu'][0] = snippets_menu.python.matplotlib['sub-menu'][1];
|
370 |
+
snippets_menu.python.matplotlib['sub-menu'][1] = tmp;
|
371 |
+
console.log('Loaded `snippets_menu` customizations from `custom.js`');
|
372 |
+
});
|
373 |
+
```
|
374 |
+
|
375 |
+
#### Change direction of sub-menus
|
376 |
+
|
377 |
+
Each sub-menu may be placed to the right or left side of the menu item
|
378 |
+
containing it. This is controlled by the `menu-direction` and
|
379 |
+
`sub-menu-direction` properties of the container. By default, both are set to
|
380 |
+
`right` for all menus, but `sub-menu-direction` is set to `left` for the
|
381 |
+
default `Snippets` menu, which means that all of its sub-menus open to the
|
382 |
+
left side. This is important because the menus may be nested quite deeply, and
|
383 |
+
need to fit on the screen. For example, the SciPy CODATA constants and SymPy's
|
384 |
+
orthogonal functions will easily extend far past the right-hand edge of the
|
385 |
+
notebook without this feature. That means the window size would abruptly
|
386 |
+
increase when you mouse over these menus, and would abruptly collapse when you
|
387 |
+
mouse out of them. So by opening them to the left, we gain enough space to
|
388 |
+
keep everything on the screen.
|
389 |
+
|
390 |
+
But these are configurable properties. If, for example, you want to change the
|
391 |
+
default menus to open on the right (which would be the more standard behavior),
|
392 |
+
you can use this:
|
393 |
+
|
394 |
+
```javascript
|
395 |
+
snippets_menu.default_menus[0]['sub-menu-direction'] = 'right';
|
396 |
+
```
|
397 |
+
|
398 |
+
This may be particularly useful if we change the position of the menus, as in
|
399 |
+
the next examples.
|
400 |
+
|
401 |
+
|
402 |
+
#### Starting over with the menus
|
403 |
+
|
404 |
+
Each of the menu items under the default `Snippets` menu is
|
405 |
+
individually available as part of the `snippets_menu` object defined
|
406 |
+
in our JavaScript examples. So if you want, you could just use them
|
407 |
+
to build your own version of the menu. For example, suppose use SymPy
|
408 |
+
and Numpy most frequently, so you want easy access to their menus,
|
409 |
+
without having to click `Snippets` first. And then suppose you still
|
410 |
+
want most of the other `Snippets` items, but less frequently so they
|
411 |
+
can stay in their menu, except that you really never use pandas. You
|
412 |
+
can create your own menu as follows:
|
413 |
+
|
414 |
+
```javascript
|
415 |
+
require(["nbextensions/snippets_menu/main"], function (snippets_menu) {
|
416 |
+
console.log('Loading `snippets_menu` customizations from `custom.js`');
|
417 |
+
snippets_menu.default_menus[0]['sub-menu'].splice(3, 2); // Remove SymPy and pandas
|
418 |
+
snippets_menu.python.sympy['sub-menu-direction'] = 'left'; // Point new SymPy menus to left
|
419 |
+
snippets_menu.python.numpy['sub-menu-direction'] = 'left'; // Point new Numpy menus to left
|
420 |
+
snippets_menu.options['menus'].push(snippets_menu.default_menus[0]); // Start with the remaining "Snippets" menu
|
421 |
+
snippets_menu.options['menus'].push(snippets_menu.python.sympy); // Follow that with a new SymPy menu
|
422 |
+
snippets_menu.options['menus'].push(snippets_menu.python.numpy); // Follow that with a new Numpy menu
|
423 |
+
console.log('Loaded `snippets_menu` customizations from `custom.js`');
|
424 |
+
});
|
425 |
+
```
|
426 |
+
|
427 |
+
The default menu group is `snippets_menu.default_menus`, and the SymPy sub-menu
|
428 |
+
is `snippets_menu.python.sympy`. You can see that we've manipulated them above
|
429 |
+
by removing two elements from the default menu, using the `splice` command.
|
430 |
+
We've also added a new property to the SymPy menu to make its sub-menus open to
|
431 |
+
the left, instead of the right -- which is necessary to keep all of SymPy's
|
432 |
+
extensively nested menus on the screen. (In fact, the list of orthogonal
|
433 |
+
polynomials under "Special functions" in the SymPy menu are some of the widest
|
434 |
+
menus in the default set.) Finally, we've combined the modified default menu
|
435 |
+
with the modified SymPy menu into one new list.
|
436 |
+
|
437 |
+
This gives us the original `Snippets` menu with SymPy and pandas removed, as
|
438 |
+
well as new menus devoted to just SymPy and Numpy right in the menu bar:
|
439 |
+
|
440 |
+
![Opened snippets menu after adjustments](screenshot2.png)
|
441 |
+
|
442 |
+
You can see that the two items are indeed removed from `Snippets`, and
|
443 |
+
"SymPy" and "Numpy" now have places of honor right in the menu bar.
|
444 |
+
You can, of course, swap their order in the code above, or make any
|
445 |
+
number of further alterations.
|
446 |
+
|
447 |
+
|
448 |
+
#### Changing the insertion point
|
449 |
+
|
450 |
+
You might want to change the order of the menus in the navbar (that
|
451 |
+
top-level bar with "File", etc.). For example, it might feel
|
452 |
+
particularly natural to have "Help" as the last item, so maybe you'd
|
453 |
+
prefer to put the `Snippets` menu *before* the "Help" menu. Or you
|
454 |
+
may prefer to maintain the structure of the menus in the navbar, and
|
455 |
+
would rather have the `Snippets` menu *inside* of some other top-level
|
456 |
+
menu -- like the "Insert" menu. Personally, I prefer to have the
|
457 |
+
`Snippets` menu in its default position for easy access. But it's
|
458 |
+
certainly possible to put it other places.
|
459 |
+
|
460 |
+
To help do this, there are two additional options available, which can
|
461 |
+
be set either in the configurator or in `custom.js`. Their default
|
462 |
+
values give us the usual placement of the `Snippets` menu; by giving
|
463 |
+
them different values, we can change the placement. These options are
|
464 |
+
|
465 |
+
1. `sibling`: This is an HTML node next to our new menu,
|
466 |
+
presumably
|
467 |
+
[selected with `jQuery`](https://learn.jquery.com/using-jquery-core/selecting-elements/).
|
468 |
+
The default value is `$("#help_menu").parent()`, which is the
|
469 |
+
"Help" menu. For the configurator, `.parent()` is automatically
|
470 |
+
appended.
|
471 |
+
2. `insert_before_sibling`: This is just a string controlling where
|
472 |
+
the new menu will be inserted relative to its sibling. The
|
473 |
+
default value is `false`. If you change it to `true`, the new
|
474 |
+
menu will be inserted before the sibling.
|
475 |
+
|
476 |
+
So placing the `Snippets` menu *before* the "Help" menu is as easy as
|
477 |
+
checking the box for that second option. For more complicated uses,
|
478 |
+
you may need to set these values from `custom.js`. For example, f you
|
479 |
+
want to put the new `Snippets` menu as an item inside the standard
|
480 |
+
"Insert" menu, and include an additional horizontal divider, you can
|
481 |
+
use this:
|
482 |
+
|
483 |
+
```javascript
|
484 |
+
require(["nbextensions/snippets_menu/main"], function (snippets_menu) {
|
485 |
+
console.log('Loading `snippets_menu` customizations from `custom.js`');
|
486 |
+
snippets_menu.default_menus[0]['menu-direction'] = 'left'; // Open top-level menu to the left...
|
487 |
+
snippets_menu.default_menus[0]['sub-menu-direction'] = 'right'; // ...and sub-menus to the right.
|
488 |
+
snippets_menu.options['menus'].push('---', snippets_menu.default_menus[0]); // Add horizontal line and default menus
|
489 |
+
snippets_menu.options['sibling'] = $("#insert_cell_below"); // Find the place at which to insert the new menus
|
490 |
+
console.log('Loaded `snippets_menu` customizations from `custom.js`');
|
491 |
+
});
|
492 |
+
```
|
493 |
+
|
494 |
+
Here's what that looks like:
|
495 |
+
|
496 |
+
![Opened snippets menu under "Insert" menu](screenshot3.png)
|
497 |
+
|
498 |
+
And of course, you can combine this selection of the insertion point with other
|
499 |
+
techniques above, where you change the content of the menus.
|
500 |
+
|
501 |
+
|
502 |
+
#### Multiple menus in separate locations
|
503 |
+
|
504 |
+
Finally, we have one more interesting example that brings together various
|
505 |
+
threads from the previous examples. It is possible to place multiple menus in
|
506 |
+
different locations. For example, suppose we want to combine two of the examples
|
507 |
+
above, where [(1)](#starting-over-with-the-menus) we separated "SymPy" into its
|
508 |
+
own menu on the navbar, and [(2)](#changing-the-insertion-point) we placed the
|
509 |
+
`Snippets` menu inside the "Insert" menu. That is, you might want "SymPy"
|
510 |
+
to be conveniently placed, but you want the rest of the `Snippets` to stay
|
511 |
+
under the "Insert" menu.
|
512 |
+
|
513 |
+
To add these two separate menus, we place the first with the usual
|
514 |
+
approach, and then place the second with another function,
|
515 |
+
`snippets_menu.menu_setup`. The former is mostly just a wrapper to
|
516 |
+
the latter, except that it also inserts JavaScript and CSS elements
|
517 |
+
into the notebook. Note that `menu_setup` does not have any default
|
518 |
+
values; you must always pass the `sibling` and `insert_before_sibling`
|
519 |
+
arguments.
|
520 |
+
|
521 |
+
So, putting it all together, the code needed for this arrangement is as
|
522 |
+
follows:
|
523 |
+
|
524 |
+
```javascript
|
525 |
+
require(["nbextensions/snippets_menu/main"], function (snippets_menu) {
|
526 |
+
console.log('Loading `snippets_menu` customizations from `custom.js`');
|
527 |
+
var sympy_menu = [snippets_menu.python.sympy,];
|
528 |
+
sympy_menu[0]['sub-menu-direction'] = 'left';
|
529 |
+
snippets_menu.options['menus'] = sympy_menu;
|
530 |
+
snippets_menu.default_menus[0]['sub-menu'].splice(3, 1); // Remove SymPy from defaults
|
531 |
+
snippets_menu.default_menus[0]['menu-direction'] = 'left';
|
532 |
+
snippets_menu.default_menus[0]['sub-menu-direction'] = 'right';
|
533 |
+
var sibling = $("#insert_cell_below");
|
534 |
+
var inserted_menu = [
|
535 |
+
'---',
|
536 |
+
snippets_menu.default_menus[0],
|
537 |
+
];
|
538 |
+
snippets_menu.menu_setup(inserted_menu, sibling, 'after');
|
539 |
+
console.log('Loaded `snippets_menu` customizations from `custom.js`');
|
540 |
+
});
|
541 |
+
```
|
542 |
+
|
543 |
+
|
544 |
+
Troubleshooting
|
545 |
+
---------------
|
546 |
+
|
547 |
+
The first step is to make sure that the default setup can be loaded.
|
548 |
+
Comment out whatever you've got in `custom.js`, and add in the simple
|
549 |
+
configuration from [the beginning](#installation). If that doesn't
|
550 |
+
work, try the following steps
|
551 |
+
suggested
|
552 |
+
[here](http://jupyter-contrib-nbextensions.readthedocs.io/en/latest/troubleshooting.html):
|
553 |
+
|
554 |
+
1. Clear your browser cache or start a private browser tab.
|
555 |
+
2. Verify your `custom.js` is the one the notebook is seeing, by opening it
|
556 |
+
in the browser: <http://127.0.0.1:8888/static/custom/custom.js> (as
|
557 |
+
opposed to looking at the file directly outside of your browser, which may
|
558 |
+
not be the `custom.js` loaded if you are using a `virtualenv`).
|
559 |
+
3. Verify the extension can be loaded by the Jupyter notebook, for example:
|
560 |
+
<http://127.0.0.1:8888/nbextensions/snippets_menu/main.js>. You
|
561 |
+
should see a page with lots of JavaScript code, and should *not*
|
562 |
+
see a 404 error.
|
563 |
+
4. Check for error messages in the JavaScript console.
|
564 |
+
|
565 |
+
Now, assuming the basic installation works, it must be something wrong
|
566 |
+
in your customization. (Or maybe a new bug you've uncovered...)
|
567 |
+
|
568 |
+
Sometimes, the menu(s) might simply not appear. This is most likely
|
569 |
+
due to a syntax error in your menu. You can find out in Chrome by
|
570 |
+
going to "View" -> "Developer" -> "JavaScript console". You'll see a
|
571 |
+
bunch of output. Red lines are usually errors (some of which are
|
572 |
+
probably *not* due to your menu error). On the right side of those
|
573 |
+
lines, you'll see the file where the error came from, and possibly
|
574 |
+
even the line number that's causing the trouble. Find an error that
|
575 |
+
links to either `snippets_menu/main.js` or `custom.js`, and click on
|
576 |
+
it. Then try to figure out what went wrong. The most common error
|
577 |
+
I've encountered is "Unexpected string", which might indicate a
|
578 |
+
missing comma, or an improperly escaped quote. Note that sometimes
|
579 |
+
the error will point to the first thing *after* the real problem.
|
580 |
+
|
581 |
+
Or maybe the menu did appear, but it doesn't work properly. You can
|
582 |
+
also inspect the actual elements that were inserted. Click on
|
583 |
+
"Elements" in that Developer Tools tab that opened at the bottom of
|
584 |
+
your window. Then click the magnifying glass, and click on the
|
585 |
+
`Snippets` menu. This will jump the Developer Tools to the part of
|
586 |
+
the source with that menu. Scroll through to find the menu item
|
587 |
+
that's not working correctly, and take a look at it. The text in the
|
588 |
+
`data-snippet-code` attribute is especially important, since that's
|
589 |
+
what gets inserted into the notebook.
|
590 |
+
|
591 |
+
|
592 |
+
TODO
|
593 |
+
----
|
594 |
+
|
595 |
+
There's a bunch of stuff I still need to do, listed in
|
596 |
+
the
|
597 |
+
[issue tracker](https://github.com/moble/jupyter_boilerplate/issues).
|
598 |
+
If you find a bug or have an idea for a good snippet that you think
|
599 |
+
should be added to the defaults, feel free
|
600 |
+
to
|
601 |
+
[open a new issue](https://github.com/moble/jupyter_boilerplate/issues/new).
|
602 |
+
|
603 |
+
In particular, I don't use Julia or R, so I welcome suggestions for
|
604 |
+
default snippets for those languages.
|
605 |
+
|
606 |
+
|
607 |
+
|
608 |
+
Reasons for using this extension
|
609 |
+
--------------------------------
|
610 |
+
|
611 |
+
This is just a nice place to collect thoughts about why anyone might
|
612 |
+
find this to be a useful extension:
|
613 |
+
|
614 |
+
* Introducing beginners to coding. It's helpful for the beginner to have a
|
615 |
+
list of useful possibilities (with correct syntax!) lined up right where
|
616 |
+
the programming is happening. It's like "Hello world" on steroids.
|
617 |
+
* Introducing the Jupyter notebook. It can be useful to have some nice
|
618 |
+
things to do in the notebook to demonstrate the possibilities. For
|
619 |
+
example, you might suggest that someone new to the notebook run the
|
620 |
+
Matplotlib setup and then make an example plot.
|
621 |
+
* Convenience for lazy people like me. For example, I usually don't want to
|
622 |
+
bother with all the typing involved in setting up the nice (but important)
|
623 |
+
parts of a plot, like the axis labels and legend. But by inserting the
|
624 |
+
template, all I have to do is change the relevant values.
|
625 |
+
* Reminders about useful things that could be done. For example,
|
626 |
+
when I'm manipulating expressions in SymPy, I'll frequently forget
|
627 |
+
that I can simplify, expand, collect, etc., in all sorts of ways.
|
628 |
+
The Snippets menu reminds me of that.
|
629 |
+
* Convenient reference for massive libraries. For example, SciPy contains
|
630 |
+
lots of constants. You could certainly go to the web page describing these
|
631 |
+
various constants to find the one you need, or you could just explore them
|
632 |
+
right in the browser. The same is true of SymPy's collection of special
|
633 |
+
functions.
|
.local/share/jupyter/nbextensions/snippets_menu/screenshot1.png
ADDED
.local/share/jupyter/nbextensions/snippets_menu/screenshot3.png
ADDED
.local/share/jupyter/nbextensions/snippets_menu/snippets_menu.css
ADDED
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/*
|
2 |
+
|
3 |
+
The left-side dropdown submenu is adapted from the usual right-side code at
|
4 |
+
<https://github.com/ipython/ipython/blob/master/IPython/html/static/style/style.min.css#L10664>
|
5 |
+
|
6 |
+
*/
|
7 |
+
.dropdown-submenu-left > .dropdown-menu {
|
8 |
+
left: auto;
|
9 |
+
right: 100%;
|
10 |
+
}
|
11 |
+
|
12 |
+
/* For space-saving menus */
|
13 |
+
.dropdown-submenu > .dropdown-menu.dropdown-menu-compact {
|
14 |
+
left: 50%;
|
15 |
+
top: 100%;
|
16 |
+
}
|
17 |
+
.dropdown-submenu-left > .dropdown-menu.dropdown-menu-compact {
|
18 |
+
left: auto;
|
19 |
+
right: 50%;
|
20 |
+
}
|
21 |
+
|
22 |
+
.dropdown-submenu-left > a:after {
|
23 |
+
visibility: hidden;
|
24 |
+
}
|
25 |
+
.dropdown-submenu-left > a:before {
|
26 |
+
display: inline-block;
|
27 |
+
font: normal normal normal 14px/1 FontAwesome;
|
28 |
+
font-size: inherit;
|
29 |
+
text-rendering: auto;
|
30 |
+
-webkit-font-smoothing: antialiased;
|
31 |
+
-moz-osx-font-smoothing: grayscale;
|
32 |
+
transform: translate(0, 0);
|
33 |
+
display: block;
|
34 |
+
content: "\f0d9";
|
35 |
+
float: left;
|
36 |
+
color: #333333;
|
37 |
+
margin-top: 2px;
|
38 |
+
margin-left: -10px;
|
39 |
+
}
|
40 |
+
|
41 |
+
|
42 |
+
/*
|
43 |
+
|
44 |
+
The following allows for control of the "tooltip" that shows the code to be
|
45 |
+
inserted when the item is clicked. Without this, the tooltip might wrap the
|
46 |
+
code, making it hard to read; will cut off some of the code; won't be
|
47 |
+
monospaced; etc. Note that these CSS selectors select any <a/> element with
|
48 |
+
an attribute `data-snippet-code`. This attribute is necessary and sufficient
|
49 |
+
for us to add the pop-up.
|
50 |
+
|
51 |
+
*/
|
52 |
+
a[data-snippet-code]:after {
|
53 |
+
content: attr(data-snippet-code); /* Read from the data-snippet-code attribute */
|
54 |
+
font-family: monospace;
|
55 |
+
font-size: 75%;
|
56 |
+
position: absolute;
|
57 |
+
width: auto;
|
58 |
+
display: table;
|
59 |
+
left: 50%;
|
60 |
+
white-space: pre;
|
61 |
+
z-index: 10000;
|
62 |
+
background: #E8E8E8;
|
63 |
+
padding: 4px;
|
64 |
+
border-color : #AAA;
|
65 |
+
border-style: solid;
|
66 |
+
border-width: 1px;
|
67 |
+
visibility: hidden;
|
68 |
+
}
|
69 |
+
a[data-snippet-code]:hover:after {
|
70 |
+
visibility: visible;
|
71 |
+
transition: all 0s ease 1s;
|
72 |
+
}
|
.local/share/jupyter/nbextensions/snippets_menu/snippets_submenus_python/numba.js
ADDED
@@ -0,0 +1,51 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
define({
|
2 |
+
'name' : 'numba',
|
3 |
+
'sub-menu' : [
|
4 |
+
{
|
5 |
+
'name' : 'Setup',
|
6 |
+
'snippet' : [
|
7 |
+
'from __future__ import print_function, division',
|
8 |
+
'import sys',
|
9 |
+
'if sys.version_info[0] >= 3:',
|
10 |
+
' xrange = range # Must always iterate with xrange in njit functions',
|
11 |
+
'import numba',
|
12 |
+
],
|
13 |
+
},
|
14 |
+
{
|
15 |
+
'name' : 'Documentation',
|
16 |
+
'external-link' : 'http://numba.pydata.org/numba-doc/dev/index.html',
|
17 |
+
},
|
18 |
+
'---',
|
19 |
+
{
|
20 |
+
'name' : 'Jit function',
|
21 |
+
'snippet' : [
|
22 |
+
'@numba.njit',
|
23 |
+
'def bp_func(x):',
|
24 |
+
' r"""Some function',
|
25 |
+
' ',
|
26 |
+
' Does some stuff.',
|
27 |
+
' ',
|
28 |
+
' """',
|
29 |
+
' return x**2',
|
30 |
+
],
|
31 |
+
},
|
32 |
+
|
33 |
+
{
|
34 |
+
'name' : 'Jit function with specified signature',
|
35 |
+
'snippet' : [
|
36 |
+
'@numba.njit(f8, f8[:])',
|
37 |
+
'def bp_func(x, y):',
|
38 |
+
' r"""Some function',
|
39 |
+
' ',
|
40 |
+
' Parameters',
|
41 |
+
' ----------',
|
42 |
+
' x : float',
|
43 |
+
' y : float array',
|
44 |
+
' ',
|
45 |
+
' """',
|
46 |
+
' for j in xrange(y.size):',
|
47 |
+
' y[j] *= x',
|
48 |
+
],
|
49 |
+
},
|
50 |
+
],
|
51 |
+
});
|
.local/share/jupyter/nbextensions/snippets_menu/snippets_submenus_python/numpy.js
ADDED
@@ -0,0 +1,618 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
define([
|
2 |
+
"require",
|
3 |
+
"./numpy_ufuncs",
|
4 |
+
"./numpy_polynomial",
|
5 |
+
], function (requirejs, numpy_ufuncs, numpy_polynomial) {
|
6 |
+
return {
|
7 |
+
'name' : 'NumPy',
|
8 |
+
'sub-menu' : [
|
9 |
+
{
|
10 |
+
'name' : 'Setup',
|
11 |
+
'snippet' : [
|
12 |
+
'from __future__ import print_function, division',
|
13 |
+
'import numpy as np',
|
14 |
+
],
|
15 |
+
},
|
16 |
+
{
|
17 |
+
'name' : 'Documentation',
|
18 |
+
'external-link' : 'http://docs.scipy.org/doc/numpy/index.html',
|
19 |
+
},
|
20 |
+
'---',
|
21 |
+
{
|
22 |
+
'name' : 'Creating arrays',
|
23 |
+
'sub-menu' : [
|
24 |
+
{
|
25 |
+
'name' : 'New array of given shape',
|
26 |
+
'snippet' : ['new_array = np.zeros((4,3,), dtype=complex)',],
|
27 |
+
},
|
28 |
+
{
|
29 |
+
'name' : 'New array shaped like another',
|
30 |
+
'snippet' : ['new_array = np.zeros_like(old_array, dtype=complex)',],
|
31 |
+
},
|
32 |
+
{
|
33 |
+
'name' : 'Copy of existing data',
|
34 |
+
'snippet' : ['new_array = np.copy(old_array)',],
|
35 |
+
},
|
36 |
+
{
|
37 |
+
'name' : 'Array from list of data',
|
38 |
+
'snippet' : ['new_array = np.array([1.2, 3.4, 5.6])',],
|
39 |
+
},
|
40 |
+
{
|
41 |
+
'name' : 'Evenly spaced values within a given interval',
|
42 |
+
'snippet' : ['new_array = np.arange(1, 10, 2)'],
|
43 |
+
},
|
44 |
+
{
|
45 |
+
'name' : 'Evenly spaced numbers over a specified interval',
|
46 |
+
'snippet' : ['new_array = np.linspace(1., 10., num=120, endpoint=True)'],
|
47 |
+
},
|
48 |
+
{
|
49 |
+
'name' : 'Numbers spaced evenly on a log scale',
|
50 |
+
'snippet' : ['new_array = np.logspace(1., 10., num=120, endpoint=True, base=2)'],
|
51 |
+
},
|
52 |
+
{
|
53 |
+
'name' : 'Coordinate matrices from coordinate vectors',
|
54 |
+
'snippet' : [
|
55 |
+
'x = np.linspace(0, 1, 7)',
|
56 |
+
'y = np.linspace(0, 1, 11)',
|
57 |
+
'xx, yy = np.meshgrid(x, y)',
|
58 |
+
],
|
59 |
+
},
|
60 |
+
{
|
61 |
+
'name' : 'Return views of the data, split into $N$ groups',
|
62 |
+
'snippet' : [
|
63 |
+
'x = np.arange(12)',
|
64 |
+
'a,b,c = np.split(x, 3)',
|
65 |
+
],
|
66 |
+
},
|
67 |
+
{
|
68 |
+
'name' : 'Return views of the data, split at given indices along given axis',
|
69 |
+
'snippet' : [
|
70 |
+
'x = np.arange(27).reshape((3,9))',
|
71 |
+
'a,b,c = np.split(x, [2,6], axis=1)',
|
72 |
+
],
|
73 |
+
},
|
74 |
+
{
|
75 |
+
'name' : 'Return copy of arrays, combined into one',
|
76 |
+
'snippet' : [
|
77 |
+
'a = np.arange(30).reshape((2,3,5))',
|
78 |
+
'b = np.arange(42).reshape((2,3,7))',
|
79 |
+
'c = np.concatenate((a, b), axis=1)',
|
80 |
+
],
|
81 |
+
},
|
82 |
+
],
|
83 |
+
},
|
84 |
+
|
85 |
+
{
|
86 |
+
'name' : 'Reshaping and viewing arrays',
|
87 |
+
'sub-menu' : [
|
88 |
+
{
|
89 |
+
'name' : 'Return a view of the data, with a different shape',
|
90 |
+
'snippet' : ['np.arange(6).reshape((3, 2))'],
|
91 |
+
},
|
92 |
+
{
|
93 |
+
'name' : 'Return a view of the data, with an extra axis',
|
94 |
+
'snippet' : ['a[:, np.newaxis]'],
|
95 |
+
},
|
96 |
+
{
|
97 |
+
'name' : 'Return a view of the data, flattened to 1-D',
|
98 |
+
'snippet' : ['a.ravel()'],
|
99 |
+
},
|
100 |
+
{
|
101 |
+
'name' : 'Return a copy of the data, flattened to 1-D',
|
102 |
+
'snippet' : ['a.flatten()'],
|
103 |
+
},
|
104 |
+
{
|
105 |
+
'name' : 'Return a view of the data, with a different dtype',
|
106 |
+
'snippet' : ['np.linspace(0, 10, num=50).view(complex)'],
|
107 |
+
'sub-menu' : [
|
108 |
+
{
|
109 |
+
'name' : 'View real array as complex',
|
110 |
+
'snippet' : [
|
111 |
+
'r = np.linspace(0, 10, num=100).reshape((25,4))',
|
112 |
+
'c = r.view(complex)',
|
113 |
+
],
|
114 |
+
},
|
115 |
+
{
|
116 |
+
'name' : 'View complex array as real with extra dimension',
|
117 |
+
'snippet' : [
|
118 |
+
'c = (np.linspace(0, 10, num=50) + 1j*np.linspace(0, 10, num=50))',
|
119 |
+
'cv = c.view(float)',
|
120 |
+
'r = cv.reshape(c.shape + (2,))',
|
121 |
+
],
|
122 |
+
},
|
123 |
+
],
|
124 |
+
},
|
125 |
+
{
|
126 |
+
'name' : 'Return a copy of the data, cast to a different dtype',
|
127 |
+
'snippet' : ['np.linspace(0, 10, num=50).astype(complex)'],
|
128 |
+
},
|
129 |
+
{
|
130 |
+
'name' : 'Return a view of the data with indices reversed (transposed)',
|
131 |
+
'snippet' : ['np.arange(210).reshape((2,3,5,7)).transpose()'],
|
132 |
+
},
|
133 |
+
{
|
134 |
+
'name' : 'Return a view of the data with indices permuted',
|
135 |
+
'snippet' : ['np.arange(210).reshape((2,3,5,7)).transpose((2,1,0,3))'],
|
136 |
+
},
|
137 |
+
{
|
138 |
+
'name' : 'Exchange two axes in an array',
|
139 |
+
'snippet' : ['np.arange(210).reshape((2,3,5,7)).swapaxes(1,3)'],
|
140 |
+
},
|
141 |
+
{
|
142 |
+
'name' : 'Permute axes, bringing given axis into new position',
|
143 |
+
'snippet' : ['np.rollaxis(np.arange(210).reshape((2,3,5,7)), 2, 0)'],
|
144 |
+
},
|
145 |
+
{
|
146 |
+
'name' : 'Permute indices by a given amount along the given axis',
|
147 |
+
'snippet' : ['np.roll(np.arange(10).reshape((2,5)), 2, axis=1)'],
|
148 |
+
},
|
149 |
+
{
|
150 |
+
'name' : 'Return views of the data, split into $N$ groups',
|
151 |
+
'snippet' : [
|
152 |
+
'x = np.arange(12)',
|
153 |
+
'a,b,c = np.split(x, 3)',
|
154 |
+
],
|
155 |
+
},
|
156 |
+
{
|
157 |
+
'name' : 'Return views of the data, split at given indices along given axis',
|
158 |
+
'snippet' : [
|
159 |
+
'x = np.arange(27).reshape((3,9))',
|
160 |
+
'a,b,c = np.split(x, [2,6], axis=1)',
|
161 |
+
],
|
162 |
+
},
|
163 |
+
{
|
164 |
+
'name' : 'Return copy of arrays, combined into one',
|
165 |
+
'snippet' : [
|
166 |
+
'a = np.arange(30).reshape((2,3,5))',
|
167 |
+
'b = np.arange(42).reshape((2,3,7))',
|
168 |
+
'c = np.concatenate((a, b), axis=1)',
|
169 |
+
],
|
170 |
+
},
|
171 |
+
],
|
172 |
+
},
|
173 |
+
|
174 |
+
{
|
175 |
+
'name' : 'Indexing and testing arrays',
|
176 |
+
'sub-menu' : [
|
177 |
+
{
|
178 |
+
'name' : 'Indexing documentation',
|
179 |
+
'external-link' : 'http://docs.scipy.org/doc/numpy/reference/arrays.indexing.html',
|
180 |
+
},
|
181 |
+
'---',
|
182 |
+
{
|
183 |
+
'name' : 'Test if array is empty',
|
184 |
+
'snippet' : [
|
185 |
+
'if a.size > 0: # Never use `if a` or `if len(a)` for numpy arrays',
|
186 |
+
' print(a)',
|
187 |
+
],
|
188 |
+
},
|
189 |
+
{
|
190 |
+
'name' : 'Get number of dimensions of array',
|
191 |
+
'snippet' : ['a.ndim'],
|
192 |
+
},
|
193 |
+
{
|
194 |
+
'name' : 'Get shape of array',
|
195 |
+
'snippet' : ['a.shape'],
|
196 |
+
},
|
197 |
+
{
|
198 |
+
'name' : 'Index a one-dimensional array',
|
199 |
+
'sub-menu' : [
|
200 |
+
{
|
201 |
+
'name' : 'Get one element',
|
202 |
+
'snippet' : [
|
203 |
+
'a = np.arange(10)',
|
204 |
+
'a[3]'
|
205 |
+
],
|
206 |
+
},
|
207 |
+
{
|
208 |
+
'name' : 'Get first $N$ elements',
|
209 |
+
'snippet' : [
|
210 |
+
'a = np.arange(10)',
|
211 |
+
'a[:3]'
|
212 |
+
],
|
213 |
+
},
|
214 |
+
{
|
215 |
+
'name' : 'Get last $N$ elements',
|
216 |
+
'snippet' : [
|
217 |
+
'a = np.arange(10)',
|
218 |
+
'a[-3:]'
|
219 |
+
],
|
220 |
+
},
|
221 |
+
{
|
222 |
+
'name' : 'Get elements $N$ to $M$',
|
223 |
+
'snippet' : [
|
224 |
+
'a = np.arange(10)',
|
225 |
+
'a[3:6]'
|
226 |
+
],
|
227 |
+
},
|
228 |
+
{
|
229 |
+
'name' : 'Get elements satisfying a condition',
|
230 |
+
'snippet' : [
|
231 |
+
'a = np.arange(10)',
|
232 |
+
'a[a>5]'
|
233 |
+
],
|
234 |
+
},
|
235 |
+
],
|
236 |
+
},
|
237 |
+
{
|
238 |
+
'name' : 'Index a multi-dimensional array',
|
239 |
+
'sub-menu' : [
|
240 |
+
{
|
241 |
+
'name' : 'Get one element',
|
242 |
+
'snippet' : [
|
243 |
+
'a = np.arange(30).reshape((2,3,5))',
|
244 |
+
'a[1, 2, 4]'
|
245 |
+
],
|
246 |
+
},
|
247 |
+
{
|
248 |
+
'name' : 'Get first $N$ elements along each final axis',
|
249 |
+
'snippet' : [
|
250 |
+
'a = np.arange(30).reshape((2,3,5))',
|
251 |
+
'a[:, :, :4]'
|
252 |
+
],
|
253 |
+
},
|
254 |
+
{
|
255 |
+
'name' : 'Get last $N$ elements along each final axis',
|
256 |
+
'snippet' : [
|
257 |
+
'a = np.arange(30).reshape((2,3,5))',
|
258 |
+
'a[:, :, -3:]'
|
259 |
+
],
|
260 |
+
},
|
261 |
+
{
|
262 |
+
'name' : 'Get elements $N$ to $M$ along each final axis',
|
263 |
+
'snippet' : [
|
264 |
+
'a = np.arange(30).reshape((2,3,5))',
|
265 |
+
'a[:, :, 3:5]'
|
266 |
+
],
|
267 |
+
},
|
268 |
+
{
|
269 |
+
'name' : 'Get elements satisfying a condition (flattened result)',
|
270 |
+
'snippet' : [
|
271 |
+
'a = np.arange(30).reshape((2,3,5))',
|
272 |
+
'a[a>5]'
|
273 |
+
],
|
274 |
+
},
|
275 |
+
],
|
276 |
+
},
|
277 |
+
{
|
278 |
+
'name' : 'Index an array of unknown dimension',
|
279 |
+
'sub-menu' : [
|
280 |
+
{
|
281 |
+
'name' : 'Get first $N$ elements along each final axis',
|
282 |
+
'snippet' : [
|
283 |
+
'a = np.arange(30).reshape((2,3,5))',
|
284 |
+
'a[..., :4]'
|
285 |
+
],
|
286 |
+
},
|
287 |
+
{
|
288 |
+
'name' : 'Get last $N$ elements along each final axis',
|
289 |
+
'snippet' : [
|
290 |
+
'a = np.arange(30).reshape((2,3,5))',
|
291 |
+
'a[..., -3:]'
|
292 |
+
],
|
293 |
+
},
|
294 |
+
{
|
295 |
+
'name' : 'Get elements $N$ to $M$ along each final axis',
|
296 |
+
'snippet' : [
|
297 |
+
'a = np.arange(30).reshape((2,3,5))',
|
298 |
+
'a[..., 3:5]'
|
299 |
+
],
|
300 |
+
},
|
301 |
+
{
|
302 |
+
'name' : 'Get elements satisfying a condition (flattened result)',
|
303 |
+
'snippet' : [
|
304 |
+
'a = np.arange(30).reshape((2,3,5))',
|
305 |
+
'a[a>5]'
|
306 |
+
],
|
307 |
+
},
|
308 |
+
],
|
309 |
+
},
|
310 |
+
{
|
311 |
+
'name' : '',
|
312 |
+
'snippet' : [
|
313 |
+
''
|
314 |
+
],
|
315 |
+
},
|
316 |
+
],
|
317 |
+
},
|
318 |
+
|
319 |
+
numpy_ufuncs,
|
320 |
+
|
321 |
+
numpy_polynomial,
|
322 |
+
|
323 |
+
// {
|
324 |
+
// 'name' : 'Polynomials',
|
325 |
+
// 'external-link' : 'http://docs.scipy.org/doc/numpy/reference/routines.polynomials.html',
|
326 |
+
// // 'sub-menu' : [
|
327 |
+
|
328 |
+
// // ],
|
329 |
+
// },
|
330 |
+
|
331 |
+
{
|
332 |
+
'name' : 'Pretty printing',
|
333 |
+
'sub-menu' : [
|
334 |
+
{
|
335 |
+
'name' : 'Context manager',
|
336 |
+
'snippet' : [
|
337 |
+
'import contextlib',
|
338 |
+
'@contextlib.contextmanager',
|
339 |
+
'def printoptions(*args, **kwargs):',
|
340 |
+
' original = np.get_printoptions()',
|
341 |
+
' np.set_printoptions(*args, **kwargs)',
|
342 |
+
' yield',
|
343 |
+
' np.set_printoptions(**original)',
|
344 |
+
],
|
345 |
+
},
|
346 |
+
'---',
|
347 |
+
{
|
348 |
+
'name' : 'Print to given precision',
|
349 |
+
'snippet' : [
|
350 |
+
'with printoptions(precision=5):',
|
351 |
+
' print(np.random.random(10))',
|
352 |
+
],
|
353 |
+
},
|
354 |
+
{
|
355 |
+
'name' : 'Summarize arrays with more than $N+1$ elements',
|
356 |
+
'snippet' : [
|
357 |
+
'with printoptions(threshold=5):',
|
358 |
+
' print(np.random.random(10))',
|
359 |
+
],
|
360 |
+
},
|
361 |
+
{
|
362 |
+
'name' : 'Print $N$ elements at each end of a summary',
|
363 |
+
'snippet' : [
|
364 |
+
'with printoptions(threshold=5, edgeitems=4):',
|
365 |
+
' print(np.random.random(10))',
|
366 |
+
],
|
367 |
+
},
|
368 |
+
{
|
369 |
+
'name' : 'Set number of characters per line',
|
370 |
+
'snippet' : [
|
371 |
+
'with printoptions(linewidth=100):',
|
372 |
+
' print(np.random.random(10))',
|
373 |
+
],
|
374 |
+
},
|
375 |
+
{
|
376 |
+
'name' : 'Suppress printing of small values',
|
377 |
+
'snippet' : [
|
378 |
+
'with printoptions(suppress=True):',
|
379 |
+
' print(1e-8*np.random.random(10))',
|
380 |
+
],
|
381 |
+
},
|
382 |
+
{
|
383 |
+
'name' : 'Set string with which to represent nan',
|
384 |
+
'snippet' : [
|
385 |
+
"with printoptions(nanstr='NaN!'):",
|
386 |
+
' print(np.array([1, np.nan, 3]))',
|
387 |
+
],
|
388 |
+
},
|
389 |
+
{
|
390 |
+
'name' : 'Set string with which to represent infinity',
|
391 |
+
'snippet' : [
|
392 |
+
"with printoptions(infstr='oo'):",
|
393 |
+
' print(np.array([1, np.inf, 3]))',
|
394 |
+
],
|
395 |
+
},
|
396 |
+
{
|
397 |
+
'name' : 'Formatting functions for specific dtypes',
|
398 |
+
'sub-menu' : [
|
399 |
+
{
|
400 |
+
'name' : 'Set formatter for `bool` type',
|
401 |
+
'snippet' : [
|
402 |
+
"def format_bool(x):",
|
403 |
+
" if x:",
|
404 |
+
" return 'TRUE'",
|
405 |
+
" else:",
|
406 |
+
" return 'FALSE'",
|
407 |
+
"with printoptions(formatter={'bool': format_bool}):",
|
408 |
+
" print(np.random.randint(0,2,10).astype(bool))",
|
409 |
+
],
|
410 |
+
},
|
411 |
+
{
|
412 |
+
'name' : 'Set formatter for `int` type',
|
413 |
+
'snippet' : [
|
414 |
+
"def format_int(x):",
|
415 |
+
" return 'int({0})'.format(x)",
|
416 |
+
"with printoptions(formatter={'int': format_int}):",
|
417 |
+
" print(np.random.randint(-3, 4, 10))",
|
418 |
+
],
|
419 |
+
},
|
420 |
+
{
|
421 |
+
'name' : 'Set formatter for `timedelta` type',
|
422 |
+
'snippet' : [
|
423 |
+
"def format_timedelta(delta):",
|
424 |
+
" days = delta.astype('timedelta64[D]').astype(int)",
|
425 |
+
" hours = delta.astype('timedelta64[h]').astype(int) - 24*days",
|
426 |
+
" minutes = delta.astype('timedelta64[m]').astype(int) - 60*(24*days+hours)",
|
427 |
+
" seconds = delta.astype('timedelta64[s]').astype(int) - 60*(60*(24*days+hours)+minutes)",
|
428 |
+
" return '{0}days,{1}hours,{2}minutes,{3}seconds'.format(days, hours, minutes, seconds)",
|
429 |
+
"with printoptions(formatter={'timedelta': format_timedelta}):",
|
430 |
+
" print(np.array([np.timedelta64(int(sec), 's') for sec in np.random.randint(0, 1000000, 10)]))",
|
431 |
+
],
|
432 |
+
},
|
433 |
+
{
|
434 |
+
'name' : 'Set formatter for `datetime` type',
|
435 |
+
'snippet' : [
|
436 |
+
"def format_datetime(date):",
|
437 |
+
" year = date.astype('datetime64[Y]').astype(int) + 1970",
|
438 |
+
" month = date.astype('datetime64[M]').astype(int) % 12 + 1",
|
439 |
+
" day = (date - date.astype('datetime64[M]')).astype(int) + 1",
|
440 |
+
" return 'Y{0}:M{1}:D{2}'.format(year, month, day)",
|
441 |
+
"with printoptions(formatter={'datetime': format_datetime}):",
|
442 |
+
" days = np.random.randint(0, 20000, 10)",
|
443 |
+
" dates = np.array([np.datetime64(int(d), 'D') for d in days])",
|
444 |
+
" print(dates)",
|
445 |
+
],
|
446 |
+
},
|
447 |
+
{
|
448 |
+
'name' : 'Set formatter for `float` type',
|
449 |
+
'snippet' : [
|
450 |
+
"def format_float(x):",
|
451 |
+
" return '{0:+0.2f}'.format(x)",
|
452 |
+
"with printoptions(formatter={'float': format_float}):",
|
453 |
+
" print(np.random.random(10)-0.5)",
|
454 |
+
],
|
455 |
+
},
|
456 |
+
{
|
457 |
+
'name' : 'Set formatter for `longfloat` type',
|
458 |
+
'snippet' : [
|
459 |
+
"def format_longfloat(x):",
|
460 |
+
" return 'long{0}'.format(x)",
|
461 |
+
"with printoptions(formatter={'longfloat': format_longfloat}):",
|
462 |
+
" print(np.random.random(10).astype(np.longfloat))",
|
463 |
+
],
|
464 |
+
},
|
465 |
+
{
|
466 |
+
'name' : 'Set formatter for `complexfloat` type',
|
467 |
+
'snippet' : [
|
468 |
+
"def format_complexfloat(x):",
|
469 |
+
" return '{0.real}+1j*{0.imag}'.format(x)",
|
470 |
+
"with printoptions(formatter={'complexfloat': format_complexfloat}):",
|
471 |
+
" print(np.random.random(5)+1j*np.random.random(5))",
|
472 |
+
],
|
473 |
+
},
|
474 |
+
{
|
475 |
+
'name' : 'Set formatter for `longcomplexfloat` type',
|
476 |
+
'snippet' : [
|
477 |
+
"def format_longcomplexfloat(x):",
|
478 |
+
" return '{0.real}+1j*{0.imag}'.format(x)",
|
479 |
+
"with printoptions(formatter={'longcomplexfloat': format_longcomplexfloat}):",
|
480 |
+
" print(np.random.random(5).astype(np.longfloat)+1j*np.random.random(5).astype(np.longfloat))",
|
481 |
+
],
|
482 |
+
},
|
483 |
+
// {
|
484 |
+
// 'name' : 'Set formatter for `numpy_str` type',
|
485 |
+
// 'snippet' : [
|
486 |
+
// "def format_numpy_str(x):",
|
487 |
+
// " return 'n\"{0}\"'.format(x)",
|
488 |
+
// "with printoptions(formatter={'numpy_str': format_numpy_str}):",
|
489 |
+
// " print(np.random.random(10))",
|
490 |
+
// ],
|
491 |
+
// },
|
492 |
+
// {
|
493 |
+
// 'name' : 'Set formatter for `str` type',
|
494 |
+
// 'snippet' : [
|
495 |
+
// "def format_str(x):",
|
496 |
+
// " return '\"{0}\"'.format(x)",
|
497 |
+
// "with printoptions(formatter={'str': format_str}):",
|
498 |
+
// " print(np.random.random(10))",
|
499 |
+
// ],
|
500 |
+
// },
|
501 |
+
'---',
|
502 |
+
{
|
503 |
+
'name' : 'Set formatter for all types',
|
504 |
+
'snippet' : [
|
505 |
+
"def format_all(x):",
|
506 |
+
" return 'repr({0})'.format(repr(x))",
|
507 |
+
"with printoptions(formatter={'all': format_all}):",
|
508 |
+
" print(np.array([3, 8]))",
|
509 |
+
" print(np.array([0.1, 0.5]))",
|
510 |
+
" print(np.array([1.4+2.3j, 2.8+4.6j]))",
|
511 |
+
" print(np.array(['abc', 'xyz']))",
|
512 |
+
],
|
513 |
+
},
|
514 |
+
{
|
515 |
+
'name' : 'Set formatter for all `int` types',
|
516 |
+
'snippet' : [
|
517 |
+
"def format_int_kind(x):",
|
518 |
+
" return 'int({0})'.format(x)",
|
519 |
+
"with printoptions(formatter={'int_kind': format_int_kind}):",
|
520 |
+
" print(np.random.randint(-100, 100, 10))",
|
521 |
+
],
|
522 |
+
},
|
523 |
+
{
|
524 |
+
'name' : 'Set formatter for all `float` types',
|
525 |
+
'snippet' : [
|
526 |
+
"def format_float_kind(x):",
|
527 |
+
" return '{0:.2%}'.format(x)",
|
528 |
+
"with printoptions(formatter={'float_kind': format_float_kind}):",
|
529 |
+
" print(np.random.random(10))",
|
530 |
+
],
|
531 |
+
},
|
532 |
+
{
|
533 |
+
'name' : 'Set formatter for all `complex` types',
|
534 |
+
'snippet' : [
|
535 |
+
"def format_complex_kind(x):",
|
536 |
+
" return '{0.real}+1j*{0.imag}'.format(x)",
|
537 |
+
"with printoptions(formatter={'complex_kind': format_complex_kind}):",
|
538 |
+
" print(np.random.random(5)+1j*np.random.random(5))",
|
539 |
+
],
|
540 |
+
},
|
541 |
+
{
|
542 |
+
'name' : 'Set formatter for all `str` types',
|
543 |
+
'snippet' : [
|
544 |
+
"def format_str_kind(x):",
|
545 |
+
" return 'str({0})'.format(x)",
|
546 |
+
"with printoptions(formatter={'str_kind': format_str_kind}):",
|
547 |
+
" print(np.array(['abc', 'xyz']))",
|
548 |
+
],
|
549 |
+
},
|
550 |
+
],
|
551 |
+
},
|
552 |
+
],
|
553 |
+
},
|
554 |
+
|
555 |
+
{
|
556 |
+
'name' : 'File I/O',
|
557 |
+
'sub-menu' : [
|
558 |
+
{
|
559 |
+
'name' : 'Read data from simple text file',
|
560 |
+
'snippet' : [
|
561 |
+
'data = np.loadtxt(filename)',
|
562 |
+
],
|
563 |
+
},
|
564 |
+
{
|
565 |
+
'name' : 'Read data from text file with missing values',
|
566 |
+
'snippet' : [
|
567 |
+
'data = np.genfromtxt(filename)',
|
568 |
+
],
|
569 |
+
},
|
570 |
+
{
|
571 |
+
'name' : 'Read data from .npy or .npz file',
|
572 |
+
'snippet' : [
|
573 |
+
'data = np.load(filename)',
|
574 |
+
],
|
575 |
+
},
|
576 |
+
'---',
|
577 |
+
{
|
578 |
+
'name' : 'Write single array to text file',
|
579 |
+
'snippet' : [
|
580 |
+
'np.savetxt(filename, x)',
|
581 |
+
],
|
582 |
+
},
|
583 |
+
{
|
584 |
+
'name' : 'Write multiple arrays to text file',
|
585 |
+
'snippet' : [
|
586 |
+
'np.savetxt(filename, np.transpose((x, y, z)))',
|
587 |
+
],
|
588 |
+
},
|
589 |
+
{
|
590 |
+
'name' : 'Write single array to single .npy file',
|
591 |
+
'snippet' : [
|
592 |
+
'np.save(filename, x)',
|
593 |
+
],
|
594 |
+
},
|
595 |
+
{
|
596 |
+
'name' : 'Write multiple arrays to single .npy file',
|
597 |
+
'snippet' : [
|
598 |
+
'np.save(filename, np.transpose((x, y, z)))',
|
599 |
+
],
|
600 |
+
},
|
601 |
+
{
|
602 |
+
'name' : 'Write multiple arrays to single .npz file',
|
603 |
+
'snippet' : [
|
604 |
+
'np.savez(filename, x, y, z)',
|
605 |
+
],
|
606 |
+
},
|
607 |
+
{
|
608 |
+
'name' : 'Write multiple arrays to single compressed .npz file',
|
609 |
+
'snippet' : [
|
610 |
+
'np.savez_compressed(filename, x, y, z)',
|
611 |
+
],
|
612 |
+
},
|
613 |
+
],
|
614 |
+
},
|
615 |
+
]
|
616 |
+
}
|
617 |
+
}
|
618 |
+
);
|
.local/share/jupyter/nbextensions/snippets_menu/snippets_submenus_python/numpy_polynomial.js
ADDED
@@ -0,0 +1,129 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
define({
|
2 |
+
'name' : 'Polynomials',
|
3 |
+
'sub-menu' : [
|
4 |
+
{
|
5 |
+
'name' : 'Setup',
|
6 |
+
'snippet' : [
|
7 |
+
'import numpy as np',
|
8 |
+
'from numpy.polynomial import Polynomial as P',
|
9 |
+
'from numpy.polynomial import Chebyshev as T',
|
10 |
+
'from numpy.polynomial import Legendre as Le',
|
11 |
+
'from numpy.polynomial import Laguerre as La',
|
12 |
+
'from numpy.polynomial import Hermite as H',
|
13 |
+
'from numpy.polynomial import HermiteE as HE',
|
14 |
+
],
|
15 |
+
},
|
16 |
+
'---',
|
17 |
+
{
|
18 |
+
'name' : 'Instantiate from coefficients',
|
19 |
+
'snippet' : [
|
20 |
+
'poly = P([1, 2, 3])',
|
21 |
+
],
|
22 |
+
},
|
23 |
+
{
|
24 |
+
'name' : 'Instantiate from roots',
|
25 |
+
'snippet' : [
|
26 |
+
'poly = P.fromroots([1, 2, 3])',
|
27 |
+
],
|
28 |
+
},
|
29 |
+
{
|
30 |
+
'name' : 'Instantiate from basis element $n$',
|
31 |
+
'snippet' : [
|
32 |
+
'poly = P.basis(n)',
|
33 |
+
],
|
34 |
+
},
|
35 |
+
{
|
36 |
+
'name' : 'Convert between types',
|
37 |
+
'snippet' : [
|
38 |
+
'from numpy.polynomial import Chebyshev',
|
39 |
+
'polyT = poly.convert(kind=Chebyshev)',
|
40 |
+
],
|
41 |
+
},
|
42 |
+
'---',
|
43 |
+
{
|
44 |
+
'name' : 'Get coefficients (constant at index 0, higher indices for higher orders)',
|
45 |
+
'snippet' : [
|
46 |
+
'poly.coeff',
|
47 |
+
],
|
48 |
+
},
|
49 |
+
{
|
50 |
+
'name' : 'Get domain (scaled and offset domain of function for fitting)',
|
51 |
+
'snippet' : [
|
52 |
+
'poly.domain',
|
53 |
+
],
|
54 |
+
},
|
55 |
+
{
|
56 |
+
'name' : 'Get window (natural domain of basis functions)',
|
57 |
+
'snippet' : [
|
58 |
+
'poly.window',
|
59 |
+
],
|
60 |
+
},
|
61 |
+
{
|
62 |
+
'name' : 'Get degree of polynomial (one less than number of coefficients)',
|
63 |
+
'snippet' : [
|
64 |
+
'poly.degree()',
|
65 |
+
],
|
66 |
+
},
|
67 |
+
'---',
|
68 |
+
{
|
69 |
+
'name' : 'Evaluate polynomial at given points',
|
70 |
+
'snippet' : [
|
71 |
+
'x = np.linspace(0, 3.14)',
|
72 |
+
'poly(x)',
|
73 |
+
],
|
74 |
+
},
|
75 |
+
{
|
76 |
+
'name' : 'Return $n$ equally spaced $(x,y)$ values',
|
77 |
+
'snippet' : [
|
78 |
+
'x, y = poly.linspace(n=100)',
|
79 |
+
],
|
80 |
+
},
|
81 |
+
{
|
82 |
+
'name' : 'Find roots',
|
83 |
+
'snippet' : [
|
84 |
+
'poly.roots()',
|
85 |
+
],
|
86 |
+
},
|
87 |
+
{
|
88 |
+
'name' : 'Differentiate once',
|
89 |
+
'snippet' : [
|
90 |
+
'poly.deriv()',
|
91 |
+
],
|
92 |
+
},
|
93 |
+
{
|
94 |
+
'name' : 'Differentiate $n$ times',
|
95 |
+
'snippet' : [
|
96 |
+
'poly.deriv(n)',
|
97 |
+
],
|
98 |
+
},
|
99 |
+
{
|
100 |
+
'name' : 'Integrate once',
|
101 |
+
'snippet' : [
|
102 |
+
'poly.integ()',
|
103 |
+
],
|
104 |
+
},
|
105 |
+
{
|
106 |
+
'name' : 'Integrate $n$ times',
|
107 |
+
'snippet' : [
|
108 |
+
'poly.integ(n)',
|
109 |
+
],
|
110 |
+
},
|
111 |
+
{
|
112 |
+
'name' : 'Integrate with given lower bound and integration constant $k$',
|
113 |
+
'snippet' : [
|
114 |
+
'poly.integ(lbnd=0.1, k=-2.34',
|
115 |
+
],
|
116 |
+
},
|
117 |
+
'---',
|
118 |
+
{
|
119 |
+
'name' : 'Fit to data with series of degree $n$',
|
120 |
+
'snippet' : [
|
121 |
+
'np.random.seed(11)',
|
122 |
+
'x = np.linspace(0, 2*np.pi, 20)',
|
123 |
+
'y = np.sin(x) + np.random.normal(scale=.1, size=x.shape)',
|
124 |
+
'n = 5',
|
125 |
+
'p = T.fit(x, y, n)',
|
126 |
+
],
|
127 |
+
},
|
128 |
+
],
|
129 |
+
});
|
.local/share/jupyter/nbextensions/snippets_menu/snippets_submenus_python/numpy_ufuncs.js
ADDED
@@ -0,0 +1,1068 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
define({
|
2 |
+
// See <http://docs.scipy.org/doc/numpy/reference/ufuncs.html#available-ufuncs> for a full list
|
3 |
+
'name' : 'Vectorized (universal) functions',
|
4 |
+
'sub-menu' : [
|
5 |
+
{
|
6 |
+
'name' : 'Characterizing arrays',
|
7 |
+
'sub-menu' : [
|
8 |
+
{
|
9 |
+
'name' : 'max: Return the maximum along a given axis.',
|
10 |
+
'snippet' : [
|
11 |
+
'np.max(a, axis=0)',
|
12 |
+
],
|
13 |
+
},
|
14 |
+
|
15 |
+
{
|
16 |
+
'name' : 'argmax: Return indices of the maximum values along the given axis.',
|
17 |
+
'snippet' : [
|
18 |
+
'np.argmax(a, axis=0)',
|
19 |
+
],
|
20 |
+
},
|
21 |
+
|
22 |
+
{
|
23 |
+
'name' : 'min: Return the minimum along a given axis.',
|
24 |
+
'snippet' : [
|
25 |
+
'np.min(a, axis=0)',
|
26 |
+
],
|
27 |
+
},
|
28 |
+
|
29 |
+
{
|
30 |
+
'name' : 'argmin: Return indices of the minimum values along the given axis of a.',
|
31 |
+
'snippet' : [
|
32 |
+
'np.argmin(a, axis=0)',
|
33 |
+
],
|
34 |
+
},
|
35 |
+
|
36 |
+
{
|
37 |
+
'name' : 'ptp: Peak-to-peak (maximum - minimum) value along a given axis.',
|
38 |
+
'snippet' : [
|
39 |
+
'np.ptp(a, axis=0)',
|
40 |
+
],
|
41 |
+
},
|
42 |
+
|
43 |
+
{
|
44 |
+
'name' : 'trace: Return the sum along diagonals of the array.',
|
45 |
+
'snippet' : [
|
46 |
+
'np.trace(a, axis1, axis2)',
|
47 |
+
],
|
48 |
+
},
|
49 |
+
|
50 |
+
{
|
51 |
+
'name' : 'mean: Returns the average of the array elements along given axis.',
|
52 |
+
'snippet' : [
|
53 |
+
'np.mean(a, axis=0)',
|
54 |
+
],
|
55 |
+
},
|
56 |
+
|
57 |
+
{
|
58 |
+
'name' : 'var: Returns the variance of the array elements, along given axis.',
|
59 |
+
'snippet' : [
|
60 |
+
'np.var(a, axis=0)',
|
61 |
+
],
|
62 |
+
},
|
63 |
+
|
64 |
+
{
|
65 |
+
'name' : 'std: Returns the standard deviation of the array elements along given axis.',
|
66 |
+
'snippet' : [
|
67 |
+
'np.std(a, axis=0)',
|
68 |
+
],
|
69 |
+
},
|
70 |
+
|
71 |
+
{
|
72 |
+
'name' : 'all: Returns True if all elements evaluate to True.',
|
73 |
+
'snippet' : [
|
74 |
+
'np.all(a, axis=0)',
|
75 |
+
],
|
76 |
+
},
|
77 |
+
|
78 |
+
{
|
79 |
+
'name' : 'any: Returns True if any of the elements of a evaluate to True.',
|
80 |
+
'snippet' : [
|
81 |
+
'np.any(a, axis=0)',
|
82 |
+
],
|
83 |
+
},
|
84 |
+
],
|
85 |
+
},
|
86 |
+
|
87 |
+
{
|
88 |
+
'name' : 'Sums, products, differences within array',
|
89 |
+
'sub-menu' : [
|
90 |
+
{
|
91 |
+
'name' : 'prod: Product of array elements over a given axis',
|
92 |
+
'snippet' : [
|
93 |
+
'np.prod(a, axis=0)',
|
94 |
+
],
|
95 |
+
},
|
96 |
+
|
97 |
+
{
|
98 |
+
'name' : 'sum: Sum of array elements over a given axis',
|
99 |
+
'snippet' : [
|
100 |
+
'np.sum(a, axis=0)',
|
101 |
+
],
|
102 |
+
},
|
103 |
+
|
104 |
+
{
|
105 |
+
'name' : 'nansum: Sum of array elements over a given axis treating NaNs as zero',
|
106 |
+
'snippet' : [
|
107 |
+
'np.nansum(a, axis=0)',
|
108 |
+
],
|
109 |
+
},
|
110 |
+
|
111 |
+
{
|
112 |
+
'name' : 'cumprod: Cumulative product of elements along a given axis',
|
113 |
+
'snippet' : [
|
114 |
+
'np.cumprod(a, axis=0)',
|
115 |
+
],
|
116 |
+
},
|
117 |
+
|
118 |
+
{
|
119 |
+
'name' : 'cumsum: Cumulative sum of the elements along a given axis',
|
120 |
+
'snippet' : [
|
121 |
+
'np.cumsum(a, axis=0)',
|
122 |
+
],
|
123 |
+
},
|
124 |
+
|
125 |
+
{
|
126 |
+
'name' : 'diff: Calculate the n-th order discrete difference along given axis',
|
127 |
+
'snippet' : [
|
128 |
+
'np.diff(a, n, axis=0)',
|
129 |
+
],
|
130 |
+
},
|
131 |
+
|
132 |
+
{
|
133 |
+
'name' : 'ediff1d: Differences between consecutive elements of an array',
|
134 |
+
'snippet' : [
|
135 |
+
'np.ediff1d(a)',
|
136 |
+
],
|
137 |
+
},
|
138 |
+
|
139 |
+
{
|
140 |
+
'name' : 'gradient: Gradient of an N-dimensional array',
|
141 |
+
'snippet' : [
|
142 |
+
'np.gradient(f, *varargs, **kwargs)',
|
143 |
+
],
|
144 |
+
},
|
145 |
+
|
146 |
+
{
|
147 |
+
'name' : 'trapz: Integrate along the given axis using the composite trapezoidal rule',
|
148 |
+
'snippet' : [
|
149 |
+
'np.trapz(y, x, dx, axis)',
|
150 |
+
],
|
151 |
+
},
|
152 |
+
|
153 |
+
{
|
154 |
+
'name' : 'convolve: Discrete, linear convolution of two one-dimensional sequences',
|
155 |
+
'snippet' : [
|
156 |
+
'np.convolve(a, v)',
|
157 |
+
],
|
158 |
+
},
|
159 |
+
|
160 |
+
{
|
161 |
+
'name' : 'interp: One-dimensional linear interpolation',
|
162 |
+
'snippet' : [
|
163 |
+
'np.interp(x, xp, fp)',
|
164 |
+
],
|
165 |
+
},
|
166 |
+
],
|
167 |
+
},
|
168 |
+
|
169 |
+
|
170 |
+
{
|
171 |
+
'name' : 'Logarithms and exponentials',
|
172 |
+
'sub-menu' : [
|
173 |
+
{
|
174 |
+
'name' : 'logaddexp: Logarithm of the sum of exponentiations of the inputs',
|
175 |
+
'snippet' : [
|
176 |
+
'np.logaddexp(x1, x2)',
|
177 |
+
],
|
178 |
+
},
|
179 |
+
|
180 |
+
{
|
181 |
+
'name' : 'logaddexp2: Logarithm of the sum of exponentiations of the inputs in base-2',
|
182 |
+
'snippet' : [
|
183 |
+
'np.logaddexp2(x1, x2)',
|
184 |
+
],
|
185 |
+
},
|
186 |
+
|
187 |
+
{
|
188 |
+
'name' : 'power: First array elements raised to powers from second array, element-wise',
|
189 |
+
'snippet' : [
|
190 |
+
'np.power(x1, x2)',
|
191 |
+
],
|
192 |
+
},
|
193 |
+
|
194 |
+
{
|
195 |
+
'name' : 'power: First array elements raised to powers from second array, element-wise with automatic domain',
|
196 |
+
'snippet' : [
|
197 |
+
'# Use np.emath.power when input dtypes are float, but may contain negatives',
|
198 |
+
'np.emath.power(x1, x2)',
|
199 |
+
],
|
200 |
+
},
|
201 |
+
|
202 |
+
{
|
203 |
+
'name' : 'exp: Calculate the exponential of all elements in the input array',
|
204 |
+
'snippet' : [
|
205 |
+
'np.exp(x)',
|
206 |
+
],
|
207 |
+
},
|
208 |
+
|
209 |
+
{
|
210 |
+
'name' : 'exp2: Calculate $2^p$ for all $p$ in the input array',
|
211 |
+
'snippet' : [
|
212 |
+
'np.exp2(x)',
|
213 |
+
],
|
214 |
+
},
|
215 |
+
|
216 |
+
{
|
217 |
+
'name' : 'log: Natural logarithm, element-wise',
|
218 |
+
'snippet' : [
|
219 |
+
'np.log(x)',
|
220 |
+
],
|
221 |
+
},
|
222 |
+
|
223 |
+
{
|
224 |
+
'name' : 'log: Natural logarithm, element-wise with automatic domain',
|
225 |
+
'snippet' : [
|
226 |
+
'# Use np.emath.log when input dtype is float, but may contain negatives',
|
227 |
+
'np.emath.log(x)',
|
228 |
+
],
|
229 |
+
},
|
230 |
+
|
231 |
+
{
|
232 |
+
'name' : 'log2: Base-2 logarithm of $x$',
|
233 |
+
'snippet' : [
|
234 |
+
'np.log2(x)',
|
235 |
+
],
|
236 |
+
},
|
237 |
+
|
238 |
+
{
|
239 |
+
'name' : 'log2: Base-2 logarithm of $x$ with automatic domain',
|
240 |
+
'snippet' : [
|
241 |
+
'# Use np.emath.log2 when input dtype is float, but may contain negatives',
|
242 |
+
'np.emath.log2(x)',
|
243 |
+
],
|
244 |
+
},
|
245 |
+
|
246 |
+
{
|
247 |
+
'name' : 'log10: Return the base 10 logarithm of the input array, element-wise',
|
248 |
+
'snippet' : [
|
249 |
+
'np.log10(x)',
|
250 |
+
],
|
251 |
+
},
|
252 |
+
|
253 |
+
{
|
254 |
+
'name' : 'log10: Return the base 10 logarithm of the input array, element-wise with automatic domain',
|
255 |
+
'snippet' : [
|
256 |
+
'# Use np.emath.log10 when input dtype is float, but may contain negatives',
|
257 |
+
'np.emath.log10(x)',
|
258 |
+
],
|
259 |
+
},
|
260 |
+
|
261 |
+
{
|
262 |
+
'name' : 'logn: Return the base $n$ logarithm of the input array, element-wise with automatic domain',
|
263 |
+
'snippet' : [
|
264 |
+
'# np.emath.logn allows for inputs with dtype float but possibly containing negatives',
|
265 |
+
'np.emath.logn(n, x)',
|
266 |
+
],
|
267 |
+
},
|
268 |
+
|
269 |
+
{
|
270 |
+
'name' : 'expm1: Calculate $\\exp(x) - 1$ for all elements in the array',
|
271 |
+
'snippet' : [
|
272 |
+
'np.expm1(x)',
|
273 |
+
],
|
274 |
+
},
|
275 |
+
|
276 |
+
{
|
277 |
+
'name' : 'log1p: Calculate $\\log(1+x)$ for all elements in the array',
|
278 |
+
'snippet' : [
|
279 |
+
'np.log1p(x)',
|
280 |
+
],
|
281 |
+
},
|
282 |
+
|
283 |
+
{
|
284 |
+
'name' : 'sqrt: Return the positive square-root of an array, element-wise',
|
285 |
+
'snippet' : [
|
286 |
+
'np.sqrt(x)',
|
287 |
+
],
|
288 |
+
},
|
289 |
+
|
290 |
+
{
|
291 |
+
'name' : 'sqrt: Return the positive square-root of an array, element-wise with automatic domain',
|
292 |
+
'snippet' : [
|
293 |
+
'# Use np.emath.sqrt when argument may contain negative real numbers',
|
294 |
+
'np.emath.sqrt(x)',
|
295 |
+
],
|
296 |
+
},
|
297 |
+
|
298 |
+
{
|
299 |
+
'name' : 'square: Return the element-wise square of the input',
|
300 |
+
'snippet' : [
|
301 |
+
'np.square(x)',
|
302 |
+
],
|
303 |
+
},
|
304 |
+
|
305 |
+
{
|
306 |
+
'name' : 'reciprocal: Return the reciprocal of the argument, element-wise',
|
307 |
+
'snippet' : [
|
308 |
+
'np.reciprocal(x)',
|
309 |
+
],
|
310 |
+
},
|
311 |
+
],
|
312 |
+
},
|
313 |
+
|
314 |
+
{
|
315 |
+
'name' : 'Trigonometric and hyperbolic functions',
|
316 |
+
'sub-menu' : [
|
317 |
+
{
|
318 |
+
'name' : 'sin: Trigonometric sine, element-wise',
|
319 |
+
'snippet' : [
|
320 |
+
'np.sin(x)',
|
321 |
+
],
|
322 |
+
},
|
323 |
+
|
324 |
+
{
|
325 |
+
'name' : 'cos: Cosine element-wise',
|
326 |
+
'snippet' : [
|
327 |
+
'np.cos(x)',
|
328 |
+
],
|
329 |
+
},
|
330 |
+
|
331 |
+
{
|
332 |
+
'name' : 'tan: Compute tangent element-wise',
|
333 |
+
'snippet' : [
|
334 |
+
'np.tan(x)',
|
335 |
+
],
|
336 |
+
},
|
337 |
+
|
338 |
+
{
|
339 |
+
'name' : 'arcsin: Trigonometric inverse sine, element-wise',
|
340 |
+
'snippet' : [
|
341 |
+
'np.arcsin(x)',
|
342 |
+
],
|
343 |
+
},
|
344 |
+
|
345 |
+
{
|
346 |
+
'name' : 'arcsin: Trigonometric inverse sine, element-wise with automatic domain',
|
347 |
+
'snippet' : [
|
348 |
+
'# Use np.emath.arcsin when input dtype is float, but may contain values outside of [-1,1]',
|
349 |
+
'np.emath.arcsin(x)',
|
350 |
+
],
|
351 |
+
},
|
352 |
+
|
353 |
+
{
|
354 |
+
'name' : 'arccos: Trigonometric inverse cosine, element-wise',
|
355 |
+
'snippet' : [
|
356 |
+
'np.arccos(x)',
|
357 |
+
],
|
358 |
+
},
|
359 |
+
|
360 |
+
{
|
361 |
+
'name' : 'arccos: Trigonometric inverse cosine, element-wise with automatic domain',
|
362 |
+
'snippet' : [
|
363 |
+
'# Use np.emath.arccos when input dtype is float, but may contain values outside of [-1,1]',
|
364 |
+
'np.emath.arccos(x)',
|
365 |
+
],
|
366 |
+
},
|
367 |
+
|
368 |
+
{
|
369 |
+
'name' : 'arctan: Trigonometric inverse tangent, element-wise',
|
370 |
+
'snippet' : [
|
371 |
+
'np.arctan(x)',
|
372 |
+
],
|
373 |
+
},
|
374 |
+
|
375 |
+
{
|
376 |
+
'name' : 'arctan2: Element-wise arc tangent of $x_1/x_2$ choosing the quadrant correctly',
|
377 |
+
'snippet' : [
|
378 |
+
'np.arctan2(x1, x2)',
|
379 |
+
],
|
380 |
+
},
|
381 |
+
|
382 |
+
{
|
383 |
+
'name' : 'hypot: Given the “legs” of a right triangle, return its hypotenuse',
|
384 |
+
'snippet' : [
|
385 |
+
'np.hypot(x1, x2)',
|
386 |
+
],
|
387 |
+
},
|
388 |
+
|
389 |
+
'---',
|
390 |
+
|
391 |
+
{
|
392 |
+
'name' : 'sinh: Hyperbolic sine, element-wise',
|
393 |
+
'snippet' : [
|
394 |
+
'np.sinh(x)',
|
395 |
+
],
|
396 |
+
},
|
397 |
+
|
398 |
+
{
|
399 |
+
'name' : 'cosh: Hyperbolic cosine, element-wise',
|
400 |
+
'snippet' : [
|
401 |
+
'np.cosh(x)',
|
402 |
+
],
|
403 |
+
},
|
404 |
+
|
405 |
+
{
|
406 |
+
'name' : 'tanh: Compute hyperbolic tangent element-wise',
|
407 |
+
'snippet' : [
|
408 |
+
'np.tanh(x)',
|
409 |
+
],
|
410 |
+
},
|
411 |
+
|
412 |
+
{
|
413 |
+
'name' : 'arcsinh: Inverse hyperbolic sine element-wise',
|
414 |
+
'snippet' : [
|
415 |
+
'np.arcsinh(x)',
|
416 |
+
],
|
417 |
+
},
|
418 |
+
|
419 |
+
{
|
420 |
+
'name' : 'arccosh: Inverse hyperbolic cosine, element-wise',
|
421 |
+
'snippet' : [
|
422 |
+
'np.arccosh(x)',
|
423 |
+
],
|
424 |
+
},
|
425 |
+
|
426 |
+
{
|
427 |
+
'name' : 'arctanh: Inverse hyperbolic tangent, element-wise',
|
428 |
+
'snippet' : [
|
429 |
+
'np.arctanh(x)',
|
430 |
+
],
|
431 |
+
},
|
432 |
+
|
433 |
+
{
|
434 |
+
'name' : 'arctanh: Inverse hyperbolic tangent, element-wise with automatic domain',
|
435 |
+
'snippet' : [
|
436 |
+
'# Use np.emath.arctanh when input dtype is float, but may contain values outside of (-1,1)',
|
437 |
+
'np.emath.arctanh(x)',
|
438 |
+
],
|
439 |
+
},
|
440 |
+
|
441 |
+
'---',
|
442 |
+
|
443 |
+
{
|
444 |
+
'name' : 'deg2rad: Convert angles from degrees to radians',
|
445 |
+
'snippet' : [
|
446 |
+
'np.deg2rad(x)',
|
447 |
+
],
|
448 |
+
},
|
449 |
+
|
450 |
+
{
|
451 |
+
'name' : 'rad2deg: Convert angles from radians to degrees',
|
452 |
+
'snippet' : [
|
453 |
+
'np.rad2deg(x)',
|
454 |
+
],
|
455 |
+
},
|
456 |
+
|
457 |
+
{
|
458 |
+
'name' : 'unwrap: Unwrap radian phase by changing jumps greater than $\\pi$ to their $2\\pi$ complement',
|
459 |
+
'snippet' : [
|
460 |
+
'np.unwrap(x)',
|
461 |
+
],
|
462 |
+
},
|
463 |
+
],
|
464 |
+
},
|
465 |
+
|
466 |
+
{
|
467 |
+
'name' : 'Complex numbers',
|
468 |
+
'sub-menu' : [
|
469 |
+
{
|
470 |
+
'name' : 'real: Real part of the elements of the array',
|
471 |
+
'snippet' : [
|
472 |
+
'np.real(a)',
|
473 |
+
],
|
474 |
+
},
|
475 |
+
|
476 |
+
{
|
477 |
+
'name' : 'imag: Imaginary part of the elements of the array',
|
478 |
+
'snippet' : [
|
479 |
+
'np.imag(a)',
|
480 |
+
],
|
481 |
+
},
|
482 |
+
|
483 |
+
{
|
484 |
+
'name' : 'conj: Complex conjugate, element-wise',
|
485 |
+
'snippet' : [
|
486 |
+
'np.conj(a)',
|
487 |
+
],
|
488 |
+
},
|
489 |
+
|
490 |
+
{
|
491 |
+
'name' : 'angle: Angle of the complex argument',
|
492 |
+
'snippet' : [
|
493 |
+
'np.angle(a)',
|
494 |
+
],
|
495 |
+
},
|
496 |
+
|
497 |
+
{
|
498 |
+
'name' : 'unwrap: Unwrap radian phase by changing jumps greater than $\\pi$ to their $2\\pi$ complement',
|
499 |
+
'snippet' : [
|
500 |
+
'np.unwrap(x)',
|
501 |
+
],
|
502 |
+
},
|
503 |
+
],
|
504 |
+
},
|
505 |
+
|
506 |
+
{
|
507 |
+
'name' : 'Rounding and clipping',
|
508 |
+
'sub-menu' : [
|
509 |
+
{
|
510 |
+
'name' : 'around: Evenly round to the given number of decimals',
|
511 |
+
'snippet' : [
|
512 |
+
'np.around(a, decimals=2)',
|
513 |
+
],
|
514 |
+
},
|
515 |
+
|
516 |
+
{
|
517 |
+
'name' : 'rint: Round elements of the array to the nearest integer',
|
518 |
+
'snippet' : [
|
519 |
+
'np.rint(a)',
|
520 |
+
],
|
521 |
+
},
|
522 |
+
|
523 |
+
{
|
524 |
+
'name' : 'fix: Round to nearest integer towards zero',
|
525 |
+
'snippet' : [
|
526 |
+
'np.fix(a)',
|
527 |
+
],
|
528 |
+
},
|
529 |
+
|
530 |
+
{
|
531 |
+
'name' : 'floor: Floor of the input, element-wise',
|
532 |
+
'snippet' : [
|
533 |
+
'np.floor(a)',
|
534 |
+
],
|
535 |
+
},
|
536 |
+
|
537 |
+
{
|
538 |
+
'name' : 'ceil: Ceiling of the input, element-wise',
|
539 |
+
'snippet' : [
|
540 |
+
'np.ceil(a)',
|
541 |
+
],
|
542 |
+
},
|
543 |
+
|
544 |
+
{
|
545 |
+
'name' : 'trunc: Truncated value of the input, element-wise',
|
546 |
+
'snippet' : [
|
547 |
+
'np.trunc(a)',
|
548 |
+
],
|
549 |
+
},
|
550 |
+
|
551 |
+
{
|
552 |
+
'name' : 'clip: Clip (limit) the values in an array',
|
553 |
+
'snippet' : [
|
554 |
+
'np.clip(a, a_min, a_max)',
|
555 |
+
],
|
556 |
+
},
|
557 |
+
|
558 |
+
{
|
559 |
+
'name' : 'nan_to_num: Replace NaNs with zero and inf with finite numbers',
|
560 |
+
'snippet' : [
|
561 |
+
'np.nan_to_num(a)',
|
562 |
+
],
|
563 |
+
},
|
564 |
+
|
565 |
+
{
|
566 |
+
'name' : 'real_if_close: Truncate complex parts if within `tol` times machine epsilon of zero',
|
567 |
+
'snippet' : [
|
568 |
+
'np.real_if_close(a, tol=100)',
|
569 |
+
],
|
570 |
+
},
|
571 |
+
],
|
572 |
+
},
|
573 |
+
|
574 |
+
{
|
575 |
+
'name' : 'Float functions',
|
576 |
+
'sub-menu' : [
|
577 |
+
{
|
578 |
+
'name' : 'isreal: Returns a bool array, where True if input element is real',
|
579 |
+
'snippet' : [
|
580 |
+
'np.isreal(x)',
|
581 |
+
],
|
582 |
+
},
|
583 |
+
|
584 |
+
{
|
585 |
+
'name' : 'iscomplex: Returns a bool array, where True if input element is complex',
|
586 |
+
'snippet' : [
|
587 |
+
'np.iscomplex(x)',
|
588 |
+
],
|
589 |
+
},
|
590 |
+
|
591 |
+
{
|
592 |
+
'name' : 'isfinite: Test element-wise for finiteness (not infinity and not NaN)',
|
593 |
+
'snippet' : [
|
594 |
+
'np.isfinite(x)',
|
595 |
+
],
|
596 |
+
},
|
597 |
+
|
598 |
+
{
|
599 |
+
'name' : 'isinf: Test element-wise for positive or negative infinity',
|
600 |
+
'snippet' : [
|
601 |
+
'np.isinf(x)',
|
602 |
+
],
|
603 |
+
},
|
604 |
+
|
605 |
+
{
|
606 |
+
'name' : 'isnan: Test element-wise for NaN and return result as a boolean array',
|
607 |
+
'snippet' : [
|
608 |
+
'np.isnan(x)',
|
609 |
+
],
|
610 |
+
},
|
611 |
+
|
612 |
+
{
|
613 |
+
'name' : 'signbit: Returns element-wise True where signbit is set (less than zero)',
|
614 |
+
'snippet' : [
|
615 |
+
'np.signbit(x)',
|
616 |
+
],
|
617 |
+
},
|
618 |
+
|
619 |
+
{
|
620 |
+
'name' : 'copysign: Change the sign of $x_1$ to that of $x_2$, element-wise',
|
621 |
+
'snippet' : [
|
622 |
+
'np.copysign(x1, x2)',
|
623 |
+
],
|
624 |
+
},
|
625 |
+
|
626 |
+
{
|
627 |
+
'name' : 'nextafter: Return the next floating-point value after $x_1$ towards $x_2$, element-wise',
|
628 |
+
'snippet' : [
|
629 |
+
'np.nextafter(x1, x2)',
|
630 |
+
],
|
631 |
+
},
|
632 |
+
|
633 |
+
{
|
634 |
+
'name' : 'modf: Return the fractional and integral parts of an array, element-wise',
|
635 |
+
'snippet' : [
|
636 |
+
'np.modf(x)',
|
637 |
+
],
|
638 |
+
},
|
639 |
+
|
640 |
+
{
|
641 |
+
'name' : 'ldexp: Returns $x_1\\, 2^{x_2}$, element-wise',
|
642 |
+
'snippet' : [
|
643 |
+
'np.ldexp(x1, x2)',
|
644 |
+
],
|
645 |
+
},
|
646 |
+
|
647 |
+
{
|
648 |
+
'name' : 'frexp: Decompose the elements of $x$ into mantissa and twos exponent',
|
649 |
+
'snippet' : [
|
650 |
+
'np.frexp(x)',
|
651 |
+
],
|
652 |
+
},
|
653 |
+
|
654 |
+
{
|
655 |
+
'name' : 'fmod: Return the element-wise remainder of division',
|
656 |
+
'snippet' : [
|
657 |
+
'np.fmod(x1, x2)',
|
658 |
+
],
|
659 |
+
},
|
660 |
+
|
661 |
+
{
|
662 |
+
'name' : 'floor: Return the floor of the input, element-wise',
|
663 |
+
'snippet' : [
|
664 |
+
'np.floor(x)',
|
665 |
+
],
|
666 |
+
},
|
667 |
+
|
668 |
+
{
|
669 |
+
'name' : 'ceil: Return the ceiling of the input, element-wise',
|
670 |
+
'snippet' : [
|
671 |
+
'np.ceil(x)',
|
672 |
+
],
|
673 |
+
},
|
674 |
+
|
675 |
+
{
|
676 |
+
'name' : 'trunc: Return the truncated value of the input, element-wise',
|
677 |
+
'snippet' : [
|
678 |
+
'np.trunc(x)',
|
679 |
+
],
|
680 |
+
},
|
681 |
+
],
|
682 |
+
},
|
683 |
+
|
684 |
+
{
|
685 |
+
'name' : 'Bit-twiddling functions',
|
686 |
+
'sub-menu' : [
|
687 |
+
{
|
688 |
+
'name' : 'bitwise_and: Compute the bit-wise AND of two arrays element-wise',
|
689 |
+
'snippet' : [
|
690 |
+
'np.bitwise_and(x1, x2)',
|
691 |
+
],
|
692 |
+
},
|
693 |
+
|
694 |
+
{
|
695 |
+
'name' : 'bitwise_or: Compute the bit-wise OR of two arrays element-wise',
|
696 |
+
'snippet' : [
|
697 |
+
'np.bitwise_or(x1, x2)',
|
698 |
+
],
|
699 |
+
},
|
700 |
+
|
701 |
+
{
|
702 |
+
'name' : 'bitwise_xor: Compute the bit-wise XOR of two arrays element-wise',
|
703 |
+
'snippet' : [
|
704 |
+
'np.bitwise_xor(x1, x2)',
|
705 |
+
],
|
706 |
+
},
|
707 |
+
|
708 |
+
{
|
709 |
+
'name' : 'invert: Compute bit-wise inversion, or bit-wise NOT, element-wise',
|
710 |
+
'snippet' : [
|
711 |
+
'np.invert(x)',
|
712 |
+
],
|
713 |
+
},
|
714 |
+
|
715 |
+
{
|
716 |
+
'name' : 'left_shift: Shift the bits of an integer to the left',
|
717 |
+
'snippet' : [
|
718 |
+
'np.left_shift(x1, x2)',
|
719 |
+
],
|
720 |
+
},
|
721 |
+
|
722 |
+
{
|
723 |
+
'name' : 'right_shift: Shift the bits of an integer to the right',
|
724 |
+
'snippet' : [
|
725 |
+
'np.right_shift(x1, x2)',
|
726 |
+
],
|
727 |
+
},
|
728 |
+
],
|
729 |
+
},
|
730 |
+
|
731 |
+
{
|
732 |
+
'name' : 'Special functions (see scipy.special)',
|
733 |
+
'sub-menu' : [
|
734 |
+
{
|
735 |
+
'name' : 'i0: Modified Bessel function of the first kind, order 0',
|
736 |
+
'snippet' : [
|
737 |
+
'np.i0(x)',
|
738 |
+
],
|
739 |
+
},
|
740 |
+
|
741 |
+
{
|
742 |
+
'name' : 'sinc: Return the sinc function',
|
743 |
+
'snippet' : [
|
744 |
+
'np.sinc(x)',
|
745 |
+
],
|
746 |
+
},
|
747 |
+
],
|
748 |
+
},
|
749 |
+
|
750 |
+
'---',
|
751 |
+
|
752 |
+
{
|
753 |
+
'name' : 'Arithmetic',
|
754 |
+
'sub-menu' : [
|
755 |
+
{
|
756 |
+
'name' : 'add: Add arguments element-wise',
|
757 |
+
'snippet' : [
|
758 |
+
'np.add(x1, x2)',
|
759 |
+
],
|
760 |
+
},
|
761 |
+
|
762 |
+
{
|
763 |
+
'name' : 'subtract: Subtract arguments, element-wise',
|
764 |
+
'snippet' : [
|
765 |
+
'np.subtract(x1, x2)',
|
766 |
+
],
|
767 |
+
},
|
768 |
+
|
769 |
+
{
|
770 |
+
'name' : 'multiply: Multiply arguments element-wise',
|
771 |
+
'snippet' : [
|
772 |
+
'np.multiply(x1, x2)',
|
773 |
+
],
|
774 |
+
},
|
775 |
+
|
776 |
+
{
|
777 |
+
'name' : 'divide: Divide arguments element-wise',
|
778 |
+
'snippet' : [
|
779 |
+
'np.divide(x1, x2)',
|
780 |
+
],
|
781 |
+
},
|
782 |
+
|
783 |
+
{
|
784 |
+
'name' : 'true_divide: Returns a true division of the inputs, element-wise',
|
785 |
+
'snippet' : [
|
786 |
+
'np.true_divide(x1, x2)',
|
787 |
+
],
|
788 |
+
},
|
789 |
+
|
790 |
+
{
|
791 |
+
'name' : 'floor_divide: Return the largest integer smaller or equal to the division of the inputs',
|
792 |
+
'snippet' : [
|
793 |
+
'np.floor_divide(x1, x2)',
|
794 |
+
],
|
795 |
+
},
|
796 |
+
|
797 |
+
{
|
798 |
+
'name' : 'negative: Numerical negative, element-wise',
|
799 |
+
'snippet' : [
|
800 |
+
'np.negative(x)',
|
801 |
+
],
|
802 |
+
},
|
803 |
+
|
804 |
+
{
|
805 |
+
'name' : 'remainder: Return element-wise remainder of integer division',
|
806 |
+
'snippet' : [
|
807 |
+
'np.remainder(x1, x2)',
|
808 |
+
],
|
809 |
+
},
|
810 |
+
|
811 |
+
{
|
812 |
+
'name' : 'mod: Return element-wise remainder of integer division',
|
813 |
+
'snippet' : [
|
814 |
+
'np.mod(x1, x2) # identical to np.remainder',
|
815 |
+
],
|
816 |
+
},
|
817 |
+
|
818 |
+
{
|
819 |
+
'name' : 'fmod: Return element-wise remainder of float division',
|
820 |
+
'snippet' : [
|
821 |
+
'np.fmod(x1, x2)',
|
822 |
+
],
|
823 |
+
},
|
824 |
+
|
825 |
+
{
|
826 |
+
'name' : 'modf: Return the fractional and integral parts of an array, element-wise',
|
827 |
+
'snippet' : [
|
828 |
+
'np.modf(x)',
|
829 |
+
],
|
830 |
+
},
|
831 |
+
|
832 |
+
{
|
833 |
+
'name' : 'absolute: Calculate the absolute value element-wise',
|
834 |
+
'snippet' : [
|
835 |
+
'np.absolute(x)',
|
836 |
+
],
|
837 |
+
},
|
838 |
+
|
839 |
+
{
|
840 |
+
'name' : 'rint: Round elements of the array to the nearest integer',
|
841 |
+
'snippet' : [
|
842 |
+
'np.rint(x)',
|
843 |
+
],
|
844 |
+
},
|
845 |
+
|
846 |
+
{
|
847 |
+
'name' : 'sign: Returns an element-wise indication of the sign of a number',
|
848 |
+
'snippet' : [
|
849 |
+
'np.sign(x)',
|
850 |
+
],
|
851 |
+
},
|
852 |
+
|
853 |
+
{
|
854 |
+
'name' : 'conj: Return the complex conjugate, element-wise',
|
855 |
+
'snippet' : [
|
856 |
+
'np.conj(x)',
|
857 |
+
],
|
858 |
+
},
|
859 |
+
|
860 |
+
{
|
861 |
+
'name' : 'sqrt: Return the positive square-root of an array, element-wise',
|
862 |
+
'snippet' : [
|
863 |
+
'np.sqrt(x)',
|
864 |
+
],
|
865 |
+
},
|
866 |
+
|
867 |
+
{
|
868 |
+
'name' : 'sqrt: Return the positive square-root of an array, element-wise with automatic domain',
|
869 |
+
'snippet' : [
|
870 |
+
'# Use np.emath.sqrt when argument may contain negative real numbers',
|
871 |
+
'np.emath.sqrt(x)',
|
872 |
+
],
|
873 |
+
},
|
874 |
+
|
875 |
+
{
|
876 |
+
'name' : 'square: Return the element-wise square of the input',
|
877 |
+
'snippet' : [
|
878 |
+
'np.square(x)',
|
879 |
+
],
|
880 |
+
},
|
881 |
+
|
882 |
+
{
|
883 |
+
'name' : 'reciprocal: Return the reciprocal of the argument, element-wise',
|
884 |
+
'snippet' : [
|
885 |
+
'np.reciprocal(x)',
|
886 |
+
],
|
887 |
+
},
|
888 |
+
],
|
889 |
+
},
|
890 |
+
|
891 |
+
{
|
892 |
+
'name' : 'Matrix and vector products',
|
893 |
+
'sub-menu' : [
|
894 |
+
{
|
895 |
+
'name' : 'tensordot: Tensor dot product over last $n$ axes of a and first $n$ of b',
|
896 |
+
'snippet' : [
|
897 |
+
'a = np.arange(60).reshape((5,3,4))',
|
898 |
+
'b = np.arange(84).reshape((3,4,7))',
|
899 |
+
'n = 2',
|
900 |
+
'np.tensordot(a, b, n)',
|
901 |
+
],
|
902 |
+
},
|
903 |
+
{
|
904 |
+
'name' : 'tensordot: Tensor dot product over given pairs of axes',
|
905 |
+
'snippet' : [
|
906 |
+
'a = np.arange(24).reshape((3,4,2))',
|
907 |
+
'axes_a = (2, 0)',
|
908 |
+
'b = np.arange(30).reshape((2,3,5))',
|
909 |
+
'axes_b = (0, 1)',
|
910 |
+
'np.tensordot(a, b, (axes_a, axes_b)',
|
911 |
+
],
|
912 |
+
},
|
913 |
+
{
|
914 |
+
'name' : 'einsum: Evaluate Einstein summation convention on operands',
|
915 |
+
'snippet' : [
|
916 |
+
'a = np.arange(6).reshape((3,2))',
|
917 |
+
'b = np.arange(12).reshape((4,3))',
|
918 |
+
"np.einsum('ki,jk->ij', a, b)",
|
919 |
+
],
|
920 |
+
},
|
921 |
+
{
|
922 |
+
'name' : 'inner: Inner product, summing over last two axes',
|
923 |
+
'snippet' : [
|
924 |
+
'a = np.arange(24).reshape((2,3,4))',
|
925 |
+
'b = np.arange(4)',
|
926 |
+
'np.inner(a, b)',
|
927 |
+
],
|
928 |
+
},
|
929 |
+
{
|
930 |
+
'name' : 'outer: Compute outer product of two vectors (automatically flattened)',
|
931 |
+
'snippet' : [
|
932 |
+
'a = np.ones((5,))',
|
933 |
+
'b = np.linspace(-2, 2, 5)',
|
934 |
+
'np.outer(a, b)',
|
935 |
+
],
|
936 |
+
},
|
937 |
+
{
|
938 |
+
'name' : 'kron: Kronecker product of arrays',
|
939 |
+
'snippet' : [
|
940 |
+
'np.kron(np.eye(2), np.ones((2,2)))',
|
941 |
+
],
|
942 |
+
},
|
943 |
+
{
|
944 |
+
'name' : 'vdot: Dot product of two complex vectors, conjugating the first',
|
945 |
+
'snippet' : [
|
946 |
+
'',
|
947 |
+
],
|
948 |
+
},
|
949 |
+
{
|
950 |
+
'name' : 'dot: Dot product of two arrays over last and second-to-last dimensions, respectively',
|
951 |
+
'snippet' : [
|
952 |
+
'',
|
953 |
+
],
|
954 |
+
},
|
955 |
+
{
|
956 |
+
'name' : 'cross: Cross product of two (arrays of) vectors',
|
957 |
+
'snippet' : [
|
958 |
+
'np.cross(a, b)',
|
959 |
+
],
|
960 |
+
},
|
961 |
+
],
|
962 |
+
},
|
963 |
+
|
964 |
+
{
|
965 |
+
'name' : 'Comparisons between two arrays',
|
966 |
+
'sub-menu' : [
|
967 |
+
{
|
968 |
+
'name' : 'greater: Return the truth value of $(x_1 > x_2)$ element-wise',
|
969 |
+
'snippet' : [
|
970 |
+
'np.greater(x1, x2)',
|
971 |
+
],
|
972 |
+
},
|
973 |
+
|
974 |
+
{
|
975 |
+
'name' : 'greater_equal: Return the truth value of $(x_1 \\geq x_2)$ element-wise',
|
976 |
+
'snippet' : [
|
977 |
+
'np.greater_equal(x1, x2)',
|
978 |
+
],
|
979 |
+
},
|
980 |
+
|
981 |
+
{
|
982 |
+
'name' : 'less: Return the truth value of $(x_1 < x_2)$ element-wise',
|
983 |
+
'snippet' : [
|
984 |
+
'np.less(x1, x2)',
|
985 |
+
],
|
986 |
+
},
|
987 |
+
|
988 |
+
{
|
989 |
+
'name' : 'less_equal: Return the truth value of $(x_1 \\leq x_2)$ element-wise',
|
990 |
+
'snippet' : [
|
991 |
+
'np.less_equal(x1, x2)',
|
992 |
+
],
|
993 |
+
},
|
994 |
+
|
995 |
+
{
|
996 |
+
'name' : 'not_equal: Return $(x_1 != x_2)$ element-wise',
|
997 |
+
'snippet' : [
|
998 |
+
'np.not_equal(x1, x2)',
|
999 |
+
],
|
1000 |
+
},
|
1001 |
+
|
1002 |
+
{
|
1003 |
+
'name' : 'equal: Return $(x_1 == x_2)$ element-wise',
|
1004 |
+
'snippet' : [
|
1005 |
+
'np.equal(x1, x2)',
|
1006 |
+
],
|
1007 |
+
},
|
1008 |
+
|
1009 |
+
{
|
1010 |
+
'name' : 'logical_and: Compute the truth value of $x_1$ AND $x_2$ element-wise',
|
1011 |
+
'snippet' : [
|
1012 |
+
'np.logical_and(x1, x2)',
|
1013 |
+
],
|
1014 |
+
},
|
1015 |
+
|
1016 |
+
{
|
1017 |
+
'name' : 'logical_or: Compute the truth value of $x_1$ OR $x_2$ element-wise',
|
1018 |
+
'snippet' : [
|
1019 |
+
'np.logical_or(x1, x2)',
|
1020 |
+
],
|
1021 |
+
},
|
1022 |
+
|
1023 |
+
{
|
1024 |
+
'name' : 'logical_xor: Compute the truth value of $x_1$ XOR $x_2$, element-wise',
|
1025 |
+
'snippet' : [
|
1026 |
+
'np.logical_xor(x1, x2)',
|
1027 |
+
],
|
1028 |
+
},
|
1029 |
+
|
1030 |
+
{
|
1031 |
+
'name' : 'logical_not: Compute the truth value of NOT $x$ element-wise',
|
1032 |
+
'snippet' : [
|
1033 |
+
'np.logical_not(x)',
|
1034 |
+
],
|
1035 |
+
},
|
1036 |
+
|
1037 |
+
{
|
1038 |
+
'name' : 'maximum: Element-wise maximum of array elements',
|
1039 |
+
'snippet' : [
|
1040 |
+
'np.maximum(x1, x2)',
|
1041 |
+
],
|
1042 |
+
},
|
1043 |
+
|
1044 |
+
{
|
1045 |
+
'name' : 'minimum: Element-wise minimum of array elements',
|
1046 |
+
'snippet' : [
|
1047 |
+
'np.minimum(x1, x2)',
|
1048 |
+
],
|
1049 |
+
},
|
1050 |
+
|
1051 |
+
{
|
1052 |
+
'name' : 'fmax: Element-wise maximum of array elements',
|
1053 |
+
'snippet' : [
|
1054 |
+
'np.fmax(x1, x2)',
|
1055 |
+
],
|
1056 |
+
},
|
1057 |
+
|
1058 |
+
{
|
1059 |
+
'name' : 'fmin: Element-wise minimum of array elements',
|
1060 |
+
'snippet' : [
|
1061 |
+
'np.fmin(x1, x2)',
|
1062 |
+
],
|
1063 |
+
},
|
1064 |
+
],
|
1065 |
+
},
|
1066 |
+
|
1067 |
+
],
|
1068 |
+
});
|
.local/share/jupyter/nbextensions/snippets_menu/thumbnail.png
ADDED
.local/share/jupyter/nbextensions/spellchecker/__pycache__/download_new_dict.cpython-310.pyc
ADDED
Binary file (1.28 kB). View file
|
|
.local/share/jupyter/nbextensions/splitcell/icon.png
ADDED
.local/share/jupyter/nbextensions/splitcell/readme.md
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
# Split Cells
|
2 |
+
|
3 |
+
Enter command mode (esc), use shift-s to toggle the current cell to either a split cell or full width.
|
.local/share/jupyter/nbextensions/splitcell/splitcell.yaml
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Type: IPython Notebook Extension
|
2 |
+
Name: Split Cells Notebook
|
3 |
+
Description: Enable split cells in Jupyter notebooks
|
4 |
+
Main: splitcell.js
|
5 |
+
Link: readme.md
|
6 |
+
Icon: icon.png
|
7 |
+
Compatibility: Jupyter (4.x, 5.x)
|
8 |
+
|
.local/share/jupyter/nbextensions/table_beautifier/table_beautifier.yaml
ADDED
@@ -0,0 +1,6 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Type: IPython Notebook Extension
|
2 |
+
Name: table_beautifier
|
3 |
+
Link: README.md
|
4 |
+
Description: Add bootstrap styling to tables in markdown cells and in html/md output
|
5 |
+
Main: main.js
|
6 |
+
Compatibility: 4.x, 5.x
|
.local/share/jupyter/nbextensions/toc2/demo3.gif
ADDED
.local/share/jupyter/nbextensions/toc2/main.css
ADDED
@@ -0,0 +1,183 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/*
|
2 |
+
|
3 |
+
originally extracted from https://gist.github.com/magican/5574556
|
4 |
+
|
5 |
+
Most colors defined here are overridden by javascript which adds css based on
|
6 |
+
values in the server config file notebook.json, which can be edited directly,
|
7 |
+
or colors can be selected in the nbextensions_configurator
|
8 |
+
*/
|
9 |
+
|
10 |
+
|
11 |
+
|
12 |
+
/*background color for links when you mouse over it */
|
13 |
+
#toc-wrapper li > span:hover {
|
14 |
+
background-color: #DAA520;
|
15 |
+
}
|
16 |
+
|
17 |
+
#toc a {
|
18 |
+
color: #333333; /* default - alterable via nbextension-configurator */
|
19 |
+
text-decoration: none;
|
20 |
+
}
|
21 |
+
#navigate_menu li > span:hover {background-color: #f1f1f1}
|
22 |
+
|
23 |
+
|
24 |
+
/* Move menus and tooolbar to the left, following @Kevin-McIsaac suggestion
|
25 |
+
This is now done in javascript, if the relevant option is selected
|
26 |
+
div#menubar-container, div#header-container {
|
27 |
+
width: auto;
|
28 |
+
padding-left: 20px;
|
29 |
+
}*/
|
30 |
+
|
31 |
+
#navigate_menu {
|
32 |
+
list-style-type: none;
|
33 |
+
max-width: 800px;
|
34 |
+
min-width: 100px;
|
35 |
+
width: 250px;
|
36 |
+
overflow: auto;
|
37 |
+
}
|
38 |
+
|
39 |
+
|
40 |
+
#navigate_menu a {
|
41 |
+
list-style-type: none;
|
42 |
+
color: #333333; /* default - alterable via nbextension-configurator */
|
43 |
+
text-decoration: none;
|
44 |
+
}
|
45 |
+
|
46 |
+
#navigate_menu li {
|
47 |
+
padding-left: 0px;
|
48 |
+
clear: both;
|
49 |
+
list-style-type: none;
|
50 |
+
}
|
51 |
+
|
52 |
+
#navigate_menu > .toc-item,
|
53 |
+
#navigate_menu ul {
|
54 |
+
padding-left: 0px;
|
55 |
+
}
|
56 |
+
|
57 |
+
.toc {
|
58 |
+
padding: 0px;
|
59 |
+
overflow-y: auto;
|
60 |
+
font-weight: normal;
|
61 |
+
color: #333333; /* default - alterable via nbextension-configurator */
|
62 |
+
white-space: nowrap;
|
63 |
+
overflow-x: auto;
|
64 |
+
}
|
65 |
+
|
66 |
+
.text_cell .toc {
|
67 |
+
margin-top: 1em;
|
68 |
+
}
|
69 |
+
|
70 |
+
.toc ul.toc-item {
|
71 |
+
list-style-type: none;
|
72 |
+
padding: 0;
|
73 |
+
margin: 0;
|
74 |
+
}
|
75 |
+
|
76 |
+
#toc-wrapper {
|
77 |
+
z-index: 90;
|
78 |
+
position: fixed !important;
|
79 |
+
display: flex;
|
80 |
+
flex-direction: column;
|
81 |
+
overflow: hidden;
|
82 |
+
padding: 10px;
|
83 |
+
border-style: solid;
|
84 |
+
border-width: thin;
|
85 |
+
background-color: #fff; /* default - alterable via nbextension-configurator */
|
86 |
+
}
|
87 |
+
|
88 |
+
#toc-wrapper .toc {
|
89 |
+
flex-grow: 1;
|
90 |
+
}
|
91 |
+
|
92 |
+
.float-wrapper {
|
93 |
+
border-color: rgba(0, 0, 0, 0.38);
|
94 |
+
border-radius: 5px;
|
95 |
+
opacity: .8;
|
96 |
+
}
|
97 |
+
|
98 |
+
.sidebar-wrapper {
|
99 |
+
top: 0;
|
100 |
+
bottom: 0;
|
101 |
+
width: 212px;
|
102 |
+
border-color: #eeeeee; /* default - alterable via nbextension-configurator */
|
103 |
+
}
|
104 |
+
|
105 |
+
.sidebar-wrapper .ui-resizable-se {
|
106 |
+
display: none;
|
107 |
+
}
|
108 |
+
|
109 |
+
.sidebar-wrapper .ui-resizable-e {
|
110 |
+
position: absolute;
|
111 |
+
top: calc(50% - 8px);
|
112 |
+
}
|
113 |
+
|
114 |
+
#toc-wrapper.closed {
|
115 |
+
min-width: 100px;
|
116 |
+
width: auto;
|
117 |
+
transition: width;
|
118 |
+
}
|
119 |
+
#toc-wrapper:hover{
|
120 |
+
opacity: 1;
|
121 |
+
}
|
122 |
+
#toc-wrapper .header {
|
123 |
+
font-size: 18px;
|
124 |
+
font-weight: bold;
|
125 |
+
}
|
126 |
+
|
127 |
+
.sidebar-wrapper .hide-btn {
|
128 |
+
display:none;
|
129 |
+
}
|
130 |
+
|
131 |
+
#toc-wrapper .hide-btn:before {
|
132 |
+
content: "\f147";
|
133 |
+
}
|
134 |
+
|
135 |
+
#toc-wrapper.closed .hide-btn:before {
|
136 |
+
content: "\f196";
|
137 |
+
}
|
138 |
+
|
139 |
+
#toc-header .fa {
|
140 |
+
font-size: 14px;
|
141 |
+
text-decoration: none;
|
142 |
+
}
|
143 |
+
|
144 |
+
/* on scroll style */
|
145 |
+
.highlight_on_scroll {
|
146 |
+
border-left: solid 4px blue;
|
147 |
+
}
|
148 |
+
|
149 |
+
.toc-item li { margin:0; padding:0; color:black }
|
150 |
+
.toc-item li > span { display:block }
|
151 |
+
.toc-item li > span { padding-left:0em }
|
152 |
+
.toc-item li li > span { padding-left:1em }
|
153 |
+
.toc-item li li li > span { padding-left:2em }
|
154 |
+
.toc-item li li li li > span { padding-left:3em }
|
155 |
+
.toc-item li li li li li > span { padding-left:4em }
|
156 |
+
.toc-item li li li li li li > span { padding-left:5em }
|
157 |
+
|
158 |
+
|
159 |
+
#toc-wrapper .toc-item-num {
|
160 |
+
font-family: Georgia, Times New Roman, Times, serif;
|
161 |
+
color: black; /* default - alterable via nbextension-configurator */
|
162 |
+
}
|
163 |
+
|
164 |
+
/*
|
165 |
+
These colors are now specified in js, after reading the extension's config stored in system
|
166 |
+
and updated using the nbextension-configurator
|
167 |
+
.toc-item-highlight-select {background-color: Gold}
|
168 |
+
.toc-item-highlight-execute {background-color: red}
|
169 |
+
.toc-item-highlight-execute.toc-item-highlight-select {background-color: Gold} */
|
170 |
+
|
171 |
+
#toc-header .fa ,
|
172 |
+
.toc-item .fa-fw:first-child {
|
173 |
+
cursor: pointer;
|
174 |
+
}
|
175 |
+
|
176 |
+
#toc-header,
|
177 |
+
.modal-header {
|
178 |
+
cursor: move;
|
179 |
+
}
|
180 |
+
|
181 |
+
.tocSkip {
|
182 |
+
display: none;
|
183 |
+
}
|
.local/share/jupyter/nbextensions/tree-filter/index.js
ADDED
@@ -0,0 +1,132 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
/*
|
2 |
+
* Based on https://github.com/jdfreder/jupyter-tree-filter.git
|
3 |
+
*/
|
4 |
+
|
5 |
+
define([
|
6 |
+
'require',
|
7 |
+
'jquery',
|
8 |
+
'base/js/namespace',
|
9 |
+
'base/js/utils',
|
10 |
+
'services/config'
|
11 |
+
], function (
|
12 |
+
requirejs,
|
13 |
+
$,
|
14 |
+
Jupyter,
|
15 |
+
utils,
|
16 |
+
configmod
|
17 |
+
) {
|
18 |
+
'use strict';
|
19 |
+
|
20 |
+
var base_url = utils.get_body_data("baseUrl");
|
21 |
+
var config = new configmod.ConfigSection('tree', {base_url: base_url});
|
22 |
+
|
23 |
+
config.loaded.then(function() {
|
24 |
+
if (config.data.hasOwnProperty('filter_keyword')) {
|
25 |
+
var filter_keyword = config.data.filter_keyword;
|
26 |
+
if (filter_keyword) {
|
27 |
+
console.log("filter_keyword:", filter_keyword);
|
28 |
+
$('#filterkeyword').val(filter_keyword);
|
29 |
+
filterRows(filter_keyword);
|
30 |
+
}
|
31 |
+
}
|
32 |
+
});
|
33 |
+
|
34 |
+
function filterRows (filterText, caseSensitive, useRegex) {
|
35 |
+
var input = $('#filterkeyword');
|
36 |
+
var btnRegex = $('#filterisreg');
|
37 |
+
|
38 |
+
filterText = filterText !== undefined ? filterText : input.val();
|
39 |
+
useRegex = useRegex !== undefined ? useRegex : btnRegex.attr('aria-pressed') === 'true';
|
40 |
+
caseSensitive = caseSensitive !== undefined ? caseSensitive : $('#filtercase').attr('aria-pressed') === 'true';
|
41 |
+
|
42 |
+
if (!useRegex) {
|
43 |
+
// escape any regex special chars
|
44 |
+
filterText = filterText.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, '\\$&');
|
45 |
+
}
|
46 |
+
var matchExpr;
|
47 |
+
try {
|
48 |
+
matchExpr = new RegExp(filterText, caseSensitive ? '' : 'i');
|
49 |
+
}
|
50 |
+
catch (err) {
|
51 |
+
// do nothing, error is handled based on undefined matchExpr
|
52 |
+
}
|
53 |
+
|
54 |
+
var invalidRegex = matchExpr === undefined;
|
55 |
+
btnRegex.toggleClass('btn-danger', invalidRegex);
|
56 |
+
btnRegex.toggleClass('btn-default', !invalidRegex);
|
57 |
+
btnRegex.closest('.form-group').toggleClass('has-error has-feedback', invalidRegex);
|
58 |
+
|
59 |
+
var rows = Array.prototype.concat.apply([], document.querySelectorAll('.list_item.row'));
|
60 |
+
rows.forEach(function (row) {
|
61 |
+
if (!filterText || row.querySelector('.item_name').textContent.search(matchExpr) !== -1) {
|
62 |
+
row.style.display = '';
|
63 |
+
} else {
|
64 |
+
row.style.display = 'none';
|
65 |
+
}
|
66 |
+
});
|
67 |
+
}
|
68 |
+
|
69 |
+
function filterRowsDefaultParams () {
|
70 |
+
return filterRows();
|
71 |
+
}
|
72 |
+
|
73 |
+
function load_ipython_extension () {
|
74 |
+
|
75 |
+
var form = $('<form/>')
|
76 |
+
.css('padding', '0 7px 4px')
|
77 |
+
.appendTo('#notebook_list_header');
|
78 |
+
|
79 |
+
var frm_grp = $('<div/>')
|
80 |
+
.addClass('form-group')
|
81 |
+
.css('margin-bottom', 0)
|
82 |
+
.appendTo(form);
|
83 |
+
|
84 |
+
var grp = $('<div/>')
|
85 |
+
.addClass('input-group')
|
86 |
+
.appendTo(frm_grp);
|
87 |
+
|
88 |
+
$('<input/>')
|
89 |
+
.attr('type', 'text')
|
90 |
+
.addClass('form-control input-sm')
|
91 |
+
.attr('title', 'Keyword for filtering tree')
|
92 |
+
.attr('id', 'filterkeyword')
|
93 |
+
.attr('placeholder', 'Filter')
|
94 |
+
.css('font-weight', 'bold')
|
95 |
+
.appendTo(grp);
|
96 |
+
|
97 |
+
var btns = $('<div/>')
|
98 |
+
.addClass('input-group-btn')
|
99 |
+
.appendTo(grp);
|
100 |
+
|
101 |
+
$('<button/>')
|
102 |
+
.attr('type', 'button')
|
103 |
+
.attr('id', 'filterisreg')
|
104 |
+
.addClass('btn btn-default btn-sm')
|
105 |
+
.attr('data-toggle', 'button')
|
106 |
+
.css('font-weight', 'bold')
|
107 |
+
.attr('title', 'Use regex (JavaScript regex syntax)')
|
108 |
+
.text('.*')
|
109 |
+
.on('click', function (evt) { setTimeout(filterRowsDefaultParams); })
|
110 |
+
.appendTo(btns);
|
111 |
+
|
112 |
+
$('<button/>')
|
113 |
+
.attr('type', 'button')
|
114 |
+
.attr('id', 'filtercase')
|
115 |
+
.addClass('btn btn-default btn-sm')
|
116 |
+
.attr('data-toggle', 'button')
|
117 |
+
.attr('tabindex', '0')
|
118 |
+
.attr('title', 'Match case')
|
119 |
+
.css('font-weight', 'bold')
|
120 |
+
.text('Aa')
|
121 |
+
.on('click', function (evt) { setTimeout(filterRowsDefaultParams); })
|
122 |
+
.appendTo(btns);
|
123 |
+
|
124 |
+
$('#filterkeyword').on('keyup', filterRowsDefaultParams);
|
125 |
+
config.load();
|
126 |
+
}
|
127 |
+
|
128 |
+
return {
|
129 |
+
load_ipython_extension : load_ipython_extension
|
130 |
+
};
|
131 |
+
|
132 |
+
});
|
.local/share/jupyter/nbextensions/tree-filter/readme.md
ADDED
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Tree-filter
|
2 |
+
===========
|
3 |
+
|
4 |
+
An extension that allows you to filter by filename in the Jupyter notebook file tree (aka dashboard) page.
|
5 |
+
Based on [jdfreder/jupyter-tree-filter](https://github.com/jdfreder/jupyter-tree-filter)
|
6 |
+
|
7 |
+
![](demo.gif)
|
8 |
+
|
.local/share/jupyter/nbextensions/tree-filter/tree-filter.yaml
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
Type: IPython Notebook Extension
|
2 |
+
Name: Tree Filter
|
3 |
+
Description: An extension that allows you to filter by filename in the Jupyter notebook file tree (aka dashboard) page.
|
4 |
+
Link: readme.md
|
5 |
+
Main: index.js
|
6 |
+
Section: tree
|
7 |
+
Compatibility: 4.x, 5.x
|
8 |
+
Parameters:
|
9 |
+
- name: filter_keyword
|
10 |
+
input_type: string
|
11 |
+
description: Filter keyword
|
12 |
+
default: ""
|
.local/share/jupyter/nbextensions/varInspector/tablesorter_LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
The MIT License (MIT)
|
2 |
+
|
3 |
+
Copyright (c) 2014 Christian Bach
|
4 |
+
|
5 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6 |
+
of this software and associated documentation files (the "Software"), to deal
|
7 |
+
in the Software without restriction, including without limitation the rights
|
8 |
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9 |
+
copies of the Software, and to permit persons to whom the Software is
|
10 |
+
furnished to do so, subject to the following conditions:
|
11 |
+
|
12 |
+
The above copyright notice and this permission notice shall be included in all
|
13 |
+
copies or substantial portions of the Software.
|
14 |
+
|
15 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16 |
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17 |
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18 |
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19 |
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20 |
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21 |
+
SOFTWARE.
|
.local/share/jupyter/nbextensions/zenmode/images/back1.jpg
ADDED
.local/share/jupyter/nbextensions/zenmode/images/back12.jpg
ADDED
.local/share/jupyter/nbextensions/zenmode/images/back2.jpg
ADDED