keras-team / keras-core

A multi-backend implementation of the Keras API, with support for TensorFlow, JAX, and PyTorch.
Apache License 2.0
1.27k stars 115 forks source link

Increase test coverage in utils + Fix Bug in `cast_to_common_dtype` #875

Closed Faisal-Alsrheed closed 11 months ago

Faisal-Alsrheed commented 11 months ago

Bug Fixe:

Corrected the dtype_size function by fixing the comparison logic. Previously, if the dtype size of the current tensor was greater than the highest_float, the highest_float value was not being updated correctly. This has been addressed by explicitly comparing the dtype sizes.

Test Coverage:

A new file dtype_utils_test.py has been added, ensuring rigorous testing of the utility functions.

The tests cover:

codecov[bot] commented 11 months ago

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.06% :tada:

Comparison is base (ac8a204) 76.45% compared to head (a7b92b4) 76.51%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #875 +/- ## ========================================== + Coverage 76.45% 76.51% +0.06% ========================================== Files 329 329 Lines 31333 31336 +3 Branches 6100 6100 ========================================== + Hits 23955 23977 +22 + Misses 5799 5782 -17 + Partials 1579 1577 -2 ``` | [Flag](https://app.codecov.io/gh/keras-team/keras-core/pull/875/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=keras-team) | Coverage Δ | | |---|---|---| | [keras_core](https://app.codecov.io/gh/keras-team/keras-core/pull/875/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=keras-team) | `76.42% <100.00%> (+0.06%)` | :arrow_up: | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=keras-team#carryforward-flags-in-the-pull-request-comment) to find out more. | [Files Changed](https://app.codecov.io/gh/keras-team/keras-core/pull/875?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=keras-team) | Coverage Δ | | |---|---|---| | [keras\_core/utils/dtype\_utils.py](https://app.codecov.io/gh/keras-team/keras-core/pull/875?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=keras-team#diff-a2VyYXNfY29yZS91dGlscy9kdHlwZV91dGlscy5weQ==) | `100.00% <100.00%> (+67.85%)` | :arrow_up: |

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