Skip to content

Commit

Permalink
feat: lazy import to ensure cli performance
Browse files Browse the repository at this point in the history
Signed-off-by: Jinzhe Zeng <[email protected]>
  • Loading branch information
njzjz committed May 8, 2024
1 parent a1e56b3 commit 75b175a
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
12 changes: 8 additions & 4 deletions reacnetgenerator/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,16 @@
"Copyright 2018-2024, East China Normal University; Copyright 2024, DeepModeling"
)

import matplotlib as mpl

from ._version import __version__

mpl.use("svg")

from .reacnetgen import ReacNetGenerator
class ReacNetGenerator:
"""Factory class for :class:`reacnetgenerator.reacnetgen.ReacNetGenerator`."""

def __new__(cls, *args, **kwargs):
"""Create a new ReacNetGenerator instance."""
from .reacnetgen import ReacNetGenerator as RealRNG
return RealRNG(*args, **kwargs)


__all__ = ["ReacNetGenerator", "__version__"]
4 changes: 2 additions & 2 deletions reacnetgenerator/commandline.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
from typing import List

from . import __version__
from ._detect import _Detect


def main_parser() -> argparse.ArgumentParser:
Expand Down Expand Up @@ -62,7 +61,8 @@ def main_parser() -> argparse.ArgumentParser:
"--type",
"-t",
help="Input file type",
choices=list(_Detect.subclasses.keys()),
# manual ensure consistent
choices=["bond", "lammpsbondfile", "dump", "lammpsdumpfile", "xyz"],
default="lammpsbondfile",
)
parser.add_argument("--nopbc", help="Disable PBC.", action="store_true")
Expand Down

0 comments on commit 75b175a

Please sign in to comment.