diff --git a/README.md b/README.md index 501bad9..0f34b38 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ Pydiffuser is a numerical simulation framework for nonequilibrium statistical ph This package mainly aims: - to share code to implement a numerical simulation on physical models written in various forms of [stochastic differential equations](https://en.wikipedia.org/wiki/Stochastic_differential_equation). -- to revisit recent research highlights in non-equilibrium statistical physics. +- to revisit recent research highlights in nonequilibrium statistical physics. - to reduce the repeated code on time-series data analysis, e.g., statistical analysis of [single-particle trajectory](https://en.wikipedia.org/wiki/Single-particle_trajectory) for [SPT](https://en.wikipedia.org/wiki/Single-particle_tracking) experiments. - to provide the skeleton of stochastic modeling for anyone interested in stochastic processes. @@ -75,7 +75,7 @@ It is obtained by `matplotlib.pyplot.plot(tracer.position_x1, tracer.position_x2 List all stochastic models supported by Pydiffuser. ```console -$ pydiffuser list +$ pydiffuser model list NAME MODEL CONFIG DIMENSION abp ActiveBrownianParticle ActiveBrownianParticleConfig 2d aoup ActiveOUParticle ActiveOUParticleConfig 1d, 2d, 3d diff --git a/pydiffuser/_cli/cli.py b/pydiffuser/_cli/cli.py index 25f1d11..bb01ced 100644 --- a/pydiffuser/_cli/cli.py +++ b/pydiffuser/_cli/cli.py @@ -1,21 +1,15 @@ import click -from pydiffuser._cli.cli_utils import get_model_info +from pydiffuser._cli.cli_utils import add_model_subcommands def create(): @click.group() @click.version_option() def pydiffuser_cli(): - """Pydiffuser CLI""" + """Pydiffuser CLI.""" - @pydiffuser_cli.command() - def list(): - """List all models defined in Pydiffuser.""" - - info = get_model_info() - for name, model, config, dimension in info: - click.echo(f"{name:16}{model:32}{config:32}{dimension:16}") + add_model_subcommands(pydiffuser_cli) return pydiffuser_cli diff --git a/pydiffuser/_cli/cli_utils.py b/pydiffuser/_cli/cli_utils.py index 99801a6..9effddb 100644 --- a/pydiffuser/_cli/cli_utils.py +++ b/pydiffuser/_cli/cli_utils.py @@ -1,3 +1,5 @@ +import click + from pydiffuser.models import CONFIG_REGISTRY, MODEL_REGISTRY @@ -17,3 +19,17 @@ def get_model_info(): for k, dim in dims.items() ] return info + + +def add_model_subcommands(cli: click.Group) -> None: + @cli.group(name="model") + def model_cli(): + """Subcommands related to model.""" + + @model_cli.command() + def list(): + """List all models defined in Pydiffuser.""" + + info = get_model_info() # type: ignore[no-untyped-call] + for name, model, config, dimension in info: + click.echo(f"{name:16}{model:32}{config:32}{dimension:16}") diff --git a/pydiffuser/mech/fields.py b/pydiffuser/mech/fields.py index b22c959..efefe20 100644 --- a/pydiffuser/mech/fields.py +++ b/pydiffuser/mech/fields.py @@ -15,7 +15,7 @@ def register(potential: Any) -> Any: def decorator() -> Any: if not isinstance(potential, PjitFunction): raise RuntimeError( - "Potential must be transformed via 'jax.jit' to register" + "Potential must be transformed via `jax.jit` to register" ) FIELD_REGISTRY[f"{potential.__name__}"] = potential return potential