Skip to content

Commit

Permalink
Merge 1ded1c3 into 1b39ac9
Browse files Browse the repository at this point in the history
  • Loading branch information
jason-neal committed Aug 28, 2018
2 parents 1b39ac9 + 1ded1c3 commit 0aa480f
Show file tree
Hide file tree
Showing 29 changed files with 1,075 additions and 748 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@

.mypy_cache/
.pytest_cache/
monkeytype.sqlite3

# pycharm
.idea/

Expand Down
7 changes: 7 additions & 0 deletions .isort.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[settings]
known_third_party = PyAstronomy,astropy,hypothesis,matplotlib,numpy,pkg_resources,pytest,scipy,setuptools,sphinx_rtd_theme
multi_line_output=3
include_trailing_comma=True
force_grid_wrap=0
combine_as_imports=True
line_length=88
39 changes: 39 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
exclude: '^$'
fail_fast: false
repos:
- repo: https://github.com/asottile/seed-isort-config
rev: v1.2.0
hooks:
- id: seed-isort-config
- repo: https://github.com/pre-commit/mirrors-isort
rev: v4.3.4
hooks:
- id: isort

- repo: https://github.com/ambv/black
rev: 18.6b4
hooks:
- id: black
language_version: python3.6

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v1.4.0 # Use the ref you want to point at
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-ast
- id: check-builtin-literals
- id: check-docstring-first
# - id: check-executables-have-shebangs # Doesn't work on windows
- id: check-merge-conflict
- id: check-json
- id: check-added-large-files
- id: check-yaml
# - id: double-quote-string-fixer
- id: debug-statements
- id: name-tests-test
args: ['--django']
- id: requirements-txt-fixer
# - id: flake8
- id: pretty-format-json
- id: sort-simple-yaml
File renamed without changes.
15 changes: 3 additions & 12 deletions .shippable.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
language: python
python:
- 2.7
- 3.5
- 3.6
- 3.7

before_install:
# http://conda.pydata.org/docs/travis.html
- if [[ "$TRAVIS_PYTHON_VERSION" == "2.7" ]]; then
travis_retry wget https://repo.continuum.io/miniconda/Miniconda2-latest-Linux-x86_64.sh -O miniconda.sh;
else
travis_retry wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh;
fi
- sudo apt-get update
- wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh;
- bash miniconda.sh -b -p $HOME/miniconda
- export PATH="$HOME/miniconda/bin:$PATH"
- hash -r
Expand All @@ -25,7 +20,7 @@ cache:
- $HOME/.cache/pip

install:
- conda create -q -n test-environment python=$TRAVIS_PYTHON_VERSION numpy scipy astropy
- conda create -q -n test-environment python=$TRAVIS_PYTHON_VERSION astropy numpy scipy
- source activate test-environment

- travis_retry pip install -r requirements.txt
Expand All @@ -42,7 +37,3 @@ build:
# Run test and code coverage and output results to the right folder
- pytest --junitxml=shippable/testresults/nosetests.xml
- pytest --cov=. --cov-report=xml:shippable/codecoverage/coverage.xml --durations=10
# - pytest --cov=. --cov-report term-missing

after_success:
- coverage xml -i
10 changes: 3 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,14 @@ dist: xenial
sudo: true
language: python
python:
- "2.7"
- "3.5"
- "3.6"
- "3.7"

before_install:
# http://conda.pydata.org/docs/travis.html
- if [[ "$TRAVIS_PYTHON_VERSION" == "2.7" ]]; then
travis_retry wget https://repo.continuum.io/miniconda/Miniconda2-latest-Linux-x86_64.sh -O miniconda.sh;
else
travis_retry wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh;
fi
- travis_retry sudo apt-get update
- travis_retry wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh
- bash miniconda.sh -b -p $HOME/miniconda
- export PATH="$HOME/miniconda/bin:$PATH"
- hash -r
Expand All @@ -35,7 +31,7 @@ install:
- python setup.py install

script:
- pytest --cov=spectrum_overload --cov-report=term-missing --durations 10
- pytest --cov=spectrum_overload --cov-report term-missing --durations 10 -W error::UserWarning
- coverage xml -i

after_success:
Expand Down
42 changes: 34 additions & 8 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,53 @@
# Spectrum Overload
# Spectrum Overload
## Changelog

Upcoming release:


### 0.3.0
- Simplified overload operator function.
- Add instrument broadening
- Add indexing/slicing spectrum with [], (Returns new spectrum)
- Add more Type hints
- Handle all warnings as errors in testing.
- Fix test parameters to avoid invalid values.
- Move test fixtures
- Test on python 3.7.
- Add makefile
- Add Appveyor and shippable configuration.
- Some general cleanup
- Update requirements to latest versions.
- Add pre-commits

