Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoInstallSign in
Socket

APLpy

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

APLpy - npm Package Compare versions

Comparing version
2.0rc1
to
2.0rc2
aplpy/tests/data/2d_fits/2MASS_k_rot.hdr

Sorry, the diff of this file is not supported yet

+161
from __future__ import absolute_import, print_function, division
import pytest
import numpy as np
from .. import FITSFigure
def test_layers(capsys):
f = FITSFigure(np.arange(256).reshape((16, 16)))
capsys.readouterr()
# No layers
f.list_layers()
captured = capsys.readouterr()
assert captured.out.strip() == ('There are no layers in this figure')
# Two layers
f.show_markers([360., 350., 340.], [-61., -62., -63], color='cyan', layer='markers')
f.show_markers([360., 350., 340.], [-61., -62., -63], color='cyan', layer='extra_markers')
capsys.readouterr()
f.list_layers()
captured = capsys.readouterr()
assert captured.out.strip() == ('There are 2 layers in this figure:\n\n'
' -> markers\n'
' -> extra_markers')
# Check removing layers
f.remove_layer('extra_markers')
f.list_layers()
captured = capsys.readouterr()
assert captured.out.strip() == ('There is one layer in this figure:\n\n'
' -> markers')
# Check all layer types and overwriting layers
f.show_markers([30, 40], [50, 70], layer='markers')
f.show_circles([360., 350., 340.], [-61., -62., -63], [0.5, 0.4, 0.3], layer='circles')
f.show_circles([30, 40], [50, 70], [10, 20], layer='circles')
f.show_ellipses(340., -66., 1.5, 2., 10., layer='ellipses')
f.show_ellipses(120, 60, 20, 40, 20., layer='ellipses')
f.show_rectangles([355., 350.], [-71, -72], [0.5, 1], [2, 1], angle=[20, 30], layer='rectangles')
f.show_rectangles([66, 80], [20, 30], [10, 14], [20, 22], angle=[20, 30], layer='rectangles')
f.show_arrows([340., 360], [-72, -68], [2, -2], [2, 2], layer='arrows')
f.show_arrows([340., 360], [-72, -68], [2, -2], [2, 2], layer='arrows')
poly = np.array([[330, 340, 360], [-65, -61, -63]])
f.show_polygons([poly], layer='polygons')
f.show_polygons([poly], layer='polygons')
f.show_lines([poly], layer='lines')
f.show_lines([poly], layer='lines')
f.add_label(350., -66., 'text', layer='label')
f.add_label(0.4, 0.25, 'text', relative=True, layer='label')
# FIXME: Uncomment the following once
# https://github.com/astropy/astropy/pull/8321 is merged into Astropy and in
# a bug fix release.
# f.show_contour(layer='contours')
f.list_layers()
captured = capsys.readouterr()
assert captured.out.strip() == ('There are 8 layers in this figure:\n\n'
' -> markers\n'
' -> circles\n'
' -> ellipses\n'
' -> rectangles\n'
' -> arrows\n'
' -> polygons\n'
' -> lines\n'
' -> label')
# Hiding/showing layers
f.hide_layer('ellipses')
f.hide_layer('polygons')
f.list_layers()
captured = capsys.readouterr()
assert captured.out.strip() == ('There are 8 layers in this figure:\n\n'
' -> markers\n'
' -> circles\n'
' -> ellipses (hidden)\n'
' -> rectangles\n'
' -> arrows\n'
' -> polygons (hidden)\n'
' -> lines\n'
' -> label')
layer = f.get_layer('circles')
assert layer.get_visible()
layer = f.get_layer('ellipses')
assert not layer.get_visible()
f.show_layer('ellipses')
f.list_layers()
captured = capsys.readouterr()
assert captured.out.strip() == ('There are 8 layers in this figure:\n\n'
' -> markers\n'
' -> circles\n'
' -> ellipses\n'
' -> rectangles\n'
' -> arrows\n'
' -> polygons (hidden)\n'
' -> lines\n'
' -> label')
layer = f.get_layer('ellipses')
assert layer.get_visible()
def test_non_existent_layers():
# Handling non-existent layers
f = FITSFigure(np.arange(256).reshape((16, 16)))
with pytest.raises(Exception) as exc:
f.get_layer('banana')
assert exc.value.args[0] == 'Layer banana does not exist'
assert f.get_layer('banana', raise_exception=False) is None
with pytest.raises(Exception) as exc:
f.show_layer('banana')
assert exc.value.args[0] == 'Layer banana does not exist'
f.show_layer('banana', raise_exception=False)
with pytest.raises(Exception) as exc:
f.hide_layer('banana')
assert exc.value.args[0] == 'Layer banana does not exist'
f.hide_layer('banana', raise_exception=False)
with pytest.raises(Exception) as exc:
f.remove_layer('banana')
assert exc.value.args[0] == 'Layer banana does not exist'
f.remove_layer('banana', raise_exception=False)
+3
-1
from __future__ import absolute_import, print_function, division
from collections import OrderedDict
from matplotlib.contour import ContourSet

