BayesicFitting

Model Fitting and Evidence Calculation

View project on GitHub



Module Formatter [source]

This module contains methods to format numbers, especially in arrays.

Examples

arr = numpy.linspace( 0, 10, 48 ).reshape( (4,12) )
print( "array ", formatter( arr, indent=7, tail=2, max=5 ) )
array  [[    0.000    0.213    0.426    0.638    0.851 ...    2.128    2.340]
        [    2.553    2.766    2.979    3.191    3.404 ...    4.681    4.894]
        [    5.106    5.319    5.532    5.745    5.957 ...    7.234    7.447]
        [    7.660    7.872    8.085    8.298    8.511 ...    9.787   10.000]]  

formatter_init( format={}, indent=None, linelength=None, max=-1 ) [source]

Initialize the formatter with new default values.

Parameters

  • format : dict {namestring : formatstring }
         name : "float64" or "int64"
         fmt : " %fmt"
  • indent : None or int
         number of spaces to indent after the first line
         Default is 0
  • linelength : None or int
         length of the lines produced
         Default is 120
  • max : None or int
         maximum number of items displayed followed by ... if there are more
         None displays all
         Default is 5

fma( erray, **kwargs ) [source]
Syntactic sugar for
     formatter( ..., max=None, ... )

It formats ALL numbers in the array

gmt( erray, **kwargs ) [source]
Syntactic sugar for
     formatter( ..., format=" %#10.3g", ... )

It formats the array in "%#10.3g" format.

formatter( erray, format=None, indent=None, linelength=None, max=-1, tail=0 ) [source]
Format a number or an array nicely into a string

Parameters override defaults given earlier with init().

Parameters

  • erray : array or number
         number or list of numbers or n-dim array of numbers
  • format : None or string
         format applying to one item of array
         Default is "8.3f" for float and "8d" for int
  • indent : None or int
         number of spaces to indent after the first line
         Default is 0
  • linelength : None or int
         length of the lines produced
         Default is 120
  • max : None or int
         maximum number of items displayed followed by ... if there are more
         None displays all
         Default is 5
  • tail : int
         print the last items in the array, preceeded by ...
         Only if the number of items is larger than max.
         Default is 0

Returns

  • string : containing the formatted array

spaces( ksp ) [source]
Return ksp spaces.