Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/xmhw-conda.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on:
push:
branches:
- master
- timestep
- fixpandas
pull_request:
branches:
- master
Expand Down Expand Up @@ -44,7 +44,7 @@ jobs:
run: |
conda install pytest coverage codecov
conda run python -m pytest
conda run coverage run --source xmhw -m py.test
conda run coverage run --source xmhw -m pytest
- name: Upload to codecov
if: steps.build.outcome == 'success'
run: |
Expand Down
31 changes: 31 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Read the Docs configuration file for Sphinx projects
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details

# Required
version: 2

# Set the OS, Python version and other tools you might need
build:
os: ubuntu-22.04
tools:
python: "3.10"
# You can also specify other tool versions:
# nodejs: "19"
# rust: "1.64"
# golang: "1.19"

# Build documentation in the "docs/" directory with Sphinx
sphinx:
configuration: docs/conf.py

# Optionally build your docs in additional formats such as PDF and ePub
# formats:
# - pdf
# - epub

# Optional but recommended, declare the Python requirements required
# to build your documentation
# See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html
python:
install:
- requirements: docs/requirements.txt
13 changes: 6 additions & 7 deletions conda/meta.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% set version = "0.9.3" %}
{% set version = "1.0.0" %}
package:
name: xmhw
version: {{ version }}
Expand All @@ -18,19 +18,19 @@ about:

requirements:
host:
- python >=3.7
- python >=3.9
- pip
- pbr
run:
- python >=3.7
- python >=3.9
- pandas
- xarray
- numpy
- dask

source:
git_url: https://github.com/coecms/xmhw.git
git_rev: 0.9.3
git_rev: 1.0.0

build:
script: "{{ PYTHON }} -m pip install . --no-deps --ignore-installed"
Expand All @@ -42,7 +42,6 @@ test:
- setup.cfg
- test
requires:
- netcdf4
- pytest
- coverage
- numpy
Expand All @@ -53,6 +52,6 @@ test:
- xmhw
script_env:
- TEST_OUTPUT
commands:
- COVERAGE_FILE=${TEST_OUTPUT:-.}/coverage coverage run --source xmhw -m pytest ./test
# commands:
#- COVERAGE_FILE=${TEST_OUTPUT:-.}/coverage coverage run --source xmhw -m pytest ./test

28 changes: 19 additions & 9 deletions docs/conf.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
#
# clef documentation build configuration file, created by
# XMHW documentation build configuration file, created by
# sphinx-quickstart on Fri May 13 10:16:43 2016.
#
# This file is execfile()d with the current directory set to its
Expand All @@ -12,7 +12,7 @@
# All configuration values have a default; values that are commented out
# serve to show the default.

from pkg_resources import get_distribution
from importlib.metadata import version
import sys
import os

Expand All @@ -21,6 +21,7 @@
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#sys.path.insert(0, os.path.abspath('.'))
sys.path.insert(0, os.path.abspath('../xmhw'))

# -- General configuration ------------------------------------------------

Expand All @@ -45,6 +46,9 @@
# source_suffix = ['.rst', '.md']
source_suffix = ['.rst']

# adding this to avoid failure of autodoc because of missing packages
autodoc_mock_imports = ['numpy', 'xarray', 'dask', 'pandas']

# The encoding of source files.
#source_encoding = 'utf-8-sig'

Expand All @@ -57,23 +61,28 @@
author = u'Paola Petrelli'

# Access project metadata
_dist = get_distribution(project)

# use version get_distribution is deprecated
#version = version("xmhw")
#_dist = get_distribution(project)

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
# built documents.
#
# The short X.Y version.
version = _dist.parsed_version.base_version
#version = _dist.parsed_version.base_version
version = 1.0.0
# The full version, including alpha/beta/rc tags.
release = _dist.version
#release = _dist.version
release = 1.0.0

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
#
# This is also used if you do content translation via gettext catalogs.
# Usually you set "language" from the command line for these cases.
language = None
language = "en"

# There are two options for replacing |today|: either, you set today to some
# non-false value, then it is used:
Expand Down Expand Up @@ -118,7 +127,8 @@

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
html_theme = 'default'
#html_theme = 'default'
html_theme = 'sphinx_rtd_theme'

# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
Expand Down Expand Up @@ -147,7 +157,7 @@
# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
html_static_path = ['_static']
#html_static_path = ['_static']

# Add any extra paths that contain custom files (such as robots.txt or
# .htaccess) here, relative to this directory. These files are copied
Expand Down Expand Up @@ -200,7 +210,7 @@
# Sphinx supports the following languages:
# 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja'
# 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr', 'zh'
#html_search_language = 'en'
html_search_language = 'en'

# A dictionary with options for the search language support, empty by default.
# 'ja' uses this config value.
Expand Down
3 changes: 3 additions & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
sphinx
sphinx-rtd-theme
sphinx_design
16 changes: 9 additions & 7 deletions test/test_identify.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
import pandas.testing as pdtest


@pytest.mark.xfail
#@pytest.mark.xfail
def test_add_doy(oisst_ts, oisst_doy, days5_doy, mon_doy):
doy = add_doy(oisst_ts, tdim="time").doy.values
nptest.assert_array_equal(doy, oisst_doy)
Expand Down Expand Up @@ -77,7 +77,7 @@ def test_runavg():
runavg(a, 2).compute()


