| decorator_with_option |
Ran ran on a synthesized input |
google-research/jax3d/jax3d/utils/py_utils.py code served (permissive licence) · get_code("3c330a09b474ddee") How it ranRan in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned function. The image it ran in was not recorded. If your copy returns the same type on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.
import collections.abc
import functools
from typing import Any
def decorator_with_option(decorator_fn):
"""Wraps a decorator to correctly forward decorator options.
`decorator_with_option` is applied on decorators. Usage:
@jax3d.utils.decorator_with_option
def my_decorator(fn, x=None, y=None):
...
The decorated decorator can then be used with or without options, or
called directly.
@my_decorator(x, y=y)
def fn():
...
@my_decorator
def fn():
...
fn = my_decorator(fn, x, y=y)
Args:
decorator_fn: The decorator with signature `(fn, *option, **option_kwargs)`
Returns:
The `decorator_fn` which now can be used as decorator with option.
"""
@functools.wraps(decorator_fn)
def decorated(*args: Any, **kwargs: Any) -> Any:
fn = args[0] if args else None
if not isinstance(fn, collections.abc.Callable):
def decorated_with_options(fn):
return decorator_fn(fn, *args, **kwargs)
return decorated_with_options
return decorator_fn(fn, *args[1:], **kwargs)
return decorated
def sample_decorator(fn, option1=None, option2=None):
"""A simple decorator function to test decorator_with_option."""
@functools.wraps(fn)
def wrapper(*args, **kwargs):
return fn(*args, **kwargs)
return wrapper
def sample_function():
"""A simple function to be decorated."""
return 42
ARGS = {
"decorator_fn": sample_decorator
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
- Imports
- none outside the standard library — import names as written, not package names to install; a name the repository itself provides is not a package
- Returned
- type function — a function output has no array shape of its own; none is stated — the instrument coerces any output to an array; for a function output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
- Environment
- image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
|
| get_coords_grid |
Ran ran on a synthesized input |
google-research/jax3d/jax3d/utils/geo_utils.py code served (permissive licence) · get_code("2f66a837d8b9c377") How it ranRan in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned ArrayImpl, ndim 3, dtype family int, shape (28, 28, 2) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.
import jax.numpy as jnp
from typing import Tuple
ARGS = {
"grid_shape": (28, 28),
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
- Imports
- etils, jax — import names as written, not package names to install; a name the repository itself provides is not a package
- Returned
- type ArrayImpl, ndim 3, dtype family int, shape (28, 28, 2) — shape (28, 28, 2) as a later run recorded it
- dtype family
- int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
- Environment
- image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
|
| get_normalizer_from_time_unit_str |
Ran ran on a synthesized input |
google-research/jax3d/jax3d/utils/chronometer.py code served (permissive licence) · get_code("4f8a6fa7be26cdeb") How it ranRan in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned float, ndim 0, dtype family float, shape () as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.
import torch
ARGS = {
'time_unit': 'seconds'
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
- Imports
- torch — import names as written, not package names to install; a name the repository itself provides is not a package
- Returned
- type float, ndim 0, dtype family float, shape () — shape () as a later run recorded it
- dtype family
- int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
- Environment
- image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
|
| lch_from_oklab |
Ran ran on a synthesized input |
google-research/jax3d/jax3d/utils/plot_segmentation.py code served (permissive licence) · get_code("a51a0695d8442d5a") How it ranRan in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned ndarray, ndim 2, dtype family float, shape (2, 3) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.
import numpy as np
import torch
torch.manual_seed(0)
# Create a small Oklab color array with shape (2, 3)
# Oklab has 3 components: L (lightness), a, b
lab = np.array([
[0.5, 0.1, 0.2],
[0.7, -0.05, 0.15]
], dtype=np.float32)
ARGS = {
'lab': lab
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
- Imports
- etils, numpy, torch — import names as written, not package names to install; a name the repository itself provides is not a package
- Returned
- type ndarray, ndim 2, dtype family float, shape (2, 3) — shape (2, 3) as a later run recorded it
- dtype family
- int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
- Environment
- image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
|
| oklab_from_rgb |
Ran ran on a synthesized input |
google-research/jax3d/jax3d/utils/plot_segmentation.py code served (permissive licence) · get_code("4c919b9133a99d5f") How it ranRan in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned ndarray, ndim 2, dtype family float, shape (2, 3) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.
import numpy as np
from etils.array_types import f32
# The function takes RGB color values and converts them to Oklab
# The input should be an array of shape (..., 3) with float values in range [0, 1]
# Create a small test RGB array with shape (2, 3)
# Using 2 colors: one reddish, one blueish
rgb_input = np.array([
[0.8, 0.2, 0.1], # reddish color
[0.1, 0.3, 0.9] # blueish color
], dtype=np.float32)
ARGS = {
'rgb': rgb_input
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
- Imports
- etils, numpy, skimage — import names as written, not package names to install; a name the repository itself provides is not a package
- Returned
- type ndarray, ndim 2, dtype family float, shape (2, 3) — shape (2, 3) as a later run recorded it
- dtype family
- int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
- Environment
- image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
|
| polar_to_cartesian |
Ran ran on a synthesized input |
google-research/jax3d/jax3d/utils/random.py code served (permissive licence) · get_code("05e7896890bec385") How it ranRan in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned ArrayImpl, ndim 2, dtype family float, shape (2, 3) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.
from jax import numpy as jnp
import numpy as np
# Create valid input for polar_to_cartesian
# The function expects theta_phi with shape (..., 2)
# where the last dimension has 2 elements: [theta, phi]
# Create a simple batch of polar coordinates
# Shape: (2, 2) - batch size 2, each with [theta, phi]
theta_phi_data = np.array([
[np.pi/4, np.pi/6], # First set of polar coordinates
[np.pi/3, np.pi/4] # Second set of polar coordinates
], dtype=np.float32)
# Convert to JAX array
theta_phi = jnp.array(theta_phi_data)
ARGS = {
"theta_phi": theta_phi
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
- Imports
- jax, numpy — import names as written, not package names to install; a name the repository itself provides is not a package
- Returned
- type ArrayImpl, ndim 2, dtype family float, shape (2, 3) — shape (2, 3) as a later run recorded it
- dtype family
- int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
- Environment
- image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
|
| rgb_from_oklab |
Ran ran on a synthesized input |
google-research/jax3d/jax3d/utils/plot_segmentation.py code served (permissive licence) · get_code("781aed1274c8408f") How it ranRan in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned ndarray, ndim 2, dtype family float, shape (2, 3) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.
import numpy as np
from etils.array_types import f32
# Create a valid Oklab color array
# Oklab values typically have L in [0, 1], a and b in roughly [-0.4, 0.4]
# Shape: (batch_size, 3) where 3 represents [L, a, b]
lab_colors = np.array([
[0.5, 0.1, -0.1],
[0.7, -0.05, 0.15]
], dtype=np.float32)
ARGS = {
'lab': lab_colors
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
- Imports
- etils, numpy, skimage — import names as written, not package names to install; a name the repository itself provides is not a package
- Returned
- type ndarray, ndim 2, dtype family float, shape (2, 3) — shape (2, 3) as a later run recorded it
- dtype family
- int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
- Environment
- image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
|
| uniform_points_on_sphere |
Ran ran on a synthesized input |
google-research/jax3d/jax3d/utils/random.py code served (permissive licence) · get_code("bf728d37bde131be") How it ranRan in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned ArrayImpl, ndim 3, dtype family float, shape (2, 4, 3) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.
import jax
import jax.random
from jax import numpy as jnp
import numpy as np
class RandomState:
"""Small stateful wrapper around `jax.random.split` to reduce boilerplate."""
def __init__(self, seed_or_rng):
"""Constructor."""
if isinstance(seed_or_rng, (np.ndarray, jnp.ndarray)):
self.curr_key = seed_or_rng
elif isinstance(seed_or_rng, int):
self.curr_key = jax.random.PRNGKey(seed_or_rng)
else:
raise TypeError(f'Invalid seed or key: {seed_or_rng}')
def next(self, n=None):
"""Returns the next rng key."""
if n is None:
self.curr_key, key = jax.random.split(self.curr_key)
return key
else:
keys = jax.random.split(self.curr_key, n + 1)
self.curr_key = keys[0]
return keys[1:]
def fork(self):
"""Returns another RandomState initialised with `.next()`."""
return RandomState(self.next())
def fold_in(self, data: int) -> None:
"""Folds in delta into the random state."""
self.curr_key = jax.random.fold_in(self.curr_key, data)
def fold_in_stateless(self, data: int):
"""Folds in delta into the random state (stateless version)."""
return RandomState(jax.random.fold_in(self.curr_key, data))
def bind_to_host_device(self, *, bind_to: str, axis_name=None):
"""Binds this random state to the host/device we are on."""
self.curr_key = self.bind_to_host_device_stateless(bind_to=bind_to, axis_name=axis_name).curr_key
def bind_to_host_device_stateless(self, *, bind_to: str, axis_name=None):
"""Binds the random state to the host/device we are on."""
if bind_to == 'host':
return RandomState(jax.random.fold_in(self.curr_key, jax.process_index()))
elif bind_to == 'device':
return RandomState(jax.random.fold_in(self.curr_key, jax.lax.axis_index(axis_name)))
else:
raise ValueError("`bind_to` should be one of the `[None, 'host', 'device']`")
def uniform_polar_points_on_sphere(rng: RandomState, shape):
"""Return an array of points evenly distributed on a sphere."""
assert shape[-1] == 2
u = jax.random.uniform(rng.next(), shape[0:-1] + (1,), minval=-1.0, maxval=1.0)
phi = jnp.arccos(u)
theta = jax.random.uniform(rng.next(), shape[0:-1] + (1,), minval=0.0, maxval=2.0 * jnp.pi)
return jnp.concatenate([theta, phi], axis=-1)
def polar_to_cartesian(theta_phi):
"""Convert polar coordinates to cartesian coordinates."""
assert theta_phi.shape[-1] == 2
sin_theta = jnp.sin(theta_phi[..., 0])
cos_theta = jnp.cos(theta_phi[..., 0])
sin_phi = jnp.sin(theta_phi[..., 1])
cos_phi = jnp.cos(theta_phi[..., 1])
return jnp.stack([sin_theta * sin_phi, cos_theta * sin_phi, cos_phi], axis=-1)
def uniform_points_on_sphere(rng: RandomState, shape):
"""Return an array of shape of points evenly distributed on a sphere."""
assert shape[-1] == 3
theta_phi = uniform_polar_points_on_sphere(rng, shape[0:-1] + (2,))
points = polar_to_cartesian(theta_phi)
return points
rng = RandomState(42)
shape = (2, 4, 3)
ARGS = {
"rng": rng,
"shape": shape,
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
- Imports
- etils, jax, numpy — import names as written, not package names to install; a name the repository itself provides is not a package
- Returned
- type ArrayImpl, ndim 3, dtype family float, shape (2, 4, 3) — shape (2, 4, 3) as a later run recorded it
- dtype family
- int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
- Environment
- image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
|
| uniform_polar_points_on_sphere |
Ran ran on a synthesized input |
google-research/jax3d/jax3d/utils/random.py code served (permissive licence) · get_code("6122daa0179cc39a") How it ranRan in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned ArrayImpl, ndim 3, dtype family float, shape (4, 3, 2) as a later run recorded it. The image it ran in was not recorded. If your copy returns the same type, ndim and shape on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.
import jax
import jax.random
from jax import numpy as jnp
import numpy as np
class RandomState:
"""Small stateful wrapper around `jax.random.split` to reduce boilerplate."""
def __init__(self, seed_or_rng):
"""Constructor."""
if isinstance(seed_or_rng, (np.ndarray, jnp.ndarray)):
self.curr_key = seed_or_rng
elif isinstance(seed_or_rng, int):
self.curr_key = jax.random.PRNGKey(seed_or_rng)
else:
raise TypeError(f'Invalid seed or key: {seed_or_rng}')
def next(self, n=None):
"""Returns the next rng key."""
if n is None:
self.curr_key, key = jax.random.split(self.curr_key)
return key
else:
keys = jax.random.split(self.curr_key, n + 1)
self.curr_key = keys[0]
return keys[1:]
def fork(self):
"""Returns another RandomState initialised with `.next()`."""
return RandomState(self.next())
def fold_in(self, data):
"""Folds in delta into the random state."""
self.curr_key = jax.random.fold_in(self.curr_key, data)
def fold_in_stateless(self, data):
"""Folds in delta into the random state."""
return RandomState(jax.random.fold_in(self.curr_key, data))
def bind_to_host_device(self, *, bind_to, axis_name=None):
"""Binds this random state to the host/device we are on."""
self.curr_key = self.bind_to_host_device_stateless(bind_to=bind_to, axis_name=axis_name).curr_key
def bind_to_host_device_stateless(self, *, bind_to, axis_name=None):
"""Binds the random state to the host/device we are on."""
if bind_to == 'host':
return RandomState(jax.random.fold_in(self.curr_key, jax.process_index()))
elif bind_to == 'device':
return RandomState(jax.random.fold_in(self.curr_key, jax.lax.axis_index(axis_name)))
else:
raise ValueError("`bind_to` should be one of the `[None, 'host', 'device']`")
def uniform_polar_points_on_sphere(rng, shape):
"""Return an array of points evenly distributed on a sphere."""
assert shape[-1] == 2
u = jax.random.uniform(rng.next(), shape[0:-1] + (1,), minval=-1.0, maxval=1.0)
phi = jnp.arccos(u)
theta = jax.random.uniform(rng.next(), shape[0:-1] + (1,), minval=0.0, maxval=2.0 * jnp.pi)
return jnp.concatenate([theta, phi], axis=-1)
rng = RandomState(42)
shape = (4, 3, 2)
ARGS = {
'rng': rng,
'shape': shape,
}
- Setup block drafted by
- a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
- Imports
- etils, jax, numpy — import names as written, not package names to install; a name the repository itself provides is not a package
- Returned
- type ArrayImpl, ndim 3, dtype family float, shape (4, 3, 2) — shape (4, 3, 2) as a later run recorded it
- dtype family
- int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
- Environment
- image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: none by the harness; any seed is in the setup block
|