Python numpy.format_float_positional() Examples

The following are 15 code examples of numpy.format_float_positional(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module numpy , or try the search function .
Example #1
Source File: bayesian.py    From pingouin with GNU General Public License v3.0 5 votes vote down vote up
def _format_bf(bf, precision=3, trim='0'):
    """Format BF10 to floating point or scientific notation.
    """
    if bf >= 1e4 or bf <= 1e-4:
        out = np.format_float_scientific(bf, precision=precision, trim=trim)
    else:
        out = np.format_float_positional(bf, precision=precision, trim=trim)
    return out 
Example #2
Source File: format.py    From dimod with Apache License 2.0 5 votes vote down vote up
def append_vector(self, name, vector, _left=False):
        """Add a data vectors column."""
        if np.issubdtype(vector.dtype, np.integer):
            # determine the length we need
            largest = str(max(vector.max(), vector.min(), key=abs))
            length = max(len(largest), min(7, len(name)))  # how many spaces we need to represent

            if len(name) > length:
                header = name[:length-1] + '.'
            else:
                header = name.rjust(length)

            def f(datum):
                return str(getattr(datum, name)).rjust(length)
        elif np.issubdtype(vector.dtype, np.floating):
            largest = np.format_float_positional(max(vector.max(), vector.min(), key=abs),
                                                 precision=6, trim='0')
            length = max(len(largest), min(7, len(name)))  # how many spaces we need to represent
            if len(name) > length:
                header = name[:length-1] + '.'
            else:
                header = name.rjust(length)

            def f(datum):
                return np.format_float_positional(getattr(datum, name),
                                                  precision=6, trim='0',
                                                  ).rjust(length)
        else:
            length = 7
            if len(name) > length:
                header = name[:length-1] + '.'
            else:
                header = name.rjust(length)

            def f(datum):
                r = repr(getattr(datum, name))
                if len(r) > length:
                    r = r[:length-3] + '...'
                return r.rjust(length)

        self.append(header, f, _left=_left) 
Example #3
Source File: utils.py    From MultiPlanarUNet with MIT License 5 votes vote down vote up
def arr_to_fixed_precision_string(arr, precision):
    f = np.format_float_positional
    s = map(lambda x: f(x, precision, pad_right=precision), arr)
    return "[{}]".format(" ".join(s)) 
Example #4
Source File: plotter.py    From allesfitter with MIT License 5 votes vote down vote up
def plot_info(ax, text=0, params=None, settings=None, **kwargs):
    params = translate(params=params, settings=settings, quiet=True, **kwargs)
    
    ax.set_axis_off()
    
    if text==0:
        ax.text(0,0.95,'R_comp = '+np.format_float_positional(params['R_companion_earth'],2)+r' $R_\odot$ = ' + np.format_float_positional(params['R_companion_jup'],2)+r' $R_J$ = ' + np.format_float_positional(params['R_companion_sun'],2)+r' $R_\odot$', transform=ax.transAxes) #bodies
        ax.text(0,0.85,'M_comp = '+np.format_float_positional(params['M_companion_earth'],2)+r' $M_\odot$ = ' + np.format_float_positional(params['M_companion_jup'],2)+r' $M_J$ = ' + np.format_float_positional(params['M_companion_sun'],2)+r' $M_\odot$', transform=ax.transAxes)
        ax.text(0,0.75,'R_host = '+str(params['R_host'])+r' $R_\odot$', transform=ax.transAxes)
        ax.text(0,0.65,'M_host = '+str(params['M_host'])+r' $M_\odot$', transform=ax.transAxes)
        ax.text(0,0.55,'sbratio = '+str(params['sbratio']), transform=ax.transAxes)
        ax.text(0,0.45,'epoch' + ' = '+str(params['epoch'])+r' $\mathrm{BJD_{TDB}}$', transform=ax.transAxes) #orbits
        ax.text(0,0.35,'period = '+str(params['period'])+' days', transform=ax.transAxes)
        ax.text(0,0.25,'incl = '+str(params['incl'])+' deg', transform=ax.transAxes)
        ax.text(0,0.15,'ecc = '+str(params['ecc']), transform=ax.transAxes)
        ax.text(0,0.05,'omega = '+str(params['omega'])+' deg', transform=ax.transAxes)
    
    if text==1:
        ax.text(0,0.95,'dil = '+str(params['dil']), transform=ax.transAxes)
        ax.text(0,0.85,'R_comp/R_host = '+np.format_float_positional(params['rr'],5,False), transform=ax.transAxes)
        ax.text(0,0.75,'(R_comp+R_host)/a = '+np.format_float_positional(params['rsuma'],5,False), transform=ax.transAxes)
        ax.text(0,0.65,'R_comp/a = '+np.format_float_positional(params['R_companion_over_a'],5,False), transform=ax.transAxes)
        ax.text(0,0.55,'R_host/a = '+np.format_float_positional(params['R_host_over_a'],5,False), transform=ax.transAxes)
        ax.text(0,0.45,'cosi = '+np.format_float_positional(params['cosi'],5,False), transform=ax.transAxes)
        ax.text(0,0.35,r'$\sqrt{e} \cos{\omega}$ = '+np.format_float_positional(params['f_c'],5,False), transform=ax.transAxes)
        ax.text(0,0.25,r'$\sqrt{e} \sin{\omega}$ = '+np.format_float_positional(params['f_s'],5,False), transform=ax.transAxes)
        ax.text(0,0.15,'LD = '+str(params['ldc']), transform=ax.transAxes)
        try: ax.text(0,0.05,'LD transf = ['+", ".join([np.format_float_positional(item,5,False) for item in params['ldc_transformed']]) + ']', transform=ax.transAxes)
        except: pass
    return ax 
Example #5
Source File: trade_fill.py    From hummingbot with Apache License 2.0 5 votes vote down vote up
def to_bounty_api_json(trade_fill: "TradeFill") -> Dict[str, Any]:
        return {
            "market": trade_fill.market,
            "trade_id": trade_fill.exchange_trade_id,
            "price": numpy.format_float_positional(trade_fill.price),
            "quantity": numpy.format_float_positional(trade_fill.amount),
            "symbol": trade_fill.symbol,
            "trade_timestamp": trade_fill.timestamp,
            "trade_type": trade_fill.trade_type,
            "base_asset": trade_fill.base_asset,
            "quote_asset": trade_fill.quote_asset,
            "raw_json": {
                "trade_fee": trade_fill.trade_fee,
            }
        } 
Example #6
Source File: order.py    From hummingbot with Apache License 2.0 5 votes vote down vote up
def to_bounty_api_json(order: "Order") -> Dict[str, Any]:
        return {
            "order_id": order.id,
            "price": numpy.format_float_positional(order.price),
            "quantity": numpy.format_float_positional(order.amount),
            "symbol": order.symbol,
            "market": order.market,
            "order_timestamp": order.creation_timestamp,
            "order_type": order.order_type,
            "base_asset": order.base_asset,
            "quote_asset": order.quote_asset,
            "raw_json": {
            }
        } 
Example #7
Source File: test_scalarprint.py    From recruit with Apache License 2.0 4 votes vote down vote up
def test_dragon4_interface(self):
        tps = [np.float16, np.float32, np.float64]
        if hasattr(np, 'float128'):
            tps.append(np.float128)

        fpos = np.format_float_positional
        fsci = np.format_float_scientific

        for tp in tps:
            # test padding
            assert_equal(fpos(tp('1.0'), pad_left=4, pad_right=4), "   1.    ")
            assert_equal(fpos(tp('-1.0'), pad_left=4, pad_right=4), "  -1.    ")
            assert_equal(fpos(tp('-10.2'),
                         pad_left=4, pad_right=4), " -10.2   ")

            # test exp_digits
            assert_equal(fsci(tp('1.23e1'), exp_digits=5), "1.23e+00001")

            # test fixed (non-unique) mode
            assert_equal(fpos(tp('1.0'), unique=False, precision=4), "1.0000")
            assert_equal(fsci(tp('1.0'), unique=False, precision=4),
                         "1.0000e+00")

            # test trimming
            # trim of 'k' or '.' only affects non-unique mode, since unique
            # mode will not output trailing 0s.
            assert_equal(fpos(tp('1.'), unique=False, precision=4, trim='k'),
                         "1.0000")

            assert_equal(fpos(tp('1.'), unique=False, precision=4, trim='.'),
                         "1.")
            assert_equal(fpos(tp('1.2'), unique=False, precision=4, trim='.'),
                         "1.2" if tp != np.float16 else "1.2002")

            assert_equal(fpos(tp('1.'), unique=False, precision=4, trim='0'),
                         "1.0")
            assert_equal(fpos(tp('1.2'), unique=False, precision=4, trim='0'),
                         "1.2" if tp != np.float16 else "1.2002")
            assert_equal(fpos(tp('1.'), trim='0'), "1.0")

            assert_equal(fpos(tp('1.'), unique=False, precision=4, trim='-'),
                         "1")
            assert_equal(fpos(tp('1.2'), unique=False, precision=4, trim='-'),
                         "1.2" if tp != np.float16 else "1.2002")
            assert_equal(fpos(tp('1.'), trim='-'), "1") 
Example #8
Source File: test_scalarprint.py    From vnpy_crypto with MIT License 4 votes vote down vote up
def test_dragon4_interface(self):
        tps = [np.float16, np.float32, np.float64]
        if hasattr(np, 'float128'):
            tps.append(np.float128)

        fpos = np.format_float_positional
        fsci = np.format_float_scientific

        for tp in tps:
            # test padding
            assert_equal(fpos(tp('1.0'), pad_left=4, pad_right=4), "   1.    ")
            assert_equal(fpos(tp('-1.0'), pad_left=4, pad_right=4), "  -1.    ")
            assert_equal(fpos(tp('-10.2'),
                         pad_left=4, pad_right=4), " -10.2   ")

            # test exp_digits
            assert_equal(fsci(tp('1.23e1'), exp_digits=5), "1.23e+00001")

            # test fixed (non-unique) mode
            assert_equal(fpos(tp('1.0'), unique=False, precision=4), "1.0000")
            assert_equal(fsci(tp('1.0'), unique=False, precision=4),
                         "1.0000e+00")

            # test trimming
            # trim of 'k' or '.' only affects non-unique mode, since unique
            # mode will not output trailing 0s.
            assert_equal(fpos(tp('1.'), unique=False, precision=4, trim='k'),
                         "1.0000")

            assert_equal(fpos(tp('1.'), unique=False, precision=4, trim='.'),
                         "1.")
            assert_equal(fpos(tp('1.2'), unique=False, precision=4, trim='.'),
                         "1.2" if tp != np.float16 else "1.2002")

            assert_equal(fpos(tp('1.'), unique=False, precision=4, trim='0'),
                         "1.0")
            assert_equal(fpos(tp('1.2'), unique=False, precision=4, trim='0'),
                         "1.2" if tp != np.float16 else "1.2002")
            assert_equal(fpos(tp('1.'), trim='0'), "1.0")

            assert_equal(fpos(tp('1.'), unique=False, precision=4, trim='-'),
                         "1")
            assert_equal(fpos(tp('1.2'), unique=False, precision=4, trim='-'),
                         "1.2" if tp != np.float16 else "1.2002")
            assert_equal(fpos(tp('1.'), trim='-'), "1") 
Example #9
Source File: test_scalarprint.py    From Mastering-Elasticsearch-7.0 with MIT License 4 votes vote down vote up
def test_dragon4_interface(self):
        tps = [np.float16, np.float32, np.float64]
        if hasattr(np, 'float128'):
            tps.append(np.float128)

        fpos = np.format_float_positional
        fsci = np.format_float_scientific

        for tp in tps:
            # test padding
            assert_equal(fpos(tp('1.0'), pad_left=4, pad_right=4), "   1.    ")
            assert_equal(fpos(tp('-1.0'), pad_left=4, pad_right=4), "  -1.    ")
            assert_equal(fpos(tp('-10.2'),
                         pad_left=4, pad_right=4), " -10.2   ")

            # test exp_digits
            assert_equal(fsci(tp('1.23e1'), exp_digits=5), "1.23e+00001")

            # test fixed (non-unique) mode
            assert_equal(fpos(tp('1.0'), unique=False, precision=4), "1.0000")
            assert_equal(fsci(tp('1.0'), unique=False, precision=4),
                         "1.0000e+00")

            # test trimming
            # trim of 'k' or '.' only affects non-unique mode, since unique
            # mode will not output trailing 0s.
            assert_equal(fpos(tp('1.'), unique=False, precision=4, trim='k'),
                         "1.0000")

            assert_equal(fpos(tp('1.'), unique=False, precision=4, trim='.'),
                         "1.")
            assert_equal(fpos(tp('1.2'), unique=False, precision=4, trim='.'),
                         "1.2" if tp != np.float16 else "1.2002")

            assert_equal(fpos(tp('1.'), unique=False, precision=4, trim='0'),
                         "1.0")
            assert_equal(fpos(tp('1.2'), unique=False, precision=4, trim='0'),
                         "1.2" if tp != np.float16 else "1.2002")
            assert_equal(fpos(tp('1.'), trim='0'), "1.0")

            assert_equal(fpos(tp('1.'), unique=False, precision=4, trim='-'),
                         "1")
            assert_equal(fpos(tp('1.2'), unique=False, precision=4, trim='-'),
                         "1.2" if tp != np.float16 else "1.2002")
            assert_equal(fpos(tp('1.'), trim='-'), "1") 
Example #10
Source File: test_scalarprint.py    From GraphicDesignPatternByPython with MIT License 4 votes vote down vote up
def test_dragon4_interface(self):
        tps = [np.float16, np.float32, np.float64]
        if hasattr(np, 'float128'):
            tps.append(np.float128)

        fpos = np.format_float_positional
        fsci = np.format_float_scientific

        for tp in tps:
            # test padding
            assert_equal(fpos(tp('1.0'), pad_left=4, pad_right=4), "   1.    ")
            assert_equal(fpos(tp('-1.0'), pad_left=4, pad_right=4), "  -1.    ")
            assert_equal(fpos(tp('-10.2'),
                         pad_left=4, pad_right=4), " -10.2   ")

            # test exp_digits
            assert_equal(fsci(tp('1.23e1'), exp_digits=5), "1.23e+00001")

            # test fixed (non-unique) mode
            assert_equal(fpos(tp('1.0'), unique=False, precision=4), "1.0000")
            assert_equal(fsci(tp('1.0'), unique=False, precision=4),
                         "1.0000e+00")

            # test trimming
            # trim of 'k' or '.' only affects non-unique mode, since unique
            # mode will not output trailing 0s.
            assert_equal(fpos(tp('1.'), unique=False, precision=4, trim='k'),
                         "1.0000")

            assert_equal(fpos(tp('1.'), unique=False, precision=4, trim='.'),
                         "1.")
            assert_equal(fpos(tp('1.2'), unique=False, precision=4, trim='.'),
                         "1.2" if tp != np.float16 else "1.2002")

            assert_equal(fpos(tp('1.'), unique=False, precision=4, trim='0'),
                         "1.0")
            assert_equal(fpos(tp('1.2'), unique=False, precision=4, trim='0'),
                         "1.2" if tp != np.float16 else "1.2002")
            assert_equal(fpos(tp('1.'), trim='0'), "1.0")

            assert_equal(fpos(tp('1.'), unique=False, precision=4, trim='-'),
                         "1")
            assert_equal(fpos(tp('1.2'), unique=False, precision=4, trim='-'),
                         "1.2" if tp != np.float16 else "1.2002")
            assert_equal(fpos(tp('1.'), trim='-'), "1") 
Example #11
Source File: test_scalarprint.py    From predictive-maintenance-using-machine-learning with Apache License 2.0 4 votes vote down vote up
def test_dragon4_interface(self):
        tps = [np.float16, np.float32, np.float64]
        if hasattr(np, 'float128'):
            tps.append(np.float128)

        fpos = np.format_float_positional
        fsci = np.format_float_scientific

        for tp in tps:
            # test padding
            assert_equal(fpos(tp('1.0'), pad_left=4, pad_right=4), "   1.    ")
            assert_equal(fpos(tp('-1.0'), pad_left=4, pad_right=4), "  -1.    ")
            assert_equal(fpos(tp('-10.2'),
                         pad_left=4, pad_right=4), " -10.2   ")

            # test exp_digits
            assert_equal(fsci(tp('1.23e1'), exp_digits=5), "1.23e+00001")

            # test fixed (non-unique) mode
            assert_equal(fpos(tp('1.0'), unique=False, precision=4), "1.0000")
            assert_equal(fsci(tp('1.0'), unique=False, precision=4),
                         "1.0000e+00")

            # test trimming
            # trim of 'k' or '.' only affects non-unique mode, since unique
            # mode will not output trailing 0s.
            assert_equal(fpos(tp('1.'), unique=False, precision=4, trim='k'),
                         "1.0000")

            assert_equal(fpos(tp('1.'), unique=False, precision=4, trim='.'),
                         "1.")
            assert_equal(fpos(tp('1.2'), unique=False, precision=4, trim='.'),
                         "1.2" if tp != np.float16 else "1.2002")

            assert_equal(fpos(tp('1.'), unique=False, precision=4, trim='0'),
                         "1.0")
            assert_equal(fpos(tp('1.2'), unique=False, precision=4, trim='0'),
                         "1.2" if tp != np.float16 else "1.2002")
            assert_equal(fpos(tp('1.'), trim='0'), "1.0")

            assert_equal(fpos(tp('1.'), unique=False, precision=4, trim='-'),
                         "1")
            assert_equal(fpos(tp('1.2'), unique=False, precision=4, trim='-'),
                         "1.2" if tp != np.float16 else "1.2002")
            assert_equal(fpos(tp('1.'), trim='-'), "1") 
Example #12
Source File: test_scalarprint.py    From pySINDy with MIT License 4 votes vote down vote up
def test_dragon4_interface(self):
        tps = [np.float16, np.float32, np.float64]
        if hasattr(np, 'float128'):
            tps.append(np.float128)

        fpos = np.format_float_positional
        fsci = np.format_float_scientific

        for tp in tps:
            # test padding
            assert_equal(fpos(tp('1.0'), pad_left=4, pad_right=4), "   1.    ")
            assert_equal(fpos(tp('-1.0'), pad_left=4, pad_right=4), "  -1.    ")
            assert_equal(fpos(tp('-10.2'),
                         pad_left=4, pad_right=4), " -10.2   ")

            # test exp_digits
            assert_equal(fsci(tp('1.23e1'), exp_digits=5), "1.23e+00001")

            # test fixed (non-unique) mode
            assert_equal(fpos(tp('1.0'), unique=False, precision=4), "1.0000")
            assert_equal(fsci(tp('1.0'), unique=False, precision=4),
                         "1.0000e+00")

            # test trimming
            # trim of 'k' or '.' only affects non-unique mode, since unique
            # mode will not output trailing 0s.
            assert_equal(fpos(tp('1.'), unique=False, precision=4, trim='k'),
                         "1.0000")

            assert_equal(fpos(tp('1.'), unique=False, precision=4, trim='.'),
                         "1.")
            assert_equal(fpos(tp('1.2'), unique=False, precision=4, trim='.'),
                         "1.2" if tp != np.float16 else "1.2002")

            assert_equal(fpos(tp('1.'), unique=False, precision=4, trim='0'),
                         "1.0")
            assert_equal(fpos(tp('1.2'), unique=False, precision=4, trim='0'),
                         "1.2" if tp != np.float16 else "1.2002")
            assert_equal(fpos(tp('1.'), trim='0'), "1.0")

            assert_equal(fpos(tp('1.'), unique=False, precision=4, trim='-'),
                         "1")
            assert_equal(fpos(tp('1.2'), unique=False, precision=4, trim='-'),
                         "1.2" if tp != np.float16 else "1.2002")
            assert_equal(fpos(tp('1.'), trim='-'), "1") 
Example #13
Source File: test_scalarprint.py    From coffeegrindsize with MIT License 4 votes vote down vote up
def test_dragon4_interface(self):
        tps = [np.float16, np.float32, np.float64]
        if hasattr(np, 'float128'):
            tps.append(np.float128)

        fpos = np.format_float_positional
        fsci = np.format_float_scientific

        for tp in tps:
            # test padding
            assert_equal(fpos(tp('1.0'), pad_left=4, pad_right=4), "   1.    ")
            assert_equal(fpos(tp('-1.0'), pad_left=4, pad_right=4), "  -1.    ")
            assert_equal(fpos(tp('-10.2'),
                         pad_left=4, pad_right=4), " -10.2   ")

            # test exp_digits
            assert_equal(fsci(tp('1.23e1'), exp_digits=5), "1.23e+00001")

            # test fixed (non-unique) mode
            assert_equal(fpos(tp('1.0'), unique=False, precision=4), "1.0000")
            assert_equal(fsci(tp('1.0'), unique=False, precision=4),
                         "1.0000e+00")

            # test trimming
            # trim of 'k' or '.' only affects non-unique mode, since unique
            # mode will not output trailing 0s.
            assert_equal(fpos(tp('1.'), unique=False, precision=4, trim='k'),
                         "1.0000")

            assert_equal(fpos(tp('1.'), unique=False, precision=4, trim='.'),
                         "1.")
            assert_equal(fpos(tp('1.2'), unique=False, precision=4, trim='.'),
                         "1.2" if tp != np.float16 else "1.2002")

            assert_equal(fpos(tp('1.'), unique=False, precision=4, trim='0'),
                         "1.0")
            assert_equal(fpos(tp('1.2'), unique=False, precision=4, trim='0'),
                         "1.2" if tp != np.float16 else "1.2002")
            assert_equal(fpos(tp('1.'), trim='0'), "1.0")

            assert_equal(fpos(tp('1.'), unique=False, precision=4, trim='-'),
                         "1")
            assert_equal(fpos(tp('1.2'), unique=False, precision=4, trim='-'),
                         "1.2" if tp != np.float16 else "1.2002")
            assert_equal(fpos(tp('1.'), trim='-'), "1") 
Example #14
Source File: test_scalarprint.py    From Serverless-Deep-Learning-with-TensorFlow-and-AWS-Lambda with MIT License 4 votes vote down vote up
def test_dragon4_interface(self):
        tps = [np.float16, np.float32, np.float64]
        if hasattr(np, 'float128'):
            tps.append(np.float128)

        fpos = np.format_float_positional
        fsci = np.format_float_scientific

        for tp in tps:
            # test padding
            assert_equal(fpos(tp('1.0'), pad_left=4, pad_right=4), "   1.    ")
            assert_equal(fpos(tp('-1.0'), pad_left=4, pad_right=4), "  -1.    ")
            assert_equal(fpos(tp('-10.2'),
                         pad_left=4, pad_right=4), " -10.2   ")

            # test exp_digits
            assert_equal(fsci(tp('1.23e1'), exp_digits=5), "1.23e+00001")

            # test fixed (non-unique) mode
            assert_equal(fpos(tp('1.0'), unique=False, precision=4), "1.0000")
            assert_equal(fsci(tp('1.0'), unique=False, precision=4),
                         "1.0000e+00")

            # test trimming
            # trim of 'k' or '.' only affects non-unique mode, since unique
            # mode will not output trailing 0s.
            assert_equal(fpos(tp('1.'), unique=False, precision=4, trim='k'),
                         "1.0000")

            assert_equal(fpos(tp('1.'), unique=False, precision=4, trim='.'),
                         "1.")
            assert_equal(fpos(tp('1.2'), unique=False, precision=4, trim='.'),
                         "1.2" if tp != np.float16 else "1.2002")

            assert_equal(fpos(tp('1.'), unique=False, precision=4, trim='0'),
                         "1.0")
            assert_equal(fpos(tp('1.2'), unique=False, precision=4, trim='0'),
                         "1.2" if tp != np.float16 else "1.2002")
            assert_equal(fpos(tp('1.'), trim='0'), "1.0")

            assert_equal(fpos(tp('1.'), unique=False, precision=4, trim='-'),
                         "1")
            assert_equal(fpos(tp('1.2'), unique=False, precision=4, trim='-'),
                         "1.2" if tp != np.float16 else "1.2002")
            assert_equal(fpos(tp('1.'), trim='-'), "1") 
Example #15
Source File: test_scalarprint.py    From twitter-stock-recommendation with MIT License 4 votes vote down vote up
def test_dragon4_interface(self):
        tps = [np.float16, np.float32, np.float64]
        if hasattr(np, 'float128'):
            tps.append(np.float128)

        fpos = np.format_float_positional
        fsci = np.format_float_scientific

        for tp in tps:
            # test padding
            assert_equal(fpos(tp('1.0'), pad_left=4, pad_right=4), "   1.    ")
            assert_equal(fpos(tp('-1.0'), pad_left=4, pad_right=4), "  -1.    ")
            assert_equal(fpos(tp('-10.2'),
                         pad_left=4, pad_right=4), " -10.2   ")

            # test exp_digits
            assert_equal(fsci(tp('1.23e1'), exp_digits=5), "1.23e+00001")

            # test fixed (non-unique) mode
            assert_equal(fpos(tp('1.0'), unique=False, precision=4), "1.0000")
            assert_equal(fsci(tp('1.0'), unique=False, precision=4),
                         "1.0000e+00")

            # test trimming
            # trim of 'k' or '.' only affects non-unique mode, since unique
            # mode will not output trailing 0s.
            assert_equal(fpos(tp('1.'), unique=False, precision=4, trim='k'),
                         "1.0000")

            assert_equal(fpos(tp('1.'), unique=False, precision=4, trim='.'),
                         "1.")
            assert_equal(fpos(tp('1.2'), unique=False, precision=4, trim='.'),
                         "1.2" if tp != np.float16 else "1.2002")

            assert_equal(fpos(tp('1.'), unique=False, precision=4, trim='0'),
                         "1.0")
            assert_equal(fpos(tp('1.2'), unique=False, precision=4, trim='0'),
                         "1.2" if tp != np.float16 else "1.2002")
            assert_equal(fpos(tp('1.'), trim='0'), "1.0")

            assert_equal(fpos(tp('1.'), unique=False, precision=4, trim='-'),
                         "1")
            assert_equal(fpos(tp('1.2'), unique=False, precision=4, trim='-'),
                         "1.2" if tp != np.float16 else "1.2002")
            assert_equal(fpos(tp('1.'), trim='-'), "1")