Skip to content

Commit

Permalink
1. Add Kuiper's Goodness-of-Fit estimator to ostap.stats.gof1d
Browse files Browse the repository at this point in the history
  • Loading branch information
VanyaBelyaev committed Sep 22, 2024
1 parent 77d8d9d commit f9ac417
Show file tree
Hide file tree
Showing 7 changed files with 186 additions and 121 deletions.
4 changes: 2 additions & 2 deletions ReleaseNotes/release_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
1. add weight to `tree.withCut` and other tree-looping methods
1. Tiny tweak for treatment of drawing ranges for `f1_draw/f2_draw/f3_draw` fnuctions: form now the explicit setting has a precedence.
1. `ostap.stats.gof1d` : improve drawing methods

1. Add Kuiper's Goodness-of-Fit estimator to `ostap.stats.gof1d`

## Backward incompatible

1. add `weight` to `tree.withCut` and other tree-looping methods
Expand All @@ -23,7 +24,6 @@

1. fix typo in `ostap.math.bnase.axis_range`


# v1.13.3.0

## New features
Expand Down
4 changes: 2 additions & 2 deletions ostap/core/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@
wilsonEff = Ostap.Math.wilsonEff
agrestiCoullEff = Ostap.Math.agrestiCoullEff
# =============================================================================
## helper function for case-insensitive dictionary with ignorance of underscores and blanks
## helper function for case-insensitive dictionary with ignorance of underscores and blanks and dashes
from ostap.utils.cidict import case_transform
cidict_fun = lambda k : case_transform ( k ) . replace('_','') . replace ( ' ', '')
cidict_fun = lambda k : case_transform ( k ) . replace('_','') . replace ( ' ', '').replace('-','')
# =============================================================================
## @class ROOTCWD
# context manager to preserve current directory (rather confusing stuff in ROOT)
Expand Down
52 changes: 26 additions & 26 deletions ostap/io/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
# Helper class for parallel processing of long list of files
# It defiend the basic teatemtn of the, calling `Files.treatFile` method
class TreatFileTask(Task) :
"""Helper class for parallel processing of long list of files
""" Helper class for parallel processing of long list of files
It defiens the basic teatemtn of the, calling `Files.treatFile` method
"""
def __init__ ( self , data ) :
Expand All @@ -44,7 +44,7 @@ def initialize_local ( self ) : pass
def initialize_remote ( self , jobid = -1 ) : pass
## actgual processing
def process ( self , jobid , files ) :
"""Actual processing"""
""" Actual processing"""
for f in files : self.__data.treatFile ( f )
return self.__data
## get the results
Expand All @@ -56,7 +56,7 @@ def merge_results ( self , results , jobid = -1 ) :
# ===========================================================================
## get the size with units for the file-size units
def fsize_unit ( size ) :
"""Get the size with units for the file-size units"""
""" Get the size with units for the file-size units"""
assert isinstance ( size , integer_types ) , "unit: invalid 'size' type"
if ( 1024 ** 5 ) <= size : return size // ( 1024 ** 5 ) , 'PB'
elif ( 1024 ** 4 ) <= size : return size // ( 1024 ** 4 ) , 'TB'
Expand All @@ -76,7 +76,7 @@ def fsize_unit ( size ) :
# @author Alexander BARANOV [email protected]
# @date 2014-06-08
class Files(object):
"""Simple utility to pickup the list of files
""" Simple utility to pickup the list of files
- collect file the file
- keeps and store them
Expand Down Expand Up @@ -203,7 +203,7 @@ def bad_files ( self ) :
# =========================================================================
## get the disk size of files, only existing files are counted
def getsize ( self ) :
"""Get the disk size of files, only existing/valid files are counted"""
""" Get the disk size of files, only existing/valid files are counted"""
s = 0
for f in self.__files :
s += max ( 0 , self.get_file_size ( f ) )
Expand All @@ -214,7 +214,7 @@ def getsize ( self ) :
# @param fname input file name
# @return ROOT file sizeor -1 for non-existingt/invalid files
def get_file_size ( self , fname ) :
"""Get the size of the file
""" Get the size of the file
- fname : input file name
- return file size or -1 for non-existing/invalid files
"""
Expand All @@ -229,7 +229,7 @@ def get_file_size ( self , fname ) :
# if the_file in files : ....
# @endcode
def __contains__ ( self , the_file ) :
"""Check if the file is a part of collection
""" Check if the file is a part of collection
>>> files = ...
>>> if the_file in files : ....
"""
Expand All @@ -238,7 +238,7 @@ def __contains__ ( self , the_file ) :
# =========================================================================
## Get the list of files from the patterns
def the_files ( self ) :
"""Get the list of files from the patterns"""
""" Get the list of files from the patterns"""

_files = set ()

Expand Down Expand Up @@ -346,7 +346,7 @@ def __or__ ( self , other ) :

## get an intersection of two datasets
def __and__ ( self , other ) :
""" get intersection of two sets
""" Get intersection of two sets
>>> ds1 = ...
>>> ds2 = ...
>>> ds = ds1 & ds2 ## get intersection
Expand All @@ -363,7 +363,7 @@ def __and__ ( self , other ) :

## get an exclusive OR for two datasets
def __xor__ ( self , other ) :
""" get an exclusive OR for two sets
""" Get an exclusive OR for two sets
>>> ds1 = ...
>>> ds2 = ...
>>> ds = ds1 ^ ds2 ## get an exclusive OR
Expand Down Expand Up @@ -405,27 +405,27 @@ def __ior__ ( self , other ) :

## get union of two datasets
def union ( self , other ) :
"""Union of two datasets"""
""" Union of two datasets"""
return self | other

## get intersection of two datasets
def intersection ( self , other ) :
"""Intersection of two datasets"""
""" Intersection of two datasets"""
return self & other

## get difference of two datasets
def difference ( self , other ) :
"""Differfence of two datasets"""
""" Differfence of two datasets"""
return self - other

## get symmetric difference of two datasets
def symmetric_difference ( self , other ) :
"""Symmetric Differfence of two datasets"""
""" Symmetric Differfence of two datasets"""
return self ^ other

## subtraction for datasets
def __sub__ ( self , other ) :
""" get subtraction of two sets
""" Get subtraction of two sets
>>> ds1 = ...
>>> ds2 = ...
>>> ds = ds1 - ds2 ## get subtraction
Expand All @@ -439,7 +439,7 @@ def __sub__ ( self , other ) :

## remove the files from another dataset
def __isub__ ( self , other ) :
""" Remove file forom anothere dataset
""" Remove file from another dataset
>>> ds1 = ...
>>> ds2 = ...
>>> ds1 -= ds2 ## get subtraction
Expand All @@ -457,7 +457,7 @@ def __isub__ ( self , other ) :
# =========================================================================
## get a sample of at most n-elements (if n is integer and >=1 ) or n-fraction
def sample_files ( self , n , sort ) :
"""get a sample of at most n-elements (if n is integer and >=1 ) or n-fraction
""" Get a sample of at most n-elements (if n is integer and >=1 ) or n-fraction
"""
if isinstance ( n , int ) and 1 <= n <= len ( self.files ) :
files = random.sample ( self.files , n )
Expand All @@ -477,7 +477,7 @@ def sample_files ( self , n , sort ) :
# f2 = files.samlpe ( 0.1 ) ## 10% of files
# @endcode
def sample ( self , n , sort = True , **kwargs ) :
"""Get a sub-sample
""" Get a sub-sample
>>> files = ...
>>> f1 = files.sample ( 5 ) ## 5 files
>>> f2 = files.sample ( 0.1 ) ## 10% of files
Expand All @@ -495,7 +495,7 @@ def sample ( self , n , sort = True , **kwargs ) :
# f2 = files[4:10]
# @endcode
def __getitem__ ( self , item ) :
"""Get a sub-sample
""" Get a sub-sample
>>> files = ...
>>> f1 = files[5]
>>> f2 = files[4:10]
Expand All @@ -511,7 +511,7 @@ def __getitem__ ( self , item ) :

