improved materials
This commit is contained in:
parent
a14fbfbf67
commit
22258b264c
@ -139,6 +139,64 @@ version = "0.3.4"
|
|||||||
[...]
|
[...]
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
|
## Projects in Julia
|
||||||
|
|
||||||
|
Formally, projects don't have specific requirements. You should activate an environment (`Project.toml`+`Manifest.toml`) in the main folder though. I recommend the following minimal structure:
|
||||||
|
|
||||||
|
- `./src/` - all functions should go there
|
||||||
|
- `./scripts/` - all actual scripts should go here,
|
||||||
|
- `./README.md` - Write what this is about, who you are etc.
|
||||||
|
- `./Project.toml` - Your explicit dependencies
|
||||||
|
- `./Manifest.toml` - Your implicit dependencies + versions <-- this makes it reproducible!
|
||||||
|
|
||||||
|
::: callout-tip
|
||||||
|
One recommendation is to use `DrWatson.initialize_project([path])` to start a new project - it will generate a nice folder structure + provide some other helpful `DrWatson.jl` features.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
:::
|
||||||
|
|
||||||
|
|
||||||
|
:::{.callout-tip collapse="true"}
|
||||||
|
## Click to expand the full datastructure
|
||||||
|
```
|
||||||
|
│projectdir <- Project's main folder. It is initialized as a Git
|
||||||
|
│ repository with a reasonable .gitignore file.
|
||||||
|
│
|
||||||
|
├── _research <- WIP scripts, code, notes, comments,
|
||||||
|
│ | to-dos and anything in an alpha state.
|
||||||
|
│ └── tmp <- Temporary data folder.
|
||||||
|
│
|
||||||
|
├── data <- **Immutable and add-only!**
|
||||||
|
│ ├── sims <- Data resulting directly from simulations.
|
||||||
|
│ ├── exp_pro <- Data from processing experiments.
|
||||||
|
│ └── exp_raw <- Raw experimental data.
|
||||||
|
│
|
||||||
|
├── plots <- Self-explanatory.
|
||||||
|
├── notebooks <- Jupyter, Weave or any other mixed media notebooks.
|
||||||
|
│
|
||||||
|
├── papers <- Scientific papers resulting from the project.
|
||||||
|
│
|
||||||
|
├── scripts <- Various scripts, e.g. simulations, plotting, analysis,
|
||||||
|
│ │ The scripts use the `src` folder for their base code.
|
||||||
|
│ └── intro.jl <- Simple file that uses DrWatson and uses its greeting.
|
||||||
|
│
|
||||||
|
├── src <- Source code for use in this project. Contains functions,
|
||||||
|
│ structures and modules that are used throughout
|
||||||
|
│ the project and in multiple scripts.
|
||||||
|
│
|
||||||
|
├── README.md <- Optional top-level README for anyone using this project.
|
||||||
|
├── .gitignore <- by default ignores _research, data, plots, videos,
|
||||||
|
│ notebooks and latex-compilation related files.
|
||||||
|
│
|
||||||
|
├── Manifest.toml <- Contains full list of exact package versions used currently.
|
||||||
|
└── Project.toml <- Main project file, allows activation and installation.
|
||||||
|
Includes DrWatson by default.
|
||||||
|
```
|
||||||
|
:::
|
||||||
|
|
||||||
|
|
||||||
## Packages in Julia
|
## Packages in Julia
|
||||||
Several thousand packages exist in Julia already. Take a thorough look before starting something new!
|
Several thousand packages exist in Julia already. Take a thorough look before starting something new!
|
||||||
|
|
||||||
@ -181,10 +239,10 @@ The default registry is [JuliaRegistries/General](https://github.com/JuliaRegist
|
|||||||
### Adding dependencies
|
### Adding dependencies
|
||||||
```julia
|
```julia
|
||||||
]activate ./path/to/MyStatsPackage
|
]activate ./path/to/MyStatsPackage
|
||||||
]add UnicodePlots
|
]add ProgressMeter
|
||||||
]compat # <1>
|
]compat # <1>
|
||||||
```
|
```
|
||||||
1. let's directly add a compat entry for UnicodePlots
|
1. let's directly add a compat entry for ProgressMeter
|
||||||
|
|
||||||
### Semantic Versioning
|
### Semantic Versioning
|
||||||
Following `semver` - three parts:
|
Following `semver` - three parts:
|
||||||
@ -234,57 +292,22 @@ As you can see, develop version (`version < 1`) are treated a bit special in Jul
|
|||||||
keep the compat list in alphabetical order - github-actions might behave very strange else.
|
keep the compat list in alphabetical order - github-actions might behave very strange else.
|
||||||
:::
|
:::
|
||||||
|
|
||||||
## Projects in Julia
|
### Internals of a package
|
||||||
|
|
||||||
Formally, projects don't have specific requirements. You should activate an environment (`Project.toml`+`Manifest.toml`) in the main folder though. I recommend the following minimal structure:
|
The file `./src/MyStatsPackage.jl` should contain:
|
||||||
|
```julia
|
||||||
|
module MyStatsPackage
|
||||||
|
using ProgressMeter # <1>
|
||||||
|
include("src/stats_functions.jl")
|
||||||
|
|
||||||
- `./src/` - all functions should go there
|
export sum
|
||||||
- `./scripts/` - all actual scripts should go here,
|
export mean, tstat
|
||||||
- `./README.md` - Write what this is about, who you are etc.
|
|
||||||
- `./Project.toml` - Your explicit dependencies
|
|
||||||
- `./Manifest.toml` - Your implicit dependencies + versions <-- this makes it reproducible!
|
|
||||||
|
|
||||||
::: callout-tip
|
end
|
||||||
One recommendation is to use `DrWatson.initialize_project([path])` to start a new project - it will generate a nice folder structure + provide some other helpful `DrWatson.jl` features.
|
|
||||||
|
|
||||||
(click the following tipp to expand the full datastructure)
|
|
||||||
|
|
||||||
:::
|
|
||||||
|
|
||||||
|
|
||||||
:::{.callout-tip collapse="true"}
|
|
||||||
```
|
```
|
||||||
│projectdir <- Project's main folder. It is initialized as a Git
|
1. We use GLMakie as a simple example as you need it on Wednesday again anyway - it does take a while to install though!
|
||||||
│ repository with a reasonable .gitignore file.
|
|
||||||
│
|
Now we are ready to use the package from a different environment
|
||||||
├── _research <- WIP scripts, code, notes, comments,
|
```julia
|
||||||
│ | to-dos and anything in an alpha state.
|
]dev ./path/to/MyStatsPackage
|
||||||
│ └── tmp <- Temporary data folder.
|
|
||||||
│
|
|
||||||
├── data <- **Immutable and add-only!**
|
|
||||||
│ ├── sims <- Data resulting directly from simulations.
|
|
||||||
│ ├── exp_pro <- Data from processing experiments.
|
|
||||||
│ └── exp_raw <- Raw experimental data.
|
|
||||||
│
|
|
||||||
├── plots <- Self-explanatory.
|
|
||||||
├── notebooks <- Jupyter, Weave or any other mixed media notebooks.
|
|
||||||
│
|
|
||||||
├── papers <- Scientific papers resulting from the project.
|
|
||||||
│
|
|
||||||
├── scripts <- Various scripts, e.g. simulations, plotting, analysis,
|
|
||||||
│ │ The scripts use the `src` folder for their base code.
|
|
||||||
│ └── intro.jl <- Simple file that uses DrWatson and uses its greeting.
|
|
||||||
│
|
|
||||||
├── src <- Source code for use in this project. Contains functions,
|
|
||||||
│ structures and modules that are used throughout
|
|
||||||
│ the project and in multiple scripts.
|
|
||||||
│
|
|
||||||
├── README.md <- Optional top-level README for anyone using this project.
|
|
||||||
├── .gitignore <- by default ignores _research, data, plots, videos,
|
|
||||||
│ notebooks and latex-compilation related files.
|
|
||||||
│
|
|
||||||
├── Manifest.toml <- Contains full list of exact package versions used currently.
|
|
||||||
└── Project.toml <- Main project file, allows activation and installation.
|
|
||||||
Includes DrWatson by default.
|
|
||||||
```
|
```
|
||||||
:::
|
|
8
material/1_mon/envs/tasks.qmd
Normal file
8
material/1_mon/envs/tasks.qmd
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
# Task
|
||||||
|
1. Create a new package `MyStatsPackage` using `generate`
|
||||||
|
2. Add your `statistic.jl` & "include" it.
|
||||||
|
3. Export all functions
|
||||||
|
4. Create a new environment in a separate folder and add the package.
|
||||||
|
5. Does `using MyStatsPackage` work now? :tada: congratulations!
|
||||||
|
6. Go back to your package environment. Now add a dependency (e.g. ProgressMeter) and a `compat`-entry
|
||||||
|
7. Go back to your project environment, has the dependency been updated? Think: should you use `resolve` or `instantiate`?
|
@ -1,8 +1,9 @@
|
|||||||
#---
|
#---
|
||||||
|
using ProgressMeter
|
||||||
|
|
||||||
function rse_sum(x)
|
function rse_sum(x)
|
||||||
s = 0
|
s = 0
|
||||||
for k = eachindex(x)
|
@showprogress for k = eachindex(x)
|
||||||
s = s+x[k]
|
s = s+x[k]
|
||||||
end
|
end
|
||||||
return s
|
return s
|
||||||
|
@ -19,7 +19,18 @@ You can mark some code and execute it using `ctrl` + `enter` - you can also gene
|
|||||||
|
|
||||||
Well done! You now have all functions defined with which we will continue our journey.
|
Well done! You now have all functions defined with which we will continue our journey.
|
||||||
|
|
||||||
|
::: callout
|
||||||
|
## Bonus Task ProgressMeter
|
||||||
|
for very large sums we might want to add a progressmeter. To do so:
|
||||||
|
|
||||||
|
```julia
|
||||||
|
]add ProgressMeter
|
||||||
|
using ProgressMeter
|
||||||
|
...
|
||||||
|
@showprogress for ...
|
||||||
|
```
|
||||||
|
|
||||||
|
And that's it! You should have a nice progress bar now
|
||||||
# Task 2 {#2}
|
# Task 2 {#2}
|
||||||
|
|
||||||
1. Implement a type `StatResult` with fields for `x`, `n`, `std` and `tvalue`
|
1. Implement a type `StatResult` with fields for `x`, `n`, `std` and `tvalue`
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
julia_version = "1.9.2"
|
julia_version = "1.9.2"
|
||||||
manifest_format = "2.0"
|
manifest_format = "2.0"
|
||||||
project_hash = "72e4df15571f2f16bde88622e0b2d85533f8eea7"
|
project_hash = "6b7e018e1e42b9e8dc72df15bdc780c4b72357b0"
|
||||||
|
|
||||||
[[deps.AbstractFFTs]]
|
[[deps.AbstractFFTs]]
|
||||||
deps = ["LinearAlgebra"]
|
deps = ["LinearAlgebra"]
|
||||||
|
@ -3,3 +3,4 @@ AlgebraOfGraphics = "cbdf2221-f076-402e-a563-3d30da359d67"
|
|||||||
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
|
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
|
||||||
GLMakie = "e9467ef8-e4e7-5192-8a1a-b1aee30e663a"
|
GLMakie = "e9467ef8-e4e7-5192-8a1a-b1aee30e663a"
|
||||||
PalmerPenguins = "8b842266-38fa-440a-9b57-31493939ab85"
|
PalmerPenguins = "8b842266-38fa-440a-9b57-31493939ab85"
|
||||||
|
ProgressMeter = "92933f4c-e287-5a05-a399-4b506db050ca"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user