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

retemplate the package and set the python version to 3.6+ #11

Merged
merged 5 commits into from
May 18, 2018
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
9 changes: 0 additions & 9 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,6 @@ jobs:
- checkout
- run: python setup.py egg_info

egg-info-35:
docker:
- image: circleci/python:3.5
steps:
- checkout
- run: python setup.py egg_info

tests:
environment:
- MPLBACKEND: 'agg'
Expand Down Expand Up @@ -64,11 +57,9 @@ workflows:
test-code:
jobs:
- egg-info-36
- egg-info-35
- tests:
requires:
- egg-info-36
- egg-info-35

test-documentation:
jobs:
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ New Features
- Add implementation of `dkist.dataset.Dataset.pixel_to_world` and
`dkist.dataset.Dataset.world_to_pixel` [#1]
- Add ability to crop Dataset array by world coordinates [#1]
- Python 3.6+ Only [#11]

Bug Fixes
---------
Expand Down
9 changes: 7 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,15 @@ DKIST User Tools
:target: http://www.sunpy.org
:alt: Powered by SunPy Badge

A Python library of tools for obtaining, processing and interacting with DKIST data.
A Python library of tools for obtaining, processing and interacting with DKIST
data.


License
-------

This project is Copyright (c) NSO / AURA and licensed under the terms of the BSD 3-Clause license. See the licenses folder for more information.
This project is Copyright (c) NSO / AURA and licensed under
the terms of the BSD 3-Clause license. This package is based upon
the `Astropy package template <https://github.com/astropy/package-template>`_
which is licensed under the BSD 3-clause licence. See the licenses folder for
more information.
13 changes: 12 additions & 1 deletion dkist/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,18 @@
from ._dkist_init import *
# ----------------------------------------------------------------------------

# Enforce Python version check during package import.
# This is the same check as the one at the top of setup.py
import sys

__minimum_python_version__ = "3.6"

class UnsupportedPythonError(Exception):
pass

if sys.version_info < tuple((int(val) for val in __minimum_python_version__.split('.'))):
raise UnsupportedPythonError("dkist does not support Python < {}".format(__minimum_python_version__))

if not _ASTROPY_SETUP_:
# For egg_info test builds to pass, put package imports here.

pass
58 changes: 57 additions & 1 deletion dkist/conftest.py
Original file line number Diff line number Diff line change
@@ -1 +1,57 @@
# This file is used to configure the behavior of pytest
# This file is used to configure the behavior of pytest when using the Astropy
# test infrastructure.

from astropy.version import version as astropy_version
if astropy_version < '3.0':
# With older versions of Astropy, we actually need to import the pytest
# plugins themselves in order to make them discoverable by pytest.
from astropy.tests.pytest_plugins import *
else:
# As of Astropy 3.0, the pytest plugins provided by Astropy are
# automatically made available when Astropy is installed. This means it's
# not necessary to import them here, but we still need to import global
# variables that are used for configuration.
from astropy.tests.plugins.display import PYTEST_HEADER_MODULES, TESTED_VERSIONS

from astropy.tests.helper import enable_deprecations_as_exceptions

## Uncomment the following line to treat all DeprecationWarnings as
## exceptions. For Astropy v2.0 or later, there are 2 additional keywords,
## as follow (although default should work for most cases).
## To ignore some packages that produce deprecation warnings on import
## (in addition to 'compiler', 'scipy', 'pygments', 'ipykernel', and
## 'setuptools'), add:
## modules_to_ignore_on_import=['module_1', 'module_2']
## To ignore some specific deprecation warning messages for Python version
## MAJOR.MINOR or later, add:
## warnings_to_ignore_by_pyver={(MAJOR, MINOR): ['Message to ignore']}
# enable_deprecations_as_exceptions()

## Uncomment and customize the following lines to add/remove entries from
## the list of packages for which version numbers are displayed when running
## the tests. Making it pass for KeyError is essential in some cases when
## the package uses other astropy affiliated packages.
# try:
# PYTEST_HEADER_MODULES['Astropy'] = 'astropy'
# PYTEST_HEADER_MODULES['scikit-image'] = 'skimage'
# del PYTEST_HEADER_MODULES['h5py']
# except (NameError, KeyError): # NameError is needed to support Astropy < 1.0
# pass

## Uncomment the following lines to display the version number of the
## package rather than the version number of Astropy in the top line when
## running the tests.
# import os
#
## This is to figure out the package version, rather than
## using Astropy's
# try:
# from .version import version
# except ImportError:
# version = 'dev'
#
# try:
# packagename = os.path.basename(os.path.dirname(__file__))
# TESTED_VERSIONS[packagename] = version
# except NameError: # Needed to support Astropy <= 1.0.0
# pass
Binary file modified dkist/data/test/EIT/eit_2004-03-01T00:00:10.515000.asdf
Binary file not shown.
7 changes: 5 additions & 2 deletions dkist/dataset/dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,18 @@
import asdf
import numpy as np
import astropy.units as u
from ndcube.ndcube import NDCubeBase
try:
from ndcube.ndcube import NDCubeABC
except ImportError:
from ndcube.ndcube import NDCubeBase as NDCubeABC

from dkist.dataset.mixins import DatasetPlotMixin
from dkist.io import DaskFITSArrayContainer, AstropyFITSLoader

__all__ = ['Dataset']


class Dataset(DatasetPlotMixin, NDCubeBase):
class Dataset(NDCubeABC):
"""
The base class for DKIST datasets.

Expand Down
2 changes: 1 addition & 1 deletion dkist/dataset/mixins.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import matplotlib.pyplot as plt

from sunpy.visualization.imageanimator import ImageAnimator
from sunpy.visualization.animator import ImageAnimator
from ndcube.mixins import NDCubePlotMixin

__all__ = ['DatasetPlotMixin']
Expand Down
4 changes: 2 additions & 2 deletions dkist/dataset/tests/test_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def identity_gwcs():
"""
A simple 1-1 gwcs that converts from pixels to arcseconds
"""
identity = m.Scale(1*u.arcsec/u.pixel) & m.Scale(1*u.arcsec/u.pixel)
identity = m.Multiply(1*u.arcsec/u.pixel) & m.Multiply(1*u.arcsec/u.pixel)
sky_frame = cf.CelestialFrame(axes_order=(0, 1), name='helioprojective',
reference_frame=Helioprojective(obstime="2018-01-01"))
return gwcs.wcs.WCS(forward_transform=identity, output_frame=sky_frame)
Expand All @@ -41,7 +41,7 @@ def identity_gwcs_3d():
"""
A simple 1-1 gwcs that converts from pixels to arcseconds
"""
identity = m.Scale(1*u.arcsec/u.pixel) & m.Scale(1*u.arcsec/u.pixel) & m.Scale(1*u.nm/u.pixel)
identity = m.Multiply(1*u.arcsec/u.pixel) & m.Multiply(1*u.arcsec/u.pixel) & m.Multiply(1*u.nm/u.pixel)
sky_frame = cf.CelestialFrame(axes_order=(0, 1), name='helioprojective',
reference_frame=Helioprojective(obstime="2018-01-01"))
wave_frame = cf.SpectralFrame(axes_order=(2, ), unit=u.nm)
Expand Down
2 changes: 2 additions & 0 deletions dkist/dataset/tests/test_plotting.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import pytest
import matplotlib.pyplot as plt

pytestmark = pytest.mark.skip

from .test_dataset import dataset_3d, identity_gwcs_3d, dataset, identity_gwcs, array


Expand Down
23 changes: 11 additions & 12 deletions dkist/tests/coveragerc
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
[run]
source = dkist
source = {packagename}
omit =
astropy_helpers/*
dkist/_dkist_init*
dkist/conftest*
dkist/cython_version*
dkist/setup_package*
dkist/*/setup_package*
dkist/*/*/setup_package*
dkist/tests/*
dkist/*/tests/*
dkist/*/*/tests/*
dkist/version*
{packagename}/_dkist_init*
{packagename}/conftest*
{packagename}/cython_version*
{packagename}/setup_package*
{packagename}/*/setup_package*
{packagename}/*/*/setup_package*
{packagename}/tests/*
{packagename}/*/tests/*
{packagename}/*/*/tests/*
{packagename}/version*

[report]
exclude_lines =
Expand Down
6 changes: 2 additions & 4 deletions dkist/tests/generate_eit_test_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,14 @@
import astropy.units as u
from astropy.io import fits
from astropy.time import Time
from astropy.modeling.models import Shift, AffineTransformation2D, Pix2Sky_TAN, RotateNative2Celestial, Scale
from astropy.modeling.models import Shift, AffineTransformation2D, Pix2Sky_TAN, RotateNative2Celestial, Multiply

import gwcs
from gwcs import coordinate_frames as cf
from gwcs.lookup_table import LookupTable

import sunpy.map
from sunpy.time import parse_time
from sunpy.net import Fido, attrs as a
from sunpy.net.jsoc import JSOCClient


def map_to_transform(smap):
Expand Down Expand Up @@ -49,7 +47,7 @@ def map_to_transform(smap):
cdelt1u, cdelt2u = smap.scale
pcu = smap.rotation_matrix * u.arcsec
shiftu = Shift(-crpix1u) & Shift(-crpix2u)
scaleu = Scale(cdelt1u) & Scale(cdelt2u)
scaleu = Multiply(cdelt1u) & Multiply(cdelt2u)
rotu = AffineTransformation2D(pcu, translation=(0, 0)*u.arcsec)
tanu = Pix2Sky_TAN()
skyrotu = RotateNative2Celestial(crval1u, crval2u, 180*u.deg)
Expand Down
2 changes: 1 addition & 1 deletion licenses/LICENSE.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright (c) 2017, NSO / AURA
Copyright (c) 2018, NSO / AURA
All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
Expand Down
4 changes: 4 additions & 0 deletions licenses/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,7 @@ Licenses

This directory holds license and credit information for the package,
works the package is derived from, and/or datasets.

Ensure that you pick a package licence which is in this folder and it matches
the one mentioned in the top level README.rst file. If you are using the
pre-rendered version of this template check for the word 'Other' in the README.
31 changes: 31 additions & 0 deletions licenses/TEMPLATE_LICENCE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
This project is based upon the Astropy package template
(https://github.com/astropy/package-template/) which is licenced under the terms
of the following licence.

---

Copyright (c) 2018, Astropy Developers
All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this
list of conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.
* Neither the name of the Astropy Team nor the names of its contributors may be
used to endorse or promote products derived from this software without
specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
9 changes: 6 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@ dask[complete]
numpy
scipy
matplotlib
ndcube
# ndcube

asdf

# git deps
git+https://github.com/Cadair/astropy@dkist
git+https://github.com/spacetelescope/asdf
git+https://github.com/astropy/astropy
# git+https://github.com/spacetelescope/asdf
git+https://github.com/Cadair/gwcs@dkist
git+https://github.com/Cadair/sunpy@asdf_tags
git+https://github.com/Cadair/ndcube@master_plotting

# test deps
coverage
Expand Down
8 changes: 5 additions & 3 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,16 @@ long_description = A Python library of tools for obtaining, processing and inter
author = NSO / AURA
author_email =
license = BSD 3-Clause
url = http://dkist.nso.edu/
url = http://dkist.nso.edu
edit_on_github = True
github_project = dkistdc/dkist
github_project = DKISTDC/dkist
# install_requires should be formatted as a comma-separated list, e.g.:
# install_requires = astropy, scipy, matplotlib
install_requires = sunpy
# version should be PEP386 compatible (http://www.python.org/dev/peps/pep-0386)
version = 0.1.dev
version = 0.1.dev0
# Note: you will also need to change this in your package's __init__.py
minimum_python_version = 3.6

[entry_points]

Expand Down
44 changes: 24 additions & 20 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,9 @@
import os
import sys

import ah_bootstrap
from setuptools import setup

# A dirty hack to get around some early import/configurations ambiguities
if sys.version_info[0] >= 3:
import builtins
else:
import __builtin__ as builtins
builtins._ASTROPY_SETUP_ = True

from astropy_helpers.setup_helpers import (register_commands, get_debug_option,
get_package_info)
from astropy_helpers.git_helpers import get_git_devstr
from astropy_helpers.version_helpers import generate_version_py
from configparser import ConfigParser

# Get some values from the setup.cfg
try:
from ConfigParser import ConfigParser
except ImportError:
from configparser import ConfigParser

conf = ConfigParser()
conf.read(['setup.cfg'])
metadata = dict(conf.items('metadata'))
Expand All @@ -35,7 +17,28 @@
AUTHOR = metadata.get('author', 'NSO / AURA')
AUTHOR_EMAIL = metadata.get('author_email', '')
LICENSE = metadata.get('license', 'unknown')
URL = metadata.get('url', 'http://dkist.nso.edu/')
URL = metadata.get('url', 'http://dkist.nso.edu')
__minimum_python_version__ = metadata.get("minimum_python_version", "3.6")

# Enforce Python version check - this is the same check as in __init__.py but
# this one has to happen before importing ah_bootstrap.
if sys.version_info < tuple((int(val) for val in __minimum_python_version__.split('.'))):
sys.stderr.write("ERROR: dkist requires Python {} or later\n".format(__minimum_python_version__))
sys.exit(1)

# Import ah_bootstrap after the python version validation

import ah_bootstrap
from setuptools import setup

import builtins
builtins._ASTROPY_SETUP_ = True

from astropy_helpers.setup_helpers import (register_commands, get_debug_option,
get_package_info)
from astropy_helpers.git_helpers import get_git_devstr
from astropy_helpers.version_helpers import generate_version_py


# order of priority for long_description:
# (1) set in setup.cfg,
Expand Down Expand Up @@ -136,5 +139,6 @@
zip_safe=False,
use_2to3=False,
entry_points=entry_points,
python_requires='>={}'.format(__minimum_python_version__),
**package_info
)