Skip to content

Commit

Permalink
formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
VanyaBelyaev committed Nov 5, 2024
1 parent 1f7ae62 commit b76805c
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 51 deletions.
63 changes: 39 additions & 24 deletions ostap/fitting/fithelpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,14 @@ def __exit__ ( self , *_ ) :
# =============================================================================
## helper factory function
def config_factory ( klass , config ) :
"""Helper factory function, used for unpickling"""
""" Helper factory function, used for unpickling"""
with NameDuplicates ( True ) :
return klass ( **config )
# =============================================================================
## @class ConfigReducer
# Helper base class for pickling/unpickling FUNs/PDFs
class ConfigReducer(object) :
"""Helper base class for pickling/unpickling FUNs/PDFs
""" Helper base class for pickling/unpickling FUNs/PDFs
"""
def __init__ ( self , **kwargs ) :
self.__config = {}
Expand All @@ -113,13 +113,13 @@ def __reduce__ ( self ) :
## factory method
@classmethod
def factory ( klass , config ) :
"""Factory method, used for unpickling"""
""" Factory method, used for unpickling"""
with NameDuplicates ( True ) :
return klass ( **config )

@property
def config ( self ) :
"""The full configuration info for the FUN/PDF"""
""" The full configuration info for the FUN/PDF"""
conf = {}
conf.update ( self.__config )
return conf
Expand All @@ -129,10 +129,11 @@ def config ( self , value ) :
conf.update ( value )
self.__config = conf

# =======================================================================
## oversimplified placeholder for the clone method
def clone ( self , **kwargs ) :
"""Oversimplified placeolder for clone method
- actual cloning for PDFs are a bit more sophistocated
""" Oversimplified placeolder for clone method
- actual cloning for PDFs are a bit more sophisticated
"""
## get config
conf = {}
Expand Down Expand Up @@ -170,27 +171,27 @@ def __new__( cls, *args, **kwargs):

## produce ERROR message using the local logger
def fatal ( self , message , *args , **kwargs ) :
"""Produce FATGAL message using the local logger"""
""" Produce FATGAL message using the local logger"""
return self.logger.fatal ( message , *args , **kwargs )
## produce ERROR message using the local logger
def error ( self , message , *args , **kwargs ) :
"""Produce ERROR message using the local logger"""
""" Produce ERROR message using the local logger"""
return self.logger.error ( message , *args , **kwargs )
## produce WARNIING message using the local logger
def warning ( self , message , *args , **kwargs ) :
"""Produce WARNIING message using the local logger"""
""" Produce WARNIING message using the local logger"""
return self.logger.warning ( message , *args , **kwargs )
## produce INFO message using the local logger
def info ( self , message , *args , **kwargs ) :
"""Produce INFO message using the local logger"""
""" Produce INFO message using the local logger"""
return self.logger.info ( message , *args , **kwargs )
## produce DEBUG message using the local logger
def debug ( self , message , *args , **kwargs ) :
"""Produce DEBUG message using the local logger"""
""" Produce DEBUG message using the local logger"""
return self.logger.debug ( message , *args , **kwargs )
## produce VERBOSE message using the local logger
def verbose ( self , message , *args , **kwargs ) :
"""Produce VERBOSE message using the local logger"""
""" Produce VERBOSE message using the local logger"""
return self.logger.verbose ( message , *args , **kwargs )

# =========================================================================
Expand All @@ -214,7 +215,7 @@ def logger ( self ) :
return _logger
@property
def name ( self ) :
"""The name of the object"""
""" The name of the object"""
return self.__name if self.__name else ''
@name.setter
def name ( self , value ) :
Expand Down Expand Up @@ -268,8 +269,8 @@ def roo_name ( prefix = 'roo' , suffix = '' , name = '' ) :

regname = ROOT.RooNameReg.instance()

## RooFit does no tline coma in the names
## RooAbsCollection::selectByName treat commas special case
## RooFit does not line commas in the names!
## RooAbsCollection::selectByName treat commas as special case

