Skip to content

Commit 79cb9a9

Browse files
authored
Merge pull request #22 from ocefpaf/travis
Many Travis-CI config updates...
2 parents cc9b2fc + e41c963 commit 79cb9a9

138 files changed

Lines changed: 205 additions & 299 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.travis.yml

Lines changed: 30 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -7,37 +7,44 @@ matrix:
77
include:
88
- python: 2.7
99
env: TEST_TARGET=default
10-
- python: 3.4
11-
env: TEST_TARGET=default
1210
- python: 3.5
1311
env: TEST_TARGET=default
14-
- python: 3.5
15-
env: TEST_TARGET=coding_standards
16-
allow_failures:
17-
- python: 3.5
12+
- python: 3.6
13+
env: TEST_TARGET=default
14+
- python: 2.7
15+
env: TEST_TARGET=doctest
16+
- python: 3.6
17+
env: TEST_TARGET=doctest
18+
- python: 3.6
1819
env: TEST_TARGET=coding_standards
1920

2021
before_install:
21-
- wget http://bit.ly/miniconda -O miniconda.sh
22-
- bash miniconda.sh -b -p $HOME/miniconda
23-
- export PATH="$HOME/miniconda/bin:$PATH"
24-
- conda update --all --yes
25-
- conda config --add channels conda-forge -f
26-
- conda create --yes -n TEST python=$TRAVIS_PYTHON_VERSION --file requirements.txt --file requirements-dev.txt
27-
- source activate TEST
28-
- travis_retry conda install --yes pytest # GUI
29-
- "export DISPLAY=:99.0"
30-
- "sh -e /etc/init.d/xvfb start"
22+
- wget http://bit.ly/miniconda -O miniconda.sh
23+
- bash miniconda.sh -b -p $HOME/miniconda
24+
- export PATH="$HOME/miniconda/bin:$PATH"
25+
- conda config --set always_yes yes --set changeps1 no --set show_channel_urls true
26+
- conda update conda
27+
- conda config --add channels conda-forge --force
28+
- conda create -n TEST python=$TRAVIS_PYTHON_VERSION --file requirements.txt --file requirements-dev.txt
29+
- source activate TEST
30+
# GUI
31+
- "export DISPLAY=:99.0"
32+
- "sh -e /etc/init.d/xvfb start"
3133

3234
# Test source distribution.
3335
install:
34-
- python setup.py sdist && version=$(python setup.py --version) && pushd dist && pip install ctd-${version}.tar.gz && popd
36+
- python setup.py sdist && version=$(python setup.py --version) && pushd dist && pip install ctd-${version}.tar.gz && popd
3537

3638
script:
37-
- if [[ $TEST_TARGET == 'default' ]]; then
38-
py.test -vv ;
39-
fi
39+
- if [[ $TEST_TARGET == 'default' ]]; then
40+
py.test -s -rxs -v tests ;
41+
fi
42+
43+
- if [[ $TEST_TARGET == 'doctest' ]]; then
44+
py.test -s -rxs --doctest-modules -vv ctd ;
45+
fi
4046

41-
- if [[ $TEST_TARGET == 'coding_standards' ]]; then
42-
find . -type f -name "*.py" ! -name 'conf.py' | xargs flake8 --max-line-length=100 ;
43-
fi
47+
- if [[ $TEST_TARGET == 'coding_standards' ]]; then
48+
flake8 --max-line-length=100 ctd ;
49+
flake8 --max-line-length=100 tests ;
50+
fi

LICENSE.txt

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,11 @@
1-
The MIT License (MIT)
1+
Copyright 2017 Filipe Fernandes
22

3-
Copyright (c) 2013 Filipe
3+
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
44

5-
Permission is hereby granted, free of charge, to any person obtaining a copy of
6-
this software and associated documentation files (the "Software"), to deal in
7-
the Software without restriction, including without limitation the rights to
8-
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9-
the Software, and to permit persons to whom the Software is furnished to do so,
10-
subject to the following conditions:
5+
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
116

12-
The above copyright notice and this permission notice shall be included in all
13-
copies or substantial portions of the Software.
7+
2. 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.
148

15-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17-
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18-
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19-
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20-
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
9+
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
10+
11+
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.

