prompt
stringlengths
859
2.51M
target_function_prompt
stringlengths
8
20.9k
target
stringlengths
28
531k
dependency_context
stringlengths
49
2.51M
target_function_name
stringlengths
1
105
target_source
stringlengths
5
159
import_statements
listlengths
0
224
example
stringlengths
0
300k
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def create_quad_func(a,b,c): '''return function f(x) = ax^2 + bx + c'''
def create_quad_func(a,b,c): '''return function f(x) = ax^2 + bx + c''' return lambda x: a*x**2 + b*x + c
{ "courses/python_scrimba/27Lambda/lambda.py": { "import_statements": [], "classes": [ { "name": "Player", "file_path": "courses/python_scrimba/27Lambda/lambda.py", "description": "DOCSTRING", "base_classes": [], "methods": [ { "name": "Playe...
create_quad_func
courses/python_scrimba/27Lambda/lambda.py
[]
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def extract_feature(df, train, flag): # # speed split # date_nunique = df.groupby(['ship'])['speed_cat'].nunique().to_dict() # train['speed_cat_nunique'] = train['ship'].map(date_nunique) ''' 统计feature '''
def extract_feature(df, train, flag): # # speed split # date_nunique = df.groupby(['ship'])['speed_cat'].nunique().to_dict() # train['speed_cat_nunique'] = train['ship'].map(date_nunique) ''' 统计feature ''' if (flag == 'on_night') or (flag == 'on_day'): t = group_feature(df, 'sh...
{ "feature_selector/feature_selector.py": { "import_statements": [ "from itertools import chain", "from sklearn.model_selection import train_test_split", "import gc", "import lightgbm", "import matplotlib.pyplot", "import numpy", "import pandas", "import seaborn" ...
extract_feature
model.py
[ "from feature_selector import FeatureSelector", "from copy import deepcopy", "from glob import glob", "from scipy.sparse import csr_matrix", "from sklearn import metrics", "from sklearn.metrics import f1_score", "from sklearn.metrics import precision_recall_fscore_support", "from sklearn.model_selecti...
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def quaternion_conjugate(quaternion): """Return conjugate of quaternion. >>> q0 = random_quaternion() >>> q1 = quaternion_conjugate(q0) >>> q1[0] == q0[0] and all(q1[1:] == -q0[1:]) True """
def quaternion_conjugate(quaternion): """Return conjugate of quaternion. >>> q0 = random_quaternion() >>> q1 = quaternion_conjugate(q0) >>> q1[0] == q0[0] and all(q1[1:] == -q0[1:]) True """ q = numpy.array(quaternion, dtype=numpy.float64, copy=True) numpy.negative(q[1:], q[1:]) re...
{ "transformations.py": { "import_statements": [ "from __future__ import division", "from __future__ import print_function", "import math", "import numpy" ] } }
quaternion_conjugate
transformations.py
[ "from __future__ import division", "from __future__ import print_function", "import math", "import numpy" ]
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def translation_matrix(direction): """Return matrix to translate by direction vector. >>> v = numpy.random.random(3) - 0.5 >>> numpy.allclose(v, translation_matrix(v)[:3, 3]) True """
def translation_matrix(direction): """Return matrix to translate by direction vector. >>> v = numpy.random.random(3) - 0.5 >>> numpy.allclose(v, translation_matrix(v)[:3, 3]) True """ M = numpy.identity(4) M[:3, 3] = direction[:3] return M
{ "transformations.py": { "import_statements": [ "from __future__ import division", "from __future__ import print_function", "import math", "import numpy" ], "classes": [], "variable": [ "_EPS = numpy.finfo(float).eps * 4.0" ], "functions": [] } }
translation_matrix
transformations.py
[ "from __future__ import division", "from __future__ import print_function", "import math", "import numpy" ]
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def random_vector(size): """Return array of random doubles in the half-open interval [0.0, 1.0). >>> v = random_vector(10000) >>> numpy.all(v >= 0) and numpy.all(v < 1) True >>> v0 = random_vector(10) >>> v1 = random_vector(10) >>> numpy.any(v0 == v1) False """
def random_vector(size): """Return array of random doubles in the half-open interval [0.0, 1.0). >>> v = random_vector(10000) >>> numpy.all(v >= 0) and numpy.all(v < 1) True >>> v0 = random_vector(10) >>> v1 = random_vector(10) >>> numpy.any(v0 == v1) False """ return numpy.ran...
{ "transformations.py": { "import_statements": [ "from __future__ import division", "from __future__ import print_function", "import math", "import numpy" ], "classes": [], "variable": [ "_EPS = numpy.finfo(float).eps * 4.0" ], "functions": [] } }
random_vector
transformations.py
[ "from __future__ import division", "from __future__ import print_function", "import math", "import numpy" ]
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def unit_vector(data, axis=None, out=None): """Return ndarray normalized by length, i.e. Euclidean norm, along axis. >>> v0 = numpy.random.random(3) >>> v1 = unit_vector(v0) >>> numpy.allclose(v1, v0 / numpy.linalg.norm(v0)) True >>> v0 = numpy.random.rand(5, 4, 3) >>> v1 = unit_vector(v0, ...
def unit_vector(data, axis=None, out=None): """Return ndarray normalized by length, i.e. Euclidean norm, along axis. >>> v0 = numpy.random.random(3) >>> v1 = unit_vector(v0) >>> numpy.allclose(v1, v0 / numpy.linalg.norm(v0)) True >>> v0 = numpy.random.rand(5, 4, 3) >>> v1 = unit_vector(v0, ...
{ "transformations.py": { "import_statements": [ "from __future__ import division", "from __future__ import print_function", "import math", "import numpy" ], "classes": [ { "name": "Arcball", "file_path": "transformations.py", "description": "Virtual T...
unit_vector
transformations.py
[ "from __future__ import division", "from __future__ import print_function", "import math", "import numpy" ]
def euler_from_quaternion(quaternion, axes='sxyz'): """Return Euler angles from quaternion for specified axis sequence. >>> angles = euler_from_quaternion([0.99810947, 0.06146124, 0, 0]) >>> numpy.allclose(angles, [0.123, 0, 0]) True """ return euler_from_matrix(quaternion_matrix(quaternion), ...
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def quaternion_imag(quaternion): """Return imaginary part of quaternion. >>> quaternion_imag([3, 0, 1, 2]) array([ 0., 1., 2.]) """
def quaternion_imag(quaternion): """Return imaginary part of quaternion. >>> quaternion_imag([3, 0, 1, 2]) array([ 0., 1., 2.]) """ return numpy.array(quaternion[1:4], dtype=numpy.float64, copy=True)
{ "transformations.py": { "import_statements": [ "from __future__ import division", "from __future__ import print_function", "import math", "import numpy" ] } }
quaternion_imag
transformations.py
[ "from __future__ import division", "from __future__ import print_function", "import math", "import numpy" ]
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def arcball_map_to_sphere(point, center, radius): """Return unit sphere coordinates from window coordinates."""
def arcball_map_to_sphere(point, center, radius): """Return unit sphere coordinates from window coordinates.""" v0 = (point[0] - center[0]) / radius v1 = (center[1] - point[1]) / radius n = v0*v0 + v1*v1 if n > 1.0: # position outside of sphere n = math.sqrt(n) return numpy.a...
{ "transformations.py": { "import_statements": [ "from __future__ import division", "from __future__ import print_function", "import math", "import numpy" ], "classes": [ { "name": "Arcball", "file_path": "transformations.py", "description": "Virtual T...
arcball_map_to_sphere
transformations.py
[ "from __future__ import division", "from __future__ import print_function", "import math", "import numpy" ]
def arcball_nearest_axis(point, axes): """Return axis, which arc is nearest to point.""" point = numpy.array(point, dtype=numpy.float64, copy=False) nearest = None mx = -1.0 for axis in axes: t = numpy.dot(arcball_constrain_to_axis(point, axis), point) if t > mx: nearest ...
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def is_same_transform(matrix0, matrix1): """Return True if two matrices perform same transformation. >>> is_same_transform(numpy.identity(4), numpy.identity(4)) True >>> is_same_transform(numpy.identity(4), random_rotation_matrix()) False """
def is_same_transform(matrix0, matrix1): """Return True if two matrices perform same transformation. >>> is_same_transform(numpy.identity(4), numpy.identity(4)) True >>> is_same_transform(numpy.identity(4), random_rotation_matrix()) False """ matrix0 = numpy.array(matrix0, dtype=numpy.floa...
{ "transformations.py": { "import_statements": [ "from __future__ import division", "from __future__ import print_function", "import math", "import numpy" ], "classes": [], "variable": [], "functions": [ { "name": "rotation_matrix", "file_path": "trans...
is_same_transform
transformations.py
[ "from __future__ import division", "from __future__ import print_function", "import math", "import numpy" ]
def dataTransform(x1_b, Rs_b, ts_b, epoch, aug_cl = False): angle = computeAngle(epoch) x1 = x1_b R = Rs_b t = ts_b x1_b = [] Rs_b = [] ts_b = [] step = epoch for i in range(len(x1)): x1_b1 = [] R_b1 = [] t_b1 = [] if not aug_cl: ang...
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def vector_norm(data, axis=None, out=None): """Return length, i.e. Euclidean norm, of ndarray along axis. >>> v = numpy.random.random(3) >>> n = vector_norm(v) >>> numpy.allclose(n, numpy.linalg.norm(v)) True >>> v = numpy.random.rand(6, 5, 3) >>> n = vector_norm(v, axis=-1) >>> numpy.a...
def vector_norm(data, axis=None, out=None): """Return length, i.e. Euclidean norm, of ndarray along axis. >>> v = numpy.random.random(3) >>> n = vector_norm(v) >>> numpy.allclose(n, numpy.linalg.norm(v)) True >>> v = numpy.random.rand(6, 5, 3) >>> n = vector_norm(v, axis=-1) >>> numpy.a...
{ "transformations.py": { "import_statements": [ "from __future__ import division", "from __future__ import print_function", "import math", "import numpy" ], "classes": [ { "name": "Arcball", "file_path": "transformations.py", "description": "Virtual T...
vector_norm
transformations.py
[ "from __future__ import division", "from __future__ import print_function", "import math", "import numpy" ]
def euler_from_quaternion(quaternion, axes='sxyz'): """Return Euler angles from quaternion for specified axis sequence. >>> angles = euler_from_quaternion([0.99810947, 0.06146124, 0, 0]) >>> numpy.allclose(angles, [0.123, 0, 0]) True """ return euler_from_matrix(quaternion_matrix(quaternion), ...
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def translation_from_matrix(matrix): """Return translation vector from translation matrix. >>> v0 = numpy.random.random(3) - 0.5 >>> v1 = translation_from_matrix(translation_matrix(v0)) >>> numpy.allclose(v0, v1) True """
def translation_from_matrix(matrix): """Return translation vector from translation matrix. >>> v0 = numpy.random.random(3) - 0.5 >>> v1 = translation_from_matrix(translation_matrix(v0)) >>> numpy.allclose(v0, v1) True """ return numpy.array(matrix, copy=False)[:3, 3].copy()
{ "transformations.py": { "import_statements": [ "from __future__ import division", "from __future__ import print_function", "import math", "import numpy" ], "classes": [], "variable": [ "_EPS = numpy.finfo(float).eps * 4.0" ], "functions": [ { "name...
translation_from_matrix
transformations.py
[ "from __future__ import division", "from __future__ import print_function", "import math", "import numpy" ]
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def concatenate_matrices(*matrices): """Return concatenation of series of transformation matrices. >>> M = numpy.random.rand(16).reshape((4, 4)) - 0.5 >>> numpy.allclose(M, concatenate_matrices(M)) True >>> numpy.allclose(numpy.dot(M, M.T), concatenate_matrices(M, M.T)) True """
def concatenate_matrices(*matrices): """Return concatenation of series of transformation matrices. >>> M = numpy.random.rand(16).reshape((4, 4)) - 0.5 >>> numpy.allclose(M, concatenate_matrices(M)) True >>> numpy.allclose(numpy.dot(M, M.T), concatenate_matrices(M, M.T)) True """ M = nu...
{ "transformations.py": { "import_statements": [ "from __future__ import division", "from __future__ import print_function", "import math", "import numpy" ], "classes": [], "variable": [ "_EPS = numpy.finfo(float).eps * 4.0" ], "functions": [] } }
concatenate_matrices
transformations.py
[ "from __future__ import division", "from __future__ import print_function", "import math", "import numpy" ]
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def quaternion_from_matrix(matrix, isprecise=False): """Return quaternion from rotation matrix. If isprecise is True, the input matrix is assumed to be a precise rotation matrix and a faster algorithm is used. >>> q = quaternion_from_matrix(numpy.identity(4), True) >>> numpy.allclose(q, [1, 0, 0, ...
def quaternion_from_matrix(matrix, isprecise=False): """Return quaternion from rotation matrix. If isprecise is True, the input matrix is assumed to be a precise rotation matrix and a faster algorithm is used. >>> q = quaternion_from_matrix(numpy.identity(4), True) >>> numpy.allclose(q, [1, 0, 0, ...
{ "transformations.py": { "import_statements": [ "from __future__ import division", "from __future__ import print_function", "import math", "import numpy" ] } }
quaternion_from_matrix
transformations.py
[ "from __future__ import division", "from __future__ import print_function", "import math", "import numpy" ]
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def random_quaternion(rand=None): """Return uniform random unit quaternion. rand: array like or None Three independent random variables that are uniformly distributed between 0 and 1. >>> q = random_quaternion() >>> numpy.allclose(1, vector_norm(q)) True >>> q = random_quaterni...
def random_quaternion(rand=None): """Return uniform random unit quaternion. rand: array like or None Three independent random variables that are uniformly distributed between 0 and 1. >>> q = random_quaternion() >>> numpy.allclose(1, vector_norm(q)) True >>> q = random_quaterni...
{ "transformations.py": { "import_statements": [ "from __future__ import division", "from __future__ import print_function", "import math", "import numpy" ], "classes": [], "variable": [ "_EPS = numpy.finfo(float).eps * 4.0" ], "functions": [ { "name...
random_quaternion
transformations.py
[ "from __future__ import division", "from __future__ import print_function", "import math", "import numpy" ]
def arcball_constrain_to_axis(point, axis): """Return sphere point perpendicular to axis.""" v = numpy.array(point, dtype=numpy.float64, copy=True) a = numpy.array(axis, dtype=numpy.float64, copy=True) v -= a * numpy.dot(a, v) # on plane n = vector_norm(v) if n > _EPS: if v[2] < 0.0: ...
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def orthogonalization_matrix(lengths, angles): """Return orthogonalization matrix for crystallographic cell coordinates. Angles are expected in degrees. The de-orthogonalization matrix is the inverse. >>> O = orthogonalization_matrix([10, 10, 10], [90, 90, 90]) >>> numpy.allclose(O[:3, :3], numpy...
def orthogonalization_matrix(lengths, angles): """Return orthogonalization matrix for crystallographic cell coordinates. Angles are expected in degrees. The de-orthogonalization matrix is the inverse. >>> O = orthogonalization_matrix([10, 10, 10], [90, 90, 90]) >>> numpy.allclose(O[:3, :3], numpy...
{ "transformations.py": { "import_statements": [ "from __future__ import division", "from __future__ import print_function", "import math", "import numpy" ], "classes": [], "variable": [], "functions": [ { "name": "rotation_matrix", "file_path": "trans...
orthogonalization_matrix
transformations.py
[ "from __future__ import division", "from __future__ import print_function", "import math", "import numpy" ]
def dataTransform(x1_b, Rs_b, ts_b, epoch, aug_cl = False): angle = computeAngle(epoch) x1 = x1_b R = Rs_b t = ts_b x1_b = [] Rs_b = [] ts_b = [] step = epoch for i in range(len(x1)): x1_b1 = [] R_b1 = [] t_b1 = [] if not aug_cl: ang...
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def quaternion_multiply(quaternion1, quaternion0): """Return multiplication of two quaternions. >>> q = quaternion_multiply([4, 1, -2, 3], [8, -5, 6, 7]) >>> numpy.allclose(q, [28, -44, -14, 48]) True """
def quaternion_multiply(quaternion1, quaternion0): """Return multiplication of two quaternions. >>> q = quaternion_multiply([4, 1, -2, 3], [8, -5, 6, 7]) >>> numpy.allclose(q, [28, -44, -14, 48]) True """ w0, x0, y0, z0 = quaternion0 w1, x1, y1, z1 = quaternion1 return numpy.array([-x1...
{ "transformations.py": { "import_statements": [ "from __future__ import division", "from __future__ import print_function", "import math", "import numpy" ] } }
quaternion_multiply
transformations.py
[ "from __future__ import division", "from __future__ import print_function", "import math", "import numpy" ]
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def identity_matrix(): """Return 4x4 identity/unit matrix. >>> I = identity_matrix() >>> numpy.allclose(I, numpy.dot(I, I)) True >>> numpy.sum(I), numpy.trace(I) (4.0, 4.0) >>> numpy.allclose(I, numpy.identity(4)) True """
def identity_matrix(): """Return 4x4 identity/unit matrix. >>> I = identity_matrix() >>> numpy.allclose(I, numpy.dot(I, I)) True >>> numpy.sum(I), numpy.trace(I) (4.0, 4.0) >>> numpy.allclose(I, numpy.identity(4)) True """ return numpy.identity(4)
{ "transformations.py": { "import_statements": [ "from __future__ import division", "from __future__ import print_function", "import math", "import numpy" ] } }
identity_matrix
transformations.py
[ "from __future__ import division", "from __future__ import print_function", "import math", "import numpy" ]
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def _import_module(name, package=None, warn=True, prefix='_py_', ignore='_'): """Try import all public attributes from module into global namespace. Existing attributes with name clashes are renamed with prefix. Attributes starting with underscore are ignored by default. Return True on successful impo...
def _import_module(name, package=None, warn=True, prefix='_py_', ignore='_'): """Try import all public attributes from module into global namespace. Existing attributes with name clashes are renamed with prefix. Attributes starting with underscore are ignored by default. Return True on successful impo...
{ "transformations.py": { "import_statements": [ "from __future__ import division", "from __future__ import print_function", "import math", "import numpy" ], "classes": [], "variable": [ "_EPS = numpy.finfo(float).eps * 4.0", "__version__ = \"2015.07.18\"" ], ...
_import_module
transformations.py
[ "from __future__ import division", "from __future__ import print_function", "import math", "import numpy" ]
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def rotation_from_matrix(matrix): """Return rotation angle and axis from rotation matrix. >>> angle = (random.random() - 0.5) * (2*math.pi) >>> direc = numpy.random.random(3) - 0.5 >>> point = numpy.random.random(3) - 0.5 >>> R0 = rotation_matrix(angle, direc, point) >>> angle, direc, point = r...
def rotation_from_matrix(matrix): """Return rotation angle and axis from rotation matrix. >>> angle = (random.random() - 0.5) * (2*math.pi) >>> direc = numpy.random.random(3) - 0.5 >>> point = numpy.random.random(3) - 0.5 >>> R0 = rotation_matrix(angle, direc, point) >>> angle, direc, point = r...
{ "transformations.py": { "import_statements": [ "from __future__ import division", "from __future__ import print_function", "import math", "import numpy" ], "classes": [], "variable": [ "_EPS = numpy.finfo(float).eps * 4.0", "_NEXT_AXIS = [1, 2, 0, 1]", "_TUP...
rotation_from_matrix
transformations.py
[ "from __future__ import division", "from __future__ import print_function", "import math", "import numpy" ]
def dataTransform(x1_b, Rs_b, ts_b, epoch, aug_cl = False): angle = computeAngle(epoch) x1 = x1_b R = Rs_b t = ts_b x1_b = [] Rs_b = [] ts_b = [] step = epoch for i in range(len(x1)): x1_b1 = [] R_b1 = [] t_b1 = [] if not aug_cl: ang...
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def reflection_from_matrix(matrix): """Return mirror plane point and normal vector from reflection matrix. >>> v0 = numpy.random.random(3) - 0.5 >>> v1 = numpy.random.random(3) - 0.5 >>> M0 = reflection_matrix(v0, v1) >>> point, normal = reflection_from_matrix(M0) >>> M1 = reflection_matrix(poi...
def reflection_from_matrix(matrix): """Return mirror plane point and normal vector from reflection matrix. >>> v0 = numpy.random.random(3) - 0.5 >>> v1 = numpy.random.random(3) - 0.5 >>> M0 = reflection_matrix(v0, v1) >>> point, normal = reflection_from_matrix(M0) >>> M1 = reflection_matrix(poi...
{ "transformations.py": { "import_statements": [ "from __future__ import division", "from __future__ import print_function", "import math", "import numpy" ] } }
reflection_from_matrix
transformations.py
[ "from __future__ import division", "from __future__ import print_function", "import math", "import numpy" ]
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def quaternion_inverse(quaternion): """Return inverse of quaternion. >>> q0 = random_quaternion() >>> q1 = quaternion_inverse(q0) >>> numpy.allclose(quaternion_multiply(q0, q1), [1, 0, 0, 0]) True """
def quaternion_inverse(quaternion): """Return inverse of quaternion. >>> q0 = random_quaternion() >>> q1 = quaternion_inverse(q0) >>> numpy.allclose(quaternion_multiply(q0, q1), [1, 0, 0, 0]) True """ q = numpy.array(quaternion, dtype=numpy.float64, copy=True) numpy.negative(q[1:], q[1...
{ "transformations.py": { "import_statements": [ "from __future__ import division", "from __future__ import print_function", "import math", "import numpy" ] } }
quaternion_inverse
transformations.py
[ "from __future__ import division", "from __future__ import print_function", "import math", "import numpy" ]
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def vector_product(v0, v1, axis=0): """Return vector perpendicular to vectors. >>> v = vector_product([2, 0, 0], [0, 3, 0]) >>> numpy.allclose(v, [0, 0, 6]) True >>> v0 = [[2, 0, 0, 2], [0, 2, 0, 2], [0, 0, 2, 2]] >>> v1 = [[3], [0], [0]] >>> v = vector_product(v0, v1) >>> numpy.allclos...
def vector_product(v0, v1, axis=0): """Return vector perpendicular to vectors. >>> v = vector_product([2, 0, 0], [0, 3, 0]) >>> numpy.allclose(v, [0, 0, 6]) True >>> v0 = [[2, 0, 0, 2], [0, 2, 0, 2], [0, 0, 2, 2]] >>> v1 = [[3], [0], [0]] >>> v = vector_product(v0, v1) >>> numpy.allclos...
{ "transformations.py": { "import_statements": [ "from __future__ import division", "from __future__ import print_function", "import math", "import numpy" ], "classes": [ { "name": "Arcball", "file_path": "transformations.py", "description": "Virtual T...
vector_product
transformations.py
[ "from __future__ import division", "from __future__ import print_function", "import math", "import numpy" ]
def euler_from_quaternion(quaternion, axes='sxyz'): """Return Euler angles from quaternion for specified axis sequence. >>> angles = euler_from_quaternion([0.99810947, 0.06146124, 0, 0]) >>> numpy.allclose(angles, [0.123, 0, 0]) True """ return euler_from_matrix(quaternion_matrix(quaternion), ...
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def reflection_matrix(point, normal): """Return matrix to mirror at plane defined by point and normal vector. >>> v0 = numpy.random.random(4) - 0.5 >>> v0[3] = 1. >>> v1 = numpy.random.random(3) - 0.5 >>> R = reflection_matrix(v0, v1) >>> numpy.allclose(2, numpy.trace(R)) True >>> numpy...
def reflection_matrix(point, normal): """Return matrix to mirror at plane defined by point and normal vector. >>> v0 = numpy.random.random(4) - 0.5 >>> v0[3] = 1. >>> v1 = numpy.random.random(3) - 0.5 >>> R = reflection_matrix(v0, v1) >>> numpy.allclose(2, numpy.trace(R)) True >>> numpy...
{ "transformations.py": { "import_statements": [ "from __future__ import division", "from __future__ import print_function", "import math", "import numpy" ] } }
reflection_matrix
transformations.py
[ "from __future__ import division", "from __future__ import print_function", "import math", "import numpy" ]
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def rotation_matrix(angle, direction, point=None): """Return matrix to rotate about axis defined by point and direction. >>> R = rotation_matrix(math.pi/2, [0, 0, 1], [1, 0, 0]) >>> numpy.allclose(numpy.dot(R, [0, 0, 0, 1]), [1, -1, 0, 1]) True >>> angle = (random.random() - 0.5) * (2*math.pi) ...
def rotation_matrix(angle, direction, point=None): """Return matrix to rotate about axis defined by point and direction. >>> R = rotation_matrix(math.pi/2, [0, 0, 1], [1, 0, 0]) >>> numpy.allclose(numpy.dot(R, [0, 0, 0, 1]), [1, -1, 0, 1]) True >>> angle = (random.random() - 0.5) * (2*math.pi) ...
{ "transformations.py": { "import_statements": [ "from __future__ import division", "from __future__ import print_function", "import math", "import numpy" ] } }
rotation_matrix
transformations.py
[ "from __future__ import division", "from __future__ import print_function", "import math", "import numpy" ]
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def scale_matrix(factor, origin=None, direction=None): """Return matrix to scale by factor around origin in direction. Use factor -1 for point symmetry. >>> v = (numpy.random.rand(4, 5) - 0.5) * 20 >>> v[3] = 1 >>> S = scale_matrix(-1.234) >>> numpy.allclose(numpy.dot(S, v)[:3], -1.234*v[:3]) ...
def scale_matrix(factor, origin=None, direction=None): """Return matrix to scale by factor around origin in direction. Use factor -1 for point symmetry. >>> v = (numpy.random.rand(4, 5) - 0.5) * 20 >>> v[3] = 1 >>> S = scale_matrix(-1.234) >>> numpy.allclose(numpy.dot(S, v)[:3], -1.234*v[:3]) ...
{ "transformations.py": { "import_statements": [ "from __future__ import division", "from __future__ import print_function", "import math", "import numpy" ], "classes": [], "variable": [ "_EPS = numpy.finfo(float).eps * 4.0" ], "functions": [] } }
scale_matrix
transformations.py
[ "from __future__ import division", "from __future__ import print_function", "import math", "import numpy" ]
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def scale_from_matrix(matrix): """Return scaling factor, origin and direction from scaling matrix. >>> factor = random.random() * 10 - 5 >>> origin = numpy.random.random(3) - 0.5 >>> direct = numpy.random.random(3) - 0.5 >>> S0 = scale_matrix(factor, origin) >>> factor, origin, direction = scal...
def scale_from_matrix(matrix): """Return scaling factor, origin and direction from scaling matrix. >>> factor = random.random() * 10 - 5 >>> origin = numpy.random.random(3) - 0.5 >>> direct = numpy.random.random(3) - 0.5 >>> S0 = scale_matrix(factor, origin) >>> factor, origin, direction = scal...
{ "transformations.py": { "import_statements": [ "from __future__ import division", "from __future__ import print_function", "import math", "import numpy" ], "classes": [], "variable": [ "_EPS = numpy.finfo(float).eps * 4.0" ], "functions": [ { "name...
scale_from_matrix
transformations.py
[ "from __future__ import division", "from __future__ import print_function", "import math", "import numpy" ]
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def projection_matrix(point, normal, direction=None, perspective=None, pseudo=False): """Return matrix to project onto plane defined by point and normal. Using either perspective point, projection direction, or none of both. If pseudo is True, perspective projections will preserve re...
def projection_matrix(point, normal, direction=None, perspective=None, pseudo=False): """Return matrix to project onto plane defined by point and normal. Using either perspective point, projection direction, or none of both. If pseudo is True, perspective projections will preserve re...
{ "transformations.py": { "import_statements": [ "from __future__ import division", "from __future__ import print_function", "import math", "import numpy" ], "classes": [ { "name": "Arcball", "file_path": "transformations.py", "description": "Virtual T...
projection_matrix
transformations.py
[ "from __future__ import division", "from __future__ import print_function", "import math", "import numpy" ]
def euler_from_quaternion(quaternion, axes='sxyz'): """Return Euler angles from quaternion for specified axis sequence. >>> angles = euler_from_quaternion([0.99810947, 0.06146124, 0, 0]) >>> numpy.allclose(angles, [0.123, 0, 0]) True """ return euler_from_matrix(quaternion_matrix(quaternion), ...
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def projection_from_matrix(matrix, pseudo=False): """Return projection plane and perspective point from projection matrix. Return values are same as arguments for projection_matrix function: point, normal, direction, perspective, and pseudo. >>> point = numpy.random.random(3) - 0.5 >>> normal = nu...
def projection_from_matrix(matrix, pseudo=False): """Return projection plane and perspective point from projection matrix. Return values are same as arguments for projection_matrix function: point, normal, direction, perspective, and pseudo. >>> point = numpy.random.random(3) - 0.5 >>> normal = nu...
{ "transformations.py": { "import_statements": [ "from __future__ import division", "from __future__ import print_function", "import math", "import numpy" ], "classes": [ { "name": "Arcball", "file_path": "transformations.py", "description": "Virtual T...
projection_from_matrix
transformations.py
[ "from __future__ import division", "from __future__ import print_function", "import math", "import numpy" ]
def affine_matrix_from_points(v0, v1, shear=True, scale=True, usesvd=True): """Return affine transform matrix to register two point sets. v0 and v1 are shape (ndims, \*) arrays of at least ndims non-homogeneous coordinates, where ndims is the dimensionality of the coordinate space. If shear is False, ...
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def clip_matrix(left, right, bottom, top, near, far, perspective=False): """Return matrix to obtain normalized device coordinates from frustum. The frustum bounds are axis-aligned along x (left, right), y (bottom, top) and z (near, far). Normalized device coordinates are in range [-1, 1] if coordinate...
def clip_matrix(left, right, bottom, top, near, far, perspective=False): """Return matrix to obtain normalized device coordinates from frustum. The frustum bounds are axis-aligned along x (left, right), y (bottom, top) and z (near, far). Normalized device coordinates are in range [-1, 1] if coordinate...
{ "transformations.py": { "import_statements": [ "from __future__ import division", "from __future__ import print_function", "import math", "import numpy" ] } }
clip_matrix
transformations.py
[ "from __future__ import division", "from __future__ import print_function", "import math", "import numpy" ]
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def shear_matrix(angle, direction, point, normal): """Return matrix to shear by angle along direction vector on shear plane. The shear plane is defined by a point and normal vector. The direction vector must be orthogonal to the plane's normal vector. A point P is transformed by the shear matrix into ...
def shear_matrix(angle, direction, point, normal): """Return matrix to shear by angle along direction vector on shear plane. The shear plane is defined by a point and normal vector. The direction vector must be orthogonal to the plane's normal vector. A point P is transformed by the shear matrix into ...
{ "transformations.py": { "import_statements": [ "from __future__ import division", "from __future__ import print_function", "import math", "import numpy" ] } }
shear_matrix
transformations.py
[ "from __future__ import division", "from __future__ import print_function", "import math", "import numpy" ]
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def shear_from_matrix(matrix): """Return shear angle, direction and plane from shear matrix. >>> angle = (random.random() - 0.5) * 4*math.pi >>> direct = numpy.random.random(3) - 0.5 >>> point = numpy.random.random(3) - 0.5 >>> normal = numpy.cross(direct, numpy.random.random(3)) >>> S0 = shear...
def shear_from_matrix(matrix): """Return shear angle, direction and plane from shear matrix. >>> angle = (random.random() - 0.5) * 4*math.pi >>> direct = numpy.random.random(3) - 0.5 >>> point = numpy.random.random(3) - 0.5 >>> normal = numpy.cross(direct, numpy.random.random(3)) >>> S0 = shear...
{ "transformations.py": { "import_statements": [ "from __future__ import division", "from __future__ import print_function", "import math", "import numpy" ] } }
shear_from_matrix
transformations.py
[ "from __future__ import division", "from __future__ import print_function", "import math", "import numpy" ]
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def compose_matrix(scale=None, shear=None, angles=None, translate=None, perspective=None): """Return transformation matrix from sequence of transformations. This is the inverse of the decompose_matrix function. Sequence of transformations: scale : vector of 3 scaling factors ...
def compose_matrix(scale=None, shear=None, angles=None, translate=None, perspective=None): """Return transformation matrix from sequence of transformations. This is the inverse of the decompose_matrix function. Sequence of transformations: scale : vector of 3 scaling factors ...
{ "transformations.py": { "import_statements": [ "from __future__ import division", "from __future__ import print_function", "import math", "import numpy" ], "classes": [ { "name": "Arcball", "file_path": "transformations.py", "description": "Virtual T...
compose_matrix
transformations.py
[ "from __future__ import division", "from __future__ import print_function", "import math", "import numpy" ]
def euler_from_quaternion(quaternion, axes='sxyz'): """Return Euler angles from quaternion for specified axis sequence. >>> angles = euler_from_quaternion([0.99810947, 0.06146124, 0, 0]) >>> numpy.allclose(angles, [0.123, 0, 0]) True """ return euler_from_matrix(quaternion_matrix(quaternion), ...
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def superimposition_matrix(v0, v1, scale=False, usesvd=True): """Return matrix to transform given 3D point set into second point set. v0 and v1 are shape (3, \*) or (4, \*) arrays of at least 3 points. The parameters scale and usesvd are explained in the more general affine_matrix_from_points function...
def superimposition_matrix(v0, v1, scale=False, usesvd=True): """Return matrix to transform given 3D point set into second point set. v0 and v1 are shape (3, \*) or (4, \*) arrays of at least 3 points. The parameters scale and usesvd are explained in the more general affine_matrix_from_points function...
{ "transformations.py": { "import_statements": [ "from __future__ import division", "from __future__ import print_function", "import math", "import numpy" ] } }
superimposition_matrix
transformations.py
[ "from __future__ import division", "from __future__ import print_function", "import math", "import numpy" ]
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def quaternion_matrix(quaternion): """Return homogeneous rotation matrix from quaternion. >>> M = quaternion_matrix([0.99810947, 0.06146124, 0, 0]) >>> numpy.allclose(M, rotation_matrix(0.123, [1, 0, 0])) True >>> M = quaternion_matrix([1, 0, 0, 0]) >>> numpy.allclose(M, numpy.identity(4)) ...
def quaternion_matrix(quaternion): """Return homogeneous rotation matrix from quaternion. >>> M = quaternion_matrix([0.99810947, 0.06146124, 0, 0]) >>> numpy.allclose(M, rotation_matrix(0.123, [1, 0, 0])) True >>> M = quaternion_matrix([1, 0, 0, 0]) >>> numpy.allclose(M, numpy.identity(4)) ...
{ "transformations.py": { "import_statements": [ "from __future__ import division", "from __future__ import print_function", "import math", "import numpy" ], "classes": [], "variable": [], "functions": [ { "name": "quaternion_from_matrix", "file_path":...
quaternion_matrix
transformations.py
[ "from __future__ import division", "from __future__ import print_function", "import math", "import numpy" ]
def dataTransform(x1_b, Rs_b, ts_b, epoch, aug_cl = False): angle = computeAngle(epoch) x1 = x1_b R = Rs_b t = ts_b x1_b = [] Rs_b = [] ts_b = [] step = epoch for i in range(len(x1)): x1_b1 = [] R_b1 = [] t_b1 = [] if not aug_cl: ang...
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def arcball_nearest_axis(point, axes): """Return axis, which arc is nearest to point."""
def arcball_nearest_axis(point, axes): """Return axis, which arc is nearest to point.""" point = numpy.array(point, dtype=numpy.float64, copy=False) nearest = None mx = -1.0 for axis in axes: t = numpy.dot(arcball_constrain_to_axis(point, axis), point) if t > mx: nearest ...
{ "transformations.py": { "import_statements": [ "from __future__ import division", "from __future__ import print_function", "import math", "import numpy" ], "classes": [ { "name": "Arcball", "file_path": "transformations.py", "description": "Virtual T...
arcball_nearest_axis
transformations.py
[ "from __future__ import division", "from __future__ import print_function", "import math", "import numpy" ]
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def angle_between_vectors(v0, v1, directed=True, axis=0): """Return angle between vectors. If directed is False, the input vectors are interpreted as undirected axes, i.e. the maximum angle is pi/2. >>> a = angle_between_vectors([1, -2, 3], [-1, 2, -3]) >>> numpy.allclose(a, math.pi) True ...
def angle_between_vectors(v0, v1, directed=True, axis=0): """Return angle between vectors. If directed is False, the input vectors are interpreted as undirected axes, i.e. the maximum angle is pi/2. >>> a = angle_between_vectors([1, -2, 3], [-1, 2, -3]) >>> numpy.allclose(a, math.pi) True ...
{ "transformations.py": { "import_statements": [ "from __future__ import division", "from __future__ import print_function", "import math", "import numpy" ], "classes": [ { "name": "Arcball", "file_path": "transformations.py", "description": "Virtual T...
angle_between_vectors
transformations.py
[ "from __future__ import division", "from __future__ import print_function", "import math", "import numpy" ]
def affine_matrix_from_points(v0, v1, shear=True, scale=True, usesvd=True): """Return affine transform matrix to register two point sets. v0 and v1 are shape (ndims, \*) arrays of at least ndims non-homogeneous coordinates, where ndims is the dimensionality of the coordinate space. If shear is False, ...
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def decompose_matrix(matrix): """Return sequence of transformations from transformation matrix. matrix : array_like Non-degenerative homogeneous transformation matrix Return tuple of: scale : vector of 3 scaling factors shear : list of shear factors for x-y, x-z, y-z axes a...
def decompose_matrix(matrix): """Return sequence of transformations from transformation matrix. matrix : array_like Non-degenerative homogeneous transformation matrix Return tuple of: scale : vector of 3 scaling factors shear : list of shear factors for x-y, x-z, y-z axes a...
{ "transformations.py": { "import_statements": [ "from __future__ import division", "from __future__ import print_function", "import math", "import numpy" ], "classes": [ { "name": "Arcball", "file_path": "transformations.py", "description": "Virtual T...
decompose_matrix
transformations.py
[ "from __future__ import division", "from __future__ import print_function", "import math", "import numpy" ]
def affine_matrix_from_points(v0, v1, shear=True, scale=True, usesvd=True): """Return affine transform matrix to register two point sets. v0 and v1 are shape (ndims, \*) arrays of at least ndims non-homogeneous coordinates, where ndims is the dimensionality of the coordinate space. If shear is False, ...
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def affine_matrix_from_points(v0, v1, shear=True, scale=True, usesvd=True): """Return affine transform matrix to register two point sets. v0 and v1 are shape (ndims, \*) arrays of at least ndims non-homogeneous coordinates, where ndims is the dimensionality of the coordinate space. If shear is False, ...
def affine_matrix_from_points(v0, v1, shear=True, scale=True, usesvd=True): """Return affine transform matrix to register two point sets. v0 and v1 are shape (ndims, \*) arrays of at least ndims non-homogeneous coordinates, where ndims is the dimensionality of the coordinate space. If shear is False, ...
{ "transformations.py": { "import_statements": [ "from __future__ import division", "from __future__ import print_function", "import math", "import numpy" ] } }
affine_matrix_from_points
transformations.py
[ "from __future__ import division", "from __future__ import print_function", "import math", "import numpy" ]
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def euler_from_quaternion(quaternion, axes='sxyz'): """Return Euler angles from quaternion for specified axis sequence. >>> angles = euler_from_quaternion([0.99810947, 0.06146124, 0, 0]) >>> numpy.allclose(angles, [0.123, 0, 0]) True """
def euler_from_quaternion(quaternion, axes='sxyz'): """Return Euler angles from quaternion for specified axis sequence. >>> angles = euler_from_quaternion([0.99810947, 0.06146124, 0, 0]) >>> numpy.allclose(angles, [0.123, 0, 0]) True """ return euler_from_matrix(quaternion_matrix(quaternion), ...
{ "transformations.py": { "import_statements": [ "from __future__ import division", "from __future__ import print_function", "import math", "import numpy" ], "classes": [], "variable": [ "_AXES2TUPLE = {\n 'sxyz': (0, 0, 0, 0), 'sxyx': (0, 0, 1, 0), 'sxzy': (0, 1, 0, 0...
euler_from_quaternion
transformations.py
[ "from __future__ import division", "from __future__ import print_function", "import math", "import numpy" ]
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def quaternion_about_axis(angle, axis): """Return quaternion for rotation about axis. >>> q = quaternion_about_axis(0.123, [1, 0, 0]) >>> numpy.allclose(q, [0.99810947, 0.06146124, 0, 0]) True """
def quaternion_about_axis(angle, axis): """Return quaternion for rotation about axis. >>> q = quaternion_about_axis(0.123, [1, 0, 0]) >>> numpy.allclose(q, [0.99810947, 0.06146124, 0, 0]) True """ q = numpy.array([0.0, axis[0], axis[1], axis[2]]) qlen = vector_norm(q) if qlen > _EPS: ...
{ "transformations.py": { "import_statements": [ "from __future__ import division", "from __future__ import print_function", "import math", "import numpy" ] } }
quaternion_about_axis
transformations.py
[ "from __future__ import division", "from __future__ import print_function", "import math", "import numpy" ]
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def quaternion_slerp(quat0, quat1, fraction, spin=0, shortestpath=True): """Return spherical linear interpolation between two quaternions. >>> q0 = random_quaternion() >>> q1 = random_quaternion() >>> q = quaternion_slerp(q0, q1, 0) >>> numpy.allclose(q, q0) True >>> q = quaternion_slerp(q0...
def quaternion_slerp(quat0, quat1, fraction, spin=0, shortestpath=True): """Return spherical linear interpolation between two quaternions. >>> q0 = random_quaternion() >>> q1 = random_quaternion() >>> q = quaternion_slerp(q0, q1, 0) >>> numpy.allclose(q, q0) True >>> q = quaternion_slerp(q0...
{ "transformations.py": { "import_statements": [ "from __future__ import division", "from __future__ import print_function", "import math", "import numpy" ], "classes": [], "variable": [], "functions": [ { "name": "unit_vector", "file_path": "transform...
quaternion_slerp
transformations.py
[ "from __future__ import division", "from __future__ import print_function", "import math", "import numpy" ]
def arcball_constrain_to_axis(point, axis): """Return sphere point perpendicular to axis.""" v = numpy.array(point, dtype=numpy.float64, copy=True) a = numpy.array(axis, dtype=numpy.float64, copy=True) v -= a * numpy.dot(a, v) # on plane n = vector_norm(v) if n > _EPS: if v[2] < 0.0: ...
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def random_rotation_matrix(rand=None): """Return uniform random rotation matrix. rand: array like Three independent random variables that are uniformly distributed between 0 and 1 for each returned quaternion. >>> R = random_rotation_matrix() >>> numpy.allclose(numpy.dot(R.T, R), numpy...
def random_rotation_matrix(rand=None): """Return uniform random rotation matrix. rand: array like Three independent random variables that are uniformly distributed between 0 and 1 for each returned quaternion. >>> R = random_rotation_matrix() >>> numpy.allclose(numpy.dot(R.T, R), numpy...
{ "transformations.py": { "import_statements": [ "from __future__ import division", "from __future__ import print_function", "import math", "import numpy" ], "classes": [], "variable": [ "_EPS = numpy.finfo(float).eps * 4.0" ], "functions": [ { "name...
random_rotation_matrix
transformations.py
[ "from __future__ import division", "from __future__ import print_function", "import math", "import numpy" ]
def dataTransform(x1_b, Rs_b, ts_b, epoch, aug_cl = False): angle = computeAngle(epoch) x1 = x1_b R = Rs_b t = ts_b x1_b = [] Rs_b = [] ts_b = [] step = epoch for i in range(len(x1)): x1_b1 = [] R_b1 = [] t_b1 = [] if not aug_cl: ang...
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def euler_matrix(ai, aj, ak, axes='sxyz'): """Return homogeneous rotation matrix from Euler angles and axis sequence. ai, aj, ak : Euler's roll, pitch and yaw angles axes : One of 24 axis sequences as string or encoded tuple >>> R = euler_matrix(1, 2, 3, 'syxz') >>> numpy.allclose(numpy.sum(R[0]),...
def euler_matrix(ai, aj, ak, axes='sxyz'): """Return homogeneous rotation matrix from Euler angles and axis sequence. ai, aj, ak : Euler's roll, pitch and yaw angles axes : One of 24 axis sequences as string or encoded tuple >>> R = euler_matrix(1, 2, 3, 'syxz') >>> numpy.allclose(numpy.sum(R[0]),...
{ "transformations.py": { "import_statements": [ "from __future__ import division", "from __future__ import print_function", "import math", "import numpy" ], "classes": [ { "name": "Arcball", "file_path": "transformations.py", "description": "Virtual T...
euler_matrix
transformations.py
[ "from __future__ import division", "from __future__ import print_function", "import math", "import numpy" ]
def euler_from_quaternion(quaternion, axes='sxyz'): """Return Euler angles from quaternion for specified axis sequence. >>> angles = euler_from_quaternion([0.99810947, 0.06146124, 0, 0]) >>> numpy.allclose(angles, [0.123, 0, 0]) True """ return euler_from_matrix(quaternion_matrix(quaternion), ...
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def quaternion_from_euler(ai, aj, ak, axes='sxyz'): """Return quaternion from Euler angles and axis sequence. ai, aj, ak : Euler's roll, pitch and yaw angles axes : One of 24 axis sequences as string or encoded tuple >>> q = quaternion_from_euler(1, 2, 3, 'ryxz') >>> numpy.allclose(q, [0.435953, 0...
def quaternion_from_euler(ai, aj, ak, axes='sxyz'): """Return quaternion from Euler angles and axis sequence. ai, aj, ak : Euler's roll, pitch and yaw angles axes : One of 24 axis sequences as string or encoded tuple >>> q = quaternion_from_euler(1, 2, 3, 'ryxz') >>> numpy.allclose(q, [0.435953, 0...
{ "transformations.py": { "import_statements": [ "from __future__ import division", "from __future__ import print_function", "import math", "import numpy" ], "classes": [], "variable": [ "_AXES2TUPLE = {\n 'sxyz': (0, 0, 0, 0), 'sxyx': (0, 0, 1, 0), 'sxzy': (0, 1, 0, 0...
quaternion_from_euler
transformations.py
[ "from __future__ import division", "from __future__ import print_function", "import math", "import numpy" ]
def euler_from_quaternion(quaternion, axes='sxyz'): """Return Euler angles from quaternion for specified axis sequence. >>> angles = euler_from_quaternion([0.99810947, 0.06146124, 0, 0]) >>> numpy.allclose(angles, [0.123, 0, 0]) True """ return euler_from_matrix(quaternion_matrix(quaternion), ...
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def arcball_constrain_to_axis(point, axis): """Return sphere point perpendicular to axis."""
def arcball_constrain_to_axis(point, axis): """Return sphere point perpendicular to axis.""" v = numpy.array(point, dtype=numpy.float64, copy=True) a = numpy.array(axis, dtype=numpy.float64, copy=True) v -= a * numpy.dot(a, v) # on plane n = vector_norm(v) if n > _EPS: if v[2] < 0.0: ...
{ "transformations.py": { "import_statements": [ "from __future__ import division", "from __future__ import print_function", "import math", "import numpy" ], "classes": [ { "name": "Arcball", "file_path": "transformations.py", "description": "Virtual T...
arcball_constrain_to_axis
transformations.py
[ "from __future__ import division", "from __future__ import print_function", "import math", "import numpy" ]
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def euler_from_matrix(matrix, axes='sxyz'): """Return Euler angles from rotation matrix for specified axis sequence. axes : One of 24 axis sequences as string or encoded tuple Note that many Euler angle triplets can describe one matrix. >>> R0 = euler_matrix(1, 2, 3, 'syxz') >>> al, be, ga = eule...
def euler_from_matrix(matrix, axes='sxyz'): """Return Euler angles from rotation matrix for specified axis sequence. axes : One of 24 axis sequences as string or encoded tuple Note that many Euler angle triplets can describe one matrix. >>> R0 = euler_matrix(1, 2, 3, 'syxz') >>> al, be, ga = eule...
{ "transformations.py": { "import_statements": [ "from __future__ import division", "from __future__ import print_function", "import math", "import numpy" ], "classes": [ { "name": "Arcball", "file_path": "transformations.py", "description": "Virtual T...
euler_from_matrix
transformations.py
[ "from __future__ import division", "from __future__ import print_function", "import math", "import numpy" ]
def random_rotation_matrix(rand=None): """Return uniform random rotation matrix. rand: array like Three independent random variables that are uniformly distributed between 0 and 1 for each returned quaternion. >>> R = random_rotation_matrix() >>> numpy.allclose(numpy.dot(R.T, R), numpy...
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def all_diffs(a, b): """ Returns a tensor of all combinations of a - b. Args: a (2D tensor): A batch of vectors shaped (B1, F). b (2D tensor): A batch of vectors shaped (B2, F). Returns: The matrix of all pairwise differences between all vectors in `a` and in `b`, will be o...
def all_diffs(a, b): """ Returns a tensor of all combinations of a - b. Args: a (2D tensor): A batch of vectors shaped (B1, F). b (2D tensor): A batch of vectors shaped (B2, F). Returns: The matrix of all pairwise differences between all vectors in `a` and in `b`, will be o...
{ "core/loss.py": { "import_statements": [ "import numbers", "import numpy", "import tensorflow" ], "classes": [], "variable": [], "functions": [ { "name": "cdist", "file_path": "core/loss.py", "description": "Similar to scipy.spatial's cdist, but sy...
all_diffs
core/loss.py
[ "import numbers", "import numpy", "import tensorflow" ]
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def get_at_indices(tensor, indices): """ Like `tensor[np.arange(len(tensor)), indices]` in numpy. """
def get_at_indices(tensor, indices): """ Like `tensor[np.arange(len(tensor)), indices]` in numpy. """ counter = tf.range(tf.shape(indices, out_type=indices.dtype)[0]) return tf.gather_nd(tensor, tf.stack((counter, indices), -1))
{ "core/loss.py": { "import_statements": [ "import numbers", "import numpy", "import tensorflow" ] } }
get_at_indices
core/loss.py
[ "import numbers", "import numpy", "import tensorflow" ]
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def batch_hard(dists, pids, margin, batch_precision_at_k=None): """Computes the batch-hard loss from arxiv.org/abs/1703.07737. Args: dists (2D tensor): A square all-to-all distance matrix as given by cdist. pids (1D tensor): The identities of the entries in `batch`, shape (B,). This...
def batch_hard(dists, pids, margin, batch_precision_at_k=None): """Computes the batch-hard loss from arxiv.org/abs/1703.07737. Args: dists (2D tensor): A square all-to-all distance matrix as given by cdist. pids (1D tensor): The identities of the entries in `batch`, shape (B,). This...
{ "core/loss.py": { "import_statements": [ "import numbers", "import numpy", "import tensorflow" ], "classes": [], "variable": [ "LOSS_CHOICES = {\n 'batch_hard': batch_hard,\n}" ], "functions": [ { "name": "all_diffs", "file_path": "core/loss.p...
batch_hard
core/loss.py
[ "import numbers", "import numpy", "import tensorflow" ]
def cdist(a, b, metric='euclidean'): """Similar to scipy.spatial's cdist, but symbolic. The currently supported metrics can be listed as `cdist.supported_metrics` and are: - 'euclidean', although with a fudge-factor epsilon. - 'sqeuclidean', the squared euclidean. - 'cityblock', the man...
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def batch_iter(data, batch_size, num_epochs, shuffle=True): """ Generates a batch iterator for a dataset. """
def batch_iter(data, batch_size, num_epochs, shuffle=True): """ Generates a batch iterator for a dataset. """ data = np.array(data) data_size = len(data) num_batches_per_epoch = int((len(data)-1)/batch_size) + 1 for epoch in range(num_epochs): # Shuffle the data at each epoch ...
{ "core/ops.py": { "import_statements": [ "from sklearn.neighbors import NearestNeighbors", "import numpy", "import tensorflow" ], "classes": [], "variable": [], "functions": [ { "name": "dropout", "file_path": "core/ops.py", "description": "DOCSTRIN...
batch_iter
core/ops.py
[ "from sklearn.neighbors import NearestNeighbors", "import numpy", "import tensorflow" ]
def conv_block(input_anc, input_pos, channels, dropout_flag, dropout_rate, laxer_idx, stride_input=1, k_size=3, padding_type='SAME', reuse=False): # Traditional 3D conv layer followed by batch norm and relu activation i_size = input_anc.get_shape().as_list()[-2]/stride_input weights = ops....
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def cdist(a, b, metric='euclidean'): """Similar to scipy.spatial's cdist, but symbolic. The currently supported metrics can be listed as `cdist.supported_metrics` and are: - 'euclidean', although with a fudge-factor epsilon. - 'sqeuclidean', the squared euclidean. - 'cityblock', the man...
def cdist(a, b, metric='euclidean'): """Similar to scipy.spatial's cdist, but symbolic. The currently supported metrics can be listed as `cdist.supported_metrics` and are: - 'euclidean', although with a fudge-factor epsilon. - 'sqeuclidean', the squared euclidean. - 'cityblock', the man...
{ "core/loss.py": { "import_statements": [ "import numbers", "import numpy", "import tensorflow" ], "classes": [], "variable": [ "LOSS_CHOICES = {\n 'batch_hard': batch_hard,\n}" ], "functions": [ { "name": "all_diffs", "file_path": "core/loss.p...
cdist
core/loss.py
[ "import numbers", "import numpy", "import tensorflow" ]
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def cal_pnsr(img_hr, img_mr, mask): ''' compute psnr value. Black regions are excluded from the computing. '''
def cal_pnsr(img_hr, img_mr, mask): ''' compute psnr value. Black regions are excluded from the computing. ''' mask_sum = np.sum(mask) mask_sum = mask_sum * 3 if img_hr.ndim == 3 else mask_sum mse = np.sum(np.square(img_hr - img_mr))/mask_sum psnr = 10 * np.log10(255**2/mse) return psnr
{ "code/utils/compute_PSNR_UP.py": { "import_statements": [ "from PIL import Image", "import copy", "import glob", "import numpy", "import os", "import pickle" ], "classes": [], "variable": [], "functions": [ { "name": "save_file", "file_pa...
cal_pnsr
code/utils/compute_PSNR_UP.py
[ "from PIL import Image", "import copy", "import glob", "import numpy", "import os", "import pickle" ]
def save_html_tbl(img_name, test_res, opt, path): img_name.insert(0, 'Average') content = np.round(test_res, decimals=4).astype(str).tolist() content.insert(0, img_name) row_name = ['', 'PSNR', 'SSIM', 'Runtime'] for i in range(len(row_name)): content[i].insert(0, row_name[i]) cont_str =...
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def rgb2ycbcr(img, only_y=True): '''same as matlab rgb2ycbcr only_y: only return Y channel Input: uint8, [0, 255] float, [0, 1] '''
def rgb2ycbcr(img, only_y=True): '''same as matlab rgb2ycbcr only_y: only return Y channel Input: uint8, [0, 255] float, [0, 1] ''' in_img_type = img.dtype img = img.astype(np.float32) if in_img_type != np.uint8: img *= 255. # convert if only_y: rlt = ...
{ "code/utils/compute_PSNR_UP.py": { "import_statements": [ "from PIL import Image", "import copy", "import glob", "import numpy", "import os", "import pickle" ], "classes": [], "variable": [], "functions": [ { "name": "ycbcr2rgb", "file_pa...
rgb2ycbcr
code/utils/compute_PSNR_UP.py
[ "from PIL import Image", "import copy", "import glob", "import numpy", "import os", "import pickle" ]
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def bgr2ycbcr(img, only_y=True): '''bgr version of rgb2ycbcr only_y: only return Y channel Input: uint8, [0, 255] float, [0, 1] '''
def bgr2ycbcr(img, only_y=True): '''bgr version of rgb2ycbcr only_y: only return Y channel Input: uint8, [0, 255] float, [0, 1] ''' in_img_type = img.dtype img.astype(np.float32) if in_img_type != np.uint8: img *= 255. # convert if only_y: rlt = np.dot...
{ "code/utils/compute_PSNR_UP.py": { "import_statements": [ "from PIL import Image", "import copy", "import glob", "import numpy", "import os", "import pickle" ], "classes": [], "variable": [], "functions": [ { "name": "rgb2ycbcr", "file_pa...
bgr2ycbcr
code/utils/compute_PSNR_UP.py
[ "from PIL import Image", "import copy", "import glob", "import numpy", "import os", "import pickle" ]
def set_channel(l, n_channel): def _set_channel(img): if img.ndim == 2: img = np.expand_dims(img, axis=2) c = img.shape[2] if n_channel == 1 and c == 3: img = np.expand_dims(sc.rgb2ycbcr(img)[:, :, 0], 2) elif n_channel == 3 and c == 1: img = np.c...
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def ycbcr2rgb(img): '''same as matlab ycbcr2rgb Input: uint8, [0, 255] float, [0, 1] '''
def ycbcr2rgb(img): '''same as matlab ycbcr2rgb Input: uint8, [0, 255] float, [0, 1] ''' in_img_type = img.dtype img.astype(np.float32) if in_img_type != np.uint8: img *= 255. # convert rlt = np.matmul(img, [[0.00456621, 0.00456621, 0.00456621], [0, -0.00153632, 0...
{ "code/utils/compute_PSNR_UP.py": { "import_statements": [ "from PIL import Image", "import copy", "import glob", "import numpy", "import os", "import pickle" ] } }
ycbcr2rgb
code/utils/compute_PSNR_UP.py
[ "from PIL import Image", "import copy", "import glob", "import numpy", "import os", "import pickle" ]
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def crop(ar, crop_width, copy=False, order='K'): """Crop array `ar` by `crop_width` along each dimension. Parameters ---------- ar : array-like of rank N Input array. crop_width : {sequence, int} Number of values to remove from the edges of each axis. ``((before_1, after_1),`...
def crop(ar, crop_width, copy=False, order='K'): """Crop array `ar` by `crop_width` along each dimension. Parameters ---------- ar : array-like of rank N Input array. crop_width : {sequence, int} Number of values to remove from the edges of each axis. ``((before_1, after_1),`...
{ "code/utils/myssim.py": { "import_statements": [ "from __future__ import absolute_import", "from __future__ import division", "from __future__ import print_function", "from numpy.lib.arraypad import _validate_lengths", "from scipy.ndimage import gaussian_filter", "from scipy....
crop
code/utils/myssim.py
[ "from __future__ import absolute_import", "from __future__ import division", "from __future__ import print_function", "from numpy.lib.arraypad import _validate_lengths", "from scipy.ndimage import gaussian_filter", "from scipy.ndimage import uniform_filter", "import numpy" ]
def compare_ssim(X, Y, win_size=None, gradient=False, data_range=None, multichannel=False, gaussian_weights=False, full=False, dynamic_range=None, **kwargs): """Compute the mean structural similarity index between two images. Parameters ---------- X, Y : ndarray ...
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def compare_ssim(X, Y, win_size=None, gradient=False, data_range=None, multichannel=False, gaussian_weights=False, full=False, dynamic_range=None, **kwargs): """Compute the mean structural similarity index between two images. Parameters ---------- X, Y : ndarray ...
def compare_ssim(X, Y, win_size=None, gradient=False, data_range=None, multichannel=False, gaussian_weights=False, full=False, dynamic_range=None, **kwargs): """Compute the mean structural similarity index between two images. Parameters ---------- X, Y : ndarray ...
{ "code/utils/myssim.py": { "import_statements": [ "from __future__ import absolute_import", "from __future__ import division", "from __future__ import print_function", "from numpy.lib.arraypad import _validate_lengths", "from scipy.ndimage import gaussian_filter", "from scipy....
compare_ssim
code/utils/myssim.py
[ "from __future__ import absolute_import", "from __future__ import division", "from __future__ import print_function", "from numpy.lib.arraypad import _validate_lengths", "from scipy.ndimage import gaussian_filter", "from scipy.ndimage import uniform_filter", "import numpy" ]
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def require_bluetooth_enabled(method): """Decorator to call `BluetoothDispatcher` method when runtime permissions are granted and Bluetooth adapter becomes ready. Decorator launches system activities that allows the user to grant runtime permissions and turn on Bluetooth, if Bluetooth is not en...
def require_bluetooth_enabled(method): """Decorator to call `BluetoothDispatcher` method when runtime permissions are granted and Bluetooth adapter becomes ready. Decorator launches system activities that allows the user to grant runtime permissions and turn on Bluetooth, if Bluetooth is not en...
{ "able/adapter.py": { "import_statements": [ "from android import activity", "from android.permissions import check_permission", "from android.permissions import request_permissions", "from dataclasses import dataclass", "from dataclasses import field", "from functools import ...
require_bluetooth_enabled
able/adapter.py
[ "from android import activity", "from android.permissions import check_permission", "from android.permissions import request_permissions", "from dataclasses import dataclass", "from dataclasses import field", "from functools import partial", "from functools import wraps", "from jnius import autoclass"...
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def set_adapter_failure_rollback(handler): """Decorator to launch handler if permissions are not granted or adapter is not enabled."""
def set_adapter_failure_rollback(handler): """Decorator to launch handler if permissions are not granted or adapter is not enabled.""" def inner(func): @wraps(func) def wrapper(self, *args, **kwargs): manager = AdapterManager.get_attached_manager(self) if manager: ...
{ "able/adapter.py": { "import_statements": [ "from android import activity", "from android.permissions import check_permission", "from android.permissions import request_permissions", "from dataclasses import dataclass", "from dataclasses import field", "from functools import ...
set_adapter_failure_rollback
able/adapter.py
[ "from android import activity", "from android.permissions import check_permission", "from android.permissions import request_permissions", "from dataclasses import dataclass", "from dataclasses import field", "from functools import partial", "from functools import wraps", "from jnius import autoclass"...
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def ble_task(method): """ Enque method """
def ble_task(method): """ Enque method """ @wraps(method) def wrapper(obj, *args, **kwargs): task = partial(method, obj, *args, **kwargs) obj.queue.enque(task) return wrapper
{ "able/queue.py": { "import_statements": [ "from functools import partial", "from functools import wraps", "from kivy.clock import Clock", "from kivy.logger import Logger", "import threading" ], "classes": [ { "name": "BLEQueue", "file_path": "able/queu...
ble_task
able/queue.py
[ "from functools import partial", "from functools import wraps", "from kivy.clock import Clock", "from kivy.logger import Logger", "import threading" ]
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def force_convertible_to_java_array( value: Any ) -> Union[list, tuple, bytes, bytearray]: """Construct a value that is convertible to a Java array. >>> force_convertible_to_java_array([3, 1, 4]) [3, 1, 4] >>> force_convertible_to_java_array(['314']) ['314'] >>> force_convertible_to_jav...
def force_convertible_to_java_array( value: Any ) -> Union[list, tuple, bytes, bytearray]: """Construct a value that is convertible to a Java array. >>> force_convertible_to_java_array([3, 1, 4]) [3, 1, 4] >>> force_convertible_to_java_array(['314']) ['314'] >>> force_convertible_to_jav...
{ "able/utils.py": { "import_statements": [ "from typing import Any", "from typing import Union" ] } }
force_convertible_to_java_array
able/utils.py
[ "from typing import Any", "from typing import Union" ]
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def require_runtime_permissions(method): """Deprecated decorator, left for backwards compatibility."""
def require_runtime_permissions(method): """Deprecated decorator, left for backwards compatibility.""" return method
{ "able/permissions.py": { "import_statements": [ "from jnius import autoclass" ], "classes": [ { "name": "Permission", "file_path": "able/permissions.py", "description": "String constants values for BLE-related permissions.\nhttps://developer.android.com/reference/andr...
require_runtime_permissions
able/__init__.py
[ "from able.adapter import require_bluetooth_enabled", "from able.permissions import Permission", "from able.structures import Advertisement", "from able.structures import Services", "from able.version import __version__", "from enum import IntEnum", "from kivy.utils import platform" ]
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def no_op_wraps(func): """Replaces functools.wraps in order to undo wrapping. Can be used to preserve the decorated function's signature in the documentation generated by Sphinx. """
def no_op_wraps(func): """Replaces functools.wraps in order to undo wrapping. Can be used to preserve the decorated function's signature in the documentation generated by Sphinx. """ def wrapper(decorator): return func return wrapper
{ "docs/conf.py": { "import_statements": [ "from mock import MagicMock", "import functools", "import os", "import sys" ] } }
no_op_wraps
docs/conf.py
[ "from mock import MagicMock", "import functools", "import os", "import sys" ]
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def _update_post_node(node, options, arguments): """ Extract metadata from options and populate a post node. """
def _update_post_node(node, options, arguments): """ Extract metadata from options and populate a post node. """ node["date"] = arguments[0] if arguments else None node["tags"] = options.get("tags", []) node["author"] = options.get("author", []) node["category"] = options.get("category", [])...
{ "src/ablog/post.py": { "import_statements": [ "from ablog.blog import Blog", "from ablog.blog import os_path_join", "from ablog.blog import revise_pending_xrefs", "from ablog.blog import slugify", "import ablog", "from datetime import datetime", "from dateutil.parser im...
_update_post_node
src/ablog/post.py
[ "from ablog.blog import Blog", "from ablog.blog import os_path_join", "from ablog.blog import revise_pending_xrefs", "from ablog.blog import slugify", "import ablog", "from datetime import datetime", "from dateutil.parser import parse", "from docutils import nodes", "from docutils.parsers.rst import...
def process_posts(app, doctree): """ Process posts and map posted document names to post details in the environment. """ env = app.builder.env if not hasattr(env, "ablog_posts"): env.ablog_posts = {} post_nodes = list(doctree.findall(PostNode)) if not post_nodes: return ...
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def require_config_str_or_list_lookup(lookup_config_key, is_optional=True): """ The default values can be a string or list of strings that match entries in a comprehensive list -- for example, the default authors are one or more of all the authors. """
def require_config_str_or_list_lookup(lookup_config_key, is_optional=True): """ The default values can be a string or list of strings that match entries in a comprehensive list -- for example, the default authors are one or more of all the authors. """ def verify_fn(key, value, config): ...
{ "src/ablog/blog.py": { "import_statements": [ "from collections.abc import Container", "from datetime import datetime", "from docutils import nodes", "from docutils.io import StringOutput", "from docutils.utils import new_document", "from operator import attrgetter", "f...
require_config_str_or_list_lookup
src/ablog/blog.py
[ "from collections.abc import Container", "from datetime import datetime", "from docutils import nodes", "from docutils.io import StringOutput", "from docutils.utils import new_document", "from operator import attrgetter", "from sphinx import addnodes", "from sphinx.util.osutil import relative_uri", ...
def process_posts(app, doctree): """ Process posts and map posted document names to post details in the environment. """ env = app.builder.env if not hasattr(env, "ablog_posts"): env.ablog_posts = {} post_nodes = list(doctree.findall(PostNode)) if not post_nodes: return ...
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def test_not_safe_for_parallel_read(rootdir: Path, tmp_path: Path): """ Ablog is NOT safe for parallel read. In such case, it doesn't collect any posts. """
def test_not_safe_for_parallel_read(rootdir: Path, tmp_path: Path): """ Ablog is NOT safe for parallel read. In such case, it doesn't collect any posts. """ # https://github.com/sunpy/ablog/issues/297 # Very ugly hack to change the parallel_read_safe value to True good_read_safe = '"paralle...
{ "src/ablog/tests/test_parallel.py": { "import_statements": [ "from pathlib import Path", "from subprocess import run", "import pytest", "import sys" ] } }
test_not_safe_for_parallel_read
src/ablog/tests/test_parallel.py
[ "from pathlib import Path", "from subprocess import run", "import pytest", "import sys" ]
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def read_text(path): """ Support function to give backward compatibility with older sphinx (v2). """
def read_text(path): """ Support function to give backward compatibility with older sphinx (v2). """ if hasattr(path, "read_text"): return path.read_text() return path.text()
{ "src/ablog/tests/test_external.py": { "import_statements": [ "import pytest" ] } }
read_text
src/ablog/tests/test_external.py
[ "import pytest" ]
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def get_html_templates_path(): """ Return path to ABlog templates folder. """
def get_html_templates_path(): """ Return path to ABlog templates folder. """ pkgdir = os.path.abspath(os.path.dirname(__file__)) return os.path.join(pkgdir, "templates")
{ "src/ablog/blog.py": { "import_statements": [ "from collections.abc import Container", "from datetime import datetime", "from docutils import nodes", "from docutils.io import StringOutput", "from docutils.utils import new_document", "from operator import attrgetter", "f...
get_html_templates_path
src/ablog/__init__.py
[ "from .blog import Blog", "from .blog import CONFIG", "from .post import CheckFrontMatter", "from .post import PostDirective", "from .post import PostListDirective", "from .post import UpdateDirective", "from .post import UpdateNode", "from .post import generate_archive_pages", "from .post import ge...
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def builder_support(builder): """ Return True when builder is supported. Supported builders output in html format, but exclude `PickleHTMLBuilder` and `JSONHTMLBuilder`, which run into issues when serializing blog objects. """
def builder_support(builder): """ Return True when builder is supported. Supported builders output in html format, but exclude `PickleHTMLBuilder` and `JSONHTMLBuilder`, which run into issues when serializing blog objects. """ if hasattr(builder, "builder"): builder = builder.builde...
{ "src/ablog/blog.py": { "import_statements": [ "from collections.abc import Container", "from datetime import datetime", "from docutils import nodes", "from docutils.io import StringOutput", "from docutils.utils import new_document", "from operator import attrgetter", "f...
builder_support
src/ablog/__init__.py
[ "from .blog import Blog", "from .blog import CONFIG", "from .post import CheckFrontMatter", "from .post import PostDirective", "from .post import PostListDirective", "from .post import UpdateDirective", "from .post import UpdateNode", "from .post import generate_archive_pages", "from .post import ge...
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def slugify(string): """ Slugify *s*. """
def slugify(string): """ Slugify *s*. """ string = normalize("NFKD", str(string)) string = re.sub(r"[^\w\s-]", "", string).strip().lower() return re.sub(r"[-\s]+", "-", string)
{ "src/ablog/blog.py": { "import_statements": [ "from collections.abc import Container", "from datetime import datetime", "from docutils import nodes", "from docutils.io import StringOutput", "from docutils.utils import new_document", "from operator import attrgetter", "f...
slugify
src/ablog/blog.py
[ "from collections.abc import Container", "from datetime import datetime", "from docutils import nodes", "from docutils.io import StringOutput", "from docutils.utils import new_document", "from operator import attrgetter", "from sphinx import addnodes", "from sphinx.util.osutil import relative_uri", ...
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def require_config_full_name_link_dict(is_link_optional=True): """ The definition for authors and similar entries is to map a short name to a (full name, link) tuple. """
def require_config_full_name_link_dict(is_link_optional=True): """ The definition for authors and similar entries is to map a short name to a (full name, link) tuple. """ def verify_fn(key, value, config): for full_name, link in value.values(): if not isinstance(full_name, str):...
{ "src/ablog/blog.py": { "import_statements": [ "from collections.abc import Container", "from datetime import datetime", "from docutils import nodes", "from docutils.io import StringOutput", "from docutils.utils import new_document", "from operator import attrgetter", "f...
require_config_full_name_link_dict
src/ablog/blog.py
[ "from collections.abc import Container", "from datetime import datetime", "from docutils import nodes", "from docutils.io import StringOutput", "from docutils.utils import new_document", "from operator import attrgetter", "from sphinx import addnodes", "from sphinx.util.osutil import relative_uri", ...
def process_posts(app, doctree): """ Process posts and map posted document names to post details in the environment. """ env = app.builder.env if not hasattr(env, "ablog_posts"): env.ablog_posts = {} post_nodes = list(doctree.findall(PostNode)) if not post_nodes: return ...
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def read_text(path): """ Support function to give backward compatibility with older sphinx (v2). """
def read_text(path): """ Support function to give backward compatibility with older sphinx (v2). """ if hasattr(path, "read_text"): return path.read_text() return path.text()
{ "src/ablog/tests/test_postlist.py": { "import_statements": [ "import pytest" ] } }
read_text
src/ablog/tests/test_postlist.py
[ "import pytest" ]
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def read_conf(confdir): """ Return conf.py file as a module. """
def read_conf(confdir): """ Return conf.py file as a module. """ sys.path.insert(0, confdir) conf = __import__("conf") sys.path.pop(0) return conf
{ "src/ablog/commands.py": { "import_statements": [ "from ablog.start import ablog_start", "import ablog", "from datetime import date", "from http import server", "from invoke import run", "from os import path", "from os.path import abspath", "from os.path import is...
read_conf
src/ablog/commands.py
[ "from ablog.start import ablog_start", "import ablog", "from datetime import date", "from http import server", "from invoke import run", "from os import path", "from os.path import abspath", "from os.path import isfile", "from os.path import join", "from watchdog.observers import Observer", "fro...
def ablog_build( builder=None, sourcedir=None, website=None, doctrees=None, traceback=False, runpdb=False, allfiles=False, werror=False, verbosity=0, quiet=False, extra_quiet=False, no_colors=False, **kwargs, ): confdir = find_confdir(sourcedir) conf = read_co...
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def anchor(post): """ Return anchor string for posts that are page sections. """
def anchor(post): """ Return anchor string for posts that are page sections. """ if post.section: return "#" + post.section else: return ""
{ "src/ablog/blog.py": { "import_statements": [ "from collections.abc import Container", "from datetime import datetime", "from docutils import nodes", "from docutils.io import StringOutput", "from docutils.utils import new_document", "from operator import attrgetter", "f...
anchor
src/ablog/__init__.py
[ "from .blog import Blog", "from .blog import CONFIG", "from .post import CheckFrontMatter", "from .post import PostDirective", "from .post import PostListDirective", "from .post import UpdateDirective", "from .post import UpdateNode", "from .post import generate_archive_pages", "from .post import ge...
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def find_confdir(sourcedir=None): """ Return path to current directory or its parent that contains conf.py. """
def find_confdir(sourcedir=None): """ Return path to current directory or its parent that contains conf.py. """ confdir = sourcedir or os.getcwd() def parent(d): return abspath(join(d, "..")) while not isfile(join(confdir, "conf.py")) and confdir != parent(confdir): confdir = p...
{ "src/ablog/commands.py": { "import_statements": [ "from ablog.start import ablog_start", "import ablog", "from datetime import date", "from http import server", "from invoke import run", "from os import path", "from os.path import abspath", "from os.path import is...
find_confdir
src/ablog/commands.py
[ "from ablog.start import ablog_start", "import ablog", "from datetime import date", "from http import server", "from invoke import run", "from os import path", "from os.path import abspath", "from os.path import isfile", "from os.path import join", "from watchdog.observers import Observer", "fro...
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def purge_posts(app, env, docname): """ Remove post and reference to it from the standard domain when its document is removed or changed. """
def purge_posts(app, env, docname): """ Remove post and reference to it from the standard domain when its document is removed or changed. """ if hasattr(env, "ablog_posts"): env.ablog_posts.pop(docname, None) filename = os.path.split(docname)[1] env.domains["std"].data["labels"].pop...
{ "src/ablog/post.py": { "import_statements": [ "from ablog.blog import Blog", "from ablog.blog import os_path_join", "from ablog.blog import revise_pending_xrefs", "from ablog.blog import slugify", "import ablog", "from datetime import datetime", "from dateutil.parser im...
purge_posts
src/ablog/post.py
[ "from ablog.blog import Blog", "from ablog.blog import os_path_join", "from ablog.blog import revise_pending_xrefs", "from ablog.blog import slugify", "import ablog", "from datetime import datetime", "from dateutil.parser import parse", "from docutils import nodes", "from docutils.parsers.rst import...
def process_posts(app, doctree): """ Process posts and map posted document names to post details in the environment. """ env = app.builder.env if not hasattr(env, "ablog_posts"): env.ablog_posts = {} post_nodes = list(doctree.findall(PostNode)) if not post_nodes: return ...
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def read_text(path): """ Support function to give backward compatibility with older sphinx (v2). """
def read_text(path): """ Support function to give backward compatibility with older sphinx (v2). """ if hasattr(path, "read_text"): return path.read_text() return path.text()
{ "src/ablog/tests/test_canonical.py": { "import_statements": [ "import pytest" ] } }
read_text
src/ablog/tests/test_canonical.py
[ "import pytest" ]
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def test_themes_templates_come_first(app: Sphinx, rootdir: Path): """ Ensures that if theme supplies own Ablog template, it is used over the builtin one, but fallback to builtin for missing ones. """
def test_themes_templates_come_first(app: Sphinx, rootdir: Path): """ Ensures that if theme supplies own Ablog template, it is used over the builtin one, but fallback to builtin for missing ones. """ app.build() # is the customized template it in the output? customized = (rootdir / "test-te...
{ "src/ablog/tests/test_templates.py": { "import_statements": [ "from pathlib import Path", "from sphinx.application import Sphinx", "from sphinx.errors import ThemeError", "import pytest" ] } }
test_themes_templates_come_first
src/ablog/tests/test_templates.py
[ "from pathlib import Path", "from sphinx.application import Sphinx", "from sphinx.errors import ThemeError", "import pytest" ]
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def html_builder_write_doc(self, docname, doctree, img_url=False): """ Part of :meth:`sphinx.builders.html.StandaloneHTMLBuilder.write_doc` method used to convert *doctree* to HTML. Extra argument `img_url` enables conversion of `<img>` source paths to fully qualified URLs based on `blog_baseurl`. ...
def html_builder_write_doc(self, docname, doctree, img_url=False): """ Part of :meth:`sphinx.builders.html.StandaloneHTMLBuilder.write_doc` method used to convert *doctree* to HTML. Extra argument `img_url` enables conversion of `<img>` source paths to fully qualified URLs based on `blog_baseurl`. ...
{ "src/ablog/blog.py": { "import_statements": [ "from collections.abc import Container", "from datetime import datetime", "from docutils import nodes", "from docutils.io import StringOutput", "from docutils.utils import new_document", "from operator import attrgetter", "f...
html_builder_write_doc
src/ablog/blog.py
[ "from collections.abc import Container", "from datetime import datetime", "from docutils import nodes", "from docutils.io import StringOutput", "from docutils.utils import new_document", "from operator import attrgetter", "from sphinx import addnodes", "from sphinx.util.osutil import relative_uri", ...
def generate_atom_feeds(app): """ Generate archive pages for all posts, categories, tags, authors, and drafts. """ if not ablog.builder_support(app): return blog = Blog(app) base_url = blog.blog_baseurl if not base_url: return feeds = [ ( blog.post...
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def link_posts(posts): """ Link posts after sorting them post by published date. """
def link_posts(posts): """ Link posts after sorting them post by published date. """ posts = filter(attrgetter("order"), posts) posts = sorted(posts) posts[0].prev = posts[-1].next = None for i in range(1, len(posts)): post = posts[i] posts[i - 1].next = post post.pre...
{ "src/ablog/blog.py": { "import_statements": [ "from collections.abc import Container", "from datetime import datetime", "from docutils import nodes", "from docutils.io import StringOutput", "from docutils.utils import new_document", "from operator import attrgetter", "f...
link_posts
src/ablog/blog.py
[ "from collections.abc import Container", "from datetime import datetime", "from docutils import nodes", "from docutils.io import StringOutput", "from docutils.utils import new_document", "from operator import attrgetter", "from sphinx import addnodes", "from sphinx.util.osutil import relative_uri", ...
def generate_atom_feeds(app): """ Generate archive pages for all posts, categories, tags, authors, and drafts. """ if not ablog.builder_support(app): return blog = Blog(app) base_url = blog.blog_baseurl if not base_url: return feeds = [ ( blog.post...
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def _get_section_title(section): """ Return section title as text. """
def _get_section_title(section): """ Return section title as text. """ for title in section.findall(nodes.title): return title.astext() raise Exception("Missing title")
{ "src/ablog/post.py": { "import_statements": [ "from ablog.blog import Blog", "from ablog.blog import os_path_join", "from ablog.blog import revise_pending_xrefs", "from ablog.blog import slugify", "import ablog", "from datetime import datetime", "from dateutil.parser im...
_get_section_title
src/ablog/post.py
[ "from ablog.blog import Blog", "from ablog.blog import os_path_join", "from ablog.blog import revise_pending_xrefs", "from ablog.blog import slugify", "import ablog", "from datetime import datetime", "from dateutil.parser import parse", "from docutils import nodes", "from docutils.parsers.rst import...
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def test_skip_ablog_templates_but_missing_templates(app: Sphinx): """ Completely override the templates used by ablog, but not provide them. """
def test_skip_ablog_templates_but_missing_templates(app: Sphinx): """ Completely override the templates used by ablog, but not provide them. """ with pytest.raises( ThemeError, match=r"An error happened in rendering the page blog/author\.\nReason: TemplateNotFound\(\"'ablog/catalog.html'...
{ "src/ablog/tests/test_templates.py": { "import_statements": [ "from pathlib import Path", "from sphinx.application import Sphinx", "from sphinx.errors import ThemeError", "import pytest" ] } }
test_skip_ablog_templates_but_missing_templates
src/ablog/tests/test_templates.py
[ "from pathlib import Path", "from sphinx.application import Sphinx", "from sphinx.errors import ThemeError", "import pytest" ]
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def register_posts(app): """ Register posts found in the Sphinx build environment. """
def register_posts(app): """ Register posts found in the Sphinx build environment. """ blog = Blog(app) for docname, posts in getattr(app.env, "ablog_posts", {}).items(): for postinfo in posts: blog.register(docname, postinfo)
{ "src/ablog/post.py": { "import_statements": [ "from ablog.blog import Blog", "from ablog.blog import os_path_join", "from ablog.blog import revise_pending_xrefs", "from ablog.blog import slugify", "import ablog", "from datetime import datetime", "from dateutil.parser im...
register_posts
src/ablog/post.py
[ "from ablog.blog import Blog", "from ablog.blog import os_path_join", "from ablog.blog import revise_pending_xrefs", "from ablog.blog import slugify", "import ablog", "from datetime import datetime", "from dateutil.parser import parse", "from docutils import nodes", "from docutils.parsers.rst import...
def process_posts(app, doctree): """ Process posts and map posted document names to post details in the environment. """ env = app.builder.env if not hasattr(env, "ablog_posts"): env.ablog_posts = {} post_nodes = list(doctree.findall(PostNode)) if not post_nodes: return ...
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def ablog_main(): """ Ablog Main. """
def ablog_main(): """ Ablog Main. """ if len(sys.argv) == 1: parser.print_help() else: namespace = parser.parse_args() namespace.func(**namespace.__dict__)
{ "src/ablog/commands.py": { "import_statements": [ "from ablog.start import ablog_start", "import ablog", "from datetime import date", "from http import server", "from invoke import run", "from os import path", "from os.path import abspath", "from os.path import is...
ablog_main
src/ablog/commands.py
[ "from ablog.start import ablog_start", "import ablog", "from datetime import date", "from http import server", "from invoke import run", "from os import path", "from os.path import abspath", "from os.path import isfile", "from os.path import join", "from watchdog.observers import Observer", "fro...
def ablog_build( builder=None, sourcedir=None, website=None, doctrees=None, traceback=False, runpdb=False, allfiles=False, werror=False, verbosity=0, quiet=False, extra_quiet=False, no_colors=False, **kwargs, ): confdir = find_confdir(sourcedir) conf = read_co...
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def generate_archive_pages(app): """ Generate archive pages for all posts, categories, tags, authors, and drafts. """
def generate_archive_pages(app): """ Generate archive pages for all posts, categories, tags, authors, and drafts. """ if not ablog.builder_support(app): return blog = Blog(app) for post in blog.posts: for redirect in post.redirect: yield (redirect, {"redirect": po...
{ "src/ablog/post.py": { "import_statements": [ "from ablog.blog import Blog", "from ablog.blog import os_path_join", "from ablog.blog import revise_pending_xrefs", "from ablog.blog import slugify", "import ablog", "from datetime import datetime", "from dateutil.parser im...
generate_archive_pages
src/ablog/post.py
[ "from ablog.blog import Blog", "from ablog.blog import os_path_join", "from ablog.blog import revise_pending_xrefs", "from ablog.blog import slugify", "import ablog", "from datetime import datetime", "from dateutil.parser import parse", "from docutils import nodes", "from docutils.parsers.rst import...
def process_posts(app, doctree): """ Process posts and map posted document names to post details in the environment. """ env = app.builder.env if not hasattr(env, "ablog_posts"): env.ablog_posts = {} post_nodes = list(doctree.findall(PostNode)) if not post_nodes: return ...
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def generate_atom_feeds(app): """ Generate archive pages for all posts, categories, tags, authors, and drafts. """
def generate_atom_feeds(app): """ Generate archive pages for all posts, categories, tags, authors, and drafts. """ if not ablog.builder_support(app): return blog = Blog(app) base_url = blog.blog_baseurl if not base_url: return feeds = [ ( blog.post...
{ "src/ablog/post.py": { "import_statements": [ "from ablog.blog import Blog", "from ablog.blog import os_path_join", "from ablog.blog import revise_pending_xrefs", "from ablog.blog import slugify", "import ablog", "from datetime import datetime", "from dateutil.parser im...
generate_atom_feeds
src/ablog/post.py
[ "from ablog.blog import Blog", "from ablog.blog import os_path_join", "from ablog.blog import revise_pending_xrefs", "from ablog.blog import slugify", "import ablog", "from datetime import datetime", "from dateutil.parser import parse", "from docutils import nodes", "from docutils.parsers.rst import...
def process_posts(app, doctree): """ Process posts and map posted document names to post details in the environment. """ env = app.builder.env if not hasattr(env, "ablog_posts"): env.ablog_posts = {} post_nodes = list(doctree.findall(PostNode)) if not post_nodes: return ...
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def test_feed(app, status, warning): """ Atom syndication feeds are built correctly. """
def test_feed(app, status, warning): """ Atom syndication feeds are built correctly. """ app.build() assert app.statuscode == 0 feed_path = app.outdir / "blog/atom.xml" assert (feed_path).exists() with feed_path.open() as feed_opened: feed_tree = lxml.etree.parse(feed_opened) ...
{ "src/ablog/tests/test_build.py": { "import_statements": [ "from datetime import datetime", "import lxml", "import pytest" ], "classes": [], "variable": [ "POST_DATETIME_FMT = \"%Y-%m-%dT%H:%M:%S%z\"" ], "functions": [] } }
test_feed
src/ablog/tests/test_build.py
[ "from datetime import datetime", "import lxml", "import pytest" ]
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def _get_update_dates(section, docname, post_date_format): """ Return list of dates of updates found section. """
def _get_update_dates(section, docname, post_date_format): """ Return list of dates of updates found section. """ update_nodes = list(section.findall(UpdateNode)) update_dates = [] for update_node in update_nodes: try: update = datetime.strptime(update_node["date"], post_date...
{ "src/ablog/post.py": { "import_statements": [ "from ablog.blog import Blog", "from ablog.blog import os_path_join", "from ablog.blog import revise_pending_xrefs", "from ablog.blog import slugify", "import ablog", "from datetime import datetime", "from dateutil.parser im...
_get_update_dates
src/ablog/post.py
[ "from ablog.blog import Blog", "from ablog.blog import os_path_join", "from ablog.blog import revise_pending_xrefs", "from ablog.blog import slugify", "import ablog", "from datetime import datetime", "from dateutil.parser import parse", "from docutils import nodes", "from docutils.parsers.rst import...
def process_posts(app, doctree): """ Process posts and map posted document names to post details in the environment. """ env = app.builder.env if not hasattr(env, "ablog_posts"): env.ablog_posts = {} post_nodes = list(doctree.findall(PostNode)) if not post_nodes: return ...
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def ask_user(d): """ Borrowed from Sphinx 1.3b3. Ask the user for quickstart values missing from *d*. Values are: * path: root path * project: project name * author: author names * version: version of project * release: release of project """
def ask_user(d): """ Borrowed from Sphinx 1.3b3. Ask the user for quickstart values missing from *d*. Values are: * path: root path * project: project name * author: author names * version: version of project * release: release of project """ d.update(CONF_DE...
{ "src/ablog/start.py": { "import_statements": [ "from ablog import __version__", "from docutils.utils import column_width", "from os import path", "from sphinx.cmd.quickstart import do_prompt", "from sphinx.cmd.quickstart import is_path", "from sphinx.util import texescape", ...
ask_user
src/ablog/start.py
[ "from ablog import __version__", "from docutils.utils import column_width", "from os import path", "from sphinx.cmd.quickstart import do_prompt", "from sphinx.cmd.quickstart import is_path", "from sphinx.util import texescape", "from sphinx.util.console import bold", "from sphinx.util.console import c...
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def process_posts(app, doctree): """ Process posts and map posted document names to post details in the environment. """
def process_posts(app, doctree): """ Process posts and map posted document names to post details in the environment. """ env = app.builder.env if not hasattr(env, "ablog_posts"): env.ablog_posts = {} post_nodes = list(doctree.findall(PostNode)) if not post_nodes: return ...
{ "src/ablog/post.py": { "import_statements": [ "from ablog.blog import Blog", "from ablog.blog import os_path_join", "from ablog.blog import revise_pending_xrefs", "from ablog.blog import slugify", "import ablog", "from datetime import datetime", "from dateutil.parser im...
process_posts
src/ablog/post.py
[ "from ablog.blog import Blog", "from ablog.blog import os_path_join", "from ablog.blog import revise_pending_xrefs", "from ablog.blog import slugify", "import ablog", "from datetime import datetime", "from dateutil.parser import parse", "from docutils import nodes", "from docutils.parsers.rst import...
def process_postlist(app, doctree, docname): """ Replace `PostList` nodes with lists of posts. Also, register all posts if they have not been registered yet. """ blog = Blog(app) if not blog: register_posts(app) for node in doctree.findall(PostList): colls = [] for c...
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def process_postlist(app, doctree, docname): """ Replace `PostList` nodes with lists of posts. Also, register all posts if they have not been registered yet. """
def process_postlist(app, doctree, docname): """ Replace `PostList` nodes with lists of posts. Also, register all posts if they have not been registered yet. """ blog = Blog(app) if not blog: register_posts(app) for node in doctree.findall(PostList): colls = [] for c...
{ "src/ablog/post.py": { "import_statements": [ "from ablog.blog import Blog", "from ablog.blog import os_path_join", "from ablog.blog import revise_pending_xrefs", "from ablog.blog import slugify", "import ablog", "from datetime import datetime", "from dateutil.parser im...
process_postlist
src/ablog/post.py
[ "from ablog.blog import Blog", "from ablog.blog import os_path_join", "from ablog.blog import revise_pending_xrefs", "from ablog.blog import slugify", "import ablog", "from datetime import datetime", "from dateutil.parser import parse", "from docutils import nodes", "from docutils.parsers.rst import...
def process_posts(app, doctree): """ Process posts and map posted document names to post details in the environment. """ env = app.builder.env if not hasattr(env, "ablog_posts"): env.ablog_posts = {} post_nodes = list(doctree.findall(PostNode)) if not post_nodes: return ...
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def generate(d, overwrite=True, silent=False): """ Borrowed from Sphinx 1.3b3. Generate project based on values in *d*. """
def generate(d, overwrite=True, silent=False): """ Borrowed from Sphinx 1.3b3. Generate project based on values in *d*. """ texescape.init() if "mastertoctree" not in d: d["mastertoctree"] = "" if "mastertocmaxdepth" not in d: d["mastertocmaxdepth"] = 2 d["project_fn"] =...
{ "src/ablog/start.py": { "import_statements": [ "from ablog import __version__", "from docutils.utils import column_width", "from os import path", "from sphinx.cmd.quickstart import do_prompt", "from sphinx.cmd.quickstart import is_path", "from sphinx.util import texescape", ...
generate
src/ablog/start.py
[ "from ablog import __version__", "from docutils.utils import column_width", "from os import path", "from sphinx.cmd.quickstart import do_prompt", "from sphinx.cmd.quickstart import is_path", "from sphinx.util import texescape", "from sphinx.util.console import bold", "from sphinx.util.console import c...
def ablog_start(**kwargs): if not color_terminal(): nocolor() d = CONF_DEFAULTS try: ask_user(d) except (KeyboardInterrupt, EOFError): print("") print("[Interrupted.]") return generate(d)
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def setup(app): """ Setup ABlog extension. """
def setup(app): """ Setup ABlog extension. """ app.require_sphinx("6.2") for args in CONFIG: app.add_config_value(*args[:3]) app.add_directive("post", PostDirective) app.add_directive("postlist", PostListDirective) app.connect("config-inited", config_inited) app.connect("buil...
{ "src/ablog/post.py": { "import_statements": [ "from ablog.blog import Blog", "from ablog.blog import os_path_join", "from ablog.blog import revise_pending_xrefs", "from ablog.blog import slugify", "import ablog", "from datetime import datetime", "from dateutil.parser im...
setup
src/ablog/__init__.py
[ "from .blog import Blog", "from .blog import CONFIG", "from .post import CheckFrontMatter", "from .post import PostDirective", "from .post import PostListDirective", "from .post import UpdateDirective", "from .post import UpdateNode", "from .post import generate_archive_pages", "from .post import ge...
def generate_archive_pages(app): """ Generate archive pages for all posts, categories, tags, authors, and drafts. """ if not ablog.builder_support(app): return blog = Blog(app) for post in blog.posts: for redirect in post.redirect: yield (redirect, {"redirect": po...
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def strip_trailing_fields_csv(names): """ Strip trailing spaces for field names #456 """
def strip_trailing_fields_csv(names): """ Strip trailing spaces for field names #456 """ field_names = [] for name in names: field_names.append(name.strip()) return field_names
{ "src/attributecode/transform.py": { "import_statements": [ "from attributecode import CRITICAL", "from attributecode import Error", "from attributecode import saneyaml", "from attributecode.util import csv", "from attributecode.util import replace_tab_with_spaces", "import at...
strip_trailing_fields_csv
src/attributecode/transform.py
[ "from attributecode import CRITICAL", "from attributecode import Error", "from attributecode import saneyaml", "from attributecode.util import csv", "from attributecode.util import replace_tab_with_spaces", "import attr", "from collections import Counter", "from collections import OrderedDict", "fro...
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def build_links_package_index(packages_by_package_name, base_url): """ Return an HTML document as string which is a links index of all packages """
def build_links_package_index(packages_by_package_name, base_url): """ Return an HTML document as string which is a links index of all packages """ document = [] header = f"""<!DOCTYPE html> <html> <head> <title>Links for all packages</title> </head> <body>""" document.append(header) ...
{ "etc/scripts/gen_pypi_simple.py": { "import_statements": [ "import re", "from collections import defaultdict", "from html import escape", "from pathlib import Path", "from typing import NamedTuple", "import hashlib", "import os", "import shutil" ], "classe...
build_links_package_index
etc/scripts/gen_pypi_simple.py
[ "import re", "from collections import defaultdict", "from html import escape", "from pathlib import Path", "from typing import NamedTuple", "import hashlib", "import os", "import shutil" ]
def build_pypi_index(directory, base_url="https://thirdparty.aboutcode.org/pypi"): """ Using a ``directory`` directory of wheels and sdists, create the a PyPI simple directory index at ``directory``/simple/ populated with the proper PyPI simple index directory structure crafted using symlinks. WARN...
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def load_json(location): """ Read JSON file at `location` and return a list of ordered dicts, one for each entry. """
def load_json(location): """ Read JSON file at `location` and return a list of ordered dicts, one for each entry. """ with open(location) as json_file: results = json.load(json_file) if not isinstance(results, list): results = [results] return results
{ "src/attributecode/__init__.py": { "import_statements": [ "from collections import namedtuple", "import logging", "import os", "import saneyaml" ], "classes": [ { "name": "Error", "file_path": "src/attributecode/__init__.py", "description": "An Error...
load_json
src/attributecode/util.py
[ "from attributecode import CRITICAL", "from attributecode import Error", "from attributecode import WARNING", "import re", "from collections import OrderedDict", "from distutils.dir_util import copy_tree", "from itertools import zip_longest", "import codecs", "import csv", "import json", "import...
def get_error_messages(errors, verbose=False): """ Return a tuple of (list of error message strings to report, severe_errors_count) given an `errors` list of Error objects and using the `verbose` flags. """ if verbose: severe_errors = errors else: severe_errors = filter_error...
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def is_about_file(path): """ Return True if the path represents a valid ABOUT file name. """
def is_about_file(path): """ Return True if the path represents a valid ABOUT file name. """ if path: path = path.lower() return path.endswith(".about") and path != ".about"
{ "src/attributecode/util.py": { "import_statements": [ "from attributecode import CRITICAL", "from attributecode import Error", "from attributecode import WARNING", "import re", "from collections import OrderedDict", "from distutils.dir_util import copy_tree", "from iter...
is_about_file
src/attributecode/util.py
[ "from attributecode import CRITICAL", "from attributecode import Error", "from attributecode import WARNING", "import re", "from collections import OrderedDict", "from distutils.dir_util import copy_tree", "from itertools import zip_longest", "import codecs", "import csv", "import json", "import...
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def read_json(location): """ Yield rows (as a list of values) from a CSV file at `location`. """
def read_json(location): """ Yield rows (as a list of values) from a CSV file at `location`. """ with open(location, encoding='utf-8', errors='replace') as jsonfile: return json.load(jsonfile)
{ "src/attributecode/__init__.py": { "import_statements": [ "from collections import namedtuple", "import logging", "import os", "import saneyaml" ], "classes": [ { "name": "Error", "file_path": "src/attributecode/__init__.py", "description": "An Error...
read_json
src/attributecode/transform.py
[ "from attributecode import CRITICAL", "from attributecode import Error", "from attributecode import saneyaml", "from attributecode.util import csv", "from attributecode.util import replace_tab_with_spaces", "import attr", "from collections import Counter", "from collections import OrderedDict", "fro...
def transform_json(location): """ Read a JSON file at `location` and convert data into list of dictionaries. """ errors = [] new_data = [] items = read_json(location) data = normalize_dict_data(items) new_data = strip_trailing_fields_json(data) return new_data, errors
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def to_posix(path): """ Return a path using the posix path separator given a path that may contain posix or windows separators, converting "\\" to "/". NB: this path will still be valid in the windows explorer (except for a UNC or share name). It will be a valid path everywhere in Python. It will no...
def to_posix(path): """ Return a path using the posix path separator given a path that may contain posix or windows separators, converting "\\" to "/". NB: this path will still be valid in the windows explorer (except for a UNC or share name). It will be a valid path everywhere in Python. It will no...
{ "src/attributecode/util.py": { "import_statements": [ "from attributecode import CRITICAL", "from attributecode import Error", "from attributecode import WARNING", "import re", "from collections import OrderedDict", "from distutils.dir_util import copy_tree", "from iter...
to_posix
src/attributecode/util.py
[ "from attributecode import CRITICAL", "from attributecode import Error", "from attributecode import WARNING", "import re", "from collections import OrderedDict", "from distutils.dir_util import copy_tree", "from itertools import zip_longest", "import codecs", "import csv", "import json", "import...
[BEGIN OF TASK INSTRUCTION] You are a Python programmer currently working with a repository. Your task is to generate the most suitable implementation of the target function using the provided context. [END OF TASK INSTRUCTION] [BEGIN OF AVAILABLE CONTEXT] Below is all the available context (import statements and cod...
def build_per_package_index(pkg_name, packages, base_url): """ Return an HTML document as string representing the index for a package """
def build_per_package_index(pkg_name, packages, base_url): """ Return an HTML document as string representing the index for a package """ document = [] header = f"""<!DOCTYPE html> <html> <head> <meta name="pypi:repository-version" content="1.0"> <title>Links for {pkg_name}</title> </hea...
{ "etc/scripts/gen_pypi_simple.py": { "import_statements": [ "import re", "from collections import defaultdict", "from html import escape", "from pathlib import Path", "from typing import NamedTuple", "import hashlib", "import os", "import shutil" ], "classe...
build_per_package_index
etc/scripts/gen_pypi_simple.py
[ "import re", "from collections import defaultdict", "from html import escape", "from pathlib import Path", "from typing import NamedTuple", "import hashlib", "import os", "import shutil" ]
def build_pypi_index(directory, base_url="https://thirdparty.aboutcode.org/pypi"): """ Using a ``directory`` directory of wheels and sdists, create the a PyPI simple directory index at ``directory``/simple/ populated with the proper PyPI simple index directory structure crafted using symlinks. WARN...