query stringlengths 9 9.05k | document stringlengths 10 222k | negatives listlengths 19 20 | metadata dict |
|---|---|---|---|
Compute Boolean OR of this matrix and another valid object. | def __or__(self, obj):
return self._boolean_operation(obj, operator.__or__) | [
"def __or__(self, other):\n return BitBoard(self.num | other.num)",
"def logical_or(x1, x2, out=None):\n return _ufunc_helper(x1, x2, _npi.logical_or, _np.logical_or, _npi.logical_or_scalar, None, out)",
"def t_or(self, other):\n if self is TRUE or other is TRUE:\n return TRUE\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Compute Boolean XOR of this matrix and another valid object. | def __xor__(self, obj):
return self._boolean_operation(obj, operator.__xor__) | [
"def __xor__(self, other):\n return _flagOp(xor, self, other)",
"def logical_xor(self, other):\n return self.operation(other, lambda x, y: int(bool(x) ^ bool(y)))",
"def bitwise_xor(self, other):\n return math_funcs.bitwise_xor(self, other)",
"def logical_xor(self, a, b):\n a = _conver... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Add a valid object to this matrix using Boolean XOR. | def __add__(self, obj):
return self ^ obj | [
"def __xor__(self, obj):\n return self._boolean_operation(obj, operator.__xor__)",
"def __xor__(self, other):\n return _flagOp(xor, self, other)",
"def __sub__(self, obj):\n return self ^ obj",
"def add(self, object_, row, column, raise_error=False):\r\n\r\n # all is OK?\r\n\r\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Subtract a valid object from this matrix using Boolean XOR. | def __sub__(self, obj):
return self ^ obj | [
"def __xor__(self, obj):\n return self._boolean_operation(obj, operator.__xor__)",
"def __xor__(self, other):\n return _flagOp(xor, self, other)",
"def bitwise_not_(self):\n return math_funcs.bitwise_not(self, self)",
"def bitwise_xor(self, other):\n return math_funcs.bitwise_xor(self, oth... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Add a valid object to this matrix and return the result. Doesn't modify the current matrix. Valid objects include other matrices and numeric scalars | def __add__(self, obj):
if isinstance(obj, Matrix):
if self.m != obj.m or self.n != obj.n:
raise exc.ComformabilityError(
"matrices must have the same dimensions")
if type(self) is not type(obj):
raise TypeError("matrices must be th... | [
"def __add__(self, obj):\n if isinstance(obj, Vector):\n if self.m != obj.m:\n raise exc.ComformabilityError(\n \"vectors must have the same length\")\n data = [self[i] + obj[i] for i in range(self.m)]\n elif Vector.is_numeric(obj):\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Subtract a valid object from this matrix and return the result. Doesn't modify the current matrix. Valid objects include other matrices and numeric scalars | def __sub__(self, obj):
if isinstance(obj, Matrix):
if self.m != obj.m or self.n != obj.n:
raise exc.ComformabilityError(
"matrices must have the same dimensions")
if type(self) is not type(obj):
raise TypeError(
... | [
"def __sub__(self, obj):\n if isinstance(obj, Vector):\n if self.m != obj.m:\n raise exc.ComformabilityError(\n \"vectors must have the same length\")\n data = [self[i] - obj[i] for i in range(self.m)]\n elif Vector.is_numeric(obj):\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Multiply this matrix by a valid object and return the result. Doesn't modify the current matrix. Valid objects include other matrices vectors, and numeric scalars. In the case where the other object is a matrix, multiplication occurs with the current matrix on the lefthand side. | def __mul__(self, obj):
if isinstance(obj, Matrix):
if self.n != obj.m:
raise exc.ComformabilityError(
"inner matrix dimensions must match")
if type(self) is not type(obj):
raise TypeError(
"matrices must be ... | [
"def __mul__(self, other):\n\t\tif self.is_scalar_element(other):\n\t\t\treturn self.scalar_multiply(other)\n\t\tif not isinstance(other, Matrix):\n\t\t\traise TypeError(\"Cannot multiply matrix and type %s\" % type(other))\n\t\tif other.is_row_vector():\n\t\t\traise Matrix_Multiplication_Error(self, other)\n\t\tre... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Calculate the Hadamard product of two matrices. | def hadamard(A, B):
if not all(isinstance(M, IntegerMatrix) for M in (A, B)):
raise TypeError("can only Hadamard two matrices")
if type(A) is not type(B):
raise TypeError(
"matrices must be the same type")
if A.m != B.m or A.n != B.n:
raise... | [
"def ham_product(q1, q2):\n prod = np.empty(4)\n prod[0] = q1[0]*q2[0] - q1[1]*q2[1] - q1[2]*q2[2] - q1[3]*q2[3]\n prod[1] = q1[0]*q2[1] + q1[1]*q2[0] + q1[2]*q2[3] - q1[3]*q2[2]\n prod[2] = q1[0]*q2[2] - q1[1]*q2[3] + q1[2]*q2[0] + q1[3]*q2[1]\n prod[3] = q1[0]*q2[3] + q1[1]*q2[2] - q1[2]*q2[1] + q1... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Make a zero matrix of dimension m by n. | def makeZero(m, n):
Matrix.validate_dimensions(m, n)
data = [[0 for j in range(n)] for i in range(m)]
return IntegerMatrix(m, n, data) | [
"def makeZero(m, n):\n Matrix.validate_dimensions(m, n)\n data = [[0. for j in range(n)] for i in range(m)]\n return RealMatrix(m, n, data)",
"def zeros(m, n):\n data = dict.fromkeys(itertools.product(range(m), range(n)), mpfr(0))\n return MPMatrix((m, n), data)",
"def make_matrix(n, ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Make an identity matrix of dimension m by m. | def makeIdentity(m):
Matrix.validate_dimensions(m, m)
data = [[1 if i == j else 0 for j in range(m)] for i in range(m)]
return IntegerMatrix(m, m, data) | [
"def identity_matrix():\r\n return numpy.identity(4)",
"def identity_matrix():\n return numpy.identity(4)",
"def identity_matrix(n):\n data = [[1 if c == r else 0 for c in range(n)] for r in range(n)]\n return Matrix(data)",
"def identity_matrix(batch_size, device, dtype):\n return torch.eye(4,... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Make a zero matrix of dimension m by n. | def makeZero(m, n):
Matrix.validate_dimensions(m, n)
data = [[0. for j in range(n)] for i in range(m)]
return RealMatrix(m, n, data) | [
"def makeZero(m, n):\n Matrix.validate_dimensions(m, n)\n data = [[0 for j in range(n)] for i in range(m)]\n return IntegerMatrix(m, n, data)",
"def zeros(m, n):\n data = dict.fromkeys(itertools.product(range(m), range(n)), mpfr(0))\n return MPMatrix((m, n), data)",
"def make_matrix(n... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Create and return a new `Tweet` instance, given the validated data. | def create(self, validated_data):
return Tweet.objects.create(**validated_data) | [
"def __init__(self, raw_text):\n def parse_tweet(text):\n \"\"\"Return Tweet object for raw tweet string.\"\"\"\n import json\n tweet_json = json.loads(text)\n created_at = tweet_json['created_at']\n hashtags = []\n if 'hashtags' in tweet_json... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Sort the stack, with the smallest item at the top, using only one other stack as a temporary buffer. Each element is popped from the stack, and placed on the temporary stack in reverse order (with largest at the top). We can put it in the correct order by using the original stack as a further temporary buffer. | def sort_stack(self, stack):
temp_stack = []
while stack:
elem = stack.pop()
while temp_stack and temp_stack[-1] > elem:
# Move items off of temp stack to allow us to place
# elem in the correct location (in reverse order)
stack.ap... | [
"def sortStack(stack):\n dest = []\n while len(stack) != 0:\n tmp = stack.pop()\n while (len(dest) != 0 and dest[-1] > tmp):\n stack.append(dest.pop())\n dest.append(tmp)\n \n return dest",
"def sort_stack_by_stack(stack):\n help = Stack()\n while not stac... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Create a RegionsSelector model from JSON files. | def from_json(cls, regions_mask, wcs_info, wcs_regions=None, dist_info=None, spec_info=None):
transforms = []
# read in primary WCS and update wcs_relative with it.?
# read in dist_info and create scomp
# assign it to rid
labels = cls.labels_from_mask(regions_mask)
sky_w... | [
"def load(file):\n\n import json\n import importlib\n\n f = open(file, 'r')\n input = json.loads(f.read())\n\n # import the appropriate transformation class\n regMethod = str(input['regMethod'])\n className = str(input['transClass'])\n transClass = getattr(imp... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
returns a hypersphere of the same dimension as the collection of input tuples (radius, (center)) Methods available for fitting are "algebraic" fitting methods Hyper AlSharadqah and Chernov's Hyperfit algorithm Pratt Vaughn Pratt's algorithm Taubin G. Taubin's algorithm The following methods, though very similar, are no... | def fit_hypersphere(data, method="Hyper"):
num_points = len(data)
# print >>stderr, "DEBUG: num_points=", num_points
if num_points==0:
return (0,None)
if num_points==1:
return (0,data[0])
dimen = len(data[0]) # dimensionality of hypersphere
# print >>stderr, "DEBUG: dim... | [
"def Icosphere(radius=1.0, center=(0.0, 0.0, 0.0), nsub=3):\n mesh = Icosahedron()\n mesh.clear_data()\n mesh = mesh.subdivide(nsub=nsub)\n\n # scale to desired radius and translate origin\n dist = np.linalg.norm(mesh.points, axis=1, keepdims=True) # distance from origin\n mesh.points = mesh.poin... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Test case for adding_criteria_to_segments Adding criteria to segments | def test_adding_criteria_to_segments(self):
pass | [
"def test_updating_segment_criteria(self):\n pass",
"def test_add_segment_bind(self):\n pass",
"def test_getting_segments(self):\n pass",
"def test_creating_a_new_segment(self):\n pass",
"def add_subsegment(self, subsegment: Any):",
"def add_segments(self, *segments):\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Test case for creating_a_new_segment Creating a new segment | def test_creating_a_new_segment(self):
pass | [
"def create_segment_object():\n return Segment()",
"def new_segment(**kwargs):\n sessiontoken = kwargs['sessiontoken']\n proxy = kwargs['proxy']\n if kwargs['objectname'] is None or kwargs['gateway'] is None:\n print(\"Please specify a name for the segment, and the gateway/network.\")\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Test case for deleting_a_segment Deleting A Segment | def test_deleting_a_segment(self):
pass | [
"def test_delete_segment_bind(self):\n pass",
"def test_delete_user_segment(self):\n pass",
"def test_delete_image_segment(self):\n pass",
"def failover_segment_delete(context, segment_uuid):\n return IMPL.failover_segment_delete(context, segment_uuid)",
"def test_creating_a_new_segm... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Test case for getting_segment_details Getting segment details | def test_getting_segment_details(self):
pass | [
"def test_getting_segments(self):\n pass",
"def test_get_user_segment(self):\n pass",
"def test_get_segment_bind(self):\n pass",
"def fetch(self, segment):\n pass",
"def test_creating_a_new_segment(self):\n pass",
"def test_get_image_segment(self):\n pass",
"def... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Test case for getting_segment_subscribers Getting segment subscribers | def test_getting_segment_subscribers(self):
pass | [
"def test_get_subscriptions(self):\n pass",
"def test_json_get_subscribers(self) -> None:\n stream_name = gather_subscriptions(self.user_profile)[0][0][\"name\"]\n stream_id = get_stream(stream_name, self.user_profile.realm).id\n expected_subscribers = gather_subscriptions(self.user_pr... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Test case for getting_segments Getting segments | def test_getting_segments(self):
pass | [
"def test_getting_segment_details(self):\n pass",
"def test_get_user_segments(self):\n pass",
"def getSegments(self) -> List[int]:\n ...",
"def getseg(*args):\n return _ida_segment.getseg(*args)",
"def test_seg(self):\n k, v = self.sch.parse_seg('6 5')\n self.assertEqual(... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Test case for updating_a_segment Updating a segment | def test_updating_a_segment(self):
pass | [
"def test_updating_segment_criteria(self):\n pass",
"def test_update_segment_bind(self):\n pass",
"def test_update_image_segment(self):\n pass",
"def test_deleting_a_segment(self):\n pass",
"def __test_all_segments_with_updates(self, arr, fnc, upd):\n segment_tree = Segmen... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Test case for updating_segment_criteria Updating segment criteria | def test_updating_segment_criteria(self):
pass | [
"def test_updating_a_segment(self):\n pass",
"def test_adding_criteria_to_segments(self):\n pass",
"def test_update_segment_bind(self):\n pass",
"def __test_all_segments_with_updates(self, arr, fnc, upd):\n segment_tree = SegmentTree(arr, fnc)\n for index, value in upd.items... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return a RandomState instance. This function exists solely to assist (un)pickling. Note that the state of the RandomState returned here is irrelevant, as this function's entire purpose is to return a newly allocated RandomState whose state pickle can set. Consequently the RandomState returned by this function is a fres... | def __RandomState_ctor():
return RandomState(seed=0) | [
"def _get_random_state(self):\n self._validate_random_state()\n return deepcopy(self.random_state)",
"def _RandomState(seed, level=1):\n if seed is None:\n return np.random.RandomState()\n else:\n return np.random.RandomState((seed, level))",
"def random_state(self):\n r... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns packages version and system architecture from names of directories from rpm directory. | def get_package_version_and_system_architecture():
rpm_directory = path.join(PMDK_PATH, 'rpm')
global PMDK_VERSION
global SYSTEM_ARCHITECTURE
for elem in listdir(rpm_directory):
if '.src.rpm' in elem:
# looks for the version number of rpm package in rpm package name
PMDK_... | [
"def infer_arch_directory(rpm_binary):\n name = rpm_binary.lower()\n if name.endswith('src.rpm'):\n return 'SRPMS'\n elif name.endswith('x86_64.rpm'):\n return 'x86_64'\n elif 'noarch' in name.lower():\n return 'noarch'\n return 'noarch'",
"def get_libraries_names():\n rpm_p... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns names of elements, for which are installed packages from PMDK library. | def get_libraries_names():
rpm_packages_path = path.join(PMDK_PATH, 'rpm', SYSTEM_ARCHITECTURE)
libraries_names = [elem.split('-')[0] for elem in listdir(rpm_packages_path)
if PMDK_VERSION in elem]
return set(libraries_names) | [
"def _get_installed_package_names():\n specs = spack.environment.installed_specs()\n return [spec.name for spec in specs]",
"def package_names(self) -> List[str]:\n return [p.name() for p in self.pkgs]",
"def get_package_list(self):\r\n val = []\r\n for pp in (self.packagelist):\r\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns names of rpm packages from PMDK library, which are not installed. | def get_not_installed_rpm_packages():
def is_installed(elem):
return elem in PMDK_TOOLS and elem in listdir('/usr/bin/') or\
elem == "pmdk" or elem + '.so' in listdir('/usr/lib64/')
elements = get_libraries_names()
not_installed_packages = []
for elem in elements:
if not is_... | [
"def get_libraries_names():\n rpm_packages_path = path.join(PMDK_PATH, 'rpm', SYSTEM_ARCHITECTURE)\n libraries_names = [elem.split('-')[0] for elem in listdir(rpm_packages_path)\n if PMDK_VERSION in elem]\n return set(libraries_names)",
"def get_incompatible_packages():\n pkgconf... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns names of rpm packages from PMDK library, which are not compatible with the current version of PMDK library. | def get_incompatible_packages():
pkgconfig_directory = '/usr/lib64/pkgconfig/'
incompatibe_packages = []
libraries = get_libraries_names() - set(NO_PKG_CONFIGS)
for library in libraries:
with open(pkgconfig_directory + library + '.pc') as f:
out = f.readlines()
for line in ou... | [
"def get_not_installed_rpm_packages():\n def is_installed(elem):\n return elem in PMDK_TOOLS and elem in listdir('/usr/bin/') or\\\n elem == \"pmdk\" or elem + '.so' in listdir('/usr/lib64/')\n\n elements = get_libraries_names()\n not_installed_packages = []\n for elem in elements:\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Checks if the version of installed rpm packages is correct. | def test_compatibility_of_version_of_installed_rpm_packages(self):
incompatible_packages = get_incompatible_packages()
error_msg = linesep + 'List of incompatible packages: '
for package in incompatible_packages:
error_msg += linesep + package
self.assertFalse(incompatible_pa... | [
"def _checkUpdateNeeded(self):\n try:\n currentVersionLine = str(subprocess.run(['pacman', '-Q', '-i', self._name],\n stdout=subprocess.PIPE, stderr=subprocess.STDOUT, check=True).stdout)\n currentVersion = re.sub(r'.*Version\\s*: ([\\d|\\.]*)-.*'... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
deterimines chunks to extract based on label_file, which is a csv file with "start" and "stop" collumns with units in seconds | def get_segments(label_file, window=5):
labels = pd.read_csv(label_file).sort_values('start').reset_index(
drop=True)
wlabels = labels.copy()
wlabels.start -= window
wlabels.stop += window
# union segments
b = []
for x in wlabels.itertuples():
if len(b) == 0:
b.ap... | [
"def loadLabels(start, stop, csvFile):\n return csvFile[start:stop]",
"def splitFeatureToPartsBasedOn112record(self,testSampleFilename, stepSize=4, groupSize=28):\n testsetDF=pd.read_csv(testSampleFilename)\n testsetDF=testsetDF.drop_duplicates(['content'])\n testsetDF.reset_index()\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
This function should be called if one of the Plan objects throws an Exception. It takes the PlanMap argument and calls the getNextAbort function just like executePlans does with todoPlans. This dynamically generates an abort plan list based on what plans were originally executed. | def abortPlans(update):
out.header('Aborting plans %r\n' % (update.plans))
sameError = False
while(True):
# This function either returns None or a tuple just like generate added to it
p = update.plans.getNextAbort()
# No more to do?
if(not p):
break
# Ex... | [
"def cancel_plan(self):\n for asv in self.asvs:\n asv._cancel_action = True",
"def ActivateAbortOnSubprojectAbort(self):\n callResult = self._Call(\"ActivateAbortOnSubprojectAbort\", )",
"def check_open_close(plan: Iterator[Any]) -> None:\n open_stack = []\n run_keys = []\n sta... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns an individual's birth date, or if that's unknown, 0. | def birth_date_or_min_year(individual):
year = fuzzy_date_year(individual.birth_date)
if year:
return year
return 0 | [
"def display_birth_date(self, individual):\n\n event = individual.events['birth_or_christening']\n if event:\n if event['precision'] == 'dmy':\n return event['date'].date().strftime('%d.%m.%Y')\n elif event['precision'] == 'my':\n return event['date'... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns a partnership's married date, or if that's unknown, 0. | def married_date_or_min_year(partnership):
year = fuzzy_date_year(partnership.married_date)
if year:
return year
return 0 | [
"def display_marriage_date(self, family):\n\n event = family.marriage\n if event['precision'] == 'dmy':\n return event['date'].date().strftime('%d.%m.%Y')\n elif event['precision'] == 'my':\n return event['date'].date().strftime('%m.%Y')\n else:\n return ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
return a string representation of the cell located at x,y. | def getCellStr(self, x, y): # TODO: refactor regarding issue #11
c = self.board.getCell(x, y)
if c == 0:
return '.' if self.__azmode else ' .'
elif self.__azmode:
az = {}
for i in range(1, int(math.log(self.board.goal(), 2))):
az[2 ** i] = ... | [
"def cells_to_str(self, row, col):\n mark = self.cells[row][col]\n if mark:\n return \" \" + mark + \" \"\n else:\n return str(row) + \",\" + str(col)",
"def to_string(self):\n return str(self.x) + ',' + str(self.y)",
"def __str__(self):\n\t\treturn \"{}, x:{}, y:{}... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Custom template tag to determine if a user likes a post or not | def post_liker(a, args):
if args.likes.filter(user=a).exists():
exists = True
else:
exists = False
return exists | [
"def check_user_liked(cls, user, post):\n likes = Like.gql(\"WHERE author = :1 AND post = :2\", user.key(),\n post.key())\n return likes.count()",
"def is_liked_post(self, urlsafe_postkey, dislike=False):\n if dislike:\n if str(urlsafe_postkey) in self.disli... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Metoda koja vraca negirani literal. Vraca ~L. | def get_negative(self):
return Literal(self.label, not self.positive_state) | [
"def negate(self):\n self.formula = '!(' + self.formula + ')'",
"def negate(p):\n return not p",
"def neg_expr(self, size, value, flags = None):\n\t\treturn self.expr(core.LLIL_NEG, value.index, size = size, flags = flags)",
"def neg(self, a):\n return -a",
"def negate(value):\n return -... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
returns True/False if the programming language is dynamically typed or not | def is_dynamic(self):
if self.typing == "Dynamic":
return True
else:
return False | [
"def is_dynamic(platform):\n return platforms[platform][DYNAMICALLY_TYPED]",
"def is_dynamic(self):\n return self.typing == \"Dynamic\"",
"def is_python(self):\n return self.lang == \"python\"",
"def exist(cls, interpreter: str) -> bool:\n if interpreter.lower() in tuple(e.value.lower(... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Format used the platform api url | def _format_api_url(self, url):
user_name = self._get_user_name()
# format and return url
return url.format(
user_name = user_name,
element = urllib.quote(self.qnet_element.encode('utf-8'), safe=''),
token = self._md5("%s:%s:%s" % (user_name, self.iteration_id... | [
"def api_url(url_base):\n return f\"{url_base}/api/v2\"",
"def format_url(url):\n #split the url into parts and get only url after /v1/\n parts = url.split('/v1/')\n url_path = parts[1]\n url_without_api_key = re.sub(\".api_key=.*?&\", '', url_path.lower())\n #remove special characters from th... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Hash input using md5 | def _md5(input):
m = hashlib.md5()
m.update(input)
return m.hexdigest() | [
"def __hash_md5__(self, text):\n key = hashlib.md5()\n key.update(text.encode('utf-8'))\n return key.digest()",
"def hash_md5(text):\n key = hashlib.md5()\n key.update(text.encode('utf-8'))\n return key",
"def md5_digest(input_string):\r\n md5 = hashlib.md5()\r\n md5.update(i... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Comment field of the Hosted Zone. | def comment(self) -> str:
return pulumi.get(self, "comment") | [
"def update_hosted_zone_comment(self, Id: str, Comment: str = None) -> Dict:\n pass",
"def comment(self):\n return self._comment",
"def comment(self):\n\t\treturn self.comment_",
"def comment(self) -> str:\n return self._comment",
"def getPostComment(self, address: ghidra.program.model.... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
The number of Record Set in the Hosted Zone. | def resource_record_set_count(self) -> int:
return pulumi.get(self, "resource_record_set_count") | [
"def get_hosted_zone_count(self) -> Dict:\n pass",
"def host_count(self) -> list:\n return self.__host_count",
"def number_of_record_sets(self) -> Optional[int]:\n return pulumi.get(self, \"number_of_record_sets\")",
"def recordingsCount(self):\n return self._recordings_count",
"... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Method to check if the server is online. | def check_status(self):
try:
self.server.ping()
return True
except Exception as e:
return False | [
"def is_online(self):\n return self.get_system_status().upper() != \"NOT CONNECTED\"",
"def is_online(self):\n online = False\n if ((self._logintime is not None) and (self._deviceid is not None)):\n online = True\n\n return online",
"def is_online():\n s = socket.socket(socket.AF_INE... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Method to get the current number of online players on the server. | def get_players(self):
return self.server.status().players.online | [
"def get_num_players(self):\n return self.num_players",
"def countPlayers():\n conn = connect()\n cur = conn.cursor()\n cur.execute(\"SELECT COUNT(*) FROM players\")\n players = int(cur.fetchone()[0])\n conn.close()\n return players",
"def online_count(self):\n return self._onlin... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Method to get the names of the online players on the server. | def get_player_names(self):
names = [user['name'] for user in self.server.status().raw['players']['sample']]
return names | [
"def get_players(self):\n return self.server.status().players.online",
"def get(self):\n all_players = _get_all_players()\n return [p.name for p in all_players]",
"def getplayerlist(self):\n return self.referee.players.values()",
"def _get_connected_player_list(self):\r\n if not zpg... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Gets the saved coordinates from json file. | def load_coords(self):
file = open(self.coords_file, 'r')
return file.readlines() | [
"def _load_coordinates_dict(self):\n with open('../resources/dicts/framename_coords_dict.json', 'r') as dict_json:\n self._framename_coords_dict = json.load(dict_json)",
"def load_coords(self):\n # load json file that contains dictionary with ad IDs and coordinates\n cdrs = json_lo... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Checks if coordinates json file was already created. | def check_coords_file(self):
if path.exists(self.coords_file):
return True
return False | [
"def json_exist(self):\n task_path = self.job_info._task_json_path\n asset_path = self.job_info._asset_json_path\n tips_path = self.job_info._tips_json_path\n\n for p in [task_path, asset_path, tips_path]:\n if not os.path.exists(p):\n msg = \"Json file is not g... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
clinvar_path_count is a df, the return value of data_for_lollipop | def plot_lollipop(clinvar_path_count):
os.chdir("/Users/Files/nogit/generisk/lollipop/figure")
app = '/Users/files/work/bin/lollipops'
for i in x.itertuples(False, None):
# uid, variants, gn
os.system("%s -domain-labels=fit -U %s -o %s.svg %s" % (app, i[0], i[2], i[1]))
# os.syste... | [
"def counter(data, location):\n\n df = pd.DataFrame(data)\n df.columns = ['Path']\n df['Category'] = df['Sub-Category'] = ''\n\n # Split in categories and sub-categories\n for i in range(len(df)):\n tmp_categories = df['Path'][i].split(location)[1].split(\"\\\\\")[1:3]\n df['Category'].... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
remove uma palavra da tabela, se existir (se não existir retorna falso, verdadeiro caso contrário) | def remove(self, palavra):
pos = self.buscaPos(palavra)
if pos == -1:
# palavra não existe na tabela
return False
else:
# marca a "exclusão" da palavra
self.lista[pos] = 0
return True | [
"def eliminarAlumno(self, alumno):",
"def remove(i):\n assert(i.p in itables)\n t = itables[i.p]\n assert(i.n in t.mapping)\n print(\"Removing child i:{} from table mapping\".format(i))\n del t.mapping[i.n]\n t.save()",
"def remove_table():\n identifier = request.args.get('identifier', '')\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
retorna tupla com a palavra e seus termos ou None se não encontrar | def busca(self, palavra):
pos = self.buscaPos(palavra)
if pos == -1:
return None
else:
return self.lista[pos] | [
"def search_node(self, node_tup):\n #signature = hashlib.sha1(node_tup[0]+node_tup[4])\n app_process = sqlite3.connect('app_process::memory:', check_same_thread=False)\n app_process_cursor = app_process.cursor()\n out = app_process_cursor.execute(\"SELECT FROM nodes WHERE uname==(:uname)... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
retorna a posição da palavra ou 1 caso não faça parte da tabela | def buscaPos(self, palavra):
chave = self.funcao_hash(palavra)
i = 1
while (self.lista[chave] != 0 and i < self.tamanho):
if self.lista[chave][0] == palavra:
# encontrou
return chave
else:
# tratamento de colisão (sondagem q... | [
"def eh_posicao_livre(tab, pos): \r\n if not eh_tabuleiro(tab) or not eh_posicao(pos):\r\n raise ValueError('eh_posicao_livre: algum dos argumentos e invalido') \r\n else:\r\n if pos < 4:\r\n return tab[0][pos-1] == 0\r\n elif pos < 7:\r\n return tab[1][pos-4]... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Verify that the widget can be constructed via CustomWidgetFactory (Issue 293) | def test_customWidgetFactory(self):
value_type = TextLine(__name__='bar')
self.field = List(__name__='foo', value_type=value_type)
request = TestRequest()
# set up the custom widget factory and verify that it works
sw = CustomWidgetFactory(ListSequenceWidget)
widget = s... | [
"def create_widget(self):\n raise NotImplementedError",
"def init_widget(self):\n raise NotImplementedError",
"def _check_registered_widget(self, *args, **kwargs):\n\n # Update the defaults from the kwargs\n new_kwargs = self.supports.copy()\n new_kwargs.update(kwargs)\n\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
This test verifies that the specified subwidget is not ignored. (Issue 293) | def test_subwidget(self):
self.field = List(__name__='foo',
value_type=TextLine(__name__='bar'))
request = TestRequest()
class PollOption:
pass
ow = CustomWidgetFactory(ObjectWidget, PollOption)
widget = SequenceWidget(
self.fiel... | [
"def test_get_widgets_hastraits_custom_view(self):\n for test_trait in self.test_traits:\n with self.subTest(type(test_trait)):\n widget = self.get_widget_from_custom_view_definition_has_traits(test_trait)\n self.assertIsInstance(widget,self.widget)\n s... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Test the get_album_tracks_lastfm function. | def test_album_tracks_lastfm(monkeypatch, bot):
song = Song('Sabaton', '1 6 4 8')
with monkeypatch.context() as mkp:
# An empty list should be returned if we can't find the album's name
mkp.setattr(song, 'fetch_album_name', lambda: None)
assert bot.get_album_tracks_lastfm(song) == []
... | [
"def test_album_tracks_lastfm_notfound(bot, monkeypatch):\n\n def get_lastfm(*args, **kwargs):\n return []\n\n song = Song('Horrendous', 'The Idolater', album='Idol')\n monkeypatch.setattr(bot, 'get_lastfm', get_lastfm)\n assert bot.get_album_tracks_lastfm(song) == []",
"def test_get_songs_by_a... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Test get_album_tracks_lastfm when the album isn't found in the lastfm database. | def test_album_tracks_lastfm_notfound(bot, monkeypatch):
def get_lastfm(*args, **kwargs):
return []
song = Song('Horrendous', 'The Idolater', album='Idol')
monkeypatch.setattr(bot, 'get_lastfm', get_lastfm)
assert bot.get_album_tracks_lastfm(song) == [] | [
"def test_album_tracks_lastfm(monkeypatch, bot):\n song = Song('Sabaton', '1 6 4 8')\n with monkeypatch.context() as mkp:\n # An empty list should be returned if we can't find the album's name\n mkp.setattr(song, 'fetch_album_name', lambda: None)\n assert bot.get_album_tracks_lastfm(song)... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Test get the next song when there is no "last result". | def test_next_song_no_last(bot):
assert bot._get_next_song(1) == "You haven't searched for anything yet" | [
"def nextSong(self) :\n if len(self.queued) > 0 :\n self.queued = self.queued[1:] # remove first element of queue\n self.index += 1 # for if the queue becomes empty\n elif len(self.list) > 0 and self.index < len(self.list) and (not self.loop or self.index + 1 != len(self.list)) :... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Test get the last song when a database error is thrown. | def test_next_song_dberror(bot):
bot.DB.get_last_res = raise_sqlite_error
assert bot._get_next_song(1).startswith('There was an error while') | [
"def test_next_song_no_last(bot):\n assert bot._get_next_song(1) == \"You haven't searched for anything yet\"",
"def test_get_last_log_error(self):\n\n with self.assertRaises(NoRowsError):\n self.db.get_last_log(1)",
"def test_get_song_from_string_lastres(bot):\n chat_id = 'chat_id'\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Test the next_song function, in a similar manner to _get_next_song. | def test_next_song(monkeypatch, bot, bot_arg, update):
tracks = [fake_res['title'], 'crop killer']
song_next = Song(fake_res['artist'], 'crop killer', fake_res['album'])
bot.log_result('chat_id', fake_log)
monkeypatch.setattr(bot, 'get_album_tracks', lambda x: tracks)
monkeypatch.setattr(bot, 'get_l... | [
"def test_next_song_no_last(bot):\n assert bot._get_next_song(1) == \"You haven't searched for anything yet\"",
"def toggnext(self):\r\n self.bot.loop.call_soon_threadsafe(self.playnextsong.set)",
"def nextSong(self) :\n if len(self.queued) > 0 :\n self.queued = self.queued[1:] # rem... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Test the 'other' function when there is no last result. | def test_other_no_lastres(bot, bot_arg, update):
other(bot_arg, update)
expect = "You haven't searched for anything yet"
assert bot_arg.msg_log[0] == expect | [
"def test_original_failure_no_result(self):\n dr = EventualResult(Deferred(), None)\n self.assertIdentical(dr.original_failure(), None)",
"def test_other_no_sources(monkeypatch, bot, bot_arg, update):\n monkeypatch.setattr(fake_log, 'source', lyricfetch.sources[-1])\n bot.log_result('chat_id',... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Test the 'other' function when a database error is thrown. | def test_other_dberror(monkeypatch, bot, bot_arg, update):
monkeypatch.setattr(bot.DB, 'get_last_res', raise_sqlite_error)
other(bot_arg, update)
expect = "There was an error"
assert bot_arg.msg_log[0].startswith(expect) | [
"def test_database_error(self):\n self.mocked_cursor.execute.side_effect = psycopg2.Error('testing')\n\n db = database.Database()\n\n with self.assertRaises(database.DatabaseError):\n db.execute(sql=\"SELECT * from FOO WHERE bar LIKE 'baz'\")",
"def test_operational_error_asis(self... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Test the 'other' function when there are no sources left to search. | def test_other_no_sources(monkeypatch, bot, bot_arg, update):
monkeypatch.setattr(fake_log, 'source', lyricfetch.sources[-1])
bot.log_result('chat_id', fake_log)
other(bot_arg, update)
assert 'No other sources' in bot_arg.msg_log[0] | [
"def test_no_sources(self):\r\n cmd = self.run(self.job(sources=None), [])\r\n assert cmd.backend.match([])",
"def _exhaust_sources(self):\n return self._exhaust_sinks(False)",
"def test_missing_data_sources(self):",
"def test_sources_not_ok_on_connection_error(self):\n measurement... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Test get a song from string when there is no hyphen and we must get the last result from the database. | def test_get_song_from_string_lastres(bot):
chat_id = 'chat_id'
assert bot.get_song_from_string('', chat_id) is None
song = Song(fake_res['artist'], 'the spectral burrows')
bot.log_result(chat_id, fake_log)
assert get_song_from_string('the spectral burrows', chat_id) == song | [
"def test_next_song_no_last(bot):\n assert bot._get_next_song(1) == \"You haven't searched for anything yet\"",
"def get_genius_song(song_name, artist_name, genius):\n song_search = song_name\n for i in range(0, 2):\n song = genius.search_song(song_search, artist_name)\n if isinstance(song,... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Call get_lyrics with an invalid song string. | def test_get_lyrics_invalid_format(bot):
assert get_lyrics('asdf', 1) == 'Invalid format!' | [
"def test_get_lyrics_notfound(monkeypatch, bot):\n\n def assert_not_found(msg):\n msg = get_lyrics(song, 1)\n msg = msg.lower()\n assert song.artist in msg\n assert song.title in msg\n assert 'could not be found' in msg\n\n song = Song('nothing more', 'christ copyright')\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Test get_lyrics when no lyrics are found. | def test_get_lyrics_notfound(monkeypatch, bot):
def assert_not_found(msg):
msg = get_lyrics(song, 1)
msg = msg.lower()
assert song.artist in msg
assert song.title in msg
assert 'could not be found' in msg
song = Song('nothing more', 'christ copyright')
result = Noth... | [
"def test_metrolyrics(self):\n bad_res = lw.get_lyrics('metrolyrics', 'eminem', 'los yourself')\n good_res = lw.get_lyrics('metrolyrics', 'eminem', 'lose yourself')\n self.assertEqual(bad_res, 404)\n self.assertTrue(good_res)",
"def fetch_lyrics(self) -> None:\n if self.artist i... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Test the 'unknown' function. | def test_unknown(bot_arg, update):
unknown(bot_arg, update)
assert "didn't understand that" in bot_arg.msg_log[0] | [
"def test_unknown_action(self):\n self.assertFalse(self.animal.do_something(action=\"play\"))\n self.assertFalse(self.animal.do_something(action=\"jump\"))\n self.assertFalse(self.animal.do_something(action=\"think\"))",
"def is_unknown(cls):\n return True",
"def is_unknown(self, pat... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Test sending a message that is longer than the maximum allowed by telegram. | def test_send_message_not_fitting(bot_arg, monkeypatch):
monkeypatch.setattr(telegram.constants, 'MAX_MESSAGE_LENGTH', 5)
msg = 'helloworld'
send_message(msg, bot_arg, 1)
assert bot_arg.msg_log[0] == 'hello'
assert bot_arg.msg_log[1] == 'world' | [
"def test_long_message(self):\n message = \"few characters\"\n message_displayed = truncate_message(message, limit=5)\n\n self.assertLessEqual(len(message_displayed), 5)\n self.assertEqual(message_displayed, \"fe...\")",
"def test_small_message(self):\n message = \"few character... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Flush the cache, keeping the .gitkeep file | def clear_cache():
path = join("data", "cache")
file_list = os.listdir(path)
file_list.remove(".gitkeep") # Exclude .gitkeep
for filename in file_list:
os.remove(join(path, filename)) | [
"def flush():\n for k in cache._thecache.keys():\n del cache._thecache[k]",
"def flush_history(self):\n shred_dir(os_join(self.directory, '.git'))\n self.git.init()\n self.git.add([self.encrypted_dir, '.gitignore'])\n self.git.commit('Clean git History')",
"def clear(self, ca... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return whether we are performing a forcedrun execution. This setting is configured in each deployment by the absence or the value of the environment variable. By default, the variable is undefined. As a consequence, execution is NOT a forcedrun. If the variable is defined in the deployment with an appropriate value, th... | def is_forced_run(self):
try:
v = environment.get("Run")
return v.lower() == "force"
except KeyError:
return False | [
"def force_deploy(self):\n try:\n return self.__meta_data__.get(\"global\").get(\"force_deploy\")\n except:\n return False",
"def is_dry_run(self):\n # Set this value to true if you want the entire operation to run, but not the ingestion.\n return os.environ.get('... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return quick run file size limit, if any. This setting is configured in each deployment by the absence or the value of the environment variable. By default, the variable is undefined. As a consequence, execution is NOT limited to a quick run. If the variable is defined in the deployment with an appropriate value, then ... | def quick_run_limit(self):
try:
return int(environment.get("Quick"))
except KeyError:
return maxsize | [
"def get_max_file_size(organization):\n if features.has('organizations:large-debug-files', organization):\n return MAX_FILE_SIZE\n else:\n return options.get('system.maximum-file-size')",
"def bytes_limit_per_file(self) -> Optional[float]:\n return pulumi.get(self, \"bytes_limit_per_fil... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return disk space to reserve in bytes. In the absence of a defined value for the environment variable, we use the maximum integer value as a default. | def reserved_disk_space_in_bytes(self):
try:
return int(environment.get("ReservedDiskSpaceInBytes"))
except KeyError:
return maxsize | [
"def os_disk_size_gb(self) -> Optional[pulumi.Input[int]]:\n return pulumi.get(self, \"os_disk_size_gb\")",
"def get_disk_space():\n try:\n return shutil.disk_usage('/')\n except FileNotFoundError:\n logging.error(\n 'Failed to locate OS partition. Could not determine disk size.')",
"def d... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Return whether we should fake the data processing during execution. This setting is configured in each deployment by the absence or presence of the environment variable. By default, the variable is undefined. As a consequence, execution performs real data processing. If the variable is defined in the deployment, then d... | def should_fake_it(self):
try:
environment.get("FakeIt")
return True
except KeyError:
return False | [
"def is_testing() -> bool:\n return bool(int(os.environ.get(\"TEST\", 0)))",
"def _set(env_var: str) -> bool:\n return os.getenv(env_var) not in [None, \"0\"]",
"def in_runtime(self):\n\n return self.is_valid_platform() and self['ENVIRONMENT']",
"def is_runtime_phase():\n return os.getenv('FAI... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Process dynamic (version, buildNumber, etc.) variables in configsToBump, then append overrides files to both configsToBump and configsToOverride. | def bump(repo, configsToBump, configsToOverride):
# First pass. Bump variables in configsToBump.
configs = ['%s/%s' % (repo, x) for x in configsToBump.keys()]
cmd = ['python', BUMP_SCRIPT, '--bump-version', '--revision=tip']
cmd.extend(configs)
run_cmd(cmd)
# Second pass.... | [
"def _generate_default_overridden(config_override):\n\n for config_filename in config_override:\n config = config_override[config_filename]\n config['-all_default'] = None\n\n config_filepath = os.path.join(OUTPUT_PATH, 'default-{}.json'.format(\n config_filename))\n logging.debug('config file <... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Polynomial path with 2dof. | def test_2_dof():
pi = PolynomialPath([[1, 2, 3], [-2, 3, 4, 5]])
# [1 + 2s + 3s^2]
# [-2 + 3s + 4s^2 + 5s^3]
assert pi.dof == 2
npt.assert_allclose(
pi.eval([0, 0.5, 1]), [[1, -2], [2.75, 1.125], [6, 10]])
npt.assert_allclose(
pi.evald([0, 0.5, 1]), [[2, 3], [5, 10.75], [8, 26]]... | [
"def polynomial(self, p, n):\n try:\n return self[int(p)][int(n)]\n except KeyError:\n raise RuntimeError, \"Conway polynomial over F_%s of degree %s not in database.\"%(p,n)",
"def polygon2pathd(polyline):\n return polyline2pathd(polyline, True)",
"def __build_simple_path... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns this assets parent. | def parent(self) -> "Asset":
if self.parent_id is None:
raise ValueError("parent_id is None")
return self._cognite_client.assets.retrieve(id=self.parent_id) | [
"def get_parent(self) :\n return self.parent",
"def parent(self):\n if self._parent is not None:\n return self._parent()\n else:\n return None",
"def parent(self):\n return self if self.is_root else self.__parent",
"def get_parent(self):\n if self.paren... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the children of this asset. | def children(self) -> "AssetList":
return self._cognite_client.assets.list(parent_ids=[self.id], limit=None) | [
"def children(self):\n return list(self._children)",
"def children(self):\n return self._children[:]",
"def get_children(self):\n return [c for (z, c) in self.children]",
"def get_children(self):\n return [ch for ch in self.children]",
"def get_asset_children(self, asset_id):\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns the subtree of this asset up to a specified depth. | def subtree(self, depth: int = None) -> "AssetList":
return self._cognite_client.assets.retrieve_subtree(id=self.id, depth=depth) | [
"def sub_tree(self):\n return self._sub_tree",
"def get_tree_below(self, max_depth=None, current_depth=0):\n\t\ttree_list = []\n\t\tif max_depth == None:\n\t\t\t# if we are not returning a row.\n\t\t\tif self.left_child != None:\n\t\t\t\t# if this is not the base of the tree\n\t\t\t\ttree_list = self.left_... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Retrieve all time series related to this asset. | def time_series(self, **kwargs) -> "TimeSeriesList":
return self._cognite_client.time_series.list(asset_ids=[self.id], **kwargs) | [
"def time_series(self) -> \"TimeSeriesList\":\n from cognite.client.data_classes import TimeSeriesList\n\n return self._retrieve_related_resources(TimeSeriesList, self._cognite_client.time_series)",
"def timeseries(self) -> List[ResponseTimeseries]:\n return self._timeseries",
"def get_time... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Retrieve all events related to this asset. | def events(self, **kwargs) -> "EventList":
return self._cognite_client.events.list(asset_ids=[self.id], **kwargs) | [
"def get_events(self):\n return self.s.query(Event).all()",
"def get_events(self):\n return self._get_model(self.api.events, model=Events)",
"def events(self):\n url = self.urls.event_url + self.network_id\n headers = self._auth_header\n self._events = _request(self, url=url, ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Retrieve all time series related to these assets. | def time_series(self) -> "TimeSeriesList":
from cognite.client.data_classes import TimeSeriesList
return self._retrieve_related_resources(TimeSeriesList, self._cognite_client.time_series) | [
"def time_series(self, **kwargs) -> \"TimeSeriesList\":\n return self._cognite_client.time_series.list(asset_ids=[self.id], **kwargs)",
"def get_time_series(self):\n pass",
"def timeseries(self) -> List[ResponseTimeseries]:\n return self._timeseries",
"def series(self):\n self._bui... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Uses the derivative of a signal to determine if a given contact has a lot of erroneous tracking. If it does, we remove to contact episode by setting cbool for that segment equal to 0 | def remove_bad_contacts(var_in,cbool,thresh=100):
var = var_in.copy()
cbool = cbool.astype('bool').ravel()
cc = cbool_to_cc(cbool)
var = scale_by_contact(var, cc)
d = get_d(var)
d[np.isnan(d)]=0
# get an estimate of energy. Seems to work better thatn just normal energy, but that could be c... | [
"def IsRemoved(self):\r\n return Contact.REMOVED in self.labels",
"def check_for_deletion(self, track, **kwargs):\n\n track_covar_trace = np.trace(track.state.covar)\n\n if(track_covar_trace > self.covar_trace_thresh):\n return True\n return False",
"def mark_as_unsatisfied(se... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Generates an HTMLformatted title. | def html_title(title):
return '<center><h1>%s</h1></center>' % (title) | [
"def generate_title(self, title=None):\n if title is None:\n title = self.header.get('title', self.title)\n\n title = self.generate(title)\n title = title.replace('<p>', '').replace('</p>', '')\n # no trailing newlines\n title = re.sub(r'\\n+', ' ', title).rstrip()\n return title",
"def htm... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Navigation bar to the TLSMD output files. | def html_job_nav_bar(job_id):
if mysql.job_get_via_pdb(job_id) == 1 and \
mysql.job_get_state(job_id) != "running":
pdb_id = mysql.job_get_structure_id(job_id)
job_dir = os.path.join(conf.WEBTLSMDD_PDB_DIR, pdb_id)
job_url = os.path.join(conf.TLSMD_PUBLIC_URL, "pdb", pdb_id)
else:... | [
"def show_navigation_commands(self):\n commands = sorted([\"help\", \"quit\", \"exit\", \"main\", \"back\"])\n self.print_topics(\"Navigation Commands\", commands, **HELP_ARGS)",
"def printMenu():\n # tWelc = PrettyTable(['Welcome to the CLI-of the repository classifier'])\n print('Welcome to ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Retrieves and confirms the job_id from a incoming form. Returns None on error, or the job_id on success. | def check_job_id(form):
if form.has_key("job_id"):
job_id = form["job_id"].value
if len(job_id) < conf.MAX_JOB_ID_LEN:
if job_id.startswith("TLSMD"):
if mysql.job_exists(job_id):
return job_id
return None | [
"def get_jobid(self):\n jobid = self.assessor.attrs.get('%s/jobid' % self.atype)\n if jobid is None:\n jobid = 'NotFound'\n return jobid.strip()",
"def job_id(self):\n return self._job.id",
"def job_id(self) -> str:\n return self._job['id']",
"def job_id(self):\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Vet email addresses. The local part (the part before the '@') must not exceed 64 characters and the domain part (after the '@') must not exceed 255 characters. The entire email address length must not exceed 320 characters. | def vet_email(email_address):
## FIXME: Doesn't warn user!
if not re.match(r'^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$', email_address):
return False
local_part = re.sub(r'^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$', '\\1', email_address)
domain_part = re.sub(r'^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2... | [
"def long_email():\n max_length = 254\n domain_part = \"@email.com\"\n user_part = (max_length + 1 - len(domain_part)) * \"a\"\n return f\"{user_part}{domain_part}\"",
"def emailValidate(form, field):\n\n if ' ' in field.data:\n raise ValidationError(message='Invalid e-mail address')\n\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
PDB ID must be exactly four characters long, alphanumeric, and the first character must be an integer. | def vet_pdb_id(pdbid):
if len(pdbid) < 4 or not \
pdbid.isalnum() or not \
re.match(r'^[0-9][A-Za-z0-9]{3}$', pdbid):
return False
return True | [
"def validateID(id):\n\n if re.compile('[0-9]+').match(id) == None:\n output.completeOutputError(InvalidArgumentCount(descape =\"'%s' is not a valid Id. ID should be numeric with Length = '%s' \" \n\t\t\t% (id, lib.constants._ATTR_ID_LENGHT)))\n return -1\n else:\n # Check for the lenght ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Extract the input from the Job Edit Form and update the MySQL database with the information. | def extract_job_edit_form(form):
if not form.has_key("edit_form"):
return False
job_id = check_job_id(form)
if job_id is None:
return False
mysql.job_set_submit_time(job_id, time.time())
## TODO: Immediately create job dir + log.txt + ANALYSIS dir, 2009-05-26
if form.has_key(... | [
"def update_job(request):\n req_data = request.POST.copy()\n job_id = req_data['job_id']\n db_result = job_detail.objects.filter(id=job_id)\n template_values = {'MEDIA_URL': media_url, 'db_result': db_result}\n return render_to_response('update_job_page.html', template_values)",
"def editJob(self):... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Returns a list of chain IDs and their sizes. | def chain_size_string(self, jdict):
## class QueuePage()
if jdict.has_key("chains") == False:
return "---"
listx = []
for cdict in jdict["chains"]:
if cdict["selected"]:
## Only show chains used selected for analysis
listx.append("... | [
"def list_sizes(self):\n return list(self.get_sizes().keys())",
"def make_size_list(self) -> list[int]:\n content_size = sum(self.content.values())\n child_lists = [child.make_size_list() for child in self.children.values()]\n child_sizes = sum([child[-1] for child in child_lists])\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Checks if a PID exists for a given job_id. Returns True if PID exists; False otherwise. | def pid_exists(self, job_id):
## class QueuePage()
pid = mysql.job_get_pid(job_id)
if pid == None:
## job PID somehow did not get stored in the database, so return
## False => state='syserror'; job may still be running!
return False
else:
p... | [
"def job_exists(self, job_id):\n\n return True if self.get_status(job_id) else False",
"def exists(cls, job_id: str, connection: Optional['Redis'] = None) -> bool:\n if not connection:\n connection = resolve_connection()\n job_key = cls.key_for(job_id)\n job_exists = connect... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Calculate the total number of residues (with/without chains). | def total_number_of_residues(self, jdict):
chain_sizes = jdict["chain_sizes"]
total = 0
if chain_sizes == None:
return "NULL"
## Sum total number of residues from each chain (ignore type)
for c in chain_sizes.split(';'):
chid, length, selected, type = mis... | [
"def numResidues(self):\n\n\t\tnres = 0\n\t\tfor chain in self.chain:\n\t\t\tnres += chain.numResidues()\n\n\t\treturn nres",
"def n_residues(self):\n residue_groups = self.extract(\"record\", \"ATOM\").residue_groups\n return sum(1 for _ in residue_groups)",
"def count_standard_residues(self):\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Constructs an HTML table of currently running TLSMD jobs. | def html_running_job_table(self, job_list):
## class QueuePage()
## get an array of "running" jobs from the job dictionary
run_jdict = []
for jdict in job_list:
if jdict["state"] == "running":
if self.pid_exists(jdict["job_id"]) == False:
m... | [
"def html_completed_job_table(self, job_list):\n ## class QueuePage()\n completed_list = []\n for jdict in job_list:\n if jdict.get(\"state\") in [\"success\",\n \"errors\", # completed w/errors\n \"warnings\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Constructs an HTML table of currently queued TLSMD jobs. | def html_queued_job_table(self, job_list):
## class QueuePage()
queued_list = []
for jdict in job_list:
if jdict.get("state") == "queued":
## Populate queued list for XHTML table below
queued_list.append(jdict)
l = ['<center>',
'<... | [
"def html_running_job_table(self, job_list):\n ## class QueuePage()\n ## get an array of \"running\" jobs from the job dictionary\n run_jdict = []\n for jdict in job_list:\n if jdict[\"state\"] == \"running\":\n if self.pid_exists(jdict[\"job_id\"]) == False:\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Constructs an HTML table of completed TLSMD jobs. | def html_completed_job_table(self, job_list):
## class QueuePage()
completed_list = []
for jdict in job_list:
if jdict.get("state") in ["success",
"errors", # completed w/errors
"warnings", # completed w/wa... | [
"def html_running_job_table(self, job_list):\n ## class QueuePage()\n ## get an array of \"running\" jobs from the job dictionary\n run_jdict = []\n for jdict in job_list:\n if jdict[\"state\"] == \"running\":\n if self.pid_exists(jdict[\"job_id\"]) == False:\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Constructs an HTML table of those TLSMD jobs currently in limbo. | def html_limbo_job_table(self, job_list):
## class QueuePage()
limbo_list = []
for jdict in job_list:
if jdict.get("state") not in ["queued",
"running",
"success",
... | [
"def html_running_job_table(self, job_list):\n ## class QueuePage()\n ## get an array of \"running\" jobs from the job dictionary\n run_jdict = []\n for jdict in job_list:\n if jdict[\"state\"] == \"running\":\n if self.pid_exists(jdict[\"job_id\"]) == False:\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Kick PID of stuck job past current process and continue with next step. | def kick(self, job_id):
if webtlsmdd.signal_job(job_id):
x = ''
x += '<center>'
x += '<h3>Job %s has been signaled ' % (job_id)
x += 'to kick it past the process it was stuck on.</h3>'
x += '</center>'
else:
x = ''
x +... | [
"def hold(jobid):\n cexec([\"bstop\", str(jobid)])\n logger.debug(\"Holding back job %d from the queue\", jobid)",
"def kill_job(jid):\n # Some OS's (Win32) don't have SIGKILL, so use salt_SIGKILL which is set to\n # an appropriate value for the operating system this is running on.\n return... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Prepares the entered pdb id by first running some sanity checks on it. | def prepare_pdbid_entry(self):
## class Submit2Page
pdbid = self.form["pdbid"].value.upper()
if vet_pdb_id(pdbid) == False:
if pdbid is None or pdbid == "":
raise SubmissionException("No PDB file uploaded and no PDB ID given. Please try again.")
else:
... | [
"def prep_id(self, prep_id):\n self.logger.debug(\"In 'prep_id' setter.\")\n\n self._prep_id = prep_id",
"def prepare(self):\n # log_assert(id)\n\n # id->header = SECURITY_ID_HEADEr\n # id->checksum = security_id_checksum_buffer(id->id)\n self.header = SECURITY_ID_HEADER\... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Provides a summary table of the userselected chains. | def submission_summary_info(self, job_id):
## TODO: Post-sanity checks, 2009-01-08
#sanity = self.form["pdbfile"].value
chains = mysql.job_get_chain_sizes(job_id).rstrip(";")
## E.g.,
# name: CHAINA
# selected: True
# chain_id: A
# length: 39
# pr... | [
"def summarystudent(self):\n pt = PrettyTable(field_names=['CWID', 'Name', 'courses'])\n for student in self.students:\n pt.add_row([student.cwid, student.name, [key for key in student.courses.keys()]])\n return pt",
"def workout_summary():\n\tprint(\"\\n---------------------------... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
If a given PDB (from pdb.org) has already been analyzed, inform the user and redirect them to the correct analysis page. | def redirect_page(self, pdbid):
## class SubmitPDBPage
## check to see if this job is still running
try:
os.chdir(conf.WEBTLSMDD_PDB_DIR + '/' + pdbid)
except OSError:
title = "This structure is currently being analyzed, please check back later."
page... | [
"def reanalyze_entry(brain_dump_id):\n\n # grabs the specific brain_dump id\n brain_dump = User_Brain_Dump.query.get(brain_dump_id)\n\n # grabs the entry's user id\n user_id = brain_dump.user_id\n\n # empty's all analysis columns from database\n brain_dump.analysis_confirmation = None\n brain_d... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
If a given PDB (from pdb.org) has already been analyzed in the TLSMD database, inform the user and redirect them to the correct analysis page. | def redirect_page_path(self, pdbid, path_head, path_tail):
## class SubmitPDBPage
## check to see if this job is still running
try:
os.chdir(os.path.join(path_head, path_tail, pdbid))
except OSError:
title = "This structure is currently being analyzed, please che... | [
"def redirect_page(self, pdbid):\n ## class SubmitPDBPage\n\n ## check to see if this job is still running\n try:\n os.chdir(conf.WEBTLSMDD_PDB_DIR + '/' + pdbid)\n except OSError:\n title = \"This structure is currently being analyzed, please check back later.\"\n ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Calculates a running standard deviation for residue windows the same size as whatever the global 'min_subsegment_size' in conf.py is set to. | def min_subsegment_stddev(atomnum, restype, resnum, chain, tfactor):
## TODO: Doesn't do anything yet, 2009-06-05
min_subsegment_size = conf.globalconf.min_subsegment_size | [
"def standardDeviation(self):\n subtracted_scores = []\n for score in self.data:\n subtracted_scores.append((score - self.mean())**2)\n sum_subtracted_scores = sum(subtracted_scores)\n length = len(subtracted_scores)\n sd_mean = sum_subtracted_scores / length\n r... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
upload data defined in suite config files | def upload(ctx, include, exclude, glob, suite_type, role, config_type, **kwargs):
ctx.obj.update(**kwargs)
ctx.obj.post_process()
namespace = ctx.obj["namespace"]
config_inst = ctx.obj["config"]
if ctx.obj["extend_sid"] is not None:
config_inst.extend_sid = ctx.obj["extend_sid"]
if ctx.o... | [
"def check_and_upload_dataset(self, opt:argparse.Namespace=None):\n # TODO: upload dataset by sperate scipt\n assert wandb, 'Install wandb to upload dataset'\n config_path = self.log_dataset_artifact(opt.data, opt.project)\n print(\"Created dataset config file \", config_path)\n w... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |
Creates the underlying QScrollAreacontrol. | def create(self, parent):
self.widget = QtGui.QScrollArea(parent) | [
"def __init_UI(self):\r\n\r\n ## Setting up the vertical bar\r\n # self.bar = self.verticalScrollBar()\r\n\r\n # Create the inner widget of the scroll area\r\n self.inner_widget = QWidget(self)\r\n self.setWidget(self.inner_widget)\r\n\r\n # Create a vertical layout inside ... | {
"objective": {
"paired": [],
"self": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} |