to_replace = ( ( ',' ,'_' ) ,
( ';' ,'_' ) ,
Expand Down Expand Up @@ -377,10 +378,10 @@ def make_var ( self ,

## content of args

## at most four argumentss: (value, min, max, unit)
## at most four arguments: (value, min, max, unit)
assert len ( args ) <= 4 , "make_var: invalid length of 'args' %s" % len ( args )

## strip out the uniuts from args
## strip out the units from args
vunit = ''
vargs = args
if args and isinstance ( args[-1] , string_types ) :
Expand All @@ -391,11 +392,11 @@ def make_var ( self ,
vargs = tuple ( float ( v ) for v in vargs )

## content of var

vvars = var [0:]
vvars = var [ 0 : ]

## pickup the name (if specified...)
vname = vvars [0]
vname = vvars [ 0 ]
if isinstance ( vname , string_types ) :
assert vname and ( ( not name ) or vname == name ) , \
"make_var: invalid specification of 'name' : %s/%s" % ( vname , name )
Expand Down Expand Up @@ -436,75 +437,89 @@ def make_var ( self ,
vargs_ = vargs
vvars = tuple ( sorted ( vvars ) )
vargs = tuple ( sorted ( vargs ) )
## attention! for 3-tupel the order is (value, min, max)
## attention! for 3-tuple the order is (value, min, max)
if 3 == len ( vvars ) : vvars = vvars [ 1 ] , vvars [ 0 ] , vvars [ 2 ]
if 3 == len ( vargs ) : vargs = vargs [ 1 ] , vargs [ 0 ] , vargs [ 2 ]
if vvars != vvars_ : self.warning ("make_var('%s'): %s -> %s " % ( name , str ( vvars_ ) , str ( vvars ) ) )
if vargs != vargs_ : self.warning ("make_var('%s'): %s -> %s " % ( name , str ( vargs_ ) , str ( vargs ) ) )

## there should be at least one useful number!
assert 1<= len_vvars + len_vargs , "make_var: empty 'vvars' and 'vargs'!"
assert 1 <= len_vvars + len_vargs , "make_var: empty 'vvars' and 'vargs'!"

fixed = False

if 0 == len_vvars :

## OK
params = vargs + ( unit , )

elif 1 == len_vvars and 0 == len_vargs :

## OK: use only vvar
params = vvars + ( unit , )

elif 1 == len_vvars and 2 == len_vargs and vargs [ 0 ] <= vvars [ 0 ] <= vargs [ 1 ] :

## OK, get min/max from vargs
params = vvars + vargs + ( unit , )

elif 1 == len_vvars and 2 == len_vargs :

## OK, get min/max from vargs
params = vvars + ( min ( vvars [ 0 ] , vargs [ 0 ] ) , max ( vvars[0] , vargs [ 1 ] ) , unit )
fixed = True

elif 1 == len_vvars and 3 == len_vargs and vargs [ 1 ] <= vvars [ 0 ] <= vargs [ 2 ] :

## OK
params = vvars + ( min ( vvars [ 0 ] , vargs [ 1 ] ) , max ( vvars [ 0 ] , vargs [ 2 ] ) , unit )

elif 1 == len_vvars and 3 == len_vargs :

## FIX IT
params = vvars + ( min ( vvars[0] , vargs [ 1 ] ) , max ( vvars[0] , vargs [ 2 ] ) , unit )
fixed = True

elif 1 == len_vvars :

## 'vargs" are ignored
params = vvars + ( unit , )
fixed = True

elif 2 == len_vvars and 0 == len_vargs :

## OK: min/max specified via vvar
params = vvars + ( unit , )

elif 2 == len_vvars and 1 == len_vargs and vvars [ 0 ] <= vargs [ 0 ] <= vvars [ 1 ] :

## get the value from vargs
params = vargs + vvars + ( unit , )

elif 2 == len_vvars and 1 == len_vargs :

## get the value from vargs
params = vvars + ( unit , )
fixed = True

elif 2 == len_vvars and 2 == len_vargs :

## igore vargs
params = vvars + ( unit , )

elif 2 == len_vvars and 3 == len_vargs and vvars [ 0 ] <= vargs [ 0 ] <= vvars [ 1 ] :

## get the value from vargs
params = vargs[:1] + vvars + ( unit , )

elif 2 == len_vvars :

## 'vargs" are ignored
params = vvars + ( unit , )
fixed = True

elif 3 == len_vvars :

## ignore vargs
params = vvars + ( unit , )

Expand Down Expand Up @@ -548,7 +563,7 @@ def make_var ( self ,
return var

# ==========================================================================
## check the possible name duplication
## check the possible name duplication
def var_name ( self , name ) :
""" Check the possible name duplication
"""
Expand Down Expand Up @@ -586,7 +601,7 @@ def __del__ ( self ) :
# bins = bining ( axis )
# @endocode
def binning ( self , axis , name = '' ) :
"""Create ROOT.RooFit.Binning from TAxis
""" Create ROOT.RooFit.Binning from TAxis
>>> axis = ...
>>> bins = binning ( axis )
"""
Expand Down
4 changes: 2 additions & 2 deletions ostap/fitting/funbasic.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
## @class AFUN1
# Helper base class for implementation of various (Roo)Function-wrappers
class AFUN1(XVar,FitHelper,ConfigReducer) : ## VarMaker) :
"""Helper base class for implementation of various (Roo)Function-wrappers
""" Helper base class for implementation of various (Roo)Function-wrappers
"""

def __init__ ( self , name , xvar , tricks = True , **kwargs ) :
Expand Down Expand Up @@ -212,7 +212,7 @@ def tricks ( self , value ) :
# ...
# @endcode
def __contains__ ( self , var ) :
"""Does this function depend on this variable?
""" Does this function depend on this variable?
>>> fun = ...
>>> var = ...
>>> if var in fun :
Expand Down
13 changes: 6 additions & 7 deletions ostap/plotting/canvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -620,7 +620,7 @@ def canvas_partition ( canvas ,


# =============================================================================
## Make partition of Canvas into nx, ny adjuncent pads and plot objects
## Make partition of Canvas into (nx)x(ny) adjuncent pads and plot objects
# @code
# canvas = ...
# objects = ...
Expand Down Expand Up @@ -819,7 +819,7 @@ def canvas_pull ( canvas ,
bottom_margin = margin_bottom ,
top_margin = margin_top ,
vSpacing = 0.0 ) :
"""Perform partition of Canvas into 1x2 non-equal pads with no inter-margins
""" Perform partition of Canvas into 1x2 non-equal pads with no inter-margins
>>> canvas = ...
>>> pads = canvas.pull_partition ( 4.0 ) ## top-pad 4-times larger
Expand Down Expand Up @@ -848,7 +848,7 @@ def draw_pads ( objects ,
fontsize = 36 ,
trim_left = False ,
trim_right = False ) :
"""Draw sequence of object on sequence of pads,
""" Draw sequence of object on sequence of pads,
- the label font size is adjusted to be uniform (in pixels)
>>> pads = ...
>>> frames = ...
Expand Down Expand Up @@ -911,7 +911,7 @@ def draw_pads ( objects ,
# =============================================================================
## change main parametes of TAttPad
def set_pad ( pad , **config ) :
"""Change main parametes of `TAttPad`"""
""" Change main parametes of `TAttPad`"""

conf = cidict ( transform = cidict_fun )
conf.update ( config )
Expand Down Expand Up @@ -1019,7 +1019,7 @@ def set_pad ( pad , **config ) :
## helper context manager for <code>TAttPad</code> objects
# @see TAttPad
class UsePad(object) :
"""Helper context manager for `TAttPad` objects
""" Helper context manager for `TAttPad` objects
- see `TAttPad`
"""

Expand Down Expand Up @@ -1069,7 +1069,6 @@ def use_pad ( pad , **config ) :

usePad = use_pad


# =============================================================================
## @class Canvas
# helper context manager to create and configure a canvas (and pad)
Expand All @@ -1078,7 +1077,7 @@ def use_pad ( pad , **config ) :
# ...
# @endcode
class Canvas(KeepCanvas) :
"""Helper context manager to create and configure a canvas (and pad)
""" Helper context manager to create and configure a canvas (and pad)
>>> with Canvas ( title = 'Canvas #2' , width = 1000 ) :
>>> ...
"""
Expand Down
11 changes: 6 additions & 5 deletions source/include/Ostap/MoreRooFit.h
Original file line number Diff line number Diff line change
Expand Up @@ -3310,15 +3310,16 @@ namespace Ostap
* @return nullptr
*/
RooAbsData* delete_data ( RooAbsData* data ) ;
// =========================================================================
/** assign RooAbsCollection
// =========================================================================
/** assign RooAbsCollection
* @see RooAbsCollection
* @see RooAbsDataStore
* @param from source collection
* @param to destination collection
* @param to destination collection
*/
void assign ( RooAbsCollection& to ,
const RooAbsCollection& from ) ;
void assign
( RooAbsCollection& to ,
const RooAbsCollection& from ) ;
// ========================================================================
/// helper function to call <code>RooAbsPdf::fitTo ( data , opts )</code>
RooFitResult*
Expand Down
16 changes: 3 additions & 13 deletions source/include/Ostap/qMath.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
// Include files
// ============================================================================
/** @file Ostap/qMath.h
* Collection of functions related qto Tsallis statistics
* Collection of functions related to Tsallis statistics
* @see https://en.wikipedia.org/wiki/Tsallis_statistics
* @see Umarov, Sabir; Tsallis, Constantino; Steinberg, Stanly (2008).
* "On a q-Central Limit Theorem Consistent with Nonextensive
Expand Down Expand Up @@ -132,7 +132,7 @@ namespace Ostap
const double y ,
const double k = 0 ) ;
// ========================================================================
/** subtaction of two variables in Kanadakis algebra
/** subtraction of two variables in Kanadakis algebra
* \f$ x \ominus_k y = x \oplus_k -y \f$
*/
inline double kaniadakis_ksubtraction
Expand All @@ -141,9 +141,7 @@ namespace Ostap
const double k = 0 )
{ return kaniadakis_ksum ( x , -y , k ) ; }
// ========================================================================

// ========================================================================
/** product of two varibales in Kaniadakis algebra
/** product of two variables in Kaniadakis algebra
* \f$ x \otimes_k y = \frac{1}{k}
* \sinh { \frac{1}{k} \asinh {kx} \asinh{ky} }
* \f$
Expand All @@ -153,8 +151,6 @@ namespace Ostap
const double y ,
const double k = 0 ) ;
// ========================================================================

// ========================================================================
/** k-exponent in Kaniadakis statistics
* \f$ \exp_k(x) =
* \left\{ \begin{array}{ll}
Expand All @@ -169,9 +165,6 @@ namespace Ostap
( const double x ,
const double k = 0 ) ;
// ========================================================================


// ========================================================================
/** k-logarithm in Kaniadakis statistics
* \f$ \log_k(x) =
* \left\{ \begin{array}{ll}
Expand All @@ -184,10 +177,7 @@ namespace Ostap
( const double x ,
const double k = 0 ) ;
// ========================================================================




// ========================================================================
} // The end of namespace Ostap::Math
// ==========================================================================
Expand Down

0 comments on commit b76805c

Please sign in to comment.