@@ -37,3 +39,3 @@ from matplotlib.collections import RegularPolyCollection, \

self._layers = {}
self._layers = OrderedDict()
self._contour_counter = 0

@@ -40,0 +42,0 @@ self._vector_counter = 0

@@ -11,2 +11,3 @@ from __future__ import absolute_import, print_function, division

from .. import FITSFigure
from ..overlays import Beam

@@ -20,3 +21,3 @@

def test_beam_addremove():
def test_beam_add_remove():
f = FITSFigure(HDU)

@@ -31,3 +32,3 @@ f.show_grayscale()

def test_beam_showhide():
def test_beam_show_hide():
f = FITSFigure(HDU)

@@ -189,1 +190,31 @@ f.show_grayscale()

f.close()
def test_beam_multiple():
f = FITSFigure(HDU)
f.show_grayscale()
f.add_beam(major=0.1, minor=0.04, angle=10.)
f.add_beam(major=0.2, minor=0.08, angle=10.)
f.add_beam(major=0.15, minor=0.08, angle=10.)
assert len(f.beam) == 3
with pytest.raises(Exception) as exc:
f.remove_beam()
assert exc.value.args[0] == ('More than one beam present - use beam_index= '
'to specify which one to remove')
f.remove_beam(beam_index=2)
assert len(f.beam) == 2
f.remove_beam(beam_index=1)
assert isinstance(f.beam, Beam)
f.remove_beam()
assert not hasattr(f, 'beam')
f.close()

@@ -16,2 +16,9 @@ from __future__ import absolute_import, print_function, division

try:
import reproject # noqa
except ImportError:
REPROJECT_INSTALLED = False
else:
REPROJECT_INSTALLED = True
from .. import FITSFigure

@@ -41,3 +48,6 @@ from .helpers import generate_file

header_4 = os.path.join(DATADIR, '2d_fits/2MASS_k_rot.hdr')
cls.filename_4 = generate_file(header_4, str(tempfile.mkdtemp()))
class TestBasic(BaseImageTests):

@@ -99,11 +109,37 @@

f.ticks.set_color('black')
f.show_markers([360., 350., 340.], [-61., -62., -63])
f.show_ellipses(330., -66., 0.15, 2., 10.)
f.show_rectangles([355., 350.], [-71, -72], [0.5, 1], [2, 1])
# Markers
f.show_markers([360., 350., 340.], [-61., -62., -63], color='cyan')
f.show_markers([30, 40], [50, 70], coords_frame='pixel', edgecolor='blue')
# Circles
f.show_circles([360., 350., 340.], [-61., -62., -63], [0.5, 0.4, 0.3], edgecolor='purple')
f.show_circles([30, 40], [50, 70], [10, 20], coords_frame='pixel', edgecolor='orange')
# Ellipses
f.show_ellipses(340., -66., 1.5, 2., 10., edgecolor='red')
f.show_ellipses(120, 60, 20, 40, 20., coords_frame='pixel', edgecolor='green')
# Rectangles
f.show_rectangles([355., 350.], [-71, -72], [0.5, 1], [2, 1], angle=[20, 30], edgecolor='magenta')
f.show_rectangles([66, 80], [20, 30], [10, 14], [20, 22], angle=[20, 30], coords_frame='pixel', edgecolor='yellow')
# Arrows
f.show_arrows([340., 360], [-72, -68], [2, -2], [2, 2])
# Polygons
poly = np.array([[330, 340, 360], [-65, -61, -63]])
f.show_polygons([poly], edgecolor='0.3', zorder=10)
# Lines
f.show_lines([poly], zorder=9, lw=5, color='red', alpha=0.5)
# Labels
f.add_label(350., -66., 'text')
f.add_label(0.4, 0.25, 'text', relative=True)
f.frame.set_linewidth(1) # points
f.frame.set_color('black')
f.axis_labels.hide()
return f._figure