##### Depreciations:
- Drop support for python 2.7
- Due xaxis and flux keywords required with "*,".
- Drop testing of python 3.4.
- Remove tox.ini


### 0.2.2 28/8/2018
- Add styling for markdown in long description.
- Testing on python 3.7

## 0.2.1 14/01/2018
- Patch try resolve pypi styling


### October 2017
For next version
## 0.2.0 14/01/2018
- Add hypothesis profiles for different test environments.
- Change header initialization from None to and empty dict
- Add normalization e.g.
- Spectrum.normalize("poly", degree=3)
- Add spectrum plot method.
- Standardize operations using a operator wrapper.
- Update documetation.
- Updated documetation.


Version 0..
## Version <0.2.0
Before october 2017
Many changes that were unrecorded in this change log...
Spectrum object with interpolation and overloaded operators.
- Many changes that were unrecorded in this change log...
- Spectrum object with interpolation and overloaded operators.


Started September 2016
Project started: September 2016
5 changes: 2 additions & 3 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
include README.md
recursive-include spectrum_overload/data *
recursive-include Notebooks *
recursive-include docs *

recursive-include Notebooks *
recursive-include docs *
63 changes: 63 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# Python makefile https://krzysztofzuraw.com/blog/2016/makefiles-in-python-projects.html
# Delcare all non-file targets as phony
.PHONY: clean clean-build clean-data data isort lint test
TEST_PATH=./

help:
@echo " clean-pyc"
@echo " Remove python artifacts."
@echo " clean-build"
@echo " Remove build artifacts."
@echo " isort"
@echo " Sort import statements."
@echo " lint"
@echo " Check style with flake8."
@echo " test"
@echo " Run py.test"
@echo " test-warn"
@echo " Run py.test with warnings errored"
@echo " init"
@echo " Initalize by installing requirements"
@echo " init-dev"
@echo " Initalize by installing normal and dev requirements"
@echo " cov"
@echo " Produce coverage report"
@echo " mypy"
@echo " Run type checking with mypy"

clean-pyc:
find . -name '*.pyc' -exec rm --force {} +
find . -name '*.pyo' -exec rm --force {} +
find . -name '*~' -exec rm --force {} +

clean-build:
rm --force --recursive build/
rm --force --recursive dist/
rm --force --recursive *.egg-info

isort:
sh -c "isort --recursive . "

lint:
flake8 --exclude=.tox

test: clean-pyc
pytest --verbose --color=yes $(TEST_PATH)

test-warn: clean-pyc
pytest --verbose --color=yes $(TEST_PATH) -o "filterwarnings=error"

init:
pip install -r requirements.txt

init-dev:
pip install -r requirements.txt
pip install -r requirements_dev.txt

