0-hero commited on
Commit
79f9b39
·
verified ·
1 Parent(s): fa0f006

Add files using upload-large-folder tool

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .config/wandb/settings +2 -0
  2. .local/share/jupyter/nbextensions/freeze/main.js +205 -0
  3. .local/share/jupyter/nbextensions/gist_it/main.js +481 -0
  4. .local/share/jupyter/nbextensions/gist_it/readme.md +59 -0
  5. .local/share/jupyter/nbextensions/help_panel/help_panel.js +248 -0
  6. .local/share/jupyter/nbextensions/help_panel/help_panel_ext_fullscreen.png +0 -0
  7. .local/share/jupyter/nbextensions/hide_header/README.md +4 -0
  8. .local/share/jupyter/nbextensions/hide_header/main.js +66 -0
  9. .local/share/jupyter/nbextensions/hide_input/icon.png +0 -0
  10. .local/share/jupyter/nbextensions/hide_input/main.js +54 -0
  11. .local/share/jupyter/nbextensions/keyboard_shortcut_editor/readme_comma.png +0 -0
  12. .local/share/jupyter/nbextensions/select_keymap/main.js +371 -0
  13. .local/share/jupyter/nbextensions/select_keymap/select_keymap.yaml +15 -0
  14. .local/share/jupyter/nbextensions/skip-traceback/main.js +204 -0
  15. .local/share/jupyter/nbextensions/snippets/snippets-demo.gif +0 -0
  16. .local/share/jupyter/nbextensions/snippets_menu/examples_for_custom.js +187 -0
  17. .local/share/jupyter/nbextensions/snippets_menu/readme.md +633 -0
  18. .local/share/jupyter/nbextensions/snippets_menu/screenshot1.png +0 -0
  19. .local/share/jupyter/nbextensions/snippets_menu/snippets_menu.css +72 -0
  20. .local/share/jupyter/nbextensions/snippets_menu/snippets_submenus_python/numba.js +51 -0
  21. .local/share/jupyter/nbextensions/snippets_menu/snippets_submenus_python/numpy.js +618 -0
  22. .local/share/jupyter/nbextensions/snippets_menu/snippets_submenus_python/numpy_polynomial.js +129 -0
  23. .local/share/jupyter/nbextensions/snippets_menu/snippets_submenus_python/numpy_ufuncs.js +1068 -0
  24. .local/share/jupyter/nbextensions/snippets_menu/snippets_submenus_python/python.js +209 -0
  25. .local/share/jupyter/nbextensions/snippets_menu/snippets_submenus_python/python_regex.js +309 -0
  26. .local/share/jupyter/nbextensions/snippets_menu/snippets_submenus_python/sympy.js +750 -0
  27. .local/share/jupyter/nbextensions/spellchecker/__pycache__/download_new_dict.cpython-310.pyc +0 -0
  28. .local/share/jupyter/nbextensions/spellchecker/config.yaml +27 -0
  29. .local/share/jupyter/nbextensions/spellchecker/main.css +12 -0
  30. .local/share/jupyter/nbextensions/spellchecker/typo/LICENSE.txt +28 -0
  31. .local/share/jupyter/nbextensions/table_beautifier/main.js +78 -0
  32. .local/share/jupyter/nbextensions/toc2/demo_dark.png +0 -0
  33. .local/share/jupyter/nbextensions/toc2/icon.png +0 -0
  34. .local/share/jupyter/nbextensions/toc2/image.png +0 -0
  35. .local/share/jupyter/nbextensions/toc2/toc2.yaml +104 -0
  36. .local/share/jupyter/nbextensions/varInspector/main.css +119 -0
  37. .triton/dump/11759acf26ac56366b171628132485d6/triton_.llir +347 -0
  38. .triton/dump/11759acf26ac56366b171628132485d6/triton_.ttgir +78 -0
  39. .triton/dump/11759acf26ac56366b171628132485d6/triton_.ttir +76 -0
  40. .triton/dump/15fa39c568de5a2b912a7bda93a479b3/triton_.cubin +0 -0
  41. .triton/dump/415aac87553b7d064f52694fa7254686/triton_.ttgir +28 -0
  42. .triton/dump/4c6ad48573c74d55ed79384f6b432d50/triton_.cubin +0 -0
  43. .triton/dump/4c6ad48573c74d55ed79384f6b432d50/triton_.llir +85 -0
  44. .triton/dump/4c6ad48573c74d55ed79384f6b432d50/triton_.ptx +312 -0
  45. .triton/dump/4d7b96448927b8146af43cb9f39e0544/triton_.cubin +0 -0
  46. .triton/dump/645565eaba0a18dd23ef200fe9abb0c0/triton_.llir +349 -0
  47. .triton/dump/8c4bac4d904709a8b7e8c698132d974c/triton_.llir +45 -0
  48. .triton/dump/8c4bac4d904709a8b7e8c698132d974c/triton_.ptx +280 -0
  49. .triton/dump/a4652f539404a11e3c068d96115a7427/triton_.cubin +0 -0
  50. .triton/dump/a4652f539404a11e3c068d96115a7427/triton_.llir +53 -0
