<commit_before>#!/usr/bin/env python
# -*- coding: utf-8 -*-
# =============================================================================
# @file ostap/plotting/makestyles.py
# Helper utilities to deal with ROOT styles 
# =============================================================================
"""Helper utilities to deal with ROOT styles 
"""
# =============================================================================
import ROOT
import ostap.plotting.color 
__all__ = (
    'StyleStore'       , ## the storage/dictionary of created/known styles
    'dump_style'       , ## dump a style into dicitonary
    'set_style'        , ## configure style from the dictionary
    'make_styles'      , ## create the styles from the configuration
    'make_ostap_style' , ## create Ostap-like style
    'canvas_width'     , ## (default) canvas width
    'canvas_height'    , ## (default) canvas height
    'margin_top'       , ## (default) top margin 
    'margin_bottom'    , ## (default) top margin 
    'margin_left'      , ## (default) top margin 
    'margin_right'     , ## (default) top margin 
    )
# =============================================================================
# logging 
# =============================================================================
from ostap.logger.logger import getLogger
if '__main__' ==  __name__ : logger = getLogger( 'ostap.plotting.makestyles' )
else                       : logger = getLogger( __name__ )
# =============================================================================
## font 
ostap_font       = 132     ## Times-Roman 
## line thickness
ostap_line_width =   1
## define style for text
ostap_label = ROOT.TText   (             )
ostap_label . SetTextFont  ( ostap_font  )
ostap_label . SetTextColor (  1          )
ostap_label . SetTextSize  (  0.04       )
ostap_label . SetTextAlign ( 12          )
## define style of latex text
ostap_latex = ROOT.TLatex   () 
ostap_latex . SetTextFont   ( ostap_font )
ostap_latex . SetTextColor  ( 1          )
ostap_latex . SetTextSize   ( 0.04       )
ostap_latex . SetTextAlign  ( 12         )
# ==============================================================================
margin_top    = 0.03
margin_bottom = 0.12
margin_left   = 0.096
margin_right  = 0.032
# ==============================================================================
import ostap.core.config as OCC
width_  = OCC.canvas.get ( 'Width'       , fallback = '1000' )
try               : width_  = int  ( width_ ) 
except ValueError : width_  = 1000
canvas_width  = width_  if 20 <= width_  else 1000
# 
height_ = OCC.canvas.get ( 'Height'      , fallback =  '800' )
try               : height_ = int  ( height_ ) 
except ValueError : height_ = 800
canvas_height = height_ if 20 <= height_ else  800
##
tmp_    = OCC.canvas.get ( 'MarginTop'   , fallback = '%f'  % margin_top      )
try               : tmp_  = float ( tmp_ ) 
except ValueError : tmp_  = margin_top
if 0 < tmp_ < 1 : margin_top = tmp_
## 
tmp_    = OCC.canvas.get ( 'MarginBottom' , fallback = '%f' %  margin_bottom  )
try               : tmp_  = float ( tmp_ ) 
except ValueError : tmp_  = margin_bottom 
if 0 < tmp_ < 1 : margin_bottom = tmp_
#
tmp_    = margin_bottom * canvas_width / canvas_height 
tmp_    = OCC.canvas.get ( 'MarginLeft'   , fallback = '%f'  % tmp_ ) 
try               : tmp_  = float ( tmp_ ) 
except ValueError : tmp_  = margin_left
if 0 < tmp_ < 1 : margin_left = tmp_
#
tmp_    = margin_top    * canvas_width / canvas_height 
tmp_    = OCC.canvas.get ( 'MarginRight'   , fallback = '%f'  % tmp_ ) 
try               : tmp_  = float ( tmp_ ) 
except ValueError : tmp_  = margin_right 
if 0 < tmp_ < 1 : margin_right = tmp_

logger.verbose ( 'Default parameters: ')
logger.verbose ( '  canvas_height : %s ' % canvas_height )
logger.verbose ( '  canvas_width  : %s ' % canvas_width  )
logger.verbose ( '  margin_top    : %s ' % margin_top    )
logger.verbose ( '  margin_bottom : %s ' % margin_bottom )
logger.verbose ( '  margin_left   : %s ' % margin_left   )
logger.verbose ( '  margin_right  : %s ' % margin_right  )

