Julia-seminar
Das Kursmaterial für dieses Julia-Seminar wurde aus zwei Quellen angepasst:
- der Kurs von Michael Herbst (MIT Lizenz).
- das Buch ThinkJulia von Allen Downey und Ben Lauwens (Creative Commons Namensnennung-Nicht-kommerziell 3.0 Unported Lizenz).
Einen sehr umfangreichen Spickzettel findest du hier.
Software und Material
Der Kurs erfordert verschiedene Dinge: eine funktionierende Installation von Julia 1.9, Jupyter, IJulia.jl, das Kursmaterial und verschiedene Abhängigkeiten. Um alles herunterzuladen und zu installieren, befolgst Du diese Schritte:
1) Julia herunterladen
Um dem Kurs zu folgen, benötigst du Julia 1.9. Julia kann leicht in binärer Form von den Julia-Downloads bezogen werden.
2) Alles andere
Um die verbleibenden Dateien und Abhängigkeiten zu erhalten, starte julia
und kopiere im resultierenden REPL-Shell folgenden Code:
import Downloads
script = Downloads.download("https://gitlab.mathematik.uni-stuttgart.de/stammbn/julia-seminar/-/raw/main/install.jl?ref_type=heads")
include(script)
Das lädt das install.jl-Skript herunter und führt es in Julia aus.
2) Alles andere (Experten-Version)
Alternativ kannst Du auch die folgenden Befehle manuell ausführen (dies setzt voraus, dass git
und julia
von der Kommandozeile aus verfügbar sind):
git clone https://gitlab.mathematik.uni-stuttgart.de/stammbn/Julia-seminar/
cd Julia-seminar
julia install-manual.jl
3) Das Notebook starten
Aus der Julia REPL
Um das Notebook zu starten, stelle sicher, dass Du dich im Ordner Julia-Seminar
befindest, und führe dann julia
aus: Eine interaktive Julia-Befehlszeile wird geöffnet. Führe darin den folgenden Befehl aus:
using Pkg
Pkg.activate(pwd())
using IJulia
notebook(dir=pwd())
und das Notebook wird automatisch in einem Browser geöffnet. Navigiere zu den Dateien und öffne das Notebook Nummer 0.
Über die Befehlszeile
Alternativ kann man das Notebook auch über die Befehlszeile öffnen:
julia -L start_notebook.jl
* Für Benutzer mit mehreren Julia-Versionen
Für Benutzer mit mehreren Julia-Versionen, falls der entsprechende Kernel in Jupyter Notebook nicht gefunden werden kann, führe bitte installkernel("julia", "--project=@.")
(nur einmal) aus, bevor Du notebook(dir=pwd())
ausführst, um zuerst den Kernel zu installieren:
using Pkg
Pkg.activate(pwd())
using IJulia
installkernel("julia", "--project=@.")
notebook(dir=pwd())
Nun sollte man in Jupyter Notebook einen neuen Kernel finden, der mit der aktuellen Julia-Version verknüpft ist und den Namen julia "Julia-Version"
trägt.
Fehlerbehebung
Wenn Du auf Probleme stößt, werfe einen Blick auf den ausgezeichneten Problembehandlungsabschnitt aus dem WorkshopWizard-Paket von Carsten Bauer (das von install.jl
verwendet wird).
Julia-seminar
Material for the Julia seminar course which is adapted from two sources:
- the course from Michael Herbst (MIT license).
- the book ThinkJulia from Allen Downey and Ben Lauwens (Creative Commons Attribution-NonCommercial 3.0 Unported license).
A very rich cheat-sheet can be found here.
Software and material
The course requires various things: a working installation of Julia 1.9, Jupyter, IJulia.jl, the course material and various dependencies. To get everything follow these steps:
1) Getting Julia
For following the course you will need Julia 1.9. Julia can be easily obtained in binary form from Julia downloads.
2) Getting all the rest
To get the remaining files and dependencies start up julia
and in the resulting REPL shell, copy and paste the following:
import Downloads
script = Downloads.download("https://gitlab.mathematik.uni-stuttgart.de/stammbn/julia-seminar/-/raw/main/install.jl?ref_type=heads")
include(script)
This downloads the install.jl script and runs it from julia.
2) Getting all the rest (expert version)
As an alternative you can also also run the following commands manually (this requires to have git
and julia
available from the commandline):
git clone https://gitlab.mathematik.uni-stuttgart.de/stammbn/Julia-seminar/
cd Julia-seminar
julia install-manual.jl
3) Starting the notebook
From Julia REPL
To start the notebook make sure to be in the folder Julia-seminar
and then run julia
: an interactive Julia command line will open. In there run this command
using Pkg
Pkg.activate(pwd())
using IJulia
notebook(dir=pwd())
and the notebook will automatically open in a browser. Navigate the files and open notebook number 0.
From command line
Alternatively, one can open the notebook from the command line:
julia -L start_notebook.jl
* For users with multiple Julia versions
For users with multiple Julia versions, if the corresponding kernel cannot be found in Jupyter Notebook, please run installkernel("julia", "--project=@.")
(only once) before executing notebook(dir=pwd())
to first install the kernel:
using Pkg
Pkg.activate(pwd())
using IJulia
installkernel("julia", "--project=@.")
notebook(dir=pwd())
Now, one should find a new kernel related to the current Julia version, named julia "Julia-version"
, in Jupyter Notebook.
Troubleshooting
If you are facing issues, check out
the great troubleshooting section
from the WorkshopWizard package by Carsten Bauer (which is being used by install.jl
).
pre-commit
For developers: setting up pre-commit
is a framework that helps to manage and maintain pre-commit hooks to ensure that your code adheres to a consistent style, prevents errors, and adheres to other quality assurance checks.
-
Install
pre-commit
: To ensure smooth development, installpre-commit
using pip by running the following command:pip install pre-commit
For more information and installation options, visit the
pre-commit
website. -
Navigate to the project directory: Change into the project directory, i.e.,
julia-seminar
by running:cd julia-seminar
-
Install hooks: Install the git hooks by executing:
pre-commit install
This command installs the pre-commit script alongside existing git hooks.
Once the pre-commit hook is installed, it will automatically check your code for any issues before each commit. If the checks do not pass, you will be prompted to fix them before proceeding.