PotentialSampler¶
- class discO.core.sample.PotentialSampler(potential: Any, *, total_mass: Quantity | None = None, representation_type: BaseRepresentation | str | None | ellipsis = None, key: module | str | None = None, **other)[source]¶
Bases:
CommonBase
Sample a Potential.
- Parameters:
- potential
PotentialWrapper
The potential object. Must have a frame.
- total_mass
Quantity
orNone
(optional) The total mass of the potential. Necessary if the mass is divergent, must be None otherwise.
- representation_type: |Representation| or None (optional, keyword-only)
The coordinate representation in which to return samples. If None (default) uses representation type from
potential
.- **defaults
default arguments for sampling parameters. In
run
, parameters with defaultNone
will draw from these defaults.
- potential
- Returns:
PotentialSampler
or subclassIf
key
is not None, returns subclass.
- Other Parameters:
- Raises:
ValueError
If directly instantiating a PotentialSampler (not subclass) and cannot find the appropriate subclass, identified using
key
.If the total mass of the potential is divergent and
total_mass
is None.
TypeError
If
potential
is notPotentialWrapper
Attributes Summary
The frame of the data.
The potential, wrapped.
The representation type of the data.
Methods Summary
__call__
([n, representation_type, random])Sample.
run
([n, iterations, representation_type, ...])Iteratively sample the potential.
Attributes Documentation
- frame¶
The frame of the data. Can be None.
- potential¶
The potential, wrapped.
- representation_type¶
The representation type of the data. Can be None.
Methods Documentation
- abstract __call__(n: int = 1, *, representation_type: BaseRepresentation | str | None | ellipsis = None, random: int | RandomState | None = None, **kwargs) SkyCoord [source]¶
Sample.
- run(n: int = 1, iterations: int = 1, *, representation_type: BaseRepresentation | str | None | ellipsis = None, random: int | RandomState | None = None, batch: bool = False, progress: bool = True, **kwargs) SkyCoord [source]¶
Iteratively sample the potential.
- Parameters:
- n
int
(optional) Number of sample points.
- iterations
int
(optional) Number of iterations. Must be > 0.
- representation_type: |Representation| or None (optional, keyword-only)
The coordinate representation.
- random
int
orRandomState
orNone
(optional, keyword-only) Random state or seed.
- progressbool (optional, keyword-only)
If True, a progress bar will be shown as the sampler progresses. If a string, will select a specific tqdm progress bar - most notable is ‘notebook’, which shows a progress bar suitable for Jupyter notebooks. If False, no progress bar will be shown.
- **kwargs
Passed to underlying instance
- n
- Yields:
SkyCoord
If
sequential
is False. The shape of the SkyCoord is(n, niter)
where a scalarn
has length 1.
- Raises:
ValueError
If number if iterations not greater than 0.