inputs stringlengths 312 52k | targets stringlengths 1 3.1k ⌀ | block_type stringclasses 11
values | scenario stringclasses 7
values |
|---|---|---|---|
<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/... | 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 Ja... | IF | prefix_suffix_full_complete_current_block_with_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... | 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_samp... | IF | prefix_suffix_full_complete_current_block_with_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/... | not populating_data and results_queue.empty():
break | IF | prefix_suffix_full_complete_current_block_with_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/... | 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 ValueE... | IF | prefix_suffix_full_complete_current_block_with_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/... | not populating_data and results_queue.empty():
break | IF | prefix_suffix_full_complete_current_block_with_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... | 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_with_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/... | 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_with_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... | mat1 is None:
mat1 = mat0 | IF | prefix_suffix_full_complete_current_block_with_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... | 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 ve... | IF | prefix_suffix_full_complete_current_block_with_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... | = jnp.diff(acc_wq, axis=-1) | STATEMENT | prefix_suffix_full_complete_current_block_with_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... | /= np.sqrt(np.sum(new_verts**2, 1, keepdims=True)) | STATEMENT | prefix_suffix_full_complete_current_block_with_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... | t_new | STATEMENT | prefix_suffix_full_complete_current_block_with_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.... | = jnp.concatenate([jnp.zeros_like(y[Ellipsis, :1]), c1], axis=-1) | STATEMENT | prefix_suffix_full_complete_current_block_with_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_trig_helper(x, jnp.sin) | STATEMENT | prefix_suffix_full_complete_current_block_with_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 | STATEMENT | prefix_suffix_full_complete_current_block_with_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... | = [] | STATEMENT | prefix_suffix_full_complete_current_block_with_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.... | = sph_harms * jnp.exp(-sigma * kappa_inv) | STATEMENT | prefix_suffix_full_complete_current_block_with_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.... | = jnp.concatenate([z**i for i in range(mat.shape[0])], axis=-1) | STATEMENT | prefix_suffix_full_complete_current_block_with_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/... | = jnp.maximum(1, jnp.sum(z**2, axis=-1, keepdims=True)) | STATEMENT | prefix_suffix_full_complete_current_block_with_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_with_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_with_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_with_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_with_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_with_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_with_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_with_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_with_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_with_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_with_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... | 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_with_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.... | 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_with_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... | j in range(v + 1 - i):
int_weights.append((i, j, v - (i + j))) | FOR | prefix_suffix_full_complete_current_block_with_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/... | item in fn(*args, **kwargs):
results_queue.put(item) | FOR | prefix_suffix_full_complete_current_block_with_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.... | k in range(l - m + 1):
mat[k, i] = sph_harm_coeff(l, m, k) | FOR | prefix_suffix_full_complete_current_block_with_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... | 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_with_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/... | item in fn(*args, **kwargs):
results_queue.put(item) | FOR | prefix_suffix_full_complete_current_block_with_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... | 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_with_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.... | m in range(l + 1):
ml_list.append((m, l)) | FOR | prefix_suffix_full_complete_current_block_with_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/... | item in fn(*args, **kwargs):
results_queue.put(item) | FOR | prefix_suffix_full_complete_current_block_with_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/... | 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
n... | METHOD | prefix_suffix_full_complete_current_block_with_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/... | 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 = True` ... | METHOD | prefix_suffix_full_complete_current_block_with_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.... | 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_with_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.... | 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.
Retu... | METHOD | prefix_suffix_full_complete_current_block_with_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_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 populating_... | METHOD | prefix_suffix_full_complete_current_block_with_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(x):
"""fn() with clipped inputs."""
return fn(jnp.clip(x, *x_range)) | METHOD | prefix_suffix_full_complete_current_block_with_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_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 populating_... | METHOD | prefix_suffix_full_complete_current_block_with_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_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 populating_... | METHOD | prefix_suffix_full_complete_current_block_with_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_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_with_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/... | 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
n... | METHOD | prefix_suffix_full_complete_current_block_with_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) | TRY | prefix_suffix_full_complete_current_block_with_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/... |
# Set timeout to allow for exceptions to be propagated.
next_value = results_queue.get(timeout=1.0) | TRY | prefix_suffix_full_complete_current_block_with_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/... |
# Set timeout to allow for exceptions to be propagated.
next_value = results_queue.get(timeout=1.0) | TRY | prefix_suffix_full_complete_current_block_with_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) | TRY | prefix_suffix_full_complete_current_block_with_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/... |
# Set timeout to allow for exceptions to be propagated.
next_value = results_queue.get(timeout=1.0) | TRY | prefix_suffix_full_complete_current_block_with_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) | TRY | prefix_suffix_full_complete_current_block_with_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/... | 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 queu... | WHILE | prefix_suffix_full_complete_current_block_with_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/... | 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 queu... | WHILE | prefix_suffix_full_complete_current_block_with_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/... | 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 queu... | WHILE | prefix_suffix_full_complete_current_block_with_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/... | queue.Empty:
continue | CATCH | prefix_suffix_full_complete_current_block_with_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/... | queue.Empty:
continue | CATCH | prefix_suffix_full_complete_current_block_with_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/... | queue.Empty:
continue | CATCH | prefix_suffix_full_complete_current_block_with_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... | null | ANNOTATION | prefix_suffix_full_complete_current_block_with_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... | null | ANNOTATION | prefix_suffix_full_complete_current_block_with_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_with_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_with_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... | all agents with status stopped = True in an efficient manner.""" | BLOCK_COMMENT | prefix_suffix_full_complete_current_block_with_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_with_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.wra... |
Memoization decorator that caches the output of a method in a SQLite
database.
""" | BLOCK_COMMENT | prefix_suffix_full_complete_current_block_with_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... | the prime agent and adds it to the agent list.""" | BLOCK_COMMENT | prefix_suffix_full_complete_current_block_with_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... | the list of agents.""" | BLOCK_COMMENT | prefix_suffix_full_complete_current_block_with_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_with_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... | all agents with status stopped = True""" | BLOCK_COMMENT | prefix_suffix_full_complete_current_block_with_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_with_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 ... | = parent_id | STATEMENT | prefix_suffix_full_complete_current_block_with_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 ... | = str(uuid.uuid4()) | STATEMENT | prefix_suffix_full_complete_current_block_with_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._fetch_from_cache(arg_hash) | STATEMENT | prefix_suffix_full_complete_current_block_with_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 ... | = initial_prompt | STATEMENT | prefix_suffix_full_complete_current_block_with_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... | = conn.cursor() | STATEMENT | prefix_suffix_full_complete_current_block_with_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... | = cosine_similarity([agent.purpose_embedding], [purpose_embedding])[0][0] | STATEMENT | prefix_suffix_full_complete_current_block_with_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.cursor() | STATEMENT | prefix_suffix_full_complete_current_block_with_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 ... | = None | STATEMENT | prefix_suffix_full_complete_current_block_with_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... | = sqlite3.connect(self.filename) | STATEMENT | prefix_suffix_full_complete_current_block_with_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 ... | = depth | STATEMENT | prefix_suffix_full_complete_current_block_with_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... |
return self.openai_wrapper.chat_completion(messages=messages) | TRY | prefix_suffix_full_complete_current_block_with_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_similar... | TRY | prefix_suffix_full_complete_current_block_with_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... |
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_with_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... |
self.agent_persistence.save_agent(agent) | TRY | prefix_suffix_full_complete_current_block_with_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... | 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_with_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... | Exception as e:
logger.exception(f"Error generating LLM prompt: {e}")
return "" | CATCH | prefix_suffix_full_complete_current_block_with_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... | Exception as e:
logger.exception(f"Error in saving agent: {e}")
raise | CATCH | prefix_suffix_full_complete_current_block_with_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... | Exception as e:
logger.exception(f"Error retrieving embedding: {e}")
raise ValueError(f"Error retrieving embedding: {e}") | CATCH | prefix_suffix_full_complete_current_block_with_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... | purpose in purposes:
agent = self.load_agent(purpose, agent_lifecycle, openai_wrapper)
if agent:
agents.append(agent) | FOR | prefix_suffix_full_complete_current_block_with_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... | 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_with_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 ... | 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_with_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 ... | id:
self.id = id
else:
self.id = str(uuid.uuid4()) | IF | prefix_suffix_full_complete_current_block_with_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 > highest_similarity:
highest_similarity = similarity
closest_agent = agent | IF | prefix_suffix_full_complete_current_block_with_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... | agent.purpose_embedding is None:
agent.purpose_embedding = self.get_embedding(agent.purpose) | IF | prefix_suffix_full_complete_current_block_with_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... | '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")
raise ValueError("Invalid response format") | IF | prefix_suffix_full_complete_current_block_with_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 is not None:
return result | IF | prefix_suffix_full_complete_current_block_with_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... | agent:
agents.append(agent) | IF | prefix_suffix_full_complete_current_block_with_evidence |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.