Skip to content

Commit 2f35636

Browse files
authored
DOC: Minor updates to docstrings (#125)
* Fixes incorrect usage of `(optional)` instead of `, optional` for optional parameters in function/method docstrings * Updates docstrings with `key` parameter to correctly list them as an `optional` parameter * Updates function, method, and class references to use their correct tag (i.e. `:func:` for functions, `:class:` for classes) instead of using `:meth:`
1 parent f7bbaf8 commit 2f35636

File tree

7 files changed

+110
-111
lines changed

7 files changed

+110
-111
lines changed

kda/calculations.py

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -109,23 +109,23 @@ def calc_sigma(G, dir_edges=None, key="name", output_strings=True, **kwargs):
109109
----------
110110
G : ``NetworkX.MultiDiGraph``
111111
A kinetic diagram
112-
dir_edges : ndarray (optional)
112+
dir_edges : ndarray, optional
113113
Array of all directional diagram edges (made from 2-tuples)
114114
for the input diagram ``G``. Created using
115-
:meth:`~kda.diagrams.generate_directional_diagrams`
115+
:func:`~kda.diagrams.generate_directional_diagrams`
116116
with ``return_edges=True``.
117-
key : str (optional)
117+
key : str, optional
118118
Attribute key used to retrieve edge data from ``G.edges``. The default
119119
``NetworkX`` edge key is ``"weight"``, however the ``kda`` edge keys
120120
are ``"name"`` (for rate constant names, e.g. ``"k12"``) and ``"val"``
121121
(for the rate constant values, e.g. ``100``). Default is ``"name"``.
122-
output_strings : bool (optional)
122+
output_strings : bool, optional
123123
Used to denote whether values or strings will be combined. Default
124124
is ``False``, which tells the function to calculate the normalization
125125
factor using numbers. If ``True``, this will assume the input
126126
``'key'`` will return strings of variable names to join into the
127127
analytic cycle flux function.
128-
kwargs : dict (optional)
128+
kwargs : dict, optional
129129
Additional keyword arguments. Note that the alias
130130
``dirpar_edges`` is deprecated; please use ``dir_edges``.
131131
@@ -228,13 +228,13 @@ def calc_sigma_K(G, cycle, flux_diags, key="name", output_strings=True):
228228
indices does not matter but should not contain all nodes.
229229
flux_diags : list
230230
List of relevant directional flux diagrams for input cycle.
231-
key : str
231+
key : str, optional
232232
Attribute key used to retrieve edge data from ``G.edges``. The default
233233
``NetworkX`` edge key is ``"weight"``, however the ``kda`` edge keys
234234
are ``"name"`` (for rate constant names, e.g. ``"k12"``) and ``"val"``
235235
(for the rate constant values, e.g. ``100``). Default is ``"name"``.
236236
Default is ``"name"``.
237-
output_strings : bool (optional)
237+
output_strings : bool, optional
238238
Used to denote whether values or strings will be combined. Default
239239
is ``False``, which tells the function to calculate the sum of all
240240
directional flux diagrams using numbers. If ``True``, this will assume
@@ -325,18 +325,18 @@ def calc_pi_difference(G, cycle, order, key="name",
325325
List of integers of length 2 (e.g. ``[0, 1]``), where the integers are
326326
nodes in ``cycle``. The pair of nodes should be ordered such that
327327
a counter-clockwise path is followed.
328-
key : str
328+
key : str, optional
329329
Attribute key used to retrieve edge data from ``G.edges``. The default
330330
``NetworkX`` edge key is ``"weight"``, however the ``kda`` edge keys
331331
are ``"name"`` (for rate constant names, e.g. ``"k12"``) and ``"val"``
332332
(for the rate constant values, e.g. ``100``). Default is ``"name"``.
333-
output_strings : bool (optional)
333+
output_strings : bool, optional
334334
Used to denote whether values or strings will be combined. Default
335335
is ``False``, which tells the function to calculate the difference
336336
using numbers. If ``True``, this will assume the input ``'key'``
337337
will return strings of variable names to join into the analytic
338338
function.
339-
net : bool (optional)
339+
net : bool, optional
340340
Used to determine whether to return the forward cycle product
341341
(i.e., ``net=False``) or the difference of the forward and reverse
342342
cycle products (i.e., ``net=True``). Default is ``True``.
@@ -418,13 +418,13 @@ def calc_thermo_force(G, cycle, order, key="name", output_strings=True):
418418
List of integers of length 2 (e.g. ``[0, 1]``), where the integers are
419419
nodes in ``cycle``. The pair of nodes should be ordered such that
420420
a counter-clockwise path is followed.
421-
key : str
421+
key : str, optional
422422
Attribute key used to retrieve edge data from ``G.edges``. The default
423423
``NetworkX`` edge key is ``"weight"``, however the ``kda`` edge keys
424424
are ``"name"`` (for rate constant names, e.g. ``"k12"``) and ``"val"``
425425
(for the rate constant values, e.g. ``100``). Default is ``"name"``.
426426
Default is ``"name"``.
427-
output_strings : bool (optional)
427+
output_strings : bool, optional
428428
Used to denote whether values or strings will be combined. Default
429429
is ``False``, which tells the function to calculate the thermodynamic
430430
force using numbers. If ``True``, this will assume the input
@@ -499,21 +499,21 @@ def calc_state_probs(G, key="name", output_strings=True, dir_edges=None):
499499
----------
500500
G : ``NetworkX.MultiDiGraph``
501501
A kinetic diagram
502-
key : str
502+
key : str, optional
503503
Attribute key used to retrieve edge data from ``G.edges``. The default
504504
``NetworkX`` edge key is ``"weight"``, however the ``kda`` edge keys
505505
are ``"name"`` (for rate constant names, e.g. ``"k12"``) and ``"val"``
506506
(for the rate constant values, e.g. ``100``). Default is ``"name"``.
507-
output_strings : bool (optional)
507+
output_strings : bool, optional
508508
Used to denote whether values or strings will be combined. Default
509509
is ``False``, which tells the function to calculate the state
510510
probabilities using numbers. If ``True``, this will assume the input
511511
``'key'`` will return strings of variable names to join into the
512512
analytic state multplicity and normalization function.
513-
dir_edges : ndarray (optional)
513+
dir_edges : ndarray, optional
514514
Array of all directional diagram edges (made from 2-tuples)
515515
for the input diagram ``G``. Created using
516-
:meth:`~kda.diagrams.generate_directional_diagrams`
516+
:func:`~kda.diagrams.generate_directional_diagrams`
517517
with ``return_edges=True``.
518518
519519
Returns
@@ -613,25 +613,25 @@ def calc_cycle_flux(G, cycle, order, key="name",
613613
List of integers of length 2 (e.g. ``[0, 1]``), where the integers are
614614
nodes in ``cycle``. The pair of nodes should be ordered such that
615615
a counter-clockwise path is followed.
616-
key : str
616+
key : str, optional
617617
Attribute key used to retrieve edge data from ``G.edges``. The default
618618
``NetworkX`` edge key is ``"weight"``, however the ``kda`` edge keys
619619
are ``"name"`` (for rate constant names, e.g. ``"k12"``) and ``"val"``
620620
(for the rate constant values, e.g. ``100``). Default is ``"name"``.
621-
output_strings : bool (optional)
621+
output_strings : bool, optional
622622
Used to denote whether values or strings will be combined. Default
623623
is ``False``, which tells the function to calculate the cycle flux
624624
using numbers. If ``True``, this will assume the input ``'key'``
625625
will return strings of variable names to join into the analytic
626626
cycle flux function.
627-
dir_edges : ndarray (optional)
627+
dir_edges : ndarray, optional
628628
Array of all directional diagram edges (made from 2-tuples)
629629
for the input diagram ``G``. Given as an option for performance reasons
630630
(when calculating net cycle fluxes for multiple cycles it is best to
631631
generate the directional diagram edges up front and provide them).
632-
Created using :meth:`~kda.diagrams.generate_directional_diagrams`
632+
Created using :func:`~kda.diagrams.generate_directional_diagrams`
633633
with ``return_edges=True``.
634-
net : bool (optional)
634+
net : bool, optional
635635
Used to determine whether to return the one-way or net cycle flux.
636636
Default is ``True`` (i.e., to generate the net cycle flux).
637637
@@ -700,24 +700,24 @@ def calc_net_cycle_flux(G, cycle, order, key="name",
700700
List of integers of length 2 (e.g. ``[0, 1]``), where the integers are
701701
nodes in ``cycle``. The pair of nodes should be ordered such that
702702
a counter-clockwise path is followed.
703-
key : str (optional)
703+
key : str, optional
704704
Attribute key used to retrieve edge data from ``G.edges``. The default
705705
``NetworkX`` edge key is ``"weight"``, however the ``kda`` edge keys
706706
are ``"name"`` (for rate constant names, e.g. ``"k12"``) and ``"val"``
707707
(for the rate constant values, e.g. ``100``). Default is ``"name"``.
708708
Default is ``"name"``.
709-
output_strings : bool (optional)
709+
output_strings : bool, optional
710710
Used to denote whether values or strings will be combined. Default
711711
is ``False``, which tells the function to calculate the cycle flux
712712
using numbers. If ``True``, this will assume the input ``'key'``
713713
will return strings of variable names to join into the analytic
714714
cycle flux function.
715-
dir_edges : ndarray (optional)
715+
dir_edges : ndarray, optional
716716
Array of all directional diagram edges (made from 2-tuples)
717717
for the input diagram ``G``. Given as an option for performance reasons
718718
(when calculating net cycle fluxes for multiple cycles it is best to
719719
generate the directional diagram edges up front and provide them).
720-
Created using :meth:`~kda.diagrams.generate_directional_diagrams`
720+
Created using :func:`~kda.diagrams.generate_directional_diagrams`
721721
with ``return_edges=True``.
722722
723723
Returns
@@ -764,7 +764,7 @@ def calc_state_probs_from_diags(
764764
method developed by King and Altman :footcite:`king_schematic_1956` and
765765
Hill :footcite:`hill_studies_1966`. If directional diagram edges are already
766766
generated this offers better performance than
767-
:meth:`~kda.calculations.calc_state_probs`.
767+
:func:`~kda.calculations.calc_state_probs`.
768768
769769
.. deprecated:: 0.3.0
770770
``calc_state_probs_from_diags`` is deprecated and will be removed in
@@ -775,23 +775,23 @@ def calc_state_probs_from_diags(
775775
----------
776776
G : ``NetworkX.MultiDiGraph``
777777
A kinetic diagram
778-
dir_edges : array (optional)
778+
dir_edges : array, optional
779779
Array of all directional diagram edges (made from 2-tuples)
780780
for the input diagram ``G``. Created using
781-
:meth:`~kda.diagrams.generate_directional_diagrams`
781+
:func:`~kda.diagrams.generate_directional_diagrams`
782782
with ``return_edges=True``.
783-
key : str (optional)
783+
key : str, optional
784784
Attribute key used to retrieve edge data from ``G.edges``. The default
785785
``NetworkX`` edge key is ``"weight"``, however the ``kda`` edge keys
786786
are ``"name"`` (for rate constant names, e.g. ``"k12"``) and ``"val"``
787787
(for the rate constant values, e.g. ``100``). Default is ``"name"``.
788-
output_strings : bool (optional)
788+
output_strings : bool, optional
789789
Used to denote whether values or strings will be combined. Default
790790
is ``False``, which tells the function to calculate the state
791791
probabilities using numbers. If ``True``, this will assume the input
792792
``'key'`` will return strings of variable names to join into the
793793
analytic state multplicity and normalization functions.
794-
kwargs : dict (optional)
794+
kwargs : dict, optional
795795
Additional keyword arguments. Note that the alias
796796
``dirpar_edges`` is deprecated; please use ``dir_edges``.
797797
@@ -850,7 +850,7 @@ def calc_net_cycle_flux_from_diags(
850850
"""Generates the expression for the net cycle flux for some ``cycle``
851851
in kinetic diagram ``G``. If directional diagram edges are already
852852
generated this offers better performance than
853-
:meth:`~kda.calculations.calc_cycle_flux`.
853+
:func:`~kda.calculations.calc_cycle_flux`.
854854
855855
.. deprecated:: 0.3.0
856856
``calc_net_cycle_flux_from_diags`` is deprecated and will be removed
@@ -868,23 +868,23 @@ def calc_net_cycle_flux_from_diags(
868868
List of integers of length 2 (e.g. ``[0, 1]``), where the integers are
869869
nodes in ``cycle``. The pair of nodes should be ordered such that
870870
a counter-clockwise path is followed.
871-
dir_edges : ndarray (optional)
871+
dir_edges : ndarray, optional
872872
Array of all directional diagram edges (made from 2-tuples)
873873
for the input diagram ``G``. Created using
874-
:meth:`~kda.diagrams.generate_directional_diagrams`
874+
:func:`~kda.diagrams.generate_directional_diagrams`
875875
with ``return_edges=True``.
876-
key : str (optional)
876+
key : str, optional
877877
Attribute key used to retrieve edge data from ``G.edges``. The default
878878
``NetworkX`` edge key is ``"weight"``, however the ``kda`` edge keys
879879
are ``"name"`` (for rate constant names, e.g. ``"k12"``) and ``"val"``
880880
(for the rate constant values, e.g. ``100``). Default is ``"name"``.
881-
output_strings : bool (optional)
881+
output_strings : bool, optional
882882
Used to denote whether values or strings will be combined. Default
883883
is ``False``, which tells the function to calculate the cycle flux
884884
using numbers. If ``True``, this will assume the input ``'key'``
885885
will return strings of variable names to join into the analytic
886886
cycle flux function.
887-
kwargs : dict (optional)
887+
kwargs : dict, optional
888888
Additional keyword arguments. Note that the alias
889889
``dirpar_edges`` is deprecated; please use ``dir_edges``.
890890

kda/core.py

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -63,13 +63,13 @@ def __init__(self, K=None, G=None):
6363
"""
6464
Parameters
6565
==========
66-
K : ndarray (optional)
66+
K : ndarray, optional
6767
``NxN`` array where ``N`` is the number of nodes in the
6868
diagram ``G``. Adjacency matrix for ``G`` where each element
6969
``kij`` is the edge weight (i.e. transition rate constant).
7070
For example, for a 2-state model with ``k12=3`` and ``k21=4``,
7171
``K=[[0, 3], [4, 0]]``. Default is ``None``.
72-
G : ``NetworkX.MultiDiGraph`` (optional)
72+
G : ``NetworkX.MultiDiGraph``, optional
7373
A kinetic diagram. Default is ``None``.
7474
7575
Raises
@@ -100,30 +100,30 @@ def __init__(self, K=None, G=None):
100100

101101
def build_cycles(self):
102102
"""Builds all cycles from the kinetic diagram using
103-
:meth:`~kda.graph_utils.find_all_unique_cycles()`.
103+
:func:`~kda.graph_utils.find_all_unique_cycles()`.
104104
"""
105105
self.cycles = graph_utils.find_all_unique_cycles(self.G)
106106

107107

108108
def build_partial_diagrams(self):
109109
"""Builds the partial diagrams for the kinetic diagram using
110-
:meth:`~kda.diagrams.generate_partial_diagrams()`.
110+
:func:`~kda.diagrams.generate_partial_diagrams()`.
111111
"""
112112
self.partial_diagrams = diagrams.generate_partial_diagrams(
113113
self.G, return_edges=False)
114114

115115

116116
def build_directional_diagrams(self):
117117
"""Builds the directional diagrams for the kinetic diagram using
118-
:meth:`~kda.diagrams.generate_directional_diagrams()`.
118+
:func:`~kda.diagrams.generate_directional_diagrams()`.
119119
"""
120120
self.directional_diagrams = diagrams.generate_directional_diagrams(
121121
self.G, return_edges=False)
122122

123123

124124
def build_flux_diagrams(self):
125125
"""Builds the flux diagrams for the kinetic diagram using
126-
:meth:`~kda.diagrams.generate_all_flux_diagrams()`.
126+
:func:`~kda.diagrams.generate_all_flux_diagrams()`.
127127
"""
128128
self.flux_diagrams = diagrams.generate_all_flux_diagrams(self.G)
129129

@@ -135,7 +135,7 @@ def get_partial_diagram_count(self):
135135
have already been generated with
136136
:meth:`~kda.core.KineticModel.build_partial_diagrams()`
137137
the count will simply be returned. Otherwise
138-
:meth:`~kda.diagrams.enumerate_partial_diagrams()` is used.
138+
:func:`~kda.diagrams.enumerate_partial_diagrams()` is used.
139139
140140
Returns
141141
=======
@@ -172,7 +172,7 @@ def get_directional_diagram_count(self):
172172
def get_flux_diagrams(self, cycle):
173173
"""
174174
Retrieves the flux diagrams for a specific cycle using
175-
:meth:`~kda.diagrams.generate_flux_diagrams()`.
175+
:func:`~kda.diagrams.generate_flux_diagrams()`.
176176
177177
Parameters
178178
==========
@@ -193,12 +193,12 @@ def get_flux_diagrams(self, cycle):
193193
def build_state_probabilities(self, symbolic=True):
194194
"""
195195
Builds the state probabilities for the kinetic diagram using
196-
:meth:`~kda.calculations.calc_state_probs()`. Probabilities
196+
:func:`~kda.calculations.calc_state_probs()`. Probabilities
197197
can be stored as raw values or symbolic algebraic expressions.
198198
199199
Parameters
200200
==========
201-
symbolic : bool (optional)
201+
symbolic : bool, optional
202202
Used to determine whether raw values or symbolic
203203
expressions will be stored. Default is ``True``.
204204
"""
@@ -228,11 +228,11 @@ def get_transition_flux(self, state_i, state_j, net=True, symbolic=True):
228228
The index (index 1) of the initial state.
229229
state_j : integer
230230
The index (index 1) of the final state.
231-
net : bool (optional)
231+
net : bool, optional
232232
Used to determine whether one-way transition fluxes
233233
or net transition fluxes will be returned. Default
234234
is ``True``.
235-
symbolic : bool (optional)
235+
symbolic : bool, optional
236236
Used to determine whether raw values or symbolic
237237
expressions will be returned. Default is ``True``.
238238
@@ -305,4 +305,3 @@ def get_transition_flux(self, state_i, state_j, net=True, symbolic=True):
305305
return j_ij - j_ji
306306
else:
307307
return j_ij
308-

kda/diagrams.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ def _append_reverse_edges(edge_list):
233233

234234
def _get_cofactor_matrix(K_laplace):
235235
"""
236-
Helper function for :meth:`~kda.diagrams.enumerate_partial_diagrams()`.
236+
Helper function for :func:`~kda.diagrams.enumerate_partial_diagrams()`.
237237
Uses singular value decomposition to get the cofactor matrix for
238238
the input Laplacian matrix.
239239

kda/graph_utils.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,15 @@ def generate_edges(G, vals, names=None, val_key="val", name_key="name"):
6464
the kinetic rate *values* for each transition in ``G``. For example,
6565
assuming we have some values ``k12_val`` and ``k21_val``, for a
6666
2-state diagram ``vals = [[0, k12_val], [k21_val, 0]]``.
67-
names : ndarray (optional)
67+
names : ndarray, optional
6868
``NxN`` array where ``N`` is the number of nodes in ``G``. Contains
6969
the kinetic rate *variable names* (as strings) for each transition
7070
in ``G``. For example, for a 2-state diagram
7171
``names = [[0, "k12"], ["k21", 0]]``.
72-
val_key : str (optional)
72+
val_key : str, optional
7373
Attribute key used to retrieve kinetic rate *values* from the
7474
edge data stored in ``G.edges``. The default is ``"val"``.
75-
name_key : str (optional)
75+
name_key : str, optional
7676
Attribute key used to retrieve kinetic rate *variable names* from
7777
the edge data stored in ``G.edges``. The default is ``"name"``.
7878
"""
@@ -101,7 +101,7 @@ def retrieve_rate_matrix(G, key="val"):
101101
----------
102102
G : ``NetworkX.MultiDiGraph``
103103
A kinetic diagram
104-
key : str
104+
key : str, optional
105105
Attribute key used to retrieve edge data from ``G.edges``. The default
106106
``NetworkX`` edge key is ``"weight"``, however the ``kda`` edge keys
107107
are ``"name"`` (for rate constant names, e.g. ``"k12"``) and ``"val"``
@@ -177,8 +177,8 @@ def _is_ccw(cycle, start, end):
177177
def get_ccw_cycle(cycle, order):
178178
"""
179179
Function used for obtaining the CCW version of an input cycle, primarily
180-
used for :meth:`~kda.calculations.calculate_pi_difference()` and
181-
:meth:`~kda.calculations.calculate_thermo_force()`.
180+
used for :func:`~kda.calculations.calculate_pi_difference()` and
181+
:func:`~kda.calculations.calculate_thermo_force()`.
182182
183183
Parameters
184184
----------

0 commit comments

Comments
 (0)