Skip to content

Commit

Permalink
better module init
Browse files Browse the repository at this point in the history
  • Loading branch information
wcxve committed Mar 2, 2024
1 parent 5940592 commit 46ce257
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 27 deletions.
41 changes: 36 additions & 5 deletions src/elisa/model/__init__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,44 @@
from . import add, conv, model, mul, parameter
from . import add, conv, mul
from .add import * # noqa: F403
from .conv import * # noqa: F403
from .model import * # noqa: F403
from .model import (
AdditiveComponent,
AnaIntAdditive,
AnaIntMultiplicative,
ConvolutionComponent,
MultiplicativeComponent,
NumIntAdditive,
NumIntMultiplicative,
)
from .mul import * # noqa: F403
from .parameter import * # noqa: F403
from .parameter import (
CompositeParameter,
ConstantInterval,
ConstantValue,
Parameter,
ParameterBase,
UniformParameter,
)

__all__ = (
model.__all__
+ parameter.__all__
[
'AdditiveComponent',
'MultiplicativeComponent',
'ConvolutionComponent',
'AnaIntAdditive',
'NumIntAdditive',
'AnaIntMultiplicative',
'NumIntMultiplicative',
]
+ [
'ParameterBase',
'Parameter',
'UniformParameter',
'ConstantValue',
'ConstantInterval',
'CompositeParameter',
# 'GPParameter',
]
+ add.__all__
+ mul.__all__
+ conv.__all__
Expand Down
16 changes: 6 additions & 10 deletions src/elisa/model/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,6 @@
T,
)

__all__ = [
'AdditiveComponent',
'MultiplicativeComponent',
'ConvolutionComponent',
'AnaIntAdditive',
'NumIntAdditive',
'AnaIntMultiplicative',
'NumIntMultiplicative',
]


class ModelBase(metaclass=ABCMeta):
"""Base model class."""
Expand Down Expand Up @@ -583,6 +573,12 @@ def flux(
) -> jax.Array | dict[str, jax.Array]:
r"""Calculate the flux of model between `emin` and `emax`.
Warnings
--------
The flux is calculated by trapzoidal rule, which may not be accurate
if not enough energy bins are used when the difference between
`emin` and emax` is large.
Parameters
----------
emin : float or int
Expand Down
13 changes: 1 addition & 12 deletions src/elisa/model/parameter.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,13 @@
import jax.numpy as jnp
from numpyro.distributions import Distribution, LogUniform, Uniform

# from tinygp import kernels, means, noise
from elisa.util.integrate import (
AdaptQuadMethod,
IntegralFactory,
make_integral_factory,
)
from elisa.util.misc import build_namespace

# from tinygp import kernels, means, noise
from elisa.util.typing import (
CompID,
CompParamName,
Expand All @@ -26,16 +25,6 @@
ParamIDValMapping,
)

__all__ = [
'ParameterBase',
'Parameter',
'UniformParameter',
'ConstantValue',
'ConstantInterval',
'CompositeParameter',
# 'GPParameter',
]


class AssignmentTracker:
"""Track component assignment of a parameter."""
Expand Down

0 comments on commit 46ce257

Please sign in to comment.