diff --git a/CMakeLists.txt b/CMakeLists.txt index d7b6e209..d5ba5d75 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,6 +40,8 @@ find_program(CMAKE_CXX_COMPILER NAMES $ENV{CXX} g++ PATHS ENV PATH NO_DEFAULT_PA message ( "----> C-compiler : " $ENV{CC} ) message ( "----> C++-compiler : " $ENV{CXX} ) +message ( "----> C-compiler ID : " ${CMAKE_CXX_COMPILER_ID} ) +message ( "----> C++-compiler ID : " ${CMAKE_CXX_COMPILER_ID} ) # You need to tell CMake where to find the ROOT installation. This can be done in a number of ways: # - ROOT built with classic configure/make use the provided $ROOTSYS/etc/cmake/FindROOT.cmake diff --git a/ReleaseNotes/release_notes.md b/ReleaseNotes/release_notes.md index 824e7661..4745eb1e 100644 --- a/ReleaseNotes/release_notes.md +++ b/ReleaseNotes/release_notes.md @@ -8,7 +8,8 @@ 1. add `isfinite` method for `(W)Covariance` objects 1. add `Ostap::MoreRooFit::Hypot` and `var_hypot` 1. add Fizher's Z-distribution - + 1. explicitely delete all created styles, see [here](https://github.com/root-project/root/issues/16918) + ## Backward incompatible ## Bug fixes diff --git a/ostap/plotting/makestyles.py b/ostap/plotting/makestyles.py index 25952baf..a27602cb 100644 --- a/ostap/plotting/makestyles.py +++ b/ostap/plotting/makestyles.py @@ -119,12 +119,16 @@ ## @class StyleStore # Store for all created/configured styles class StyleStore(object) : - """Store for all created/cofigures styles + """ Store for all created/cofigures styles """ - __styles = {} + __styles = {} + __own_styles = {} @classprop - def styles ( kls ) : + def styles ( kls ) : return kls.__styles + @classprop + def own_styles ( kls ) : + return kls.__own_styles # ============================================================================= ## get the ROOT style by name @@ -148,7 +152,7 @@ def root_style ( name ) : # getters, setters, special = style_methods() # @endcode def style_methods () : - """Get the essential methods of class ROOT.TStyle + """ Get the essential methods of class ROOT.TStyle >>> getters, setters, special = style_methods() """ # The style getters @@ -231,7 +235,7 @@ def style_methods () : # conf = style.get () ## ditto # @endcode def dump_style ( style ) : - """Dump the style to the dictionary + """ Dump the style to the dictionary >>> style = ... >>> conf = dump_style ( style ) >>> conf = style.dump () ## ditto @@ -280,7 +284,7 @@ def dump_style ( style ) : # ============================================================================= ## Dump the style as a table def table_style ( style , prefix = '' , title = '' ) : - """Dump the style as a table""" + """ Dump the style as a table""" conf = dump_style ( style ) @@ -302,7 +306,7 @@ def table_style ( style , prefix = '' , title = '' ) : ROOT.TStyle.table = table_style # ============================================================================= -## extr aattribvutes +## extra attributes extra = 'NumberOfColors' , 'showeditor', 'showeventstatus', 'showtoolbar', 'basestyle', 'ostaplike' # ============================================================================= ## Set the style from the configuration dictionary @@ -313,7 +317,7 @@ def table_style ( style , prefix = '' , title = '' ) : # style.set ( config ) ## ditto # @endcode def set_style ( style , config , base_style = '' , **kwargs ) : - """Set the style from the configurtaion dictionary + """ Set the style from the configurtaion dictionary >>> config = ... >>> style = ... >>> set_style ( style , config ) @@ -590,7 +594,7 @@ def set_style ( style , config , base_style = '' , **kwargs ) : ## Parse the configuration and create # all the styles according to configuration def make_styles ( config = None ) : - """Parse the configuration and create + """ Parse the configuration and create all the styles according to configuration """ @@ -617,7 +621,7 @@ def make_styles ( config = None ) : if not style : logger.debug ( 'Create new generic style %s/%s' % ( name , description ) ) style = ROOT.TStyle ( name , description ) - + StyleStore.own_styles.update ( { name : style } ) set_style ( style , section ) if name in StyleStore.styles : @@ -629,8 +633,7 @@ def make_styles ( config = None ) : if nname in StyleStore.styles : logger.info ( "The configuration %s replaced" % nname ) StyleStore.styles.update ( { nname : style } ) - - + # ============================================================================== def get_float ( config , name , default ) : try : @@ -680,7 +683,8 @@ def make_ostap_style ( name , description = 'The Style' , config = {} , base_style = '' , **kwargs ) : - + """ Make ostap-like style + """ kw = cidict ( transform = cidict_fun ) kw.update ( kwargs ) @@ -935,18 +939,36 @@ def make_ostap_style ( name , ## create the style style = root_style ( name ) + if not style : logger.debug ( "Create new Ostap style `%s'" % name ) style = ROOT.TStyle ( name , description ) + StyleStore.own_styles.update ( { name : style } ) + print ( 'CREATE NEW OSTAP STYLE', name ) + StyleStore.styles.update ( { name : style } ) set_style ( style , conf , base_style = base_style ) - + return style # ============================================================================= ## read the configuration files and create the styles make_styles () - + + + +import atexit +@atexit.register +def styles_clean () : + """ The styles need to be deleted + - see https://github.com/root-project/root/issues/16918 + """ + while StyleStore.styles : + _ , _ = StyleStore.styles.popitem () + while StyleStore.own_styles : + _ , st = StyleStore.own_styles.popitem () + del st + # ============================================================================= _decorated_classes_ = ( ROOT.TStyle , diff --git a/ostap/plotting/style.py b/ostap/plotting/style.py index 934a25cd..798acc77 100755 --- a/ostap/plotting/style.py +++ b/ostap/plotting/style.py @@ -4,7 +4,7 @@ # @file ostap/plotting/style.py # Ostap style file for ROOT-plots # ============================================================================= -"""Ostap Style for ROOT-plots""" +""" Ostap Style for ROOT-plots""" # ============================================================================= __all__ = ( 'UseStyle' , ## context manager for the style (class) @@ -55,7 +55,7 @@ def OstapStyle ( name , force = True , scale = 1.0 , colz = False ) : - """Create Ostap-style for the plots + """ Create Ostap-style for the plots """ # ================================================================ @@ -255,6 +255,26 @@ def useStyle ( style = None , **config ) : """ return UseStyle ( style , **config ) + +import atexit +@atexit.register +def styles_delete () : + """ The styles need to be deleted + - see https://github.com/root-project/root/issues/16918 + """ + global Style1Z, Style2Z, Style3Z + global Style1 , Style2 , Style3 + global Style , StyleZ , ostapStyle + + del Style1Z + del Style2Z + del Style3Z + del Style1 + del Style2 + del Style3 + del StyleZ + del Style + del ostapStyle # ============================================================================= if '__main__' == __name__ :