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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
d1c25cc78eafef806c4fdc62 | train | function | def enlistaAlumnos(cursor):
selectAlumnos="SELECT * FROM alumno"
cursor.execute(selectAlumnos)
for campo in cursor:
print("\nID: ",campo[0])
print("NOMBRE: "+campo[1])
print("APELLIDO PATERNO: ",campo[2])
print("APELLIDO MATERNO: ",campo[3])
print("GRUPO: ",campo[4])... | def enlistaAlumnos(cursor):
| selectAlumnos="SELECT * FROM alumno"
cursor.execute(selectAlumnos)
for campo in cursor:
print("\nID: ",campo[0])
print("NOMBRE: "+campo[1])
print("APELLIDO PATERNO: ",campo[2])
print("APELLIDO MATERNO: ",campo[3])
print("GRUPO: ",campo[4])
| enlistaAlumnos(cursor)
def borraAlumno(cursor,idAlumno):
borrarAlumno="DELETE FROM alumno WHERE alumno_id="+idAlumno+";"
cursor.execute(borrarAlumno)
bd.commit()
print("se elimino el alumno")
enlistaAlumnos(cursor)
def enlistaAlumnos(cursor):
| 64 | 64 | 94 | 7 | 57 | josrangel/SQLiteEjemploPython | archivoSqlite.py | Python | enlistaAlumnos | enlistaAlumnos | 27 | 36 | 27 | 27 | 825a0567fc7190b9a0de2a1d5965e5169a45f90e | bigcode/the-stack | train |
1697b438342f72dce341e98c | train | function | def ingresaAlumno(cursor, nombre, apellidoPaterno, apellidoMaterno, grupo):
insertaAlumno="INSERT INTO alumno(alumno_nombre, alumno_apellidopat, alumno_apellidomat, alumno_grupo) VALUES('"+nombre+"','"+apellidoPaterno+"','"+apellidoMaterno+"','"+grupo+"');"
cursor.execute(insertaAlumno)
bd.commit()
prin... | def ingresaAlumno(cursor, nombre, apellidoPaterno, apellidoMaterno, grupo):
| insertaAlumno="INSERT INTO alumno(alumno_nombre, alumno_apellidopat, alumno_apellidomat, alumno_grupo) VALUES('"+nombre+"','"+apellidoPaterno+"','"+apellidoMaterno+"','"+grupo+"');"
cursor.execute(insertaAlumno)
bd.commit()
print("se inserto el alumno")
enlistaAlumnos(cursor)
| alumno_apellidopat varchar(20) NOT NULL,
alumno_apellidomat varchar(20) NOT NULL,
alumno_grupo varchar(10)
);''');
print("tabla Alumno creada")
def ingresaAlumno(cursor, nombre, apellidoPaterno, apellidoMaterno, grupo):
| 64 | 64 | 94 | 18 | 46 | josrangel/SQLiteEjemploPython | archivoSqlite.py | Python | ingresaAlumno | ingresaAlumno | 13 | 18 | 13 | 13 | 19f93691da04d25fc0732cc3ef6428b42983543c | bigcode/the-stack | train |
d51e0c321b567b7e40d1e582 | train | function | def measure_time(f_name):
"""This is a decorator that measures performance of the decorated function
:param function_name: The name of the decorated function
"""
def wrapper(f):
f_inner_name = f_name
if f_inner_name is None:
f_inner_name = f.__name__
def wrapped_f(... | def measure_time(f_name):
| """This is a decorator that measures performance of the decorated function
:param function_name: The name of the decorated function
"""
def wrapper(f):
f_inner_name = f_name
if f_inner_name is None:
f_inner_name = f.__name__
def wrapped_f(*args, **kwargs):
... | coding: utf-8 -*-
# Copyright (c) 2012-2015, Anima Istanbul
#
# This module is part of anima-tools and is released under the BSD 2
# License: http://www.opensource.org/licenses/BSD-2-Clause
import time
def measure_time(f_name):
| 64 | 64 | 136 | 6 | 57 | nocturne25/anima | anima/perf.py | Python | measure_time | measure_time | 10 | 29 | 10 | 10 | 9e4c488e883103747fa571ae6c4618243b8cc6b1 | bigcode/the-stack | train |
f342c16f0202e98cdbd34df8 | train | function | def get_git_top_level_path() -> Path:
"""Get the path of the git repository where this CLI is running"""
proc = subprocess.run(
["git", "rev-parse", "--show-toplevel"], check=True, stdout=subprocess.PIPE
)
output = proc.stdout.decode("utf-8").strip()
return Path(output)
| def get_git_top_level_path() -> Path:
| """Get the path of the git repository where this CLI is running"""
proc = subprocess.run(
["git", "rev-parse", "--show-toplevel"], check=True, stdout=subprocess.PIPE
)
output = proc.stdout.decode("utf-8").strip()
return Path(output)
| to write the BUILD file
"""
build_text = black.format_str(
astor.to_source(tree), mode=black.FileMode(line_length=88)
)
with open(build_file_path, "w") as f:
f.write(build_text)
def get_git_top_level_path() -> Path:
| 64 | 64 | 72 | 10 | 54 | dmyers87/pypants | pypants/util.py | Python | get_git_top_level_path | get_git_top_level_path | 63 | 69 | 63 | 63 | 3a015407d3f6f379259852f0b015bff3602b913b | bigcode/the-stack | train |
5708050124bb9742f31830b6 | train | function | def gather_dependencies_from_module(path: str) -> Set[str]:
"""Gather a set of other build targets from a single Python module
Args:
path: Python module path
Returns:
set of package names that were imported in the module
"""
with open(path) as f:
contents = f.read()
tr... | def gather_dependencies_from_module(path: str) -> Set[str]:
| """Gather a set of other build targets from a single Python module
Args:
path: Python module path
Returns:
set of package names that were imported in the module
"""
with open(path) as f:
contents = f.read()
tree = ast.parse(contents)
visitor = ModuleImportVisitor()... | .imports.add(node.module.split(".")[0])
def visit_Import(self, node) -> None:
"""Collect an import when specified as `import foo`"""
self.imports.add(node.names[0].name.split(".")[0])
def gather_dependencies_from_module(path: str) -> Set[str]:
| 64 | 64 | 94 | 13 | 51 | dmyers87/pypants | pypants/util.py | Python | gather_dependencies_from_module | gather_dependencies_from_module | 28 | 43 | 28 | 28 | 6827b924356cad7d3da3b7062b4dcdfad7124879 | bigcode/the-stack | train |
2455a3b9f7a1865732a60082 | train | function | def write_build_file(tree: ast.Module, build_file_path: str) -> None:
"""Format and write a BUILD file from an AST module tree.
The final output is auto-formatted using Black.
Args:
tree: AST module for the BUILD file
build_file_path: Output path to write the BUILD file
"""
build_... | def write_build_file(tree: ast.Module, build_file_path: str) -> None:
| """Format and write a BUILD file from an AST module tree.
The final output is auto-formatted using Black.
Args:
tree: AST module for the BUILD file
build_file_path: Output path to write the BUILD file
"""
build_text = black.format_str(
astor.to_source(tree), mode=black.Fil... | imported in the module
"""
with open(path) as f:
contents = f.read()
tree = ast.parse(contents)
visitor = ModuleImportVisitor()
visitor.visit(tree)
return visitor.imports
def write_build_file(tree: ast.Module, build_file_path: str) -> None:
| 64 | 64 | 117 | 18 | 45 | dmyers87/pypants | pypants/util.py | Python | write_build_file | write_build_file | 46 | 60 | 46 | 46 | adde3f431ced3295c0a3c9e11087d2c3a6874a6a | bigcode/the-stack | train |
dd7faf51567f330ac6ff5227 | train | class | class ModuleImportVisitor(ast.NodeVisitor):
"""AST visitor for collecting imports from a module"""
def __init__(self) -> None:
self.imports = set()
def visit_ImportFrom(self, node) -> None:
"""Collect an import when specified as `from foo import bar`"""
if node.module is not None:
... | class ModuleImportVisitor(ast.NodeVisitor):
| """AST visitor for collecting imports from a module"""
def __init__(self) -> None:
self.imports = set()
def visit_ImportFrom(self, node) -> None:
"""Collect an import when specified as `from foo import bar`"""
if node.module is not None:
self.imports.add(node.module.spl... | """Utility functions"""
import ast
from pathlib import Path
import subprocess
from typing import Set
import astor
import black
class ModuleImportVisitor(ast.NodeVisitor):
| 35 | 64 | 125 | 8 | 26 | dmyers87/pypants | pypants/util.py | Python | ModuleImportVisitor | ModuleImportVisitor | 12 | 25 | 12 | 12 | 2cc9b30758fc4736eebf69b9faa30636c2d39f29 | bigcode/the-stack | train |
0d025c9255cfb40b0b923166 | train | class | class WeatherSensorSchema(Schema):
"""
Schema for the weather sensor registration.
Based on flexmeasures.Sensor, plus some attributes for the weather station asset.
"""
name = fields.Str(required=True)
timezone = fields.Str()
latitude = fields.Float(required=True, validate=validate.Range(mi... | class WeatherSensorSchema(Schema):
| """
Schema for the weather sensor registration.
Based on flexmeasures.Sensor, plus some attributes for the weather station asset.
"""
name = fields.Str(required=True)
timezone = fields.Str()
latitude = fields.Float(required=True, validate=validate.Range(min=-90, max=90))
longitude = fie... | from marshmallow import (
Schema,
validates,
validates_schema,
ValidationError,
fields,
validate,
)
import pytz
from flexmeasures.data.models.time_series import Sensor
from ...utils.modeling import get_or_create_weather_station
from ...utils.owm import get_supported_sensor_spec, get_supported_... | 78 | 110 | 367 | 7 | 70 | SeitaBV/flexmeasures-openweathermap | flexmeasures_openweathermap/cli/schemas/weather_sensor.py | Python | WeatherSensorSchema | WeatherSensorSchema | 17 | 57 | 17 | 17 | c906ff32bcfe58a5e85d76c71647ad08d0125fd5 | bigcode/the-stack | train |
9a2f179d2cc6e34e6b2c6d33 | train | class | class MCTSTest(absltest.TestCase):
def test_mcts(self):
# Create a fake environment to test with.
num_actions = 5
environment = fakes.DiscreteEnvironment(
num_actions=num_actions,
num_observations=10,
obs_dtype=np.float32,
episode_length=10)
spec = specs.make_environme... | class MCTSTest(absltest.TestCase):
| def test_mcts(self):
# Create a fake environment to test with.
num_actions = 5
environment = fakes.DiscreteEnvironment(
num_actions=num_actions,
num_observations=10,
obs_dtype=np.float32,
episode_length=10)
spec = specs.make_environment_spec(environment)
network = ... |
from acme import specs
from acme.agents.tf import mcts
from acme.agents.tf.mcts.models import simulator
from acme.testing import fakes
from acme.tf import networks
import numpy as np
import sonnet as snt
from absl.testing import absltest
class MCTSTest(absltest.TestCase):
| 76 | 76 | 255 | 11 | 64 | wookayin/acme | acme/agents/tf/mcts/agent_test.py | Python | MCTSTest | MCTSTest | 29 | 64 | 29 | 30 | 4798dc469dfaa07d222a411adca475465fbdfd0d | bigcode/the-stack | train |
607836670068fe384942f739 | train | class | class MainWindow(Qt.QMainWindow):
def __init__(self, parent = None):
Qt.QMainWindow.__init__(self, parent)
self.frame = Qt.QFrame()
self.vl = Qt.QVBoxLayout()
self.vtkWidget = QVTKRenderWindowInteractor(self.frame)
self.vl.addWidget(self.vtkWidget)
self.ren = vtk.v... | class MainWindow(Qt.QMainWindow):
| def __init__(self, parent = None):
Qt.QMainWindow.__init__(self, parent)
self.frame = Qt.QFrame()
self.vl = Qt.QVBoxLayout()
self.vtkWidget = QVTKRenderWindowInteractor(self.frame)
self.vl.addWidget(self.vtkWidget)
self.ren = vtk.vtkRenderer()
self.vtkWidget... | #!/usr/bin/env python
import sys
import vtk
from PyQt5 import QtCore, QtGui
from PyQt5 import Qt
from vtk.qt.QVTKRenderWindowInteractor import QVTKRenderWindowInteractor
class MainWindow(Qt.QMainWindow):
| 55 | 74 | 247 | 8 | 46 | Sachartemis/dubrayn.github.io | examples/vtk/vtk_qt.py | Python | MainWindow | MainWindow | 9 | 45 | 9 | 10 | 325a2a92d6f1bc94626bdf5bd698e431ab124ebd | bigcode/the-stack | train |
a3dbd30c26c904a9841c9d2a | train | function | def dataSplit(X, y, test_size=0.33, path='./'):
X_tr, X_test, y_tr, y_test = train_test_split(X, y, test_size=test_size, random_state=SEED, stratify=y)
X_train, X_val, y_train, y_val = train_test_split(X_tr, y_tr, test_size=test_size, random_state=SEED, stratify=y_tr)
y_train = np_utils.to_categorical(y_tra... | def dataSplit(X, y, test_size=0.33, path='./'):
| X_tr, X_test, y_tr, y_test = train_test_split(X, y, test_size=test_size, random_state=SEED, stratify=y)
X_train, X_val, y_train, y_val = train_test_split(X_tr, y_tr, test_size=test_size, random_state=SEED, stratify=y_tr)
y_train = np_utils.to_categorical(y_train)
y_test = np_utils.to_categorical(y_test)... | import numpy as np
from keras.utils import np_utils
from sklearn.model_selection import train_test_split
SEED = 666
def rescale(X):
return X / 255.0
def dataSplit(X, y, test_size=0.33, path='./'):
| 58 | 64 | 166 | 17 | 40 | dsanmartin/chilean-bills-classification | preprocessing.py | Python | dataSplit | dataSplit | 10 | 19 | 10 | 10 | a1cc366d05517a7923344eb1aa174aa658359b5b | bigcode/the-stack | train |
91198d6e3cb1e0f1806f2bbb | train | function | def rescale(X):
return X / 255.0
| def rescale(X):
| return X / 255.0
| import numpy as np
from keras.utils import np_utils
from sklearn.model_selection import train_test_split
SEED = 666
def rescale(X):
| 32 | 64 | 14 | 5 | 26 | dsanmartin/chilean-bills-classification | preprocessing.py | Python | rescale | rescale | 7 | 8 | 7 | 7 | 3ea727e1ec72a8c6d3e36b51d3a4b5fc416f8372 | bigcode/the-stack | train |
b11d5ab72c1bac7031d8182b | train | function | def simple_dnn_regressor(export_path, eval_export_path):
"""Trains and exports a simple DNN regressor."""
feature_spec = tf.feature_column.make_parse_example_spec(
feature_columns=util.dnn_columns(True))
regressor = tf_estimator.DNNRegressor(
hidden_units=[4],
feature_columns=util.dnn_columns(F... | def simple_dnn_regressor(export_path, eval_export_path):
| """Trains and exports a simple DNN regressor."""
feature_spec = tf.feature_column.make_parse_example_spec(
feature_columns=util.dnn_columns(True))
regressor = tf_estimator.DNNRegressor(
hidden_units=[4],
feature_columns=util.dnn_columns(False),
loss_reduction=tf.losses.Reduction.SUM)
re... | metrics added by DNNRegressor, plus additional
metrics added using tf.estimator.
"""
import tensorflow as tf
from tensorflow import estimator as tf_estimator
from tensorflow_model_analysis.eval_saved_model import export
from tensorflow_model_analysis.eval_saved_model.example_trainers import util
def simple_dnn_regres... | 69 | 69 | 233 | 13 | 55 | rtg0795/model-analysis | tensorflow_model_analysis/eval_saved_model/example_trainers/dnn_regressor.py | Python | simple_dnn_regressor | simple_dnn_regressor | 28 | 51 | 28 | 28 | e5eec8402df2a160b36f940b2ab8795c3abdf39b | bigcode/the-stack | train |
5c94e6961fbb0929ea7ee29a | train | class | class Migration(migrations.Migration):
dependencies = [
('smsbillables', '0019_deactivate_hardcoded_twilio_gateway_fees'),
]
operations = [
migrations.RunPython(update_sislog_vodacom_mozambique_fees),
]
| class Migration(migrations.Migration):
| dependencies = [
('smsbillables', '0019_deactivate_hardcoded_twilio_gateway_fees'),
]
operations = [
migrations.RunPython(update_sislog_vodacom_mozambique_fees),
]
| logBackend.get_api_id(),
OUTGOING,
Decimal('0.35'),
country_code=country_code,
prefix=prefix,
currency=mzn,
fee_class=sms_gateway_fee_class,
criteria_class=sms_gateway_fee_criteria_class,
)
class Migration(migrations.Migration):... | 64 | 64 | 56 | 7 | 57 | kkrampa/commcare-hq | corehq/apps/smsbillables/migrations/0020_update_sislog_fees.py | Python | Migration | Migration | 45 | 53 | 45 | 46 | 148fd4a73fcc3c5802542d9a18b764f055eddcd9 | bigcode/the-stack | train |
31fa34f1ab8c962a6e48cca6 | train | function | def update_sislog_vodacom_mozambique_fees(apps, schema_editor):
mzn, _ = apps.get_model('accounting', 'Currency').objects.get_or_create(code='MZN')
sms_gateway_fee_class = apps.get_model('smsbillables', 'SmsGatewayFee')
sms_gateway_fee_criteria_class = apps.get_model('smsbillables', 'SmsGatewayFeeCriteria')... | def update_sislog_vodacom_mozambique_fees(apps, schema_editor):
| mzn, _ = apps.get_model('accounting', 'Currency').objects.get_or_create(code='MZN')
sms_gateway_fee_class = apps.get_model('smsbillables', 'SmsGatewayFee')
sms_gateway_fee_criteria_class = apps.get_model('smsbillables', 'SmsGatewayFeeCriteria')
country_code = 258
for prefix in ['84', '85']:
... |
from django.db import migrations
from corehq.apps.sms.models import INCOMING, OUTGOING
from corehq.apps.smsbillables.models import SmsGatewayFee
from corehq.messaging.smsbackends.sislog.models import SQLSislogBackend
def update_sislog_vodacom_mozambique_fees(apps, schema_editor):
| 70 | 70 | 235 | 19 | 50 | kkrampa/commcare-hq | corehq/apps/smsbillables/migrations/0020_update_sislog_fees.py | Python | update_sislog_vodacom_mozambique_fees | update_sislog_vodacom_mozambique_fees | 15 | 42 | 15 | 15 | 3e5e7fd332cdb8ccd1ef86e8c5cab0ea77680539 | bigcode/the-stack | train |
dfdaa35f385863b8062a907e | train | class | class LoggingMixin(object):
def initial_setup(self, args):
#print(f"Setting up logging, rank: {args.rank}")
root = logging.getLogger()
root.handlers = []
if args.debug:
root.setLevel(logging.DEBUG)
else:
root.setLevel(logging.INFO)
fo... | class LoggingMixin(object):
| def initial_setup(self, args):
#print(f"Setting up logging, rank: {args.rank}")
root = logging.getLogger()
root.handlers = []
if args.debug:
root.setLevel(logging.DEBUG)
else:
root.setLevel(logging.INFO)
formatter = logging.Formatter(... | .
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
"""
import logging
import sys
import pdb
import shutil
from tensorboardX import SummaryWriter
class TensorboardHandler(logging.Handler):
def __init__(self, writer, tag):
self.writer... | 212 | 213 | 712 | 5 | 207 | sbelenki/fastMRI | banding_removal/fastmri/logging_mixin.py | Python | LoggingMixin | LoggingMixin | 42 | 128 | 42 | 42 | 297bb625e0c8bd179a7f48204a480e5e58bedeb1 | bigcode/the-stack | train |
6d2f9c46d7596372fef5809c | train | class | class TensorboardHandler(logging.Handler):
def __init__(self, writer, tag):
self.writer = writer
self.tag = tag
super().__init__()
def emit(self, record):
log_entry = self.format(record)
#tag, text_string, global_step=None, walltime=None
if self.writer.file_writer... | class TensorboardHandler(logging.Handler):
| def __init__(self, writer, tag):
self.writer = writer
self.tag = tag
super().__init__()
def emit(self, record):
log_entry = self.format(record)
#tag, text_string, global_step=None, walltime=None
if self.writer.file_writer is not None:
self.writer.add_t... | Copyright (c) Facebook, Inc. and its affiliates.
This source code is licensed under the MIT license found in the
LICENSE file in the root directory of this source tree.
"""
import logging
import sys
import pdb
import shutil
from tensorboardX import SummaryWriter
class TensorboardHandler(logging.Handler):
| 64 | 64 | 86 | 7 | 56 | sbelenki/fastMRI | banding_removal/fastmri/logging_mixin.py | Python | TensorboardHandler | TensorboardHandler | 16 | 25 | 16 | 16 | c89e20f4afaa6c384c9a3e097a3957475d434c7d | bigcode/the-stack | train |
3975f3798e325555064d666b | train | class | class LoggerWriter:
def __init__(self, level, stream):
self.level = level
self._stream = stream
def write(self, message):
if message != '\n':
self.level(message)
self._stream.write(message)
self._stream.flush()
def flush(self):
self.level("")
... | class LoggerWriter:
| def __init__(self, level, stream):
self.level = level
self._stream = stream
def write(self, message):
if message != '\n':
self.level(message)
self._stream.write(message)
self._stream.flush()
def flush(self):
self.level("")
self._stream.f... | .tag = tag
super().__init__()
def emit(self, record):
log_entry = self.format(record)
#tag, text_string, global_step=None, walltime=None
if self.writer.file_writer is not None:
self.writer.add_text(self.tag, log_entry)
class LoggerWriter:
| 64 | 64 | 75 | 4 | 60 | sbelenki/fastMRI | banding_removal/fastmri/logging_mixin.py | Python | LoggerWriter | LoggerWriter | 27 | 40 | 27 | 27 | 649553a8006757bb035897c619e0bd876cbc649b | bigcode/the-stack | train |
5bc1cb138bf98f86fd1aa9b2 | train | class | class Alphabet(object):
def __init__(
self,
standard_toks: Sequence[str],
prepend_toks: Sequence[str] = ("<null_0>", "<pad>", "<eos>", "<unk>"),
append_toks: Sequence[str] = ("<cls>", "<mask>", "<sep>"),
prepend_bos: bool = True,
append_eos: bool = False,
use_... | class Alphabet(object):
| def __init__(
self,
standard_toks: Sequence[str],
prepend_toks: Sequence[str] = ("<null_0>", "<pad>", "<eos>", "<unk>"),
append_toks: Sequence[str] = ("<cls>", "<mask>", "<sep>"),
prepend_bos: bool = True,
append_eos: bool = False,
use_msa: bool = False,
)... | return cls(sequence_labels, sequence_strs)
def __len__(self):
return len(self.sequence_labels)
def __getitem__(self, idx):
return self.sequence_labels[idx], self.sequence_strs[idx]
def get_batch_indices(self, toks_per_batch, extra_toks_per_seq=0):
sizes = [(len(s), i) for i, s in... | 220 | 220 | 736 | 4 | 215 | luoyunan/esm | esm/data.py | Python | Alphabet | Alphabet | 88 | 162 | 88 | 88 | e32d81af79d74131143fe6c39e2c284c563c1956 | bigcode/the-stack | train |
5837b7103248d0790a361c17 | train | class | class FastaBatchedDataset(object):
def __init__(self, sequence_labels, sequence_strs):
self.sequence_labels = list(sequence_labels)
self.sequence_strs = list(sequence_strs)
@classmethod
def from_file(cls, fasta_file):
sequence_labels, sequence_strs = [], []
cur_seq_label = N... | class FastaBatchedDataset(object):
| def __init__(self, sequence_labels, sequence_strs):
self.sequence_labels = list(sequence_labels)
self.sequence_strs = list(sequence_strs)
@classmethod
def from_file(cls, fasta_file):
sequence_labels, sequence_strs = [], []
cur_seq_label = None
buf = []
def _... | # Copyright (c) Facebook, Inc. and its affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
import os
from typing import Sequence, Tuple, List, Union
import pickle
import re
import shutil
import torch
from pathlib import Path
from .co... | 99 | 141 | 472 | 8 | 91 | luoyunan/esm | esm/data.py | Python | FastaBatchedDataset | FastaBatchedDataset | 18 | 85 | 18 | 18 | 32a9fe3d164f595d9add6b1406cb45f98e5d8eeb | bigcode/the-stack | train |
95f263054ebdc618c8f32e9f | train | class | class BatchConverter(object):
"""Callable to convert an unprocessed (labels + strings) batch to a
processed (labels + tensor) batch.
"""
def __init__(self, alphabet):
self.alphabet = alphabet
def __call__(self, raw_batch: Sequence[Tuple[str, str]]):
# RoBERTa uses an eos token, whi... | class BatchConverter(object):
| """Callable to convert an unprocessed (labels + strings) batch to a
processed (labels + tensor) batch.
"""
def __init__(self, alphabet):
self.alphabet = alphabet
def __call__(self, raw_batch: Sequence[Tuple[str, str]]):
# RoBERTa uses an eos token, while ESM-1 does not.
bat... | oks"]
prepend_toks = ("<cls>", "<pad>", "<eos>", "<unk>")
append_toks = ("<mask>",)
prepend_bos = True
append_eos = False
use_msa = True
else:
raise ValueError("Unknown architecture selected")
return cls(standard_toks, prepend_toks,... | 97 | 97 | 326 | 5 | 92 | luoyunan/esm | esm/data.py | Python | BatchConverter | BatchConverter | 165 | 201 | 165 | 165 | 3bb99adb3b15926af0ff4f3e444bac75ab59d6af | bigcode/the-stack | train |
42ed1424d9aecc8d9fec0b6e | train | class | class MSABatchConverter(BatchConverter):
def __call__(self, inputs: Union[Sequence[RawMSA], RawMSA]):
if isinstance(inputs[0][0], str):
# Input is a single MSA
raw_batch: Sequence[RawMSA] = [inputs] # type: ignore
else:
raw_batch = inputs # type: ignore
... | class MSABatchConverter(BatchConverter):
| def __call__(self, inputs: Union[Sequence[RawMSA], RawMSA]):
if isinstance(inputs[0][0], str):
# Input is a single MSA
raw_batch: Sequence[RawMSA] = [inputs] # type: ignore
else:
raw_batch = inputs # type: ignore
batch_size = len(raw_batch)
max_... | for s in seq_str], dtype=torch.int64)
tokens[
i,
int(self.alphabet.prepend_bos) : len(seq_str) + int(self.alphabet.prepend_bos),
] = seq
if self.alphabet.append_eos:
tokens[i, len(seq_str) + int(self.alphabet.prepend_bos)] = self.alpha... | 99 | 99 | 330 | 9 | 89 | luoyunan/esm | esm/data.py | Python | MSABatchConverter | MSABatchConverter | 204 | 240 | 204 | 204 | c98285d9ac111595e6c018ae96f19191e68a3b90 | bigcode/the-stack | train |
f777495a29ea8a44eb54a00e | train | function | def read_fasta(
path,
keep_gaps=True,
keep_insertions=True,
to_upper=False,
):
with open(path, "r") as f:
for result in read_alignment_lines(
f, keep_gaps=keep_gaps, keep_insertions=keep_insertions, to_upper=to_upper
):
yield result
| def read_fasta(
path,
keep_gaps=True,
keep_insertions=True,
to_upper=False,
):
| with open(path, "r") as f:
for result in read_alignment_lines(
f, keep_gaps=keep_gaps, keep_insertions=keep_insertions, to_upper=to_upper
):
yield result
| strs.append(msa_strs)
tokens[i, : msa_tokens.size(0), : msa_tokens.size(1)] = msa_tokens
return labels, strs, tokens
def read_fasta(
path,
keep_gaps=True,
keep_insertions=True,
to_upper=False,
):
| 64 | 64 | 76 | 26 | 37 | luoyunan/esm | esm/data.py | Python | read_fasta | read_fasta | 243 | 253 | 243 | 248 | 0d2b164d4b685cc6cd9614dab5d77a4726aa109e | bigcode/the-stack | train |
e89dfa537d296f0e533ebe7d | train | function | def read_alignment_lines(
lines,
keep_gaps=True,
keep_insertions=True,
to_upper=False,
):
seq = desc = None
def parse(s):
if not keep_gaps:
s = re.sub("-", "", s)
if not keep_insertions:
s = re.sub("[a-z]", "", s)
return s.upper() if to_upper else... | def read_alignment_lines(
lines,
keep_gaps=True,
keep_insertions=True,
to_upper=False,
):
| seq = desc = None
def parse(s):
if not keep_gaps:
s = re.sub("-", "", s)
if not keep_insertions:
s = re.sub("[a-z]", "", s)
return s.upper() if to_upper else s
for line in lines:
# Line may be empty if seq % file_line_width == 0
if len(line) ... | for result in read_alignment_lines(
f, keep_gaps=keep_gaps, keep_insertions=keep_insertions, to_upper=to_upper
):
yield result
def read_alignment_lines(
lines,
keep_gaps=True,
keep_insertions=True,
to_upper=False,
):
| 64 | 64 | 182 | 26 | 37 | luoyunan/esm | esm/data.py | Python | read_alignment_lines | read_alignment_lines | 256 | 282 | 256 | 261 | 6818f8be4c7f3aba6d0603f310cf096b4213d4cc | bigcode/the-stack | train |
cf08184edba71fc3624ffc4b | train | class | class ESMStructuralSplitDataset(torch.utils.data.Dataset):
"""
Structural Split Dataset as described in section A.10 of the supplement of our paper.
https://doi.org/10.1101/622803
We use the full version of SCOPe 2.07, clustered at 90% sequence identity,
generated on January 23, 2020.
For each... | class ESMStructuralSplitDataset(torch.utils.data.Dataset):
| """
Structural Split Dataset as described in section A.10 of the supplement of our paper.
https://doi.org/10.1101/622803
We use the full version of SCOPe 2.07, clustered at 90% sequence identity,
generated on January 23, 2020.
For each SCOPe domain:
- We extract the sequence from the c... | ,
keep_insertions=True,
to_upper=False,
):
with open(path, "r") as f:
for result in read_alignment_lines(
f, keep_gaps=keep_gaps, keep_insertions=keep_insertions, to_upper=to_upper
):
yield result
def read_alignment_lines(
lines,
keep_gaps=True,
keep_ins... | 256 | 256 | 1,009 | 11 | 245 | luoyunan/esm | esm/data.py | Python | ESMStructuralSplitDataset | ESMStructuralSplitDataset | 285 | 397 | 285 | 285 | 9895404c2a3872c2396c857fa689194c6c073635 | bigcode/the-stack | train |
bcd36de3c5e614c5a3f906e7 | train | class | class UnpackWheelsTest(TaskTestBase):
@classmethod
def task_type(cls):
return UnpackWheels
def _make_req_library(self, requirement):
return self.make_target(spec='unpack/whls:foo-whls',
target_type=PythonRequirementLibrary,
requirements=[requiremen... | class UnpackWheelsTest(TaskTestBase):
@classmethod
| def task_type(cls):
return UnpackWheels
def _make_req_library(self, requirement):
return self.make_target(spec='unpack/whls:foo-whls',
target_type=PythonRequirementLibrary,
requirements=[requirement])
def _make_unpacked_wheel(self, requirement, inc... | # Copyright 2019 Pants project contributors (see CONTRIBUTORS.md).
# Licensed under the Apache License, Version 2.0 (see LICENSE).
import functools
import re
from pants.backend.python.python_requirement import PythonRequirement
from pants.backend.python.targets.python_requirement_library import PythonRequirementLibra... | 141 | 216 | 722 | 14 | 126 | anthonyjpratti/pants | tests/python/pants_test/backend/python/tasks/test_unpack_wheels.py | Python | UnpackWheelsTest | UnpackWheelsTest | 16 | 87 | 16 | 18 | 2248c5bd82a3e2529510b700ef2cf7d6221b4839 | bigcode/the-stack | train |
f5cda55c3601ff8d06fbd401 | train | class | class ResetOnExceptionWrapper(gym.Wrapper):
def __init__(self, env: gym.Env, max_reset_attempts: int = 5):
super().__init__(env)
self.max_reset_attempts = max_reset_attempts
def reset(self, **kwargs):
attempt = 0
while attempt < self.max_reset_attempts:
try:
... | class ResetOnExceptionWrapper(gym.Wrapper):
| def __init__(self, env: gym.Env, max_reset_attempts: int = 5):
super().__init__(env)
self.max_reset_attempts = max_reset_attempts
def reset(self, **kwargs):
attempt = 0
while attempt < self.max_reset_attempts:
try:
return self.env.reset(**kwargs)
... | Logger(__name__)
class TooManyResetAttemptsException(Exception):
def __init__(self, max_attempts: int):
super().__init__(
f"Reached the maximum number of attempts ({max_attempts}) "
f"to reset an environment.")
class ResetOnExceptionWrapper(gym.Wrapper):
| 63 | 64 | 168 | 10 | 53 | firebolt55439/ray | rllib/env/wrappers/exception_wrapper.py | Python | ResetOnExceptionWrapper | ResetOnExceptionWrapper | 16 | 37 | 16 | 16 | 630b7483582ce7ced093ab3030818741bb5f537b | bigcode/the-stack | train |
3227ebf266c0344e85725b02 | train | class | class TooManyResetAttemptsException(Exception):
def __init__(self, max_attempts: int):
super().__init__(
f"Reached the maximum number of attempts ({max_attempts}) "
f"to reset an environment.")
| class TooManyResetAttemptsException(Exception):
| def __init__(self, max_attempts: int):
super().__init__(
f"Reached the maximum number of attempts ({max_attempts}) "
f"to reset an environment.")
| import logging
import traceback
import gym
logger = logging.getLogger(__name__)
class TooManyResetAttemptsException(Exception):
| 25 | 64 | 49 | 8 | 17 | firebolt55439/ray | rllib/env/wrappers/exception_wrapper.py | Python | TooManyResetAttemptsException | TooManyResetAttemptsException | 9 | 13 | 9 | 9 | 7ebc34cd7b7ea4b662c3c454d42c0411a70b26c0 | bigcode/the-stack | train |
2f0d04253ca8807002651032 | train | class | class GRADIENT_RECT(Structure):
_fields_ = [
('UpperLeft', c_ulong),
('LowerRight', c_ulong)]
| class GRADIENT_RECT(Structure):
| _fields_ = [
('UpperLeft', c_ulong),
('LowerRight', c_ulong)]
| _ = [
('x', c_long),
('y', c_long),
('Red', COLOR16),
('Green', COLOR16),
('Blue', COLOR16),
('Alpha', COLOR16)]
PTRIVERTEX = POINTER(TRIVERTEX)
class GRADIENT_RECT(Structure):
| 64 | 64 | 29 | 8 | 56 | Answeror/lit | pywingui/gdi.py | Python | GRADIENT_RECT | GRADIENT_RECT | 194 | 197 | 194 | 194 | 5be1bfb37b8d78d82a99b835f10d654c2366f2b0 | bigcode/the-stack | train |
512d8a0c67e04eecede3e499 | train | function | def CetMiterLimit(hdc):
'Retrieves the miter limit for the specified device context.'
peLimit = c_float()
result = _GetMiterLimit(hdc, byref(peLimit))
return result, peLimit.value
| def CetMiterLimit(hdc):
| 'Retrieves the miter limit for the specified device context.'
peLimit = c_float()
result = _GetMiterLimit(hdc, byref(peLimit))
return result, peLimit.value
| Pen.__doc__ = 'Creates a logical cosmetic or geometric pen that has the specified style, width, and brush attributes.'
_GetMiterLimit = WINFUNCTYPE(c_bool, c_void_p, c_void_p)(('GetMiterLimit', windll.gdi32))
def CetMiterLimit(hdc):
| 64 | 64 | 51 | 8 | 56 | Answeror/lit | pywingui/gdi.py | Python | CetMiterLimit | CetMiterLimit | 413 | 417 | 413 | 413 | 98795ae01cdd7f0d5c9f967e99254d9f3833f421 | bigcode/the-stack | train |
cf802665d14a622220f42435 | train | class | class DISPLAY_DEVICE(Structure):
_fields_ = [
('cb', DWORD),
('DeviceName', c_wchar * 32),
('DeviceString', c_wchar * 128),
('StateFlags', DWORD),
('DeviceID', c_wchar * 128),
('DeviceKey', c_wchar * 128)]
| class DISPLAY_DEVICE(Structure):
| _fields_ = [
('cb', DWORD),
('DeviceName', c_wchar * 32),
('DeviceString', c_wchar * 128),
('StateFlags', DWORD),
('DeviceID', c_wchar * 128),
('DeviceKey', c_wchar * 128)]
| )]
class BITMAPFILEHEADER(Structure):
_fields_ = [
("bfType", WORD),
("bfSize", DWORD),
("bfReserved1", WORD),
("bfReserved2", WORD),
("bfOffBits", DWORD)]
class DISPLAY_DEVICE(Structure):
| 64 | 64 | 72 | 6 | 58 | Answeror/lit | pywingui/gdi.py | Python | DISPLAY_DEVICE | DISPLAY_DEVICE | 173 | 180 | 173 | 173 | b5537982aee28c0a05ab24262640415fdcb34b2d | bigcode/the-stack | train |
e46764cc4081db81b6f4ca3a | train | class | class XFORM(Structure):
_fields_ = [('eM11', c_float),
('eM12', c_float),
('eM21', c_float),
('eM22', c_float),
('eDx', c_float),
('eDy', c_float)]
| class XFORM(Structure):
| _fields_ = [('eM11', c_float),
('eM12', c_float),
('eM21', c_float),
('eM22', c_float),
('eDx', c_float),
('eDy', c_float)]
| ))
GradientFill = GdiGradientFill# for backward compatibility
else:
GradientFill = WINFUNCTYPE(c_byte, c_void_p, PTRIVERTEX, c_ulong, c_void_p, c_ulong, c_ulong)(('GradientFill', windll.gdi32))
class XFORM(Structure):
| 64 | 64 | 61 | 6 | 58 | Answeror/lit | pywingui/gdi.py | Python | XFORM | XFORM | 331 | 337 | 331 | 331 | a50e8cf222c40eccaf88a8ffda5314bac2a129f3 | bigcode/the-stack | train |
8bac0cd036ff4f5bc585c097 | train | function | def GetWorldTransform(hdc):
'Retrieves the current world-space to page-space transformation.'
lpXform = XFORM()
result = _GetWorldTransform(hdc, lpXform)
return result, lpXform
| def GetWorldTransform(hdc):
| 'Retrieves the current world-space to page-space transformation.'
lpXform = XFORM()
result = _GetWorldTransform(hdc, lpXform)
return result, lpXform
| line segments. PolyPolyline(hdc, POINT(2,2), (c_ulong*2)(1, 2), 2)'
_GetWorldTransform = WINFUNCTYPE(c_bool, c_void_p, LPXFORM)(('GetWorldTransform', windll.gdi32))
def GetWorldTransform(hdc):
| 64 | 64 | 47 | 7 | 57 | Answeror/lit | pywingui/gdi.py | Python | GetWorldTransform | GetWorldTransform | 346 | 350 | 346 | 346 | 3c3ad733f5ccac81b1dc55c6e2a8c0372a675771 | bigcode/the-stack | train |
5367a03ef01b0dadb165c388 | train | class | class Pen(WindowsObject):
__dispose__ = DeleteObject
def Create(cls, fnPenStyle = PS_SOLID, nWidth = 1, crColor = 0x00000000):
return Pen(CreatePen(fnPenStyle, nWidth, crColor))
Create = classmethod(Create)
def CreateEx(cls, dwPenStyle = PS_COSMETIC | PS_SOLID, dwWidth = 1, lbStyle = BS_... | class Pen(WindowsObject):
| __dispose__ = DeleteObject
def Create(cls, fnPenStyle = PS_SOLID, nWidth = 1, crColor = 0x00000000):
return Pen(CreatePen(fnPenStyle, nWidth, crColor))
Create = classmethod(Create)
def CreateEx(cls, dwPenStyle = PS_COSMETIC | PS_SOLID, dwWidth = 1, lbStyle = BS_SOLID,
lb... | None, "")
#TODO refactor into Brush class with static factory class methods
class SolidBrush(WindowsObject):
__dispose__ = DeleteObject
def __init__(self, colorRef):
WindowsObject.__init__(self, CreateSolidBrush(colorRef))
class Pen(WindowsObject):
| 63 | 64 | 183 | 6 | 57 | Answeror/lit | pywingui/gdi.py | Python | Pen | Pen | 460 | 474 | 460 | 460 | f7ea5b33de285e4d2bd8a7652a1a0eec7f5f5b89 | bigcode/the-stack | train |
c939ec9cac2cb2511b844660 | train | class | class ENUMLOGFONTEX(Structure):
_fields_ = [("elfLogFont", LOGFONT),
("elfFullName", TCHAR * LF_FACESIZE),
("elfStyle", TCHAR * LF_FACESIZE),
("elfScript", TCHAR * LF_FACESIZE)]
| class ENUMLOGFONTEX(Structure):
| _fields_ = [("elfLogFont", LOGFONT),
("elfFullName", TCHAR * LF_FACESIZE),
("elfStyle", TCHAR * LF_FACESIZE),
("elfScript", TCHAR * LF_FACESIZE)]
| lfPitchAndFamily", BYTE),
("lfFaceName", TCHAR * LF_FACESIZE)]
class LOGBRUSH(Structure):
_fields_ = [("lbStyle", UINT),
("lbColor", COLORREF),
("lbHatch", LONG)]
class ENUMLOGFONTEX(Structure):
| 63 | 64 | 59 | 8 | 55 | Answeror/lit | pywingui/gdi.py | Python | ENUMLOGFONTEX | ENUMLOGFONTEX | 134 | 138 | 134 | 134 | 10701908e94996da62e1c6074b217c9ee909be03 | bigcode/the-stack | train |
fef8657423047b5dec36557c | train | class | class TRIVERTEX(Structure):
_fields_ = [
('x', c_long),
('y', c_long),
('Red', COLOR16),
('Green', COLOR16),
('Blue', COLOR16),
('Alpha', COLOR16)]
| class TRIVERTEX(Structure):
| _fields_ = [
('x', c_long),
('y', c_long),
('Red', COLOR16),
('Green', COLOR16),
('Blue', COLOR16),
('Alpha', COLOR16)]
| DeviceString', c_wchar * 128),
('StateFlags', DWORD),
('DeviceID', c_wchar * 128),
('DeviceKey', c_wchar * 128)]
HDC = POINTER(DISPLAY_DEVICE)
COLOR16 = c_ushort
class TRIVERTEX(Structure):
| 64 | 64 | 55 | 8 | 55 | Answeror/lit | pywingui/gdi.py | Python | TRIVERTEX | TRIVERTEX | 184 | 191 | 184 | 184 | f4fb059ffc2016566f2fa2c00bab59534c8629a2 | bigcode/the-stack | train |
c062bf4d5f42517270623fff | train | function | def PALETTEINDEX(i):
return 0x01000000 | i
| def PALETTEINDEX(i):
| return 0x01000000 | i
|
TRUETYPE_FONTTYPE = 0x004
def RGB(r,g,b):
return r | (g<<8) | (b<<16)
def PALETTERGB(r,g,b):
return 0x02000000 | RGB(r,g,b)
def PALETTEINDEX(i):
| 64 | 64 | 18 | 7 | 57 | Answeror/lit | pywingui/gdi.py | Python | PALETTEINDEX | PALETTEINDEX | 99 | 100 | 99 | 99 | 0d17f2dd3a528652cd917efe3a08cfe4211da84f | bigcode/the-stack | train |
34f5fec62f8ab9e425fd6b5e | train | class | class BITMAPINFO(Structure):
_fields_ = [("bmiHeader", BITMAPINFOHEADER),
("bmiColors", RGBQUAD)]
| class BITMAPINFO(Structure):
| _fields_ = [("bmiHeader", BITMAPINFOHEADER),
("bmiColors", RGBQUAD)]
| ", DWORD),
("biClrImportant", DWORD)]
class RGBQUAD(Structure):
_fields_ = [("rgbBlue", BYTE),
("rgbGreen", BYTE),
("rgbRed", BYTE),
("rgbReserved", BYTE)]
class BITMAPINFO(Structure):
| 64 | 64 | 33 | 7 | 57 | Answeror/lit | pywingui/gdi.py | Python | BITMAPINFO | BITMAPINFO | 161 | 163 | 161 | 161 | 77eb6b6ef3a93fbce80ee59d81a3f15e123e3403 | bigcode/the-stack | train |
4958585e4c8fd7442abc72e6 | train | function | def PALETTERGB(r,g,b):
return 0x02000000 | RGB(r,g,b)
| def PALETTERGB(r,g,b):
| return 0x02000000 | RGB(r,g,b)
| TTYPE = 0x0001
DEVICE_FONTTYPE = 0x002
TRUETYPE_FONTTYPE = 0x004
def RGB(r,g,b):
return r | (g<<8) | (b<<16)
def PALETTERGB(r,g,b):
| 64 | 64 | 22 | 8 | 56 | Answeror/lit | pywingui/gdi.py | Python | PALETTERGB | PALETTERGB | 96 | 97 | 96 | 96 | ab1ab93067df1e1f6d57c4d8cba111654227658d | bigcode/the-stack | train |
16a35f4a9fe1d5c4880e42ea | train | class | class BITMAP(Structure):
_fields_ = [("bmType", LONG),
("bmWidth", LONG),
("bmHeight", LONG),
("bmWidthBytes", LONG),
("bmPlanes", WORD),
("bmBitsPixel", WORD),
("bmBits", LPVOID)]
| class BITMAP(Structure):
| _fields_ = [("bmType", LONG),
("bmWidth", LONG),
("bmHeight", LONG),
("bmWidthBytes", LONG),
("bmPlanes", WORD),
("bmBitsPixel", WORD),
("bmBits", LPVOID)]
| ,g,b):
return r | (g<<8) | (b<<16)
def PALETTERGB(r,g,b):
return 0x02000000 | RGB(r,g,b)
def PALETTEINDEX(i):
return 0x01000000 | i
class BITMAP(Structure):
| 64 | 64 | 69 | 6 | 57 | Answeror/lit | pywingui/gdi.py | Python | BITMAP | BITMAP | 102 | 109 | 102 | 102 | 4a1cc3463ae98257cf32c30dabb02f9549dfc30e | bigcode/the-stack | train |
2ccbc7e5e5324e5a99c38c44 | train | class | class Bitmap(WindowsObject):
__dispose__ = DeleteObject
def __init__(self, path):
WindowsObject.__init__(self, LoadImage(NULL, path, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE))
bm = BITMAP()
GetObject(self.handle, sizeof(bm), byref(bm))
self.m_width, self.m_height = bm.bmWidth, bm.bmH... | class Bitmap(WindowsObject):
| __dispose__ = DeleteObject
def __init__(self, path):
WindowsObject.__init__(self, LoadImage(NULL, path, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE))
bm = BITMAP()
GetObject(self.handle, sizeof(bm), byref(bm))
self.m_width, self.m_height = bm.bmWidth, bm.bmHeight
def getWidth(self)... | ll.gdi32))
SetMapMode.__doc__ = '''Sets the mapping mode of the specified device context. The mapping mode defines the unit of measure used to transform page-space units into device-space units, and also defines the orientation of the device's x and y axes.'''
class Bitmap(WindowsObject):
| 63 | 64 | 140 | 6 | 57 | Answeror/lit | pywingui/gdi.py | Python | Bitmap | Bitmap | 432 | 449 | 432 | 432 | b9718a4c80c381fe0328fd5ab83a80d0ae703dd8 | bigcode/the-stack | train |
1343b964dda7dd4ec2ddf4d8 | train | class | class Font(WindowsObject):
__dispose__ = DeleteObject
def __init__(self, **kwargs):
#TODO move these kwargs to init, use default values
hfont = CreateFont(kwargs.get('height', 0),
kwargs.get('width', 0),
kwargs.get('escapement', 0),
... | class Font(WindowsObject):
| __dispose__ = DeleteObject
def __init__(self, **kwargs):
#TODO move these kwargs to init, use default values
hfont = CreateFont(kwargs.get('height', 0),
kwargs.get('width', 0),
kwargs.get('escapement', 0),
kwargs.g... | lpStyle = 0):
lb = LOGBRUSH(lbStyle, lbColor, lbHatch)
return Pen(ExtCreatePen(dwPenStyle, dwWidth, byref(lb), dwStyleCount, lpStyle))
CreateEx = classmethod(CreateEx)
class Font(WindowsObject):
| 63 | 64 | 198 | 6 | 57 | Answeror/lit | pywingui/gdi.py | Python | Font | Font | 477 | 496 | 477 | 477 | 82f58177c53d4a2b6dc964e582eb9507e65795bf | bigcode/the-stack | train |
5e3d237adcb93c786a79758c | train | class | class LOGBRUSH(Structure):
_fields_ = [("lbStyle", UINT),
("lbColor", COLORREF),
("lbHatch", LONG)]
| class LOGBRUSH(Structure):
| _fields_ = [("lbStyle", UINT),
("lbColor", COLORREF),
("lbHatch", LONG)]
| ", BYTE),
("lfCharSet", BYTE),
("lfOutPrecision", BYTE),
("lfClipPrecision", BYTE),
("lfQuality", BYTE),
("lfPitchAndFamily", BYTE),
("lfFaceName", TCHAR * LF_FACESIZE)]
class LOGBRUSH(Structure):
| 64 | 64 | 35 | 7 | 57 | Answeror/lit | pywingui/gdi.py | Python | LOGBRUSH | LOGBRUSH | 129 | 132 | 129 | 129 | e6922596203b9350a55d5c3e38b70165ba9f1dde | bigcode/the-stack | train |
b870115999352ae3943eb9f2 | train | class | class BITMAPFILEHEADER(Structure):
_fields_ = [
("bfType", WORD),
("bfSize", DWORD),
("bfReserved1", WORD),
("bfReserved2", WORD),
("bfOffBits", DWORD)]
| class BITMAPFILEHEADER(Structure):
| _fields_ = [
("bfType", WORD),
("bfSize", DWORD),
("bfReserved1", WORD),
("bfReserved2", WORD),
("bfOffBits", DWORD)]
| ("rgbGreen", BYTE),
("rgbRed", BYTE),
("rgbReserved", BYTE)]
class BITMAPINFO(Structure):
_fields_ = [("bmiHeader", BITMAPINFOHEADER),
("bmiColors", RGBQUAD)]
class BITMAPFILEHEADER(Structure):
| 64 | 64 | 57 | 8 | 56 | Answeror/lit | pywingui/gdi.py | Python | BITMAPFILEHEADER | BITMAPFILEHEADER | 165 | 171 | 165 | 165 | e4d753e71505f76df227bfb48a0783b0bb19fd2e | bigcode/the-stack | train |
a6450fdfa7dcc8aebb65ee67 | train | class | class BITMAPINFOHEADER(Structure):
_fields_ = [("biSize", DWORD),
("biWidth", LONG),
("biHeight", LONG),
("biPlanes", WORD),
("biBitCount", WORD),
("biCompression", DWORD),
("biSizeImage", DWORD),
... | class BITMAPINFOHEADER(Structure):
| _fields_ = [("biSize", DWORD),
("biWidth", LONG),
("biHeight", LONG),
("biPlanes", WORD),
("biBitCount", WORD),
("biCompression", DWORD),
("biSizeImage", DWORD),
("biXPelsPerMeter", LONG),
... | _FACESIZE),
("elfStyle", TCHAR * LF_FACESIZE),
("elfScript", TCHAR * LF_FACESIZE)]
EnumFontFamExProc = WINFUNCTYPE(c_int, POINTER(ENUMLOGFONTEX), POINTER(DWORD), DWORD, LPARAM)
class BITMAPINFOHEADER(Structure):
| 63 | 64 | 111 | 8 | 55 | Answeror/lit | pywingui/gdi.py | Python | BITMAPINFOHEADER | BITMAPINFOHEADER | 142 | 153 | 142 | 142 | 85cdbe96eb43dddc14a82417aefc8d69d924b825 | bigcode/the-stack | train |
0b70b7b80276e12479992330 | train | class | class SolidBrush(WindowsObject):
__dispose__ = DeleteObject
def __init__(self, colorRef):
WindowsObject.__init__(self, CreateSolidBrush(colorRef))
| class SolidBrush(WindowsObject):
| __dispose__ = DeleteObject
def __init__(self, colorRef):
WindowsObject.__init__(self, CreateSolidBrush(colorRef))
| return self.m_width
width = property(getWidth, None, None, "")
def getHeight(self):
return self.m_height
height = property(getHeight, None, None, "")
#TODO refactor into Brush class with static factory class methods
class SolidBrush(WindowsObject):
| 64 | 64 | 39 | 7 | 56 | Answeror/lit | pywingui/gdi.py | Python | SolidBrush | SolidBrush | 454 | 458 | 454 | 454 | 7d714ac2215cd902b8629131239366d73c1674eb | bigcode/the-stack | train |
5715712b6f74a94c92f06f0a | train | class | class RGBQUAD(Structure):
_fields_ = [("rgbBlue", BYTE),
("rgbGreen", BYTE),
("rgbRed", BYTE),
("rgbReserved", BYTE)]
| class RGBQUAD(Structure):
| _fields_ = [("rgbBlue", BYTE),
("rgbGreen", BYTE),
("rgbRed", BYTE),
("rgbReserved", BYTE)]
| ("biCompression", DWORD),
("biSizeImage", DWORD),
("biXPelsPerMeter", LONG),
("biYPelsPerMeter", LONG),
("biClrUsed", DWORD),
("biClrImportant", DWORD)]
class RGBQUAD(Structure):
| 64 | 64 | 44 | 7 | 57 | Answeror/lit | pywingui/gdi.py | Python | RGBQUAD | RGBQUAD | 155 | 159 | 155 | 155 | c4cbcbc6979a25a2927de0854ae3827d75789607 | bigcode/the-stack | train |
890a4c33bab82e61358c0cec | train | function | def RGB(r,g,b):
return r | (g<<8) | (b<<16)
| def RGB(r,g,b):
| return r | (g<<8) | (b<<16)
| = 16
from ctypes import *
from .windows import *
from .wtl import *
RASTER_FONTTYPE = 0x0001
DEVICE_FONTTYPE = 0x002
TRUETYPE_FONTTYPE = 0x004
def RGB(r,g,b):
| 64 | 64 | 21 | 6 | 57 | Answeror/lit | pywingui/gdi.py | Python | RGB | RGB | 93 | 94 | 93 | 93 | eddf2d82f1116a59d02f48477e1aac0c96302b22 | bigcode/the-stack | train |
c3db75a465380bb50d47e1f3 | train | class | class LOGFONT(Structure):
_fields_ = [("lfHeight", LONG),
("lfWidth", LONG),
("lfEscapement", LONG),
("lfOrientation", LONG),
("lfWeight", LONG),
("lfItalic", BYTE),
("lfUnderline", BYTE),
... | class LOGFONT(Structure):
| _fields_ = [("lfHeight", LONG),
("lfWidth", LONG),
("lfEscapement", LONG),
("lfOrientation", LONG),
("lfWeight", LONG),
("lfItalic", BYTE),
("lfUnderline", BYTE),
("lfStrikeOut", BYTE),
... | ("bmWidth", LONG),
("bmHeight", LONG),
("bmWidthBytes", LONG),
("bmPlanes", WORD),
("bmBitsPixel", WORD),
("bmBits", LPVOID)]
LF_FACESIZE = 32
class LOGFONT(Structure):
| 64 | 64 | 125 | 6 | 57 | Answeror/lit | pywingui/gdi.py | Python | LOGFONT | LOGFONT | 113 | 127 | 113 | 113 | 344e61bf139171e830516745239b41677bba8792 | bigcode/the-stack | train |
4934aee79ec30adca8e47120 | train | function | def SetMiterLimit(hdc, eNewLimit):
'Sets the limit for the length of miter joins for the specified device context.'
peOldLimit = c_float()
result = _SetMiterLimit(hdc, eNewLimit, byref(peOldLimit))
return result, peOldLimit.value
| def SetMiterLimit(hdc, eNewLimit):
| 'Sets the limit for the length of miter joins for the specified device context.'
peOldLimit = c_float()
result = _SetMiterLimit(hdc, eNewLimit, byref(peOldLimit))
return result, peOldLimit.value
| .__doc__ = 'Sets the drawing direction to be used for arc and rectangle functions.'
_SetMiterLimit = WINFUNCTYPE(c_bool, c_void_p, c_float, c_void_p)(('SetMiterLimit', windll.gdi32))
def SetMiterLimit(hdc, eNewLimit):
| 64 | 64 | 66 | 12 | 52 | Answeror/lit | pywingui/gdi.py | Python | SetMiterLimit | SetMiterLimit | 399 | 403 | 399 | 399 | f407a9d8843849fc7c8c4dc4ca27704e431b8739 | bigcode/the-stack | train |
0c3121d20e34604aaad7e9c7 | train | class | class FileSetUpload(BaseModel):
task_id: Optional[str] = Field(None, title="Task to scope the fileset against")
tags: Dict[str, Tags] = Field(
..., title="Dict of tags, each containing a list of file names"
)
| class FileSetUpload(BaseModel):
| task_id: Optional[str] = Field(None, title="Task to scope the fileset against")
tags: Dict[str, Tags] = Field(
..., title="Dict of tags, each containing a list of file names"
)
| FileSetLinks(BaseModel):
tag_name: Optional[str] = Field(None, title="The tag name of the files")
links: Optional[List[FileSetLink]] = Field(None, title="The files")
class Tags(BaseModel):
__root__: List[str]
class FileSetUpload(BaseModel):
| 64 | 64 | 57 | 7 | 57 | entailor/pytailor | src/pytailor/models.py | Python | FileSetUpload | FileSetUpload | 67 | 71 | 67 | 67 | 81e34b1c41303a041f6250914c42a9dcbfe9db06 | bigcode/the-stack | train |
d3379ce3c3affcfef8e0c25f | train | class | class Account(BaseModel):
id: Optional[str] = Field(None, title="unique identifier")
organization_name: Optional[str] = Field(None, title="organization name")
organization_id: Optional[str] = Field(
None, title="the official registration number of the organization"
)
projects: Optional[List[... | class Account(BaseModel):
| id: Optional[str] = Field(None, title="unique identifier")
organization_name: Optional[str] = Field(None, title="organization name")
organization_id: Optional[str] = Field(
None, title="the official registration number of the organization"
)
projects: Optional[List[str]] = Field(
Non... | openapi.json
# timestamp: 2020-11-11T07:22:43+00:00
from __future__ import annotations
from enum import Enum
from typing import Any, Dict, List, Optional
from pydantic import BaseModel, Field
class Account(BaseModel):
| 64 | 64 | 214 | 5 | 58 | entailor/pytailor | src/pytailor/models.py | Python | Account | Account | 13 | 33 | 13 | 13 | 7389d68fa068838bfc247762054096d1d300242c | bigcode/the-stack | train |
bb74a448ac68735735c9378c | train | class | class TaskOperationType(Enum):
RESET = "RESET"
| class TaskOperationType(Enum):
| RESET = "RESET"
| None,
description="Use the processing id to retrieve PENDING results from /task/pending-results/{id}",
title="Processing id",
)
processing_msg: Optional[str] = Field(
None, title="A message with info about the processing result"
)
class TaskOperationType(Enum):
| 64 | 64 | 12 | 6 | 58 | entailor/pytailor | src/pytailor/models.py | Python | TaskOperationType | TaskOperationType | 143 | 144 | 143 | 143 | 1346e5b43da9d9a65889d6e116039820fb285035 | bigcode/the-stack | train |
07f313999f377c7f19476655 | train | class | class WorkflowDefinitionCreate(BaseModel):
dag: Optional[Dict[str, Any]] = Field(None, title="The DAG definition as JSON")
inputs_schema: Optional[Dict[str, Any]] = Field(
None, title="(Optional) The inputs schema specification as JSON"
)
outputs_schema: Optional[Dict[str, Any]] = Field(
... | class WorkflowDefinitionCreate(BaseModel):
| dag: Optional[Dict[str, Any]] = Field(None, title="The DAG definition as JSON")
inputs_schema: Optional[Dict[str, Any]] = Field(
None, title="(Optional) The inputs schema specification as JSON"
)
outputs_schema: Optional[Dict[str, Any]] = Field(
None, title="(Optional) The outputs schema... | this workflow definition, by id"
)
created_by_user: Optional[str] = Field(None, title="the uuid of the creating user")
created_on: Optional[str] = Field(
None, title="the date and time this workflow definition was created"
)
class WorkflowDefinitionCreate(BaseModel):
| 64 | 64 | 172 | 7 | 57 | entailor/pytailor | src/pytailor/models.py | Python | WorkflowDefinitionCreate | WorkflowDefinitionCreate | 267 | 282 | 267 | 267 | a24342e787522912c1ee8a4f99e889c3a4d49ef4 | bigcode/the-stack | train |
3ef391564b8622ad5ac399bc | train | class | class WorkflowSummary(BaseModel):
id: Optional[str] = Field(None, title="unique ID of the workflow")
name: Optional[str] = Field(None, title="non-unique name of the workflow")
project_id: Optional[str] = Field(None, title="project that owns this workflow")
updated_utc: Optional[str] = Field(
Non... | class WorkflowSummary(BaseModel):
| id: Optional[str] = Field(None, title="unique ID of the workflow")
name: Optional[str] = Field(None, title="non-unique name of the workflow")
project_id: Optional[str] = Field(None, title="project that owns this workflow")
updated_utc: Optional[str] = Field(
None, title="timestamp of the latest ... | Optional[str] = Field(None, title="unique ID of the workflow definition")
name: Optional[str] = Field(
None, title="non-unique name of the workflow definition"
)
description: Optional[str] = Field(None, title="description of the workflow")
class WorkflowSummary(BaseModel):
| 64 | 64 | 166 | 6 | 58 | entailor/pytailor | src/pytailor/models.py | Python | WorkflowSummary | WorkflowSummary | 293 | 306 | 293 | 293 | 2281f33d1534235b7c334c9723affb9936a4d9b4 | bigcode/the-stack | train |
af80db0680f6fe0cda4346c9 | train | class | class WorkflowDefinition(BaseModel):
id: Optional[str] = Field(None, title="unique ID of the workflow definition")
name: Optional[str] = Field(
None, title="non-unique name of the workflow definition"
)
description: Optional[str] = Field(None, title="description of the workflow")
dag: Option... | class WorkflowDefinition(BaseModel):
| id: Optional[str] = Field(None, title="unique ID of the workflow definition")
name: Optional[str] = Field(
None, title="non-unique name of the workflow definition"
)
description: Optional[str] = Field(None, title="description of the workflow")
dag: Optional[Dict[str, Any]] = Field(None, titl... | : Optional[str] = Field(
None, title="(Optional) the name of the one Worker who should run this workflow"
)
fileset_id: Optional[str] = Field(
None,
title="(Optional) use input files from the specified FileSet. If not specified, a new, initially empty, FileSet will be created",
)
cla... | 82 | 82 | 275 | 6 | 76 | entailor/pytailor | src/pytailor/models.py | Python | WorkflowDefinition | WorkflowDefinition | 239 | 264 | 239 | 239 | 948e77228bad31d6a1fc78fb67dfd8cd7d77229b | bigcode/the-stack | train |
6062b87e9e0fb3e01e3fed6c | train | class | class FileSetLink(BaseModel):
filename: str = Field(..., title="Filename")
url: str = Field(..., title="Url")
size: Optional[str] = Field(None, title="Size")
| class FileSetLink(BaseModel):
| filename: str = Field(..., title="Filename")
url: str = Field(..., title="Url")
size: Optional[str] = Field(None, title="Size")
| , title="File list by tag")
class FileSetDownload(BaseModel):
task_id: Optional[str] = Field(None, title="Task to scope the fileset against")
tags: Optional[List[str]] = Field(None, title="List of tags to download files for")
class FileSetLink(BaseModel):
| 64 | 64 | 45 | 7 | 57 | entailor/pytailor | src/pytailor/models.py | Python | FileSetLink | FileSetLink | 52 | 55 | 52 | 52 | 38e01fc2eec08c1f2b7cecedae20d4e2bf9d98a3 | bigcode/the-stack | train |
fd2929a3599983513f135739 | train | class | class FileSet(BaseModel):
id: Optional[str] = Field(None, title="unique identifier")
tags: Optional[List[FileSetLinks]] = Field(None, title="File links")
size: Optional[str] = Field(None, title="Total size of files in fileset")
| class FileSet(BaseModel):
| id: Optional[str] = Field(None, title="unique identifier")
tags: Optional[List[FileSetLinks]] = Field(None, title="File links")
size: Optional[str] = Field(None, title="Total size of files in fileset")
| Workflow is based on"
)
class WorkflowTask(BaseModel):
id: Optional[str] = Field(None, title="Task id")
name: Optional[str] = Field(None, title="Task name")
type: Optional[str] = Field(None, title="Task type")
class FileSet(BaseModel):
| 64 | 64 | 60 | 6 | 58 | entailor/pytailor | src/pytailor/models.py | Python | FileSet | FileSet | 315 | 318 | 315 | 315 | a00b36b3d27cce17a6d54e6e899714270d28aa32 | bigcode/the-stack | train |
f62c92811a35c982c8b6948d | train | class | class TaskOperation(BaseModel):
type: Optional[TaskOperationType] = Field(
None, title="The type of operation to be performed"
)
| class TaskOperation(BaseModel):
| type: Optional[TaskOperationType] = Field(
None, title="The type of operation to be performed"
)
| _workflow_definitions: Optional[List[str]] = Field(
[], title="the workflow definitions this project can use, by id"
)
users: Optional[List[str]] = Field(
[], title="the users who are a member of this account, by id"
)
class TaskOperation(BaseModel):
| 64 | 64 | 33 | 6 | 58 | entailor/pytailor | src/pytailor/models.py | Python | TaskOperation | TaskOperation | 344 | 347 | 344 | 344 | 2cc6d6f5272ccfc0bc2989331b75403cc6706161 | bigcode/the-stack | train |
8de1b99d465ccf214afb6b87 | train | class | class Context1(Context):
pass
| class Context1(Context):
| pass
| [str]] = Field(
None,
title="(Optional) limit tasks to those origination from these workflow definitions, by id",
)
workflows: Optional[List[str]] = Field(
None, title="(Optional) limit tasks to these workflows, by id"
)
class Context1(Context):
| 64 | 64 | 8 | 5 | 59 | entailor/pytailor | src/pytailor/models.py | Python | Context1 | Context1 | 115 | 116 | 115 | 115 | 54c6dffaa439853058c57e44436342e6d880ef53 | bigcode/the-stack | train |
af8ce2043f99a263d76c4a2b | train | class | class Tags(BaseModel):
__root__: List[str]
| class Tags(BaseModel):
| __root__: List[str]
| size: Optional[str] = Field(None, title="Size")
class FileSetLinks(BaseModel):
tag_name: Optional[str] = Field(None, title="The tag name of the files")
links: Optional[List[FileSetLink]] = Field(None, title="The files")
class Tags(BaseModel):
| 64 | 64 | 12 | 5 | 59 | entailor/pytailor | src/pytailor/models.py | Python | Tags | Tags | 63 | 64 | 63 | 63 | cfbd548cd14312f211d826aced3a98059288ff32 | bigcode/the-stack | train |
0546bf588247011d022956d0 | train | class | class ValidationError(BaseModel):
loc: List[str] = Field(..., title="Location")
msg: str = Field(..., title="Message")
type: str = Field(..., title="Error Type")
| class ValidationError(BaseModel):
| loc: List[str] = Field(..., title="Location")
msg: str = Field(..., title="Message")
type: str = Field(..., title="Error Type")
| identifier")
accounts: Optional[List[str]] = Field(
None, title="the accounts the user has access to, by id"
)
projects: Optional[List[str]] = Field(
None, title="the projects the user has access to, by id"
)
class ValidationError(BaseModel):
| 64 | 64 | 45 | 6 | 58 | entailor/pytailor | src/pytailor/models.py | Python | ValidationError | ValidationError | 213 | 216 | 213 | 213 | a876464473e67e01542993f707e52d60090b58b5 | bigcode/the-stack | train |
f67effa7e5613d5cbb41c057 | train | class | class ApiKey(BaseModel):
api_worker_id: str = Field(..., title="Api Worker Id")
api_secret_key: str = Field(..., title="Api Secret Key")
| class ApiKey(BaseModel):
| api_worker_id: str = Field(..., title="Api Worker Id")
api_secret_key: str = Field(..., title="Api Secret Key")
| Optional[List[str]] = Field(
None, title="the workflow definitions owned by this account, by id"
)
workflow_definitions_subscriptions: Optional[List[str]] = Field(
None, title="the workflow definitions subscribed to by this account, by id"
)
class ApiKey(BaseModel):
| 64 | 64 | 38 | 6 | 58 | entailor/pytailor | src/pytailor/models.py | Python | ApiKey | ApiKey | 36 | 38 | 36 | 36 | 06592420574e41c79852be6859e1aa1650ffd9b0 | bigcode/the-stack | train |
506d16995ad456997c3ebffc | train | class | class FileSetLinks(BaseModel):
tag_name: Optional[str] = Field(None, title="The tag name of the files")
links: Optional[List[FileSetLink]] = Field(None, title="The files")
| class FileSetLinks(BaseModel):
| tag_name: Optional[str] = Field(None, title="The tag name of the files")
links: Optional[List[FileSetLink]] = Field(None, title="The files")
| (None, title="List of tags to download files for")
class FileSetLink(BaseModel):
filename: str = Field(..., title="Filename")
url: str = Field(..., title="Url")
size: Optional[str] = Field(None, title="Size")
class FileSetLinks(BaseModel):
| 64 | 64 | 46 | 7 | 57 | entailor/pytailor | src/pytailor/models.py | Python | FileSetLinks | FileSetLinks | 58 | 60 | 58 | 58 | dcbbeb1d1bde893022f1433d38b9411a8da823d0 | bigcode/the-stack | train |
a2f3310189945fe5072acfaf | train | class | class WorkflowTask(BaseModel):
id: Optional[str] = Field(None, title="Task id")
name: Optional[str] = Field(None, title="Task name")
type: Optional[str] = Field(None, title="Task type")
| class WorkflowTask(BaseModel):
| id: Optional[str] = Field(None, title="Task id")
name: Optional[str] = Field(None, title="Task name")
type: Optional[str] = Field(None, title="Task type")
| user that created this workflow")
state: Optional[str] = Field(
None, title="current aggregated state of the workflow's tasks"
)
from_definition_id: Optional[str] = Field(
None, title="The workflow definition this Workflow is based on"
)
class WorkflowTask(BaseModel):
| 64 | 64 | 51 | 6 | 58 | entailor/pytailor | src/pytailor/models.py | Python | WorkflowTask | WorkflowTask | 309 | 312 | 309 | 309 | 0d4e28dd4cc41910381dad771b414c9d9b16886d | bigcode/the-stack | train |
de1ddd1273a4631225a0e1bb | train | class | class TaskRun(BaseModel):
state: Optional[TaskState] = Field(None, title="state of the task run")
ended_utc: Optional[str] = Field(
None, title="timestamp of when the workflow ended, in ISO-8601 datetime format"
)
traceback: Optional[List[str]] = Field(None, title="detailed error message")
t... | class TaskRun(BaseModel):
| state: Optional[TaskState] = Field(None, title="state of the task run")
ended_utc: Optional[str] = Field(
None, title="timestamp of when the workflow ended, in ISO-8601 datetime format"
)
traceback: Optional[List[str]] = Field(None, title="detailed error message")
traceback_raw: Optional[str... | [List[str]] = Field(
[], title="the users who are a member of this account, by id"
)
class TaskOperation(BaseModel):
type: Optional[TaskOperationType] = Field(
None, title="The type of operation to be performed"
)
class TaskRun(BaseModel):
| 64 | 64 | 120 | 6 | 58 | entailor/pytailor | src/pytailor/models.py | Python | TaskRun | TaskRun | 350 | 359 | 350 | 350 | dc9e12337abb86121a12bc2d27bb39c9b2b0d34a | bigcode/the-stack | train |
40693ce86376ccaef6fecedb | train | class | class StorageType(Enum):
AZURE_BLOB_CONTAINER = "AZURE_BLOB_CONTAINER"
LOCAL_FILESYSTEM = "LOCAL_FILESYSTEM"
S3_BUCKET = "S3_BUCKET"
| class StorageType(Enum):
| AZURE_BLOB_CONTAINER = "AZURE_BLOB_CONTAINER"
LOCAL_FILESYSTEM = "LOCAL_FILESYSTEM"
S3_BUCKET = "S3_BUCKET"
| = Field([], title="Ids to remove")
class PermissionList(BaseModel):
__root__: List[str] = Field(..., title="PermissionList")
class ProcessingStatus(Enum):
COMPLETED = "COMPLETED"
PENDING = "PENDING"
FAILED = "FAILED"
class StorageType(Enum):
| 64 | 64 | 39 | 5 | 59 | entailor/pytailor | src/pytailor/models.py | Python | StorageType | StorageType | 89 | 92 | 89 | 89 | 6124c956822bd3fc7d2267e437c1988cbdc41821 | bigcode/the-stack | train |
8ae378cccf6540eed111c38b | train | class | class TaskExecutionData(BaseModel):
run_id: Optional[str] = Field(
None, title="The current Task Run id, if it is running"
)
task_id: Optional[str] = Field(None, title="The task's id")
definition: Optional[Dict[str, Any]] = Field(None, title="The task's definition")
context: Optional[Context... | class TaskExecutionData(BaseModel):
| run_id: Optional[str] = Field(
None, title="The current Task Run id, if it is running"
)
task_id: Optional[str] = Field(None, title="The task's id")
definition: Optional[Dict[str, Any]] = Field(None, title="The task's definition")
context: Optional[Context1] = Field(None, title="The task's c... | Field(
None,
title="(Optional) limit tasks to those origination from these workflow definitions, by id",
)
workflows: Optional[List[str]] = Field(
None, title="(Optional) limit tasks to these workflows, by id"
)
class Context1(Context):
pass
class TaskExecutionData(BaseModel):... | 71 | 71 | 237 | 7 | 63 | entailor/pytailor | src/pytailor/models.py | Python | TaskExecutionData | TaskExecutionData | 119 | 140 | 119 | 119 | 593ca96d1311fb91c0b7cd6c1c03150f12acb6e9 | bigcode/the-stack | train |
1bbe6d40939d34c5daef596c | train | class | class TaskCheckout(BaseModel):
worker_capabilities: Optional[List[str]] = Field(
None, title="The worker's task capabilities"
)
worker_id: Optional[str] = Field(None, title="The unique id of the worker")
worker_name: Optional[str] = Field(
None, title="A human-friendly name describing th... | class TaskCheckout(BaseModel):
| worker_capabilities: Optional[List[str]] = Field(
None, title="The worker's task capabilities"
)
worker_id: Optional[str] = Field(None, title="The unique id of the worker")
worker_name: Optional[str] = Field(
None, title="A human-friendly name describing the worker"
)
projects: O... | "COMPLETED"
PENDING = "PENDING"
FAILED = "FAILED"
class StorageType(Enum):
AZURE_BLOB_CONTAINER = "AZURE_BLOB_CONTAINER"
LOCAL_FILESYSTEM = "LOCAL_FILESYSTEM"
S3_BUCKET = "S3_BUCKET"
class TaskCheckout(BaseModel):
| 64 | 64 | 171 | 6 | 58 | entailor/pytailor | src/pytailor/models.py | Python | TaskCheckout | TaskCheckout | 95 | 112 | 95 | 95 | ee294b93867c11814161c48e594eeee0cbe2bfb8 | bigcode/the-stack | train |
d7cba93b3b7693be82752d0b | train | class | class TaskUpdate(BaseModel):
task_id: Optional[str] = Field(None, title="The identifier of the task")
run_id: Optional[str] = Field(None, title="The identifier of the task run")
state: Optional[TaskState] = Field(None, title="The updated state of the task run")
outputs: Optional[Dict[str, Any]] = Field(... | class TaskUpdate(BaseModel):
| task_id: Optional[str] = Field(None, title="The identifier of the task")
run_id: Optional[str] = Field(None, title="The identifier of the task run")
state: Optional[TaskState] = Field(None, title="The updated state of the task run")
outputs: Optional[Dict[str, Any]] = Field(
None, title="The upd... | unique name of the task")
updated_utc: Optional[str] = Field(
None, title="timestamp of the latest change, in ISO-8601 datetime format"
)
state: Optional[TaskState] = Field(None, title="current state of the task")
class TaskUpdate(BaseModel):
| 64 | 64 | 201 | 6 | 58 | entailor/pytailor | src/pytailor/models.py | Python | TaskUpdate | TaskUpdate | 167 | 184 | 167 | 167 | 778532fc9543b737d9e995f3340c1577f0deb13f | bigcode/the-stack | train |
5b86ea35345f48dd75a50f17 | train | class | class WorkflowCreate(BaseModel):
from_definition_id: Optional[str] = Field(
None, title="(Optional) the workflow definition to base this Workflow on"
)
dag: Optional[Dict[str, Any]] = Field(
None, title="(Optional) The DAG specification as JSON"
)
name: Optional[str] = Field(None, ti... | class WorkflowCreate(BaseModel):
| from_definition_id: Optional[str] = Field(
None, title="(Optional) the workflow definition to base this Workflow on"
)
dag: Optional[Dict[str, Any]] = Field(
None, title="(Optional) The DAG specification as JSON"
)
name: Optional[str] = Field(None, title="The name selected for this W... | the projects the user has access to, by id"
)
class ValidationError(BaseModel):
loc: List[str] = Field(..., title="Location")
msg: str = Field(..., title="Message")
type: str = Field(..., title="Error Type")
class WorkflowCreate(BaseModel):
| 64 | 64 | 195 | 6 | 58 | entailor/pytailor | src/pytailor/models.py | Python | WorkflowCreate | WorkflowCreate | 219 | 236 | 219 | 219 | 358c3ad08063b495bdac97672d14bc100755078b | bigcode/the-stack | train |
81f16c5578a188c626060f84 | train | class | class ProcessingStatus(Enum):
COMPLETED = "COMPLETED"
PENDING = "PENDING"
FAILED = "FAILED"
| class ProcessingStatus(Enum):
| COMPLETED = "COMPLETED"
PENDING = "PENDING"
FAILED = "FAILED"
| PermissionChange(BaseModel):
add: Optional[List[str]] = Field([], title="Ids to add")
delete: Optional[List[str]] = Field([], title="Ids to remove")
class PermissionList(BaseModel):
__root__: List[str] = Field(..., title="PermissionList")
class ProcessingStatus(Enum):
| 64 | 64 | 28 | 5 | 59 | entailor/pytailor | src/pytailor/models.py | Python | ProcessingStatus | ProcessingStatus | 83 | 86 | 83 | 83 | 7ffc4bf2e3241121b76296e5e1f718d29526137f | bigcode/the-stack | train |
bbcbbccc9b2e7aa7d4965f95 | train | class | class User(BaseModel):
username: Optional[str] = Field(None, title="unique username")
id: Optional[str] = Field(None, title="unique identifier")
accounts: Optional[List[str]] = Field(
None, title="the accounts the user has access to, by id"
)
projects: Optional[List[str]] = Field(
No... | class User(BaseModel):
| username: Optional[str] = Field(None, title="unique username")
id: Optional[str] = Field(None, title="unique identifier")
accounts: Optional[List[str]] = Field(
None, title="the accounts the user has access to, by id"
)
projects: Optional[List[str]] = Field(
None, title="the projects... | [str] = Field(
None,
title="The location on the Worker's filesystem for the current task run. Mandatory on first check in.",
)
perform_branching: Optional[bool] = Field(
False, title="Signal to the backend to perform branching"
)
class User(BaseModel):
| 64 | 64 | 162 | 5 | 59 | entailor/pytailor | src/pytailor/models.py | Python | User | User | 187 | 199 | 187 | 187 | ebeb3dea91fcb0fc9da1e81ab73692d60c5e2a6c | bigcode/the-stack | train |
6682770997f3a64546d81b79 | train | class | class Workflow(BaseModel):
id: Optional[str] = Field(None, title="unique ID of the workflow")
name: Optional[str] = Field(None, title="non-unique name of the workflow")
project_id: Optional[str] = Field(None, title="project that owns this workflow")
updated_utc: Optional[str] = Field(
None, titl... | class Workflow(BaseModel):
| id: Optional[str] = Field(None, title="unique ID of the workflow")
name: Optional[str] = Field(None, title="non-unique name of the workflow")
project_id: Optional[str] = Field(None, title="project that owns this workflow")
updated_utc: Optional[str] = Field(
None, title="timestamp of the latest ... | (BaseModel):
state: Optional[TaskState] = Field(None, title="state of the task run")
ended_utc: Optional[str] = Field(
None, title="timestamp of when the workflow ended, in ISO-8601 datetime format"
)
traceback: Optional[List[str]] = Field(None, title="detailed error message")
traceback_raw:... | 122 | 122 | 408 | 5 | 117 | entailor/pytailor | src/pytailor/models.py | Python | Workflow | Workflow | 362 | 394 | 362 | 362 | 219bf7fcc56064c5a61420b7b820ef8f867baffd | bigcode/the-stack | train |
31834dc553b4d9321acf7579 | train | class | class PermissionList(BaseModel):
__root__: List[str] = Field(..., title="PermissionList")
| class PermissionList(BaseModel):
| __root__: List[str] = Field(..., title="PermissionList")
| Field(
..., title="Dict of tags, each containing a list of file names"
)
class PermissionChange(BaseModel):
add: Optional[List[str]] = Field([], title="Ids to add")
delete: Optional[List[str]] = Field([], title="Ids to remove")
class PermissionList(BaseModel):
| 64 | 64 | 22 | 6 | 58 | entailor/pytailor | src/pytailor/models.py | Python | PermissionList | PermissionList | 79 | 80 | 79 | 79 | 454389e76c5fe22957b66dcd30503f5fccd55c29 | bigcode/the-stack | train |
5d991d10f48700a826cb6310 | train | class | class TaskState(Enum):
ARCHIVED = "ARCHIVED"
FAILED = "FAILED"
STOPPED = "STOPPED"
WAITING = "WAITING"
READY = "READY"
RESERVED = "RESERVED"
RUNNING = "RUNNING"
COMPLETED = "COMPLETED"
| class TaskState(Enum):
| ARCHIVED = "ARCHIVED"
FAILED = "FAILED"
STOPPED = "STOPPED"
WAITING = "WAITING"
READY = "READY"
RESERVED = "RESERVED"
RUNNING = "RUNNING"
COMPLETED = "COMPLETED"
| retrieve PENDING results from /task/pending-results/{id}",
title="Processing id",
)
processing_msg: Optional[str] = Field(
None, title="A message with info about the processing result"
)
class TaskOperationType(Enum):
RESET = "RESET"
class TaskState(Enum):
| 64 | 64 | 65 | 5 | 59 | entailor/pytailor | src/pytailor/models.py | Python | TaskState | TaskState | 147 | 155 | 147 | 147 | 0d244901b4615767f9fb847620e9ddcd049874f4 | bigcode/the-stack | train |
6378bd7ba7480ed81eab2ca9 | train | class | class WorkflowDefinitionSummary(BaseModel):
id: Optional[str] = Field(None, title="unique ID of the workflow definition")
name: Optional[str] = Field(
None, title="non-unique name of the workflow definition"
)
description: Optional[str] = Field(None, title="description of the workflow")
| class WorkflowDefinitionSummary(BaseModel):
| id: Optional[str] = Field(None, title="unique ID of the workflow definition")
name: Optional[str] = Field(
None, title="non-unique name of the workflow definition"
)
description: Optional[str] = Field(None, title="description of the workflow")
| schema specification as JSON"
)
name: Optional[str] = Field(None, title="The name selected for this Workflow")
description: Optional[str] = Field(
None,
title="The description of this workflow definition, in Markdown format or plain text",
)
class WorkflowDefinitionSummary(BaseModel):
| 64 | 64 | 68 | 7 | 57 | entailor/pytailor | src/pytailor/models.py | Python | WorkflowDefinitionSummary | WorkflowDefinitionSummary | 285 | 290 | 285 | 285 | 1e325a78225ed5c84d1ac3d9a40e6557a86953ba | bigcode/the-stack | train |
2c01c269ab5fb66d76577952 | train | class | class PermissionChange(BaseModel):
add: Optional[List[str]] = Field([], title="Ids to add")
delete: Optional[List[str]] = Field([], title="Ids to remove")
| class PermissionChange(BaseModel):
| add: Optional[List[str]] = Field([], title="Ids to add")
delete: Optional[List[str]] = Field([], title="Ids to remove")
| ]
class FileSetUpload(BaseModel):
task_id: Optional[str] = Field(None, title="Task to scope the fileset against")
tags: Dict[str, Tags] = Field(
..., title="Dict of tags, each containing a list of file names"
)
class PermissionChange(BaseModel):
| 64 | 64 | 38 | 6 | 58 | entailor/pytailor | src/pytailor/models.py | Python | PermissionChange | PermissionChange | 74 | 76 | 74 | 74 | 566556a1a61d23c0e5bd64cf0cad2cac3b85dfce | bigcode/the-stack | train |
b57367ac9c9f83f41879b799 | train | class | class Context(BaseModel):
inputs: Optional[Dict[str, Any]] = Field(None, title="Scoped inputs")
outputs: Optional[Dict[str, Any]] = Field(None, title="Scoped outputs")
files: Optional[Dict[str, Any]] = Field(None, title="File list by tag")
| class Context(BaseModel):
| inputs: Optional[Dict[str, Any]] = Field(None, title="Scoped inputs")
outputs: Optional[Dict[str, Any]] = Field(None, title="Scoped outputs")
files: Optional[Dict[str, Any]] = Field(None, title="File list by tag")
| Field(
None, title="the workflow definitions subscribed to by this account, by id"
)
class ApiKey(BaseModel):
api_worker_id: str = Field(..., title="Api Worker Id")
api_secret_key: str = Field(..., title="Api Secret Key")
class Context(BaseModel):
| 64 | 64 | 64 | 5 | 59 | entailor/pytailor | src/pytailor/models.py | Python | Context | Context | 41 | 44 | 41 | 41 | 2bc233ae858940713c3ef07ae332da47d88b896b | bigcode/the-stack | train |
344f1f726b0f33ffd6fbcccb | train | class | class FileSetDownload(BaseModel):
task_id: Optional[str] = Field(None, title="Task to scope the fileset against")
tags: Optional[List[str]] = Field(None, title="List of tags to download files for")
| class FileSetDownload(BaseModel):
| task_id: Optional[str] = Field(None, title="Task to scope the fileset against")
tags: Optional[List[str]] = Field(None, title="List of tags to download files for")
| : Optional[Dict[str, Any]] = Field(None, title="Scoped inputs")
outputs: Optional[Dict[str, Any]] = Field(None, title="Scoped outputs")
files: Optional[Dict[str, Any]] = Field(None, title="File list by tag")
class FileSetDownload(BaseModel):
| 64 | 64 | 49 | 7 | 57 | entailor/pytailor | src/pytailor/models.py | Python | FileSetDownload | FileSetDownload | 47 | 49 | 47 | 47 | 26be0b94c0568fa563d2fad03adad5aaaf191299 | bigcode/the-stack | train |
8cb76a616e9e5bc4ef662d86 | train | class | class TaskSummary(BaseModel):
id: Optional[str] = Field(None, title="unique identifier of the task")
name: Optional[str] = Field(None, title="non-unique name of the task")
updated_utc: Optional[str] = Field(
None, title="timestamp of the latest change, in ISO-8601 datetime format"
)
state: O... | class TaskSummary(BaseModel):
| id: Optional[str] = Field(None, title="unique identifier of the task")
name: Optional[str] = Field(None, title="non-unique name of the task")
updated_utc: Optional[str] = Field(
None, title="timestamp of the latest change, in ISO-8601 datetime format"
)
state: Optional[TaskState] = Field(Non... | IVED = "ARCHIVED"
FAILED = "FAILED"
STOPPED = "STOPPED"
WAITING = "WAITING"
READY = "READY"
RESERVED = "RESERVED"
RUNNING = "RUNNING"
COMPLETED = "COMPLETED"
class TaskSummary(BaseModel):
| 64 | 64 | 96 | 6 | 58 | entailor/pytailor | src/pytailor/models.py | Python | TaskSummary | TaskSummary | 158 | 164 | 158 | 158 | 7bfb8290b51663d39014ba4890d6aaaea6917236 | bigcode/the-stack | train |
682dcc90ee868c5122ee8ea5 | train | class | class Project(BaseModel):
id: Optional[str] = Field(None, title="unique identifier")
name: Optional[str] = Field(None, title="project name")
account_id: Optional[str] = Field(None, title="the project owner account, by id")
storage_type: Optional[StorageType] = Field(None, title="File storage type")
... | class Project(BaseModel):
| id: Optional[str] = Field(None, title="unique identifier")
name: Optional[str] = Field(None, title="project name")
account_id: Optional[str] = Field(None, title="the project owner account, by id")
storage_type: Optional[StorageType] = Field(None, title="File storage type")
storage_identifier: Option... | [List[FileSetLinks]] = Field(None, title="File links")
size: Optional[str] = Field(None, title="Total size of files in fileset")
class HTTPValidationError(BaseModel):
detail: Optional[List[ValidationError]] = Field(None, title="Detail")
class Project(BaseModel):
| 64 | 64 | 190 | 5 | 59 | entailor/pytailor | src/pytailor/models.py | Python | Project | Project | 325 | 341 | 325 | 325 | 31eaa07ac197eea9bd48200ca97503cd7ace6454 | bigcode/the-stack | train |
7dd3730447df6c21b6f9fc20 | train | class | class Task(BaseModel):
id: Optional[str] = Field(None, title="unique identifier of the task")
name: Optional[str] = Field(None, title="non-unique name of the task")
updated_utc: Optional[str] = Field(
None, title="timestamp of the latest change, in ISO-8601 datetime format"
)
state: Optional... | class Task(BaseModel):
| id: Optional[str] = Field(None, title="unique identifier of the task")
name: Optional[str] = Field(None, title="non-unique name of the task")
updated_utc: Optional[str] = Field(
None, title="timestamp of the latest change, in ISO-8601 datetime format"
)
state: Optional[TaskState] = Field(Non... | (None, title="The Workflow's input")
outputs: Optional[Dict[str, Any]] = Field(None, title="The Workflow's output")
files: Optional[Dict[str, Any]] = Field(None, title="The Workflow's files")
tasks: Optional[List[WorkflowTask]] = Field(None, title="The Workflow's output")
class Task(BaseModel):
| 76 | 76 | 255 | 5 | 71 | entailor/pytailor | src/pytailor/models.py | Python | Task | Task | 397 | 418 | 397 | 397 | 7bf34dd215f1dc9008944ced03530a8ad8d6e065 | bigcode/the-stack | train |
009abf0fa31d2f57b4d82601 | train | class | class HTTPValidationError(BaseModel):
detail: Optional[List[ValidationError]] = Field(None, title="Detail")
| class HTTPValidationError(BaseModel):
| detail: Optional[List[ValidationError]] = Field(None, title="Detail")
| (BaseModel):
id: Optional[str] = Field(None, title="unique identifier")
tags: Optional[List[FileSetLinks]] = Field(None, title="File links")
size: Optional[str] = Field(None, title="Total size of files in fileset")
class HTTPValidationError(BaseModel):
| 64 | 64 | 24 | 7 | 57 | entailor/pytailor | src/pytailor/models.py | Python | HTTPValidationError | HTTPValidationError | 321 | 322 | 321 | 321 | 0ecc95d35756c96886696fca931d7bc4604bf254 | bigcode/the-stack | train |
869d612b45815552f8798977 | train | class | class UserSummary(BaseModel):
username: Optional[str] = Field(None, title="unique username")
id: Optional[str] = Field(None, title="unique identifier")
accounts: Optional[List[str]] = Field(
None, title="the accounts the user has access to, by id"
)
projects: Optional[List[str]] = Field(
... | class UserSummary(BaseModel):
| username: Optional[str] = Field(None, title="unique username")
id: Optional[str] = Field(None, title="unique identifier")
accounts: Optional[List[str]] = Field(
None, title="the accounts the user has access to, by id"
)
projects: Optional[List[str]] = Field(
None, title="the projects... | the user's given name")
family_name: Optional[str] = Field(None, title="the user's family name")
email: Optional[str] = Field(None, title="the user's email address")
phone_number: Optional[str] = Field(None, title="the user's phone number")
class UserSummary(BaseModel):
| 64 | 64 | 92 | 6 | 58 | entailor/pytailor | src/pytailor/models.py | Python | UserSummary | UserSummary | 202 | 210 | 202 | 202 | 6503e8b98c968c5c7412939eaea04b30e8a54568 | bigcode/the-stack | train |
3dc0716458ebeba2789b33f6 | train | class | class Migration(migrations.Migration):
dependencies = [
('tag', '0001_initial'),
('slide', '0003_slide_pathology'),
]
operations = [
migrations.AddField(
model_name='slide',
name='tags',
field=models.ManyToManyField(to='tag.Tag'),
),
... | class Migration(migrations.Migration):
| dependencies = [
('tag', '0001_initial'),
('slide', '0003_slide_pathology'),
]
operations = [
migrations.AddField(
model_name='slide',
name='tags',
field=models.ManyToManyField(to='tag.Tag'),
),
]
| # Generated by Django 3.2 on 2021-09-20 09:43
from django.db import migrations, models
class Migration(migrations.Migration):
| 36 | 64 | 69 | 7 | 28 | AICAN-Research/learn-pathology | slide/migrations/0004_slide_tags.py | Python | Migration | Migration | 6 | 19 | 6 | 7 | acdd09c894840828b857a4f0601d7c41b37460e9 | bigcode/the-stack | train |
5c577dfad20549afdff27c82 | train | class | class Deployment(pulumi.CustomResource):
created_date: pulumi.Output[str]
"""
The creation date of the deployment
"""
description: pulumi.Output[str]
"""
The description of the deployment
"""
execution_arn: pulumi.Output[str]
"""
The execution ARN to be used in [`lambda_permi... | class Deployment(pulumi.CustomResource):
| created_date: pulumi.Output[str]
"""
The creation date of the deployment
"""
description: pulumi.Output[str]
"""
The description of the deployment
"""
execution_arn: pulumi.Output[str]
"""
The execution ARN to be used in [`lambda_permission`](https://www.terraform.io/docs/pro... | # coding=utf-8
# *** WARNING: this file was generated by the Pulumi Terraform Bridge (tfgen) Tool. ***
# *** Do not edit by hand unless you're certain you know what you are doing! ***
import json
import warnings
import pulumi
import pulumi.runtime
from .. import utilities, tables
class Deployment(pulumi.CustomResource... | 76 | 256 | 921 | 8 | 67 | lemonade-hq/pulumi-aws | sdk/python/pulumi_aws/apigateway/deployment.py | Python | Deployment | Deployment | 11 | 104 | 11 | 11 | fe2af4efa3011c2e0886e3f704c31e9cf2b11899 | bigcode/the-stack | train |
52dd14a1378f54f4f7d1a9d7 | train | class | class ProfilerTest(test_util.TensorFlowTestCase):
def test_profile_exceptions(self):
logdir = self.get_temp_dir()
profiler.start(logdir)
with self.assertRaises(errors.AlreadyExistsError):
profiler.start(logdir)
profiler.stop()
with self.assertRaises(errors.UnavailableError):
profiler... | class ProfilerTest(test_util.TensorFlowTestCase):
| def test_profile_exceptions(self):
logdir = self.get_temp_dir()
profiler.start(logdir)
with self.assertRaises(errors.AlreadyExistsError):
profiler.start(logdir)
profiler.stop()
with self.assertRaises(errors.UnavailableError):
profiler.stop()
# Test with a bad logdir, and it corre... | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ==============================================================================
"""Tests for tf 2.x profiler."""
from __future__ import absol... | 143 | 143 | 479 | 11 | 131 | where-is-brett/tensorflow | tensorflow/python/profiler/profiler_v2_test.py | Python | ProfilerTest | ProfilerTest | 33 | 87 | 33 | 34 | 801b9b600e8cedbf94becc3c2f0a86260c7f1041 | bigcode/the-stack | train |
fd21e3ac8772f041fe10fa74 | train | function | def test_binary_dice_loss():
"""
test binary loss
"""
A = torch.zeros((3, 10, 10))
A[:,:,:3] = 1
B = torch.zeros((3, 10, 10))
B[:,:,:3] = 1
print(f"A.shape = {A.shape} B.shape = {B.shape}")
dl = BinaryDiceLoss(reduction='mean', ohem_ratio=0.2)
loss = dl(A, B)
print(loss)
| def test_binary_dice_loss():
| """
test binary loss
"""
A = torch.zeros((3, 10, 10))
A[:,:,:3] = 1
B = torch.zeros((3, 10, 10))
B[:,:,:3] = 1
print(f"A.shape = {A.shape} B.shape = {B.shape}")
dl = BinaryDiceLoss(reduction='mean', ohem_ratio=0.2)
loss = dl(A, B)
print(loss)
| ] == target.shape[1], \
'Expect weight shape [{}], get[{}]'.format(target.shape[1], self.weight.shape[0])
dice_loss *= self.weights[i]
total_loss += dice_loss
return total_loss/target.shape[1]
def test_binary_dice_loss():
| 64 | 64 | 112 | 7 | 57 | WdBlink/Brats_State_of_the_art_models | unet3d/dice_loss.py | Python | test_binary_dice_loss | test_binary_dice_loss | 129 | 140 | 129 | 129 | aa48a6dad3c1fe8615d2a6be38b7d1474afa39b5 | bigcode/the-stack | train |
f332f682be33afa3a662e583 | train | function | def test_dice_loss():
"""
test dice loss
"""
A = torch.zeros((1, 3, 256, 256))
B = torch.ones((1, 3, 256, 256))
print(f"A.shape = {A.shape} B.shape = {B.shape}")
dl = DiceLoss(reduction='mean', ohem_ratio=0.5)
loss = dl(A, B)
print(loss)
| def test_dice_loss():
| """
test dice loss
"""
A = torch.zeros((1, 3, 256, 256))
B = torch.ones((1, 3, 256, 256))
print(f"A.shape = {A.shape} B.shape = {B.shape}")
dl = DiceLoss(reduction='mean', ohem_ratio=0.5)
loss = dl(A, B)
print(loss)
| B[:,:,:3] = 1
print(f"A.shape = {A.shape} B.shape = {B.shape}")
dl = BinaryDiceLoss(reduction='mean', ohem_ratio=0.2)
loss = dl(A, B)
print(loss)
def test_dice_loss():
| 64 | 64 | 96 | 6 | 58 | WdBlink/Brats_State_of_the_art_models | unet3d/dice_loss.py | Python | test_dice_loss | test_dice_loss | 143 | 152 | 143 | 143 | fec1d5cc071b0d3df10bc92b32a9da7761b14877 | bigcode/the-stack | train |
d8e135761d8a0999909eeac8 | train | class | class DiceLoss(nn.Module):
"""Dice loss, need one hot encode input
Args:
weight: An array of shape [num_classes,]
ignore_index: class index to ignore
predict: A tensor of shape [N, C, *]
target: A tensor of same shape with predict
other args pass to BinaryDiceLoss
Ret... | class DiceLoss(nn.Module):
| """Dice loss, need one hot encode input
Args:
weight: An array of shape [num_classes,]
ignore_index: class index to ignore
predict: A tensor of shape [N, C, *]
target: A tensor of same shape with predict
other args pass to BinaryDiceLoss
Return:
same as Binary... | ) + target.pow(self.p), dim=1) + self.smooth
loss = 1 - num / den
if self.reduction == 'mean':
return loss.mean()
elif self.reduction == 'sum':
return loss.sum()
elif self.reduction == 'none':
return loss
else:
raise Exception... | 88 | 88 | 295 | 6 | 82 | WdBlink/Brats_State_of_the_art_models | unet3d/dice_loss.py | Python | DiceLoss | DiceLoss | 94 | 126 | 94 | 94 | c0970ed8eac15e81f6162a40c4609a8de716210f | bigcode/the-stack | train |
efd479097d4259299dcc25b2 | train | class | class BinaryDiceLoss(nn.Module):
"""Dice loss of binary class
Args:
smooth: A float number to smooth loss, and avoid NaN error, default: 1
p: Denominator value: \sum{x^p} + \sum{y^p}, default: 2
predict: A tensor of shape [N, *]
target: A tensor of shape same with predict
... | class BinaryDiceLoss(nn.Module):
| """Dice loss of binary class
Args:
smooth: A float number to smooth loss, and avoid NaN error, default: 1
p: Denominator value: \sum{x^p} + \sum{y^p}, default: 2
predict: A tensor of shape [N, *]
target: A tensor of shape same with predict
reduction: Reduction method to a... | ohem funciton
1. define each classes' weight
2. use ohem or every class
"""
import torch
import torch.nn as nn
import torch.nn.functional as F
import numpy as np
def make_one_hot(input, num_classes):
"""Convert class index tensor to one hot encoding tensor.
Args:
input: A tensor of shape [N... | 171 | 171 | 571 | 7 | 163 | WdBlink/Brats_State_of_the_art_models | unet3d/dice_loss.py | Python | BinaryDiceLoss | BinaryDiceLoss | 36 | 91 | 36 | 36 | cdf5a966ae39b5ce0cb783969b513b44fe03360e | bigcode/the-stack | train |
c81d11290ae814ad6a74b521 | train | function | def make_one_hot(input, num_classes):
"""Convert class index tensor to one hot encoding tensor.
Args:
input: A tensor of shape [N, 1, *]
num_classes: An int of number of class
Returns:
A tensor of shape [N, num_classes, *]
"""
shape = np.array(input.shape)
shape[1] = nu... | def make_one_hot(input, num_classes):
| """Convert class index tensor to one hot encoding tensor.
Args:
input: A tensor of shape [N, 1, *]
num_classes: An int of number of class
Returns:
A tensor of shape [N, num_classes, *]
"""
shape = np.array(input.shape)
shape[1] = num_classes
shape = tuple(shape)
... | -PyTorch.git
add ohem funciton
1. define each classes' weight
2. use ohem or every class
"""
import torch
import torch.nn as nn
import torch.nn.functional as F
import numpy as np
def make_one_hot(input, num_classes):
| 64 | 64 | 116 | 9 | 54 | WdBlink/Brats_State_of_the_art_models | unet3d/dice_loss.py | Python | make_one_hot | make_one_hot | 19 | 33 | 19 | 19 | f38d225c400e19dbd6debb459e6d87668d2c2c6d | bigcode/the-stack | train |
6ee94ffb7f1a453aa363c5ac | train | class | class BackgroundFileConsumer:
"""A consumer that writes to a file like object. Supports both push
and pull producers
Args:
file_obj: The file like object to write to. Closed when
finished.
reactor: the Twisted reactor to use
"""
# For PushProducers pause if we have this... | class BackgroundFileConsumer:
| """A consumer that writes to a file like object. Supports both push
and pull producers
Args:
file_obj: The file like object to write to. Closed when
finished.
reactor: the Twisted reactor to use
"""
# For PushProducers pause if we have this many unwritten slices
_PA... | # Copyright 2018 New Vector Ltd
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writin... | 203 | 256 | 1,025 | 5 | 197 | maxkratz/synapse | synapse/util/file_consumer.py | Python | BackgroundFileConsumer | BackgroundFileConsumer | 26 | 151 | 26 | 26 | 38c33e5aacc23a726b2bc6e3b8271e7243529ee4 | bigcode/the-stack | train |
9d7e0ac19b0baf8f945c597c | train | function | def test_PythonCodePrinter():
prntr = PythonCodePrinter()
assert not prntr.module_imports
assert prntr.doprint(x**y) == 'x**y'
assert prntr.doprint(Mod(x, 2)) == 'x % 2'
assert prntr.doprint(And(x, y)) == 'x and y'
assert prntr.doprint(Or(x, y)) == 'x or y'
assert not prntr.module_imports
... | def test_PythonCodePrinter():
| prntr = PythonCodePrinter()
assert not prntr.module_imports
assert prntr.doprint(x**y) == 'x**y'
assert prntr.doprint(Mod(x, 2)) == 'x % 2'
assert prntr.doprint(And(x, y)) == 'x and y'
assert prntr.doprint(Or(x, y)) == 'x or y'
assert not prntr.module_imports
assert prntr.doprint(pi) ... |
from sympy.core.numbers import pi
from sympy.functions import acos, Piecewise, sign, sqrt
from sympy.logic import And, Or
from sympy.matrices import SparseMatrix, MatrixSymbol, Identity
from sympy.printing.pycode import (
MpmathPrinter, NumPyPrinter, PythonCodePrinter, pycode, SciPyPrinter,
SymPyPrinter
)
from... | 126 | 126 | 423 | 7 | 119 | miguelmarco/sympy | sympy/printing/tests/test_pycode.py | Python | test_PythonCodePrinter | test_PythonCodePrinter | 23 | 49 | 23 | 23 | 23bff2d578f885364abd749592cb8f9233621dba | bigcode/the-stack | train |
61df3831cfe486e9b416893b | train | function | def test_sqrt():
prntr = PythonCodePrinter()
assert prntr._print_Pow(sqrt(x), rational=False) == 'math.sqrt(x)'
assert prntr._print_Pow(1/sqrt(x), rational=False) == '1/math.sqrt(x)'
prntr = PythonCodePrinter({'standard' : 'python2'})
assert prntr._print_Pow(sqrt(x), rational=True) == 'x**(1./2.)'
... | def test_sqrt():
| prntr = PythonCodePrinter()
assert prntr._print_Pow(sqrt(x), rational=False) == 'math.sqrt(x)'
assert prntr._print_Pow(1/sqrt(x), rational=False) == '1/math.sqrt(x)'
prntr = PythonCodePrinter({'standard' : 'python2'})
assert prntr._print_Pow(sqrt(x), rational=True) == 'x**(1./2.)'
assert prntr.... | {(0, 1): 3})
assert p.doprint(smat) == 'scipy.sparse.coo_matrix([3], ([0], [1]), shape=(2, 5))'
assert 'scipy.sparse' in p.module_imports
def test_pycode_reserved_words():
s1, s2 = symbols('if else')
raises(ValueError, lambda: pycode(s1 + s2, error_on_reserved=True))
py_str = pycode(s1 + s2)
... | 132 | 132 | 443 | 5 | 127 | miguelmarco/sympy | sympy/printing/tests/test_pycode.py | Python | test_sqrt | test_sqrt | 105 | 133 | 105 | 105 | 482b6765f74aca1a720641e706cce9c275696b29 | bigcode/the-stack | train |
58c95cfd76e5a8e6a36a8d03 | train | function | def test_PythonCodePrinter_standard():
import sys
prntr = PythonCodePrinter({'standard':None})
python_version = sys.version_info.major
if python_version == 2:
assert prntr.standard == 'python2'
if python_version == 3:
assert prntr.standard == 'python3'
raises(ValueError, lambda... | def test_PythonCodePrinter_standard():
| import sys
prntr = PythonCodePrinter({'standard':None})
python_version = sys.version_info.major
if python_version == 2:
assert prntr.standard == 'python2'
if python_version == 3:
assert prntr.standard == 'python3'
raises(ValueError, lambda: PythonCodePrinter({'standard':'python... | prntr.doprint(sign(x)) == '(0.0 if x == 0 else math.copysign(1, x))'
assert prntr.doprint(p[0, 1]) == 'p[0, 1]'
def test_PythonCodePrinter_standard():
| 63 | 64 | 89 | 8 | 55 | miguelmarco/sympy | sympy/printing/tests/test_pycode.py | Python | test_PythonCodePrinter_standard | test_PythonCodePrinter_standard | 52 | 62 | 52 | 52 | fc32ad14d072536e96196d5b89e9ecd1f64e4c83 | bigcode/the-stack | train |
956b101e33548e59b941567a | train | function | def test_MpmathPrinter():
p = MpmathPrinter()
assert p.doprint(sign(x)) == 'mpmath.sign(x)'
assert p.doprint(Rational(1, 2)) == 'mpmath.mpf(1)/mpmath.mpf(2)'
| def test_MpmathPrinter():
| p = MpmathPrinter()
assert p.doprint(sign(x)) == 'mpmath.sign(x)'
assert p.doprint(Rational(1, 2)) == 'mpmath.mpf(1)/mpmath.mpf(2)'
| .major
if python_version == 2:
assert prntr.standard == 'python2'
if python_version == 3:
assert prntr.standard == 'python3'
raises(ValueError, lambda: PythonCodePrinter({'standard':'python4'}))
def test_MpmathPrinter():
| 64 | 64 | 61 | 7 | 57 | miguelmarco/sympy | sympy/printing/tests/test_pycode.py | Python | test_MpmathPrinter | test_MpmathPrinter | 64 | 67 | 64 | 64 | 984d64b119803e596695938e528e02b3b0994587 | bigcode/the-stack | train |
5a955d9047519ddf39e62183 | train | function | def test_codegen_ast_nodes():
assert pycode(none) == 'None'
| def test_codegen_ast_nodes():
| assert pycode(none) == 'None'
| _mpmathcode(self, printer):
return 'mpmath'
def test_printmethod():
obj = CustomPrintedObject()
assert NumPyPrinter().doprint(obj) == 'numpy'
assert MpmathPrinter().doprint(obj) == 'mpmath'
def test_codegen_ast_nodes():
| 64 | 64 | 17 | 6 | 58 | miguelmarco/sympy | sympy/printing/tests/test_pycode.py | Python | test_codegen_ast_nodes | test_codegen_ast_nodes | 150 | 151 | 150 | 150 | 6300c00dd7b8edd93e2cbb88431efd4a43d36543 | bigcode/the-stack | train |
e3128052ac9bbdb31e11621f | train | function | def test_issue_14283():
prntr = PythonCodePrinter()
assert prntr.doprint(zoo) == "float('nan')"
assert prntr.doprint(-oo) == "float('-inf')"
| def test_issue_14283():
| prntr = PythonCodePrinter()
assert prntr.doprint(zoo) == "float('nan')"
assert prntr.doprint(-oo) == "float('-inf')"
| ():
obj = CustomPrintedObject()
assert NumPyPrinter().doprint(obj) == 'numpy'
assert MpmathPrinter().doprint(obj) == 'mpmath'
def test_codegen_ast_nodes():
assert pycode(none) == 'None'
def test_issue_14283():
| 64 | 64 | 52 | 7 | 57 | miguelmarco/sympy | sympy/printing/tests/test_pycode.py | Python | test_issue_14283 | test_issue_14283 | 154 | 158 | 154 | 154 | 340a630134ac67b4aa1110445c47276c8fb9d21a | bigcode/the-stack | train |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.