From 0520346605bbe0e92bef2af434e1e7504605ec1c Mon Sep 17 00:00:00 2001 From: vmenezesmoura Date: Sun, 19 Apr 2026 11:11:50 -0300 Subject: [PATCH 1/3] Fix minor Python 3 compatibility issues in ttide tests and docstrings --- ttide/t_tide.py | 4 ++-- ttide/tests/print_tests.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ttide/t_tide.py b/ttide/t_tide.py index 130ccc2..0a9713b 100644 --- a/ttide/t_tide.py +++ b/ttide/t_tide.py @@ -98,8 +98,8 @@ def t_tide(xin, dt=1, stime=None, lat=None, series will remain and mean/trend are included). lsq : string - 'direct' - use A\ x fit - 'normal' - use (A'A)\(A'x) (may be necessary for very large + 'direct' - use A\\ x fit + 'normal' - use (A'A)\\(A'x) (may be necessary for very large input vectors since A'A is much smaller than A) 'best' - automatically choose based on length of series (default). diff --git a/ttide/tests/print_tests.py b/ttide/tests/print_tests.py index 71f06d9..cf6633c 100644 --- a/ttide/tests/print_tests.py +++ b/ttide/tests/print_tests.py @@ -1,6 +1,6 @@ from ttide.t_tide import t_tide import ttide.tests.base as bmod -from cStringIO import StringIO +from io import StringIO import sys import numpy as np From 55b0c1b5f2579eff5b3b7901b1ed809e46c287ce Mon Sep 17 00:00:00 2001 From: vmenezesmoura Date: Sun, 19 Apr 2026 11:19:51 -0300 Subject: [PATCH 2/3] Fix ambiguous empty-array check and real-series inference phase calculation in t_tide --- ttide/t_tide.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ttide/t_tide.py b/ttide/t_tide.py index 0a9713b..7be9cf2 100644 --- a/ttide/t_tide.py +++ b/ttide/t_tide.py @@ -427,14 +427,14 @@ def t_tide(xin, dt=1, stime=None, lat=None, # would be to change the basis functions. #################################################################### ii = np.flatnonzero(np.isfinite(jref)) - if ii: + if ii.size > 0: print(' Do inference corrections\\n') snarg = nobsu * pi * dt * (fi[(ii - 1)] - fu[(jref[(ii - 1)] - 1)]) scarg = np.sin(snarg) / snarg if infamprat.shape[1] == 1: # For real time series - pearg = np.dot(2 * pi,ii - (vu[(mu + ii - 1)] - + pearg = np.dot(2 * pi, ii * ( + vu[(mu + ii - 1)] - vu[(jref[(ii - 1)] - 1)] + infph[(ii - 1)])) / 360 pcfac = infamprat[(ii - 1)] * f[(mu + ii - 1)] / \ From 7aaba68f8734a03f19b9d4c232ad1f0653779926 Mon Sep 17 00:00:00 2001 From: vmenezesmoura Date: Sun, 19 Apr 2026 11:22:12 -0300 Subject: [PATCH 3/3] Fix t_predic name lookup for constituent indices --- ttide/t_predic.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ttide/t_predic.py b/ttide/t_predic.py index fede2f8..17e9f9d 100644 --- a/ttide/t_predic.py +++ b/ttide/t_predic.py @@ -96,7 +96,11 @@ def t_predic(t_time, names, freq, tidecon, ju = np.zeros((len(freq),), dtype='int32') # Check to make sure names and frequencies match expected values. for k in range(0, (names.shape[0])): - ju[k] = np.argwhere(const['name'] == names[(k)]) + matches = np.flatnonzero(const['name'] == names[(k)]) + if matches.size == 0: + raise ValueError("Constituent name '%s' not found in constants" % + (names[(k)],)) + ju[k] = matches[0] # if any(freq~=const.freq(ju)), # error('Frequencies do not match names in input'); # end;