diff --git a/.ipynb_checkpoints/01 - Julia_from_IPython-checkpoint.ipynb b/.ipynb_checkpoints/01 - Julia_from_IPython-checkpoint.ipynb
deleted file mode 100644
index bf232c8..0000000
--- a/.ipynb_checkpoints/01 - Julia_from_IPython-checkpoint.ipynb
+++ /dev/null
@@ -1,109 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "8b4b2ab7",
- "metadata": {},
- "source": [
- "Load the Julia magic extension"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 3,
- "id": "4d4cbc68",
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "The julia.magic extension is already loaded. To reload it, use:\n",
- " %reload_ext julia.magic\n"
- ]
- }
- ],
- "source": [
- "%load_ext julia.magic"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "f578aa1c",
- "metadata": {},
- "source": [
- "Excute some code written in ''Julia''"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 12,
- "id": "6fdc193d",
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "x = 10 ⇒ x² = 100\n"
- ]
- }
- ],
- "source": [
- "%%julia\n",
- "x = 10\n",
- "y = x^2\n",
- "println(\"x = $(x) ⇒ x² = $(y)\")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "66b2da7a",
- "metadata": {},
- "source": [
- "Variables defined in Julia can be accessed from Python"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 10,
- "id": "ae1c4b46",
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "x = 10 ⇒ x² = 100\n"
- ]
- }
- ],
- "source": [
- "x = %julia x\n",
- "y = %julia y\n",
- "print(f'x = {x} ⇒ x² = {y}')"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- },
- "language_info": {
- "codemirror_mode": {
- "name": "ipython",
- "version": 3
- },
- "file_extension": ".py",
- "mimetype": "text/x-python",
- "name": "python",
- "nbconvert_exporter": "python",
- "pygments_lexer": "ipython3",
- "version": "3.9.2"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/.ipynb_checkpoints/01-Julia-dream-PyHEP2021-checkpoint.ipynb b/.ipynb_checkpoints/01-Julia-dream-PyHEP2021-checkpoint.ipynb
deleted file mode 100644
index 195e2c6..0000000
--- a/.ipynb_checkpoints/01-Julia-dream-PyHEP2021-checkpoint.ipynb
+++ /dev/null
@@ -1,834 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "bda53ff3-7ee5-4f17-824b-6a979ef10ed6",
- "metadata": {},
- "source": [
- "_Next cell is used to modify display setting for a presentation style._"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 12,
- "id": "a26ab57b-021a-438d-896a-8662e22a44ab",
- "metadata": {
- "jupyter": {
- "source_hidden": true
- },
- "tags": []
- },
- "outputs": [
- {
- "data": {
- "text/html": [
- "\n",
- "
\n",
- "Presentation mode. Clear the output of this cell to exit the mode.
\n",
- "Use j (next) and k (previous) keys to navigate between cells.
\n",
- "\n"
- ],
- "text/plain": [
- "HTML{String}(\"\\n\\nPresentation mode. Clear the output of this cell to exit the mode.
\\nUse j (next) and k (previous) keys to navigate between cells.
\\n\\n\")"
- ]
- },
- "execution_count": 12,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "singleCellDisplay = false\n",
- "editor_font_size = 25\n",
- "code_output_font_size = 25\n",
- "markdown_output_font_size = 25\n",
- "markdown_list_font_size = 25\n",
- "HTML(\"\"\"\n",
- "\n",
- "\n",
- "Presentation mode. Clear the output of this cell to exit the mode.
\n",
- "Use j (next) and k (previous) keys to navigate between cells.
\n",
- "\n",
- "\"\"\")"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "57c90a10-c8b4-47f8-8bb8-9bbf14058c66",
- "metadata": {},
- "outputs": [],
- "source": []
- },
- {
- "cell_type": "markdown",
- "id": "2ba91127-2e73-4bb4-bc2c-6ee77392c36e",
- "metadata": {
- "tags": []
- },
- "source": [
- "# PyHEP 2021 \n",
- "\n",
- "\n",
- "----------\n",
- "\n",
- "\n",
- "\n",
- "\n",
- "\n",
- "
\n",
- " \n",
- "
Julia, a HEP dream comes true
\n",
- " \n",
- " Philippe Gras (Université Paris-Saclay, CEA/Irfu)\n",
- "\n",
- "\n",
- "
July 9th, 2021
\n",
- "
"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "527db46a-1650-4a50-8351-67222923a458",
- "metadata": {},
- "source": [
- "# Introduction\n",
- "\n",
- "## Julia is a new __programming language__\n",
- "## I've discovered it while making a survey of programming language for the projet of CUPID neutrinoless double-beta decay experiment, in last April\n",
- " * It's a new programming language for me\n",
- " * I've learned it for this talk and it was as fast as learning Python (actually faster because of their similarities)\n",
- " \n",
- "## I will present Julia to you in the perspective of using it for HEP applications"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "demographic-nicaragua",
- "metadata": {
- "tags": []
- },
- "source": [
- "# High performance computing is important for HEP\n",
- "\n",
- "\n",
- "
\n",
- "
\n",
- "
\n",
- "\n",
- " * Computing plays a central role in the research done at LHC\n",
- " + Theoretical predictions: simulation of the proton-proton collision\n",
- " + Simulation of the detector response\n",
- " + Reconstruction of the phyics events\n",
- " + Analysis of reconstructed events to perform measurements and new physics search."
- ]
- },
- {
- "cell_type": "markdown",
- "id": "21a5c5fa-eeeb-459e-8e07-f1306c3d2304",
- "metadata": {},
- "source": [
- "# Analysis of the reconstructed events\n",
- " * Behind an LHC experiment result publication there are tens of thousands of computing jobs that have run on the worldwide computing grid. Both ATLAS and CMS reached their 1000th papers in June 2020.\n",
- " * C++ is widely used and the performance it offers is essential\n",
- " * Research code: developped by the main authors of the prepared publication\n",
- " * Python is attractive becasue of its easy/fast code writing it offers and the library ecosystem that comes with it and we are many to use it. But it does not meet the performance provided by C++\n",
- " + Used in conjunction of C++\n",
- " + Huge development under way to leverage the performance of Python in terms of code running speed\n",
- " * __More attracive would be a Programming language that offers at the same time the C++ and Python pros__"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "62d38060-8798-42e1-9a0b-2af3e7b8a1c7",
- "metadata": {},
- "source": [
- "# Julia solving the two-language problem\n",
- "-----\n",
- "\n",
- " \n",
- " \n",
- " Fast/easy coding fast | | Fast running |
\n",
- " Python | ⇔ | C/C++ |
\n",
- "
\n",
- " => Mixing languages and Go back-and-forth between them\n",
- " \n",
- "\n",
- "\n",
- "\n",
- "* J. Bezanson, A. Edelman, S. Karpinski, and V. B. Shah tackled the problem in 2009 aiming to design a programing langue that providess both Fast/easy coding __AND__ Fast running\n",
- " + Birth of Julia, release 0.1 in __2013__ \n",
- " + This breakthrough was recognized by awards attributed to the authors\n",
- " - [James H. Wilkinson Prize in Numerical Analysis and Scientific in 2019](https://www.ll.mit.edu/news/wilkinson-prize-goes-developers-flexible-julia-programming-language) \n",
- " - [IEEE Computer Society Sidney Fernbach Award in 2019](https://www.computer.org/press-room/2019-news/2019-ieee-fernbach-award-edelman)\n",
- "* In 12 years since its conceptualisation, Julia has been improved from release to release and has aggratated many package developpers\n",
- " \n",
- "\n",
- "
Nowadays, Julia is a mature language, with a wide ecosystem
\n",
- " \n",
- "\n",
- "\n"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "legendary-sampling",
- "metadata": {},
- "source": [
- "# Loops\n",
- "\n",
- "\n",
- "\n",
- ""
- ]
- },
- {
- "cell_type": "markdown",
- "id": "outside-apartment",
- "metadata": {},
- "source": [
- "# HEP data analysis is a looping game\n",
- "\n",
- "HEP enjoys loop: we loop on physics events to loop on particles/physics objects. We often perform particle matching and clustering and for this we loop on events to loop on objects to loop on objects.\n",
- "\n",
- "```julia\n",
- "for event in billions_of_lhc_events\n",
- " for tens_or_hundreds_of_objects in event\n",
- " for tens_or_hundres_of_objects_to_match in event\n",
- " ...\n",
- " end\n",
- " end\n",
- "end\n",
- "```\n",
- "\n",
- " * The outter loops hides several loops: datasets > files\n",
- " * This is repeated several times for each analysis.\n",
- " ⇒ Lines of code executed billions of times even for a Kleenex code, written specially for a publication.
"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "c7f88121",
- "metadata": {},
- "source": [
- "## Python dislikes loop\n",
- "\n",
- " * A master rule for high-performance code in Python is to avoid writing loop in Python \n",
- " + ⇒ push the loop to underlying compiled libraries. Approach of the `numpy` vectorisation.\n",
- " \n",
- "Let's run a simple loop\n",
- " \n",
- "[Simple loop in Python](Python-code.ipynb#simple-loop)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "7e87ebd7-31da-4d23-a15f-ea90dc553b6f",
- "metadata": {},
- "source": [
- "| Python |\n",
- "|--------|\n",
- "| 90 ms |"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "de449e8a-809f-49ed-92cb-4ef01554d1bf",
- "metadata": {},
- "source": [
- "## In C++. Code in `simple-loop.cc`:\n",
- "\n",
- "```cpp\n",
- "#include \n",
- "#include x\n",
- "\n",
- "int main(){\n",
- " struct timeval t0, t1;\n",
- " gettimeofday(&t0, 0);\n",
- " \n",
- " double a = 0.;\n",
- " for(unsigned i = 0; i <= 1000000; ++i) a += 1.0/i;\n",
- " std::cout << \"Computation Result: \" << a << \"\\n\";\n",
- " \n",
- " gettimeofday(&t1, 0);\n",
- " std::cerr << \"Duration: \" << (t1.tv_sec-t0.tv_sec)\n",
- " + 1.e-6*(t1.tv_usec-t0.tv_usec)\n",
- "\t << \" seconds\\n\";\n",
- " return 0;\n",
- "}\n",
- "```"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 2,
- "id": "b914e148-86e3-4de0-9155-1849c66603f4",
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "Computation Result: 14.3927\n"
- ]
- },
- {
- "name": "stderr",
- "output_type": "stream",
- "text": [
- "Duration: 0.003847 seconds\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "Computation Result: 14.3927\n"
- ]
- },
- {
- "name": "stderr",
- "output_type": "stream",
- "text": [
- "Duration: 0.001713 seconds\n"
- ]
- }
- ],
- "source": [
- "run(`g++ -Wall -o simple-loop simple-loop.cc`)\n",
- "run(`./simple-loop`)\n",
- ";\n",
- "run(`g++ -O3 -Wall -o simple-loop simple-loop.cc`)\n",
- "run(`./simple-loop`)\n",
- ";"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "261eaf0d-85c3-4cbe-ad23-be8031148137",
- "metadata": {},
- "source": [
- "| Python | C++ |\n",
- "|--------|-------|\n",
- "| 90 ms | 1.5 ms |"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "d235f987-a157-4bb7-9aea-609edd9126e8",
- "metadata": {},
- "source": [
- "## How is doing Julia?"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 3,
- "id": "ebf7c4e9-0851-486e-8a7c-944b212b67b0",
- "metadata": {
- "tags": []
- },
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- " 0.001671 seconds (1 allocation: 16 bytes)\n"
- ]
- },
- {
- "data": {
- "text/plain": [
- "14.392726722864989"
- ]
- },
- "execution_count": 3,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "#\n",
- "# Julia\n",
- "#\n",
- "function f()\n",
- " a = 0.0\n",
- " for i in 1:1_000_000 # ✨ Note the underscores that improves legibility\n",
- " a = a + 1.0/i\n",
- " end\n",
- " return a\n",
- "end\n",
- "f()\n",
- "@time b = f()"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "c91f2f0f-e963-43fd-bf54-85e021e0dcf7",
- "metadata": {},
- "source": [
- "| Python | C++ | Julia |\n",
- "|--------|--------|--------|\n",
- "| 90ms | 1.5 ms | 1.6 ms |"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "084c9d64-9eff-4aeb-a8c6-51a4906f8fec",
- "metadata": {},
- "source": [
- "# Ease of programming\n",
- "\n",
- "## The goal is not only running performance. We want also fast and easy coding\n",
- "\n",
- " * You have already seen in the previous example that the code syntax and grammar is similar to Pythons. No ''std::map>''..., no compilation step."
- ]
- },
- {
- "cell_type": "markdown",
- "id": "e2572361-9b37-4891-9592-5b050a4029e8",
- "metadata": {},
- "source": [
- "# Programming in a community"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "behavioral-mining",
- "metadata": {},
- "source": [
- "## Googling programming\n",
- "\n",
- "Internet search engine and stack overflow play is an essential ingredient in nowadays programming workflow.\n",
- "\n",
- "Julia is already widespread enough, to find all the information on the Internet.\n",
- "\n",
- "Go to [DuckDuckGo](https://www.duckduckgo.com) or your prefered search engine and make a try.\n",
- "\n"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "fd0ced5b-6eee-426a-9b4c-035dea81a0cc",
- "metadata": {},
- "source": [
- "# Ecosystem\n",
- "\n",
- "* Large set of libraries and active developement\n",
- " + Julia is firstly used by scientific community ⇒ oriented to our needs\n",
- "* I did the following game during the wokshop: I've looked for a Julia equivalent each time a speaker mention a Python library (apart from HEP specific ones).\n",
- " + Caveat: I've not checked that it covers all the features of the Python package\n",
- " + The results of this survey shows the large activity around Julia\n",
- "\n",
- "cmd (Olivier Mattelaer) ✓\n",
- "FreeCAD interface (Christophe Delaere) ❌ [In discussion](https://forum.freecadweb.org/viewtopic.php?f=8&t=42400&sid=77306c4ad6e62533dfbf06909b06c0c8&start=10)\n",
- "Telegram bot (Matias Senge) ✓ https://github.com/Arkoniak/Telegram.jl\n",
- "DataFrames (Vincenzo Eduardo Padulano) ✓\n",
- "Spark (Vicenzo and Andr F.) ✓ https://github.com/dfdx/Spark.jl\n",
- "Dask (Vincenzo E. P., Graham Markal) ✓\n",
- "Batch computing (Vincenzo E. P.) ✓ https://docs.julialang.org/en/v1/manual/parallel-computing/, https://github.com/JuliaParallel, https://juliagpu.org/\n",
- "Apache Parquet (Andre Frankenthal) ✓\n",
- "Jupyter/Binder/SWAN ✓\n",
- "Bokeh (Bruno Alves) ✓ https://github.com/samuelcolvin/Bokeh.jl\n",
- "CUDA (Graham Markall) ✓ https://juliagpu.org/cuda/\n",
- "Hypothesis (Santam Roy Choudhury, property testing) ❌ ([besised an unmaintained QuickCheck projet](https://quickcheckjl.readthedocs.io/))\n",
- "Virtualenv (Henry Schneider, Packaging talk) ✓ [built in the std package manager](https://pkgdocs.julialang.org/v1/environments/)\n",
- "Unit test tools (Henry Schneider, Packaging talk) ✓ [std package](https://docs.julialang.org/en/v1/stdlib/Test/) and more: [Coverage](https://github.com/JuliaCI/Coverage.jl), [FactCheck](https://github.com/JuliaAttic/FactCheck.jl)\n",
- "JIT/Numba (Graham Markal, Henry Schneider) ✓ [Intrisic to the language](https://docs.julialang.org/en/v1/#man-introduction)\n",
- "Machine learning ✓ [Flux](https://fluxml.ai/), [JuliaML](https://juliaml.github.io/), TensorFlow( )[TensorFlow](https://github.com/malmaud/TensorFlow.jl)\n",
- " GPyTorch/Gaussian Process ML (Irina Espejo Morales [talk](https://indico.cern.ch/event/1019958/timetable/#14-active-learning-for-level-s)) [GPML](https://github.com/JuliaGaussianProcesses/GPMLj.jl)\n",
- "\n",
- "\n"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "450cbd31-e8e9-438b-b287-6571acd700d8",
- "metadata": {},
- "source": [
- "# Data format support\n",
- "\n",
- "* Non-HEP format\n",
- " + HDF5 and Parquet are fully supported (also CSV and Excel, less relevant our data size)\n",
- "* ROOT\n",
- " + Missing a solid and performant library to read ROOT file and with xroot support.\n",
- " + Two packages developped by users.\n",
- " - [UpROOT.jl](https://github.com/JuliaPy/PyCall.jl) from Oliver Schulz. A wrapper to [uproot](https://github.com/scikit-hep/uproot3) \n",
- " - [UnROOT.jl](https://github.com/tamasgal/UnROOT.jl) from Tamas Gal and Jerry Ling. Port of uproot in Julia. Can read KM3Net data and tree of simple type and/or vector of simple type like CMS NanoAOD. Johannes Schumann mentionned yesterday in his [talk](https://indico.cern.ch/event/1019958/timetable/#9-python-based-tools-and-frame)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "c3db8c57",
- "metadata": {},
- "source": [
- "# Advanced tools\n",
- "\n",
- "## IDE\n",
- " * Emacs and vim support\n",
- " * Atom and VScode support. Many features. Code can be run and debugged with the IDE, with support for plots.\n",
- "\n",
- "## Notebooks\n",
- " * Jupyter\n",
- " * [Pluto](https://github.com/fonsp/Pluto.jlhttps://github.com/fonsp/Pluto.jl). A new generation notebook with automatic update of cells.\n",
- " * Debugger: Debugger, Rebugger, Juno debugger (for Atom IDE)\n",
- " \n",
- " \n",
- "## Package installation\n",
- " * Python made it easy with conda and pip. It's even easier in Julia\n",
- " + A standard library part of the Julia installation\n",
- " + Give instructions to the user, when he or she try to import a missing package. Try it:"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 4,
- "id": "43a3c214-d79b-499f-ae17-54f2dce639b5",
- "metadata": {},
- "outputs": [
- {
- "ename": "LoadError",
- "evalue": "ArgumentError: Package Blink not found in current path:\n- Run `import Pkg; Pkg.add(\"Blink\")` to install the Blink package.\n",
- "output_type": "error",
- "traceback": [
- "ArgumentError: Package Blink not found in current path:\n- Run `import Pkg; Pkg.add(\"Blink\")` to install the Blink package.\n",
- "",
- "Stacktrace:",
- " [1] require(into::Module, mod::Symbol)",
- " @ Base ./loading.jl:871",
- " [2] eval",
- " @ ./boot.jl:360 [inlined]",
- " [3] include_string(mapexpr::typeof(REPL.softscope), mod::Module, code::String, filename::String)",
- " @ Base ./loading.jl:1094"
- ]
- }
- ],
- "source": [
- "import Blink"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "427c5e02-ad4e-4da5-b889-00e9fa4d3d63",
- "metadata": {},
- "source": [
- "💡 Dedicated command mode for package handling in the REPL (interactive terminal application equivalent ipython):\n",
- "```julia-repl\n",
- "julia> ]\n",
- "(@v1.6) pkg> add Grady\n",
- "(@v1.6) pkg> [Backspace]\n",
- "julia>\n",
- "```"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "d62ddb94",
- "metadata": {},
- "source": [
- "# Interoperability\n",
- "\n",
- "\n",
- " \n",
- "
\n",
- "
\"Credits: Karen V Bryan is licensed under CC BY-ND 2.0\n",
- "
\n",
- "\n",
- "\n",
- "* Python, C, Fortran code: direct call from Julia and Jupyter Julia kernels\n",
- "* C++ code: call via a wrapper. Lacking a tool for automatic generation of wrapper like swig. Project for direct-call (ala cppyy) on hold and not working for recent versions of Julia.\n",
- "\n",
- "The other way around\n",
- "\n",
- "* Python code can call Julia as well"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "27bc2a1b-7fe5-4942-884c-1b1741f7a73f",
- "metadata": {},
- "source": [
- "# Calling Python from Julia\n",
- "\n",
- "As simple as calling Julia code"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 5,
- "id": "461e51f3-647b-4566-891c-6840c5d577da",
- "metadata": {},
- "outputs": [
- {
- "data": {
- "text/plain": [
- "0.7071067811865475"
- ]
- },
- "execution_count": 5,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "# Enable Python call:\n",
- "using PyCall\n",
- "\n",
- "# Inport a python module:\n",
- "math = pyimport(\"math\")\n",
- "\n",
- "# Use it as a Julia module:\n",
- "math.sin(math.pi / 4)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "ce6da619",
- "metadata": {},
- "source": [
- "# Calling C from Julia"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 6,
- "id": "03fbd939",
- "metadata": {},
- "outputs": [
- {
- "data": {
- "text/plain": [
- "\"/bin/bash\""
- ]
- },
- "execution_count": 6,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "path = ccall(:getenv, Cstring, (Cstring,), \"SHELL\")\n",
- "unsafe_string(path)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "8eaf62ef",
- "metadata": {},
- "source": [
- "For C, you will typically write a wrapper in ''Julia'' to handle errors, like:"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 7,
- "id": "497fec73",
- "metadata": {},
- "outputs": [
- {
- "data": {
- "text/plain": [
- "getenv (generic function with 1 method)"
- ]
- },
- "execution_count": 7,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "function getenv(var::AbstractString)\n",
- " val = ccall(:getenv, Cstring, (Cstring,), var)\n",
- " if val == C_NULL\n",
- " error(\"getenv: undefined variable: \", var)\n",
- " end\n",
- " return unsafe_string(val)\n",
- "end"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 8,
- "id": "409d2d27",
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "pgras\n"
- ]
- },
- {
- "ename": "LoadError",
- "evalue": "getenv: undefined variable: SMOKE",
- "output_type": "error",
- "traceback": [
- "getenv: undefined variable: SMOKE",
- "",
- "Stacktrace:",
- " [1] error(::String, ::String)",
- " @ Base ./error.jl:42",
- " [2] getenv(var::String)",
- " @ Main ./In[7]:4",
- " [3] top-level scope",
- " @ In[8]:2",
- " [4] eval",
- " @ ./boot.jl:360 [inlined]",
- " [5] include_string(mapexpr::typeof(REPL.softscope), mod::Module, code::String, filename::String)",
- " @ Base ./loading.jl:1094"
- ]
- }
- ],
- "source": [
- "println(getenv(\"USER\"))\n",
- "println(getenv(\"SMOKE\")) # ⇒ will through an exception unless you have SMOKE in your environment "
- ]
- },
- {
- "cell_type": "markdown",
- "id": "8c1bcc56",
- "metadata": {},
- "source": [
- "# Calling Julia from python\n",
- "\n",
- "```python\n",
- "$ python3 -m pip install julia # install PyJulia\n",
- "... # you may need `--user` after `install`\n",
- "\n",
- "$ python3\n",
- ">>> import julia\n",
- ">>> julia.install() # install PyCall.jl etc.\n",
- ">>> from julia import Base # short demo\n",
- ">>> Base.sind(90)\n",
- "1.0\n",
- "```"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "d8eec976",
- "metadata": {},
- "source": [
- "# Embedding Julia code in a Python notebook\n",
- "\n",
- "\n",
- " "
- ]
- },
- {
- "cell_type": "markdown",
- "id": "b272d46e-3395-454b-bfa6-21f0aef9487d",
- "metadata": {},
- "source": [
- "# Let's use Julia for HEP example\n",
- "\n",
- "## CMS dimuon analysis \n",
- "\n",
- " > ⚡ It's an extremely simple analysis, way far from usual LHC analysis\n",
- "\n",
- " > Let's go,\n",
- " \n",
- " * [Dimuon spectrum in Julia](dimu/diMuon-bin-jl.ipynb)\n",
- " "
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "08cb8517",
- "metadata": {},
- "outputs": [],
- "source": []
- },
- {
- "cell_type": "markdown",
- "id": "13e38ba4-d873-4919-821f-fb4502890444",
- "metadata": {},
- "source": [
- "# Conclusions\n",
- "\n",
- "* Julia offers the code running performance of C++, with the same programming language the ease of programming of Python, and a large Ecosystem\n",
- "* Julia is the ideal language for our usage\n",
- "* It's now mature enough to be used for HEP\n",
- " + It's the right time to catch the Julia's train\n",
- " + Needs developers to provides tools, especially for ROOT I/O and a ROOT binding\n",
- " + Needs to be advertised to users. Most of the Physicist does not know it.\n",
- "\n",
- "\n",
- "_Thanks to Jim Pivarski for the tricks to turn out a notebook in a presentations and the nice tutorial he gave on the subject_"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Julia 1.6.1",
- "language": "julia",
- "name": "julia-1.6"
- },
- "language_info": {
- "file_extension": ".jl",
- "mimetype": "application/julia",
- "name": "julia",
- "version": "1.6.1"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/.ipynb_checkpoints/Julia-dream-PyHEP2021-checkpoint.ipynb b/.ipynb_checkpoints/Julia-dream-PyHEP2021-checkpoint.ipynb
deleted file mode 100644
index 2e8db91..0000000
--- a/.ipynb_checkpoints/Julia-dream-PyHEP2021-checkpoint.ipynb
+++ /dev/null
@@ -1,723 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "8acf72d6-fc3e-439c-9a3f-4db4c942cbac",
- "metadata": {
- "jupyter": {
- "source_hidden": true
- },
- "scrolled": true,
- "tags": []
- },
- "outputs": [],
- "source": [
- "singleCellDisplay = true\n",
- "editor_font_size = 25\n",
- "code_output_font_size = 25\n",
- "markdown_output_font_size = 30\n",
- "markdown_list_font_size = 25\n",
- "HTML(\"\"\"\n",
- "\n",
- "\n",
- "Presentation mode. Clear the output of this cell to exit the mode.
\n",
- "Use j (next) and k (previous) keys to navigate between cells.
\n",
- "\n",
- "\"\"\")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "2ba91127-2e73-4bb4-bc2c-6ee77392c36e",
- "metadata": {
- "tags": []
- },
- "source": [
- "# PyHEP 2021 \n",
- "----------\n",
- "\n",
- "\n",
- "\n",
- "\n",
- "\n",
- "\n",
- "\n",
- "
\n",
- " \n",
- "
Julia, a HEP dream comes true
\n",
- " \n",
- " Philippe Gras (Université Paris-Saclay, CEA/Irfu)\n",
- "\n",
- "\n",
- "
July 9th, 2021
\n",
- "
"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "527db46a-1650-4a50-8351-67222923a458",
- "metadata": {},
- "source": [
- "# Introduction"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "demographic-nicaragua",
- "metadata": {},
- "source": [
- "# High performance computing is important for HEP\n",
- "\n",
- "\n",
- "
\n",
- "
\n",
- "
\n",
- "\n",
- " * Computing plays a central role in the research done at LHC\n",
- " + Theoretical predictions: simulation of the proton-proton collision\n",
- " + Simulation of the detector response\n",
- " + Reconstruction of the phyics events\n",
- " + Analysis of reconstructed events to perform measurements and new physics search."
- ]
- },
- {
- "cell_type": "markdown",
- "id": "21a5c5fa-eeeb-459e-8e07-f1306c3d2304",
- "metadata": {},
- "source": [
- "# Analysis of the reconstructed events \n",
- " * Behind an LHC experiment result publication there are tens of thousands of computing jobs that have run on the worldwide computing grid. Both ATLAS and CMS reached their 1000th papers in June 2020.\n",
- " * C++ is widely used and the performance it offers is essential\n",
- " * Research code: developped by the main authors of the prepared publication\n",
- " * Python is attractive becasue of its easy/fast code writing it offers and the library ecosystem that comes with it and we are many to use it. But it does not meet the performance provided by C++\n",
- " + Used in conjunction of C++\n",
- " + Huge developmen under way to leverage the performance of Python in terms of code running speed\n",
- " * __More attracive would be a Programming language that offers at the same time the C++ and Python pros__"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "62d38060-8798-42e1-9a0b-2af3e7b8a1c7",
- "metadata": {},
- "source": [
- "# Julia solving the two-language problem\n",
- "-----\n",
- "\n",
- " \n",
- " \n",
- " Fast/easy coding fast | | Fast running |
\n",
- " Python | ⇔ | C/C++ |
\n",
- "
\n",
- " => Mixing languages and Go back-and-forth between them\n",
- " \n",
- "\n",
- "\n",
- "\n",
- "* J. Bezanson, A. Edelman, S. Karpinski, and V. B. Shah tackled the problem in 2009 aiming to design a programing langue that providess both Fast/easy coding __AND__ Fast running\n",
- " + Birth of Julia, release 0.1 in __2013__ \n",
- " + This breakthrough was recognized by awards attributed to the authors\n",
- " - [James H. Wilkinson Prize in Numerical Analysis and Scientific in 2019](https://www.ll.mit.edu/news/wilkinson-prize-goes-developers-flexible-julia-programming-language) \n",
- " - [IEEE Computer Society Sidney Fernbach Award in 2019](https://www.computer.org/press-room/2019-news/2019-ieee-fernbach-award-edelman)\n",
- "* In 12 years since its conceptualisation, Julia has been improved from release to release and has aggratated many package developpers\n",
- " \n",
- "\n",
- "
Nowadays, Julia is a mature language, with a wide ecosystem
\n",
- " \n",
- "\n",
- "\n"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "legendary-sampling",
- "metadata": {},
- "source": [
- "# Loops\n",
- "\n",
- "\n",
- "\n",
- ""
- ]
- },
- {
- "cell_type": "markdown",
- "id": "outside-apartment",
- "metadata": {},
- "source": [
- "# HEP data analysis is a looping game\n",
- "\n",
- "HEP enjoys loop: we loop on physics events to loop on particles/physics objects. We often perform particle matching and clustering and for this we loop on events to loop on objects to loop on objects.\n",
- "\n",
- "```julia\n",
- "for event in billions_of_lhc_events\n",
- " for tens_or_hundreds_of_objects in event\n",
- " for tens_or_hundres_of_objects_to_match in event\n",
- " ...\n",
- " end\n",
- " end\n",
- "end\n",
- "```\n",
- "\n",
- " * The outter loops hides several loops: datasets > files\n",
- " * This is repeated several times for each analysis.\n",
- " ⇒ Lines of code executed billions of times even for a Kleenex code, written specially for a publication.
"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "c7f88121",
- "metadata": {},
- "source": [
- "# Python dislikes loop\n",
- "\n",
- " * A master rule for high-performance code in Python is to avoid writing loop in Python \n",
- " + ⇒ push the loop to underlying compiled libraries. Approach of the `numpy` vectorisation.\n",
- " \n",
- "Let's run a simple loop\n",
- " \n",
- "[Simple loop in Python](Python-code.ipynb#simple-loop)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "7e87ebd7-31da-4d23-a15f-ea90dc553b6f",
- "metadata": {},
- "source": [
- "| Python |\n",
- "|--------|\n",
- "| 90 ms |"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "de449e8a-809f-49ed-92cb-4ef01554d1bf",
- "metadata": {},
- "source": [
- "In C++. Code in `simple-loop.cc`:\n",
- "\n",
- "```cpp\n",
- "#include \n",
- "#include x\n",
- "\n",
- "int main(){\n",
- " struct timeval t0, t1;\n",
- " gettimeofday(&t0, 0);\n",
- " double a = 0.;\n",
- " for(unsigned i = 0; i <= 1000000; ++i) a += 1.0/i;\n",
- " std::cout << \"Computation Result: \" << a << \"\\n\";\n",
- " gettimeofday(&t1, 0);\n",
- " std::cerr << \"Duration: \" << (t1.tv_sec-t0.tv_sec)\n",
- " + 1.e-6*(t1.tv_usec-t0.tv_usec)\n",
- "\t << \" seconds\\n\";\n",
- " return 0;\n",
- "}\n",
- "```"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 97,
- "id": "b914e148-86e3-4de0-9155-1849c66603f4",
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "Computation Result: 14.3927\n"
- ]
- },
- {
- "name": "stderr",
- "output_type": "stream",
- "text": [
- "Duration: 0.003699 seconds\n"
- ]
- },
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "Computation Result: 14.3927\n"
- ]
- },
- {
- "name": "stderr",
- "output_type": "stream",
- "text": [
- "Duration: 0.001569 seconds\n"
- ]
- }
- ],
- "source": [
- "run(`g++ -Wall -o simple-loop simple-loop.cc`)\n",
- "run(`./simple-loop`)\n",
- ";\n",
- "run(`g++ -O3 -Wall -o simple-loop simple-loop.cc`)\n",
- "run(`./simple-loop`)\n",
- ";"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "261eaf0d-85c3-4cbe-ad23-be8031148137",
- "metadata": {},
- "source": [
- "| Python | C++ |\n",
- "|--------|-------|\n",
- "| 90 ms | 1.5 ms |"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "1492b430-f3ce-4eef-a32a-e33761accb7b",
- "metadata": {},
- "outputs": [],
- "source": [
- "# Loop"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 96,
- "id": "ebf7c4e9-0851-486e-8a7c-944b212b67b0",
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- " 0.001673 seconds\n"
- ]
- },
- {
- "data": {
- "text/plain": [
- "14.392726722864989"
- ]
- },
- "execution_count": 96,
- "metadata": {},
- "output_type": "execute_result"
- }
- ],
- "source": [
- "#\n",
- "# Julia\n",
- "#\n",
- "function f()\n",
- " a = 0.0\n",
- " for i in 1:1_000_000 # ✨ Note the underscores that improves legibility\n",
- " a = a + 1.0/i\n",
- " end\n",
- " return a\n",
- "end\n",
- "@time f()"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "c91f2f0f-e963-43fd-bf54-85e021e0dcf7",
- "metadata": {},
- "source": [
- "| Python | C++ | Julia |\n",
- "|--------|--------|--------|\n",
- "| 90ms | 1.5 ms | 1.6 ms |"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 12,
- "id": "608925e8-c4dd-49e4-a237-a5f77b4cae87",
- "metadata": {},
- "outputs": [
- {
- "ename": "LoadError",
- "evalue": "syntax: cannot juxtapose string literal",
- "output_type": "error",
- "traceback": [
- "syntax: cannot juxtapose string literal",
- "",
- "Stacktrace:",
- " [1] top-level scope",
- " @ In[12]:1",
- " [2] eval",
- " @ ./boot.jl:360 [inlined]",
- " [3] include_string(mapexpr::typeof(REPL.softscope), mod::Module, code::String, filename::String)",
- " @ Base ./loading.jl:1094"
- ]
- }
- ],
- "source": [
- "\"\"\"int main(){\n",
- " struct timeval t0, t1;\n",
- " gettimeofday(&t0, 0);\n",
- " double a = 0.;\n",
- " for(unsigned i = 0; i <= 1000000; ++i) a += 1.0/i;\n",
- " std::cout << \"Computation Result: \" << a << \"\\n\";\n",
- " gettimeofday(&t1, 0);\n",
- " std::cerr << \"Duration: \" << (t1.tv_sec-t0.tv_sec)\n",
- " + 1.e-6*(t1.tv_usec-t0.tv_usec)\n",
- "\t << \" seconds\\n\";\n",
- " return 0;\n",
- "}\"\"\""
- ]
- },
- {
- "cell_type": "markdown",
- "id": "behavioral-mining",
- "metadata": {},
- "source": [
- "## Googling programming\n",
- "\n",
- "Internet search engine and stack overflow play is an essential ingredient in nowadays programming workflow.\n",
- "\n",
- "Julia is already widespread enough, to find all the information on the Internet.\n",
- "\n",
- "Go to [DuckDuckGo](https://duckduckgo) or your prefered search engine and make a try.\n",
- "\n"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "ec1a273d-5abc-4134-84bb-24aa2d4308f3",
- "metadata": {},
- "source": [
- " ⇒ ~16 ms In Julia\n",
- " \n",
- " Switch to Python notebook to see in Python"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "2a5f5ff5-735b-419d-9e09-aa99d9803f45",
- "metadata": {},
- "source": [
- "# As easy and sweat as Python\n",
- "\n",
- "... help to add package\n"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "fd0ced5b-6eee-426a-9b4c-035dea81a0cc",
- "metadata": {},
- "source": [
- "# Ecosystem\n",
- "\n",
- "* Large set of libraries and active developement\n",
- "* Firstly used by scientific community ⇒ oriented to our needs\n",
- "\n",
- "* I did the following game during the wokshop: I've looked for a Julia equivalent each time a speaker mention a Python library (apart from HEP specific ones).\n",
- " + Caveat: I've not checked that it covers all the features of the Python package\n",
- " + The results of this survey shows the large activity around Julia\n",
- "\n",
- "cmd (Olivier M.) ✓\n",
- "FreeCAD interface (Christophe D.) ❌ [In discussion](https://forum.freecadweb.org/viewtopic.php?f=8&t=42400&sid=77306c4ad6e62533dfbf06909b06c0c8&start=10)\n",
- "Telegram bot (Matias Senge) ✓ https://github.com/Arkoniak/Telegram.jl\n",
- "DataFrames (Vincenzo Eduardo Padulano) ✓\n",
- "Spark (Vicenzo and Andr F.) ✓ https://github.com/dfdx/Spark.jl\n",
- "Dask (Vincenzo E. P., Graham Markal) ✓\n",
- "Batch computing (Vincenzo E. P.) ✓ https://docs.julialang.org/en/v1/manual/parallel-computing/, https://github.com/JuliaParallel, https://juliagpu.org/\n",
- "Apache Parquet (Andre Frankenthal) ✓\n",
- "Jupyter/Binder/SWAN ✓\n",
- "Bokeh (Bruno Alves) ✓ https://github.com/samuelcolvin/Bokeh.jl\n",
- "CUDA (Graham Markall) ✓ https://juliagpu.org/cuda/\n",
- "Hypothesis (, property testing) ❌ ([besised an unmaintained QuickCheck projet](https://quickcheckjl.readthedocs.io/))\n",
- "Virtualenv (Henry Schneider, Packaging talk) ✓ [built in the std package manager](https://pkgdocs.julialang.org/v1/environments/)\n",
- "Unit test tools (Henry Schneider, Packaging talk) ✓ [std package](https://docs.julialang.org/en/v1/stdlib/Test/) and more: [Coverage](https://github.com/JuliaCI/Coverage.jl), [FactCheck](https://github.com/JuliaAttic/FactCheck.jl)\n",
- "JIT/Numba (Graham Markal, Henry Schneider) ✓ [Intrisic to the language](https://docs.julialang.org/en/v1/#man-introduction)\n",
- "Machine learning ✓ [Flux](https://fluxml.ai/), [JuliaML](https://juliaml.github.io/), TensorFlow( )[TensorFlow](https://github.com/malmaud/TensorFlow.jl)\n",
- " GPyTorch/Gaussian Process ML (Irina Espejo Morales [talk](https://indico.cern.ch/event/1019958/timetable/#14-active-learning-for-level-s)) [GPML](https://github.com/JuliaGaussianProcesses/GPMLj.jl)\n",
- "\n",
- "\n"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "450cbd31-e8e9-438b-b287-6571acd700d8",
- "metadata": {},
- "source": [
- "# Data format support\n",
- "\n",
- "* Non-HEP format\n",
- "+ HFD5 and Parquet are fully supported (also CSV and Excel, less relevant our data size)\n",
- "\n",
- "* ROOT\n",
- " + Missing a solid and performant library to read ROOT file\n",
- " + Two packages developped by users.\n",
- " - [UpROOT.jl](https://github.com/JuliaPy/PyCall.jl) from Oliver Schulz. A wrapper to [uproot](https://github.com/scikit-hep/uproot3) \n",
- " - [UnROOT.jl](https://github.com/tamasgal/UnROOT.jl) from and Jerry Ling. Port of uproot in Julia. Can read KM3Net data and tree of simple type and/or vector of simple type like CMS NanoAOD. Johannes Schumann mentionned yesterday in his [talk](https://indico.cern.ch/event/1019958/timetable/#9-python-based-tools-and-frame)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "c3db8c57",
- "metadata": {},
- "source": [
- "# Advanced tools\n",
- "\n",
- "## IDE\n",
- " * Emacs and vim support\n",
- " * Atom and VScode support. Many features. Code can be run and debugged with the IDE, with support for plots.\n",
- "\n",
- "## Notebooks\n",
- " * Jupyter\n",
- " * [Pluto](https://github.com/fonsp/Pluto.jlhttps://github.com/fonsp/Pluto.jl). A new generation notebook with automatic update of cells.\n",
- " * Debugger: Debugger, Rebugger, Juno debugger (for Atom IDE)\n",
- " \n",
- " \n",
- "## Package installation\n",
- " * Python made it easy with conda and pip. It's even easier in Julia\n",
- " + A standard library part of the Julia installation\n",
- " + Give instructions to the user, when he or she try to import a missing package. Try it:"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "43a3c214-d79b-499f-ae17-54f2dce639b5",
- "metadata": {},
- "outputs": [],
- "source": [
- "import Gradfy"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "427c5e02-ad4e-4da5-b889-00e9fa4d3d63",
- "metadata": {},
- "source": [
- "💡 Dedicated command mode for package handling in the REPL (interactive terminal application equivalent ipython):\n",
- "```julia-repl\n",
- "julia> ]\n",
- "(@v1.6) pkg> add Grady\n",
- "(@v1.6) pkg> [Backspace]\n",
- "julia>\n",
- "```"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "d62ddb94",
- "metadata": {},
- "source": [
- "# Interoperability\n",
- "\n",
- "\n",
- " \n",
- "
\n",
- "
\"UK to US plug adaptor and UK to European plug adaptor\" by Karen V Bryan is licensed under CC BY-ND 2.0\n",
- "
\n",
- "\n",
- "\n",
- "* Python, C, Fortran code: direct call from Julia and Jupyter Julia kernels\n",
- "* C++ code: call via a wrapper (as for call of C++ from Python). Project for direct-call on hold.\n",
- "\n",
- "The other way around\n",
- "\n",
- "* Python code "
- ]
- },
- {
- "cell_type": "markdown",
- "id": "8c1bcc56",
- "metadata": {},
- "source": [
- "# Calling Julia from python\n",
- "\n",
- "```python\n",
- "$ python3 -m pip install julia # install PyJulia\n",
- "... # you may need `--user` after `install`\n",
- "\n",
- "$ python3\n",
- ">>> import julia\n",
- ">>> julia.install() # install PyCall.jl etc.\n",
- ">>> from julia import Base # short demo\n",
- ">>> Base.sind(90)\n",
- "1.0\n",
- "```"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "d8eec976",
- "metadata": {},
- "source": [
- "# Embedding Julia code in a Python notebook\n",
- "\n",
- "\n",
- " "
- ]
- },
- {
- "cell_type": "markdown",
- "id": "27bc2a1b-7fe5-4942-884c-1b1741f7a73f",
- "metadata": {},
- "source": [
- "# Calling Python from Julia\n",
- "\n",
- "As simple as calling Julia code"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "461e51f3-647b-4566-891c-6840c5d577da",
- "metadata": {},
- "outputs": [],
- "source": [
- "# Enable Python call:\n",
- "using PyCall\n",
- "\n",
- "# Inport a python module:\n",
- "math = pyimport(\"math\")\n",
- "\n",
- "# Use it as a Julia module:\n",
- "math.sin(math.pi / 4)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "ce6da619",
- "metadata": {},
- "source": [
- "# Calling C from Julia"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "03fbd939",
- "metadata": {},
- "outputs": [],
- "source": [
- "path = ccall(:getenv, Cstring, (Cstring,), \"SHELL\")\n",
- "unsafe_string(path)"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "8eaf62ef",
- "metadata": {},
- "source": [
- "For C, you will typically write a wrapper in ''Julia'' to handle errors, like:"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "497fec73",
- "metadata": {},
- "outputs": [],
- "source": [
- "function getenv(var::AbstractString)\n",
- " val = ccall(:getenv, Cstring, (Cstring,), var)\n",
- " if val == C_NULL\n",
- " error(\"getenv: undefined variable: \", var)\n",
- " end\n",
- " return unsafe_string(val)\n",
- "end"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "409d2d27",
- "metadata": {},
- "outputs": [],
- "source": [
- "println(getenv(\"USER\"))\n",
- "println(getenv(\"SMOKE\")) # ⇒ will through an exception unless you have SMOKE in your environment "
- ]
- },
- {
- "cell_type": "markdown",
- "id": "b272d46e-3395-454b-bfa6-21f0aef9487d",
- "metadata": {},
- "source": [
- "# Let's use Julia for HEP example\n",
- "\n",
- "## CMS dimuon analysis \n",
- "\n",
- " > ⚡ It's an extremely simple analysis, way far from usual LHC analysis\n",
- "\n",
- " > Let's go,\n",
- " \n",
- " * [Dimuon spectrum in Julia](dimu/diMuon-bin-jl.ipynb)\n",
- " * [Dimuon spectrum in Python](dimu/diMuon-bin-py.ipynb)"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "08cb8517",
- "metadata": {},
- "outputs": [],
- "source": []
- },
- {
- "cell_type": "markdown",
- "id": "13e38ba4-d873-4919-821f-fb4502890444",
- "metadata": {},
- "source": [
- "# Conclusions\n",
- "....\n",
- "\n",
- "_Thanks to Jim Pivarski for the tricks to turn out a notebook in a presentations and the nice tutorial he gave on the subject_"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Julia 1.6.1",
- "language": "julia",
- "name": "julia-1.6"
- },
- "language_info": {
- "file_extension": ".jl",
- "mimetype": "application/julia",
- "name": "julia",
- "version": "1.6.1"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/.ipynb_checkpoints/Julia_from_IPython-checkpoint.ipynb b/.ipynb_checkpoints/Julia_from_IPython-checkpoint.ipynb
deleted file mode 100644
index 4a5b03c..0000000
--- a/.ipynb_checkpoints/Julia_from_IPython-checkpoint.ipynb
+++ /dev/null
@@ -1,117 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "8b4b2ab7",
- "metadata": {},
- "source": [
- "Load the Julia magic extension"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 2,
- "id": "4d4cbc68",
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "The julia.magic extension is already loaded. To reload it, use:\n",
- " %reload_ext julia.magic\n"
- ]
- }
- ],
- "source": [
- "%load_ext julia.magic"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "f578aa1c",
- "metadata": {},
- "source": [
- "Excute some code written in ''Julia''"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 3,
- "id": "6fdc193d",
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "x = 10 ⇒ x² = 100\n"
- ]
- }
- ],
- "source": [
- "%%julia\n",
- "x = 10\n",
- "y = x^2\n",
- "println(\"x = $(x) ⇒ x² = $(y)\")"
- ]
- },
- {
- "cell_type": "markdown",
- "id": "66b2da7a",
- "metadata": {},
- "source": [
- "Variables defined in Julia can be accessed from Python"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 4,
- "id": "ae1c4b46",
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "x = 10 ⇒ x² = 100\n"
- ]
- }
- ],
- "source": [
- "x = %julia x\n",
- "y = %julia y\n",
- "print(f'x = {x} ⇒ x² = {y}')"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": null,
- "id": "241206ff-31f4-4ca2-a93a-783831585db7",
- "metadata": {},
- "outputs": [],
- "source": []
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- },
- "language_info": {
- "codemirror_mode": {
- "name": "ipython",
- "version": 3
- },
- "file_extension": ".py",
- "mimetype": "text/x-python",
- "name": "python",
- "nbconvert_exporter": "python",
- "pygments_lexer": "ipython3",
- "version": "3.9.2"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/.ipynb_checkpoints/Python-code-checkpoint.ipynb b/.ipynb_checkpoints/Python-code-checkpoint.ipynb
deleted file mode 100644
index ceaf032..0000000
--- a/.ipynb_checkpoints/Python-code-checkpoint.ipynb
+++ /dev/null
@@ -1,72 +0,0 @@
-{
- "cells": [
- {
- "cell_type": "markdown",
- "id": "c3908552-6dee-4767-830a-274c61bf7ee1",
- "metadata": {},
- "source": [
- "\n",
- " \n",
- "# Simple loop example"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 41,
- "id": "17ea0d9f-5134-418d-a057-65bfc5bba7a4",
- "metadata": {},
- "outputs": [],
- "source": [
- "def f():\n",
- " a = 0.\n",
- " for i in range(1, 1000*1000 +1):\n",
- " a = a + 1.0/i\n",
- " print(i)\n",
- " return a"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 42,
- "id": "83dc3089-0828-44a1-a257-27e14f1c01e6",
- "metadata": {},
- "outputs": [
- {
- "name": "stdout",
- "output_type": "stream",
- "text": [
- "1000000\n",
- "14.392726722864989\n",
- "CPU times: user 91.5 ms, sys: 511 µs, total: 92.1 ms\n",
- "Wall time: 90.3 ms\n"
- ]
- }
- ],
- "source": [
- "%%time\n",
- "print(f())\n"
- ]
- }
- ],
- "metadata": {
- "kernelspec": {
- "display_name": "Python 3",
- "language": "python",
- "name": "python3"
- },
- "language_info": {
- "codemirror_mode": {
- "name": "ipython",
- "version": 3
- },
- "file_extension": ".py",
- "mimetype": "text/x-python",
- "name": "python",
- "nbconvert_exporter": "python",
- "pygments_lexer": "ipython3",
- "version": "3.9.2"
- }
- },
- "nbformat": 4,
- "nbformat_minor": 5
-}
diff --git a/01-Julia-dream-PyHEP2021.ipynb b/01-Julia-dream-PyHEP2021.ipynb
index 9e8b80d..8ae234d 100644
--- a/01-Julia-dream-PyHEP2021.ipynb
+++ b/01-Julia-dream-PyHEP2021.ipynb
@@ -10,7 +10,7 @@
},
{
"cell_type": "code",
- "execution_count": 12,
+ "execution_count": 1,
"id": "a26ab57b-021a-438d-896a-8662e22a44ab",
"metadata": {
"jupyter": {
@@ -30,17 +30,18 @@
" /* resize the markdown output */\n",
" div.jp-MarkdownOutput { font-size: 25px; }\n",
" div.jp-MarkdownOutput li { font-size: 25px; }\n",
- "\n",
- "# /* Shadow around markdown output cells */\n",
- "# div.jp-MarkdownOutput { box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.2), 0 6px 20px 0 rgba(0, 0, 0, 0.19);}\n",
- "# div.jp-MarkdownOutput {\n",
- "# padding: 10px 10px 50px 50px;\n",
- "# }\n",
+ " .jp.RenderedHTMLCommon table { font-size: 25px important;}\n",
+ " div.text_cell_render { font-size: 25px; \n",
+ " line-height: 35px;}\n",
+ " div.text_cell_render li { font-size: 25px; }\n",
+ " div.text_cell_render table { font-size: 25px;}\n",
"\n",
" /* Frame around markdown output cells */\n",
- " div.jp-MarkdownOutput { border-style: solid; border-color: #a6a6a6;}\n",
- " div.jp-MarkdownOutput {\n",
- " padding: 10px 10px 50px 50px;\n",
+ " div.jp-MarkdownOutput { border-style: solid; border-color: #a6a6a6;\n",
+ " padding: 10px 10px 50px 50px;\n",
+ " }\n",
+ " div.text_cell_render { border-style: solid; border-color: #a6a6a6;\n",
+ " padding: 10px 10px 50px 50px;\n",
" }\n",
"\n",
"\n",
@@ -50,10 +51,10 @@
"\\nPresentation mode. Clear the output of this cell to exit the mode.
\\nUse j (next) and k (previous) keys to navigate between cells.
\\n\\nPresentation mode. Clear the output of this cell to exit the mode.
\\nUse j (next) and k (previous) keys to navigate between cells.
\\n