Changeset e8418bb in sasview for src/sas/sasgui/perspectives


Ignore:
Timestamp:
Aug 4, 2016 4:17:12 AM (8 years ago)
Author:
lewis
Branches:
master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
40b14f3
Parents:
2ed088a
Message:

Fix bug when displaying output params if one of them is 0

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sasgui/perspectives/corfunc/corfunc_panel.py

    r2ed088a re8418bb  
    636636            figures, as a string 
    637637        """ 
    638         # Index of first significant digit 
    639         significant_digit = -int(np.floor(np.log10(np.abs(x)))) 
    640         # Number of digits required for correct number of sig figs 
    641         digits = significant_digit + (sigfigs - 1) 
    642         rounded = np.round(x, decimals=digits) 
    643         rounded_str = "{1:.{0}f}".format(sigfigs -1  + significant_digit, 
    644             rounded) 
     638        rounded_str = "" 
     639        try: 
     640            # Index of first significant digit 
     641            significant_digit = -int(np.floor(np.log10(np.abs(x)))) 
     642            # Number of digits required for correct number of sig figs 
     643            digits = significant_digit + (sigfigs - 1) 
     644            rounded = np.round(x, decimals=digits) 
     645            rounded_str = "{1:.{0}f}".format(sigfigs -1  + significant_digit, 
     646                rounded) 
     647        except: 
     648            # Method for finding significant_digit fails if x is 0 (since log10(0)=inf) 
     649            if x == 0.0: 
     650                rounded_str = "0.0" 
     651            else: 
     652                rounded_str = "-" 
     653 
    645654        return rounded_str 
Note: See TracChangeset for help on using the changeset viewer.