Metadata-Version: 2.4
Name: torch-bounds
Version: 0.2.0
Summary: Boundary conditions and real transforms in PyTorch
Author-email: Yael Balbastre <yael.balbastre@gmail.com>
License: MIT License
        
        Copyright (c) 2024 Yaël Balbastre
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://github.com/balbasty/torch-bounds
Project-URL: Issues, https://github.com/balbasty/torch-bounds/issues
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Intended Audience :: Science/Research
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.6
Description-Content-Type: text/markdown
License-File: LICENSE
License-File: LICENSE-CUPY
Requires-Dist: torch>=1.3
Provides-Extra: realtransforms
Requires-Dist: torch>=1.8; extra == "realtransforms"
Provides-Extra: test
Requires-Dist: scipy; extra == "test"
Dynamic: license-file

# torch-bounds

Boundary conditions (circulant, mirror, reflect) and real transforms (DCT, DST) in PyTorch.

## Overview

This small package implements a wide range of boundary conditions used
to extrapolate a given discrete signal outside of its native bounds.

Based on these additional boundary conditions, it implements:

- [`pad`](https://torch-bounds.readthedocs.io/en/latest/api/padding/#bounds.padding.pad): an extension of `torch.nn.functional.pad`
- [`roll`](https://torch-bounds.readthedocs.io/en/latest/api/padding/#bounds.padding.roll): an extension of `torch.roll`

It also implements discrete
[sine and cosine transforms](https://torch-bounds.readthedocs.io/en/latest/api/realtransforms)
(variants 1, 2 and 3), using a trick similar to `cupy`.

Finally, it implements additional utilities:

- [`ensure_shape`](https://torch-bounds.readthedocs.io/en/latest/api/padding/#bounds.padding.ensure_shape)
  crops or pads a tensor (with any boundary condition) so that it matches a give shape.
- [`indexing`](https://torch-bounds.readthedocs.io/en/latest/api/indexing)
  is a module that implements functions to tranforms out-of-bounds
  coordinates into in-bounds coordinates according to any boundary condition.
- [`types`](https://torch-bounds.readthedocs.io/en/latest/api/types)
  is a module that defines names and aliases for different boundary conditions,
  as well as tools to convert between different naming conventions.

## Documentation

See our [**documentation**](https://torch-bounds.readthedocs.io) and
[**notebooks**](docs/notebooks/).

## Installation

### Dependency

- `torch >= 1.3`
- `torch >= 1.8` if real transforms are needed (dct, dst)

### Conda

```shell
conda install torch-bounds -c balbasty -c pytorch
```

### Pip

```shell
pip install torch-bounds
```



## Related packages

- [`torch-interpol`](https://github.com/balbasty/torch-interpol):
  B-spline interpolation with the same boundary conditions as those
  implemented here.
- [`torch-distmap`](https://github.com/balbasty/torch-distmap):
  Euclidean distance transform.
