Skip to content

Commit d2fd257

Browse files
committed
initial polars intro
1 parent 69ac6f3 commit d2fd257

25 files changed

+4236
-1391
lines changed

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,18 @@ title: "SIH Quarto Training template"
55

66
- We recommend storing all notebooks (.ipynb) or R files (as .qmd or .rmd) in the `notebooks` folder.
77

8-
## How to use
8+
## How to use this repository
99

10-
- Copy this repository
10+
- Clone this repository and `ParallelPython`.
1111
- Edit `index.qmd` to change the main landing page.
1212
- Edit or create `setup.qmd` to change the Setup instruction pages.
1313
- Edit `_quarto.yml` to change the dropdown menu options.
1414
- Add additional `*.md` files to the root dir to have them converted to html files (and add them to `_quarto.yml` to make them navigable).
1515

16-
- If using Python, use VSCode's [Quarto Extension](https://quarto.org/docs/tools/vscode.html) to render the project (recommended b/c it's easier/nice)
17-
- If using R, type `quarto render` in the Terminal in RStudio (not the R command line, the Terminal tab!) - or use the buttons
18-
- If you want to command line, run the below commands (after activating the correct Python environment, if needed)
16+
- Download [Quarto](https://quarto.org/. VSCode also has an extension [Quarto Extension](https://quarto.org/docs/tools/vscode.html) to render the training.
17+
18+
- On the command line after Quarto is installed, type `quarto render`. Afterwhich, `open -a "firefox" docs/index.html` can be run to view the rendered training.
19+
1920

2021
## Note:
2122

_quarto.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ website:
1313
text: "Setup"
1414
- text: "Fundamentals"
1515
href: notebooks/01a-pandas_fundamentals.html
16+
- text: "Polars Dataframes"
17+
href: notebooks/polars-intro.html
1618
- text: "Dask"
1719
href: notebooks/01b-TransitionToDask.html
1820
- text: "Scientific Computing"

docs/index.html

Lines changed: 179 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"><head>
33

44
<meta charset="utf-8">
5-
<meta name="generator" content="quarto-1.1.251">
5+
<meta name="generator" content="quarto-1.3.450">
66

77
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
88

@@ -17,7 +17,7 @@
1717
ul.task-list{list-style: none;}
1818
ul.task-list li input[type="checkbox"] {
1919
width: 0.8em;
20-
margin: 0 0.8em 0.2em -1.6em;
20+
margin: 0 0.8em 0.2em -1em; /* quarto-specific, see https://github.com/quarto-dev/quarto-cli/issues/4556 */
2121
vertical-align: middle;
2222
}
2323
</style>
@@ -55,7 +55,8 @@
5555
"search-more-matches-text": "more matches in this document",
5656
"search-clear-button-title": "Clear",
5757
"search-detached-cancel-button-title": "Cancel",
58-
"search-submit-button-title": "Submit"
58+
"search-submit-button-title": "Submit",
59+
"search-label": "Search"
5960
}
6061
}</script>
6162

