Skip to content

Commit

Permalink
Merge pull request #56 from XENONnT/half_open_right
Browse files Browse the repository at this point in the history
Open right side of the bin to follow numpy convention
  • Loading branch information
dachengx authored Dec 19, 2024
2 parents eabb254 + ec8aed7 commit a666883
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ repos:
language_version: python3.9

- repo: https://github.com/pycqa/docformatter
rev: v1.7.5
rev: master
hooks:
- id: docformatter

Expand Down
4 changes: 2 additions & 2 deletions GOFevaluation/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ def get_equiprobable_binning(
# Get binning in second dimension (for each bin in first dimension):
bin_edges_second = []
for low, high in zip(bin_edges_first[:-1], bin_edges_first[1:]):
mask = (first > low) & (first <= high)
mask = (first >= low) & (first < high)
if weights_flag:
bin_edges = _weighted_equi(
n_partitions[order[1]], second[mask], reference_sample_weights[mask]
Expand Down Expand Up @@ -333,7 +333,7 @@ def apply_irregular_binning(data_sample, bin_edges, order=None, data_sample_weig
ns = []
i = 0
for low, high in zip(bin_edges[0][:-1], bin_edges[0][1:]):
mask = (first > low) & (first <= high)
mask = (first >= low) & (first < high)
if weights_flag:
n, _ = np.histogram(
second[mask], bins=bin_edges[1][i], weights=data_sample_weights[mask.flatten()]
Expand Down
8 changes: 4 additions & 4 deletions tests/test_evaluators_nd.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ def test_bin_equiprobable(self):
reference_sample = np.linspace(0, 1, int(10 * n_data))
reference_sample = np.vstack([reference_sample for i in range(2)]).T

binned_data = np.full(n_partitions, n_data / np.product(n_partitions))
binned_reference = np.full(n_partitions, n_expected / np.product(n_partitions))
binned_data = np.full(n_partitions, n_data / np.prod(n_partitions))
binned_reference = np.full(n_partitions, n_expected / np.prod(n_partitions))
gofclass_from_binned = BinnedPoissonChi2GOF.from_binned(binned_data, binned_reference)
gof_from_binned = gofclass_from_binned.get_gof()

Expand Down Expand Up @@ -295,8 +295,8 @@ def test_bin_equiprobable(self):
reference_sample = np.linspace(0, 1, int(10 * n_data))
reference_sample = np.vstack([reference_sample for i in range(2)]).T

binned_data = np.full(n_partitions, n_data / np.product(n_partitions))
binned_reference = np.full(n_partitions, n_expected / np.product(n_partitions))
binned_data = np.full(n_partitions, n_data / np.prod(n_partitions))
binned_reference = np.full(n_partitions, n_expected / np.prod(n_partitions))
gofclass_from_binned = BinnedChi2GOF.from_binned(binned_data, binned_reference)
gof_from_binned = gofclass_from_binned.get_gof()

Expand Down
2 changes: 1 addition & 1 deletion tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def eqpb_2d(
)
self.assertEqual(np.sum(n), n_data)
for expect in n.reshape(-1):
self.assertEqual(expect, n_data / np.product(n_partitions))
self.assertEqual(expect, n_data / np.prod(n_partitions))
self.assertEqual(np.shape(bin_edges[0])[0] - 1, n_partitions[order[0]])
self.assertEqual(np.shape(bin_edges[1])[0], n_partitions[order[0]])
self.assertEqual(np.shape(bin_edges[1])[1] - 1, n_partitions[order[1]])
Expand Down

0 comments on commit a666883

Please sign in to comment.