@@ -192,1 +228,12 @@

return f._figure
@pytest.mark.remote_data
@pytest.mark.skipif("not REPROJECT_INSTALLED")
@pytest.mark.mpl_image_compare(style={}, savefig_kwargs={'adjust_bbox': False}, baseline_dir=baseline_dir, tolerance=5)
def test_north(self):
f = FITSFigure(self.filename_4, figsize=(3, 3), north=True)
f.show_grayscale(vmin=-1, vmax=1)
f.axis_labels.hide()
f.tick_labels.hide()
f.ticks.hide()
return f._figure

@@ -179,1 +179,19 @@ from __future__ import absolute_import, print_function, division

f.show_grayscale()
def test_not_first_hdu(tmpdir):
# Test that data is fetched from the first compatible HDU with data
filename = tmpdir.join('test.fits').strpath
hdu0 = fits.PrimaryHDU()
hdu1 = fits.BinTableHDU()
hdu2 = fits.ImageHDU(np.zeros((12, 12)))
hdulist = fits.HDUList([hdu0, hdu1, hdu2])
hdulist.writeto(filename)
f = FITSFigure(filename)
assert f._data.shape == (12, 12)

@@ -10,7 +10,15 @@ from __future__ import absolute_import, print_function, division

try:
import pyavm # noqa
except ImportError:
PYAVM_INSTALLED = False
else:
PYAVM_INSTALLED = True
from .. import FITSFigure
from ..rgb import make_rgb_image
from ..rgb import make_rgb_image, make_rgb_cube
from .test_images import BaseImageTests
from . import baseline_dir
from .helpers import generate_header

@@ -24,5 +32,11 @@ ROOT = os.path.dirname(os.path.abspath(__file__))

@pytest.mark.remote_data
@pytest.mark.mpl_image_compare(style={}, savefig_kwargs={'adjust_bbox': False}, baseline_dir=baseline_dir, tolerance=7.5)
def test_rgb(self, tmpdir):
@pytest.mark.mpl_image_compare(style={}, savefig_kwargs={'adjust_bbox': False},
baseline_dir=baseline_dir, tolerance=7.5,
filename='test_rgb.png')
@pytest.mark.parametrize('embed_avm_tags', (False, True))
def test_rgb(self, tmpdir, embed_avm_tags):
if embed_avm_tags:
pytest.importorskip('pyavm')
# Regression test to check that RGB recenter works properly

@@ -48,5 +62,8 @@

make_rgb_image([r_file, g_file, b_file], rgb_file, embed_avm_tags=False)
make_rgb_image([r_file, g_file, b_file], rgb_file, embed_avm_tags=embed_avm_tags)
f = FITSFigure(r_file, figsize=(7, 5))
if embed_avm_tags:
f = FITSFigure(rgb_file, figsize=(7, 5))
else:
f = FITSFigure(r_file, figsize=(7, 5))

@@ -63,1 +80,55 @@ with warnings.catch_warnings():

