Skip to content

Commit

Permalink
add num2pydate convenience function, update Changelog and .appveyor.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
jswhit committed Jan 31, 2020
1 parent 3b47ea8 commit cfa1619
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 18 deletions.
45 changes: 29 additions & 16 deletions .appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
environment:
CONDA_INSTALL_LOCN: C:\\Miniconda36-x64
matrix:
- TARGET_ARCH: x64
NPY: 1.16
PY: 3.6

- TARGET_ARCH: x64
NPY: 1.16
NPY: 1.17
PY: 3.7

- TARGET_ARCH: x64
NPY: 1.17
PY: 3.8

platform:
- x64

Expand All @@ -24,18 +25,30 @@ install:
throw "There are newer queued builds for this pull request, failing early." }

# Add path, activate `conda` and update conda.
- cmd: call %CONDA_INSTALL_LOCN%\Scripts\activate.bat
- cmd: conda config --set always_yes yes --set changeps1 no --set show_channel_urls true
- cmd: conda update conda
- cmd: conda config --add channels conda-forge --force
- cmd: conda config --set channel_priority strict
- cmd: set PYTHONUNBUFFERED=1
- cmd: conda install conda-build vs2008_express_vc_python_patch
- cmd: call setup_x64

- cmd: conda.exe create --name TEST python=%PY% numpy=%NPY% cython pip pytest pytest-cov
- cmd: conda info --all
- cmd: conda activate TEST

- set URL="https://repo.anaconda.com/miniconda/Miniconda3-latest-Windows-x86_64.exe"
- curl -fsS -o miniconda3.exe %URL%
- start /wait "" miniconda3.exe /InstallationType=JustMe /RegisterPython=0 /S /D=%PYTHON%
- "set PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%"
- call %PYTHON%\Scripts\activate
- conda config --set always_yes yes --set changeps1 no --set show_channel_urls true
- conda config --add channels conda-forge --force
- set PYTHONUNBUFFERED=1
- conda install conda-build vs2008_express_vc_python_patch
- call setup_x64
- conda create --name TEST python=%PY% numpy=%NPY% cython pip pytest pytest-cov
- conda activate TEST
# - cmd: call %CONDA_INSTALL_LOCN%\Scripts\activate.bat
# - cmd: conda config --set always_yes yes --set changeps1 no --set show_channel_urls true
# - cmd: conda update conda
# - cmd: conda config --add channels conda-forge --force
# - cmd: conda config --set channel_priority strict
# - cmd: set PYTHONUNBUFFERED=1
# - cmd: conda install conda-build vs2008_express_vc_python_patch
# - cmd: call setup_x64
# - cmd: conda.exe create --name TEST python=%PY% numpy=%NPY% cython pip pytest pytest-cov
# - cmd: conda info --all
# - cmd: conda activate TEST

# Skip .NET project specific build phase.
build: off
Expand Down
4 changes: 3 additions & 1 deletion Changelog
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ version 1.1.0 (not yet released)

* If only_use_python_datetimes=True and only_use_cftime_datetimes=False,
num2date only returns python datetime instances and raises an exception
if this is not possible.
if this is not possible. num2pydate convenience function added which just calls
num2date with only_use_python_datetimes=True and
only_use_cftime_datetimes=False.
Remove positive times check, raise ValueError if python datetime
tries to compute a date before MINYEAR (issue #134)

Expand Down
12 changes: 11 additions & 1 deletion cftime/_cftime.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,19 @@ def date2num(dates,units,calendar='standard'):
return cdftime.date2num(dates)


def num2pydate(times,units,calendar='standard'):
"""num2pydate(times,units,calendar='standard')
Always returns python datetime.datetime
objects and raise an error if this is not possible.
Same as
num2date(times,units,calendar',only_use_cftime_datetimes=Falsee,only_use_python_datetimes=Truee)
"""
return num2date(times,units,calendar,only_use_cftime_datetimes=False,only_use_python_datetimes=True)

def num2date(times,units,calendar='standard',\
only_use_cftime_datetimes=True,only_use_python_datetimes=False):
"""num2date(times,units,calendar='standard')
"""num2date(times,units,calendar='standard',only_use_cftime_datetimes=True,only_use_python_datetimes=False)
Return datetime objects given numeric time values. The units
of the numeric time values are described by the `units` argument
Expand Down

0 comments on commit cfa1619

Please sign in to comment.