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

Removes optional dependency bottleneck #102

Merged
merged 1 commit into from
Oct 13, 2024
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: 0 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,6 @@ or from this distribution with
$ python setup.py install
```

## Performance: Optional

This library is optionally compatible with [bottleneck](https://github.com/pydata/bottleneck) and may offer performance improvements in some cases.
Install bottleneck in your project as a peer to astroalign using:

```bash
pip install bottleneck
```

`Astroalign` will pick this optional dependency up and use it's performance improved functions for computing transforms.

## Running Tests

```bash
Expand Down
31 changes: 2 additions & 29 deletions astroalign.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,6 @@
"register",
]

try:
import bottleneck as bn
except ImportError:
HAS_BOTTLENECK = False
else:
HAS_BOTTLENECK = True

import numpy as _np


Expand Down Expand Up @@ -109,26 +102,6 @@ def matrix_transform(*args, **kwargs):
Default: 5
"""

_default_median = bn.nanmedian if HAS_BOTTLENECK else _np.nanmedian # pragma: no cover
"""
Default median function when/if optional bottleneck is available
"""

_default_average = bn.nanmean if HAS_BOTTLENECK else _np.nanmean # pragma: no cover
"""
Default mean function when/if optional bottleneck is available
"""

_default_sum = bn.nansum if HAS_BOTTLENECK else _np.nansum # pragma: no cover
"""
Default sum function when/if optional bottleneck is available
"""

_default_std = bn.nanstd if HAS_BOTTLENECK else _np.nanstd # pragma: no cover
"""
Default std deviation function when/if optional bottleneck is available
"""


def _invariantfeatures(x1, x2, x3):
"""Given 3 points x1, x2, x3, return the invariant features for the set."""
Expand Down Expand Up @@ -270,7 +243,7 @@ def _bw(image):
"""Return a 2D numpy array for an array of arbitrary channels."""
if image.ndim == 2:
return image
return _default_average(image, axis=-1)
return _np.mean(image, axis=-1)


def _shape(image):
Expand Down Expand Up @@ -471,7 +444,7 @@ def apply_transform(
output_shape=target_shape,
order=3,
mode="constant",
cval=_default_median(source_data),
cval=_np.median(source_data),
clip=True,
preserve_range=True,
)
Expand Down
4 changes: 0 additions & 4 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@ You can find a Jupyter notebook example with the main features at http://quatrop
If your images contain a large number of hot pixels, this may result in an incorrect registration.
Please refer to the tutorial for how to solve this problem using `CCDProc's cosmic-ray remover <https://ccdproc.readthedocs.io/en/latest/api/ccdproc.cosmicray_lacosmic.html>`_.

.. note::
This library is compatible with `bottleneck <https://github.com/pydata/bottleneck>`_ and may offer performance improvements in some cases.
`Astroalign` will pick this optional dependency up and use its performance improved ``mean`` and ``median`` functions.


Citation
--------
Expand Down
4 changes: 0 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ keywords = [
"stellar-astronomical-images"
]


[project.optional-dependencies]
bottleneck = ["bottleneck"]

[project.urls]
homepage = "https://astroalign.quatrope.org"
documentation = "https://astroalign.readthedocs.io/"
Expand Down