Compare commits
3 Commits
9ab39d61c3
...
structure
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
75326daa85 | ||
|
|
790b584d49 | ||
|
|
c805605ecf |
48
code/README.md
Normal file
48
code/README.md
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
# Structure of a script
|
||||||
|
|
||||||
|
1. Initially you should specify which packages you use in the scripts
|
||||||
|
|
||||||
|
~~~python
|
||||||
|
import pathlib # Packages that are provided from python
|
||||||
|
|
||||||
|
import numpy as np # Packages that are downloaded, specified in the requierements.txt
|
||||||
|
|
||||||
|
import myscript # Scripts from your Project/Pipeline
|
||||||
|
~~~
|
||||||
|
|
||||||
|
|
||||||
|
2. Next your code for the specific problem that you are trying to solve, all written code should be containded in a function/classes
|
||||||
|
It should contain a main function with is calling all individual function to solve the problem.
|
||||||
|
|
||||||
|
~~~python
|
||||||
|
def load_data(path):
|
||||||
|
with open(path, "r") as f:
|
||||||
|
f.read()
|
||||||
|
return f
|
||||||
|
|
||||||
|
def main(path):
|
||||||
|
load_data(path)
|
||||||
|
~~~
|
||||||
|
|
||||||
|
3. If the script is a standalone script, it can be run by calling python myscript.py it should contain...
|
||||||
|
|
||||||
|
~~~python
|
||||||
|
if __name__ == "__main__":
|
||||||
|
path = "../data/README.md"
|
||||||
|
main(path)
|
||||||
|
~~~
|
||||||
|
|
||||||
|
# Tips and tricks
|
||||||
|
- Plotting scripts should be named the same as the output figure for easier backtracking
|
||||||
|
- Plotting scripts should start with plot, so that one can create a bash script for that executes all plot* scripts
|
||||||
|
- If you use a directory for managing specific task, in python it is called a module, you neeed a __init__.py file in the directory more in [packagehowto](https://whale.am28.uni-tuebingen.de/git/pweygoldt/packagehowto)
|
||||||
|
|
||||||
|
# Naming conventions
|
||||||
|
- Use snake_case for functions and variables
|
||||||
|
|
||||||
|
# Documentation
|
||||||
|
- Use docstrings for all functions and classes
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
3
data/README.md
Normal file
3
data/README.md
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
# Tips and Tricks for the data directory
|
||||||
|
|
||||||
|
The filename should contain information about the date
|
||||||
Reference in New Issue
Block a user