Skip to content

Commit

Permalink
Merge pull request #6 from weaverba137/pep8
Browse files Browse the repository at this point in the history
PEP 8 and other code cleanup.
  • Loading branch information
Benjamin Alan Weaver committed Dec 11, 2015
2 parents f871969 + c475f87 commit d9d7672
Show file tree
Hide file tree
Showing 224 changed files with 7,847 additions and 7,844 deletions.
16 changes: 14 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ python:
- 2.7
- 3.3
- 3.4
- 3.5
# This is just for "egg_info". All other builds are explicitly given in the matrix
env:
global:
Expand All @@ -16,6 +17,7 @@ env:
- ASTROPY_VERSION=stable
- CONDA_INSTALL='conda install -c astropy-ci-extras --yes'
- PIP_INSTALL='pip install'
- MAIN_CMD='python setup.py'
matrix:
- SETUP_CMD='egg_info'

Expand Down Expand Up @@ -46,6 +48,9 @@ matrix:
env: SETUP_CMD='test'
- python: 3.4
env: SETUP_CMD='test'
# Postpone 3.5 tests due to a scipy conflict.
# - python: 3.5
# env: SETUP_CMD='test'

# Try older numpy versions
- python: 2.7
Expand All @@ -55,14 +60,18 @@ matrix:
- python: 2.7
env: NUMPY_VERSION=1.6 SCIPY_VERSION=0.12 SETUP_CMD='test'

# PEP 8 Compliance
- python: 2.7
env: MAIN_CMD='pep8' SETUP_CMD='--count pydl'

before_install:

# Use utf8 encoding. Should be default, but this is insurance against
# future changes
- export PYTHONIOENCODING=UTF8
- wget http://repo.continuum.io/miniconda/Miniconda-latest-Linux-x86_64.sh -O miniconda.sh
- chmod +x miniconda.sh
- ./miniconda.sh -b
- ./miniconda.sh -b -p /home/travis/miniconda
- export PATH=/home/travis/miniconda/bin:$PATH
- conda update --yes conda

Expand Down Expand Up @@ -103,8 +112,11 @@ install:
# COVERAGE DEPENDENCIES
- if [[ $SETUP_CMD == 'test --coverage' ]]; then $PIP_INSTALL coverage==3.7.1 coveralls; fi

# PEP8 DEPENDENCIES
- if [[ $MAIN_CMD == 'pep8' ]]; then $PIP_INSTALL pep8; fi

script:
- python setup.py $SETUP_CMD
- $MAIN_CMD $SETUP_CMD

after_success:
# If coveralls.io is set up for this package, uncomment the line
Expand Down
7 changes: 6 additions & 1 deletion docs/pydl/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
pydl Changelog
==============

0.4.2 (unreleased)
0.5.0 (unreleased)
------------------

* Ongoing review and upgrade of docstrings.
Expand All @@ -11,6 +11,11 @@ pydl Changelog
to :class:`numpy.ndarray` with named columns, which is a slightly different
thing.
* Added additional tests on :class:`~pydl.pydlutils.yanny.yanny` objects.
* Improving `PEP 8`_ compliance
* Restructuing sub-packages to reduce the number of files.
* Improvements to template processing code, deduplicated some code.

.. _`PEP 8`: https://www.python.org/dev/peps/pep-0008/

0.4.1 (2015-09-22)
------------------
Expand Down
4 changes: 0 additions & 4 deletions docs/pydl/goddard.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,9 @@ API
+++

.. automodapi:: pydl.goddard
:no-inheritance-diagram:

.. automodapi:: pydl.goddard.astro
:no-inheritance-diagram:

.. automodapi:: pydl.goddard.math
:no-inheritance-diagram:

.. automodapi:: pydl.goddard.misc
:no-inheritance-diagram:
4 changes: 0 additions & 4 deletions docs/pydl/photoop.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,9 @@ API
+++

.. automodapi:: pydl.photoop
:no-inheritance-diagram:

.. automodapi:: pydl.photoop.photoobj
:no-inheritance-diagram:

.. automodapi:: pydl.photoop.sdssio
:no-inheritance-diagram:

.. automodapi:: pydl.photoop.window
:no-inheritance-diagram:
3 changes: 0 additions & 3 deletions docs/pydl/pydlspec2d.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@ API
+++

.. automodapi:: pydl.pydlspec2d
:no-inheritance-diagram:

.. automodapi:: pydl.pydlspec2d.spec1d
:no-inheritance-diagram:

.. automodapi:: pydl.pydlspec2d.spec2d
:no-inheritance-diagram:
15 changes: 3 additions & 12 deletions docs/pydl/pydlutils.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,37 +14,28 @@ API
+++

.. automodapi:: pydl.pydlutils
:no-inheritance-diagram:

.. automodapi:: pydl.pydlutils.bspline
:no-inheritance-diagram:

.. automodapi:: pydl.pydlutils.cooling
:no-inheritance-diagram:

.. automodapi:: pydl.pydlutils.coord
:no-inheritance-diagram:

.. automodapi:: pydl.pydlutils.image
:no-inheritance-diagram:

