Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Remove register_awkward() #258

Merged
merged 1 commit into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/pylhe/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from particle.exceptions import MatchingIDNotFound

from pylhe._version import version as __version__
from pylhe.awkward import register_awkward, to_awkward
from pylhe.awkward import to_awkward

__all__ = [
"__version__",
Expand All @@ -22,7 +22,6 @@
"read_lhe_init",
"read_lhe_with_attributes",
"read_num_events",
"register_awkward",
"to_awkward",
]

Expand Down
20 changes: 1 addition & 19 deletions src/pylhe/awkward.py
Original file line number Diff line number Diff line change
@@ -1,31 +1,13 @@
import awkward as ak
import vector

__all__ = ["register_awkward", "to_awkward"]
__all__ = ["to_awkward"]


def __dir__():
return __all__


def register_awkward():
"""
.. deprecated:: 0.6.0
Remove use of :func:`~pylhe.awkward.register_awkward` as registration
is automatic.
.. warning:: :func:`~pylhe.awkward.register_awkward` will be removed in
``pylhe`` ``v0.8.0``.
"""
import warnings

warnings.warn(
"pylhe.awkward.register_awkward is deprecated as of pylhe v0.6.0 and will be removed in pylhe v0.8.0."
+ " Please remove use of pylhe.awkward.register_awkward in favor of automatic registration.",
category=DeprecationWarning,
stacklevel=2, # Raise to user level
)


def to_awkward(event_iterable):
"""Convert iterable of LHEEvent instances to Awkward-Array."""

Expand Down
10 changes: 1 addition & 9 deletions tests/test_api.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import pytest

import pylhe


Expand All @@ -17,18 +15,12 @@ def test_top_level_api():
"read_lhe_init",
"read_lhe_with_attributes",
"read_num_events",
"register_awkward",
"to_awkward",
]


def test_awkward_api():
assert dir(pylhe.awkward) == ["register_awkward", "to_awkward"]


def test_deprecated_api_warning():
with pytest.warns(DeprecationWarning):
pylhe.register_awkward()
assert dir(pylhe.awkward) == ["to_awkward"]


def test_load_version():
Expand Down
4 changes: 0 additions & 4 deletions tests/test_awkward.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@
TEST_FILE = skhep_testdata.data_path("pylhe-testfile-pr29.lhe")


def test_register_awkward():
pylhe.register_awkward()


def test_to_awkward():
arr = pylhe.to_awkward(pylhe.read_lhe_with_attributes(TEST_FILE))
assert len(arr) == 791
Expand Down
Loading