Skip to content

Commit efd774d

Browse files
committed
Merge pull request #41 from ocefpaf/py3k
Python 3 support and Travis-CI boilerplate.
2 parents 7236f5e + 374b631 commit efd774d

File tree

7 files changed

+60
-12
lines changed

7 files changed

+60
-12
lines changed

.travis.yml

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
language: python
2+
3+
env:
4+
- CONDA="python=2.7"
5+
- CONDA="python=3.4"
6+
- CONDA="python=3.5"
7+
8+
before_install:
9+
- wget http://bit.ly/miniconda -O miniconda.sh
10+
- bash miniconda.sh -b -p $HOME/miniconda
11+
- export PATH="$HOME/miniconda/bin:$PATH"
12+
- conda update --yes conda
13+
- travis_retry conda create --yes -n TEST $CONDA --file requirements.txt
14+
- source activate TEST
15+
- travis_retry conda install --yes pytest
16+
17+
script:
18+
- python setup.py test

cmocean/__init__.py

+8-4
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,14 @@
55
See README.md for an overview on instructions.
66
'''
77

8+
from __future__ import absolute_import
9+
810
# from cmocean import *
9-
from cmocean import cm
10-
from cmocean import tools
11-
from cmocean import plots
12-
from cmocean import data
11+
from . import cm, tools, plots, data
12+
13+
__all__ = ['cm',
14+
'tools',
15+
'plots',
16+
'data']
1317

1418
__authors__ = ['Kristen Thyng <[email protected]>']

cmocean/cm.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,16 @@
1919
Used tool from http://bids.github.io/colormap/ to redo colormaps to be more perceptually correct.
2020
'''
2121

22+
from __future__ import absolute_import
23+
2224
# from matplotlib import cm, colors
23-
from cmocean import tools
2425
import matplotlib
2526
# import plotting
2627
# import data
2728
import numpy as np
2829
import os
2930

31+
from . import tools
3032

3133
# Location of rgb files
3234
datadir = os.path.join(os.path.split(__file__)[0], 'rgb')

cmocean/plots.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,16 @@
22
Plots with colormaps.
33
'''
44

5-
from cmocean import cm
5+
from __future__ import absolute_import
6+
67
import matplotlib.pyplot as plt
78
import numpy as np
89
import matplotlib as mpl
9-
from cmocean import tools
1010
# from skimage import color
1111

12+
from . import cm
13+
from . import tools
14+
1215

1316
mpl.rcParams.update({'font.size': 14})
1417
mpl.rcParams['font.sans-serif'] = 'Arev Sans, Bitstream Vera Sans, Lucida Grande, Verdana, Geneva, Lucid, Helvetica, Avant Garde, sans-serif'

cmocean/tools.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ def get_dict(cmap, N=256):
5151
r2 = rgb[:, 0]
5252

5353
# Creating tuples
54-
R = zip(x, r2, r3)
55-
G = zip(x, g2, g3)
56-
B = zip(x, b2, b3)
54+
R = list(zip(x, r2, r3))
55+
G = list(zip(x, g2, g3))
56+
B = list(zip(x, b2, b3))
5757

5858
# Creating dictionary
5959
k = ['red', 'green', 'blue']

requirements.txt

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
numpy
2+
matplotlib

setup.py

+21-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
66
"""
77
# import shutil
8+
import sys
89
from setuptools import setup # to support "develop" mode
10+
from setuptools.command.test import test as TestCommand
911
# from numpy.distutils.core import setup, Extension
1012

1113
# cmocean_mod = Extension(name = "cmocean",
@@ -15,6 +17,20 @@
1517

1618
# print cmocean_mod
1719

20+
class PyTest(TestCommand):
21+
def finalize_options(self):
22+
TestCommand.finalize_options(self)
23+
self.verbose = True
24+
25+
def run_tests(self):
26+
import pytest
27+
errno = pytest.main(self.test_args)
28+
sys.exit(errno)
29+
30+
with open('requirements.txt') as f:
31+
require = f.readlines()
32+
install_requires = [r.strip() for r in require]
33+
1834
setup(
1935
name = "cmocean",
2036
version = "0.1",
@@ -30,11 +46,14 @@
3046
],
3147
package_data={
3248
'cmocean': ['rgb/*.txt'],
33-
},
49+
},
3450
packages = ["cmocean"],
3551
# py_modules = cmocean_mod,
36-
ext_package='cmocean',
52+
ext_package='cmocean',
3753
# ext_modules = [cmocean_mod],
3854
scripts = [],
3955
keywords = ['colormaps', 'oceanography', 'plotting', 'visualization'],
56+
tests_require=['pytest'],
57+
cmdclass=dict(test=PyTest),
58+
install_requires=install_requires,
4059
)

0 commit comments

Comments
 (0)