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: docs/source/getting_started/contributors_guide.rst
+38-3Lines changed: 38 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -50,13 +50,48 @@ For changes to ``./docs``::
50
50
Building the docs the first time takes a little while. After this, you will see a build directory. From here you can preview the generated HTML
51
51
in your browser.
52
52
53
+
Linting and code format
54
+
~~~~~~~~~~~~~~~~~~~~~~~
55
+
56
+
We use both black and ruff to format and lint the code.
57
+
The code will automatically be formatted by black after being committed, alternatively run black on any changed files.
58
+
59
+
A linting check is done with ruff, please ensure that this passes prior to creating a pull request.
60
+
To check the code with ruff run the following command in the root directory of the repository::
61
+
62
+
ruff LoopStructural
63
+
64
+
The configuration parameters for ruff and black are stored in the pyproject.toml file.
65
+
66
+
Coding Guidelines
67
+
~~~~~~~~~~~~~~~~~
68
+
- Reduce Duplicated Code: Strive to avoid duplication by modularizing code and promoting code reuse where appropriate.
69
+
- Document code: Use numpy style docstrings and ensure that any new features are added into the documentation
70
+
- Type hints: Use appropriate type hints for any function arguments and returns
71
+
- Avoid python loops: Avoid using pure python loops - where possible used vectorized functions in numpy, geopandas, scipy
72
+
- Use Object-Oriented Data Structures: Utilize object-oriented programming principles to structure data and functionality in a cohesive manner.
73
+
- Use British English Spelling: Adhere to British English spelling conventions throughout the codebase and documentation.
74
+
- Use Conventional Commits: Follow the Conventional Commits specification for clear and structured commit messages.
75
+
- Ensure Tests Pass: Before submitting any changes, ensure that all tests pass locally.
76
+
- Write Tests for New Code: Include tests for any new functionality or code additions to maintain code quality and prevent regressions.
77
+
- Minimize External Dependencies: Aim to minimize reliance on external libraries and frameworks to keep the project lightweight.
78
+
- Make External Dependencies Optional: When external dependencies are necessary, make them optional where feasible to increase flexibility and ease of installation.
79
+
53
80
Commit messages
54
81
---------------
55
82
A changelog is automatically generated from the commit message, the following keywords are identified in the commit log.
56
83
57
-
* add - defining a new feature that is added to LoopStructural
58
-
* fix - a bugfix
59
-
* change - any changes to features
84
+
.. code-block::
85
+
<type>[optional scope]: <description>
86
+
87
+
[optional body]
88
+
89
+
[optional footer(s)]
90
+
91
+
92
+
* feat: - defining a new feature that is added to LoopStructural
93
+
* fix: - a bugfix
94
+
* BREAKING CHANGE: - any changes to features
60
95
* remove - removing features or code from LoopStructural
Copy file name to clipboardExpand all lines: docs/source/getting_started/loopstructural_design.rst
+11-1Lines changed: 11 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -49,13 +49,19 @@ The main modules for the library are:
49
49
2. modelling
50
50
3. visualisation
51
51
4. utils
52
+
5. datasets
53
+
54
+
52
55
53
56
**Coding paradigm** LoopStructural is written in an object oriented paradigm.
54
57
The four pillars of object oriented coding should be adhered to:
55
58
56
59
* **Encapsulation**: Attributes in python are designed to be accessible both within the class and from outside of the class. In LoopStructural, the where an attribute of a class should be private the ``@property`` decorator should be used.
57
60
* **Inheritance**: Classes should inheret attributes and methods from parent classes.
58
61
* **Polymorphism**: Child classes, where a method is different from a parent class should override methods from parent classes.
62
+
* **Abstraction**: Classes should be designed to be abstract and avoid containing implementation details.
63
+
64
+
**ABC** LoopStructural uses abstract base classes to define the interface for different classes.
59
65
60
66
**Dependency management** The library is written in python and is dependent on numpy, scipy. Care should be taken to avoid incorporating of uncessary dependencies. For dependencies that are not part of the standard scientific python toolkit (numfocus projects) the dependencies should be optional and not be required.
61
67
@@ -65,6 +71,8 @@ The four pillars of object oriented coding should be adhered to:
65
71
There should be unit tests for all classes and methods.
66
72
Integration tests should be included to test the interaction between classes.
67
73
74
+
**Commits** Commits should be made using the conventional commit style.
75
+
68
76
**CI/CD** The code is automatically versioned using release-please.
69
77
When creating a commit use the conventional commit style e.g. ``fix: bug fix``, ``feat: new feature``, ``chore: code change``.
70
78
A new patch pull request will be created when a bug fix is applied and passes the tests.
@@ -120,6 +128,7 @@ A visualisation module can be implemented by simply subclassing the **BaseModelP
120
128
---------
121
129
122
130
The utils module is a container for utility functions that are used throughout the library.
131
+
Where possible util functions should be stored in separate files that are imported in the `__init__.py` file.
123
132
124
133
125
134
@@ -138,6 +147,7 @@ A fixture is a function that can be called by a test for a range of predefined p
138
147
For example a fixture to generate different discrete interpolators would be
139
148
140
149
.. code-block::
150
+
141
151
from LoopStructural.interpolators import FiniteDifferenceInterpolator as FDI, \
142
152
PiecewiseLinearInterpolator as PLI
143
153
from LoopStructural.interpolators import StructuredGrid, TetMesh
@@ -165,7 +175,7 @@ For example a fixture to generate different discrete interpolators would be
165
175
166
176
This fixture can then be called by any test in the testing suite:
167
177
168
-
.. code-block:
178
+
.. code-block::
169
179
170
180
from LoopStructural.interpolators import GeologicalInterpolator
0 commit comments