diff --git a/.github/workflows/package_workflow.yml b/.github/workflows/package_workflow.yml new file mode 100644 index 0000000..1c85f0a --- /dev/null +++ b/.github/workflows/package_workflow.yml @@ -0,0 +1,27 @@ +name: Python Package + +on: + workflow_run: + workflows: ["Tests"] + types: + - completed + +jobs: + build_package: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: ./.github/actions/build + + publish_package: + needs: build_package + runs-on: ubuntu-latest + if: ${{ github.event.workflow_run.conclusion == 'success' }} + steps: + - uses: actions/checkout@v4 + - uses: ./.github/actions/publish + permissions: + id-token: write + environment: + name: pypi + url: https://pypi.org/p/ikpls \ No newline at end of file diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml deleted file mode 100644 index a31f467..0000000 --- a/.github/workflows/pull_request.yml +++ /dev/null @@ -1,32 +0,0 @@ -# This workflow will install Python dependencies, run tests and lint with a variety of Python versions -# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python - -name: Python package - -on: - pull_request: - branches: [ "main" ] - paths: - - 'cvmatrix/**' - - 'tests/**' - - 'pyproject.toml' - -jobs: - test_package: - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: [ubuntu-latest, windows-latest, macos-12] - python-version: ["3.9", "3.10", "3.11", "3.12"] - steps: - - uses: actions/checkout@v4 - - uses: ./.github/actions/test - with: - PYTHON_VERSION: ${{ matrix.python-version }} - - build_package: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: ./.github/actions/build \ No newline at end of file diff --git a/.github/workflows/pull_request_package_workflow.yml b/.github/workflows/pull_request_package_workflow.yml new file mode 100644 index 0000000..fad9e84 --- /dev/null +++ b/.github/workflows/pull_request_package_workflow.yml @@ -0,0 +1,18 @@ +name: Pull Request Python Package + +on: + pull_request: + branches: [ "main" ] + paths: + - 'cvmatrix/**' + - 'tests/**' + - '.github/**' + - 'pyproject.toml' + - 'poetry.lock' + +jobs: + build_package: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: ./.github/actions/build \ No newline at end of file diff --git a/.github/workflows/pull_request_test_workflow.yml b/.github/workflows/pull_request_test_workflow.yml new file mode 100644 index 0000000..08f0662 --- /dev/null +++ b/.github/workflows/pull_request_test_workflow.yml @@ -0,0 +1,25 @@ +name: Pull Request Tests + +on: + pull_request: + branches: [ "main" ] + paths: + - 'cvmatrix/**' + - 'tests/**' + - '.github/**' + - 'pyproject.toml' + - 'poetry.lock' + +jobs: + test_package: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + python-version: ["3.9", "3.10", "3.11", "3.12"] + steps: + - uses: actions/checkout@v4 + - uses: ./.github/actions/test + with: + PYTHON_VERSION: ${{ matrix.python-version }} \ No newline at end of file diff --git a/.github/workflows/test_workflow.yml b/.github/workflows/test_workflow.yml new file mode 100644 index 0000000..36987a7 --- /dev/null +++ b/.github/workflows/test_workflow.yml @@ -0,0 +1,25 @@ +name: Tests + +on: + push: + branches: [ "main" ] + paths: + - 'cvmatrix/**' + - 'tests/**' + - '.github/**' + - 'pyproject.toml' + - 'poetry.lock' + +jobs: + test_package: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [ubuntu-latest, windows-latest, macos-latest] + python-version: ["3.9", "3.10", "3.11", "3.12"] + steps: + - uses: actions/checkout@v4 + - uses: ./.github/actions/test + with: + PYTHON_VERSION: ${{ matrix.python-version }} \ No newline at end of file diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml deleted file mode 100644 index 4e9ce29..0000000 --- a/.github/workflows/workflow.yml +++ /dev/null @@ -1,46 +0,0 @@ -# This workflow will install Python dependencies, run tests and lint with a variety of Python versions -# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python - -name: Python package - -on: - push: - branches: [ "main" ] - paths: - - 'cvmatrix/**' - - 'tests/**' - - 'pyproject.toml' - - '.github/**' - - 'poetry.lock' - -jobs: - test_package: - runs-on: ${{ matrix.os }} - strategy: - fail-fast: false - matrix: - os: [ubuntu-latest, windows-latest, macos-latest] - python-version: ["3.9", "3.10", "3.11", "3.12"] - steps: - - uses: actions/checkout@v4 - - uses: ./.github/actions/test - with: - PYTHON_VERSION: ${{ matrix.python-version }} - - build_package: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: ./.github/actions/build - - publish_package: - needs: [build_package, test_package] - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: ./.github/actions/publish - permissions: - id-token: write - environment: - name: pypi - url: https://pypi.org/p/cvmatrix \ No newline at end of file diff --git a/README.md b/README.md index 4c8a18f..296249e 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,9 @@ [![Documentation Status](https://readthedocs.org/projects/cvmatrix/badge/?version=latest)](https://cvmatrix.readthedocs.io/en/latest/?badge=latest) -[![Build Status](https://github.com/Sm00thix/CVMatrix/actions/workflows/workflow.yml/badge.svg)](https://github.com/Sm00thix/CVMatrix/actions/workflows/workflow.yml) +[![Tests Status](https://github.com/Sm00thix/CVMatrix/actions/workflows/test_workflow.yml/badge.svg)](https://github.com/Sm00thix/CVMatrix/actions/workflows/test_workflow.yml) + +[![Package Status](https://github.com/Sm00thix/CVMatrix/actions/workflows/package_workflow.yml/badge.svg)](https://github.com/Sm00thix/CVMatrix/actions/workflows/package_workflow.yml) The [`cvmatrix`](https://pypi.org/project/cvmatrix/) package implements the fast algorithms by Engstrøm [[1]](#references) for computation of training set $\mathbf{X}^{\mathbf{T}}\mathbf{X}$ and $\mathbf{X}^{\mathbf{T}}\mathbf{Y}$ in a cross-validation setting. In addition to correctly handling arbitrary row-wise pre-processing, the algorithms allow for and efficiently and correctly handle any combination of column-wise centering and scaling of `X` and `Y` based on training set statistics. diff --git a/cvmatrix/__init__.py b/cvmatrix/__init__.py index cd7ca49..a6221b3 100644 --- a/cvmatrix/__init__.py +++ b/cvmatrix/__init__.py @@ -1 +1 @@ -__version__ = '1.0.1' +__version__ = '1.0.2' diff --git a/cvmatrix/cvmatrix.py b/cvmatrix/cvmatrix.py index 19e2d9d..8ad6ade 100644 --- a/cvmatrix/cvmatrix.py +++ b/cvmatrix/cvmatrix.py @@ -85,6 +85,7 @@ def __init__( self.scale_Y = scale_Y self.dtype = dtype self.copy = copy + self.eps = np.finfo(dtype).eps self.X_total = None self.Y_total = None self.N = None @@ -533,7 +534,7 @@ def _compute_training_mat_std( + train_sum_sq_mat ) ) - mat_train_std[mat_train_std == 0] = 1 + mat_train_std[np.abs(mat_train_std) <= self.eps] = 1 return mat_train_std def _init_mat(self, mat: np.ndarray) -> np.ndarray: diff --git a/pyproject.toml b/pyproject.toml index 96a0106..6e81738 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "cvmatrix" -version = "1.0.1" +version = "1.0.2" description = "Fast computation of possibly centered/scaled training set kernel matrices in a cross-validation setting." authors = ["Sm00thix "] maintainers = ["Sm00thix "]