.config/wandb/settings ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ [default]
2
+
.local/share/jupyter/nbextensions/freeze/main.js ADDED
@@ -0,0 +1,205 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ define([
2
+ 'base/js/namespace',
3
+ 'base/js/events',
4
+ 'notebook/js/codecell',
5
+ 'notebook/js/textcell',
6
+ 'jquery'
7
+ ], function (
8
+ Jupyter,
9
+ events,
10
+ codecell,
11
+ textcell,
12
+ $
13
+ ) {
14
+ 'use strict';
15
+
16
+ var CodeCell = codecell.CodeCell;
17
+ var MarkdownCell = textcell.MarkdownCell;
18
+
19
+ var mod_name = 'Freeze';
20
+ var log_prefix = '[' + mod_name + ']';
21
+
22
+ // defaults, overridden by server's config
23
+ var options = {
24
+ readonly_color: '#fffef0',
25
+ frozen_color: '#f0feff'
26
+ };
27
+
28
+ function patch_MarkdownCell_unrender () {
29
+ console.log('[Freeze] patching MarkdownCell.prototype.unrender');
30
+ var old_unrender = MarkdownCell.prototype.unrender;
31
+
32
+ MarkdownCell.prototype.unrender = function () {
33
+ // console.log('[Freeze] patched unrender applied');
34
+ if (this.metadata.run_control === undefined ||
35
+ !this.metadata.run_control.frozen
36
+ ) {
37
+ old_unrender.apply(this, arguments);
38
+ }
39
+ };
40
+ }
41
+
42
+ function patch_CodeCell_execute () {
43
+ console.log('[Freeze] patching CodeCell.prototype.execute');
44
+ var old_execute = CodeCell.prototype.execute;
45
+
46
+ CodeCell.prototype.execute = function () {
47
+ if (this.metadata.run_control === undefined ||
48
+ !this.metadata.run_control.frozen
49
+ ) {
50
+ old_execute.apply(this, arguments);
51
+ }
52
+ };
53
+ }
54
+
55
+ // Migrate old metadata format to new notebook-defined metadata.editable
56
+ function migrate_state (cell) {
57
+ if (cell.metadata.run_control !== undefined) {
58
+ if (cell instanceof CodeCell || cell instanceof MarkdownCell) {
59
+ if (cell.metadata.run_control.read_only === true) {
60
+ cell.metadata.editable = false;
61
+ }
62
+ }
63
+ else {
64
+ // remove metadata irrelevant to non-code/markdown cells
65
+ delete cell.metadata.run_control.frozen;
66
+ }
67
+ // remove old key replaced by metadata.editable
68
+ delete cell.metadata.run_control.read_only;
69
+ // remove whole object if it's now empty
70
+ if (Object.keys(cell.metadata.run_control).length === 0) {
71
+ delete cell.metadata.run_control;
72
+ }
73
+ }
74
+ }
75
+
76
+ function get_state (cell) {
77
+ if (cell.metadata.editable === false && (cell instanceof CodeCell || cell instanceof MarkdownCell)) {
78
+ if (cell.metadata.run_control !== undefined && cell.metadata.run_control.frozen) {
79
+ return 'frozen';
80
+ }
81
+ return 'readonly';
82
+ }
83
+ return 'normal';
84
+ }
85
+
86
+ function set_state(cell, state) {
87
+ if (!(cell instanceof CodeCell || cell instanceof MarkdownCell)) {
88
+ return;
89
+ }
90
+
91
+ state = state || 'normal';
92
+ var bg;
93
+ switch (state) {
94
+ case 'normal':
95
+ cell.metadata.editable = true;
96
+ cell.metadata.deletable = true;
97
+ if (cell.metadata.run_control !== undefined) {
98
+ delete cell.metadata.run_control.frozen;
99
+ }
100
+ bg = "";
101
+ break;
102
+ case 'read_only':
103
+ case 'readonly':
104
+ cell.metadata.editable = false;
105
+ cell.metadata.deletable = false;
106
+ if (cell.metadata.run_control !== undefined) {
107
+ delete cell.metadata.run_control.frozen;
108
+ }
109
+ bg = options.readonly_color;
110
+ break;
111
+ case 'frozen':
112
+ cell.metadata.editable = false;
113
+ cell.metadata.deletable = false;
114
+ $.extend(true, cell.metadata, {run_control: {frozen: true}});
115
+ bg = options.frozen_color;
116
+ break;
117
+ }
118
+ // remove whole object if it's now empty
119
+ if (cell.metadata.run_control !== undefined && Object.keys(cell.metadata.run_control).length === 0) {
120
+ delete cell.metadata.run_control;
121
+ }
122
+ cell.code_mirror.setOption('readOnly', !cell.metadata.editable);
123
+ var prompt = cell.element.find('div.input_area');
124
+ prompt.css("background-color", bg);
125
+ }
126
+
127
+ function set_state_selected (state) {
128
+ var cells = Jupyter.notebook.get_selected_cells();
129
+ for (var i = 0; i < cells.length; i++) {
130
+ set_state(cells[i], state);
131
+ }
132
+ }
133
+
134
+ function button_callback(state) {
135
+ set_state_selected(state);
136
+ var dirty_state = {value: true};
137
+ events.trigger("set_dirty.Notebook", dirty_state);
138
+ }
139
+
140
+ function make_normal_selected () {
141
+ button_callback('normal');
142
+ }
143
+
144
+ function make_read_only_selected () {
145
+ button_callback('read_only');
146
+ }
147
+
148
+ function make_frozen_selected () {
149
+ button_callback('frozen');
150
+ }
151
+
152
+ function initialize_states () {
153
+ var cells = Jupyter.notebook.get_cells();
154
+ for (var i = 0; i < cells.length; i++) {
155
+ var cell = cells[i];
156
+ migrate_state(cell);
157
+ var state = get_state(cell);
158
+ set_state(cell, state);
159
+ }
160
+ }
161
+
162
+ function load_extension () {
163
+ Jupyter.toolbar.add_buttons_group([
164
+ Jupyter.keyboard_manager.actions.register ({
165
+ help : 'lift restrictions from selected cells',
166
+ icon : 'fa-unlock-alt',
167
+ handler : make_normal_selected
168
+ }, 'make-cells-normal', mod_name),
169
+ Jupyter.keyboard_manager.actions.register({
170
+ help : 'make selected cells read-only',
171
+ icon: 'fa-lock',
172
+ handler : make_read_only_selected
173
+ }, 'make-cells-read-only', mod_name),
174
+ Jupyter.keyboard_manager.actions.register({
175
+ help : 'freeze selected cells',
176
+ icon : 'fa-asterisk',
177
+ handler : make_frozen_selected
178
+ }, 'freeze-cells', mod_name)
179
+ ]);
180
+
181
+ patch_CodeCell_execute();
182
+ patch_MarkdownCell_unrender();
183
+
184
+ Jupyter.notebook.config.loaded.then(function on_config_loaded () {
185
+ $.extend(true, options, Jupyter.notebook.config.data[mod_name]);
186
+ }, function on_config_load_error (reason) {
187
+ console.warn(log_prefix, 'Using defaults after error loading config:', reason);
188
+ }).then(function do_stuff_with_config () {
189
+ events.on("notebook_loaded.Notebook", initialize_states);
190
+ if (Jupyter.notebook !== undefined && Jupyter.notebook._fully_loaded) {
191
+ // notebook already loaded, so we missed the event, so update all
192
+ initialize_states();
193
+ }
194
+ }).catch(function on_error (reason) {
195
+ console.error(log_prefix, 'Error:', reason);
196
+ });
197
+ }
198
+
199
+ return {
200
+ get_state : get_state,
201
+ set_state : set_state,
202
+ load_jupyter_extension : load_extension,
203
+ load_ipython_extension : load_extension
204
+ };
205
+ });
.local/share/jupyter/nbextensions/gist_it/main.js ADDED
@@ -0,0 +1,481 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ *
3
+ // Avoid server side code :
4
+ // https://github.com/ipython/ipython/issues/2780
5
+ *
6
+ * This essentially boils down to the following:
7
+ * Github authentication requires some server-side code for any 'app' which
8
+ * wants to authenticate over the Github API.
9
+ * When registering an app with Github, Github provides the app with what they
10
+ * call a 'client secret'.
11
+ * The client secret is then incorporated into the app, and the app sends it to
12
+ * Github as part of the authentication process, thus proving to Github's
13
+ * servers that the communicating app was written by someone with appropriate
14
+ * credentials.
15
+ *
16
+ * The issue with writing a single Github app for Gist-ing notebooks, is that
17
+ * it would need to include such a client secret. Since this would be part of
18
+ * the extension source code, anyone could use the client secret, potentially
19
+ * gaining the permissions that any given user has granted to the app.
20
+ *
21
+ * As a result, we only support:
22
+ * - anonymous (non-authenticated) API usage
23
+ * - client-side authentication using a personal access token
24
+ * (see https://github.com/settings/tokens)
25
+ */
26
+
27
+ define([
28
+ 'jquery',
29
+ 'base/js/namespace',
30
+ 'base/js/dialog'
31
+ ], function (
32
+ $,
33
+ Jupyter,
34
+ dialog
35
+ ) {
36
+ "use strict";
37
+
38
+ // define default values for config parameters
39
+ var params = {
40
+ gist_it_default_to_public: false,
41
+ gist_it_personal_access_token: '',
42
+ github_endpoint: 'github.com'
43
+ };
44
+
45
+ var initialize = function () {
46
+ update_params();
47
+ Jupyter.toolbar.add_buttons_group([
48
+ Jupyter.keyboard_manager.actions.register ({
49
+ help : 'Create/Edit Gist of Notebook',
50
+ icon : 'fa-github',
51
+ handler: show_gist_editor_modal
52
+ }, 'create-gist-from-notebook', 'gist_it')
53
+ ]);
54
+ };
55
+
56
+ // update params with any specified in the server's config file
57
+ var update_params = function() {
58
+ var config = Jupyter.notebook.config;
59
+ for (var key in params) {
60
+ if (config.data.hasOwnProperty(key))
61
+ params[key] = config.data[key];
62
+ }
63
+ default_metadata.data.public = Boolean(config.data.gist_it_default_to_public);
64
+ };
65
+
66
+ var default_metadata = {
67
+ id: '',
68
+ data: {
69
+ description: Jupyter.notebook.notebook_path,
70
+ public: false
71
+ }
72
+ };
73
+
74
+ function ensure_default_metadata () {
75
+ Jupyter.notebook.metadata.gist = $.extend(
76
+ true, // deep-copy
77
+ default_metadata, //defaults
78
+ Jupyter.notebook.metadata.gist // overrides
79
+ );
80
+ }
81
+
82
+ var add_auth_token = function add_auth_token (xhr) {
83
+ var token = '';
84
+ if (params.gist_it_personal_access_token !== '') {
85
+ token = params.gist_it_personal_access_token;
86
+ }
87
+ if (token !== '') {
88
+ xhr.setRequestHeader("Authorization", "token " + token);
89
+ }
90
+ };
91
+
92
+ function build_alert(alert_class) {
93
+ return $('<div/>')
94
+ .addClass('alert alert-dismissable')
95
+ .addClass(alert_class)
96
+ .append(
97
+ $('<button class="close" type="button" data-dismiss="alert" aria-label="Close"/>')
98
+ .append($('<span aria-hidden="true"/>').html('&times;'))
99
+ );
100
+ }
101
+
102
+ function gist_error (jqXHR, textStatus, errorThrown) {
103
+ console.log('github ajax error:', jqXHR, textStatus, errorThrown);
104
+ var alert = build_alert('alert-danger')
105
+ .hide()
106
+ .append(
107
+ $('<p/>').text('The ajax request to Github went wrong:')
108
+ )
109
+ .append(
110
+ $('<pre/>').text(jqXHR.responseJSON ? JSON.stringify(jqXHR.responseJSON, null, 2) : errorThrown)
111
+ );
112
+ $('#gist_modal').find('.modal-body').append(alert);
113
+ alert.slideDown('fast');
114
+ }
115
+
116
+ function gist_success (response, textStatus, jqXHR) {
117
+ // if (Jupyter.notebook.metadata.gist.id === response.id) return;
118
+
119
+ Jupyter.notebook.metadata.gist.id = response.id;
120
+ Jupyter.notebook.metadata._draft = $.extend(
121
+ true, // deep copy
122
+ Jupyter.notebook.metadata._draft, // defaults
123
+ {nbviewer_url: response.html_url} // overrides
124
+ );
125
+
126
+ var d = new Date();
127
+ var msg_head = d.toLocaleString() + ': Gist ';
128
+ var msg_tail = response.history.length === 1 ? ' published' : ' updated to revision ' + response.history.length;
129
+ var alert = build_alert('alert-success')
130
+ .hide()
131
+ .append(msg_head)
132
+ .append(
133
+ $('<a/>')
134
+ .attr('href', response.html_url)
135
+ .attr('target', '_blank')
136
+ .text(response.id)
137
+ )
138
+ .append(msg_tail);
139
+ $('#gist_modal').find('.modal-body').append(alert);
140
+ alert.slideDown('fast');
141
+ }
142
+
143
+ function get_github_endpoint() {
144
+ return params.github_endpoint !== '' ? params.github_endpoint : 'github.com';
145
+ }
146
+
147
+ function get_api_endpoint() {
148
+ const github_endpoint = get_github_endpoint();
149
+ if (github_endpoint === 'github.com') {
150
+ return 'https://api.'+ github_endpoint;
151
+ } else {
152
+ // Github Enterprise
153
+ // https://developer.github.com/enterprise/2.18/v3/enterprise-admin/#endpoint-urls
154
+ return 'https://' + github_endpoint + '/api/v3'
155
+ }
156
+ }
157
+
158
+ function gist_id_updated_callback(gist_editor) {
159
+ if (gist_editor === undefined) gist_editor = $('#gist_editor');
160
+
161
+ var id_input = gist_editor.find('#gist_id');
162
+ var id = id_input.val();
163
+
164
+ var help_block = gist_editor.find('#gist_id ~ .help-block');
165
+ var help_block_base_text = 'Set the gist id to update an existing gist, ' +
166
+ 'or leave blank to create a new one.';
167
+
168
+ var gist_it_button = $('#gist_modal').find('.btn-primary');
169
+
170
+ id_input.parent()
171
+ .removeClass('has-success has-error has-warning')
172
+ .find('#gist_id ~ .form-control-feedback > i.fa')
173
+ .removeClass('fa-pencil-square fa-exclamation-circle fa-question-circle');
174
+
175
+ if (id === '') {
176
+ $('#gist_id ~ .form-control-feedback > i.fa')
177
+ .addClass('fa-plus-circle');
178
+ help_block.html(
179
+ '<p>' + help_block_base_text + '</p>' +
180
+ '<p><i class="fa fa-plus-circle"></i> a new gist will be created</p>'
181
+ );
182
+ gist_it_button.prop('disabled', false);
183
+ }
184
+ else {
185
+ $('#gist_id ~ .form-control-feedback > i.fa')
186
+ .addClass('fa-circle-o-notch fa-spin');
187
+ // List commits as a way of checking whether the gist exists.
188
+ // Listing commits appears to give the most concise response.
189
+
190
+ $.ajax({
191
+ url: get_api_endpoint() +'/gists/' + id + '/commits',
192
+ dataType: 'json',
193
+ beforeSend: add_auth_token,
194
+ error: function(jqXHR, textStatus, errorThrown) {
195
+ jqXHR.errorThrown = errorThrown;
196
+ },
197
+ complete: function(jqXHR, textStatus) {
198
+ var success = textStatus === 'success';
199
+ var error = !success && jqXHR.status === 404 && jqXHR.responseJSON !== undefined;
200
+ var warning = !success && !error;
201
+
202
+ var help_block_html = '<p>' + help_block_base_text + '</p>';
203
+
204
+ gist_it_button.prop('disabled', error);
205
+ if (success) {
206
+ var single = (jqXHR.responseJSON.length === 1);
207
+ help_block_html += '<p>' +
208
+ '<i class="fa fa-pencil-square"></i>' +
209
+ ' gist ' +
210
+ '<a href="https://'+ get_github_endpoint() + '/gist/' + id +
211
+ '" target="_blank">' + id + '</a> will be updated' +
212
+ ' (' + jqXHR.responseJSON.length +
213
+ ' revision' + (single ? '' : 's') +
214
+ ' exist' + (single ? 's' : '') + ' so far)' +
215
+ '</p>';
216
+ }
217
+ else if (error) {
218
+ help_block_html += '<p>' +
219
+ '<i class="fa fa-exclamation-circle"></i>' +
220
+ ' no gist exists with the specified id (given current access token)'+
221
+ '</p>';
222
+ }
223
+ else {
224
+ help_block_html += '<p>' +
225
+ '<i class="fa fa-question-circle"></i>' +
226
+ ' can\'t list commits for the specified gist id - you may have problems updating it!' +
227
+ '</p>';
228
+ help_block_html += '<p>The ajax request to Github went wrong:<p/>' +
229
+ '<pre>';
230
+ if (jqXHR.responseJSON) {
231
+ help_block_html += JSON.stringify(jqXHR.responseJSON, null, 2);
232
+ }
233
+ else {
234
+ help_block_html += jqXHR.errorThrown || textStatus;
235
+ }
236
+ help_block_html += '</pre>';
237
+ console.log('non-404 github ajax error:', jqXHR, textStatus);
238
+ }
239
+ help_block.html(help_block_html);
240
+
241
+ id_input.parent()
242
+ .toggleClass('has-success', success)
243
+ .toggleClass('has-error', error)
244
+ .toggleClass('has-warning', warning)
245
+ .find('#gist_id ~ .form-control-feedback > i.fa')
246
+ .removeClass('fa-circle-o-notch fa-spin')
247
+ .toggleClass('fa-pencil-square', success)
248
+ .toggleClass('fa-exclamation-circle', error)
249
+ .toggleClass('fa-question-circle', warning);
250
+ }
251
+ });
252
+ }
253
+ }
254
+
255
+ function update_gist_editor (gist_editor) {
256
+ if (gist_editor === undefined) gist_editor = $('#gist_editor');
257
+
258
+ var id_input = gist_editor.find('#gist_id');
259
+
260
+ var have_auth = params.gist_it_personal_access_token !== '';
261
+ var id = '';
262
+ var is_public = true;
263
+ if (have_auth) {
264
+ id = Jupyter.notebook.metadata.gist.id;
265
+ is_public = Jupyter.notebook.metadata.gist.data.public;
266
+ id_input.val(id);
267
+ }
268
+ id_input.closest('.form-group').toggle(have_auth);
269
+
270
+ gist_editor.find('#gist_public')
271
+ .prop('checked', is_public)
272
+ .prop('readonly', !have_auth);
273
+
274
+ gist_editor.find('#gist_description')
275
+ .val(Jupyter.notebook.metadata.gist.data.description);
276
+
277
+ if (have_auth) {
278
+ gist_id_updated_callback(gist_editor);
279
+ }
280
+ }
281
+
282
+ function build_gist_editor () {
283
+ ensure_default_metadata();
284
+
285
+ var gist_editor = $('#gist_editor');
286
+
287
+ if (gist_editor.length > 0) return gist_editor;
288
+
289
+ gist_editor = $('<div/>').attr('id', 'gist_editor').append(controls);
290
+
291
+ var id = params.gist_it_personal_access_token !== '' ? Jupyter.notebook.metadata.gist.id : '';
292
+ var controls = $('<form/>')
293
+ .appendTo(gist_editor)
294
+ .addClass('form-horizontal');
295
+
296
+ $('<div/>')
297
+ .addClass('has-feedback')
298
+ .hide()
299
+ .appendTo(controls)
300
+ .append(
301
+ $('<label/>')
302
+ .attr('for', 'gist_id')
303
+ .text('Gist id')
304
+ )
305
+ .append(
306
+ $('<input/>')
307
+ .addClass('form-control')
308
+ .attr('id', 'gist_id')
309
+ .val(Jupyter.notebook.metadata.gist.id)
310
+ )
311
+ .append(
312
+ $('<span/>')
313
+ .addClass('form-control-feedback')
314
+ .append(
315
+ $('<i/>')
316
+ .addClass('fa fa-lg')
317
+ )
318
+ )
319
+ .append(
320
+ $('<span/>')
321
+ .addClass('help-block')
322
+ );
323
+ $('<div/>')
324
+ .appendTo(controls)
325
+ .append(
326
+ $('<div/>')
327
+ .addClass('checkbox')
328
+ .append(
329
+ $('<label>')
330
+ .text('Make the gist public')
331
+ .prepend(
332
+ $('<input/>')
333
+ .attr('type', 'checkbox')
334
+ .attr('id', 'gist_public')
335
+ .prop('checked', Jupyter.notebook.metadata.gist.data.public)
336
+ .prop('readonly', id === '')
337
+ )
338
+ )
339
+ )
340
+ .append(
341
+ $('<label/>')
342
+ .attr('for', 'gist_public')
343
+ .text('public')
344
+ );
345
+ $('<div/>')
346
+ .appendTo(controls)
347
+ .append(
348
+ $('<label/>')
349
+ .attr('for', 'gist_description')
350
+ .text('description')
351
+ )
352
+ .append(
353
+ $('<input/>')
354
+ .addClass('form-control')
355
+ .attr('id', 'gist_description')
356
+ .attr('type', 'textarea')
357
+ .val(Jupyter.notebook.metadata.gist.data.description)
358
+ );
359
+
360
+ var form_groups = controls.children('div').addClass('form-group');
361
+ form_groups
362
+ .children('label')
363
+ .addClass('col-sm-2 control-label')
364
+ .css('padding-right', '1em');
365
+ form_groups
366
+ .each(function (index, elem) {
367
+ $('<div/>')
368
+ .appendTo(elem)
369
+ .addClass('col-sm-10')
370
+ .append($(elem).children(':not(label)'));
371
+ });
372
+
373
+ update_gist_editor(gist_editor);
374
+
375
+ // bind events for id changing
376
+ var id_input = gist_editor.find('#gist_id');
377
+ // Save current value of element
378
+ id_input.data('oldVal', id_input.val());
379
+ // Look for changes in the value
380
+ id_input.bind("change click keyup input paste", function(event) {
381
+ // If value has changed...
382
+ if (id_input.data('oldVal') !== id_input.val()) {
383
+ // Updated stored value
384
+ id_input.data('oldVal', id_input.val());
385
+ // Do action
386
+ gist_id_updated_callback(gist_editor);
387
+ }
388
+ });
389
+
390
+ return gist_editor;
391
+ }
392
+
393
+ function show_gist_editor_modal () {
394
+ var modal;
395
+ modal = dialog.modal({
396
+ show: false,
397
+ title: 'Share on Github',
398
+ notebook: Jupyter.notebook,
399
+ keyboard_manager: Jupyter.notebook.keyboard_manager,
400
+ body: build_gist_editor(),
401
+ buttons: {
402
+ ' Gist it!': {
403
+ class : 'btn-primary',
404
+ click: function() {
405
+ modal.find('.btn').prop('disabled', true);
406
+ var new_data = {
407
+ public: $('#gist_public').prop('checked'),
408
+ description: $('#gist_description').val()
409
+ };
410
+ $.extend(
411
+ true,
412
+ Jupyter.notebook.metadata.gist.data,
413
+ new_data
414
+ );
415
+ // prevent the modal from closing. See github.com/twbs/bootstrap/issues/1202
416
+ modal.data('bs.modal').isShown = false;
417
+ var spinner = modal.find('.btn-primary .fa-github').addClass('fa-spin');
418
+ make_gist(function (jqXHR, textStatus) {
419
+ modal.find('.btn').prop('disabled', false);
420
+ // allow the modal to close again. See github.com/twbs/bootstrap/issues/1202
421
+ modal.data('bs.modal').isShown = true;
422
+ spinner.removeClass('fa-spin');
423
+ });
424
+ }
425
+ },
426
+ done: {}
427
+ }
428
+ })
429
+ .attr('id', 'gist_modal')
430
+ .on('shown.bs.modal', function (evt) {
431
+ var err = modal.find('#gist_id').parent().hasClass('has-error');
432
+ modal.find('.btn-primary').prop('disabled', err);
433
+ });
434
+
435
+ modal.find('.btn-primary').prepend(
436
+ $('<i/>')
437
+ .addClass('fa fa-lg fa-github')
438
+ );
439
+
440
+ modal.modal('show');
441
+ }
442
+
443
+ var make_gist = function make_gist (complete_callback) {
444
+ ensure_default_metadata();
445
+
446
+ var data = $.extend(
447
+ true, // deep-copy
448
+ { files: {} }, // defaults
449
+ Jupyter.notebook.metadata.gist.data // overrides
450
+ );
451
+ var filename = Jupyter.notebook.notebook_name;
452
+ data.files[filename] = {
453
+ content: JSON.stringify(Jupyter.notebook.toJSON(), null, 2)
454
+ };
455
+
456
+ var id_input = $('#gist_id');
457
+ var id = params.gist_it_personal_access_token !== '' ? id_input.val() : '';
458
+ var method = id ? 'PATCH' : 'POST';
459
+
460
+ // Create/edit the Gist
461
+ $.ajax({
462
+ url: get_api_endpoint() +'/gists' + (id ? '/' + id : ''),
463
+ type: method,
464
+ dataType: 'json',
465
+ data: JSON.stringify(data),
466
+ beforeSend: add_auth_token,
467
+ success: gist_success,
468
+ error: gist_error,
469
+ complete: complete_callback
470
+ });
471
+ };
472
+
473
+ function load_jupyter_extension () {
474
+ return Jupyter.notebook.config.loaded.then(initialize);
475
+ }
476
+
477
+ return {
478
+ load_jupyter_extension: load_jupyter_extension,
479
+ load_ipython_extension: load_jupyter_extension
480
+ };
481
+ });
.local/share/jupyter/nbextensions/gist_it/readme.md ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Gist it
2
+ =======
3
+
4
+ Publish notebooks as Github gists with a single button click!
5
+
6
+ ![](icon.png)
7
+
8
+
9
+ Authentication
10
+ --------------
11
+
12
+ The extension works with no special settings, publishing anonymous,
13
+ non-modifiable gists.
14
+
15
+ To create gists owned by your Github user, or to modify existing gists (useful
16
+ for multiple revisions of a notebook!), you need to be authenticated with Github.
17
+
18
+
19
+ ### Anonymous
20
+
21
+ You can publish anonymous gists without any authentication (the default mode).
22
+ Anonymous gists can't be edited, so every time you click the button, a new gist
23
+ is created.
24
+
25
+
26
+
27
+ ### Personal access tokens
28
+
29
+ At the moment, the only supported method of authentication is client-side,
30
+ using Github _personal access tokens_.
31
+
32
+ __Important:__ __using personal access token authentication only makes sense if
33
+ you are the only user of the notebook server__, and control the server.
34
+ Otherwise, other users of the server may use your token
35
+ (either accidentally or maliciously) to create/edit/delete gists,
36
+ or exercise any other permissions you might have given to the token.
37
+ If the server is only for your personal use, then you can create a github
38
+ personal access token at [github.com/settings/tokens](https://github.com/settings/tokens).
39
+ It makes sense to only grant the token the minimum permissions (scopes)
40
+ necessary for the extension to work, in this case, the `gists` scope.
41
+ Once you've got your token from Github, enter it in the
42
+ [jupyter_nbextensions_configurator](https://github.com/Jupyter-contrib/jupyter_nbextensions_configurator)
43
+ ui for it to be stored in the server config.
44
+
45
+
46
+ ### Full Github OAuth
47
+
48
+ Github's full OAuth authentication
49
+ (which would be required to make this extension useful for authenticating users
50
+ in a multi-notebook setup)
51
+ requires some server-side code.
52
+ There are some issues with implementing this directly (
53
+ essentially related to a secret which the App server must know, and for obvious
54
+ reasons can't be published as part of open-source code) as a Jupyter extension.
55
+ I ([@jcb91](https://github.com/jcb91)) started writing this `Gist it` extension
56
+ to work with a 3rd-party authentication app, but didn't finish it or test it,
57
+ so it's not functional at the moment.
58
+ If you'd like to have the full OAuth model, I'd be happy to help with any
59
+ attempt you make - drop me a line on Github.
.local/share/jupyter/nbextensions/help_panel/help_panel.js ADDED
@@ -0,0 +1,248 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Add help panel at right side of notebook window
2
+
3
+ define([
4
+ 'require',
5
+ 'jqueryui',
6
+ 'base/js/namespace',
7
+ 'base/js/events',
8
+ ], function (
9
+ requirejs,
10
+ $,
11
+ IPython,
12
+ events
13
+ ) {
14
+ 'use strict';
15
+
16
+ /**
17
+ * try to get bootstrap tooltip plugin.
18
+ * The require call may fail, since the plugin doesn't seem to be included
19
+ * in all Jupyter versions. In this case, we fallback to using jqueryui tooltips.
20
+ */
21
+ var have_bs_tooltips = false;
22
+ requirejs(
23
+ ['components/bootstrap/js/tooltip'],
24
+ // we don't actually need to do anything with the return
25
+ // just ensure that the plugin gets loaded.
26
+ function () { have_bs_tooltips = true; },
27
+ // The errback, error callback
28
+ // The error has a list of modules that failed
29
+ function (err) {
30
+ var failedId = err.requireModules && err.requireModules[0];
31
+ if (failedId === 'components/bootstrap/js/tooltip') {
32
+ // could do something here, like load a cdn version.
33
+ // For now, just ignore it.
34
+ have_bs_tooltips = false;
35
+ }
36
+ }
37
+ );
38
+
39
+ // define default values for config parameters
40
+ var params = {
41
+ help_panel_add_toolbar_button: false
42
+ };
43
+
44
+ // update params with any specified in the server's config file
45
+ function update_params () {
46
+ var config = IPython.notebook.config;
47
+ for (var key in params) {
48
+ if (config.data.hasOwnProperty(key))
49
+ params[key] = config.data[key];
50
+ }
51
+ }
52
+
53
+ var initialize = function () {
54
+ update_params();
55
+ if (params.help_panel_add_toolbar_button) {
56
+ $(IPython.toolbar.add_buttons_group([
57
+ IPython.keyboard_manager.actions.register({
58
+ help : 'Show help panel',
59
+ icon : 'fa-book',
60
+ handler: function() {
61
+ var visible = toggleHelpPanel();
62
+ var btn = $(this);
63
+ setTimeout(function() { btn.blur(); }, 500);
64
+ }
65
+ }, 'show-help-panel', 'help_panel'),
66
+ ])).find('.btn').attr({
67
+ id: 'btn_help_panel',
68
+ 'data-toggle': 'button',
69
+ 'aria-pressed': 'false'
70
+ });
71
+ }
72
+ };
73
+
74
+ var side_panel_min_rel_width = 10;
75
+ var side_panel_max_rel_width = 90;
76
+ var side_panel_start_width = 45;
77
+
78
+ var build_side_panel = function (main_panel, side_panel, min_rel_width, max_rel_width) {
79
+ if (min_rel_width === undefined) min_rel_width = 0;
80
+ if (max_rel_width === undefined) max_rel_width = 100;
81
+
82
+ side_panel.css('display','none');
83
+ side_panel.insertAfter(main_panel);
84
+
85
+ var side_panel_splitbar = $('<div class="side_panel_splitbar"/>');
86
+ var side_panel_inner = $('<div class="side_panel_inner"/>');
87
+ var side_panel_expand_contract = $('<i class="btn fa fa-expand hidden-print">');
88
+ side_panel.append(side_panel_splitbar);
89
+ side_panel.append(side_panel_inner);
90
+ side_panel_inner.append(side_panel_expand_contract);
91
+
92
+ side_panel_expand_contract.attr({
93
+ title: 'expand/contract panel',
94
+ 'data-toggle': 'tooltip'
95
+ }).tooltip({
96
+ placement: 'right'
97
+ }).click(function () {
98
+ var open = $(this).hasClass('fa-expand');
99
+ var site = $('#site');
100
+ slide_side_panel(main_panel, side_panel,
101
+ open ? 100 : side_panel.data('last_width') || side_panel_start_width);
102
+ $(this).toggleClass('fa-expand', !open).toggleClass('fa-compress', open);
103
+
104
+ var tooltip_text = (open ? 'shrink to not' : 'expand to') + ' fill the window';
105
+ if (open) {
106
+ side_panel.insertAfter(site);
107
+ site.slideUp();
108
+ $('#header').slideUp();
109
+ side_panel_inner.css({'margin-left': 0});
110
+ side_panel_splitbar.hide();
111
+ }
112
+ else {
113
+ side_panel.insertAfter(main_panel);
114
+ $('#header').slideDown();
115
+ site.slideDown({
116
+ complete: function() { events.trigger('resize-header.Page'); }
117
+ });
118
+ side_panel_inner.css({'margin-left': ''});
119
+ side_panel_splitbar.show();
120
+ }
121
+
122
+ if (have_bs_tooltips) {
123
+ side_panel_expand_contract.attr('title', tooltip_text);
124
+ side_panel_expand_contract.tooltip('hide').tooltip('fixTitle');
125
+ }
126
+ else {
127
+ side_panel_expand_contract.tooltip('option', 'content', tooltip_text);
128
+ }
129
+ });
130
+
131
+ // bind events for resizing side panel
132
+ side_panel_splitbar.mousedown(function (md_evt) {
133
+ md_evt.preventDefault();
134
+ $(document).mousemove(function (mm_evt) {
135
+ mm_evt.preventDefault();
136
+ var pix_w = side_panel.offset().left + side_panel.outerWidth() - mm_evt.pageX;
137
+ var rel_w = 100 * (pix_w) / side_panel.parent().width();
138
+ rel_w = rel_w > min_rel_width ? rel_w : min_rel_width;
139
+ rel_w = rel_w < max_rel_width ? rel_w : max_rel_width;
140
+ main_panel.css('width', (100 - rel_w) + '%');
141
+ side_panel.css('width', rel_w + '%').data('last_width', rel_w);
142
+ });
143
+ return false;
144
+ });
145
+ $(document).mouseup(function (mu_evt) {
146
+ $(document).unbind('mousemove');
147
+ });
148
+
149
+ return side_panel;
150
+ };
151
+
152
+ var slide_side_panel = function (main_panel, side_panel, desired_width) {
153
+
154
+ var anim_opts = {
155
+ step : function (now, tween) {
156
+ main_panel.css('width', 100 - now + '%');
157
+ }
158
+ };
159
+
160
+ if (desired_width === undefined) {
161
+ if (side_panel.is(':hidden')) {
162
+ desired_width = (side_panel.data('last_width') || side_panel_start_width);
163
+ }
164
+ else {
165
+ desired_width = 0;
166
+ }
167
+ }
168
+
169
+ var visible = desired_width > 0;
170
+ if (visible) {
171
+ main_panel.css({float: 'left', 'overflow-x': 'auto'});
172
+ side_panel.show();
173
+ }
174
+ else {
175
+ anim_opts['complete'] = function () {
176
+ side_panel.hide();
177
+ main_panel.css({float : '', 'overflow-x': '', width: ''});
178
+ };
179
+ }
180
+
181
+ side_panel.animate({width: desired_width + '%'}, anim_opts);
182
+ return visible;
183
+ };
184
+
185
+ var populate_side_panel = function(side_panel) {
186
+ var side_panel_inner = side_panel.find('.side_panel_inner');
187
+ var qh = IPython.quick_help;
188
+ var strip_modal = function(into) {
189
+ // strip qh modal, insert content into element 'into'
190
+ $('.quickhelp').closest('.modal-body').children().children().appendTo(into);
191
+ };
192
+
193
+ if ($('.quickhelp').length > 0) {
194
+ strip_modal(side_panel_inner);
195
+ }
196
+ else {
197
+ // ensure quickhelp shortcuts modal won't show
198
+ $('body').addClass('help_panel_hide');
199
+ // get quickhelp to show shortcuts
200
+ qh.show_keyboard_shortcuts();
201
+ // attach handler for qh showing shortcuts
202
+ var qh_dia = $(qh.shortcut_dialog);
203
+ qh_dia.on('shown.bs.modal', function(evt) {
204
+ strip_modal(side_panel_inner);
205
+ // delicately pretend that it was never shown, unbind handlers
206
+ qh_dia.on('hidden.bs.modal', function () {
207
+ $('body').removeClass('help_panel_hide');
208
+ qh_dia.off('hidden.bs.modal');
209
+ }).off('shown.bs.modal').modal("hide");
210
+ });
211
+ }
212
+ // make sure content we stripped will be rebuilt
213
+ qh.force_rebuild = true;
214
+ };
215
+
216
+ var toggleHelpPanel = function () {
217
+ var main_panel = $('#notebook_panel');
218
+ var side_panel = $('#side_panel');
219
+
220
+ if (side_panel.length < 1) {
221
+ side_panel = $('<div id="side_panel"/>');
222
+ build_side_panel(main_panel, side_panel,
223
+ side_panel_min_rel_width, side_panel_max_rel_width);
224
+ populate_side_panel(side_panel);
225
+ }
226
+
227
+ var visible = slide_side_panel(main_panel, side_panel);
228
+ if (params.help_panel_add_toolbar_button) {
229
+ $('#btn_help_panel').toggleClass('active', visible);
230
+ }
231
+ return visible;
232
+ };
233
+
234
+ var load_ipython_extension = function () {
235
+ $('head').append(
236
+ $('<link/>', {
237
+ rel: 'stylesheet',
238
+ type:'text/css',
239
+ href: requirejs.toUrl('./help_panel.css')
240
+ })
241
+ );
242
+ return IPython.notebook.config.loaded.then(initialize);
243
+ };
244
+
245
+ return {
246
+ load_ipython_extension : load_ipython_extension
247
+ };
248
+ });
.local/share/jupyter/nbextensions/help_panel/help_panel_ext_fullscreen.png ADDED
.local/share/jupyter/nbextensions/hide_header/README.md ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ Hide Header
2
+ ===========
3
+
4
+ Add keyboard shortcut to toggle the whole header, menubar and toolbar visibility.
.local/share/jupyter/nbextensions/hide_header/main.js ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ define([
2
+ 'base/js/namespace',
3
+ 'base/js/events'
4
+ ], function(
5
+ Jupyter,
6
+ events
7
+ ) {
8
+ // define default config parameter values
9
+ var params = {
10
+ header_toggle : 'ctrl-h',
11
+ };
12
+
13
+ // updates default params with any specified in the server's config
14
+ var update_params = function() {
15
+ var config = Jupyter.notebook.config;
16
+ for (var key in params){
17
+ if (config.data.hasOwnProperty(key) ){
18
+ params[key] = config.data[key];
19
+ }
20
+ }
21
+ };
22
+
23
+ var initialize = function () {
24
+ // update defaults
25
+ update_params();
26
+
27
+ // register action
28
+ var toggle_header = function (event) {
29
+ if (Jupyter.notebook.mode == 'command') {
30
+ $('#header').toggle();
31
+ $('div#site').toggleClass('noheader');
32
+ events.trigger('toggle-all-headers');
33
+ return false;
34
+ }
35
+ return true;
36
+ };
37
+
38
+ var action = {
39
+ icon: 'fa-gear',
40
+ help: 'Toggle All Headers',
41
+ help_index: 'zz',
42
+ handler: toggle_header,
43
+ };
44
+ var prefix = 'hide_header';
45
+ var action_name = 'toggle';
46
+
47
+ var full_action_name = Jupyter.keyboard_manager.actions.register(action, action_name, prefix);
48
+
49
+ // define keyboard shortcuts
50
+ var shortcuts = {};
51
+ shortcuts[params.header_toggle] = full_action_name;
52
+
53
+ // register keyboard shortcuts with keyboard_manager
54
+ Jupyter.notebook.keyboard_manager.command_shortcuts.add_shortcuts(shortcuts);
55
+ };
56
+
57
+ function load_ipython_extension() {
58
+ $("head").append(
59
+ '<style type="text/css"> .noheader { height: 100% !important }</style>');
60
+ return Jupyter.notebook.config.loaded.then(initialize);
61
+ }
62
+
63
+ return {
64
+ load_ipython_extension: load_ipython_extension
65
+ };
66
+ });
.local/share/jupyter/nbextensions/hide_input/icon.png ADDED
.local/share/jupyter/nbextensions/hide_input/main.js ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // Adds a button to hide the input part of the currently selected cells
2
+
3
+ define([
4
+ 'jquery',
5
+ 'base/js/namespace',
6
+ 'base/js/events'
7
+ ], function(
8
+ $,
9
+ Jupyter,
10
+ events
11
+ ) {
12
+ "use strict";
13
+
14
+ var toggle_selected_input = function () {
15
+ // Find the selected cell
16
+ var cell = Jupyter.notebook.get_selected_cell();
17
+ // Toggle visibility of the input div
18
+ cell.element.find("div.input").toggle('slow');
19
+ cell.metadata.hide_input = ! cell.metadata.hide_input;
20
+ };
21
+
22
+ var update_input_visibility = function () {
23
+ Jupyter.notebook.get_cells().forEach(function(cell) {
24
+ if (cell.metadata.hide_input) {
25
+ cell.element.find("div.input").hide();
26
+ }
27
+ })
28
+ };
29
+
30
+ var load_ipython_extension = function() {
31
+
32
+ // Add a button to the toolbar
33
+ $(Jupyter.toolbar.add_buttons_group([
34
+ Jupyter.keyboard_manager.actions.register({
35
+ help : 'Toggle selected cell input display',
36
+ icon : 'fa-chevron-up',
37
+ handler: function() {
38
+ toggle_selected_input();
39
+ setTimeout(function() { $('#btn-hide-input').blur(); }, 500);
40
+ }
41
+ }, 'toggle-cell-input-display', 'hide_input')
42
+ ])).find('.btn').attr('id', 'btn-hide-input');
43
+ // Collapse all cells that are marked as hidden
44
+ if (Jupyter.notebook !== undefined && Jupyter.notebook._fully_loaded) {
45
+ // notebook already loaded. Update directly
46
+ update_input_visibility();
47
+ }
48
+ events.on("notebook_loaded.Notebook", update_input_visibility);
49
+ };
50
+
51
+ return {
52
+ load_ipython_extension : load_ipython_extension
53
+ };
54
+ });
.local/share/jupyter/nbextensions/keyboard_shortcut_editor/readme_comma.png ADDED
.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.yaml ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Type: Jupyter Notebook Extension
2
+ Name: Select CodeMirror Keymap
3
+ Link: README.md
4
+ Description: "A little extension to choose between CodeMirror keymaps: default, emacs, vim, and sublime"
5
+ Main: main.js
6
+ Compatibility: 4.x, 5.x
7
+ Parameters:
8
+ - name: select_keymap_line_wrap
9
+ description: Enable line wrap in CodeMirror
10
+ input_type: checkbox
11
+ default: true
12
+ - name: select_keymap_local_storage
13
+ description: Store keymap selection on the client instead of server config
14
+ input_type: checkbox
15
+ default: true
.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/snippets/snippets-demo.gif ADDED
.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/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/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/snippets_submenus_python/python.js ADDED
@@ -0,0 +1,209 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ define([
2
+ "require",
3
+ "./python_regex",
4
+ ], function (requirejs, python_regex) {
5
+ return {
6
+ 'name' : 'Python',
7
+ 'sub-menu' : [
8
+ {
9
+ 'name' : 'Setup',
10
+ 'snippet' : ['from __future__ import print_function, division',],
11
+ },
12
+ {
13
+ 'name' : 'Documentation',
14
+ 'external-link' : 'https://docs.python.org/',
15
+ },
16
+ '---',
17
+
18
+ {
19
+ 'name' : 'Lists',
20
+ 'sub-menu' : [
21
+ {
22
+ 'name' : 'List comprehension',
23
+ 'snippet' : ['[x**2 for x in range(-10, 11)]',],
24
+ },
25
+ {
26
+ 'name' : 'Conditional list comprehension',
27
+ 'snippet' : ['[x**2 for x in range(-10, 11) if (x%3)==0]',],
28
+ },
29
+ {
30
+ 'name' : 'Conditional alternative list comprehension',
31
+ 'snippet' : ['[x**2 if (x%3)==0 else x**3 for x in range(-10, 11)]',],
32
+ },
33
+ {
34
+ 'name' : 'Reversed list',
35
+ 'snippet' : ['reversed(l)'],
36
+ },
37
+ {
38
+ 'name' : 'Sorted list',
39
+ 'snippet' : ['sorted(l)'],
40
+ },
41
+ {
42
+ 'name' : 'Sort two lists at the same time',
43
+ 'snippet' : ['x, y = [list(tmp) for tmp in zip(*sorted(zip(x,y), key=lambda pair: pair[0]))]'],
44
+ },
45
+ ],
46
+ },
47
+
48
+ {
49
+ 'name' : 'Basic file input/output',
50
+ 'sub-menu' : [
51
+ {
52
+ 'name' : 'Read file into string',
53
+ 'snippet' : [
54
+ 'with open("some/file.txt", "r") as file_handle:',
55
+ ' file_contents = file_handle.read()',
56
+ ],
57
+ },
58
+ {
59
+ 'name' : 'Read file into string, operating on each line',
60
+ 'snippet' : [
61
+ 'file_contents = ""',
62
+ 'with open("some/file.txt", "r") as file_handle:',
63
+ ' for line in file_handle.readlines():',
64
+ ' file_contents += line.replace("-", "_")',
65
+ ],
66
+ }
67
+ ],
68
+ },
69
+
70
+ {
71
+ 'name' : 'Defining functions',
72
+ 'sub-menu' : [
73
+ {
74
+ 'name' : 'Simple function',
75
+ 'snippet' : [
76
+ 'def bp_some_func(x):',
77
+ ' r"""Brief description of the function"""',
78
+ ' return x**2',
79
+ ],
80
+ },
81
+ {
82
+ 'name' : 'Complicated function',
83
+ 'snippet' : [
84
+ 'def bp_some_func(x, y, z=3.14, **kwargs):',
85
+ ' r"""Some function',
86
+ ' ',
87
+ ' Does some stuff.',
88
+ ' ',
89
+ ' Parameters',
90
+ ' ----------',
91
+ ' x : int',
92
+ ' Description of x',
93
+ ' y : str',
94
+ ' Description of y',
95
+ ' z : float, optional',
96
+ ' Description of z. Defaults to 3.14',
97
+ ' **kwargs',
98
+ ' Arbitrary optional keyword arguments.',
99
+ ' w : float',
100
+ ' Defaults to 6.28',
101
+ ' ',
102
+ ' Returns',
103
+ ' -------',
104
+ ' double',
105
+ ' Some nonsensical number computed from some ugly formula',
106
+ ' ',
107
+ ' """',
108
+ ' w = kwargs.pop("w", 6.28)',
109
+ ' if kwargs:',
110
+ ' print("Got {0} unused kwargs".format(len(kwargs)))',
111
+ ' return (x**2 + len(y)) * (w + z)',
112
+ ],
113
+ },
114
+ ],
115
+ },
116
+
117
+ {
118
+ 'name' : 'Defining classes',
119
+ 'sub-menu' : [
120
+ {
121
+ 'name' : 'Simple class',
122
+ 'snippet' : [
123
+ 'class BPSomeClass(object):',
124
+ ' r"""Describe the class"""',
125
+ ' def __init__(self, arg1, arg2):',
126
+ ' self.attr1 = arg1',
127
+ ' self.attr2 = arg2',
128
+ ' ',
129
+ ' def attribute1(self):',
130
+ ' return self.attr1',
131
+ 'bp_obj = BPSomeClass("a", 2.7182)',
132
+ 'bp_obj.attribute1()',
133
+ ],
134
+ },
135
+ {
136
+ 'name' : 'Complicated class',
137
+ 'snippet' : [
138
+ 'class BPSomeClass(object):',
139
+ ' """Brief class description',
140
+ ' ',
141
+ ' Some more extensive description',
142
+ ' ',
143
+ ' Attributes',
144
+ ' ----------',
145
+ ' attr1 : string',
146
+ ' Purpose of attr1.',
147
+ ' attr2 : float',
148
+ ' Purpose of attr2.',
149
+ ' ',
150
+ ' """',
151
+ ' ',
152
+ ' def __init__(self, param1, param2, param3=0):',
153
+ ' """Example of docstring on the __init__ method.',
154
+ ' ',
155
+ ' Parameters',
156
+ ' ----------',
157
+ ' param1 : str',
158
+ ' Description of `param1`.',
159
+ ' param2 : float',
160
+ ' Description of `param2`.',
161
+ ' param3 : int, optional',
162
+ ' Description of `param3`, defaults to 0.',
163
+ ' ',
164
+ ' """',
165
+ ' self.attr1 = param1',
166
+ ' self.attr2 = param2',
167
+ ' print(param3 // 4)',
168
+ ' ',
169
+ ' @property',
170
+ ' def attribute2(self):',
171
+ ' return self.attr2',
172
+ ' ',
173
+ ' @attribute2.setter',
174
+ ' def attribute2(self, new_attr2):',
175
+ ' if not isinstance(float, new_attr2):',
176
+ ' raise ValueError("attribute2 must be a float, not {0}".format(new_attr2))',
177
+ ' self.attr2 = new_attr2',
178
+ '',
179
+ '',
180
+ 'bp_obj = BPSomeClass("a", 1.618)',
181
+ 'print(bp_obj.attribute2)',
182
+ 'bp_obj.attribute2 = 3.236',
183
+ '',
184
+ ],
185
+ },
186
+ {
187
+ 'name' : 'Subclass',
188
+ 'snippet' : [
189
+ 'class BP_A(object):',
190
+ ' def __init__(self, param1):',
191
+ ' self.attr1 = param1',
192
+ '',
193
+ 'class BP_B(BP_A):',
194
+ ' def __init__(self, param1, param2):',
195
+ ' super(BP_B, self).__init__(param1)',
196
+ ' self.attr2 = param2',
197
+ '',
198
+ '',
199
+ 'bp_b = BP_B("a", "b")',
200
+ 'print(bp_b.attr1, bp_b.attr2)',
201
+ ],
202
+ },
203
+ ],
204
+ },
205
+
206
+ python_regex,
207
+ ],
208
+ };
209
+ });
.local/share/jupyter/nbextensions/snippets_menu/snippets_submenus_python/python_regex.js ADDED
@@ -0,0 +1,309 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ define({
2
+ 'name' : 'Regular expressions',
3
+ 'sub-menu' : [
4
+ {
5
+ 'name' : 'Setup',
6
+ 'snippet' : [
7
+ 'import re',
8
+ ],
9
+ },
10
+ '---',
11
+ {
12
+ 'name' : 'Basic search for pattern anywhere in string',
13
+ 'snippet' : [
14
+ 'string = " abc def "',
15
+ 'pattern = re.compile(r"[a-z]+")',
16
+ 'result = re.search(pattern, string)',
17
+ 'if result is not None:',
18
+ ' print("Substring \'{0}\' was found in the range {1}".format(result.group(), result.span()))',
19
+ ],
20
+ },
21
+ {
22
+ 'name' : 'Basic search (match) for exact pattern at beginning of string',
23
+ 'snippet' : [
24
+ 'string = " abc def "',
25
+ 'pattern = re.compile(r".*[a-z]+")',
26
+ 'result = re.match(pattern, string)',
27
+ 'if result is not None:',
28
+ ' print("Substring \'{0}\' was found in the range {1}".format(result.group(), result.span()))',
29
+ ],
30
+ },
31
+ {
32
+ 'name' : 'Basic substitution',
33
+ 'snippet' : [
34
+ 'string = " abc def "',
35
+ 'pattern = re.compile(r"[a-z]+")',
36
+ 'new_string = re.sub(pattern, "something", string)',
37
+ 'print("New string is \'{0}\'".format(new_string))',
38
+ ],
39
+ },
40
+ {
41
+ 'name' : 'Substitution with backreferences',
42
+ 'snippet' : [
43
+ 'string = "John Doe lives at 221B Baker Street."',
44
+ 'pattern = re.compile(r"""',
45
+ ' ([a-zA-Z ]+) # Save as many letters and spaces as possible to group 1',
46
+ ' \\ lives\\ at\\ # Match " lives at "',
47
+ ' (?P<address>.*) # Save everything in between as a group named `address`',
48
+ ' \\. # Match the period at the end',
49
+ '""", re.VERBOSE)',
50
+ 'new_string = re.sub(pattern, r"\\g<address> is occupied by \\1.", string)',
51
+ 'print("New string is \'{0}\'".format(new_string))',
52
+ ],
53
+ },
54
+ '---',
55
+ {
56
+ 'name' : 'Escaped special characters',
57
+ 'sub-menu' : [
58
+ {
59
+ 'name' : '.',
60
+ 'snippet' : ['\\.',],
61
+ },
62
+ {
63
+ 'name' : '^',
64
+ 'snippet' : ['\\^',],
65
+ },
66
+ {
67
+ 'name' : '$',
68
+ 'snippet' : ['\\$',],
69
+ },
70
+ {
71
+ 'name' : '*',
72
+ 'snippet' : ['\\*',],
73
+ },
74
+ {
75
+ 'name' : '+',
76
+ 'snippet' : ['\\+',],
77
+ },
78
+ {
79
+ 'name' : '?',
80
+ 'snippet' : ['\\?',],
81
+ },
82
+ {
83
+ 'name' : '{',
84
+ 'snippet' : ['\\{',],
85
+ },
86
+ {
87
+ 'name' : '}',
88
+ 'snippet' : ['\\}',],
89
+ },
90
+ {
91
+ 'name' : '[',
92
+ 'snippet' : ['\\[',],
93
+ },
94
+ {
95
+ 'name' : ']',
96
+ 'snippet' : ['\\]',],
97
+ },
98
+ {
99
+ 'name' : '\\',
100
+ 'snippet' : ['\\\\',],
101
+ },
102
+ {
103
+ 'name' : '|',
104
+ 'snippet' : ['\\|',],
105
+ },
106
+ {
107
+ 'name' : '(',
108
+ 'snippet' : ['\\(',],
109
+ },
110
+ {
111
+ 'name' : ')',
112
+ 'snippet' : ['\\)',],
113
+ },
114
+ ],
115
+ },
116
+
117
+ {
118
+ 'name' : 'Character classes and alternatives',
119
+ 'sub-menu' : [
120
+ {
121
+ 'name' : 'Standard character-class abbreviations',
122
+ 'sub-menu' : [
123
+ {
124
+ 'name' : 'Any decimal digit',
125
+ 'snippet' : ['\\d',],
126
+ },
127
+ {
128
+ 'name' : 'Any non-digit character',
129
+ 'snippet' : ['\\D',],
130
+ },
131
+ {
132
+ 'name' : 'Any whitespace character',
133
+ 'snippet' : ['\\s',],
134
+ },
135
+ {
136
+ 'name' : 'Any non-whitespace character',
137
+ 'snippet' : ['\\S',],
138
+ },
139
+ {
140
+ 'name' : 'Any alphanumeric character',
141
+ 'snippet' : ['\\w',],
142
+ },
143
+ {
144
+ 'name' : 'Any non-alphanumeric character',
145
+ 'snippet' : ['\\W',],
146
+ },
147
+ ],
148
+ },
149
+ {
150
+ 'name' : 'Inclusive character classes',
151
+ 'snippet' : [
152
+ '[a-zA-Z0-9 \\t\\n\\r\\f\\v]',
153
+ ],
154
+ },
155
+ {
156
+ 'name' : 'Exclusive character classes',
157
+ 'snippet' : [
158
+ '[^a-zA-Z0-9]',
159
+ ],
160
+ },
161
+ {
162
+ 'name' : 'Alternatives',
163
+ 'snippet' : [
164
+ '(?:abc|def)',
165
+ ],
166
+ },
167
+
168
+ ],
169
+ },
170
+
171
+ {
172
+ 'name' : 'Repetition',
173
+ 'sub-menu' : [
174
+ {
175
+ 'name' : 'Match 0 or more repetitions of the preceding, greedily',
176
+ 'snippet' : ['*',],
177
+ },
178
+ {
179
+ 'name' : 'Match 1 or more repetitions of the preceding, greedily',
180
+ 'snippet' : ['+',],
181
+ },
182
+ {
183
+ 'name' : 'Match 0 or 1 repetitions of the preceding, greedily',
184
+ 'snippet' : ['?',],
185
+ },
186
+ '---',
187
+ {
188
+ 'name' : 'Match 0 or more repetitions of the preceding, non-greedily',
189
+ 'snippet' : ['*?',],
190
+ },
191
+ {
192
+ 'name' : 'Match 1 or more repetitions of the preceding, non-greedily',
193
+ 'snippet' : ['+?',],
194
+ },
195
+ {
196
+ 'name' : 'Match 0 or 1 repetitions of the preceding, non-greedily',
197
+ 'snippet' : ['??',],
198
+ },
199
+ '---',
200
+ {
201
+ 'name' : 'Match exactly n repeititions of the preceding',
202
+ 'snippet' : ['{3}',],
203
+ },
204
+ {
205
+ 'name' : 'Match between m and n repetions of the preceding, greedily',
206
+ 'snippet' : ['{3,5}',],
207
+ },
208
+ {
209
+ 'name' : 'Match between m and n repetions of the preceding, non-greedily',
210
+ 'snippet' : ['{3,5}?',],
211
+ },
212
+ ],
213
+ },
214
+
215
+ // {
216
+ // 'name' : '',
217
+ // 'sub-menu' : [
218
+
219
+ // ],
220
+ // },
221
+
222
+ // {
223
+ // 'name' : '',
224
+ // 'sub-menu' : [
225
+
226
+ // ],
227
+ // },
228
+
229
+ {
230
+ 'name' : 'Lookahead/behind',
231
+ 'sub-menu' : [
232
+ {
233
+ 'name' : 'Positive lookahead',
234
+ 'snippet' : [
235
+ 'string = "Isaac Asimov"',
236
+ 'pattern = re.compile(r"Isaac(?= Asimov)") # Only match "Isaac Asimov", but drop the " Asimov"',
237
+ 'result = re.match(pattern, string)',
238
+ 'if result is not None:',
239
+ ' print("Substring \'{0}\' was found in the range {1}".format(result.group(), result.span()))',
240
+ ],
241
+ },
242
+ {
243
+ 'name' : 'Negative lookahead',
244
+ 'snippet' : [
245
+ 'string = "Isaac Newton"',
246
+ 'pattern = re.compile(r"Isaac(?! Asimov)") # Match any Isaac except Asimov, and only keep the "Isaac"',
247
+ 'result = re.match(pattern, string)',
248
+ 'if result is not None:',
249
+ ' print("Substring \'{0}\' was found in the range {1}".format(result.group(), result.span()))',
250
+ ],
251
+ },
252
+ {
253
+ 'name' : 'Positive lookbehind',
254
+ 'snippet' : [
255
+ 'string = "Janet Asimov"',
256
+ 'pattern = re.compile(r"(?<=Janet )Asimov") # Only match "Janet Asimov", but drop the "Janet "',
257
+ 'result = re.search(pattern, string)',
258
+ 'if result is not None:',
259
+ ' print("Substring \'{0}\' was found in the range {1}".format(result.group(), result.span()))',
260
+ ],
261
+ },
262
+ {
263
+ 'name' : 'Negative lookbehind',
264
+ 'snippet' : [
265
+ 'string = "Janet Asimov"',
266
+ 'pattern = re.compile(r"(?<!Isaac )Asimov") # Will match any Asimov except Isaac, and only keep "Asimov"',
267
+ 'result = re.search(pattern, string)',
268
+ 'if result is not None:',
269
+ ' print("Substring \'{0}\' was found in the range {1}".format(result.group(), result.span()))',
270
+ ],
271
+ },
272
+ ],
273
+ },
274
+
275
+ {
276
+ 'name' : 'Compilation flags',
277
+ 'sub-menu' : [
278
+ {
279
+ 'name' : 'Enable verbose REs, for cleaner and more organized code',
280
+ 'snippet' : ['re.VERBOSE',],
281
+ },
282
+ {
283
+ 'name' : 'Do case-insensitive matches',
284
+ 'snippet' : ['re.IGNORECASE',],
285
+ },
286
+ {
287
+ 'name' : 'Make "." match any character, including newlines',
288
+ 'snippet' : ['re.DOTALL',],
289
+ },
290
+ {
291
+ 'name' : 'Multi-line matching, affecting "^" and "$"',
292
+ 'snippet' : ['re.MULTILINE',],
293
+ },
294
+ {
295
+ 'name' : 'Make \\w, \\W, \\b, \\B, \\s, and \\S Unicode aware',
296
+ 'snippet' : ['re.UNICODE',],
297
+ },
298
+ {
299
+ 'name' : 'Make \\w, \\W, \\b, \\B, \\s, and \\S dependent on the current locale',
300
+ 'snippet' : ['re.LOCALE',],
301
+ },
302
+ {
303
+ 'name' : 'Display debug info about compiled regex',
304
+ 'snippet' : ['re.DEBUG',],
305
+ },
306
+ ],
307
+ },
308
+ ],
309
+ });
.local/share/jupyter/nbextensions/snippets_menu/snippets_submenus_python/sympy.js ADDED
@@ -0,0 +1,750 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ define([
2
+ "require",
3
+ "./sympy_functions",
4
+ "./sympy_assumptions",
5
+ ], function (requirejs, sympy_functions, sympy_assumptions) {
6
+ return {
7
+ 'name' : 'SymPy',
8
+ 'sub-menu' : [
9
+ {
10
+ 'name' : 'Setup',
11
+ 'snippet' : [
12
+ 'from __future__ import print_function, division',
13
+ 'from sympy import *',
14
+ 'a, s, t, u, v, w, x, y, z = symbols("a, s, t, u, v, w, x, y, z")',
15
+ 'k, m, n = symbols("k, m, n", integer=True)',
16
+ 'f, g, h = symbols("f, g, h", cls=Function)',
17
+ 'init_printing()',
18
+ ],
19
+ },
20
+ {
21
+ 'name' : 'Documentation',
22
+ 'external-link' : 'http://docs.sympy.org/latest/index.html',
23
+ },
24
+ '---',
25
+ {
26
+ 'name' : 'Constants',
27
+ 'sub-menu' : [
28
+ {
29
+ 'name' : '1',
30
+ 'snippet' : ['S(1)',], //'S.One',],
31
+ },
32
+ // {
33
+ // 'name' : '0',
34
+ // 'snippet' : ['S.Zero',],
35
+ // },
36
+ // {
37
+ // 'name' : '-1',
38
+ // 'snippet' : ['S.NegativeOne',],
39
+ // },
40
+ {
41
+ 'name' : '1/2',
42
+ 'snippet' : ['S(1)/2',], //'S.Half',],
43
+ },
44
+ {
45
+ 'name' : 'Rational numbers',
46
+ 'snippet' : ['Rational(3, 7)',],
47
+ },
48
+ '---',
49
+ {
50
+ 'name' : 'Base of natural logarithm, \\(e\\)',
51
+ 'snippet' : ['E',],
52
+ },
53
+ {
54
+ 'name' : 'Unit imaginary number, \\(i\\)',
55
+ 'snippet' : ['I',],
56
+ },
57
+ {
58
+ 'name' : 'Geometric constant, \\(\\pi\\)',
59
+ 'snippet' : ['pi',],
60
+ },
61
+ {
62
+ 'name' : 'Golden ratio, \\(\\phi\\)',
63
+ 'snippet' : ['GoldenRatio',],
64
+ },
65
+ {
66
+ 'name' : 'Euler-Mascheroni constant, \\(\\gamma\\)',
67
+ 'snippet' : ['EulerGamma',],
68
+ },
69
+ {
70
+ 'name' : 'Catalan\'s constant, \\(K\\)',
71
+ 'snippet' : ['Catalan',],
72
+ },
73
+ '---',
74
+ {
75
+ 'name' : 'Infinity, \\(\\infty\\)',
76
+ 'snippet' : ['oo',], // 'S.Infinity'
77
+ },
78
+ // {
79
+ // 'name' : 'Negative infinity, \\(-\\infty\\)',
80
+ // 'snippet' : ['S.NegativeInfinity',],
81
+ // },
82
+ {
83
+ 'name' : 'Complex infinity, \\(\\tilde{\\infty}\\)',
84
+ 'snippet' : ['zoo'], //'S.ComplexInfinity',],
85
+ },
86
+ {
87
+ 'name' : 'NaN',
88
+ 'snippet' : ['nan',], // 'S.NaN'
89
+ },
90
+ ],
91
+ },
92
+ sympy_functions,
93
+ {
94
+ 'name' : 'Calculus',
95
+ 'sub-menu' : [
96
+ {
97
+ 'name' : 'Differentiate once',
98
+ 'snippet' : [
99
+ 'expr = exp(x**2)',
100
+ 'deriv = diff(expr, x)',
101
+ ],
102
+ },
103
+ {
104
+ 'name' : 'Differentiate multiple times',
105
+ 'snippet' : [
106
+ 'expr = x**4',
107
+ 'deriv = diff(expr, x, 3)',
108
+ ],
109
+ },
110
+ {
111
+ 'name' : 'Mixed partial derivatives',
112
+ 'snippet' : [
113
+ 'expr = exp(x*y*z)',
114
+ 'deriv = diff(expr, x, y, 2, z, 4)',
115
+ ],
116
+ },
117
+ {
118
+ 'name' : 'Finite differences',
119
+ 'snippet' : [
120
+ 'dx0, dx1 = symbols("dx0, dx1")',
121
+ 'formula = as_finite_diff(f(x).diff(x), [x-dx0, x, x+dx1])',
122
+ ],
123
+ },
124
+ '---',
125
+ {
126
+ 'name' : 'Indefinite integral',
127
+ 'snippet' : [
128
+ 'integral = integrate(cos(x), x)',
129
+ ],
130
+ },
131
+ {
132
+ 'name' : 'Definite integral',
133
+ 'snippet' : [
134
+ 'integral = integrate(exp(-x), (x, 0, oo))',
135
+ ],
136
+ },
137
+ {
138
+ 'name' : 'Double integral',
139
+ 'snippet' : [
140
+ 'integral = integrate(exp(-x**2-y**2), (x, -oo, oo), (y, -oo, oo))',
141
+ ],
142
+ },
143
+ '---',
144
+ {
145
+ 'name' : 'Limits',
146
+ 'snippet' : [
147
+ 'lim = limit(sin(x)/x, x, 0, "+")',
148
+ ],
149
+ },
150
+ {
151
+ 'name' : 'Series expansion',
152
+ 'snippet' : [
153
+ 'expr = exp(sin(x))',
154
+ 'ser = series(expr, x, 0, 6)',
155
+ ],
156
+ },
157
+ {
158
+ 'name' : 'Series expansion, removing order term',
159
+ 'snippet' : [
160
+ 'expr = exp(sin(x))',
161
+ 'ser = series(expr, x, 0, 6).removeO()',
162
+ ],
163
+ },
164
+ {
165
+ 'name' : 'Summations',
166
+ 'snippet' : [
167
+ 'ell_min,ell,ell_max = symbols("ell_min,ell,ell_max", integer=True)',
168
+ 'summ = summation((2*ell + 1), (ell, ell_min, ell_max))',
169
+ ],
170
+ },
171
+ ],
172
+ },
173
+
174
+ {
175
+ 'name' : 'Solvers',
176
+ 'sub-menu' : [
177
+ {
178
+ 'name' : 'Solve for one variable',
179
+ 'snippet' : [
180
+ 'expr = x**4 - 4*x**3 + 2*x**2 - x',
181
+ 'eqn = Eq(expr, 0)',
182
+ 'soln = solve(eqn, x)',
183
+ ],
184
+ },
185
+ {
186
+ 'name' : 'Solve for two variables',
187
+ 'snippet' : [
188
+ 'eqns = Eq(x + y, 4), Eq(x*y, 3)',
189
+ 'soln = solve(eqns, [x,y])',
190
+ ],
191
+ },
192
+ {
193
+ 'name' : 'Solve differential equation',
194
+ 'snippet' : [
195
+ 'expr = f(x).diff(x, x) + 9*f(x)',
196
+ "eqn = Eq(expr, 1) # f''(x) + 9f(x) = 1",
197
+ 'soln = dsolve(eqn, f(x))',
198
+ ],
199
+ },
200
+ ],
201
+ },
202
+ {
203
+ 'name' : 'Manipulating expressions',
204
+ 'sub-menu' : [
205
+ {
206
+ 'name' : 'Simplify',
207
+ 'snippet' : [
208
+ 'expr = (x**3 + x**2 - x - 1)/(x**2 + 2*x + 1)',
209
+ 'expr = simplify(expr)',
210
+ ],
211
+ },
212
+ {
213
+ 'name' : 'Refine, using assumptions',
214
+ // 'snippet' : [
215
+ // 'expr = exp(pi*I*2*x)',
216
+ // 'assumption = Q.integer(x) & Q.integer(y)',
217
+ // 'expr = refine(expr, assumption)',
218
+ // ],
219
+ 'sub-menu' : [
220
+ {
221
+ 'name' : 'Refine',
222
+ 'snippet' : [
223
+ 'expr = exp(pi*I*2*(x+y))',
224
+ 'assumption = Q.integer(x) & Q.integer(y)',
225
+ 'expr = refine(expr, assumption)',
226
+ ],
227
+ },
228
+ {
229
+ 'name' : 'Refine in context manager',
230
+ 'snippet' : [
231
+ 'expr = exp(pi*I*2*(x+y))',
232
+ 'with assuming(Q.integer(x) & Q.integer(y)):',
233
+ ' expr = refine(expr)',
234
+ ],
235
+ },
236
+ sympy_assumptions,
237
+ ],
238
+ },
239
+ {
240
+ 'name' : 'Expansion',
241
+ 'sub-menu' : [
242
+ {
243
+ 'name' : 'Expand basic expressions',
244
+ 'snippet' : [
245
+ 'expr = (x + 2)*(x - 3)',
246
+ 'expr = expand(expr)',
247
+ ],
248
+ },
249
+ '---',
250
+ {
251
+ 'name' : 'Expand, including complex parts',
252
+ 'snippet' : [
253
+ 'expr = cos(x)',
254
+ 'expr = expand(expr, complex=True)',
255
+ ],
256
+ },
257
+ {
258
+ 'name' : 'Expand, including functions',
259
+ 'snippet' : [
260
+ 'expr = gamma(x+3)',
261
+ 'expr = expand(expr, func=True)',
262
+ ],
263
+ },
264
+ {
265
+ 'name' : 'Expand, including trig',
266
+ 'snippet' : [
267
+ 'expr = sin(x+y)*(x+y)',
268
+ 'expr = expand(expr, trig=True)',
269
+ ],
270
+ },
271
+ '---',
272
+ {
273
+ 'name' : 'Expand only real and imaginary parts',
274
+ 'snippet' : [
275
+ 'expand_complex(x)',
276
+ ],
277
+ },
278
+ {
279
+ 'name' : 'Expand only functions',
280
+ 'snippet' : [
281
+ 'expr = gamma(x + 2)',
282
+ 'expr = expand_func(expr)',
283
+ ],
284
+ },
285
+ {
286
+ 'name' : 'Expand only hypergeometric functions',
287
+ 'snippet' : [
288
+ 'expr = hyper([1,1], [1,], z) + gamma(z)',
289
+ 'expr = hyperexpand(expr)',
290
+ ],
291
+ },
292
+ {
293
+ 'name' : 'Expand only logarithms',
294
+ 'snippet' : [
295
+ 'a, b = symbols("a, b", positive=True)',
296
+ 'expr = log(a**2*b)',
297
+ 'expr = expand_log(expr)',
298
+ ],
299
+ },
300
+ {
301
+ 'name' : 'Expand only multiplication over addition',
302
+ 'snippet' : [
303
+ 'expr = y*(x + z)',
304
+ 'expr = expand_mul(expr)',
305
+ ],
306
+ },
307
+ {
308
+ 'name' : 'Expand only multinomials',
309
+ 'snippet' : [
310
+ 'expr = (x + y + z)**3',
311
+ 'expr = expand_multinomial(expr)',
312
+ ],
313
+ },
314
+ {
315
+ 'name' : 'Expand only powers of multiplied bases',
316
+ 'snippet' : [
317
+ 'a, b = symbols("a, b", positive=True)',
318
+ 'expr = (a*b)**z',
319
+ 'expr = expand_power_base(expr)',
320
+ ],
321
+ },
322
+ {
323
+ 'name' : 'Expand only addition in exponents',
324
+ 'snippet' : [
325
+ 'expr = x**(y + 2)',
326
+ 'expr = expand_power_exp(expr)',
327
+ ],
328
+ },
329
+ {
330
+ 'name' : 'Expand only trig',
331
+ 'snippet' : [
332
+ 'expr = sin(x+y)*(x+y)',
333
+ 'expr = expand_trig(expr)',
334
+ ],
335
+ },
336
+ ],
337
+ },
338
+ {
339
+ 'name' : 'Collect terms',
340
+ 'sub-menu' : [
341
+ {
342
+ 'name' : 'Collect as coefficients of one factor',
343
+ 'snippet' : [
344
+ 'expr = y*x**2 + z*x**2 + t*x - 2*x + 3',
345
+ 'expr = collect(expr, x)',
346
+ ],
347
+ },
348
+ {
349
+ 'name' : 'Collect as coefficients of multiple factors',
350
+ 'snippet' : [
351
+ 'expr = x**2 + y*x**2 + x*y + y + z*y',
352
+ 'expr = collect(expr, [x, y])',
353
+ ],
354
+ },
355
+ {
356
+ 'name' : 'Collect with respect to wild card',
357
+ 'snippet' : [
358
+ 'w = Wild("w")',
359
+ 'expr = z*x**y - t*z**y',
360
+ 'expr = collect(expr, w**y)',
361
+ ],
362
+ },
363
+ {
364
+ 'name' : 'Collect and apply function to each coefficient',
365
+ 'snippet' : [
366
+ 'expr = expand((x + y + 1)**3)',
367
+ 'expr = collect(expr, x, factor)',
368
+ ],
369
+ },
370
+ {
371
+ 'name' : 'Recursively collect',
372
+ 'snippet' : [
373
+ 'expr = (x**2*y + x*y + x + y)/(x*y + z*y)',
374
+ 'expr = rcollect(expr, y)',
375
+ ],
376
+ },
377
+ {
378
+ 'name' : 'Collect constants',
379
+ 'snippet' : [
380
+ 'expr = sqrt(3)*x + sqrt(7)*x + sqrt(3) + sqrt(7)',
381
+ 'expr = collect_const(expr)',
382
+ ],
383
+ },
384
+ ],
385
+ },
386
+ {
387
+ 'name' : 'Substitutions and replacements',
388
+ 'sub-menu' : [
389
+ {
390
+ 'name' : 'Substitute one subexpression for another',
391
+ 'snippet' : [
392
+ 'expr = 1 + x*y',
393
+ 'expr = expr.subs(x, pi)',
394
+ ],
395
+ },
396
+ {
397
+ 'name' : 'Substitute multiple subexpressions successively',
398
+ 'snippet' : [
399
+ 'expr = (x+y)/y',
400
+ 'substitutions = [(x+y, y), (y, x+y)]',
401
+ 'expr = expr.subs(substitutions)',
402
+ ],
403
+ },
404
+ {
405
+ 'name' : 'Substitute multiple subexpressions simultaneously',
406
+ 'snippet' : [
407
+ 'expr = (x+y)/y',
408
+ 'substitutions = [(x+y, y), (y, x+y)]',
409
+ 'expr = expr.subs(substitutions, simultaneous=True)',
410
+ ],
411
+ },
412
+ '---',
413
+ {
414
+ 'name' : 'Replace one object with another',
415
+ 'snippet' : [
416
+ 'expr = 1 + x*y',
417
+ 'expr = expr.replace(x, pi)',
418
+ ],
419
+ },
420
+ {
421
+ 'name' : 'Replace one object with some function of its arguments',
422
+ 'snippet' : [
423
+ 'expr = log(sin(x)) + tan(sin(x**2))',
424
+ 'expr = expr.replace(sin, lambda arg: sin(2*arg))',
425
+ ],
426
+ },
427
+ {
428
+ 'name' : 'Replace a pattern with an object',
429
+ 'snippet' : [
430
+ '# Note: `exclude=` specifies that the Wild cannot match any item in the list',
431
+ 'a, b = symbols("a, b", cls=Wild, exclude=[x,y])',
432
+ 'expr = 2*x + y + z',
433
+ 'wild = a*x + b',
434
+ 'replacement = b - a',
435
+ '# Note: `exact=True` demands that all Wilds have nonzero matches',
436
+ 'expr = expr.replace(wild, replacement, exact=True)',
437
+ ],
438
+ },
439
+ {
440
+ 'name' : 'Replace a pattern with some function of that object',
441
+ 'snippet' : [
442
+ 'a = symbols("a", cls=Wild, exclude=[])',
443
+ 'expr = log(sin(x)) + tan(sin(x**2))',
444
+ 'expr.replace(sin(a), lambda a: sin(2*a))',
445
+ ],
446
+ },
447
+ {
448
+ 'name' : 'Replace anything with some function of that thing',
449
+ 'snippet' : [
450
+ 'g = 2*sin(x**3)',
451
+ 'g.replace(lambda expr: expr.is_Function, lambda expr: expr**2)',
452
+ ],
453
+ },
454
+ '---',
455
+ {
456
+ 'name' : 'Replace exact subexpressions',
457
+ 'snippet' : [
458
+ 'expr = x**2 + x**4',
459
+ 'replacements = {x**2: y}',
460
+ 'expr = expr.xreplace(replacements)',
461
+ ],
462
+ },
463
+ // {
464
+ // 'name' : 'rewrite',
465
+ // 'snippet' : [
466
+ // 'expr = tan(x)',
467
+ // 'expr = expr.rewrite(sin)',
468
+ // ],
469
+ // },
470
+ ],
471
+ },
472
+ {
473
+ 'name' : 'Evaluation',
474
+ 'sub-menu' : [
475
+ {
476
+ 'name' : 'Evaluate numerically to arbitrary precision',
477
+ 'snippet' : [
478
+ 'expr = x * sqrt(8)',
479
+ 'precision = 50',
480
+ 'val = N(expr, precision, subs={x:2.4})',
481
+ ],
482
+ },
483
+ {
484
+ 'name' : 'Evaluate numerically to python float',
485
+ 'snippet' : [
486
+ 'expr = x * sqrt(8)',
487
+ 'val = float(expr.subs([(x, 2.4)]))',
488
+ ],
489
+ },
490
+ {
491
+ 'name' : 'Create numpy function for efficient evaluation',
492
+ 'snippet' : [
493
+ 'import numpy',
494
+ 'a = numpy.arange(10)',
495
+ 'expr = sin(x)',
496
+ 'f = lambdify(x, expr, "numpy")',
497
+ 'vals = f(a)',
498
+ ],
499
+ },
500
+ ],
501
+ },
502
+ '---',
503
+ {
504
+ 'name' : 'Polynomials',
505
+ 'sub-menu' : [
506
+ {
507
+ 'name' : 'Factor polynomial over rationals',
508
+ 'snippet' : [
509
+ 'expr = x**3 - x**2 + x - 1',
510
+ 'expr = factor(expr)',
511
+ ],
512
+ },
513
+ {
514
+ 'name' : 'Collect common powers of a term',
515
+ 'snippet' : [
516
+ 'expr = x*y + x - 3 + 2*x**2 - z*x**2 + x**3',
517
+ 'expr = collect(expr, x)',
518
+ ],
519
+ },
520
+ {
521
+ 'name' : 'Extract coefficient of a term',
522
+ 'snippet' : [
523
+ 'expr = 3+2*x+4*x**2',
524
+ 'expr = expr.coeff(x**2)',
525
+ ],
526
+ },
527
+ ],
528
+ },
529
+ {
530
+ 'name' : 'Rational functions',
531
+ 'sub-menu' : [
532
+ {
533
+ 'name' : 'Cancel',
534
+ 'snippet' : [
535
+ 'expr = (x**2 + 2*x + 1)/(x**2 + x)',
536
+ 'expr = cancel(expr)',
537
+ ],
538
+ },
539
+ {
540
+ 'name' : 'Decompose into partial fractions',
541
+ 'snippet' : [
542
+ 'expr = (4*x**3 + 21*x**2 + 10*x + 12)/(x**4 + 5*x**3 + 5*x**2 + 4*x)',
543
+ 'expr = apart(expr)',
544
+ ],
545
+ },
546
+ {
547
+ 'name' : 'Join over common denominator',
548
+ 'snippet' : [
549
+ 'expr = 1/x + 1/y',
550
+ 'expr = ratsimp(expr)',
551
+ ],
552
+ },
553
+ {
554
+ 'name' : 'Remove square roots from denominator',
555
+ 'snippet' : [
556
+ 'expr = 1/(1+I)',
557
+ 'expr = radsimp(expr)',
558
+ ],
559
+ },
560
+ ],
561
+ },
562
+ {
563
+ 'name' : 'Powers',
564
+ 'sub-menu' : [
565
+ {
566
+ 'name' : 'Important caveats',
567
+ 'external-link' : 'http://docs.sympy.org/dev/tutorial/simplification.html#powers'
568
+ },
569
+ '---',
570
+ // {
571
+ // 'name' : 'Setup for these snippets',
572
+ // 'snippet' : [
573
+ // 'x, y = symbols("x, y", positive=True)',
574
+ // 'a, b = symbols("a, b", real=True)',
575
+ // 'z, t, c = symbols("z, t, c")',
576
+ // ],
577
+ // },
578
+ {
579
+ 'name' : 'Simplify powers for general arguments',
580
+ 'snippet' : [
581
+ 'powsimp(x**y * x**z)',
582
+ ],
583
+ },
584
+ {
585
+ 'name' : 'Simplify powers, forcing assumptions',
586
+ 'snippet' : [
587
+ 'powsimp(x**y * x**z, force=True)',
588
+ ],
589
+ },
590
+ {
591
+ 'name' : 'Expand powers by exponent for general arguments',
592
+ 'snippet' : [
593
+ 'expand_power_exp(x**(y + z))',
594
+ ],
595
+ },
596
+ {
597
+ 'name' : 'Expand powers of multiplied bases, forcing assumptions',
598
+ 'snippet' : [
599
+ 'expand_power_base((x*y)**z, force=True)',
600
+ ],
601
+ },
602
+ {
603
+ 'name' : 'Collect exponents on powers for general arguments',
604
+ 'snippet' : [
605
+ 'powdenest((x**y)**z)',
606
+ ],
607
+ },
608
+ {
609
+ 'name' : 'Collect exponents on powers, forcing assumptions',
610
+ 'snippet' : [
611
+ 'powdenest((x**y)**z, force=True)',
612
+ ],
613
+ },
614
+ {
615
+ 'name' : 'Collect exponents on powers, forcing assumptions and polar simplifications',
616
+ 'snippet' : [
617
+ 'powdenest((z**a)**b, force=True, polar=True)',
618
+ ],
619
+ },
620
+ {
621
+ 'name' : 'Denest square-roots',
622
+ 'snippet' : [
623
+ 'sqrtdenest(sqrt(5 + 2*sqrt(6)))',
624
+ ],
625
+ },
626
+ ],
627
+ },
628
+ {
629
+ 'name' : 'Exponentials and Logarithms',
630
+ 'sub-menu' : [
631
+ {
632
+ 'name' : 'Important caveats',
633
+ 'external-link' : 'http://docs.sympy.org/dev/tutorial/simplification.html#exponentials-and-logarithms'
634
+ },
635
+ '---',
636
+ // {
637
+ // 'name' : 'Setup for these snippets',
638
+ // 'snippet' : [
639
+ // 'x, y = symbols("x, y", positive=True)',
640
+ // 'n = symbols("n", real=True)',
641
+ // ],
642
+ // },
643
+ {
644
+ 'name' : 'Combine exponentials',
645
+ 'snippet' : [
646
+ 'powsimp(exp(y) * exp(z))',
647
+ ],
648
+ },
649
+ {
650
+ 'name' : 'Expand logarithms for general arguments',
651
+ 'snippet' : [
652
+ 'expand_log(log(x*y))',
653
+ ],
654
+ },
655
+ {
656
+ 'name' : 'Expand logarithms, forcing assumptions',
657
+ 'snippet' : [
658
+ 'expand_log(log(z**2), force=True)',
659
+ ],
660
+ },
661
+ {
662
+ 'name' : 'Combine logarithms for general arguments',
663
+ 'snippet' : [
664
+ 'logcombine(log(x) + z*log(y))',
665
+ ],
666
+ },
667
+ {
668
+ 'name' : 'Combine logarithms, forcing assumptions',
669
+ 'snippet' : [
670
+ 'logcombine(log(x) + z*log(y))',
671
+ ],
672
+ },
673
+ {
674
+ 'name' : 'Simplification, possibly to trig functions',
675
+ 'snippet' : [
676
+ 'exptrigsimp(exp(z) + exp(-z))',
677
+ ],
678
+ },
679
+ ],
680
+ },
681
+ {
682
+ 'name' : 'Trigonometric functions',
683
+ 'sub-menu' : [
684
+ {
685
+ 'name' : 'Expansion',
686
+ 'snippet' : [
687
+ 'expr = sin(x + y)',
688
+ 'expr = expand(expr, trig=True)',
689
+ ],
690
+ },
691
+ {
692
+ 'name' : 'Simplification',
693
+ 'snippet' : [
694
+ 'expr = sin(x)**4 - 2*cos(x)**2*sin(x)**2 + cos(x)**4',
695
+ 'expr = trigsimp(expr)',
696
+ ],
697
+ },
698
+ {
699
+ 'name' : 'Simplification, possibly to exponentials',
700
+ 'snippet' : [
701
+ 'expr = cosh(z) - sinh(z)',
702
+ 'expr = exptrigsimp(expr)',
703
+ ],
704
+ },
705
+ ],
706
+ },
707
+ {
708
+ 'name' : 'Miscellaneous',
709
+ 'sub-menu' : [
710
+ {
711
+ 'name' : 'Simplify factorials',
712
+ 'snippet' : [
713
+ 'expr = factorial(n)/factorial(n - 3)',
714
+ 'expr = combsimp(expr)',
715
+ ],
716
+ },
717
+ {
718
+ 'name' : 'Simplify binomials',
719
+ 'snippet' : [
720
+ 'expr = binomial(n+1, k+1)/binomial(n, k)',
721
+ 'expr = combsimp(expr)',
722
+ ],
723
+ },
724
+ {
725
+ 'name' : 'Simplify numerical expressions to exact values',
726
+ 'snippet' : [
727
+ 'nsimplify(4.0/(1+sqrt(5.0)), constants=[GoldenRatio,])',
728
+ ],
729
+ },
730
+ {
731
+ 'name' : 'Expand gamma functions',
732
+ 'snippet' : [
733
+ 'expr = gamma(z+3)',
734
+ 'expr = expand_func(expr)',
735
+ ],
736
+ },
737
+ {
738
+ 'name' : 'Simplify Bessel functions',
739
+ 'snippet' : [
740
+ 'expr = besselj(x, z*polar_lift(-1))',
741
+ 'expr = besselsimp(expr)',
742
+ ],
743
+ },
744
+ ],
745
+ },
746
+ ],
747
+ },
748
+ ],
749
+ };
750
+ });
.local/share/jupyter/nbextensions/spellchecker/__pycache__/download_new_dict.cpython-310.pyc ADDED
Binary file (1.28 kB). View file
 
.local/share/jupyter/nbextensions/spellchecker/config.yaml ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Type: IPython Notebook Extension
2
+ Compatibility: 4.x, 5.x
3
+ Name: spellchecker
4
+ Main: main.js
5
+ Description: 'Adds a CodeMirror overlay mode for Typo.js spellchecking'
6
+ Link: README.md
7
+ Parameters:
8
+ - name: spellchecker.enable_on_load
9
+ input_type: checkbox
10
+ description: enable spellchecker for all Markdown/Raw cells on notebook load
11
+ default: true
12
+ - name: spellchecker.add_toolbar_button
13
+ input_type: checkbox
14
+ description: add a toolbar button to toggle spellchecker on and off for all Markdown/Raw cells
15
+ default: true
16
+ - name: spellchecker.lang_code
17
+ intput_type: text
18
+ description: language code to use with typo.js
19
+ default: 'en_US'
20
+ - name: spellchecker.dic_url
21
+ intput_type: url
22
+ description: url for the dictionary .dic file to use
23
+ default: 'https://cdn.jsdelivr.net/codemirror.spell-checker/latest/en_US.dic'
24
+ - name: spellchecker.aff_url
25
+ intput_type: url
26
+ description: url for the dictionary .aff file to use
27
+ default: 'https://cdn.jsdelivr.net/codemirror.spell-checker/latest/en_US.aff'
.local/share/jupyter/nbextensions/spellchecker/main.css ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .CodeMirror .cm-spell-error:not(.cm-url):not(.cm-tag):not(.cm-word) {
2
+ background: rgba(255, 0, 0, .15);
3
+ }
4
+
5
+ #spellchecker_btn > .fa:after {
6
+ content: 'abc';
7
+ position: absolute;
8
+ top: 2px;
9
+ left: 4px;
10
+ text-align: left;
11
+ font-size: 0.5em;
12
+ }
.local/share/jupyter/nbextensions/spellchecker/typo/LICENSE.txt ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ The typo.js file included as part of this nbextension is a requirejs-compatible
2
+ adaptation of typo.js from
3
+ https://github.com/cfinke/Typo.js/
4
+ essentially just wrapping it in a define call. The license for typo.js follows:
5
+
6
+ Copyright (c) 2011, Christopher Finke
7
+ All rights reserved.
8
+
9
+ Redistribution and use in source and binary forms, with or without
10
+ modification, are permitted provided that the following conditions are met:
11
+ * Redistributions of source code must retain the above copyright
12
+ notice, this list of conditions and the following disclaimer.
13
+ * Redistributions in binary form must reproduce the above copyright
14
+ notice, this list of conditions and the following disclaimer in the
15
+ documentation and/or other materials provided with the distribution.
16
+ * The name of the author may not be used to endorse or promote products
17
+ derived from this software without specific prior written permission.
18
+
19
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22
+ DISCLAIMED. IN NO EVENT SHALL THE AUTHOR FINKE BE LIABLE FOR ANY
23
+ DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.local/share/jupyter/nbextensions/table_beautifier/main.js ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * ----------------------------------------------------------------------------
3
+ * Copyright (c) 2016 - Jan Schulz
4
+ *
5
+ * Distributed under the terms of the Modified BSD License.
6
+ *
7
+ * Extension to style markdown and output tables in the notebook with bootstrap
8
+ * ----------------------------------------------------------------------------
9
+ */
10
+
11
+ define([
12
+ 'require',
13
+ 'jquery',
14
+ 'base/js/events'
15
+ ], function (
16
+ requirejs,
17
+ $,
18
+ events
19
+ ) {
20
+ 'use strict';
21
+
22
+ var sortable;
23
+ var bst = requirejs(
24
+ ['https://cdnjs.cloudflare.com/ajax/libs/jquery.tablesorter/2.25.7/js/jquery.tablesorter.min.js'],
25
+ function () {
26
+ sortable = true;
27
+ bootstrapify_all();
28
+ },
29
+ function (err) {
30
+ sortable = false;
31
+ }
32
+ );
33
+
34
+ function bootstrapify_tables($tables, wherefound) {
35
+ wherefound = wherefound ? ' in '+ wherefound : '';
36
+ $tables.addClass('table table-condensed table-nonfluid');
37
+ if (sortable) {
38
+ $tables.tablesorter();
39
+ }
40
+ if ($tables.length > 0) {
41
+ console.log('beautified', $tables.length, 'tables' + wherefound + '...');
42
+ }
43
+ }
44
+
45
+ function bootstrapify_all (){
46
+ bootstrapify_tables($('.rendered_html table'));
47
+ }
48
+
49
+ function bootstrapify_output (event, type, value, metadata, $toinsert){
50
+ bootstrapify_tables($toinsert.find('table'), 'output');
51
+ }
52
+
53
+ function bootstrapify_mdcell (event, mdcell){
54
+ bootstrapify_tables(mdcell.cell.element.find('table'), 'md');
55
+ }
56
+
57
+ function load_css (name) {
58
+ $('<link/>').attr({
59
+ type: 'text/css',
60
+ rel: 'stylesheet',
61
+ href: requirejs.toUrl(name)
62
+ }).appendTo('head');
63
+ }
64
+
65
+ var load_jupyter_extension = function () {
66
+ load_css('./main.css');
67
+ events.on("notebook_loaded.Notebook", bootstrapify_all);
68
+ events.on("kernel_ready.Kernel", bootstrapify_all);
69
+ events.on("output_appended.OutputArea", bootstrapify_output);
70
+ events.on("rendered.MarkdownCell", bootstrapify_mdcell);
71
+ };
72
+
73
+ return {
74
+ 'load_jupyter_extension': load_jupyter_extension,
75
+ 'load_ipython_extension': load_jupyter_extension
76
+ };
77
+
78
+ });
.local/share/jupyter/nbextensions/toc2/demo_dark.png ADDED
.local/share/jupyter/nbextensions/toc2/icon.png ADDED
.local/share/jupyter/nbextensions/toc2/image.png ADDED
.local/share/jupyter/nbextensions/toc2/toc2.yaml ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Type: Jupyter Notebook Extension
2
+ Name: Table of Contents (2)
3
+ Description: The toc2 extension enables to collect all running headers and display them in a floating window, as a sidebar or with a navigation menu. The extension is also draggable, resizable, collapsable, dockable and features automatic numerotation with unique links ids, and an optional toc cell.
4
+ Link: README.md
5
+ Icon: icon.png
6
+ Main: main.js
7
+ Compatibility: 4.x, 5.x
8
+ Parameters:
9
+ - name: toc2.number_sections
10
+ description: Automatically number notebook's sections
11
+ input_type: checkbox
12
+ default: true
13
+ - name: toc2.threshold
14
+ description: Maximum level of nested sections to display on the tables of contents
15
+ input_type: number
16
+ min: -1
17
+ step: 1
18
+ default: 4
19
+
20
+ - name: toc2.skip_h1_title
21
+ description: |
22
+ Skip h1 headings from numbering, so that they can serve as a notebook title.
23
+ See the README for details, caveats and alternatives
24
+ input_type: checkbox
25
+ default: false
26
+
27
+ - name: toc2.toc_cell
28
+ description: Add a Table of Contents cell at the top of the notebook
29
+ input_type: checkbox
30
+ default: false
31
+
32
+ - name: toc2.title_cell
33
+ description: Default heading used for ToC cell (can also be set per-notebook)
34
+ default: 'Table of Contents'
35
+
36
+ - name: toc2.title_sidebar
37
+ description: Default title used for ToC sidebar/window (can also be set per-notebook)
38
+ default: 'Contents'
39
+
40
+ - name: toc2.toc_window_display
41
+ description: Display toc window/sidebar at startup
42
+ input_type: checkbox
43
+ default: false
44
+ - name: toc2.sideBar
45
+ description: Display Table of Contents as a sidebar (otherwise as a floating window)
46
+ input_type: checkbox
47
+ default: true
48
+ - name: toc2.markTocItemOnScroll
49
+ description: Mark toc item of header in viewport when scrolling
50
+ input_type: checkbox
51
+ default: true
52
+ - name: toc2.widenNotebook
53
+ description: Widen the display area to fit the browser window (may be useful with sidebar option)
54
+ input_type: checkbox
55
+ default: true
56
+ - name: toc2.navigate_menu
57
+ description: Display Table of Contents as a navigation menu
58
+ input_type: checkbox
59
+ default: true
60
+ - name: toc2.moveMenuLeft
61
+ description: Move notebook's title and menu on the left instead of being centered -- This provides a better look when the toc/sidebar is present
62
+ input_type: checkbox
63
+ default: true
64
+
65
+ - name: toc2.collapse_to_match_collapsible_headings
66
+ input_type: checkbox
67
+ default: false
68
+ description: |
69
+ Collapse/uncollapse ToC sections when the collapsible_headings nbextension
70
+ is used to collapse/uncollapse sections in the notebook. For the inverse
71
+ behaviour, see collapsible_headings' configuration
72
+
73
+ - name: toc2.colors.hover_highlight
74
+ input_type: color
75
+ description: Hover color in toc
76
+ default: "#DAA520"
77
+ - name: toc2.colors.on_scroll
78
+ input_type: color
79
+ description: Color of highlight mark on scrolling
80
+ default: '#2447f0'
81
+ - name: toc2.colors.selected_highlight
82
+ input_type: color
83
+ description: Color of sections with selected elements
84
+ default: "#FFD700"
85
+ - name: toc2.colors.running_highlight
86
+ input_type: color
87
+ description: Color of sections with running cells
88
+ default: "#FF0000"
89
+ - name: toc2.colors.wrapper_background
90
+ input_type: color
91
+ description: Color of wrapper window background
92
+ default: "#FFFFFF"
93
+ - name: toc2.colors.sidebar_border
94
+ input_type: color
95
+ description: Color of sidebar border
96
+ default: "#EEEEEE"
97
+ - name: toc2.colors.navigate_text
98
+ input_type: color
99
+ description: Color of navigate text
100
+ default: "#333333"
101
+ - name: toc2.colors.navigate_num
102
+ input_type: color
103
+ description: Color of navigate number
104
+ default: "#000000"
.local/share/jupyter/nbextensions/varInspector/main.css ADDED
@@ -0,0 +1,119 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ .varInspector {
3
+ max-height: 500px;
4
+ min-height: 100px;
5
+ font-size: 80%;
6
+ padding: 0px;
7
+ overflow-y: auto;
8
+ font-weight: normal;
9
+ color: #333333;
10
+ white-space: nowrap;
11
+ overflow-x: auto;
12
+ }
13
+
14
+ .varInspector-float-wrapper {
15
+ position: fixed !important;
16
+ top: 120px;
17
+ width:350px;
18
+ max-width:800px;
19
+ right: 20px;
20
+ border: thin solid rgba(0, 0, 0, 0.38);
21
+ border-radius: 5px;
22
+ padding:10px;
23
+ background-color: #fff;
24
+ opacity: .95;
25
+ z-index: 100;
26
+ overflow: hidden;
27
+ }
28
+
29
+ .hide-btn{
30
+ float: right;
31
+ }
32
+
33
+ .reload-btn{
34
+ float: right;
35
+ }
36
+
37
+ .kill-btn{
38
+ float: right;
39
+ }
40
+
41
+ .col-md-9 {
42
+ overflow:hidden;
43
+ margin-left: 14%;
44
+ width: 80%}
45
+
46
+ #varInspector-wrapper.closed {
47
+ min-width: 250px;
48
+ width: auto;
49
+ transition: width;
50
+ }
51
+ #varInspector-wrapper:hover{
52
+ opacity: 1;
53
+ }
54
+ #varInspector-wrapper .header {
55
+ font-size: 16px;
56
+ font-weight: bold;
57
+ }
58
+ #varInspector-wrapper .hide-btn {
59
+ font-size: 14px;
60
+ font-family: monospace;
61
+ }
62
+
63
+ #varInspector-wrapper .reload-btn {
64
+ font-size: 14px;
65
+ font-family: monospace;
66
+ }
67
+
68
+ #varInspector-wrapper .kill-btn {
69
+ font-size: 14px;
70
+ font-family: monospace;
71
+ }
72
+
73
+
74
+
75
+ /* don't waste so much screen space... */
76
+ #varInspector-wrapper .toc-item{
77
+ padding-left: 20px;
78
+ }
79
+
80
+ #varInspector-wrapper .toc-item .toc-item{
81
+ padding-left: 10px;
82
+ }
83
+
84
+
85
+
86
+ table.table, table.table tr, table.table td, table.table th {
87
+ border: 0;
88
+ }
89
+ table.table-nonfluid {
90
+ width: auto !important;
91
+ }
92
+ table.table {
93
+ margin-left: 0;
94
+ margin-right: 0;
95
+ }
96
+ /* stuff for tablesorter plugin */
97
+ .tablesorter-default .header,
98
+ .tablesorter-default .tablesorter-header {
99
+ background-image: url(data:image/gif;base64,R0lGODlhFQAJAIAAACMtMP///yH5BAEAAAEALAAAAAAVAAkAAAIXjI+AywnaYnhUMoqt3gZXPmVg94yJVQAAOw==);
100
+ background-position: right center;
101
+ background-repeat: no-repeat;
102
+ cursor: pointer;
103
+ padding-right: 20px;
104
+ }
105
+ .tablesorter-default thead .headerSortUp,
106
+ .tablesorter-default thead .tablesorter-headerSortUp,
107
+ .tablesorter-default thead .tablesorter-headerAsc {
108
+ background-image: url(data:image/gif;base64,R0lGODlhFQAEAIAAACMtMP///yH5BAEAAAEALAAAAAAVAAQAAAINjI8Bya2wnINUMopZAQA7);
109
+ }
110
+ .tablesorter-default thead .headerSortDown,
111
+ .tablesorter-default thead .tablesorter-headerSortDown,
112
+ .tablesorter-default thead .tablesorter-headerDesc {
113
+ background-image: url(data:image/gif;base64,R0lGODlhFQAEAIAAACMtMP///yH5BAEAAAEALAAAAAAVAAQAAAINjB+gC+jP2ptn0WskLQA7);
114
+ }
115
+ .tablesorter-default thead .sorter-false {
116
+ background-image: none;
117
+ cursor: default;
118
+ padding-right: 5px;
119
+ }
.triton/dump/11759acf26ac56366b171628132485d6/triton_.llir ADDED
@@ -0,0 +1,347 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ; ModuleID = 'LLVMDialectModule'
2
+ source_filename = "LLVMDialectModule"
3
+
4
+ @global_smem = external addrspace(3) global [0 x i8]
5
+ @.str = private unnamed_addr constant [11 x i8] c"__CUDA_FTZ\00", align 1
6
+
7
+ define void @triton__0d1d2d3d4d5d6d7d8de9de(ptr addrspace(1) %0, ptr addrspace(1) %1, ptr addrspace(1) %2, ptr addrspace(1) %3, ptr addrspace(1) %4, ptr addrspace(1) %5, ptr addrspace(1) %6, ptr addrspace(1) %7, i32 %8, i32 %9) local_unnamed_addr !dbg !7 {
8
+ %11 = tail call i32 @llvm.nvvm.read.ptx.sreg.tid.x(), !dbg !10
9
+ %12 = and i32 %11, 31, !dbg !10
10
+ %13 = lshr i32 %11, 5, !dbg !10
11
+ %14 = and i32 %13, 1, !dbg !10
12
+ %urem = and i32 %11, 63, !dbg !10
13
+ %15 = shl nuw nsw i32 %urem, 2, !dbg !10
14
+ %16 = tail call i32 asm "mov.u32 $0, %ctaid.x;", "=r"() #6, !dbg !11
15
+ %17 = shl i32 %16, 8, !dbg !12
16
+ %18 = or i32 %17, %15, !dbg !13
17
+ %19 = sext i32 %18 to i64, !dbg !14
18
+ %20 = getelementptr float, ptr addrspace(1) %1, i64 %19, !dbg !14
19
+ %21 = tail call { i32, i32, i32, i32 } asm sideeffect "mov.u32 $0, 0x0;\0A\09mov.u32 $1, 0x0;\0A\09mov.u32 $2, 0x0;\0A\09mov.u32 $3, 0x0;\0A\09@$5 ld.global.v4.b32 { $0, $1, $2, $3 }, [ $4 + 0 ];\0A\09@!$7 mov.u32 $0, $6;\0A\09@!$9 mov.u32 $1, $8;\0A\09@!$11 mov.u32 $2, $10;\0A\09@!$13 mov.u32 $3, $12;", "=r,=r,=r,=r,l,b,r,b,r,b,r,b,r,b"(ptr addrspace(1) %20, i1 true, i32 0, i1 true, i32 0, i1 true, i32 0, i1 true, i32 0, i1 true) #6, !dbg !15
20
+ %22 = extractvalue { i32, i32, i32, i32 } %21, 0, !dbg !15
21
+ %23 = extractvalue { i32, i32, i32, i32 } %21, 1, !dbg !15
22
+ %24 = extractvalue { i32, i32, i32, i32 } %21, 2, !dbg !15
23
+ %25 = extractvalue { i32, i32, i32, i32 } %21, 3, !dbg !15
24
+ %26 = bitcast i32 %24 to float, !dbg !15
25
+ %27 = bitcast i32 %25 to float, !dbg !15
26
+ %28 = getelementptr i16, ptr addrspace(1) %2, i64 %19, !dbg !16
27
+ %29 = tail call { i32, i32 } asm sideeffect "mov.u32 $0, 0x0;\0A\09mov.u32 $1, 0x0;\0A\09@$3 ld.global.v2.b32 { $0, $1 }, [ $2 + 0 ];\0A\09@!$5 mov.u32 $0, $4;\0A\09@!$7 mov.u32 $1, $6;", "=r,=r,l,b,r,b,r,b"(ptr addrspace(1) %28, i1 true, i32 0, i1 true, i32 0, i1 true) #6, !dbg !17
28
+ %30 = extractvalue { i32, i32 } %29, 0, !dbg !17
29
+ %31 = extractvalue { i32, i32 } %29, 1, !dbg !17
30
+ %32 = trunc i32 %30 to i16, !dbg !17
31
+ %extelt.offset = lshr i32 %30, 16, !dbg !17
32
+ %33 = trunc i32 %extelt.offset to i16, !dbg !17
33
+ %34 = trunc i32 %31 to i16, !dbg !17
34
+ %extelt.offset1 = lshr i32 %31, 16, !dbg !17
35
+ %35 = trunc i32 %extelt.offset1 to i16, !dbg !17
36
+ %36 = tail call float asm "cvt.f32.bf16 $0, $1;", "=r,h"(i16 %32) #6, !dbg !18
37
+ %37 = tail call float asm "cvt.f32.bf16 $0, $1;", "=r,h"(i16 %33) #6, !dbg !18
38
+ %38 = tail call float asm "cvt.f32.bf16 $0, $1;", "=r,h"(i16 %34) #6, !dbg !18
39
+ %39 = tail call float asm "cvt.f32.bf16 $0, $1;", "=r,h"(i16 %35) #6, !dbg !18
40
+ %40 = getelementptr i16, ptr addrspace(1) %3, i64 %19, !dbg !19
41
+ %41 = tail call { i32, i32 } asm sideeffect "mov.u32 $0, 0x0;\0A\09mov.u32 $1, 0x0;\0A\09@$3 ld.global.v2.b32 { $0, $1 }, [ $2 + 0 ];\0A\09@!$5 mov.u32 $0, $4;\0A\09@!$7 mov.u32 $1, $6;", "=r,=r,l,b,r,b,r,b"(ptr addrspace(1) %40, i1 true, i32 0, i1 true, i32 0, i1 true) #6, !dbg !20
42
+ %42 = extractvalue { i32, i32 } %41, 0, !dbg !20
43
+ %43 = extractvalue { i32, i32 } %41, 1, !dbg !20
44
+ %44 = trunc i32 %42 to i16, !dbg !20
45
+ %extelt.offset2 = lshr i32 %42, 16, !dbg !20
46
+ %45 = trunc i32 %extelt.offset2 to i16, !dbg !20
47
+ %46 = trunc i32 %43 to i16, !dbg !20
48
+ %extelt.offset3 = lshr i32 %43, 16, !dbg !20
49
+ %47 = trunc i32 %extelt.offset3 to i16, !dbg !20
50
+ %48 = tail call float asm "cvt.f32.bf16 $0, $1;", "=r,h"(i16 %44) #6, !dbg !21
51
+ %49 = tail call float asm "cvt.f32.bf16 $0, $1;", "=r,h"(i16 %45) #6, !dbg !21
52
+ %50 = tail call float asm "cvt.f32.bf16 $0, $1;", "=r,h"(i16 %46) #6, !dbg !21
53
+ %51 = tail call float asm "cvt.f32.bf16 $0, $1;", "=r,h"(i16 %47) #6, !dbg !21
54
+ %52 = getelementptr i16, ptr addrspace(1) %4, i64 %19, !dbg !22
55
+ %53 = tail call { i32, i32 } asm sideeffect "mov.u32 $0, 0x0;\0A\09mov.u32 $1, 0x0;\0A\09@$3 ld.global.v2.b32 { $0, $1 }, [ $2 + 0 ];\0A\09@!$5 mov.u32 $0, $4;\0A\09@!$7 mov.u32 $1, $6;", "=r,=r,l,b,r,b,r,b"(ptr addrspace(1) %52, i1 true, i32 0, i1 true, i32 0, i1 true) #6, !dbg !23
56
+ %54 = extractvalue { i32, i32 } %53, 0, !dbg !23
57
+ %55 = extractvalue { i32, i32 } %53, 1, !dbg !23
58
+ %56 = trunc i32 %54 to i16, !dbg !23
59
+ %extelt.offset4 = lshr i32 %54, 16, !dbg !23
60
+ %57 = trunc i32 %extelt.offset4 to i16, !dbg !23
61
+ %58 = trunc i32 %55 to i16, !dbg !23
62
+ %extelt.offset5 = lshr i32 %55, 16, !dbg !23
63
+ %59 = trunc i32 %extelt.offset5 to i16, !dbg !23
64
+ %60 = tail call float asm "cvt.f32.bf16 $0, $1;", "=r,h"(i16 %56) #6, !dbg !24
65
+ %61 = tail call float asm "cvt.f32.bf16 $0, $1;", "=r,h"(i16 %57) #6, !dbg !24
66
+ %62 = tail call float asm "cvt.f32.bf16 $0, $1;", "=r,h"(i16 %58) #6, !dbg !24
67
+ %63 = tail call float asm "cvt.f32.bf16 $0, $1;", "=r,h"(i16 %59) #6, !dbg !24
68
+ %64 = zext nneg i32 %15 to i64, !dbg !25
69
+ %65 = getelementptr float, ptr addrspace(1) %5, i64 %64, !dbg !25
70
+ %66 = tail call { i32, i32, i32, i32 } asm sideeffect "mov.u32 $0, 0x0;\0A\09mov.u32 $1, 0x0;\0A\09mov.u32 $2, 0x0;\0A\09mov.u32 $3, 0x0;\0A\09@$5 ld.global.L1::evict_last.v4.b32 { $0, $1, $2, $3 }, [ $4 + 0 ];\0A\09@!$7 mov.u32 $0, $6;\0A\09@!$9 mov.u32 $1, $8;\0A\09@!$11 mov.u32 $2, $10;\0A\09@!$13 mov.u32 $3, $12;", "=r,=r,=r,=r,l,b,r,b,r,b,r,b,r,b"(ptr addrspace(1) %65, i1 true, i32 0, i1 true, i32 0, i1 true, i32 0, i1 true, i32 0, i1 true) #6, !dbg !26
71
+ %67 = fadd float %38, %26, !dbg !27
72
+ %68 = fadd float %39, %27, !dbg !27
73
+ %69 = fadd float %67, %50, !dbg !28
74
+ %70 = fadd float %68, %51, !dbg !28
75
+ %71 = insertelement <2 x i32> poison, i32 %22, i64 0, !dbg !15
76
+ %72 = insertelement <2 x i32> %71, i32 %23, i64 1, !dbg !15
77
+ %73 = bitcast <2 x i32> %72 to <2 x float>, !dbg !15
78
+ %74 = insertelement <2 x float> poison, float %36, i64 0, !dbg !27
79
+ %75 = insertelement <2 x float> %74, float %37, i64 1, !dbg !27
80
+ %76 = fadd <2 x float> %75, %73, !dbg !27
81
+ %77 = insertelement <2 x float> poison, float %48, i64 0, !dbg !28
82
+ %78 = insertelement <2 x float> %77, float %49, i64 1, !dbg !28
83
+ %79 = fadd <2 x float> %76, %78, !dbg !28
84
+ %80 = insertelement <2 x float> poison, float %60, i64 0, !dbg !29
85
+ %81 = insertelement <2 x float> %80, float %61, i64 1, !dbg !29
86
+ %82 = fadd <2 x float> %79, %81, !dbg !29
87
+ %83 = fadd float %69, %62, !dbg !29
88
+ %84 = fadd float %70, %63, !dbg !29
89
+ %85 = extractelement <2 x float> %82, i64 0, !dbg !30
90
+ %86 = extractelement <2 x float> %82, i64 1, !dbg !30
91
+ %87 = fadd float %85, %86, !dbg !30
92
+ %88 = fadd float %87, %83, !dbg !30
93
+ %89 = fadd float %88, %84, !dbg !30
94
+ %90 = bitcast float %89 to i32, !dbg !36
95
+ %91 = tail call i32 @llvm.nvvm.shfl.sync.bfly.i32(i32 -1, i32 %90, i32 16, i32 31), !dbg !36
96
+ %92 = bitcast i32 %91 to float, !dbg !36
97
+ %93 = fadd float %89, %92, !dbg !30
98
+ %94 = bitcast float %93 to i32, !dbg !36
99
+ %95 = tail call i32 @llvm.nvvm.shfl.sync.bfly.i32(i32 -1, i32 %94, i32 8, i32 31), !dbg !36
100
+ %96 = bitcast i32 %95 to float, !dbg !36
101
+ %97 = fadd float %93, %96, !dbg !30
102
+ %98 = bitcast float %97 to i32, !dbg !36
103
+ %99 = tail call i32 @llvm.nvvm.shfl.sync.bfly.i32(i32 -1, i32 %98, i32 4, i32 31), !dbg !36
104
+ %100 = bitcast i32 %99 to float, !dbg !36
105
+ %101 = fadd float %97, %100, !dbg !30
106
+ %102 = bitcast float %101 to i32, !dbg !36
107
+ %103 = tail call i32 @llvm.nvvm.shfl.sync.bfly.i32(i32 -1, i32 %102, i32 2, i32 31), !dbg !36
108
+ %104 = bitcast i32 %103 to float, !dbg !36
109
+ %105 = fadd float %101, %104, !dbg !30
110
+ %106 = bitcast float %105 to i32, !dbg !36
111
+ %107 = tail call i32 @llvm.nvvm.shfl.sync.bfly.i32(i32 -1, i32 %106, i32 1, i32 31), !dbg !36
112
+ %108 = bitcast i32 %107 to float, !dbg !36
113
+ %109 = fadd float %105, %108, !dbg !30
114
+ %110 = icmp eq i32 %12, 0, !dbg !36
115
+ %111 = zext nneg i32 %14 to i64, !dbg !36
116
+ %112 = getelementptr float, ptr addrspace(3) @global_smem, i64 %111, !dbg !36
117
+ tail call void asm sideeffect "@$2 st.shared.b32 [ $0 + 0 ], $1;", "r,r,b"(ptr addrspace(3) %112, float %109, i1 %110) #6, !dbg !36
118
+ tail call void @llvm.nvvm.barrier0(), !dbg !36
119
+ %113 = icmp slt i32 %11, 2, !dbg !36
120
+ %114 = sext i32 %11 to i64, !dbg !36
121
+ %115 = getelementptr float, ptr addrspace(3) @global_smem, i64 %114, !dbg !36
122
+ %116 = tail call float asm sideeffect "@$2 ld.shared.b32 $0, [ $1 + 0 ];", "=r,r,b"(ptr addrspace(3) %115, i1 %113) #6, !dbg !36
123
+ %117 = bitcast float %116 to i32, !dbg !36
124
+ %118 = tail call i32 @llvm.nvvm.shfl.sync.bfly.i32(i32 -1, i32 %117, i32 1, i32 31), !dbg !36
125
+ %119 = bitcast i32 %118 to float, !dbg !36
126
+ %120 = fadd float %116, %119, !dbg !30
127
+ %121 = and i32 %11, 1, !dbg !36
128
+ %122 = icmp eq i32 %121, 0, !dbg !36
129
+ %123 = and i1 %113, %122, !dbg !36
130
+ tail call void asm sideeffect "@$2 st.shared.b32 [ $0 + 0 ], $1;", "r,r,b"(ptr addrspace(3) %115, float %120, i1 %123) #6, !dbg !36
131
+ tail call void @llvm.nvvm.barrier0(), !dbg !36
132
+ %124 = load float, ptr addrspace(3) @global_smem, align 4, !dbg !36
133
+ %125 = fadd float %124, 0.000000e+00, !dbg !38
134
+ %126 = tail call float asm "div.full.f32 $0, $1, $2;", "=r,r,r"(float %125, float 2.560000e+02) #6, !dbg !42
135
+ %127 = fsub float %85, %126, !dbg !43
136
+ %128 = fsub float %86, %126, !dbg !43
137
+ %129 = fsub float %83, %126, !dbg !43
138
+ %130 = fsub float %84, %126, !dbg !43
139
+ %131 = fmul float %127, %127, !dbg !44
140
+ %132 = fmul float %128, %128, !dbg !44
141
+ %133 = fmul float %129, %129, !dbg !44
142
+ %134 = fmul float %130, %130, !dbg !44
143
+ tail call void @llvm.nvvm.barrier0(), !dbg !45
144
+ %135 = fadd float %131, %132, !dbg !47
145
+ %136 = fadd float %133, %135, !dbg !47
146
+ %137 = fadd float %134, %136, !dbg !47
147
+ %138 = bitcast float %137 to i32, !dbg !45
148
+ %139 = tail call i32 @llvm.nvvm.shfl.sync.bfly.i32(i32 -1, i32 %138, i32 16, i32 31), !dbg !45
149
+ %140 = bitcast i32 %139 to float, !dbg !45
150
+ %141 = fadd float %137, %140, !dbg !47
151
+ %142 = bitcast float %141 to i32, !dbg !45
152
+ %143 = tail call i32 @llvm.nvvm.shfl.sync.bfly.i32(i32 -1, i32 %142, i32 8, i32 31), !dbg !45
153
+ %144 = bitcast i32 %143 to float, !dbg !45
154
+ %145 = fadd float %141, %144, !dbg !47
155
+ %146 = bitcast float %145 to i32, !dbg !45
156
+ %147 = tail call i32 @llvm.nvvm.shfl.sync.bfly.i32(i32 -1, i32 %146, i32 4, i32 31), !dbg !45
157
+ %148 = bitcast i32 %147 to float, !dbg !45
158
+ %149 = fadd float %145, %148, !dbg !47
159
+ %150 = bitcast float %149 to i32, !dbg !45
160
+ %151 = tail call i32 @llvm.nvvm.shfl.sync.bfly.i32(i32 -1, i32 %150, i32 2, i32 31), !dbg !45
161
+ %152 = bitcast i32 %151 to float, !dbg !45
162
+ %153 = fadd float %149, %152, !dbg !47
163
+ %154 = bitcast float %153 to i32, !dbg !45
164
+ %155 = tail call i32 @llvm.nvvm.shfl.sync.bfly.i32(i32 -1, i32 %154, i32 1, i32 31), !dbg !45
165
+ %156 = bitcast i32 %155 to float, !dbg !45
166
+ %157 = fadd float %153, %156, !dbg !47
167
+ tail call void asm sideeffect "@$2 st.shared.b32 [ $0 + 0 ], $1;", "r,r,b"(ptr addrspace(3) %112, float %157, i1 %110) #6, !dbg !45
168
+ tail call void @llvm.nvvm.barrier0(), !dbg !45
169
+ %158 = tail call float asm sideeffect "@$2 ld.shared.b32 $0, [ $1 + 0 ];", "=r,r,b"(ptr addrspace(3) %115, i1 %113) #6, !dbg !45
170
+ %159 = bitcast float %158 to i32, !dbg !45
171
+ %160 = tail call i32 @llvm.nvvm.shfl.sync.bfly.i32(i32 -1, i32 %159, i32 1, i32 31), !dbg !45
172
+ %161 = bitcast i32 %160 to float, !dbg !45
173
+ %162 = fadd float %158, %161, !dbg !47
174
+ tail call void asm sideeffect "@$2 st.shared.b32 [ $0 + 0 ], $1;", "r,r,b"(ptr addrspace(3) %115, float %162, i1 %123) #6, !dbg !45
175
+ tail call void @llvm.nvvm.barrier0(), !dbg !45
176
+ %163 = load float, ptr addrspace(3) @global_smem, align 4, !dbg !45
177
+ %164 = fadd float %163, 0.000000e+00, !dbg !50
178
+ %165 = tail call float asm "div.full.f32 $0, $1, $2;", "=r,r,r"(float %164, float 2.560000e+02) #6, !dbg !52
179
+ %166 = fadd float %165, 0x3EE4F8B580000000, !dbg !53
180
+ %167 = tail call i32 @__nvvm_reflect(ptr nonnull @.str) #6, !dbg !54
181
+ %.not.i = icmp eq i32 %167, 0, !dbg !54
182
+ br i1 %.not.i, label %170, label %168, !dbg !54
183
+
184
+ 168: ; preds = %10
185
+ %169 = tail call float @llvm.nvvm.rsqrt.approx.ftz.f(float %166), !dbg !54
186
+ br label %__nv_rsqrtf.exit, !dbg !54
187
+
188
+ 170: ; preds = %10
189
+ %171 = tail call float @llvm.nvvm.rsqrt.approx.f(float %166), !dbg !54
190
+ br label %__nv_rsqrtf.exit, !dbg !54
191
+
192
+ __nv_rsqrtf.exit: ; preds = %168, %170
193
+ %.0.i = phi float [ %169, %168 ], [ %171, %170 ], !dbg !54
194
+ %172 = extractvalue { i32, i32, i32, i32 } %66, 3, !dbg !26
195
+ %173 = bitcast i32 %172 to float, !dbg !26
196
+ %174 = extractvalue { i32, i32, i32, i32 } %66, 2, !dbg !26
197
+ %175 = bitcast i32 %174 to float, !dbg !26
198
+ %176 = extractvalue { i32, i32, i32, i32 } %66, 1, !dbg !26
199
+ %177 = bitcast i32 %176 to float, !dbg !26
200
+ %178 = extractvalue { i32, i32, i32, i32 } %66, 0, !dbg !26
201
+ %179 = bitcast i32 %178 to float, !dbg !26
202
+ %180 = fmul float %127, %.0.i, !dbg !55
203
+ %181 = fmul float %128, %.0.i, !dbg !55
204
+ %182 = fmul float %129, %.0.i, !dbg !55
205
+ %183 = fmul float %130, %.0.i, !dbg !55
206
+ %184 = fmul float %180, %179, !dbg !56
207
+ %185 = fmul float %181, %177, !dbg !56
208
+ %186 = fmul float %182, %175, !dbg !56
209
+ %187 = fmul float %183, %173, !dbg !56
210
+ tail call void @llvm.nvvm.barrier0(), !dbg !57
211
+ %188 = sext i32 %16 to i64, !dbg !58
212
+ %189 = getelementptr float, ptr addrspace(1) %0, i64 %188, !dbg !58
213
+ %190 = icmp eq i32 %urem, 0, !dbg !59
214
+ %191 = bitcast float %.0.i to i32, !dbg !59
215
+ tail call void asm sideeffect "@$2 st.global.b32 [ $1 + 0 ], { $0 };", "r,l,b"(i32 %191, ptr addrspace(1) %189, i1 %190) #6, !dbg !59
216
+ %192 = getelementptr i16, ptr addrspace(1) %7, i64 %19, !dbg !60
217
+ %193 = tail call i16 asm "cvt.rn.bf16.f32 $0, $1;", "=h,r"(float %184) #6, !dbg !61
218
+ %194 = tail call i16 asm "cvt.rn.bf16.f32 $0, $1;", "=h,r"(float %185) #6, !dbg !61
219
+ %195 = tail call i16 asm "cvt.rn.bf16.f32 $0, $1;", "=h,r"(float %186) #6, !dbg !61
220
+ %196 = tail call i16 asm "cvt.rn.bf16.f32 $0, $1;", "=h,r"(float %187) #6, !dbg !61
221
+ %197 = insertelement <2 x i16> undef, i16 %193, i64 0, !dbg !61
222
+ %198 = insertelement <2 x i16> %197, i16 %194, i64 1, !dbg !61
223
+ %199 = bitcast <2 x i16> %198 to i32, !dbg !61
224
+ %200 = insertelement <2 x i16> undef, i16 %195, i64 0, !dbg !61
225
+ %201 = insertelement <2 x i16> %200, i16 %196, i64 1, !dbg !61
226
+ %202 = bitcast <2 x i16> %201 to i32, !dbg !61
227
+ tail call void asm sideeffect "@$3 st.global.v2.b32 [ $2 + 0 ], { $0, $1 };", "r,r,l,b"(i32 %199, i32 %202, ptr addrspace(1) %192, i1 true) #6, !dbg !61
228
+ %203 = getelementptr float, ptr addrspace(1) %6, i64 %188, !dbg !62
229
+ %204 = bitcast float %126 to i32, !dbg !63
230
+ tail call void asm sideeffect "@$2 st.global.b32 [ $1 + 0 ], { $0 };", "r,l,b"(i32 %204, ptr addrspace(1) %203, i1 %190) #6, !dbg !63
231
+ ret void, !dbg !64
232
+ }
233
+
234
+ ; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
235
+ declare noundef i32 @llvm.nvvm.read.ptx.sreg.tid.x() #0
236
+
237
+ ; Function Attrs: convergent nocallback nounwind memory(inaccessiblemem: readwrite)
238
+ declare i32 @llvm.nvvm.shfl.sync.bfly.i32(i32, i32, i32, i32) #1
239
+
240
+ ; Function Attrs: convergent nocallback nounwind
241
+ declare void @llvm.nvvm.barrier0() #2
242
+
243
+ ; Function Attrs: alwaysinline nounwind
244
+ define float @__nv_rsqrtf(float %x) local_unnamed_addr #3 {
245
+ %1 = tail call i32 @__nvvm_reflect(ptr nonnull @.str) #6
246
+ %.not = icmp eq i32 %1, 0
247
+ br i1 %.not, label %4, label %2
248
+
249
+ 2: ; preds = %0
250
+ %3 = tail call float @llvm.nvvm.rsqrt.approx.ftz.f(float %x)
251
+ br label %6
252
+
253
+ 4: ; preds = %0
254
+ %5 = tail call float @llvm.nvvm.rsqrt.approx.f(float %x)
255
+ br label %6
256
+
257
+ 6: ; preds = %4, %2
258
+ %.0 = phi float [ %3, %2 ], [ %5, %4 ]
259
+ ret float %.0
260
+ }
261
+
262
+ declare i32 @__nvvm_reflect(ptr) local_unnamed_addr #4
263
+
264
+ ; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(none)
265
+ declare float @llvm.nvvm.rsqrt.approx.ftz.f(float) #5
266
+
267
+ ; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(none)
268
+ declare float @llvm.nvvm.rsqrt.approx.f(float) #5
269
+
270
+ attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
271
+ attributes #1 = { convergent nocallback nounwind memory(inaccessiblemem: readwrite) }
272
+ attributes #2 = { convergent nocallback nounwind }
273
+ attributes #3 = { alwaysinline nounwind "disable-tail-calls"="false" "frame-pointer"="all" "less-precise-fpmad"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
274
+ attributes #4 = { "disable-tail-calls"="false" "frame-pointer"="all" "less-precise-fpmad"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
275
+ attributes #5 = { mustprogress nocallback nofree nosync nounwind willreturn memory(none) }
276
+ attributes #6 = { nounwind }
277
+
278
+ !llvm.module.flags = !{!0, !1}
279
+ !llvm.dbg.cu = !{!2}
280
+ !nvvm.annotations = !{!4, !5, !5, !4}
281
+ !llvm.ident = !{!6}
282
+
283
+ !0 = !{i32 2, !"Debug Info Version", i32 3}
284
+ !1 = !{i32 4, !"nvvm-reflect-ftz", i32 1}
285
+ !2 = distinct !DICompileUnit(language: DW_LANG_C, file: !3, producer: "triton", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug)
286
+ !3 = !DIFile(filename: "cdxa5yqgsimvskocpuiz4ajfrjfcwys3opyrdv53xfphj4576qx7.py", directory: "/tmp/torchinductor_root/dx")
287
+ !4 = !{ptr @triton__0d1d2d3d4d5d6d7d8de9de, !"kernel", i32 1}
288
+ !5 = !{ptr @triton__0d1d2d3d4d5d6d7d8de9de, !"maxntidx", i32 64}
289
+ !6 = !{!"clang version 3.8.0 (tags/RELEASE_380/final)"}
290
+ !7 = distinct !DISubprogram(name: "triton__0d1d2d3d4d5d6d7d8de9de", linkageName: "triton__0d1d2d3d4d5d6d7d8de9de", scope: !3, file: !3, line: 18, type: !8, scopeLine: 18, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2)
291
+ !8 = !DISubroutineType(cc: DW_CC_normal, types: !9)
292
+ !9 = !{}
293
+ !10 = !DILocation(line: 26, column: 26, scope: !7)
294
+ !11 = !DILocation(line: 23, column: 28, scope: !7)
295
+ !12 = !DILocation(line: 30, column: 40, scope: !7)
296
+ !13 = !DILocation(line: 30, column: 36, scope: !7)
297
+ !14 = !DILocation(line: 30, column: 30, scope: !7)
298
+ !15 = !DILocation(line: 30, column: 46, scope: !7)
299
+ !16 = !DILocation(line: 31, column: 30, scope: !7)
300
+ !17 = !DILocation(line: 31, column: 46, scope: !7)
301
+ !18 = !DILocation(line: 31, column: 67, scope: !7)
302
+ !19 = !DILocation(line: 32, column: 30, scope: !7)
303
+ !20 = !DILocation(line: 32, column: 46, scope: !7)
304
+ !21 = !DILocation(line: 32, column: 67, scope: !7)
305
+ !22 = !DILocation(line: 33, column: 30, scope: !7)
306
+ !23 = !DILocation(line: 33, column: 46, scope: !7)
307
+ !24 = !DILocation(line: 33, column: 67, scope: !7)
308
+ !25 = !DILocation(line: 34, column: 31, scope: !7)
309
+ !26 = !DILocation(line: 34, column: 36, scope: !7)
310
+ !27 = !DILocation(line: 36, column: 18, scope: !7)
311
+ !28 = !DILocation(line: 38, column: 18, scope: !7)
312
+ !29 = !DILocation(line: 40, column: 18, scope: !7)
313
+ !30 = !DILocation(line: 233, column: 15, scope: !31, inlinedAt: !34)
314
+ !31 = distinct !DILexicalBlockFile(scope: !33, file: !32, discriminator: 0)
315
+ !32 = !DIFile(filename: "standard.py", directory: "/usr/local/lib/python3.10/dist-packages/triton/language")
316
+ !33 = distinct !DILexicalBlockFile(scope: !7, file: !32, discriminator: 0)
317
+ !34 = !DILocation(line: 243, column: 36, scope: !31, inlinedAt: !35)
318
+ !35 = !DILocation(line: 45, column: 59, scope: !31)
319
+ !36 = !DILocation(line: 243, column: 36, scope: !33, inlinedAt: !37)
320
+ !37 = !DILocation(line: 45, column: 59, scope: !33)
321
+ !38 = !DILocation(line: 8, column: 15, scope: !39, inlinedAt: !41)
322
+ !39 = distinct !DILexicalBlockFile(scope: !7, file: !40, discriminator: 0)
323
+ !40 = !DIFile(filename: "triton_helpers.py", directory: "/usr/local/lib/python3.10/dist-packages/torch/_inductor")
324
+ !41 = !DILocation(line: 45, column: 45, scope: !39)
325
+ !42 = !DILocation(line: 48, column: 20, scope: !7)
326
+ !43 = !DILocation(line: 49, column: 20, scope: !7)
327
+ !44 = !DILocation(line: 50, column: 20, scope: !7)
328
+ !45 = !DILocation(line: 243, column: 36, scope: !33, inlinedAt: !46)
329
+ !46 = !DILocation(line: 53, column: 59, scope: !33)
330
+ !47 = !DILocation(line: 233, column: 15, scope: !31, inlinedAt: !48)
331
+ !48 = !DILocation(line: 243, column: 36, scope: !31, inlinedAt: !49)
332
+ !49 = !DILocation(line: 53, column: 59, scope: !31)
333
+ !50 = !DILocation(line: 8, column: 15, scope: !39, inlinedAt: !51)
334
+ !51 = !DILocation(line: 53, column: 45, scope: !39)
335
+ !52 = !DILocation(line: 55, column: 20, scope: !7)
336
+ !53 = !DILocation(line: 57, column: 20, scope: !7)
337
+ !54 = !DILocation(line: 58, column: 26, scope: !7)
338
+ !55 = !DILocation(line: 60, column: 20, scope: !7)
339
+ !56 = !DILocation(line: 61, column: 20, scope: !7)
340
+ !57 = !DILocation(line: 63, column: 4, scope: !7)
341
+ !58 = !DILocation(line: 64, column: 28, scope: !7)
342
+ !59 = !DILocation(line: 64, column: 40, scope: !7)
343
+ !60 = !DILocation(line: 65, column: 25, scope: !7)
344
+ !61 = !DILocation(line: 65, column: 48, scope: !7)
345
+ !62 = !DILocation(line: 66, column: 25, scope: !7)
346
+ !63 = !DILocation(line: 66, column: 37, scope: !7)
347
+ !64 = !DILocation(line: 66, column: 4, scope: !7)
.triton/dump/11759acf26ac56366b171628132485d6/triton_.ttgir ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #blocked = #triton_gpu.blocked<{sizePerThread = [4], threadsPerWarp = [32], warpsPerCTA = [2], order = [0], CTAsPerCGA = [1], CTASplitNum = [1], CTAOrder = [0]}>
2
+ #blocked1 = #triton_gpu.blocked<{sizePerThread = [1], threadsPerWarp = [32], warpsPerCTA = [2], order = [0], CTAsPerCGA = [1], CTASplitNum = [1], CTAOrder = [0]}>
3
+ module attributes {"triton_gpu.compute-capability" = 89 : i32, "triton_gpu.num-ctas" = 1 : i32, "triton_gpu.num-warps" = 2 : i32, "triton_gpu.threads-per-warp" = 32 : i32} {
4
+ tt.func public @triton__0d1d2d3d4d5d6d7d8de9de(%arg0: !tt.ptr<f32, 1> {tt.divisibility = 16 : i32}, %arg1: !tt.ptr<f32, 1> {tt.divisibility = 16 : i32}, %arg2: !tt.ptr<bf16, 1> {tt.divisibility = 16 : i32}, %arg3: !tt.ptr<bf16, 1> {tt.divisibility = 16 : i32}, %arg4: !tt.ptr<bf16, 1> {tt.divisibility = 16 : i32}, %arg5: !tt.ptr<f32, 1> {tt.divisibility = 16 : i32}, %arg6: !tt.ptr<f32, 1> {tt.divisibility = 16 : i32}, %arg7: !tt.ptr<bf16, 1> {tt.divisibility = 16 : i32}, %arg8: i32 {tt.divisibility = 16 : i32, tt.max_divisibility = 16 : i32}, %arg9: i32 {tt.divisibility = 16 : i32, tt.max_divisibility = 16 : i32}) attributes {noinline = false} {
5
+ %cst = arith.constant dense<256> : tensor<256xi32, #blocked>
6
+ %cst_0 = arith.constant 9.99999974E-6 : f32
7
+ %cst_1 = arith.constant 2.560000e+02 : f32
8
+ %cst_2 = arith.constant 0.000000e+00 : f32
9
+ %c256_i32 = arith.constant 256 : i32
10
+ %cst_3 = arith.constant dense<0.000000e+00> : tensor<256xf32, #blocked>
11
+ %cst_4 = arith.constant dense<0.000000e+00> : tensor<256xbf16, #blocked>
12
+ %0 = tt.get_program_id x : i32
13
+ %1 = tt.make_range {end = 256 : i32, start = 0 : i32} : tensor<256xi32, #blocked>
14
+ %2 = arith.cmpi slt, %1, %cst : tensor<256xi32, #blocked>
15
+ %3 = arith.muli %0, %c256_i32 : i32
16
+ %4 = tt.splat %3 : (i32) -> tensor<256xi32, #blocked>
17
+ %5 = arith.addi %1, %4 : tensor<256xi32, #blocked>
18
+ %6 = tt.splat %arg1 : (!tt.ptr<f32, 1>) -> tensor<256x!tt.ptr<f32, 1>, #blocked>
19
+ %7 = tt.addptr %6, %5 : tensor<256x!tt.ptr<f32, 1>, #blocked>, tensor<256xi32, #blocked>
20
+ %8 = tt.load %7, %2, %cst_3 {cache = 1 : i32, evict = 1 : i32, isVolatile = false} : tensor<256xf32, #blocked>
21
+ %9 = tt.splat %arg2 : (!tt.ptr<bf16, 1>) -> tensor<256x!tt.ptr<bf16, 1>, #blocked>
22
+ %10 = tt.addptr %9, %5 : tensor<256x!tt.ptr<bf16, 1>, #blocked>, tensor<256xi32, #blocked>
23
+ %11 = tt.load %10, %2, %cst_4 {cache = 1 : i32, evict = 1 : i32, isVolatile = false} : tensor<256xbf16, #blocked>
24
+ %12 = arith.extf %11 : tensor<256xbf16, #blocked> to tensor<256xf32, #blocked>
25
+ %13 = tt.splat %arg3 : (!tt.ptr<bf16, 1>) -> tensor<256x!tt.ptr<bf16, 1>, #blocked>
26
+ %14 = tt.addptr %13, %5 : tensor<256x!tt.ptr<bf16, 1>, #blocked>, tensor<256xi32, #blocked>
27
+ %15 = tt.load %14, %2, %cst_4 {cache = 1 : i32, evict = 1 : i32, isVolatile = false} : tensor<256xbf16, #blocked>
28
+ %16 = arith.extf %15 : tensor<256xbf16, #blocked> to tensor<256xf32, #blocked>
29
+ %17 = tt.splat %arg4 : (!tt.ptr<bf16, 1>) -> tensor<256x!tt.ptr<bf16, 1>, #blocked>
30
+ %18 = tt.addptr %17, %5 : tensor<256x!tt.ptr<bf16, 1>, #blocked>, tensor<256xi32, #blocked>
31
+ %19 = tt.load %18, %2, %cst_4 {cache = 1 : i32, evict = 1 : i32, isVolatile = false} : tensor<256xbf16, #blocked>
32
+ %20 = arith.extf %19 : tensor<256xbf16, #blocked> to tensor<256xf32, #blocked>
33
+ %21 = tt.splat %arg5 : (!tt.ptr<f32, 1>) -> tensor<256x!tt.ptr<f32, 1>, #blocked>
34
+ %22 = tt.addptr %21, %1 : tensor<256x!tt.ptr<f32, 1>, #blocked>, tensor<256xi32, #blocked>
35
+ %23 = tt.load %22, %2, %cst_3 {cache = 1 : i32, evict = 3 : i32, isVolatile = false} : tensor<256xf32, #blocked>
36
+ %24 = arith.addf %8, %12 : tensor<256xf32, #blocked>
37
+ %25 = arith.addf %24, %16 : tensor<256xf32, #blocked>
38
+ %26 = arith.addf %25, %20 : tensor<256xf32, #blocked>
39
+ %27 = arith.select %2, %26, %cst_3 : tensor<256xi1, #blocked>, tensor<256xf32, #blocked>
40
+ %28 = "tt.reduce"(%27) <{axis = 0 : i32}> ({
41
+ ^bb0(%arg10: f32, %arg11: f32):
42
+ %52 = arith.addf %arg10, %arg11 : f32
43
+ tt.reduce.return %52 : f32
44
+ }) : (tensor<256xf32, #blocked>) -> f32
45
+ %29 = arith.addf %28, %cst_2 : f32
46
+ %30 = arith.divf %29, %cst_1 : f32
47
+ %31 = tt.splat %30 : (f32) -> tensor<1xf32, #blocked1>
48
+ %32 = tt.splat %30 : (f32) -> tensor<256xf32, #blocked>
49
+ %33 = arith.subf %26, %32 : tensor<256xf32, #blocked>
50
+ %34 = arith.mulf %33, %33 : tensor<256xf32, #blocked>
51
+ %35 = arith.select %2, %34, %cst_3 : tensor<256xi1, #blocked>, tensor<256xf32, #blocked>
52
+ %36 = "tt.reduce"(%35) <{axis = 0 : i32}> ({
53
+ ^bb0(%arg10: f32, %arg11: f32):
54
+ %52 = arith.addf %arg10, %arg11 : f32
55
+ tt.reduce.return %52 : f32
56
+ }) : (tensor<256xf32, #blocked>) -> f32
57
+ %37 = arith.addf %36, %cst_2 : f32
58
+ %38 = arith.divf %37, %cst_1 : f32
59
+ %39 = arith.addf %38, %cst_0 : f32
60
+ %40 = tt.extern_elementwise %39 {libname = "libdevice", libpath = "/usr/local/lib/python3.10/dist-packages/triton/language/../third_party/cuda/lib/libdevice.10.bc", pure = true, symbol = "__nv_rsqrtf"} : (f32) -> f32
61
+ %41 = tt.splat %40 : (f32) -> tensor<1xf32, #blocked1>
62
+ %42 = tt.splat %40 : (f32) -> tensor<256xf32, #blocked>
63
+ %43 = arith.mulf %33, %42 : tensor<256xf32, #blocked>
64
+ %44 = arith.mulf %43, %23 : tensor<256xf32, #blocked>
65
+ gpu.barrier
66
+ %45 = tt.addptr %arg0, %0 : !tt.ptr<f32, 1>, i32
67
+ %46 = tt.splat %45 : (!tt.ptr<f32, 1>) -> tensor<1x!tt.ptr<f32, 1>, #blocked1>
68
+ tt.store %46, %41 {cache = 1 : i32, evict = 1 : i32} : tensor<1xf32, #blocked1>
69
+ %47 = tt.splat %arg7 : (!tt.ptr<bf16, 1>) -> tensor<256x!tt.ptr<bf16, 1>, #blocked>
70
+ %48 = tt.addptr %47, %5 : tensor<256x!tt.ptr<bf16, 1>, #blocked>, tensor<256xi32, #blocked>
71
+ %49 = arith.truncf %44 : tensor<256xf32, #blocked> to tensor<256xbf16, #blocked>
72
+ tt.store %48, %49, %2 {cache = 1 : i32, evict = 1 : i32} : tensor<256xbf16, #blocked>
73
+ %50 = tt.addptr %arg6, %0 : !tt.ptr<f32, 1>, i32
74
+ %51 = tt.splat %50 : (!tt.ptr<f32, 1>) -> tensor<1x!tt.ptr<f32, 1>, #blocked1>
75
+ tt.store %51, %31 {cache = 1 : i32, evict = 1 : i32} : tensor<1xf32, #blocked1>
76
+ tt.return
77
+ }
78
+ }
.triton/dump/11759acf26ac56366b171628132485d6/triton_.ttir ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ module {
2
+ tt.func public @triton__0d1d2d3d4d5d6d7d8de9de(%arg0: !tt.ptr<f32, 1> {tt.divisibility = 16 : i32}, %arg1: !tt.ptr<f32, 1> {tt.divisibility = 16 : i32}, %arg2: !tt.ptr<bf16, 1> {tt.divisibility = 16 : i32}, %arg3: !tt.ptr<bf16, 1> {tt.divisibility = 16 : i32}, %arg4: !tt.ptr<bf16, 1> {tt.divisibility = 16 : i32}, %arg5: !tt.ptr<f32, 1> {tt.divisibility = 16 : i32}, %arg6: !tt.ptr<f32, 1> {tt.divisibility = 16 : i32}, %arg7: !tt.ptr<bf16, 1> {tt.divisibility = 16 : i32}, %arg8: i32 {tt.divisibility = 16 : i32, tt.max_divisibility = 16 : i32}, %arg9: i32 {tt.divisibility = 16 : i32, tt.max_divisibility = 16 : i32}) attributes {noinline = false} {
3
+ %c256_i32 = arith.constant 256 : i32
4
+ %cst = arith.constant dense<0.000000e+00> : tensor<256xbf16>
5
+ %cst_0 = arith.constant 0.000000e+00 : f32
6
+ %cst_1 = arith.constant 2.560000e+02 : f32
7
+ %cst_2 = arith.constant 9.99999974E-6 : f32
8
+ %cst_3 = arith.constant dense<0.000000e+00> : tensor<256xf32>
9
+ %cst_4 = arith.constant dense<256> : tensor<256xi32>
10
+ %0 = tt.get_program_id x : i32
11
+ %1 = tt.make_range {end = 256 : i32, start = 0 : i32} : tensor<256xi32>
12
+ %2 = arith.cmpi slt, %1, %cst_4 : tensor<256xi32>
13
+ %3 = arith.muli %0, %c256_i32 : i32
14
+ %4 = tt.splat %3 : (i32) -> tensor<256xi32>
15
+ %5 = arith.addi %1, %4 : tensor<256xi32>
16
+ %6 = tt.splat %arg1 : (!tt.ptr<f32, 1>) -> tensor<256x!tt.ptr<f32, 1>>
17
+ %7 = tt.addptr %6, %5 : tensor<256x!tt.ptr<f32, 1>>, tensor<256xi32>
18
+ %8 = tt.load %7, %2, %cst_3 {cache = 1 : i32, evict = 1 : i32, isVolatile = false} : tensor<256xf32>
19
+ %9 = tt.splat %arg2 : (!tt.ptr<bf16, 1>) -> tensor<256x!tt.ptr<bf16, 1>>
20
+ %10 = tt.addptr %9, %5 : tensor<256x!tt.ptr<bf16, 1>>, tensor<256xi32>
21
+ %11 = tt.load %10, %2, %cst {cache = 1 : i32, evict = 1 : i32, isVolatile = false} : tensor<256xbf16>
22
+ %12 = arith.extf %11 : tensor<256xbf16> to tensor<256xf32>
23
+ %13 = tt.splat %arg3 : (!tt.ptr<bf16, 1>) -> tensor<256x!tt.ptr<bf16, 1>>
24
+ %14 = tt.addptr %13, %5 : tensor<256x!tt.ptr<bf16, 1>>, tensor<256xi32>
25
+ %15 = tt.load %14, %2, %cst {cache = 1 : i32, evict = 1 : i32, isVolatile = false} : tensor<256xbf16>
26
+ %16 = arith.extf %15 : tensor<256xbf16> to tensor<256xf32>
27
+ %17 = tt.splat %arg4 : (!tt.ptr<bf16, 1>) -> tensor<256x!tt.ptr<bf16, 1>>
28
+ %18 = tt.addptr %17, %5 : tensor<256x!tt.ptr<bf16, 1>>, tensor<256xi32>
29
+ %19 = tt.load %18, %2, %cst {cache = 1 : i32, evict = 1 : i32, isVolatile = false} : tensor<256xbf16>
30
+ %20 = arith.extf %19 : tensor<256xbf16> to tensor<256xf32>
31
+ %21 = tt.splat %arg5 : (!tt.ptr<f32, 1>) -> tensor<256x!tt.ptr<f32, 1>>
32
+ %22 = tt.addptr %21, %1 : tensor<256x!tt.ptr<f32, 1>>, tensor<256xi32>
33
+ %23 = tt.load %22, %2, %cst_3 {cache = 1 : i32, evict = 3 : i32, isVolatile = false} : tensor<256xf32>
34
+ %24 = arith.addf %8, %12 : tensor<256xf32>
35
+ %25 = arith.addf %24, %16 : tensor<256xf32>
36
+ %26 = arith.addf %25, %20 : tensor<256xf32>
37
+ %27 = arith.select %2, %26, %cst_3 : tensor<256xi1>, tensor<256xf32>
38
+ %28 = "tt.reduce"(%27) <{axis = 0 : i32}> ({
39
+ ^bb0(%arg10: f32, %arg11: f32):
40
+ %52 = arith.addf %arg10, %arg11 : f32
41
+ tt.reduce.return %52 : f32
42
+ }) : (tensor<256xf32>) -> f32
43
+ %29 = arith.addf %28, %cst_0 : f32
44
+ %30 = arith.divf %29, %cst_1 : f32
45
+ %31 = tt.splat %30 : (f32) -> tensor<1xf32>
46
+ %32 = tt.splat %30 : (f32) -> tensor<256xf32>
47
+ %33 = arith.subf %26, %32 : tensor<256xf32>
48
+ %34 = arith.mulf %33, %33 : tensor<256xf32>
49
+ %35 = arith.select %2, %34, %cst_3 : tensor<256xi1>, tensor<256xf32>
50
+ %36 = "tt.reduce"(%35) <{axis = 0 : i32}> ({
51
+ ^bb0(%arg10: f32, %arg11: f32):
52
+ %52 = arith.addf %arg10, %arg11 : f32
53
+ tt.reduce.return %52 : f32
54
+ }) : (tensor<256xf32>) -> f32
55
+ %37 = arith.addf %36, %cst_0 : f32
56
+ %38 = arith.divf %37, %cst_1 : f32
57
+ %39 = arith.addf %38, %cst_2 : f32
58
+ %40 = tt.extern_elementwise %39 {libname = "libdevice", libpath = "/usr/local/lib/python3.10/dist-packages/triton/language/../third_party/cuda/lib/libdevice.10.bc", pure = true, symbol = "__nv_rsqrtf"} : (f32) -> f32
59
+ %41 = tt.splat %40 : (f32) -> tensor<1xf32>
60
+ %42 = tt.splat %40 : (f32) -> tensor<256xf32>
61
+ %43 = arith.mulf %33, %42 : tensor<256xf32>
62
+ %44 = arith.mulf %43, %23 : tensor<256xf32>
63
+ gpu.barrier
64
+ %45 = tt.addptr %arg0, %0 : !tt.ptr<f32, 1>, i32
65
+ %46 = tt.splat %45 : (!tt.ptr<f32, 1>) -> tensor<1x!tt.ptr<f32, 1>>
66
+ tt.store %46, %41 {cache = 1 : i32, evict = 1 : i32} : tensor<1xf32>
67
+ %47 = tt.splat %arg7 : (!tt.ptr<bf16, 1>) -> tensor<256x!tt.ptr<bf16, 1>>
68
+ %48 = tt.addptr %47, %5 : tensor<256x!tt.ptr<bf16, 1>>, tensor<256xi32>
69
+ %49 = arith.truncf %44 : tensor<256xf32> to tensor<256xbf16>
70
+ tt.store %48, %49, %2 {cache = 1 : i32, evict = 1 : i32} : tensor<256xbf16>
71
+ %50 = tt.addptr %arg6, %0 : !tt.ptr<f32, 1>, i32
72
+ %51 = tt.splat %50 : (!tt.ptr<f32, 1>) -> tensor<1x!tt.ptr<f32, 1>>
73
+ tt.store %51, %31 {cache = 1 : i32, evict = 1 : i32} : tensor<1xf32>
74
+ tt.return
75
+ }
76
+ }
.triton/dump/15fa39c568de5a2b912a7bda93a479b3/triton_.cubin ADDED
Binary file (7.07 kB). View file
 
.triton/dump/415aac87553b7d064f52694fa7254686/triton_.ttgir ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #blocked = #triton_gpu.blocked<{sizePerThread = [8], threadsPerWarp = [32], warpsPerCTA = [4], order = [0], CTAsPerCGA = [1], CTASplitNum = [1], CTAOrder = [0]}>
2
+ module attributes {"triton_gpu.compute-capability" = 89 : i32, "triton_gpu.num-ctas" = 1 : i32, "triton_gpu.num-warps" = 4 : i32, "triton_gpu.threads-per-warp" = 32 : i32} {
3
+ tt.func public @triton__0d1d2de(%arg0: !tt.ptr<bf16, 1> {tt.divisibility = 16 : i32}, %arg1: !tt.ptr<bf16, 1> {tt.divisibility = 16 : i32}, %arg2: i32 {tt.divisibility = 16 : i32, tt.max_divisibility = 16 : i32}) attributes {noinline = false} {
4
+ %cst = arith.constant dense<1.000000e+00> : tensor<1024xf32, #blocked>
5
+ %cst_0 = arith.constant dense<0.707106769> : tensor<1024xf32, #blocked>
6
+ %cst_1 = arith.constant dense<5.000000e-01> : tensor<1024xf32, #blocked>
7
+ %c1024_i32 = arith.constant 1024 : i32
8
+ %0 = tt.get_program_id x : i32
9
+ %1 = arith.muli %0, %c1024_i32 : i32
10
+ %2 = tt.make_range {end = 1024 : i32, start = 0 : i32} : tensor<1024xi32, #blocked>
11
+ %3 = tt.splat %1 : (i32) -> tensor<1024xi32, #blocked>
12
+ %4 = arith.addi %3, %2 : tensor<1024xi32, #blocked>
13
+ %5 = tt.splat %arg0 : (!tt.ptr<bf16, 1>) -> tensor<1024x!tt.ptr<bf16, 1>, #blocked>
14
+ %6 = tt.addptr %5, %4 : tensor<1024x!tt.ptr<bf16, 1>, #blocked>, tensor<1024xi32, #blocked>
15
+ %7 = tt.load %6 {cache = 1 : i32, evict = 1 : i32, isVolatile = false} : tensor<1024xbf16, #blocked>
16
+ %8 = arith.extf %7 : tensor<1024xbf16, #blocked> to tensor<1024xf32, #blocked>
17
+ %9 = arith.mulf %8, %cst_1 : tensor<1024xf32, #blocked>
18
+ %10 = arith.mulf %8, %cst_0 : tensor<1024xf32, #blocked>
19
+ %11 = tt.extern_elementwise %10 {libname = "libdevice", libpath = "/usr/local/lib/python3.10/dist-packages/triton/language/../third_party/cuda/lib/libdevice.10.bc", pure = true, symbol = "__nv_erff"} : (tensor<1024xf32, #blocked>) -> tensor<1024xf32, #blocked>
20
+ %12 = arith.addf %11, %cst : tensor<1024xf32, #blocked>
21
+ %13 = arith.mulf %9, %12 : tensor<1024xf32, #blocked>
22
+ %14 = tt.splat %arg1 : (!tt.ptr<bf16, 1>) -> tensor<1024x!tt.ptr<bf16, 1>, #blocked>
23
+ %15 = tt.addptr %14, %4 : tensor<1024x!tt.ptr<bf16, 1>, #blocked>, tensor<1024xi32, #blocked>
24
+ %16 = arith.truncf %13 : tensor<1024xf32, #blocked> to tensor<1024xbf16, #blocked>
25
+ tt.store %15, %16 {cache = 1 : i32, evict = 1 : i32} : tensor<1024xbf16, #blocked>
26
+ tt.return
27
+ }
28
+ }
.triton/dump/4c6ad48573c74d55ed79384f6b432d50/triton_.cubin ADDED
Binary file (5.54 kB). View file
 
.triton/dump/4c6ad48573c74d55ed79384f6b432d50/triton_.llir ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ; ModuleID = 'LLVMDialectModule'
2
+ source_filename = "LLVMDialectModule"
3
+
4
+ define void @triton__0d1d2de(ptr addrspace(1) %0, ptr addrspace(1) %1, i32 %2) local_unnamed_addr !dbg !5 {
5
+ %4 = tail call i32 @llvm.nvvm.read.ptx.sreg.tid.x(), !dbg !8
6
+ %5 = shl i32 %4, 3, !dbg !8
7
+ %6 = and i32 %5, 1016, !dbg !8
8
+ %7 = tail call i32 asm "mov.u32 $0, %ctaid.x;", "=r"() #1, !dbg !9
9
+ %8 = shl i32 %7, 10, !dbg !10
10
+ %9 = or i32 %8, %6, !dbg !11
11
+ %10 = or i32 %9, 4, !dbg !11
12
+ %11 = sext i32 %9 to i64, !dbg !12
13
+ %12 = getelementptr float, ptr addrspace(1) %0, i64 %11, !dbg !12
14
+ %13 = sext i32 %10 to i64, !dbg !12
15
+ %14 = getelementptr float, ptr addrspace(1) %0, i64 %13, !dbg !12
16
+ %15 = tail call { i32, i32, i32, i32 } asm sideeffect "mov.u32 $0, 0x0;\0A\09mov.u32 $1, 0x0;\0A\09mov.u32 $2, 0x0;\0A\09mov.u32 $3, 0x0;\0A\09@$5 ld.global.v4.b32 { $0, $1, $2, $3 }, [ $4 + 0 ];", "=r,=r,=r,=r,l,b"(ptr addrspace(1) %12, i1 true) #1, !dbg !13
17
+ %16 = extractvalue { i32, i32, i32, i32 } %15, 0, !dbg !13
18
+ %17 = extractvalue { i32, i32, i32, i32 } %15, 1, !dbg !13
19
+ %18 = extractvalue { i32, i32, i32, i32 } %15, 2, !dbg !13
20
+ %19 = extractvalue { i32, i32, i32, i32 } %15, 3, !dbg !13
21
+ %20 = bitcast i32 %16 to float, !dbg !13
22
+ %21 = bitcast i32 %17 to float, !dbg !13
23
+ %22 = bitcast i32 %18 to float, !dbg !13
24
+ %23 = bitcast i32 %19 to float, !dbg !13
25
+ %24 = tail call { i32, i32, i32, i32 } asm sideeffect "mov.u32 $0, 0x0;\0A\09mov.u32 $1, 0x0;\0A\09mov.u32 $2, 0x0;\0A\09mov.u32 $3, 0x0;\0A\09@$5 ld.global.v4.b32 { $0, $1, $2, $3 }, [ $4 + 0 ];", "=r,=r,=r,=r,l,b"(ptr addrspace(1) %14, i1 true) #1, !dbg !13
26
+ %25 = extractvalue { i32, i32, i32, i32 } %24, 0, !dbg !13
27
+ %26 = extractvalue { i32, i32, i32, i32 } %24, 1, !dbg !13
28
+ %27 = extractvalue { i32, i32, i32, i32 } %24, 2, !dbg !13
29
+ %28 = extractvalue { i32, i32, i32, i32 } %24, 3, !dbg !13
30
+ %29 = bitcast i32 %25 to float, !dbg !13
31
+ %30 = bitcast i32 %26 to float, !dbg !13
32
+ %31 = bitcast i32 %27 to float, !dbg !13
33
+ %32 = bitcast i32 %28 to float, !dbg !13
34
+ %33 = getelementptr i16, ptr addrspace(1) %1, i64 %11, !dbg !14
35
+ %34 = tail call i16 asm "cvt.rn.bf16.f32 $0, $1;", "=h,r"(float %20) #1, !dbg !15
36
+ %35 = tail call i16 asm "cvt.rn.bf16.f32 $0, $1;", "=h,r"(float %21) #1, !dbg !15
37
+ %36 = tail call i16 asm "cvt.rn.bf16.f32 $0, $1;", "=h,r"(float %22) #1, !dbg !15
38
+ %37 = tail call i16 asm "cvt.rn.bf16.f32 $0, $1;", "=h,r"(float %23) #1, !dbg !15
39
+ %38 = tail call i16 asm "cvt.rn.bf16.f32 $0, $1;", "=h,r"(float %29) #1, !dbg !15
40
+ %39 = tail call i16 asm "cvt.rn.bf16.f32 $0, $1;", "=h,r"(float %30) #1, !dbg !15
41
+ %40 = tail call i16 asm "cvt.rn.bf16.f32 $0, $1;", "=h,r"(float %31) #1, !dbg !15
42
+ %41 = tail call i16 asm "cvt.rn.bf16.f32 $0, $1;", "=h,r"(float %32) #1, !dbg !15
43
+ %42 = insertelement <2 x i16> undef, i16 %34, i64 0, !dbg !15
44
+ %43 = insertelement <2 x i16> %42, i16 %35, i64 1, !dbg !15
45
+ %44 = bitcast <2 x i16> %43 to i32, !dbg !15
46
+ %45 = insertelement <2 x i16> undef, i16 %36, i64 0, !dbg !15
47
+ %46 = insertelement <2 x i16> %45, i16 %37, i64 1, !dbg !15
48
+ %47 = bitcast <2 x i16> %46 to i32, !dbg !15
49
+ %48 = insertelement <2 x i16> undef, i16 %38, i64 0, !dbg !15
50
+ %49 = insertelement <2 x i16> %48, i16 %39, i64 1, !dbg !15
51
+ %50 = bitcast <2 x i16> %49 to i32, !dbg !15
52
+ %51 = insertelement <2 x i16> undef, i16 %40, i64 0, !dbg !15
53
+ %52 = insertelement <2 x i16> %51, i16 %41, i64 1, !dbg !15
54
+ %53 = bitcast <2 x i16> %52 to i32, !dbg !15
55
+ tail call void asm sideeffect "@$5 st.global.v4.b32 [ $4 + 0 ], { $0, $1, $2, $3 };", "r,r,r,r,l,b"(i32 %44, i32 %47, i32 %50, i32 %53, ptr addrspace(1) %33, i1 true) #1, !dbg !15
56
+ ret void, !dbg !16
57
+ }
58
+
59
+ ; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
60
+ declare noundef i32 @llvm.nvvm.read.ptx.sreg.tid.x() #0
61
+
62
+ attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
63
+ attributes #1 = { nounwind }
64
+
65
+ !llvm.module.flags = !{!0}
66
+ !llvm.dbg.cu = !{!1}
67
+ !nvvm.annotations = !{!3, !4, !4, !3}
68
+
69
+ !0 = !{i32 2, !"Debug Info Version", i32 3}
70
+ !1 = distinct !DICompileUnit(language: DW_LANG_C, file: !2, producer: "triton", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug)
71
+ !2 = !DIFile(filename: "czjxjqxojsyyr4zmce6q6twysnucw6p4l5ujgp6ts2ecrm3ue3ex.py", directory: "/tmp/torchinductor_root/zj")
72
+ !3 = !{ptr @triton__0d1d2de, !"kernel", i32 1}
73
+ !4 = !{ptr @triton__0d1d2de, !"maxntidx", i32 128}
74
+ !5 = distinct !DISubprogram(name: "triton__0d1d2de", linkageName: "triton__0d1d2de", scope: !2, file: !2, line: 18, type: !6, scopeLine: 18, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !1)
75
+ !6 = !DISubroutineType(cc: DW_CC_normal, types: !7)
76
+ !7 = !{}
77
+ !8 = !DILocation(line: 21, column: 36, scope: !5)
78
+ !9 = !DILocation(line: 20, column: 28, scope: !5)
79
+ !10 = !DILocation(line: 20, column: 33, scope: !5)
80
+ !11 = !DILocation(line: 21, column: 23, scope: !5)
81
+ !12 = !DILocation(line: 24, column: 30, scope: !5)
82
+ !13 = !DILocation(line: 24, column: 35, scope: !5)
83
+ !14 = !DILocation(line: 26, column: 25, scope: !5)
84
+ !15 = !DILocation(line: 26, column: 36, scope: !5)
85
+ !16 = !DILocation(line: 26, column: 4, scope: !5)
.triton/dump/4c6ad48573c74d55ed79384f6b432d50/triton_.ptx ADDED
@@ -0,0 +1,312 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //
2
+ // Generated by LLVM NVPTX Back-End
3
+ //
4
+
5
+ .version 8.2
6
+ .target sm_89
7
+ .address_size 64
8
+
9
+ // .globl triton__0d1d2de
10
+
11
+ .visible .entry triton__0d1d2de(
12
+ .param .u64 triton__0d1d2de_param_0,
13
+ .param .u64 triton__0d1d2de_param_1,
14
+ .param .u32 triton__0d1d2de_param_2
15
+ )
16
+ .maxntid 128, 1, 1
17
+ {
18
+ .reg .pred %p<4>;
19
+ .reg .b16 %rs<9>;
20
+ .reg .b32 %r<31>;
21
+ .reg .b64 %rd<8>;
22
+ .loc 1 18 0
23
+ $L__func_begin0:
24
+ .loc 1 18 0
25
+
26
+ ld.param.u64 %rd4, [triton__0d1d2de_param_0];
27
+ ld.param.u64 %rd5, [triton__0d1d2de_param_1];
28
+ $L__tmp0:
29
+ .loc 1 21 36
30
+ mov.u32 %r22, %tid.x;
31
+ shl.b32 %r23, %r22, 3;
32
+ and.b32 %r24, %r23, 1016;
33
+ .loc 1 20 28
34
+ mov.u32 %r1, %ctaid.x;
35
+ .loc 1 20 33
36
+ shl.b32 %r25, %r1, 10;
37
+ .loc 1 21 23
38
+ or.b32 %r26, %r25, %r24;
39
+ .loc 1 24 30
40
+ mul.wide.s32 %rd6, %r26, 4;
41
+ add.s64 %rd1, %rd4, %rd6;
42
+ add.s64 %rd2, %rd1, 16;
43
+ mov.pred %p1, -1;
44
+ .loc 1 24 35
45
+ mov.u32 %r10, 0x0;
46
+ mov.u32 %r11, 0x0;
47
+ mov.u32 %r12, 0x0;
48
+ mov.u32 %r13, 0x0;
49
+ @%p1 ld.global.v4.b32 { %r10, %r11, %r12, %r13 }, [ %rd1 + 0 ];
50
+ mov.u32 %r14, 0x0;
51
+ mov.u32 %r15, 0x0;
52
+ mov.u32 %r16, 0x0;
53
+ mov.u32 %r17, 0x0;
54
+ @%p1 ld.global.v4.b32 { %r14, %r15, %r16, %r17 }, [ %rd2 + 0 ];
55
+ .loc 1 26 25
56
+ mul.wide.s32 %rd7, %r26, 2;
57
+ add.s64 %rd3, %rd5, %rd7;
58
+ .loc 1 26 36
59
+ cvt.rn.bf16.f32 %rs1, %r10;
60
+ cvt.rn.bf16.f32 %rs2, %r11;
61
+ cvt.rn.bf16.f32 %rs3, %r12;
62
+ cvt.rn.bf16.f32 %rs4, %r13;
63
+ cvt.rn.bf16.f32 %rs5, %r14;
64
+ cvt.rn.bf16.f32 %rs6, %r15;
65
+ cvt.rn.bf16.f32 %rs7, %r16;
66
+ cvt.rn.bf16.f32 %rs8, %r17;
67
+ mov.b32 %r27, {%rs1, %rs2};
68
+ mov.b32 %r28, {%rs3, %rs4};
69
+ mov.b32 %r29, {%rs5, %rs6};
70
+ mov.b32 %r30, {%rs7, %rs8};
71
+ @%p1 st.global.v4.b32 [ %rd3 + 0 ], { %r27, %r28, %r29, %r30 };
72
+ .loc 1 26 4
73
+ ret;
74
+ $L__tmp1:
75
+ $L__func_end0:
76
+
77
+ }
78
+ .file 1 "/tmp/torchinductor_root/zj/czjxjqxojsyyr4zmce6q6twysnucw6p4l5ujgp6ts2ecrm3ue3ex.py"
79
+ .section .debug_abbrev
80
+ {
81
+ .b8 1
82
+ .b8 17
83
+ .b8 1
84
+ .b8 37
85
+ .b8 8
86
+ .b8 19
87
+ .b8 5
88
+ .b8 3
89
+ .b8 8
90
+ .b8 16
91
+ .b8 6
92
+ .b8 27
93
+ .b8 8
94
+ .b8 180
95
+ .b8 66
96
+ .b8 12
97
+ .b8 17
98
+ .b8 1
99
+ .b8 18
100
+ .b8 1
101
+ .b8 0
102
+ .b8 0
103
+ .b8 2
104
+ .b8 46
105
+ .b8 0
106
+ .b8 17
107
+ .b8 1
108
+ .b8 18
109
+ .b8 1
110
+ .b8 64
111
+ .b8 10
112
+ .b8 135
113
+ .b8 64
114
+ .b8 8
115
+ .b8 3
116
+ .b8 8
117
+ .b8 58
118
+ .b8 11
119
+ .b8 59
120
+ .b8 11
121
+ .b8 63
122
+ .b8 12
123
+ .b8 0
124
+ .b8 0
125
+ .b8 0
126
+ }
127
+ .section .debug_info
128
+ {
129
+ .b32 176
130
+ .b8 2
131
+ .b8 0
132
+ .b32 .debug_abbrev
133
+ .b8 8
134
+ .b8 1
135
+ .b8 116
136
+ .b8 114
137
+ .b8 105
138
+ .b8 116
139
+ .b8 111
140
+ .b8 110
141
+ .b8 0
142
+ .b8 2
143
+ .b8 0
144
+ .b8 99
145
+ .b8 122
146
+ .b8 106
147
+ .b8 120
148
+ .b8 106
149
+ .b8 113
150
+ .b8 120
151
+ .b8 111
152
+ .b8 106
153
+ .b8 115
154
+ .b8 121
155
+ .b8 121
156
+ .b8 114
157
+ .b8 52
158
+ .b8 122
159
+ .b8 109
160
+ .b8 99
161
+ .b8 101
162
+ .b8 54
163
+ .b8 113
164
+ .b8 54
165
+ .b8 116
166
+ .b8 119
167
+ .b8 121
168
+ .b8 115
169
+ .b8 110
170
+ .b8 117
171
+ .b8 99
172
+ .b8 119
173
+ .b8 54
174
+ .b8 112
175
+ .b8 52
176
+ .b8 108
177
+ .b8 53
178
+ .b8 117
179
+ .b8 106
180
+ .b8 103
181
+ .b8 112
182
+ .b8 54
183
+ .b8 116
184
+ .b8 115
185
+ .b8 50
186
+ .b8 101
187
+ .b8 99
188
+ .b8 114
189
+ .b8 109
190
+ .b8 51
191
+ .b8 117
192
+ .b8 101
193
+ .b8 51
194
+ .b8 101
195
+ .b8 120
196
+ .b8 46
197
+ .b8 112
198
+ .b8 121
199
+ .b8 0
200
+ .b32 .debug_line
201
+ .b8 47
202
+ .b8 116
203
+ .b8 109
204
+ .b8 112
205
+ .b8 47
206
+ .b8 116
207
+ .b8 111
208
+ .b8 114
209
+ .b8 99
210
+ .b8 104
211
+ .b8 105
212
+ .b8 110
213
+ .b8 100
214
+ .b8 117
215
+ .b8 99
216
+ .b8 116
217
+ .b8 111
218
+ .b8 114
219
+ .b8 95
220
+ .b8 114
221
+ .b8 111
222
+ .b8 111
223
+ .b8 116
224
+ .b8 47
225
+ .b8 122
226
+ .b8 106
227
+ .b8 0
228
+ .b8 1
229
+ .b64 $L__func_begin0
230
+ .b64 $L__func_end0
231
+ .b8 2
232
+ .b64 $L__func_begin0
233
+ .b64 $L__func_end0
234
+ .b8 1
235
+ .b8 156
236
+ .b8 116
237
+ .b8 114
238
+ .b8 105
239
+ .b8 116
240
+ .b8 111
241
+ .b8 110
242
+ .b8 95
243
+ .b8 95
244
+ .b8 48
245
+ .b8 100
246
+ .b8 49
247
+ .b8 100
248
+ .b8 50
249
+ .b8 100
250
+ .b8 101
251
+ .b8 0
252
+ .b8 116
253
+ .b8 114
254
+ .b8 105
255
+ .b8 116
256
+ .b8 111
257
+ .b8 110
258
+ .b8 95
259
+ .b8 95
260
+ .b8 48
261
+ .b8 100
262
+ .b8 49
263
+ .b8 100
264
+ .b8 50
265
+ .b8 100
266
+ .b8 101
267
+ .b8 0
268
+ .b8 1
269
+ .b8 18
270
+ .b8 1
271
+ .b8 0
272
+ }
273
+ .section .debug_pubnames
274
+ {
275
+ .b32 $L__pubNames_end0-$L__pubNames_start0
276
+ $L__pubNames_start0:
277
+ .b8 2
278
+ .b8 0
279
+ .b32 .debug_info
280
+ .b32 180
281
+ .b32 125
282
+ .b8 116
283
+ .b8 114
284
+ .b8 105
285
+ .b8 116
286
+ .b8 111
287
+ .b8 110
288
+ .b8 95
289
+ .b8 95
290
+ .b8 48
291
+ .b8 100
292
+ .b8 49
293
+ .b8 100
294
+ .b8 50
295
+ .b8 100
296
+ .b8 101
297
+ .b8 0
298
+ .b32 0
299
+ $L__pubNames_end0:
300
+ }
301
+ .section .debug_pubtypes
302
+ {
303
+ .b32 $L__pubTypes_end0-$L__pubTypes_start0
304
+ $L__pubTypes_start0:
305
+ .b8 2
306
+ .b8 0
307
+ .b32 .debug_info
308
+ .b32 180
309
+ .b32 0
310
+ $L__pubTypes_end0:
311
+ }
312
+ .section .debug_loc { }
.triton/dump/4d7b96448927b8146af43cb9f39e0544/triton_.cubin ADDED
Binary file (12 kB). View file
 
.triton/dump/645565eaba0a18dd23ef200fe9abb0c0/triton_.llir ADDED
@@ -0,0 +1,349 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ; ModuleID = 'LLVMDialectModule'
2
+ source_filename = "LLVMDialectModule"
3
+
4
+ @assertFunc_0 = internal constant [25 x i8] c"_call_with_frames_removed"
5
+ @assertFile_0 = internal constant [38 x i8] c"<frozen importlib._bootstrap_external>"
6
+ @assertMessage_0 = internal constant [38 x i8] c"index out of bounds: 0 <= tmp3 < 50257"
7
+ @global_smem = external addrspace(3) global [0 x i8]
8
+ @.str = private unnamed_addr constant [11 x i8] c"__CUDA_FTZ\00", align 1
9
+
10
+ declare void @__assertfail(ptr, ptr, i32, ptr, i64) local_unnamed_addr
11
+
12
+ define void @triton__0d1d2d3d4d5d6d7d8de9de(ptr addrspace(1) %0, ptr addrspace(1) %1, ptr addrspace(1) %2, ptr addrspace(1) %3, ptr addrspace(1) %4, ptr addrspace(1) %5, ptr addrspace(1) %6, ptr addrspace(1) %7, i32 %8, i32 %9) local_unnamed_addr !dbg !7 {
13
+ %11 = tail call i32 @llvm.nvvm.read.ptx.sreg.tid.x(), !dbg !10
14
+ %urem = and i32 %11, 63, !dbg !10
15
+ %12 = shl nuw nsw i32 %urem, 2, !dbg !10
16
+ %13 = tail call i32 asm "mov.u32 $0, %ctaid.x;", "=r"() #6, !dbg !11
17
+ %14 = srem i32 %13, 512, !dbg !12
18
+ %15 = sext i32 %13 to i64, !dbg !13
19
+ %16 = getelementptr i64, ptr addrspace(1) %1, i64 %15, !dbg !13
20
+ %17 = tail call i64 asm sideeffect "mov.u64 $0, 0x0;\0A\09@$2 ld.global.L1::evict_last.b64 { $0 }, [ $1 + 0 ];", "=l,l,b"(ptr addrspace(1) %16, i1 true) #6, !dbg !14
21
+ %18 = tail call i64 asm sideeffect "mov.u64 $0, 0x0;\0A\09@$2 ld.global.L1::evict_last.b64 { $0 }, [ $1 + 0 ];", "=l,l,b"(ptr addrspace(1) %16, i1 true) #6, !dbg !14
22
+ %19 = tail call i64 asm sideeffect "mov.u64 $0, 0x0;\0A\09@$2 ld.global.L1::evict_last.b64 { $0 }, [ $1 + 0 ];", "=l,l,b"(ptr addrspace(1) %16, i1 true) #6, !dbg !14
23
+ %20 = tail call i64 asm sideeffect "mov.u64 $0, 0x0;\0A\09@$2 ld.global.L1::evict_last.b64 { $0 }, [ $1 + 0 ];", "=l,l,b"(ptr addrspace(1) %16, i1 true) #6, !dbg !14
24
+ %21 = tail call i64 asm sideeffect "mov.u64 $0, 0x0;\0A\09@$2 ld.global.L1::evict_last.b64 { $0 }, [ $1 + 0 ];", "=l,l,b"(ptr addrspace(1) %16, i1 true) #6, !dbg !14
25
+ %22 = shl nsw i32 %14, 8, !dbg !15
26
+ %23 = or i32 %22, %12, !dbg !16
27
+ %24 = sext i32 %23 to i64, !dbg !17
28
+ %25 = getelementptr float, ptr addrspace(1) %3, i64 %24, !dbg !17
29
+ %26 = tail call { i32, i32, i32, i32 } asm sideeffect "mov.u32 $0, 0x0;\0A\09mov.u32 $1, 0x0;\0A\09mov.u32 $2, 0x0;\0A\09mov.u32 $3, 0x0;\0A\09@$5 ld.global.L1::evict_last.v4.b32 { $0, $1, $2, $3 }, [ $4 + 0 ];\0A\09@!$7 mov.u32 $0, $6;\0A\09@!$9 mov.u32 $1, $8;\0A\09@!$11 mov.u32 $2, $10;\0A\09@!$13 mov.u32 $3, $12;", "=r,=r,=r,=r,l,b,r,b,r,b,r,b,r,b"(ptr addrspace(1) %25, i1 true, i32 0, i1 true, i32 0, i1 true, i32 0, i1 true, i32 0, i1 true) #6, !dbg !18
30
+ %27 = zext nneg i32 %12 to i64, !dbg !19
31
+ %28 = getelementptr float, ptr addrspace(1) %4, i64 %27, !dbg !19
32
+ %29 = tail call { i32, i32, i32, i32 } asm sideeffect "mov.u32 $0, 0x0;\0A\09mov.u32 $1, 0x0;\0A\09mov.u32 $2, 0x0;\0A\09mov.u32 $3, 0x0;\0A\09@$5 ld.global.L1::evict_last.v4.b32 { $0, $1, $2, $3 }, [ $4 + 0 ];\0A\09@!$7 mov.u32 $0, $6;\0A\09@!$9 mov.u32 $1, $8;\0A\09@!$11 mov.u32 $2, $10;\0A\09@!$13 mov.u32 $3, $12;", "=r,=r,=r,=r,l,b,r,b,r,b,r,b,r,b"(ptr addrspace(1) %28, i1 true, i32 0, i1 true, i32 0, i1 true, i32 0, i1 true, i32 0, i1 true) #6, !dbg !20
33
+ %30 = add i64 %21, 50257, !dbg !21
34
+ %31 = icmp slt i64 %21, 0, !dbg !22
35
+ %32 = select i1 %31, i64 %30, i64 %21, !dbg !23
36
+ %33 = icmp ugt i64 %32, 50256, !dbg !24
37
+ br i1 %33, label %34, label %35, !dbg !25
38
+
39
+ 34: ; preds = %10
40
+ tail call void @__assertfail(ptr nonnull @assertMessage_0, ptr nonnull @assertFile_0, i32 883, ptr nonnull @assertFunc_0, i64 1), !dbg !25
41
+ br label %35, !dbg !25
42
+
43
+ 35: ; preds = %34, %10
44
+ %36 = icmp slt i64 %17, 0, !dbg !22
45
+ %37 = extractvalue { i32, i32, i32, i32 } %26, 3, !dbg !18
46
+ %38 = extractvalue { i32, i32, i32, i32 } %26, 2, !dbg !18
47
+ %39 = extractvalue { i32, i32, i32, i32 } %26, 1, !dbg !18
48
+ %40 = extractvalue { i32, i32, i32, i32 } %26, 0, !dbg !18
49
+ %41 = lshr i32 %11, 5, !dbg !10
50
+ %42 = and i32 %41, 1, !dbg !10
51
+ %43 = and i32 %11, 31, !dbg !10
52
+ %44 = shl i64 %17, 8, !dbg !26
53
+ %45 = add i64 %44, 12865792, !dbg !26
54
+ %46 = select i1 %36, i64 %45, i64 %44, !dbg !26
55
+ %47 = or i64 %46, %27, !dbg !27
56
+ %48 = getelementptr float, ptr addrspace(1) %2, i64 %47, !dbg !28
57
+ %49 = tail call { i32, i32, i32, i32 } asm sideeffect "mov.u32 $0, 0x0;\0A\09mov.u32 $1, 0x0;\0A\09mov.u32 $2, 0x0;\0A\09mov.u32 $3, 0x0;\0A\09@$5 ld.global.v4.b32 { $0, $1, $2, $3 }, [ $4 + 0 ];\0A\09@!$7 mov.u32 $0, $6;\0A\09@!$9 mov.u32 $1, $8;\0A\09@!$11 mov.u32 $2, $10;\0A\09@!$13 mov.u32 $3, $12;", "=r,=r,=r,=r,l,b,r,b,r,b,r,b,r,b"(ptr addrspace(1) %48, i1 true, i32 0, i1 true, i32 0, i1 true, i32 0, i1 true, i32 0, i1 true) #6, !dbg !29
58
+ %50 = extractvalue { i32, i32, i32, i32 } %49, 0, !dbg !29
59
+ %51 = extractvalue { i32, i32, i32, i32 } %49, 1, !dbg !29
60
+ %52 = extractvalue { i32, i32, i32, i32 } %49, 2, !dbg !29
61
+ %53 = extractvalue { i32, i32, i32, i32 } %49, 3, !dbg !29
62
+ %54 = insertelement <2 x i32> poison, i32 %40, i64 0, !dbg !18
63
+ %55 = insertelement <2 x i32> %54, i32 %39, i64 1, !dbg !18
64
+ %56 = bitcast <2 x i32> %55 to <2 x float>, !dbg !18
65
+ %57 = insertelement <2 x i32> poison, i32 %50, i64 0, !dbg !29
66
+ %58 = insertelement <2 x i32> %57, i32 %51, i64 1, !dbg !29
67
+ %59 = bitcast <2 x i32> %58 to <2 x float>, !dbg !29
68
+ %60 = fadd <2 x float> %56, %59, !dbg !30
69
+ %61 = insertelement <2 x i32> poison, i32 %37, i64 0, !dbg !18
70
+ %62 = insertelement <2 x i32> %61, i32 %38, i64 1, !dbg !18
71
+ %63 = bitcast <2 x i32> %62 to <2 x float>, !dbg !18
72
+ %64 = insertelement <2 x i32> poison, i32 %53, i64 0, !dbg !29
73
+ %65 = insertelement <2 x i32> %64, i32 %52, i64 1, !dbg !29
74
+ %66 = bitcast <2 x i32> %65 to <2 x float>, !dbg !29
75
+ %67 = fadd <2 x float> %63, %66, !dbg !30
76
+ %68 = extractelement <2 x float> %60, i64 0, !dbg !31
77
+ %69 = extractelement <2 x float> %60, i64 1, !dbg !31
78
+ %70 = fadd float %68, %69, !dbg !31
79
+ %71 = extractelement <2 x float> %67, i64 1, !dbg !31
80
+ %72 = fadd float %71, %70, !dbg !31
81
+ %73 = extractelement <2 x float> %67, i64 0, !dbg !31
82
+ %74 = fadd float %73, %72, !dbg !31
83
+ %75 = bitcast float %74 to i32, !dbg !37
84
+ %76 = tail call i32 @llvm.nvvm.shfl.sync.bfly.i32(i32 -1, i32 %75, i32 16, i32 31), !dbg !37
85
+ %77 = bitcast i32 %76 to float, !dbg !37
86
+ %78 = fadd float %74, %77, !dbg !31
87
+ %79 = bitcast float %78 to i32, !dbg !37
88
+ %80 = tail call i32 @llvm.nvvm.shfl.sync.bfly.i32(i32 -1, i32 %79, i32 8, i32 31), !dbg !37
89
+ %81 = bitcast i32 %80 to float, !dbg !37
90
+ %82 = fadd float %78, %81, !dbg !31
91
+ %83 = bitcast float %82 to i32, !dbg !37
92
+ %84 = tail call i32 @llvm.nvvm.shfl.sync.bfly.i32(i32 -1, i32 %83, i32 4, i32 31), !dbg !37
93
+ %85 = bitcast i32 %84 to float, !dbg !37
94
+ %86 = fadd float %82, %85, !dbg !31
95
+ %87 = bitcast float %86 to i32, !dbg !37
96
+ %88 = tail call i32 @llvm.nvvm.shfl.sync.bfly.i32(i32 -1, i32 %87, i32 2, i32 31), !dbg !37
97
+ %89 = bitcast i32 %88 to float, !dbg !37
98
+ %90 = fadd float %86, %89, !dbg !31
99
+ %91 = bitcast float %90 to i32, !dbg !37
100
+ %92 = tail call i32 @llvm.nvvm.shfl.sync.bfly.i32(i32 -1, i32 %91, i32 1, i32 31), !dbg !37
101
+ %93 = bitcast i32 %92 to float, !dbg !37
102
+ %94 = fadd float %90, %93, !dbg !31
103
+ %95 = icmp eq i32 %43, 0, !dbg !37
104
+ %96 = zext nneg i32 %42 to i64, !dbg !37
105
+ %97 = getelementptr float, ptr addrspace(3) @global_smem, i64 %96, !dbg !37
106
+ tail call void asm sideeffect "@$2 st.shared.b32 [ $0 + 0 ], $1;", "r,r,b"(ptr addrspace(3) %97, float %94, i1 %95) #6, !dbg !37
107
+ tail call void @llvm.nvvm.barrier0(), !dbg !37
108
+ %98 = icmp slt i32 %11, 2, !dbg !37
109
+ %99 = sext i32 %11 to i64, !dbg !37
110
+ %100 = getelementptr float, ptr addrspace(3) @global_smem, i64 %99, !dbg !37
111
+ %101 = tail call float asm sideeffect "@$2 ld.shared.b32 $0, [ $1 + 0 ];", "=r,r,b"(ptr addrspace(3) %100, i1 %98) #6, !dbg !37
112
+ %102 = bitcast float %101 to i32, !dbg !37
113
+ %103 = tail call i32 @llvm.nvvm.shfl.sync.bfly.i32(i32 -1, i32 %102, i32 1, i32 31), !dbg !37
114
+ %104 = bitcast i32 %103 to float, !dbg !37
115
+ %105 = fadd float %101, %104, !dbg !31
116
+ %106 = and i32 %11, 1, !dbg !37
117
+ %107 = icmp eq i32 %106, 0, !dbg !37
118
+ %108 = and i1 %98, %107, !dbg !37
119
+ tail call void asm sideeffect "@$2 st.shared.b32 [ $0 + 0 ], $1;", "r,r,b"(ptr addrspace(3) %100, float %105, i1 %108) #6, !dbg !37
120
+ tail call void @llvm.nvvm.barrier0(), !dbg !37
121
+ %109 = load float, ptr addrspace(3) @global_smem, align 4, !dbg !37
122
+ %110 = fadd float %109, 0.000000e+00, !dbg !39
123
+ %111 = tail call float asm "div.full.f32 $0, $1, $2;", "=r,r,r"(float %110, float 2.560000e+02) #6, !dbg !43
124
+ %112 = fsub float %68, %111, !dbg !44
125
+ %113 = fsub float %69, %111, !dbg !44
126
+ %114 = fsub float %71, %111, !dbg !44
127
+ %115 = fsub float %73, %111, !dbg !44
128
+ %116 = fmul float %112, %112, !dbg !45
129
+ %117 = fmul float %113, %113, !dbg !45
130
+ %118 = fmul float %114, %114, !dbg !45
131
+ %119 = fmul float %115, %115, !dbg !45
132
+ tail call void @llvm.nvvm.barrier0(), !dbg !46
133
+ %120 = fadd float %116, %117, !dbg !48
134
+ %121 = fadd float %118, %120, !dbg !48
135
+ %122 = fadd float %119, %121, !dbg !48
136
+ %123 = bitcast float %122 to i32, !dbg !46
137
+ %124 = tail call i32 @llvm.nvvm.shfl.sync.bfly.i32(i32 -1, i32 %123, i32 16, i32 31), !dbg !46
138
+ %125 = bitcast i32 %124 to float, !dbg !46
139
+ %126 = fadd float %122, %125, !dbg !48
140
+ %127 = bitcast float %126 to i32, !dbg !46
141
+ %128 = tail call i32 @llvm.nvvm.shfl.sync.bfly.i32(i32 -1, i32 %127, i32 8, i32 31), !dbg !46
142
+ %129 = bitcast i32 %128 to float, !dbg !46
143
+ %130 = fadd float %126, %129, !dbg !48
144
+ %131 = bitcast float %130 to i32, !dbg !46
145
+ %132 = tail call i32 @llvm.nvvm.shfl.sync.bfly.i32(i32 -1, i32 %131, i32 4, i32 31), !dbg !46
146
+ %133 = bitcast i32 %132 to float, !dbg !46
147
+ %134 = fadd float %130, %133, !dbg !48
148
+ %135 = bitcast float %134 to i32, !dbg !46
149
+ %136 = tail call i32 @llvm.nvvm.shfl.sync.bfly.i32(i32 -1, i32 %135, i32 2, i32 31), !dbg !46
150
+ %137 = bitcast i32 %136 to float, !dbg !46
151
+ %138 = fadd float %134, %137, !dbg !48
152
+ %139 = bitcast float %138 to i32, !dbg !46
153
+ %140 = tail call i32 @llvm.nvvm.shfl.sync.bfly.i32(i32 -1, i32 %139, i32 1, i32 31), !dbg !46
154
+ %141 = bitcast i32 %140 to float, !dbg !46
155
+ %142 = fadd float %138, %141, !dbg !48
156
+ tail call void asm sideeffect "@$2 st.shared.b32 [ $0 + 0 ], $1;", "r,r,b"(ptr addrspace(3) %97, float %142, i1 %95) #6, !dbg !46
157
+ tail call void @llvm.nvvm.barrier0(), !dbg !46
158
+ %143 = tail call float asm sideeffect "@$2 ld.shared.b32 $0, [ $1 + 0 ];", "=r,r,b"(ptr addrspace(3) %100, i1 %98) #6, !dbg !46
159
+ %144 = bitcast float %143 to i32, !dbg !46
160
+ %145 = tail call i32 @llvm.nvvm.shfl.sync.bfly.i32(i32 -1, i32 %144, i32 1, i32 31), !dbg !46
161
+ %146 = bitcast i32 %145 to float, !dbg !46
162
+ %147 = fadd float %143, %146, !dbg !48
163
+ tail call void asm sideeffect "@$2 st.shared.b32 [ $0 + 0 ], $1;", "r,r,b"(ptr addrspace(3) %100, float %147, i1 %108) #6, !dbg !46
164
+ tail call void @llvm.nvvm.barrier0(), !dbg !46
165
+ %148 = load float, ptr addrspace(3) @global_smem, align 4, !dbg !46
166
+ %149 = fadd float %148, 0.000000e+00, !dbg !51
167
+ %150 = tail call float asm "div.full.f32 $0, $1, $2;", "=r,r,r"(float %149, float 2.560000e+02) #6, !dbg !53
168
+ %151 = fadd float %150, 0x3EE4F8B580000000, !dbg !54
169
+ %152 = tail call i32 @__nvvm_reflect(ptr nonnull @.str) #6, !dbg !55
170
+ %.not.i = icmp eq i32 %152, 0, !dbg !55
171
+ br i1 %.not.i, label %155, label %153, !dbg !55
172
+
173
+ 153: ; preds = %35
174
+ %154 = tail call float @llvm.nvvm.rsqrt.approx.ftz.f(float %151), !dbg !55
175
+ br label %__nv_rsqrtf.exit, !dbg !55
176
+
177
+ 155: ; preds = %35
178
+ %156 = tail call float @llvm.nvvm.rsqrt.approx.f(float %151), !dbg !55
179
+ br label %__nv_rsqrtf.exit, !dbg !55
180
+
181
+ __nv_rsqrtf.exit: ; preds = %153, %155
182
+ %.0.i = phi float [ %154, %153 ], [ %156, %155 ], !dbg !55
183
+ %157 = extractvalue { i32, i32, i32, i32 } %29, 0, !dbg !20
184
+ %158 = bitcast i32 %157 to float, !dbg !20
185
+ %159 = extractvalue { i32, i32, i32, i32 } %29, 1, !dbg !20
186
+ %160 = bitcast i32 %159 to float, !dbg !20
187
+ %161 = extractvalue { i32, i32, i32, i32 } %29, 2, !dbg !20
188
+ %162 = bitcast i32 %161 to float, !dbg !20
189
+ %163 = extractvalue { i32, i32, i32, i32 } %29, 3, !dbg !20
190
+ %164 = bitcast i32 %163 to float, !dbg !20
191
+ %165 = fmul float %112, %.0.i, !dbg !56
192
+ %166 = fmul float %113, %.0.i, !dbg !56
193
+ %167 = fmul float %114, %.0.i, !dbg !56
194
+ %168 = fmul float %115, %.0.i, !dbg !56
195
+ %169 = fmul float %165, %158, !dbg !57
196
+ %170 = fmul float %166, %160, !dbg !57
197
+ %171 = fmul float %167, %162, !dbg !57
198
+ %172 = fmul float %168, %164, !dbg !57
199
+ %173 = shl i32 %13, 8, !dbg !58
200
+ %174 = or i32 %173, %12, !dbg !59
201
+ %175 = sext i32 %174 to i64, !dbg !60
202
+ %176 = getelementptr float, ptr addrspace(1) %5, i64 %175, !dbg !60
203
+ %177 = bitcast float %68 to i32, !dbg !61
204
+ %178 = bitcast float %69 to i32, !dbg !61
205
+ %179 = bitcast float %71 to i32, !dbg !61
206
+ %180 = bitcast float %73 to i32, !dbg !61
207
+ tail call void asm sideeffect "@$5 st.global.v4.b32 [ $4 + 0 ], { $0, $1, $2, $3 };", "r,r,r,r,l,b"(i32 %177, i32 %178, i32 %179, i32 %180, ptr addrspace(1) %176, i1 true) #6, !dbg !61
208
+ tail call void @llvm.nvvm.barrier0(), !dbg !62
209
+ %181 = getelementptr float, ptr addrspace(1) %0, i64 %15, !dbg !63
210
+ %182 = icmp eq i32 %urem, 0, !dbg !64
211
+ %183 = bitcast float %.0.i to i32, !dbg !64
212
+ tail call void asm sideeffect "@$2 st.global.b32 [ $1 + 0 ], { $0 };", "r,l,b"(i32 %183, ptr addrspace(1) %181, i1 %182) #6, !dbg !64
213
+ %184 = getelementptr i16, ptr addrspace(1) %7, i64 %175, !dbg !65
214
+ %185 = tail call i16 asm "cvt.rn.bf16.f32 $0, $1;", "=h,r"(float %169) #6, !dbg !66
215
+ %186 = tail call i16 asm "cvt.rn.bf16.f32 $0, $1;", "=h,r"(float %170) #6, !dbg !66
216
+ %187 = tail call i16 asm "cvt.rn.bf16.f32 $0, $1;", "=h,r"(float %171) #6, !dbg !66
217
+ %188 = tail call i16 asm "cvt.rn.bf16.f32 $0, $1;", "=h,r"(float %172) #6, !dbg !66
218
+ %189 = insertelement <2 x i16> undef, i16 %185, i64 0, !dbg !66
219
+ %190 = insertelement <2 x i16> %189, i16 %186, i64 1, !dbg !66
220
+ %191 = bitcast <2 x i16> %190 to i32, !dbg !66
221
+ %192 = insertelement <2 x i16> undef, i16 %187, i64 0, !dbg !66
222
+ %193 = insertelement <2 x i16> %192, i16 %188, i64 1, !dbg !66
223
+ %194 = bitcast <2 x i16> %193 to i32, !dbg !66
224
+ tail call void asm sideeffect "@$3 st.global.v2.b32 [ $2 + 0 ], { $0, $1 };", "r,r,l,b"(i32 %191, i32 %194, ptr addrspace(1) %184, i1 true) #6, !dbg !66
225
+ %195 = getelementptr float, ptr addrspace(1) %6, i64 %15, !dbg !67
226
+ %196 = bitcast float %111 to i32, !dbg !68
227
+ tail call void asm sideeffect "@$2 st.global.b32 [ $1 + 0 ], { $0 };", "r,l,b"(i32 %196, ptr addrspace(1) %195, i1 %182) #6, !dbg !68
228
+ ret void, !dbg !69
229
+ }
230
+
231
+ ; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
232
+ declare noundef i32 @llvm.nvvm.read.ptx.sreg.tid.x() #0
233
+
234
+ ; Function Attrs: convergent nocallback nounwind memory(inaccessiblemem: readwrite)
235
+ declare i32 @llvm.nvvm.shfl.sync.bfly.i32(i32, i32, i32, i32) #1
236
+
237
+ ; Function Attrs: convergent nocallback nounwind
238
+ declare void @llvm.nvvm.barrier0() #2
239
+
240
+ ; Function Attrs: alwaysinline nounwind
241
+ define float @__nv_rsqrtf(float %x) local_unnamed_addr #3 {
242
+ %1 = tail call i32 @__nvvm_reflect(ptr nonnull @.str) #6
243
+ %.not = icmp eq i32 %1, 0
244
+ br i1 %.not, label %4, label %2
245
+
246
+ 2: ; preds = %0
247
+ %3 = tail call float @llvm.nvvm.rsqrt.approx.ftz.f(float %x)
248
+ br label %6
249
+
250
+ 4: ; preds = %0
251
+ %5 = tail call float @llvm.nvvm.rsqrt.approx.f(float %x)
252
+ br label %6
253
+
254
+ 6: ; preds = %4, %2
255
+ %.0 = phi float [ %3, %2 ], [ %5, %4 ]
256
+ ret float %.0
257
+ }
258
+
259
+ declare i32 @__nvvm_reflect(ptr) local_unnamed_addr #4
260
+
261
+ ; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(none)
262
+ declare float @llvm.nvvm.rsqrt.approx.ftz.f(float) #5
263
+
264
+ ; Function Attrs: mustprogress nocallback nofree nosync nounwind willreturn memory(none)
265
+ declare float @llvm.nvvm.rsqrt.approx.f(float) #5
266
+
267
+ attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
268
+ attributes #1 = { convergent nocallback nounwind memory(inaccessiblemem: readwrite) }
269
+ attributes #2 = { convergent nocallback nounwind }
270
+ attributes #3 = { alwaysinline nounwind "disable-tail-calls"="false" "frame-pointer"="all" "less-precise-fpmad"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
271
+ attributes #4 = { "disable-tail-calls"="false" "frame-pointer"="all" "less-precise-fpmad"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
272
+ attributes #5 = { mustprogress nocallback nofree nosync nounwind willreturn memory(none) }
273
+ attributes #6 = { nounwind }
274
+
275
+ !llvm.module.flags = !{!0, !1}
276
+ !llvm.dbg.cu = !{!2}
277
+ !nvvm.annotations = !{!4, !5, !5, !4}
278
+ !llvm.ident = !{!6}
279
+
280
+ !0 = !{i32 2, !"Debug Info Version", i32 3}
281
+ !1 = !{i32 4, !"nvvm-reflect-ftz", i32 1}
282
+ !2 = distinct !DICompileUnit(language: DW_LANG_C, file: !3, producer: "triton", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug)
283
+ !3 = !DIFile(filename: "cpdqiwgwgnzx7tsvbieui7kffx5dt43uhgvg7z7egekxcsybpv34.py", directory: "/tmp/torchinductor_root/pd")
284
+ !4 = !{ptr @triton__0d1d2d3d4d5d6d7d8de9de, !"kernel", i32 1}
285
+ !5 = !{ptr @triton__0d1d2d3d4d5d6d7d8de9de, !"maxntidx", i32 64}
286
+ !6 = !{!"clang version 3.8.0 (tags/RELEASE_380/final)"}
287
+ !7 = distinct !DISubprogram(name: "triton__0d1d2d3d4d5d6d7d8de9de", linkageName: "triton__0d1d2d3d4d5d6d7d8de9de", scope: !3, file: !3, line: 18, type: !8, scopeLine: 18, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2)
288
+ !8 = !DISubroutineType(cc: DW_CC_normal, types: !9)
289
+ !9 = !{}
290
+ !10 = !DILocation(line: 26, column: 26, scope: !7)
291
+ !11 = !DILocation(line: 23, column: 28, scope: !7)
292
+ !12 = !DILocation(line: 30, column: 18, scope: !7)
293
+ !13 = !DILocation(line: 31, column: 30, scope: !7)
294
+ !14 = !DILocation(line: 31, column: 35, scope: !7)
295
+ !15 = !DILocation(line: 32, column: 40, scope: !7)
296
+ !16 = !DILocation(line: 32, column: 36, scope: !7)
297
+ !17 = !DILocation(line: 32, column: 30, scope: !7)
298
+ !18 = !DILocation(line: 32, column: 46, scope: !7)
299
+ !19 = !DILocation(line: 33, column: 31, scope: !7)
300
+ !20 = !DILocation(line: 33, column: 36, scope: !7)
301
+ !21 = !DILocation(line: 34, column: 18, scope: !7)
302
+ !22 = !DILocation(line: 35, column: 18, scope: !7)
303
+ !23 = !DILocation(line: 36, column: 32, scope: !7)
304
+ !24 = !DILocation(line: 37, column: 36, scope: !7)
305
+ !25 = !DILocation(line: 37, column: 51, scope: !7)
306
+ !26 = !DILocation(line: 38, column: 40, scope: !7)
307
+ !27 = !DILocation(line: 38, column: 36, scope: !7)
308
+ !28 = !DILocation(line: 38, column: 30, scope: !7)
309
+ !29 = !DILocation(line: 38, column: 48, scope: !7)
310
+ !30 = !DILocation(line: 39, column: 18, scope: !7)
311
+ !31 = !DILocation(line: 233, column: 15, scope: !32, inlinedAt: !35)
312
+ !32 = distinct !DILexicalBlockFile(scope: !34, file: !33, discriminator: 0)
313
+ !33 = !DIFile(filename: "standard.py", directory: "/usr/local/lib/python3.10/dist-packages/triton/language")
314
+ !34 = distinct !DILexicalBlockFile(scope: !7, file: !33, discriminator: 0)
315
+ !35 = !DILocation(line: 243, column: 36, scope: !32, inlinedAt: !36)
316
+ !36 = !DILocation(line: 44, column: 59, scope: !32)
317
+ !37 = !DILocation(line: 243, column: 36, scope: !34, inlinedAt: !38)
318
+ !38 = !DILocation(line: 44, column: 59, scope: !34)
319
+ !39 = !DILocation(line: 8, column: 15, scope: !40, inlinedAt: !42)
320
+ !40 = distinct !DILexicalBlockFile(scope: !7, file: !41, discriminator: 0)
321
+ !41 = !DIFile(filename: "triton_helpers.py", directory: "/usr/local/lib/python3.10/dist-packages/torch/_inductor")
322
+ !42 = !DILocation(line: 44, column: 45, scope: !40)
323
+ !43 = !DILocation(line: 47, column: 20, scope: !7)
324
+ !44 = !DILocation(line: 48, column: 19, scope: !7)
325
+ !45 = !DILocation(line: 49, column: 20, scope: !7)
326
+ !46 = !DILocation(line: 243, column: 36, scope: !34, inlinedAt: !47)
327
+ !47 = !DILocation(line: 52, column: 59, scope: !34)
328
+ !48 = !DILocation(line: 233, column: 15, scope: !32, inlinedAt: !49)
329
+ !49 = !DILocation(line: 243, column: 36, scope: !32, inlinedAt: !50)
330
+ !50 = !DILocation(line: 52, column: 59, scope: !32)
331
+ !51 = !DILocation(line: 8, column: 15, scope: !40, inlinedAt: !52)
332
+ !52 = !DILocation(line: 52, column: 45, scope: !40)
333
+ !53 = !DILocation(line: 54, column: 20, scope: !7)
334
+ !54 = !DILocation(line: 56, column: 20, scope: !7)
335
+ !55 = !DILocation(line: 57, column: 26, scope: !7)
336
+ !56 = !DILocation(line: 59, column: 20, scope: !7)
337
+ !57 = !DILocation(line: 60, column: 20, scope: !7)
338
+ !58 = !DILocation(line: 62, column: 35, scope: !7)
339
+ !59 = !DILocation(line: 62, column: 31, scope: !7)
340
+ !60 = !DILocation(line: 62, column: 25, scope: !7)
341
+ !61 = !DILocation(line: 62, column: 47, scope: !7)
342
+ !62 = !DILocation(line: 63, column: 4, scope: !7)
343
+ !63 = !DILocation(line: 64, column: 28, scope: !7)
344
+ !64 = !DILocation(line: 64, column: 40, scope: !7)
345
+ !65 = !DILocation(line: 65, column: 25, scope: !7)
346
+ !66 = !DILocation(line: 65, column: 48, scope: !7)
347
+ !67 = !DILocation(line: 66, column: 25, scope: !7)
348
+ !68 = !DILocation(line: 66, column: 37, scope: !7)
349
+ !69 = !DILocation(line: 66, column: 4, scope: !7)
.triton/dump/8c4bac4d904709a8b7e8c698132d974c/triton_.llir ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ; ModuleID = 'LLVMDialectModule'
2
+ source_filename = "LLVMDialectModule"
3
+
4
+ define void @triton__0d1de(ptr addrspace(1) %0, i32 %1) local_unnamed_addr !dbg !5 {
5
+ %3 = tail call i32 @llvm.nvvm.read.ptx.sreg.tid.x(), !dbg !8
6
+ %4 = shl i32 %3, 1, !dbg !8
7
+ %5 = and i32 %4, 254, !dbg !8
8
+ %6 = tail call i32 asm "mov.u32 $0, %ctaid.x;", "=r"() #1, !dbg !9
9
+ %7 = shl i32 %6, 8, !dbg !10
10
+ %8 = or i32 %7, %5, !dbg !11
11
+ %9 = or i32 %8, 1, !dbg !11
12
+ %10 = icmp slt i32 %8, 512, !dbg !12
13
+ %11 = sext i32 %8 to i64, !dbg !13
14
+ %12 = getelementptr i64, ptr addrspace(1) %0, i64 %11, !dbg !13
15
+ %13 = sext i32 %9 to i64, !dbg !14
16
+ tail call void asm sideeffect "@$3 st.global.v2.b64 [ $2 + 0 ], { $0, $1 };", "l,l,l,b"(i64 %11, i64 %13, ptr addrspace(1) %12, i1 %10) #1, !dbg !14
17
+ ret void, !dbg !15
18
+ }
19
+
20
+ ; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
21
+ declare noundef i32 @llvm.nvvm.read.ptx.sreg.tid.x() #0
22
+
23
+ attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
24
+ attributes #1 = { nounwind }
25
+
26
+ !llvm.module.flags = !{!0}
27
+ !llvm.dbg.cu = !{!1}
28
+ !nvvm.annotations = !{!3, !4, !4, !3}
29
+
30
+ !0 = !{i32 2, !"Debug Info Version", i32 3}
31
+ !1 = distinct !DICompileUnit(language: DW_LANG_C, file: !2, producer: "triton", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug)
32
+ !2 = !DIFile(filename: "cwxxgxdevnyc453z7hh4nxzgmvlhh6suwokktps3dw62btskgxt4.py", directory: "/tmp/torchinductor_root/wx")
33
+ !3 = !{ptr @triton__0d1de, !"kernel", i32 1}
34
+ !4 = !{ptr @triton__0d1de, !"maxntidx", i32 128}
35
+ !5 = distinct !DISubprogram(name: "triton__0d1de", linkageName: "triton__0d1de", scope: !2, file: !2, line: 18, type: !6, scopeLine: 18, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !1)
36
+ !6 = !DISubroutineType(cc: DW_CC_normal, types: !7)
37
+ !7 = !{}
38
+ !8 = !DILocation(line: 21, column: 36, scope: !5)
39
+ !9 = !DILocation(line: 20, column: 28, scope: !5)
40
+ !10 = !DILocation(line: 20, column: 33, scope: !5)
41
+ !11 = !DILocation(line: 21, column: 23, scope: !5)
42
+ !12 = !DILocation(line: 22, column: 21, scope: !5)
43
+ !13 = !DILocation(line: 25, column: 25, scope: !5)
44
+ !14 = !DILocation(line: 25, column: 36, scope: !5)
45
+ !15 = !DILocation(line: 25, column: 4, scope: !5)
.triton/dump/8c4bac4d904709a8b7e8c698132d974c/triton_.ptx ADDED
@@ -0,0 +1,280 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ //
2
+ // Generated by LLVM NVPTX Back-End
3
+ //
4
+
5
+ .version 8.2
6
+ .target sm_89
7
+ .address_size 64
8
+
9
+ // .globl triton__0d1de
10
+
11
+ .visible .entry triton__0d1de(
12
+ .param .u64 triton__0d1de_param_0,
13
+ .param .u32 triton__0d1de_param_1
14
+ )
15
+ .maxntid 128, 1, 1
16
+ {
17
+ .reg .pred %p<2>;
18
+ .reg .b32 %r<8>;
19
+ .reg .b64 %rd<6>;
20
+ .loc 1 18 0
21
+ $L__func_begin0:
22
+ .loc 1 18 0
23
+
24
+ ld.param.u64 %rd4, [triton__0d1de_param_0];
25
+ $L__tmp0:
26
+ .loc 1 21 36
27
+ mov.u32 %r2, %tid.x;
28
+ shl.b32 %r3, %r2, 1;
29
+ and.b32 %r4, %r3, 254;
30
+ .loc 1 20 28
31
+ mov.u32 %r1, %ctaid.x;
32
+ .loc 1 20 33
33
+ shl.b32 %r5, %r1, 8;
34
+ .loc 1 21 23
35
+ or.b32 %r6, %r5, %r4;
36
+ or.b32 %r7, %r6, 1;
37
+ .loc 1 22 21
38
+ setp.lt.s32 %p1, %r6, 512;
39
+ .loc 1 25 25
40
+ cvt.s64.s32 %rd1, %r6;
41
+ mul.wide.s32 %rd5, %r6, 8;
42
+ add.s64 %rd3, %rd4, %rd5;
43
+ .loc 1 25 36
44
+ cvt.s64.s32 %rd2, %r7;
45
+ @%p1 st.global.v2.b64 [ %rd3 + 0 ], { %rd1, %rd2 };
46
+ .loc 1 25 4
47
+ ret;
48
+ $L__tmp1:
49
+ $L__func_end0:
50
+
51
+ }
52
+ .file 1 "/tmp/torchinductor_root/wx/cwxxgxdevnyc453z7hh4nxzgmvlhh6suwokktps3dw62btskgxt4.py"
53
+ .section .debug_abbrev
54
+ {
55
+ .b8 1
56
+ .b8 17
57
+ .b8 1
58
+ .b8 37
59
+ .b8 8
60
+ .b8 19
61
+ .b8 5
62
+ .b8 3
63
+ .b8 8
64
+ .b8 16
65
+ .b8 6
66
+ .b8 27
67
+ .b8 8
68
+ .b8 180
69
+ .b8 66
70
+ .b8 12
71
+ .b8 17
72
+ .b8 1
73
+ .b8 18
74
+ .b8 1
75
+ .b8 0
76
+ .b8 0
77
+ .b8 2
78
+ .b8 46
79
+ .b8 0
80
+ .b8 17
81
+ .b8 1
82
+ .b8 18
83
+ .b8 1
84
+ .b8 64
85
+ .b8 10
86
+ .b8 135
87
+ .b8 64
88
+ .b8 8
89
+ .b8 3
90
+ .b8 8
91
+ .b8 58
92
+ .b8 11
93
+ .b8 59
94
+ .b8 11
95
+ .b8 63
96
+ .b8 12
97
+ .b8 0
98
+ .b8 0
99
+ .b8 0
100
+ }
101
+ .section .debug_info
102
+ {
103
+ .b32 172
104
+ .b8 2
105
+ .b8 0
106
+ .b32 .debug_abbrev
107
+ .b8 8
108
+ .b8 1
109
+ .b8 116
110
+ .b8 114
111
+ .b8 105
112
+ .b8 116
113
+ .b8 111
114
+ .b8 110
115
+ .b8 0
116
+ .b8 2
117
+ .b8 0
118
+ .b8 99
119
+ .b8 119
120
+ .b8 120
121
+ .b8 120
122
+ .b8 103
123
+ .b8 120
124
+ .b8 100
125
+ .b8 101
126
+ .b8 118
127
+ .b8 110
128
+ .b8 121
129
+ .b8 99
130
+ .b8 52
131
+ .b8 53
132
+ .b8 51
133
+ .b8 122
134
+ .b8 55
135
+ .b8 104
136
+ .b8 104
137
+ .b8 52
138
+ .b8 110
139
+ .b8 120
140
+ .b8 122
141
+ .b8 103
142
+ .b8 109
143
+ .b8 118
144
+ .b8 108
145
+ .b8 104
146
+ .b8 104
147
+ .b8 54
148
+ .b8 115
149
+ .b8 117
150
+ .b8 119
151
+ .b8 111
152
+ .b8 107
153
+ .b8 107
154
+ .b8 116
155
+ .b8 112
156
+ .b8 115
157
+ .b8 51
158
+ .b8 100
159
+ .b8 119
160
+ .b8 54
161
+ .b8 50
162
+ .b8 98
163
+ .b8 116
164
+ .b8 115
165
+ .b8 107
166
+ .b8 103
167
+ .b8 120
168
+ .b8 116
169
+ .b8 52
170
+ .b8 46
171
+ .b8 112
172
+ .b8 121
173
+ .b8 0
174
+ .b32 .debug_line
175
+ .b8 47
176
+ .b8 116
177
+ .b8 109
178
+ .b8 112
179
+ .b8 47
180
+ .b8 116
181
+ .b8 111
182
+ .b8 114
183
+ .b8 99
184
+ .b8 104
185
+ .b8 105
186
+ .b8 110
187
+ .b8 100
188
+ .b8 117
189
+ .b8 99
190
+ .b8 116
191
+ .b8 111
192
+ .b8 114
193
+ .b8 95
194
+ .b8 114
195
+ .b8 111
196
+ .b8 111
197
+ .b8 116
198
+ .b8 47
199
+ .b8 119
200
+ .b8 120
201
+ .b8 0
202
+ .b8 1
203
+ .b64 $L__func_begin0
204
+ .b64 $L__func_end0
205
+ .b8 2
206
+ .b64 $L__func_begin0
207
+ .b64 $L__func_end0
208
+ .b8 1
209
+ .b8 156
210
+ .b8 116
211
+ .b8 114
212
+ .b8 105
213
+ .b8 116
214
+ .b8 111
215
+ .b8 110
216
+ .b8 95
217
+ .b8 95
218
+ .b8 48
219
+ .b8 100
220
+ .b8 49
221
+ .b8 100
222
+ .b8 101
223
+ .b8 0
224
+ .b8 116
225
+ .b8 114
226
+ .b8 105
227
+ .b8 116
228
+ .b8 111
229
+ .b8 110
230
+ .b8 95
231
+ .b8 95
232
+ .b8 48
233
+ .b8 100
234
+ .b8 49
235
+ .b8 100
236
+ .b8 101
237
+ .b8 0
238
+ .b8 1
239
+ .b8 18
240
+ .b8 1
241
+ .b8 0
242
+ }
243
+ .section .debug_pubnames
244
+ {
245
+ .b32 $L__pubNames_end0-$L__pubNames_start0
246
+ $L__pubNames_start0:
247
+ .b8 2
248
+ .b8 0
249
+ .b32 .debug_info
250
+ .b32 176
251
+ .b32 125
252
+ .b8 116
253
+ .b8 114
254
+ .b8 105
255
+ .b8 116
256
+ .b8 111
257
+ .b8 110
258
+ .b8 95
259
+ .b8 95
260
+ .b8 48
261
+ .b8 100
262
+ .b8 49
263
+ .b8 100
264
+ .b8 101
265
+ .b8 0
266
+ .b32 0
267
+ $L__pubNames_end0:
268
+ }
269
+ .section .debug_pubtypes
270
+ {
271
+ .b32 $L__pubTypes_end0-$L__pubTypes_start0
272
+ $L__pubTypes_start0:
273
+ .b8 2
274
+ .b8 0
275
+ .b32 .debug_info
276
+ .b32 176
277
+ .b32 0
278
+ $L__pubTypes_end0:
279
+ }
280
+ .section .debug_loc { }
.triton/dump/a4652f539404a11e3c068d96115a7427/triton_.cubin ADDED
Binary file (5.03 kB). View file
 
.triton/dump/a4652f539404a11e3c068d96115a7427/triton_.llir ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ; ModuleID = 'LLVMDialectModule'
2
+ source_filename = "LLVMDialectModule"
3
+
4
+ define void @triton__0d1d2de(ptr addrspace(1) %0, ptr addrspace(1) %1, i32 %2) local_unnamed_addr !dbg !5 {
5
+ %4 = tail call i32 @llvm.nvvm.read.ptx.sreg.tid.x(), !dbg !8
6
+ %5 = shl i32 %4, 1, !dbg !8
7
+ %6 = and i32 %5, 254, !dbg !8
8
+ %7 = tail call i32 asm "mov.u32 $0, %ctaid.x;", "=r"() #1, !dbg !9
9
+ %8 = shl i32 %7, 8, !dbg !10
10
+ %9 = or i32 %8, %6, !dbg !11
11
+ %10 = sext i32 %9 to i64, !dbg !12
12
+ %11 = getelementptr i16, ptr addrspace(1) %0, i64 %10, !dbg !12
13
+ %12 = tail call i32 asm sideeffect "mov.u32 $0, 0x0;\0A\09@$2 ld.global.b32 { $0 }, [ $1 + 0 ];", "=r,l,b"(ptr addrspace(1) %11, i1 true) #1, !dbg !13
14
+ %13 = trunc i32 %12 to i16, !dbg !13
15
+ %extelt.offset = lshr i32 %12, 16, !dbg !13
16
+ %14 = trunc i32 %extelt.offset to i16, !dbg !13
17
+ %15 = tail call float asm "cvt.f32.bf16 $0, $1;", "=r,h"(i16 %13) #1, !dbg !14
18
+ %16 = tail call float asm "cvt.f32.bf16 $0, $1;", "=r,h"(i16 %14) #1, !dbg !14
19
+ %17 = getelementptr float, ptr addrspace(1) %1, i64 %10, !dbg !15
20
+ %18 = bitcast float %15 to i32, !dbg !16
21
+ %19 = bitcast float %16 to i32, !dbg !16
22
+ tail call void asm sideeffect "@$3 st.global.v2.b32 [ $2 + 0 ], { $0, $1 };", "r,r,l,b"(i32 %18, i32 %19, ptr addrspace(1) %17, i1 true) #1, !dbg !16
23
+ ret void, !dbg !17
24
+ }
25
+
26
+ ; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
27
+ declare noundef i32 @llvm.nvvm.read.ptx.sreg.tid.x() #0
28
+
29
+ attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
30
+ attributes #1 = { nounwind }
31
+
32
+ !llvm.module.flags = !{!0}
33
+ !llvm.dbg.cu = !{!1}
34
+ !nvvm.annotations = !{!3, !4, !4, !3}
35
+
36
+ !0 = !{i32 2, !"Debug Info Version", i32 3}
37
+ !1 = distinct !DICompileUnit(language: DW_LANG_C, file: !2, producer: "triton", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug)
38
+ !2 = !DIFile(filename: "czl6nmwasl7k4ic55xowihczcooh3mhu5v6ls6w2xzqqocdc2da7.py", directory: "/tmp/torchinductor_root/zl")
39
+ !3 = !{ptr @triton__0d1d2de, !"kernel", i32 1}
40
+ !4 = !{ptr @triton__0d1d2de, !"maxntidx", i32 128}
41
+ !5 = distinct !DISubprogram(name: "triton__0d1d2de", linkageName: "triton__0d1d2de", scope: !2, file: !2, line: 18, type: !6, scopeLine: 18, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !1)
42
+ !6 = !DISubroutineType(cc: DW_CC_normal, types: !7)
43
+ !7 = !{}
44
+ !8 = !DILocation(line: 21, column: 36, scope: !5)
45
+ !9 = !DILocation(line: 20, column: 28, scope: !5)
46
+ !10 = !DILocation(line: 20, column: 33, scope: !5)
47
+ !11 = !DILocation(line: 21, column: 23, scope: !5)
48
+ !12 = !DILocation(line: 24, column: 30, scope: !5)
49
+ !13 = !DILocation(line: 24, column: 35, scope: !5)
50
+ !14 = !DILocation(line: 24, column: 44, scope: !5)
51
+ !15 = !DILocation(line: 26, column: 25, scope: !5)
52
+ !16 = !DILocation(line: 26, column: 36, scope: !5)
53
+ !17 = !DILocation(line: 26, column: 4, scope: !5)