11# Contributing
22
3- Thank you for your interest in contributing to the Anscombe Transform codec! This guide will help you get started.
4-
53## Development Setup
64
7- ### Prerequisites
8-
9- - Python >= 3.11
10- - [ Hatch] ( https://hatch.pypa.io/ ) for environment management
11- - Git
12-
135### Getting Started
146
1571 . ** Fork and clone the repository**
@@ -21,10 +13,15 @@ cd anscombe-transform
2113
22142 . ** Install Hatch**
2315
16+ Via pip:
17+
2418``` bash
2519pip install hatch
2620```
2721
22+ Or [ directly] ( https://hatch.pypa.io/latest/install/#installers ) .
23+
24+
28253 . ** Create a development environment**
2926
3027``` bash
@@ -48,161 +45,9 @@ hatch run test:pytest tests/test_codec.py
4845hatch run test:pytest tests/ --cov=src/anscombe_transform
4946```
5047
51- ## Development Workflow
52-
53- ### Making Changes
54-
55- 1 . Create a new branch for your feature or fix:
56- ``` bash
57- git checkout -b feature/my-new-feature
58- ```
59-
60- 2 . Make your changes following the coding standards below
61-
62- 3 . Run tests to ensure everything works:
63- ``` bash
64- hatch run test:pytest tests/
65- ```
66-
67- 4 . Run linting and formatting:
68- ``` bash
69- hatch run test:ruff check src/ tests/
70- hatch run test:ruff format src/ tests/
71- ```
72-
7348### Testing
7449
75- The project uses pytest for testing. Tests are organized in the ` tests/ ` directory:
76-
77- - ` test_codec.py ` - Direct codec encode/decode tests
78- - ` test_zarr.py ` - Zarr integration tests for V2 and V3
79- - ` test_notebooks.py ` - Notebook execution tests
80-
81- ** Writing Tests**
82-
83- - Use the ` nearly_equal() ` fixture for comparing arrays with tolerance
84- - Test with synthetic Poisson-distributed data
85- - Cover both Zarr V2 and V3 implementations
86- - Include edge cases (zero values, large values, etc.)
87-
88- Example:
89- ``` python
90- def test_my_feature (nearly_equal ):
91- # Create test data
92- data = np.random.poisson(lam = 50 , size = (10 , 100 , 100 )).astype(' int16' )
93-
94- # Test your feature
95- result = my_function(data)
96-
97- # Assert with tolerance
98- assert nearly_equal(result, expected, conversion_gain = 2.5 )
99- ```
100-
101- ### Running Tests Across Environments
102-
103- Test against multiple Python and NumPy versions:
104-
105- ``` bash
106- # Run on all environments
107- hatch run test:pytest tests/
108-
109- # Run on specific Python version
110- hatch run test.py3.12-2.2:pytest tests/
111-
112- # Test against upstream dependencies
113- hatch run upstream:pytest tests/
114- ```
115-
116- ## Coding Standards
117-
118- ### Style Guide
119-
120- - Follow PEP 8
121- - Use Ruff for linting and formatting
122- - Maximum line length: 100 characters
123- - Use type hints for all public functions
124-
125- ### Documentation
126-
127- - Write docstrings for all public functions and classes
128- - Use NumPy-style docstrings
129- - Include examples in docstrings where helpful
130- - Update relevant documentation in ` docs/ `
131-
132- Example docstring:
133- ``` python
134- def my_function (data : np.ndarray, param : float ) -> np.ndarray:
135- """
136- Brief description of what this function does.
137-
138- Parameters
139- ----------
140- data : np.ndarray
141- Description of data parameter
142- param : float
143- Description of param parameter
144-
145- Returns
146- -------
147- np.ndarray
148- Description of return value
149-
150- Examples
151- --------
152- >>> data = np.array([1, 2, 3])
153- >>> result = my_function(data, 2.5)
154- """
155- pass
156- ```
157-
158- ### Type Hints
159-
160- Use type hints for function signatures:
161-
162- ``` python
163- from typing import Optional, Union
164- import numpy as np
165-
166- def process_data (
167- data : np.ndarray,
168- conversion_gain : float ,
169- zero_level : Optional[float ] = None
170- ) -> tuple[np.ndarray, dict ]:
171- """ Process data with optional parameters."""
172- pass
173- ```
174-
175- ## Submitting Changes
176-
177- ### Pull Request Process
178-
179- 1 . ** Update documentation** if you've changed APIs or added features
180-
181- 2 . ** Add tests** for new functionality
182-
183- 3 . ** Update CHANGELOG** if significant changes were made
184-
185- 4 . ** Push your branch** to your fork:
186- ``` bash
187- git push origin feature/my-new-feature
188- ```
189-
190- 5 . ** Open a Pull Request** on GitHub:
191- - Provide a clear description of the changes
192- - Reference any related issues
193- - Ensure CI tests pass
194-
195- ### Pull Request Checklist
196-
197- Before submitting, verify:
198-
199- - [ ] Tests pass locally
200- - [ ] New tests added for new features
201- - [ ] Documentation updated
202- - [ ] Code follows style guidelines
203- - [ ] Type hints added
204- - [ ] Docstrings written
205- - [ ] CHANGELOG updated (if applicable)
50+ The project uses [ pytest] ( https://docs.pytest.org/en/stable/ ) for testing. Tests are organized in the ` tests/ ` directory.
20651
20752## Building Documentation
20853
@@ -224,37 +69,12 @@ hatch run docs:mkdocs build
22469# Output in site/
22570```
22671
227- ## Project Structure
228-
229- ```
230- anscombe-transform/
231- ├── src/
232- │ └── anscombe_transform/
233- │ ├── __init__.py
234- │ ├── codec.py # Main codec implementations
235- │ ├── estimate.py # Parameter estimation
236- │ └── version.py # Version info (auto-generated)
237- ├── tests/
238- │ ├── conftest.py # Pytest fixtures
239- │ ├── test_codec.py # Codec tests
240- │ ├── test_zarr.py # Zarr integration tests
241- │ └── test_notebooks.py # Notebook tests
242- ├── docs/ # Documentation source
243- ├── examples/ # Example notebooks
244- ├── pyproject.toml # Project configuration
245- └── mkdocs.yml # Documentation config
246- ```
24772
24873## Getting Help
24974
25075- ** Questions?** Open a [ GitHub Discussion] ( https://github.com/datajoint/anscombe-transform/discussions )
25176- ** Bug reports?** Open an [ Issue] ( https://github.com/datajoint/anscombe-transform/issues )
252- - ** Need to chat?** Contact the maintainers
253-
254- ## Code of Conduct
255-
256- Please be respectful and constructive in all interactions. We aim to foster an inclusive and welcoming community.
25777
25878## License
25979
260- By contributing, you agree that your contributions will be licensed under the MIT License.
80+ By contributing, you agree that your contributions will be licensed under the [ MIT License] ( https://opensource.org/license/mit ) .
0 commit comments