Skip to content

Commit

Permalink
add docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
jvshields committed Apr 3, 2024
1 parent 7d6f26d commit 5d8eec9
Showing 1 changed file with 47 additions and 1 deletion.
48 changes: 47 additions & 1 deletion stardis/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,28 @@ def run_stardis(config_fname, tracing_lambdas_or_nus):


def set_num_threads(n_threads):
# Set multithreading as specified by the config
"""
Set the number of threads for multithreading.
This function sets the number of threads to be used for multithreading based on the
input argument `n_threads`. It uses Numba's `set_num_threads` function to set the
number of threads.
Parameters
----------
n_threads : int
The number of threads to use. If `n_threads` is 1, the function will run in
serial mode. If `n_threads` is -99, the function will run with the maximum
number of available threads. If `n_threads` is greater than 1, the function
will run with `n_threads` threads.
Raises
------
ValueError
If `n_threads` is not a positive integer less than the number of available
threads, and it's not -99.
"""
if n_threads == 1:
logging.info("Running in serial mode")
elif n_threads == -99:

Check warning on line 73 in stardis/base.py

View check run for this annotation

Codecov / codecov/patch

stardis/base.py#L73

Added line #L73 was not covered by tests
Expand All @@ -61,6 +82,31 @@ def set_num_threads(n_threads):


def create_stellar_radiation_field(tracing_nus, stellar_model, stellar_plasma, config):
"""
Create a stellar radiation field.
This function creates a stellar radiation field by initializing a `RadiationField`
object and calculating the alpha values for the stellar plasma. It then performs
raytracing on the stellar model.
Parameters
----------
tracing_nus : array
The frequencies at which to trace the radiation field.
stellar_model : StellarModel
The stellar model to use for the radiation field.
stellar_plasma : StellarPlasma
The stellar plasma to use for the radiation field.
config : Config
The configuration object containing the opacity and threading settings.
Returns
-------
stellar_radiation_field : RadiationField
The created stellar radiation field.
"""

stellar_radiation_field = RadiationField(
tracing_nus, blackbody_flux_at_nu, stellar_model
)
Expand Down

0 comments on commit 5d8eec9

Please sign in to comment.