return f._figure
@pytest.mark.remote_data
@pytest.mark.mpl_image_compare(style={}, savefig_kwargs={'adjust_bbox': False},
baseline_dir=baseline_dir, tolerance=7.5)
def test_make_rgb_cube(self, tmpdir):
# Regression test to check that RGB recenter works properly
pytest.importorskip('pyavm')
header = generate_header(os.path.join(ROOT, 'data', '2d_fits', '2MASS_k_rot.hdr'))
header['CRPIX1'] = 6.5
header['CRPIX2'] = 6.5
header_r = header.copy()
header_r['CROTA2'] = 5
header_g = header.copy()
header_g['CROTA2'] = 35
header_b = header.copy()
header_b['CROTA2'] = 70
r_file = tmpdir.join('r.fits').strpath
g_file = tmpdir.join('g.fits').strpath
b_file = tmpdir.join('b.fits').strpath
rgb_cube = tmpdir.join('rgb.fits').strpath
rgb_file = tmpdir.join('rgb.png').strpath
header = fits.Header.fromtextfile(HEADER)
r = fits.PrimaryHDU(np.ones((12, 12)), header_r)
r.writeto(r_file)
g = fits.PrimaryHDU(np.ones((12, 12)), header_g)
g.writeto(g_file)
b = fits.PrimaryHDU(np.ones((12, 12)), header_b)
b.writeto(b_file)
make_rgb_cube([r_file, g_file, b_file], rgb_cube)
make_rgb_image(rgb_cube, rgb_file, embed_avm_tags=True,
vmin_r=0, vmax_r=1, vmin_g=0, vmax_g=1, vmin_b=0, vmax_b=1)
f = FITSFigure(rgb_file, figsize=(3, 3))
with warnings.catch_warnings():
warnings.simplefilter("ignore")
f.show_rgb(rgb_file)
f.tick_labels.hide()
f.axis_labels.hide()
return f._figure

@@ -1,2 +0,2 @@

# Autogenerated by Astropy-affiliated package aplpy's setup.py on 2018-12-30 15:52:03 UTC
# Autogenerated by Astropy-affiliated package aplpy's setup.py on 2018-12-31 21:31:30 UTC
from __future__ import unicode_literals

@@ -190,4 +190,4 @@ import datetime

_packagename = "aplpy"
_last_generated_version = "2.0rc1"
_last_githash = "2fb9c568703db747a31dbe87c5c653e844ce9180"
_last_generated_version = "2.0rc2"
_last_githash = "80493a087c524582c35f4f9159da6ee515d170a3"

@@ -215,3 +215,3 @@ # Determine where the source code for this module

release = True
timestamp = datetime.datetime(2018, 12, 30, 15, 52, 3)
timestamp = datetime.datetime(2018, 12, 31, 21, 31, 30)
debug = False

@@ -218,0 +218,0 @@

Metadata-Version: 2.1
Name: aplpy
Version: 2.0rc1
Version: 2.0rc2
Summary: The Astronomical Plotting Library in Python

@@ -12,3 +12,4 @@ Home-page: http://aplpy.github.io

Requires-Python: >=3.5
Provides-Extra: docs
Provides-Extra: all
Provides-Extra: docs
Provides-Extra: test
[![Build Status](https://travis-ci.org/aplpy/aplpy.svg?branch=master)](https://travis-ci.org/aplpy/aplpy)
[![CircleCI](https://circleci.com/gh/aplpy/aplpy/tree/master.svg?style=svg)](https://circleci.com/gh/aplpy/aplpy/tree/master)
[![Coverage Status](https://coveralls.io/repos/aplpy/aplpy/badge.svg?branch=master)](https://coveralls.io/r/aplpy/aplpy?branch=master)
[![codecov](https://codecov.io/gh/aplpy/aplpy/branch/master/graph/badge.svg)](https://codecov.io/gh/aplpy/aplpy)
[![Documentation Status](https://img.shields.io/badge/docs-latest-brightgreen.svg?style=flat)](https://aplpy.readthedocs.io/en/latest/)

@@ -37,2 +37,3 @@

* [pillow](https://pypi.org/project/Pillow/) 4.0 or later
* [scikit-image](https://pypi.org/project/scikit-image/) 0.14 or later

@@ -39,0 +40,0 @@ You can install APLpy with:

@@ -34,6 +34,7 @@ [build_sphinx]

# version should be PEP440 compatible (https://www.python.org/dev/peps/pep-0440/)
version = 2.0rc1
version = 2.0rc2
[options.extras_require]
docs = sphinx-astropy
all = pyregion>=2.0; pillow>=4.0; pyavm>=0.9.4
test = pytest-astropy; codecov; pytest-mpl
all = pyregion>=2.0; pillow>=4.0; pyavm>=0.9.4; scikit-image>=0.14

Sorry, the diff of this file is too big to display