# ==============================================================================
## @class StyleStore
#  Store for all created/cofigures styles
class StyleStore(object) :
    """Store for all created/cofigures styles<commit_msg> more fixes<commit_after>#!/usr/bin/env python
# -*- coding: utf-8 -*-
# =============================================================================
# @file ostap/plotting/makestyles.py
# Helper utilities to deal with ROOT styles 
# =============================================================================
"""Helper utilities to deal with ROOT styles 
"""
# =============================================================================
import ROOT
import ostap.plotting.color 
__all__ = (
    'StyleStore'       , ## the storage/dictionary of created/known styles
    'dump_style'       , ## dump a style into dicitonary
    'set_style'        , ## configure style from the dictionary
    'make_styles'      , ## create the styles from the configuration
    'make_ostap_style' , ## create Ostap-like style
    'canvas_width'     , ## (default) canvas width
    'canvas_height'    , ## (default) canvas height
    'margin_top'       , ## (default) top margin 
    'margin_bottom'    , ## (default) top margin 
    'margin_left'      , ## (default) top margin 
    'margin_right'     , ## (default) top margin 
    )
# =============================================================================
# logging 
# =============================================================================
from ostap.logger.logger import getLogger
if '__main__' ==  __name__ : logger = getLogger( 'ostap.plotting.makestyles' )
else                       : logger = getLogger( __name__ )
# =============================================================================
## font 
ostap_font       = 132     ## Times-Roman 
## line thickness
ostap_line_width =   1
## define style for text
ostap_label = ROOT.TText   (             )
ostap_label . SetTextFont  ( ostap_font  )
ostap_label . SetTextColor (  1          )
ostap_label . SetTextSize  (  0.04       )
ostap_label . SetTextAlign ( 12          )
## define style of latex text
ostap_latex = ROOT.TLatex   () 
ostap_latex . SetTextFont   ( ostap_font )
ostap_latex . SetTextColor  ( 1          )
ostap_latex . SetTextSize   ( 0.04       )
ostap_latex . SetTextAlign  ( 12         )
# ==============================================================================
margin_top    = 0.03
margin_bottom = 0.12
margin_left   = 0.096
margin_right  = 0.032
# ==============================================================================
import ostap.core.config as OCC
width_  = OCC.canvas.get ( 'Width'       , fallback = '1000' )
try               : width_  = int  ( width_ ) 
except ValueError : width_  = 1000
canvas_width  = width_  if 20 <= width_  else 1000
# 
height_ = OCC.canvas.get ( 'Height'      , fallback =  '800' )
try               : height_ = int  ( height_ ) 
except ValueError : height_ = 800
canvas_height = height_ if 20 <= height_ else  800
##
tmp_    = OCC.canvas.get ( 'MarginTop'   , fallback = '%f'  % margin_top      )
try               : tmp_  = float ( tmp_ ) 
except ValueError : tmp_  = margin_top
if   0 <      tmp_ < 1             : margin_top = tmp_
elif 0 < -1 * tmp_ < canvas_height : margin_top = abs ( 1.0 * tmp_ / canvas_height )  
## 
tmp_    = OCC.canvas.get ( 'MarginBottom' , fallback = '%f' %  margin_bottom  )
try               : tmp_  = float ( tmp_ ) 
except ValueError : tmp_  = margin_bottom 
if   0 <      tmp_ < 1             : margin_bottom = tmp_
elif 0 < -1 * tmp_ < canvas_height : margin_bottom = abs ( 1.0 * tmp_ / canvas_height )  
#
tmp_    = margin_bottom * canvas_width / canvas_height 
tmp_    = OCC.canvas.get ( 'MarginLeft'   , fallback = '%f'  % tmp_ ) 
try               : tmp_  = float ( tmp_ ) 
except ValueError : tmp_  = margin_left
if   0 <      tmp_ < 1             : margin_left = tmp_
elif 0 < -1 * tmp_ < canvas_width  : margin_left = abs ( 1.0 * tmp_ / canvas_width  )  
#
tmp_    = margin_top    * canvas_width / canvas_height 
tmp_    = OCC.canvas.get ( 'MarginRight'   , fallback = '%f'  % tmp_ ) 
try               : tmp_  = float ( tmp_ ) 
except ValueError : tmp_  = margin_right 
if   0 <      tmp_ < 1             : margin_right = tmp_
elif 0 < -1 * tmp_ < canvas_width  : margin_right = abs ( 1.0 * tmp_ / canvas_width  )  

logger.verbose ( 'Default parameters: ')
logger.verbose ( '  canvas_height : %s ' % canvas_height )
logger.verbose ( '  canvas_width  : %s ' % canvas_width  )
logger.verbose ( '  margin_top    : %s ' % margin_top    )
logger.verbose ( '  margin_bottom : %s ' % margin_bottom )
logger.verbose ( '  margin_left   : %s ' % margin_left   )
logger.verbose ( '  margin_right  : %s ' % margin_right  )

# ==============================================================================
## @class StyleStore
#  Store for all created/cofigures styles
class StyleStore(object) :
    """Store for all created/cofigures styles
{'fraction_non_alphanumeric': 0.24620127725170668, 'fraction_numerical': 0.015855538427659105, 'mean_word_length': 3.045879732739421, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '748202', 'n_tokens_mistral': 2821, 'n_tokens_neox': 2625, 'n_words': 679}