From 305ebfbe65babb51a172498a37bb4c6c9d79a472 Mon Sep 17 00:00:00 2001 From: Sanjay Ramchandani <65647041+sanjaygrr@users.noreply.github.com> Date: Wed, 4 Nov 2026 19:38:13 -0300 Subject: [PATCH] Pass out=None with where= for masked arrays to silence numpy warning --- gsw/_utilities.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/gsw/_utilities.py b/gsw/_utilities.py index f508699..ca1b429 100644 --- a/gsw/_utilities.py +++ b/gsw/_utilities.py @@ -51,7 +51,13 @@ def wrapper(*args, **kwargs): ) where = ~mask - new_kwargs = {"where": where} + # Values under the mask are left uninitialized, which is fine for masked + # arrays; passing out=None explicitly avoids numpy's "'where' used + # without 'out'" warning. Multi-output ufuncs need one None per output. + nout = len(f.types[0].split("->")[1]) if hasattr(f, "types") else 1 + out = None if nout == 1 else (None,) * nout + + new_kwargs = {"where": where, "out": out} new_kwargs.update( **kwargs ) # Allow user override of the where kwarg if they passed it in.