-
Notifications
You must be signed in to change notification settings - Fork 11
feat(ripley_template): Add Ripley‑L template, helpers, fixtures and t… #355
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
base: dev
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR introduces a new Ripley-L template for spatial analysis, providing a clean, platform-agnostic interface for running Ripley-L analysis with configurable parameters. The template is extracted from the NIDAP template and includes comprehensive testing infrastructure.
Key changes:
- New template system with parameter validation and flexible input handling (JSON file, string, or dict)
- Utility functions for pickle file operations with automatic directory creation
- Complete test suite with synthetic data fixtures for CI/CD integration
Reviewed Changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/spac/templates/ripley_l_template.py | Main template implementation with parameter parsing, validation, and Ripley-L analysis execution |
| src/spac/templates/template_utils.py | Utility functions for pickle file loading and saving operations |
| src/spac/templates/init.py | Package initialization with template documentation |
| tests/templates/test_ripley_l_template.py | Unit tests covering dict and JSON file parameter input scenarios |
| tests/templates/_fixtures.py | Mock data generation for testing with synthetic AnnData objects |
| examples/ripley_l_params.json | Example parameter configuration file for template usage |
| .github/workflows/gitflow-py-action.yml | CI configuration update to include src directory in PYTHONPATH |
tests/templates/_fixtures.py
Outdated
| """Tiny AnnData with coords + phenotype labels for fast tests.""" | ||
| rng = np.random.default_rng(0) | ||
| obs = pd.DataFrame( | ||
| {"renamed_phenotypes": np.where(rng.random(n_cells) > 0.5, |
Copilot
AI
Jul 16, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The magic number 0.5 should be extracted as a named constant to improve code clarity and maintainability.
tests/templates/_fixtures.py
Outdated
| ) | ||
| X = rng.normal(size=(n_cells, 3)) | ||
| adata = ad.AnnData(X=X, obs=obs) | ||
| adata.obsm["spatial"] = rng.random((n_cells, 2)) * 300 |
Copilot
AI
Jul 16, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The magic number 300 should be extracted as a named constant to improve code clarity and maintainability.
| adata.obsm["spatial"] = rng.random((n_cells, 2)) * 300 | |
| adata.obsm["spatial"] = rng.random((n_cells, 2)) * SPATIAL_SCALING_FACTOR |
| if isinstance(src, dict): | ||
| return src | ||
| if isinstance(src, (str, Path)): | ||
| text = Path(src).read_text() if str(src).endswith(".json") else src |
Copilot
AI
Jul 16, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The file extension check using string operations is fragile. Consider using Path.suffix for more robust file extension detection.
| text = Path(src).read_text() if str(src).endswith(".json") else src | |
| text = Path(src).read_text() if Path(src).suffix.lower() == ".json" else src |
This reverts commit 3aa787d.
…ests
Ripley‑L template extracted from the NIDAP template, minus Foundry calls, A clean, importable template under spac.templates, Working unit tests:
notes:
overrides environment vars, so the PYTHONPATH set in the caller file never reaches the Python process that runs pytest.)