query stringlengths 9 9.05k | document stringlengths 10 222k | metadata dict | negatives listlengths 30 30 | negative_scores listlengths 30 30 | document_score stringlengths 4 10 | document_rank stringclasses 2
values |
|---|---|---|---|---|---|---|
Inserts Qt Creator markers around method docs. In order to display the method signature inside Qt Creator's tooltip, the method signature is also inserted as a text inside a hidden div. | def insert_methods_markers(soup):
# look for all memitem divs
divs = soup.find_all("div", "memitem")
for div in divs:
# look for method name and signature
memdoc = div.find("div", "memdoc")
memname_td = div.find("td","memname")
memname_table = div.find("table", "mem... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _add_doc(func, doc):\r\n func.__doc__ = doc",
"def _add_doc(func, doc):\r\n func.__doc__ = doc",
"def _add_doc(func, doc):\r\n func.__doc__ = doc",
"def show_popup(self, view, docstring, location=None):",
"def signature(self) -> global___SnippetSignature:",
"def _add_doc(func, doc):\n fun... | [
"0.63913465",
"0.63913465",
"0.63913465",
"0.6378863",
"0.6372265",
"0.6335496",
"0.63318473",
"0.62927926",
"0.62695724",
"0.62648576",
"0.61829376",
"0.6147917",
"0.6072649",
"0.605651",
"0.60020053",
"0.59880006",
"0.59529907",
"0.5952288",
"0.58864117",
"0.58829296",
"0.5... | 0.6983738 | 0 |
Creates the subcloud config file for a subcloud. | def _create_subcloud_config_file(self, context, subcloud, payload):
DEFAULT_STR = '<EDIT>'
pxe_cidr = payload.get(
'pxe-subnet', DEFAULT_STR)
management_vlan = payload.get(
'management-vlan', DEFAULT_STR)
management_interface_mtu = payload.get(
'manag... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generateConfig(run,subrun,conditions):\n \n configname = (conditions.numcdir + \"/\" + str(run) + \"/\" + str(subrun)\n + \"/numc_config_\" + str(run) + \"_\" + str(subrun) + \".cfg\")\n \n configContents = \"\"\n \n configContents += \"[software]\\n\"\n if conditi... | [
"0.6121712",
"0.6021425",
"0.5970042",
"0.58997214",
"0.57222944",
"0.565262",
"0.5609398",
"0.55893815",
"0.55608094",
"0.55608094",
"0.5529405",
"0.5481049",
"0.5470068",
"0.5454739",
"0.5422953",
"0.5411979",
"0.53847975",
"0.53629035",
"0.5360652",
"0.5286819",
"0.5279199... | 0.8010254 | 0 |
Get the subcloud users and passwords from keyring | def _get_subcloud_users(self):
DEFAULT_SERVICE_PROJECT_NAME = 'services'
# First entry is openstack user name, second entry is the user stored
# in keyring. Not sure why heat_admin uses a different keystone name.
SUBCLOUD_USERS = [
('nova', 'nova'),
('placement', ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_credentials(service_name=\"dataforSeo\", uname=\"matteo.jriva@gmail.com\"):\n pw = keyring.get_password(service_name, uname)\n return [uname, pw]",
"def GetUserCredentials(self):\r\n # Create a local alias to the email variable to avoid Python's crazy\r\n # scoping rules.\r\n global keyrin... | [
"0.65946317",
"0.6310419",
"0.6153865",
"0.605549",
"0.60493493",
"0.6014239",
"0.59450334",
"0.592866",
"0.5894807",
"0.58728194",
"0.58414346",
"0.5836289",
"0.5806845",
"0.5778761",
"0.57776064",
"0.5770482",
"0.5766917",
"0.5747226",
"0.57193136",
"0.57034826",
"0.5702921... | 0.68357867 | 0 |
Get the system controller's management address pool | def _get_management_address_pool(self, context):
session = KeystoneClient().endpoint_cache.get_session_from_token(
context.auth_token, context.project)
sysinv_client = SysinvClient(consts.DEFAULT_REGION_NAME, session)
return sysinv_client.get_management_address_pool() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def customer_owned_ipv4_pool(self) -> str:\n return pulumi.get(self, \"customer_owned_ipv4_pool\")",
"def get_pool():\n app = get_app()\n return app['pool']",
"def getManageIp(self):\n dev = self.device()\n if dev: return dev.getManageIp()\n return \"\"",
"def pool(self):\n ... | [
"0.6537697",
"0.6467163",
"0.6289136",
"0.6148119",
"0.59776145",
"0.59776145",
"0.59086293",
"0.59005976",
"0.58809096",
"0.57775706",
"0.57616085",
"0.5676692",
"0.56216216",
"0.5545167",
"0.5511758",
"0.5487965",
"0.54841584",
"0.54414916",
"0.54396343",
"0.5414244",
"0.54... | 0.8022331 | 0 |
Get details about subcloud. | def get(self, subcloud_ref=None, qualifier=None):
context = restcomm.extract_context_from_environ()
if subcloud_ref is None:
# List of subclouds requested
subclouds = db_api.subcloud_get_all_with_status(context)
result = dict()
result['subclouds'] = []
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cloud_information(self):\n url = \"%s/state/teams/%s/cloud\" % (self.url, self.identifier, )\n return perform_request(url)",
"def show_private_cloud(client, private_cloud, location):\n return client.get(private_cloud, location)",
"def getting_info(self, cloud_path):\n\t\telog(\"getting inf... | [
"0.6381916",
"0.6156021",
"0.6005347",
"0.5974986",
"0.59666353",
"0.5932248",
"0.5835864",
"0.56580114",
"0.5640536",
"0.5608603",
"0.5590534",
"0.55747557",
"0.5502725",
"0.54266745",
"0.53677464",
"0.5365587",
"0.5317455",
"0.5309048",
"0.52923965",
"0.52414227",
"0.519046... | 0.65140164 | 0 |
Create a new subcloud. | def post(self, subcloud_ref=None, qualifier=None):
context = restcomm.extract_context_from_environ()
if subcloud_ref is None:
payload = eval(request.body)
if not payload:
pecan.abort(400, _('Body required'))
name = payload.get('name')
if ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def do_overcloud_create(tuskar, args, outfile=sys.stdout):\n overcloud_roles = tuskar.overcloud_roles.list()\n overcloud_dict = create_overcloud_dict(args, overcloud_roles)\n overcloud = tuskar.overclouds.create(**overcloud_dict)\n print_overcloud_detail(overcloud, outfile=outfile)",
"def createSubCo... | [
"0.6277258",
"0.5818628",
"0.58078766",
"0.5735925",
"0.5690465",
"0.5561859",
"0.55411196",
"0.55319256",
"0.55319256",
"0.54515827",
"0.5434961",
"0.54282016",
"0.54041386",
"0.5379939",
"0.535935",
"0.5331922",
"0.53081214",
"0.5296964",
"0.5261467",
"0.525956",
"0.5254205... | 0.7108754 | 0 |
r""" Dialog is method to send messges to users. | def Dialog(self, usrId: int, message: str, keybaord=None):
self.session.method("messages.send",
{
"user_id": usrId,
"keyboard": keybaord,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def alert(self, msg):\r\n messagedialog = Gtk.MessageDialog(self, type=1, buttons=1, message_format=msg)\r\n messagedialog.run()\r\n messagedialog.destroy()",
"def dialog(message, timeout=0, buttons=DIALOGBUTTON_OK):\n warnings.warn(\"This Method moved uwstyle.dialog()\", DeprecationWarnin... | [
"0.671091",
"0.65158796",
"0.63043237",
"0.62783515",
"0.6270365",
"0.62470025",
"0.6136271",
"0.6118671",
"0.6094713",
"0.60610235",
"0.5989061",
"0.5960819",
"0.59547096",
"0.5923431",
"0.59099215",
"0.5885811",
"0.58625066",
"0.58583194",
"0.5829125",
"0.5825792",
"0.57982... | 0.7148442 | 0 |
take raw tweet receveid from stream into dataframe. | def tweet_to_df(tweet):
count = helper("./data")
dict_ = {}
dict_["text"] = tweet.text
dict_["user"] = tweet.user.description
dict_["user_location"] = tweet.user.location
dict_["screem_name"] = tweet.user.screen_name
dict_["account_date_cr"] = tweet.user.created_at
dict_["nb_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fetch_tweets(event):\r\n return pd.read_csv(\"data/tweets/%s.csv\" % event, \r\n dtype={\r\n 'tweet_id': str,\r\n 'in_reply_tweet': str,\r\n 'thread': str,\r\n 'user_id': str,\r\n 'in_reply_user': ... | [
"0.6158354",
"0.5887331",
"0.5759622",
"0.57456875",
"0.526741",
"0.5223173",
"0.52187014",
"0.51563835",
"0.51196",
"0.51054513",
"0.51028097",
"0.5037918",
"0.5022799",
"0.50189",
"0.50117546",
"0.5011563",
"0.5006884",
"0.49508464",
"0.49424398",
"0.4938977",
"0.49200106",... | 0.5895293 | 1 |
Explicitly sets the shapes of the lightcurve and label tensor, otherwise TensorFlow can't infer it. | def set_shape_function(self, lightcurve: tf.Tensor, label: tf.Tensor):
lightcurve.set_shape([self.time_steps_per_example, 1])
label.set_shape([1])
return lightcurve, label | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _set_shapes(self, batch_size, features_in, labels_in):\n features_in['mcts_features'] = tf.reshape(\n features_in['mcts_features'], [batch_size, self._env_state_space],\n name='mcts_feature_reshape')\n\n features_in['policy_features'] = tf.reshape(\n features_in['policy_features'], [... | [
"0.6137845",
"0.60065645",
"0.5872062",
"0.57126576",
"0.5393481",
"0.53474146",
"0.51422065",
"0.51182985",
"0.5107572",
"0.5032816",
"0.50240093",
"0.5020178",
"0.49794286",
"0.4963954",
"0.49477613",
"0.49311468",
"0.4915292",
"0.4882078",
"0.48768413",
"0.4874847",
"0.486... | 0.768438 | 0 |
Prepares the lightcurves for training with several preprocessing and augmenting steps. | def preprocess_and_augment_lightcurve(self, lightcurve: np.ndarray) -> np.ndarray:
lightcurve = self.remove_random_values(lightcurve) # Helps prevent overfitting.
lightcurve = self.roll_lightcurve(lightcurve) # Helps prevent overfitting.
# Current network expects a fixed length.
lightc... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _build_preprocessing(self):\n\n # For now, do nothing\n pass",
"def preprocess(self):\n\n mm_magcoord.add_aacgm_coordinates(self)\n mm_magcoord.add_quasi_dipole_coordinates(self)\n mm_sc.calculate_ecef_velocity(self)\n mm_sc.add_ram_pointing_sc_attitude_vectors(self)\n\n return",... | [
"0.5853681",
"0.5652716",
"0.5586441",
"0.55639637",
"0.5559372",
"0.55316097",
"0.54928076",
"0.5492174",
"0.5487747",
"0.5486643",
"0.54820913",
"0.5477242",
"0.54748636",
"0.546489",
"0.54609436",
"0.54541045",
"0.5415051",
"0.54064196",
"0.5394433",
"0.5393204",
"0.539246... | 0.6309759 | 0 |
Randomly rolls the lightcurve, moving starting elements to the end. | def roll_lightcurve(lightcurve: np.ndarray) -> np.ndarray:
shift = np.random.randint(0, len(lightcurve))
return np.roll(lightcurve, shift) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def roll(self):\n return random.randrange(1, sides + 1)",
"def roll(self):\n\t\treturn randint(1, self.num_sides)",
"def move(self):\n if self._z >= 75:\n a = random.random()\n print(str(a))\n if a < 0.2:\n self._z += 1\n if a > 0.2 and a... | [
"0.6308937",
"0.5868974",
"0.5851354",
"0.58155835",
"0.5804617",
"0.5804617",
"0.5804617",
"0.5804617",
"0.57860935",
"0.57860935",
"0.5687163",
"0.568123",
"0.5665804",
"0.5656522",
"0.5652201",
"0.5631834",
"0.56227976",
"0.5609408",
"0.5596563",
"0.5579034",
"0.55781525",... | 0.72958153 | 0 |
Builds a list of possible criteria for a given tweet image url | def build_criteria_for_image(image_url):
return CriteriaBuilder.image_to_search_criteria_candidates(image_url) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_image_link():\n image_links = set()\n supplemented_keyword = urllib.parse.quote(\n supplemented_keywords[random.randint(0,\n len(supplemented_keywords) - 1)],\n safe='')\n main_keyword = urllib.parse.quote(\n main_keywords[random.ran... | [
"0.5719972",
"0.5613022",
"0.55762494",
"0.5220945",
"0.5181238",
"0.517683",
"0.51250625",
"0.50868136",
"0.5066444",
"0.5054839",
"0.50462866",
"0.50453806",
"0.50050765",
"0.50005877",
"0.4949409",
"0.49419117",
"0.49135473",
"0.49121162",
"0.49065983",
"0.48964915",
"0.48... | 0.7036948 | 0 |
Returns a list of twittersearch.result with the given search results for each candidate | def find_tweets(criteria_candidates):
results = TweetFinder.__get_results(criteria_candidates)
return results | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_search_results(twitter_dict, search_dict):\r\n\r\n search_list = [search_dict['username']] \r\n search_specified_list = []\r\n\r\n for user in search_list:\r\n search_users_list = [user]\r\n \r\n for operation in search_dict['operations']:\r\n search_users_list = se... | [
"0.6786443",
"0.6461131",
"0.6449749",
"0.6402167",
"0.6381735",
"0.6232362",
"0.619198",
"0.6130979",
"0.6125187",
"0.60322547",
"0.60284257",
"0.6014197",
"0.60123754",
"0.59707797",
"0.5924647",
"0.59239054",
"0.5910617",
"0.58979976",
"0.5829122",
"0.5818287",
"0.5793622"... | 0.6826167 | 0 |
Obtain random samples from pred_df and call them samples that do not have neolithic sites in them | def randomSamplingFromDF(site_df, pred_df):
# sample len(site_df) number points from pred_df
rand_sites = random.sample(range(len(pred_df)), len(site_df))
rand_sites_sorted = list(reversed(sorted(rand_sites)))
nonsite_df = pred_df.iloc[rand_sites_sorted]
less_pred_df = pred_df.drop(rand_sites_sorte... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def negative_sampling(data: pd.DataFrame,\n vocab: np.ndarray,\n noise_distribution: list,\n neg_sample_size: int\n ) -> pd.DataFrame:\n \n def samples_generator(word: str\n ) -> List[str]:\n wh... | [
"0.5981191",
"0.5967193",
"0.58507997",
"0.58230144",
"0.57899874",
"0.57562643",
"0.5723299",
"0.5722238",
"0.5689162",
"0.5658051",
"0.5632118",
"0.56263244",
"0.5613833",
"0.56116945",
"0.5548289",
"0.5542219",
"0.5518756",
"0.55116874",
"0.5510275",
"0.55085206",
"0.54868... | 0.7193351 | 0 |
Raise the quantitative term's values to an integer power, i.e. polynomial. | def __pow__(self, power):
try:
power = float(power)
except:
raise ValueError('expecting a float')
if power == int(power):
name = '%s^%d' % (self.name, int(power))
else:
name = '%s^%0.2f' % (self.name, power)
value = Quantitative(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __pow__(self, exponent):\n return self.runtime.pow(self, exponent)",
"def __pow__(self, exponent):\n return Quantity(pow(self._value, exponent), pow(self.unit, exponent))",
"def __pow__(self, power):\n\n try:\n power = float(power)\n except:\n raise ValueEr... | [
"0.6837971",
"0.67961013",
"0.6763757",
"0.66937846",
"0.6623749",
"0.66045123",
"0.660015",
"0.65881026",
"0.65583694",
"0.65102786",
"0.6501719",
"0.64707184",
"0.6433635",
"0.64150035",
"0.6349218",
"0.63410777",
"0.63376534",
"0.6324819",
"0.63147056",
"0.6307297",
"0.629... | 0.68291706 | 1 |
Factor is initialized with keys, representing all valid levels of the factor. | def __init__(self, termname, keys, ordinal=False):
if not ordinal:
self.keys = list(set(keys))
self.keys.sort()
else:
self.keys = keys
if len(set(keys)) != len(list(keys)):
raise ValueError('keys for ordinal Factor should be unique, in inc... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, poss_keys, poss_vals):\n self.Poss_Tree = {x: list(POSS_DIGITS) for x in poss_keys}\n self.place = len(str(poss_keys[0]))",
"def factors(self, name):\n val_loc = self._get_value_loc(name)\n factors = OrderedDict()\n for val in val_loc:\n f = val.ge... | [
"0.5926843",
"0.5815458",
"0.57676935",
"0.57458484",
"0.5718854",
"0.5558079",
"0.5531594",
"0.55071265",
"0.5450327",
"0.54118156",
"0.5399657",
"0.5393091",
"0.53577244",
"0.5311729",
"0.5306964",
"0.5304899",
"0.52516556",
"0.524584",
"0.52402365",
"0.5225359",
"0.5224217... | 0.5946812 | 0 |
Verify that all values correspond to valid keys in self. | def verify(self, values):
s = set(values)
if not s.issubset(self.keys):
raise ValueError('unknown keys in values') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def verify(self, values):\n s = set(values)\n if not s.issubset(self.keys):\n raise ValueError, 'unknown keys in values'",
"def is_valid(self):\n\n # Test whether every element in required_keys is in actual_keys\n actual_keys = set(self.fields.keys())\n required_keys... | [
"0.79676634",
"0.7523778",
"0.7267099",
"0.70457435",
"0.70228183",
"0.68855286",
"0.68023276",
"0.6781746",
"0.6705627",
"0.65737057",
"0.6545705",
"0.6543366",
"0.6543026",
"0.6543026",
"0.65038353",
"0.6500311",
"0.64711374",
"0.64711374",
"0.64206946",
"0.6416924",
"0.638... | 0.79266214 | 1 |
Formula(self) + Formula(other) When adding \'intercept\' to a factor, this just returns Formula(self, namespace=self.namespace) | def __add__(self, other):
if isinstance(other, Term) and other.name is 'intercept':
return Formula(self, namespace=self.namespace)
else:
return Term.__add__(self, other) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __add__(self, other):\n \n if other.name is 'intercept':\n return formula(self, namespace=self.namespace)\n else:\n return term.__add__(self, other)",
"def __add__(self, other):\n\n other = Formula(other)\n terms = self.terms + other.terms\n pie... | [
"0.892706",
"0.7850612",
"0.7582543",
"0.7247086",
"0.6729214",
"0.6699146",
"0.6654158",
"0.6565891",
"0.6484925",
"0.64614576",
"0.6342464",
"0.63215107",
"0.6316699",
"0.62675995",
"0.62595725",
"0.62517965",
"0.6236327",
"0.6232033",
"0.62143403",
"0.61953527",
"0.6192967... | 0.90075254 | 0 |
Return the 'main effect' columns of a factor, choosing an optional reference key. The reference key can be one of the keys of the Factor, or an integer, representing which column to remove. It defaults to 0. | def main_effect(self, reference=None):
names = self.names()
if reference is None:
reference = 0
else:
try:
reference = self.keys.index(reference)
except ValueError:
reference = int(reference)
def maineffect_func(value... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main_effect(self, reference=None):\n\n if reference is None:\n reference = 0\n\n names = self.names()\n\n def maineffect_func(value, reference=reference):\n rvalue = []\n keep = range(value.shape[0])\n keep.pop(reference)\n for i in ra... | [
"0.4996892",
"0.4893916",
"0.48386535",
"0.4811764",
"0.4706963",
"0.46767664",
"0.46290508",
"0.46205783",
"0.44753227",
"0.44314414",
"0.44152927",
"0.4411382",
"0.43374035",
"0.43291432",
"0.43158427",
"0.43082914",
"0.43082914",
"0.42838398",
"0.42731515",
"0.42687482",
"... | 0.5115011 | 0 |
String representation of list of termnames of a formula. | def __str__(self):
value = []
for term in self.terms:
value += [term.termname]
return '<formula: %s>' % ' + '.join(value) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_formula_in_list(self):\n return tree_to_string(self.expression)",
"def termnames(self):\n\n names = []\n for term in self.terms:\n names += [term.termname]\n return names",
"def termnames(self):\n\n names = []\n for term in self.terms:\n n... | [
"0.69266677",
"0.68499625",
"0.68499625",
"0.64276206",
"0.6309525",
"0.6309525",
"0.6289808",
"0.60963464",
"0.58912927",
"0.58158964",
"0.58133405",
"0.579924",
"0.5791099",
"0.57738787",
"0.57626975",
"0.57447326",
"0.5739617",
"0.57184756",
"0.5633028",
"0.5621945",
"0.55... | 0.7957115 | 0 |
Create (transpose) of the design matrix of the formula within namespace. Extra arguments are passed to each term instance. If the formula just contains an intercept, then the keyword argument 'nrow' indicates the number of rows (observations). | def __call__(self, *args, **kw):
if 'namespace' in kw:
namespace = kw['namespace']
else:
namespace = self.namespace
allvals = []
intercept = False
iindex = 0
for t in self.terms:
t = copy.copy(t)
t.namespace = namespace
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __call__(self, *args, **kw):\n\n if 'namespace' in kw:\n namespace = kw['namespace']\n else:\n namespace = self.namespace\n \n\n allvals = []\n intercept = False\n iindex = 0\n for t in self.terms:\n\n t.namespace = namespace... | [
"0.61720544",
"0.5275372",
"0.5216206",
"0.51585174",
"0.5141125",
"0.50233305",
"0.49952924",
"0.49952924",
"0.49816874",
"0.4925911",
"0.48947468",
"0.48677468",
"0.48216242",
"0.48089668",
"0.4760504",
"0.47341752",
"0.47339922",
"0.47330117",
"0.46915984",
"0.46374306",
"... | 0.6225268 | 0 |
Determine whether a given term is in a formula. | def hasterm(self, query_term):
if not isinstance(query_term, Formula):
if isinstance(query_term, string_types):
try:
query = self[query_term]
return query.termname in self.termnames()
except:
return False
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hasterm(self, query_term):\n\n if not isinstance(query_term, formula):\n if type(query_term) == type(\"name\"):\n try: query = self[query_term]\n except: return False\n elif isinstance(query_term, term):\n return query_term.termname in s... | [
"0.7291431",
"0.6615992",
"0.63654065",
"0.6328823",
"0.6289445",
"0.62756157",
"0.62110174",
"0.60039693",
"0.5977211",
"0.5941926",
"0.5867839",
"0.586434",
"0.5817701",
"0.5814318",
"0.5751372",
"0.57293576",
"0.5700423",
"0.568234",
"0.5663981",
"0.5624077",
"0.56082124",... | 0.7191981 | 1 |
Return a list of the indices of all columns associated to a given term. | def termcolumns(self, query_term, dict=False):
if self.hasterm(query_term):
names = query_term.names()
value = {}
for name in names:
value[name] = self._names.index(name)
else:
raise ValueError('term not in formula')
if dict:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def indices_for_column(self, colname):\n rv = []\n\n fieldid = self.attrs[colname]\n\n for index in self.indices:\n if index.columns[0] == fieldid:\n rv.append(index)\n\n # TODO: New indices\n\n return rv",
"def termcolumns(self, query_term, dict=False... | [
"0.6974512",
"0.6489588",
"0.634191",
"0.6214408",
"0.61922437",
"0.61877096",
"0.610803",
"0.59453714",
"0.5941658",
"0.58720946",
"0.5815702",
"0.5770179",
"0.576646",
"0.57438403",
"0.5735558",
"0.57219255",
"0.5706351",
"0.57011116",
"0.56981784",
"0.5687769",
"0.56733966... | 0.6924449 | 1 |
Return a list of the names in the formula. The order of the names corresponds to the order of the columns when self is evaluated. | def names(self):
allnames = []
for term in self.terms:
allnames += term.names()
return allnames | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_column_names(self):\n names = []\n names.append(self.question_column + \"_agree_lot\")\n names.append(self.question_column + \"_agree_little\")\n names.append(self.question_column + \"_neither\")\n names.append(self.question_column + \"_dis_little\")\n names.append... | [
"0.6978195",
"0.6668148",
"0.6560185",
"0.65295213",
"0.6467635",
"0.64270437",
"0.6383126",
"0.6363696",
"0.6346294",
"0.633791",
"0.6307332",
"0.6303675",
"0.62803394",
"0.62780005",
"0.62708455",
"0.62452453",
"0.6240283",
"0.6224373",
"0.6216947",
"0.6202079",
"0.61605483... | 0.66823804 | 1 |
Return a list of the term names in the formula. These are the names of each term instance in self. | def termnames(self):
names = []
for term in self.terms:
names += [term.termname]
return names | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def names(self):\n\n allnames = []\n for term in self.terms:\n allnames += term.names()\n return allnames",
"def names(self):\n\n allnames = []\n for term in self.terms:\n allnames += term.names()\n return allnames",
"def terms(self):\n ret... | [
"0.8022005",
"0.8022005",
"0.6990429",
"0.6694842",
"0.6694842",
"0.6694842",
"0.6694842",
"0.6694842",
"0.6694842",
"0.6694842",
"0.6694842",
"0.6694842",
"0.66725796",
"0.6669108",
"0.6669108",
"0.66505086",
"0.661695",
"0.6545174",
"0.6503503",
"0.6435962",
"0.6298151",
... | 0.8274434 | 0 |
This returns a formula whose columns are the pairwise product of the columns of self and other. | def __mul__(self, other, nested=False):
other = Formula(other)
selftermnames = self.termnames()
othertermnames = other.termnames()
I = len(selftermnames)
J = len(othertermnames)
terms = []
termnames = []
for i in range(I):
for j in range(J... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __mul__(self, othertr):\n res = self.dot(othertr)\n return res",
"def __mul__(self, other, nested=False):\n\n other = formula(other, namespace=self.namespace)\n\n selftermnames = self.termnames()\n othertermnames = other.termnames()\n\n I = len(selftermnames)\n ... | [
"0.64140505",
"0.63255924",
"0.6279798",
"0.6277444",
"0.6248262",
"0.62374085",
"0.6095252",
"0.6049075",
"0.6034012",
"0.6012328",
"0.59264356",
"0.5915682",
"0.5843071",
"0.5842043",
"0.5837421",
"0.5814968",
"0.5803651",
"0.57777655",
"0.5762164",
"0.57367915",
"0.5723196... | 0.6386615 | 1 |
Return a formula with all terms in other removed from self. If other contains term instances not in formula, this function does not raise an exception. | def __sub__(self, other):
other = Formula(other)
terms = copy.copy(self.terms)
for term in other.terms:
for i in range(len(terms)):
if terms[i].termname == term.termname:
terms.pop(i)
break
f = Formula(terms)
f... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __sub__(self, other):\n\n other = formula(other, namespace=self.namespace)\n terms = copy.copy(self.terms)\n\n for term in other.terms:\n for i in range(len(terms)):\n if terms[i].termname == term.termname:\n terms.pop(i)\n br... | [
"0.8369117",
"0.7235107",
"0.6456491",
"0.6246613",
"0.59090024",
"0.59075487",
"0.583818",
"0.5830051",
"0.5789227",
"0.57837075",
"0.5763275",
"0.57111454",
"0.5702665",
"0.57007825",
"0.5649963",
"0.5625294",
"0.56151897",
"0.5607506",
"0.5577634",
"0.5573287",
"0.5572609"... | 0.8258985 | 1 |
Output all pairwise interactions of given order of a sequence of terms. The argument order is a sequence specifying which order of interactions should be generated the default creates main effects and twoway interactions. If order is an integer, it is changed to range(1,order+1), so order=3 is equivalent to order=[1,2,... | def interactions(terms, order=[1,2]):
l = len(terms)
values = {}
if np.asarray(order).shape == ():
order = lrange(1, int(order)+1)
# First order
for o in order:
I = np.indices((l,)*(o))
I.shape = (I.shape[0], np.product(I.shape[1:]))
for m in range(I.shape[1]):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def diff(self, order=1):\n order = int(order)\n if order < 0:\n raise ValueError(\"order must be >= 0, got %d\" % order)\n\n if order == 0:\n return self.__call__\n\n if order > self.p: # identically zero, but force the same output format as in the general case\n ... | [
"0.50208193",
"0.49593326",
"0.48951837",
"0.48186675",
"0.47466713",
"0.46223867",
"0.45471212",
"0.4546781",
"0.45429128",
"0.45283663",
"0.44752872",
"0.44683182",
"0.4408208",
"0.4404306",
"0.43998128",
"0.43998128",
"0.43941587",
"0.43856522",
"0.43695247",
"0.43439233",
... | 0.69528484 | 0 |
Displays all process along with Ports and Process IDS | def display_port(self):
ports=os.popen("sudo netstat -ntlp").read().strip().splitlines()[2:]
for port in ports:
split=re.split('[\s]+',port)
self.portDic["Protcol"]=split[0]
self.portDic["Receive Q"]=split[1]
self.portDic["Send Q"]=split[2]
spl... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _showProcessList(self, procs):\n device_name = self._devId\n proc_list = ['%s %s %s' % (pid, name, args) for pid, (name, args) in sorted(procs)]\n proc_list.append('')\n log.info(\"#===== Processes on %s:\\n%s\", device_name, '\\n'.join(proc_list))",
"def print_process_list(self) ... | [
"0.725191",
"0.6919943",
"0.6882458",
"0.6662438",
"0.6527916",
"0.6403569",
"0.6377524",
"0.6372277",
"0.6365713",
"0.62965727",
"0.6290927",
"0.61608934",
"0.6155275",
"0.61273324",
"0.6119863",
"0.6109947",
"0.60304934",
"0.6015953",
"0.60154057",
"0.6005746",
"0.59994674"... | 0.6956632 | 1 |
Kill Process with given process ID `PID` Process ID | def kill_process(self,PID):
os.system("sudo kill {}".format(PID))
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def kill(pid):\n p = psutil.Process(pid)\n\n try:\n p.kill()\n except Exception:\n pass",
"def processKill(uPid):\n return processTerminate(uPid);",
"def _KillProcess(self, pid):\n if sys.platform.startswith('win'):\n process_terminate = 1\n handle = ctypes.windll.kernel3... | [
"0.7816297",
"0.773752",
"0.77095354",
"0.7672007",
"0.76110274",
"0.7358674",
"0.73388183",
"0.7314189",
"0.72366554",
"0.71744215",
"0.703986",
"0.6969621",
"0.6960862",
"0.6879827",
"0.6843893",
"0.67791253",
"0.670096",
"0.6696248",
"0.6672676",
"0.66505",
"0.6650049",
... | 0.7942027 | 0 |
Returns the first found packet with the given reportID while keeping the rest of the packets on the queue in the correct order. | def get_packet_withreportID(self, reportID, timeout=0.01):
# check if we've got a correct packet in the queue
incorrect_packets = []
correct_pkt = None
start_time = time.time()
while time.time() < start_time + timeout:
pkt = self.get_packet()
if pkt:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send_report(self, report_ID, payload=None):\n if report_ID < 0 or report_ID > 127:\n raise ValueError(\"Report ID {} is out of the valid range!\".format(report_ID))\n\n self._serial_write(self.MAGIC_NUM_0)\n self._serial_write(self.MAGIC_NUM_1)\n self._serial_write(self.M... | [
"0.5876091",
"0.55140936",
"0.545259",
"0.5442561",
"0.5426714",
"0.52965784",
"0.52956307",
"0.52622616",
"0.5228871",
"0.5184876",
"0.51326233",
"0.50348186",
"0.4981323",
"0.49604148",
"0.49549568",
"0.4922734",
"0.49177262",
"0.4852774",
"0.483061",
"0.48110393",
"0.47965... | 0.7943378 | 0 |
Writes `values_to_write` to the serial port. | def _serial_write(self, values_to_write):
if self.verbose:
self.log("Writing 0x{:x} to serial port...".format(values_to_write))
if type(values_to_write) is not list:
self.serial.write(bytearray([values_to_write]))
else:
self.serial.write(bytearray(values_to_wr... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write(self, values, file_obj, format=None):\n pass",
"def _spi_write(self, dc, values):\n self._gpio.output(self.cs_pin, 0)\n self._gpio.output(self.dc_pin, dc)\n\n if type(values) is str:\n values = [ord(c) for c in values]\n\n for byte_value in values:\n ... | [
"0.66824037",
"0.6468341",
"0.6362898",
"0.62047505",
"0.6188161",
"0.6069787",
"0.60293794",
"0.6015024",
"0.5997377",
"0.5970137",
"0.5953444",
"0.5944348",
"0.5928449",
"0.58901906",
"0.58859426",
"0.5849831",
"0.5816865",
"0.5813451",
"0.5778106",
"0.57472885",
"0.5656866... | 0.86318475 | 0 |
reads `num_bytes` from the serial port. | def _serial_read(self, num_bytes):
out = self.serial.read(num_bytes)
if len(out) != num_bytes:
self.log("WARNING: Didn't get the expected number of bytes")
self.log(" Received {}, expected {}. Serial port dead?".format(len(out), num_bytes))
out_list = [int(v) for v in... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read(self, num_bytes_to_read):\n pass",
"def read_bytes(self, number_of_bytes):\n\n self.index = -1\n data = self.buf[self.offset:self.offset + number_of_bytes]\n self.offset += number_of_bytes\n\n return data",
"async def read(self, num_bytes=0) -> bytes:\n if... | [
"0.75836605",
"0.7325011",
"0.7147769",
"0.7057854",
"0.7018971",
"0.68422747",
"0.6747512",
"0.64437133",
"0.6420467",
"0.6404139",
"0.64017504",
"0.63769394",
"0.6248493",
"0.6245583",
"0.62369466",
"0.62223905",
"0.6211439",
"0.62023777",
"0.61807936",
"0.6122951",
"0.6094... | 0.7343166 | 1 |
Clears the serial buffer of anything received. | def _serial_clear(self):
self.serial.reset_input_buffer() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clear_in_serial_buffer(self):\n if self.serial.inWaiting():\n resp = self.serial.readall()\n log.warn(\"Unknown/unparsed serial response: %s\", resp)",
"def clearBuffer(self):\n self.buffer = b''\n self._linesReceived = []\n self._lineBuffer = b''",
"def _c... | [
"0.84202254",
"0.81880486",
"0.8017563",
"0.77988154",
"0.77487266",
"0.7468556",
"0.74253863",
"0.73461974",
"0.7287638",
"0.7238226",
"0.7233992",
"0.72171247",
"0.7203294",
"0.7098728",
"0.7098728",
"0.70947367",
"0.7071002",
"0.706498",
"0.7038408",
"0.6951526",
"0.693798... | 0.84938765 | 0 |
The threaded listener that looks for packets from Pensel. | def _listener(self):
while self.thread_run.is_set():
if self._serial_bytes_available() >= len(self.MAGIC_HEADER) and \
self._check_for_start():
report, retval, payload = self._receive_packet()
if report >= 0:
self.queue.put((rep... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def listener(localSearchForFile):\n for con in listenForConnection(GLOBALS.LOCAL_PORT):\n if con == -1: return -1\n\n if GLOBALS.DEBUG_MODE: print(\"[info] Linear lib: received connection\")\n\n # spawn connection handler thread\n superPeer = Thread(target = superPeerConnection, args=[con, localSearch... | [
"0.6188723",
"0.6181703",
"0.6155212",
"0.61097896",
"0.60706186",
"0.60596853",
"0.60125685",
"0.6005501",
"0.592774",
"0.5900257",
"0.5859468",
"0.577193",
"0.57254094",
"0.56806195",
"0.56681275",
"0.56416494",
"0.56133914",
"0.560342",
"0.5548568",
"0.5541672",
"0.5541235... | 0.62927926 | 0 |
Serializes session to buffer | def vscr_ratchet_group_session_serialize(self, ctx):
vscr_ratchet_group_session_serialize = self._lib.vscr_ratchet_group_session_serialize
vscr_ratchet_group_session_serialize.argtypes = [POINTER(vscr_ratchet_group_session_t)]
vscr_ratchet_group_session_serialize.restype = POINTER(vsc_buffer_t)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def serialize(self) -> str:\n return json.dumps([session.to_dict() for session in self.sessions])",
"def save_session(session, path):\n with open(path, 'w', encoding='utf-8') as f:\n json.dump(session, f, ensure_ascii=False, indent=4, cls=classes.CustomEncoder)",
"def save_to_session(self, ser... | [
"0.65804774",
"0.6362454",
"0.61549973",
"0.61451703",
"0.5916309",
"0.5916149",
"0.5871953",
"0.5779407",
"0.57596093",
"0.57299167",
"0.5727005",
"0.5723597",
"0.57071483",
"0.56273746",
"0.56186277",
"0.5615529",
"0.56047714",
"0.55918837",
"0.5528991",
"0.5525956",
"0.550... | 0.64907396 | 1 |
This function performs a variety of slicing operations based on the given task parameter. | def Slice(seq, task):
if task == 'swapfirstlast' and len(seq) >= 2:
seq = seq[-1:] + seq[1:-1] + seq[:1]
elif task == 'removeeveryother':
seq = seq[::2]
elif task == 'reverse':
seq = seq[::-1]
elif task == 'reorder':
onethird = (len(seq) / 3)
remainder = (len(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def simple_slice():\n examples = [\n benchmark.Example(\n inputs=[\n [[12, 34, 56, 78], [-1, -2, -3, -4]],\n -1,\n ],\n output=[[34, 56], [-2, -3]],\n ),\n ]\n constants = []\n description = 'Slice a tensor'\n target_program = 'in1[:, 1:in2]'\n s... | [
"0.6612952",
"0.57252514",
"0.55938196",
"0.5583914",
"0.55479294",
"0.5539142",
"0.54901874",
"0.54826033",
"0.5461477",
"0.5425997",
"0.53798646",
"0.53485817",
"0.5332608",
"0.5315734",
"0.5297336",
"0.5265292",
"0.5263417",
"0.52609426",
"0.52609426",
"0.5229619",
"0.5202... | 0.7156067 | 0 |
CDF for the skewgaussian. Additional safety to filter out large arguments. | def single_peak_cdf(x, mean, sigma, alpha):
z = np.clip((x-mean)/sigma, -10, 10)
return skewnorm.cdf(z, alpha) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gaussian_cdf(x, _erf=erf):\n return (1 + _erf(x / math.sqrt(2))) / 2",
"def cdf(X, parameters):\n check_data_type_column_data(X)\n check_model_params_dict(parameters)\n\n sigma = (1.0/parameters['rho'])**.5\n\n return norm.cdf(X,parameters['mu'],sigma)",
"def std_norm_cdf(x):... | [
"0.65131265",
"0.6186629",
"0.6161622",
"0.6146133",
"0.6136695",
"0.6125919",
"0.6050933",
"0.60233885",
"0.60069877",
"0.59550256",
"0.5927398",
"0.5910854",
"0.5899473",
"0.5862627",
"0.58616513",
"0.5841404",
"0.5840815",
"0.58182883",
"0.5798016",
"0.5798016",
"0.5788954... | 0.63566905 | 1 |
Function to fit vdistributions in partial copula by beta(a,1) cdfs. | def fu_fit(fu, v):
popt, pcov = curve_fit(
lambda v, a : beta.cdf(v, a, 1),
v, fu,
p0 = (1,)
)
chi2 = np.sum((beta.cdf(v, *popt, 1) - fu)**2 / (len(v)-2))
res = np.zeros(len(popt)+1)
res[0:1] = popt
res[1] = math.sqrt(chi2)
return res | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def V_fit(x, a, b, c, d, e, f):\n x1 = x[0] # I\n x2 = x[1] # dT\n m = (a * x1 ** 2 + b * x1 + c)\n b = (d * x1 ** 2 + e * x1 + f)\n return m * x2 + b",
"def fitfunc_Coulomb_wF(a_x, a_p1, a_p2):\n \n # 4.27014423267 = sqrt(18.2341317678 fm^-2) (= sqrt(0.71 GeV^2))\n # 1.43996507808 = 197.... | [
"0.5953164",
"0.5694468",
"0.5640919",
"0.56255734",
"0.5607747",
"0.55408704",
"0.551601",
"0.54907",
"0.5482917",
"0.5444024",
"0.54390156",
"0.5406749",
"0.5400015",
"0.53816324",
"0.53800315",
"0.5361456",
"0.5336376",
"0.5291689",
"0.5291689",
"0.5280807",
"0.5275895",
... | 0.6380507 | 0 |
This is the periodic component for u in , with peaks derived from margin fit, shift and first shape parameter for the beta kernel. | def beta_periodic(u, shift, n, peaks):
res = np.zeros_like(u)
safe_n = min(50, max(1.1,n))
safe_shift = min(0.05, max(-0.05, shift))
size = np.mean(np.diff(peaks))
for m in peaks:
z = (u - m + safe_shift)/size
indices = np.abs(z) < 0.5
res[indices] += 0.5 * (beta.pdf(0.5 + z[... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __call__(self, u):\n # get index of grid point left of u\n index = self.get_index(u)\n # get current controlpoints\n current_controlpoints = self.get_controlpoints(index)\n # setup matrix to store the values in the de Boor array:\n # deBoorvalues =\n # ... | [
"0.5633326",
"0.53691405",
"0.5280884",
"0.519096",
"0.51834625",
"0.51490057",
"0.50876623",
"0.50546724",
"0.5012297",
"0.5001122",
"0.49511448",
"0.4948063",
"0.49467683",
"0.4946201",
"0.49404076",
"0.49395758",
"0.49327973",
"0.4920169",
"0.49003652",
"0.48976943",
"0.48... | 0.66574705 | 0 |
kolmogorov distance is the maximum distance between two probability distributions. This calculates the KD of two pdfs in the form of numpy arrays. | def kolmogorov_distance(pdfx, pdfy):
cdfx = np.cumsum(pdfx)/np.sum(pdfx)
cdfy = np.cumsum(pdfy)/np.sum(pdfy)
return np.max(np.abs(cdfx - cdfy)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def distance(p0, p1):\n return( numpy.sqrt( (p0[0]-p1[0])**2 + \n (p0[1]-p1[1])**2 + \n (p0[2]-p1[2])**2 ) )",
"def dist(p1,p2):\n\n return sqrt((p1[0] - p2[0])**2 + (p1[1] - p2[1])**2)",
"def distance (p1,p2):\n return np.sqrt(np.sum(np.power(p2-p1,2)))",
"de... | [
"0.6695389",
"0.6530534",
"0.6528139",
"0.6474828",
"0.64736056",
"0.6458455",
"0.6420905",
"0.63969034",
"0.63817",
"0.6379324",
"0.6358662",
"0.6355999",
"0.63409716",
"0.63376147",
"0.6327973",
"0.63198674",
"0.6312635",
"0.6306476",
"0.62971365",
"0.6286765",
"0.6282493",... | 0.7690672 | 0 |
Simple reconnoisance tool to harvest comments in webpages | def main(u, o):
click.echo(f"Web crawling on {u} started successfully...")
comment_regex = re.compile('<!--(.*?-->)')
with requests.Session() as session:
resp = session.get(u)
soup = BeautifulSoup(resp.text, 'lxml')
#TODO: search for hidden attributes, may be useful
comment... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def comment():",
"def test_print_comments():\n flat_comments, tree_comments = get_comments_from_submission_id('jrjn70')\n print(len(flat_comments))\n print(len(tree_comments))\n\n print('flat comments')\n for c in flat_comments[0:5]:\n comment_instance = REDDIT.comment(c)\n print(com... | [
"0.65669584",
"0.6525056",
"0.6505806",
"0.6469335",
"0.6297864",
"0.6289731",
"0.62210983",
"0.6215077",
"0.61902016",
"0.6184528",
"0.6149626",
"0.61480325",
"0.61391455",
"0.6130129",
"0.60489833",
"0.60166967",
"0.6005638",
"0.6002507",
"0.59990406",
"0.59586626",
"0.5936... | 0.7606145 | 0 |
Scrape charlesriverapparel.com. If url is set, scrape only item in the url If url_to_scrape is not set, returns list of itemInfo dict If url_to_scrape is set, returns itemInfo dict | def scrape(url_to_scrape=None, cached_data=None):
all_items = []
if cached_data:
cat_dict = cached_data['categories_dict']
else:
cat_dict = _traverse_categories() # {item_id: { 'id': item_id, 'category_list': [categories], 'url': item_url } }
category_list = None
brand = ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def single_crawl(self, urlitem: str):\n # print(\"Item: \", urlitem)\n try:\n hdr = {\n \"User-Agent\": \"Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36 \",\n \"Accept\": \"text/html,application/xhtml+xml,a... | [
"0.65837955",
"0.62235403",
"0.6197151",
"0.6080949",
"0.59467924",
"0.5946328",
"0.5896769",
"0.58487123",
"0.5833526",
"0.58186036",
"0.57552403",
"0.5735235",
"0.5734194",
"0.570501",
"0.56573653",
"0.5643743",
"0.5621614",
"0.5603681",
"0.560318",
"0.56009895",
"0.5574103... | 0.70564085 | 0 |
Downloads the detection model from tensorflow servers | def download_model(\
download_base='http://download.tensorflow.org/models/object_detection/', \
model_name='ssd_mobilenet_v1_coco_11_06_2017'\
):
# add tar gz to the end of file name
model_file = model_name + '.tar.gz'
try:
opener = urllib.request.URLopener()
opener.retrieve(do... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def download_model_from_gcs(self):\n # download model\n download_file_from_gcs(self.config.model_bucket_name,\n self.config.model_gcs_path,\n self.config.model_local_path)\n\n # download lable columns\n download_file_from_gcs(s... | [
"0.6803891",
"0.6580865",
"0.6538049",
"0.6379923",
"0.63532656",
"0.6349845",
"0.63104683",
"0.62438935",
"0.6224687",
"0.6155579",
"0.6152166",
"0.6123481",
"0.6121159",
"0.6108375",
"0.6105838",
"0.60727674",
"0.60591805",
"0.60474735",
"0.6028902",
"0.59698546",
"0.595215... | 0.75390905 | 0 |
binning and binarise outputs a csv into "cleaned" folder "_bin" | def bin_binarise(self):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _binarization(self):\n for feat in self.cat_feats:\n lbl = preprocessing.LabelBinarizer()\n lbl.fit(self.dataframe[feat].values)\n val = lbl.transform(self.dataframe[feat].values)\n self.dataframe_d_copy = self.dataframe_d_copy.drop(feat,axis=1)\n \... | [
"0.64596856",
"0.6200215",
"0.6026526",
"0.57897776",
"0.55271953",
"0.5480028",
"0.54477143",
"0.54473263",
"0.5424563",
"0.53364795",
"0.5334798",
"0.53143245",
"0.5308128",
"0.5306266",
"0.5300616",
"0.53005636",
"0.5279393",
"0.5272336",
"0.5262879",
"0.52385354",
"0.5228... | 0.6602217 | 0 |
returns row indices where more than threshold entries are missing, e.g. 0.5 | def _remove_non_informative_rows(self, df, threshold):
df_tmp = pd.DataFrame()
n_features = len(df.columns)
# calculating ratio of rows that have more than "ratio" missing values
df_tmp['ratio'] = df.apply(lambda row: row.isnull().sum()/n_features, axis='columns')
# kick too noi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def filterMissings(self, threshold, data):\n\n #replace NAs by 0 for counting\n data.fillna(0).astype(bool).sum(axis=1)\n\n filtered_columns = data.columns\n\n\n #find out threshold, i.e. minimum number of non-zero in real numbers\n rowNumber = data.shape[0]\n min_nonZeros... | [
"0.6818863",
"0.6373628",
"0.6308382",
"0.6293913",
"0.62112623",
"0.6198604",
"0.6150571",
"0.6133567",
"0.5942086",
"0.5931809",
"0.5892998",
"0.58830494",
"0.5831952",
"0.58169055",
"0.58158576",
"0.57656103",
"0.5757377",
"0.5756951",
"0.5692738",
"0.5690874",
"0.568918",... | 0.6447905 | 1 |
creates a dataframe with r samples for each feature | def _get_sample_df(self, df, features, r):
grouped = df.groupby('feature')
df_sample = pd.DataFrame()
for feature in features:
group = grouped.get_group(feature)
samples = group.sample(n=r)
df_sample = df_sample.append(samples)
return df_sample | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_dataframe_for_training(data):\n feature_column_name = 'X'\n #data_cp = data[['label']].copy()\n for i, row in tqdm(data.iterrows(), total=len(data)):\n all_features = f'{row.claimant} {row.claim} {row.article_content}'\n data.loc[i, feature_column_name] = all_features\n\n retur... | [
"0.66862357",
"0.6420824",
"0.6418054",
"0.6401807",
"0.6305013",
"0.61754525",
"0.61719656",
"0.6149171",
"0.6146527",
"0.6113724",
"0.60907054",
"0.60811317",
"0.6028008",
"0.60071933",
"0.60071933",
"0.59889555",
"0.59559",
"0.5942348",
"0.5926523",
"0.59253466",
"0.591285... | 0.8428525 | 0 |
Aggregates crowd answers and evaluates for all crowd answers | def evaluate_crowd_all_answers(self, mode=CSFSCrowdAggregator.Mode.EXTENDED, fake_features={}):
df_clean = CSFSCrowdCleaner(self.path_questions, self.path_answers_raw, self.target).clean()
for f in fake_features:
df_clean = df_clean.append({'answer': fake_features[f], 'answerUser': 'FAKE', '... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def evaluate_question(self):\n self.get_question_fequency()\n self.count_answers()",
"def evaluate_questions(self):\n for question in self.question_list:\n question.evaluate_question()",
"def run_compute_reread_counts(self):\n questions = []\n contexts = []\n ... | [
"0.610443",
"0.5850755",
"0.5820487",
"0.58010185",
"0.57327366",
"0.56864023",
"0.5647703",
"0.56394255",
"0.55239356",
"0.551901",
"0.5397282",
"0.53928953",
"0.5356523",
"0.5340461",
"0.5325382",
"0.5309455",
"0.52819633",
"0.5268165",
"0.52674896",
"0.52351356",
"0.522711... | 0.59926075 | 1 |
Appends n user answers for feature with given value to df | def _append_fake_user_answers(self, df, feature, value, n=1):
data = {'answer': value, 'answerUser': 'FAKE', 'feature': feature}
df = df.append([data]*n, ignore_index=True) # need to append it several times in order to allow random selection
return df | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def nunique_stats(df, df_history, uid_key, value, feat):\n add = pd.DataFrame(df_history.groupby(uid_key)[value].nunique()).reset_index()\n add = add.rename(columns={value: feat})\n df = pd.merge(df, add, on=uid_key, how='left')\n return df",
"def alspostprocess(data, prediction, features, user_featu... | [
"0.56743383",
"0.56375664",
"0.55274326",
"0.5411185",
"0.53533185",
"0.5296851",
"0.52790606",
"0.5259034",
"0.52224356",
"0.5220007",
"0.5216666",
"0.51741165",
"0.51733893",
"0.51651996",
"0.51016253",
"0.50685185",
"0.5061694",
"0.504281",
"0.5034425",
"0.50202996",
"0.50... | 0.8131136 | 0 |
Calculcates KendallTau Correlation for binary features | def autocorrelation(self):
# For all features calculate kendall's tau with every other feature.
df_bin = pd.read_csv(self.path_bin)
features = sorted(list(df_bin.columns))
df_correlation = pd.DataFrame({f: [np.nan] * len(features) for f in features}, index=features)
for f1 in fea... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculate_feature_corr(self):\n \n return self.train_data.astype(float).corr(method='kendall')",
"def kendall(features, labels):\n n, d = features.shape\n coefficients = np.asarray([stats.kendalltau(features[:, idx], labels,\n method='asymptotic', ... | [
"0.7024077",
"0.60572654",
"0.592135",
"0.57627964",
"0.57089365",
"0.5693804",
"0.56896114",
"0.563734",
"0.558531",
"0.5533107",
"0.5526995",
"0.55004585",
"0.54897",
"0.54560375",
"0.5441303",
"0.54251665",
"0.54239964",
"0.54215145",
"0.54153144",
"0.54020524",
"0.5377469... | 0.65094215 | 1 |
Plots a bar chart for each number of features and condition showing the distribution of AUCs | def crowd_auc_plot(self, auto_open=False):
def get_name(nofeat, cond):
plural = nofeat > 1
return "{} features (condition {})".format(nofeat, cond) if plural else "{} feature (condition {})".format(nofeat, cond)
def get_trace(values, nofeat, cond):
name = get_name(no... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_histogram_assess(assess_input, figure_output):\n\n sns.set_style(\"white\")\n raw_auc = pd.read_table(assess_input, index_col=\"Motif\")\n raw_auc = raw_auc.drop_duplicates()\n # df = df.T.drop_duplicates().T\n raw_auc = raw_auc.sort(columns=\"MNCP\", axis=0, ascending=False)\n labels = ... | [
"0.7165492",
"0.65022504",
"0.6471554",
"0.6354328",
"0.63000333",
"0.6286439",
"0.6243622",
"0.6206506",
"0.6189631",
"0.6127064",
"0.6123013",
"0.6092255",
"0.60813063",
"0.6076884",
"0.60670537",
"0.60670257",
"0.6065567",
"0.60621655",
"0.6054025",
"0.60462296",
"0.604361... | 0.6859097 | 1 |
substring of pattern without the last letter | def prefix(pattern):
return pattern[0:len(pattern)-1] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prefix(pattern):\n return pattern[0:len(pattern)-1]",
"def sufix(pattern):\n return pattern[1:len(pattern)]",
"def without_end(s):\n string = s[1:-1]\n return string",
"def getFinal(endstr):\n if not endstr:\n return ''\n if endstr.endswith('ng'):\n return ... | [
"0.70545506",
"0.69251823",
"0.65390664",
"0.6211243",
"0.61586004",
"0.6141123",
"0.60177153",
"0.5907959",
"0.5879715",
"0.58760023",
"0.57343626",
"0.57218856",
"0.5695807",
"0.5687177",
"0.56706446",
"0.5668733",
"0.5656999",
"0.5640331",
"0.5611039",
"0.5600304",
"0.5589... | 0.70895904 | 0 |
Tests that an org can successfully be renamed. | def test_rename_org(client: Client) -> None:
with dev_login(client, 'admin'):
# Create an org
resp = client.post('api/v1/org', json={
'name': 'testorg12'
})
org_id = resp.json['id']
assert 200 <= resp.status_code <= 300
# Create the second test org
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_rename_org_permissions(client: Client) -> None:\n with dev_login(client, 'admin'):\n # Create an org\n resp = client.post('/api/v1/org', json={\n 'name': 'testorg12'\n })\n assert 200 <= resp.status_code <= 300\n org_id = resp.json['id']\n\n with dev_log... | [
"0.7659885",
"0.6947406",
"0.67307895",
"0.66063076",
"0.65478325",
"0.6541099",
"0.64136106",
"0.6373427",
"0.6351179",
"0.6306828",
"0.6300058",
"0.6207878",
"0.6204783",
"0.61821",
"0.6181979",
"0.6157419",
"0.61501044",
"0.6108966",
"0.610483",
"0.60282815",
"0.6019909",
... | 0.737055 | 1 |
Tests that a user cannot rename an org if they are not an admin | def test_rename_org_permissions(client: Client) -> None:
with dev_login(client, 'admin'):
# Create an org
resp = client.post('/api/v1/org', json={
'name': 'testorg12'
})
assert 200 <= resp.status_code <= 300
org_id = resp.json['id']
with dev_login(client, 'us... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_delete_admin_from_org(self):\n pass",
"def test_add_admin_to_org(self):\n pass",
"def test_get_one_for_other_organization_forbidden(self):\n org = Organization.create(name='foo', program_id=self.program.uid)\n org.put()\n coAdmin = User.create(name='coAdmin', email='... | [
"0.67709506",
"0.6742589",
"0.6593983",
"0.6527626",
"0.64782",
"0.6455436",
"0.64416325",
"0.64155805",
"0.64003736",
"0.63265234",
"0.63119966",
"0.6310905",
"0.63084286",
"0.62969965",
"0.62476504",
"0.62471217",
"0.6205791",
"0.61786944",
"0.6114555",
"0.60967547",
"0.609... | 0.7595818 | 0 |
tax_id is None, defaults to 9606, if 0, means load all supported species, entrez_gene is only used in local mode to accelerate Symbol retrieval | def load(tax_id=9606, l_use_GPDB=True, user_go=None, l_L1k=False):
if tax_id is None:
util.error_msg('tax_id must be an9606 int, or 0 mans all supported species')
tax_id=abs(tax_id)
s_key=Cache.key(l_use_GPDB, l_L1k=l_L1k)
if tax_id!=0 and tax_id in Cache.TOTAL_GENE_COUNT[s_k... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, taxid, species_name = None, lineage=None):\n self.genes = dict()\n self.taxid = taxid\n self.species = species_name\n self.lineage = lineage",
"def fetch_by_id(self, taxon):\n res = self.ensembl.get_taxonomy_by_id(taxon)\n return res",
"def tax_id(se... | [
"0.6346636",
"0.625637",
"0.6142789",
"0.61208576",
"0.60079664",
"0.6005236",
"0.5974465",
"0.59199226",
"0.58072674",
"0.57864153",
"0.5702004",
"0.5685285",
"0.56351686",
"0.55774224",
"0.5565969",
"0.5563953",
"0.5563647",
"0.5512005",
"0.55049115",
"0.5504886",
"0.549050... | 0.6361208 | 0 |
return a dict of GO and the number of genes appear in each GO if S_go is provided, only counts for those go terms | def go_count(self, S_hit, S_go=None):
c={}
if S_go is not None: S_go=set(S_go)
for x in S_hit:
Y=self.GENE_GO.get(x, [])
if S_go is not None: Y = set(Y).intersection(S_go)
for y in Y:
c[y]=c.get(y,0)+1
return c | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gene_count(self, S_go, S_gene=None):\n c={}\n if S_gene is not None: S_gene=set(S_gene)\n for x in S_go:\n Y=self.GO_GENE.get(x, [])\n if S_gene is not None: Y = set(Y).intersection(S_gene)\n for y in self.GO_GENE.get(x, []):\n c[y]=c.get(y,0... | [
"0.8170838",
"0.748599",
"0.59387326",
"0.5920755",
"0.591932",
"0.58161604",
"0.5669939",
"0.5669421",
"0.56335974",
"0.5606092",
"0.55677086",
"0.54992825",
"0.5486521",
"0.5461191",
"0.54585624",
"0.54531324",
"0.5440361",
"0.5438768",
"0.5429132",
"0.5395651",
"0.5392278"... | 0.7851776 | 1 |
return a dict of Gene and the number of GOs appear for each gene if S_gene is provided, only counts for those genes | def gene_count(self, S_go, S_gene=None):
c={}
if S_gene is not None: S_gene=set(S_gene)
for x in S_go:
Y=self.GO_GENE.get(x, [])
if S_gene is not None: Y = set(Y).intersection(S_gene)
for y in self.GO_GENE.get(x, []):
c[y]=c.get(y,0)+1
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def membership_count(self, S_go, S_gene):\n return self.go_count(S_gene, S_go)\n #c=self.go_count(S_gene)\n #if type(S_go)!=set:\n # S_go=set(S_go)\n #c={ k:v for k,v in c.items() if k in S_go }\n #return c",
"def go_count(self, S_hit, S_go=None):\n c={}\n ... | [
"0.76964927",
"0.71774846",
"0.62404954",
"0.5983294",
"0.5660781",
"0.5644812",
"0.5643061",
"0.56363577",
"0.56089014",
"0.5598228",
"0.5502627",
"0.5496427",
"0.5490733",
"0.5489337",
"0.5476215",
"0.5476014",
"0.5450471",
"0.5441512",
"0.5429098",
"0.5408223",
"0.540261",... | 0.8732856 | 0 |
L is a list of [[s_name, S_hit, s_go]], s_go can also be a list | def analyze(L):
rslt=[]
#p=util.Progress(len(L))
i=0
import multiprocessing
s_pid=str(multiprocessing.current_process().pid)
for s_name, S_hit, S_go in L:
i+=1
#if (i % 50000): p.check(i, s_pid)
if ty... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def label(l):\r\n def action(string, loc, tokens):\r\n newlist = [l]\r\n newlist.extend(tokens)\r\n return newlist\r\n return action",
"def scatter_list(self, l):\n pass",
"def Student_names(l:list)->list:\n result=[]\n for s in l:\n result.append(s.name)\n ret... | [
"0.5778658",
"0.56123483",
"0.5564983",
"0.5401471",
"0.53305316",
"0.51975167",
"0.5192305",
"0.5182059",
"0.513531",
"0.5119218",
"0.50108427",
"0.49965453",
"0.49447706",
"0.49369943",
"0.49039128",
"0.48992655",
"0.4888057",
"0.48818138",
"0.48812246",
"0.48663783",
"0.48... | 0.57596344 | 1 |
Look for terms presented in both list and the pvaleu is even better in the combined list S_old is the set of genes in Old set, if None, set to all genes in t_old table This method is to be used by analyze_key_terms. | def key_terms(self, t_old, t_new, t_union, S_old=None, t_over=None):
if t_old is None or t_new is None or t_union is None:
return None
print("Old: %d, New: %d, Union: %d" % (len(t_old), len(t_new), len(t_union)))
if S_old is None:
S_old=set([y for x in [ t_old.ix[i, 'Gen... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fix_missing(self, set_tweets, original_sents):\n res = []\n full_original_sents = [\" \".join(s[\"tokens\"]) for s in original_sents]\n for s1, s2 in zip(set_tweets, full_original_sents):\n if not s1:\n res.append([s2]) # add the original as candidate if no candid... | [
"0.5270499",
"0.5263518",
"0.52220106",
"0.52068335",
"0.51452315",
"0.50743026",
"0.50405735",
"0.5016303",
"0.50064653",
"0.49099362",
"0.48987463",
"0.48954973",
"0.48942754",
"0.48571077",
"0.4847399",
"0.48385495",
"0.48297605",
"0.47905686",
"0.47897458",
"0.47897458",
... | 0.6873936 | 0 |
If self.t_go is None, it cluster the self.data membership matrix and return a dict | def cluster(self, similarity=0.3, l_go_selective=False):
sw=util.StopWatch("GO_Cluster::cluster")
#K=stats.kappa_stat(self.data.values)
#T_edge=pd.DataFrame({'Gene_A':[],'Gene_B':[],'TYPE':[],'SCORE':[]})
M=self.data.values
n,m=M.shape
print("Matrix size: %d genes x %d GO... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cluster(self):\n\t\tself.index[\"cluster\"] = {}\n\n\t\tfor item in self.index[\"items\"]:\n\t\t\tself.index[\"cluster\"][item] = [{\"weight\" : float(len(set(self.index[\"items\"][item]).intersection( set(self.index[\"items\"][id]))))/float(len(self.index[\"items\"][item])) , \"name\" : id, \"authority\" : se... | [
"0.6026801",
"0.59989464",
"0.5909006",
"0.58761305",
"0.5691569",
"0.56816846",
"0.567273",
"0.55920225",
"0.5523509",
"0.55081856",
"0.5492725",
"0.548897",
"0.5476533",
"0.54749143",
"0.5442817",
"0.54381925",
"0.5394746",
"0.53318834",
"0.53260607",
"0.5310842",
"0.530978... | 0.6161217 | 0 |
Construct a GO network, b/c too many nodes will lead to useless networks, we can impose an upper bound on the max_nodes size. We try to take 1 node from each cluster, then 2, then 3, until max_nodes is reached. | def network(self, max_clusters=20, max_members=10, max_nodes=300, l_go_selective=False):
if len(self.data)==0:
return None
if self.DM is None:
util.error_msg('Please run cluster first!')
S_node=GO_Cluster.sample_rows(self.t_go, max_clusters=max_clusters, max_members=max_m... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __createNetwork__(self, amount_nodes, amount_links):\n random.seed()\n numOfNodes = 0\n linksPerIteration = (amount_links-3)/(amount_nodes-3) if amount_nodes > 3 else 1\n #generate n nodes\n while numOfNodes < amount_nodes:\n node = Node(numOfNodes)\n se... | [
"0.70511895",
"0.63774914",
"0.625035",
"0.61599034",
"0.59952337",
"0.5991076",
"0.5991076",
"0.59114605",
"0.5858617",
"0.5844498",
"0.5819003",
"0.58181596",
"0.5803368",
"0.58022726",
"0.57998455",
"0.579773",
"0.5786971",
"0.5779051",
"0.5770885",
"0.57656467",
"0.573997... | 0.737439 | 0 |
Main method for plotting a confusion matrix of an input file. | def main():
parser = ArgumentParser(description='Run BoW experiments.')
parser.add_argument('input', help='csv file')
parser.add_argument('output', help='output path.', default=None)
args = vars(parser.parse_args())
data = np.genfromtxt(args['input'], delimiter=';', dtype=str)
predictions = dat... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_confusion_matrix(conf_matrix_list, labels, cm_file_path):\n\n logging.info(\"run plot_confusion_matrix\")\n\n # construct plot figure with 36 subplots in a square grid\n fig, ax = plt.subplots(6, 6, figsize=(12, 7))\n\n # for each categories' name and confusion matrices\n for axes, cm, labe... | [
"0.6811695",
"0.66890585",
"0.6661385",
"0.6602234",
"0.6555866",
"0.65173465",
"0.65019476",
"0.6501667",
"0.6468689",
"0.6454575",
"0.64506686",
"0.6438366",
"0.64235675",
"0.6412188",
"0.63892514",
"0.63323826",
"0.63196456",
"0.6305887",
"0.62828386",
"0.62782794",
"0.626... | 0.6841279 | 0 |
Define the ellipsoid used by the source, target, and definition CRS. Required to apply the offset to coordinates | def setCrsEllipsoid(self, a, rf=None):
self.isgeographic = True
self.ellipsoid_a = a
if rf is None:
self.ellipsoid_b = a
else:
self.ellipsoid_b = a * (1.0 - 1.0 / rf)
self.a2 = self.ellipsoid_a * self.ellipsoid_a
self.b2 = self.ellipsoid_b * self.e... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _init_projection(self):\n radius = 6370e3\n \n # Spherical latlon used by WRF\n self.latlon_sphere = pyproj.Proj(proj='latlong',\n a=radius, b=radius, towgs84='0,0,0', no_defs=True)\n\n # Lambert Conformal Conic used by WRF\n self.lambert_grid = pyproj.P... | [
"0.6040166",
"0.60394746",
"0.59396076",
"0.59256494",
"0.58521795",
"0.5771095",
"0.5674094",
"0.56357586",
"0.5605683",
"0.5517585",
"0.5476492",
"0.5439007",
"0.53797853",
"0.53455025",
"0.53209114",
"0.53010976",
"0.5291954",
"0.52865607",
"0.5256215",
"0.52353615",
"0.52... | 0.65401864 | 0 |
Get an imdb (image database) by name. | def get_imdb(name):
if not __sets.has_key(name):
raise KeyError('Unknown dataset: {}'.format(name))
return __sets[name]() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def imdb_info(title):\n try:\n if title in _imdb_cache:\n return _imdb_cache[title]\n except KeyError:\n pass\n i = imdb.IMDb()\n search_result = i.search_movie(title, results=1)\n if not search_result:\n return None\n result = search_result[0]\n i.update(result... | [
"0.616333",
"0.6082698",
"0.60265845",
"0.60114175",
"0.58648026",
"0.58400637",
"0.58213335",
"0.57996124",
"0.5794334",
"0.5785268",
"0.5768992",
"0.5731461",
"0.5723369",
"0.57161194",
"0.56995326",
"0.5677104",
"0.5616365",
"0.55860436",
"0.555823",
"0.5479197",
"0.546353... | 0.7363138 | 1 |
Method to read the csv file | def read_csv_file(self):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_csv():",
"def _read_csv(self):\n self.function_name = '_read_csv'\n with open(os.path.join(self.task.downloads, self.csv_name)) as csv_file:\n reader = csv.reader(csv_file, dialect='excel')\n for row in reader:\n self.input_data.append(row)",
"def get... | [
"0.874578",
"0.8275162",
"0.7794639",
"0.7679718",
"0.76562405",
"0.7616285",
"0.7401663",
"0.7334804",
"0.7147184",
"0.70850873",
"0.70783514",
"0.7049833",
"0.6993045",
"0.6967052",
"0.6965624",
"0.6955517",
"0.69535315",
"0.6939918",
"0.6938868",
"0.6930313",
"0.6920754",
... | 0.898817 | 0 |
Method to check if the file exists | def is_file_exists(self):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_file_exist(self):\n return False",
"def file_exists(self):\r\n if os.path.exists(self.file_path):\r\n return True\r\n else:\r\n return False",
"def file_exist() -> bool:\n pass",
"def file_exists(self):\n if os.path.isfile(self.file_name):\n ... | [
"0.8750944",
"0.8677664",
"0.86291355",
"0.8440019",
"0.83819354",
"0.8322929",
"0.8270689",
"0.8260134",
"0.8172603",
"0.81232107",
"0.8122489",
"0.809497",
"0.80892795",
"0.80884355",
"0.79643077",
"0.79612887",
"0.7935783",
"0.792067",
"0.7898609",
"0.78921366",
"0.7891174... | 0.9018266 | 0 |
print the statistics from the field triplen | def printLenStats(data):
print "statistics of training trips length: mean",
print data["triplen"].mean(), # Mean of values
print "std",
print data["triplen"].std(), # Unbiased standard deviation
print "var",
print data["triplen"].var(), # Unbiased variance
print "max",
print data["tri... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print_trigrams_count(self):\n for u_v in self.trigram_counts:\n for w in self.trigram_counts[u_v]:\n count=self.trigram_counts[u_v][w]\n print \"{2}\\tc({0} {1})\".format(u_v,w,count)",
"def print_metric(self):\r\n print(f'\\n\\n{self.sort} metric of siz... | [
"0.6339487",
"0.6272609",
"0.6054619",
"0.5972678",
"0.5954653",
"0.59238714",
"0.5839713",
"0.58144724",
"0.58086455",
"0.57821864",
"0.5774344",
"0.57310075",
"0.57287866",
"0.5718309",
"0.57071096",
"0.5701905",
"0.56911206",
"0.568461",
"0.56664026",
"0.5662793",
"0.56611... | 0.75883275 | 0 |
given the arrays, it computes the mean of the Haversine distances | def meanHaversineDistance(lat_sub, lon_sub, lat_real, lon_real):
return np.mean(HaversineDistance(lat_sub, lon_sub, lat_real, lon_real)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mean(self, words: [str]) -> numpy.ndarray:\n vecs = numpy.array([self[word] for word in words])\n return numpy.mean(vecs, axis=0)",
"def geo_mean(num_list):\n np_array = np.array(num_list)\n return np_array.prod() ** (1.0 / len(np_array))",
"def average_qa_distance(distances):\n\treturn... | [
"0.6321584",
"0.6258387",
"0.6237396",
"0.6234049",
"0.61874163",
"0.61680406",
"0.612857",
"0.60996014",
"0.6094646",
"0.6094646",
"0.6063661",
"0.6013036",
"0.600364",
"0.59932184",
"0.594262",
"0.5918531",
"0.5912743",
"0.5897897",
"0.589348",
"0.58902544",
"0.58897704",
... | 0.68384725 | 0 |
Gets the next element in the list. Returns Null on timeout, or raises Empty when finished. | def next_ele(self):
try:
ret = self._queue.get(block=True, timeout=0.5)
self._queue.task_done()
return ret
except queue.Empty:
if not self.isAlive():
raise
else:
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def next_ele(self):\n\t\ttry:\n\t\t\tret = self._queue.get(block = True, timeout=0.5)\n\t\t\tself._queue.task_done()\n\t\t\treturn ret\n\t\texcept queue.Empty:\n\t\t\tif not self.is_running():\n\t\t\t\traise\n\t\t\telse:\n\t\t\t\treturn None",
"def get_next_item(self, timeout=None):\n if self.current_item... | [
"0.8053774",
"0.7185805",
"0.71605355",
"0.69760185",
"0.6794046",
"0.6730466",
"0.6636796",
"0.6606605",
"0.6502341",
"0.64677364",
"0.64234453",
"0.6394917",
"0.6389111",
"0.6373149",
"0.63690454",
"0.6351756",
"0.6346494",
"0.63144475",
"0.6292954",
"0.6280215",
"0.6276917... | 0.8092506 | 0 |
If testing was enabled, returns the cache of all loaded RedditElements. | def get_elements(self):
return self._testing_cache | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def all(self):\n if not self._cache:\n self.load()\n\n return self._cache",
"def get(self):\n if path.exists(self.cachefile):\n self.invalidion()\n full_cache = self._get_all()\n return full_cache\n else:\n return []",
"def mine... | [
"0.6270382",
"0.56245005",
"0.5519018",
"0.54027367",
"0.54011166",
"0.54011166",
"0.54011166",
"0.54011166",
"0.5344163",
"0.5297615",
"0.528587",
"0.52725077",
"0.5247935",
"0.522117",
"0.5188726",
"0.51864684",
"0.5170986",
"0.51583016",
"0.5130199",
"0.51186985",
"0.50906... | 0.70427525 | 0 |
This method should be called upon initialization to do the string processing as soon as an instance of MyPassportClass is created. It should take a list of strings `self.entry` and process each string into keyvalue pairs. With the way the attribute are defined in this class, I do not have to pass anything into this met... | def process_entry(self):
for line_item in self.entry:
pairs = line_item.split(' ')
for pair in pairs:
if ':' in pair:
key, value = pair.split(':')
if value.isdigit():
self.fields[key] = int(value)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, first_name, last_name, **user_info):\n self.first_name = first_name\n self.last_name = last_name\n\n # Similar to Exercise 8-13 user_profile-2.py except the dictionary is\n # an attribute of self.\n self.attributes = {'login_attempts': 0}\n for key,value... | [
"0.49940896",
"0.49859047",
"0.49709833",
"0.4953203",
"0.48999676",
"0.48774707",
"0.48774707",
"0.4860976",
"0.48323658",
"0.4814549",
"0.47757342",
"0.47644758",
"0.47550556",
"0.47471005",
"0.47459665",
"0.47355053",
"0.46886247",
"0.46850675",
"0.46790436",
"0.46672106",
... | 0.5435954 | 0 |
Handler for button event, redirects to handlers for specific buttons | def OnButton(self, event):
button = event.GetEventObject().GetName()
if button == "Button1":
self.OnButton1()
elif button == "Button2":
self.OnButton2()
elif button == "Button3":
self.OnExit(event) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def OnButton(self, event):\r\n \r\n button = event.GetInt()\r\n\r\n if button == AUI_BUTTON_LEFT or button == AUI_BUTTON_RIGHT:\r\n if button == AUI_BUTTON_LEFT:\r\n if self.GetTabOffset() > 0:\r\n \r\n self.SetTabOffset(self.GetTabOf... | [
"0.7044635",
"0.6786346",
"0.6749938",
"0.6737374",
"0.64038026",
"0.6324577",
"0.6317142",
"0.62803805",
"0.6239058",
"0.62135565",
"0.6211251",
"0.62016696",
"0.61881936",
"0.61719483",
"0.61423606",
"0.60934865",
"0.60849035",
"0.6071122",
"0.60655963",
"0.60495496",
"0.60... | 0.76285523 | 0 |
Shape the rounded corners for the window | def SetRoundShape(self):
w, h = self.GetSize()
self.SetShape(GetRoundShape(w, h, 10)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rounded_border_box(self):\n return self.rounded_box(0, 0, 0, 0)",
"def draw_window_pane():\n houseturtle.begin_fill()\n for y in range(4):\n houseturtle.pendown()\n houseturtle.forward(35)\n houseturtle.left(90)\n houseturtle.penup()\n h... | [
"0.72191507",
"0.66822755",
"0.6522677",
"0.64682794",
"0.6444937",
"0.6425309",
"0.6359084",
"0.6307169",
"0.62756234",
"0.62698317",
"0.6259612",
"0.6259098",
"0.6244389",
"0.6243569",
"0.6236145",
"0.62334776",
"0.61594945",
"0.6116691",
"0.6098656",
"0.605642",
"0.6045871... | 0.72325355 | 0 |
Loads icon files by name, returns wx.BitMaps | def LoadIcon(filename):
# wx.Image.AddHandler(wx.PNGHandler) # This should work but it doesn't so...
wx.InitAllImageHandlers() # ...falling back to this instead
filename = "icons/" + filename + ".png"
image = wx.Image()
with open(filename, mode='rb') as file:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_icon(fn):\n\n fn = os.path.join(os.path.dirname(__file__), fn)\n bmp = c4d.bitmaps.BaseBitmap()\n if bmp.InitWith(fn)[0] == c4d.IMAGERESULT_OK:\n return bmp\n return None",
"def xInitializeBitmaps(self, basedir):\n # ---------------------------------------------------------------... | [
"0.6490824",
"0.64318",
"0.6354683",
"0.62018186",
"0.61104596",
"0.59513116",
"0.58033264",
"0.57248694",
"0.57137376",
"0.56984043",
"0.5696082",
"0.56323403",
"0.56122166",
"0.5600569",
"0.55870014",
"0.54954994",
"0.54757214",
"0.54697824",
"0.5464561",
"0.5461193",
"0.54... | 0.7397227 | 0 |
Creates a virtual bitmap with round corners. | def GetRoundBitmap(w, h, r):
maskColor = wx.Colour(0, 0, 0)
shownColor = wx.Colour(5, 5, 5)
b = wx.Bitmap(w, h)
dc = wx.MemoryDC(b)
dc.SetBrush(wx.Brush(maskColor))
dc.DrawRectangle(0, 0, w, h)
dc.SetBrush(wx.Brush(shownColor))
dc.SetPen(wx.Pen(shownColor))
dc.DrawRoundedRectangle(0,... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_round_edges_bitmap(width: int, height: int, radius: int):\n mask_color = opts['gui']['attrs']['mask_color']\n background_color = opts['gui']['attrs']['background_color']\n bitmap = wx.Bitmap(width, height)\n dc = wx.MemoryDC(bitmap)\n dc.SetBrush(wx.Brush(mask_color))\n dc.DrawRectangle(... | [
"0.7063769",
"0.60604304",
"0.5830127",
"0.5667308",
"0.5437381",
"0.54086745",
"0.5393314",
"0.5353336",
"0.5332856",
"0.53235507",
"0.5276968",
"0.52623665",
"0.52610254",
"0.524472",
"0.52440923",
"0.5211178",
"0.51898247",
"0.5180378",
"0.5161632",
"0.5122108",
"0.5118235... | 0.6869948 | 1 |
builds the two tkinter frames that are used as parents for the tkinter widgets that both control and display the RDM messages. | def build_frames(self):
self.cntrl_frame = tk.PanedWindow(self.root)
self.cntrl_frame.pack(side = tk.TOP, padx = 1, pady = 1, fill = tk.Y)
self.info_frame_1 = tk.PanedWindow(self.root)
self.info_frame_1.pack(side = tk.TOP, padx = 1, pady = 2, fill = tk.Y) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _make_message_frame( self, parent, default_scroll = True ):\n# color = \"black\" # this may need a bit of rework -- looks like not used\n #iframe = Tk.Frame( parent, width=300, height=800,\n # bg =\"blue\", relief = Tk.RAISED, borderwidth=1, )\n iframe = self\n\n #... | [
"0.68194026",
"0.67628336",
"0.66859114",
"0.6685763",
"0.66459084",
"0.6627091",
"0.65815926",
"0.65467334",
"0.65451664",
"0.65284294",
"0.65139276",
"0.643256",
"0.6422164",
"0.6420944",
"0.6383805",
"0.6314913",
"0.62750316",
"0.62735295",
"0.626137",
"0.6218138",
"0.6210... | 0.7488129 | 0 |
sets the int var self.universe to the value of i | def set_universe(self, i):
self.universe.set(i) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def i(self, i):\n\n self._i = i",
"def assignMoreVectors(self, i):\n return",
"def update_global_identifiers(self, universe_test):\n self.cellNum += 1\n self.surfaceNum += 1\n self.materialNum += 1\n if universe_test:\n self.universe += 1",
"def universe(s... | [
"0.59920424",
"0.5927336",
"0.57459134",
"0.56548715",
"0.5609323",
"0.5395382",
"0.5320092",
"0.5219125",
"0.51983535",
"0.5163157",
"0.5133494",
"0.5103622",
"0.5095128",
"0.50520754",
"0.50436985",
"0.5029962",
"0.499586",
"0.49659938",
"0.49072215",
"0.49047565",
"0.49040... | 0.91754603 | 0 |
runs discovery for the current universe. | def discover(self):
self.ola_thread.run_discovery(self.universe.get(), self._upon_discover)
if self.auto_disc.get():
self.ola_thread.add_event(5000, self.discover)
else:
print "auto_disc is off" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def discover(self):\n pass",
"async def discover(self):\n raise NotImplementedError(\"this is a base class\")",
"def detailed_discovery(categories):\n if len(categories) > 0:\n unlock_vault()\n\n for ip in discovery_info.get(\"ip_addresses\"):\n names = vault.get_names... | [
"0.64019483",
"0.6259512",
"0.58157563",
"0.57681084",
"0.5739528",
"0.5714246",
"0.56753683",
"0.564835",
"0.55920976",
"0.5574409",
"0.55319387",
"0.5502363",
"0.54179734",
"0.54072213",
"0.5403968",
"0.5373921",
"0.5297729",
"0.5259509",
"0.5221286",
"0.5197727",
"0.517012... | 0.6932293 | 0 |
Command is called by id_box. sets the value of the device"s identify field based on the value of id_box. | def identify(self):
if self.cur_uid is None:
return
self.ola_thread.rdm_set(self.universe.get(), self.cur_uid, 0,
"IDENTIFY_DEVICE",
lambda b, s, uid = self.cur_uid:self._rdm_set_complete(uid, b, s),
[self.id_state.get()]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def identify(self):\n self.__send_short(self.MGMSG_MOD_IDENTIFY, 0x00, 0x00)",
"def test_id_set(mocker):\n mocker.patch('serial.Serial.open')\n mocker.patch('serial.Serial.flushInput')\n css = mocker.patch('pysds011.driver.SDS011.cmd_set_sleep')\n css.return_value = True\n csi = mocker.patch('p... | [
"0.6012484",
"0.56254315",
"0.5605983",
"0.54867625",
"0.54489803",
"0.5412264",
"0.54017085",
"0.5397051",
"0.5396992",
"0.53842187",
"0.5315069",
"0.5282258",
"0.52782863",
"0.526158",
"0.5250456",
"0.52348113",
"0.5213762",
"0.52123815",
"0.51809037",
"0.5173153",
"0.51727... | 0.64114225 | 0 |
callback for the rdm_get in upon_discover. populates self.device_menu | def _add_device(self, uid, succeeded, data):
# TODO: Bug: on discover the label in the label in the device option menu
# doesn't change and if you try to select the first device it tells
# you that it is already selected
if succeeded:
self._uid_dict.setdefault(uid, {})["DEVICE_LABEL"... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def on_menu_connect():\n\n ServerSockets.get_menuitems_by_category(True)",
"def device_infomation_submenu(dev, pdmssp=False):\n \n loop = True\n menu.clear()\n\n while loop:\n print(\"Device Information Menu\")\n print(\"=======================\")\n print(\"1. Show Device ... | [
"0.6013685",
"0.57967615",
"0.57610536",
"0.5615194",
"0.5563712",
"0.5537211",
"0.5413569",
"0.53911567",
"0.5368401",
"0.5362007",
"0.5357612",
"0.53087044",
"0.52785635",
"0.527515",
"0.5239037",
"0.5237308",
"0.52293265",
"0.5228126",
"0.52249765",
"0.5221598",
"0.5154385... | 0.59731305 | 1 |
callback for the rdm_set in identify. | def _rdm_set_complete(self, uid, succeded, value):
print "value: %s" % value
print "rdm set complete" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def identify(self):\n if self.cur_uid is None:\n return\n self.ola_thread.rdm_set(self.universe.get(), self.cur_uid, 0, \n \"IDENTIFY_DEVICE\", \n lambda b, s, uid = self.cur_uid:self._rdm_set_complete(uid, b, s), \n [self.id_state.get()])",
"def _get_identify_co... | [
"0.5682611",
"0.5316892",
"0.52162796",
"0.52162796",
"0.5072463",
"0.50554055",
"0.4996405",
"0.49675164",
"0.49276254",
"0.49173698",
"0.48191282",
"0.4788057",
"0.47169998",
"0.4650642",
"0.4647563",
"0.4641984",
"0.46267664",
"0.46096426",
"0.46091643",
"0.4599053",
"0.45... | 0.56141204 | 1 |
Capitalize the two DNA sequences so that the answers are not affected. function homology is used to find the interval with the highest similarity. I use double for loop, one for the position of a long sequence string, and the other for each word in the string. | def main():
long_sequence = input("Please give ne a DNA sequence to search: ")
short_sequence = input("What DNA sequence would you like to match? ")
# converts characters to uppercase
new_long_sequence = long_sequence.upper()
new_short_sequence = short_sequence.upper()
ans = homology(new_long_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def question_13(one_string: str, two_string: str) -> str:\n return one_string.capitalize() + two_string.capitalize()",
"def sequence(word1: str, word2: str) -> str:\r\n matrix = [[[0, [0, 0]] for x in range(len(word1) + 1)] for i in range(len(word2) + 1)]\r\n\r\n for i in range(1, len(word2) + 1):\r\n ... | [
"0.60838586",
"0.60141426",
"0.5906382",
"0.58889776",
"0.5880022",
"0.57611173",
"0.5745369",
"0.5738358",
"0.5728159",
"0.56908894",
"0.5626435",
"0.5607777",
"0.5582242",
"0.55685735",
"0.5559297",
"0.55515736",
"0.555132",
"0.55334914",
"0.550639",
"0.55015826",
"0.550100... | 0.62365746 | 0 |
Decorator to cache the given function's output. | def _memorize(func):
def _wrapper(self, *args, **kwargs):
"""Wrapper to cache the function's output.
"""
if self.use_cache:
cache = load_cache(self.cache_filename)
original_key = generate_hash(
self.__class__.__name__, func.__name__, args, kwargs)
cache_key = hashlib.md5(o... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cache_function(self, func):\n\n @wraps(func)\n def wrapper(*args):\n if self.__log:\n self.__logger.info(f\"Called {func.__name__} with {args}\")\n fileName = self.__build_file_name(func, args)\n\n if os.path.isfile(fileName):\n # Res... | [
"0.80434555",
"0.802811",
"0.80147463",
"0.7940685",
"0.78886366",
"0.7886459",
"0.77482986",
"0.7695859",
"0.7625713",
"0.7599214",
"0.75760525",
"0.74956316",
"0.7471002",
"0.7471002",
"0.7467602",
"0.7437199",
"0.741782",
"0.74044234",
"0.73983026",
"0.73818004",
"0.738007... | 0.8269284 | 0 |
Groups chunks by entities retrieved from NL API Entity Analysis. | def _group_chunks_by_entities(self, chunks, entities):
for entity in entities:
chunks_to_concat = chunks.get_overlaps(
entity['beginOffset'], len(entity['content']))
if not chunks_to_concat:
continue
new_chunk_word = u''.join([chunk.word for chunk in chunks_to_concat])
new_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _group_chunks_by_entities(self, chunks, entities):\n for entity in entities:\n chunks_to_concat = chunks.get_overlaps(\n entity['beginOffset'], len(entity['content']))\n if not chunks_to_concat: continue\n new_chunk_word = u''.join([chunk.word for chunk in chunks_to_concat])\n n... | [
"0.78132176",
"0.6900138",
"0.6900138",
"0.623251",
"0.60541534",
"0.6033899",
"0.599321",
"0.5869792",
"0.5774038",
"0.5766394",
"0.5745294",
"0.57265353",
"0.5688995",
"0.5677096",
"0.56333464",
"0.55718493",
"0.55683404",
"0.55677456",
"0.5554525",
"0.555384",
"0.5523666",... | 0.7806981 | 1 |
Returns the list of annotations retrieved from the given text. | def _get_annotations(self, text, language=''):
body = {
'document': {
'type': 'PLAIN_TEXT',
'content': text,
},
'features': {
'extract_syntax': True,
},
'encodingType': 'UTF32',
}
if language:
body['document']['language'] = la... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_raw_annotations_for_text(text, ontologies='MESH', semantic_types=None):\n\n if semantic_types is None:\n semantic_types = ()\n\n params = {}\n params['text'] = text\n params['ontologies'] = ontologies\n params['semantic_types'] = ','.join(semantic_types)\n response = _make_api_cal... | [
"0.72478795",
"0.7009146",
"0.6540529",
"0.651889",
"0.6381263",
"0.63721395",
"0.6350639",
"0.62808055",
"0.61848694",
"0.6099416",
"0.6034471",
"0.60143244",
"0.60053957",
"0.594642",
"0.5920167",
"0.5902729",
"0.5899829",
"0.5843016",
"0.58206964",
"0.5813129",
"0.5790471"... | 0.7336573 | 0 |
Returns the list of entities retrieved from the given text. | def _get_entities(self, text, language=''):
body = {
'document': {
'type': 'PLAIN_TEXT',
'content': text,
},
'encodingType': 'UTF32',
}
if language:
body['document']['language'] = language
request = self.service.documents().analyzeEntities(body=body... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def entities_text(text):\n if len(text) == 0:\n return None\n\n client = language.LanguageServiceClient()\n\n if isinstance(text, six.binary_type):\n text = text.decode('utf-8')\n\n # Instantiates a plain text document.\n document = types.Document(\n content=text,\n type=... | [
"0.7677393",
"0.7066265",
"0.67262036",
"0.6620404",
"0.66058445",
"0.6437475",
"0.6425754",
"0.6414616",
"0.6380142",
"0.63607067",
"0.6341214",
"0.633624",
"0.62974226",
"0.6291807",
"0.6288747",
"0.6282542",
"0.62515336",
"0.61551136",
"0.6136373",
"0.61311215",
"0.6127788... | 0.80995923 | 0 |
Obtaining Account type key for given label | def get_account_type_value(self, label=None):
if label is not None:
index = list(map(lambda x: x[1], self.ACCOUNT_TYPES)).index(label)
return self.ACCOUNT_TYPES[index][0]
else:
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def key_type(self) -> global___Type:",
"def get_keypair_name ( aws_account_type, region_name, keytype ) :\n return aws_account_type.upper( ) + '-' + keytype.upper( ) + '-' + region_name.lower( ) + '-keypair'",
"def _create_key(_type, name):\n return \"{}{}{}\".format(_type, DiagnosticManager._type_sep... | [
"0.61789745",
"0.61113775",
"0.5973853",
"0.5878963",
"0.5767249",
"0.5738894",
"0.57032627",
"0.566649",
"0.56554073",
"0.56554073",
"0.56357807",
"0.5621801",
"0.5605613",
"0.5601492",
"0.55755854",
"0.55486083",
"0.55069405",
"0.5498101",
"0.547072",
"0.5462579",
"0.544380... | 0.67215216 | 0 |
Test bills page (/bills) | def test_bills_page(self):
self.make_request("/bills", follow_redirects=True)
headings = [
"Current Bills",
"All Tabled Bills",
"Private Member & Committee Bills",
"All Tabled & Draft Bills",
"Draft Bills",
"Bills Explained"... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_bill_page(self):\n bill = self.fx.BillData.food\n self.make_request(\"/bill/%d/\" % bill.id, follow_redirects=True)\n self.assertIn(bill.type.name, self.html)\n # Check if \"na\" stage is in page\n self.assertIn(\"stage2\", self.html)\n # Check if plenary event is... | [
"0.7680774",
"0.70165765",
"0.67381495",
"0.671697",
"0.6493225",
"0.6169521",
"0.6162236",
"0.61248475",
"0.60678047",
"0.5941131",
"0.5916215",
"0.58462006",
"0.5843386",
"0.5824207",
"0.5804087",
"0.5803388",
"0.57419884",
"0.57244706",
"0.5711201",
"0.5695939",
"0.5693122... | 0.8518053 | 0 |
Test bill page (/bill/) | def test_bill_page(self):
bill = self.fx.BillData.food
self.make_request("/bill/%d/" % bill.id, follow_redirects=True)
self.assertIn(bill.type.name, self.html)
# Check if "na" stage is in page
self.assertIn("stage2", self.html)
# Check if plenary event is shown in Bill Hi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_bills_page(self):\n self.make_request(\"/bills\", follow_redirects=True)\n headings = [\n \"Current Bills\",\n \"All Tabled Bills\",\n \"Private Member & Committee Bills\",\n \"All Tabled & Draft Bills\",\n \"Draft Bills\",\n ... | [
"0.7101309",
"0.6749772",
"0.6648777",
"0.64527935",
"0.62037534",
"0.6166715",
"0.61598116",
"0.61127925",
"0.60858375",
"0.6062945",
"0.60293883",
"0.5998675",
"0.5993028",
"0.59900546",
"0.5974807",
"0.5946354",
"0.58807683",
"0.5874141",
"0.5833708",
"0.5829351",
"0.58253... | 0.8359883 | 0 |
Test current bills page (/bills/current) | def test_current_bills_page(self):
self.make_request("/bills/current", follow_redirects=True)
self.assertIn("Current Bills", self.html)
self.assertIn("Weekly update for all current bills", self.html)
for bill_key in self.fx.BillData:
bill = getattr(self.fx.BillData, bill_key[... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_bills_page(self):\n self.make_request(\"/bills\", follow_redirects=True)\n headings = [\n \"Current Bills\",\n \"All Tabled Bills\",\n \"Private Member & Committee Bills\",\n \"All Tabled & Draft Bills\",\n \"Draft Bills\",\n ... | [
"0.70060414",
"0.6251623",
"0.61162347",
"0.59430474",
"0.5937214",
"0.5659221",
"0.56577533",
"0.56432396",
"0.5577943",
"0.5549721",
"0.55134785",
"0.5268124",
"0.5258236",
"0.5243746",
"0.52388626",
"0.5181961",
"0.5178942",
"0.5174875",
"0.5121769",
"0.5106999",
"0.508390... | 0.84873515 | 0 |
Test draft bills page (/bills/draft/) redirects to current year's draft bills page. | def test_draft_bills_page(self):
response = self.make_request("/bills/draft/", follow_redirects=False)
self.assertEqual(302, response.status_code)
current_year = datetime.datetime.today().year
self.assertEqual(
urlparse(response.location).path, "/bills/draft/year/%d/" % curre... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_draft_bills_page_for_year(self):\n year = 2019\n response = self.make_request(\n \"/bills/draft/year/%d/\" % year, follow_redirects=True\n )\n self.assertEqual(200, response.status_code)\n bill = self.fx.BillData.draft\n self.assertIn(bill.title, self.h... | [
"0.796481",
"0.70448816",
"0.70290816",
"0.665954",
"0.6471485",
"0.6356927",
"0.635401",
"0.632725",
"0.6307408",
"0.61629856",
"0.6149977",
"0.58866006",
"0.57728565",
"0.5759125",
"0.568433",
"0.5669418",
"0.5656988",
"0.560628",
"0.55976933",
"0.550295",
"0.54979414",
"... | 0.8807852 | 0 |
Test draft bills page for a year (/bills/draft/). | def test_draft_bills_page_for_year(self):
year = 2019
response = self.make_request(
"/bills/draft/year/%d/" % year, follow_redirects=True
)
self.assertEqual(200, response.status_code)
bill = self.fx.BillData.draft
self.assertIn(bill.title, self.html) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_draft_bills_page(self):\n response = self.make_request(\"/bills/draft/\", follow_redirects=False)\n self.assertEqual(302, response.status_code)\n current_year = datetime.datetime.today().year\n self.assertEqual(\n urlparse(response.location).path, \"/bills/draft/year... | [
"0.84138995",
"0.7889149",
"0.6775302",
"0.65236485",
"0.62575066",
"0.6029107",
"0.5984826",
"0.59390867",
"0.58819306",
"0.5876933",
"0.5722013",
"0.5572942",
"0.5545011",
"0.5518728",
"0.5517939",
"0.5496567",
"0.54783195",
"0.54646355",
"0.5458014",
"0.54177934",
"0.53996... | 0.88270897 | 0 |
Test bills page for a year (/bills/). | def test_bills_page_for_year(self):
year = 2019
response = self.make_request(
"/bills/all/year/%d/" % year, follow_redirects=True
)
self.assertEqual(200, response.status_code)
self.assertIn(self.fx.BillData.bill_with_none_number.title, self.html)
self.assertIn... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_draft_bills_page_for_year(self):\n year = 2019\n response = self.make_request(\n \"/bills/draft/year/%d/\" % year, follow_redirects=True\n )\n self.assertEqual(200, response.status_code)\n bill = self.fx.BillData.draft\n self.assertIn(bill.title, self.h... | [
"0.7934322",
"0.73883474",
"0.7205412",
"0.6592645",
"0.6201756",
"0.5930797",
"0.5895609",
"0.5849038",
"0.56935006",
"0.56164986",
"0.55925894",
"0.5533068",
"0.5509524",
"0.53481203",
"0.5337408",
"0.53338116",
"0.5332658",
"0.5323729",
"0.5322545",
"0.52949613",
"0.528518... | 0.844176 | 0 |
Print a Fibonacci series up to n. | def fib(n): # write Fibonacci series up to n
a, b = 0, 1
while a < n:
print(a, end=' ')
a, b = b, a+b
print() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fib(n): # write Fibonacci series up to n\n a, b = 1, 1\n while a < n:\n print(a, end=' ')\n a, b = b, a + b\n print()",
"def fibon(n):\r\n a, b = 0, 1\r\n while b < n:\r\n print(b, end=' ')\r\n a, b = b, a + b\r\n\r\n print()",
"def fib(n):\n a, b = 0, 1\... | [
"0.86665875",
"0.865262",
"0.85437036",
"0.8514844",
"0.83812505",
"0.8376221",
"0.8372399",
"0.82822764",
"0.8197588",
"0.818762",
"0.8139177",
"0.7916685",
"0.79095733",
"0.7795058",
"0.7737876",
"0.7699194",
"0.76678586",
"0.7626423",
"0.7606383",
"0.7585965",
"0.7549635",... | 0.8673606 | 0 |
Attempts to decode a message hidden in the image The secret_key and random_seed MUST be the same as the ones used to embed the message initially message_length will ensure that the decoded string doesn't contain any extra characters. If not specified, the decoder will keep trying to decode until an error is thrown | def decode (self, secret_key, random_seed, message_length=math.inf):
# seed the random number generator with the seed used to embed
random.seed(random_seed)
bytes_visited = {} # a dictionary of the unique bytes already visited
color_offset = StegImage.color_offset # the color plane where... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def decrypt_message(encrypted_message):",
"def decode(decryption=None):\n\n key_to_encrypt = {'a': 'q', 'b': 'v', 'c': 'x', 'd': 'z', 'e': 'y', 'f': 'w', 'g': 'u', 'h': 't', 'i': 's',\n 'j': 'r',\n 'k': 'p', 'l': 'o', 'm': 'n', 'n': 'm', 'o': 'l', 'p': 'k', 'r': 'j', ... | [
"0.64776963",
"0.63632095",
"0.6322363",
"0.61773396",
"0.6124936",
"0.6089968",
"0.6028787",
"0.60207546",
"0.5953228",
"0.594839",
"0.5930802",
"0.59212095",
"0.5885464",
"0.57913494",
"0.57555205",
"0.57384247",
"0.5734379",
"0.5689325",
"0.5677325",
"0.5625216",
"0.561360... | 0.8330446 | 0 |
index_of_byte index of byte in array index_of_bit index of the bit in the byte new_value the new value at the index of the bit (0 or 1) | def set_bit(self, index_of_byte, index_of_bit, new_value):
if index_of_bit >= self.binary_size:
print("You tried to modify a byte at %d index. This cannot be done. The maximum index is %d."%(index_of_bit, self.binary_size - 1))
else:
new_value = str(new_value)
byte = ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def updatebyte(byte, bit, value):\n if value == 0:\n return byte & ~(1 << bit)\n elif value == 1:\n return byte | (1 << bit)",
"def modify_byte(byte: int, message_bit: bool) -> int:\n byte = bin(byte)\n byte_new_last_bit = int(message_bit)\n new_byte = int(byte[:-1] +... | [
"0.74368215",
"0.6721762",
"0.6662158",
"0.65792656",
"0.6568271",
"0.65516293",
"0.64147186",
"0.62618554",
"0.6233598",
"0.6209762",
"0.62077487",
"0.61962634",
"0.6191687",
"0.6158861",
"0.6106333",
"0.60963595",
"0.6089261",
"0.60875833",
"0.6047753",
"0.60092896",
"0.589... | 0.8123513 | 0 |
Updates the binary_array array based on the bytes private variable | def update_binary_bytes(self):
self.binary_array = data_manipulation.convert_byte_array(self.bytes, self.binary_size) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_bytes_array(self):\n self.bytes = data_manipulation.convert_from_binary_array(self.binary_array)",
"def update_binary(self, offset, data):\n log.debug(\"write binary {0} to {1}\".format(offset, offset+len(data)))\n cmd = bytearray([0x00, 0xD6, offset/256, offset%256, len(data)])\n... | [
"0.85522306",
"0.6417961",
"0.6182146",
"0.6066188",
"0.6042835",
"0.5951569",
"0.5898244",
"0.58424544",
"0.5830605",
"0.5825022",
"0.5725478",
"0.5692757",
"0.56252694",
"0.5581197",
"0.55731577",
"0.55338085",
"0.55332655",
"0.55148214",
"0.55130553",
"0.5489311",
"0.54890... | 0.88327396 | 0 |
updates the bytes array based on binary bytes. reconstructs bytes from binary_array | def update_bytes_array(self):
self.bytes = data_manipulation.convert_from_binary_array(self.binary_array) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_binary_bytes(self):\n self.binary_array = data_manipulation.convert_byte_array(self.bytes, self.binary_size)",
"def update_binary(self, offset, data):\n log.debug(\"write binary {0} to {1}\".format(offset, offset+len(data)))\n cmd = bytearray([0x00, 0xD6, offset/256, offset%256, l... | [
"0.8974595",
"0.6320197",
"0.6153868",
"0.6111419",
"0.5868646",
"0.5779125",
"0.56829494",
"0.56726515",
"0.55885434",
"0.5576249",
"0.55422443",
"0.5534472",
"0.5524987",
"0.5517247",
"0.55114347",
"0.54999715",
"0.54987884",
"0.549476",
"0.5493693",
"0.54716897",
"0.546844... | 0.8828117 | 1 |
writes self.bytes to an image. probably should run self.update_bytes_array() before calling this method | def write_bytes_to_image(self, file_path):
data_manipulation.bytes_to_image(self.bytes, file_path) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write(self, image):\n raise NotImplementedError()",
"def writeimage(self, fp):\n execfile = open(self.binpath, \"w\")\n databuf = fp.read(4096)\n while databuf:\n execfile.write(databuf)\n databuf = fp.read(4096)\n execfile.flush()\n execfile.cl... | [
"0.7372077",
"0.65278393",
"0.64787364",
"0.647208",
"0.6361551",
"0.63133377",
"0.62308866",
"0.62225616",
"0.6169296",
"0.6163713",
"0.6159095",
"0.61500794",
"0.6142363",
"0.6139682",
"0.6130171",
"0.61293423",
"0.6119667",
"0.6098111",
"0.60803",
"0.6067082",
"0.6058352",... | 0.8263245 | 0 |
Allows the user to select number of human players. Validates input and returns a matching tuple of players. | def get_participating_players(raw_input=raw_input):
no_players = 0
while no_players != 1 and no_players != 2:
inp = raw_input("Single player or multiplayer? (1/2): ")
try:
no_players = int(inp)
except ValueError:
print "Invalid input - please try again"
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_num_players(num_players):\n \n try:\n\tnum_players = int(num_players)\n except ValueError:\n\treturn None\n if num_players < 2 or num_players > 4:\n return None\n\n return num_players",
"def set_n_players(self):\n complain = \"\"\n while True:\n clear_outp... | [
"0.6700877",
"0.66584164",
"0.6638199",
"0.6623469",
"0.6545826",
"0.64794976",
"0.64397866",
"0.6357553",
"0.6274813",
"0.6097092",
"0.6070521",
"0.60677963",
"0.5964063",
"0.5918203",
"0.5834943",
"0.5820832",
"0.5770313",
"0.5723989",
"0.57173026",
"0.57104576",
"0.5704357... | 0.72646415 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.