Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
- Loading branch information
Showing
2 changed files
with
62 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package: | ||
name: boost-histogram | ||
version: 1.3.0 | ||
source: | ||
url: https://files.pythonhosted.org/packages/0a/9a/1ebde600886eee433a99434e0ddb462630a0b25ab1f58efb91ffc385a0ff/boost_histogram-1.3.0.tar.gz | ||
sha256: 62240dae889cbf05f8b4f2203f0b7d6c7a2e029502723a377fc33226e425ce50 | ||
requirements: | ||
run: | ||
- numpy | ||
build: | ||
script: | | ||
pip install setuptools_scm[toml] | ||
test: | ||
imports: | ||
- boost-histogram | ||
about: | ||
home: https://github.com/scikit-hep/boost-histogram | ||
PyPI: https://pypi.org/project/boost-histogram | ||
summary: The Boost::Histogram Python wrapper. | ||
license: BSD-3-Clause |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
from pyodide_build.testing import run_in_pyodide | ||
|
||
|
||
@run_in_pyodide(packages=["boost-histogram"]) | ||
def test_boost_histogram(): | ||
import boost_histogram as bh | ||
import unittest | ||
|
||
class TestBasicHistogram(unittest.TestCase): | ||
|
||
def test_1d_histogram(self): | ||
h = bh.Histogram(bh.axis.Integer(0, 10)) | ||
h.fill([1,1,1,14]) | ||
self.assertEquals(h[bh.underflow], 0) | ||
self.assertEquals(h[bh.loc(0)], 0) | ||
self.assertEquals(h[bh.loc(1)], 3) | ||
self.assertEquals(h[bh.overflow], 1) | ||
|
||
self.assertEquals(h.sum(), 3) | ||
self.assertEquals(h.sum(flow=True), 4) | ||
self.assertEquals(h[sum], 4) | ||
|
||
def test_2d_histogram(self): | ||
h = bh.Histogram(bh.axis.Regular(10,0,10), bh.axes.Boolean()) | ||
self.assertEquals(len(h.axes[0]), 10) | ||
self.assertEquals(len(h.axes[0]), 2) | ||
|
||
h.fill([.5, .5, 3.5], [True, False, True]) | ||
self.assertEquals(h[sum, bh.loc(True)], 2) | ||
self.assertEquals(h[sum, bh.loc(False)], 1) | ||
self.assertEquals(h[0, sum], 2) | ||
self.assertEquals(h[0, bh.loc(True)], 1) | ||
|
||
def test_cat_histogram(self): | ||
h = bh.Histogram(bh.axis.StrCategory(growth=True)) | ||
h.fill("fear leads to anger anger leads to hate hate leads to suffering".split()) | ||
|
||
self.assertEquals(h[bh.loc("fear")], 1) | ||
self.assertEquals(h[bh.loc("anger")], 2) | ||
self.assertEquals(h[bh.loc("hate")], 2) | ||
self.assertEquals(h[bh.loc("to")], 3) | ||
|