@@ -74,31 +75,43 @@
7475
<span class="navbar-title">Parallel Python with Dask</span>
7576
</a>
7677
</div>
78+
<div id="quarto-search" class="" title="Search"></div>
7779
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarCollapse" aria-controls="navbarCollapse" aria-expanded="false" aria-label="Toggle navigation" onclick="if (window.quartoToggleHeadroom) { window.quartoToggleHeadroom(); }">
7880
<span class="navbar-toggler-icon"></span>
7981
</button>
8082
<div class="collapse navbar-collapse" id="navbarCollapse">
8183
<ul class="navbar-nav navbar-nav-scroll me-auto">
8284
<li class="nav-item">
83-
<a class="nav-link active" href="./index.html" aria-current="page">Home</a>
85+
<a class="nav-link active" href="./index.html" rel="" target="" aria-current="page">
86+
<span class="menu-text">Home</span></a>
8487
</li>
8588
<li class="nav-item">
86-
<a class="nav-link" href="./setup.html">Setup</a>
89+
<a class="nav-link" href="./setup.html" rel="" target="">
90+
<span class="menu-text">Setup</span></a>
8791
</li>
8892
<li class="nav-item">
89-
<a class="nav-link" href="./notebooks/01a-pandas_fundamentals.html">Fundamentals</a>
93+
<a class="nav-link" href="./notebooks/01a-pandas_fundamentals.html" rel="" target="">
94+
<span class="menu-text">Fundamentals</span></a>
9095
</li>
9196
<li class="nav-item">
92-
<a class="nav-link" href="./notebooks/01b-TransitionToDask.html">Dask</a>
97+
<a class="nav-link" href="./notebooks/polars-intro.html" rel="" target="">
98+
<span class="menu-text">Polars Dataframes</span></a>
9399
</li>
94100
<li class="nav-item">
95-
<a class="nav-link" href="./notebooks/01c-Scientific_Computing.html">Scientific Computing</a>
101+
<a class="nav-link" href="./notebooks/01b-TransitionToDask.html" rel="" target="">
102+
<span class="menu-text">Dask</span></a>
96103
</li>
97104
<li class="nav-item">
98-
<a class="nav-link" href="./notebooks/01d-dask_delayed.html">Dask Delayed</a>
105+
<a class="nav-link" href="./notebooks/01c-Scientific_Computing.html" rel="" target="">
106+
<span class="menu-text">Scientific Computing</span></a>
107+
</li>
108+
<li class="nav-item">
109+
<a class="nav-link" href="./notebooks/01d-dask_delayed.html" rel="" target="">
110+
<span class="menu-text">Dask Delayed</span></a>
99111
</li>
100112
</ul>
101-
<div id="quarto-search" class="" title="Search"></div>
113+
<div class="quarto-navbar-tools ms-auto">
114+
</div>
102115
</div> <!-- /navcollapse -->
103116
</div> <!-- /container-fluid -->
104117
</nav>
@@ -133,6 +146,7 @@ <h1 class="title">Parallel Python</h1>
133146
<div class="quarto-title-meta">
134147

135148

149+
136150

137151
</div>
138152

