Skip to content

Commit

Permalink
Merge pull request #136 from SarthakJariwala/v0.4.x
Browse files Browse the repository at this point in the history
Added `imshow` as an alias for `imgplot`
  • Loading branch information
SarthakJariwala authored Feb 6, 2021
2 parents ec12f81 + 1804a6d commit 11d9249
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 2 deletions.
4 changes: 4 additions & 0 deletions docs/api/imshow.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
seaborn_image.imshow
====================

.. autofunction:: seaborn_image.imshow
2 changes: 1 addition & 1 deletion docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Installation

.. code-block:: bash
pip install seaborn-image
pip install -U seaborn-image
Quick Usage
===========
Expand Down
7 changes: 7 additions & 0 deletions docs/reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ Reference

Axes level function to visualize 2-D images.


:doc:`imshow <api/imshow>`
----------------------------

Alias for ``imgplot``. Axes level function to visualize 2-D image data.


:doc:`imghist <api/imghist>`
----------------------------

Expand Down
11 changes: 10 additions & 1 deletion src/seaborn_image/_general.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@

from ._colormap import _CMAP_QUAL
from ._core import _SetupImage
from .utils import is_documented_by

__all__ = ["imgplot", "imghist"]
__all__ = ["imgplot", "imghist", "imshow"]


def imgplot(
Expand Down Expand Up @@ -355,6 +356,14 @@ def imgplot(
return ax


@is_documented_by(imgplot)
def imshow(data, **kwargs):

ax = imgplot(data, **kwargs)

return ax


# TODO implement a imgdist function with more distributions (?)
def imghist(
data,
Expand Down
10 changes: 10 additions & 0 deletions src/seaborn_image/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,3 +166,13 @@ def despine(fig=None, ax=None, which="all"):
for ax in axes:
for spine in _to_despine:
ax.spines[spine].set_visible(False)


def is_documented_by(original):
"Wrapper to document alias functions"

def wrapper(target):
target.__doc__ = original.__doc__
return target

return wrapper
7 changes: 7 additions & 0 deletions tests/test_general.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,13 @@ def test_map_func():
ax.images[0].get_array().data, adjust_gamma(cells, gamma=0.5)
)

# imshow with kwargs to test if they are passed on to imgplot
ax = isns.imshow(cells, map_func=adjust_gamma, gamma=0.5)

np.testing.assert_array_equal(
ax.images[0].get_array().data, adjust_gamma(cells, gamma=0.5)
)


def test_cbar_log_and_norm():
# special case of log-norm
Expand Down

0 comments on commit 11d9249

Please sign in to comment.