Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updated warning messages #399

Merged
merged 1 commit into from
Apr 26, 2023
Merged
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
21 changes: 14 additions & 7 deletions pyleoclim/utils/tsutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@

from .tsbase import (
clean_ts,
dropna
dropna,
is_evenly_spaced
)


Expand Down Expand Up @@ -245,9 +246,6 @@ def bin(x, y, bin_size=None, start=None, stop=None, step_style=None, evenly_spac
x = np.array(x, dtype='float64')
y = np.array(y, dtype='float64')

if (bin_size is not None or bin_edges is not None or time_axis is not None) and no_nans:
warnings.warn('The step, time axis, or bin edges have been set, the series may not be evenly_spaced',stacklevel=3)

# Set the bin edges
if bin_edges is not None:
if start is not None or stop is not None or bin_size is not None or step_style is not None or time_axis is not None:
Expand Down Expand Up @@ -278,6 +276,12 @@ def bin(x, y, bin_size=None, start=None, stop=None, step_style=None, evenly_spac
'error': error,
}

if no_nans is True:
_,ts = dropna(binned_values,time_axis)
check = is_evenly_spaced(ts)
if not check:
warnings.warn('no_nans is set to True but has been overridden by other parameters. This has resulted in nans being present in the returned series',stacklevel=3)

return res_dict


Expand Down Expand Up @@ -437,9 +441,6 @@ def gkernel(t,y, h = 3.0, step=None,start=None,stop=None, step_style = None, eve
# Make sure x and y are numpy arrays
t = np.array(t, dtype='float64')
y = np.array(y, dtype='float64')

if (step is not None or bin_edges is not None) and no_nans:
warnings.warn('The step or bins has been set, the series may not be evenly_spaced',stacklevel=3)

# Set the bin edges
if bin_edges is not None:
Expand Down Expand Up @@ -478,6 +479,12 @@ def gkernel(t,y, h = 3.0, step=None,start=None,stop=None, step_style = None, eve
else:
yc[i] = np.nan

if no_nans is True:
_,ts = dropna(yc,time_axis)
check = is_evenly_spaced(ts)
if not check:
warnings.warn('no_nans is set to True but has been overridden by other parameters. This has resulted in nans being present in the returned series',stacklevel=3)

return time_axis, yc


Expand Down