chispa icon indicating copy to clipboard operation
chispa copied to clipboard

Added font colour selection for dataframe comparison

Open calum-mcg opened this issue 2 years ago • 7 comments

Description

Added an option to provide a color scheme for font when comparing dataframes. Example:

Usage:

colour_scheme = {
   "default":"light_red",
   "matched":"light_blue",
   "underlined":"purple"    
}
assert_df_equality(df1, df2, allow_nan_equality=False, underline_cells=True, color_scheme=colour_scheme)

The default color scheme (if none provided):

default_colour_scheme = {
   "default":"light_red",
   "matched":"light_blue",
   "underlined":"green"    
}

List of available colors in the bcolors class.

In addition, I've added two checks to validate the color scheme dict:

  • Check correct keys are set
  • Validate color provided is available in bcolors class

Fixes #66

Type of change

  • [x] New feature (non-breaking change which adds functionality)
  • [x] This change requires a documentation update

How Has This Been Tested?

  • [x] Passes existing testing suite (poetry run pytest tests)

calum-mcg avatar Aug 14 '23 10:08 calum-mcg

@MrPowers - please let me know if this meets the requirements

calum-mcg avatar Aug 15 '23 14:08 calum-mcg

Once this is merged, I'll work on the refactor ticket

calum-mcg avatar Aug 19 '23 10:08 calum-mcg

Just bumping @MrPowers

calum-mcg avatar Sep 05 '23 17:09 calum-mcg

any movement on this one @MrPowers? This will be a really good addition beyond the original issue as will very useful for accessibility reasons too.

pricemg avatar Sep 15 '23 08:09 pricemg

@MrPowers

calum-mcg avatar Sep 28 '23 22:09 calum-mcg

This is great, thanks for the contribution.

From a user perspective, I think they'll want to set the colors globally and not have to set this manually for every test.

Setting underline_cells=True and then seperately setting "underlined":"purple" in the color_scheme seems off.

We have a few things we're tracking now:

  • matched rows
  • mismatched rows
  • matched cells
  • mismatched cells

The underline_cells option is poorly named. If we're giving the user full configuration options, then they should be able to underline whatever they want (including matched rows or matched cells).

I am going to have to think about this one some more. We should give the user good defaults, a reasonable mechanism to set global overrides, and the flexibility to set test-level settings.

MrPowers avatar Sep 30 '23 01:09 MrPowers

Created an issue to discuss this at a higher level: https://github.com/MrPowers/chispa/issues/75

MrPowers avatar Oct 01 '23 15:10 MrPowers