diff --git a/ostap/core/core.py b/ostap/core/core.py index eef67268..fe88c7e3 100644 --- a/ostap/core/core.py +++ b/ostap/core/core.py @@ -395,7 +395,31 @@ def check_color ( color ) : return color - +# ============================================================================= +## alowed argument for draw-function +draw_args = frozenset ( [ 'linecolor' , 'markercolor' , 'fillcolor' , 'color' , + 'linestyle' , 'linewidth' , 'width' , + 'markerstyle' , 'markersize' , 'marker' , + 'fillstyle' , 'fill' , 'opacity' , 'opaque' , + 'minimum' , 'minimal' , 'min' , 'minval' , 'minvalue' , + 'maximum' , 'maximal' , 'max' , 'maxval' , 'maxvalue' , + 'labelsize' , 'labelfont' , 'labelscale' , + 'xaxislabeloffset' , + 'yaxislabeloffset' , + 'zaxislabeloffset' , + 'copy' , + 'logx' , + 'logy' ] ) +## ============================================================================ +## remove "draw-args" from dictionary of arguments +def remove_draw_args ( kwargs ) : + """ remove "draw-args" from dictionary of arguments """ + nargs = {} + for k, v in loop_items ( kwargs ) : + key = cidict_fun ( k ) + if key in draw_args : continue + nargs [ k ] = v + return nargs # ============================================================================= ## Silent draw # ============================================================================= diff --git a/ostap/math/models.py b/ostap/math/models.py index ef7d6534..0706db05 100644 --- a/ostap/math/models.py +++ b/ostap/math/models.py @@ -120,15 +120,19 @@ def tf1 ( self , **kwargs ) : fun.SetTitle ( title ) ## if kwargs : - import ostap.logger.table as T - rows = [ ( 'Argument' , 'Value' ) ] - for k , v in loop_items ( kwargs ) : - row = k , str ( v ) - rows.append ( row ) - title = 'tf1: %d unused arguments' % len ( kwargs ) - table = T.table ( rows , title = 'Unused arguments' , prefix = '# ' , alignment = 'll' ) - logger.warning ( '%s\n%s' % ( title , table ) ) - + from ostap.core.core import remove_draw_args + kw = remove_draw_args ( kwargs ) + if kw : + import ostap.logger.table as T + rows = [ ( 'Argument' , 'Value' ) ] + for k, v in loop_items ( kw ) : + c = kwargs [ k ] + row = k , str ( v ) + rows.append ( row ) + title = 'tf1: %d unused arguments' % len ( kwargs ) + table = T.table ( rows , title = 'Unused arguments' , prefix = '# ' , alignment = 'll' ) + logger.warning ( '%s\n%s' % ( title , table ) ) + ## return fun # ============================================================================= @@ -196,6 +200,19 @@ def tf2 ( self , **kwargs ) : if title is None : title = str ( self ) fun.SetTitle ( title ) # + if kwargs : + from ostap.core.core import remove_draw_args + kw = remove_draw_args ( kwargs ) + if kw : + import ostap.logger.table as T + rows = [ ( 'Argument' , 'Value' ) ] + for k , v in loop_items ( kw ) : + row = k , str ( v ) + rows.append ( row ) + title = 'tf2: %d unused arguments' % len ( kwargs ) + table = T.table ( rows , title = 'Unused arguments' , prefix = '# ' , alignment = 'll' ) + logger.warning ( '%s\n%s' % ( title , table ) ) + ## return fun # ============================================================================= @@ -274,15 +291,18 @@ def tf3 ( self , **kwargs ) : fun.SetNpy ( npz ) # if kwargs : - import ostap.logger.table as T - rows = [ ( 'Argument' , 'Value' ) ] - for k , v in loop_items ( kwargs ) : - row = k , str ( v ) - rows.append ( row ) - title = 'tf3: %d unused arguments' % len ( kwargs ) - table = T.table ( rows , title = 'Unused arguments' , prefix = '# ' , alignment = 'll' ) - logger.warning ( '%s\n%s' % ( title , table ) ) - + from ostap.core.core import remove_draw_args + kw = remove_draw_args ( kwargs ) + if kw : + import ostap.logger.table as T + rows = [ ( 'Argument' , 'Value' ) ] + for k , v in loop_items ( kw ) : + row = k , str ( v ) + rows.append ( row ) + title = 'tf3: %d unused arguments' % len ( kwargs ) + table = T.table ( rows , title = 'Unused arguments' , prefix = '# ' , alignment = 'll' ) + logger.warning ( '%s\n%s' % ( title , table ) ) + ## return fun positives = ( Ostap.Math.Positive , @@ -1259,10 +1279,10 @@ def _tf3_getattr_ ( self , attr ) : # ======================================================================================= -## Special ``getattr'' for Bernstein dual basis functions: delegate the stuff to +## Special `getattr' for Bernstein dual basis functions: delegate the stuff to # the underlying bernstein polynomial def _bdb_getattr_ ( self , attr ) : - """Special ``getattr'' for Bernstein dual basis functions: + """ Special `getattr' for Bernstein dual basis functions: - delegate the stuff to the underlying Bernstein polynomial """ b = self.bernstein() @@ -1492,7 +1512,6 @@ def sp_maximum_1D_ ( pdf , xmin , xmax , x0 , *args ) : s.varsigma () , s.kL () , s.kR () ) - # ============================================================================= ## decorate 1D-PDFs # ============================================================================= @@ -1708,7 +1727,7 @@ def sp_maximum_3D_ ( pdf , # >>> for x,y in func.generate( 1000 ) : print x,y # @endcode def _random_generate_bernstein2D_ ( fun , num = 1 ) : - """Generate random numbers from 2D bernstein-like distribuitions + """ Generate random numbers from 2D bernstein-like distribuitions >>> func = ... >>> for x,y in func.generate( 1000 ) : print x,y """