.. automodapi:: pydl.pydlutils.mangle
:no-inheritance-diagram:

.. automodapi:: pydl.pydlutils.math
:no-inheritance-diagram:

.. automodapi:: pydl.pydlutils.misc
:no-inheritance-diagram:

.. automodapi:: pydl.pydlutils.sdss
:no-inheritance-diagram:

.. automodapi:: pydl.pydlutils.spheregroup
:no-inheritance-diagram:
:skip: PydlutilsException, PydlutilsUserWarning

.. automodapi:: pydl.pydlutils.trace
:no-inheritance-diagram:
:skip: PydlutilsException, flegendre

.. automodapi:: pydl.pydlutils.yanny
:no-inheritance-diagram:
:skip: PydlutilsException
3 changes: 3 additions & 0 deletions docs/pydl/todo.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ TODO
====

* Lots of tests!
* Allow yanny files to be read and written to/from the
:class:`~astropy.table.Table` class.
* Complete consolidation of the template processing code.
12 changes: 7 additions & 5 deletions pydl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,17 @@
# For egg_info test builds to pass, put package imports here.
if not _ASTROPY_SETUP_:
from .file_lines import file_lines
from .median import median
from .pcomp import pcomp
from .smooth import smooth
from .uniq import uniq
from . import goddard
from . import photoop
from . import pydlutils
from . import pydlspec2d
# from . import goddard
# from . import photoop
# from . import pydlutils
# from . import pydlspec2d


class PydlException(Exception):
pass

__all__ = ['file_lines', 'pcomp', 'smooth', 'uniq', 'PydlException']
__all__ = ['file_lines', 'median', 'pcomp', 'smooth', 'uniq', 'PydlException']
3 changes: 3 additions & 0 deletions pydl/_astropy_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,14 @@
__githash__ = ''

# set up the test command


def _get_test_runner():
import os
from astropy.tests.helper import TestRunner
return TestRunner(os.path.dirname(__file__))


def test(package=None, test_path=None, args=None, plugins=None,
verbose=False, pastebin=None, remote_data=False, pep8=False,
pdb=False, coverage=False, open_files=False, **kwargs):
Expand Down
20 changes: 10 additions & 10 deletions pydl/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,27 @@

from astropy.tests.pytest_plugins import *

## Uncomment the following line to treat all DeprecationWarnings as
## exceptions
# Uncomment the following line to treat all DeprecationWarnings as
# exceptions
# 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
# 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
try:
PYTEST_HEADER_MODULES['Astropy'] = 'astropy'
PYTEST_HEADER_MODULES['pydl'] = 'pydl'
del PYTEST_HEADER_MODULES['h5py']
except NameError: # 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.
# 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 affiliated package version, rather than
## using Astropy's
# This is to figure out the affiliated package version, rather than
# using Astropy's
from . import version

try:
Expand Down
16 changes: 8 additions & 8 deletions pydl/file_lines.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
# Licensed under a 3-clause BSD style license - see LICENSE.rst
# -*- coding: utf-8 -*-
from __future__ import absolute_import, division, print_function, unicode_literals
from astropy.extern import six


def file_lines(path,compress=False):
"""Replicates the IDL FILE_LINES() function.
def file_lines(path, compress=False):
"""Replicates the IDL ``FILE_LINES()`` function.
Given a path to a file name or a list of such paths, returns the number of
lines in the file(s).
Expand All @@ -15,17 +13,18 @@ def file_lines(path,compress=False):
path : :class:`str` or :class:`list` of :class:`str`
Path to a file. Can be a list of paths.
compress : :class:`bool`, optional
If set to ``True``, assumes that all files in `path` are GZIP compressed.
If set to ``True``, assumes that all files in `path` are GZIP
compressed.
Returns
-------
file_lines : :class:`int` or :class:`list` of :class:`int`
:class:`int` or :class:`list` of :class:`int`
The number of lines in `path`. Returns a list of lengths if a list of
files is supplied.
Notes
-----
The ``/NOEXPAND_PATH`` option in IDL's FILE_LINES() is not implemented.
The ``/NOEXPAND_PATH`` option in IDL's ``FILE_LINES()`` is not implemented.
References
----------
Expand All @@ -38,8 +37,9 @@ def file_lines(path,compress=False):
>>> file_lines(join(dirname(__file__),'tests','t','this-file-contains-42-lines.txt'))
42
"""
from astropy.extern.six import string_types
scalar = False
if isinstance(path, six.string_types):
if isinstance(path, string_types):
working_path = [path]
scalar = True
else:
Expand Down
18 changes: 0 additions & 18 deletions pydl/goddard/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,3 @@
"""
This subpackage contains the Goddard utilities.
"""
#
# Define this early on so that submodules can use it
#
#from .. import PydlException
#class GoddardException(PydlException):
# pass
#class GoddardException(Exception):
# pass
#
# Import subpackages
#
from . import astro
from . import math
from . import misc
#
# Set __all__
#
__all__ = ['astro', 'math', 'misc']
Loading

0 comments on commit d9d7672

Please sign in to comment.