Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation additions: [contribution guide, unit tests guide] #16

Merged
merged 3 commits into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 61 additions & 0 deletions .github/CONTRIBUTE/contribute.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
### **How to contribute?**
* Open a pull request exaplaining your addition/fix. You can also see the [Bug report](../ISSUE_TEMPLATE/bug_report.md)

* Implementation is not everything. You have to add test cases for every function that you add at the [tests](../../tests/) folder.

* Last but not least, some documentation will be good for the users to learn how to use your code. You can add your documentation at the [docs](../../docs/) folder.

### **Good practices**
* We have automated test cases that are located at the [tests](../../tests/) folder. The workflow will automatically run the test cases on your PR, but, before creating a PR make sure your test cases run correctly locally using this command ```cd tests/unit && python -m unittest discover -s . -p "*.py"```

* Make sure that you add any new libraries that you may use at [dev-dependencies](../../dev-dependencies.txt) as well as updating the [setup.py](../../setup.py) file(if needed).

* Try to add docstrings on every new function that you implement as it will automatically be generated to documentation.Comments should look like this
- For functions:
```python
def your_function(param1: type, param2: type, ...) -> return_type:
"""
Describe briefly what your function does

Args:
param1(type): Describe what param1 is used for.
param2(type): Describe what param2 is used for.
etc.
Return:
return_type: Explain what your function returns.
"""
```
- For classes:
```python
class your_class:
"""
Describe briefly what your class does

Static attributes:
param1(type): Explain what param1 is used for.
param2(type): Explain what param2 is used for.
etc.

Methods:
func1(param1, param2, ...):
Here you have to explain what func1 does using the tutorial above.
You have to do the same for every function.

Note that you can add more docstrings inside function if you wish.
"""
def __init__(self, param1: type, param2: type, ...):
...

def func1(self, param1: type, param2: type, ...) -> return_type:
...
```

* As seen above, it is a good practice to always set parameter types in functions as well as return types.

### **Useful files for contributions**

* You can find all the csv samples at the [data](../../spare_scores/data/) folder.

* You can find all the existing model weights at the [mdl](../../spare_scores/mdl/) folder.

* All the code that is used for the documentation is located at the [contents](../../docs/source/) folder and you can manually add more.
28 changes: 28 additions & 0 deletions .github/CONTRIBUTE/unit_tests.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
### **How to write unit tests**
* As explained at the [contribution guide](contribute.md) it's a good practice to write test cases for any additions you make. For our test cases we use the unittest python3 library. The following is an example of a unit test with unittest library:

```python

import unittest

class CheckThisAndThat(unittest.TestCase):

def testing_this(self):
self.data1 = ...
self.data2 = ...
# run your functions...
# result1 = my_func(self.data1, ...)
# result2 = my_func(self.data2, ...)
self.assertTrue(result1 == CorrectResult1)
self.assertTrue(result2 == CorrectResult2)

def testing_that(self):
self.param1 = ...
self.param2 = ...
# run something
# model = my_model(self.param1, self.param2, ...)
# result1 = my_model.do_sth()
self.assertTrue(result1 == CorrectResult1)
```

The following will run 2 test cases and 3 assertions. We explain how to run test cases at the [contribution guide](contribute.md).
12 changes: 6 additions & 6 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,25 @@ assignees: ''

---

**Describe the bug**
### **Describe the bug**
A clear and concise description of what the bug is.

**To Reproduce**
### **To Reproduce**
Steps to reproduce the behavior:
1. Go to '...'
2. Click on '....'
3. Scroll down to '....'
4. See error

**Expected behavior**
### **Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
### **Screenshots**
If applicable, add screenshots to help explain your problem.

**Platform Info (please complete the following information):**
### **Platform Info (please complete the following information):**
- OS: [e.g. Windows] + Version [e.g. 10]
- spare_scores Version: 1.0.0

**Additional context**
### **Additional context**
Add any other context about the problem here.
Loading