inputs
stringlengths
312
52k
targets
stringlengths
1
3.1k
block_type
stringclasses
11 values
scenario
stringclasses
7 values
<filename>camp_zipnerf/internal/math.py<fim_prefix># coding=utf-8 # Copyright 2023 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/l...
"""Backpropagate using the gradient and clipped inputs."""
BLOCK_COMMENT
prefix_suffix_full_complete_current_block_no_evidence
<filename>camp_zipnerf/internal/render.py<fim_prefix># coding=utf-8 # Copyright 2023 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org...
"""Approximate a cylinder as a Gaussian distribution (mean+cov). Assumes the ray is originating from the origin, and radius is the radius. Does not renormalize `d`. Args: d: jnp.float32 3-vector, the axis of the cylinder t0: float, the starting distance of the cylinder. t1: float, the ending distanc...
BLOCK_COMMENT
prefix_suffix_full_complete_current_block_no_evidence
<filename>camp_zipnerf/internal/coord.py<fim_prefix># coding=utf-8 # Copyright 2023 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/...
"""Compute the mean of sin(x), x ~ N(mean, var)."""
BLOCK_COMMENT
prefix_suffix_full_complete_current_block_no_evidence
<filename>camp_zipnerf/internal/math.py<fim_prefix># coding=utf-8 # Copyright 2023 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/l...
"""Clamps `x` from below to be positive."""
BLOCK_COMMENT
prefix_suffix_full_complete_current_block_no_evidence
<filename>camp_zipnerf/internal/stepfun.py<fim_prefix># coding=utf-8 # Copyright 2023 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.or...
if deterministic_center: pad = 1 / (2 * num_samples) u = jnp.linspace(pad, 1.0 - pad - eps, num_samples) else: u = jnp.linspace(0, 1.0 - eps, num_samples)
IF
prefix_suffix_full_complete_current_block_no_evidence
<filename>camp_zipnerf/internal/coord.py<fim_prefix># coding=utf-8 # Copyright 2023 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/...
if scale is not None: # Compute the Jacobian of fn function at the locations of each mean. jac = jax.vmap(lin_fn, in_axes=-1, out_axes=-1)( jnp.broadcast_to(jnp.eye(d), mean.shape + (d,)) ) # The cube root of the determinant of the Jacobian is the geometric mean # of the eigenvalues of the ...
IF
prefix_suffix_full_complete_current_block_no_evidence
<filename>camp_zipnerf/internal/stepfun.py<fim_prefix># coding=utf-8 # Copyright 2023 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.or...
if rng is None: # Match the behavior of jax.random.uniform() by spanning [0, 1-eps]. if deterministic_center: pad = 1 / (2 * num_samples) u = jnp.linspace(pad, 1.0 - pad - eps, num_samples) else: u = jnp.linspace(0, 1.0 - eps, num_samples) u = jnp.broadcast_to(u, t.shape[:-1] + (num_sa...
IF
prefix_suffix_full_complete_current_block_no_evidence
<filename>camp_zipnerf/internal/utils.py<fim_prefix># coding=utf-8 # Copyright 2023 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/...
if not populating_data and results_queue.empty(): break
IF
prefix_suffix_full_complete_current_block_no_evidence
<filename>camp_zipnerf/internal/coord.py<fim_prefix># coding=utf-8 # Copyright 2023 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/...
if mode == 'fast': det = jnp.linalg.det(cov) diag_val = det ** (1 / d) is_invalid = (det <= jnp.finfo(jnp.float32).tiny) | ~jnp.isfinite(det) elif mode == 'accurate': log_det = jnp.linalg.slogdet(cov)[1] diag_val = jnp.exp(log_det / d) is_invalid = ~jnp.isfinite(log_det) else: raise Valu...
IF
prefix_suffix_full_complete_current_block_no_evidence
<filename>camp_zipnerf/internal/utils.py<fim_prefix># coding=utf-8 # Copyright 2023 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/...
if not populating_data and results_queue.empty(): break
IF
prefix_suffix_full_complete_current_block_no_evidence
<filename>camp_zipnerf/internal/geopoly.py<fim_prefix># coding=utf-8 # Copyright 2023 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.or...
if remove_symmetries: # Remove elements of `verts` that are reflections of each other. match = compute_sq_dist(verts.T, -verts.T) < eps verts = verts[~np.any(np.triu(match), axis=0), :]
IF
prefix_suffix_full_complete_current_block_no_evidence
<filename>camp_zipnerf/internal/coord.py<fim_prefix># coding=utf-8 # Copyright 2023 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/...
if fn_inv is None: # A simple mapping from some functions to their inverse. inv_mapping = { 'reciprocal': jnp.reciprocal, 'log': jnp.exp, 'exp': jnp.log, 'sqrt': jnp.square, 'square': jnp.sqrt, } fn_inv = inv_mapping[fn.__name__]
IF
prefix_suffix_full_complete_current_block_no_evidence
<filename>camp_zipnerf/internal/geopoly.py<fim_prefix># coding=utf-8 # Copyright 2023 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.or...
if mat1 is None: mat1 = mat0
IF
prefix_suffix_full_complete_current_block_no_evidence
<filename>camp_zipnerf/internal/math.py<fim_prefix># coding=utf-8 # Copyright 2023 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/l...
if device_is_tpu: # Identify the location in `xp` that corresponds to each `x`. # The final `True` index in `mask` is the start of the matching interval. mask = x[Ellipsis, None, :] >= xp[Ellipsis, :, None] def find_interval(x): # Grab the value where `mask` switches from True to False, and vice ...
IF
prefix_suffix_full_complete_current_block_no_evidence
<filename>camp_zipnerf/internal/stepfun.py<fim_prefix># coding=utf-8 # Copyright 2023 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.or...
wq = jnp.diff(acc_wq, axis=-1)
STATEMENT
prefix_suffix_full_complete_current_block_no_evidence
<filename>camp_zipnerf/internal/geopoly.py<fim_prefix># coding=utf-8 # Copyright 2023 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.or...
new_verts /= np.sqrt(np.sum(new_verts**2, 1, keepdims=True))
STATEMENT
prefix_suffix_full_complete_current_block_no_evidence
<filename>camp_zipnerf/internal/stepfun.py<fim_prefix># coding=utf-8 # Copyright 2023 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.or...
return t_new
STATEMENT
prefix_suffix_full_complete_current_block_no_evidence
<filename>camp_zipnerf/internal/linspline.py<fim_prefix># coding=utf-8 # Copyright 2023 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache....
c = jnp.concatenate([jnp.zeros_like(y[Ellipsis, :1]), c1], axis=-1)
STATEMENT
prefix_suffix_full_complete_current_block_no_evidence
<filename>camp_zipnerf/internal/math.py<fim_prefix># coding=utf-8 # Copyright 2023 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/l...
return safe_trig_helper(x, jnp.sin)
STATEMENT
prefix_suffix_full_complete_current_block_no_evidence
<filename>camp_zipnerf/internal/coord.py<fim_prefix># coding=utf-8 # Copyright 2023 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/...
return z
STATEMENT
prefix_suffix_full_complete_current_block_no_evidence
<filename>camp_zipnerf/internal/math.py<fim_prefix># coding=utf-8 # Copyright 2023 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/l...
vals = []
STATEMENT
prefix_suffix_full_complete_current_block_no_evidence
<filename>camp_zipnerf/internal/ref_utils.py<fim_prefix># coding=utf-8 # Copyright 2023 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache....
ide = sph_harms * jnp.exp(-sigma * kappa_inv)
STATEMENT
prefix_suffix_full_complete_current_block_no_evidence
<filename>camp_zipnerf/internal/ref_utils.py<fim_prefix># coding=utf-8 # Copyright 2023 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache....
vmz = jnp.concatenate([z**i for i in range(mat.shape[0])], axis=-1)
STATEMENT
prefix_suffix_full_complete_current_block_no_evidence
<filename>camp_zipnerf/internal/coord.py<fim_prefix># coding=utf-8 # Copyright 2023 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/...
z_mag_sq = jnp.maximum(1, jnp.sum(z**2, axis=-1, keepdims=True))
STATEMENT
prefix_suffix_full_complete_current_block_no_evidence
<filename>camp_zipnerf/internal/utils.py<fim_prefix># coding=utf-8 # Copyright 2023 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/...
# Thread exception will be raised here
LINE_COMMENT
prefix_suffix_full_complete_current_block_no_evidence
<filename>camp_zipnerf/internal/stepfun.py<fim_prefix># coding=utf-8 # Copyright 2023 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.or...
# Sample a set of points from the step function.
LINE_COMMENT
prefix_suffix_full_complete_current_block_no_evidence
<filename>camp_zipnerf/internal/ref_utils.py<fim_prefix># coding=utf-8 # Copyright 2023 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache....
# concentration parameter, kappa.
LINE_COMMENT
prefix_suffix_full_complete_current_block_no_evidence
<filename>camp_zipnerf/internal/stepfun.py<fim_prefix># coding=utf-8 # Copyright 2023 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.or...
# The loss incurred within each individual interval with itself.
LINE_COMMENT
prefix_suffix_full_complete_current_block_no_evidence
<filename>camp_zipnerf/internal/linspline.py<fim_prefix># coding=utf-8 # Copyright 2023 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache....
# Dilate the t-values by at least numerical epsilon in each direction.
LINE_COMMENT
prefix_suffix_full_complete_current_block_no_evidence
<filename>camp_zipnerf/internal/geopoly.py<fim_prefix># coding=utf-8 # Copyright 2023 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.or...
# Barycentric weights.
LINE_COMMENT
prefix_suffix_full_complete_current_block_no_evidence
<filename>camp_zipnerf/internal/coord.py<fim_prefix># coding=utf-8 # Copyright 2023 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/...
# Guard against NaN outputs when `det` is super small. Note that this does not
LINE_COMMENT
prefix_suffix_full_complete_current_block_no_evidence
<filename>camp_zipnerf/internal/stepfun.py<fim_prefix># coding=utf-8 # Copyright 2023 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.or...
# The loss incurred between all pairs of intervals.
LINE_COMMENT
prefix_suffix_full_complete_current_block_no_evidence
<filename>camp_zipnerf/internal/math.py<fim_prefix># coding=utf-8 # Copyright 2023 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/l...
# jnp.searchsorted() has slightly different conventions for boundary
LINE_COMMENT
prefix_suffix_full_complete_current_block_no_evidence
<filename>camp_zipnerf/internal/utils.py<fim_prefix># coding=utf-8 # Copyright 2023 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/...
# iterations
LINE_COMMENT
prefix_suffix_full_complete_current_block_no_evidence
<filename>camp_zipnerf/internal/geopoly.py<fim_prefix># coding=utf-8 # Copyright 2023 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.or...
for i in range(v + 1): for j in range(v + 1 - i): int_weights.append((i, j, v - (i + j)))
FOR
prefix_suffix_full_complete_current_block_no_evidence
<filename>camp_zipnerf/internal/ref_utils.py<fim_prefix># coding=utf-8 # Copyright 2023 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache....
for i in range(deg_view): l = 2**i # Only use nonnegative m values, later splitting real and imaginary parts. for m in range(l + 1): ml_list.append((m, l))
FOR
prefix_suffix_full_complete_current_block_no_evidence
<filename>camp_zipnerf/internal/geopoly.py<fim_prefix># coding=utf-8 # Copyright 2023 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.or...
for j in range(v + 1 - i): int_weights.append((i, j, v - (i + j)))
FOR
prefix_suffix_full_complete_current_block_no_evidence
<filename>camp_zipnerf/internal/utils.py<fim_prefix># coding=utf-8 # Copyright 2023 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/...
for item in fn(*args, **kwargs): results_queue.put(item)
FOR
prefix_suffix_full_complete_current_block_no_evidence
<filename>camp_zipnerf/internal/ref_utils.py<fim_prefix># coding=utf-8 # Copyright 2023 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache....
for k in range(l - m + 1): mat[k, i] = sph_harm_coeff(l, m, k)
FOR
prefix_suffix_full_complete_current_block_no_evidence
<filename>camp_zipnerf/internal/math.py<fim_prefix># coding=utf-8 # Copyright 2023 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/l...
for fp in fps: fp0 = jnp.take_along_axis(fp, idx0, axis=-1) fp1 = jnp.take_along_axis(fp, idx1, axis=-1) vals.append((fp0, fp1))
FOR
prefix_suffix_full_complete_current_block_no_evidence
<filename>camp_zipnerf/internal/utils.py<fim_prefix># coding=utf-8 # Copyright 2023 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/...
for item in fn(*args, **kwargs): results_queue.put(item)
FOR
prefix_suffix_full_complete_current_block_no_evidence
<filename>camp_zipnerf/internal/geopoly.py<fim_prefix># coding=utf-8 # Copyright 2023 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.or...
for base_face in base_faces: new_verts = np.matmul(tri_weights, base_verts[base_face, :]) new_verts /= np.sqrt(np.sum(new_verts**2, 1, keepdims=True)) verts.append(new_verts)
FOR
prefix_suffix_full_complete_current_block_no_evidence
<filename>camp_zipnerf/internal/ref_utils.py<fim_prefix># coding=utf-8 # Copyright 2023 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache....
for m in range(l + 1): ml_list.append((m, l))
FOR
prefix_suffix_full_complete_current_block_no_evidence
<filename>camp_zipnerf/internal/utils.py<fim_prefix># coding=utf-8 # Copyright 2023 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/...
for item in fn(*args, **kwargs): results_queue.put(item)
FOR
prefix_suffix_full_complete_current_block_no_evidence
<filename>camp_zipnerf/internal/utils.py<fim_prefix># coding=utf-8 # Copyright 2023 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/...
def result_fn(*args, **kwargs): results_queue = queue.Queue(queue_size) populating_data = True populating_data_lock = threading.Lock() def thread_fn(): # Mark has_data as a variable that's outside of thread_fn # Otherwise, `populating_data = True` creates a local variable ...
METHOD
prefix_suffix_full_complete_current_block_no_evidence
<filename>camp_zipnerf/internal/utils.py<fim_prefix># coding=utf-8 # Copyright 2023 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/...
def decorator( fn, ): def result_fn(*args, **kwargs): results_queue = queue.Queue(queue_size) populating_data = True populating_data_lock = threading.Lock() def thread_fn(): # Mark has_data as a variable that's outside of thread_fn # Otherwise, `populating_data = Tru...
METHOD
prefix_suffix_full_complete_current_block_no_evidence
<filename>camp_zipnerf/internal/ref_utils.py<fim_prefix># coding=utf-8 # Copyright 2023 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache....
def dir_enc_fn(xyz): """Function returning directional encoding (DE).""" return integrated_dir_enc_fn(xyz, jnp.zeros_like(xyz[Ellipsis, :1]))
METHOD
prefix_suffix_full_complete_current_block_no_evidence
<filename>camp_zipnerf/internal/ref_utils.py<fim_prefix># coding=utf-8 # Copyright 2023 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache....
def integrated_dir_enc_fn(xyz, kappa_inv): """Function returning integrated directional encoding (IDE). Args: xyz: [..., 3] array of Cartesian coordinates of directions to evaluate at. kappa_inv: [..., 1] reciprocal of the concentration parameter of the von Mises-Fisher distribution. R...
METHOD
prefix_suffix_full_complete_current_block_no_evidence
<filename>camp_zipnerf/internal/utils.py<fim_prefix># coding=utf-8 # Copyright 2023 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/...
def thread_fn(): # Mark has_data as a variable that's outside of thread_fn # Otherwise, `populating_data = True` creates a local variable nonlocal populating_data try: for item in fn(*args, **kwargs): results_queue.put(item) finally: # Set populati...
METHOD
prefix_suffix_full_complete_current_block_no_evidence
<filename>camp_zipnerf/internal/math.py<fim_prefix># coding=utf-8 # Copyright 2023 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/l...
def safe_fn(x): """fn() with clipped inputs.""" return fn(jnp.clip(x, *x_range))
METHOD
prefix_suffix_full_complete_current_block_no_evidence
<filename>camp_zipnerf/internal/utils.py<fim_prefix># coding=utf-8 # Copyright 2023 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/...
def thread_fn(): # Mark has_data as a variable that's outside of thread_fn # Otherwise, `populating_data = True` creates a local variable nonlocal populating_data try: for item in fn(*args, **kwargs): results_queue.put(item) finally: # Set populati...
METHOD
prefix_suffix_full_complete_current_block_no_evidence
<filename>camp_zipnerf/internal/utils.py<fim_prefix># coding=utf-8 # Copyright 2023 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/...
def thread_fn(): # Mark has_data as a variable that's outside of thread_fn # Otherwise, `populating_data = True` creates a local variable nonlocal populating_data try: for item in fn(*args, **kwargs): results_queue.put(item) finally: # Set populati...
METHOD
prefix_suffix_full_complete_current_block_no_evidence
<filename>camp_zipnerf/internal/math.py<fim_prefix># coding=utf-8 # Copyright 2023 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/l...
def safe_fn_jvp(primals, tangents): """Backpropagate using the gradient and clipped inputs.""" (x,) = primals (x_dot,) = tangents y = safe_fn(x) y_dot = grad_fn(jnp.clip(x, *x_range), y, x_dot) return y, y_dot
METHOD
prefix_suffix_full_complete_current_block_no_evidence
<filename>camp_zipnerf/internal/utils.py<fim_prefix># coding=utf-8 # Copyright 2023 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/...
def result_fn(*args, **kwargs): results_queue = queue.Queue(queue_size) populating_data = True populating_data_lock = threading.Lock() def thread_fn(): # Mark has_data as a variable that's outside of thread_fn # Otherwise, `populating_data = True` creates a local variable ...
METHOD
prefix_suffix_full_complete_current_block_no_evidence
<filename>camp_zipnerf/internal/utils.py<fim_prefix># coding=utf-8 # Copyright 2023 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/...
try: for item in fn(*args, **kwargs): results_queue.put(item)
TRY
prefix_suffix_full_complete_current_block_no_evidence
<filename>camp_zipnerf/internal/utils.py<fim_prefix># coding=utf-8 # Copyright 2023 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/...
try: # Set timeout to allow for exceptions to be propagated. next_value = results_queue.get(timeout=1.0)
TRY
prefix_suffix_full_complete_current_block_no_evidence
<filename>camp_zipnerf/internal/utils.py<fim_prefix># coding=utf-8 # Copyright 2023 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/...
try: # Set timeout to allow for exceptions to be propagated. next_value = results_queue.get(timeout=1.0)
TRY
prefix_suffix_full_complete_current_block_no_evidence
<filename>camp_zipnerf/internal/utils.py<fim_prefix># coding=utf-8 # Copyright 2023 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/...
try: for item in fn(*args, **kwargs): results_queue.put(item)
TRY
prefix_suffix_full_complete_current_block_no_evidence
<filename>camp_zipnerf/internal/utils.py<fim_prefix># coding=utf-8 # Copyright 2023 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/...
try: # Set timeout to allow for exceptions to be propagated. next_value = results_queue.get(timeout=1.0)
TRY
prefix_suffix_full_complete_current_block_no_evidence
<filename>camp_zipnerf/internal/utils.py<fim_prefix># coding=utf-8 # Copyright 2023 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/...
try: for item in fn(*args, **kwargs): results_queue.put(item)
TRY
prefix_suffix_full_complete_current_block_no_evidence
<filename>camp_zipnerf/internal/utils.py<fim_prefix># coding=utf-8 # Copyright 2023 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/...
while True: with populating_data_lock: if not populating_data and results_queue.empty(): break get_start = time.time() try: # Set timeout to allow for exceptions to be propagated. next_value = results_queue.get(timeout=1.0) except...
WHILE
prefix_suffix_full_complete_current_block_no_evidence
<filename>camp_zipnerf/internal/utils.py<fim_prefix># coding=utf-8 # Copyright 2023 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/...
while True: with populating_data_lock: if not populating_data and results_queue.empty(): break get_start = time.time() try: # Set timeout to allow for exceptions to be propagated. next_value = results_queue.get(timeout=1.0) except...
WHILE
prefix_suffix_full_complete_current_block_no_evidence
<filename>camp_zipnerf/internal/utils.py<fim_prefix># coding=utf-8 # Copyright 2023 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/...
while True: with populating_data_lock: if not populating_data and results_queue.empty(): break get_start = time.time() try: # Set timeout to allow for exceptions to be propagated. next_value = results_queue.get(timeout=1.0) except...
WHILE
prefix_suffix_full_complete_current_block_no_evidence
<filename>camp_zipnerf/internal/utils.py<fim_prefix># coding=utf-8 # Copyright 2023 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/...
except queue.Empty: continue
CATCH
prefix_suffix_full_complete_current_block_no_evidence
<filename>camp_zipnerf/internal/utils.py<fim_prefix># coding=utf-8 # Copyright 2023 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/...
except queue.Empty: continue
CATCH
prefix_suffix_full_complete_current_block_no_evidence
<filename>camp_zipnerf/internal/utils.py<fim_prefix># coding=utf-8 # Copyright 2023 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/...
except queue.Empty: continue
CATCH
prefix_suffix_full_complete_current_block_no_evidence
<filename>camp_zipnerf/internal/math.py<fim_prefix># coding=utf-8 # Copyright 2023 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/l...
@jax.custom_jvp
ANNOTATION
prefix_suffix_full_complete_current_block_no_evidence
<filename>camp_zipnerf/internal/math.py<fim_prefix># coding=utf-8 # Copyright 2023 The Google Research Authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/l...
@safe_fn.defjvp
ANNOTATION
prefix_suffix_full_complete_current_block_no_evidence
<filename>microagents/agents/agent_persistence_manager.py<fim_prefix>from agents.agent_serializer import AgentSerializer from integrations.memoize import memoize_to_sqlite from integrations.sqlite_agent_persistence import SQLiteAgentPersistence class AgentPersistenceManager: def __init__(self, db_filename="agents...
""" Load all agents from the database. """
BLOCK_COMMENT
prefix_suffix_full_complete_current_block_no_evidence
<filename>microagents/integrations/sqlite_agent_persistence.py<fim_prefix>import sqlite3 import json from integrations.agent_persistence import AbstractAgentPersistence class SQLiteAgentPersistence(AbstractAgentPersistence): def __init__(self, filename="agents.db"): self.filename = filename self._i...
""" Save the serialized agent to an SQLite database. """
BLOCK_COMMENT
prefix_suffix_full_complete_current_block_no_evidence
<filename>microagents/agents/agent_lifecycle.py<fim_prefix>import logging from typing import List from agents.microagent import MicroAgent from integrations.openaiwrapper import OpenAIAPIWrapper from agents.agent_similarity import AgentSimilarity from agents.agent_persistence_manager import AgentPersistenceManager from...
"""Remove all agents with status stopped = True in an efficient manner."""
BLOCK_COMMENT
prefix_suffix_full_complete_current_block_no_evidence
<filename>microagents/agents/agent_lifecycle.py<fim_prefix>import logging from typing import List from agents.microagent import MicroAgent from integrations.openaiwrapper import OpenAIAPIWrapper from agents.agent_similarity import AgentSimilarity from agents.agent_persistence_manager import AgentPersistenceManager from...
""" Generates a prompt for the LLM based on the given goal and sample input. """
BLOCK_COMMENT
prefix_suffix_full_complete_current_block_no_evidence
<filename>microagents/integrations/memoize.py<fim_prefix>import sqlite3 import hashlib import json import functools ## Originally from https://www.kevinkatz.io/posts/memoize-to-sqlite def memoize_to_sqlite(func_name: str, filename: str = "cache.db"): <fim_suffix> def decorator(func): @functools.wraps(...
""" Memoization decorator that caches the output of a method in a SQLite database. """
BLOCK_COMMENT
prefix_suffix_full_complete_current_block_no_evidence
<filename>microagents/agents/agent_lifecycle.py<fim_prefix>import logging from typing import List from agents.microagent import MicroAgent from integrations.openaiwrapper import OpenAIAPIWrapper from agents.agent_similarity import AgentSimilarity from agents.agent_persistence_manager import AgentPersistenceManager from...
"""Creates the prime agent and adds it to the agent list."""
BLOCK_COMMENT
prefix_suffix_full_complete_current_block_no_evidence
<filename>microagents/agents/microagent_manager.py<fim_prefix>import logging from typing import List, Optional, Any from agents.agent_lifecycle import AgentLifecycle from agents.agent_similarity import AgentSimilarity from agents.agent_persistence_manager import AgentPersistenceManager from integrations.openaiwrappe...
"""Returns the list of agents."""
BLOCK_COMMENT
prefix_suffix_full_complete_current_block_no_evidence
<filename>microagents/agents/agent_similarity.py<fim_prefix>import logging import numpy as np from typing import List, Tuple, Optional from sklearn.metrics.pairwise import cosine_similarity from integrations.openaiwrapper import OpenAIAPIWrapper logger = logging.getLogger() class Agent: def __init__(self, purpos...
""" Finds the closest agent based on the given purpose embedding. :param purpose_embedding: The embedding of the purpose to find the closest agent for. :return: Tuple of the closest agent and the highest similarity score. """
BLOCK_COMMENT
prefix_suffix_full_complete_current_block_no_evidence
<filename>microagents/agents/microagent_manager.py<fim_prefix>import logging from typing import List, Optional, Any from agents.agent_lifecycle import AgentLifecycle from agents.agent_similarity import AgentSimilarity from agents.agent_persistence_manager import AgentPersistenceManager from integrations.openaiwrappe...
"""Remove all agents with status stopped = True"""
BLOCK_COMMENT
prefix_suffix_full_complete_current_block_no_evidence
<filename>microagents/agents/agent_similarity.py<fim_prefix>import logging import numpy as np from typing import List, Tuple, Optional from sklearn.metrics.pairwise import cosine_similarity from integrations.openaiwrapper import OpenAIAPIWrapper logger = logging.getLogger() class Agent: def __init__(self, purpos...
""" Retrieves the embedding for a given text. :param text: Text to get embedding for. :return: Embedding as a numpy array. """
BLOCK_COMMENT
prefix_suffix_full_complete_current_block_no_evidence
<filename>microagents/agents/microagent.py<fim_prefix>import logging import uuid from integrations.openaiwrapper import OpenAIAPIWrapper from agents.agent_evaluation import AgentEvaluator from agents.agent_response import AgentResponse from agents.agent_similarity import AgentSimilarity from agents.response_extraction ...
self.parent_id = parent_id
STATEMENT
prefix_suffix_full_complete_current_block_no_evidence
<filename>microagents/agents/microagent.py<fim_prefix>import logging import uuid from integrations.openaiwrapper import OpenAIAPIWrapper from agents.agent_evaluation import AgentEvaluator from agents.agent_response import AgentResponse from agents.agent_similarity import AgentSimilarity from agents.response_extraction ...
self.id = str(uuid.uuid4())
STATEMENT
prefix_suffix_full_complete_current_block_no_evidence
<filename>microagents/integrations/memoize.py<fim_prefix>import sqlite3 import hashlib import json import functools ## Originally from https://www.kevinkatz.io/posts/memoize-to-sqlite def memoize_to_sqlite(func_name: str, filename: str = "cache.db"): """ Memoization decorator that caches the output of a metho...
result = self._fetch_from_cache(arg_hash)
STATEMENT
prefix_suffix_full_complete_current_block_no_evidence
<filename>microagents/agents/microagent.py<fim_prefix>import logging import uuid from integrations.openaiwrapper import OpenAIAPIWrapper from agents.agent_evaluation import AgentEvaluator from agents.agent_response import AgentResponse from agents.agent_similarity import AgentSimilarity from agents.response_extraction ...
self.dynamic_prompt = initial_prompt
STATEMENT
prefix_suffix_full_complete_current_block_no_evidence
<filename>microagents/integrations/sqlite_agent_persistence.py<fim_prefix>import sqlite3 import json from integrations.agent_persistence import AbstractAgentPersistence class SQLiteAgentPersistence(AbstractAgentPersistence): def __init__(self, filename="agents.db"): self.filename = filename self._i...
cursor = conn.cursor()
STATEMENT
prefix_suffix_full_complete_current_block_no_evidence
<filename>microagents/agents/agent_similarity.py<fim_prefix>import logging import numpy as np from typing import List, Tuple, Optional from sklearn.metrics.pairwise import cosine_similarity from integrations.openaiwrapper import OpenAIAPIWrapper logger = logging.getLogger() class Agent: def __init__(self, purpos...
similarity = cosine_similarity([agent.purpose_embedding], [purpose_embedding])[0][0]
STATEMENT
prefix_suffix_full_complete_current_block_no_evidence
<filename>microagents/integrations/memoize.py<fim_prefix>import sqlite3 import hashlib import json import functools ## Originally from https://www.kevinkatz.io/posts/memoize-to-sqlite def memoize_to_sqlite(func_name: str, filename: str = "cache.db"): """ Memoization decorator that caches the output of a metho...
cursor = self.connection.cursor()
STATEMENT
prefix_suffix_full_complete_current_block_no_evidence
<filename>microagents/agents/microagent.py<fim_prefix>import logging import uuid from integrations.openaiwrapper import OpenAIAPIWrapper from agents.agent_evaluation import AgentEvaluator from agents.agent_response import AgentResponse from agents.agent_similarity import AgentSimilarity from agents.response_extraction ...
self.parent_id = None
STATEMENT
prefix_suffix_full_complete_current_block_no_evidence
<filename>microagents/integrations/memoize.py<fim_prefix>import sqlite3 import hashlib import json import functools ## Originally from https://www.kevinkatz.io/posts/memoize-to-sqlite def memoize_to_sqlite(func_name: str, filename: str = "cache.db"): """ Memoization decorator that caches the output of a metho...
self.connection = sqlite3.connect(self.filename)
STATEMENT
prefix_suffix_full_complete_current_block_no_evidence
<filename>microagents/agents/microagent.py<fim_prefix>import logging import uuid from integrations.openaiwrapper import OpenAIAPIWrapper from agents.agent_evaluation import AgentEvaluator from agents.agent_response import AgentResponse from agents.agent_similarity import AgentSimilarity from agents.response_extraction ...
self.depth = depth
STATEMENT
prefix_suffix_full_complete_current_block_no_evidence
<filename>microagents/agents/agent_lifecycle.py<fim_prefix>import logging from typing import List from agents.microagent import MicroAgent from integrations.openaiwrapper import OpenAIAPIWrapper from agents.agent_similarity import AgentSimilarity from agents.agent_persistence_manager import AgentPersistenceManager from...
try: return self.openai_wrapper.chat_completion(messages=messages)
TRY
prefix_suffix_full_complete_current_block_no_evidence
<filename>microagents/agents/agent_similarity.py<fim_prefix>import logging import numpy as np from typing import List, Tuple, Optional from sklearn.metrics.pairwise import cosine_similarity from integrations.openaiwrapper import OpenAIAPIWrapper logger = logging.getLogger() class Agent: def __init__(self, purpos...
try: for agent in self.agents: if agent.purpose_embedding is None: agent.purpose_embedding = self.get_embedding(agent.purpose) similarity = cosine_similarity([agent.purpose_embedding], [purpose_embedding])[0][0] if similarity > highest_sim...
TRY
prefix_suffix_full_complete_current_block_no_evidence
<filename>microagents/agents/agent_similarity.py<fim_prefix>import logging import numpy as np from typing import List, Tuple, Optional from sklearn.metrics.pairwise import cosine_similarity from integrations.openaiwrapper import OpenAIAPIWrapper logger = logging.getLogger() class Agent: def __init__(self, purpos...
try: response = self.openai_wrapper.get_embedding(text) if 'data' in response and len(response['data']) > 0 and 'embedding' in response['data'][0]: return np.array(response['data'][0]['embedding']) else: logger.exception("Invalid response format") ...
TRY
prefix_suffix_full_complete_current_block_no_evidence
<filename>microagents/agents/agent_lifecycle.py<fim_prefix>import logging from typing import List from agents.microagent import MicroAgent from integrations.openaiwrapper import OpenAIAPIWrapper from agents.agent_similarity import AgentSimilarity from agents.agent_persistence_manager import AgentPersistenceManager from...
try: self.agent_persistence.save_agent(agent)
TRY
prefix_suffix_full_complete_current_block_no_evidence
<filename>microagents/agents/agent_similarity.py<fim_prefix>import logging import numpy as np from typing import List, Tuple, Optional from sklearn.metrics.pairwise import cosine_similarity from integrations.openaiwrapper import OpenAIAPIWrapper logger = logging.getLogger() class Agent: def __init__(self, purpos...
except Exception as e: logger.exception(f"Error finding closest agent: {e}") raise ValueError(f"Error finding closest agent: {e}")
CATCH
prefix_suffix_full_complete_current_block_no_evidence
<filename>microagents/agents/agent_lifecycle.py<fim_prefix>import logging from typing import List from agents.microagent import MicroAgent from integrations.openaiwrapper import OpenAIAPIWrapper from agents.agent_similarity import AgentSimilarity from agents.agent_persistence_manager import AgentPersistenceManager from...
except Exception as e: logger.exception(f"Error generating LLM prompt: {e}") return ""
CATCH
prefix_suffix_full_complete_current_block_no_evidence
<filename>microagents/agents/agent_lifecycle.py<fim_prefix>import logging from typing import List from agents.microagent import MicroAgent from integrations.openaiwrapper import OpenAIAPIWrapper from agents.agent_similarity import AgentSimilarity from agents.agent_persistence_manager import AgentPersistenceManager from...
except Exception as e: logger.exception(f"Error in saving agent: {e}") raise
CATCH
prefix_suffix_full_complete_current_block_no_evidence
<filename>microagents/agents/agent_similarity.py<fim_prefix>import logging import numpy as np from typing import List, Tuple, Optional from sklearn.metrics.pairwise import cosine_similarity from integrations.openaiwrapper import OpenAIAPIWrapper logger = logging.getLogger() class Agent: def __init__(self, purpos...
except Exception as e: logger.exception(f"Error retrieving embedding: {e}") raise ValueError(f"Error retrieving embedding: {e}")
CATCH
prefix_suffix_full_complete_current_block_no_evidence
<filename>microagents/agents/agent_persistence_manager.py<fim_prefix>from agents.agent_serializer import AgentSerializer from integrations.memoize import memoize_to_sqlite from integrations.sqlite_agent_persistence import SQLiteAgentPersistence class AgentPersistenceManager: def __init__(self, db_filename="agents...
for purpose in purposes: agent = self.load_agent(purpose, agent_lifecycle, openai_wrapper) if agent: agents.append(agent)
FOR
prefix_suffix_full_complete_current_block_no_evidence
<filename>microagents/agents/agent_similarity.py<fim_prefix>import logging import numpy as np from typing import List, Tuple, Optional from sklearn.metrics.pairwise import cosine_similarity from integrations.openaiwrapper import OpenAIAPIWrapper logger = logging.getLogger() class Agent: def __init__(self, purpos...
for agent in self.agents: if agent.purpose_embedding is None: agent.purpose_embedding = self.get_embedding(agent.purpose) similarity = cosine_similarity([agent.purpose_embedding], [purpose_embedding])[0][0] if similarity > highest_similarity: ...
FOR
prefix_suffix_full_complete_current_block_no_evidence
<filename>microagents/agents/microagent.py<fim_prefix>import logging import uuid from integrations.openaiwrapper import OpenAIAPIWrapper from agents.agent_evaluation import AgentEvaluator from agents.agent_response import AgentResponse from agents.agent_similarity import AgentSimilarity from agents.response_extraction ...
if is_prime: self.id = "2a5e6fe9-1bb1-426c-9521-145caa2cf66b" else: if id: self.id = id else: self.id = str(uuid.uuid4())
IF
prefix_suffix_full_complete_current_block_no_evidence
<filename>microagents/agents/microagent.py<fim_prefix>import logging import uuid from integrations.openaiwrapper import OpenAIAPIWrapper from agents.agent_evaluation import AgentEvaluator from agents.agent_response import AgentResponse from agents.agent_similarity import AgentSimilarity from agents.response_extraction ...
if id: self.id = id else: self.id = str(uuid.uuid4())
IF
prefix_suffix_full_complete_current_block_no_evidence