You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: CONTRIBUTING.md
+132-67
Original file line number
Diff line number
Diff line change
@@ -7,78 +7,119 @@ If an issue for the changes you intend to make does not exist, create one.
7
7
8
8
1. Raise an issue for the changes you wish to make (or start working on a pre-existing issue).
9
9
2. Make a feature branch for your changes.
10
-
> Name the branch as add_<name_of_the_function_to_be_added>
10
+
11
+
> Name the branch as <issue_number>-add-<name_of_the_function_to_be_added> or something as descriptive
12
+
11
13
3. Base your feature branch on the master branch.
14
+
12
15
> Remember to
13
-
```console
16
+
17
+
```bash
14
18
git pull
15
19
```
16
-
before checking out to a new branch.
17
-
18
-
4. Do all
19
-
- editing
20
-
- formatting
21
20
22
-
and
23
-
24
-
- testing
21
+
before checking out to a new branch.
25
22
26
-
on the issue-specific branch. Commit only to that branch, do not edit the master branch directly.
23
+
4. Do all editing formatting and testing on the issue-specific branch.
24
+
Commit only to that branch, do not edit the master branch directly.
27
25
28
-
5. Once you have something working, make sure your commits are according to the desired coding style and that your branch contains appropriate documentation and tests.
26
+
5. Once you have something working, make sure your commits are
27
+
according to the desired coding style and that your branch contains
28
+
appropriate documentation and tests.
29
29
30
-
6. Create a pull request (PR) to merge your branch into the master. In it, summarize your changes.
31
-
Assign a reviewer / reviewers for the PR.
30
+
6. Create a pull request (PR) to merge your branch into the master. In
31
+
it, summarize your changes. Assign a reviewer / reviewers for the
32
+
PR.
32
33
33
34
## Terminology and general coding principles
34
35
35
36
1. Packages
36
37
37
-
The folders at eis_toolkit/eis_toolkit are called packages. The initial division to packages already exist. Feel free to suggest modifications to the
38
-
current package division via creating an issue for it! Note that the packages can split up into sub packages if needed. Subpackages' names should also represent the main purpose of the modules belonging to the particular subpackage.
38
+
The folders inside `./eis_toolkit` are called subpackages. Feel free to suggest
39
+
modifications to the current subpackage division via creating an issue for it!
40
+
Note that the subpackages can split up into more subpackages if needed.
39
41
40
42
2. Modules
41
43
42
-
Module names come from the names of the .py files containing function declarations. You will need to create a new python file for each functionality. The name of the file containing the function declaration(s) for providing the functionality will be essentially the same as the function’s name but instead of the basic form use –ing form if it makes sense.
44
+
Module names come from the names of the .py files containing function
45
+
declarations. You will need to create a new python file for each functionality.
46
+
The name of the file containing the function declaration(s) for providing the
47
+
functionality will be essentially the same as the function’s name but instead
48
+
of the basic form use –ing form if it makes sense.
43
49
44
-
- Try to create modules in a way that each module contains only one functionality. Split this functionality into two function declarations: one for external use and one (the core functionality) for internal use. See e.g. implementation of [clipping functionality](./eis_toolkit/raster_processing/clipping.py) for reference.
50
+
- Try to create modules in a way that each module contains only one
51
+
functionality. Split this functionality into two function
52
+
declarations: one for external use and one (the core functionality)
53
+
for internal use. See e.g. implementation of [clipping
54
+
functionality](./eis_toolkit/raster_processing/clipping.py) for
55
+
reference.
45
56
46
57
1. Functions
47
58
48
-
Name each function according to what it is supposed to do. Try to express the purpose as simplistic as possible. In principle, each function should be creted for executing one task. We prefer modular structure and low hierarchy by trying to avoid nested function declarations. It is highly recommended to call other functions for executing sub tasks.
59
+
Name each function according to what it is supposed to do. Try to
60
+
express the purpose as simplistic as possible. In principle, each
61
+
function should be created for executing one task. We prefer modular
62
+
structure and low hierarchy by trying to avoid nested function
63
+
declarations. It is highly recommended to call other functions for
64
+
executing sub tasks.
49
65
50
66
**Example (packages, modules & functions):**
51
67
52
-
Create a function which clips a raster file with polygon -> name the function as clip. Write this function declaration into a new python file with name clipping.py inside of the eis_toolkit/eis_toolkit/raster_processing folder.
68
+
Create a function which clips a raster file with polygon -\> name the
69
+
function as clip. Write this function declaration into a new python file
70
+
with name clipping.py inside of the
71
+
`eis_toolkit/raster_processing` folder.
53
72
54
73
4. Classes
55
74
56
-
A class can be defined inside of a module or a function. Class names should begin with a capital letter and follow the CamelCase naming convention: if a class name contains multiple words, the spaces are simply ignored and each separate word begins with capital letters.
75
+
A class can be defined inside of a module or a function. Class names
76
+
should begin with a capital letter and follow the CamelCase naming
77
+
convention: if a class name contains multiple words, the spaces are
78
+
simply ignored and each separate word begins with capital letters.
79
+
80
+
When implementing the toolkit functions, create classes only when they
81
+
are clearly beneficial.
57
82
58
-
When implementing the toolkit functions, create classes only when they are clearly beneficial.
59
-
> If you create new custom exception classes, add them directly into eis_toolkit/eis_toolkit/exceptions.py file.
83
+
> If you create new custom exception classes, add them directly into
84
+
> `eis_toolkit/exceptions.py` file.
60
85
61
86
5. Variables
62
87
63
-
Avoid using global variables. Name your variables clearly for code maintainability and to avoid bugs.
88
+
Avoid using global variables. Name your variables clearly for code
89
+
maintainability and to avoid bugs.
64
90
65
91
6. Docstrings and code comments
66
92
67
-
For creating docstrings, we rely on google convention (see section 3.8 in [link](https://google.github.io/styleguide/pyguide.html) for more detailed instructions). Let’s try to minimize the amount of code comments. Well defined docstrings should do most of the job with clear code structure.
93
+
For creating docstrings, we rely on google convention (see section 3.8
94
+
in [link](https://google.github.io/styleguide/pyguide.html) for more
95
+
detailed instructions). Let's try to minimize the amount of code
96
+
comments. Well defined docstrings should do most of the job with clear
97
+
code structure.
68
98
69
99
## Naming policy
70
100
71
-
General guidelines about naming policy (applies to package, module, function, class and variable names):
72
-
- all names should be given in English
73
-
- avoid too cryptic names by using complete words
74
-
- if the name consists of multiple words, use snake_case so replace space with underscore character (_) (CamelCase is used for classes as an exception to this rule)
75
-
- do not include special characters, capital letters or numbers into the names unless in case of using numbers in variable names and there is an unavoidable need for it / using numbers significantly increases clarity
101
+
General guidelines about naming policy (applies to package, module,
102
+
function, class and variable names):
103
+
104
+
- all names should be given in English
105
+
106
+
- avoid too cryptic names by using complete words
107
+
108
+
- if the name consists of multiple words, use snake_case so replace
109
+
space with underscore character (\_) (CamelCase is used for classes
110
+
as an exception to this rule)
111
+
112
+
- do not include special characters, capital letters or numbers into
113
+
the names unless in case of using numbers in variable names and
114
+
there is an unavoidable need for it / using numbers significantly
115
+
increases clarity
76
116
77
117
## Code style
78
118
79
119
### pre-commit
80
120
81
-
> Note that pre-commit was added as the primary style check tool later in the project and you need to install and enable it manually!
121
+
> Note that pre-commit was added as the primary style check tool later
122
+
> in the project and you need to install and enable it manually!
82
123
83
124
The repository contains a `.pre-commit-config.yaml` file that has configuration
84
125
to run a set of [`pre-commit`](https://pre-commit.com) hooks. As the name
@@ -90,14 +131,14 @@ copy of the repository to run.
90
131
To install `pre-commit` on Debian or Ubuntu -based systems with `apt` as
91
132
the package manager you should be able to run:
92
133
93
-
```console
134
+
```bash
94
135
apt update
95
136
apt install pre-commit
96
137
```
97
138
98
139
Alternatively, it can be installed with the system installation of `Python`:
raise InvalidParameterValueException(f"Window size is too small: {height}, {width}.")
198
250
```
199
-
- Use beartype's decorator for automatic function argument type checking and import types from `beartype.typing` if a warning is raised by beartype on imports from `typing`:
251
+
252
+
- Use beartype's decorator for automatic function argument type
253
+
checking and import types from `beartype.typing` if a warning is
Here are some things to remember while implementing a new tool:
233
290
234
-
- Create an issue **before or when you start** developing a functionality
235
-
- Adhere to the style guide
236
-
- Look at existing implementations and copy the form
237
-
- Enable pre-commit and fix style/other issues according to the error messages
238
-
- Remember to use typing hints
239
-
- Write tests for your functions
240
-
- Add a .md file for you functionality
241
-
- If you think the tool you are developing could use a separate general utility function, make an issue about this need before starting to develop it on your own. Also check if a utility function exists already
242
-
- Remember to implement only the minimum what is required for the tool! With data functions, you can usually assume file reading/writing, nodata handling and other such processes are done before/after executing your tool
291
+
- Create an issue **before or when you start** developing a
292
+
functionality
293
+
- Adhere to the style guide
294
+
- Look at existing implementations and copy the form
295
+
- Enable pre-commit and fix style/other issues according to the
296
+
error messages
297
+
- Remember to use typing hints
298
+
- Write tests for your functions
299
+
- Add a .md file for you functionality
300
+
- If you think the tool you are developing could use a separate
301
+
general utility function, make an issue about this need before
302
+
starting to develop it on your own. Also check if a utility function
303
+
exists already
304
+
- Remember to implement only the minimum what is required for the
305
+
tool! With data functions, you can usually assume file
306
+
reading/writing, nodata handling and other such processes are done
0 commit comments