Skip to content

Commit

Permalink
adding something super-basic to README
Browse files Browse the repository at this point in the history
  • Loading branch information
zbilodea committed Oct 19, 2023
1 parent df45547 commit 40315b5
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,16 @@
[rtd-badge]: https://readthedocs.org/projects/odapt/badge/?version=latest
[rtd-link]: https://odapt.readthedocs.io/en/latest/?badge=latest

The odapt library is a bridge between columnar file formats **ROOT, Parquet, Feather, and HDF5.** It aims to simplify file conversions in Python, replacing what is usually a multi-step process with one line of code, with builtin features for managing large datasets and choosing compression levels.

# Getting started

```python
import odapt as od

od.operations.hadd("destination.root",
["file1.root", "file2.root"])
```


<!-- prettier-ignore-end -->
18 changes: 9 additions & 9 deletions tests/test_hadd.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import pytest
import uproot

import odapt
import odapt as od

ROOT = pytest.importorskip("pyarrow")

Expand Down Expand Up @@ -111,12 +111,12 @@ def test_simple(tmp_path, file_paths):

path = Path(tmp_path)
destination = path / "destination.root"
odapt.operations.hadd(destination, file_paths, force=True)
od.operations.hadd(destination, file_paths, force=True)

with uproot.open(destination) as file:
added = uproot.from_pyroot(
gauss_1 + gauss_2 + gauss_3
) # test odapt vs Pyroot histogram adding
) # test od vs Pyroot histogram adding
assert file["name"].member("fN") == added.member("fN")
assert file["name"].member("fTsumw") == added.member("fTsumw")
assert np.equal(file["name"].values(flow=True), added.values(flow=True)).all
Expand All @@ -142,7 +142,7 @@ def test_simple(tmp_path, file_paths):
def test_3_glob(file_paths):
h1, h2, h3 = generate_1D_gaussian(file_paths)

odapt.operations.hadd("tests/place.root", "tests/samples", force=True)
od.operations.hadd("tests/place.root", "tests/samples", force=True)

with uproot.open("tests/place.root") as file:
assert file["name"].member("fN") == h1.member("fN")
Expand All @@ -159,7 +159,7 @@ def test_3_glob(file_paths):

def simple_1dim_F():
h1, h2 = generate_1D_simple()
odapt.operations.hadd(
od.operations.hadd(
"tests/place2.root",
["tests/file1dim1.root", "tests/file2dim1.root"],
force=True,
Expand Down Expand Up @@ -279,7 +279,7 @@ def mult_2D_hists():
outHistFile.Close()
h4 = uproot.from_pyroot(h4)

odapt.operations.hadd(
od.operations.hadd(
"tests/place2.root",
["tests/file3dim2.root", "tests/file4dim2.root"],
force=True,
Expand Down Expand Up @@ -369,7 +369,7 @@ def simple_2dim_F():

h2 = uproot.from_pyroot(h2)

odapt.operations.hadd(
od.operations.hadd(
"tests/place2.root",
["tests/file1dim2.root", "tests/file2dim2.root"],
force=True,
Expand Down Expand Up @@ -445,7 +445,7 @@ def simple_2D():
outHistFile.Close()
h1 = uproot.from_pyroot(h1)

odapt.operations.hadd(
od.operations.hadd(
"tests/place2.root",
["tests/file1dim2.root", "tests/file2dim2.root"],
force=True,
Expand Down Expand Up @@ -509,7 +509,7 @@ def break_bins():
outHistFile.Close()
h2 = uproot.from_pyroot(h2)

odapt.operations.hadd(
od.operations.hadd(
"tests/place2break.root",
["tests/file1dim1break.root", "tests/file2dim1break.root"],
force=True,
Expand Down

0 comments on commit 40315b5

Please sign in to comment.