From 693dd1364ee5ecc0698bb6bb294c87efc60574c8 Mon Sep 17 00:00:00 2001 From: "Bryan W. Weber" Date: Fri, 21 Apr 2017 11:52:14 -0400 Subject: [PATCH 1/6] Revert "Add back support for Python 2.7" Take Python 2.7 support out again to allow using Python 3-only features This reverts commit 740db45a08ed69cbbc54b3f53560b9dad1defe3f. --- .travis.yml | 6 ------ pyked/chemked.py | 35 +++++++++++++++-------------------- pyked/tests/test_chemked.py | 2 -- 3 files changed, 15 insertions(+), 28 deletions(-) diff --git a/.travis.yml b/.travis.yml index 847fabc..6eac99f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,18 +8,12 @@ language: generic matrix: include: - - os: linux - env: PYTHON="2.7" - - os: linux env: PYTHON="3.5" - os: linux env: PYTHON="3.6" - - os: osx - env: PYTHON="2.7" - - os: osx env: PYTHON="3.5" diff --git a/pyked/chemked.py b/pyked/chemked.py index eac8b74..d68e02c 100644 --- a/pyked/chemked.py +++ b/pyked/chemked.py @@ -1,11 +1,9 @@ """ Main ChemKED module """ -from __future__ import print_function, division from collections import namedtuple from warnings import warn from copy import deepcopy -from sys import version_info import numpy as np @@ -14,29 +12,26 @@ from .utils import Q_ VolumeHistory = namedtuple('VolumeHistory', ['time', 'volume']) -if version_info.major >= 3: - VolumeHistory.__doc__ = 'Time history of the volume in an RCM experiment' - VolumeHistory.time.__doc__ = '(`~numpy.ndarray`): the time during the experiment' - VolumeHistory.volume.__doc__ = '(`~numpy.ndarray`): the volume during the experiment' +VolumeHistory.__doc__ = 'Time history of the volume in an RCM experiment' +VolumeHistory.time.__doc__ = '(`~numpy.ndarray`): the time during the experiment' +VolumeHistory.volume.__doc__ = '(`~numpy.ndarray`): the volume during the experiment' Reference = namedtuple('Reference', ['volume', 'journal', 'doi', 'authors', 'detail', 'year', 'pages']) -if version_info.major >= 3: - Reference.__doc__ = 'Information about the article or report where the data can be found' - Reference.volume.__doc__ = '(`str`) The journal volume' - Reference.journal.__doc__ = '(`str`) The name of the journal' - Reference.doi.__doc__ = '(`str`) The Digital Object Identifier of the article' - Reference.authors.__doc__ = '(`list`) The list of authors of the article' - Reference.detail.__doc__ = '(`str`) Detail about where the data can be found in the article' - Reference.year.__doc__ = '(`str`) The year the article was published' - Reference.pages.__doc__ = '(`str`) The pages in the journal where the article was published' +Reference.__doc__ = 'Information about the article or report where the data can be found' +Reference.volume.__doc__ = '(`str`) The journal volume' +Reference.journal.__doc__ = '(`str`) The name of the journal' +Reference.doi.__doc__ = '(`str`) The Digital Object Identifier of the article' +Reference.authors.__doc__ = '(`list`) The list of authors of the article' +Reference.detail.__doc__ = '(`str`) Detail about where the data can be found in the article' +Reference.year.__doc__ = '(`str`) The year the article was published' +Reference.pages.__doc__ = '(`str`) The pages in the journal where the article was published' Apparatus = namedtuple('Apparatus', ['kind', 'institution', 'facility']) -if version_info.major >= 3: - Apparatus.__doc__ = 'Information about the experimental apparatus used to generate the data' - Apparatus.kind.__doc__ = '(`str`) The kind of experimental apparatus' - Apparatus.institution.__doc__ = '(`str`) The institution where the experiment is located' - Apparatus.facility.__doc__ = '(`str`) The particular experimental facility at the location' +Apparatus.__doc__ = 'Information about the experimental apparatus used to generate the data' +Apparatus.kind.__doc__ = '(`str`) The kind of experimental apparatus' +Apparatus.institution.__doc__ = '(`str`) The institution where the experiment is located' +Apparatus.facility.__doc__ = '(`str`) The particular experimental facility at the location' class ChemKED(object): diff --git a/pyked/tests/test_chemked.py b/pyked/tests/test_chemked.py index 6271a8e..1c4638c 100644 --- a/pyked/tests/test_chemked.py +++ b/pyked/tests/test_chemked.py @@ -4,7 +4,6 @@ # Standard libraries import os import pkg_resources -import warnings # Third-party libraries import numpy as np @@ -15,7 +14,6 @@ from ..chemked import ChemKED, DataPoint from ..utils import Q_ -warnings.simplefilter("always") class TestChemKED(object): """ From ffb640622c1db3b9c13525196c3b7d196bb65c50 Mon Sep 17 00:00:00 2001 From: "Bryan W. Weber" Date: Fri, 21 Apr 2017 11:53:35 -0400 Subject: [PATCH 2/6] Force warnings in tests to always appear --- pyked/tests/test_chemked.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pyked/tests/test_chemked.py b/pyked/tests/test_chemked.py index 1c4638c..b64cf97 100644 --- a/pyked/tests/test_chemked.py +++ b/pyked/tests/test_chemked.py @@ -4,6 +4,7 @@ # Standard libraries import os import pkg_resources +import warnings # Third-party libraries import numpy as np @@ -14,6 +15,8 @@ from ..chemked import ChemKED, DataPoint from ..utils import Q_ +warnings.simplefilter('always') + class TestChemKED(object): """ From 07dd17b3444aa5c6044b2ff0ff3c9879e6e90407 Mon Sep 17 00:00:00 2001 From: "Bryan W. Weber" Date: Fri, 21 Apr 2017 11:54:15 -0400 Subject: [PATCH 3/6] Revert "Have to allow Python 2.7 as an option in conda builds duh..." No longer needed as Python 2 is no longer supported This reverts commit 78d38a93dc7eeaf2d9d18d3ab637076d903c91cc. --- conda.recipe/meta.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conda.recipe/meta.yaml b/conda.recipe/meta.yaml index dc8c182..84c897f 100644 --- a/conda.recipe/meta.yaml +++ b/conda.recipe/meta.yaml @@ -13,7 +13,7 @@ build: requirements: build: - - python >=2.7,<3|>=3.5,{{PY_VER}}* + - python >=3.5,{{PY_VER}}* - setuptools run: From d55d64c3ffa8c28fa05fb67d8942933e2614a303 Mon Sep 17 00:00:00 2001 From: "Bryan W. Weber" Date: Fri, 21 Apr 2017 13:12:32 -0400 Subject: [PATCH 4/6] Add kwarg to skip validation of ChemKED files Use of keyword-only argument means that this is Python 3 only --- pyked/chemked.py | 7 +++++-- pyked/tests/test_chemked.py | 5 +++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/pyked/chemked.py b/pyked/chemked.py index d68e02c..78d6558 100644 --- a/pyked/chemked.py +++ b/pyked/chemked.py @@ -45,6 +45,8 @@ class ChemKED(object): yaml_file (`str`, optional): The filename of the YAML database in ChemKED format. dict_input (`str`, optional): A dictionary with the parsed ouput of YAML file in ChemKED format. + skip_validation (`bool`, optional): Whether validation of the ChemKED should be done. Must + be supplied as a keyword-argument. Attributes: datapoints (`list`): List of `DataPoint` objects storing each datapoint in the database. @@ -59,7 +61,7 @@ class ChemKED(object): file_author (`dict`): Information about the author of the ChemKED database file. file_version (`str`): Version of the ChemKED database file. """ - def __init__(self, yaml_file=None, dict_input=None): + def __init__(self, yaml_file=None, dict_input=None, *, skip_validation=False): if yaml_file is not None: with open(yaml_file, 'r') as f: properties = yaml.safe_load(f) @@ -68,7 +70,8 @@ def __init__(self, yaml_file=None, dict_input=None): else: raise NameError("ChemKED needs either a YAML filename or dictionary as input.") - self.validate_yaml(properties) + if not skip_validation: + self.validate_yaml(properties) self.datapoints = [] for point in properties['datapoints']: diff --git a/pyked/tests/test_chemked.py b/pyked/tests/test_chemked.py index b64cf97..4a42d9e 100644 --- a/pyked/tests/test_chemked.py +++ b/pyked/tests/test_chemked.py @@ -26,6 +26,11 @@ def test_create_chemked(self): filename = pkg_resources.resource_filename(__name__, file_path) ChemKED(filename) + def test_skip_validation(self): + file_path = os.path.join('testfile_bad.yaml') + filename = pkg_resources.resource_filename(__name__, file_path) + ChemKED(filename, skip_validation=True) + def test_datapoints(self): file_path = os.path.join('testfile_st.yaml') filename = pkg_resources.resource_filename(__name__, file_path) From 9c066248e64263eca46291c4d3875f727406385d Mon Sep 17 00:00:00 2001 From: "Bryan W. Weber" Date: Fri, 21 Apr 2017 14:30:36 -0400 Subject: [PATCH 5/6] Update CHANGELOG with skip_validation --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 43f3476..834e6a5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] ### Added +- Add `skip_validation` keyword argument to the `ChemKED` initializer ### Fixed From d21808c38f4925bacce681b245dd2ad95e0758af Mon Sep 17 00:00:00 2001 From: "Bryan W. Weber" Date: Fri, 21 Apr 2017 14:36:18 -0400 Subject: [PATCH 6/6] Remove Python 2.7 from appveyor.yml --- appveyor.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index f27640b..4cc7a0a 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -4,9 +4,6 @@ environment: secure: agG4yvYjpYq1nzjLhnZ92Z6ZFVM+KA5JyYIYwX2YVQxpuRj7myqJNfttUVTqynIg matrix: - - PYTHON_LOC: "C:\\Miniconda-x64" - PYTHON_VERSION: "2.7" - - PYTHON_LOC: "C:\\Miniconda36-x64" PYTHON_VERSION: "3.5"