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
f12fdb41af80835d58f923da
train
class
class TestCompletionStatus(Enum): """Enumeration to represent the status of a single test. """ #: The test completed successfully. success = 1 #: The test failed, but did not encounter an unexpected error. failure = 2 #: The test encountered an unexpected error. error = 3 #: A t...
class TestCompletionStatus(Enum):
"""Enumeration to represent the status of a single test. """ #: The test completed successfully. success = 1 #: The test failed, but did not encounter an unexpected error. failure = 2 #: The test encountered an unexpected error. error = 3 #: A test marked as expected to fail une...
from __future__ import absolute_import, unicode_literals from datetime import datetime, timedelta from enum import Enum from functools import wraps import locale import sys import traceback import warnings import six from six.moves import StringIO from .error_holder import ErrorHolder class TestCompletionStatus(Enum...
64
64
115
6
57
pzahemszky/haas
haas/result.py
Python
TestCompletionStatus
TestCompletionStatus
23
44
23
23
109de96b75997d9a291e156d27fd093980ed382a
bigcode/the-stack
train
4a22277068af4955a554c5df
train
function
def _format_exception(err, is_failure, stdout=None, stderr=None): """Converts a sys.exc_info()-style tuple of values into a string.""" exctype, value, tb = err # Skip test runner traceback levels while tb and _is_relevant_tb_level(tb): tb = tb.tb_next if is_failure: # Skip assert*()...
def _format_exception(err, is_failure, stdout=None, stderr=None):
"""Converts a sys.exc_info()-style tuple of values into a string.""" exctype, value, tb = err # Skip test runner traceback levels while tb and _is_relevant_tb_level(tb): tb = tb.tb_next if is_failure: # Skip assert*() traceback levels length = _count_relevant_tb_levels(tb) ...
return length def _decode(line, encoding): if isinstance(line, six.text_type): return line try: return line.decode(encoding) except UnicodeDecodeError: return line.decode(encoding, 'replace') def _format_exception(err, is_failure, stdout=None, stderr=None):
64
64
216
15
49
pzahemszky/haas
haas/result.py
Python
_format_exception
_format_exception
76
101
76
76
a4eff430cbdca89f71fb0da10871473e9bf217f7
bigcode/the-stack
train
a785de693c2ee1ea48c7dc28
train
class
class ResultCollector(object): """Collecter for test results. This handles creating :class:`~.TestResult` instances and handing them off the registered result output handlers. """ # Temporary compatibility with unittest's runner separator2 = separator2 def __init__(self, buffer=False, fa...
class ResultCollector(object):
"""Collecter for test results. This handles creating :class:`~.TestResult` instances and handing them off the registered result output handlers. """ # Temporary compatibility with unittest's runner separator2 = separator2 def __init__(self, buffer=False, failfast=False): self.buf...
) return cls(test_class, test_method_name, status, duration, exception, message) @property def test(self): """The test case instance this result represents. """ return self.test_class(self.test_method_name) def to_dict(self): """Serialize the ``T...
256
256
1,826
5
250
pzahemszky/haas
haas/result.py
Python
ResultCollector
ResultCollector
324
620
324
324
e3068bf37a0f36b15960492d051640e22fbd6bd9
bigcode/the-stack
train
4abc2d1d967f6e409ada2479
train
class
class backgroundSHIP(QtWidgets.QFrame): ''' Draw the background frame and lines for the Theta-E plot frame ''' def __init__(self): super(backgroundSHIP, self).__init__() self.initUI() def initUI(self): ## window configuration settings, ## sich as padding, width, hei...
class backgroundSHIP(QtWidgets.QFrame):
''' Draw the background frame and lines for the Theta-E plot frame ''' def __init__(self): super(backgroundSHIP, self).__init__() self.initUI() def initUI(self): ## window configuration settings, ## sich as padding, width, height, and ## min/max plot axes ...
import numpy as np import os from qtpy import QtGui, QtCore, QtWidgets import sharppy.sharptab as tab import sharppy.databases.inset_data as inset_data from sharppy.sharptab.constants import * import platform ## routine written by Kelton Halbert and Greg Blumberg ## keltonhalbert@ou.edu and wblumberg@ou.edu __all__ ...
107
256
1,664
8
99
skovic/SHARPpy
sharppy/viz/ship.py
Python
backgroundSHIP
backgroundSHIP
14
155
14
14
7e15745fc6d7dbf1b941455d209cf97692c9d602
bigcode/the-stack
train
b59b9e5c0469d191c7e3802b
train
class
class plotSHIP(backgroundSHIP): ''' Plot the data on the frame. Inherits the background class that plots the frame. ''' def __init__(self): self.bg_color = QtGui.QColor('#000000') self.fg_color = QtGui.QColor('#ffffff') self.box_color = QtGui.QColor('#00ff00') self.li...
class plotSHIP(backgroundSHIP):
''' Plot the data on the frame. Inherits the background class that plots the frame. ''' def __init__(self): self.bg_color = QtGui.QColor('#000000') self.fg_color = QtGui.QColor('#ffffff') self.box_color = QtGui.QColor('#00ff00') self.line_color = QtGui.QColor('#0080ff...
[i,2], center[i] + width/2., ef[i,2]) # Draw upper whisker qp.drawLine(center[i], ef[i,3], center[i], ef[i,4]) # Set black transparent pen to draw a rectangle color = QtGui.QColor(self.bg_color) color.setAlpha(0) pen = QtGui.QPen(color, 1, QtCore.Q...
255
255
852
6
249
skovic/SHARPpy
sharppy/viz/ship.py
Python
plotSHIP
plotSHIP
158
278
158
158
f921cb7a863ea85b73329bae1f27e46bf7bc206a
bigcode/the-stack
train
35efe24b2b3dded286fbec34
train
function
def miles_to_km(miles): return miles * 1.6
def miles_to_km(miles):
return miles * 1.6
# map # Определим функцию, которая будет переводить МИли в километры print('map Определим функцию, которая будет переводить МИли в километры') def miles_to_km(miles):
50
64
17
8
42
HeyArtem/python_lesson_4
4.3_Map_Reduce_Filter_Sort.py
Python
miles_to_km
miles_to_km
5
6
5
5
17e31a4f9434db84a1589cef033a3c297af82363
bigcode/the-stack
train
73f83af1da51511723ce73a0
train
class
@dataclass class DataTrainingArguments: """ Arguments pertaining to what data we are going to input our model for training and eval. """ data_dir: str = field( metadata={"help": "The input data dir. Should contain the .txt files for a CoNLL-2003-formatted task."} ) labels: Optional[str] ...
@dataclass class DataTrainingArguments:
""" Arguments pertaining to what data we are going to input our model for training and eval. """ data_dir: str = field( metadata={"help": "The input data dir. Should contain the .txt files for a CoNLL-2003-formatted task."} ) labels: Optional[str] = field( default=None, m...
tokenizer, you should do it in a distinct script, # or just modify its tokenizer_config.json. cache_dir: Optional[str] = field( default=None, metadata={"help": "Where do you want to store the pretrained models downloaded from s3"} ) @dataclass class DataTrainingArguments:
64
64
195
8
56
brufino/ehr-relation-extraction
biobert_ner/run_ner.py
Python
DataTrainingArguments
DataTrainingArguments
51
72
51
52
6fe9858d4a7da8a8d2df89d143329853d22c9805
bigcode/the-stack
train
94d5f562aba895451b08ee7d
train
class
@dataclass class ModelArguments: """ Arguments pertaining to which model/config/tokenizer we are going to fine-tune from. """ model_name_or_path: str = field( metadata={"help": "Path to pretrained model or model identifier from huggingface.co/models"} ) config_name: Optional[str] = field...
@dataclass class ModelArguments:
""" Arguments pertaining to which model/config/tokenizer we are going to fine-tune from. """ model_name_or_path: str = field( metadata={"help": "Path to pretrained model or model identifier from huggingface.co/models"} ) config_name: Optional[str] = field( default=None, metadata=...
( AutoConfig, AutoModelForTokenClassification, AutoTokenizer, EvalPrediction, HfArgumentParser, Trainer, TrainingArguments, set_seed ) from utils_ner import NerDataset, Split, get_labels logger = logging.getLogger(__name__) @dataclass class ModelArguments:
66
66
222
7
59
brufino/ehr-relation-extraction
biobert_ner/run_ner.py
Python
ModelArguments
ModelArguments
29
48
29
30
fdfd75246ab74592b207dcb87132e380f497af5c
bigcode/the-stack
train
d7c7996048499701f5686e50
train
function
def main(): parser = HfArgumentParser((ModelArguments, DataTrainingArguments, TrainingArguments)) if len(sys.argv) == 2 and sys.argv[1].endswith(".json"): # If we pass only one argument to the script and it's the path to a json file, # let's parse it to get our arguments. model_args, dat...
def main():
parser = HfArgumentParser((ModelArguments, DataTrainingArguments, TrainingArguments)) if len(sys.argv) == 2 and sys.argv[1].endswith(".json"): # If we pass only one argument to the script and it's the path to a json file, # let's parse it to get our arguments. model_args, data_args, trai...
on your tokenizer, you should do it in a distinct script, # or just modify its tokenizer_config.json. cache_dir: Optional[str] = field( default=None, metadata={"help": "Where do you want to store the pretrained models downloaded from s3"} ) @dataclass class DataTrainingArguments: """ Argu...
256
256
1,682
3
253
brufino/ehr-relation-extraction
biobert_ner/run_ner.py
Python
main
main
75
282
75
75
41577b23af22364e13569c6e55f10554ce5a7a25
bigcode/the-stack
train
c186930c7cc2dd8ac50decfe
train
function
def resolve_update_site(_, info, site_id, data): user = load_user(info) if not user.is_authenticated: raise Exception("You can't do that!") try: site = Site.objects.get(id=site_id, user=user) except Site.DoesNotExist: logging.debug("Site not found") raise Except...
def resolve_update_site(_, info, site_id, data):
user = load_user(info) if not user.is_authenticated: raise Exception("You can't do that!") try: site = Site.objects.get(id=site_id, user=user) except Site.DoesNotExist: logging.debug("Site not found") raise Exception("Site not found") city = data.get("city...
) except City.DoesNotExist: logging.debug("City not found") raise Exception("City not found") site = Site.objects.create(city=city_obj, description=description, user=user) create_default_page(site) return site def resolve_update_site(_, info, site_id, data):
64
64
162
12
51
patryk-tech/summer-code-jam-2020
cloudy-crocodiles/django/djangocities/sites/mutation.py
Python
resolve_update_site
resolve_update_site
41
67
41
41
9ef3e0080ed37ad994b254e222caa9bd80a69fbe
bigcode/the-stack
train
2bd43ae4dcff49c349792fbe
train
function
def resolve_create_site(_, info, data): user = load_user(info) if not user.is_authenticated: raise Exception("You can't do that!") city = data.get("city", None) description = data.get("description", None) if not city: logging.debug("City is missing") raise Excepti...
def resolve_create_site(_, info, data):
user = load_user(info) if not user.is_authenticated: raise Exception("You can't do that!") city = data.get("city", None) description = data.get("description", None) if not city: logging.debug("City is missing") raise Exception("City is missing") if not descrip...
djangocities.iam.jwt import load_user from djangocities.pages.models import Page from djangocities.sites.models import Site def create_default_page(site): page = Page.objects.create(site=site, file_name="index.html") return page def resolve_create_site(_, info, data):
64
64
160
9
54
patryk-tech/summer-code-jam-2020
cloudy-crocodiles/django/djangocities/sites/mutation.py
Python
resolve_create_site
resolve_create_site
14
38
14
14
0e9ddfced83fc6cf502857dff7d92d93a4ffd508
bigcode/the-stack
train
61f8bef571a20bbe74d88bc4
train
function
def create_default_page(site): page = Page.objects.create(site=site, file_name="index.html") return page
def create_default_page(site):
page = Page.objects.create(site=site, file_name="index.html") return page
import logging from djangocities.cities.models import City from djangocities.iam.jwt import load_user from djangocities.pages.models import Page from djangocities.sites.models import Site def create_default_page(site):
49
64
26
6
42
patryk-tech/summer-code-jam-2020
cloudy-crocodiles/django/djangocities/sites/mutation.py
Python
create_default_page
create_default_page
9
11
9
9
76df3db4d32df4d0082b76bf4101f7bfc6e5b15f
bigcode/the-stack
train
7f9ed3cb4a1f3809edb5456d
train
class
class POWER_SEQUENCER_OT_split_strips_under_cursor(bpy.types.Operator): """ Splits all strips under cursor including muted strips, but excluding locked strips. Auto selects sequences under the time cursor when you don't have a selection. """ doc = { "name": doc_name(__qualname__), "...
class POWER_SEQUENCER_OT_split_strips_under_cursor(bpy.types.Operator):
""" Splits all strips under cursor including muted strips, but excluding locked strips. Auto selects sequences under the time cursor when you don't have a selection. """ doc = { "name": doc_name(__qualname__), "demo": "https://i.imgur.com/ZyEd0jD.gif", "description": doc_des...
hope that it will be useful, but WITHOUT ANY WARRANTY; # without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License along with Power Sequencer. If # not, see <http...
124
124
416
17
106
naetherm/Bforartists
release/scripts/addons/power_sequencer/operators/cut_strips_under_cursor.py
Python
POWER_SEQUENCER_OT_split_strips_under_cursor
POWER_SEQUENCER_OT_split_strips_under_cursor
23
65
23
23
78ebde6487aa8f4c90aad0ee532fde83940fc9f6
bigcode/the-stack
train
8322c0260bf3ae621ea0a628
train
function
def _fullsplit(path, result=None): """ Split a pathname into components (the opposite of os.path.join) in a platform-neutral way. """ if result is None: result = [] head, tail = os.path.split(path) if head == '': return [tail] + result if head == path: return resu...
def _fullsplit(path, result=None):
""" Split a pathname into components (the opposite of os.path.join) in a platform-neutral way. """ if result is None: result = [] head, tail = os.path.split(path) if head == '': return [tail] + result if head == path: return result return _fullsplit(head, [tai...
#!/usr/bin/env python import os from distutils.core import setup def _fullsplit(path, result=None):
25
64
91
9
15
slipstream/SlipStreamClient
client/src/setup.py
Python
_fullsplit
_fullsplit
7
19
7
7
c52577cc4c47f369ff79d7c13f43aaf374ff54ae
bigcode/the-stack
train
48605bae78a9dd6cb27e9200
train
function
def get_packages(basepkg_name, root_dir=''): # Compile the list of packages available, because distutils doesn't have # an easy way to do this. packages = [] root_dir = os.path.join(os.path.dirname(__file__), root_dir) cwd = os.getcwd() if root_dir != '': os.chdir(root_dir) for dirp...
def get_packages(basepkg_name, root_dir=''): # Compile the list of packages available, because distutils doesn't have # an easy way to do this.
packages = [] root_dir = os.path.join(os.path.dirname(__file__), root_dir) cwd = os.getcwd() if root_dir != '': os.chdir(root_dir) for dirpath, dirnames, filenames in os.walk(basepkg_name): # Ignore dirnames that start with '.' for i, dirname in enumerate(dirnames): ...
[tail] + result if head == path: return result return _fullsplit(head, [tail] + result) def get_packages(basepkg_name, root_dir=''): # Compile the list of packages available, because distutils doesn't have # an easy way to do this.
64
64
153
35
29
slipstream/SlipStreamClient
client/src/setup.py
Python
get_packages
get_packages
22
40
22
24
83136040bb4327fad342ad65a4a7cbdbcbb9609b
bigcode/the-stack
train
8394c94d62c183acf43d4810
train
class
class ValueNetworkMixin: def __init__(self, obs_space, action_space, config): if config["use_gae"]: def value(ob, prev_action, prev_reward, *state): model_out, _ = self.model({ SampleBatch.CUR_OBS: convert_to_torch_tensor( np.asarray([...
class ValueNetworkMixin:
def __init__(self, obs_space, action_space, config): if config["use_gae"]: def value(ob, prev_action, prev_reward, *state): model_out, _ = self.model({ SampleBatch.CUR_OBS: convert_to_torch_tensor( np.asarray([ob]), self.device), ...
sampled_kl > 2.0 * self.kl_target: self.kl_coeff *= 1.5 elif sampled_kl < 0.5 * self.kl_target: self.kl_coeff *= 0.5 return self.kl_coeff class ValueNetworkMixin:
64
64
209
5
58
heyong4725/ray
rllib/agents/ppo/ppo_torch_policy.py
Python
ValueNetworkMixin
ValueNetworkMixin
184
208
184
184
b94522ed7bafc8d84a202f7b43d4f383e211c0b7
bigcode/the-stack
train
216db16ccf69bd80c307e1e5
train
class
class KLCoeffMixin: def __init__(self, config): # KL Coefficient. self.kl_coeff = config["kl_coeff"] self.kl_target = config["kl_target"] def update_kl(self, sampled_kl): if sampled_kl > 2.0 * self.kl_target: self.kl_coeff *= 1.5 elif sampled_kl < 0.5 * self....
class KLCoeffMixin:
def __init__(self, config): # KL Coefficient. self.kl_coeff = config["kl_coeff"] self.kl_target = config["kl_target"] def update_kl(self, sampled_kl): if sampled_kl > 2.0 * self.kl_target: self.kl_coeff *= 1.5 elif sampled_kl < 0.5 * self.kl_target: ...
entropy_coeff": policy.entropy_coeff, } def vf_preds_fetches(policy, input_dict, state_batches, model, action_dist): """Adds value function outputs to experience train_batches.""" return { SampleBatch.VF_PREDS: policy.model.value_function(), } class KLCoeffMixin:
64
64
116
7
57
heyong4725/ray
rllib/agents/ppo/ppo_torch_policy.py
Python
KLCoeffMixin
KLCoeffMixin
170
181
170
170
df38a56ccf87ee9610526fe4bc3f0181ae6a3642
bigcode/the-stack
train
6300d52183b1b6645e082734
train
class
class PPOLoss: def __init__(self, dist_class, model, value_targets, advantages, actions, prev_logits, prev_actions_logp, vf_preds, curr_action_dist, ...
class PPOLoss:
def __init__(self, dist_class, model, value_targets, advantages, actions, prev_logits, prev_actions_logp, vf_preds, curr_action_dist, value_fn, ...
import logging import numpy as np import ray from ray.rllib.agents.a3c.a3c_torch_policy import apply_grad_clipping from ray.rllib.agents.ppo.ppo_tf_policy import postprocess_ppo_gae, \ setup_config from ray.rllib.evaluation.postprocessing import Postprocessing from ray.rllib.policy.sample_batch import SampleBatch ...
173
222
741
5
168
heyong4725/ray
rllib/agents/ppo/ppo_torch_policy.py
Python
PPOLoss
PPOLoss
22
111
22
22
abc4d69b22b6a441c3f9e60217138be4e79069b5
bigcode/the-stack
train
6c1642cf054f0849b5b3f879
train
function
def vf_preds_fetches(policy, input_dict, state_batches, model, action_dist): """Adds value function outputs to experience train_batches.""" return { SampleBatch.VF_PREDS: policy.model.value_function(), }
def vf_preds_fetches(policy, input_dict, state_batches, model, action_dist):
"""Adds value function outputs to experience train_batches.""" return { SampleBatch.VF_PREDS: policy.model.value_function(), }
[Postprocessing.VALUE_TARGETS], policy.model.value_function()), "kl": policy.loss_obj.mean_kl, "entropy": policy.loss_obj.mean_entropy, "entropy_coeff": policy.entropy_coeff, } def vf_preds_fetches(policy, input_dict, state_batches, model, action_dist):
64
64
47
18
46
heyong4725/ray
rllib/agents/ppo/ppo_torch_policy.py
Python
vf_preds_fetches
vf_preds_fetches
163
167
163
163
0f96d9ca98abc5695126fe12c859f0231debe4d0
bigcode/the-stack
train
1621ebeae7505f2da9fe9887
train
function
def kl_and_loss_stats(policy, train_batch): return { "cur_kl_coeff": policy.kl_coeff, "cur_lr": policy.cur_lr, "total_loss": policy.loss_obj.loss, "policy_loss": policy.loss_obj.mean_policy_loss, "vf_loss": policy.loss_obj.mean_vf_loss, "vf_explained_var": explained_v...
def kl_and_loss_stats(policy, train_batch):
return { "cur_kl_coeff": policy.kl_coeff, "cur_lr": policy.cur_lr, "total_loss": policy.loss_obj.loss, "policy_loss": policy.loss_obj.mean_policy_loss, "vf_loss": policy.loss_obj.mean_vf_loss, "vf_explained_var": explained_variance( train_batch[Postprocess...
clip_param=policy.config["clip_param"], vf_clip_param=policy.config["vf_clip_param"], vf_loss_coeff=policy.config["vf_loss_coeff"], use_gae=policy.config["use_gae"], ) return policy.loss_obj.loss def kl_and_loss_stats(policy, train_batch):
64
64
130
10
53
heyong4725/ray
rllib/agents/ppo/ppo_torch_policy.py
Python
kl_and_loss_stats
kl_and_loss_stats
147
160
147
147
bdb71d83a5aedf4d4ec7560efbd70dbce6609393
bigcode/the-stack
train
e30c1e31f0a6833c43b4f07d
train
function
def setup_mixins(policy, obs_space, action_space, config): ValueNetworkMixin.__init__(policy, obs_space, action_space, config) KLCoeffMixin.__init__(policy, config) EntropyCoeffSchedule.__init__(policy, config["entropy_coeff"], config["entropy_coeff_schedule"]) Learning...
def setup_mixins(policy, obs_space, action_space, config):
ValueNetworkMixin.__init__(policy, obs_space, action_space, config) KLCoeffMixin.__init__(policy, config) EntropyCoeffSchedule.__init__(policy, config["entropy_coeff"], config["entropy_coeff_schedule"]) LearningRateSchedule.__init__(policy, config["lr"], config["lr_sche...
orch_tensor(np.asarray([1]), self.device)) return self.model.value_function()[0] else: def value(ob, prev_action, prev_reward, *state): return 0.0 self._value = value def setup_mixins(policy, obs_space, action_space, config):
64
64
84
14
49
heyong4725/ray
rllib/agents/ppo/ppo_torch_policy.py
Python
setup_mixins
setup_mixins
211
216
211
211
21eaaa1c92069f3116c460e0e3be917162ba076d
bigcode/the-stack
train
dacd8cbddfa33622a005bd95
train
function
def ppo_surrogate_loss(policy, model, dist_class, train_batch): logits, state = model.from_batch(train_batch, is_training=True) action_dist = dist_class(logits, model) mask = None if state: max_seq_len = torch.max(train_batch["seq_lens"]) mask = sequence_mask(train_batch["seq_lens"], ma...
def ppo_surrogate_loss(policy, model, dist_class, train_batch):
logits, state = model.from_batch(train_batch, is_training=True) action_dist = dist_class(logits, model) mask = None if state: max_seq_len = torch.max(train_batch["seq_lens"]) mask = sequence_mask(train_batch["seq_lens"], max_seq_len) mask = torch.reshape(mask, [-1]) policy....
* vf_loss - entropy_coeff * curr_entropy) else: self.mean_vf_loss = 0.0 loss = reduce_mean_valid(-surrogate_loss + cur_kl_coeff * action_kl - entropy_coeff * curr_entropy) self.loss = loss def ppo_surrogat...
75
75
251
16
58
heyong4725/ray
rllib/agents/ppo/ppo_torch_policy.py
Python
ppo_surrogate_loss
ppo_surrogate_loss
114
144
114
114
18a7c2fa06d04f470cae56ec2ab421a4ad9330ca
bigcode/the-stack
train
537c1e74e80dccd0bf1a1e3b
train
function
def prepare_detections(args): config_path = args.conf input_path = args.input det_folder = args.detFolder tf_checkpoint_dir = args.tf_checkpoint_dir binary_dir = args.binary_dir use_subset = args.use_subset is_dequantize = args.dequantize with open(config_path) as config_buffer: ...
def prepare_detections(args):
config_path = args.conf input_path = args.input det_folder = args.detFolder tf_checkpoint_dir = args.tf_checkpoint_dir binary_dir = args.binary_dir use_subset = args.use_subset is_dequantize = args.dequantize with open(config_path) as config_buffer: config = json.load(config_...
import os import json import cv2 from yolo3.utils import get_yolo_boxes, makedirs from yolo3.bbox import draw_boxes from keras.models import load_model from utils.detections.eval import evaluate from utils.detections.eval import parser from utils.detections.voc_subset_10_percent import voc_subset from demo import res...
103
215
717
7
95
videetparekh/model-zoo-models
yolo/eval.py
Python
prepare_detections
prepare_detections
16
97
16
16
01a07132955f8c2702041285ebcaa85f66b9bae6
bigcode/the-stack
train
f02296858025c690084a09c2
train
function
def Matrix(X, Xi, Xl): return (X-Xl)/(Xi-Xl)
def Matrix(X, Xi, Xl):
return (X-Xl)/(Xi-Xl)
array will be ignored if len(LArray) != 0 : print("\n\n-------------------------------------------------------------------" "\n L | L(Value) | X | Y | Y(x) " "\n-------------------------------------------------------------------") def Matrix(X, Xi, Xl):
64
64
20
9
55
Mezo0099/Numerical-Methods
Lagrange-Interpolating-Polynomial.py
Python
Matrix
Matrix
18
19
18
18
3c88199a26b7abd8143216f215f09202348df13a
bigcode/the-stack
train
252f77d7ccec85dce87b3005
train
function
def midi_to_notes(midi_filename): ''' string filename: relative path to midi file. Saves a intermediate csv and csv of notes used as training data ''' # Make sure midi file exists if not os.path.isfile(midi_filename): print(midi_filename, " does not exist. Stopping.") return...
def midi_to_notes(midi_filename):
''' string filename: relative path to midi file. Saves a intermediate csv and csv of notes used as training data ''' # Make sure midi file exists if not os.path.isfile(midi_filename): print(midi_filename, " does not exist. Stopping.") return # Get filename with no p...
# coding: utf-8 # In[1]: import pandas as pd import numpy as np import subprocess as sbp import os # In[5]: def midi_to_notes(midi_filename):
45
251
839
8
37
NicholasConnors/AI-Assisted-Music-Editor
LSTM/data/preprocess.py
Python
midi_to_notes
midi_to_notes
16
105
16
16
1c60f9d9d888ac58334006b64a59d3314bc1dbe9
bigcode/the-stack
train
57b9ec0e03316d8d3f7ca721
train
function
def get_setup_version(reponame): """Use autover to get up to date version.""" # importing self into setup.py is unorthodox, but param has no # required dependencies outside of python from param.version import Version return Version.setup_version(os.path.dirname(__file__),reponame,archive_commit="$Fo...
def get_setup_version(reponame):
"""Use autover to get up to date version.""" # importing self into setup.py is unorthodox, but param has no # required dependencies outside of python from param.version import Version return Version.setup_version(os.path.dirname(__file__),reponame,archive_commit="$Format:%h$")
import os from setuptools import setup ########## autover ########## def get_setup_version(reponame):
22
64
74
8
14
ektar/param
setup.py
Python
get_setup_version
get_setup_version
8
13
8
8
50e808e7925337b5e4ac828fbc048bc95615add3
bigcode/the-stack
train
07f2d1f9be3e254f058666ea
train
class
class Selector(threadedadaptivecommscomponent): #Axon.AdaptiveCommsComponent.AdaptiveCommsComponent): # SmokeTests_Selector.test_SmokeTest """\ Selector() -> new Selector component Use Selector.getSelectorService(...) in preference as it returns an existing instance, or automatically creates a new one....
class Selector(threadedadaptivecommscomponent): #Axon.AdaptiveCommsComponent.AdaptiveCommsComponent): # SmokeTests_Selector.test_SmokeTest
"""\ Selector() -> new Selector component Use Selector.getSelectorService(...) in preference as it returns an existing instance, or automatically creates a new one. """ Inboxes = { "control" : "Recieving a Axon.Ipc.shutdown() message here causes shutdown", "inbox" : "Not used ...
requested that descriptor be deregistered, then someone can register for it once again. Deregister by sending on of the following messages to the "notify" inbox of Selector: * Kamaelia.KamaeliaIpc.removeReader(caller, descriptor) * Kamaelia.KamaeliaIpc.removeWriter(caller, descriptor) * Kamaelia.KamaeliaIpc.removeEx...
256
256
2,365
34
221
sparkslabs/kamaelia_orig
Code/Python/Kamaelia/Kamaelia/Internet/Selector.py
Python
Selector
Selector
128
411
128
128
bb57e1f12739290d54d438e6cac4cb70d4811773
bigcode/the-stack
train
c97f8aa3881de2feb4c713f2
train
function
def link_GL(name, restype, argtypes, requires=None, suggestions=None): try: func = getattr(gl_lib, name) func.restype = restype func.argtypes = argtypes decorate_function(func, name) return func except AttributeError: return missing_function(name, requires, sugges...
def link_GL(name, restype, argtypes, requires=None, suggestions=None):
try: func = getattr(gl_lib, name) func.restype = restype func.argtypes = argtypes decorate_function(func, name) return func except AttributeError: return missing_function(name, requires, suggestions)
L'] gl_lib = pyglet.lib.load_library( framework='/System/Library/Frameworks/OpenGL.framework') agl_lib = pyglet.lib.load_library( framework='/System/Library/Frameworks/AGL.framework') def link_GL(name, restype, argtypes, requires=None, suggestions=None):
64
64
71
17
47
mintzer/pupillometry-rf-back
venv/Lib/site-packages/pyglet/gl/lib_agl.py
Python
link_GL
link_GL
54
62
54
54
094f7a131ca55a8d9949db0c236b7252063ff01b
bigcode/the-stack
train
b3565953076fb69120836f6f
train
function
def link_AGL(name, restype, argtypes, requires=None, suggestions=None): try: func = getattr(agl_lib, name) func.restype = restype func.argtypes = argtypes decorate_function(func, name) return func except AttributeError: return missing_function(name, requires, sugg...
def link_AGL(name, restype, argtypes, requires=None, suggestions=None):
try: func = getattr(agl_lib, name) func.restype = restype func.argtypes = argtypes decorate_function(func, name) return func except AttributeError: return missing_function(name, requires, suggestions)
ype = restype func.argtypes = argtypes decorate_function(func, name) return func except AttributeError: return missing_function(name, requires, suggestions) link_GLU = link_GL def link_AGL(name, restype, argtypes, requires=None, suggestions=None):
64
64
73
18
45
mintzer/pupillometry-rf-back
venv/Lib/site-packages/pyglet/gl/lib_agl.py
Python
link_AGL
link_AGL
66
74
66
66
0bd3b8a81be6d8377124bc1c48eb4d886c1db3f5
bigcode/the-stack
train
154df513fdcf19fa6a855689
train
class
class MyWindow: def init(self, win): self.lbl1=Label(win, text='Enter your fullname:', fg='Red') self.lbl1.place(x=20, y=70) self.t1=Entry() self.t1.place(x=150, y=70) self.t1.place(width=120, height=20) self.t2 = Entry() self.t2.place(x=150, y=100) ...
class MyWindow:
def init(self, win): self.lbl1=Label(win, text='Enter your fullname:', fg='Red') self.lbl1.place(x=20, y=70) self.t1=Entry() self.t1.place(x=150, y=70) self.t1.place(width=120, height=20) self.t2 = Entry() self.t2.place(x=150, y=100) self.t2.pl...
from tkinter import * class MyWindow:
8
64
146
4
4
jes-coder/OOP-58002
MidtermExam.py
Python
MyWindow
MyWindow
2
13
2
2
93edaa5041ae0b111ee5eab5438d41c864c59f5b
bigcode/the-stack
train
e3e73c44c28b6c0dffccb9fc
train
function
def on_data_scan(data): deviceNumber = data[10] * 256 + data[9] deviceType = data[11] ActualTime = time.time() - TimeProgramStart print(ActualTime, "RX:", deviceNumber, ", ", deviceType, ":", format_list(data))
def on_data_scan(data):
deviceNumber = data[10] * 256 + data[9] deviceType = data[11] ActualTime = time.time() - TimeProgramStart print(ActualTime, "RX:", deviceNumber, ", ", deviceType, ":", format_list(data))
import sys import time # Definition of Variables NETWORK_KEY = [0xB9, 0xA5, 0x21, 0xFB, 0xBD, 0x72, 0xC3, 0x45] def on_data_scan(data):
63
64
65
6
57
pirower/test1
examples/continuous_scan.py
Python
on_data_scan
on_data_scan
21
25
21
21
422f68202d04168773f7157c6ba32f91ddeb39d9
bigcode/the-stack
train
4e186560b3d0f0e00bed5627
train
function
def main(): print("ANT+ Open Rx Scan Mode Demo") logging.basicConfig(filename="example.log", level=logging.DEBUG) TimeProgramStart = time.time() # get start time node = Node() node.set_network_key(0x00, NETWORK_KEY) # 1. Set Network Key # CHANNEL CONFIGURATION channel = node.new...
def main():
print("ANT+ Open Rx Scan Mode Demo") logging.basicConfig(filename="example.log", level=logging.DEBUG) TimeProgramStart = time.time() # get start time node = Node() node.set_network_key(0x00, NETWORK_KEY) # 1. Set Network Key # CHANNEL CONFIGURATION channel = node.new_channel( ...
Time, "RX:", deviceNumber, ", ", deviceType, ":", format_list(data)) def on_data_ack_scan(data): deviceNumber = data[10] * 256 + data[9] deviceType = data[11] ActualTime = time.time() - TimeProgramStart print(ActualTime, "RX-Ack:", deviceNumber, ", ", deviceType, ":", format_list(data)) def mai...
91
92
309
3
88
pirower/test1
examples/continuous_scan.py
Python
main
main
35
69
35
35
dff4df87482a65d9c9e4415b355afb66daa4f754
bigcode/the-stack
train
a77fafe483367162fc7e6cd9
train
function
def on_data_ack_scan(data): deviceNumber = data[10] * 256 + data[9] deviceType = data[11] ActualTime = time.time() - TimeProgramStart print(ActualTime, "RX-Ack:", deviceNumber, ", ", deviceType, ":", format_list(data))
def on_data_ack_scan(data):
deviceNumber = data[10] * 256 + data[9] deviceType = data[11] ActualTime = time.time() - TimeProgramStart print(ActualTime, "RX-Ack:", deviceNumber, ", ", deviceType, ":", format_list(data))
= data[10] * 256 + data[9] deviceType = data[11] ActualTime = time.time() - TimeProgramStart print(ActualTime, "RX:", deviceNumber, ", ", deviceType, ":", format_list(data)) def on_data_ack_scan(data):
63
64
68
7
56
pirower/test1
examples/continuous_scan.py
Python
on_data_ack_scan
on_data_ack_scan
28
32
28
28
9eff520433f3960e580d74b4a5e67bf81a7fde67
bigcode/the-stack
train
2fd1fab4b47b4cb817b7bc8f
train
class
class MatrixListener(gevent.Greenlet): def __init__( self, private_key: str, chain_id: ChainID, callback: Callable, service_room_suffix: str ) -> None: super().__init__() self.private_key = private_key self.chain_id = chain_id self.callback = callback try: ...
class MatrixListener(gevent.Greenlet):
def __init__( self, private_key: str, chain_id: ChainID, callback: Callable, service_room_suffix: str ) -> None: super().__init__() self.private_key = private_key self.chain_id = chain_id self.callback = callback try: self.client, self.monitoring_roo...
Message("Invalid message data. Can not find the data type") from None return klass.from_dict(data) def deserialize_messages(data: str, peer_address: BytesAddress) -> List[SignedMessage]: messages: List[SignedMessage] = list() for line in data.splitlines(): line = line.strip() if not line...
256
256
909
9
246
palango/raiden-services
src/raiden_libs/matrix.py
Python
MatrixListener
MatrixListener
84
204
84
84
3edac3c7a893049ba36ddd98c0db27921b6d72fb
bigcode/the-stack
train
c2057cf6c0cb6a4cc53e2df0
train
function
def message_from_dict(data: dict) -> Message: try: klass: Message = CLASSNAME_TO_CLASS[data["type"]] except KeyError: if "type" in data: raise InvalidProtocolMessage( 'Invalid message type (data["type"] = {})'.format(data["type"]) ) from None raise...
def message_from_dict(data: dict) -> Message:
try: klass: Message = CLASSNAME_TO_CLASS[data["type"]] except KeyError: if "type" in data: raise InvalidProtocolMessage( 'Invalid message type (data["type"] = {})'.format(data["type"]) ) from None raise InvalidProtocolMessage("Invalid message data....
Address as BytesAddress, ChainID log = structlog.get_logger(__name__) SERVICE_MESSAGES: Tuple = (UpdatePFS, RequestMonitoring) CLASSNAME_TO_CLASS: Dict[str, Message] = {klass.__name__: klass for klass in SERVICE_MESSAGES} def message_from_dict(data: dict) -> Message:
64
64
97
11
53
palango/raiden-services
src/raiden_libs/matrix.py
Python
message_from_dict
message_from_dict
39
49
39
39
b18f7737c68faf7f78e268e87a782f97efb6a6a4
bigcode/the-stack
train
c9dfb93bc10f5c29b8628dc8
train
function
def deserialize_messages(data: str, peer_address: BytesAddress) -> List[SignedMessage]: messages: List[SignedMessage] = list() for line in data.splitlines(): line = line.strip() if not line: continue logger = log.bind(peer_address=to_checksum_address(peer_address)) ...
def deserialize_messages(data: str, peer_address: BytesAddress) -> List[SignedMessage]:
messages: List[SignedMessage] = list() for line in data.splitlines(): line = line.strip() if not line: continue logger = log.bind(peer_address=to_checksum_address(peer_address)) try: message_dict = json.loads(line) message = message_from_dict...
Invalid message type (data["type"] = {})'.format(data["type"]) ) from None raise InvalidProtocolMessage("Invalid message data. Can not find the data type") from None return klass.from_dict(data) def deserialize_messages(data: str, peer_address: BytesAddress) -> List[SignedMessage]:
67
67
224
19
48
palango/raiden-services
src/raiden_libs/matrix.py
Python
deserialize_messages
deserialize_messages
52
81
52
52
8f318093fa90b6cd605dd7b8298b114d9df7b579
bigcode/the-stack
train
f339485b631ae76c9f9217e5
train
function
def make_circuit(n:int) -> QuantumCircuit: # circuit begin input_qubit = QuantumRegister(n,"qc") prog = QuantumCircuit(input_qubit) prog.h(input_qubit[0]) # number=1 prog.h(input_qubit[1]) # number=2 prog.h(input_qubit[2]) # number=3 prog.h(input_qubit[3]) # number=4 for edge in E: ...
def make_circuit(n:int) -> QuantumCircuit: # circuit begin
input_qubit = QuantumRegister(n,"qc") prog = QuantumCircuit(input_qubit) prog.h(input_qubit[0]) # number=1 prog.h(input_qubit[1]) # number=2 prog.h(input_qubit[2]) # number=3 prog.h(input_qubit[3]) # number=4 for edge in E: k = edge[0] l = edge[1] prog.cp(-2 * gamm...
x as nx from qiskit.visualization import plot_histogram from typing import * from pprint import pprint from math import log2 from collections import Counter from qiskit.test.mock import FakeVigo, FakeYorktown kernel = 'circuit/bernstein' def make_circuit(n:int) -> QuantumCircuit: # circuit begin
75
75
253
16
59
UCLA-SEAL/QDiff
data/p4VQE/R4/benchmark/startQiskit_QC44.py
Python
make_circuit
make_circuit
18
44
18
19
30e3da9502972989fb6d4f1f8013c58b230c45fc
bigcode/the-stack
train
510b19fd0a6a93cdb09b0fa1
train
class
class RevStr(str): def __str__(self): return self[6:0:-1]
class RevStr(str):
def __str__(self): return self[6:0:-1]
super().__init__(**kwargs) def kill(self, s): print(f'{self.name()} will kill {s}') def main(): catAnimal = Kitten(name='Tomas', sound='Meaw') print(catAnimal) catAnimal.kill('human') class RevStr(str):
64
64
22
5
59
MahmudX/TestSharp
Py Learning/8. Class/inheritance.py
Python
RevStr
RevStr
62
64
62
62
fffcf94c9d3adadcea66aa70373a74153a7cd6bc
bigcode/the-stack
train
5903903836c767f84206427c
train
class
class Duck(Animal): def __init__(self, **kwargs): self._type = 'Duck' if 'type' in kwargs: del kwargs['type'] super().__init__(**kwargs)
class Duck(Animal):
def __init__(self, **kwargs): self._type = 'Duck' if 'type' in kwargs: del kwargs['type'] super().__init__(**kwargs)
if s: self._sound = s try: return self._sound except AttributeError: return None def __str__(self): return f'The {self.type()} is named {self.name()} and it says {self.sound()}' class Duck(Animal):
63
64
45
5
58
MahmudX/TestSharp
Py Learning/8. Class/inheritance.py
Python
Duck
Duck
38
43
38
38
75d6ae03b562f9cf2128672f85db055f760c7291
bigcode/the-stack
train
53e42d234577dbc5b7a3d301
train
function
def main(): catAnimal = Kitten(name='Tomas', sound='Meaw') print(catAnimal) catAnimal.kill('human')
def main():
catAnimal = Kitten(name='Tomas', sound='Meaw') print(catAnimal) catAnimal.kill('human')
): def __init__(self, **kwargs): self._type = 'Cat' if 'type' in kwargs: del kwargs['type'] super().__init__(**kwargs) def kill(self, s): print(f'{self.name()} will kill {s}') def main():
63
64
31
3
60
MahmudX/TestSharp
Py Learning/8. Class/inheritance.py
Python
main
main
57
60
57
57
8a37bfda0247a05366631b0b45d1a53cf8708c48
bigcode/the-stack
train
db308d0a8a9d291773642568
train
class
class Kitten(Animal): def __init__(self, **kwargs): self._type = 'Cat' if 'type' in kwargs: del kwargs['type'] super().__init__(**kwargs) def kill(self, s): print(f'{self.name()} will kill {s}')
class Kitten(Animal):
def __init__(self, **kwargs): self._type = 'Cat' if 'type' in kwargs: del kwargs['type'] super().__init__(**kwargs) def kill(self, s): print(f'{self.name()} will kill {s}')
{self.name()} and it says {self.sound()}' class Duck(Animal): def __init__(self, **kwargs): self._type = 'Duck' if 'type' in kwargs: del kwargs['type'] super().__init__(**kwargs) class Kitten(Animal):
64
64
66
6
58
MahmudX/TestSharp
Py Learning/8. Class/inheritance.py
Python
Kitten
Kitten
46
54
46
46
dd4b854ca8fc82c336df0f96022b6a6ad5d4265b
bigcode/the-stack
train
428899c2e974e04c760fb003
train
class
class Animal: def __init__(self, **kwargs): if 'type' in kwargs: self._type = kwargs['type'] if 'name' in kwargs: self._name = kwargs['name'] if 'sound' in kwargs: self._sound = kwargs['sound'] def type(self, t=None): if t: ...
class Animal:
def __init__(self, **kwargs): if 'type' in kwargs: self._type = kwargs['type'] if 'name' in kwargs: self._name = kwargs['name'] if 'sound' in kwargs: self._sound = kwargs['sound'] def type(self, t=None): if t: self._type ...
class Animal:
3
64
206
3
0
MahmudX/TestSharp
Py Learning/8. Class/inheritance.py
Python
Animal
Animal
1
35
1
1
d6891080c81a5835ed380c4a80081a238ebb1c69
bigcode/the-stack
train
a04c3812e065c6a39d049409
train
function
def header_stack_elements(): stack_instances = filter(lambda i: i.max_index > 0 and not i.virtual, hlir.p4_header_instances.values()) hs_names = list(set(map(lambda i: i.base_name, stack_instances))) xs = map(lambda s : "{" + ",\n ".join(instances4stack(hlir, s)) + "}", hs_names) return hsarrayarray("h...
def header_stack_elements():
stack_instances = filter(lambda i: i.max_index > 0 and not i.virtual, hlir.p4_header_instances.values()) hs_names = list(set(map(lambda i: i.base_name, stack_instances))) xs = map(lambda s : "{" + ",\n ".join(instances4stack(hlir, s)) + "}", hs_names) return hsarrayarray("header_instance_t", xs)
def header_stack_e(): l = header_stack_ids(hlir) l.append("header_stack_") return enum(l) def header_instance_e(): return enum(header_instance_ids(hlir)) def field_instance_e(): return enum(field_instance_ids(hlir)) def header_stack_elements():
64
64
93
5
59
Anmol-007/l2l3_ACL_cartesian_product
build/util/desugared_compiler/parser.h.desugared.py
Python
header_stack_elements
header_stack_elements
45
49
45
45
dd7fa65b172ab18fc699573282821d0d04f31b60
bigcode/the-stack
train
9b6df160a850fbd09970e104
train
function
def header_stack_size(): stack_instances = filter(lambda i: i.max_index > 0 and not i.virtual, hlir.p4_header_instances.values()) hs_names = list(set(map(lambda i: i.base_name, stack_instances))) xs = map(lambda s : str(len(instances4stack(hlir, s))), hs_names) return hsarray("unsigned", xs)
def header_stack_size():
stack_instances = filter(lambda i: i.max_index > 0 and not i.virtual, hlir.p4_header_instances.values()) hs_names = list(set(map(lambda i: i.base_name, stack_instances))) xs = map(lambda s : str(len(instances4stack(hlir, s))), hs_names) return hsarray("unsigned", xs)
_names = list(set(map(lambda i: i.base_name, stack_instances))) xs = map(lambda s : "{" + ",\n ".join(instances4stack(hlir, s)) + "}", hs_names) return hsarrayarray("header_instance_t", xs) def header_stack_size():
64
64
80
5
59
Anmol-007/l2l3_ACL_cartesian_product
build/util/desugared_compiler/parser.h.desugared.py
Python
header_stack_size
header_stack_size
51
55
51
51
28970582ce3488618d9030e02f0f4efe64e038fc
bigcode/the-stack
train
25777fa5be71533fa8202027
train
function
def field_instance_mask(): ws = [f[1] for hn,hi in hlir.p4_header_instances.items() for f in hi.header_type.layout.items()] os = [item%8 for sublist in [field_offsets(hi.header_type) for hi in header_instances(hlir)] for item in sublist] ms = [field_mask(a, b) for (a,b) in zip(os, ws)] return farray("ui...
def field_instance_mask():
ws = [f[1] for hn,hi in hlir.p4_header_instances.items() for f in hi.header_type.layout.items()] os = [item%8 for sublist in [field_offsets(hi.header_type) for hi in header_instances(hlir)] for item in sublist] ms = [field_mask(a, b) for (a,b) in zip(os, ws)] return farray("uint32_t", ms)
farray("int", os) def field_instance_byte_offset_hdr(): os = [str(item//8) for sublist in [field_offsets(hi.header_type) for hi in header_instances(hlir)] for item in sublist] return farray("int", os) def field_instance_mask():
64
64
101
5
59
Anmol-007/l2l3_ACL_cartesian_product
build/util/desugared_compiler/parser.h.desugared.py
Python
field_instance_mask
field_instance_mask
80
84
80
80
659266b7d7e71478adb7aa0892620c53ae4aadc8
bigcode/the-stack
train
ef099888d6c640009911e609
train
function
def farray(t, es): es2 = [ a + " /* " + b + " */" for (a,b) in zip(es, field_instance_ids(hlir))] return "static const %s %s[FIELD_INSTANCE_COUNT] = {\n %s\n};\n\n" % (t, inspect.stack()[1][3], ",\n ".join(es2))
def farray(t, es):
es2 = [ a + " /* " + b + " */" for (a,b) in zip(es, field_instance_ids(hlir))] return "static const %s %s[FIELD_INSTANCE_COUNT] = {\n %s\n};\n\n" % (t, inspect.stack()[1][3], ",\n ".join(es2))
in zip(es, header_instance_ids(hlir))] return "static const %s %s[HEADER_INSTANCE_COUNT] = {\n %s\n};\n\n" % (t, inspect.stack()[1][3], ",\n ".join(es2)) def farray(t, es):
64
64
86
7
57
Anmol-007/l2l3_ACL_cartesian_product
build/util/desugared_compiler/parser.h.desugared.py
Python
farray
farray
22
24
22
22
b86d7ca6b8fc12aef92edeccff03ccb336954cbb
bigcode/the-stack
train
b8e79f440b59261e6f6a145a
train
function
def field_instance_byte_offset_hdr(): os = [str(item//8) for sublist in [field_offsets(hi.header_type) for hi in header_instances(hlir)] for item in sublist] return farray("int", os)
def field_instance_byte_offset_hdr():
os = [str(item//8) for sublist in [field_offsets(hi.header_type) for hi in header_instances(hlir)] for item in sublist] return farray("int", os)
array("int", ws) def field_instance_bit_offset(): os = [str(item%8) for sublist in [field_offsets(hi.header_type) for hi in header_instances(hlir)] for item in sublist] return farray("int", os) def field_instance_byte_offset_hdr():
64
64
52
7
57
Anmol-007/l2l3_ACL_cartesian_product
build/util/desugared_compiler/parser.h.desugared.py
Python
field_instance_byte_offset_hdr
field_instance_byte_offset_hdr
76
78
76
76
8f510ff2d93833d0a2aa087cb7a46f8bf262f9cf
bigcode/the-stack
train
c80f5902d587cb63f86e8908
train
function
def header_instance_e(): return enum(header_instance_ids(hlir))
def header_instance_e():
return enum(header_instance_ids(hlir))
%s\n};\n\n" % (t, inspect.stack()[1][3], ",\n ".join(es2)) #============================================================================== def header_stack_e(): l = header_stack_ids(hlir) l.append("header_stack_") return enum(l) def header_instance_e():
64
64
15
5
59
Anmol-007/l2l3_ACL_cartesian_product
build/util/desugared_compiler/parser.h.desugared.py
Python
header_instance_e
header_instance_e
39
40
39
39
710166be898891689810190f20825f41c8cdf91a
bigcode/the-stack
train
5b34ee520b4308a64b661c01
train
function
def field_instance_header(): names = [i.name for i in header_instances(hlir) for fn,fw in i.header_type.layout.items()] ids = map(hdr_prefix, names) return farray("header_instance_t", ids)
def field_instance_header():
names = [i.name for i in header_instances(hlir) for fn,fw in i.header_type.layout.items()] ids = map(hdr_prefix, names) return farray("header_instance_t", ids)
for sublist in [field_offsets(hi.header_type) for hi in header_instances(hlir)] for item in sublist] ms = [field_mask(a, b) for (a,b) in zip(os, ws)] return farray("uint32_t", ms) def field_instance_header():
64
64
52
5
59
Anmol-007/l2l3_ACL_cartesian_product
build/util/desugared_compiler/parser.h.desugared.py
Python
field_instance_header
field_instance_header
86
89
86
86
127745f8941f2f0f229d19872f416f57452cb71a
bigcode/the-stack
train
8e3e966b227991d359b4ba90
train
function
def harray(t, es): es2 = [ a + " /* " + b + " */" for (a,b) in zip(es, header_instance_ids(hlir))] return "static const %s %s[HEADER_INSTANCE_COUNT] = {\n %s\n};\n\n" % (t, inspect.stack()[1][3], ",\n ".join(es2))
def harray(t, es):
es2 = [ a + " /* " + b + " */" for (a,b) in zip(es, header_instance_ids(hlir))] return "static const %s %s[HEADER_INSTANCE_COUNT] = {\n %s\n};\n\n" % (t, inspect.stack()[1][3], ",\n ".join(es2))
governing permissions and # limitations under the License. import inspect from utils.hlir import * def enum(es): return "enum %s {\n %s\n};\n\n" % (inspect.stack()[1][3], ",\n ".join(es)) def harray(t, es):
64
64
85
7
57
Anmol-007/l2l3_ACL_cartesian_product
build/util/desugared_compiler/parser.h.desugared.py
Python
harray
harray
19
21
19
19
6724bcdba5d77855db144cc52ad00748036073d1
bigcode/the-stack
train
2b4880781b1973b1a29bfd2c
train
function
def hsarray(t, es): es2 = [ a + " /* " + b + " */" for (a,b) in zip(es, header_stack_ids(hlir))] return "static const %s %s[HEADER_STACK_COUNT] = {\n %s\n};\n\n" % (t, inspect.stack()[1][3], ",\n ".join(es2))
def hsarray(t, es):
es2 = [ a + " /* " + b + " */" for (a,b) in zip(es, header_stack_ids(hlir))] return "static const %s %s[HEADER_STACK_COUNT] = {\n %s\n};\n\n" % (t, inspect.stack()[1][3], ",\n ".join(es2))
zip(es, field_instance_ids(hlir))] return "static const %s %s[FIELD_INSTANCE_COUNT] = {\n %s\n};\n\n" % (t, inspect.stack()[1][3], ",\n ".join(es2)) def hsarray(t, es):
64
64
85
7
57
Anmol-007/l2l3_ACL_cartesian_product
build/util/desugared_compiler/parser.h.desugared.py
Python
hsarray
hsarray
25
27
25
25
4d056aa609a5419f957d9683763907e2d05b7255
bigcode/the-stack
train
5ddb572502f65533b7e5e933
train
function
def header_stack_e(): l = header_stack_ids(hlir) l.append("header_stack_") return enum(l)
def header_stack_e():
l = header_stack_ids(hlir) l.append("header_stack_") return enum(l)
, header_stack_ids(hlir))] return "static const %s %s[HEADER_STACK_COUNT][10] = {\n %s\n};\n\n" % (t, inspect.stack()[1][3], ",\n ".join(es2)) #============================================================================== def header_stack_e():
64
64
28
5
58
Anmol-007/l2l3_ACL_cartesian_product
build/util/desugared_compiler/parser.h.desugared.py
Python
header_stack_e
header_stack_e
34
37
34
34
f806458654b54bf77d1bb4462971af4ce746aefd
bigcode/the-stack
train
ebba6893fe4638420a980668
train
function
def field_instance_bit_width(): ws = ["-1 /* variable-width field */" if f[1] == p4.P4_AUTO_WIDTH else str(f[1]) for hi in header_instances(hlir) for f in hi.header_type.layout.items()] return farray("int", ws)
def field_instance_bit_width():
ws = ["-1 /* variable-width field */" if f[1] == p4.P4_AUTO_WIDTH else str(f[1]) for hi in header_instances(hlir) for f in hi.header_type.layout.items()] return farray("int", ws)
header_instance_is_metadata(): ms = ["1" if hi.metadata else "0" for hi in header_instances(hlir)] return harray("int", ms) def header_instance_var_width_field(): return harray("int", variable_width_field_ids(hlir)) def field_instance_bit_width():
64
64
63
6
58
Anmol-007/l2l3_ACL_cartesian_product
build/util/desugared_compiler/parser.h.desugared.py
Python
field_instance_bit_width
field_instance_bit_width
68
70
68
68
640b0ec0670e5c1a79f217a17cc9f041ce5d4953
bigcode/the-stack
train
ef6bc3bd14405f22de7771c5
train
function
def hsarrayarray(t, es): es2 = [ a + " /* " + b + " */" for (a,b) in zip(es, header_stack_ids(hlir))] return "static const %s %s[HEADER_STACK_COUNT][10] = {\n %s\n};\n\n" % (t, inspect.stack()[1][3], ",\n ".join(es2))
def hsarrayarray(t, es):
es2 = [ a + " /* " + b + " */" for (a,b) in zip(es, header_stack_ids(hlir))] return "static const %s %s[HEADER_STACK_COUNT][10] = {\n %s\n};\n\n" % (t, inspect.stack()[1][3], ",\n ".join(es2))
zip(es, header_stack_ids(hlir))] return "static const %s %s[HEADER_STACK_COUNT] = {\n %s\n};\n\n" % (t, inspect.stack()[1][3], ",\n ".join(es2)) def hsarrayarray(t, es):
64
64
88
8
56
Anmol-007/l2l3_ACL_cartesian_product
build/util/desugared_compiler/parser.h.desugared.py
Python
hsarrayarray
hsarrayarray
28
30
28
28
fb7e1502cbf082e5cf3a6941afd8ba1dc5fe15dc
bigcode/the-stack
train
ff22b8c4f370bdfd00c1d0f8
train
function
def header_instance_var_width_field(): return harray("int", variable_width_field_ids(hlir))
def header_instance_var_width_field():
return harray("int", variable_width_field_ids(hlir))
*/" for hi in header_instances(hlir)] return harray("int", ws) def header_instance_is_metadata(): ms = ["1" if hi.metadata else "0" for hi in header_instances(hlir)] return harray("int", ms) def header_instance_var_width_field():
64
64
22
7
57
Anmol-007/l2l3_ACL_cartesian_product
build/util/desugared_compiler/parser.h.desugared.py
Python
header_instance_var_width_field
header_instance_var_width_field
65
66
65
65
c460d5c30feb822d7b8d2c4941a06aef2ce38b72
bigcode/the-stack
train
ff3e505e0625f1764735d089
train
function
def field_instance_e(): return enum(field_instance_ids(hlir))
def field_instance_e():
return enum(field_instance_ids(hlir))
1][3], ",\n ".join(es2)) #============================================================================== def header_stack_e(): l = header_stack_ids(hlir) l.append("header_stack_") return enum(l) def header_instance_e(): return enum(header_instance_ids(hlir)) def field_instance_e():
64
64
15
5
59
Anmol-007/l2l3_ACL_cartesian_product
build/util/desugared_compiler/parser.h.desugared.py
Python
field_instance_e
field_instance_e
42
43
42
42
29888edf061338f5bacfe552bf26a71f1fbdf813
bigcode/the-stack
train
e9dc2f6645589ceefa4258fa
train
function
def header_instance_is_metadata(): ms = ["1" if hi.metadata else "0" for hi in header_instances(hlir)] return harray("int", ms)
def header_instance_is_metadata():
ms = ["1" if hi.metadata else "0" for hi in header_instances(hlir)] return harray("int", ms)
unsigned", xs) def header_instance_byte_width(): ws = [str(hi.header_type.length) if isinstance(hi.header_type.length, int) else "-1 /* variable-width header */" for hi in header_instances(hlir)] return harray("int", ws) def header_instance_is_metadata():
64
64
37
6
58
Anmol-007/l2l3_ACL_cartesian_product
build/util/desugared_compiler/parser.h.desugared.py
Python
header_instance_is_metadata
header_instance_is_metadata
61
63
61
61
c3189532c3c6a1437a7e96f92f39030d13f24dcc
bigcode/the-stack
train
37383ba7ccc6b76aef44f62b
train
function
def field_instance_bit_offset(): os = [str(item%8) for sublist in [field_offsets(hi.header_type) for hi in header_instances(hlir)] for item in sublist] return farray("int", os)
def field_instance_bit_offset():
os = [str(item%8) for sublist in [field_offsets(hi.header_type) for hi in header_instances(hlir)] for item in sublist] return farray("int", os)
(): ws = ["-1 /* variable-width field */" if f[1] == p4.P4_AUTO_WIDTH else str(f[1]) for hi in header_instances(hlir) for f in hi.header_type.layout.items()] return farray("int", ws) def field_instance_bit_offset():
64
64
51
6
58
Anmol-007/l2l3_ACL_cartesian_product
build/util/desugared_compiler/parser.h.desugared.py
Python
field_instance_bit_offset
field_instance_bit_offset
72
74
72
72
de5353fe445f2126942a4c9b9fe15efd81fa6376
bigcode/the-stack
train
2cfee0d5487f0f1186fb9436
train
function
def enum(es): return "enum %s {\n %s\n};\n\n" % (inspect.stack()[1][3], ",\n ".join(es))
def enum(es):
return "enum %s {\n %s\n};\n\n" % (inspect.stack()[1][3], ",\n ".join(es))
writing, software # distributed under the License is distributed on an "AS IS" BASIS, # 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. import inspect from utils.hlir import * def enum(es):
64
64
38
4
60
Anmol-007/l2l3_ACL_cartesian_product
build/util/desugared_compiler/parser.h.desugared.py
Python
enum
enum
17
18
17
17
cb368b9d29ef23e102801131142310dff6b740d6
bigcode/the-stack
train
c1c5379524ddce15af8726b9
train
function
def header_instance_byte_width(): ws = [str(hi.header_type.length) if isinstance(hi.header_type.length, int) else "-1 /* variable-width header */" for hi in header_instances(hlir)] return harray("int", ws)
def header_instance_byte_width():
ws = [str(hi.header_type.length) if isinstance(hi.header_type.length, int) else "-1 /* variable-width header */" for hi in header_instances(hlir)] return harray("int", ws)
.virtual, hlir.p4_header_instances.values()) hs_names = list(set(map(lambda i: i.base_name, stack_instances))) xs = map(lambda s : str(len(instances4stack(hlir, s))), hs_names) return hsarray("unsigned", xs) def header_instance_byte_width():
64
64
54
6
58
Anmol-007/l2l3_ACL_cartesian_product
build/util/desugared_compiler/parser.h.desugared.py
Python
header_instance_byte_width
header_instance_byte_width
57
59
57
57
bdddb175549332025bb5e64fe19233be089b1e7e
bigcode/the-stack
train
7df63114bff4241a20b6eaa6
train
class
class FakeOsModuleWalkTest(FakeOsModuleTestBase): def assertWalkResults(self, expected, top, topdown=True, followlinks=False): # as the result of walk is unsorted, we have to check against # sorted results result = [step for step in self.os.walk( top, to...
class FakeOsModuleWalkTest(FakeOsModuleTestBase):
def assertWalkResults(self, expected, top, topdown=True, followlinks=False): # as the result of walk is unsorted, we have to check against # sorted results result = [step for step in self.os.walk( top, topdown=topdown, followlinks=followlinks)] r...
1, None, 4) self.os.sendfile(fd2, fd1, None, 3) self.os.close(fd2) self.os.close(fd1) with self.open(dst_file_path) as f: self.assertEqual('testcon', f.read()) @unittest.skipIf(not TestCase.is_macos, 'Testing MacOs only behavior') def test_no_sendfile_to_regular_file...
256
256
1,756
13
242
JarnoRFB/pyfakefs
pyfakefs/tests/fake_os_test.py
Python
FakeOsModuleWalkTest
FakeOsModuleWalkTest
4,290
4,458
4,290
4,290
64182888fe0f45f85a8129ce16661a94af5da9a8
bigcode/the-stack
train
5c7d2314b7a58c9153bef39c
train
class
class RealScandirTest(FakeScandirTest): def use_real_fs(self): return True
class RealScandirTest(FakeScandirTest):
def use_real_fs(self): return True
.path.join(self.scandir_path(), 'file'), os.fspath(self.dir_entries[1])) def test_non_existing_dir(self): self.assert_raises_os_error( errno.ENOENT, self.scandir, 'non_existing/fake_dir') class RealScandirTest(FakeScandirTest):
64
64
22
11
53
JarnoRFB/pyfakefs
pyfakefs/tests/fake_os_test.py
Python
RealScandirTest
RealScandirTest
4,989
4,991
4,989
4,989
e440a7744361b441120347e3abe7d35db5891353
bigcode/the-stack
train
81b6fc7b2a1c8816dec55079
train
class
@unittest.skipIf(not use_scandir, 'only run if scandir is available') class FakeScandirTest(FakeOsModuleTestBase): FILE_SIZE = 50 LINKED_FILE_SIZE = 10 def setUp(self): super(FakeScandirTest, self).setUp() self.supports_symlinks = (not self.is_windows or no...
@unittest.skipIf(not use_scandir, 'only run if scandir is available') class FakeScandirTest(FakeOsModuleTestBase):
FILE_SIZE = 50 LINKED_FILE_SIZE = 10 def setUp(self): super(FakeScandirTest, self).setUp() self.supports_symlinks = (not self.is_windows or not self.use_real_fs()) if use_scandir_package: if self.use_real_fs(): from scan...
self.assertEqual(content, self.filesystem.get_object(file_path).contents) fh.close() self.assertEqual(len(content), self.os.stat(file_path)[stat.ST_SIZE]) self.assertEqual(content, self.filesystem.get_object(file_path).contents) def test_fi...
256
256
2,495
31
225
JarnoRFB/pyfakefs
pyfakefs/tests/fake_os_test.py
Python
FakeScandirTest
FakeScandirTest
4,742
4,986
4,742
4,743
e0a8e3a80a49231c8499d0994634cbfd701c11f4
bigcode/the-stack
train
f8ecae094c5cc86b099a29c3
train
class
class FakeScandirFdRelTest(FakeScandirFdTest): def do_scandir(self): self.dir_fd = self.os.open(self.os.path.relpath(self.directory), os.O_RDONLY) return self.scandir(self.dir_fd)
class FakeScandirFdRelTest(FakeScandirFdTest):
def do_scandir(self): self.dir_fd = self.os.open(self.os.path.relpath(self.directory), os.O_RDONLY) return self.scandir(self.dir_fd)
(self): self.dir_fd = self.os.open(self.directory, os.O_RDONLY) return self.scandir(self.dir_fd) class RealScandirFdTest(FakeScandirFdTest): def use_real_fs(self): return True class FakeScandirFdRelTest(FakeScandirFdTest):
64
64
51
14
49
JarnoRFB/pyfakefs
pyfakefs/tests/fake_os_test.py
Python
FakeScandirFdRelTest
FakeScandirFdRelTest
5,032
5,036
5,032
5,032
678ab5507c2973512135c8485709eed429453c0e
bigcode/the-stack
train
af9a6df84d911274927303af
train
class
class FakeOsModuleDirFdTest(FakeOsModuleTestBase): def setUp(self): super(FakeOsModuleDirFdTest, self).setUp() self.os.supports_dir_fd = set() self.filesystem.is_windows_fs = False self.filesystem.create_dir('/foo/bar') self.dir_fd = self.os.open('/foo', os.O_RDONLY) ...
class FakeOsModuleDirFdTest(FakeOsModuleTestBase):
def setUp(self): super(FakeOsModuleDirFdTest, self).setUp() self.os.supports_dir_fd = set() self.filesystem.is_windows_fs = False self.filesystem.create_dir('/foo/bar') self.dir_fd = self.os.open('/foo', os.O_RDONLY) self.filesystem.create_file('/foo/baz') def te...
linked') self.create_file(self.os.path.join(link_dir, 'subfile')) self.create_file(self.os.path.join(base_dir, 'bar', 'baz')) self.create_file(self.os.path.join(base_dir, 'bar', 'xyzzy', 'plugh')) self.create_symlink(self.os.path.join(base_dir, 'created_link'), ...
256
256
1,753
14
241
JarnoRFB/pyfakefs
pyfakefs/tests/fake_os_test.py
Python
FakeOsModuleDirFdTest
FakeOsModuleDirFdTest
4,466
4,637
4,466
4,466
264d2ff7980ac7dd5e6973169e39dea7354d25b5
bigcode/the-stack
train
8c5dc9fa62b32475ec3e9deb
train
class
class FakeOsModuleLowLevelFileOpTest(FakeOsModuleTestBase): """Test low level functions `os.open()`, `os.read()` and `os.write()`.""" def setUp(self): os.umask(0o022) super(FakeOsModuleLowLevelFileOpTest, self).setUp() def test_open_read_only(self): file_path = self.make_path('file...
class FakeOsModuleLowLevelFileOpTest(FakeOsModuleTestBase):
"""Test low level functions `os.open()`, `os.read()` and `os.write()`.""" def setUp(self): os.umask(0o022) super(FakeOsModuleLowLevelFileOpTest, self).setUp() def test_open_read_only(self): file_path = self.make_path('file1') self.create_file(file_path, contents=b'contents'...
def test_utime_incorrect_ns_argument_raises(self): file_path = 'some_file' self.filesystem.create_file(file_path) self.assertRaises(TypeError, self.os.utime, file_path, ns=200000000) self.assertRaises(TypeError, self.os.utime, file_path, ns=('a', 'b')) self.assertRaises(Valu...
256
256
5,262
16
240
JarnoRFB/pyfakefs
pyfakefs/tests/fake_os_test.py
Python
FakeOsModuleLowLevelFileOpTest
FakeOsModuleLowLevelFileOpTest
3,784
4,282
3,784
3,784
b48373f85668f635d876da14caf69f6a18b77892
bigcode/the-stack
train
56c1c507c128a6306b388972
train
class
class FakeScandirRelTest(FakeScandirTest): def scandir_path(self): # When scandir is called with a relative path, that relative path is # used in the path attribute of the DirEntry objects. return self.os.path.relpath(self.directory) def do_scandir(self): return self.scandir(sel...
class FakeScandirRelTest(FakeScandirTest):
def scandir_path(self): # When scandir is called with a relative path, that relative path is # used in the path attribute of the DirEntry objects. return self.os.path.relpath(self.directory) def do_scandir(self): return self.scandir(self.os.path.relpath(self.directory))
_non_existing_dir(self): self.assert_raises_os_error( errno.ENOENT, self.scandir, 'non_existing/fake_dir') class RealScandirTest(FakeScandirTest): def use_real_fs(self): return True class FakeScandirRelTest(FakeScandirTest):
64
64
79
12
51
JarnoRFB/pyfakefs
pyfakefs/tests/fake_os_test.py
Python
FakeScandirRelTest
FakeScandirRelTest
4,994
5,001
4,994
4,994
41530cb9eca38d2d76ab6ef499fa079a4fe3e2b0
bigcode/the-stack
train
8f6d6ec2776e7f95038f2411
train
class
class RealOsUnreadableDirTest(FakeOsUnreadableDirTest): def use_real_fs(self): return True
class RealOsUnreadableDirTest(FakeOsUnreadableDirTest):
def use_real_fs(self): return True
): if not is_root(): self.assert_raises_os_error( errno.EACCES, self.os.stat, self.file_path) else: self.assertEqual(0, self.os.stat(self.file_path).st_size) class RealOsUnreadableDirTest(FakeOsUnreadableDirTest):
64
64
26
15
49
JarnoRFB/pyfakefs
pyfakefs/tests/fake_os_test.py
Python
RealOsUnreadableDirTest
RealOsUnreadableDirTest
5,112
5,114
5,112
5,112
f70f6105efb4e10dc28d459d697f14e717c2ac3d
bigcode/the-stack
train
5ef5bf3082c6edf989fbde36
train
class
class RealOsModuleWalkTest(FakeOsModuleWalkTest): def use_real_fs(self): return True
class RealOsModuleWalkTest(FakeOsModuleWalkTest):
def use_real_fs(self): return True
, followlinks=True) expected = [(self.os.path.join(base_dir, 'created_link'), [], ['subfile'])] self.assertWalkResults(expected, self.os.path.join(base_dir, 'created_link'), followlinks=True) class RealOsModuleWalkTest(F...
64
64
24
13
51
JarnoRFB/pyfakefs
pyfakefs/tests/fake_os_test.py
Python
RealOsModuleWalkTest
RealOsModuleWalkTest
4,461
4,463
4,461
4,461
f460026f48bc3e9f7f8cb04fd4e40b345746403c
bigcode/the-stack
train
b5f760718fe1583ffc628521
train
class
class RealOsModuleTest(FakeOsModuleTest): def use_real_fs(self): return True
class RealOsModuleTest(FakeOsModuleTest):
def use_real_fs(self): return True
_read_fd(self): read_fd, write_fd = self.os.pipe() self.assert_raises_os_error(errno.EBADF, self.os.write, read_fd, b'test') self.os.close(read_fd) self.os.close(write_fd) class RealOsModuleTest(FakeOsModuleTest):
64
64
22
11
53
JarnoRFB/pyfakefs
pyfakefs/tests/fake_os_test.py
Python
RealOsModuleTest
RealOsModuleTest
2,662
2,664
2,662
2,662
fcab5a8b3b947f52b4053101fb1d861b4d161bf4
bigcode/the-stack
train
3b266f9f40688fa295e7f198
train
class
class FakeOsModuleTestBase(RealFsTestCase): def createTestFile(self, path): self.create_file(path) self.assertTrue(self.os.path.exists(path)) st = self.os.stat(path) self.assertEqual(0o666, stat.S_IMODE(st.st_mode)) self.assertTrue(st.st_mode & stat.S_IFREG) self.asse...
class FakeOsModuleTestBase(RealFsTestCase):
def createTestFile(self, path): self.create_file(path) self.assertTrue(self.os.path.exists(path)) st = self.os.stat(path) self.assertEqual(0o666, stat.S_IMODE(st.st_mode)) self.assertTrue(st.st_mode & stat.S_IFREG) self.assertFalse(st.st_mode & stat.S_IFDIR) def ...
ystem import FakeFileOpen, is_root from pyfakefs.extra_packages import ( use_scandir, use_scandir_package, use_builtin_scandir ) from pyfakefs.tests.test_utils import DummyTime, TestCase, RealFsTestCase class FakeOsModuleTestBase(RealFsTestCase):
64
64
164
12
51
JarnoRFB/pyfakefs
pyfakefs/tests/fake_os_test.py
Python
FakeOsModuleTestBase
FakeOsModuleTestBase
37
52
37
37
2bb4ca8d4f78b7f24bcc8a3028d592499012605f
bigcode/the-stack
train
d236564e04bee1f495c6f06f
train
class
class StatPropagationTest(TestCase): def setUp(self): self.filesystem = fake_filesystem.FakeFilesystem(path_separator='/') self.os = fake_filesystem.FakeOsModule(self.filesystem) self.open = fake_filesystem.FakeFileOpen(self.filesystem) def test_file_size_updated_via_close(self): ...
class StatPropagationTest(TestCase):
def setUp(self): self.filesystem = fake_filesystem.FakeFilesystem(path_separator='/') self.os = fake_filesystem.FakeOsModule(self.filesystem) self.open = fake_filesystem.FakeFileOpen(self.filesystem) def test_file_size_updated_via_close(self): """test that file size gets updated...
/baz')) def test_unlink(self): self.assertRaises( NotImplementedError, self.os.unlink, 'baz', dir_fd=self.dir_fd) self.os.supports_dir_fd.add(os.unlink) self.os.unlink('baz', dir_fd=self.dir_fd) self.assertFalse(self.os.path.exists('/foo/baz')) def test_utime(self):...
256
256
949
7
249
JarnoRFB/pyfakefs
pyfakefs/tests/fake_os_test.py
Python
StatPropagationTest
StatPropagationTest
4,640
4,739
4,640
4,640
2573cfeb7c335770207747b255f4ec5bec0034aa
bigcode/the-stack
train
ad69e3dafd40aa6d638d5d4c
train
class
class FakeOsModuleTest(FakeOsModuleTestBase): def setUp(self): super(FakeOsModuleTest, self).setUp() self.rwx = self.os.R_OK | self.os.W_OK | self.os.X_OK self.rw = self.os.R_OK | self.os.W_OK def test_chdir(self): """chdir should work on a directory.""" directory = self...
class FakeOsModuleTest(FakeOsModuleTestBase):
def setUp(self): super(FakeOsModuleTest, self).setUp() self.rwx = self.os.R_OK | self.os.W_OK | self.os.X_OK self.rw = self.os.R_OK | self.os.W_OK def test_chdir(self): """chdir should work on a directory.""" directory = self.make_path('foo') self.create_dir(dire...
unittest from pyfakefs.helpers import IN_DOCKER from pyfakefs import fake_filesystem from pyfakefs.fake_filesystem import FakeFileOpen, is_root from pyfakefs.extra_packages import ( use_scandir, use_scandir_package, use_builtin_scandir ) from pyfakefs.tests.test_utils import DummyTime, TestCase, RealFsTestCase ...
256
256
25,633
12
244
JarnoRFB/pyfakefs
pyfakefs/tests/fake_os_test.py
Python
FakeOsModuleTest
FakeOsModuleTest
55
2,659
55
55
443d85a819c008d975c72f4ca8064b793f739a40
bigcode/the-stack
train
ea567af8337706a74ea6a2b1
train
class
class RealOsModuleLowLevelFileOpTest(FakeOsModuleLowLevelFileOpTest): def use_real_fs(self): return True
class RealOsModuleLowLevelFileOpTest(FakeOsModuleLowLevelFileOpTest):
def use_real_fs(self): return True
socket operation on non-socket self.assertRaises(OSError, self.os.sendfile, fd2, fd1, 0, 3) self.os.close(fd2) self.os.close(fd1) class RealOsModuleLowLevelFileOpTest(FakeOsModuleLowLevelFileOpTest):
64
64
30
19
45
JarnoRFB/pyfakefs
pyfakefs/tests/fake_os_test.py
Python
RealOsModuleLowLevelFileOpTest
RealOsModuleLowLevelFileOpTest
4,285
4,287
4,285
4,285
f0116d51780bc5dd5047c9024ed0b31a1bd77feb
bigcode/the-stack
train
7f6332fa6262b95cf7db32a8
train
class
class FakeOsModuleTestCaseInsensitiveFS(FakeOsModuleTestBase): def setUp(self): super(FakeOsModuleTestCaseInsensitiveFS, self).setUp() self.check_case_insensitive_fs() self.rwx = self.os.R_OK | self.os.W_OK | self.os.X_OK self.rw = self.os.R_OK | self.os.W_OK def test_chdir_fail...
class FakeOsModuleTestCaseInsensitiveFS(FakeOsModuleTestBase):
def setUp(self): super(FakeOsModuleTestCaseInsensitiveFS, self).setUp() self.check_case_insensitive_fs() self.rwx = self.os.R_OK | self.os.W_OK | self.os.X_OK self.rw = self.os.R_OK | self.os.W_OK def test_chdir_fails_non_directory(self): """chdir should raise OSError if...
Greater(read_fd, fd) self.os.close(fd) self.os.close(read_fd) self.os.close(write_fd) def test_open_file_with_existing_pipe(self): read_fd, write_fd = self.os.pipe() file1 = self.make_path('file1') fd = self.os.open(file1, os.O_CREAT) self.assertGreater(fd, w...
256
256
8,880
15
240
JarnoRFB/pyfakefs
pyfakefs/tests/fake_os_test.py
Python
FakeOsModuleTestCaseInsensitiveFS
FakeOsModuleTestCaseInsensitiveFS
2,667
3,566
2,667
2,667
3a247588e93e604e10baaa86c362edc82bf6e950
bigcode/the-stack
train
f2f3e9053ccb73684d444a5d
train
class
class RealOsModuleTestCaseInsensitiveFS(FakeOsModuleTestCaseInsensitiveFS): def use_real_fs(self): return True
class RealOsModuleTestCaseInsensitiveFS(FakeOsModuleTestCaseInsensitiveFS):
def use_real_fs(self): return True
link_path = self.make_path('link') self.os.symlink(self.base_path, link_path) link_path = self.os.path.join(link_path, 'Link') self.assertTrue(self.os.lstat(link_path)) class RealOsModuleTestCaseInsensitiveFS(FakeOsModuleTestCaseInsensitiveFS):
64
64
28
17
47
JarnoRFB/pyfakefs
pyfakefs/tests/fake_os_test.py
Python
RealOsModuleTestCaseInsensitiveFS
RealOsModuleTestCaseInsensitiveFS
3,569
3,571
3,569
3,569
964865f89ec5385590e3af1af0d5f6169e652b0c
bigcode/the-stack
train
ee5882770006c6be1768a3e1
train
class
class FakeOsModuleTimeTest(FakeOsModuleTestBase): def setUp(self): super(FakeOsModuleTimeTest, self).setUp() self.orig_time = time.time self.dummy_time = None self.setDummyTime(200) def tearDown(self): time.time = self.orig_time super(FakeOsModuleTimeTest, self)....
class FakeOsModuleTimeTest(FakeOsModuleTestBase):
def setUp(self): super(FakeOsModuleTimeTest, self).setUp() self.orig_time = time.time self.dummy_time = None self.setDummyTime(200) def tearDown(self): time.time = self.orig_time super(FakeOsModuleTimeTest, self).tearDown() def setDummyTime(self, start): ...
_path) self.assert_raises_os_error(errno.EEXIST, self.os.link, file_path.upper(), file_path.upper()) def test_link_is_broken_symlink(self): # Regression test for #311 self.skip_if_symlink_not_supported() self.check_case_insensitive_fs() fi...
256
256
2,000
13
242
JarnoRFB/pyfakefs
pyfakefs/tests/fake_os_test.py
Python
FakeOsModuleTimeTest
FakeOsModuleTimeTest
3,574
3,781
3,574
3,574
472fc60b69f4ee7cfcfc038f1e7166da131f7404
bigcode/the-stack
train
e76b1f5fa77e15357fb4e34c
train
class
class RealScandirFdTest(FakeScandirFdTest): def use_real_fs(self): return True
class RealScandirFdTest(FakeScandirFdTest):
def use_real_fs(self): return True
the # entry is returned in the path attribute of the DirEntry objects. return '' def do_scandir(self): self.dir_fd = self.os.open(self.directory, os.O_RDONLY) return self.scandir(self.dir_fd) class RealScandirFdTest(FakeScandirFdTest):
64
64
24
13
51
JarnoRFB/pyfakefs
pyfakefs/tests/fake_os_test.py
Python
RealScandirFdTest
RealScandirFdTest
5,027
5,029
5,027
5,027
3afa7548c58183fefe0f9ae7055ed8d9524884f7
bigcode/the-stack
train
9083e8403ab51799f186ed7c
train
class
class FakeExtendedAttributeTest(FakeOsModuleTestBase): def setUp(self): super(FakeExtendedAttributeTest, self).setUp() self.check_linux_only() self.dir_path = self.make_path('foo') self.file_path = self.os.path.join(self.dir_path, 'bar') self.create_file(self.file_path) ...
class FakeExtendedAttributeTest(FakeOsModuleTestBase):
def setUp(self): super(FakeExtendedAttributeTest, self).setUp() self.check_linux_only() self.dir_path = self.make_path('foo') self.file_path = self.os.path.join(self.dir_path, 'bar') self.create_file(self.file_path) def test_empty_xattr(self): self.assertEqual([]...
= self.os.open(self.directory, os.O_RDONLY) return self.scandir(self.dir_fd) class RealScandirFdTest(FakeScandirFdTest): def use_real_fs(self): return True class FakeScandirFdRelTest(FakeScandirFdTest): def do_scandir(self): self.dir_fd = self.os.open(self.os.path.relpath(self.direc...
133
133
444
12
120
JarnoRFB/pyfakefs
pyfakefs/tests/fake_os_test.py
Python
FakeExtendedAttributeTest
FakeExtendedAttributeTest
5,044
5,082
5,044
5,044
00609ab53561bd5d9571f0df27936a61b906a7cf
bigcode/the-stack
train
d1cc558b9467d359ef3f354a
train
class
@unittest.skipIf(sys.version_info < (3, 7) or TestCase.is_windows or use_scandir_package, 'dir_fd support for os.scandir was introduced in Python 3.7') class FakeScandirFdTest(FakeScandirTest): def tearDown(self): self.os.close(self.dir_fd) super(FakeScandirFdTest, ...
@unittest.skipIf(sys.version_info < (3, 7) or TestCase.is_windows or use_scandir_package, 'dir_fd support for os.scandir was introduced in Python 3.7') class FakeScandirFdTest(FakeScandirTest):
def tearDown(self): self.os.close(self.dir_fd) super(FakeScandirFdTest, self).tearDown() def scandir_path(self): # When scandir is called with a filedescriptor, only the name of the # entry is returned in the path attribute of the DirEntry objects. return '' def do_...
(self): return True @unittest.skipIf(sys.version_info < (3, 7) or TestCase.is_windows or use_scandir_package, 'dir_fd support for os.scandir was introduced in Python 3.7') class FakeScandirFdTest(FakeScandirTest):
64
64
160
58
5
JarnoRFB/pyfakefs
pyfakefs/tests/fake_os_test.py
Python
FakeScandirFdTest
FakeScandirFdTest
5,009
5,024
5,009
5,012
fc398ec4c495b252d84329fef3616d14d5b019fe
bigcode/the-stack
train
b359507efc2e39df630bbc2b
train
class
class RealScandirRelTest(FakeScandirRelTest): def use_real_fs(self): return True
class RealScandirRelTest(FakeScandirRelTest):
def use_real_fs(self): return True
relative path, that relative path is # used in the path attribute of the DirEntry objects. return self.os.path.relpath(self.directory) def do_scandir(self): return self.scandir(self.os.path.relpath(self.directory)) class RealScandirRelTest(FakeScandirRelTest):
64
64
24
13
51
JarnoRFB/pyfakefs
pyfakefs/tests/fake_os_test.py
Python
RealScandirRelTest
RealScandirRelTest
5,004
5,006
5,004
5,004
e0cc7f74ad72c013eb6471da30344a6ef385dce8
bigcode/the-stack
train
c8a783aab2d99cec35a9999e
train
class
class FakeOsUnreadableDirTest(FakeOsModuleTestBase): def setUp(self): super(FakeOsUnreadableDirTest, self).setUp() self.check_posix_only() self.dir_path = self.make_path('some_dir') self.file_path = self.os.path.join(self.dir_path, 'some_file') self.create_file(self.file_path...
class FakeOsUnreadableDirTest(FakeOsModuleTestBase):
def setUp(self): super(FakeOsUnreadableDirTest, self).setUp() self.check_posix_only() self.dir_path = self.make_path('some_dir') self.file_path = self.os.path.join(self.dir_path, 'some_file') self.create_file(self.file_path) self.os.chmod(self.dir_path, 0o000) de...
self.os.chdir(self.dir_path) self.os.setxattr(self.dir_path, b'test', b'value') self.assertEqual(['test'], self.os.listxattr()) self.assertEqual(b'value', self.os.getxattr(self.dir_path, 'test')) class FakeOsUnreadableDirTest(FakeOsModuleTestBase):
71
72
242
14
57
JarnoRFB/pyfakefs
pyfakefs/tests/fake_os_test.py
Python
FakeOsUnreadableDirTest
FakeOsUnreadableDirTest
5,085
5,109
5,085
5,085
6284c9520a110651552f2178f4c21b910857c7a6
bigcode/the-stack
train
8879e6af93d83904ad9c9da3
train
class
class RealScandirFdRelTest(FakeScandirFdRelTest): def use_real_fs(self): return True
class RealScandirFdRelTest(FakeScandirFdRelTest):
def use_real_fs(self): return True
ScandirFdRelTest(FakeScandirFdTest): def do_scandir(self): self.dir_fd = self.os.open(self.os.path.relpath(self.directory), os.O_RDONLY) return self.scandir(self.dir_fd) class RealScandirFdRelTest(FakeScandirFdRelTest):
64
64
26
15
49
JarnoRFB/pyfakefs
pyfakefs/tests/fake_os_test.py
Python
RealScandirFdRelTest
RealScandirFdRelTest
5,039
5,041
5,039
5,039
587d66e54bb90c4d380910fe96af952997a84ddc
bigcode/the-stack
train
eddef1623dc612b5ea926b52
train
function
def test_AFNICommandBase_inputs(): input_map = dict( args=dict( argstr="%s", ), environ=dict( nohash=True, usedefault=True, ), ) inputs = AFNICommandBase.input_spec() for key, metadata in list(input_map.items()): for metakey, v...
def test_AFNICommandBase_inputs():
input_map = dict( args=dict( argstr="%s", ), environ=dict( nohash=True, usedefault=True, ), ) inputs = AFNICommandBase.input_spec() for key, metadata in list(input_map.items()): for metakey, value in list(metadata.items()): ...
# AUTO-GENERATED by tools/checkspecs.py - DO NOT EDIT from ..base import AFNICommandBase def test_AFNICommandBase_inputs():
33
64
92
8
24
richung99/digitizePlots
venv/Lib/site-packages/nipype/interfaces/afni/tests/test_auto_AFNICommandBase.py
Python
test_AFNICommandBase_inputs
test_AFNICommandBase_inputs
5
19
5
5
6e55f4d305b8b822cf5ae530f717066c1f0e9198
bigcode/the-stack
train
b8687023102b9c2e2f1942d9
train
function
def conv2d_gradfix( transpose: bool, weight_shape: tuple, stride: int, padding: int, output_padding: int, dilation: int, groups: int ): ndim = 2 weight_shape = tuple(weight_shape) stride = ensure_tuple(stride, ndim) padding = ensure_tuple(padding, ndim) output_padding = e...
def conv2d_gradfix( transpose: bool, weight_shape: tuple, stride: int, padding: int, output_padding: int, dilation: int, groups: int ):
ndim = 2 weight_shape = tuple(weight_shape) stride = ensure_tuple(stride, ndim) padding = ensure_tuple(padding, ndim) output_padding = ensure_tuple(output_padding, ndim) dilation = ensure_tuple(dilation, ndim) key = (transpose, weight_shape, stride, padding, output_padding, dilation, groups...
, bias=bias, stride=stride, padding=padding, output_padding=output_padding, dilation=dilation, groups=groups, ) def could_use_op(in_tensor: torch.Tensor) -> bool: if (not enabled) or (not torch.backends.cudnn.enabled): return False if in_tensor.devi...
256
256
928
45
211
Tollanador/alias-free-gan
src/op/conv2d_gradfix.py
Python
conv2d_gradfix
conv2d_gradfix
114
243
114
122
83f4c34bf6f95c18bde0d7fe0f558572d1c01eef
bigcode/the-stack
train
7c3cb19740412ee189fa636e
train
function
@contextlib.contextmanager def no_weight_gradients(): global weight_gradients_disabled old = weight_gradients_disabled weight_gradients_disabled = True yield weight_gradients_disabled = old
@contextlib.contextmanager def no_weight_gradients():
global weight_gradients_disabled old = weight_gradients_disabled weight_gradients_disabled = True yield weight_gradients_disabled = old
import contextlib import warnings import torch from torch import autograd from torch.nn import functional as F enabled = True weight_gradients_disabled = False # TODO finish type hinting this file @contextlib.contextmanager def no_weight_gradients():
56
64
46
12
43
Tollanador/alias-free-gan
src/op/conv2d_gradfix.py
Python
no_weight_gradients
no_weight_gradients
13
20
13
14
1692ec1de5de32f2dc28f9e7d05789bab0e38a24
bigcode/the-stack
train
8ba6a5bfc06574a10412c51e
train
function
def could_use_op(in_tensor: torch.Tensor) -> bool: if (not enabled) or (not torch.backends.cudnn.enabled): return False if in_tensor.device.type != "cuda": # TODO see if this file really needs cuda or can be converted to arrayfire return False if any(torch.__version__.startswith(x)...
def could_use_op(in_tensor: torch.Tensor) -> bool:
if (not enabled) or (not torch.backends.cudnn.enabled): return False if in_tensor.device.type != "cuda": # TODO see if this file really needs cuda or can be converted to arrayfire return False if any(torch.__version__.startswith(x) for x in ["1.7.", "1.8."]): return True ...
F.conv_transpose2d( input=in_tensor, weight=weight, bias=bias, stride=stride, padding=padding, output_padding=output_padding, dilation=dilation, groups=groups, ) def could_use_op(in_tensor: torch.Tensor) -> bool:
64
64
134
13
51
Tollanador/alias-free-gan
src/op/conv2d_gradfix.py
Python
could_use_op
could_use_op
87
102
87
87
39f33a51e76b46e481ec41a64faf649c0a337a09
bigcode/the-stack
train
62f146100157f0cf95ad6f5c
train
function
def conv_transpose2d( in_tensor: torch.Tensor, weight: torch.Tensor, bias: torch.Tensor = None, stride: int = 1, padding: int = 0, output_padding: int = 0, groups: int = 1, dilation: int = 1, ) -> torch.Tensor: if could_use_op(in_tensor): return conv2d_gradfix( tr...
def conv_transpose2d( in_tensor: torch.Tensor, weight: torch.Tensor, bias: torch.Tensor = None, stride: int = 1, padding: int = 0, output_padding: int = 0, groups: int = 1, dilation: int = 1, ) -> torch.Tensor:
if could_use_op(in_tensor): return conv2d_gradfix( transpose=True, weight_shape=weight.shape, stride=stride, padding=padding, output_padding=output_padding, groups=groups, dilation=dilation, ).apply(in_tensor, weight...
def conv_transpose2d( in_tensor: torch.Tensor, weight: torch.Tensor, bias: torch.Tensor = None, stride: int = 1, padding: int = 0, output_padding: int = 0, groups: int = 1, dilation: int = 1, ) -> torch.Tensor:
74
64
191
74
0
Tollanador/alias-free-gan
src/op/conv2d_gradfix.py
Python
conv_transpose2d
conv_transpose2d
54
84
54
63
9c7416044e45666e91ecada8b2aa7ec6611bc701
bigcode/the-stack
train
fcaf023ec59af31efead846f
train
function
def conv2d( in_tensor: torch.Tensor, weight: torch.Tensor, bias: torch.Tensor = None, stride: int = 1, padding: int = 0, dilation: int = 1, groups:int = 1 ) -> torch.Tensor: if could_use_op(in_tensor): return conv2d_gradfix( transpose=False, weight_shape=w...
def conv2d( in_tensor: torch.Tensor, weight: torch.Tensor, bias: torch.Tensor = None, stride: int = 1, padding: int = 0, dilation: int = 1, groups:int = 1 ) -> torch.Tensor:
if could_use_op(in_tensor): return conv2d_gradfix( transpose=False, weight_shape=weight.shape, stride=stride, padding=padding, output_padding=0, dilation=dilation, groups=groups, ).apply(in_tensor, weight, bias) ...
old def conv2d( in_tensor: torch.Tensor, weight: torch.Tensor, bias: torch.Tensor = None, stride: int = 1, padding: int = 0, dilation: int = 1, groups:int = 1 ) -> torch.Tensor:
64
64
169
62
1
Tollanador/alias-free-gan
src/op/conv2d_gradfix.py
Python
conv2d
conv2d
23
51
23
31
a09bc1f80de06831e729bcaaf7fa925387f2b254
bigcode/the-stack
train
90bbff0f03cc38f4a9549b76
train
function
def ensure_tuple(xs, ndim): xs = tuple(xs) if isinstance(xs, (tuple, list)) else (xs,) * ndim return xs
def ensure_tuple(xs, ndim):
xs = tuple(xs) if isinstance(xs, (tuple, list)) else (xs,) * ndim return xs
in ["1.7.", "1.8."]): return True warnings.warn( f"conv2d_gradfix not supported on PyTorch {torch.__version__}. Falling back to torch.nn.functional.conv2d()." ) return False def ensure_tuple(xs, ndim):
64
64
33
7
56
Tollanador/alias-free-gan
src/op/conv2d_gradfix.py
Python
ensure_tuple
ensure_tuple
105
108
105
105
a750303c2118f5197f821d125c5ca0d0fc1d66d8
bigcode/the-stack
train
5cf3fbda6fff4bb567bb21bc
train
class
class ContractTestCase(unittest.TestCase): def shortDescription(self): # disable docstring printing in test runner return None def test_create_signature_contract(self): """ var priv_key1 = new byte[] { 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, ...
class ContractTestCase(unittest.TestCase):
def shortDescription(self): # disable docstring printing in test runner return None def test_create_signature_contract(self): """ var priv_key1 = new byte[] { 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, 0x1, ...
import unittest import binascii from neo3 import contracts, vm from neo3.core import cryptography, types class ContractTestCase(unittest.TestCase):
33
256
3,162
8
24
ixje/neo-voting-backend
tests/contracts/test_contract.py
Python
ContractTestCase
ContractTestCase
7
241
7
7
b155f5592477537a5105fe6ffd612fb60f89584b
bigcode/the-stack
train
9776475095895dc60815825a
train
function
def rangename3d(book, ref3d): """ Utility function: ``Ref3D(1, 4, 5, 20, 7, 10)`` => ``'Sheet2:Sheet3!$H$6:$J$20'`` (assuming Excel's default sheetnames) """ coords = ref3d.coords return "%s!%s" % ( sheetrange(book, *coords[:2]), rangename2d(*coords[2:6]))
def rangename3d(book, ref3d):
""" Utility function: ``Ref3D(1, 4, 5, 20, 7, 10)`` => ``'Sheet2:Sheet3!$H$6:$J$20'`` (assuming Excel's default sheetnames) """ coords = ref3d.coords return "%s!%s" % ( sheetrange(book, *coords[:2]), rangename2d(*coords[2:6]))
clorel, browx, bcolx, r1c1), cellnamerel(rhi - 1, chi - 1, rhirel, chirel, browx, bcolx, r1c1), ) def rangename3d(book, ref3d):
64
64
114
11
53
DissectMalware/xlrd2
xlrd2/formula.py
Python
rangename3d
rangename3d
2,696
2,706
2,696
2,696
d1590c6a2562ded4cf740ccd7dc28b439a927602
bigcode/the-stack
train
624bb8496dae404f386ecae6
train
function
def sheetrange(book, slo, shi): shnames = book.sheet_names() shdesc = quotedsheetname(shnames, slo) if slo != shi-1: shdesc += ":" + quotedsheetname(shnames, shi-1) return shdesc
def sheetrange(book, slo, shi):
shnames = book.sheet_names() shdesc = quotedsheetname(shnames, slo) if slo != shi-1: shdesc += ":" + quotedsheetname(shnames, shi-1) return shdesc
# if "'" in shname: # return "'" + shname.replace("'", "''") + "'" # if " " in shname: # return "'" + shname + "'" return "'" + shname + "'" def sheetrange(book, slo, shi):
64
64
61
10
53
DissectMalware/xlrd2
xlrd2/formula.py
Python
sheetrange
sheetrange
2,741
2,746
2,741
2,741
f3a140e09a820c18bdd9cedd54591bb5b987f057
bigcode/the-stack
train
b6d65966b6688a247a59c7d7
train
function
def num2strg(num): """ Attempt to emulate Excel's default conversion from number to string. """ s = str(num) if s.endswith(".0"): s = s[:-2] return s
def num2strg(num):
""" Attempt to emulate Excel's default conversion from number to string. """ s = str(num) if s.endswith(".0"): s = s[:-2] return s
x <= y def _opr_eq(x, y): return x == y def _opr_ge(x, y): return x >= y def _opr_gt(x, y): return x > y def _opr_ne(x, y): return x != y def num2strg(num):
64
64
48
7
56
DissectMalware/xlrd2
xlrd2/formula.py
Python
num2strg
num2strg
1,215
1,222
1,215
1,215
c08d78254c671db95edb0569bedcfc6ba5f9ed00
bigcode/the-stack
train
4c7b5460396b2c8820d4f204
train
function
def quotedsheetname(shnames, shx): if shx >= 0: shname = shnames[shx] else: shname = { -1: "?internal; any sheet?", -2: "internal; deleted sheet", -3: "internal; macro sheet", -4: "<<external>>", }.get(shx, "?error %d?" % shx) # if "'" ...
def quotedsheetname(shnames, shx):
if shx >= 0: shname = shnames[shx] else: shname = { -1: "?internal; any sheet?", -2: "internal; deleted sheet", -3: "internal; macro sheet", -4: "<<external>>", }.get(shx, "?error %d?" % shx) # if "'" in shname: # return "'" + s...
rel(coords[2:6], relflags[2:6], browx, bcolx, r1c1) if not shdesc: return rngdesc return "%s!%s" % (shdesc, rngdesc) def quotedsheetname(shnames, shx):
64
64
144
11
53
DissectMalware/xlrd2
xlrd2/formula.py
Python
quotedsheetname
quotedsheetname
2,725
2,739
2,725
2,725
41e37feed0d9cdb0d2ec27dd42b43c91d119822a
bigcode/the-stack
train
c0a03a035c317709a2d984f9
train
function
def decompile_formula(bk, fmla, fmlalen, fmlatype=None, browx=None, bcolx=None, blah=0, level=0, r1c1=0): if level > STACK_ALARM_LEVEL: blah = 1 reldelta = fmlatype in (FMLA_TYPE_SHARED, FMLA_TYPE_NAME, FMLA_TYPE_COND_FMT, FMLA_TYPE_DATA_VAL) data = fmla ...
def decompile_formula(bk, fmla, fmlalen, fmlatype=None, browx=None, bcolx=None, blah=0, level=0, r1c1=0):
if level > STACK_ALARM_LEVEL: blah = 1 reldelta = fmlatype in (FMLA_TYPE_SHARED, FMLA_TYPE_NAME, FMLA_TYPE_COND_FMT, FMLA_TYPE_DATA_VAL) data = fmla bv = bk.biff_version if blah: print("::: decompile_formula len=%d fmlatype=%r browx=%r bcolx=%r reldelta=%d %r level=%d" % ...
handled yet: t" + oname, file=bk.logfile) any_err = 1 if sz <= 0: raise FormulaError("Fatal: token size is not positive") pos += sz any_rel = not not any_rel if blah: fprintf(bk.logfile, "End of formula. level=%d any_rel=%d any_err=%d stack=%r\n", lev...
256
256
6,468
45
211
DissectMalware/xlrd2
xlrd2/formula.py
Python
decompile_formula
decompile_formula
1,895
2,444
1,895
1,897
7e93756a11b2b226170a312228448961078bd221
bigcode/the-stack
train
e8b9baa5b40ee88a003a707d
train
function
def get_externsheet_local_range_b57( bk, raw_extshtx, ref_first_sheetx, ref_last_sheetx, blah=0): if raw_extshtx > 0: if blah: print("/// get_externsheet_local_range_b57(raw_extshtx=%d) -> external" % raw_extshtx, file=bk.logfile) return (-4, -4) # external reference if ref_f...
def get_externsheet_local_range_b57( bk, raw_extshtx, ref_first_sheetx, ref_last_sheetx, blah=0):
if raw_extshtx > 0: if blah: print("/// get_externsheet_local_range_b57(raw_extshtx=%d) -> external" % raw_extshtx, file=bk.logfile) return (-4, -4) # external reference if ref_first_sheetx == -1 and ref_last_sheetx == -1: return (-2, -2) # internal reference, deleted sheet(s...
xlrd_sheetx2 = bk._all_sheets_map[ref_last_sheetx] if not(0 <= xlrd_sheetx1 <= xlrd_sheetx2): return (-3, -3) # internal reference, but to a macro sheet return xlrd_sheetx1, xlrd_sheetx2 def get_externsheet_local_range_b57( bk, raw_extshtx, ref_first_sheetx, ref_last_sheetx, blah=0):
102
102
340
33
68
DissectMalware/xlrd2
xlrd2/formula.py
Python
get_externsheet_local_range_b57
get_externsheet_local_range_b57
1,012
1,031
1,012
1,013
a59c5175016d66fdd487fe8e1fe9511e3e35775f
bigcode/the-stack
train
403d634411f29e1d64d0c4ac
train
function
def sheetrangerel(book, srange, srangerel): slo, shi = srange slorel, shirel = srangerel if not slorel and not shirel: return sheetrange(book, slo, shi) assert (slo == 0 == shi-1) and slorel and shirel return ""
def sheetrangerel(book, srange, srangerel):
slo, shi = srange slorel, shirel = srangerel if not slorel and not shirel: return sheetrange(book, slo, shi) assert (slo == 0 == shi-1) and slorel and shirel return ""
shnames = book.sheet_names() shdesc = quotedsheetname(shnames, slo) if slo != shi-1: shdesc += ":" + quotedsheetname(shnames, shi-1) return shdesc def sheetrangerel(book, srange, srangerel):
64
64
80
14
49
DissectMalware/xlrd2
xlrd2/formula.py
Python
sheetrangerel
sheetrangerel
2,748
2,754
2,748
2,748
9a962552a05b6de6f4f9f72ed38e80652e920c3c
bigcode/the-stack
train
6c0b69dbf276438f0ea564d2
train
function
def adjust_cell_addr_biff_le7( rowval, colval, reldelta, browx=None, bcolx=None): row_rel = (rowval >> 15) & 1 col_rel = (rowval >> 14) & 1 rowx = rowval & 0x3fff colx = colval if reldelta: if row_rel and rowx >= 8192: rowx -= 16384 if col_rel and colx >= 128: ...
def adjust_cell_addr_biff_le7( rowval, colval, reldelta, browx=None, bcolx=None):
row_rel = (rowval >> 15) & 1 col_rel = (rowval >> 14) & 1 rowx = rowval & 0x3fff colx = colval if reldelta: if row_rel and rowx >= 8192: rowx -= 16384 if col_rel and colx >= 128: colx -= 256 else: if row_rel: rowx -= browx if co...
-= browx if col_rel and bcolx: colx -= bcolx return rowx, colx, row_rel, col_rel def adjust_cell_addr_biff_le7( rowval, colval, reldelta, browx=None, bcolx=None):
64
64
165
29
34
DissectMalware/xlrd2
xlrd2/formula.py
Python
adjust_cell_addr_biff_le7
adjust_cell_addr_biff_le7
928
944
928
929
956519e39e0dfcd67edec53213dd100101243c6d
bigcode/the-stack
train
adf41b9f63dabbfe8c031bd1
train
function
def _opr_lt(x, y): return x < y
def _opr_lt(x, y):
return x < y
0x08 tLT, tLE, tEQ, tGE, tGT, tNE = range(0x09, 0x0F) def nop(x): return x def _opr_pow(x, y): return x ** y def _opr_lt(x, y):
64
64
14
9
54
DissectMalware/xlrd2
xlrd2/formula.py
Python
_opr_lt
_opr_lt
1,208
1,208
1,208
1,208
fb8b75069d6b1dec82fcc5d5afa1c418ef250b57
bigcode/the-stack
train