MANIFEST.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
include README.rst
22
include *.txt
3-
include ctd/*.py
3+
recursive-include ctd *.py

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ python-ctd
1010
.. image:: http://img.shields.io/travis/pyoceans/python-ctd/master.svg?style=flat
1111
:target: https://travis-ci.org/pyoceans/python-ctd
1212
:alt: Build_status
13-
.. image:: http://img.shields.io/badge/license-MIT-blue.svg?style=flat
13+
.. image:: http://img.shields.io/badge/license-BSD-blue.svg?style=flat
1414
:target: https://github.com/pyoceans/python-ctd/blob/master/LICENSE.txt
1515
:alt: license
1616

ctd/__init__.py

Lines changed: 49 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,56 @@
1-
from __future__ import absolute_import, unicode_literals
1+
from __future__ import (absolute_import, division, print_function)
22

3-
__version__ = '0.2.3'
3+
__version__ = '0.3.0'
44

5-
from pandas import Index, Series, DataFrame
5+
from pandas import DataFrame, Index, Series
66

7-
from .ctd import asof, from_edf, from_cnv, from_fsi, rosette_summary
8-
from .processing import (data_conversion, align, despike, lp_filter,
9-
cell_thermal_mass, press_check, bindata, split,
10-
movingaverage, pmel_inversion_check, smooth,
11-
mixed_layer_depth, barrier_layer_thickness,
12-
derive_cnv)
13-
from .plotting import (get_maxdepth, extrap_sec, gen_topomask, plot, plot_vars,
14-
plot_section)
7+
from .ctd import asof, from_cnv, from_edf, from_fsi, rosette_summary
8+
from .plotting import (
9+
extrap_sec,
10+
gen_topomask,
11+
get_maxdepth,
12+
plot,
13+
plot_section,
14+
plot_vars,
15+
)
16+
from .processing import (
17+
barrier_layer_thickness,
18+
bindata,
19+
cell_thermal_mass,
20+
derive_cnv,
21+
despike,
22+
lp_filter,
23+
mixed_layer_depth,
24+
movingaverage,
25+
press_check,
26+
smooth,
27+
split,
28+
)
1529

30+
__all__ = [
31+
asof,
32+
barrier_layer_thickness,
33+
bindata,
34+
cell_thermal_mass,
35+
derive_cnv,
36+
despike,
37+
extrap_sec,
38+
from_cnv,
39+
from_edf,
40+
from_fsi,
41+
gen_topomask,
42+
get_maxdepth,
43+
lp_filter,
44+
mixed_layer_depth,
45+
movingaverage,
46+
plot,
47+
plot_section,
48+
plot_vars,
49+
press_check,
50+
rosette_summary,
51+
smooth,
52+
split,
53+
]
1654

1755
# Attach methods.
1856
Index.asof = asof

ctd/ctd.py

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,22 @@
1-
from __future__ import absolute_import, unicode_literals
1+
from __future__ import (absolute_import, division, print_function)
22

3-
# Standard library.
43
import os
54
import warnings
65

7-
# Scientific stack.
86
import numpy as np
7+
98
from pandas import DataFrame
109
from pandas import read_table
1110

12-
from .utilities import read_file, basename, normalize_names
13-
14-
data_path = os.path.join(os.path.dirname(__file__), 'tests', 'data')
11+
from .utilities import basename, normalize_names, read_file
1512

16-
__all__ = ['CTD',
17-
'asof',
18-
'from_edf',
19-
'from_cnv',
20-
'from_fsi',
21-
'rosette_summary']
13+
data_path = os.path.join(
14+
os.path.dirname(os.path.dirname(__file__)), 'tests', 'data'
15+
)
2216

2317

24-
# TODO: https://github.com/nilmtk/nilmtk/issues/83
2518
def asof(self, label):
26-
"""FIXME: pandas index workaround."""
19+
"""pandas index workaround."""
2720
if label not in self:
2821
loc = self.searchsorted(label, side='left')
2922
if loc > 0:
@@ -178,7 +171,7 @@ def from_cnv(fname, compression=None, below_water=False, lon=None,
178171
elif hemisphere == 'N':
179172
lat = lat[0] + lat[1] / 60.
180173
else:
181-
raise ValueError("Latitude not recognized.")
174+
raise ValueError('Latitude not recognized.')
182175
if 'NMEA Longitude' in line:
183176
hemisphere = line[-1]
184177
lon = line.strip(hemisphere).split('=')[1].strip()
@@ -188,7 +181,7 @@ def from_cnv(fname, compression=None, below_water=False, lon=None,
188181
elif hemisphere == 'E':
189182
lon = lon[0] + lon[1] / 60.
190183
else:
191-
raise ValueError("Latitude not recognized.")
184+
raise ValueError('Latitude not recognized.')
192185
if line == '*END*': # Get end of header.
193186
skiprows = k + 1
194187
break
@@ -280,6 +273,7 @@ def rosette_summary(fname):
280273
ros.set_index('nbf', drop=True, inplace=True, verify_integrity=False)
281274
return ros
282275

276+
283277
if __name__ == '__main__':
284278
import doctest
285279
doctest.testmod()

ctd/plotting.py

Lines changed: 24 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,20 @@
11
# -*- coding: utf-8 -*-
22

3-
from __future__ import absolute_import, unicode_literals
43

5-
# Scientific stack.
6-
import numpy as np
7-
import numpy.ma as ma
4+
from __future__ import (absolute_import, division, print_function)
5+
86
import matplotlib.pyplot as plt
7+
98
import mpl_toolkits.axisartist as AA
109

11-
from pandas import Series
1210
from mpl_toolkits.axes_grid1 import host_subplot
1311

14-
from .utilities import extrap1d
12+
import numpy as np
13+
import numpy.ma as ma
1514

16-
__all__ = ['get_maxdepth',
17-
'extrap_sec',
18-
'gen_topomask',
19-
'plot',
20-
'plot_vars',
21-
'plot_section']
15+
from pandas import Series
16+
17+
from .utilities import extrap1d
2218

2319

2420
def get_maxdepth(self):
@@ -159,20 +155,20 @@ def plot_vars(self, variables=None, **kwds):
159155

160156
# Axis location.
161157
host_new_axis = ax0.get_grid_helper().new_fixed_axis
162-
ax0.axis["bottom"] = host_new_axis(loc="top", axes=ax0, offset=(0, 0))
158+
ax0.axis['bottom'] = host_new_axis(loc='top', axes=ax0, offset=(0, 0))
163159
par_new_axis = ax1.get_grid_helper().new_fixed_axis
164-
ax1.axis["top"] = par_new_axis(loc="bottom", axes=ax1, offset=(0, 0))
160+
ax1.axis['top'] = par_new_axis(loc='bottom', axes=ax1, offset=(0, 0))
165161

166162
ax0.plot(self[variables[0]], self.index, 'r.', label='Temperature')
167163
ax1.plot(self[variables[1]], self.index, 'b.', label='Salinity')
168164

169-
ax0.set_ylabel("Pressure [dbar]")
170-
ax0.set_xlabel("Temperature [\u00b0C]")
171-
ax1.set_xlabel("Salinity [kg g$^{-1}$]")
165+
ax0.set_ylabel('Pressure [dbar]')
166+
ax0.set_xlabel('Temperature [\u00b0C]')
167+
ax1.set_xlabel('Salinity [kg g$^{-1}$]')
172168
ax1.invert_yaxis()
173169

174-
try: # FIXME with metadata.
175-
fig.suptitle(r"Station %s profile" % self.name)
170+
try:
171+
fig.suptitle(r'Station %s profile' % self.name)
176172
except AttributeError:
177173
pass
178174

@@ -202,10 +198,11 @@ def plot_section(self, reverse=False, filled=False, **kw):
202198
lat = lat[::-1]
203199
data = data.T[::-1].T
204200
h = h[::-1]
201+
lon, lat = map(np.atleast_2d, (lon, lat))
205202
x = np.append(0, np.cumsum(gsw.distance(lon, lat)[0] / 1e3))
206203
z = self.index.values.astype(float)
207204

208-
if filled: # FIXME: Cause discontinuities.
205+
if filled: # CAVEAT: this method cause discontinuities.
209206
data = data.filled(fill_value=np.nan)
210207
data = extrap_sec(data, x, z, w1=0.97, w2=0.03)
211208

@@ -257,18 +254,13 @@ def plot_section(self, reverse=False, filled=False, **kw):
257254
ax.xaxis.set_tick_params(tickdir='out', labelsize=labelsize, pad=1)
258255
ax.yaxis.set_tick_params(tickdir='out', labelsize=labelsize, pad=1)
259256

260-
if False: # TODO: +/- Black-and-White version.
261-
cs = ax.contour(x, z, data, colors='grey', levels=levels,
262-
extend=extend, linewidths=1., alpha=1., zorder=2)
263-
ax.clabel(cs, fontsize=8, colors='grey', fmt=fmt, zorder=1)
264-
cb = None
265-
if True: # Color version.
266-
cs = ax.contourf(x, z, data, cmap=cmap, levels=levels, alpha=1.,
267-
extend=extend, zorder=2) # manual=True
268-
# Colorbar.
269-
cb = fig.colorbar(mappable=cs, ax=ax, orientation='vertical',
270-
aspect=aspect, shrink=shrink, fraction=fraction,
271-
pad=pad)
257+
# Color version.
258+
cs = ax.contourf(x, z, data, cmap=cmap, levels=levels, alpha=1.,
259+
extend=extend, zorder=2) # manual=True
260+
# Colorbar.
261+
cb = fig.colorbar(mappable=cs, ax=ax, orientation='vertical',
262+
aspect=aspect, shrink=shrink, fraction=fraction,
263+
pad=pad)
272264
return fig, ax, cb
273265

274266

0 commit comments

Comments
 (0)