Skip to content

Commit

Permalink
Fix numpydoc lints
Browse files Browse the repository at this point in the history
  • Loading branch information
padix-key committed Feb 22, 2025
1 parent 5eb181c commit 3379953
Show file tree
Hide file tree
Showing 12 changed files with 110 additions and 98 deletions.
9 changes: 6 additions & 3 deletions src/biotite/structure/io/trajfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,9 @@ def read_iter(
See Also
--------
read_iter_structure
read_iter_structure :
Get an :class:`AtomArray` for each frame or an :class:`AtomArrayStack`
for each chunk of frames instead.
Notes
-----
Expand Down Expand Up @@ -317,7 +319,8 @@ def read_iter_structure(
See Also
--------
read_iter
read_iter :
Get an the raw data for each frame or for each chunk of frames instead.
Notes
-----
Expand Down Expand Up @@ -480,7 +483,7 @@ def set_box(self, box):
Parameters
----------
time : ndarray, dtype=float, shape=(m,3,3)
box : ndarray, dtype=float, shape=(m,3,3)
The box vectors to be set.
"""
self._check_model_count(box)
Expand Down
1 change: 0 additions & 1 deletion src/biotite/structure/mechanics.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ def gyration_radius(array, masses=None):
Must have the same length as `array`. By default, the standard
atomic mass for each element is taken.
Returns
-------
masses : float or ndarray, dtype=float
Expand Down
15 changes: 0 additions & 15 deletions src/biotite/structure/molecules.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,6 @@ def get_molecule_indices(array):
Consequently, the length of this list is equal to the number of
molecules in the input `array`.
See Also
--------
get_molecule_masks
molecule_iter
Examples
--------
Get an :class:`AtomArray` for ATP and show that it is a single
Expand Down Expand Up @@ -157,11 +152,6 @@ def get_molecule_masks(array):
Consequently, the length of this list is equal to the number of
molecules in the input `array`.
See Also
--------
get_molecule_indices
molecule_iter
Examples
--------
Get an :class:`AtomArray` for ATP and show that it is a single
Expand Down Expand Up @@ -270,11 +260,6 @@ def molecule_iter(array):
molecule : AtomArray or AtomArrayStack
A single molecule of the input `array`.
See Also
--------
get_molecule_indices
get_molecule_masks
Examples
--------
Get an :class:`AtomArray` for ATP and break it into two molecules
Expand Down
20 changes: 7 additions & 13 deletions src/biotite/structure/pseudoknots.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ def pseudoknots(base_pairs, scores=None, max_pseudoknot_order=None):
Therefore, there are no pseudoknots between base pairs with the same
pseudoknot order.
References
----------
.. footbibliography::
Examples
--------
Remove the pseudoknotted base pair for the sequence *ABCbac*, where
Expand Down Expand Up @@ -102,17 +107,6 @@ def pseudoknots(base_pairs, scores=None, max_pseudoknot_order=None):
[[0 0 1]]
>>> print(dot_bracket(basepairs, 6)[0])
(([))]
See Also
--------
base_pairs
dot_bracket
References
----------
.. footbibliography::
"""
if len(base_pairs) == 0:
# No base pairs -> empty pseudoknot order array
Expand Down Expand Up @@ -149,9 +143,9 @@ class _Region:
Parameters
----------
base_pairs: ndarray, shape=(n,2), dtype=int
base_pairs : ndarray, shape=(n,2), dtype=int
All base pairs of the structure the region is a subset for.
region_pairs: ndarray, dtype=int
region_pairs : ndarray, dtype=int
The indices of the base pairs in ``base_pairs`` that are part of
the region.
scores : ndarray, dtype=int, shape=(n,) (default: None)
Expand Down
6 changes: 2 additions & 4 deletions src/biotite/structure/repair.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ def create_continuous_res_ids(atoms, restart_each_chain=True):
>>> res_ids, _ = get_residues(atom_array)
>>> print(res_ids)
[ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19]
"""
res_ids_diff = np.zeros(atoms.array_length(), dtype=int)
res_starts = get_residue_starts(atoms)
Expand Down Expand Up @@ -80,7 +79,7 @@ def infer_elements(atoms):
See Also
--------
create_atoms_names : The opposite of this function
create_atoms_names : The opposite of this function.
Examples
--------
Expand All @@ -89,7 +88,6 @@ def infer_elements(atoms):
['N' 'C' 'C' 'O' 'C' 'C' 'O' 'N' 'H' 'H']
>>> print(infer_elements(["CA", "C", "C1", "OD1", "HD21", "1H", "FE"]))
['C' 'C' 'C' 'O' 'H' 'H' 'FE']
"""
if isinstance(atoms, (AtomArray, AtomArrayStack)):
atom_names = atoms.atom_name
Expand Down Expand Up @@ -117,7 +115,7 @@ def create_atom_names(atoms):
See Also
--------
infer_elements : The opposite of this function
infer_elements : The opposite of this function.
Notes
-----
Expand Down
34 changes: 10 additions & 24 deletions src/biotite/structure/residues.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,8 @@ def apply_residue_wise(array, data, function, axis=None):
Returns
-------
processed_data : ndarray
Residue-wise evaluation of `data` by `function`. The size of the
first dimension of this array is equal to the amount of
residues.
Residue-wise evaluation of `data` by `function`. The size of the first dimension
of this array is equal to the amount of residues.
Examples
--------
Expand Down Expand Up @@ -196,14 +195,15 @@ def spread_residue_wise(array, input_data):
array : AtomArray or AtomArrayStack
The atom array (stack) to determine the residues from.
input_data : ndarray
The data to be spread. The length of axis=0 must be equal to
the amount of different residue IDs in `array`.
The data to be spread.
The length of the 0-th axis must be equal to the amount of different residue IDs
in `array`.
Returns
-------
output_data : ndarray
Residue-wise spread `input_data`. Length is the same as
`array_length()` of `array`.
Residue-wise spread `input_data`.
Length is the same as `array_length()` of `array`.
Examples
--------
Expand Down Expand Up @@ -263,11 +263,6 @@ def get_residue_masks(array, indices):
Each array masks the atoms that belong to the same residue as
the atom at the given index.
See Also
--------
get_residue_starts_for
get_residue_positions
Examples
--------
Expand Down Expand Up @@ -341,11 +336,6 @@ def get_residue_starts_for(array, indices):
The indices that point to the residue starts for the input
`indices`.
See Also
--------
get_residue_masks
get_residue_positions
Examples
--------
Expand Down Expand Up @@ -385,14 +375,9 @@ def get_residue_positions(array, indices):
Returns
-------
start_indices : ndarray, dtype=int, shape=(k,)
residue_indices : ndarray, dtype=int, shape=(k,)
The indices that point to the position of the residues.
See Also
--------
get_residue_masks
get_residue_starts_for
Examples
--------
>>> atom_index = [5, 42]
Expand Down Expand Up @@ -572,4 +557,5 @@ def residue_iter(array):
"""
# The exclusive stop is appended to the residue starts
starts = get_residue_starts(array, add_exclusive_stop=True)
return segment_iter(array, starts)
for residue in segment_iter(array, starts):
yield residue
63 changes: 63 additions & 0 deletions src/biotite/structure/segments.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,22 @@ def apply_segment_wise(starts, data, function, axis=None):
The sorted start indices of segments.
Includes exclusive stop, i.e. the length of the corresponding
atom array.
data : ndarray
The data, whose intervals are the parameter for `function`.
Must have same length as `array`.
function : function
The `function` must have either the form *f(data)* or
*f(data, axis)* in case `axis` is given. Every `function` call
must return a value with the same shape and data type.
axis : int, optional
This value is given to the `axis` parameter of `function`.
Returns
-------
processed_data : ndarray
Segment-wise evaluation of `data` by `function`.
The size of the first dimension of this array is equal to the amount of
residues.
"""
# The result array
processed_data = None
Expand Down Expand Up @@ -65,6 +81,16 @@ def spread_segment_wise(starts, input_data):
The sorted start indices of segments.
Includes exclusive stop, i.e. the length of the corresponding
atom array.
input_data : ndarray
The data to be spread.
The length of the 0-th axis must be equal to the amount of different residue IDs
in `array`.
Returns
-------
output_data : ndarray
Segment-wise spread `input_data`.
Length is the same as `array_length()` of `array`.
"""
output_data = np.zeros(starts[-1], dtype=input_data.dtype)
for i in range(len(starts) - 1):
Expand All @@ -85,6 +111,17 @@ def get_segment_masks(starts, indices):
The sorted start indices of segments.
Includes exclusive stop, i.e. the length of the corresponding
atom array.
indices : ndarray, dtype=int, shape=(k,)
These indices indicate the atoms to get the corresponding
segments for.
Negative indices are not allowed.
Returns
-------
residues_masks : ndarray, dtype=bool, shape=(k,n)
Multiple boolean masks, one for each given index in `indices`.
Each array masks the atoms that belong to the same segment as
the atom at the given index.
"""
indices = np.asarray(indices)
length = starts[-1]
Expand Down Expand Up @@ -116,6 +153,16 @@ def get_segment_starts_for(starts, indices):
The sorted start indices of segments.
Includes exclusive stop, i.e. the length of the corresponding
atom array.
indices : ndarray, dtype=int, shape=(k,)
These indices point to the atoms to get the corresponding
segment starts for.
Negative indices are not allowed.
Returns
-------
start_indices : ndarray, dtype=int, shape=(k,)
The indices that point to the segment starts for the input
`indices`.
"""
indices = np.asarray(indices)
length = starts[-1]
Expand Down Expand Up @@ -145,6 +192,15 @@ def get_segment_positions(starts, indices):
The sorted start indices of segments.
Includes exclusive stop, i.e. the length of the corresponding
atom array.
indices : ndarray, shape=(k,)
These indices point to the atoms to get the corresponding
residue positions for.
Negative indices are not allowed.
Returns
-------
segment_indices : ndarray, shape=(k,)
The indices that point to the position of the segments.
"""
indices = np.asarray(indices)
length = starts[-1]
Expand All @@ -169,10 +225,17 @@ def segment_iter(array, starts):
Parameters
----------
array : AtomArray or AtomArrayStack
The structure to iterate over.
starts : ndarray, dtype=int
The sorted start indices of segments.
Includes exclusive stop, i.e. the length of the corresponding
atom array.
Yields
------
segment : AtomArray or AtomArrayStack
Each residue or chain of the structure.
"""
for i in range(len(starts) - 1):
yield array[..., starts[i] : starts[i + 1]]
1 change: 0 additions & 1 deletion src/biotite/structure/sequence.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ def to_sequence(atoms, allow_hetero=False):
>>> sequences, chain_starts = to_sequence(atom_array)
>>> print(sequences)
[ProteinSequence("NLYIQWLKDGGPSSGRPPPS")]
"""
sequences = []
chain_start_indices = get_chain_starts(atoms, add_exclusive_stop=True)
Expand Down
2 changes: 0 additions & 2 deletions src/biotite/structure/sse.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ def annotate_sse(atom_array):
Non-peptide residues are also allowed and obtain a ``''``
SSE.
Returns
-------
sse : ndarray
Expand Down Expand Up @@ -81,7 +80,6 @@ def annotate_sse(atom_array):
>>> print(sse)
['c' 'a' 'a' 'a' 'a' 'a' 'a' 'a' 'a' 'c' 'c' 'c' 'c' 'c' 'c' 'c' 'c' 'c'
'c' 'c']
"""
residue_starts = get_residue_starts(atom_array)
# Sort CA coord into the coord array at the respective residue index
Expand Down
Loading

0 comments on commit 3379953

Please sign in to comment.