Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reformat code blocks #286

Merged
merged 1 commit into from
May 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,17 @@ repos:
hooks:
- id: python-check-blanket-noqa
- id: python-use-type-annotations
- repo: https://github.com/psf/black
rev: 23.3.0
hooks:
- id: black
language_version: python3.10
- repo: https://github.com/adamchainz/blacken-docs
rev: "1.13.0"
hooks:
- id: blacken-docs
additional_dependencies:
- black>=23.3
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.270
hooks:
Expand Down
2 changes: 1 addition & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ docformatter = { extras = ["tomli"], version = "^1.7" }
pre-commit = "^3.3"
pylint = "^2.17"
pytest = "^7.3"
pytest-cov = "^4.0"
pytest-cov = "^4.1"
pytest-timeout = "^2.1"
ruff = "^0.0,>=0.0.270"

Expand Down
36 changes: 17 additions & 19 deletions src/redcat/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def clone(self) -> TBatch:

Example usage:

.. code-block:: python
.. code-block:: pycon

>>> import torch
>>> from redcat import BatchedTensor
Expand Down Expand Up @@ -77,7 +77,7 @@ def allclose(

Example usage:

.. code-block:: python
.. code-block:: pycon

>>> import torch
>>> from redcat import BatchedTensor
Expand All @@ -100,7 +100,7 @@ def equal(self, other: Any) -> bool:

Example usage:

.. code-block:: python
.. code-block:: pycon

>>> import torch
>>> from redcat import BatchedTensor
Expand All @@ -127,7 +127,7 @@ def permute_along_batch(self, permutation: Sequence[int] | Tensor) -> TBatch:

Example usage:

.. code-block:: python
.. code-block:: pycon

>>> import torch
>>> from redcat import BatchedTensor
Expand All @@ -152,7 +152,7 @@ def permute_along_batch_(self, permutation: Sequence[int] | Tensor) -> None:

Example usage:

.. code-block:: python
.. code-block:: pycon

>>> import torch
>>> from redcat import BatchedTensor
Expand All @@ -179,7 +179,7 @@ def shuffle_along_batch(self, generator: torch.Generator | None = None) -> TBatc

Example usage:

.. code-block:: python
.. code-block:: pycon

>>> import torch
>>> from redcat import BatchedTensor
Expand All @@ -203,7 +203,7 @@ def shuffle_along_batch_(self, generator: torch.Generator | None = None) -> None

Example usage:

.. code-block:: python
.. code-block:: pycon

>>> import torch
>>> from redcat import BatchedTensor
Expand Down Expand Up @@ -241,7 +241,7 @@ def append(self, other: BaseBatch) -> None:

Example usage:

.. code-block:: python
.. code-block:: pycon

>>> import torch
>>> from redcat import BatchedTensor
Expand Down Expand Up @@ -271,7 +271,7 @@ def chunk_along_batch(self, chunks: int) -> tuple[TBatch, ...]:

Example usage:

.. code-block:: python
.. code-block:: pycon

>>> import torch
>>> from redcat import BatchedTensor
Expand Down Expand Up @@ -304,14 +304,12 @@ def extend(self, other: Iterable[BaseBatch]) -> None:

Example usage:

.. code-block:: python
.. code-block:: pycon

>>> import torch
>>> from redcat import BatchedTensor
>>> batch = BatchedTensor(torch.ones(2, 3))
>>> batch.extend(
... [BatchedTensor(torch.zeros(1, 3)), BatchedTensor(torch.full((1, 3), 2.0))]
... )
>>> batch.extend([BatchedTensor(torch.zeros(1, 3)), BatchedTensor(torch.full((1, 3), 2.0))])
>>> batch.data
tensor([[1., 1., 1.],
[1., 1., 1.],
Expand All @@ -334,7 +332,7 @@ def index_select_along_batch(self, index: Tensor | Sequence[int]) -> BaseBatch:

Example usage:

.. code-block:: python
.. code-block:: pycon

>>> import torch
>>> from redcat import BatchedTensor
Expand Down Expand Up @@ -363,7 +361,7 @@ def select_along_batch(self, index: int) -> T:

Example usage:

.. code-block:: python
.. code-block:: pycon

>>> import torch
>>> from redcat import BatchedTensor
Expand All @@ -389,7 +387,7 @@ def slice_along_batch(self, start: int = 0, stop: int | None = None, step: int =

Example usage:

.. code-block:: python
.. code-block:: pycon

>>> import torch
>>> from redcat import BatchedTensor
Expand Down Expand Up @@ -421,7 +419,7 @@ def split_along_batch(self, split_size_or_sections: int | Sequence[int]) -> tupl

Example usage:

.. code-block:: python
.. code-block:: pycon

>>> import torch
>>> from redcat import BatchedTensor
Expand Down Expand Up @@ -450,7 +448,7 @@ def get_num_minibatches(self, batch_size: int, drop_last: bool = False) -> int:

Example usage:

.. code-block:: python
.. code-block:: pycon

>>> import torch
>>> from redcat import BatchedTensor
Expand Down Expand Up @@ -490,7 +488,7 @@ def to_minibatches(

Example usage:

.. code-block:: python
.. code-block:: pycon

>>> import torch
>>> from redcat import BatchedTensor
Expand Down
20 changes: 8 additions & 12 deletions src/redcat/batchdict.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def permute_along_seq(self, permutation: Sequence[int] | Tensor) -> TBatchDict:

Example usage:

.. code-block:: python
.. code-block:: pycon

>>> import torch
>>> from redcat import BatchDict, BatchList, BatchedTensorSeq
Expand Down Expand Up @@ -181,7 +181,7 @@ def permute_along_seq_(self, permutation: Sequence[int] | Tensor) -> None:

Example usage:

.. code-block:: python
.. code-block:: pycon

>>> import torch
>>> from redcat import BatchDict, BatchList, BatchedTensorSeq
Expand Down Expand Up @@ -222,7 +222,7 @@ def shuffle_along_seq(self, generator: torch.Generator | None = None) -> TBatchD

Example usage:

.. code-block:: python
.. code-block:: pycon

>>> import torch
>>> from redcat import BatchDict, BatchList, BatchedTensorSeq
Expand Down Expand Up @@ -264,7 +264,7 @@ def shuffle_along_seq_(self, generator: torch.Generator | None = None) -> None:

Example usage:

.. code-block:: python
.. code-block:: pycon

>>> import torch
>>> from redcat import BatchDict, BatchList, BatchedTensorSeq
Expand Down Expand Up @@ -324,7 +324,7 @@ def cat_along_seq(self, batches: BatchDict | Sequence[BatchDict]) -> TBatchDict:

Example usage:

.. code-block:: python
.. code-block:: pycon

>>> import torch
>>> from redcat import BatchDict, BatchList, BatchedTensorSeq
Expand All @@ -335,9 +335,7 @@ def cat_along_seq(self, batches: BatchDict | Sequence[BatchDict]) -> TBatchDict:
... }
... )
>>> b.cat_along_seq(
... BatchDict(
... {"key1": BatchedTensorSeq(torch.tensor([[10, 11, 12], [20, 21, 22]]))}
... )
... BatchDict({"key1": BatchedTensorSeq(torch.tensor([[10, 11, 12], [20, 21, 22]]))})
... )
BatchDict(
(key1) tensor([[ 0, 1, 2, 3, 4, 10, 11, 12],
Expand Down Expand Up @@ -366,7 +364,7 @@ def cat_along_seq_(self, batches: BatchDict | Sequence[BatchDict]) -> None:

Example usage:

.. code-block:: python
.. code-block:: pycon

>>> import torch
>>> from redcat import BatchDict, BatchList, BatchedTensorSeq
Expand All @@ -377,9 +375,7 @@ def cat_along_seq_(self, batches: BatchDict | Sequence[BatchDict]) -> None:
... }
... )
>>> b.cat_along_seq_(
... BatchDict(
... {"key1": BatchedTensorSeq(torch.tensor([[10, 11, 12], [20, 21, 22]]))}
... )
... BatchDict({"key1": BatchedTensorSeq(torch.tensor([[10, 11, 12], [20, 21, 22]]))})
... )
>>> b
BatchDict(
Expand Down
4 changes: 2 additions & 2 deletions src/redcat/batchlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def apply(self, fn: Callable[[T], T]) -> TBatchList:

Example usage:

.. code-block:: python
.. code-block:: pycon

>>> import torch
>>> from redcat import BatchList
Expand All @@ -183,7 +183,7 @@ def apply_(self, fn: Callable[[T], T]) -> None:

Example usage:

.. code-block:: python
.. code-block:: pycon

>>> import torch
>>> from redcat import BatchList
Expand Down
2 changes: 1 addition & 1 deletion src/redcat/datapipes/iter/batching.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class MiniBatcherIterDataPipe(IterDataPipe[BaseBatch[T]]):

Example usage:

.. code-block:: python
.. code-block:: pycon

>>> import torch
>>> from torch.utils.data.datapipes.iter import IterableWrapper
Expand Down
2 changes: 1 addition & 1 deletion src/redcat/datapipes/iter/joining.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class BatchExtenderIterDataPipe(IterDataPipe[BaseBatch[T]]):

Example usage:

.. code-block:: python
.. code-block:: pycon

>>> import torch
>>> from torch.utils.data.datapipes.iter import IterableWrapper
Expand Down
2 changes: 1 addition & 1 deletion src/redcat/datapipes/iter/shuffling.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class BatchShufflerIterDataPipe(IterDataPipe[BaseBatch[T]]):

Example usage:

.. code-block:: python
.. code-block:: pycon

>>> import torch
>>> from torch.utils.data.datapipes.iter import IterableWrapper
Expand Down
Loading