Skip to content

Commit

Permalink
fix ?
Browse files Browse the repository at this point in the history
  • Loading branch information
VanyaBelyaev committed Aug 7, 2024
1 parent 203933d commit 8e342ec
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 25 deletions.
14 changes: 2 additions & 12 deletions ostap/fitting/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -2406,25 +2406,15 @@ def _ds_store_asym_error_ ( dataset ) :
- see Ostap::Utils::storeAsymError
"""

print ( 'STORE_ASYM_ERROR/0' , dataset.isWeighted() )

if not dataset.isWeighted() : return False ## UNWEIGHTED!

attr = '_store_asym_weight_error_'
print ( 'STORE_ASYM_ERROR/1' , attr )

if not hasattr ( dataset , attr ) :

print ( 'STORE_ASYM_ERROR/2' , attr )

##
wn = Ostap.Utils.storeAsymError ( dataset )
wn = True if wn else False

print ( 'STORE_ASYM_ERROR/3' , attr , wn )

##
setattr ( dataset , attr , wn )

print ( 'STORE_ASYM_ERROR/4' , attr , hasattr ( dataset , attr ) )

return getattr ( dataset , attr , '' )

Expand Down
24 changes: 11 additions & 13 deletions ostap/fitting/ds2numpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,10 @@
except ImportError :
np = None
# =============================================================================
_new_methods_ = []
_new_methods_ = []



# =============================================================================
if np and ( 6 , 28 ) <= root_info : ## 6.26 <= ROOT
# =============================================================================

if np and ( 6 , 28 ) <= root_info : ## 6.26 <= ROOT
# =========================================================================
## Convert dataset into numpy array using <code>ROOT.RooAbsData</code> interface
# @see ROOT.RooAbsData.getBatches
Expand Down Expand Up @@ -176,7 +172,6 @@ def ds2numpy ( dataset , var_lst , silent = True , more_vars = {} ) :
if dname in doubles :
part [ dname ] = d.second


elif dname == weight :
part [ dname ] = d.second
del dpart
Expand Down Expand Up @@ -224,8 +219,6 @@ def ds2numpy ( dataset , var_lst , silent = True , more_vars = {} ) :

# =============================================================================
elif np : ## ROOT < 6.26
# =============================================================================

# =========================================================================
## Convert dataset into numpy array using (slow) explicit loops
def ds2numpy ( dataset , var_lst , silent = False , more_vars = {} ) :
Expand Down Expand Up @@ -287,7 +280,8 @@ def ds2numpy ( dataset , var_lst , silent = False , more_vars = {} ) :
categories = [ v.name for v in vars if isinstance ( v , ROOT.RooAbsCategory ) ]

## name of weight variable
weight = '' if not dataset.isWeighted() else dataset.wname ()
weighted = dataset.isWeighted ()
weight = '' if not weighted else dataset.wname ()

dtypes = []
for v in vnames :
Expand All @@ -300,15 +294,19 @@ def ds2numpy ( dataset , var_lst , silent = False , more_vars = {} ) :
## create data
data = np.zeros ( len ( dataset ) , dtype = dtypes )


## make an explict loop:
for i , evt in enumerate ( progress_bar ( dataset , silent = silent ) ) :
for i , item in enumerate ( progress_bar ( dataset , silent = silent ) ) :

if weighted : evt, the_weight = item
else : evt = item

for v in evt :
vname = v.name
if vname in doubles : data [ vname ] [ i ] = float ( v )
elif vname in categories : data [ vname ] [ i ] = int ( v )
if weight : data [ weight ] [ i ] = dataset.weight()

if weighted and weight : data [ weight ] [ i ] = float ( the_weight )

## add PDF values
for vname , func , obsvars in funcs :
Expand Down

0 comments on commit 8e342ec

Please sign in to comment.