query stringlengths 9 3.4k | document stringlengths 9 87.4k | metadata dict | negatives listlengths 4 101 | negative_scores listlengths 4 101 | document_score stringlengths 3 10 | document_rank stringclasses 102
values |
|---|---|---|---|---|---|---|
Activated at the end of the with statement. It automatically releases the lock if it isn't locked. | def __exit__(self, type, value, traceback):
if self.is_locked:
self.release() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __enter__(self):\n return self._lock.__enter__()",
"def release_lock (self):\n\n self.connection.commit ()\n self.locked = False",
"def f_lock(self):\n self._locked = True",
"def unlock(self):\n self.mtx.release()",
"def __enter__(self):\r\n if not self.is_lock... | [
"0.7080658",
"0.7025476",
"0.70232004",
"0.69914573",
"0.6963012",
"0.6948403",
"0.69412583",
"0.69065493",
"0.6876333",
"0.6871718",
"0.68130976",
"0.6804783",
"0.6804783",
"0.67605686",
"0.6756091",
"0.67532426",
"0.6746366",
"0.67164165",
"0.67095083",
"0.6674132",
"0.6673... | 0.6992507 | 3 |
Make sure that the FileLock instance doesn't leave a lockfile lying around. | def __del__(self):
self.release() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_deletes_lockfile_on_exit(self):\n self.lock.__enter__()\n self.assertTrue(os.path.exists(self.lock.lockfile_path))\n self.lock.__exit__(None, None, None)\n self.assertFalse(os.path.exists(self.lock.lockfile_path))",
"def release(self):\n self.filelock.set()\n se... | [
"0.78801745",
"0.76483494",
"0.76483494",
"0.75490755",
"0.7488548",
"0.7469351",
"0.7421171",
"0.73736024",
"0.73573565",
"0.7331623",
"0.7324912",
"0.72909725",
"0.7228303",
"0.7150227",
"0.711266",
"0.7106166",
"0.7083957",
"0.70789677",
"0.70712996",
"0.70579004",
"0.7052... | 0.0 | -1 |
Gets the view model for the cards in the deck | def get_cards(self):
return [card.view_model() for card in self._deck.loc] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_card_model(self, model: str) -> Any:\n return self.collection.models.byName(model)",
"def cards(self):\r\n return Cards(self)",
"def get_card_list(self):\n return self.cards",
"def cards(self):\n return self._cards",
"def GetView(self):\r\n return self.model.GetV... | [
"0.62337184",
"0.6114645",
"0.5980971",
"0.5815437",
"0.5713382",
"0.57027954",
"0.5669594",
"0.5646416",
"0.56217915",
"0.5597641",
"0.55945307",
"0.5587441",
"0.5510169",
"0.5467855",
"0.5467855",
"0.54545987",
"0.542285",
"0.540551",
"0.5393853",
"0.5392188",
"0.52771145",... | 0.7292069 | 0 |
Mystic Eight Ball Responds With Random Answer | async def eightball(self, ctx, question: str = None):
if question is None:
await ctx.send("Error, you have to ask a question!")
else:
await ctx.send(random.choice(eightBallJSON['answers'])) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def eightball(self, ctx, *, question):\n await ctx.send(\n f\"```Question: {question}\\nAnswer: {random.choice(self.responses)}```\")",
"def DoRandomAction(self, gameState: TekkenGameState):\n actionRNG = random.randint(1, 100)\n # Anything generated above this number, the b... | [
"0.6794446",
"0.6734153",
"0.67054445",
"0.6653877",
"0.65052915",
"0.6452931",
"0.6386174",
"0.6384732",
"0.6284734",
"0.6214471",
"0.6208734",
"0.6195117",
"0.61737174",
"0.61737174",
"0.6138124",
"0.61276114",
"0.6124817",
"0.61160946",
"0.61017245",
"0.60368645",
"0.60303... | 0.6258881 | 9 |
Having a hard time choosing between something? Try this command! | async def choices(self, ctx, *, options):
choices = options.split('-')
choice = random.choice(choices)
await ctx.send(f'My choice is\"{choice}\"') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def decide():",
"async def cmd_choose(self, args: Args, **_):\n response = \"From what you gave me, I believe `{}` is the best choice\".format(\n args[randint(0, len(args) - 1)]\n )\n return response",
"def show(name):\n try:os.system(f'python -m pip show {name}') \n excep... | [
"0.59110534",
"0.58999944",
"0.5865456",
"0.5857205",
"0.5706629",
"0.5687489",
"0.5673805",
"0.5668537",
"0.56640285",
"0.5654722",
"0.5606341",
"0.5571618",
"0.5564646",
"0.5529666",
"0.5524218",
"0.551562",
"0.55042744",
"0.5503928",
"0.54644406",
"0.54613674",
"0.54507",
... | 0.0 | -1 |
Create a new aggregation for dataset_id called name that calculates formula after grouping by group. The optional query will restrict the rows the aggregation is calculated for. | def POST(self, dataset_id, name, formula, group, query=None):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def group(self):\n return self._groupby().agg(self.formula_name)",
"def agg(self, arg):\n # DataFrame{'a': [1, 1, 2], 'b': [1, 2, 3], 'c': [2, 2, 1]})\n # a.groupby('a').agg('sum') -- applied on rest\n # a.groupby('a').agg(['sum', 'min']) -- both applied on rest\n # a.groupby('... | [
"0.6273711",
"0.5875546",
"0.5832929",
"0.57932544",
"0.5748951",
"0.5716479",
"0.5648441",
"0.5568975",
"0.54940236",
"0.5461808",
"0.5461521",
"0.54294634",
"0.5404009",
"0.53744936",
"0.52802795",
"0.52688944",
"0.5244623",
"0.5223877",
"0.5217374",
"0.52026427",
"0.515909... | 0.57171005 | 5 |
Performs any additional configuration of the cluster. | def ConfigureCluster(messages, args, cluster):
cluster.labels = labels_util.ParseCreateArgs(args,
messages.Cluster.LabelsValue) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setup(self, cluster):\n raise NotImplementedError()",
"def _setup_cluster(self):\n raise NotImplementedError('Must be implemented in subclasses.')",
"def config(self, cluster_name, name, username, version, int_netmask, int_ip_low,\n int_ip_high, ext_netmask, ext_ip_low, ext_ip_high,... | [
"0.74382454",
"0.7336474",
"0.7002774",
"0.68381417",
"0.64714193",
"0.6382179",
"0.63404334",
"0.6311427",
"0.62798417",
"0.6274801",
"0.62714297",
"0.62680733",
"0.6262011",
"0.62424606",
"0.6193381",
"0.6175728",
"0.61687416",
"0.61629295",
"0.6125787",
"0.60447395",
"0.60... | 0.6089944 | 19 |
Return objects for the current authenticated user only | def get_queryset(self):
assigned_only = bool(
int(self.request.query_params.get('assigned_only', 0))
)
queryset = self.queryset
if assigned_only:
queryset = queryset.filter(recipe__isnull=False)
return queryset.filter(user=self.request.user).order_by('-na... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_queryset(self):\n return super().get_queryset().filter(user=self.request.user)",
"def get_queryset(self, request):\n qs = super().get_queryset(request)\n return qs.filter(user=request.user)",
"def get_queryset(self, *args, **kwargs):\n qs = super().get_queryset(*args, **kwar... | [
"0.8128217",
"0.81258285",
"0.7882456",
"0.78440523",
"0.7745406",
"0.7604245",
"0.7604245",
"0.7497975",
"0.7315406",
"0.7285781",
"0.7250722",
"0.7198163",
"0.71906906",
"0.71667135",
"0.7160965",
"0.7144866",
"0.7118433",
"0.7115828",
"0.7115828",
"0.7115828",
"0.71137464"... | 0.0 | -1 |
Create a new object | def perform_create(self, serializer):
serializer.save(user=self.request.user) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new_object(self):\r\n\t\tpass",
"def new(self, obj):\n pass",
"def create(cls, _):\n return cls",
"def create():",
"def create():",
"def make_object():\n return object()",
"def create(cls):\n pass\n return cls()",
"def create(self):\n pass",
"def create(sel... | [
"0.8279344",
"0.81875837",
"0.76169944",
"0.7532984",
"0.7532984",
"0.74903953",
"0.7413568",
"0.7263086",
"0.7263086",
"0.7263086",
"0.7188198",
"0.71668696",
"0.7105122",
"0.70978415",
"0.7032688",
"0.70286256",
"0.69967264",
"0.697575",
"0.6942721",
"0.6913294",
"0.6906194... | 0.0 | -1 |
Convert a list of string IDs to a list on integers | def _params_to_ints(self, qs):
return [int(str_id) for str_id in qs.split(',')] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _convert_ids(self, ids):\n ids_list_int = []\n\n for id_ in ids:\n if not self._validate_identifier(id_):\n raise PhabfiveDataException(f\"Identifier '{id_}' is not valid\")\n\n id_ = id_.replace(\"P\", \"\")\n # constraints takes int\n i... | [
"0.7969724",
"0.7835356",
"0.7576945",
"0.7402606",
"0.74012876",
"0.7372816",
"0.7366341",
"0.73153883",
"0.7292588",
"0.7179581",
"0.71674055",
"0.7167337",
"0.7105371",
"0.7059471",
"0.70118207",
"0.6980508",
"0.6861776",
"0.6840759",
"0.6822096",
"0.68123996",
"0.67824876... | 0.7235464 | 13 |
Retrieve the product for the authenticated user | def get_queryset(self):
# tags = self.request.query_params.get('tags')
# ingredients = self.request.query_params.get('ingredients')
queryset = self.queryset
# if tags:
# tag_ids = self._params_to_ints(tags)
# queryset = queryset.filter(tags__id__in=tag_ids)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_product(cls, product_id):\n return Product.query.get(product_id)",
"def get_product(request, product_pk):\n\n product = get_object_or_404(Product, pk=product_pk)\n context = {\n 'product': product,\n 'MEDIA_URL': settings.MEDIA_URL\n }\n\n return render(request, 'products... | [
"0.7143646",
"0.7130459",
"0.70785874",
"0.7058554",
"0.69830626",
"0.6969065",
"0.6870364",
"0.6868916",
"0.68577504",
"0.68425035",
"0.6795423",
"0.6639035",
"0.661149",
"0.65376776",
"0.6468543",
"0.64582205",
"0.64522296",
"0.6400238",
"0.6393843",
"0.639191",
"0.6350939"... | 0.0 | -1 |
Return appropriate serializer class | def get_serializer_class(self):
if self.action == 'retrieve':
return serializers.ProductDetailSerializer
return self.serializer_class | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_serializer_class(self):\n return self.serializer_class",
"def get_serializer_class(self):\n assert self.serializer_class is not None, (\n \"'%s' should either include a `serializer_class` attribute, \"\n \"or override the `get_serializer_class()` method.\"\n ... | [
"0.81929946",
"0.80643964",
"0.80134255",
"0.8013179",
"0.80126834",
"0.7968286",
"0.7913326",
"0.7845621",
"0.77449894",
"0.77158886",
"0.7681139",
"0.76497275",
"0.7639574",
"0.76310956",
"0.7610852",
"0.7609168",
"0.75984967",
"0.75662816",
"0.7496931",
"0.7473103",
"0.739... | 0.7491611 | 19 |
Create a new recipe | def perform_create(self, serializer):
serializer.save(user=self.request.user) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create(self):\n self._finish_creation_settings()\n return self.project.create_recipe(self.recipe_proto, self.creation_settings)",
"def create_recipe(*, recipe_in: RecipeCreate) -> dict:\n new_entry_id = len(RECIPES) + 1\n recipe_entry = Recipe(\n id=new_entry_id,\n label=rec... | [
"0.78439105",
"0.74703336",
"0.73011774",
"0.69697547",
"0.6958079",
"0.69279486",
"0.6701816",
"0.6668637",
"0.6606927",
"0.65834",
"0.6465179",
"0.64530647",
"0.6418615",
"0.63959163",
"0.6368633",
"0.6325504",
"0.6294982",
"0.6287265",
"0.6253624",
"0.6156452",
"0.61508805... | 0.0 | -1 |
validate rpy2 can load correctly | def test_rpy2_integration():
## Try to import rpy (test R_HOME path) ##
import rpy2.robjects as robjects
import rpy2
from rpy2.robjects.packages import importr
req_filepath = path.join(ROOT, R_REQUIREMENTS_FILE)
with open(req_filepath, 'r') as req_fh:
raw_req = req_fh.read().splitlines(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_valid_python():\n from decisionengine.framework.util import reaper # noqa: F401\n\n pass",
"def test_rlmm_imported():\n assert \"rlmm\" in sys.modules",
"def rpy2_import_test(self):\n try:\n import rpy2\n\n rpy2_present = True\n except:\n rpy2_p... | [
"0.6022934",
"0.59124196",
"0.5730419",
"0.5573902",
"0.551886",
"0.5433446",
"0.5393205",
"0.53599614",
"0.53094214",
"0.53094214",
"0.5308447",
"0.5308447",
"0.5308447",
"0.5288998",
"0.52846456",
"0.52457887",
"0.52206194",
"0.52099794",
"0.5209703",
"0.51939344",
"0.51855... | 0.7157122 | 0 |
validate that every R file has a JSON pair | def test_matched_pairs():
template_filelist = listdir(RTEMPLATE_PATH)
R_files = []
json_files = []
orphan_files = []
for file in template_filelist:
if '.r' in file:
file = file.replace('.r', '')
R_files.append(file)
elif '.json' in file:
file = fi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_valid_json():\n invalid_json = False\n for filename in os.listdir(\"../networking\"):\n if filename.endswith(\".cfn.json\"):\n print(\"Validating json file: %s\" % filename)\n with open(f\"../networking/{filename}\", encoding=\"utf-8\") as f:\n try:\n ... | [
"0.70313704",
"0.69702756",
"0.6969368",
"0.6946178",
"0.67831564",
"0.6720923",
"0.6689942",
"0.65622365",
"0.6552107",
"0.64909637",
"0.64838433",
"0.6460589",
"0.63513964",
"0.62783813",
"0.62266463",
"0.61936957",
"0.61910045",
"0.6189006",
"0.61693394",
"0.61471575",
"0.... | 0.6666789 | 7 |
validate that R template can map values | def test_format_map():
template_filelist = listdir(RTEMPLATE_PATH)
R_files = []
json_files = []
for file in template_filelist:
if '.r' in file:
file = file.replace('.r', '')
R_files.append(file)
elif '.json' in file:
file = file.replace('.json', '')
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def requires_mapping(self):",
"def test_no_template_or_value(self):\n template = None\n value_count = 0\n try:\n validate_str_substitution(template, value_count)\n except ValidationError:\n self.fail('Name raised ValidationError unexpectedly')",
"def test_allow... | [
"0.61837167",
"0.60400736",
"0.5744981",
"0.5737587",
"0.5696172",
"0.56593275",
"0.55823135",
"0.55687314",
"0.5560397",
"0.55549306",
"0.555412",
"0.54934895",
"0.54844713",
"0.5472239",
"0.5459567",
"0.5437041",
"0.54308283",
"0.5387117",
"0.53411204",
"0.5337661",
"0.5324... | 0.5015287 | 53 |
getter for data and display features | def data(self, index, role):
# convert dictionary contents to a list
rows = list(self._data.items())
# get the row as a tuple (key, [data])
row = rows[index.row()]
# convert row to a list
row = [row[0]] + row[1]
if role == qc.Qt.DisplayRole:
return ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extractFeatures(self, datum):\n abstract",
"def get_features(self):\n return self._features",
"def get_features(self):\n return []",
"def get_data(self):",
"def get_data():\n pass",
"def features(self):\n return self._features",
"def display_data_features(self, da... | [
"0.6885116",
"0.68501854",
"0.680383",
"0.66005695",
"0.65818864",
"0.6581865",
"0.65775317",
"0.65313435",
"0.64752614",
"0.6449635",
"0.6435333",
"0.64265454",
"0.642317",
"0.6421087",
"0.6401905",
"0.6392673",
"0.63891315",
"0.6376536",
"0.6376536",
"0.6345152",
"0.6336732... | 0.0 | -1 |
getter for the table headers | def headerData(self, section, orientation, role):
headers = ["Constituancy", "Lab", "Con", "LD"]
if role == qc.Qt.DisplayRole and orientation == qc.Qt.Horizontal:
return qc.QVariant(headers[section])
return qc.QVariant() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_headings(self):\n return self.headings",
"def __get_table_headers(self):\n\n return self._page_content.cssselect('tr[valign=\"middle\"]')[0].xpath(\n \"td//text()\"\n )",
"def row_headers(self) -> Sequence[str]:\n return self._row_headers",
"def headers(self):\n... | [
"0.8011598",
"0.7981528",
"0.7561273",
"0.7511613",
"0.7283222",
"0.72829247",
"0.7277994",
"0.7275853",
"0.7259404",
"0.72483766",
"0.72102445",
"0.7167601",
"0.7156981",
"0.6990772",
"0.69882745",
"0.69426394",
"0.6926475",
"0.69256324",
"0.6912805",
"0.68934655",
"0.687855... | 0.0 | -1 |
the number of rows in table | def rowCount(self, index):
return len(self._data) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getNumRows(self) -> int:\n ...",
"def num_rows(self):\n return (len(self.rows))",
"def row_count(self) -> int:\n return len(self.rows)",
"def row_count(self) -> int:\n return len(self.rows)",
"def num_rows(self):\n return len(self.rows)",
"def rows_count(self):\n ... | [
"0.8705973",
"0.8478985",
"0.84346503",
"0.84346503",
"0.837452",
"0.8211421",
"0.8197341",
"0.81781596",
"0.8164352",
"0.8141076",
"0.8087774",
"0.80864626",
"0.807266",
"0.8067912",
"0.8066846",
"0.79875976",
"0.79777974",
"0.7970405",
"0.79507315",
"0.7892005",
"0.7889868"... | 0.7413387 | 47 |
the number of columns in the table | def columnCount(self, index):
return 4 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def no_of_columns(self): \n return len(self.columns) + (1 if self.serialize else 0)",
"def getColumnCount(self) -> int:\n ...",
"def ncolumns(self):\n return len(self.__column_list)",
"def column_count(self):\n return self.column_length",
"def number_of_columns(self):\n re... | [
"0.86391896",
"0.8618993",
"0.84609485",
"0.8389525",
"0.837738",
"0.8366331",
"0.8340181",
"0.83172053",
"0.8265017",
"0.82134295",
"0.81812006",
"0.8146298",
"0.8007196",
"0.7990876",
"0.79689646",
"0.7959868",
"0.7910805",
"0.78819776",
"0.77902555",
"0.77791256",
"0.77584... | 0.8064028 | 12 |
return that the numeric columns are editable | def flags(self, index):
if index.column() == 0:
return qc.Qt.ItemIsEnabled|qc.Qt.ItemIsSelectable
return qc.Qt.ItemIsEnabled|qc.Qt.ItemIsSelectable|qc.Qt.ItemIsEditable | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_numeric_cols(self):\n self.create_numeric_status()\n self.create_date_integer()",
"def get_editor ( self, object ):\n return super( NumericColumn, self ).get_editor( object )",
"def IsColumnMode(self):\n return self.VertEdit.Enabled",
"def IsColumnEditable(self, column):\r... | [
"0.6510541",
"0.649641",
"0.59568053",
"0.58170843",
"0.5801659",
"0.578838",
"0.5725331",
"0.54594517",
"0.5397822",
"0.53914595",
"0.5348922",
"0.53446525",
"0.5342064",
"0.5322869",
"0.5313026",
"0.52976865",
"0.5293376",
"0.5287403",
"0.5274033",
"0.5266411",
"0.5251051",... | 0.5294089 | 16 |
allow the new value to replace the old in the data source, this method will not work if the order of the data is different between the dictionary and the table, Python 3.6 onward preserve insetion order by default | def setData(self, index, value, role):
if role == qc.Qt.EditRole and value.isnumeric():
# convert keys to a list so that they they can be indexed
keys = [x for x in self._data.keys()]
key = keys[index.row()]
self._data[key][index.column()-1] = value
s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_old_row(self, data):\n for key, value in data.items():\n _column = self._labels.index([v['display'] for k, v in self.headers.items() if k == key].pop())\n cell = self.item(self._opt_row, _column)\n _cell_data = cell.get_data()\n _cell_data[key] = value\... | [
"0.6593884",
"0.6439751",
"0.62804306",
"0.62170357",
"0.61690855",
"0.6152403",
"0.61033905",
"0.6073576",
"0.5987888",
"0.59177953",
"0.5758352",
"0.57487994",
"0.572674",
"0.56419826",
"0.557847",
"0.553965",
"0.5529713",
"0.55203426",
"0.55203426",
"0.55107254",
"0.549782... | 0.51564014 | 67 |
getter for data and display features | def data(self, index, role):
if role == qc.Qt.DisplayRole:
percentages = self._data.party_percentages()
item = "{:.2f}".format(percentages[index.row()])
return qc.QVariant(item)
return qc.QVariant() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extractFeatures(self, datum):\n abstract",
"def get_features(self):\n return self._features",
"def get_features(self):\n return []",
"def get_data(self):",
"def get_data():\n pass",
"def features(self):\n return self._features",
"def display_data_features(self, da... | [
"0.6885116",
"0.68501854",
"0.680383",
"0.66005695",
"0.65818864",
"0.6581865",
"0.65775317",
"0.65313435",
"0.64752614",
"0.6449635",
"0.6435333",
"0.64265454",
"0.642317",
"0.6421087",
"0.6401905",
"0.6392673",
"0.63891315",
"0.6376536",
"0.6376536",
"0.6345152",
"0.6336732... | 0.0 | -1 |
getter for the table headers | def headerData(self, section, orientation, role):
headers = ["Lab", "Con", "LD"]
if role == qc.Qt.DisplayRole:
if orientation == qc.Qt.Vertical:
return qc.QVariant(headers[section])
return qc.QVariant("Vote (%)")
return qc.QVariant() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_headings(self):\n return self.headings",
"def __get_table_headers(self):\n\n return self._page_content.cssselect('tr[valign=\"middle\"]')[0].xpath(\n \"td//text()\"\n )",
"def row_headers(self) -> Sequence[str]:\n return self._row_headers",
"def headers(self):\n... | [
"0.8011598",
"0.7981528",
"0.7561273",
"0.7511613",
"0.7283222",
"0.72829247",
"0.7277994",
"0.7275853",
"0.7259404",
"0.72483766",
"0.72102445",
"0.7167601",
"0.7156981",
"0.6990772",
"0.69882745",
"0.69426394",
"0.6926475",
"0.69256324",
"0.6912805",
"0.68934655",
"0.687855... | 0.0 | -1 |
the number of rows in table | def rowCount(self, index):
return 3 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getNumRows(self) -> int:\n ...",
"def num_rows(self):\n return (len(self.rows))",
"def row_count(self) -> int:\n return len(self.rows)",
"def row_count(self) -> int:\n return len(self.rows)",
"def num_rows(self):\n return len(self.rows)",
"def rows_count(self):\n ... | [
"0.8705973",
"0.8478985",
"0.84346503",
"0.84346503",
"0.837452",
"0.8211421",
"0.8197341",
"0.81781596",
"0.8164352",
"0.8141076",
"0.8087774",
"0.80864626",
"0.807266",
"0.8067912",
"0.8066846",
"0.79875976",
"0.79777974",
"0.7970405",
"0.79507315",
"0.7892005",
"0.7889868"... | 0.7160755 | 63 |
the number of columns in the table | def columnCount(self, index):
return 1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def no_of_columns(self): \n return len(self.columns) + (1 if self.serialize else 0)",
"def getColumnCount(self) -> int:\n ...",
"def ncolumns(self):\n return len(self.__column_list)",
"def column_count(self):\n return self.column_length",
"def number_of_columns(self):\n re... | [
"0.8638714",
"0.86198246",
"0.8460776",
"0.83896136",
"0.83774775",
"0.8365918",
"0.83406776",
"0.831683",
"0.8265246",
"0.8213207",
"0.81807095",
"0.8147555",
"0.8063359",
"0.80066955",
"0.7990847",
"0.79687726",
"0.7960059",
"0.7911159",
"0.7883409",
"0.7790608",
"0.7778441... | 0.7535604 | 30 |
Captures from the set interface, returning a generator which returns packets continuously. | def sniff_continuously(self, packet_count=None):
self.lcapture_tshark = (self.lcapture_tshark or
self.eventloop.run_until_complete(self._get_tshark_process()))
self._running_processes.add(self.lcapture_tshark)
# Retained for backwards compatibility and to add document... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def next_batch(self):\n\n while self.cap.isOpened():\n flag, frame = self.cap.read()\n yield frame",
"def make_iter(capture, channel):\n\n def cycle():\n threading.Timer(INTERVAL, cycle).start()\n publish_frame(capture, channel)\n\n return cycle",
"def __iter__(... | [
"0.63577783",
"0.584588",
"0.5843037",
"0.5768111",
"0.5759957",
"0.5715275",
"0.5713004",
"0.5701512",
"0.56724066",
"0.5652078",
"0.56261146",
"0.5621041",
"0.56017673",
"0.56017673",
"0.5577811",
"0.5564901",
"0.55633557",
"0.5558496",
"0.55493593",
"0.5540167",
"0.550823"... | 0.5074381 | 98 |
Returns a generator of packets. This is the sync version of packets_from_tshark. It wait for the completion of each coroutine and reimplements reading packets in a sync way, yielding each packet as it arrives. | def _packets_from_tshark_sync(self, tshark_process, packet_count=None, timeout:float=3.0,
max_data_length:int=10000):
# NOTE: This has code duplication with the async version, think about how to solve this
psml_structure, data = self.eventloop.run_until_complete(self... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_pkt_seq(self):\n pkt = self.read_pkt_line()\n while pkt:\n yield pkt\n pkt = self.read_pkt_line()",
"def pkt_gen(self):\n for i in range(self.num_pkts):\n # create the test packets\n pkt = Ether()/IP()/TCP()/'hello there pretty world!!!'\n... | [
"0.6388171",
"0.59669185",
"0.58295953",
"0.58010983",
"0.57933766",
"0.579229",
"0.57740164",
"0.56658477",
"0.5569597",
"0.55228883",
"0.5494399",
"0.5487101",
"0.5454645",
"0.5428898",
"0.54204917",
"0.53887296",
"0.5376197",
"0.53683877",
"0.52956384",
"0.52746814",
"0.52... | 0.6835916 | 0 |
A coroutine which returns a single packet if it can be read from the given StreamReader. | async def _get_packet_from_stream(self, stream, existing_data,
got_first_packet=True,
psml_structure=None,
timeout:float=3.0):
import asyncio
from pyshark.tshark.tshark_j... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read(self):\n packet = None\n while packet is None:\n packet = self.async_read()\n return packet",
"async def read_or_exc(reader, n, timeout = None):\n\n\ttemp = await asyncio.gather(*[asyncio.wait_for(reader.read(n), timeout = timeout)], return_exceptions=True)\n\tif isinstan... | [
"0.6065404",
"0.56700957",
"0.55717975",
"0.55116373",
"0.5447172",
"0.54275465",
"0.5420315",
"0.53565",
"0.5311616",
"0.5290682",
"0.5247364",
"0.521039",
"0.5189609",
"0.51673543",
"0.51564765",
"0.5112726",
"0.5105092",
"0.5059999",
"0.50377053",
"0.50214815",
"0.50121653... | 0.55929154 | 2 |
Tests the matrix_vector_product code. | def test_matrix_product(self, use_cache):
key = jrandom.PRNGKey(0)
dim = 50
max_power = 25
matrix = jrandom.normal(key, (dim, dim)) / 10
vector = jnp.ones((dim,), dtype=jnp.float32)
if use_cache:
mpstate = model_utils.CachedMatrixPowerState.precompute(matrix, max_power)
else:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_mul():\n assert_equal(Vector(3, 1) * 2, Vector(6, 2))\n assert_equal(2 * Vector(3, 1), Vector(6, 2))",
"def matrix_vector_prod(m,u):\n each_product = []\n for v in m:\n each_product.append(dot_prod(v, u))\n return each_product",
"def test_suite():\r\n test(add_vectors([1, 1], ... | [
"0.7020426",
"0.68284523",
"0.6791578",
"0.67468673",
"0.67026436",
"0.66827",
"0.66523254",
"0.66410244",
"0.65571856",
"0.65571856",
"0.650921",
"0.6467925",
"0.6419744",
"0.6303483",
"0.62950623",
"0.62891656",
"0.6261458",
"0.62439704",
"0.62265456",
"0.6186289",
"0.61308... | 0.75648934 | 0 |
Tests the matrix_power_cached code. | def test_matrix_power(self, use_cache):
key = jrandom.PRNGKey(0)
dim = 50
max_power = 25
matrix = jrandom.normal(key, (dim, dim)) / 10
if use_cache:
mpstate = model_utils.CachedMatrixPowerState.precompute(matrix, max_power)
else:
mpstate = model_utils.LazyMatrixPowerState(matrix)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_matrix_product(self, use_cache):\n\n key = jrandom.PRNGKey(0)\n dim = 50\n max_power = 25\n\n matrix = jrandom.normal(key, (dim, dim)) / 10\n vector = jnp.ones((dim,), dtype=jnp.float32)\n\n if use_cache:\n mpstate = model_utils.CachedMatrixPowerState.precompute(matrix, max_power)\n... | [
"0.73225653",
"0.58746",
"0.58050704",
"0.56987643",
"0.5631421",
"0.5607155",
"0.55773807",
"0.55611145",
"0.54241306",
"0.5411276",
"0.5373944",
"0.5357646",
"0.5337961",
"0.5331032",
"0.5329204",
"0.5325335",
"0.5301618",
"0.5290857",
"0.52838194",
"0.5280639",
"0.5274496"... | 0.824397 | 0 |
Execute this ConfigScope. This will evaluate the function body and fill the relevant local variables into entries into keys in this dictionary. | def __call__(self, fixed=None, preset=None, fallback=None):
self._initialized = True
self.clear()
cfg_locals = dogmatize(fixed or {})
fallback = fallback or {}
preset = preset or {}
fallback_view = {}
available_entries = set(preset.keys()) | set(fallback.keys())
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run_block(self, config: Dict) -> Dict:\n super().run_block(config)\n test.validate_eda(self.params['key'], config)\n\n for key in config.keys():\n keyword = re.sub('[^a-zA-Z]+', '', key)\n params = eval(f'self.run_{keyword}(key, config[key])')\n # Check if ... | [
"0.60466635",
"0.5884264",
"0.5868618",
"0.58231854",
"0.5787232",
"0.56576097",
"0.56254226",
"0.55412364",
"0.54660976",
"0.5162968",
"0.51326597",
"0.51057833",
"0.5091101",
"0.50769436",
"0.5075155",
"0.49954832",
"0.49798885",
"0.49690154",
"0.49621612",
"0.49449146",
"0... | 0.58032787 | 4 |
This function returns the stations with the N highest relative water levels. | def stations_highest_rel_level(stations, N):
relative_water_level = []
# Create dictionary of relevant stations with relative water levels
for station in stations:
if type(station.relative_water_level()) != float:
continue
else:
relative_water_level.append((station.na... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run():\n # build the station list and update the current levels\n station_list = build_station_list()\n update_water_levels(station_list, use_cache=True)\n\n num_stations = 10\n highest_level_stations = stations_highest_rel_level(station_list, num_stations)\n\n print(\"{} stations with the hi... | [
"0.6555966",
"0.5809836",
"0.5742762",
"0.5694438",
"0.5691747",
"0.56783056",
"0.56687224",
"0.564456",
"0.56208897",
"0.56125605",
"0.5601425",
"0.5596799",
"0.55452675",
"0.55452675",
"0.5542017",
"0.55126023",
"0.54798305",
"0.54398257",
"0.5438739",
"0.54237264",
"0.5405... | 0.83433473 | 0 |
Quickly clear all events from the database | def clear_events():
if request.method == 'POST':
if not request.user.is_admin:
raise Exception('Only admin users can clear events!')
events = db.session.query(
db.models.Event
)
event_count = events.count()
events.delet... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clear(self, clearall=False):\n def closure(cur):\n cur.execute(\"\"\"\n DELETE FROM events\n \"\"\")\n if clearall:\n cur.execute(\"\"\"\n DELETE FROM slides\n \"\"\")\n cur.execute(\"\"\"\n ... | [
"0.7713988",
"0.7361082",
"0.7353579",
"0.7100708",
"0.7022059",
"0.70220476",
"0.6873817",
"0.6845115",
"0.67618793",
"0.67451537",
"0.6742549",
"0.67197734",
"0.6695115",
"0.6687401",
"0.6670323",
"0.66390884",
"0.66312635",
"0.66301024",
"0.656529",
"0.6550377",
"0.6541515... | 0.71477395 | 3 |
Receive a report from BLEtr | def report(events):
# Parse events into the database
for event in events:
event_obj = db.models.Event(
user=request.user,
seen_at=datetime.datetime.fromtimestamp(event['timestamp']),
beacon_id=event['id'],
beacon_distance=event[... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _usb_get_report(self):\n arraydata=self.usbdev.ctrl_transfer(bmRequestType=0xa1, bRequest=0x01, wValue=0x03b0, wIndex=0, data_or_wLength=9)\n data=arraydata.tolist()\n assert (data[0:4]==[0xb0,0x00,0x00,0x01]) or \\\n (data[0:4]==[0xb0,0xaa,0x00,0x01]) or \\\n (... | [
"0.6467434",
"0.63177305",
"0.6259963",
"0.6041349",
"0.59555084",
"0.59191746",
"0.5784229",
"0.5735927",
"0.5665564",
"0.5608296",
"0.5595612",
"0.5592399",
"0.5586286",
"0.55761623",
"0.5565981",
"0.55595016",
"0.5553837",
"0.55452824",
"0.5530131",
"0.55269146",
"0.549782... | 0.0 | -1 |
initializes a graph object If no dictionary or None is given, an empty dictionary will be used | def __init__(self, graph_dict=None):
if graph_dict == None:
graph_dict = {}
self.__graph_dict = graph_dict | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, graph_dict=None):\n if graph_dict == None:\n graph_dict = {}\n self.graph_dict = graph_dict",
"def __init__(self, graph_dict=None):\n if graph_dict == None:\n graph_dict = {}\n self.__graph_dict = graph_dict",
"def __init__(self, graph_dict: ... | [
"0.8344055",
"0.8285363",
"0.8214404",
"0.72901297",
"0.71258545",
"0.7124108",
"0.7106261",
"0.7093344",
"0.70315224",
"0.69043237",
"0.68703043",
"0.6836525",
"0.6788376",
"0.67615396",
"0.6751665",
"0.6686756",
"0.6486332",
"0.6468483",
"0.64452416",
"0.6436104",
"0.643236... | 0.82731 | 2 |
returns the vertices of a graph | def vertices(self):
return list(self.__graph_dict.keys()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def vertices(self):\n return list(self._graph)",
"def vertices(self):\n return list(self.__graph.values())",
"def get_vertices(self):\n return self.graph.keys()",
"def vertices(self):\n return list(self.graph_dict.keys())",
"def vertices(self):\n return list(self.__graph_... | [
"0.8339351",
"0.8274758",
"0.823995",
"0.8100039",
"0.8052383",
"0.8052383",
"0.8052383",
"0.79671496",
"0.75977874",
"0.7488906",
"0.7488286",
"0.74764013",
"0.7459909",
"0.7459909",
"0.7436597",
"0.7425249",
"0.7394321",
"0.73892194",
"0.7370652",
"0.73655087",
"0.7309654",... | 0.8049111 | 7 |
returns the edges of a graph | def edges(self):
return self.__generate_edges() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extract_edges(graph):\n return graph.get_edges()",
"def edges(self):\n return self.graph.edges",
"def getEdges(self):\n # for node in graph,\n # return node -> node for j in graph[node]\n\n return [\"->\".join([str(n1), str(n2)]) for n1 in self.graph.keys() for n2 in self.gra... | [
"0.80207413",
"0.78984654",
"0.77479947",
"0.76289475",
"0.7576712",
"0.7551123",
"0.7533409",
"0.7533409",
"0.7533409",
"0.75039995",
"0.7475862",
"0.74394375",
"0.7431105",
"0.7407345",
"0.74057573",
"0.7385167",
"0.7377495",
"0.7371777",
"0.7371777",
"0.7371777",
"0.737177... | 0.7509772 | 9 |
returns the number of vertices of a graph | def num_vertices(self):
return len(self.__graph_dict.keys()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_num_vertices(self):\n\n return self._graph_state.get_num_vertices()",
"def num_vertices(self):\n return self._top_exp.number_of_vertices()",
"def n_vertices(self):\n try: \n return self._n_vertices\n except AttributeError:\n self._n_vertices = 0\n ... | [
"0.8294428",
"0.82162774",
"0.8099264",
"0.8084873",
"0.8084873",
"0.80744034",
"0.80422086",
"0.7976934",
"0.79424685",
"0.79383194",
"0.7920504",
"0.7877179",
"0.7767539",
"0.7748465",
"0.7637932",
"0.75549054",
"0.74742794",
"0.7297782",
"0.72895753",
"0.7250115",
"0.72318... | 0.8577807 | 0 |
returns the number of edges of a graph | def num_edges(self):
return len(self.__generate_edges()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute_num_edges(graph):\n # return the number of edges\n return sum([len(graph[source_node].keys()) for source_node in graph.keys()]) / 2",
"def num_of_edge(self):\n try:\n return self.edges\n except:\n print(\"ERROR: No graph exists\")",
"def number_of_e... | [
"0.8555402",
"0.84465003",
"0.83987844",
"0.8311189",
"0.8286456",
"0.825919",
"0.8178529",
"0.8159551",
"0.8123871",
"0.8040028",
"0.80336994",
"0.8014446",
"0.8012517",
"0.79744923",
"0.7944467",
"0.78664666",
"0.78160673",
"0.7815068",
"0.775783",
"0.77435327",
"0.7735299"... | 0.8191377 | 6 |
If the vertex "vertex" is not in self.__graph_dict, a key "vertex" with an empty list as a value is added to the dictionary. Otherwise nothing has to be done. | def add_vertex(self, vertex):
if vertex not in self.__graph_dict:
self.__graph_dict[vertex] = {} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_vertex(self, vertex):\n if vertex not in self.graph_dict:\n self.graph_dict[vertex] = []",
"def add_vertex(self, vertex):\n if vertex not in self.__graph_dict:\n self.__graph_dict[vertex] = []",
"def add_vertex(self, vertex):\n if vertex not in self.__graph_di... | [
"0.8620155",
"0.85858893",
"0.85858893",
"0.8486344",
"0.8405291",
"0.77837217",
"0.7466885",
"0.74570274",
"0.7251097",
"0.719812",
"0.71429664",
"0.70753896",
"0.70753896",
"0.6962258",
"0.6887333",
"0.68829846",
"0.6833113",
"0.67997783",
"0.6796253",
"0.67158026",
"0.6710... | 0.8476053 | 4 |
assumes that edge is of type set, tuple or list; between two vertices can be multiple edges! | def add_edge(self, edge):
edge = set(edge)
(vertex1, vertex2) = tuple(edge)
if vertex1 in self.__graph_dict.keys() and vertex2 in self.__graph_dict.keys():
if vertex2 in self.__graph_dict[vertex1] and vertex1 in self.__graph_dict[vertex2]:
return
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_edge(self, edge):\n edge = set(edge)\n (vertex1, vertex2) = tuple(edge)\n if vertex1 in self.graph_dict:\n self.graph_dict[vertex1].append(vertex2)\n else:\n self.graph_dict[vertex1] = [vertex2]\n return edge",
"def add_edge(self, edge):\n e... | [
"0.6924097",
"0.67404646",
"0.6645291",
"0.6581878",
"0.65670335",
"0.65597415",
"0.6473252",
"0.6442472",
"0.64420813",
"0.6412036",
"0.6311367",
"0.6298211",
"0.62873614",
"0.6284625",
"0.6282889",
"0.62800133",
"0.6269465",
"0.6244941",
"0.6243469",
"0.62401235",
"0.622762... | 0.69176805 | 1 |
A static method generating the edges of the graph "graph". Edges are represented as sets with one (a loop back to the vertex) or two vertices | def __generate_edges(self):
edges = []
for vertex in self.__graph_dict:
for neighbor in self.__graph_dict[vertex]:
if {neighbor, vertex} not in edges:
edges.append({vertex, neighbor})
return edges | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_edges(self):\n edges = []\n for vertex in self.graph_dict:\n for neighbour in self.graph_dict[vertex]:\n if (neighbour, vertex) not in edges:\n edges.append((vertex, neighbour))\n \n for pair in edges:\n fo... | [
"0.73716545",
"0.72505623",
"0.72265285",
"0.721765",
"0.7204707",
"0.71817553",
"0.7153131",
"0.7065879",
"0.70504165",
"0.70436686",
"0.70436686",
"0.70436686",
"0.70392895",
"0.70211285",
"0.70063096",
"0.69740987",
"0.69275105",
"0.6899286",
"0.68731266",
"0.6758873",
"0.... | 0.71938413 | 5 |
use bfs explore graph from a single vertex return a shortest path tree from that vertex | def bfs(self, vertex_s):
nd_list = list(self.vertices())
visited = dict((node, 0) for node in nd_list)
nq = deque()
pre_dict, dist = {}, {}
nq.append(vertex_s)
visited[vertex_s]=1
dist[vertex_s] = 0
loop_counts = 0
while nq:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bfs_from_vertex(graph, vertex):\n\n return bfs(graph, key=lambda x: x == vertex and 1 or 2)",
"def bfs(self, starting_vertex, destination_vertex): # great if you know to result is somewhere close to the root/start\n visited = set() # create an empty 'set' to store visisted vertex, set sorts \n\n ... | [
"0.76203096",
"0.7432687",
"0.72287714",
"0.7196392",
"0.7150825",
"0.7148143",
"0.70788413",
"0.706312",
"0.7000629",
"0.69856966",
"0.69793636",
"0.6961361",
"0.6954599",
"0.68917525",
"0.6887795",
"0.68663275",
"0.6845486",
"0.6844108",
"0.6839384",
"0.6826373",
"0.6809841... | 0.70014113 | 8 |
use bfs explore graph from a single vertex return a shortest path tree from that vertex | def bfs_counting(graph, root_vertex, bottom_vertex): # perform analysis twice: 1) set root_vertex = 't'; 2) set root_vertex = 's'
#visited = dict()
nd_list = graph.keys()
visited = dict((node, 0) for node in nd_list)
visited[bottom_vertex]=0
nq = deque()# queue for recording current nodes
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bfs_from_vertex(graph, vertex):\n\n return bfs(graph, key=lambda x: x == vertex and 1 or 2)",
"def bfs(self, starting_vertex, destination_vertex): # great if you know to result is somewhere close to the root/start\n visited = set() # create an empty 'set' to store visisted vertex, set sorts \n\n ... | [
"0.76203096",
"0.7432687",
"0.72287714",
"0.7196392",
"0.7150825",
"0.7148143",
"0.70788413",
"0.706312",
"0.70014113",
"0.7000629",
"0.69856966",
"0.69793636",
"0.6961361",
"0.6954599",
"0.68917525",
"0.6887795",
"0.68663275",
"0.6845486",
"0.6844108",
"0.6839384",
"0.682637... | 0.0 | -1 |
Checks if the given keyvalue pair may be added to the relation. As implemented here, the method always returns True. Subclasses should override this method to produce custom behavior. | def validate(self, key, val):
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _can_add(self, key, value):\n return not bool(self._add_callback(key, value))",
"def has(self, key):\n return False",
"def contains(self, key):\n try:\n self.keyvaluepair_set.get(key=key)\n return True\n except KeyValuePair.DoesNotExist:\n return... | [
"0.73913777",
"0.66206956",
"0.64852184",
"0.6331098",
"0.62183887",
"0.6200746",
"0.6200038",
"0.61909205",
"0.61909205",
"0.6185929",
"0.6133091",
"0.61278236",
"0.610416",
"0.6088021",
"0.60546404",
"0.60384786",
"0.5968625",
"0.59586126",
"0.5953377",
"0.5937124",
"0.5936... | 0.61643666 | 11 |
Checks if the given keyvalue pair may be added to the relation. As implemented here, the method always returns True. Subclasses should override this method to produce custom behavior. | def validate(self, key, val):
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _can_add(self, key, value):\n return not bool(self._add_callback(key, value))",
"def has(self, key):\n return False",
"def contains(self, key):\n try:\n self.keyvaluepair_set.get(key=key)\n return True\n except KeyValuePair.DoesNotExist:\n return... | [
"0.7392581",
"0.66212904",
"0.64854825",
"0.63318294",
"0.62193114",
"0.62007934",
"0.6200576",
"0.6190558",
"0.6190558",
"0.6187284",
"0.6133693",
"0.61274534",
"0.61035764",
"0.60882723",
"0.60550296",
"0.60404927",
"0.5968527",
"0.5958795",
"0.59528434",
"0.5937537",
"0.59... | 0.61656994 | 10 |
Return list of source objs most similar to base source obj w genre new. | def get_close_sent(base, new, database, verbose=False):
l = len(base["sequence"]["tokens sensored"])
options = database[new][l]
if verbose:
print('same len', len(options))
def slim_down_options(options, count_func, n=25, v=''):
"""Slim options if more than n left."""
if len(op... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_genre_similarity(self):\n genre_words = []\n for w in self.target_movie.genres.split('|'):\n w = w.strip('- ,:(){}[]')\n genre_words.append(w)\n\n print(genre_words)\n\n res = self.db.query(Movie).filter(\n Movie.movie_id != self.target_movie.mov... | [
"0.62178683",
"0.5641775",
"0.5581096",
"0.55121994",
"0.5471099",
"0.54031825",
"0.5342264",
"0.5278724",
"0.5236598",
"0.5204825",
"0.5150956",
"0.50674236",
"0.50566036",
"0.50377613",
"0.50275636",
"0.50235635",
"0.5005771",
"0.49999645",
"0.49894613",
"0.49832267",
"0.49... | 0.0 | -1 |
Slim options if more than n left. | def slim_down_options(options, count_func, n=25, v=''):
if len(options) > 100:
options_slim = []
c = count_func(base)
for obj in options:
if c == count_func(obj):
options_slim.append(obj)
if len(options_slim) > n:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def keep_n(self, n=100):\n before = self.item_count()\n\n item_count = self.item_count()\n if item_count > n: self.filter(self.sample(n))\n\n after = self.item_count()\n with msg(f'Keeping (at most) {n} items: {after} of {before}', done=False, enabled=self.output):pass",
"def l... | [
"0.5554807",
"0.54940754",
"0.544022",
"0.53377664",
"0.5276856",
"0.5170868",
"0.5170868",
"0.51587814",
"0.51399946",
"0.51267874",
"0.50891244",
"0.50637853",
"0.5049573",
"0.50469786",
"0.5009878",
"0.49905896",
"0.4988287",
"0.49703386",
"0.49435568",
"0.4943084",
"0.493... | 0.7012843 | 0 |
Print the words in the vocabulary sorted according to their embeddingdistance to the given word. Different metrics can be used, e.g. 'cosine' or 'euclidean'. | def print_sorted_words(word, metric='cosine'):
# Get the token (i.e. integer ID) for the given word.
token = tokenizer.word_index[word]
# Get the embedding for the given word. Note that the
# embedding-weight-matrix is indexed by the word-tokens
# which are integer IDs.
embedding = weights_emb... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def word_analogy(self):\n data = open(\"data/word_analogy_subset.en.ar.txt\").read().split('\\n')\n data = [x for x in data if len(x.split()) == 4]\n cnt = 0\n keys = list(self.embeddings_index.keys())\n vectors = np.array(list(self.embeddings_index.values()))\n norms = np... | [
"0.6305388",
"0.6230253",
"0.6139421",
"0.6103458",
"0.60941505",
"0.6086169",
"0.60522497",
"0.6010836",
"0.6005883",
"0.5975922",
"0.5967013",
"0.59614223",
"0.59542745",
"0.5919518",
"0.5901676",
"0.5882043",
"0.58806413",
"0.5867562",
"0.5837269",
"0.5824132",
"0.58083713... | 0.8753714 | 0 |
Calculate the FDR curve for arrays of target scores and decoy scores. | def calc_fdr_arr(target_arr, decoy_arr, ascending=False):
n, m = len(target_arr), len(decoy_arr)
if n != m:
raise TypeError('target should be same length as decoy {} {}'.format(n, m))
ordering = 1 if ascending else -1 # reversed sorting if score is not ascending
combined = np.concatenate((targe... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _cost_function_derivative(self, y_pred, y, X, m):\n\n derivatives= np.zeros((X.shape[0],1))\n for j in range(X.shape[0]):\n auxsum = 0\n for i in range(m):\n auxsum+=(y_pred[0][i] -y[0][i])*X[j][i]\n derivatives[j][0] = self.theta[j][0] - self.alpha... | [
"0.5936621",
"0.5873862",
"0.5801516",
"0.5756439",
"0.57008326",
"0.5582457",
"0.55692595",
"0.55287987",
"0.55272543",
"0.55269563",
"0.55214703",
"0.5503548",
"0.5492775",
"0.5465149",
"0.54620695",
"0.5462017",
"0.54504746",
"0.5437137",
"0.5423348",
"0.5410652",
"0.54100... | 0.7097738 | 0 |
Find the index of the point before the rightmost crossing point between an FDR curve and a FDR target value. Formally speaking, given an array fdr_curve and a number fdr_target, find the smallest index i such that fdr_curve[j] >= fdr_target for all j > i | def find_crossing(fdr_curve, fdr_target):
#if not is_fdr_curve(fdr_curve):
# raise ValueError("Not a valid FDR curve") #ADP - need to review is_fdr_curve criteria +noise means can start above 0
if not 0 < fdr_target < 1:
return -1
less_zero_indices = np.where(fdr_curve <= fdr_target)[0]
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_closest(A, target):\n idx = A.searchsorted(target)\n idx = np.clip(idx, 1, len(A)-1)\n left = A[idx-1]\n right = A[idx]\n idx -= target - left < right - target\n return idx",
"def __find_r_corr_in_points(arr):\n n = len(arr)\n th = arr[n // 2] * exp(-1.0)\n for i i... | [
"0.6155449",
"0.60407877",
"0.5844136",
"0.5744244",
"0.5732119",
"0.5721886",
"0.57151353",
"0.56536",
"0.56136966",
"0.55823135",
"0.5580776",
"0.557572",
"0.557235",
"0.55606055",
"0.5549734",
"0.55226475",
"0.5512953",
"0.5509117",
"0.55001134",
"0.5492124",
"0.5484047",
... | 0.8555478 | 0 |
Calculate the MSM crossing point at a given target fdr | def get_msm_thresholds(self, adduct, fdr_target, n_reps=10, col='msm'):
fdr_curves, _, score_vects = self.get_fdr_curve(adduct, n_reps, col)
msm_vals = []
for fdr_curve, score_vect in zip(fdr_curves, score_vects):
crossing_idx = find_crossing(fdr_curve, fdr_target)
if cro... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_line_to(self,target):\n\n m = (target.y - self.y) / (target.x - self.x)\n\n b = self.y - m * self.x\n\n return (m,b)",
"def goto_point(self,targetx,targety):\n #if point is 0,0, make 0.01,0.01 to avoid divide by 0\n if targetx == 0 and targety == 0:\n targetx... | [
"0.61080945",
"0.5717393",
"0.57080674",
"0.54190785",
"0.5416999",
"0.54152584",
"0.53966874",
"0.53370297",
"0.5332797",
"0.53247976",
"0.5223969",
"0.5208665",
"0.5179126",
"0.51741207",
"0.51675516",
"0.5164787",
"0.5164787",
"0.5164787",
"0.51419383",
"0.51312935",
"0.50... | 0.47364852 | 84 |
Calculation file hash use md5 | def calc_file_md5(file_path):
hash_md5 = str()
method = hashlib.md5()
if not os.path.exists(file_path):
logger.error("File(%s) don not exist, can not calculation file hash" % file_path)
return hash_md5
with open(file_path, 'rb') as f:
for chunk in read_chunks(f, 1024 * 1024):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def CalcMD5(filepath):\n with open(filepath,'rb') as f:\n md5obj = hashlib.md5()\n md5obj.update(f.read())\n return md5obj.hexdigest()",
"def calc_file_hash(filepath):\n with open(filepath, 'rb') as f:\n return md5(f.read()).hexdigest()",
"def md5_hash(file_path):\n with op... | [
"0.82365745",
"0.80100733",
"0.79871917",
"0.7958175",
"0.79547316",
"0.7920195",
"0.78607863",
"0.7847036",
"0.7811081",
"0.7784871",
"0.7781297",
"0.7760272",
"0.7756879",
"0.7747943",
"0.7744211",
"0.7732946",
"0.77212536",
"0.77095705",
"0.7701398",
"0.7690354",
"0.768329... | 0.8185329 | 1 |
Fetch the process info | def get_process_info(name):
process_lst = list()
all_pid = psutil.pids()
for pid in all_pid:
info = psutil.Process(pid)
if name in info.name():
process_lst.append(info)
return process_lst | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _proc_info(self):\n ret = cext.proc_info(self.pid)\n assert len(ret) == len(pinfo_map)\n return ret",
"def get_process():\n data = _get_process_detail_expanded_data()[\"process\"]\n return data",
"def procinfo(self):\n\n info = {}\n info[\"pid\"] = self.pid\n ... | [
"0.75732034",
"0.7344559",
"0.7254735",
"0.71787053",
"0.70919347",
"0.7023751",
"0.69661444",
"0.69379693",
"0.6882566",
"0.6813353",
"0.6781926",
"0.66613996",
"0.66077",
"0.65982217",
"0.6582502",
"0.65402883",
"0.653665",
"0.65346354",
"0.6523505",
"0.64439726",
"0.640312... | 0.68193763 | 9 |
Fetch the process of cpu and memory info | def get_cpu_memory_info(process_name):
info_dict = dict()
try:
process_list = get_process_info(process_name)
for process in process_list:
cmdline = process.cmdline()
name = os.path.basename(cmdline[2]) if len(cmdline) > 3 else process_name + "_" + str(process.pid)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cpuinfo(self):\n \n command = 'cat /proc/cpuinfo'\n\tpipe = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)\n stdout, stderr = pipe.communicate()\n\tinfo = stdout.strip()\n cpu_type = None\n\tn_proc = 0\n\tfor line in info.split('\\n'):\n ... | [
"0.7663754",
"0.74077755",
"0.7378916",
"0.72161144",
"0.71284556",
"0.7078209",
"0.7037945",
"0.70256805",
"0.70198095",
"0.6998216",
"0.69025713",
"0.68909866",
"0.68835574",
"0.6817426",
"0.67715806",
"0.67403156",
"0.673724",
"0.6727778",
"0.6664821",
"0.66454977",
"0.663... | 0.75478333 | 1 |
Check whether `obj` inherits from Boost.Python.enum. | def is_boost_enum(obj: Any) -> bool:
for cls in type(obj).__bases__:
if "Boost.Python.enum" in str(cls):
return True
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_enum(schema_obj):\n\n return (isinstance(schema_obj, schema.Enum) or\n (isinstance(schema_obj, schema.Field) and schema_obj.enum_type))",
"def is_enum(self):\n return False",
"def is_enum(self):\n return self.is_complex and not self.is_class",
"def inherits_from(obj, a_class):\... | [
"0.7379043",
"0.6682498",
"0.6575283",
"0.63988435",
"0.6314002",
"0.63092816",
"0.6300783",
"0.62994534",
"0.62766397",
"0.6261479",
"0.6242206",
"0.6231385",
"0.6226024",
"0.62231505",
"0.6219832",
"0.6219832",
"0.6207228",
"0.61851394",
"0.61775",
"0.6171979",
"0.6163057",... | 0.8621327 | 0 |
Check whether `obj` is instance of Boost.Python.enum. | def is_boost_class(obj: Any) -> bool:
return "Boost.Python.class" in str(type(obj)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_boost_enum(obj: Any) -> bool:\n for cls in type(obj).__bases__:\n if \"Boost.Python.enum\" in str(cls):\n return True\n return False",
"def is_enum(schema_obj):\n\n return (isinstance(schema_obj, schema.Enum) or\n (isinstance(schema_obj, schema.Field) and schema_obj.enum_... | [
"0.84022284",
"0.76667625",
"0.67724174",
"0.66248685",
"0.63890505",
"0.63192445",
"0.61951196",
"0.6047925",
"0.60392463",
"0.6001024",
"0.59998184",
"0.59177816",
"0.5839826",
"0.58214223",
"0.5817479",
"0.5814377",
"0.5801613",
"0.5796566",
"0.5784162",
"0.5746553",
"0.57... | 0.6009498 | 9 |
Check whether `obj` is an IceCubespecific class. | def is_icecube_class(obj: Any) -> bool:
classname = str(type(obj))
return "icecube." in classname | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def obj_is_in_class(obj: unrealsdk.UObject, in_class: str) -> bool:\n return bool(obj.Class == unrealsdk.FindClass(in_class))",
"def isclass(object):\r\n return isinstance(object, (type, types.ClassType))",
"def is_child_class(obj, classinfo):\n try:\n return issubclass(obj, classinfo)\n exc... | [
"0.6861989",
"0.6678009",
"0.6629571",
"0.6614257",
"0.6606721",
"0.65752107",
"0.65565765",
"0.6548872",
"0.6548872",
"0.6548872",
"0.6548872",
"0.6548872",
"0.6548872",
"0.6514387",
"0.65030473",
"0.6499084",
"0.6499084",
"0.6495338",
"0.6488729",
"0.6484178",
"0.6481067",
... | 0.8361728 | 0 |
Check whether `obj` is a type, and not an instance. | def is_type(obj: Any) -> bool:
return type(obj).__name__ == "type" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_type(obj):\n return type(obj) is type or type(obj) is types.ClassType",
"def verify_type(self, obj):\n return isinstance(obj, self.type_)",
"def is_object(obj):\n return (isinstance(obj, object) and\n type(obj) is not type and\n type(obj) is not types.FunctionType)",
... | [
"0.8257847",
"0.8233891",
"0.76409554",
"0.75532305",
"0.7550207",
"0.7423816",
"0.7423816",
"0.73078024",
"0.72801566",
"0.71918416",
"0.715885",
"0.7127154",
"0.71085626",
"0.7095457",
"0.70536214",
"0.6942919",
"0.69310355",
"0.69265175",
"0.69235885",
"0.69235885",
"0.692... | 0.7958079 | 2 |
Check whether `obj` is a method. | def is_method(obj: Any) -> bool:
return inspect.ismethod(obj) or "Boost.Python.function" in str(type(obj)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ismethod(object):\r\n return isinstance(object, types.MethodType)",
"def is_method_of(method, object):\n if not callable(method) or not hasattr(method, \"__name__\"):\n return False\n if inspect.ismethod(method):\n return method.__self__ is object\n for cls in inspect.getmro(object.... | [
"0.8177807",
"0.77033913",
"0.7681355",
"0.76295954",
"0.7574309",
"0.71349955",
"0.6971231",
"0.6931637",
"0.68637705",
"0.6751655",
"0.6716016",
"0.6662323",
"0.665518",
"0.6646023",
"0.6576209",
"0.6575024",
"0.6565945",
"0.6479175",
"0.6429495",
"0.6226134",
"0.6117707",
... | 0.8378316 | 0 |
Ensure that method isn't called recursively on the same object. | def break_cyclic_recursion(fn: Callable) -> Callable:
@wraps(fn)
def wrapper(obj: Any) -> Any:
global BEING_EVALUATED
try:
hash_ = (hash(fn), hash(obj))
if hash_ in BEING_EVALUATED:
Logger().warning_once(
"break_cyclic_recursion - Alre... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_universal_calls(cls):\n assert True == cls.universal_called\n assert True == cls.nested_called\n\n # Reset for next time.\n cls.base_called = None\n cls.nested_called = None",
"def do_fixup(self):\n if not self.is_in_s... | [
"0.6073565",
"0.58817387",
"0.57517314",
"0.5682072",
"0.56402695",
"0.55823404",
"0.55541307",
"0.5483463",
"0.54408056",
"0.5359991",
"0.5355755",
"0.5271763",
"0.5256923",
"0.5223782",
"0.5218685",
"0.5218685",
"0.52184343",
"0.5216824",
"0.515347",
"0.51432097",
"0.514281... | 0.53553635 | 11 |
Return list of valid member variables. Ignoring mangled (__) variables, types, methods, and Boost enums. | def get_member_variables(
obj: Any, return_discarded: bool = False
) -> Union[List[str], Tuple[List[str], Dict[str, List[str]]]]:
valid_member_variables = []
discarded_member_variables: Dict[str, List[str]] = {
"mangled": [],
"is_type": [],
"invalid_attr": [],
"is_method": []... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def vars(cls):\n for key in dir(cls):\n if key.startswith('var_'):\n yield key[4:]",
"def unusedVars(self):\n fullcode = self.code_cfg\n variables = set([x[1:] for x in codeconfig_getvars(fullcode)])\n exceptions = set(['complexity', 'code_cfg'])\n cls... | [
"0.65596557",
"0.65094596",
"0.64906734",
"0.6424824",
"0.6148797",
"0.61362445",
"0.59760153",
"0.58430034",
"0.5842859",
"0.57547677",
"0.5730297",
"0.5725713",
"0.56944275",
"0.56628054",
"0.56521",
"0.5649057",
"0.5615413",
"0.56144106",
"0.5612419",
"0.5602482",
"0.55804... | 0.6909306 | 0 |
Cast `obj`, and any members/elements, to purepython classes. The function takes any object `obj` and tries to cast it to a pure python class. This is mainly relevant for IceCubespecific classes (I3) that cannot be cast trivially. For IceCubespecific classes, we check whether the object has any member, variables and if ... | def cast_object_to_pure_python(obj: Any) -> Any:
logger = Logger()
logger.debug(f"Value: {obj}")
logger.debug(f"Type: {str(type(obj))}")
if not is_icecube_class(obj):
logger.debug("Found non-I3 class. Exiting.")
if isinstance(obj, (list, tuple, set)):
return [cast_object_to_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def class_casting(obj: object, cls: type):\n orig_cls = obj.__class__\n obj.__class__ = cls\n yield\n obj.__class__ = orig_cls",
"def ns_from_py(pyobj):\n\n if isinstance(pyobj, enum.Enum):\n pyobj = pyobj.value\n\n # Many Objective-C method calls here use the convert_result=False kwarg ... | [
"0.6468261",
"0.6169947",
"0.60216856",
"0.5780408",
"0.5687424",
"0.5681913",
"0.56698275",
"0.5660798",
"0.5552916",
"0.5541389",
"0.5449535",
"0.5432965",
"0.5367629",
"0.5346508",
"0.53237635",
"0.530361",
"0.52975327",
"0.52757865",
"0.5227139",
"0.5226663",
"0.51880336"... | 0.7611115 | 0 |
Cast pulse series `key` to a purepython data representation. | def cast_pulse_series_to_pure_python(
frame: "icetray.I3Frame",
key: str,
calibration: Any,
gcd_dict: Dict,
) -> Optional[Dict[str, List[Any]]]:
om_keys, data = get_om_keys_and_pulseseries(
frame,
key,
calibration,
)
result = []
for om_key in om_keys:
om_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def field(self, key):\n typ = self.d_series._meta.struct.field(key).dtype\n\n return self.d_series.map_partitions(\n lambda s: s.struct.field(key),\n meta=self.d_series._meta._constructor([], dtype=typ),\n )",
"def _key_to_str(self, key: Any) -> Any:\n if isinsta... | [
"0.5926849",
"0.58000153",
"0.57439965",
"0.5699257",
"0.55784553",
"0.5528174",
"0.55275714",
"0.55070806",
"0.5495972",
"0.544524",
"0.54317164",
"0.53724545",
"0.53542686",
"0.5334089",
"0.53163993",
"0.5289975",
"0.5248975",
"0.5237378",
"0.52019364",
"0.51576406",
"0.515... | 0.5301733 | 15 |
Return's tensors containing a batch of images and labels | def get_inputs(self):
x_h_batch, x_m_batch = self.queue.dequeue_up_to(batch_size)
return x_h_batch, x_m_batch | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_batches(image, label, image_path, num_threads=800, batch_size=32):\n assert len(image.get_shape().as_list()) == 4\n batch_images, batch_one_hot_labels, batch_image_paths = tensorflow.train.batch(\n [image, label, image_path],\n batch_size=batch_size,\n num_threads=num_threads,\n ... | [
"0.7233761",
"0.7173265",
"0.7121252",
"0.7059829",
"0.70281094",
"0.7000236",
"0.69339347",
"0.6917312",
"0.69002867",
"0.68962145",
"0.6890418",
"0.688369",
"0.6853334",
"0.6840723",
"0.68327755",
"0.6819258",
"0.6814771",
"0.68146247",
"0.6798603",
"0.6794633",
"0.67815083... | 0.0 | -1 |
Function run on alternate thread. Basically, keep adding data to the queue. | def thread_main(self, sess):
for x_h, x_m, y in self.data_iterator():
sess.run(self.enqueue_op, feed_dict={self.x_h:x_h, self.x_m:x_m}) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def threadWorker(self):\n while True:\n row = self.queue.get() #get a row of data\n if row is None: #ending criterium\n break\n self.similarityQuestions(row) #the actual working function\n self.queue.task_done() #inform the queue one task is done",
"def _worker_mai... | [
"0.7424981",
"0.7353033",
"0.7236351",
"0.7169823",
"0.71250737",
"0.69463426",
"0.69192547",
"0.67611694",
"0.6733895",
"0.6649321",
"0.6638051",
"0.6637718",
"0.6602408",
"0.6547625",
"0.6542828",
"0.6537276",
"0.65200925",
"0.6479801",
"0.6450813",
"0.6444012",
"0.6439474"... | 0.0 | -1 |
Start background threads to feed queue | def start_threads(self, sess, n_threads=1):
self.threads = []
for n in range(n_threads):
t = threading.Thread(target=self.thread_main, args=(sess,))
t.daemon = True # thread will close when parent quits
t.start()
self.threads.append(t) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start_background_thread(self):\n self.runner = Runner(queue=queue, app_id=self.app_id)\n self.runner.start()\n # TODO: stop the thread at some point?",
"def start_workers(self):\n\n for thread in self.threads:\n thread.start()",
"def create_and_start_threads(self):\r\... | [
"0.7448205",
"0.71422285",
"0.7048377",
"0.69680226",
"0.69349277",
"0.6807512",
"0.6731116",
"0.67261374",
"0.6700598",
"0.6661624",
"0.66503876",
"0.6625",
"0.66248053",
"0.661343",
"0.66063064",
"0.6584528",
"0.6556267",
"0.6551169",
"0.6528996",
"0.6515108",
"0.6487246",
... | 0.0 | -1 |
Return's tensors containing a batch of images and labels | def get_inputs(self):
x_h_batch, x_m_batch, y_batch = self.queue.dequeue_up_to(batch_size)
return x_h_batch, x_m_batch, y_batch | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_batches(image, label, image_path, num_threads=800, batch_size=32):\n assert len(image.get_shape().as_list()) == 4\n batch_images, batch_one_hot_labels, batch_image_paths = tensorflow.train.batch(\n [image, label, image_path],\n batch_size=batch_size,\n num_threads=num_threads,\n ... | [
"0.7234958",
"0.7174815",
"0.7123308",
"0.70614076",
"0.70303947",
"0.7001951",
"0.69344926",
"0.69199246",
"0.69017446",
"0.68981457",
"0.6892885",
"0.6884737",
"0.6855283",
"0.6841651",
"0.6834391",
"0.68195397",
"0.68160814",
"0.68151313",
"0.67992914",
"0.67952174",
"0.67... | 0.0 | -1 |
Function run on alternate thread. Basically, keep adding data to the queue. | def thread_main(self, sess):
for x_h, x_m, y in self.data_iterator():
sess.run(self.enqueue_op, feed_dict={self.x_h:x_h, self.x_m:x_m, self.y:y}) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def threadWorker(self):\n while True:\n row = self.queue.get() #get a row of data\n if row is None: #ending criterium\n break\n self.similarityQuestions(row) #the actual working function\n self.queue.task_done() #inform the queue one task is done",
"def _worker_mai... | [
"0.74255943",
"0.73529714",
"0.72351384",
"0.71696067",
"0.7124813",
"0.6946827",
"0.6920035",
"0.6762393",
"0.6733649",
"0.6648056",
"0.6638403",
"0.663644",
"0.66034234",
"0.65477896",
"0.6542435",
"0.65361744",
"0.65179265",
"0.64787143",
"0.6451529",
"0.64417064",
"0.6440... | 0.0 | -1 |
Start background threads to feed queue | def start_threads(self, sess, n_threads=1):
self.threads = []
for n in range(n_threads):
t = threading.Thread(target=self.thread_main, args=(sess,))
t.daemon = True # thread will close when parent quits
t.start()
self.threads.append(t) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start_background_thread(self):\n self.runner = Runner(queue=queue, app_id=self.app_id)\n self.runner.start()\n # TODO: stop the thread at some point?",
"def start_workers(self):\n\n for thread in self.threads:\n thread.start()",
"def create_and_start_threads(self):\r\... | [
"0.7448205",
"0.71422285",
"0.7048377",
"0.69680226",
"0.69349277",
"0.6807512",
"0.6731116",
"0.67261374",
"0.6700598",
"0.6661624",
"0.66503876",
"0.6625",
"0.66248053",
"0.661343",
"0.66063064",
"0.6584528",
"0.6556267",
"0.6551169",
"0.6528996",
"0.6515108",
"0.6487246",
... | 0.0 | -1 |
Set leds with pixel values | def set(self, pixels):
rgb_array = [int(x) for pixel in pixels for x in pixel.rgb]
if self._are_rgb_arrays_equal(rgb_array, self.current_rgb_vals):
# if led values are the same, don't bother sending. This stops
# spamming the serial port when nothing's happening... dunno if that'... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_leds():\n # zaświeć\n for i in range(current_leds):\n volume_leds[i].configure(background=TURN_ON_COLOR)\n\n # zgaś\n for i in range(current_leds, LEDS):\n volume_leds[i].configure(background=TURN_OFF_COLOR)",
"def set_pixel(self, x, y, value):\r\n \r\n # Rotati... | [
"0.72096604",
"0.71945995",
"0.7119041",
"0.7114636",
"0.70880646",
"0.70106107",
"0.6923163",
"0.6921453",
"0.6886742",
"0.6870684",
"0.68527406",
"0.6727933",
"0.6711373",
"0.6662691",
"0.65572274",
"0.65195435",
"0.6511411",
"0.6489685",
"0.648497",
"0.6442501",
"0.6441107... | 0.6994683 | 6 |
Ensure values are <= max brightness and != stop byte | def _check_values(self, rgb_array):
for i, value in enumerate(rgb_array):
if value > self.brightness_limit:
rgb_array[i] = self.brightness_limit
if value == self.STOP_BYTE:
rgb_array[i] -= 1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_channel_value(value: int) -> None:\n if 0 <= value <= 255:\n pass\n else:\n raise ValueError(\"Color channel has to be in range [0; 255]\")",
"def is_0to255(value):\n return 0 <= value <= 255",
"def verify_brightness_value(brightness):\n\n check_value_is_number_type(brigh... | [
"0.6506269",
"0.648789",
"0.632641",
"0.6291771",
"0.6192554",
"0.6170371",
"0.6110706",
"0.6030551",
"0.5996378",
"0.59669286",
"0.5962",
"0.59381783",
"0.58866835",
"0.5861975",
"0.5832914",
"0.5733476",
"0.5728271",
"0.5698746",
"0.5698746",
"0.5675874",
"0.56753343",
"0... | 0.77700883 | 0 |
Redefines the size of the buffer. | def resize_memory(self, new_size=None):
self.capacity = new_size
# self.push() takes care of decreasing the memory.
# # Oldest experiences are discarded. For Ever.
# # TODO: Check for a more efficient way of cleaning the memory.
# while len(self.memory) > self.capacity:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setBufferSize(self, buffer_size):\n DPxSetDinBuffSize(buffer_size)",
"def use_buffer(self, buffer_size):\n self.__buffer_size = buffer_size\n if self.__buffer is None:\n self.__buffer = []",
"def setsize(self, size):\n self.__size = size",
"def buffer_size(self):\n ... | [
"0.7421728",
"0.7280224",
"0.6786766",
"0.6720138",
"0.660248",
"0.6564156",
"0.654087",
"0.6469055",
"0.6469055",
"0.64685136",
"0.6412179",
"0.64071226",
"0.64071226",
"0.6391134",
"0.632705",
"0.63231176",
"0.6318994",
"0.62779015",
"0.62604064",
"0.6232587",
"0.6174553",
... | 0.0 | -1 |
Redefines the size of the buffer. | def resize_memory(self, new_size=None):
self.container.capacity = new_size | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setBufferSize(self, buffer_size):\n DPxSetDinBuffSize(buffer_size)",
"def use_buffer(self, buffer_size):\n self.__buffer_size = buffer_size\n if self.__buffer is None:\n self.__buffer = []",
"def setsize(self, size):\n self.__size = size",
"def buffer_size(self):\n ... | [
"0.7421728",
"0.7280224",
"0.6786766",
"0.6720138",
"0.660248",
"0.6564156",
"0.654087",
"0.6469055",
"0.6469055",
"0.64685136",
"0.6412179",
"0.64071226",
"0.64071226",
"0.6391134",
"0.632705",
"0.63231176",
"0.6318994",
"0.62779015",
"0.62604064",
"0.6232587",
"0.6174553",
... | 0.57274216 | 65 |
Install emacs with some features in python 2.7 environement | def install_p2k():
if 'pkgs' not in env:
env.pkgs = []
pkgs = [
'python2',
'git',
'mercurial',
'emacs',
# For flymake
'xmlstarlet',
#'csslint-git',
]
require.arch.packages(pkgs)
python_cmd = 'python2.7'
virtualenv = '.virtualenvs/... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setup_zxpy_repl() -> None:\n print(\"zxpy shell\")\n print(\"Python\", sys.version)\n print()\n\n install()",
"def develop():\n# Install package in development mode\n sh('python setup.py develop')",
"def open_in_emacs_command(event):\n c = event.get('c')\n if c:\n open_in_emac... | [
"0.594541",
"0.58539075",
"0.5628848",
"0.5576539",
"0.5572069",
"0.5543689",
"0.5543153",
"0.54723585",
"0.54654664",
"0.54646444",
"0.54574805",
"0.54236794",
"0.5378128",
"0.5352251",
"0.53416926",
"0.53223884",
"0.5298473",
"0.5297451",
"0.5256946",
"0.5242978",
"0.523045... | 0.67693573 | 0 |
Create creates a set session | async def create(
self, *, header: Optional[headers.RequestHeader] = None
) -> CreateResponse:
request = CreateRequest()
if header is not None:
request.header = header
return await self._unary_unary(
"/atomix.set.SetService/Create", request, CreateResponse,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create(data):\n \n return Setlist(\n list_id = data['id'],\n name = data['name'],\n items = data['num_sets'])",
"def new_set(*, ctx: context.ContextLevel, **kwargs) -> irast.Set:\n ir_set = irast.Set(**kwargs)\n ctx.all_sets.append(ir_set)\n return ir_s... | [
"0.6151142",
"0.6048097",
"0.60076725",
"0.5988856",
"0.5988856",
"0.5877816",
"0.5837743",
"0.5801947",
"0.57588005",
"0.572035",
"0.57137334",
"0.5670384",
"0.56422436",
"0.5623634",
"0.5616179",
"0.5612067",
"0.5610329",
"0.5587627",
"0.5562947",
"0.5547399",
"0.550339",
... | 0.62500304 | 0 |
Close closes a set | async def close(
self, *, header: Optional[headers.RequestHeader] = None, delete: bool = False
) -> CloseResponse:
request = CloseRequest()
if header is not None:
request.header = header
request.delete = delete
return await self._unary_unary(
"/atomi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def close_changeset(self):\n pass",
"def _close_result_set(self):\n if self._result_set:\n self._result_set.close(self.session)\n self._result_set = None",
"def close_file(self, data_set):\n if hasattr(data_set, '_h5_base_group'):\n data_set._h5_base_group.... | [
"0.6684206",
"0.6438695",
"0.6179789",
"0.5959591",
"0.5912371",
"0.5891763",
"0.5832663",
"0.58226657",
"0.58226657",
"0.58226657",
"0.58226657",
"0.58226657",
"0.58226657",
"0.58226657",
"0.58226657",
"0.58226657",
"0.58226657",
"0.58129406",
"0.58081174",
"0.5796722",
"0.5... | 0.64467335 | 1 |
Size gets the number of elements in the set | async def size(
self, *, header: Optional[headers.RequestHeader] = None
) -> SizeResponse:
request = SizeRequest()
if header is not None:
request.header = header
return await self._unary_unary(
"/atomix.set.SetService/Size", request, SizeResponse,
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __len__(self):\n\n if self.is_finite_set:\n size = 0\n for set in self.sets:\n size += len(set)\n return size\n else:\n raise ValueError(\"'%s' is not a finite set.\" % self)",
"def __len__(self):\n return len(self.set)",
"def ... | [
"0.79854566",
"0.7878397",
"0.77432305",
"0.7528662",
"0.7375253",
"0.73256296",
"0.7318299",
"0.73137283",
"0.7241106",
"0.72328115",
"0.72008455",
"0.7190952",
"0.7189001",
"0.71774817",
"0.71774817",
"0.71774817",
"0.7164819",
"0.7155079",
"0.71056724",
"0.7090391",
"0.705... | 0.0 | -1 |
Contains returns whether the set contains a value | async def contains(
self, *, header: Optional[headers.RequestHeader] = None, value: str = ""
) -> ContainsResponse:
request = ContainsRequest()
if header is not None:
request.header = header
request.value = value
return await self._unary_unary(
"/ato... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_contains(self):\n s = djset()\n s.add([1, 2, 3])\n s.add([4, 5, 6])\n self.assertTrue(2 in s)\n self.assertTrue(5 in s)",
"def contains(self, value):\n return value in self.values",
"def __contains__(self, v):\n for i in self:\n if v in i:\n ... | [
"0.77923185",
"0.77377176",
"0.75346315",
"0.75018543",
"0.7492035",
"0.7417618",
"0.7380783",
"0.7380783",
"0.73111457",
"0.7238775",
"0.7159179",
"0.7152344",
"0.7145575",
"0.71060693",
"0.7088303",
"0.7070911",
"0.70613056",
"0.705864",
"0.7048832",
"0.7035732",
"0.7028573... | 0.69588226 | 24 |
Add adds a value to the set | async def add(
self, *, header: Optional[headers.RequestHeader] = None, value: str = ""
) -> AddResponse:
request = AddRequest()
if header is not None:
request.header = header
request.value = value
return await self._unary_unary(
"/atomix.set.SetServ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add(self, value):",
"def add(self, value):\n pass",
"def __iadd__(self, value):\n self.store.append(value)\n return self",
"def add(self, val):\n val = self._conversion(val)\n if self.__tree.search(val):\n print(\"Element is already exist\") \n else:\n... | [
"0.7770512",
"0.7550393",
"0.7222648",
"0.71882683",
"0.71800035",
"0.7004646",
"0.6897328",
"0.68678784",
"0.6859076",
"0.6831484",
"0.6742819",
"0.67410994",
"0.6721825",
"0.6721825",
"0.66597855",
"0.6646095",
"0.6623483",
"0.65995175",
"0.6527265",
"0.6486651",
"0.648611"... | 0.66859055 | 14 |
Remove removes a value from the set | async def remove(
self, *, header: Optional[headers.RequestHeader] = None, value: str = ""
) -> RemoveResponse:
request = RemoveRequest()
if header is not None:
request.header = header
request.value = value
return await self._unary_unary(
"/atomix.se... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove(self, value): # real signature unknown; restored from __doc__\n pass",
"def remove(self, value):\n pass",
"def remove(self, item):\n try:\n entry = self.set.pop(item)\n entry[-1] = self.REMOVED\n except KeyError:\n print(\"Can't remove a n... | [
"0.7499105",
"0.7475474",
"0.7413744",
"0.73840106",
"0.7267877",
"0.72519946",
"0.72145766",
"0.7209538",
"0.7179464",
"0.71740055",
"0.7169468",
"0.71024555",
"0.707675",
"0.7063856",
"0.7060687",
"0.7044186",
"0.7035269",
"0.7035269",
"0.7035269",
"0.7018425",
"0.6988541",... | 0.66783094 | 39 |
Clear removes all values from the set | async def clear(
self, *, header: Optional[headers.RequestHeader] = None
) -> ClearResponse:
request = ClearRequest()
if header is not None:
request.header = header
return await self._unary_unary(
"/atomix.set.SetService/Clear", request, ClearResponse,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clear():",
"def clear(self) -> None:\n self._used = set()\n self.search_pos = 1",
"def clear(self):",
"def clear(self):",
"def clear(self):",
"def clear(self):",
"def clear(self):",
"def clear(self):",
"def clear(self):",
"def clear(self) -> None:",
"def reset(self):\n ... | [
"0.7805768",
"0.7707385",
"0.76996446",
"0.76996446",
"0.76996446",
"0.76996446",
"0.76996446",
"0.76996446",
"0.76996446",
"0.76792973",
"0.7615851",
"0.76151764",
"0.749507",
"0.74909836",
"0.7487331",
"0.7479187",
"0.74638087",
"0.7438506",
"0.7423704",
"0.7420464",
"0.742... | 0.0 | -1 |
Events listens for set change events | async def events(
self, *, header: Optional[headers.RequestHeader] = None, replay: bool = False
) -> AsyncGenerator[EventResponse, None]:
request = EventRequest()
if header is not None:
request.header = header
request.replay = replay
async for response in self._... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def changed(self, event: Event):\n\n for observer in self._observers:\n observer.on_change(event)",
"def on_change(self, value):",
"def changed_event(self):\n return True",
"def events(self):",
"def process_IN_MODIFY(self, event):",
"def on_change(key):\n pass",
"def _se... | [
"0.6882418",
"0.67092174",
"0.65666777",
"0.6551096",
"0.6546439",
"0.64864707",
"0.64165723",
"0.63784915",
"0.6310342",
"0.62813646",
"0.624877",
"0.6219667",
"0.6213797",
"0.61540306",
"0.61390483",
"0.61263835",
"0.61263835",
"0.6097671",
"0.6097671",
"0.6097035",
"0.6078... | 0.0 | -1 |
Iterate iterates through all values in the set | async def iterate(
self, *, header: Optional[headers.RequestHeader] = None
) -> AsyncGenerator[IterateResponse, None]:
request = IterateRequest()
if header is not None:
request.header = header
async for response in self._unary_stream(
"/atomix.set.SetService... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __iter__(self):\n return iproduct(*self.sets)",
"def __iter__(self):\n for val in self.value:\n yield val",
"def __iter__(self):\n\n # For each key in set of keys\n for key in self.keys_set:\n\n # Yield that key and associated value\n yield key, ... | [
"0.7051855",
"0.69685805",
"0.69519144",
"0.69185954",
"0.6838135",
"0.6813809",
"0.6758065",
"0.66853005",
"0.66784126",
"0.6678248",
"0.6676724",
"0.6655518",
"0.6621701",
"0.6564479",
"0.6495076",
"0.64398426",
"0.6436683",
"0.6436683",
"0.6436683",
"0.6436683",
"0.6392469... | 0.5919447 | 63 |
Generates sound according to , and applies the algorithm on it. Saves the result in .wav format. Testing is repeated times. | def test_sound(alg, repNum, soundType):
fs = 1000
if soundType=='c_maj':
alg.input_func = gen_sound_dataset
alg.input_func_args=([(1,'C',0),(1,'E',0),(1,'G',0)], fs)
elif soundType=='c_min':
alg.input_func = gen_sound_dataset
alg.input_func_args=([(1,'C',0),(1,'D#',0),(1,'G',0)], fs)
elif soundType=='c_fif... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_audio():\n text, lang = introduction()\n ses = boto3.Session(profile_name=\"default\")\n pol = ses.client(\"polly\")\n res = pol.synthesize_speech(Text=text, LanguageCode=lang, OutputFormat=\"mp3\", VoiceId=VOICE)\n return res",
"def morse_to_audio(words, playsound=None, name_file=\"o... | [
"0.66214776",
"0.6580639",
"0.6445524",
"0.6420695",
"0.6413206",
"0.6407476",
"0.6347746",
"0.6261488",
"0.6259845",
"0.6184484",
"0.6165459",
"0.614598",
"0.6100138",
"0.60954386",
"0.6089836",
"0.60553485",
"0.60398495",
"0.5991466",
"0.59838504",
"0.5979664",
"0.59610015"... | 0.6011576 | 17 |
Loads 10 seconds of 8000Hz music ('dataset/wind_lq_predicted.wav'), applies algorithm on windows of size alg.N, and outputs the result in a .wav file. | def test_real_song(alg):
alg.input_func = None
alg.input_func_args = 'dataset/wind_lq.wav',True
alg.predict_long_wav_data(fs=8000, outname='wind_lq_predicted.wav') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main(_):\n\tlabel_wav()",
"def load_train_dataset(data_dir, word_list, silence_percentage, noise_percentage):\n validation_percentage, testing_percentage = 0.1, 0.1\n temp_list = []\n\n #wav_lists = os.path.join(data_dir, *, '*.wav')\n for word_l in word_list:\n #wav_word_list = os.path.jo... | [
"0.5846201",
"0.57938576",
"0.57843184",
"0.57702315",
"0.56909996",
"0.5670173",
"0.5635622",
"0.5609626",
"0.558032",
"0.5578267",
"0.5574669",
"0.55611974",
"0.55452716",
"0.5497656",
"0.54688525",
"0.5414804",
"0.5396864",
"0.5391886",
"0.538346",
"0.53793347",
"0.5373648... | 0.74534905 | 0 |
Uses the data generation function as defined prior to this function call (set alg.input_func and alg.input_func_args), and creates an image of it for easier inspection of the performance. Testing is repeated times. | def test_random_noise_img(alg, repNum=1):
import math
performance = alg.predict_perf(repNum=repNum)
print performance
alg.plot()
alg.shape = (math.sqrt(alg.N),math.sqrt(alg.N))
save_img(alg.x, alg, 'random_original.png', False)
save_img(alg.x_pred, alg, 'random_predicted.png', False)
return performance | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate(self):\n self.training_data.gen_x(self.x_func)\n self.training_data.gen_a(self.a_func)\n self.training_data.gen_y(self.y_func)\n \n self.testing_data.gen_x(self.x_func)\n self.testing_data.gen_ys(self.y_func)\n self.testing_data.gen_azero(self.ytotal_fu... | [
"0.61088735",
"0.5973177",
"0.5904214",
"0.5859187",
"0.5835866",
"0.5775228",
"0.5771744",
"0.57647645",
"0.56805056",
"0.5679807",
"0.5660722",
"0.56150275",
"0.561212",
"0.5611035",
"0.5578854",
"0.556222",
"0.5535504",
"0.552646",
"0.5524133",
"0.5521532",
"0.55168223",
... | 0.5726014 | 8 |
Loads a real image as defined in , and applies . Set to True/False to convert the image to frequency domain (i.e. apply np.fft.fft2()). | def test_real_img(alg, img_name, use_transform, plot_on=False):
alg.input_func = None
alg.input_func_args = img_name,use_transform
performance = alg.predict_perf(repNum=1)
print performance
if plot_on:
alg.plot()
save_img(alg.x_pred, alg, '%s_predicted.png'%img_name, use_transform)
return performance | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def op(self, img):\n return self._mask * np.fft.fft2(img, norm=\"ortho\")",
"def ff_correct_image(image):\n pass",
"def ff_correct_image(image):\n pass",
"def read_img(filename, use_flat_32_type, one_channel, flip):\r\n\r\n if one_channel:\r\n img = cv2.imread(filename,... | [
"0.5800233",
"0.571093",
"0.571093",
"0.562062",
"0.55912846",
"0.5581692",
"0.5542418",
"0.55164516",
"0.53814065",
"0.53507775",
"0.5319273",
"0.53127134",
"0.53067523",
"0.53023916",
"0.52974594",
"0.52043843",
"0.51897603",
"0.5185835",
"0.5166272",
"0.5161582",
"0.515979... | 0.5287391 | 15 |
General testing module. Manually set the data generation method. (set alg.input_func and alg.input_func_args) Testing is repeated times. | def test_any(alg, repNum=1):
performance = alg.predict_perf(repNum=repNum)
print performance
alg.plot()
return performance | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setUpTestData(cls):\n data_gen.run()",
"def setUpTestData(cls):\n data_gen.run()",
"def setUpTestData(cls):\n data_gen.run()",
"def setUpTestData(cls):\n data_gen.run()",
"def main():\n parser = optparse.OptionParser()\n parser.add_option(\"-c\", \"--clear\", action=\"... | [
"0.6612698",
"0.6612698",
"0.6612698",
"0.6612698",
"0.6581655",
"0.651736",
"0.6358582",
"0.6229981",
"0.6167597",
"0.61485285",
"0.6095539",
"0.606338",
"0.60473436",
"0.60217035",
"0.5973555",
"0.5954401",
"0.59299994",
"0.59078056",
"0.5899024",
"0.58836544",
"0.58675027"... | 0.0 | -1 |
Ensure module attributes' signatures. | def test_module_attribute() -> None:
assert hasattr(lmp.tknzr._bpe, 'BPETknzr')
assert inspect.isclass(lmp.tknzr._bpe.BPETknzr)
assert not inspect.isabstract(lmp.tknzr._bpe.BPETknzr)
assert issubclass(lmp.tknzr._bpe.BPETknzr, BaseTknzr)
assert hasattr(lmp.tknzr._bpe, 'EOW_TK')
assert isinstance(lmp.tknzr._... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def verify_attrs(self):\n self.verify_namespace_attrs(self.newlibrary.wrap_namespace)",
"def assert_attributes_exist(name, module_dict, attributes):\n for attribute in attributes:\n assert attribute in module_dict, \\\n f'{name} should define {attribute} in its __init__.py file.'",
"def... | [
"0.70217013",
"0.64923775",
"0.60221565",
"0.59418005",
"0.5927303",
"0.5787525",
"0.57695055",
"0.5680364",
"0.5629567",
"0.56272185",
"0.5619597",
"0.5604891",
"0.55963236",
"0.5548894",
"0.5503465",
"0.54832876",
"0.54719925",
"0.5449704",
"0.54479873",
"0.5434557",
"0.543... | 0.58752966 | 5 |
Ensure class attributes' signatures. | def test_class_attribute() -> None:
assert get_type_hints(lmp.tknzr._bpe.BPETknzr) == {'tknzr_name': ClassVar[str]}
assert lmp.tknzr._bpe.BPETknzr.tknzr_name == 'BPE' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_class_args(self, **kwargs):\n pass",
"def verify_attrs(self):\n self.verify_namespace_attrs(self.newlibrary.wrap_namespace)",
"def check_class_definition(cls):\n if not cls.callable:\n cls.definition_error('Must provide \"callable\" attribute.')\n\n if not re... | [
"0.6690239",
"0.6579591",
"0.6553533",
"0.6349605",
"0.6328544",
"0.6255223",
"0.62358034",
"0.6223971",
"0.61924374",
"0.6124737",
"0.61087817",
"0.5985653",
"0.59492594",
"0.5943543",
"0.59111685",
"0.5893377",
"0.58839774",
"0.58703357",
"0.58515596",
"0.58254915",
"0.5808... | 0.0 | -1 |
Ensure class methods' signatures. | def test_class_method() -> None:
assert inspect.signature(lmp.tknzr._bpe.BPETknzr.add_CLI_args) == inspect.signature(BaseTknzr.add_CLI_args) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_implemented_functions(_class):\n mandatory_functions_to_implement = [('generate', 2), ('__init__', 6)]\n implemented_class_function_names = get_implemented_class_functions(_class)\n for function in mandatory_functions_to_implement:\n function_name = function[0]\n number_function_ma... | [
"0.6865951",
"0.6779388",
"0.6498488",
"0.6362184",
"0.62972075",
"0.62814236",
"0.6257724",
"0.62441605",
"0.6198573",
"0.61527693",
"0.6070059",
"0.60478127",
"0.6041627",
"0.6029048",
"0.5988869",
"0.59486306",
"0.5920295",
"0.5917137",
"0.59127486",
"0.587004",
"0.5849536... | 0.6849367 | 1 |
Ensure inherent instance methods are same as base class. | def test_inherent_instance_method() -> None:
assert lmp.tknzr._bpe.BPETknzr.dec == BaseTknzr.dec
assert lmp.tknzr._bpe.BPETknzr.enc == BaseTknzr.enc
assert lmp.tknzr._bpe.BPETknzr.norm == BaseTknzr.norm
assert lmp.tknzr._bpe.BPETknzr.pad_to_max == BaseTknzr.pad_to_max
assert lmp.tknzr._bpe.BPETknzr.vocab_size... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_class_method(self):\n self.assertEqual(pyperry.Base.adapter.im_self.__name__, 'Base')",
"def test_class_method(self):\n self.assertEqual(pyperry.Base.resolve_name.im_self.__name__, 'Base')",
"def test_class_method(self):\n self.assertEqual(pyperry.Base.add_processor.im_self.__name... | [
"0.6679002",
"0.6651",
"0.64923453",
"0.6323402",
"0.6282509",
"0.6204761",
"0.61769134",
"0.61768293",
"0.6155188",
"0.613983",
"0.6128832",
"0.60652184",
"0.60199344",
"0.5996563",
"0.593412",
"0.5932251",
"0.5925863",
"0.5918437",
"0.5918437",
"0.5918437",
"0.5918437",
"... | 0.63654554 | 3 |
Ensure instance methods' signatures. | def test_instance_method() -> None:
assert inspect.signature(lmp.tknzr._bpe.BPETknzr.__init__) == Signature(
parameters=[
Parameter(
annotation=Parameter.empty,
default=Parameter.empty,
kind=Parameter.POSITIONAL_OR_KEYWORD,
name='self',
),
Parameter(
annot... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_class_method() -> None:\n assert inspect.signature(lmp.tknzr._bpe.BPETknzr.add_CLI_args) == inspect.signature(BaseTknzr.add_CLI_args)",
"def signature(cls):\n raise NotImplementedError(\"%s.signature()\" % cls)",
"def check_params(self):\n raise NotImplementedError",
"def check_implemente... | [
"0.6633604",
"0.6633455",
"0.6397099",
"0.6391364",
"0.63903403",
"0.6352831",
"0.63265115",
"0.6266008",
"0.6223172",
"0.6191569",
"0.6160456",
"0.6119572",
"0.6080453",
"0.6053841",
"0.5989254",
"0.5964804",
"0.59569246",
"0.5929215",
"0.5927285",
"0.5860871",
"0.5840367",
... | 0.61456877 | 11 |
Display a Warning Dialog and return the response to the caller | def show_question_dialog(self, title, message):
dialog = QMessageBox.question(self, title, message, QMessageBox.Yes | QMessageBox.No | QMessageBox.Cancel)
'''dialog.setText(title) # format_secondary_text(message)
dialog.setInformativeText(message)
dialog.setStandardButtons(QMessageBox.Sa... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def warning(message, title=None):\n return dialog(\"warning\", message=message, title=title)",
"def warning(self, message):\n msg_dlg = wx.MessageDialog(None, message, '', wx.OK | wx.CANCEL| wx.ICON_ERROR)\n val = msg_dlg.ShowModal()\n msg_dlg.Show()\n msg_dlg.Destroy()\n re... | [
"0.7924776",
"0.75474113",
"0.7359508",
"0.73021257",
"0.72687703",
"0.70980227",
"0.70980227",
"0.7085822",
"0.7061339",
"0.7056901",
"0.70497286",
"0.7011222",
"0.69738966",
"0.6909007",
"0.6881498",
"0.6877935",
"0.6766182",
"0.67576104",
"0.665784",
"0.6655004",
"0.663020... | 0.0 | -1 |
Instantiate a StartFunction task. | def __init__(self, func=None, **kwargs):
self.func = func if func is not None else self.start_func_default
super(StartFunction, self).__init__(**kwargs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _init_start(self):\n def start(core, args):\n task = ' '.join(args.task) if args.task else ''\n return core.start(task=task)\n\n usage = 'stl start [task]'\n desc = (\n 'make a log that you are starting to work'\n )\n\n subp = self.subparsers.... | [
"0.64261806",
"0.6352809",
"0.6259454",
"0.61059666",
"0.6070468",
"0.6019398",
"0.5951755",
"0.593934",
"0.5893391",
"0.5785626",
"0.57718456",
"0.5657987",
"0.56442446",
"0.5641955",
"0.5632375",
"0.5630811",
"0.56288636",
"0.5609423",
"0.56023276",
"0.55829614",
"0.5582961... | 0.6456831 | 0 |
Default implementation for start function. Do nothing, just create a new process instance. | def start_func_default(self, activation):
activation.prepare()
activation.done()
return activation | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Start(self):\n\n\n\n assert not self._process, 'Start() can only be called once'\n self._process = subprocess.Popen(self._args)",
"def start(self):\n self._proc = self._get_subprocess()\n self._pid = self._proc.pid\n self._return_code = None",
"def new_process() -> Process:\n ... | [
"0.7200789",
"0.7043506",
"0.6862106",
"0.6856768",
"0.67740154",
"0.6757407",
"0.66499764",
"0.6637979",
"0.6611261",
"0.6534633",
"0.65241134",
"0.64906675",
"0.6465283",
"0.64606667",
"0.64336574",
"0.6416866",
"0.6400661",
"0.6348408",
"0.63384014",
"0.62968725",
"0.62941... | 0.0 | -1 |
Execute the function task. | def run(self, *args, **kwargs):
return self.func(self, *args, **kwargs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _execute_task(task, function, config):\n logging.debug('<Task-%s> started.' % task.get_id())\n start_time = time.time()\n try:\n function(task.get_data())\n logging.debug('<Task-%s> finished in %2.2f seconds with result: %s' % (task.get_id(),\n ... | [
"0.73130786",
"0.727794",
"0.727794",
"0.7223112",
"0.7086795",
"0.7083772",
"0.70426476",
"0.69302607",
"0.6923544",
"0.6868409",
"0.6854366",
"0.67575186",
"0.67484105",
"0.67245996",
"0.66799116",
"0.66722405",
"0.663224",
"0.6616039",
"0.6605105",
"0.6604266",
"0.659991",... | 0.58586454 | 82 |
Instantiate a Function task. | def __init__(self, func, task_loader=None, **kwargs):
self.func = func
self.task_loader = task_loader
super(Function, self).__init__(**kwargs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_task():",
"def from_function(\n cls,\n task: ty.Callable,\n cleanup: ty.Callable=None,\n provides=tuple(),\n depends_on=tuple(),\n submit_to='thread',\n parallel=True,\n changing_inputs=False):\n if not len(... | [
"0.7264041",
"0.6980909",
"0.68889225",
"0.6819239",
"0.6739775",
"0.65774894",
"0.65699",
"0.6558215",
"0.6550279",
"0.6496677",
"0.6468632",
"0.64679205",
"0.64679205",
"0.6448362",
"0.644499",
"0.6404104",
"0.64028794",
"0.63484013",
"0.63439476",
"0.63439476",
"0.63439476... | 0.722987 | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.