From 0b95fdeb3039f848d62d10c23363039c536f372d Mon Sep 17 00:00:00 2001 From: Vanya Belyaev Date: Thu, 25 Aug 2022 09:26:03 +0200 Subject: [PATCH] 1. fix newly introduced typo in drawing for simulltaneous pdf. Thanks to Dima Pereima for reporitng a problem! --- CMakeLists.txt | 2 +- ReleaseNotes/release_notes.md | 4 ++++ ReleaseNotes/v1.9.2.4.md | 9 +++++++++ ostap/fitting/simfit.py | 11 ++++++----- ostap/fitting/tests/test_fitting_simfit1.py | 18 +++++++++--------- 5 files changed, 29 insertions(+), 15 deletions(-) create mode 100644 ReleaseNotes/v1.9.2.4.md diff --git a/CMakeLists.txt b/CMakeLists.txt index cfab179c..43ec1499 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,7 +21,7 @@ include(CTest) set(OSTAP_VERSION_MAJOR 1) set(OSTAP_VERSION_MINOR 9) set(OSTAP_VERSION_PATCH 2) -set(OSTAP_VERSION_TWEAK 3) +set(OSTAP_VERSION_TWEAK 4) set(OSTAP_VERSION ${OSTAP_VERSION_MAJOR}.${OSTAP_VERSION_MINOR}.${OSTAP_VERSION_PATCH}.${OSTAP_VERSION_TWEAK}) diff --git a/ReleaseNotes/release_notes.md b/ReleaseNotes/release_notes.md index 5d2e553d..e5dae6ca 100644 --- a/ReleaseNotes/release_notes.md +++ b/ReleaseNotes/release_notes.md @@ -1,9 +1,13 @@ +# v1.9.2.4 + ## New features: ## Backward incompatible: ## Bug fixes: + 1. fix newly introduced typo in drawing for simulltaneous pdf. Thanks to Dima Pereima for reporitng a problem! + # v1.9.2.2 ## New features: diff --git a/ReleaseNotes/v1.9.2.4.md b/ReleaseNotes/v1.9.2.4.md new file mode 100644 index 00000000..8bfa3e7c --- /dev/null +++ b/ReleaseNotes/v1.9.2.4.md @@ -0,0 +1,9 @@ +# v1.9.2.4 + +## New features: + +## Backward incompatible: + +## Bug fixes: + + 1. fix newly introduced typo in drawing for simulltaneous pdf. Thanks to Dima Pereima for reporitng a problem! diff --git a/ostap/fitting/simfit.py b/ostap/fitting/simfit.py index c45f1acd..3a7723b8 100644 --- a/ostap/fitting/simfit.py +++ b/ostap/fitting/simfit.py @@ -590,8 +590,6 @@ def __init__ ( self , 'Invalid type for "sample":' % ( sample , type ( sample ) ) name = name if name else self.generate_name ( 'simfit' , '' , sample.GetName() ) - - ## propagate the name self.name = name @@ -837,6 +835,7 @@ def draw ( self , >>> pdf.fitTo ( dataset ) >>> pf.draw ( 'signal' , dataset , nbins = 100 ) """ + dvar = None if isinstance ( category , ( tuple , list ) ) and 2 == len ( category ) : category , dvar = category @@ -913,7 +912,7 @@ def draw ( self , return None elif isinstance ( draw_pdf , PDF2 ) : - + if 2 == dvar or dvar in ( 'y' , 'Y' , '2' , draw_pdf.yvar.name ) : return draw_pdf.draw2 ( dataset = dataset , nbins = nbins , @@ -928,12 +927,14 @@ def draw ( self , self.error("Unknown 'dvar' for 2D-draw pdf! %s" % dvar ) return None - elif isinstance ( draw_pdf , PDF3 ) : - + elif isinstance ( draw_pdf , PDF1 ) : return draw_pdf.draw ( dataset = dataset , nbins = nbins , silent = silent , args = args , **kwargs ) + + self.error ("draw: inconsistent combination of draw_pdf '%s' and dvar '%s'" % ( + type ( draw_pdf ) , dvar ) ) # ========================================================================= ## create NLL diff --git a/ostap/fitting/tests/test_fitting_simfit1.py b/ostap/fitting/tests/test_fitting_simfit1.py index 65b8ed80..6735bad8 100755 --- a/ostap/fitting/tests/test_fitting_simfit1.py +++ b/ostap/fitting/tests/test_fitting_simfit1.py @@ -114,14 +114,16 @@ def test_simfit1 () : model2.S = NS2 model2.B = NB2 - with use_canvas ( 'test_simfit1' ) : + with use_canvas ( 'test_simfit1: fit dataset1' ) : # ========================================================================= ## fit 1 with wait ( 1 ) : r1 , f1 = model1.fitTo ( dataset1 , draw = True , nbins = 50 , silent = True ) title = 'Results of fit to dataset1' logger.info ( '%s\n%s' % ( title , r1.table ( title = title , prefix = '# ' ) ) ) + + with use_canvas ( 'test_simfit1: fit dataset2' ) : ## fit 2 with wait ( 1 ) : r2 , f2 = model2.fitTo ( dataset2 , draw = True , nbins = 50 , silent = True ) @@ -150,11 +152,10 @@ def test_simfit1 () : title = 'Results of simultaneous fit' logger.info ( '%s\n%s' % ( title , r.table ( title = title , prefix = '# ' ) ) ) - with use_canvas ( 'test_simfit1' ) : - with wait ( 1 ) : - fA = model_sim.draw ( 'A' , dataset , nbins = 50 ) - with wait ( 1 ) : - fB = model_sim.draw ( 'B' , dataset , nbins = 50 ) + with wait ( 2 ) , use_canvas ( 'test_simfit1: fit both datasets & draw A' ) : + fA = model_sim.draw ( 'A' , dataset , nbins = 50 ) + with wait ( 2 ) , use_canvas ( 'test_simfit1: fit both datasets & draw B' ) : + fB = model_sim.draw ( 'B' , dataset , nbins = 50 ) models.add ( model1 ) models.add ( model2 ) @@ -196,13 +197,12 @@ def test_db() : if '__main__' == __name__ : - with timing( "simfit-1" , logger ) : - test_simfit1 () + test_simfit1 () ## check finally that everything is serializeable: with timing ('Save to DB:' , logger ) : - test_db () + test_db () # ============================================================================= ## The END