From 2e571e1412ed578a0aa767e467b6b521eaf81b6e Mon Sep 17 00:00:00 2001 From: Victor Lin <13424970+victorlin@users.noreply.github.com> Date: Tue, 10 Jan 2023 14:16:18 -0800 Subject: [PATCH] Use isodate instead of python-dateutil --- augur/frequency_estimators.py | 8 ++++---- setup.py | 1 - 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/augur/frequency_estimators.py b/augur/frequency_estimators.py index 8a2a9a3c5..31cc96aee 100644 --- a/augur/frequency_estimators.py +++ b/augur/frequency_estimators.py @@ -2,7 +2,7 @@ from __future__ import division, print_function from collections import defaultdict, deque import datetime -from dateutil.relativedelta import relativedelta +import isodate import numpy as np import pandas as pd from scipy.interpolate import interp1d @@ -59,9 +59,9 @@ def get_pivots(observations, pivot_interval, start_date=None, end_date=None, piv pivot_end = end_date if end_date else np.ceil(np.max(observations) / pivot_frequency) * pivot_frequency if pivot_interval_units == "months": - delta_keywords = {"months": pivot_interval} + duration_str = f'P{pivot_interval}M' elif pivot_interval_units == "weeks": - delta_keywords = {"weeks": pivot_interval} + duration_str = f'P{pivot_interval}W' else: raise ValueError(f"The given interval unit '{pivot_interval_units}' is not supported.") @@ -69,7 +69,7 @@ def get_pivots(observations, pivot_interval, start_date=None, end_date=None, piv # dates and the corresponding delta time for the interval between pivots. start = datetime.datetime.strptime(float_to_datestring(pivot_start), "%Y-%m-%d") end = datetime.datetime.strptime(float_to_datestring(pivot_end), "%Y-%m-%d") - delta = relativedelta(**delta_keywords) + delta = isodate.parse_duration(duration_str) # Start calculating pivots from the end date (inclusive), working backwards # in time by a time delta that matches the user-requested interval. Include diff --git a/setup.py b/setup.py index 584f3b277..736887173 100644 --- a/setup.py +++ b/setup.py @@ -61,7 +61,6 @@ "pandas >=1.0.0, ==1.*", "phylo-treetime >=0.9.3, ==0.9.*", "pyfastx >=0.8.4, ==0.8.*", - "python-dateutil >=2.8.2, ==2.*", "xopen[zstd] >=1.7.0, ==1.*" ], extras_require = {