great-tables icon indicating copy to clipboard operation
great-tables copied to clipboard

Add truncate option to data_color

Open mahdibaghbanzadeh opened this issue 7 months ago • 1 comments

Summary

This PR adds a new boolean parameter truncate to the data_color method. When truncate=True, values outside the specified domain will be assigned the color of the domain's minimum or maximum value instead of being treated as NaN. The default is set to truncate=False, which follows the previous functionality.

Changes include:

  • Added the truncate parameter (default: False)
  • Updated the _rescale_numeric function to support truncation
  • Added unit tests test_data_color_truncate in tests/data_color/test_data_color.py to verify that truncation works correctly

This close #430

mahdibaghbanzadeh avatar Apr 24 '25 15:04 mahdibaghbanzadeh

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 91.42%. Comparing base (9f7c334) to head (27e5915). Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #673      +/-   ##
==========================================
+ Coverage   91.40%   91.42%   +0.02%     
==========================================
  Files          47       47              
  Lines        5629     5634       +5     
==========================================
+ Hits         5145     5151       +6     
+ Misses        484      483       -1     

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

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

codecov[bot] avatar Apr 25 '25 02:04 codecov[bot]

@machow hope this PR is going to be integrated into the next release of GT!

Thank you!

Yasin197 avatar Jun 21 '25 12:06 Yasin197

@rich-iannone I think this is ready if you don't mind reviewing! I didn't look in-depth at the documentation / try it, just tweaked the code

machow avatar Jul 02 '25 19:07 machow