Skip to content

Commit

Permalink
docs: Add versionadded to new tensorlib methods (#2025)
Browse files Browse the repository at this point in the history
* Add versionadded sphinx directive to transpose and percentile tensorlib methods.
  • Loading branch information
kratsg authored Sep 23, 2022
1 parent 67c0b58 commit c2710e9
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/pyhf/tensor/jax_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ def percentile(self, tensor_in, q, axis=None, interpolation="linear"):
Returns:
JAX ndarray: The value of the :math:`q`-th percentile of the tensor along the specified axis.
.. versionadded:: 0.7.0
"""
return jnp.percentile(tensor_in, q, axis=axis, interpolation=interpolation)

Expand Down Expand Up @@ -618,5 +619,6 @@ def transpose(self, tensor_in):
Returns:
JAX ndarray: The transpose of the input tensor.
.. versionadded:: 0.7.0
"""
return tensor_in.transpose()
2 changes: 2 additions & 0 deletions src/pyhf/tensor/numpy_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ def percentile(
Returns:
NumPy ndarray: The value of the :math:`q`-th percentile of the tensor along the specified axis.
.. versionadded:: 0.7.0
"""
# see https://github.com/numpy/numpy/issues/22125
return np.percentile(tensor_in, q, axis=axis, interpolation=interpolation) # type: ignore[call-overload,no-any-return]
Expand Down Expand Up @@ -637,5 +638,6 @@ def transpose(self, tensor_in: Tensor[T]) -> ArrayLike:
Returns:
:class:`numpy.ndarray`: The transpose of the input tensor.
.. versionadded:: 0.7.0
"""
return tensor_in.transpose()
2 changes: 2 additions & 0 deletions src/pyhf/tensor/pytorch_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ def percentile(self, tensor_in, q, axis=None, interpolation="linear"):
Returns:
PyTorch tensor: The value of the :math:`q`-th percentile of the tensor along the specified axis.
.. versionadded:: 0.7.0
"""
# Interpolation options not yet supported
# c.f. https://github.com/pytorch/pytorch/pull/49267
Expand Down Expand Up @@ -621,5 +622,6 @@ def transpose(self, tensor_in):
Returns:
PyTorch FloatTensor: The transpose of the input tensor.
.. versionadded:: 0.7.0
"""
return tensor_in.transpose(0, 1)
2 changes: 2 additions & 0 deletions src/pyhf/tensor/tensorflow_backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,7 @@ def percentile(self, tensor_in, q, axis=None, interpolation="linear"):
Returns:
TensorFlow Tensor: The value of the :math:`q`-th percentile of the tensor along the specified axis.
.. versionadded:: 0.7.0
"""
return tfp.stats.percentile(
tensor_in, q, axis=axis, interpolation=interpolation
Expand Down Expand Up @@ -718,5 +719,6 @@ def transpose(self, tensor_in):
Returns:
TensorFlow Tensor: The transpose of the input tensor.
.. versionadded:: 0.7.0
"""
return tf.transpose(tensor_in)

0 comments on commit c2710e9

Please sign in to comment.