cov: $(module)/*
py.test --cov=$(module)
coverage html

mypy:
# py.test --mypy
mypy --ignore-missing-imports .
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
[![PyPI version](https://badge.fury.io/py/spectrum-overload.svg)](https://badge.fury.io/py/spectrum-overload)[![Updates](https://pyup.io/repos/github/jason-neal/spectrum_overload/shield.svg)](https://pyup.io/repos/github/jason-neal/spectrum_overload/)[![Python 3](https://pyup.io/repos/github/jason-neal/spectrum_overload/python-3-shield.svg)](https://pyup.io/repos/github/jason-neal/spectrum_overload/)

[![Documentation Status](https://readthedocs.org/projects/spectrum-overload/badge/?version=latest)](http://spectrum-overload.readthedocs.io/en/latest/?badge=latest) [![Build Status](https://travis-ci.org/jason-neal/spectrum_overload.svg?branch=master)](https://travis-ci.org/jason-neal/spectrum_overload) [![Coverage Status](https://coveralls.io/repos/github/jason-neal/spectrum_overload/badge.svg?branch=master)](https://coveralls.io/github/jason-neal/spectrum_overload?branch=master) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/3e9a2cf4ad914e0ebc24b6b2b83059db)](https://www.codacy.com/app/jason-neal/spectrum_overload?utm_source=github.com&utm_medium=referral&utm_content=jason-neal/spectrum_overload&utm_campaign=badger)[![Test Coverage](https://codeclimate.com/github/jason-neal/spectrum_overload/badges/coverage.svg)](https://codeclimate.com/github/jason-neal/spectrum_overload/coverage) [![Code Climate](https://codeclimate.com/github/jason-neal/spectrum_overload/badges/gpa.svg)](https://codeclimate.com/github/jason-neal/spectrum_overload)[![Issue Count](https://codeclimate.com/github/jason-neal/spectrum_overload/badges/issue_count.svg)](https://codeclimate.com/github/jason-neal/spectrum_overload)


## Overview
The purpose of this was project was to learn how to use and create Classes, and to create a Spectrum object to use within my Phd work.
Expand All @@ -22,10 +22,10 @@ Further documentation can be found on [read the docs](https://spectrum-overload.

## Installation
### Pip

pip install spectrum-overload

### git / manual
### git / manual
Currently to install and use Spectrum class for your own projects.

clone the git repository where you want it then type:
Expand All @@ -52,7 +52,7 @@ or :

or how ever else you would like to import it.

A tutorial is provided [here](Notebooks/Tutorial.ipynb) to show an example of how to use this class.
A tutorial is provided [here](Notebooks/Tutorial.ipynb) to show an example of how to use this class.


## Contributions
Expand All @@ -63,6 +63,9 @@ I would really appreciate user feedback or suggested improvements if you have an
Feel free to submit issues or create pull requests.


## Python 2.7
Python 2.7 is only supported in versions <0.2.1 (also available on pip) to make use of useful python3 features.


## Other Spectrum Classes

Expand Down
19 changes: 6 additions & 13 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@ environment:
matrix:
# For Python versions available on Appveyor, see
# http://www.appveyor.com/docs/installed-software#python
- PYTHON: "C:\\Python27"
- PYTHON: "C:\\Python35"
- PYTHON: "C:\\Python36"
- PYTHON: "C:\\Python37"
- PYTHON: "C:\\Python27-x64"
- PYTHON: "C:\\Python35-x64"
- PYTHON: "C:\\Python36-x64"
- PYTHON: "C:\\Python37-x64"
Expand All @@ -16,29 +14,24 @@ install:
- "%PYTHON%\\python.exe -m pip install wheel"

# Install spectrum_overload
- "%PYTHON%\\python.exe -m pip install -r requirements.txt"
- "%PYTHON%\\python.exe -m pip install -r requirements_dev.txt"
- "%PYTHON%\\python.exe setup.py install"
- cmd: "cd %APPVEYOR_BUILD_FOLDER%"
- cmd: "%PYTHON%\\python.exe -m pip install -r requirements.txt"
- cmd: "%PYTHON%\\python.exe -m pip install -r requirements_dev.txt"
- cmd: "%PYTHON%\\python.exe setup.py install"

build: off

test_script:
# Put your test command here.
# If you don't need to build C extensions on 64-bit Python 3.3 or 3.4,
# you can remove "build.cmd" from the front of the command, as it's
# only needed to support those cases.
# Note that you must use the environment variable %PYTHON% to refer to
# the interpreter you're using - Appveyor does not do anything special
# to put the Python version you want to use on PATH.
- cmd: "%PYTHON%\\python.exe -m pytest --cov=. --cov-report term-missing --durations 10"
- cmd: "%PYTHON%\\python.exe -m pytest --cov=spectrum_overload --cov-report term-missing --durations 10"
- cmd: "%PYTHON%\\python.exe -m coverage xml -i"

after_test:
# This step builds your wheels.
# Again, you only need build.cmd if you're building C extensions for
# 64-bit Python 3.3/3.4. And you need to use %PYTHON% to get the correct
# interpreter
- "%PYTHON%\\python.exe setup.py bdist_wheel"
- cmd: "%PYTHON%\\python.exe setup.py bdist_wheel"

artifacts:
# bdist_wheel puts your built wheel in the dist directory
Expand Down
34 changes: 31 additions & 3 deletions conftest.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,35 @@
import os
from hypothesis import settings, Verbosity

import numpy as np
import pytest
from astropy.io import fits
from hypothesis import Verbosity, settings
from pkg_resources import resource_filename

from spectrum_overload import Spectrum

settings.register_profile("ci", settings(max_examples=1000))
settings.register_profile("rpi", settings(max_examples=2))
settings.register_profile("dev", settings(max_examples=10))
settings.register_profile("debug", settings(max_examples=10, verbosity=Verbosity.verbose))
settings.load_profile(os.getenv(u'HYPOTHESIS_PROFILE', 'default'))
settings.register_profile(
"debug", settings(max_examples=10, verbosity=Verbosity.verbose)
)
settings.load_profile(os.getenv(u"HYPOTHESIS_PROFILE", "default"))


@pytest.fixture
def phoenix_spectrum():
# Get a phoenix spectrum in test
spec_1 = resource_filename("spectrum_overload", "data/spec_1.fits")
flux = fits.getdata(spec_1)
wave = np.arange(len(flux))
header = fits.getheader(spec_1)
return Spectrum(xaxis=wave, flux=flux, header=header)


@pytest.fixture
def ones_spectrum():
x = np.linspace(2000, 2200, 1000)
y = np.ones_like(x)
spec = Spectrum(xaxis=x, flux=y)
return spec
Loading

0 comments on commit 0aa480f

Please sign in to comment.