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

Remove deprecated method DecFileParser.load_grammar #456

Merged
merged 1 commit into from
Aug 9, 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
1 change: 1 addition & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ ignore:
- "src/decaylanguage/modeling/*"
- "src/decaylanguage/utils/errors.py"
- "src/decaylanguage/utils/utilities.py"
- "src/decaylanguage/_compat/*"
43 changes: 3 additions & 40 deletions src/decaylanguage/dec/dec.py
Original file line number Diff line number Diff line change
Expand Up @@ -265,46 +265,6 @@ def grammar_info(self) -> dict[str, Any]:

return self._grammar_info

def load_grammar(
self,
filename: str | None = None,
parser: str = "lalr",
lexer: str = "auto",
**options: Any,
) -> None:
"""
DEPRECATED, please use "``load_additional_decay_models``" instead.

Load a Lark grammar definition file, either the default one,
or a user-specified one, optionally setting Lark parsing options.

Parameters
----------
filename: str, optional, default=None
Input .dec decay file name. By default 'data/decfile.lark' is loaded.
parser: str, optional, default='lalr'
The Lark parser engine name.
lexer: str, optional, default='auto'
The Lark parser lexer mode to use.
options: keyword arguments, optional
Extra options to pass on to the parsing algorithm.

See Lark's Lark class for a description of available options
for parser, lexer and options.
"""

warnings.warn(
"This method is deprecated, please add unknown decay models by passing them to "
"``load_additional_decay_models`` instead before parsing the decayfile.",
DeprecationWarning,
stacklevel=2,
)

if filename is None:
filename = "decfile.lark"

self._load_grammar(filename, parser, lexer, **options)

def load_additional_decay_models(self, *models: str) -> None:
"""
Add one or more EvtGen decay models in addition to the ones already provided via
Expand Down Expand Up @@ -343,6 +303,9 @@ def _load_grammar(
The Lark parser lexer mode to use.
options: keyword arguments, optional
Extra options to pass on to the parsing algorithm.

See Lark's Lark class for a description of available options
for parser, lexer and options.
"""

with data.basepath.joinpath(filename).open() as f1:
Expand Down
Loading