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

Resolve some deprecation warnings #523

Merged
merged 2 commits into from
May 18, 2024
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions scico/_autograd.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (C) 2020-2022 by SCICO Developers
# Copyright (C) 2020-2024 by SCICO Developers
# All rights reserved. BSD 3-clause License.
# This file is part of the SCICO package. Details of the copyright and
# user license can be found in the 'LICENSE' file distributed with the
Expand Down Expand Up @@ -191,6 +191,6 @@ def cvjp(fun: Callable, *primals, jidx: Optional[int] = None) -> Tuple[Tuple[Any
primals_out, fun_vjp = jax.vjp(pfun, primals[jidx])

def conj_vjp(tangent):
return jax.tree_map(jax.numpy.conj, fun_vjp(tangent.conj()))
return jax.tree_util.tree_map(jax.numpy.conj, fun_vjp(tangent.conj()))

return primals_out, conj_vjp
6 changes: 3 additions & 3 deletions scico/flax/examples/data_generation.py
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ def generate_ct_data(
img = distributed_data_generation(imgfunc, size, nimg, False)
time_dtgen = time() - start_time
# Clip to [0,1] range.
img = jnp.clip(img, a_min=0, a_max=1)
img = jnp.clip(img, 0, 1)

nproc = jax.device_count()

Expand Down Expand Up @@ -319,7 +319,7 @@ def generate_blur_data(
time_dtgen = time() - start_time

# Clip to [0,1] range.
img = jnp.clip(img, a_min=0, a_max=1)
img = jnp.clip(img, 0, 1)
nproc = jax.device_count()

# Configure blur operator
Expand All @@ -343,7 +343,7 @@ def generate_blur_data(
noise = jax.random.normal(key, blur.shape)
blurn = blur + noise_sigma * noise
# Clip to [0,1] range.
blurn = jnp.clip(blurn, a_min=0, a_max=1)
blurn = jnp.clip(blurn, 0, 1)

if verbose: # pragma: no cover
platform = jax.lib.xla_bridge.get_backend().platform
Expand Down
6 changes: 3 additions & 3 deletions scico/flax/train/traversals.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2022 by SCICO Developers
# Copyright (C) 2022-2024 by SCICO Developers
# All rights reserved. BSD 3-clause License.
# This file is part of the SCICO package. Details of the copyright and
# user license can be found in the 'LICENSE' file distributed with the
Expand Down Expand Up @@ -37,7 +37,7 @@ def clip_positive(params: PyTree, traversal: ModelParamTraversal, minval: float
minval: Minimum value to clip selected model parameters and keep
them in a positive range. Default: 1e-4.
"""
params_out = traversal.update(lambda x: jnp.clip(x, a_min=minval), params)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fine, could also jnp.clip(x, min=minval)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately whether that works is dependent on the jax version in use.

params_out = traversal.update(lambda x: jnp.clip(x, minval), params)

return params_out

Expand All @@ -55,6 +55,6 @@ def clip_range(
maxval: Maximum value to clip selected model parameters.
Default: 1.
"""
params_out = traversal.update(lambda x: jnp.clip(x, a_min=minval, a_max=maxval), params)
params_out = traversal.update(lambda x: jnp.clip(x, minval, maxval), params)

return params_out
Loading