8000 Merge branch 'master' into check-sharekey · skytree-brian/plotly.py@3406034 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3406034

Browse files
committed
Merge branch 'master' into check-sharekey
2 parents bbb3cec + 183a577 commit 3406034

File tree

9 files changed

+692
-49
lines changed

9 files changed

+692
-49
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,15 @@ This project adheres to [Semantic Versioning](http://semver.org/).
44

55
## [Unreleased]
66

7+
## [1.8.7] - 2015-10-01
8+
### Added
9+
- The FigureFactory can now create dendrogram plots with `.create_dendrogram`.
10+
711
## [1.8.6] - 2015-09-28
12+
### Fixed
813
- Saving "world_readable" to your config file via `plotly.tools.set_config` actually works.
14+
15+
### Added
916
- You can also save `auto_open` and `sharing` to the config file so that you can forget these
1017
keyword argument in `py.iplot` and `py.plot`.
1118

circle.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
11
machine:
2+
23
environment:
4+
35
PLOTLY_PACKAGE_ROOT: /home/ubuntu/python-api
46
PLOTLY_CONFIG_DIR: ${HOME}/.plotly
57
PLOTLY_PYTHON_VERSIONS: 2.7.8 3.3.3 3.4.1
68
PLOTLY_CORE_REQUIREMENTS_FILE: ${PLOTLY_PACKAGE_ROOT}/requirements.txt
79
PLOTLY_OPTIONAL_REQUIREMENTS_FILE: ${PLOTLY_PACKAGE_ROOT}/optional-requirements.txt
10+
811
dependencies:
12+
913
override:
1014

1115
# run all the pre-written installers (this will take a *while*)
@@ -19,8 +23,11 @@ dependencies:
1923
- cd ~ && python -c "import plotly"
2024

2125
cache_directories:
26+
2227
- "~/.pyenv/versions" # attempt to just cache installed pyenv things
28+
2329
test:
30+
2431
override:
2532

2633
# run test suite in all our python versions
@@ -34,6 +41,6 @@ test:
3441
- sudo chmod -R 777 ${PLOTLY_CONFIG_DIR} && python -c "import plotly"
3542

3643
# test core things in the general 2.7 version that circle has
37-
- nosetests -xv plotly/tests/test_core --with-coverage --cover-package=plotly
44+
- nosetests -x plotly/tests/test_core --with-coverage --cover-package=plotly
3845
- mkdir "${CIRCLE_ARTIFACTS}/2.7" || true
3946
- coverage html -d "${CIRCLE_ARTIFACTS}/2.7" --title=2.7

circle/setup.sh

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,44 @@
11
#!/bin/bash
22

3-
echo "running setup routine with python versions:"
3+
SIG="☁☀☂"
4+
5+
echo "${SIG} Running setup routine with Python versions:"
46
for version in ${PLOTLY_PYTHON_VERSIONS[@]}; do
5-
echo " ${version}"
7+
echo "${SIG} ${version}"
68
done
79

810
PROGNAME=$(basename $0)
911
function error_exit
1012
{
11-
echo -e "${PROGNAME}: ${1:-"Unknown Error"}\n" 1>&2
13+
echo -e "${SIG} ${PROGNAME}: ${1:-"Unknown Error"}\n" 1>&2
1214
exit 1
1315
}
1416

1517
# PYENV shims need to be infront of the rest of the path to work!
16-
echo "adding pyenv shims to the beginning of the path in this shell"
18+
echo "${SIG} Adding pyenv shims to the beginning of the path in this shell."
1719
export PATH="/home/ubuntu/.pyenv/shims:$PATH"
1820

1921
# for each version we want, setup a functional virtual environment
2022
for version in ${PLOTLY_PYTHON_VERSIONS[@]}; do
21-
echo Setting up Python ${version}
23+
echo "${SIG} Setting up Python ${version}"
2224

2325
# exporting this variable (in this scope) chooses the python version
2426
export PYENV_VERSION=${version}
25-
echo "Using pyenv version $(pyenv version)"
27+
echo "${SIG} Using pyenv version $(pyenv version)"
2628

2729
# this was a major issue previously, sanity check that we're using the
2830
# version we *think* we're using (that pyenv is pointing to)
29-
echo "python -c 'import sys; print(sys.version)'"
31+
echo "${SIG} python -c 'import sys; print(sys.version)'"
3032
python -c 'import sys; print(sys.version)'
3133

3234
# install core requirements all versions need
3335
pip install -r ${PLOTLY_CORE_REQUIREMENTS_FILE} ||
34-
error_exit "${LINENO}: can't install core reqs for Python ${version}"
36+
error_exit "${SIG} ${LINENO}: can't install core reqs for Python ${version}."
3537

3638
pip install -r ${PLOTLY_OPTIONAL_REQUIREMENTS_FILE} ||
37-
error_exit "${LINENO}: can't install optional for Python ${version}"
39+
error_exit "${SIG} ${LINENO}: can't install optional for Python ${version}."
3840

3941
# install some test tools
4042
pip install nose coverage ||
41-
error_exit "${LINENO}: can't install test tools for Python ${version}"
43+
error_exit "${SIG} ${LINENO}: can't install test tools for Python ${version}."
4244
done

circle/test.sh

Lines changed: 20 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,47 @@
11
#!/bin/bash
22

3-
echo "running test routine with python versions:"
3+
SIG="☁☀☂"
4+
5+
echo "${SIG} Running test routine with python versions:"
46
for version in ${PLOTLY_PYTHON_VERSIONS[@]}; do
5-
echo " ${version}"
7+
echo "${SIG} ${version}"
68
done
79

810
PROGNAME=$(basename $0)
911
function error_exit
1012
{
11-
echo -e "${PROGNAME}: ${1:-"Unknown Error"}\n" 1>&2
13+
echo -e "${SIG} ${PROGNAME}: ${1:-"Unknown Error"}\n" 1>&2
1214
exit 1
1315
}
1416

1517
# PYENV shims need to be infront of the rest of the path to work!
16-
echo "adding pyenv shims to the beginning of the path in this shell"
18+
echo "${SIG} Adding pyenv shims to the beginning of the path in this shell."
1719
export PATH="/home/ubuntu/.pyenv/shims:$PATH"
1820

1921
# for each version we want, setup a functional virtual environment
2022
for version in ${PLOTLY_PYTHON_VERSIONS[@]}; do
21-
echo Testing Python ${version}
23+
echo "${SIG} Testing Python ${version}"
2224

2325
# exporting this variable (in this scope) chooses the python version
2426
export PYENV_VERSION=${version}
25-
echo "Using pyenv version $(pyenv version)"
27+
echo "${SIG} Using pyenv version $(pyenv version)."
2628

2729
# this was a major issue previously, sanity check that we're using the
2830
# version we *think* we're using (that pyenv is pointing to)
29-
echo "python -c 'import sys; print(sys.version)'"
31+
echo "${SIG} Running: python -c 'import sys; print(sys.version)'. We've got:"
3032
python -c 'import sys; print(sys.version)'
3133

3234

33-
echo "install plotly (ignoring possibly cached versions)"
34-
pip install -I ${PLOTLY_PACKAGE_ROOT} ||
35-
error_exit "${LINENO}: can't install plotly package from project root"
36-
37-
echo "import plotly to create .plotly dir if DNE"
38-
python -c 'import plotly' ||
39-
error_exit "${LINENO}: can't import plotly package"
40-
41-
# echo "${HOME}"
42-
# echo "${PLOTLY_CONFIG_DIR}"
43-
#
44-
# # test that it imports when you don't have write permissions
45-
# sudo chmod -R 444 ${PLOTLY_CONFIG_DIR} && python -c "import plotly" ||
46-
# error_exit "${LINENO}: permissions test 444 on .plotly dir failed"
47-
#
48-
# # test that setting write permissions will work for import (and tests)
49-
# sudo chmod -R 666 ${PLOTLY_CONFIG_DIR} && python -c "import plotly" ||
50-
# error_exit "${LINENO}: permissions test 666 on .plotly dir failed"
51-
52-
echo "running tests for Python ${version} as user '$(whoami)'"
53-
nosetests -xv plotly/tests --with-coverage --cover-package=plotly ||
54-
error_exit "${LINENO}: test suite failed for Python ${version}"
55-
mkdir "${CIRCLE_ARTIFACTS}/${PYENV_VERSION}" || true
56-
coverage html -d "${CIRCLE_ARTIFACTS}/${PYENV_VERSION}" \
57-
--title=${PYENV_VERSION}
35+
echo "${SIG} Install plotly (ignoring possibly cached versions)."
36+
pip install -I ${PLOTLY_PACKAGE_ROOT} >/dev/null ||
37+
error_exit "${SIG} ${LINENO}: can't install plotly package from project root"
38+
39+
echo "${SIG} Import plotly to create .plotly dir if DNE."
40+
python -c 'import plotly' >/dev/null ||
41+
error_exit "${SIG} ${LINENO}: can't import plotly package"
42+
43+
echo "${SIG} Running tests for Python ${version} as user '$(whoami)'."
44+
nosetests -x plotly/tests ||
45+
error_exit "${SIG} ${LINENO}: test suite failed for Python ${version}"
5846

5947
done

plotly/tests/test_core/test_tools/test_figure_factory.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
import datetime
55
from nose.tools import raises
6-
76
import plotly.tools as tls
87
from plotly.exceptions import PlotlyError
98
from plotly.graph_objs import graph_objs

plotly/tests/test_optional/optional_utils.py

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,93 @@
33
import matplotlib
44
# Force matplotlib to not use any Xwindows backend.
55
matplotlib.use('Agg')
6+
7+
import numpy as np
8+
69
from plotly.matplotlylib import Exporter, PlotlyRenderer
10+
from plotly.tests.utils import is_num_list
11+
from plotly.utils import get_by_path, node_generator
712

813

914
def run_fig(fig):
1015
renderer = PlotlyRenderer()
1116
exporter = Exporter(renderer)
1217
exporter.run(fig)
1318
return renderer
19+
20+
21+
class NumpyTestUtilsMixin(object):
22+
"""Provides some helper functions to make testing easier."""
23+
24+
def _format_path(self, path):
25+
str_path = [repr(p) for p in path]
26+
return '[' + ']['.join(sp for sp in str_path) + ']'
27+
28+
def assert_dict_equal(self, d1, d2, msg=None):
29+
"""
30+
Uses `np.allclose()` on number arrays.
31+
32+
:raises: (AssertionError) Using TestCase's self.failureException
33+
34+
"""
35+
self.assertIsInstance(d1, dict, 'First argument is not a dictionary')
36+
self.assertIsInstance(d2, dict, 'Second argument is not a dictionary')
37+
38+
for node, path in node_generator(d1):
39+
40+
# first check that this sub-dict is contained in both dicts
41+
try:
42+
comp_node = get_by_path(d2, path)
43+
except (KeyError, IndexError):
44+
standard_msg = (
45+
'Path {} exists in dict 1, but not dict 2.'
46+
.format(path)
47+
)
48+
self.fail(self._formatMessage(msg, standard_msg))
49+
self.assertIsInstance(
50+
comp_node, dict, 'Value at path {} is not a dict.'.format(path)
51+
)
52+
53+
# check that each key in the first is contained in the second
54+
for key, val in node.items():
55+
if isinstance(val, dict):
56+
continue # this gets tested as its own node
57+
58+
# check that the values at this key are equal
59+
val_path = path + (key, )
60+
try:
61+
comp_val = comp_node[key]
62+
except KeyError:
63+
standard_msg = (
64+
'Path {} exists in dict 1, but not dict 2.'
65+
.format(self._format_path(val_path))
66+
)
67+
self.fail(self._formatMessage(msg, standard_msg))
68+
69+
if (isinstance(val, np.ndarray) or
70+
isinstance(comp_val, np.ndarray)):
71+
if np.array_equal(val, comp_val):
72+
continue
73+
elif val == comp_val:
74+
continue
75+
76+
if is_num_list(val) and is_num_list(comp_val):
77+
if np.allclose(val, comp_val):
78+
continue
79+
80+
standard_msg = (
81+
'Value comparison failed at path {}.\n'
82+
'{} != {}'
83+
.format(self._format_path(val_path), val, comp_val)
84+
)
85+
self.fail(self._formatMessage(msg, standard_msg))
86+
87+
# finally, check that keys in the second are in the first
88+
for key in comp_node:
89+
val_path = path + (key, )
90+
if key not in node:
91+
standard_msg = (
92+
'Path {} exists in dict 2, but not dict 1.'
93+
.format(self._format_path(val_path))
94+
)
95+
self.fail(self._formatMessage(msg, standard_msg))

0 commit comments

Comments
 (0)
0