Skip to content

Commit

Permalink
Removed optional dependency bottleneck
Browse files Browse the repository at this point in the history
The two places where this was used are only invoked once.
  • Loading branch information
martinberoiz committed Oct 13, 2024
1 parent 7725b92 commit 9f8c812
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 48 deletions.
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

0 comments on commit 9f8c812

Please sign in to comment.