uid stringlengths 24 24 | split stringclasses 1
value | category stringclasses 2
values | content stringlengths 5 482k | signature stringlengths 1 14k | suffix stringlengths 1 482k | prefix stringlengths 9 14k | prefix_token_count int64 3 5.01k | prefix_token_budget int64 64 256 | element_token_count int64 1 292k | signature_token_count int64 1 5.01k | prefix_context_token_count int64 0 255 | repo stringlengths 7 112 | path stringlengths 4 208 | language stringclasses 1
value | name stringlengths 1 218 | qualname stringlengths 1 218 | start_line int64 1 26.7k | end_line int64 1 26.7k | signature_start_line int64 1 26.7k | signature_end_line int64 1 26.7k | source_hash stringlengths 40 40 | source_dataset stringclasses 1
value | source_split stringclasses 1
value |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
86db5f48f4feaff317379dfc | train | function | def prewhiten(x):
mean = np.mean(x)
std = np.std(x)
std_adj = np.maximum(std, 1.0/np.sqrt(x.size))
y = np.multiply(np.subtract(x, mean), 1/std_adj)
return y
| def prewhiten(x):
| mean = np.mean(x)
std = np.std(x)
std_adj = np.maximum(std, 1.0/np.sqrt(x.size))
y = np.multiply(np.subtract(x, mean), 1/std_adj)
return y
| moving_average_decay, global_step)
variables_averages_op = variable_averages.apply(tf.trainable_variables())
with tf.control_dependencies([apply_gradient_op, variables_averages_op]):
train_op = tf.no_op(name='train')
return train_op
def prewhiten(x):
| 64 | 64 | 58 | 6 | 57 | aashishrai3799/Automated-Attendance-System-using-CNN | facenet.py | Python | prewhiten | prewhiten | 185 | 190 | 185 | 185 | b9be8d877cb26afc963917d6b819a2d0291ee8ae | bigcode/the-stack | train |
f866ff18a144dbdac74babda | train | function | def get_control_flag(control, field):
return tf.equal(tf.mod(tf.floor_div(control, field), 2), 1)
| def get_control_flag(control, field):
| return tf.equal(tf.mod(tf.floor_div(control, field), 2), 1)
| _labels_list, batch_size=batch_size_placeholder,
shapes=[image_size + (3,), ()], enqueue_many=True,
capacity=4 * nrof_preprocess_threads * 100,
allow_smaller_final_batch=True)
return image_batch, label_batch
def get_control_flag(control, field):
| 64 | 64 | 27 | 8 | 55 | aashishrai3799/Automated-Attendance-System-using-CNN | facenet.py | Python | get_control_flag | get_control_flag | 111 | 112 | 111 | 111 | c590a1fe67250081a4ee21c4ee73809d452b4a49 | bigcode/the-stack | train |
88937bfef92a388a2bca4677 | train | function | def calculate_val_far(threshold, dist, actual_issame):
predict_issame = np.less(dist, threshold)
true_accept = np.sum(np.logical_and(predict_issame, actual_issame))
false_accept = np.sum(np.logical_and(predict_issame, np.logical_not(actual_issame)))
n_same = np.sum(actual_issame)
n_diff = np.sum(np.... | def calculate_val_far(threshold, dist, actual_issame):
| predict_issame = np.less(dist, threshold)
true_accept = np.sum(np.logical_and(predict_issame, actual_issame))
false_accept = np.sum(np.logical_and(predict_issame, np.logical_not(actual_issame)))
n_same = np.sum(actual_issame)
n_diff = np.sum(np.logical_not(actual_issame))
val = float(true_accept... | reshold, dist[test_set], actual_issame[test_set])
val_mean = np.mean(val)
far_mean = np.mean(far)
val_std = np.std(val)
return val_mean, val_std, far_mean
def calculate_val_far(threshold, dist, actual_issame):
| 64 | 64 | 124 | 14 | 49 | aashishrai3799/Automated-Attendance-System-using-CNN | facenet.py | Python | calculate_val_far | calculate_val_far | 480 | 488 | 480 | 480 | 8a0c0b1b2692b6e663dec1068aaec4713a1e21fc | bigcode/the-stack | train |
ade966d3f1cd42c850612a39 | train | function | def get_model_filenames(model_dir):
files = os.listdir(model_dir)
meta_files = [s for s in files if s.endswith('.meta')]
if len(meta_files)==0:
raise ValueError('No meta file found in the model directory (%s)' % model_dir)
elif len(meta_files)>1:
raise ValueError('There should not be mor... | def get_model_filenames(model_dir):
| files = os.listdir(model_dir)
meta_files = [s for s in files if s.endswith('.meta')]
if len(meta_files)==0:
raise ValueError('No meta file found in the model directory (%s)' % model_dir)
elif len(meta_files)>1:
raise ValueError('There should not be more than one meta file in the model di... |
print('Metagraph file: %s' % meta_file)
print('Checkpoint file: %s' % ckpt_file)
saver = tf.train.import_meta_graph(os.path.join(model_exp, meta_file), input_map=input_map)
saver.restore(tf.get_default_session(), os.path.join(model_exp, ckpt_file))
def get_model_filenames... | 78 | 79 | 265 | 8 | 70 | aashishrai3799/Automated-Attendance-System-using-CNN | facenet.py | Python | get_model_filenames | get_model_filenames | 356 | 378 | 356 | 356 | 2bde2c9711c142d1400672097d0e7e1e242516f5 | bigcode/the-stack | train |
eb7878d8544f2bd152441aef | train | function | def _add_loss_summaries(total_loss):
"""Add summaries for losses.
Generates moving average for all losses and associated summaries for
visualizing the performance of the network.
Args:
total_loss: Total loss from loss().
Returns:
loss_averages_op: op for generating moving averages ... | def _add_loss_summaries(total_loss):
| """Add summaries for losses.
Generates moving average for all losses and associated summaries for
visualizing the performance of the network.
Args:
total_loss: Total loss from loss().
Returns:
loss_averages_op: op for generating moving averages of losses.
"""
# Compute the ... | _many=True,
capacity=4 * nrof_preprocess_threads * 100,
allow_smaller_final_batch=True)
return image_batch, label_batch
def get_control_flag(control, field):
return tf.equal(tf.mod(tf.floor_div(control, field), 2), 1)
def _add_loss_summaries(total_loss):
| 71 | 72 | 242 | 10 | 61 | aashishrai3799/Automated-Attendance-System-using-CNN | facenet.py | Python | _add_loss_summaries | _add_loss_summaries | 114 | 138 | 114 | 114 | 68ebbb10c2956fb9e1e075310aecfcf2713dcc96 | bigcode/the-stack | train |
1ca1e9e452d3a949080f4bfd | train | function | def shuffle_examples(image_paths, labels):
shuffle_list = list(zip(image_paths, labels))
random.shuffle(shuffle_list)
image_paths_shuff, labels_shuff = zip(*shuffle_list)
return image_paths_shuff, labels_shuff
| def shuffle_examples(image_paths, labels):
| shuffle_list = list(zip(image_paths, labels))
random.shuffle(shuffle_list)
image_paths_shuff, labels_shuff = zip(*shuffle_list)
return image_paths_shuff, labels_shuff
| (dataset):
image_paths_flat = []
labels_flat = []
for i in range(len(dataset)):
image_paths_flat += dataset[i].image_paths
labels_flat += [i] * len(dataset[i].image_paths)
return image_paths_flat, labels_flat
def shuffle_examples(image_paths, labels):
| 64 | 64 | 52 | 8 | 55 | aashishrai3799/Automated-Attendance-System-using-CNN | facenet.py | Python | shuffle_examples | shuffle_examples | 59 | 63 | 59 | 59 | 38bf8cafdb0f09e1924d3f2a87f8bbd6cc4c5979 | bigcode/the-stack | train |
144f06eab8556b6fced8193b | train | function | def test_protected_files(tmp_path, monkeypatch):
shutil.copytree(SAMPLE_PROJECTS / "protected_files", tmp_path, dirs_exist_ok=True)
monkeypatch.chdir(tmp_path)
result = run_vendoring_sync()
assert result.exit_code == 0
vendored = tmp_path / "vendored"
assert vendored.exists()
assert sorted... | def test_protected_files(tmp_path, monkeypatch):
| shutil.copytree(SAMPLE_PROJECTS / "protected_files", tmp_path, dirs_exist_ok=True)
monkeypatch.chdir(tmp_path)
result = run_vendoring_sync()
assert result.exit_code == 0
vendored = tmp_path / "vendored"
assert vendored.exists()
assert sorted(os.listdir(vendored)) == ["README.md", "packagin... | .py",
"appdirs.pyi",
]
# Just check a single patched line
line = linecache.getline(str(vendored / "appdirs.py"), 560)
assert line == " from ctypes import windll\n"
def test_protected_files(tmp_path, monkeypatch):
| 64 | 64 | 92 | 11 | 53 | jdufresne/vendoring | tests/test_sample_projects.py | Python | test_protected_files | test_protected_files | 141 | 150 | 141 | 141 | a2b8e8d93c15d8d1bed791442d81de6417c7b68e | bigcode/the-stack | train |
27dabe3218f15910a65fdcc3 | train | function | @pytest.mark.skipif(
sys.platform == "win32",
reason="Fails with 'error: corrupt patch at line 6' on `git apply` (needs fixing)",
)
def test_patches(tmp_path, monkeypatch):
shutil.copytree(SAMPLE_PROJECTS / "patches", tmp_path, dirs_exist_ok=True)
monkeypatch.chdir(tmp_path)
result = run_vendoring_... | @pytest.mark.skipif(
sys.platform == "win32",
reason="Fails with 'error: corrupt patch at line 6' on `git apply` (needs fixing)",
)
def test_patches(tmp_path, monkeypatch):
| shutil.copytree(SAMPLE_PROJECTS / "patches", tmp_path, dirs_exist_ok=True)
monkeypatch.chdir(tmp_path)
result = run_vendoring_sync()
assert result.exit_code == 0
vendored = tmp_path / "vendored"
assert vendored.exists()
assert sorted(os.listdir(vendored)) == [
"appdirs.LICENSE.txt"... | assert (vendored / "webencodings" / "LICENSE").exists()
@pytest.mark.skipif(
sys.platform == "win32",
reason="Fails with 'error: corrupt patch at line 6' on `git apply` (needs fixing)",
)
def test_patches(tmp_path, monkeypatch):
| 64 | 64 | 187 | 48 | 16 | jdufresne/vendoring | tests/test_sample_projects.py | Python | test_patches | test_patches | 117 | 138 | 117 | 121 | c3283b4fb726e3d6bb96355aadb02d4efbf00b69 | bigcode/the-stack | train |
02a832cd375afbd96dfc41ff | train | function | def test_licenses(tmp_path, monkeypatch):
shutil.copytree(SAMPLE_PROJECTS / "licenses", tmp_path, dirs_exist_ok=True)
monkeypatch.chdir(tmp_path)
result = run_vendoring_sync()
assert result.exit_code == 0
vendored = tmp_path / "vendored"
assert vendored.exists()
assert sorted(os.listdir(ve... | def test_licenses(tmp_path, monkeypatch):
| shutil.copytree(SAMPLE_PROJECTS / "licenses", tmp_path, dirs_exist_ok=True)
monkeypatch.chdir(tmp_path)
result = run_vendoring_sync()
assert result.exit_code == 0
vendored = tmp_path / "vendored"
assert vendored.exists()
assert sorted(os.listdir(vendored)) == [
"appdirs.LICENSE.txt... | _lineno - 1):
next(iterable)
interesting_line = next(iterable)
expected_line = (
"from import_rewriting.vendored.six.moves.urllib import parse as urlparse\n"
)
assert interesting_line == expected_line
def test_licenses(tmp_path, monkeypatch):
| 64 | 64 | 175 | 10 | 53 | jdufresne/vendoring | tests/test_sample_projects.py | Python | test_licenses | test_licenses | 92 | 114 | 92 | 92 | 8df4a5b1e859bda5dd6adc30790b8e468b90c573 | bigcode/the-stack | train |
ae3bb5cead9e74b09e2b8c4e | train | function | def test_basic(tmp_path, monkeypatch):
shutil.copytree(SAMPLE_PROJECTS / "basic", tmp_path, dirs_exist_ok=True)
monkeypatch.chdir(tmp_path)
result = run_vendoring_sync()
assert result.exit_code == 0
vendored = tmp_path / "vendored"
assert vendored.exists()
assert sorted(os.listdir(vendored... | def test_basic(tmp_path, monkeypatch):
| shutil.copytree(SAMPLE_PROJECTS / "basic", tmp_path, dirs_exist_ok=True)
monkeypatch.chdir(tmp_path)
result = run_vendoring_sync()
assert result.exit_code == 0
vendored = tmp_path / "vendored"
assert vendored.exists()
assert sorted(os.listdir(vendored)) == ["packaging"]
packaging = ve... | ()
result = runner.invoke(main, ["sync"], catch_exceptions=False)
# Print information to stdout, so that failures are easier to diagnose.
print(result.output)
if result.exc_info:
traceback.print_exception(*result.exc_info)
return result
def test_basic(tmp_path, monkeypatch):
| 64 | 64 | 192 | 9 | 54 | jdufresne/vendoring | tests/test_sample_projects.py | Python | test_basic | test_basic | 30 | 59 | 30 | 30 | 2726f3bde58bae4cdad065f76419f7cb6a1de170 | bigcode/the-stack | train |
62d6f4cbd2037e1aceacd0a4 | train | function | def test_transformations(tmp_path, monkeypatch):
shutil.copytree(SAMPLE_PROJECTS / "transformations", tmp_path, dirs_exist_ok=True)
monkeypatch.chdir(tmp_path)
result = run_vendoring_sync()
assert result.exit_code == 0
vendored = tmp_path / "vendored"
assert vendored.exists()
assert sorted... | def test_transformations(tmp_path, monkeypatch):
| shutil.copytree(SAMPLE_PROJECTS / "transformations", tmp_path, dirs_exist_ok=True)
monkeypatch.chdir(tmp_path)
result = run_vendoring_sync()
assert result.exit_code == 0
vendored = tmp_path / "vendored"
assert vendored.exists()
assert sorted(os.listdir(vendored)) == [
"pkg_resource... | "
def test_protected_files(tmp_path, monkeypatch):
shutil.copytree(SAMPLE_PROJECTS / "protected_files", tmp_path, dirs_exist_ok=True)
monkeypatch.chdir(tmp_path)
result = run_vendoring_sync()
assert result.exit_code == 0
vendored = tmp_path / "vendored"
assert vendored.exists()
assert so... | 103 | 104 | 348 | 10 | 93 | jdufresne/vendoring | tests/test_sample_projects.py | Python | test_transformations | test_transformations | 153 | 201 | 153 | 153 | 20556869d8bf3abbe9c63de2325225a808a1b565 | bigcode/the-stack | train |
077fc2ef8f4150bd0a84199a | train | function | def test_typing_fun(tmp_path, monkeypatch):
shutil.copytree(SAMPLE_PROJECTS / "typing_fun", tmp_path, dirs_exist_ok=True)
monkeypatch.chdir(tmp_path)
result = run_vendoring_sync()
assert result.exit_code == 0
vendored = tmp_path / "vendored"
assert vendored.exists()
assert sorted(os.listdi... | def test_typing_fun(tmp_path, monkeypatch):
| shutil.copytree(SAMPLE_PROJECTS / "typing_fun", tmp_path, dirs_exist_ok=True)
monkeypatch.chdir(tmp_path)
result = run_vendoring_sync()
assert result.exit_code == 0
vendored = tmp_path / "vendored"
assert vendored.exists()
assert sorted(os.listdir(vendored)) == [
"appdirs.LICENSE.t... | from transformations.vendored import six\n"
line = linecache.getline(str(vendored / "pkg_resources" / "__init__.py"), 81)
assert line == "__import__('transformations.vendored.packaging.version')\n"
def test_typing_fun(tmp_path, monkeypatch):
| 64 | 64 | 181 | 11 | 53 | jdufresne/vendoring | tests/test_sample_projects.py | Python | test_typing_fun | test_typing_fun | 204 | 228 | 204 | 204 | 3523725437452c39a2cf99213574196327fa7f92 | bigcode/the-stack | train |
16e134c20f407b2bdda43e23 | train | function | def run_vendoring_sync():
runner = CliRunner()
result = runner.invoke(main, ["sync"], catch_exceptions=False)
# Print information to stdout, so that failures are easier to diagnose.
print(result.output)
if result.exc_info:
traceback.print_exception(*result.exc_info)
return result
| def run_vendoring_sync():
| runner = CliRunner()
result = runner.invoke(main, ["sync"], catch_exceptions=False)
# Print information to stdout, so that failures are easier to diagnose.
print(result.output)
if result.exc_info:
traceback.print_exception(*result.exc_info)
return result
| sample projects."""
import linecache
import os
import shutil
import sys
import traceback
from pathlib import Path
import pytest
from click.testing import CliRunner
from vendoring.cli import main
SAMPLE_PROJECTS = Path(__file__).parent / "sample-projects"
def run_vendoring_sync():
| 64 | 64 | 67 | 7 | 57 | jdufresne/vendoring | tests/test_sample_projects.py | Python | run_vendoring_sync | run_vendoring_sync | 18 | 27 | 18 | 18 | 2f62f2cbcc5f4b1df258a60c22076e8291a3c618 | bigcode/the-stack | train |
85cb3ca196eee839f7a3aa2c | train | function | def test_import_rewriting(tmp_path, monkeypatch):
shutil.copytree(SAMPLE_PROJECTS / "import_rewriting", tmp_path, dirs_exist_ok=True)
monkeypatch.chdir(tmp_path)
result = run_vendoring_sync()
assert result.exit_code == 0
vendored = tmp_path / "vendored"
assert vendored.exists()
assert sort... | def test_import_rewriting(tmp_path, monkeypatch):
| shutil.copytree(SAMPLE_PROJECTS / "import_rewriting", tmp_path, dirs_exist_ok=True)
monkeypatch.chdir(tmp_path)
result = run_vendoring_sync()
assert result.exit_code == 0
vendored = tmp_path / "vendored"
assert vendored.exists()
assert sorted(os.listdir(vendored)) == [
"packaging",... | compat.py",
"_structures.py",
"_typing.py",
"markers.py",
"py.typed",
"requirements.py",
"specifiers.py",
"tags.py",
"utils.py",
"version.py",
]
def test_import_rewriting(tmp_path, monkeypatch):
| 63 | 64 | 209 | 11 | 52 | jdufresne/vendoring | tests/test_sample_projects.py | Python | test_import_rewriting | test_import_rewriting | 62 | 89 | 62 | 62 | fd3a62f207e04f9b68d6c11ad13d141414a092c3 | bigcode/the-stack | train |
f267684596195c2ff045708b | train | class | class LakeSerializer(serializers.ModelSerializer):
class Meta:
model = Lake
lookup_field = "abbrev"
fields = ("lake_name", "abbrev")
| class LakeSerializer(serializers.ModelSerializer):
| class Meta:
model = Lake
lookup_field = "abbrev"
fields = ("lake_name", "abbrev")
| slug"
fields = ("slug", "grid")
read_only_fields = ("slug",)
class UserSerializer(serializers.ModelSerializer):
class Meta:
model = User
lookup_field = "username"
fields = ("username", "first_name", "last_name")
class LakeSerializer(serializers.ModelSerializer):
| 64 | 64 | 35 | 7 | 57 | AdamCottrill/FishNetPortal | fn_portal/api/serializers/common_serializers.py | Python | LakeSerializer | LakeSerializer | 34 | 38 | 34 | 34 | ed92ab76074c28f8b0ebaaa73c2b82a1812c916d | bigcode/the-stack | train |
2889c332c378ff7ebb620557 | train | class | class GridSerializer(serializers.ModelSerializer):
class Meta:
model = Grid5
lookup_field = "slug"
fields = ("slug", "grid")
read_only_fields = ("slug",)
| class GridSerializer(serializers.ModelSerializer):
| class Meta:
model = Grid5
lookup_field = "slug"
fields = ("slug", "grid")
read_only_fields = ("slug",)
| import Lake, Species, Grid5
User = get_user_model()
class SpeciesSerializer(serializers.ModelSerializer):
class Meta:
model = Species
lookup_field = "spc"
fields = ("spc", "spc_nmco", "spc_nmsc")
class GridSerializer(serializers.ModelSerializer):
| 64 | 64 | 42 | 7 | 57 | AdamCottrill/FishNetPortal | fn_portal/api/serializers/common_serializers.py | Python | GridSerializer | GridSerializer | 19 | 24 | 19 | 19 | 0357236a25864461bf9adafedec7943e9ae6dc5c | bigcode/the-stack | train |
b24f789f209ec9394034b246 | train | class | class UserSerializer(serializers.ModelSerializer):
class Meta:
model = User
lookup_field = "username"
fields = ("username", "first_name", "last_name")
| class UserSerializer(serializers.ModelSerializer):
| class Meta:
model = User
lookup_field = "username"
fields = ("username", "first_name", "last_name")
| spc", "spc_nmco", "spc_nmsc")
class GridSerializer(serializers.ModelSerializer):
class Meta:
model = Grid5
lookup_field = "slug"
fields = ("slug", "grid")
read_only_fields = ("slug",)
class UserSerializer(serializers.ModelSerializer):
| 64 | 64 | 37 | 7 | 57 | AdamCottrill/FishNetPortal | fn_portal/api/serializers/common_serializers.py | Python | UserSerializer | UserSerializer | 27 | 31 | 27 | 27 | 4c7ae4589a428c41dd240bd18688d7d13cec3cf2 | bigcode/the-stack | train |
706d6d1dd590434f13f1ea05 | train | class | class LakeExtentSerializer(serializers.ModelSerializer):
"""
A serializer for lake objects that returns the lake name, lake
abbreviation, and the extent of the ontario waters of the lake.
"""
extent = serializers.SerializerMethodField()
class Meta:
model = Lake
lookup_field = ... | class LakeExtentSerializer(serializers.ModelSerializer):
| """
A serializer for lake objects that returns the lake name, lake
abbreviation, and the extent of the ontario waters of the lake.
"""
extent = serializers.SerializerMethodField()
class Meta:
model = Lake
lookup_field = "abbrev"
fields = ("lake_name", "abbrev", "extent... | lookup_field = "username"
fields = ("username", "first_name", "last_name")
class LakeSerializer(serializers.ModelSerializer):
class Meta:
model = Lake
lookup_field = "abbrev"
fields = ("lake_name", "abbrev")
class LakeExtentSerializer(serializers.ModelSerializer):
| 64 | 64 | 133 | 8 | 56 | AdamCottrill/FishNetPortal | fn_portal/api/serializers/common_serializers.py | Python | LakeExtentSerializer | LakeExtentSerializer | 41 | 64 | 41 | 41 | e13253040b1a269033f94bd3beef7dbd203e0902 | bigcode/the-stack | train |
57e89eb4013e4550496da4bb | train | class | class SpeciesSerializer(serializers.ModelSerializer):
class Meta:
model = Species
lookup_field = "spc"
fields = ("spc", "spc_nmco", "spc_nmsc")
| class SpeciesSerializer(serializers.ModelSerializer):
| class Meta:
model = Species
lookup_field = "spc"
fields = ("spc", "spc_nmco", "spc_nmsc")
| application that will be
used in FN_Portal"""
from fn_portal.data_upload.project_upload import process_accdb_upload
from rest_framework import serializers
from django.contrib.auth import get_user_model
from common.models import Lake, Species, Grid5
User = get_user_model()
class SpeciesSerializer(serializers.ModelSer... | 64 | 64 | 43 | 7 | 57 | AdamCottrill/FishNetPortal | fn_portal/api/serializers/common_serializers.py | Python | SpeciesSerializer | SpeciesSerializer | 12 | 16 | 12 | 12 | 369084472d7aa90230c59f08e60e55e467fab2bc | bigcode/the-stack | train |
ca03e20f8d8ba832f3ac3e49 | train | class | class Solution:
def numPrimeArrangements(self, n: int) -> int:
def countPrime(n):
count = 0
for i in range(2, n+1):
flag = True
for j in range(2, int(math.sqrt(i))+1):
if i % j == 0:
flag = False
... | class Solution:
| def numPrimeArrangements(self, n: int) -> int:
def countPrime(n):
count = 0
for i in range(2, n+1):
flag = True
for j in range(2, int(math.sqrt(i))+1):
if i % j == 0:
flag = False
brea... | from typing import List
import math
class Solution:
| 11 | 64 | 178 | 3 | 7 | KenWoo/Algorithm | Algorithms/Easy/1175. Prime Arrangements/answer.py | Python | Solution | Solution | 5 | 25 | 5 | 5 | 82767a9c6e38d72575d4b1220dafd901a40d4162 | bigcode/the-stack | train |
2aa17df0205f6337a9db217e | train | function | def kill_time_five(party_size: int, challenge_mode: bool):
shaman = CoxMonster.from_de0(
name='lizardman shaman',
party_size=party_size,
challenge_mode=challenge_mode
)
# On-task chin
task_chinner = Player.on_task_chinchompa()
task_chinner.pray(PlayerStats.StatPrayer.rigour())
task_chinner.overload()
task... | def kill_time_five(party_size: int, challenge_mode: bool):
| shaman = CoxMonster.from_de0(
name='lizardman shaman',
party_size=party_size,
challenge_mode=challenge_mode
)
# On-task chin
task_chinner = Player.on_task_chinchompa()
task_chinner.pray(PlayerStats.StatPrayer.rigour())
task_chinner.overload()
task_damage = task_chinner.damage_against_monster(shaman, dista... | _damage = rapid_chinner.damage_against_monster(shaman, distance=9)
longrange_damage = longrange_chinner.damage_against_monster(shaman, distance=9)
return 5*rapid_damage.per_second, 5*longrange_damage.per_second
def kill_time_five(party_size: int, challenge_mode: bool):
| 71 | 71 | 237 | 16 | 54 | noahgill409/osrs-tools-v2 | osrs-tools-v2/shamans_sandbox.py | Python | kill_time_five | kill_time_five | 98 | 125 | 98 | 98 | 4e437d84106da85312bb83ef084f7516543691da | bigcode/the-stack | train |
6423379c84d86317cea05cd6 | train | function | def main(party_size: int, challenge_mode: bool):
def inner(xxx, yyy):
shaman = CoxMonster.from_de0(
name='lizardman shaman',
party_size=xxx,
challenge_mode=yyy
)
# On-task chin
task_chinner = Player.on_task_chinchompa()
task_chinner.pray(PlayerStats.StatPrayer.rigour())
# Void chin
void_chinne... | def main(party_size: int, challenge_mode: bool):
| def inner(xxx, yyy):
shaman = CoxMonster.from_de0(
name='lizardman shaman',
party_size=xxx,
challenge_mode=yyy
)
# On-task chin
task_chinner = Player.on_task_chinchompa()
task_chinner.pray(PlayerStats.StatPrayer.rigour())
# Void chin
void_chinner = Player.void_chinchompa()
void_chinner.pray(... | from main import *
import matplotlib.pyplot as plt
import cox_tools as ct
def main(party_size: int, challenge_mode: bool):
| 30 | 165 | 553 | 13 | 16 | noahgill409/osrs-tools-v2 | osrs-tools-v2/shamans_sandbox.py | Python | main | main | 5 | 70 | 5 | 5 | 7f92020c0793c1d159b1ce7c6f719852c0b37347 | bigcode/the-stack | train |
ad3b64bf69a137490cb141e0 | train | function | def rapid_vs_longrange(party_size: int, challenge_mode: bool):
shaman = CoxMonster.from_de0(
name='lizardman shaman',
party_size=party_size,
challenge_mode=challenge_mode
)
# On-task rapid
rapid_chinner = Player.on_task_chinchompa()
rapid_chinner.pray(PlayerStats.StatPrayer.rigour())
# On-task longrange
... | def rapid_vs_longrange(party_size: int, challenge_mode: bool):
| shaman = CoxMonster.from_de0(
name='lizardman shaman',
party_size=party_size,
challenge_mode=challenge_mode
)
# On-task rapid
rapid_chinner = Player.on_task_chinchompa()
rapid_chinner.pray(PlayerStats.StatPrayer.rigour())
# On-task longrange
longrange_chinner = Player.on_task_chinchompa()
longrange_chin... | 6 shamans, task, and overload')
plt.xlabel('party size')
plt.ylabel('dps')
plt.legend(['rapid', 'longrange'], loc='upper right')
plt.show()
kill_time_five(39, cm)
def rapid_vs_longrange(party_size: int, challenge_mode: bool):
| 64 | 64 | 205 | 16 | 48 | noahgill409/osrs-tools-v2 | osrs-tools-v2/shamans_sandbox.py | Python | rapid_vs_longrange | rapid_vs_longrange | 73 | 95 | 73 | 73 | 0de4a63407447dc01ce31578402d3071b6d097b3 | bigcode/the-stack | train |
972b129c9e0723d49a1befa2 | train | function | def chin_decorator():
shaman_name = 'lizardman shaman'
task_chinner = Player.on_task_chinchompa()
task_tbow = Player.on_task_tbow()
void_tbow = Player.void_tbow()
players = [task_chinner, task_tbow, void_tbow]
for p in players:
p.overload()
p.pray(PlayerStats.StatPrayer.rigour())
attack_distance = 9
cs... | def chin_decorator():
| shaman_name = 'lizardman shaman'
task_chinner = Player.on_task_chinchompa()
task_tbow = Player.on_task_tbow()
void_tbow = Player.void_tbow()
players = [task_chinner, task_tbow, void_tbow]
for p in players:
p.overload()
p.pray(PlayerStats.StatPrayer.rigour())
attack_distance = 9
csc = ct.plot_comparison... | _times) * 0.6
health = shaman.stats.combat.hitpoints
dps_actual = 5*health / longest_time
print('theory: {:.3f}'.format(dps_theory))
print('actual: {:.3f}'.format(dps_actual))
def chin_decorator():
| 64 | 64 | 134 | 5 | 59 | noahgill409/osrs-tools-v2 | osrs-tools-v2/shamans_sandbox.py | Python | chin_decorator | chin_decorator | 128 | 144 | 128 | 128 | e1c5a5d6d44ac04523e99f4687eb9e2491fc0321 | bigcode/the-stack | train |
6036489342fd56a419607b90 | train | function | def shaman_decorator():
shaman_name = 'lizardman shaman'
task_chinner = Player.on_task_chinchompa()
void_chin = Player.void_chinchompa()
arma_chin = Player.arma_chinchompa()
task_tbow = Player.on_task_tbow()
void_tbow = Player.void_tbow()
arma_tbow = Player.arma_tbow()
players = [
task_chinner,
void_chin,... | def shaman_decorator():
| shaman_name = 'lizardman shaman'
task_chinner = Player.on_task_chinchompa()
void_chin = Player.void_chinchompa()
arma_chin = Player.arma_chinchompa()
task_tbow = Player.on_task_tbow()
void_tbow = Player.void_tbow()
arma_tbow = Player.arma_tbow()
players = [
task_chinner,
void_chin,
arma_chin,
task_tbo... | p in players:
p.overload()
p.pray(PlayerStats.StatPrayer.rigour())
attack_distance = 9
csc = ct.plot_comparison(ct.cox_scale_comparison)
csc(players, shaman_name, distance=attack_distance, bounds=(15, 39), additional_monsters_hit=4)
def shaman_decorator():
| 75 | 75 | 250 | 6 | 69 | noahgill409/osrs-tools-v2 | osrs-tools-v2/shamans_sandbox.py | Python | shaman_decorator | shaman_decorator | 148 | 184 | 148 | 148 | b663510cf626d65283fb8ceae57e2746ce42e849 | bigcode/the-stack | train |
ad86a5768b6324ab9db5acfa | train | class | class ImageType(enum.Enum):
IMAGE = "image"
PACKAGE = "package"
| class ImageType(enum.Enum):
| IMAGE = "image"
PACKAGE = "package"
| # Copyright (c) Contributors to the aswf-docker Project. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
"""
Main configuration and constants for aswfdocker
"""
import enum
class ImageType(enum.Enum):
| 50 | 64 | 18 | 6 | 43 | boberfly/aswf-docker | python/aswfdocker/constants.py | Python | ImageType | ImageType | 9 | 11 | 9 | 9 | 579ed415b6d4c9cb84e60f201c8f0b91a3d4dfdf | bigcode/the-stack | train |
6c318e853808d6e066221fc1 | train | function | def pyx_decl_sub(name, args, header_name):
argtypes, argnames = arg_names_and_types(args)
argtypes = [npy_types.get(t, t) for t in argtypes]
argnames = [n if n not in ['lambda', 'in'] else n + '_' for n in argnames]
fort_args = ', '.join([' *'.join([n, t])
for n, t in zip(argt... | def pyx_decl_sub(name, args, header_name):
| argtypes, argnames = arg_names_and_types(args)
argtypes = [npy_types.get(t, t) for t in argtypes]
argnames = [n if n not in ['lambda', 'in'] else n + '_' for n in argnames]
fort_args = ', '.join([' *'.join([n, t])
for n, t in zip(argtypes, argnames)])
argnames = [arg_casts... | _name}":
void _fortran_{name} "F_FUNC({name},{upname})"({fort_args}) nogil
cdef void {name}({args}) nogil:
_fortran_{name}({argnames})
"""
def pyx_decl_sub(name, args, header_name):
| 64 | 64 | 193 | 12 | 52 | jeikabu/lumberyard | dev/Tools/Python/2.7.13/mac/Python.framework/Versions/2.7/lib/python2.7/site-packages/scipy/linalg/_generate_pyx.py | Python | pyx_decl_sub | pyx_decl_sub | 96 | 107 | 96 | 96 | 0029d7cab6ac04d5586b3d47bc5304bb3522a6bc | bigcode/the-stack | train |
b52ca0ea7baf4e8a8fcb42a8 | train | function | def split_signature(sig):
name_and_type, args = sig[:-1].split('(')
ret_type, name = name_and_type.split(' ')
return name, ret_type, args
| def split_signature(sig):
| name_and_type, args = sig[:-1].split('(')
ret_type, name = name_and_type.split(' ')
return name, ret_type, args
| 'LAPACK':
preamble = (c_preamble.format(lib=lib_name) + lapack_decls)
else:
preamble = c_preamble.format(lib=lib_name)
return "".join([preamble, cpp_guard, funcs, subs, c_end])
def split_signature(sig):
| 64 | 64 | 41 | 5 | 59 | jeikabu/lumberyard | dev/Tools/Python/2.7.13/mac/Python.framework/Versions/2.7/lib/python2.7/site-packages/scipy/linalg/_generate_pyx.py | Python | split_signature | split_signature | 627 | 630 | 627 | 627 | e2bddef6bbc5ecedef5d98bacb3375f7b060b022 | bigcode/the-stack | train |
0067be8b4fd05757355d4e76 | train | function | def generate_lapack_pyx(func_sigs, sub_sigs, all_sigs, header_name):
funcs = "\n".join(pyx_decl_func(*(s+(header_name,))) for s in func_sigs)
subs = "\n" + "\n".join(pyx_decl_sub(*(s[::2]+(header_name,)))
for s in sub_sigs)
preamble = make_lapack_pyx_preamble(all_sigs)
return... | def generate_lapack_pyx(func_sigs, sub_sigs, all_sigs, header_name):
| funcs = "\n".join(pyx_decl_func(*(s+(header_name,))) for s in func_sigs)
subs = "\n" + "\n".join(pyx_decl_sub(*(s[::2]+(header_name,)))
for s in sub_sigs)
preamble = make_lapack_pyx_preamble(all_sigs)
return preamble + funcs + subs + lapack_py_wrappers
| , a non-temporary variable
# must be passed as a part of the function call.
cdef char* cmach_char = cmach_bytes
return slamch(cmach_char)
"""
def generate_lapack_pyx(func_sigs, sub_sigs, all_sigs, header_name):
| 64 | 64 | 112 | 22 | 42 | jeikabu/lumberyard | dev/Tools/Python/2.7.13/mac/Python.framework/Versions/2.7/lib/python2.7/site-packages/scipy/linalg/_generate_pyx.py | Python | generate_lapack_pyx | generate_lapack_pyx | 446 | 451 | 446 | 446 | e58bf676cc9698ac21acbed321cdbfd6c8c72df6 | bigcode/the-stack | train |
79df6a6d8b259ab4381dd1a5 | train | function | def pxd_decl(name, ret_type, args):
args = args.replace('lambda', 'lambda_').replace('*in,', '*in_,')
return pxd_template.format(name=name, ret_type=ret_type, args=args)
| def pxd_decl(name, ret_type, args):
| args = args.replace('lambda', 'lambda_').replace('*in,', '*in_,')
return pxd_template.format(name=name, ret_type=ret_type, args=args)
| = """ctypedef {ret_type} {name}_t({args}) nogil
cdef {name}_t *{name}_f
"""
pxd_template = """cdef {ret_type} {name}({args}) nogil
"""
def pxd_decl(name, ret_type, args):
| 64 | 64 | 50 | 11 | 53 | jeikabu/lumberyard | dev/Tools/Python/2.7.13/mac/Python.framework/Versions/2.7/lib/python2.7/site-packages/scipy/linalg/_generate_pyx.py | Python | pxd_decl | pxd_decl | 460 | 462 | 460 | 460 | fc8fa8da95a9ff3d28573051d00c8a3814c1a880 | bigcode/the-stack | train |
332eff0f8e5c0ee7a3db36d6 | train | function | def arg_casts(arg):
if arg in ['npy_complex64', 'npy_complex128', '_cselect1', '_cselect2',
'_dselect2', '_dselect3', '_sselect2', '_sselect3',
'_zselect1', '_zselect2']:
return '<{0}*>'.format(arg)
return ''
| def arg_casts(arg):
| if arg in ['npy_complex64', 'npy_complex128', '_cselect1', '_cselect2',
'_dselect2', '_dselect3', '_sselect2', '_sselect3',
'_zselect1', '_zselect2']:
return '<{0}*>'.format(arg)
return ''
| '_dselect2', 'dselect3': '_dselect3',
'sselect2': '_sselect2', 'sselect3': '_sselect3',
'zselect1': '_zselect1', 'zselect2': '_zselect2'}
def arg_casts(arg):
| 63 | 64 | 78 | 6 | 57 | jeikabu/lumberyard | dev/Tools/Python/2.7.13/mac/Python.framework/Versions/2.7/lib/python2.7/site-packages/scipy/linalg/_generate_pyx.py | Python | arg_casts | arg_casts | 57 | 62 | 57 | 57 | 8a4ae30ea8fe4331d29cfb84998cbb4265a3cdf7 | bigcode/the-stack | train |
e936eedaef7621de195b3aa4 | train | function | def all_newer(src_files, dst_files):
from distutils.dep_util import newer
return all(os.path.exists(dst) and newer(dst, src)
for dst in dst_files for src in src_files)
| def all_newer(src_files, dst_files):
| from distutils.dep_util import newer
return all(os.path.exists(dst) and newer(dst, src)
for dst in dst_files for src in src_files)
| split_signature(l) for l in ls if l.split(' ')[0] == 'void']
all_sigs = list(sorted(func_sigs + sub_sigs, key=itemgetter(0)))
return func_sigs, sub_sigs, all_sigs
def all_newer(src_files, dst_files):
| 64 | 64 | 45 | 10 | 53 | jeikabu/lumberyard | dev/Tools/Python/2.7.13/mac/Python.framework/Versions/2.7/lib/python2.7/site-packages/scipy/linalg/_generate_pyx.py | Python | all_newer | all_newer | 641 | 644 | 641 | 641 | 1b1ab6b01af58e8b2a687fbdf44c512cba5149e7 | bigcode/the-stack | train |
c83e396eef9c37742b3037b0 | train | function | def make_blas_pyx_preamble(all_sigs):
names = [sig[0] for sig in all_sigs]
return blas_pyx_preamble.format("\n- ".join(names))
| def make_blas_pyx_preamble(all_sigs):
| names = [sig[0] for sig in all_sigs]
return blas_pyx_preamble.format("\n- ".join(names))
| wrappers should not be used.
# The original libraries should be linked directly.
from __future__ import absolute_import
cdef extern from "fortran_defs.h":
pass
from numpy cimport npy_complex64, npy_complex128
'''
def make_blas_pyx_preamble(all_sigs):
| 63 | 64 | 42 | 12 | 51 | jeikabu/lumberyard | dev/Tools/Python/2.7.13/mac/Python.framework/Versions/2.7/lib/python2.7/site-packages/scipy/linalg/_generate_pyx.py | Python | make_blas_pyx_preamble | make_blas_pyx_preamble | 152 | 154 | 152 | 152 | 7ae7945abb855afff5d8fa984e7c8671af230c11 | bigcode/the-stack | train |
c0bd24cd81f830295287715f | train | function | def c_func_decl(name, return_type, args):
args = make_c_args(args)
return_type = c_types[return_type]
return c_func_template.format(name=name, upname=name.upper(),
return_type=return_type, args=args)
| def c_func_decl(name, return_type, args):
| args = make_c_args(args)
return_type = c_types[return_type]
return c_func_template.format(name=name, upname=name.upper(),
return_type=return_type, args=args)
| *{1}'.format(t, n) for t, n in zip(types, names))
c_func_template = "void F_FUNC({name}wrp, {upname}WRP)({return_type} *ret, {args});\n"
def c_func_decl(name, return_type, args):
| 64 | 64 | 53 | 11 | 53 | jeikabu/lumberyard | dev/Tools/Python/2.7.13/mac/Python.framework/Versions/2.7/lib/python2.7/site-packages/scipy/linalg/_generate_pyx.py | Python | c_func_decl | c_func_decl | 572 | 576 | 572 | 572 | e4c0b6bbf6b515be3e2f8cb2b84eedbdcd3b3c6b | bigcode/the-stack | train |
b811a1121be96c1c0b7ee908 | train | function | def fort_subroutine_wrapper(name, ret_type, args):
if name[0] in ['c', 's'] or name in ['zladiv', 'zdotu', 'zdotc']:
wrapper = 'w' + name
else:
wrapper = name
types, names = arg_names_and_types(args)
argnames = ', '.join(names)
names = [process_fortran_name(n, name) for n in names]
... | def fort_subroutine_wrapper(name, ret_type, args):
| if name[0] in ['c', 's'] or name in ['zladiv', 'zdotu', 'zdotc']:
wrapper = 'w' + name
else:
wrapper = name
types, names = arg_names_and_types(args)
argnames = ', '.join(names)
names = [process_fortran_name(n, name) for n in names]
argdecls = '\n '.join('{0} {1}'.format(f... | 3']
if ('x' in name or 'y' in name) and funcname[1:] not in xy_exclusions:
return name + '(n)'
if name in dims:
return name + dims[name]
return name
def fort_subroutine_wrapper(name, ret_type, args):
| 64 | 64 | 170 | 12 | 51 | jeikabu/lumberyard | dev/Tools/Python/2.7.13/mac/Python.framework/Versions/2.7/lib/python2.7/site-packages/scipy/linalg/_generate_pyx.py | Python | fort_subroutine_wrapper | fort_subroutine_wrapper | 544 | 557 | 544 | 544 | bb8ebac0a4db484769772c9178308fa8d87f6b63 | bigcode/the-stack | train |
4670d40bcedbf615dd47f4bb | train | function | def process_fortran_name(name, funcname):
if 'inc' in name:
return name
xy_exclusions = ['ladiv', 'lapy2', 'lapy3']
if ('x' in name or 'y' in name) and funcname[1:] not in xy_exclusions:
return name + '(n)'
if name in dims:
return name + dims[name]
return name
| def process_fortran_name(name, funcname):
| if 'inc' in name:
return name
xy_exclusions = ['ladiv', 'lapy2', 'lapy3']
if ('x' in name or 'y' in name) and funcname[1:] not in xy_exclusions:
return name + '(n)'
if name in dims:
return name + dims[name]
return name
| ab': '(ldab,*)', 'a': '(lda,*)', 'dl': '(*)',
'd': '(*)', 'du': '(*)', 'ap': '(*)', 'e': '(*)', 'lld': '(*)'}
def process_fortran_name(name, funcname):
| 63 | 64 | 91 | 10 | 53 | jeikabu/lumberyard | dev/Tools/Python/2.7.13/mac/Python.framework/Versions/2.7/lib/python2.7/site-packages/scipy/linalg/_generate_pyx.py | Python | process_fortran_name | process_fortran_name | 533 | 541 | 533 | 533 | b73464032d56fefe900fd32881212bb8b8414121 | bigcode/the-stack | train |
a76436c3c849e8fede891ba3 | train | function | def arg_names_and_types(args):
return zip(*[arg.split(' *') for arg in args.split(', ')])
| def arg_names_and_types(args):
| return zip(*[arg.split(' *') for arg in args.split(', ')])
| ',
'dselect3': '_dselect3',
'sselect2': '_sselect2',
'sselect3': '_sselect3',
'zselect1': '_zselect1',
'zselect2': '_zselect2'}
def arg_names_and_types(args):
| 63 | 64 | 25 | 7 | 56 | jeikabu/lumberyard | dev/Tools/Python/2.7.13/mac/Python.framework/Versions/2.7/lib/python2.7/site-packages/scipy/linalg/_generate_pyx.py | Python | arg_names_and_types | arg_names_and_types | 38 | 39 | 38 | 38 | 6b47aa3e7298b2c99c433cbc18e7f75a71230926 | bigcode/the-stack | train |
77dfa78c997d917f8f929128 | train | function | def make_c_args(args):
types, names = arg_names_and_types(args)
types = [c_types[arg] for arg in types]
return ', '.join('{0} *{1}'.format(t, n) for t, n in zip(types, names))
| def make_c_args(args):
| types, names = arg_names_and_types(args)
types = [c_types[arg] for arg in types]
return ', '.join('{0} *{1}'.format(t, n) for t, n in zip(types, names))
| =wrapper,
argnames=argnames, argdecls=argdecls,
ret_type=fortran_types[ret_type])
def generate_fortran(func_sigs):
return "\n".join(fort_subroutine_wrapper(*sig) for sig in func_sigs)
def make_c_args(args):
| 64 | 64 | 57 | 6 | 58 | jeikabu/lumberyard | dev/Tools/Python/2.7.13/mac/Python.framework/Versions/2.7/lib/python2.7/site-packages/scipy/linalg/_generate_pyx.py | Python | make_c_args | make_c_args | 564 | 567 | 564 | 564 | 32857a567f9540703cf769fd1d28f5af797fc404 | bigcode/the-stack | train |
f3cdcbcf58e2eae7c491270e | train | function | def generate_fortran(func_sigs):
return "\n".join(fort_subroutine_wrapper(*sig) for sig in func_sigs)
| def generate_fortran(func_sigs):
| return "\n".join(fort_subroutine_wrapper(*sig) for sig in func_sigs)
| tran_types[t], n)
for n, t in zip(names, types))
return fortran_template.format(name=name, wrapper=wrapper,
argnames=argnames, argdecls=argdecls,
ret_type=fortran_types[ret_type])
def generate_fortran(func_sigs):
| 64 | 64 | 29 | 8 | 56 | jeikabu/lumberyard | dev/Tools/Python/2.7.13/mac/Python.framework/Versions/2.7/lib/python2.7/site-packages/scipy/linalg/_generate_pyx.py | Python | generate_fortran | generate_fortran | 560 | 561 | 560 | 560 | ef94ea8c60d0f4f0f4b1a05ea89353a1fa33cee3 | bigcode/the-stack | train |
7855d619adc0e71f0e5ffe55 | train | function | def generate_blas_pxd(all_sigs):
body = '\n'.join(pxd_decl(*sig) for sig in all_sigs)
return blas_pxd_preamble + body
| def generate_blas_pxd(all_sigs):
| body = '\n'.join(pxd_decl(*sig) for sig in all_sigs)
return blas_pxd_preamble + body
| are needed in C/C++/Fortran,
# these wrappers should not be used.
# The original libraries should be linked directly.
ctypedef float s
ctypedef double d
ctypedef float complex c
ctypedef double complex z
"""
def generate_blas_pxd(all_sigs):
| 64 | 64 | 40 | 10 | 54 | jeikabu/lumberyard | dev/Tools/Python/2.7.13/mac/Python.framework/Versions/2.7/lib/python2.7/site-packages/scipy/linalg/_generate_pyx.py | Python | generate_blas_pxd | generate_blas_pxd | 483 | 485 | 483 | 483 | ee6101cdc0f5749f8e2233ee29b81cd732e21631 | bigcode/the-stack | train |
4b421d7f148ad045157d547d | train | function | def pyx_decl_func(name, ret_type, args, header_name):
argtypes, argnames = arg_names_and_types(args)
# Fix the case where one of the arguments has the same name as the
# abbreviation for the argument type.
# Otherwise the variable passed as an argument is considered overwrites
# the previous typedef... | def pyx_decl_func(name, ret_type, args, header_name):
| argtypes, argnames = arg_names_and_types(args)
# Fix the case where one of the arguments has the same name as the
# abbreviation for the argument type.
# Otherwise the variable passed as an argument is considered overwrites
# the previous typedef and Cython compilation fails.
if ret_type in argn... | '}
def arg_casts(arg):
if arg in ['npy_complex64', 'npy_complex128', '_cselect1', '_cselect2',
'_dselect2', '_dselect3', '_sselect2', '_sselect3',
'_zselect1', '_zselect2']:
return '<{0}*>'.format(arg)
return ''
def pyx_decl_func(name, ret_type, args, header_name):
| 95 | 96 | 321 | 15 | 80 | jeikabu/lumberyard | dev/Tools/Python/2.7.13/mac/Python.framework/Versions/2.7/lib/python2.7/site-packages/scipy/linalg/_generate_pyx.py | Python | pyx_decl_func | pyx_decl_func | 65 | 87 | 65 | 65 | aaafdbae68045d55118d5af268fb850f2a933481 | bigcode/the-stack | train |
9de7a654e1f3688c6e0e92bc | train | function | def make_lapack_pyx_preamble(all_sigs):
names = [sig[0] for sig in all_sigs]
return lapack_pyx_preamble.format("\n- ".join(names))
| def make_lapack_pyx_preamble(all_sigs):
| names = [sig[0] for sig in all_sigs]
return lapack_pyx_preamble.format("\n- ".join(names))
| *)
ctypedef bint _sselect3(s*, s*, s*)
ctypedef bint _zselect1(npy_complex128*)
ctypedef bint _zselect2(npy_complex128*, npy_complex128*)
'''
def make_lapack_pyx_preamble(all_sigs):
| 63 | 64 | 44 | 13 | 50 | jeikabu/lumberyard | dev/Tools/Python/2.7.13/mac/Python.framework/Versions/2.7/lib/python2.7/site-packages/scipy/linalg/_generate_pyx.py | Python | make_lapack_pyx_preamble | make_lapack_pyx_preamble | 212 | 214 | 212 | 212 | 7c462981eb03ed975e92d9a4b6a399de03218e53 | bigcode/the-stack | train |
522e43ca9bb35c95c1640d06 | train | function | def c_sub_decl(name, return_type, args):
args = make_c_args(args)
return c_sub_template.format(name=name, upname=name.upper(), args=args)
| def c_sub_decl(name, return_type, args):
| args = make_c_args(args)
return c_sub_template.format(name=name, upname=name.upper(), args=args)
| return_type = c_types[return_type]
return c_func_template.format(name=name, upname=name.upper(),
return_type=return_type, args=args)
c_sub_template = "void F_FUNC({name},{upname})({args});\n"
def c_sub_decl(name, return_type, args):
| 64 | 64 | 36 | 11 | 53 | jeikabu/lumberyard | dev/Tools/Python/2.7.13/mac/Python.framework/Versions/2.7/lib/python2.7/site-packages/scipy/linalg/_generate_pyx.py | Python | c_sub_decl | c_sub_decl | 581 | 583 | 581 | 581 | e30cd790ee1be480ea4e1dd79a836ce94b9b4c05 | bigcode/the-stack | train |
8dee0f2381e6cf505b850bfa | train | function | def make_all(blas_signature_file="cython_blas_signatures.txt",
lapack_signature_file="cython_lapack_signatures.txt",
blas_name="cython_blas",
lapack_name="cython_lapack",
blas_fortran_name="_blas_subroutine_wrappers.f",
lapack_fortran_name="_lapack_subrou... | def make_all(blas_signature_file="cython_blas_signatures.txt",
lapack_signature_file="cython_lapack_signatures.txt",
blas_name="cython_blas",
lapack_name="cython_lapack",
blas_fortran_name="_blas_subroutine_wrappers.f",
lapack_fortran_name="_lapack_subrou... | src_files = (os.path.abspath(__file__),
blas_signature_file,
lapack_signature_file)
dst_files = (blas_name + '.pyx',
blas_name + '.pxd',
blas_fortran_name,
blas_header_name,
lapack_name + '.pyx',
... | [0] != '#']
func_sigs = [split_signature(l) for l in ls if l.split(' ')[0] != 'void']
sub_sigs = [split_signature(l) for l in ls if l.split(' ')[0] == 'void']
all_sigs = list(sorted(func_sigs + sub_sigs, key=itemgetter(0)))
return func_sigs, sub_sigs, all_sigs
def all_newer(src_files, dst_files):
... | 240 | 240 | 802 | 104 | 136 | jeikabu/lumberyard | dev/Tools/Python/2.7.13/mac/Python.framework/Versions/2.7/lib/python2.7/site-packages/scipy/linalg/_generate_pyx.py | Python | make_all | make_all | 647 | 716 | 647 | 655 | e155e4dc1308b7b95eb4fc3b6aeb924a6f3a6326 | bigcode/the-stack | train |
b38b0cb71e6ce59f1411e892 | train | function | def filter_lines(ls):
ls = [l.strip() for l in ls if l != '\n' and l[0] != '#']
func_sigs = [split_signature(l) for l in ls if l.split(' ')[0] != 'void']
sub_sigs = [split_signature(l) for l in ls if l.split(' ')[0] == 'void']
all_sigs = list(sorted(func_sigs + sub_sigs, key=itemgetter(0)))
return f... | def filter_lines(ls):
| ls = [l.strip() for l in ls if l != '\n' and l[0] != '#']
func_sigs = [split_signature(l) for l in ls if l.split(' ')[0] != 'void']
sub_sigs = [split_signature(l) for l in ls if l.split(' ')[0] == 'void']
all_sigs = list(sorted(func_sigs + sub_sigs, key=itemgetter(0)))
return func_sigs, sub_sigs, al... | return "".join([preamble, cpp_guard, funcs, subs, c_end])
def split_signature(sig):
name_and_type, args = sig[:-1].split('(')
ret_type, name = name_and_type.split(' ')
return name, ret_type, args
def filter_lines(ls):
| 64 | 64 | 115 | 5 | 58 | jeikabu/lumberyard | dev/Tools/Python/2.7.13/mac/Python.framework/Versions/2.7/lib/python2.7/site-packages/scipy/linalg/_generate_pyx.py | Python | filter_lines | filter_lines | 633 | 638 | 633 | 633 | 5e7fd3a8001fae4b0cb0cbbef601ffc7ad30b9fb | bigcode/the-stack | train |
89f5c13004f52423ff32b4d8 | train | function | def generate_c_header(func_sigs, sub_sigs, all_sigs, lib_name):
funcs = "".join(c_func_decl(*sig) for sig in func_sigs)
subs = "\n" + "".join(c_sub_decl(*sig) for sig in sub_sigs)
if lib_name == 'LAPACK':
preamble = (c_preamble.format(lib=lib_name) + lapack_decls)
else:
preamble = c_prea... | def generate_c_header(func_sigs, sub_sigs, all_sigs, lib_name):
| funcs = "".join(c_func_decl(*sig) for sig in func_sigs)
subs = "\n" + "".join(c_sub_decl(*sig) for sig in sub_sigs)
if lib_name == 'LAPACK':
preamble = (c_preamble.format(lib=lib_name) + lapack_decls)
else:
preamble = c_preamble.format(lib=lib_name)
return "".join([preamble, cpp_guar... | zselect2)(npy_complex128*, npy_complex128*);
"""
cpp_guard = """
#ifdef __cplusplus
extern "C" {
#endif
"""
c_end = """
#ifdef __cplusplus
}
#endif
#endif
"""
def generate_c_header(func_sigs, sub_sigs, all_sigs, lib_name):
| 64 | 64 | 123 | 19 | 45 | jeikabu/lumberyard | dev/Tools/Python/2.7.13/mac/Python.framework/Versions/2.7/lib/python2.7/site-packages/scipy/linalg/_generate_pyx.py | Python | generate_c_header | generate_c_header | 617 | 624 | 617 | 617 | 1f0bf57b7b6297bc30745cf4f5a170a5daa80c8b | bigcode/the-stack | train |
3ea2f6e04ff4250c378b0b0c | train | function | def generate_blas_pyx(func_sigs, sub_sigs, all_sigs, header_name):
funcs = "\n".join(pyx_decl_func(*(s+(header_name,))) for s in func_sigs)
subs = "\n" + "\n".join(pyx_decl_sub(*(s[::2]+(header_name,)))
for s in sub_sigs)
return make_blas_pyx_preamble(all_sigs) + funcs + subs + b... | def generate_blas_pyx(func_sigs, sub_sigs, all_sigs, header_name):
| funcs = "\n".join(pyx_decl_func(*(s+(header_name,))) for s in func_sigs)
subs = "\n" + "\n".join(pyx_decl_sub(*(s[::2]+(header_name,)))
for s in sub_sigs)
return make_blas_pyx_preamble(all_sigs) + funcs + subs + blas_py_wrappers
| int incy = zy.strides[0] // sizeof(zy[0])
return zdotu(&n, &zx[0], &incx, &zy[0], &incy)
"""
def generate_blas_pyx(func_sigs, sub_sigs, all_sigs, header_name):
| 64 | 64 | 103 | 21 | 43 | jeikabu/lumberyard | dev/Tools/Python/2.7.13/mac/Python.framework/Versions/2.7/lib/python2.7/site-packages/scipy/linalg/_generate_pyx.py | Python | generate_blas_pyx | generate_blas_pyx | 418 | 422 | 418 | 418 | 93b73ef0c7b3dd6035a8e9660dbcb1acf5749674 | bigcode/the-stack | train |
66408e81ca047af568e8345c | train | function | def generate_lapack_pxd(all_sigs):
return lapack_pxd_preamble + '\n'.join(pxd_decl(*sig) for sig in all_sigs)
| def generate_lapack_pxd(all_sigs):
| return lapack_pxd_preamble + '\n'.join(pxd_decl(*sig) for sig in all_sigs)
| d*, d*)
ctypedef bint sselect2(s*, s*)
ctypedef bint sselect3(s*, s*, s*)
ctypedef bint zselect1(z*)
ctypedef bint zselect2(z*, z*)
"""
def generate_lapack_pxd(all_sigs):
| 64 | 64 | 37 | 11 | 53 | jeikabu/lumberyard | dev/Tools/Python/2.7.13/mac/Python.framework/Versions/2.7/lib/python2.7/site-packages/scipy/linalg/_generate_pyx.py | Python | generate_lapack_pxd | generate_lapack_pxd | 517 | 518 | 517 | 517 | 196908ccaa8cd198a55cb277dd544eff3e7d0c01 | bigcode/the-stack | train |
1ef347c51ac5a35c4fdef95b | train | class | class PackageRepository(rdf_structs.RDFProtoStruct):
"""Description of the configured repositories (Yum etc).
Describes the configured software package repositories.
"""
protobuf = sysinfo_pb2.PackageRepository
| class PackageRepository(rdf_structs.RDFProtoStruct):
| """Description of the configured repositories (Yum etc).
Describes the configured software package repositories.
"""
protobuf = sysinfo_pb2.PackageRepository
| ):
return None
class PCIDevice(rdf_structs.RDFProtoStruct):
"""A PCI device on the client.
This class describes a PCI device located on the client.
"""
protobuf = sysinfo_pb2.PCIDevice
class PackageRepository(rdf_structs.RDFProtoStruct):
| 64 | 64 | 45 | 12 | 51 | nkrios/grr | grr/core/grr_response_core/lib/rdfvalues/client.py | Python | PackageRepository | PackageRepository | 173 | 178 | 173 | 173 | cfd4023e26d2195d1b98cba09bf8d9d1d7a55645 | bigcode/the-stack | train |
398bfe7736c4b7b7cbec7d1e | train | class | class SoftwarePackages(rdf_structs.RDFProtoStruct):
"""A list of installed packages on the system."""
protobuf = sysinfo_pb2.SoftwarePackages
rdf_deps = [
SoftwarePackage,
]
| class SoftwarePackages(rdf_structs.RDFProtoStruct):
| """A list of installed packages on the system."""
protobuf = sysinfo_pb2.SoftwarePackages
rdf_deps = [
SoftwarePackage,
]
| (psutil.NoSuchProcess, psutil.AccessDenied):
pass
return response
class SoftwarePackage(rdf_structs.RDFProtoStruct):
"""Represent an installed package on the client."""
protobuf = sysinfo_pb2.SoftwarePackage
class SoftwarePackages(rdf_structs.RDFProtoStruct):
| 64 | 64 | 46 | 12 | 51 | nkrios/grr | grr/core/grr_response_core/lib/rdfvalues/client.py | Python | SoftwarePackages | SoftwarePackages | 502 | 508 | 502 | 502 | 3ed78f4ceea37e5fcf1011203fee16c207a95834 | bigcode/the-stack | train |
e1ecdc6d880c54955ec806fe | train | function | def GetClientURNFromPath(path):
"""Extracts the Client id from the path, if it is present."""
# Make sure that the first component of the path looks like a client.
try:
return ClientURN(path.split("/")[1])
except (type_info.TypeValueError, IndexError):
return None
| def GetClientURNFromPath(path):
| """Extracts the Client id from the path, if it is present."""
# Make sure that the first component of the path looks like a client.
try:
return ClientURN(path.split("/")[1])
except (type_info.TypeValueError, IndexError):
return None
| result = rdfvalue.RDFURN(self.Copy(age))
result.Update(path=utils.JoinPath(self._string_urn, path))
return result
def Queue(self):
"""Returns the queue name of this clients task queue."""
return self.Add("tasks")
def GetClientURNFromPath(path):
| 64 | 64 | 69 | 8 | 56 | nkrios/grr | grr/core/grr_response_core/lib/rdfvalues/client.py | Python | GetClientURNFromPath | GetClientURNFromPath | 155 | 162 | 155 | 155 | f4deed12c78c1e6f707bcd02c833c90ba6710c6c | bigcode/the-stack | train |
a5d6001ea0319e4504a2390a | train | class | class SoftwarePackage(rdf_structs.RDFProtoStruct):
"""Represent an installed package on the client."""
protobuf = sysinfo_pb2.SoftwarePackage
| class SoftwarePackage(rdf_structs.RDFProtoStruct):
| """Represent an installed package on the client."""
protobuf = sysinfo_pb2.SoftwarePackage
| Could be in state LISTEN.
if c.remote_address:
(conn.remote_address.ip,
conn.remote_address.port) = c.remote_address
except (psutil.NoSuchProcess, psutil.AccessDenied):
pass
return response
class SoftwarePackage(rdf_structs.RDFProtoStruct):
| 64 | 64 | 33 | 12 | 51 | nkrios/grr | grr/core/grr_response_core/lib/rdfvalues/client.py | Python | SoftwarePackage | SoftwarePackage | 497 | 499 | 497 | 497 | 7bd9b66c0e8a1d2f5cd472c9217e28e90371f640 | bigcode/the-stack | train |
86ea1906ebb2b8ba2bd68f8f | train | class | class ClientInformation(rdf_structs.RDFProtoStruct):
"""The GRR client information."""
protobuf = jobs_pb2.ClientInformation
| class ClientInformation(rdf_structs.RDFProtoStruct):
| """The GRR client information."""
protobuf = jobs_pb2.ClientInformation
| .type.type_infos.descriptor_names:
fields.add("users.%s" % field)
return sorted(fields)
class HardwareInfo(rdf_structs.RDFProtoStruct):
"""Various hardware information."""
protobuf = sysinfo_pb2.HardwareInfo
class ClientInformation(rdf_structs.RDFProtoStruct):
| 64 | 64 | 29 | 12 | 51 | nkrios/grr | grr/core/grr_response_core/lib/rdfvalues/client.py | Python | ClientInformation | ClientInformation | 338 | 340 | 338 | 338 | 536d106778367c6e3dcdbb0a2e449c1eebeefd65 | bigcode/the-stack | train |
c10750ce7359314093dfaf1d | train | class | class PCIDevice(rdf_structs.RDFProtoStruct):
"""A PCI device on the client.
This class describes a PCI device located on the client.
"""
protobuf = sysinfo_pb2.PCIDevice
| class PCIDevice(rdf_structs.RDFProtoStruct):
| """A PCI device on the client.
This class describes a PCI device located on the client.
"""
protobuf = sysinfo_pb2.PCIDevice
| , if it is present."""
# Make sure that the first component of the path looks like a client.
try:
return ClientURN(path.split("/")[1])
except (type_info.TypeValueError, IndexError):
return None
class PCIDevice(rdf_structs.RDFProtoStruct):
| 64 | 64 | 47 | 13 | 50 | nkrios/grr | grr/core/grr_response_core/lib/rdfvalues/client.py | Python | PCIDevice | PCIDevice | 165 | 170 | 165 | 165 | e70da1412324067d0fca1e97b994880f34bd0bee | bigcode/the-stack | train |
b258f7e44bc3062c36864e0e | train | class | class Process(rdf_structs.RDFProtoStruct):
"""Represent a process on the client."""
protobuf = sysinfo_pb2.Process
rdf_deps = [
rdf_client_network.NetworkConnection,
]
@classmethod
def FromPsutilProcess(cls, psutil_process):
response = cls()
process_fields = ["pid", "ppid", "name", "exe", "us... | class Process(rdf_structs.RDFProtoStruct):
| """Represent a process on the client."""
protobuf = sysinfo_pb2.Process
rdf_deps = [
rdf_client_network.NetworkConnection,
]
@classmethod
def FromPsutilProcess(cls, psutil_process):
response = cls()
process_fields = ["pid", "ppid", "name", "exe", "username", "terminal"]
with psutil_proce... | as type of the "users" field has changed from jobs.User to
# knowledge_base.User.
fields.remove("DEPRECATED_users")
# We used to have a "hostname" field that contained an fqdn and is
# therefore now renamed to "fqdn".
# TODO(amoser): Remove once the artifact has removed the provides
# section ... | 256 | 256 | 1,152 | 11 | 244 | nkrios/grr | grr/core/grr_response_core/lib/rdfvalues/client.py | Python | Process | Process | 354 | 494 | 354 | 354 | 2da44cbce0f733ded857a882252ec9f646bc1f8b | bigcode/the-stack | train |
bec317687f2b68e5cd58f08d | train | class | class KnowledgeBase(rdf_structs.RDFProtoStruct):
"""Information about the system and users."""
protobuf = knowledge_base_pb2.KnowledgeBase
rdf_deps = [
User,
]
def _CreateNewUser(self, kb_user):
self.users.Append(kb_user)
return ["users.%s" % k for k in kb_user.AsDict()]
def MergeOrAddUser(s... | class KnowledgeBase(rdf_structs.RDFProtoStruct):
| """Information about the system and users."""
protobuf = knowledge_base_pb2.KnowledgeBase
rdf_deps = [
User,
]
def _CreateNewUser(self, kb_user):
self.users.Append(kb_user)
return ["users.%s" % k for k in kb_user.AsDict()]
def MergeOrAddUser(self, kb_user):
"""Merge a user into existing ... | PwEntry,
]
class User(rdf_structs.RDFProtoStruct):
"""Information about the users."""
protobuf = knowledge_base_pb2.User
rdf_deps = [
PwEntry,
rdfvalue.RDFDatetime,
]
def __init__(self, initializer=None, age=None, **kwargs):
if isinstance(initializer, KnowledgeBaseUser):
# Knowledg... | 229 | 230 | 768 | 12 | 217 | nkrios/grr | grr/core/grr_response_core/lib/rdfvalues/client.py | Python | KnowledgeBase | KnowledgeBase | 234 | 330 | 234 | 234 | 428305a678bf1dfded629e314bc8bb6435a12974 | bigcode/the-stack | train |
c77fb6652773c3e036f78af6 | train | class | class LogMessage(rdf_structs.RDFProtoStruct):
"""A log message sent from the client to the server."""
protobuf = jobs_pb2.LogMessage
| class LogMessage(rdf_structs.RDFProtoStruct):
| """A log message sent from the client to the server."""
protobuf = jobs_pb2.LogMessage
| 2.SoftwarePackage
class SoftwarePackages(rdf_structs.RDFProtoStruct):
"""A list of installed packages on the system."""
protobuf = sysinfo_pb2.SoftwarePackages
rdf_deps = [
SoftwarePackage,
]
class LogMessage(rdf_structs.RDFProtoStruct):
| 63 | 64 | 34 | 12 | 51 | nkrios/grr | grr/core/grr_response_core/lib/rdfvalues/client.py | Python | LogMessage | LogMessage | 511 | 513 | 511 | 511 | ac882d2e8b10e390f770e40548573d08a6931645 | bigcode/the-stack | train |
621cea6dbe091f582f241ca1 | train | class | class RunKeyEntry(rdf_protodict.RDFValueArray):
"""Structure of a Run Key entry with keyname, filepath, and last written."""
rdf_type = RunKey
| class RunKeyEntry(rdf_protodict.RDFValueArray):
| """Structure of a Run Key entry with keyname, filepath, and last written."""
rdf_type = RunKey
| ict.AttributedDict,
SoftwarePackage,
rdf_client_fs.StatEntry,
]
# Start of the Registry Specific Data types
class RunKey(rdf_structs.RDFProtoStruct):
protobuf = sysinfo_pb2.RunKey
class RunKeyEntry(rdf_protodict.RDFValueArray):
| 64 | 64 | 39 | 14 | 49 | nkrios/grr | grr/core/grr_response_core/lib/rdfvalues/client.py | Python | RunKeyEntry | RunKeyEntry | 629 | 631 | 629 | 629 | 787abe25ab86bd8324e47bda1183fc1bc4baa936 | bigcode/the-stack | train |
2b99e572aec21b75d6ac2622 | train | class | class KnowledgeBaseUser(User):
"""Backwards compatibility for old clients.
Linux client action EnumerateUsers previously returned KnowledgeBaseUser
objects.
"""
| class KnowledgeBaseUser(User):
| """Backwards compatibility for old clients.
Linux client action EnumerateUsers previously returned KnowledgeBaseUser
objects.
"""
| .0.7.1.
super(User, self).__init__(initializer=None, age=age, **kwargs)
self.ParseFromString(initializer.SerializeToString())
else:
super(User, self).__init__(initializer=initializer, age=age, **kwargs)
class KnowledgeBaseUser(User):
| 64 | 64 | 33 | 6 | 58 | nkrios/grr | grr/core/grr_response_core/lib/rdfvalues/client.py | Python | KnowledgeBaseUser | KnowledgeBaseUser | 226 | 231 | 226 | 226 | 594cbae29703ea7b735dcbedc3d204287479bd47 | bigcode/the-stack | train |
d8ad59744f8d6fec5bdefdb5 | train | class | class ClientURN(rdfvalue.RDFURN):
"""A client urn has to have a specific form."""
# Valid client urns must match this expression.
CLIENT_ID_RE = re.compile(r"^(aff4:)?/?(?P<clientid>(c|C)\.[0-9a-fA-F]{16})$")
def __init__(self, initializer=None, age=None):
if isinstance(initializer, rdfvalue.RDFURN):
... | class ClientURN(rdfvalue.RDFURN):
| """A client urn has to have a specific form."""
# Valid client urns must match this expression.
CLIENT_ID_RE = re.compile(r"^(aff4:)?/?(?P<clientid>(c|C)\.[0-9a-fA-F]{16})$")
def __init__(self, initializer=None, age=None):
if isinstance(initializer, rdfvalue.RDFURN):
if not self.Validate(initializer... | .lib.rdfvalues import structs as rdf_structs
from grr_response_core.lib.util import compatibility
from grr_response_core.lib.util import precondition
from grr_response_proto import jobs_pb2
from grr_response_proto import knowledge_base_pb2
from grr_response_proto import sysinfo_pb2
# ntop does not exist on Windows.
# ... | 224 | 224 | 747 | 10 | 213 | nkrios/grr | grr/core/grr_response_core/lib/rdfvalues/client.py | Python | ClientURN | ClientURN | 65 | 152 | 65 | 65 | 9155fc5e883ca53653bdd8a058ee3fbb35e1dfb0 | bigcode/the-stack | train |
a64c647925005a126fd846b6 | train | class | class Group(rdf_structs.RDFProtoStruct):
"""Information about system posix groups."""
protobuf = knowledge_base_pb2.Group
rdf_deps = [
PwEntry,
]
| class Group(rdf_structs.RDFProtoStruct):
| """Information about system posix groups."""
protobuf = knowledge_base_pb2.Group
rdf_deps = [
PwEntry,
]
| sysinfo_pb2.ManagementAgent
rdf_deps = [
rdfvalue.RDFDatetime,
]
class PwEntry(rdf_structs.RDFProtoStruct):
"""Information about password structures."""
protobuf = knowledge_base_pb2.PwEntry
class Group(rdf_structs.RDFProtoStruct):
| 64 | 64 | 41 | 11 | 52 | nkrios/grr | grr/core/grr_response_core/lib/rdfvalues/client.py | Python | Group | Group | 198 | 203 | 198 | 198 | 91e2e7e2bf531071097cae3c73b4e9da52f0c418 | bigcode/the-stack | train |
95bac6e29bf2718668cdd763 | train | class | class Uname(rdf_structs.RDFProtoStruct):
"""A protobuf to represent the current system."""
protobuf = jobs_pb2.Uname
rdf_deps = [
rdfvalue.RDFDatetime,
]
@property
def arch(self):
"""Return a more standard representation of the architecture."""
if self.machine in ["x86_64", "AMD64", "i686"]:
... | class Uname(rdf_structs.RDFProtoStruct):
| """A protobuf to represent the current system."""
protobuf = jobs_pb2.Uname
rdf_deps = [
rdfvalue.RDFDatetime,
]
@property
def arch(self):
"""Return a more standard representation of the architecture."""
if self.machine in ["x86_64", "AMD64", "i686"]:
# 32 bit binaries running on AMD64 ... | conn.local_address.ip, conn.local_address.port = c.local_address
# Could be in state LISTEN.
if c.remote_address:
(conn.remote_address.ip,
conn.remote_address.port) = c.remote_address
except (psutil.NoSuchProcess, psutil.AccessDenied):
pas... | 195 | 195 | 653 | 12 | 182 | nkrios/grr | grr/core/grr_response_core/lib/rdfvalues/client.py | Python | Uname | Uname | 516 | 586 | 516 | 516 | dbed1e895219919cb8286167eb93563f21f44b31 | bigcode/the-stack | train |
e7391ce89a0791fca9252f0f | train | function | def _DecodeArgument(arg):
if compatibility.PY2:
return arg.decode(FS_ENCODING)
else:
return arg
| def _DecodeArgument(arg):
| if compatibility.PY2:
return arg.decode(FS_ENCODING)
else:
return arg
| disable=import-error
from wheel import pep425tags # pylint: disable=g-import-not-at-top
# pytype: enable=import-error
except ImportError:
pep425tags = None
FS_ENCODING = sys.getfilesystemencoding() or sys.getdefaultencoding()
def _DecodeArgument(arg):
| 64 | 64 | 28 | 6 | 58 | nkrios/grr | grr/core/grr_response_core/lib/rdfvalues/client.py | Python | _DecodeArgument | _DecodeArgument | 58 | 62 | 58 | 58 | 2fd7c7612de164f5280256cca30433da831633b6 | bigcode/the-stack | train |
5a999ec4a63b0dbbc21c2aa9 | train | class | class ManagementAgent(rdf_structs.RDFProtoStruct):
"""Description of the running management agent (puppet etc).
Describes the state, last run timestamp, and name of the management agent
installed on the system.
"""
protobuf = sysinfo_pb2.ManagementAgent
rdf_deps = [
rdfvalue.RDFDatetime,
]
| class ManagementAgent(rdf_structs.RDFProtoStruct):
| """Description of the running management agent (puppet etc).
Describes the state, last run timestamp, and name of the management agent
installed on the system.
"""
protobuf = sysinfo_pb2.ManagementAgent
rdf_deps = [
rdfvalue.RDFDatetime,
]
| info_pb2.PCIDevice
class PackageRepository(rdf_structs.RDFProtoStruct):
"""Description of the configured repositories (Yum etc).
Describes the configured software package repositories.
"""
protobuf = sysinfo_pb2.PackageRepository
class ManagementAgent(rdf_structs.RDFProtoStruct):
| 64 | 64 | 75 | 12 | 51 | nkrios/grr | grr/core/grr_response_core/lib/rdfvalues/client.py | Python | ManagementAgent | ManagementAgent | 181 | 190 | 181 | 181 | f90f82fd9b2b165870ce0d9e8ae83122b137c44c | bigcode/the-stack | train |
5ec299fe55ba49a52a65715f | train | class | class OSXServiceInformation(rdf_structs.RDFProtoStruct):
"""OSX Service (launchagent/daemon)."""
protobuf = sysinfo_pb2.OSXServiceInformation
rdf_deps = [
rdfvalue.RDFURN,
]
| class OSXServiceInformation(rdf_structs.RDFProtoStruct):
| """OSX Service (launchagent/daemon)."""
protobuf = sysinfo_pb2.OSXServiceInformation
rdf_deps = [
rdfvalue.RDFURN,
]
| WindowsServiceInformation(rdf_structs.RDFProtoStruct):
"""Windows Service."""
protobuf = sysinfo_pb2.WindowsServiceInformation
rdf_deps = [
rdf_protodict.Dict,
rdf_client_fs.StatEntry,
]
class OSXServiceInformation(rdf_structs.RDFProtoStruct):
| 63 | 64 | 52 | 13 | 50 | nkrios/grr | grr/core/grr_response_core/lib/rdfvalues/client.py | Python | OSXServiceInformation | OSXServiceInformation | 606 | 611 | 606 | 606 | c084e50c80e2d9a3e16847e0b67e3e8ed1972956 | bigcode/the-stack | train |
c695149112d8722d5368a906 | train | class | class HardwareInfo(rdf_structs.RDFProtoStruct):
"""Various hardware information."""
protobuf = sysinfo_pb2.HardwareInfo
| class HardwareInfo(rdf_structs.RDFProtoStruct):
| """Various hardware information."""
protobuf = sysinfo_pb2.HardwareInfo
| removed the provides
# section upstream.
fields.add("hostname")
fields.remove("users")
for field in self.users.type_descriptor.type.type_infos.descriptor_names:
fields.add("users.%s" % field)
return sorted(fields)
class HardwareInfo(rdf_structs.RDFProtoStruct):
| 64 | 64 | 29 | 12 | 52 | nkrios/grr | grr/core/grr_response_core/lib/rdfvalues/client.py | Python | HardwareInfo | HardwareInfo | 333 | 335 | 333 | 333 | 6df6ee838426bb4ec01974242f2d25839ab3fbe8 | bigcode/the-stack | train |
a024a71dd609899ad7ac4bb8 | train | class | class User(rdf_structs.RDFProtoStruct):
"""Information about the users."""
protobuf = knowledge_base_pb2.User
rdf_deps = [
PwEntry,
rdfvalue.RDFDatetime,
]
def __init__(self, initializer=None, age=None, **kwargs):
if isinstance(initializer, KnowledgeBaseUser):
# KnowledgeBaseUser was re... | class User(rdf_structs.RDFProtoStruct):
| """Information about the users."""
protobuf = knowledge_base_pb2.User
rdf_deps = [
PwEntry,
rdfvalue.RDFDatetime,
]
def __init__(self, initializer=None, age=None, **kwargs):
if isinstance(initializer, KnowledgeBaseUser):
# KnowledgeBaseUser was renamed to User, the protos are identical.... | protobuf = knowledge_base_pb2.PwEntry
class Group(rdf_structs.RDFProtoStruct):
"""Information about system posix groups."""
protobuf = knowledge_base_pb2.Group
rdf_deps = [
PwEntry,
]
class User(rdf_structs.RDFProtoStruct):
| 63 | 64 | 178 | 11 | 52 | nkrios/grr | grr/core/grr_response_core/lib/rdfvalues/client.py | Python | User | User | 206 | 223 | 206 | 206 | f644404e3df47071e2478340b906720552398149 | bigcode/the-stack | train |
fb731629fa9fc27a6c8e6a1a | train | class | class RunKey(rdf_structs.RDFProtoStruct):
protobuf = sysinfo_pb2.RunKey
| class RunKey(rdf_structs.RDFProtoStruct):
| protobuf = sysinfo_pb2.RunKey
| )."""
protobuf = sysinfo_pb2.LinuxServiceInformation
rdf_deps = [
rdf_protodict.AttributedDict,
SoftwarePackage,
rdf_client_fs.StatEntry,
]
# Start of the Registry Specific Data types
class RunKey(rdf_structs.RDFProtoStruct):
| 64 | 64 | 22 | 12 | 51 | nkrios/grr | grr/core/grr_response_core/lib/rdfvalues/client.py | Python | RunKey | RunKey | 625 | 626 | 625 | 625 | 0a04e49445cce80a635702b59841508ad5ca212d | bigcode/the-stack | train |
8cd51b8a82c4f4c754cc3844 | train | class | class LinuxServiceInformation(rdf_structs.RDFProtoStruct):
"""Linux Service (init/upstart/systemd)."""
protobuf = sysinfo_pb2.LinuxServiceInformation
rdf_deps = [
rdf_protodict.AttributedDict,
SoftwarePackage,
rdf_client_fs.StatEntry,
]
| class LinuxServiceInformation(rdf_structs.RDFProtoStruct):
| """Linux Service (init/upstart/systemd)."""
protobuf = sysinfo_pb2.LinuxServiceInformation
rdf_deps = [
rdf_protodict.AttributedDict,
SoftwarePackage,
rdf_client_fs.StatEntry,
]
| ServiceInformation(rdf_structs.RDFProtoStruct):
"""OSX Service (launchagent/daemon)."""
protobuf = sysinfo_pb2.OSXServiceInformation
rdf_deps = [
rdfvalue.RDFURN,
]
class LinuxServiceInformation(rdf_structs.RDFProtoStruct):
| 63 | 64 | 65 | 13 | 50 | nkrios/grr | grr/core/grr_response_core/lib/rdfvalues/client.py | Python | LinuxServiceInformation | LinuxServiceInformation | 614 | 621 | 614 | 614 | a3267b93a931438a7460e1bb920add0d76b4b960 | bigcode/the-stack | train |
ecc9c9665526395c9d865831 | train | class | class WindowsServiceInformation(rdf_structs.RDFProtoStruct):
"""Windows Service."""
protobuf = sysinfo_pb2.WindowsServiceInformation
rdf_deps = [
rdf_protodict.Dict,
rdf_client_fs.StatEntry,
]
| class WindowsServiceInformation(rdf_structs.RDFProtoStruct):
| """Windows Service."""
protobuf = sysinfo_pb2.WindowsServiceInformation
rdf_deps = [
rdf_protodict.Dict,
rdf_client_fs.StatEntry,
]
| 425tag=pep425tag,
)
class StartupInfo(rdf_structs.RDFProtoStruct):
protobuf = jobs_pb2.StartupInfo
rdf_deps = [
ClientInformation,
rdfvalue.RDFDatetime,
]
class WindowsServiceInformation(rdf_structs.RDFProtoStruct):
| 63 | 64 | 51 | 13 | 50 | nkrios/grr | grr/core/grr_response_core/lib/rdfvalues/client.py | Python | WindowsServiceInformation | WindowsServiceInformation | 597 | 603 | 597 | 597 | f88692b6444aa6d399c206f85a91991a172cf7c0 | bigcode/the-stack | train |
b31919ca67cf1709631cb0d0 | train | class | class BufferReference(rdf_structs.RDFProtoStruct):
"""Stores information about a buffer in a file on the client."""
protobuf = jobs_pb2.BufferReference
rdf_deps = [
rdf_paths.PathSpec,
]
def __eq__(self, other):
return self.data == other
| class BufferReference(rdf_structs.RDFProtoStruct):
| """Stores information about a buffer in a file on the client."""
protobuf = jobs_pb2.BufferReference
rdf_deps = [
rdf_paths.PathSpec,
]
def __eq__(self, other):
return self.data == other
| s.RDFProtoStruct):
"""Various hardware information."""
protobuf = sysinfo_pb2.HardwareInfo
class ClientInformation(rdf_structs.RDFProtoStruct):
"""The GRR client information."""
protobuf = jobs_pb2.ClientInformation
class BufferReference(rdf_structs.RDFProtoStruct):
| 64 | 64 | 65 | 12 | 51 | nkrios/grr | grr/core/grr_response_core/lib/rdfvalues/client.py | Python | BufferReference | BufferReference | 343 | 351 | 343 | 343 | 9f661699e79494f6f8cb4defb8a72be9caa6de7b | bigcode/the-stack | train |
c7bd7b35a4415e021f043ef4 | train | class | class PwEntry(rdf_structs.RDFProtoStruct):
"""Information about password structures."""
protobuf = knowledge_base_pb2.PwEntry
| class PwEntry(rdf_structs.RDFProtoStruct):
| """Information about password structures."""
protobuf = knowledge_base_pb2.PwEntry
| ).
Describes the state, last run timestamp, and name of the management agent
installed on the system.
"""
protobuf = sysinfo_pb2.ManagementAgent
rdf_deps = [
rdfvalue.RDFDatetime,
]
class PwEntry(rdf_structs.RDFProtoStruct):
| 63 | 64 | 30 | 12 | 51 | nkrios/grr | grr/core/grr_response_core/lib/rdfvalues/client.py | Python | PwEntry | PwEntry | 193 | 195 | 193 | 193 | b1079f5b725a63e8a0151f7d7ac301f769c875d3 | bigcode/the-stack | train |
51d70dc69c480a66731595c8 | train | class | class ClientCrash(rdf_structs.RDFProtoStruct):
"""Details of a client crash."""
protobuf = jobs_pb2.ClientCrash
rdf_deps = [
ClientInformation,
ClientURN,
rdfvalue.RDFDatetime,
rdfvalue.SessionID,
]
| class ClientCrash(rdf_structs.RDFProtoStruct):
| """Details of a client crash."""
protobuf = jobs_pb2.ClientCrash
rdf_deps = [
ClientInformation,
ClientURN,
rdfvalue.RDFDatetime,
rdfvalue.SessionID,
]
| ProtoStruct):
protobuf = sysinfo_pb2.RunKey
class RunKeyEntry(rdf_protodict.RDFValueArray):
"""Structure of a Run Key entry with keyname, filepath, and last written."""
rdf_type = RunKey
class ClientCrash(rdf_structs.RDFProtoStruct):
| 64 | 64 | 58 | 12 | 51 | nkrios/grr | grr/core/grr_response_core/lib/rdfvalues/client.py | Python | ClientCrash | ClientCrash | 634 | 642 | 634 | 634 | c881880f60935a28eaff750be4d84b6be7fd5983 | bigcode/the-stack | train |
f672cb47a6e0539abb2a0c12 | train | class | class StartupInfo(rdf_structs.RDFProtoStruct):
protobuf = jobs_pb2.StartupInfo
rdf_deps = [
ClientInformation,
rdfvalue.RDFDatetime,
]
| class StartupInfo(rdf_structs.RDFProtoStruct):
| protobuf = jobs_pb2.StartupInfo
rdf_deps = [
ClientInformation,
rdfvalue.RDFDatetime,
]
| architecture,
release=release,
version=version,
machine=uname[4], # x86, x86_64
kernel=kernel,
fqdn=fqdn,
pep425tag=pep425tag,
)
class StartupInfo(rdf_structs.RDFProtoStruct):
| 64 | 64 | 41 | 12 | 52 | nkrios/grr | grr/core/grr_response_core/lib/rdfvalues/client.py | Python | StartupInfo | StartupInfo | 589 | 594 | 589 | 589 | 8e889a5e8a5daad16444980a715782cdea999344 | bigcode/the-stack | train |
2bf93bd5aa4b53c04c9a72a8 | train | class | class VersionString(rdfvalue.RDFString):
@property
def versions(self):
result = []
for x in str(self).split("."):
try:
result.append(int(x))
except ValueError:
break
return result
| class VersionString(rdfvalue.RDFString):
@property
| def versions(self):
result = []
for x in str(self).split("."):
try:
result.append(int(x))
except ValueError:
break
return result
| client's summary data."""
protobuf = jobs_pb2.ClientSummary
rdf_deps = [
ClientInformation,
ClientURN,
rdf_client_network.Interface,
rdfvalue.RDFDatetime,
Uname,
User,
]
class VersionString(rdfvalue.RDFString):
@property
| 63 | 64 | 54 | 14 | 49 | nkrios/grr | grr/core/grr_response_core/lib/rdfvalues/client.py | Python | VersionString | VersionString | 658 | 669 | 658 | 660 | 388db55206870f68a10538be8f9db97680b3b154 | bigcode/the-stack | train |
866941defe408f5c1cced60a | train | class | class ClientSummary(rdf_structs.RDFProtoStruct):
"""Object containing client's summary data."""
protobuf = jobs_pb2.ClientSummary
rdf_deps = [
ClientInformation,
ClientURN,
rdf_client_network.Interface,
rdfvalue.RDFDatetime,
Uname,
User,
]
| class ClientSummary(rdf_structs.RDFProtoStruct):
| """Object containing client's summary data."""
protobuf = jobs_pb2.ClientSummary
rdf_deps = [
ClientInformation,
ClientURN,
rdf_client_network.Interface,
rdfvalue.RDFDatetime,
Uname,
User,
]
| .RDFProtoStruct):
"""Details of a client crash."""
protobuf = jobs_pb2.ClientCrash
rdf_deps = [
ClientInformation,
ClientURN,
rdfvalue.RDFDatetime,
rdfvalue.SessionID,
]
class ClientSummary(rdf_structs.RDFProtoStruct):
| 63 | 64 | 65 | 12 | 51 | nkrios/grr | grr/core/grr_response_core/lib/rdfvalues/client.py | Python | ClientSummary | ClientSummary | 645 | 655 | 645 | 645 | b2d198309468f7a018fa949f6b1bbcdba9f63208 | bigcode/the-stack | train |
4ccd1f027568e8643086220d | train | function | def test_get_media_info(ffmpeg, video_path):
media_info = ffmpeg.get_media_info(video_path)
assert media_info == {'width': 1280,
'height': 720,
'duration': 2.022}
| def test_get_media_info(ffmpeg, video_path):
| media_info = ffmpeg.get_media_info(video_path)
assert media_info == {'width': 1280,
'height': 720,
'duration': 2.022}
| import os
import tempfile
import pytest
from PIL import Image
from video_encoding import exceptions
from video_encoding.backends.ffmpeg import FFmpegBackend
def test_get_media_info(ffmpeg, video_path):
| 42 | 64 | 51 | 11 | 30 | fossabot/django-video-encoding | test_proj/media_library/tests/test_ffmpeg_backend.py | Python | test_get_media_info | test_get_media_info | 11 | 16 | 11 | 11 | b140559e9a44bdd73ff546cb019f57c4bac4e64f | bigcode/the-stack | train |
ec150de720bc8c0fc0fa1f02 | train | function | def test_get_thumbnail__invalid_time(ffmpeg, video_path):
with pytest.raises(exceptions.InvalidTimeError):
ffmpeg.get_thumbnail(video_path, at_time=1000000)
| def test_get_thumbnail__invalid_time(ffmpeg, video_path):
| with pytest.raises(exceptions.InvalidTimeError):
ffmpeg.get_thumbnail(video_path, at_time=1000000)
| = ffmpeg.get_thumbnail(video_path)
assert os.path.isfile(thumbnail_path)
with Image.open(thumbnail_path) as im:
width, height = im.size
assert width == 1280
assert height == 720
def test_get_thumbnail__invalid_time(ffmpeg, video_path):
| 64 | 64 | 38 | 13 | 50 | fossabot/django-video-encoding | test_proj/media_library/tests/test_ffmpeg_backend.py | Python | test_get_thumbnail__invalid_time | test_get_thumbnail__invalid_time | 51 | 53 | 51 | 51 | 8bda8ee6e312a8776adc997bbc324ea09a20da59 | bigcode/the-stack | train |
07cb08fa5ec388e9c80a9df7 | train | function | def test_check():
assert FFmpegBackend.check() == []
path = os.environ['PATH']
os.environ['PATH'] = ''
assert len(FFmpegBackend.check()) == 1
os.environ['PATH'] = path
| def test_check():
| assert FFmpegBackend.check() == []
path = os.environ['PATH']
os.environ['PATH'] = ''
assert len(FFmpegBackend.check()) == 1
os.environ['PATH'] = path
| close to the end of the video,
a video frame cannot be extracted.
"""
duration = ffmpeg.get_media_info(video_path)['duration']
with pytest.raises(exceptions.InvalidTimeError):
ffmpeg.get_thumbnail(
video_path, at_time=duration - offset,
)
def test_check():
| 64 | 64 | 51 | 4 | 60 | fossabot/django-video-encoding | test_proj/media_library/tests/test_ffmpeg_backend.py | Python | test_check | test_check | 72 | 78 | 72 | 72 | a4579926389d8081b1fa5b6ac72a90cdfb0f309a | bigcode/the-stack | train |
01c5fc7b3406b9aaf2a8d7cf | train | function | def test_get_thumbnail(ffmpeg, video_path):
thumbnail_path = ffmpeg.get_thumbnail(video_path)
assert os.path.isfile(thumbnail_path)
with Image.open(thumbnail_path) as im:
width, height = im.size
assert width == 1280
assert height == 720
| def test_get_thumbnail(ffmpeg, video_path):
| thumbnail_path = ffmpeg.get_thumbnail(video_path)
assert os.path.isfile(thumbnail_path)
with Image.open(thumbnail_path) as im:
width, height = im.size
assert width == 1280
assert height == 720
| assert percent == 100
assert os.path.isfile(target_path)
media_info = ffmpeg.get_media_info(target_path)
assert media_info == {'width': 568,
'height': 320,
'duration': 2.1}
def test_get_thumbnail(ffmpeg, video_path):
| 64 | 64 | 64 | 10 | 54 | fossabot/django-video-encoding | test_proj/media_library/tests/test_ffmpeg_backend.py | Python | test_get_thumbnail | test_get_thumbnail | 41 | 48 | 41 | 41 | 03de3630bf6a24e84e8caa1ff517c57ceb440045 | bigcode/the-stack | train |
5ae34149769f86be90fb3b32 | train | function | @pytest.mark.parametrize(
'offset', (0, 0.02),
)
def test_get_thumbnail__too_close_to_the_end(ffmpeg, video_path, offset):
"""
If the selected time point is close to the end of the video,
a video frame cannot be extracted.
"""
duration = ffmpeg.get_media_info(video_path)['duration']
with py... | @pytest.mark.parametrize(
'offset', (0, 0.02),
)
def test_get_thumbnail__too_close_to_the_end(ffmpeg, video_path, offset):
| """
If the selected time point is close to the end of the video,
a video frame cannot be extracted.
"""
duration = ffmpeg.get_media_info(video_path)['duration']
with pytest.raises(exceptions.InvalidTimeError):
ffmpeg.get_thumbnail(
video_path, at_time=duration - offset,
... | , video_path):
with pytest.raises(exceptions.InvalidTimeError):
ffmpeg.get_thumbnail(video_path, at_time=1000000)
@pytest.mark.parametrize(
'offset', (0, 0.02),
)
def test_get_thumbnail__too_close_to_the_end(ffmpeg, video_path, offset):
| 64 | 64 | 104 | 35 | 29 | fossabot/django-video-encoding | test_proj/media_library/tests/test_ffmpeg_backend.py | Python | test_get_thumbnail__too_close_to_the_end | test_get_thumbnail__too_close_to_the_end | 56 | 69 | 56 | 59 | 74beb76d18bd0f37508492a3200f16d728371573 | bigcode/the-stack | train |
11df362a9c9a24dcf05281c5 | train | function | def test_encode(ffmpeg, video_path):
__, target_path = tempfile.mkstemp(suffix='.mp4')
encoding = ffmpeg.encode(video_path, target_path, ['-vf', 'scale=-2:320',
'-r', '20',
'-codec:v', 'libx264'])
p... | def test_encode(ffmpeg, video_path):
| __, target_path = tempfile.mkstemp(suffix='.mp4')
encoding = ffmpeg.encode(video_path, target_path, ['-vf', 'scale=-2:320',
'-r', '20',
'-codec:v', 'libx264'])
percent = next(encoding)
assert 0 ... | FFmpegBackend
def test_get_media_info(ffmpeg, video_path):
media_info = ffmpeg.get_media_info(video_path)
assert media_info == {'width': 1280,
'height': 720,
'duration': 2.022}
def test_encode(ffmpeg, video_path):
| 64 | 64 | 168 | 9 | 55 | fossabot/django-video-encoding | test_proj/media_library/tests/test_ffmpeg_backend.py | Python | test_encode | test_encode | 19 | 38 | 19 | 19 | 033411ba075008ddb024071da684cc854090e7eb | bigcode/the-stack | train |
28f0c7b7f1dfdab30eec920a | train | class | class ContainerDimension(Document):
pass
| class ContainerDimension(Document):
| pass
| # -*- coding: utf-8 -*-
# Copyright (c) 2015, Opensource Solutions Philippines and contributors
# For license information, please see license.txt
from __future__ import unicode_literals
import frappe
from frappe.model.document import Document
class ContainerDimension(Document):
| 57 | 64 | 7 | 5 | 51 | ahmadRagheb/cargonext | cargonext/general_setup/doctype/container_dimension/container_dimension.py | Python | ContainerDimension | ContainerDimension | 9 | 10 | 9 | 9 | 89f5f84147466b463a6b802c4fbfb65d7d6bbb13 | bigcode/the-stack | train |
17f3463c2a7888557d9272e0 | train | class | class Migration(migrations.Migration):
dependencies = [("variants", "0013_smallvariantflags_flag_summary")]
operations = [
migrations.RemoveIndex(model_name="smallvariant", name="variants_sm_exac_fr_f91f1b_idx"),
migrations.RemoveIndex(model_name="smallvariant", name="variants_sm_exac_fr_b0171... | class Migration(migrations.Migration):
| dependencies = [("variants", "0013_smallvariantflags_flag_summary")]
operations = [
migrations.RemoveIndex(model_name="smallvariant", name="variants_sm_exac_fr_f91f1b_idx"),
migrations.RemoveIndex(model_name="smallvariant", name="variants_sm_exac_fr_b0171c_idx"),
migrations.RemoveIndex(... | # -*- coding: utf-8 -*-
# Generated by Django 1.11.16 on 2018-11-15 14:26
from __future__ import unicode_literals
from django.db import migrations
class Migration(migrations.Migration):
| 52 | 64 | 190 | 7 | 44 | brand-fabian/varfish-server | variants/migrations/0014_auto_20181115_1426.py | Python | Migration | Migration | 8 | 20 | 8 | 9 | 886c38a758540585d7d452607aa0a57506ad2bf8 | bigcode/the-stack | train |
f4f35e4242d680d124563edd | train | function | @app.route("/form-params", methods=['POST'])
def form_params():
assert request.form['param1'] == 'value1'
assert request.form['param2'] == ''
assert request.form['param3'] == 'a=b'
assert request.form['param4'] == 'a%3db'
return ''
| @app.route("/form-params", methods=['POST'])
def form_params():
| assert request.form['param1'] == 'value1'
assert request.form['param2'] == ''
assert request.form['param3'] == 'a=b'
assert request.form['param4'] == 'a%3db'
return ''
| from tests import app
from flask import request
@app.route("/form-params", methods=['POST'])
def form_params():
| 25 | 64 | 69 | 15 | 9 | youhavethewrong/hurl | integration/tests/form_params.py | Python | form_params | form_params | 4 | 10 | 4 | 5 | 8738f584802356ec78c0f3c7c0bfb10a3e3fbee9 | bigcode/the-stack | train |
5dfecd02b7f99f7c5c9e0950 | train | class | class Column(object):
'''One column of rectangles in a `Layer`'''
def __init__(self, x, w, yh_list=None):
self.x = x
self.w = w
self.yh_list = [] if yh_list is None else yh_list
self.finished_updating_yh_list()
def size(self):
return len(self.yh_list)
@property
def h(self):
y, h = ... | class Column(object):
| '''One column of rectangles in a `Layer`'''
def __init__(self, x, w, yh_list=None):
self.x = x
self.w = w
self.yh_list = [] if yh_list is None else yh_list
self.finished_updating_yh_list()
def size(self):
return len(self.yh_list)
@property
def h(self):
y, h = self.yh_list[-1]
r... | , y, color, alpha=0.8)
plt.fill(x, y, color, alpha=0.4)
@property
def right(self):
return self.x + self.w
@property
def top(self):
return self.y + self.h
class Column(object):
| 64 | 64 | 171 | 4 | 59 | koreiklein/dist_zero | scripts/wooden_blocks.py | Python | Column | Column | 72 | 96 | 72 | 72 | 13e520cd45b3bcd1197bf53ce3ced018760af649 | bigcode/the-stack | train |
b29c49deac4e12ae86fc9787 | train | function | def initial(nsrcs, ntgts, max_above=10, max_below=10):
return RectangleSolver(
max_above=max_above,
max_below=max_below,
srcs=Layer(columns=[Column(x=x, w=1.0 / nsrcs, yh_list=[(0.0, 1.0)]) for x in partition(nsrcs)]),
tgts=Layer(columns=[Column(x=0.0, w=1.0, yh_list=[(y, 1.0 / ntgts) for y in... | def initial(nsrcs, ntgts, max_above=10, max_below=10):
| return RectangleSolver(
max_above=max_above,
max_below=max_below,
srcs=Layer(columns=[Column(x=x, w=1.0 / nsrcs, yh_list=[(0.0, 1.0)]) for x in partition(nsrcs)]),
tgts=Layer(columns=[Column(x=0.0, w=1.0, yh_list=[(y, 1.0 / ntgts) for y in partition(ntgts)])]))
| =================================================
def partition(n):
result = 0.0
inc = 1.0 / n
while result < 1.0:
yield result
result += inc
def initial(nsrcs, ntgts, max_above=10, max_below=10):
| 64 | 64 | 130 | 22 | 41 | koreiklein/dist_zero | scripts/wooden_blocks.py | Python | initial | initial | 249 | 254 | 249 | 249 | d9d7a57831ae629bf402c55bb0c4b5847649eb9e | bigcode/the-stack | train |
e398e928e2eb1e9fb437b8c9 | train | function | def partition(n):
result = 0.0
inc = 1.0 / n
while result < 1.0:
yield result
result += inc
| def partition(n):
| result = 0.0
inc = 1.0 / n
while result < 1.0:
yield result
result += inc
| (column=column, cur_y=cur_y)
column.yh_list.append((cur_y, cur_h))
cur_y += cur_h
column.finished_updating_yh_list()
return Layer(columns=columns)
# =================================================
# =============== Testing/demo code ===============
# =====================================... | 64 | 64 | 40 | 4 | 59 | koreiklein/dist_zero | scripts/wooden_blocks.py | Python | partition | partition | 241 | 246 | 241 | 241 | b59960be935e7220934a5e9139c257e889be94f8 | bigcode/the-stack | train |
fdf40c3305b1c2b86bbd630d | train | function | def test_rectangles():
i = 0
for xstart in range(-5, 3):
for ystart in range(-5, 3):
x = [xstart, xstart + 1, xstart + 1, xstart]
y = [ystart, ystart, ystart + 1, ystart + 1]
plt.plot(x, y, PALLETTE[i % len(PALLETTE)], alpha=0.8)
plt.fill(x, y, PALLETTE[i % len(PALLETTE)], alpha=0.5)
... | def test_rectangles():
| i = 0
for xstart in range(-5, 3):
for ystart in range(-5, 3):
x = [xstart, xstart + 1, xstart + 1, xstart]
y = [ystart, ystart, ystart + 1, ystart + 1]
plt.plot(x, y, PALLETTE[i % len(PALLETTE)], alpha=0.8)
plt.fill(x, y, PALLETTE[i % len(PALLETTE)], alpha=0.5)
i += 1
plt.ylim(... | initial(nsrcs=400, ntgts=428, max_above=11, max_below=11)
layers = solver.solve()
print(f'total blocks = {solver.size()}')
for layer in reversed(layers):
layer.plot()
plt.show()
def test_rectangles():
| 64 | 64 | 157 | 5 | 59 | koreiklein/dist_zero | scripts/wooden_blocks.py | Python | test_rectangles | test_rectangles | 266 | 279 | 266 | 266 | 0de55035c7973290329fd37a70ac64a94c90e288 | bigcode/the-stack | train |
d45770e5db439012e8ed5b5f | train | class | class RectangleSolver(object):
def __init__(self, srcs, tgts, max_below, max_above):
self.max_below = max_below
self.max_above = max_above
self.src_layer = srcs
self.tgt_layer = tgts
self.cur_layer = self.src_layer
self.layers = [self.src_layer]
self.h = self.src_layer.h
if abs(self... | class RectangleSolver(object):
| def __init__(self, srcs, tgts, max_below, max_above):
self.max_below = max_below
self.max_above = max_above
self.src_layer = srcs
self.tgt_layer = tgts
self.cur_layer = self.src_layer
self.layers = [self.src_layer]
self.h = self.src_layer.h
if abs(self.h - self.tgt_layer.h) >= epsil... | [k:l]:
yield Rectangle(x=column.x, y=y, w=column.w, h=h)
def count_overlapping(self, rectangle):
i = bisect.bisect_left(self.left_endpoints, rectangle.x)
j = bisect.bisect_left(self.right_endpoints, rectangle.right) + 1
total = 0
for column in self.columns[i:j]:
k = bisect.bisect_left(c... | 221 | 222 | 743 | 5 | 216 | koreiklein/dist_zero | scripts/wooden_blocks.py | Python | RectangleSolver | RectangleSolver | 164 | 233 | 164 | 164 | 0d1d03233f1c69531331b41d9f2e1d5108b0b752 | bigcode/the-stack | train |
6c0394c0032249014f6c11e5 | train | function | def run():
demo_solver()
| def run():
| demo_solver()
| )], alpha=0.8)
plt.fill(x, y, PALLETTE[i % len(PALLETTE)], alpha=0.5)
i += 1
plt.ylim((-5, 5))
plt.xlim((-5, 5))
plt.show()
def run():
| 64 | 64 | 7 | 3 | 61 | koreiklein/dist_zero | scripts/wooden_blocks.py | Python | run | run | 282 | 283 | 282 | 282 | cb0fb40303a40a6596701d914c21628ac1db4cc3 | bigcode/the-stack | train |
bf50930f35a6fbf2ddf81621 | train | function | def demo_solver():
solver = initial(nsrcs=400, ntgts=428, max_above=11, max_below=11)
layers = solver.solve()
print(f'total blocks = {solver.size()}')
for layer in reversed(layers):
layer.plot()
plt.show()
| def demo_solver():
| solver = initial(nsrcs=400, ntgts=428, max_above=11, max_below=11)
layers = solver.solve()
print(f'total blocks = {solver.size()}')
for layer in reversed(layers):
layer.plot()
plt.show()
| , 1.0)]) for x in partition(nsrcs)]),
tgts=Layer(columns=[Column(x=0.0, w=1.0, yh_list=[(y, 1.0 / ntgts) for y in partition(ntgts)])]))
def demo_solver():
| 63 | 64 | 66 | 4 | 59 | koreiklein/dist_zero | scripts/wooden_blocks.py | Python | demo_solver | demo_solver | 257 | 263 | 257 | 257 | 9f978a9521a2e7772a7a08437b024f309727d08c | bigcode/the-stack | train |
d5ad6c9487453ef0657566ae | train | class | class Rectangle(object):
'''A half-open 2-dimensional rectangle in the x-y plane.'''
def __init__(self, x, y, w, h):
self.x = x
self.y = y
self.w = w
self.h = h
def __repr__(self):
return f"(x={self.x}, y={self.y}, w={self.w}, h={self.h})"
def plot(self, color):
x = [self.x, self.righ... | class Rectangle(object):
| '''A half-open 2-dimensional rectangle in the x-y plane.'''
def __init__(self, x, y, w, h):
self.x = x
self.y = y
self.w = w
self.h = h
def __repr__(self):
return f"(x={self.x}, y={self.y}, w={self.w}, h={self.h})"
def plot(self, color):
x = [self.x, self.right, self.right, self.x]
... | is meant to inspire a full solution to be added to DistZero and used by LinkNodes.
'''
import bisect
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.colors as colors
PALLETTE = list(colors.TABLEAU_COLORS.values())
epsilon = 0.003
class Rectangle(object):
| 64 | 64 | 194 | 4 | 59 | koreiklein/dist_zero | scripts/wooden_blocks.py | Python | Rectangle | Rectangle | 45 | 69 | 45 | 45 | 7b54273f8a912076457aebdb83635e6afa6df550 | bigcode/the-stack | train |
648cc9c890c95e860a4fa1a8 | train | class | class Layer(object):
'''Represents a single layer of boxes in a solution to a boxes problem.'''
def __init__(self, columns=None):
self.columns = [] if columns is None else columns
self.left_endpoints = [column.x for column in self.columns]
self.right_endpoints = [column.right for column in self.columns... | class Layer(object):
| '''Represents a single layer of boxes in a solution to a boxes problem.'''
def __init__(self, columns=None):
self.columns = [] if columns is None else columns
self.left_endpoints = [column.x for column in self.columns]
self.right_endpoints = [column.right for column in self.columns]
self._h = None... | self.y + self.h
class Column(object):
'''One column of rectangles in a `Layer`'''
def __init__(self, x, w, yh_list=None):
self.x = x
self.w = w
self.yh_list = [] if yh_list is None else yh_list
self.finished_updating_yh_list()
def size(self):
return len(self.yh_list)
@property
def h... | 181 | 181 | 605 | 4 | 176 | koreiklein/dist_zero | scripts/wooden_blocks.py | Python | Layer | Layer | 99 | 161 | 99 | 99 | 0c423a1f5b352dea1a3ea61b66f48ccb6a3fe743 | bigcode/the-stack | train |
4e02a614dfbafe8c340d3df0 | train | class | class Migration(migrations.Migration):
dependencies = [
('collect', '0001_initial'),
]
operations = [
migrations.AlterUniqueTogether(
name='digestcounter',
unique_together=set(),
),
migrations.AlterUniqueTogether(
name='digestpartial',
... | class Migration(migrations.Migration):
| dependencies = [
('collect', '0001_initial'),
]
operations = [
migrations.AlterUniqueTogether(
name='digestcounter',
unique_together=set(),
),
migrations.AlterUniqueTogether(
name='digestpartial',
unique_together=set(),
... | # Generated by Django 2.2.7 on 2019-11-21 11:48
from django.db import migrations, models
class Migration(migrations.Migration):
| 38 | 64 | 134 | 7 | 30 | eHealthAfrica/aether | aether-odk-module/aether/odk/api/collect/migrations/0002_unique_together_constraint.py | Python | Migration | Migration | 6 | 29 | 6 | 7 | f2d3145735ece442d88b26afa9e8f9246143c68a | bigcode/the-stack | train |
3c006125995ce2e63631b97c | train | function | def allow_apply_task(account):
stat_logger.info("start request cloud AuthorityApplied")
institution_signature_item = item.InstitutionSignatureItem(fateManagerId=account.fate_manager_id,
appKey=account.app_key,
... | def allow_apply_task(account):
| stat_logger.info("start request cloud AuthorityApplied")
institution_signature_item = item.InstitutionSignatureItem(fateManagerId=account.fate_manager_id,
appKey=account.app_key,
appSecr... | update_institutions_models:
model_info = institutions_model.to_json()
db_operator.DBOperator.update_entity(ApplyInstitutionsInfo, model_info)
for institutions_info in add_institutions_info:
db_operator.DBOperator.create_entity(ApplyInstitutionsInfo, institutions_info)
def allow_apply_task(a... | 64 | 64 | 176 | 6 | 58 | FederatedAI/FATE-Cloud | fate-manager/fate_manager/controller/apply.py | Python | allow_apply_task | allow_apply_task | 71 | 87 | 71 | 71 | 77fc7d1dcc150d59488592b83314cc25a0c183e3 | bigcode/the-stack | train |
3177eecd57aaf79a19203dbc | train | function | def apply_result_task(account):
stat_logger.info("start request cloud ApprovedUri")
institution_signature_item = item.InstitutionSignatureItem(fateManagerId=account.fate_manager_id,
appKey=account.app_key,
... | def apply_result_task(account):
| stat_logger.info("start request cloud ApprovedUri")
institution_signature_item = item.InstitutionSignatureItem(fateManagerId=account.fate_manager_id,
appKey=account.app_key,
appSecret=ac... | from fate_manager.db.db_models import AccountInfo, ApplyInstitutionsInfo
from fate_manager.entity import item
from fate_manager.entity.types import IsValidType, UserRole, ApplyReadStatusType
from fate_manager.operation import db_operator
from fate_manager.settings import stat_logger
from fate_manager.utils.request_clou... | 74 | 216 | 723 | 6 | 67 | FederatedAI/FATE-Cloud | fate-manager/fate_manager/controller/apply.py | Python | apply_result_task | apply_result_task | 9 | 68 | 9 | 9 | 9113c380f00c3585fb7ad8413c4561cd2fc8a8da | bigcode/the-stack | train |
3442ad5539bad0c39f9b673d | train | class | class VillagerType(Constants):
WORKER = _Globals.WORKER.value
GUARD = _Globals.GUARD.value
FARMER = _Globals.FARMER.value
MERCHANT = _Globals.MERCHANT.value
# added for easy access when adding a "villager" to the playermat
BARBARIAN = _Globals.BARBARIAN.value
| class VillagerType(Constants):
| WORKER = _Globals.WORKER.value
GUARD = _Globals.GUARD.value
FARMER = _Globals.FARMER.value
MERCHANT = _Globals.MERCHANT.value
# added for easy access when adding a "villager" to the playermat
BARBARIAN = _Globals.BARBARIAN.value
| # Sorted by Animal Preference Gathering - especially Joan
class AnimalType(Constants):
PIG = _Globals.PIG.value
HORSE = _Globals.HORSE.value
CHICKEN = _Globals.CHICKEN.value
COW = _Globals.COW.value
class VillagerType(Constants):
| 64 | 64 | 83 | 6 | 57 | Karins-Coils/CastleDice | castledice/common/constants.py | Python | VillagerType | VillagerType | 81 | 88 | 81 | 81 | 3ccb2d8cd0ca797a440b68c4f811e7b3814637ee | bigcode/the-stack | train |
04bff0c762931e209eb15682 | train | class | class MarketCardType(Constants):
BARD = "M01"
HUNGRY_BARBARIANS = "M02"
JESTER = "M03"
MAIDEN = "M04"
SHEPHERD = "M05"
VOLUNTEER = "M06"
| class MarketCardType(Constants):
| BARD = "M01"
HUNGRY_BARBARIANS = "M02"
JESTER = "M03"
MAIDEN = "M04"
SHEPHERD = "M05"
VOLUNTEER = "M06"
| "
TALL_KEEP = "C11"
WALL_ANIMAL = "C12"
WALL_FARMER = "C13"
WALL_GUARD = "C14"
WALL_MERCHANT = "C15"
WALL_WORKER = "C16"
class MarketCardType(Constants):
| 64 | 64 | 66 | 6 | 58 | Karins-Coils/CastleDice | castledice/common/constants.py | Python | MarketCardType | MarketCardType | 141 | 147 | 141 | 141 | 51628e6ec558cafb1b773103bf26047b0f2cd4c5 | bigcode/the-stack | train |
79c0322445945321f3d33c4a | train | class | class PhaseType(Constants):
"""
These attributes do not stem from _Globals, as their explicit numbers are needed for
ordering and display
"""
ORDER = 1
DRAW = 2
CHOOSE = 3
ROLL = 4
GATHER = 5
MARKET = 6
WORKERS = 7
MERCHANTS = 8
BUILD = 9
BARBARIANS = 10
| class PhaseType(Constants):
| """
These attributes do not stem from _Globals, as their explicit numbers are needed for
ordering and display
"""
ORDER = 1
DRAW = 2
CHOOSE = 3
ROLL = 4
GATHER = 5
MARKET = 6
WORKERS = 7
MERCHANTS = 8
BUILD = 9
BARBARIANS = 10
| V01"
GUARD = "V02"
KINGS_MESSENGER = "V03"
MERCHANT = "V04"
SOLDIER = "V05"
WISE_GRANDFATHER = "V06"
WORKER = "V07"
class PhaseType(Constants):
| 64 | 64 | 101 | 5 | 59 | Karins-Coils/CastleDice | castledice/common/constants.py | Python | PhaseType | PhaseType | 165 | 180 | 165 | 165 | 81b8269b99c43c46753d03d5d8679c2b699dfe9d | bigcode/the-stack | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.