Skip to content

Fix issues #224 and #225: Parallel Documentation and add Unit Tests#283

Merged
ndem0 merged 1 commit intomathLab:masterfrom
kshitij-maths:parallel-docs-test
Apr 9, 2026
Merged

Fix issues #224 and #225: Parallel Documentation and add Unit Tests#283
ndem0 merged 1 commit intomathLab:masterfrom
kshitij-maths:parallel-docs-test

Conversation

@kshitij-maths
Copy link
Copy Markdown
Member

Description

This PR resolves the issues found in the Parallel Reduced Order Model (ROM) module. It modernizes the ezyrb.parallel implementation to align with the current EZyRB (v1.3.3) API and introduces a dedicated unit test suite.

Fixes and Improvements

1. API Synchronization (#224)

  • Attribute Update: Replaced deprecated .parameters and .snapshots calls with parameters_matrix and snapshots_matrix to match the core Database structure.
  • Matrix Orientation: Implemented the "Transpose Sandwich" in the fit() and predict() methods. This ensures that data is passed to the POD and RBF engines in the correct $(n_features, n_samples)$ orientation.
  • Signature Cleanup: Removed legacy arguments (scaler_red, database) from internal method calls that were causing TypeError during parallel task distribution.

2. Documentation & Quality (#225)

  • Mathematical Docstrings: Added LaTeX-formatted documentation to the predict() method $(\mu \in \mathbb{R}^d \rightarrow u(\mu)).$
  • Future-Proofing: Updated Delaunay imports from scipy.spatial.qhull to scipy.spatial to maintain compatibility with SciPy 2.0.
  • New Test Suite: Created tests/test_parallel.py which covers:
    • test_initialization: Verifies proper object construction and attribute mapping.
    • test_fit: Confirms the parallel training workflow and generation of reduction modes.
    • test_predict_scalar: Tests the "Transpose Sandwich" logic for a single parametric input.
    • test_predict_db: Mathematically verifies accuracy by predicting a full database and comparing against original snapshots.
    • test_wrong_dimensions: Ensures the model correctly raises exceptions for mismatched input data.

Verification Results

pytest -v tests/test_parallel.py

  • Result: 5/5 parallel tests passed.

Related Issues

This PR resolves issues #224 and #225

Comment thread ezyrb/parallel/__init__.py Outdated
@ndem0
Copy link
Copy Markdown
Member

ndem0 commented Apr 2, 2026

Can you please use the same tests for the parallel and serial versions? The test_parallel should actually be a folder containing all the other tests tests/*, but using the parallel submodule!

@kshitij-maths kshitij-maths force-pushed the parallel-docs-test branch 3 times, most recently from ac8b964 to 218b5b1 Compare April 3, 2026 06:48
@ndem0
Copy link
Copy Markdown
Member

ndem0 commented Apr 3, 2026

Dear @kshitij-maths, I think no one of the tests for the parallel module is running.
From the action:

Run python3 -m pytest
============================= test session starts ==============================
platform linux -- Python 3.11.15, pytest-9.0.2, pluggy-1.6.0
rootdir: /home/runner/work/EZyRB/EZyRB
configfile: pyproject.toml
plugins: cov-7.1.0
collected 154 items / 18 skipped

tests/test_ae.py ........                                                [  5%]
tests/test_ann.py .................                                      [ 16%]
tests/test_approximation.py ...............                              [ 25%]
tests/test_database.py .......                                           [ 30%]
tests/test_gpr.py ......                                                 [ 34%]
tests/test_k_neighbors_regressor.py ..........                           [ 40%]
tests/test_linear.py .......                                             [ 45%]
tests/test_nnshift.py .                                                  [ 46%]
tests/test_parameter.py ..                                               [ 47%]
tests/test_pod.py ....................                                   [ 60%]
tests/test_podae.py ...                                                  [ 62%]
tests/test_radius_neighbors_regressor.py ..........                      [ 68%]
tests/test_reducedordermodel.py ................                         [ 79%]
tests/test_regular_grid.py .......                                       [ 83%]
tests/test_scaler.py ......                                              [ 87%]
tests/test_shift.py ....                                                 [ 90%]
tests/test_sklearn_wrappers.py ...........                               [ 97%]
tests/test_snapshot.py ....                                              [100%]

=============================== warnings summary ===============================
tests/test_ae.py: 16 warnings
tests/test_podae.py: 4 warnings
  /opt/hostedtoolcache/Python/3.11.15/x64/lib/python3.11/site-packages/sklearn/neural_network/_multilayer_perceptron.py:785: ConvergenceWarning: Stochastic Optimizer: Maximum iterations (1) reached and the optimization hasn't converged yet.
    warnings.warn(

tests/test_ae.py::test_decode_encode
tests/test_ann.py::TestANN::test_fit_01
  /opt/hostedtoolcache/Python/3.11.15/x64/lib/python3.11/site-packages/sklearn/neural_network/_multilayer_perceptron.py:785: ConvergenceWarning: Stochastic Optimizer: Maximum iterations (200) reached and the optimization hasn't converged yet.
    warnings.warn(

tests/test_ae.py::test_optimizer
tests/test_ae.py::test_optimizer_doublefit
tests/test_ae.py::test_optimizer_doublefit
tests/test_ann.py::TestANN::test_predict_01
  /opt/hostedtoolcache/Python/3.11.15/x64/lib/python3.11/site-packages/sklearn/neural_network/_multilayer_perceptron.py:785: ConvergenceWarning: Stochastic Optimizer: Maximum iterations (20) reached and the optimization hasn't converged yet.
    warnings.warn(

tests/test_ae.py::test_optimizer
  /opt/hostedtoolcache/Python/3.11.15/x64/lib/python3.11/site-packages/sklearn/neural_network/_multilayer_perceptron.py:785: ConvergenceWarning: Stochastic Optimizer: Maximum iterations (10) reached and the optimization hasn't converged yet.
    warnings.warn(

tests/test_ann.py::TestANN::test_different_activations
tests/test_ann.py::TestANN::test_different_activations
tests/test_ann.py::TestANN::test_different_activations
tests/test_ann.py::TestANN::test_different_activations
tests/test_ann.py::TestANN::test_loss_trend
tests/test_ann.py::TestANN::test_regularization
tests/test_ann.py::TestANN::test_solver_adam
  /opt/hostedtoolcache/Python/3.11.15/x64/lib/python3.11/site-packages/sklearn/neural_network/_multilayer_perceptron.py:785: ConvergenceWarning: Stochastic Optimizer: Maximum iterations (100) reached and the optimization hasn't converged yet.
    warnings.warn(

tests/test_ann.py::TestANN::test_early_stopping
tests/test_podae.py::test_decode_encode
  /opt/hostedtoolcache/Python/3.11.15/x64/lib/python3.11/site-packages/sklearn/neural_network/_multilayer_perceptron.py:785: ConvergenceWarning: Stochastic Optimizer: Maximum iterations (1000) reached and the optimization hasn't converged yet.
    warnings.warn(

tests/test_ann.py::TestANN::test_fit_mono
tests/test_approximation.py::TestApproximation::test_fit[ANN-kwargs1]
  /opt/hostedtoolcache/Python/3.11.15/x64/lib/python3.11/site-packages/sklearn/neural_network/_multilayer_perceptron.py:1775: DataConversionWarning: A column-vector y was passed when a 1d array was expected. Please change the shape of y to (n_samples, ), for example using ravel().
    y = column_or_1d(y, warn=True)

tests/test_ann.py::TestANN::test_predict_02
tests/test_ann.py::TestANN::test_predict_03
  /opt/hostedtoolcache/Python/3.11.15/x64/lib/python3.11/site-packages/sklearn/neural_network/_multilayer_perceptron.py:785: ConvergenceWarning: Stochastic Optimizer: Maximum iterations (5000) reached and the optimization hasn't converged yet.
    warnings.warn(

tests/test_podae.py::test_reconstruction
  /opt/hostedtoolcache/Python/3.11.15/x64/lib/python3.11/site-packages/sklearn/neural_network/_multilayer_perceptron.py:785: ConvergenceWarning: Stochastic Optimizer: Maximum iterations (500) reached and the optimization hasn't converged yet.
    warnings.warn(

tests/test_radius_neighbors_regressor.py::TestRadius::test_predict
  /opt/hostedtoolcache/Python/3.11.15/x64/lib/python3.11/site-packages/numpy/_core/numeric.py:475: RuntimeWarning: invalid value encountered in cast
    multiarray.copyto(res, fill_value, casting='unsafe')

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
================ 154 passed, 18 skipped, 42 warnings in 12.88s =================

I also tried locally, and none of the tests in that folder are actually running.
Be careful that you also have conflicts (basically in all the PRs you opened)

@kshitij-maths kshitij-maths force-pushed the parallel-docs-test branch 9 times, most recently from 5b403f7 to 40f8507 Compare April 8, 2026 13:15
@kshitij-maths
Copy link
Copy Markdown
Member Author

Dear @kshitij-maths, I think no one of the tests for the parallel module is running. From the action:

Run python3 -m pytest
============================= test session starts ==============================
platform linux -- Python 3.11.15, pytest-9.0.2, pluggy-1.6.0
rootdir: /home/runner/work/EZyRB/EZyRB
configfile: pyproject.toml
plugins: cov-7.1.0
collected 154 items / 18 skipped

tests/test_ae.py ........                                                [  5%]
tests/test_ann.py .................                                      [ 16%]
tests/test_approximation.py ...............                              [ 25%]
tests/test_database.py .......                                           [ 30%]
tests/test_gpr.py ......                                                 [ 34%]
tests/test_k_neighbors_regressor.py ..........                           [ 40%]
tests/test_linear.py .......                                             [ 45%]
tests/test_nnshift.py .                                                  [ 46%]
tests/test_parameter.py ..                                               [ 47%]
tests/test_pod.py ....................                                   [ 60%]
tests/test_podae.py ...                                                  [ 62%]
tests/test_radius_neighbors_regressor.py ..........                      [ 68%]
tests/test_reducedordermodel.py ................                         [ 79%]
tests/test_regular_grid.py .......                                       [ 83%]
tests/test_scaler.py ......                                              [ 87%]
tests/test_shift.py ....                                                 [ 90%]
tests/test_sklearn_wrappers.py ...........                               [ 97%]
tests/test_snapshot.py ....                                              [100%]

=============================== warnings summary ===============================
tests/test_ae.py: 16 warnings
tests/test_podae.py: 4 warnings
  /opt/hostedtoolcache/Python/3.11.15/x64/lib/python3.11/site-packages/sklearn/neural_network/_multilayer_perceptron.py:785: ConvergenceWarning: Stochastic Optimizer: Maximum iterations (1) reached and the optimization hasn't converged yet.
    warnings.warn(

tests/test_ae.py::test_decode_encode
tests/test_ann.py::TestANN::test_fit_01
  /opt/hostedtoolcache/Python/3.11.15/x64/lib/python3.11/site-packages/sklearn/neural_network/_multilayer_perceptron.py:785: ConvergenceWarning: Stochastic Optimizer: Maximum iterations (200) reached and the optimization hasn't converged yet.
    warnings.warn(

tests/test_ae.py::test_optimizer
tests/test_ae.py::test_optimizer_doublefit
tests/test_ae.py::test_optimizer_doublefit
tests/test_ann.py::TestANN::test_predict_01
  /opt/hostedtoolcache/Python/3.11.15/x64/lib/python3.11/site-packages/sklearn/neural_network/_multilayer_perceptron.py:785: ConvergenceWarning: Stochastic Optimizer: Maximum iterations (20) reached and the optimization hasn't converged yet.
    warnings.warn(

tests/test_ae.py::test_optimizer
  /opt/hostedtoolcache/Python/3.11.15/x64/lib/python3.11/site-packages/sklearn/neural_network/_multilayer_perceptron.py:785: ConvergenceWarning: Stochastic Optimizer: Maximum iterations (10) reached and the optimization hasn't converged yet.
    warnings.warn(

tests/test_ann.py::TestANN::test_different_activations
tests/test_ann.py::TestANN::test_different_activations
tests/test_ann.py::TestANN::test_different_activations
tests/test_ann.py::TestANN::test_different_activations
tests/test_ann.py::TestANN::test_loss_trend
tests/test_ann.py::TestANN::test_regularization
tests/test_ann.py::TestANN::test_solver_adam
  /opt/hostedtoolcache/Python/3.11.15/x64/lib/python3.11/site-packages/sklearn/neural_network/_multilayer_perceptron.py:785: ConvergenceWarning: Stochastic Optimizer: Maximum iterations (100) reached and the optimization hasn't converged yet.
    warnings.warn(

tests/test_ann.py::TestANN::test_early_stopping
tests/test_podae.py::test_decode_encode
  /opt/hostedtoolcache/Python/3.11.15/x64/lib/python3.11/site-packages/sklearn/neural_network/_multilayer_perceptron.py:785: ConvergenceWarning: Stochastic Optimizer: Maximum iterations (1000) reached and the optimization hasn't converged yet.
    warnings.warn(

tests/test_ann.py::TestANN::test_fit_mono
tests/test_approximation.py::TestApproximation::test_fit[ANN-kwargs1]
  /opt/hostedtoolcache/Python/3.11.15/x64/lib/python3.11/site-packages/sklearn/neural_network/_multilayer_perceptron.py:1775: DataConversionWarning: A column-vector y was passed when a 1d array was expected. Please change the shape of y to (n_samples, ), for example using ravel().
    y = column_or_1d(y, warn=True)

tests/test_ann.py::TestANN::test_predict_02
tests/test_ann.py::TestANN::test_predict_03
  /opt/hostedtoolcache/Python/3.11.15/x64/lib/python3.11/site-packages/sklearn/neural_network/_multilayer_perceptron.py:785: ConvergenceWarning: Stochastic Optimizer: Maximum iterations (5000) reached and the optimization hasn't converged yet.
    warnings.warn(

tests/test_podae.py::test_reconstruction
  /opt/hostedtoolcache/Python/3.11.15/x64/lib/python3.11/site-packages/sklearn/neural_network/_multilayer_perceptron.py:785: ConvergenceWarning: Stochastic Optimizer: Maximum iterations (500) reached and the optimization hasn't converged yet.
    warnings.warn(

tests/test_radius_neighbors_regressor.py::TestRadius::test_predict
  /opt/hostedtoolcache/Python/3.11.15/x64/lib/python3.11/site-packages/numpy/_core/numeric.py:475: RuntimeWarning: invalid value encountered in cast
    multiarray.copyto(res, fill_value, casting='unsafe')

-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html
================ 154 passed, 18 skipped, 42 warnings in 12.88s =================

I also tried locally, and none of the tests in that folder are actually running. Be careful that you also have conflicts (basically in all the PRs you opened)

Dear @ndem0 please check if everything is okay now.

@ndem0
Copy link
Copy Markdown
Member

ndem0 commented Apr 8, 2026

Yes, great! Btw, the tests are not running on macOs, so please add an issue for the future.

The PR is fine, I would merge but "This branch cannot be rebased due to conflicts".
Please rebase it wrt the master and push again!

@kshitij-maths
Copy link
Copy Markdown
Member Author

@ndem0 Done!

@ndem0 ndem0 merged commit bd6b4aa into mathLab:master Apr 9, 2026
16 checks passed
This was referenced Apr 9, 2026
@kshitij-maths kshitij-maths deleted the parallel-docs-test branch April 9, 2026 12:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants