tslearn-team / tslearn

The machine learning toolkit for time series analysis in Python
https://tslearn.readthedocs.io
BSD 2-Clause "Simplified" License
2.92k stars 342 forks source link

Cast the input data to backend option and test functions in metrics for different input data types and different backend options. #479

Closed YannCabanes closed 1 year ago

YannCabanes commented 1 year ago

In the functions of the folder tslearn/metrics supporting the backend optional input parameter be, cast the input data to the backend option when possible (using be.array). Test the functions of the file test_metrics.py for different input data types (list, numpy, pytorch) and different backend options (numpy, pytorch, None). Two nested for loops are used.

Therefore the following generic metric function is tested for different input data types and backend options:

def metric_function(s1, s2, be=None):
    be = instantiate_backend(be, s1, s2)
    s1 = be.array(s1)
    s2 = be.array(s2)
    ...
codecov-commenter commented 1 year ago

Codecov Report

Patch coverage: 99.46% and project coverage change: +0.10% :tada:

Comparison is base (cac29f5) 92.79% compared to head (78517d9) 92.90%.

:exclamation: Current head 78517d9 differs from pull request most recent head 7622481. Consider uploading reports for the commit 7622481 to get more accurate results

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #479 +/- ## ========================================== + Coverage 92.79% 92.90% +0.10% ========================================== Files 67 67 Lines 5583 5680 +97 ========================================== + Hits 5181 5277 +96 - Misses 402 403 +1 ``` | [Files Changed](https://app.codecov.io/gh/tslearn-team/tslearn/pull/479?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=tslearn-team) | Coverage Δ | | |---|---|---| | [tslearn/tests/test\_metrics.py](https://app.codecov.io/gh/tslearn-team/tslearn/pull/479?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=tslearn-team#diff-dHNsZWFybi90ZXN0cy90ZXN0X21ldHJpY3MucHk=) | `99.21% <99.36%> (-0.15%)` | :arrow_down: | | [tslearn/backend/\_\_init\_\_.py](https://app.codecov.io/gh/tslearn-team/tslearn/pull/479?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=tslearn-team#diff-dHNsZWFybi9iYWNrZW5kL19faW5pdF9fLnB5) | `100.00% <100.00%> (ø)` | | | [tslearn/backend/backend.py](https://app.codecov.io/gh/tslearn-team/tslearn/pull/479?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=tslearn-team#diff-dHNsZWFybi9iYWNrZW5kL2JhY2tlbmQucHk=) | `85.71% <100.00%> (+3.89%)` | :arrow_up: | | [tslearn/backend/numpy\_backend.py](https://app.codecov.io/gh/tslearn-team/tslearn/pull/479?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=tslearn-team#diff-dHNsZWFybi9iYWNrZW5kL251bXB5X2JhY2tlbmQucHk=) | `94.11% <100.00%> (+0.17%)` | :arrow_up: | | [tslearn/backend/pytorch\_backend.py](https://app.codecov.io/gh/tslearn-team/tslearn/pull/479?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=tslearn-team#diff-dHNsZWFybi9iYWNrZW5kL3B5dG9yY2hfYmFja2VuZC5weQ==) | `75.98% <100.00%> (+0.35%)` | :arrow_up: | | [tslearn/metrics/dtw\_variants.py](https://app.codecov.io/gh/tslearn-team/tslearn/pull/479?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=tslearn-team#diff-dHNsZWFybi9tZXRyaWNzL2R0d192YXJpYW50cy5weQ==) | `95.52% <100.00%> (+0.03%)` | :arrow_up: | | [tslearn/metrics/softdtw\_variants.py](https://app.codecov.io/gh/tslearn-team/tslearn/pull/479?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=tslearn-team#diff-dHNsZWFybi9tZXRyaWNzL3NvZnRkdHdfdmFyaWFudHMucHk=) | `93.90% <100.00%> (+0.19%)` | :arrow_up: |

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.