Skip to content

Commit fd0d1aa

Browse files
authored
Doc: Cleanup / fixup (#53)
* Doc: Intersphinx and source references * some docstring fixes * fix some more * sphinx-autodoc-typehints * Revert "sphinx-autodoc-typehints" This reverts commit 997f07f.
1 parent eb893c6 commit fd0d1aa

File tree

8 files changed

+52
-37
lines changed

8 files changed

+52
-37
lines changed

doc/conf.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,21 @@
3939
extensions = [
4040
'sphinx.ext.napoleon',
4141
'sphinx.ext.autodoc',
42-
'recommonmark',
4342
'sphinx.ext.autosummary',
43+
'sphinx.ext.intersphinx',
44+
'sphinx.ext.viewcode',
45+
'recommonmark',
4446
'sphinx_markdown_tables',
4547
'nbsphinx',
4648
]
4749

50+
intersphinx_mapping = {
51+
'pandas': ('https://pandas.pydata.org/docs/', None),
52+
'numpy': ('https://numpy.org/devdocs/', None),
53+
'sympy': ('https://docs.sympy.org/latest/', None),
54+
'python': ('https://docs.python.org/3', None),
55+
}
56+
4857
# Add any paths that contain templates here, relative to this directory.
4958
templates_path = ['_templates']
5059

petab/composite_problem.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class CompositeProblem:
1515
1616
Attributes:
1717
problems:
18-
List ``petab.Problems``
18+
List of :py:class:`petab.Problem` s
1919
parameter_df:
2020
PEtab parameter DataFrame
2121
"""

petab/conditions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ def create_condition_df(parameter_ids: Iterable[str],
6161
parameter_ids: the columns
6262
condition_ids: the rows
6363
Returns:
64-
A ``pandas.DataFrame`` with empty given rows and columns and all nan
65-
values
64+
A :py:class:`pandas.DataFrame` with empty given rows and columns and
65+
all nan values
6666
"""
6767

6868
condition_ids = [] if condition_ids is None else list(condition_ids)

petab/core.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,8 @@ def unique_preserve_order(seq: Sequence) -> List:
355355
"""Return a list of unique elements in Sequence, keeping only the first
356356
occurrence of each element
357357
358-
seq: Sequence to prune
358+
Parameters:
359+
seq: Sequence to prune
359360
360361
Returns:
361362
List of unique elements in ``seq``

petab/lint.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,7 @@ def assert_parameter_prior_type_is_valid(
448448
parameter_df: PEtab parameter table
449449
450450
Raises:
451-
AssertionError in case of invalid prior
451+
AssertionError: in case of invalid prior
452452
"""
453453
for col in [INITIALIZATION_PRIOR_TYPE, OBJECTIVE_PRIOR_TYPE]:
454454
if col not in parameter_df.columns:
@@ -468,7 +468,7 @@ def assert_parameter_prior_parameters_are_valid(
468468
parameter_df: PEtab parameter table
469469
470470
Raises:
471-
AssertionError in case of invalide prior parameters
471+
AssertionError: in case of invalid prior parameters
472472
"""
473473
prior_type_cols = [INITIALIZATION_PRIOR_TYPE,
474474
OBJECTIVE_PRIOR_TYPE]
@@ -534,7 +534,7 @@ def is_scalar_float(x: Any):
534534
:param x:
535535
input
536536
:return:
537-
True if is or can be converted to number, False otherwise.
537+
``True`` if is or can be converted to number, ``False`` otherwise.
538538
"""
539539
if isinstance(x, numbers.Number):
540540
return True

petab/parameter_mapping.py

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ def get_optimization_to_simulation_parameter_mapping(
4848
Create list of mapping dicts from PEtab-problem to SBML parameters.
4949
5050
Mapping can be performed in parallel. The number of threads is controlled
51-
by the environment variable with the name of petab.ENV_NUM_THREADS.
51+
by the environment variable with the name of
52+
:py:data:`petab.ENV_NUM_THREADS`.
5253
5354
Parameters:
5455
condition_df, measurement_df, parameter_df, observable_df:
@@ -78,9 +79,9 @@ def get_optimization_to_simulation_parameter_mapping(
7879
Parameter value and parameter scale mapping for all conditions.
7980
8081
The length of the returned array is the number of unique combinations
81-
of ``simulationConditionId``s and ``preequilibrationConditionId``s from
82-
the measurement table. Each entry is a tuple of four dicts of length
83-
equal to the number of model parameters.
82+
of ``simulationConditionId`` s and ``preequilibrationConditionId`` s
83+
from the measurement table. Each entry is a tuple of four dicts of
84+
length equal to the number of model parameters.
8485
The first two dicts map simulation parameter IDs to optimization
8586
parameter IDs or values (where values are fixed) for preequilibration
8687
and simulation condition, respectively.
@@ -160,7 +161,9 @@ def _map_condition_arg_packer(
160161
def _map_condition(packed_args):
161162
"""Helper function for parallel condition mapping.
162163
163-
For arguments see get_optimization_to_simulation_parameter_mapping"""
164+
For arguments see
165+
:py:func:`get_optimization_to_simulation_parameter_mapping`.
166+
"""
164167

165168
(condition, measurement_df, condition_df, parameter_df, sbml_model,
166169
simulation_parameters, warn_unmapped, scaled_parameters,
@@ -264,7 +267,7 @@ def get_parameter_mapping_for_condition(
264267
to mapped parameters IDs to be estimated or to filled-in values in case
265268
of non-estimated parameters.
266269
Second dictionary mapping model parameter IDs to their scale.
267-
NaN is used where no mapping exists.
270+
``NaN`` is used where no mapping exists.
268271
"""
269272
_perform_mapping_checks(
270273
cur_measurement_df,
@@ -323,7 +326,7 @@ def _apply_output_parameter_overrides(
323326
324327
Arguments:
325328
mapping: parameter mapping dict as obtained from
326-
``get_parameter_mapping_for_condition``
329+
:py:func:`get_parameter_mapping_for_condition`.
327330
cur_measurement_df:
328331
Subset of the measurement table for the current condition
329332
"""
@@ -376,7 +379,7 @@ def _apply_condition_parameters(par_mapping: ParMappingDict,
376379
table parameter values (in-place).
377380
378381
Arguments:
379-
par_mapping: see get_parameter_mapping_for_condition
382+
par_mapping: see :py:func:`get_parameter_mapping_for_condition`
380383
condition_id: ID of condition to work on
381384
condition_df: PEtab condition table
382385
"""
@@ -410,7 +413,8 @@ def _apply_parameter_table(par_mapping: ParMappingDict,
410413
411414
Arguments:
412415
par_mapping:
413-
mapping dict obtained from ``get_parameter_mapping_for_condition``
416+
mapping dict obtained from
417+
:py:func:`get_parameter_mapping_for_condition`
414418
parameter_df:
415419
PEtab parameter table
416420
"""
@@ -495,7 +499,7 @@ def handle_missing_overrides(mapping_par_opt_to_par_sim: ParMappingDict,
495499
496500
Parameters:
497501
mapping_par_opt_to_par_sim:
498-
Output of get_parameter_mapping_for_condition
502+
Output of :py:func:`get_parameter_mapping_for_condition`
499503
warn:
500504
If True, log warning regarding unmapped parameters
501505
condition_id:
@@ -538,10 +542,10 @@ def merge_preeq_and_sim_pars_condition(
538542
Arguments:
539543
condition_map_preeq, condition_map_sim:
540544
Parameter mapping as obtained from
541-
`get_parameter_mapping_for_condition`
545+
:py:func:`get_parameter_mapping_for_condition`
542546
condition_scale_map_preeq, condition_scale_map_sim:
543547
Parameter scale mapping as obtained from
544-
`get_get_scale_mapping_for_condition`
548+
:py:func:`get_parameter_mapping_for_condition`
545549
condition: Condition identifier for more informative error messages
546550
"""
547551
if not condition_map_preeq:
@@ -610,9 +614,10 @@ def merge_preeq_and_sim_pars(
610614
Parameters:
611615
parameter_mappings:
612616
As returned by
613-
petab.get_optimization_to_simulation_parameter_mapping
617+
:py:func:`petab.get_optimization_to_simulation_parameter_mapping`.
614618
scale_mappings:
615-
As returned by petab.get_optimization_to_simulation_scale_mapping.
619+
As returned by
620+
:py:func:`petab.get_optimization_to_simulation_parameter_mapping`.
616621
617622
Returns:
618623
The parameter and scale simulation mappings, modified and checked.

petab/parameters.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -364,8 +364,7 @@ def scale(parameter: numbers.Number, scale_str: 'str') -> numbers.Number:
364364
One of 'lin' (synonymous with ''), 'log', 'log10'.
365365
366366
Returns:
367-
parameter:
368-
The scaled parameter.
367+
The scaled parameter.
369368
"""
370369

371370
if scale_str == LIN or not scale_str:
@@ -387,8 +386,7 @@ def unscale(parameter: numbers.Number, scale_str: 'str') -> numbers.Number:
387386
One of 'lin' (synonymous with ''), 'log', 'log10'.
388387
389388
Returns:
390-
parameter:
391-
The unscaled parameter.
389+
The unscaled parameter.
392390
"""
393391

394392
if scale_str == LIN or not scale_str:

petab/problem.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -233,13 +233,13 @@ def from_folder(folder: str, model_name: str = None) -> 'Problem':
233233
def from_combine(filename: str) -> 'Problem':
234234
"""Read PEtab COMBINE archive (http://co.mbine.org/documents/archive).
235235
236-
See also ``create_combine_archive``.
236+
See also :py:func:`petab.create_combine_archive`.
237237
238238
Arguments:
239239
filename: Path to the PEtab-COMBINE archive
240240
241241
Returns:
242-
A ``petab.Problem`` instance.
242+
A :py:class:`petab.Problem` instance.
243243
"""
244244
# function-level import, because module-level import interfered with
245245
# other SWIG interfaces
@@ -291,8 +291,8 @@ def to_files(self,
291291
yaml_file: YAML file destination
292292
293293
Raises:
294-
ValueError: If a destination was provided for a non-existing
295-
entity.
294+
ValueError:
295+
If a destination was provided for a non-existing entity.
296296
"""
297297

298298
if sbml_file:
@@ -350,26 +350,27 @@ def get_optimization_parameters(self):
350350
"""
351351
Return list of optimization parameter IDs.
352352
353-
See ``petab.parameters.get_optimization_parameters``.
353+
See :py:func:`petab.parameters.get_optimization_parameters`.
354354
"""
355355
return parameters.get_optimization_parameters(self.parameter_df)
356356

357357
def get_optimization_parameter_scales(self):
358358
"""
359359
Return list of optimization parameter scaling strings.
360360
361-
See ``petab.parameters.get_optimization_parameters``.
361+
See :py:func:`petab.parameters.get_optimization_parameters`.
362362
"""
363363
return parameters.get_optimization_parameter_scaling(self.parameter_df)
364364

365365
def get_model_parameters(self):
366-
"""See `petab.sbml.get_model_parameters`"""
366+
"""See :py:func:`petab.sbml.get_model_parameters`"""
367367
return sbml.get_model_parameters(self.sbml_model)
368368

369369
def get_observables(self, remove: bool = False):
370370
"""
371371
Returns dictionary of observables definitions.
372-
See `assignment_rules_to_dict` for details.
372+
373+
See :py:func:`petab.assignment_rules_to_dict` for details.
373374
"""
374375
warn("This function will be removed in future releases.",
375376
DeprecationWarning)
@@ -386,6 +387,7 @@ def get_sigmas(self, remove: bool = False):
386387
"""
387388
Return dictionary of observableId => sigma as defined in the SBML
388389
model.
390+
389391
This does not include parameter mappings defined in the measurement
390392
table.
391393
"""
@@ -396,7 +398,7 @@ def get_sigmas(self, remove: bool = False):
396398

397399
def get_noise_distributions(self):
398400
"""
399-
See `get_noise_distributions`.
401+
See :py:func:`petab.get_noise_distributions`.
400402
"""
401403
return measurements.get_noise_distributions(
402404
measurement_df=self.measurement_df)
@@ -633,7 +635,7 @@ def get_optimization_to_simulation_parameter_mapping(
633635
def create_parameter_df(self, *args, **kwargs):
634636
"""Create a new PEtab parameter table
635637
636-
See create_parameter_df
638+
See :py:func:`create_parameter_df`.
637639
"""
638640
return parameters.create_parameter_df(
639641
self.sbml_model,
@@ -645,7 +647,7 @@ def create_parameter_df(self, *args, **kwargs):
645647
def sample_parameter_startpoints(self, n_starts: int = 100):
646648
"""Create starting points for optimization
647649
648-
See sample_parameter_startpoints
650+
See :py:func:`petab.sample_parameter_startpoints`.
649651
"""
650652
return sampling.sample_parameter_startpoints(
651653
self.parameter_df, n_starts=n_starts)

0 commit comments

Comments
 (0)