Skip to content

Commit 29412fc

Browse files
authored
Add backwards compatibility for NormalCG and add deprecation warning (#190)
* Deprecate NormalCG helper function - Added **kwargs support to NormalCG function signature - Added DeprecationWarning directing users to use lx.Normal(lx.CG(...)) instead - Added docstring with deprecation notice - Imported warnings module * Align deprecation warning with Diffrax patterns - Use "in favour of" phrasing (consistent with Diffrax) - Add backticks around code examples - Specify "in some future version of Lineax" - Keep DeprecationWarning category (more semantically correct) - Update both warning message and docstring * fix precommit
1 parent 288ca23 commit 29412fc

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

lineax/_solver/cg.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15+
import warnings
1516
from collections.abc import Callable
1617
from typing import Any, TypeAlias
1718

@@ -267,5 +268,17 @@ def assume_full_rank(self):
267268
"""
268269

269270

270-
def NormalCG(*args):
271-
return Normal(CG(*args))
271+
def NormalCG(*args, **kwargs):
272+
"""Deprecated helper function. Use `lx.Normal(lx.CG(...))` instead.
273+
274+
!!! warning "Deprecated"
275+
`NormalCG(...)` is deprecated in favour of `lx.Normal(lx.CG(...))`.
276+
This will be removed in some future version of Lineax.
277+
"""
278+
warnings.warn(
279+
"`NormalCG(...)` is deprecated in favour of `lx.Normal(lx.CG(...))`. "
280+
"This will be removed in some future version of Lineax.",
281+
DeprecationWarning,
282+
stacklevel=2,
283+
)
284+
return Normal(CG(*args, **kwargs))

0 commit comments

Comments
 (0)