Skip to content

Commit

Permalink
fix for new PyROOT/cppyy the issue with picklinng of enums
Browse files Browse the repository at this point in the history
  • Loading branch information
VanyaBelyaev committed Apr 2, 2024
1 parent 8f59dbf commit e22ae3c
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
1 change: 1 addition & 0 deletions ReleaseNotes/release_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
1. add possibility to add separator line to `summary_graphs`
1. fix for new ROOT>6.31 few issues with std::string <--> const char*
1. imporve a bit BLUE
1. add "fix" for new pyROOT/cppyy for failure with ickling of enums

## Backward incompatible

Expand Down
11 changes: 11 additions & 0 deletions ostap/tools/chopping.py
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,17 @@ def __init__ ( self ,
from ostap.trees.trees import Chain
if isinstance ( self.__signal , ROOT.TTree ) : self.__signal = Chain ( self.__signal )
if isinstance ( self.__background , ROOT.TTree ) : self.__background = Chain ( self.__background )

## trick to pleas Kisa for ROTO 6.31/01 (enum TMVA.Types.ETMVA is not pickable...
if ( 6, 31 ) <= root_info :
ms = list ( self.__methods )
for i, e in enumerate ( ms ) :
e = list ( e )
e = tuple ( [ int ( e[0] ) ] + e[1:])
ms [ i ] = e
self.__methods = ms



## book the trainers
self.__trainers = ()
Expand Down
3 changes: 2 additions & 1 deletion ostap/tools/tests/test_tools_chopping.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@
## parallel_conf = { 'ncpus' : 0 , 'ppservers' : 'auto' }
)


# train it!
with timing ( 'for TMVA/Chopping training' , logger ) :
trainer.train ()
Expand Down Expand Up @@ -344,7 +345,7 @@
table = T.table ( rows , title = title , prefix = '# ' , alignment = 'cc' )
logger.info ( '%s\n%s' % ( title , table ) )



# =============================================================================
## The END
Expand Down
7 changes: 7 additions & 0 deletions ostap/tools/tmva.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,13 @@ def __init__( self ,
if isinstance ( logging , string_types ) : self.__logging = logging
else : self.__logging = "%s.log" % self.name



for i , e in enumerate ( methods ) :
t = e [ 0 ]
assert ROOT.TMVA.Types.kVariable <= t < ROOT.TMVA.Types.kMaxMethod, \
'Invalid TMVA.Types.EMVA %s' % t

self.__methods = tuple ( methods )

variables = list ( variables )
Expand Down

0 comments on commit e22ae3c

Please sign in to comment.