@pytest.mark.xfail
#@pytest.mark.xfail
def test_window_roll(oisst_ts, tstack):
ts = oisst_ts.sel(
time=slice("2003-01-01", "2003-01-03"), lat=-42.625, lon=148.125
Expand All @@ -100,8 +100,8 @@ def test_join_gaps(filter_data):
pdtest.assert_series_equal(df2.end, end2)
pdtest.assert_series_equal(df2.events, evs2)
# testing only last two events to make sure it works with array len 1
st[5] = np.nan
end[5] = np.nan
st.iloc[5] = np.nan
end.iloc[5] = np.nan
evs[1:6] = np.nan
df3 = join_gaps(st, end, evs, 3)
pdtest.assert_series_equal(df3.events[10:], evs2[10:])
Expand Down Expand Up @@ -129,7 +129,7 @@ def test_join_events(join_data):
assert True


@pytest.mark.xfail
#@pytest.mark.xfail
def test_land_check(oisst_ts, clim_oisst, landgrid):
newts = land_check(oisst_ts)
assert newts.shape == (731, 12)
Expand All @@ -145,8 +145,10 @@ def test_land_check(oisst_ts, clim_oisst, landgrid):
diffdim = oisst_ts.rename({"lat": "a", "lon": "b", "time": "c"})
newts = land_check(diffdim, tdim="c")
assert newts.shape == (731, 12)
newts = land_check(clim_oisst.thresh1)
assert newts.shape == (366, 1)
# remiving this test as it raises exception as it should as thresh1
# has only time dim unless a "cell" dim was added before
# newts = land_check(clim_oisst.thresh1)
# assert newts.shape == (366, 1)
# test exception raised when all points are land
with pytest.raises(XmhwException):
land_check(landgrid)
Expand Down
4 changes: 2 additions & 2 deletions test/test_xmhw.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from xmhw.exception import XmhwException


@pytest.mark.xfail
#@pytest.mark.xfail
def test_threshold(clim_oisst, clim_oisst_nosmooth, oisst_ts):
# test exceptions with wrong arguments
with pytest.raises(XmhwException):
Expand Down Expand Up @@ -67,7 +67,7 @@ def test_threshold(clim_oisst, clim_oisst_nosmooth, oisst_ts):
# add test with skipna False for this set and one without nans


@pytest.mark.xfail
#@pytest.mark.xfail
def test_detect(oisst_ts, clim_oisst):
# detect(temp, thresh, seas, minDuration=5, joinAcrossGaps=True, maxGap=2, maxPadLength=None, coldSpells=False, tdim='time')
# test exceptions with wrong arguments
Expand Down
34 changes: 17 additions & 17 deletions test/xmhw_fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,20 +138,20 @@ def filter_data():
st = pd.Series(index=time, dtype="float64").rename("start")
end = pd.Series(index=time, dtype="float64").rename("end")
events = pd.Series(index=time, dtype="float64").rename("events")
st[5] = 1
st[16] = 11
st[24] = 20
end[5] = 5
end[16] = 16
end[24] = 24
st.iloc[5] = 1
st.iloc[16] = 11
st.iloc[24] = 20
end.iloc[5] = 5
end.iloc[16] = 16
end.iloc[24] = 24
events[1:6] = 1
events[11:17] = 11
events[20:25] = 20
st2 = st.copy()
end2 = end.copy()
events2 = events.copy()
st2[24] = np.nan
end2[16] = np.nan
st2.iloc[24] = np.nan
end2.iloc[16] = np.nan
events2[17:25] = 11
return (bthresh, idxarr, st, end, events, st2, end2, events2)

Expand Down Expand Up @@ -334,15 +334,15 @@ def inter_data():

@pytest.fixture
def calendars():
noleap = xr.cftime_range("2000", periods=6, calendar="noleap")
all_leap = xr.cftime_range("2000", periods=6, calendar="all_leap")
day_365 = xr.cftime_range("2000", periods=6, calendar="365_day")
day_366 = xr.cftime_range("2000", periods=6, calendar="366_day")
gregorian = xr.cftime_range("2000", periods=6, calendar="gregorian")
standard = xr.cftime_range("2000", periods=6, calendar="standard")
julian = xr.cftime_range("2000", periods=6, calendar="julian")
proleptic = xr.cftime_range(
"2000", periods=6, calendar="proleptic_gregorian"
noleap = xr.date_range("2000", periods=6, calendar="noleap", use_cftime=True)
all_leap = xr.date_range("2000", periods=6, calendar="all_leap", use_cftime=True)
day_365 = xr.date_range("2000", periods=6, calendar="365_day", use_cftime=True)
day_366 = xr.date_range("2000", periods=6, calendar="366_day", use_cftime=True)
gregorian = xr.date_range("2000", periods=6, calendar="gregorian", use_cftime=True)
standard = xr.date_range("2000", periods=6, calendar="standard", use_cftime=True)
julian = xr.date_range("2000", periods=6, calendar="julian", use_cftime=True)
proleptic = xr.date_range(
"2000", periods=6, calendar="proleptic_gregorian", use_cftime=True
)
ndays_year = {
"noleap": 365,
Expand Down
Loading
Loading