## printout
def __str__(self):
"""The specific printout
""" The specific printout
"""
return "<#files: %4d>" % len ( self.files )

Expand All @@ -527,7 +527,7 @@ def __len__ ( self ) : return len ( self.files )
# print ( files.table() )
# @endcode
def table ( self , title = 'Files' , prefix = '' ) :
"""Print collection of files as table
""" Print collection of files as table
"""
rows = [ ( '#' , 'size' , 'name' ) ]
files = self.files
Expand Down Expand Up @@ -616,7 +616,7 @@ def commonpath ( self ) :
# - new directory will be created (if needed)
# - common path (prefix) for all files will be replaced by new directory
def copy_files ( self , new_dir = None , parallel = False , also_bad = False ) :
"""copy all the files to new directory
""" Copy all the files to new directory
- new directory will be created (if needed)
- common path (prefix) for all files will be replaced by new directory
"""
Expand Down Expand Up @@ -644,7 +644,7 @@ def copy_files ( self , new_dir = None , parallel = False , also_bad = False ) :
# - new directory will be created (if needed)
# - common path (prefix) for all files will be replaced by new directory
def sync_files ( self , new_dir = None , parallel = False , also_bad = False ) :
"""Sync/copy all the files to new directory
""" Sync/copy all the files to new directory
- new directory will be created (if needed)
- common path (prefix) for all files will be replaced by new directory
"""
Expand Down Expand Up @@ -685,7 +685,7 @@ def copy_files ( files_to_copy ,
copier = None ,
copy_cmd = '' ,
progress = False ) :
"""Copy set of files into new directory.
""" Copy set of files into new directory.
Files are copied in a way to preserve they name uniqueness:
Expand Down Expand Up @@ -799,7 +799,7 @@ def sync_files ( files_to_copy ,
copy_cmd = '' ,
progress = False ) :

"""Sync/copy set of files into new directory.
""" Sync/copy set of files into new directory.
Files are copied in a way to preserve they name uniqueness:
Expand Down Expand Up @@ -859,7 +859,7 @@ def sync_dirs ( source_dir ,
copier = None ,
copy_cmd = '' ,
progress = False ) :
"""Sync/copy two directories
""" Sync/copy two directories
Files are copied in a way to preserve they name uniqueness:
Expand Down
Loading

0 comments on commit f9ac417

Please sign in to comment.