Skip to content

Commit

Permalink
importimport
Browse files Browse the repository at this point in the history
  • Loading branch information
kdund committed Dec 13, 2023
1 parent f865fb2 commit 3066be4
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
3 changes: 2 additions & 1 deletion GOFevaluation/evaluator_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,8 @@ class EvaluatorBaseMCUnbinned(EvaluatorBase):
Base for MC-based unbinned GOF tests, takes 3 things:
- data: array of data coordinates
- data_generator: a function that generates toy samples from the tested model
- distance_measure: a function that evaluates how extreme a data sample is given the tested model
- distance_measure: a function that evaluates how extreme
a data sample is given the tested model
"""
def __init__(self, data, data_generator, distance_measure):
super().__init__()
Expand Down
12 changes: 8 additions & 4 deletions GOFevaluation/evaluators_1d.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,11 @@ def __init__(self, data, opening_angle=np.pi, fixed_length=True):
mu = len(data)
assert 0 < mu # otherwise, pointless
if fixed_length:
get_uniform_thetas = lambda: sps.uniform(-np.pi, 2*np.pi).rvs(mu)
def get_uniform_thetas():
return sps.uniform(-np.pi, 2 * np.pi).rvs(mu)
else:
get_uniform_thetas = lambda: sps.uniform(-np.pi, 2*np.pi).rvs(sps.poisson(mu).rvs())
def get_uniform_thetas()
return sps.uniform(-np.pi, 2 * np.pi).rvs(sps.poisson(mu).rvs())
distance = self.get_best_partition
super().__init__(data, get_uniform_thetas, distance)

Expand All @@ -169,8 +171,10 @@ def dtheta(t0, t1):
def get_best_partition(data_t, opening_angle=np.pi, test_angles=None, return_best_angle=False):
"""
Find the angle and number of events that is the most events you can fit into opening_angle
If test_angles = None, the direction of all data-points will be tried, but if there are many 1000s of points,
it can be more performant and good enough to just pass np.linspace(0, 2*np.pi, 100) instead
If test_angles = None, the direction of all data-points will be tried,
but if there are many 1000s of points,
it can be more performant and good enough to
just pass np.linspace(0, 2*np.pi, 100) instead
"""
if len(data_t) == 0:
if return_best_angle:
Expand Down
2 changes: 1 addition & 1 deletion tests/test_evaluators_1d.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import unittest
import warnings

from GOFevaluation.evaluator_base import import EvaluatorBaseMCUnbinned
from GOFevaluation.evaluator_base import EvaluatorBaseMCUnbinned
from GOFevaluation.evaluators_1d import KSTestGOF
from GOFevaluation.evaluators_1d import KSTestTwoSampleGOF
from GOFevaluation.evaluators_1d import ADTestTwoSampleGOF
Expand Down

0 comments on commit 3066be4

Please sign in to comment.