From 86c6c26d79c189e2463a729de88bc51d08a7ad2d Mon Sep 17 00:00:00 2001 From: Charles Doutriaux Date: Fri, 1 Sep 2017 11:39:40 -0700 Subject: [PATCH 1/8] fix #238 for @lee1043 based on @durack1 recommendation to not load it a start time but only on demand --- tests/test_vcs_load_mpl_cmaps.py | 9 +++++++++ vcs/colors.py | 11 ++++++++++- vcs/utils.py | 2 +- 3 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 tests/test_vcs_load_mpl_cmaps.py diff --git a/tests/test_vcs_load_mpl_cmaps.py b/tests/test_vcs_load_mpl_cmaps.py new file mode 100644 index 000000000..a637c1b96 --- /dev/null +++ b/tests/test_vcs_load_mpl_cmaps.py @@ -0,0 +1,9 @@ +import unittest +import vcs +class VCSMPLCmaps(unittest.TestCase): + def testLoadMPLCmaps(self): + import vcs + original = vcs.listelements("colormap") + vcs.utils.loadmatplotlibcolormaps() + mpl = vcs.listelements("colormap") + self.assertGreater(len(mpl),len(original)) diff --git a/vcs/colors.py b/vcs/colors.py index afc8b5cd7..dcedf992d 100644 --- a/vcs/colors.py +++ b/vcs/colors.py @@ -1,6 +1,5 @@ from genutil.colors import rgb2str, str2rgb # noqa - def matplotlib2vcs(cmap, vcs_name=None): """ Convert a matplotlib colormap to a vcs colormap @@ -42,3 +41,13 @@ def matplotlib2vcs(cmap, vcs_name=None): vcs_cmap.setcolorcell(i, *([int(x * 100) for x in cmap_rgbs[i][:4]])) return vcs_cmap + + +def loadmatplotlibcolormaps(): + """ + Convert all matplotlib colormaps to vcs colormaps + """ + import matplotlib.pyplot as plt + mpl_cmaps = sorted(m for m in plt.cm.datad if not m.endswith("_r")) + for cmap in mpl_cmaps: + matplotlib2vcs(cmap) diff --git a/vcs/utils.py b/vcs/utils.py index 83ec77ead..772b9b36c 100644 --- a/vcs/utils.py +++ b/vcs/utils.py @@ -45,7 +45,7 @@ hasVCSAddons = False -from colors import rgb2str, str2rgb, matplotlib2vcs # noqa +from colors import rgb2str, str2rgb, matplotlib2vcs, loadmatplotlibcolormaps # noqa indent = 1 sort_keys = True From 435944ecdf9dd748cbf80ea92f8cd3cb3a66f273 Mon Sep 17 00:00:00 2001 From: Charles Doutriaux Date: Fri, 1 Sep 2017 11:41:54 -0700 Subject: [PATCH 2/8] flake8 --- vcs/colors.py | 1 + 1 file changed, 1 insertion(+) diff --git a/vcs/colors.py b/vcs/colors.py index dcedf992d..c6a66e416 100644 --- a/vcs/colors.py +++ b/vcs/colors.py @@ -1,5 +1,6 @@ from genutil.colors import rgb2str, str2rgb # noqa + def matplotlib2vcs(cmap, vcs_name=None): """ Convert a matplotlib colormap to a vcs colormap From b4399dd4b8332fa3402fb0a85d3e67e55cf18281 Mon Sep 17 00:00:00 2001 From: Charles Doutriaux Date: Fri, 1 Sep 2017 13:26:28 -0700 Subject: [PATCH 3/8] with new cdtime, better compare correctly --- vcs/VCS_validation_functions.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/vcs/VCS_validation_functions.py b/vcs/VCS_validation_functions.py index 1adadb513..94b57eb7e 100644 --- a/vcs/VCS_validation_functions.py +++ b/vcs/VCS_validation_functions.py @@ -1256,7 +1256,7 @@ def checkTimeUnits(self, name, value): checkedRaise(self, value, ValueError, value + ' is invalid time units') sp = value.split('since')[1] b = cdtime.s2c(sp) - if b == cdtime.comptime(0, 1): + if b.cmp(cdtime.comptime(0, 1))==0: checkedRaise(self, value, ValueError, sp + ' is invalid date') return value @@ -1267,10 +1267,10 @@ def checkDatawc(self, name, value): value = float(value), 0 elif isinstance(value, str): t = cdtime.s2c(value) - if t != cdtime.comptime(0, 1): + if t.cmp(cdtime.comptime(0, 1))!=0: t = t.torel(self.datawc_timeunits, self.datawc_calendar) value = float(t.value), 1 - else: + else: # Bad string led to 0-1-1 checkedRaise( self, value, From a0f9ba4ec98dec20f0446e11b1e2486b85be3016 Mon Sep 17 00:00:00 2001 From: Charles Doutriaux Date: Fri, 1 Sep 2017 13:54:55 -0700 Subject: [PATCH 4/8] spaces... --- vcs/VCS_validation_functions.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vcs/VCS_validation_functions.py b/vcs/VCS_validation_functions.py index 94b57eb7e..791f4cdcd 100644 --- a/vcs/VCS_validation_functions.py +++ b/vcs/VCS_validation_functions.py @@ -1256,7 +1256,7 @@ def checkTimeUnits(self, name, value): checkedRaise(self, value, ValueError, value + ' is invalid time units') sp = value.split('since')[1] b = cdtime.s2c(sp) - if b.cmp(cdtime.comptime(0, 1))==0: + if b.cmp(cdtime.comptime(0, 1)) == 0: checkedRaise(self, value, ValueError, sp + ' is invalid date') return value @@ -1267,7 +1267,7 @@ def checkDatawc(self, name, value): value = float(value), 0 elif isinstance(value, str): t = cdtime.s2c(value) - if t.cmp(cdtime.comptime(0, 1))!=0: + if t.cmp(cdtime.comptime(0, 1)) != 0: t = t.torel(self.datawc_timeunits, self.datawc_calendar) value = float(t.value), 1 else: # Bad string led to 0-1-1 From a04382d182674bb004c74f9ef5f75b4ff9d83a21 Mon Sep 17 00:00:00 2001 From: Charles Doutriaux Date: Fri, 1 Sep 2017 15:14:18 -0700 Subject: [PATCH 5/8] moved ci-support in its own dir only 1 test at a time longer but easier to see output --- .travis.yml | 4 ++-- {scripts => ci-support}/checkout_merge_commit.sh | 0 {scripts => ci-support}/circle.sh | 0 {scripts => ci-support}/circleci_mac.sh | 4 ++-- {scripts => ci-support}/circleci_mac_dep.sh | 0 {scripts => ci-support}/circleci_mac_machine_pre.sh | 0 {scripts => ci-support}/conda_upload.sh | 0 circle.yml | 10 +++++----- 8 files changed, 9 insertions(+), 9 deletions(-) rename {scripts => ci-support}/checkout_merge_commit.sh (100%) rename {scripts => ci-support}/circle.sh (100%) rename {scripts => ci-support}/circleci_mac.sh (85%) rename {scripts => ci-support}/circleci_mac_dep.sh (100%) rename {scripts => ci-support}/circleci_mac_machine_pre.sh (100%) rename {scripts => ci-support}/conda_upload.sh (100%) diff --git a/.travis.yml b/.travis.yml index 76f09916c..9ace0745c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -22,6 +22,6 @@ script: - git clone git://github.com/uv-cdat/uvcdat-testdata - cd uvcdat-testdata ; git checkout $TRAVIS_BRANCH ; cd .. - df -h -- python run_tests.py -n 2 -v2 -g --no-vtk-ui +- python run_tests.py -n 1 -v2 -g --no-vtk-ui after_success: - - if [ "$TRAVIS_BRANCH" == "master" -a "$TRAVIS_PULL_REQUEST" == "false" ]; then conda install conda-build && conda install anaconda-client && bash scripts/conda_upload.sh ; fi + - if [ "$TRAVIS_BRANCH" == "master" -a "$TRAVIS_PULL_REQUEST" == "false" ]; then conda install conda-build && conda install anaconda-client && bash ci-support/conda_upload.sh ; fi diff --git a/scripts/checkout_merge_commit.sh b/ci-support/checkout_merge_commit.sh similarity index 100% rename from scripts/checkout_merge_commit.sh rename to ci-support/checkout_merge_commit.sh diff --git a/scripts/circle.sh b/ci-support/circle.sh similarity index 100% rename from scripts/circle.sh rename to ci-support/circle.sh diff --git a/scripts/circleci_mac.sh b/ci-support/circleci_mac.sh similarity index 85% rename from scripts/circleci_mac.sh rename to ci-support/circleci_mac.sh index 439ac9ec9..e38894d42 100644 --- a/scripts/circleci_mac.sh +++ b/ci-support/circleci_mac.sh @@ -2,10 +2,10 @@ export UVCDAT_ANONYMOUS_LOG=False export PATH=${HOME}/miniconda/bin:${PATH} #export VCS_BACKGROUND=0 # circleci seg faults on bg=1 #python run_tests.py -v2 -g -H -p # -H and -p for collection by artifacts -python run_tests.py -n 2 -v2 -g --no-vtk-ui +python run_tests.py -n 1 -v2 -g --no-vtk-ui RESULT=$? echo "test command exit result:",$RESULT if [ $RESULT -eq 0 -a $CIRCLE_BRANCH == "master" ]; then conda install conda-build anaconda-client ; fi -if [ $RESULT -eq 0 -a $CIRCLE_BRANCH == "master" ]; then bash ./scripts/conda_upload.sh ; fi +if [ $RESULT -eq 0 -a $CIRCLE_BRANCH == "master" ]; then bash ./ci-support/conda_upload.sh ; fi exit $RESULT diff --git a/scripts/circleci_mac_dep.sh b/ci-support/circleci_mac_dep.sh similarity index 100% rename from scripts/circleci_mac_dep.sh rename to ci-support/circleci_mac_dep.sh diff --git a/scripts/circleci_mac_machine_pre.sh b/ci-support/circleci_mac_machine_pre.sh similarity index 100% rename from scripts/circleci_mac_machine_pre.sh rename to ci-support/circleci_mac_machine_pre.sh diff --git a/scripts/conda_upload.sh b/ci-support/conda_upload.sh similarity index 100% rename from scripts/conda_upload.sh rename to ci-support/conda_upload.sh diff --git a/circle.yml b/circle.yml index f9b34566c..14a4d1fe9 100644 --- a/circle.yml +++ b/circle.yml @@ -10,7 +10,7 @@ general: checkout: post: - - ./scripts/checkout_merge_commit.sh + - ./ci-support/checkout_merge_commit.sh #machine: machine: @@ -20,17 +20,17 @@ machine: - sudo -H pip install --upgrade virtualenv - ls - pwd - - bash vcs/scripts/circleci_mac_machine_pre.sh + - bash vcs/ci-support/circleci_mac_machine_pre.sh #services: # - docker dependencies: override: - - bash ./scripts/circleci_mac_dep.sh + - bash ./ci-support/circleci_mac_dep.sh # - docker pull cdat/conda:conda-forge-cdms2 test: override: - - bash ./scripts/circleci_mac.sh - # - docker run -it -v `pwd`:/git_repo -a STDOUT -a STDERR -P cdat/conda:conda-forge-cdms2 /git_repo/scripts/circle.sh + - bash ./ci-support/circleci_mac.sh + # - docker run -it -v `pwd`:/git_repo -a STDOUT -a STDERR -P cdat/conda:conda-forge-cdms2 /git_repo/ci-support/circle.sh From d19459f1ae9600f4aeb3597ef528e682b7b42438 Mon Sep 17 00:00:00 2001 From: Charles Doutriaux Date: Fri, 1 Sep 2017 17:24:38 -0700 Subject: [PATCH 6/8] ok numpy 13 needed a tweak here for minmax --- tests/test_vcs_queries.py | 2 +- vcs/utils.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/test_vcs_queries.py b/tests/test_vcs_queries.py index e79b99f08..e5e235a1d 100644 --- a/tests/test_vcs_queries.py +++ b/tests/test_vcs_queries.py @@ -3,7 +3,7 @@ class TestVCSQueries(unittest.TestCase): def testVCSQueries(self): - gms = ["boxfill","isofill","isoline","meshfill","scatter","yxvsx","xvsy","xyvsy","vector"] + gms = ["boxfill","isofill","isoline","meshfill","scatter","yxvsx","xvsy","xyvsy","vector","streamline"] for gm in gms: print "testing query work for:",gm exec("g=vcs.create%s()" % gm) diff --git a/vcs/utils.py b/vcs/utils.py index 772b9b36c..9a7bc9fa6 100644 --- a/vcs/utils.py +++ b/vcs/utils.py @@ -1148,6 +1148,8 @@ def myfunction(d, mx, mn): if d is None: return mx, mn from numpy.ma import maximum, minimum, count + if isinstance(d,(int,float)): + return maximum(d,mx),minimum(d,mn) try: if count(d) == 0: return mx, mn From b18588131afd130bf471260198f85d678a166e9c Mon Sep 17 00:00:00 2001 From: Charles Doutriaux Date: Sat, 2 Sep 2017 07:52:46 -0700 Subject: [PATCH 7/8] Flake8 --- vcs/utils.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/vcs/utils.py b/vcs/utils.py index 9a7bc9fa6..5a27d3a05 100644 --- a/vcs/utils.py +++ b/vcs/utils.py @@ -1148,8 +1148,8 @@ def myfunction(d, mx, mn): if d is None: return mx, mn from numpy.ma import maximum, minimum, count - if isinstance(d,(int,float)): - return maximum(d,mx),minimum(d,mn) + if isinstance(d, (int, float)): + return maximum(d, mx), minimum(d, mn) try: if count(d) == 0: return mx, mn From 42a8ad295fd5933b4db7d97cc5cdab34cbfb2613 Mon Sep 17 00:00:00 2001 From: Charles Doutriaux Date: Sat, 2 Sep 2017 11:55:49 -0700 Subject: [PATCH 8/8] circleci stuck with older vtk --- ci-support/circleci_mac_dep.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci-support/circleci_mac_dep.sh b/ci-support/circleci_mac_dep.sh index 3a9319e83..c34767aca 100644 --- a/ci-support/circleci_mac_dep.sh +++ b/ci-support/circleci_mac_dep.sh @@ -2,6 +2,6 @@ ls pwd export PATH=${HOME}/miniconda/bin:${PATH} -conda install -c uvcdat/label/nightly -c conda-forge -c uvcdat "vtk-cdat<7.1.0.2.10.2017.07.07" cdutil genutil dv3d "mesalib=17.1.4=3" nose image-compare flake8 matplotlib +conda install -c uvcdat/label/nightly -c conda-forge -c uvcdat vtk-cdat cdutil genutil dv3d mesalib nose image-compare flake8 matplotlib export UVCDAT_ANONYMOUS_LOG=False python setup.py install --old-and-unmanageable