updats, cheatsheet, installInstruc

This commit is contained in:
behinger (s-ccs 001) 2023-09-13 14:57:26 +00:00
parent af63f9f552
commit 3f696ac721
5 changed files with 75 additions and 30 deletions

View File

@ -19,7 +19,7 @@ website:
contents:
- href: index.qmd
text: "🏠 Home"
- href: installation.qmd
- href: installation/julia.qmd
text: "Installation"
- href: schedule.qmd
text: "📓 Schedule"
@ -83,7 +83,7 @@ website:
background: primary
page-footer:
background: light
left: "CC-By Benedikt Ehinger"
left: "CC-By Ehinger, Oesting, Uekerman"
resources:
- CNAME

View File

@ -0,0 +1,22 @@
## "meta"-tools
| | Julia | Python |
|------------------------|------------------------|------------------------|
| Documentation | `?obj` | `help(obj)` |
| Object content | `dump(obj)` | `print(repr(obj))` |
| Exported functions | `names(FooModule)` | `dir(foo_module)` |
| List function signatures with that name | `methods(myFun)` | |
| List functions for specific type | `methodswith(SomeType)` | `dir(SomeType)` |
| Where is ...? | `@which func` | `func.__module__` |
| What is ...? | `typeof(obj)` | `type(obj)` |
| Is it really a ...? | `isa(obj, SomeType)` | `isinstance(obj, SomeType)` |
## debugging
|||
|--|--|
`@run sum(5+1)`| run debugger, stop at error/breakpoints
`@enter sum(5+1)` | enter debugger, dont start code yet
`@show variable` | prints: variable = variablecontent
`@debug variable` | prints only to debugger, very convient in combination with `>ENV["JULIA_DEBUG"] = ToBeDebuggedModule` (could be `Main` as well)

View File

@ -0,0 +1,21 @@
# Installing Julia
The recommended way to install julia is [juliaup](https://github.com/JuliaLang/juliaup). It allows you toe.g. easily update Julia at a later point, but also test out alpha/beta versions etc.
TLDR; If you dont want to read the explicit instructions, just copy the following command
### Windows
AppStore -> JuliaUp, or `winget install julia -s msstore` in CMD
### Mac & Linux
`curl -fsSL https://install.julialang.org | sh` in any shell
# VSCode
To install VSCode (the recommended IDE), go to [this link](https://code.visualstudio.com/download) and download + install the correct package.
Next, install the Julia extension
![](https://juliateachingctu.github.io/Julia-for-Optimization-and-Learning/stable/installation/vscodeext_1.png) (thanks to https://juliateachingctu.github.io for providing us with the nice graphics)
Finally press `Ctrl + Shift + P` to get VSCodes command palette, and type in `Julia: Start REPL`
![](https://juliateachingctu.github.io/Julia-for-Optimization-and-Learning/stable/installation/vscodeext_2.png)

View File

@ -192,13 +192,14 @@ Following `semver` - three parts:
`v2.7.5`
means:
- **Major** 2
- **Minor** 7
- **Bugfix** 5
Bump **Major** if you propose backward-breaking changes
Bump **Minor** if you only introduce new features
Bump **Bugfix** if you, well, fix bugs
- Bump **Major** if you propose backward-breaking changes
- Bump **Minor** if you only introduce new features
-Bump **Bugfix** if you, well, fix bugs
**Special case:**

View File

@ -152,6 +152,30 @@ And a nice sideeffect: By doing this, we get rid of any specialized "serialized"
:::
## Linear Algebra
```julia
import LinearAlgebra # <1>
import LinearAlgebra: qr
using LinearAlgebra # <2>
```
1. Requires to write `LinearAlgebra.QR(...)` to access a function
2. `LinearAlgebra` is a `Base` package, and always available
:: callout
Julia typically recommends to use `using PackageNames`. Name-space polution is not a problem, as the package manager will never silently overwrite an already existing method - it will always as the user to specify in those cases (different to R: shows a warning, or Python: just does on with life as if nothing happened)
::
```julia
A = Matrix{Float64}(undef,11,22) # <1>
B = Array{Float64,2}(undef,22,33) # <2>
qr(A*B)
```
1. equivalent to `Array`, as `Matrix` is a convenience type-alias for `Array` with 2 dimensions. Same thing for `Vector`.
2. the `2` of `{Float64,2}` is not mandatory
Much more on wednesday in the lecture `LinearAlgebra`!
## Style-conventions
@ -389,28 +413,5 @@ Macros allow to programmers to edit the actual code **before** it is run. We wil
a = "123"
@show a
```
# Cheatsheets
## meta-tools
<!-- maybe move to own file "cheatsheets?" -->
| | Julia | Python |
|------------------------|------------------------|------------------------|
| Documentation | `?obj` | `help(obj)` |
| Object content | `dump(obj)` | `print(repr(obj))` |
| Exported functions | `names(FooModule)` | `dir(foo_module)` |
| List function signatures with that name | `methods(myFun)` | |
| List functions for specific type | `methodswith(SomeType)` | `dir(SomeType)` |
| Where is ...? | `@which func` | `func.__module__` |
| What is ...? | `typeof(obj)` | `type(obj)` |
| Is it really a ...? | `isa(obj, SomeType)` | `isinstance(obj, SomeType)` |
## debugging
|||
|--|--|
`@run sum(5+1)`| run debugger, stop at error/breakpoints
`@enter sum(5+1)` | enter debugger, dont start code yet
`@show variable` | prints: variable = variablecontent
`@debug variable` | prints only to debugger, very convient in combination with `>ENV["JULIA_DEBUG"] = ToBeDebuggedModule` (could be `Main` as well)
## Debugging
XXX