Issue693commadisplay

#249 Merged at ab8bb90
Repository
Branch
issue693commadisplay
Repository
Branch
develop
Author
  1. Ed McDonagh
Reviewers
Description
  • Added filter snippet to set significant figures. From https://djangosnippets.org/snippets/1372/ but edited to deal with "0E-12" and to return a Decimal that can be localised. Refs #693
  • Updating sigdig to work with negative numbers as pointed out by @dplatten. Thanks! refs #693
  • Better handling of zero, works for negative numbers. Refs #693
  • Added ref #693 to changes. [skip ci] docs only

Comments (6)

  1. Ed McDonagh author

    If anyone wants to try this, apart from checking out the code you only need to change the language code in local_settings.py - I think it will only affect the interface display.

  2. Luuk

    @edmcdonagh , it looks fine, except that None values are not handled correctly (resulting in runtime errors).

    I think the first lines of sigdig should be:

        if value is None:
            return None
    

    (I only tested the interface, no rdsr-import tested)

  3. Ed McDonagh author

    Thanks Luuk - I have modified it to not return anything if None, which (locally) sorts out the test failure, hopefully the pipeline too.

    Can you test again please?

  4. Luuk

    Hi Ed, It is working fine now.

    Just to nitpick😉, it seems "floatformat" returns an empty string if the value is None. So the columns using floatformat don't show a value and the columns using sigdig show ‘None’ (see last 2 colums in screenshot below):

    To make behaviour consistent, an empty string should be returned if value is None (already tested and it works). Up to you if you want to implement that!

  5. Ed McDonagh author

    I’m happy with this now @LuukO now that sigdigreturns '' if None is passed. Have you been able to check it?