From 28a37be0f276d8dcb7414a5225715b6a8e79b43c Mon Sep 17 00:00:00 2001 From: Yoshihiro Nagano Date: Thu, 23 Oct 2025 20:07:55 +0900 Subject: [PATCH 1/4] [chore] migration from setup.py-based packaging to pyproject.toml-based packaging --- .gitignore | 5 +++- pyproject.toml | 29 ++++++++++++++++++++++ setup.py | 14 ----------- {fastl2lir => src/fastl2lir}/__init__.py | 0 {fastl2lir => src/fastl2lir}/fastl2lir.py | 0 src/fastl2lir/py.typed | 0 test.py => tests/test_fastl2lir.py | 10 ++++---- {test => tests}/testdata.npz | Bin {test => tests}/testdata_alpha01.npz | Bin {test => tests}/testdata_basic.npz | Bin {test => tests}/testdata_chunk.npz | Bin {test => tests}/testdata_nfeat.npz | Bin 12 files changed, 38 insertions(+), 20 deletions(-) create mode 100644 pyproject.toml delete mode 100644 setup.py rename {fastl2lir => src/fastl2lir}/__init__.py (100%) rename {fastl2lir => src/fastl2lir}/fastl2lir.py (100%) create mode 100644 src/fastl2lir/py.typed rename test.py => tests/test_fastl2lir.py (94%) rename {test => tests}/testdata.npz (100%) rename {test => tests}/testdata_alpha01.npz (100%) rename {test => tests}/testdata_basic.npz (100%) rename {test => tests}/testdata_chunk.npz (100%) rename {test => tests}/testdata_nfeat.npz (100%) diff --git a/.gitignore b/.gitignore index 04c2462..bdce9d0 100644 --- a/.gitignore +++ b/.gitignore @@ -9,4 +9,7 @@ dist .ipynb_checkpoints/ .coverage -htmlcov/ \ No newline at end of file +htmlcov/ + +.python-version +uv.lock diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..5219f9a --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,29 @@ +[project] +name = "fastl2lir" +version = "0.10" +description = "Fast L2-reguralized linear regression" +readme = "README.md" +authors = [ + { name = "Kei Majima", email = "kamitanilab@gmail.com" } +] +maintainers = [ + { name = "Shuntaro C. Aoki", email = "kamitanilab@gmail.com" }, + { name = "Yoshihiro Nagano", email = "kamitanilab@gmail.com" } +] +license = { file = "LICENSE" } +requires-python = ">=3.1" +dependencies = [ + "numpy>=1.16.6", + "threadpoolctl>=2.1.0 ; python_full_version >= '3.5'", + "tqdm>=4.64.1", +] + +[build-system] +requires = ["uv_build>=0.8.22,<0.9.0"] +build-backend = "uv_build" + +[dependency-groups] +dev = [ + "pytest>=4.6.11", + "ruff>=0.0.17", +] diff --git a/setup.py b/setup.py deleted file mode 100644 index ad1c514..0000000 --- a/setup.py +++ /dev/null @@ -1,14 +0,0 @@ -from setuptools import setup - - -setup(name='fastl2lir', - version='0.10', - description='Fast L2-reguralized linear regression', - author='Kei Majima', - author_email='kamitanilab@gmail.com', - maintainer='Shuntaro C. Aoki', - maintainer_email='kamitanilab@gmail.com', - url='https://github.com/KamitaniLab/PyFastL2LiR', - license='MIT', - packages=['fastl2lir'], - install_requires=['numpy', 'tqdm']) diff --git a/fastl2lir/__init__.py b/src/fastl2lir/__init__.py similarity index 100% rename from fastl2lir/__init__.py rename to src/fastl2lir/__init__.py diff --git a/fastl2lir/fastl2lir.py b/src/fastl2lir/fastl2lir.py similarity index 100% rename from fastl2lir/fastl2lir.py rename to src/fastl2lir/fastl2lir.py diff --git a/src/fastl2lir/py.typed b/src/fastl2lir/py.typed new file mode 100644 index 0000000..e69de29 diff --git a/test.py b/tests/test_fastl2lir.py similarity index 94% rename from test.py rename to tests/test_fastl2lir.py index 927954b..a13a9e4 100644 --- a/test.py +++ b/tests/test_fastl2lir.py @@ -16,7 +16,7 @@ class TestFastL2LiR(TestCase): def test_basic(self): '''Basic Test.''' - data = np.load('./test/testdata_basic.npz') + data = np.load('./tests/testdata_basic.npz') model_1d = fastl2lir.FastL2LiR() model_2d = fastl2lir.FastL2LiR() @@ -38,7 +38,7 @@ def test_basic(self): def test_alpha(self): '''Test for alpha.''' - data = np.load('./test/testdata_alpha01.npz') + data = np.load('./tests/testdata_alpha01.npz') model_1d = fastl2lir.FastL2LiR() model_2d = fastl2lir.FastL2LiR() @@ -60,7 +60,7 @@ def test_alpha(self): def test_nfeat(self): '''Test for n_feat.''' - data = np.load('./test/testdata_nfeat.npz') + data = np.load('./tests/testdata_nfeat.npz') model_1d = fastl2lir.FastL2LiR() model_2d = fastl2lir.FastL2LiR() @@ -82,7 +82,7 @@ def test_nfeat(self): def test_nfeat_no_feature_selection(self): '''Test for n_feat when X.shape[1] < n_feat.''' - data = np.load('./test/testdata_basic.npz') + data = np.load('./tests/testdata_basic.npz') model_1d = fastl2lir.FastL2LiR() model_2d = fastl2lir.FastL2LiR() @@ -104,7 +104,7 @@ def test_nfeat_no_feature_selection(self): def test_chunk(self): '''Test for chunk_size.''' - data = np.load('./test/testdata_chunk.npz') + data = np.load('./tests/testdata_chunk.npz') model_2d = fastl2lir.FastL2LiR() diff --git a/test/testdata.npz b/tests/testdata.npz similarity index 100% rename from test/testdata.npz rename to tests/testdata.npz diff --git a/test/testdata_alpha01.npz b/tests/testdata_alpha01.npz similarity index 100% rename from test/testdata_alpha01.npz rename to tests/testdata_alpha01.npz diff --git a/test/testdata_basic.npz b/tests/testdata_basic.npz similarity index 100% rename from test/testdata_basic.npz rename to tests/testdata_basic.npz diff --git a/test/testdata_chunk.npz b/tests/testdata_chunk.npz similarity index 100% rename from test/testdata_chunk.npz rename to tests/testdata_chunk.npz diff --git a/test/testdata_nfeat.npz b/tests/testdata_nfeat.npz similarity index 100% rename from test/testdata_nfeat.npz rename to tests/testdata_nfeat.npz From 155933ca1057e80af4895cb22306cadfa76f1355 Mon Sep 17 00:00:00 2001 From: Yoshihiro Nagano Date: Thu, 23 Oct 2025 20:17:53 +0900 Subject: [PATCH 2/4] [docs] add CONTRIBUTING.md with guidelines for project contributions --- CONTRIBUTING.md | 185 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 185 insertions(+) create mode 100644 CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000..9e99d34 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,185 @@ +# Contributing to PyFastL2LiR + +Thank you for your interest in contributing to PyFastL2LiR! This document provides guidelines and instructions for contributing to the project. + +## Table of Contents + +- [Getting Started](#getting-started) +- [Development Setup](#development-setup) +- [Making Changes](#making-changes) +- [Testing](#testing) +- [Code Style](#code-style) +- [Submitting Changes](#submitting-changes) + +## Getting Started + +### Prerequisites + +- [uv](https://github.com/astral-sh/uv) + +## Development Setup + +1. **Fork and clone the repository** + + ```bash + git clone https://github.com//PyFastL2LiR.git + cd PyFastL2LiR + ``` + +2. **Create a virtual environment and install dependencies** + + ```bash + uv sync + ``` + + This will install the package in editable mode along with all development dependencies. + +## Making Changes + +1. **Create a new branch for your changes** + + ```bash + git checkout -b feature/your-feature-name + ``` + + Use descriptive branch names: + - `feature/` for new features + - `fix/` for bug fixes + - `docs/` for documentation changes + - `refactor/` for code refactoring + +2. **Make your changes** + + - Write clear, concise commit messages + - Keep commits focused and atomic + - Update documentation as needed + +## Testing + +We use pytest for testing. All tests should pass before submitting a pull request. + +### Running Tests + +Run all tests: + +```bash +pytest +``` + +Run tests with coverage: + +```bash +pytest --cov=fastl2lir --cov-report=term-missing +``` + +Run specific tests: + +```bash +pytest tests/test_specific_module.py +``` + +### Writing Tests + +- Place tests in the `tests/` directory +- Name test files with the `test_` prefix +- Name test functions with the `test_` prefix +- Aim for high test coverage, especially for new features +- Include both unit tests and integration tests where appropriate + +## Code Style + +We use [Ruff](https://github.com/astral-sh/ruff) for linting and code formatting. + +### Running Ruff + +Check for linting issues: + +```bash +ruff check . +``` + +Automatically fix issues: + +```bash +ruff check --fix . +``` + +Format code: + +```bash +ruff format . +``` + +### Before Committing + +Make sure your code passes both linting and formatting checks: + +```bash +ruff check . && ruff format --check . +``` + +## Submitting Changes + +1. **Ensure all tests pass** + + ```bash + pytest + ``` + +2. **Ensure code passes linting** + + ```bash + ruff check . + ruff format --check . + ``` + +3. **Commit your changes** + + ```bash + git add . + git commit -m "[tag] Brief description of your changes" + ``` + + Write clear commit messages following these guidelines: + - Use the imperative mood ("Add feature" not "Added feature") + - Provide additional details in the body if needed + +4. **Push to your fork** + + ```bash + git push origin feature/your-feature-name + ``` + +5. **Create a Pull Request** + + - Go to the original repository on GitHub + - Click "New Pull Request" + - Select your fork and branch + - Provide a clear description of your changes + - Reference any related issues + +### Pull Request Guidelines + +- Provide a clear description of the problem and solution +- Include relevant issue numbers (e.g., "Fixes #123") +- Ensure CI checks pass +- Respond to review comments promptly +- Keep pull requests focused on a single feature or fix + +## Code Review Process + +- Maintainers will review your pull request +- Address any requested changes +- Once approved, your changes will be merged + +## Questions? + +If you have questions or need help, feel free to: +- Open an issue on GitHub +- Reach out to the maintainers + +## License + +By contributing to PyFastL2LiR, you agree that your contributions will be licensed under the same license as the project. + +Thank you for contributing! From 7de891c9b3bdc2f731549af5797fa471b8ad45b0 Mon Sep 17 00:00:00 2001 From: Yoshihiro Nagano Date: Thu, 23 Oct 2025 20:43:38 +0900 Subject: [PATCH 3/4] [docs] add project URLs section to pyproject.toml --- pyproject.toml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pyproject.toml b/pyproject.toml index 5219f9a..7a33446 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -17,6 +17,10 @@ dependencies = [ "threadpoolctl>=2.1.0 ; python_full_version >= '3.5'", "tqdm>=4.64.1", ] +[project.urls] +Homepage = "https://github.com/KamitaniLab/PyFastL2LiR" +Repository = "https://github.com/KamitaniLab/PyFastL2LiR" +"Bug Tracker" = "https://github.com/KamitaniLab/PyFastL2LiR/issues" [build-system] requires = ["uv_build>=0.8.22,<0.9.0"] From 20891bfcbe23468931c5ccbe528d7cf427af1819 Mon Sep 17 00:00:00 2001 From: Yoshihiro Nagano Date: Fri, 24 Oct 2025 18:30:44 +0900 Subject: [PATCH 4/4] [fix] correct file path in test_nfeat_no_feature_selection_wide --- tests/test_fastl2lir.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/test_fastl2lir.py b/tests/test_fastl2lir.py index 0a81de0..11bd9a2 100644 --- a/tests/test_fastl2lir.py +++ b/tests/test_fastl2lir.py @@ -104,7 +104,7 @@ def test_nfeat_no_feature_selection(self): def test_nfeat_no_feature_selection_wide(self): '''Test for n_feat when X.shape[1] < n_feat (more features than samples).''' - data = np.load('./test/testdata_wide.npz') + data = np.load('./tests/testdata_wide.npz') model_1d = fastl2lir.FastL2LiR() model_2d = fastl2lir.FastL2LiR()