@@ -144,9 +158,8 @@ <h1 class="title">Parallel Python</h1>
144158
<h2 class="anchored" data-anchor-id="trainers">Trainers</h2>
145159
<ul>
146160
<li>Kristian Maras (Kris) (MSc Mathematics / Ba Commerce)</li>
147-
<li>Nathaniel (Nate) Butterworth (PhD Computational Geophysics), [email protected]</li>
148-
<li>Darya Vanichkina (PhD Bioinformatics, SFHEA)</li>
149-
<li>Tim White (PhD Physics and Astronomy)</li>
161+
<li>Thomas Mauch (Thomas) (PhD in astronomy)</li>
162+
<li>Nathaniel (Nate) Butterworth (PhD Computational Geophysics)</li>
150163
</ul>
151164
</section>
152165
<section id="course-pre-requisites-and-setup-requirements" class="level2">
@@ -170,8 +183,8 @@ <h2 class="anchored" data-anchor-id="code-of-conduct">Code of Conduct</h2>
170183
<h2 class="anchored" data-anchor-id="general-session-timings">General session timings</h2>
171184
<ul>
172185
<li>A. Intoduction and Revise Python Data Manipulation and Pandas Data Structure</li>
173-
<li>B. Dask Fundamentals and application to solving data and computationally bounded bottlenecks.</li>
174-
<li>C. Scientific Computing Demonstration</li>
186+
<li>B. Why Polars is a better option for dataframes</li>
187+
<li>C. Why Dask provides an ecosystem of tools that can run on clusters of machines.</li>
175188
</ul>
176189
</section>
177190
<section id="setup-instructions" class="level2">
@@ -211,9 +224,23 @@ <h2 class="anchored" data-anchor-id="setup-instructions">Setup Instructions</h2>
211224
icon: icon
212225
};
213226
anchorJS.add('.anchored');
227+
const isCodeAnnotation = (el) => {
228+
for (const clz of el.classList) {
229+
if (clz.startsWith('code-annotation-')) {
230+
return true;
231+
}
232+
}
233+
return false;
234+
}
214235
const clipboard = new window.ClipboardJS('.code-copy-button', {
215-
target: function(trigger) {
216-
return trigger.previousElementSibling;
236+
text: function(trigger) {
237+
const codeEl = trigger.previousElementSibling.cloneNode(true);
238+
for (const childEl of codeEl.children) {
239+
if (isCodeAnnotation(childEl)) {
240+
childEl.remove();
241+
}
242+
}
243+
return codeEl.innerText;
217244
}
218245
});
219246
clipboard.on('success', function(e) {
@@ -225,7 +252,24 @@ <h2 class="anchored" data-anchor-id="setup-instructions">Setup Instructions</h2>
225252
button.classList.add('code-copy-button-checked');
226253
var currentTitle = button.getAttribute("title");
227254
button.setAttribute("title", "Copied!");
255+
let tooltip;
256+
if (window.bootstrap) {
257+
button.setAttribute("data-bs-toggle", "tooltip");
258+
button.setAttribute("data-bs-placement", "left");
259+
button.setAttribute("data-bs-title", "Copied!");
260+
tooltip = new bootstrap.Tooltip(button,
261+
{ trigger: "manual",
262+
customClass: "code-copy-button-tooltip",
263+
offset: [0, -8]});
264+
tooltip.show();
265+
}
228266
setTimeout(function() {
267+
if (tooltip) {
268+
tooltip.hide();
269+
button.removeAttribute("data-bs-title");
270+
button.removeAttribute("data-bs-toggle");
271+
button.removeAttribute("data-bs-placement");
272+
}
229273
button.setAttribute("title", currentTitle);
230274
button.classList.remove('code-copy-button-checked');
231275
}, 1000);
@@ -261,24 +305,128 @@ <h2 class="anchored" data-anchor-id="setup-instructions">Setup Instructions</h2>
261305
return note.innerHTML;
262306
});
263307
}
308+
let selectedAnnoteEl;
309+
const selectorForAnnotation = ( cell, annotation) => {
310+
let cellAttr = 'data-code-cell="' + cell + '"';
311+
let lineAttr = 'data-code-annotation="' + annotation + '"';
312+
const selector = 'span[' + cellAttr + '][' + lineAttr + ']';
313+
return selector;
314+
}
315+
const selectCodeLines = (annoteEl) => {
316+
const doc = window.document;
317+
const targetCell = annoteEl.getAttribute("data-target-cell");
318+
const targetAnnotation = annoteEl.getAttribute("data-target-annotation");
319+
const annoteSpan = window.document.querySelector(selectorForAnnotation(targetCell, targetAnnotation));
320+
const lines = annoteSpan.getAttribute("data-code-lines").split(",");
321+
const lineIds = lines.map((line) => {
322+
return targetCell + "-" + line;
323+
})
324+
let top = null;
325+
let height = null;
326+
let parent = null;
327+
if (lineIds.length > 0) {
328+
//compute the position of the single el (top and bottom and make a div)
329+
const el = window.document.getElementById(lineIds[0]);
330+
top = el.offsetTop;
331+
height = el.offsetHeight;
332+
parent = el.parentElement.parentElement;
333+
if (lineIds.length > 1) {
334+
const lastEl = window.document.getElementById(lineIds[lineIds.length - 1]);
335+
const bottom = lastEl.offsetTop + lastEl.offsetHeight;
336+
height = bottom - top;
337+
}
338+
if (top !== null && height !== null && parent !== null) {
339+
// cook up a div (if necessary) and position it
340+
let div = window.document.getElementById("code-annotation-line-highlight");
341+
if (div === null) {
342+
div = window.document.createElement("div");
343+
div.setAttribute("id", "code-annotation-line-highlight");
344+
div.style.position = 'absolute';
345+
parent.appendChild(div);
346+
}
347+
div.style.top = top - 2 + "px";
348+
div.style.height = height + 4 + "px";
349+
let gutterDiv = window.document.getElementById("code-annotation-line-highlight-gutter");
350+
if (gutterDiv === null) {
351+
gutterDiv = window.document.createElement("div");
352+
gutterDiv.setAttribute("id", "code-annotation-line-highlight-gutter");
353+
gutterDiv.style.position = 'absolute';
354+
const codeCell = window.document.getElementById(targetCell);
355+
const gutter = codeCell.querySelector('.code-annotation-gutter');
356+
gutter.appendChild(gutterDiv);
357+
}
358+
gutterDiv.style.top = top - 2 + "px";
359+
gutterDiv.style.height = height + 4 + "px";
360+
}
361+
selectedAnnoteEl = annoteEl;
362+
}
363+
};
364+
const unselectCodeLines = () => {
365+
const elementsIds = ["code-annotation-line-highlight", "code-annotation-line-highlight-gutter"];
366+
elementsIds.forEach((elId) => {
367+
const div = window.document.getElementById(elId);
368+
if (div) {
369+
div.remove();
370+
}
371+
});
372+
selectedAnnoteEl = undefined;
373+
};
374+
// Attach click handler to the DT
375+
const annoteDls = window.document.querySelectorAll('dt[data-target-cell]');
376+
for (const annoteDlNode of annoteDls) {
377+
annoteDlNode.addEventListener('click', (event) => {
378+
const clickedEl = event.target;
379+
if (clickedEl !== selectedAnnoteEl) {
380+
unselectCodeLines();
381+
const activeEl = window.document.querySelector('dt[data-target-cell].code-annotation-active');
382+
if (activeEl) {
383+
activeEl.classList.remove('code-annotation-active');
384+
}
385+
selectCodeLines(clickedEl);
386+
clickedEl.classList.add('code-annotation-active');
387+
} else {
388+
// Unselect the line
389+
unselectCodeLines();
390+
clickedEl.classList.remove('code-annotation-active');
391+
}
392+
});
393+
}
394+
const findCites = (el) => {
395+
const parentEl = el.parentElement;
396+
if (parentEl) {
397+
const cites = parentEl.dataset.cites;
398+
if (cites) {
399+
return {
400+
el,
401+
cites: cites.split(' ')
402+
};
403+
} else {
404+
return findCites(el.parentElement)
405+
}
406+
} else {
407+
return undefined;
408+
}
409+
};
264410
var bibliorefs = window.document.querySelectorAll('a[role="doc-biblioref"]');
265411
for (var i=0; i<bibliorefs.length; i++) {
266412
const ref = bibliorefs[i];
267-
const cites = ref.parentNode.getAttribute('data-cites').split(' ');
268-
tippyHover(ref, function() {
269-
var popup = window.document.createElement('div');
270-
cites.forEach(function(cite) {
271-
var citeDiv = window.document.createElement('div');
272-
citeDiv.classList.add('hanging-indent');
273-
citeDiv.classList.add('csl-entry');
274-
var biblioDiv = window.document.getElementById('ref-' + cite);
275-
if (biblioDiv) {
276-
citeDiv.innerHTML = biblioDiv.innerHTML;
277-
}
278-
popup.appendChild(citeDiv);
413+
const citeInfo = findCites(ref);
414+
if (citeInfo) {
415+
tippyHover(citeInfo.el, function() {
416+
var popup = window.document.createElement('div');
417+
citeInfo.cites.forEach(function(cite) {
418+
var citeDiv = window.document.createElement('div');
419+
citeDiv.classList.add('hanging-indent');
420+
citeDiv.classList.add('csl-entry');
421+
var biblioDiv = window.document.getElementById('ref-' + cite);
422+
if (biblioDiv) {
423+
citeDiv.innerHTML = biblioDiv.innerHTML;
424+
}
425+
popup.appendChild(citeDiv);
426+
});
427+
return popup.innerHTML;
279428
});
280-
return popup.innerHTML;
281-
});
429+
}
282430
}
283431
});
284432
</script>

0 commit comments

Comments
 (0)