Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
VanyaBelyaev committed Nov 6, 2024
1 parent b7afe14 commit 0277019
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
3 changes: 2 additions & 1 deletion ostap/fitting/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -1398,14 +1398,15 @@ def ds_draw ( dataset ,
return tree_draw ( dataset , what, cuts = cuts , opts = opts , first = first , last = last , delta = delta , **kwargs )
elif isinstance ( dataset , ROOT.RooAbsData ) :
ranges = ds_range ( dataset , varlst , cuts = cuts , cut_range = cut_range , first = first , last = last , delta = delta )
print ( 'RANGES' , ranges , varlst )
else :
## something else ? e.g. DataFrame
assert not cut_range , "ds_draw: `cut_range' is not allowed!"
assert ( first , last ) == ALL_ENTRIES , "ds_draw: `first'/`last' are not allowed!"
ranges = data_range ( dataset , varlst , cuts = cuts , delta = delta )

if not ranges :
logger.warning ("ds_draw: nothning to draw, return None" )
logger.warning ("ds_draw: nothing to draw, return None" )
return None

assert len ( ranges ) == nvars , 'Invalid ranges: %s' % str ( ranges )
Expand Down
9 changes: 6 additions & 3 deletions ostap/stats/statvars.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,6 @@ def data_statistics ( data , expressions , cuts = '' , *args ) :
with rootException() :
result = StatVar.statVar ( data , var , cuts , *args )
if not result.isfinite() : logger.error ( "Invalid statistics for `%s`" % var )
return result
result = { var : result }
return result

Expand All @@ -293,6 +292,7 @@ def data_statistics ( data , expressions , cuts = '' , *args ) :
names = strings ( *var_lst )
results = StatVar.Statistics()
with rootException() :

if cuts : StatVar.statVars ( data , results , names , cuts , *args )
else : StatVar.statVars ( data , results , names , *args )
assert len ( var_lst ) == len ( results ) , \
Expand All @@ -302,6 +302,7 @@ def data_statistics ( data , expressions , cuts = '' , *args ) :
for v , r in zip ( var_lst , results ) :
if not r.isfinite() : logger.error ( "Invalid statistics for `%s`" % v )
result [ v ] = r

return result

# ==============================================================================
Expand All @@ -325,8 +326,10 @@ def data_minmax ( data , expressions , cuts = '' , *args ) :
"""
results = data_statistics ( data , expressions , cuts , *args )
if isinstance ( results , dictlike_types ) :
res = {}
for k, r in loop_items ( results ) :
results [ k ] = r.min() , r.max()
res [ k ] = r.min() , r.max()
results = res
else : results = results.min() , results.max()
##
return results
Expand All @@ -352,7 +355,7 @@ def data_range ( data ,
>>> result = data_range ( data , 'sin(x)*100*y' , 'x<0' )
>>> results = data_range ( dataset , 'x,y,z,t,u,v' , 'x<0' ) ## as dictionary
"""
results = data_minmax ( data, expressions , cuts , *args )
results = data_minmax ( data, expressions , cuts , *args )
if isinstance ( results , dictlike_types ) :
for k , r in loop_items ( results ) :
mn, mx = r
Expand Down

0 comments on commit 0277019

Please sign in to comment.