(x, parens=False)
| 755 | |
| 756 | |
| 757 | def format_float(x, parens=False): |
| 758 | if not np.issubdtype(type(x), np.floating): |
| 759 | return str(x) |
| 760 | |
| 761 | opts = np.get_printoptions() |
| 762 | |
| 763 | if np.isnan(x): |
| 764 | return opts['nanstr'] |
| 765 | elif np.isinf(x): |
| 766 | return opts['infstr'] |
| 767 | |
| 768 | exp_format = False |
| 769 | if x != 0: |
| 770 | a = absolute(x) |
| 771 | if a >= 1.e8 or a < 10**min(0, -(opts['precision']-1)//2): |
| 772 | exp_format = True |
| 773 | |
| 774 | trim, unique = '0', True |
| 775 | if opts['floatmode'] == 'fixed': |
| 776 | trim, unique = 'k', False |
| 777 | |
| 778 | if exp_format: |
| 779 | s = dragon4_scientific(x, precision=opts['precision'], |
| 780 | unique=unique, trim=trim, |
| 781 | sign=opts['sign'] == '+') |
| 782 | if parens: |
| 783 | s = '(' + s + ')' |
| 784 | else: |
| 785 | s = dragon4_positional(x, precision=opts['precision'], |
| 786 | fractional=True, |
| 787 | unique=unique, trim=trim, |
| 788 | sign=opts['sign'] == '+') |
| 789 | return s |
nothing calls this directly
no test coverage detected