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 |
|---|---|---|---|---|---|---|
Creates a new session or returns existing one if path exists | def create_session(
path: str,
type: str,
name: Optional[str] = None,
kernel_name: Optional[str] = None,
kernel_id: Optional[str] = None,
) -> str:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_new_session():\n session = Session.objects.create(uuid=str(uuid4()), container_id=None)\n return session.id",
"def _insert_new_session():\n request = self._make_request()\n session_existing = self._set_up_session_in_Redis_and_makeOne( # noqa: F841\n request, s... | [
"0.7212364",
"0.6900169",
"0.6895351",
"0.6759798",
"0.6726369",
"0.6653804",
"0.6640182",
"0.65958303",
"0.65842575",
"0.65202713",
"0.6479733",
"0.64455444",
"0.6434389",
"0.64199865",
"0.63682336",
"0.6362771",
"0.63557774",
"0.63264036",
"0.6294936",
"0.6289158",
"0.62681... | 0.70272946 | 1 |
Updates an existing session. | def update_session(
id: str,
path: Optional[str] = None,
name: Optional[str] = None,
type: Optional[str] = None,
kernel_name: Optional[str] = None,
kernel_id: Optional[str] = None,
) -> None:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def upsert_session(session_data):\n g_db['sessions'].update(\n get_session_id(session_data),\n {\n \"$set\": session_data,\n },\n upsert=True\n )",
"def test_update_session(self):\r\n now = time.time()\r\n\r\n # Make sure the session has data so that it ... | [
"0.7159977",
"0.686218",
"0.68574136",
"0.66107583",
"0.6506551",
"0.6489274",
"0.6447803",
"0.64465",
"0.63691455",
"0.63294715",
"0.62878484",
"0.6127597",
"0.6104474",
"0.6089136",
"0.6085308",
"0.6046978",
"0.6046949",
"0.60441613",
"0.5959553",
"0.59453976",
"0.5927981",... | 0.726062 | 0 |
Takes a two element tuple. The second element must be a Beliefs object which system1 will use to update the belief module. Once updated, the action queue will be emptied and the rules will be checked for satisfied conditions. The action queue will be refilled with new active actions from the rule list. | def process_belief(self, args):
goal, belief = args
if isinstance(belief, Beliefs):
self.belief_module.process_belief(belief)
self.initialize_action_queue()
return [{}] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_beliefs(self, result, action):\n if self.traceUpdate:\n print(\"Updating beliefs based on action\", action, \"with result\", result)\n\n if result == 'TryAgain':\n return None\n\n elif not result and not self.isTransient(action):\n if self.traceUpdat... | [
"0.62839353",
"0.5601004",
"0.54203224",
"0.523504",
"0.523504",
"0.523504",
"0.523504",
"0.52241856",
"0.51511395",
"0.5150723",
"0.5111748",
"0.50751257",
"0.5067793",
"0.50459915",
"0.5037544",
"0.50247914",
"0.4989329",
"0.4953486",
"0.49498907",
"0.49385783",
"0.49159616... | 0.60782725 | 1 |
Calls the belief module's emit_belief method to get and return a Beliefs object with the agents chosen belief for emission. | def emit_belief(self, args):
goal, belief = args
return [{belief: self.belief_module.emit_belief()}] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process_belief(self, args):\n goal, belief = args\n\n if isinstance(belief, Beliefs):\n self.belief_module.process_belief(belief)\n self.initialize_action_queue()\n\n return [{}]",
"def calculateBeliefs(self):\n\n belief = {}\n\n for question in self.g... | [
"0.6572719",
"0.60047936",
"0.58963394",
"0.5791217",
"0.5663534",
"0.5584099",
"0.5567305",
"0.550817",
"0.54517233",
"0.53226274",
"0.53167677",
"0.5304004",
"0.51742756",
"0.51660204",
"0.5156423",
"0.5151522",
"0.5149159",
"0.51191115",
"0.5110184",
"0.50023305",
"0.49014... | 0.74441326 | 0 |
Checks if an incoming belief is in conflict with internal beliefs. A conflict occurs when the belief is of opposite valence to a current belief. This method does not update own or perceived beliefs. | def belief_conflict(self, args):
goal, belief = args
if isinstance(belief, Beliefs):
if self.belief_module.is_conflicting_belief(belief):
return [{}]
return [] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_conflict(self):\n for diffstat in self.diffstat():\n if diffstat.has_conflict:\n return True\n return False",
"def checkConflicts(self):\n\t\treturn",
"def refine_conflict(self):\n self._raise_not_supported()",
"def check_conflicts(self):\n\t\tshutit_glo... | [
"0.60755587",
"0.5997811",
"0.5935477",
"0.5858629",
"0.57589734",
"0.56303644",
"0.5552522",
"0.55062824",
"0.54827005",
"0.54471344",
"0.5424391",
"0.54060894",
"0.53555745",
"0.53466696",
"0.53354824",
"0.5331523",
"0.5313019",
"0.530491",
"0.5267892",
"0.52595043",
"0.522... | 0.66045004 | 0 |
quad(f, a, b) > \int_a^b f(x) dx Uses some quadrature rule to evaluate the integral. | def quad(f, a, b):
S, D = (b+a)/2.0, (b-a)/2.0
def rescaled_f(x):
return f(x*D + S)*D
return sum(w * rescaled_f(p) for w, p in zip(quad_weights, quad_points)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def quad(func, a, b, args=()):\n\tx_units = a.units\n\tf_units = func(.5*(a+b)).units\n\n\tI, abserr = sciquad(\n\t\tlambda x : func(x*x_units).to(f_units).magnitude,\n\t\ta.magnitude, b.to(x_units).magnitude,\n\t\targs)\n\n\treturn I*x_units*f_units, abserr*x_units*f_units",
"def add_quad(a, b):\n s = np.sqr... | [
"0.7321034",
"0.66224813",
"0.6437059",
"0.64194804",
"0.62829626",
"0.62496614",
"0.6247555",
"0.6206842",
"0.6206842",
"0.6199654",
"0.61690414",
"0.6163885",
"0.61347663",
"0.6107581",
"0.60302866",
"0.60202134",
"0.6018099",
"0.6005248",
"0.60019904",
"0.5973936",
"0.5925... | 0.7673257 | 0 |
List or create friendrequests. Create an unconfirmed friendship between two users. Or return all friendships which are not confirmed for the current user. | def create_friend_request():
if request.method == "GET":
friend_requests = [f.to_dict() for f in g.user.get_friend_requests()]
return jsonify({'success': True, 'friend_requests': friend_requests})
if request.method == "POST":
# Get recieving user id from request
json = request.g... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_pending_friendships(self):\n url = 'friendships/pending/'\n return self.send_request(url)",
"def get_friend_requests(self, user):\n return self.filter(addresser_user=user, status=Friendship.STATUS_PENDING, active=True)",
"def friend_request():\n if 'username' not in session:\n ... | [
"0.66678417",
"0.65838015",
"0.64492136",
"0.6419166",
"0.6355479",
"0.6347656",
"0.63212603",
"0.6301099",
"0.6292718",
"0.62728006",
"0.6239098",
"0.62126476",
"0.61244184",
"0.60886",
"0.6074877",
"0.6053998",
"0.6042511",
"0.60373974",
"0.59732705",
"0.5967323",
"0.59309"... | 0.7035371 | 0 |
Get, update or delete friendship with the specified id. | def get_friend_request_with_id(id):
# Get friend request
friendship = Friendship.query.get(id)
if friendship is None:
raise CustomError(
404,
message="Friendship with id: {} not found.".format(id)
)
can_view = friendship.actioning_user_id == g.user.id or \
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_friend(request, id):\n user = request.user\n friend = get_object_or_404(User, id=id)\n user.profile.friends.remove(friend)\n friend.profile.friends.remove(user)\n messages.success(\n request,\n 'User deleted from your friends list'\n )\n return redirect('profiles:profi... | [
"0.6267513",
"0.60474205",
"0.5893467",
"0.57769",
"0.57769",
"0.57769",
"0.55159366",
"0.5514679",
"0.5414053",
"0.53229433",
"0.5308454",
"0.52603304",
"0.52275467",
"0.5149211",
"0.51255256",
"0.51151985",
"0.51151985",
"0.5048067",
"0.49942237",
"0.49900073",
"0.49625716"... | 0.74585414 | 0 |
outLookSender is not utilized in this module but wrote the function in case we want to send from an outlook account in the future | def outLookSender(receiverAddress, receiverName, retainedCompany, companyName, senderName, senderTitle, senderCompany, senderEmail, senderCompanyHomePage, senderPhone, returnHTML=False):
subj = f'Engineers from {retainedCompany} Search'
if returnHTML:
[text, html] = emailTextHTML(receiverName, retainedC... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pcorMacVerification(window,refrenceid,objectidentifier,texttoenter):\n try:\n buttons = getAppButtons(window)\n atomacclick(buttons[9])\n childwindow = refrenceid.windowsR()\n protectMoreDevicestitle = getApplicatontitle(childwindow[0])\n entertext(protectMoreDevicestitle,... | [
"0.5824598",
"0.5588486",
"0.5576109",
"0.55656964",
"0.55588704",
"0.5537601",
"0.55139714",
"0.55043477",
"0.5502522",
"0.54980785",
"0.54489857",
"0.5415622",
"0.5409443",
"0.53969055",
"0.5394186",
"0.5353212",
"0.5353212",
"0.534986",
"0.5313206",
"0.5311404",
"0.5300741... | 0.65203226 | 0 |
emailJobs is a function that is used to email jobs/careers email addresses for companies in a dataframe | def emailJobs(
df,
retainedCompany,
senderName,
defaultSenderEmail,
emailPassword,
senderTitle,
senderCompany,
senderCompanyHomePage,
senderPhone,
noContactCompanyListPickleFileName,
port=465,
returnHTML=True
):
try:
with open(noContactC... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send_email(jobs):\n jobs = jobs\n server = smtplib.SMTP(\"smtp.gmail.com\", 587)\n server.ehlo()\n server.starttls()\n server.ehlo()\n\n server.login(EMAIL, PASS)\n\n subject = f\"Job Scraper Results\"\n\n if jobs != \"Not working\":\n body = []\n job_ids = [\n ... | [
"0.6686441",
"0.573404",
"0.5680976",
"0.5586321",
"0.5568828",
"0.5565883",
"0.5497524",
"0.54533464",
"0.537631",
"0.5351467",
"0.5310948",
"0.5301148",
"0.52795285",
"0.5278291",
"0.5266971",
"0.52349377",
"0.5156166",
"0.51303834",
"0.51244825",
"0.5099825",
"0.5099411",
... | 0.8165515 | 0 |
Display HTML icon of OS distribution. | def show_os_icon(self):
if self.os == 0:
return "<i class='devicon-debian-plain'></i>"
elif self.os == 1:
return "<i class='devicon-redhat-plain'></i>"
else:
return "?" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def downloadicon_name(self):\n return 'platform_%s.gif' % \\\n re.sub(r'\\W', '_', self.context.getPlatform()).lower()",
"def icon(self) -> str:\n return ICON_SERVER",
"def icon(self):\n return \"mdi:hubspot\"",
"def icon(self):\n return ICON_BUS",
"def icon(s... | [
"0.6832323",
"0.68212587",
"0.6478877",
"0.6392684",
"0.63691825",
"0.63691825",
"0.63691825",
"0.63691825",
"0.63691825",
"0.63691825",
"0.63691825",
"0.63691825",
"0.63691825",
"0.63691825",
"0.63597417",
"0.63435024",
"0.63178104",
"0.6314043",
"0.6314043",
"0.6243124",
"0... | 0.83448386 | 0 |
Sets "_total_posts" as amount of posts in the VK domain. | async def _set_total_posts_in_domain(self) -> None:
logger.info('Getting total posts in "vk.com/%s"...', self.vk_domain)
params = {
"v": settings.VKAPI_VERSION,
"access_token": settings.VKAPI_TOKEN,
"count": 1, # Enough just to get total post in domain.
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def posts_count(self):\n return Post.objects.filter(user__username = self.user.username).count()",
"def num_posts(self):\n\n return FlicketTicket.query.filter_by(started_id=self.id).count() + FlicketPost.query.filter_by(\n user_id=self.id).count()",
"def _update_count(self):\n s... | [
"0.63555706",
"0.6204205",
"0.56337523",
"0.55793494",
"0.5573961",
"0.5543833",
"0.5520672",
"0.55201143",
"0.5465146",
"0.5398032",
"0.53932655",
"0.53263414",
"0.52809906",
"0.52755684",
"0.5259448",
"0.5227877",
"0.51914954",
"0.5175302",
"0.51708394",
"0.5170826",
"0.516... | 0.84554565 | 0 |
Fetches posts from VK domain asynchronously and put it into "posts" attribute. | async def fetch_posts(self) -> None:
async def fetch_posts_for_offset(offset) -> list:
logger.info(
"(offset %i) Start fetching posts from vk.com/%s...",
offset,
self.vk_domain,
)
# VK Script code for /execute method.
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fetch_posts():\n get_chain_address = F\"{CONNECTED_NODE_ADDRESS}/chain\"\n response = requests.get(get_chain_address)\n if response.status_code == 200:\n content = []\n chain = json.loads(response.content)\n for block in chain[\"chain\"]:\n for tx in block[\"transaction... | [
"0.655602",
"0.65269387",
"0.6413515",
"0.6018604",
"0.5916808",
"0.59025943",
"0.5787382",
"0.57700604",
"0.5734009",
"0.57019544",
"0.5652772",
"0.56395626",
"0.5616751",
"0.5613428",
"0.56133306",
"0.56015396",
"0.5592875",
"0.5583471",
"0.5548579",
"0.551852",
"0.55078864... | 0.7330048 | 0 |
Creates posts as Pydantic schemas based on posts data given from VK API. | def posts_as_schemas(posts_from_vk: list[dict]) -> list[Post]:
posts = []
for post_from_vk in posts_from_vk:
try:
post = Post(
date=post_from_vk["date"],
likes=post_from_vk["likes"]["count"],
text=post_from_vk["text"],
path=f"w... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def posts_post():\n data = request.json\n\n try:\n validate(data, post_schema)\n except ValidationError as error:\n data = {\"message\": error.message}\n return Response(json.dumps(data), 422, mimetype=\"application/json\")\n\n post = Post(title=data[\"title\"], body=data[\"body\"]... | [
"0.6354075",
"0.6284115",
"0.6081727",
"0.59250623",
"0.57985914",
"0.57881165",
"0.56837225",
"0.5657414",
"0.56563574",
"0.56495565",
"0.56208336",
"0.56018806",
"0.55971843",
"0.55958605",
"0.557369",
"0.55589396",
"0.5542766",
"0.5523133",
"0.5506989",
"0.5501767",
"0.550... | 0.7757099 | 0 |
Builds an HParam object with default hyperparameters. | def default_hparams():
raise NotImplementedError('Not implemented') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def default_hparams():\n\n model_hparams = hparams.ModelHparams(\n model_name='imagenet_resnet_50',\n model_init='kaiming_normal',\n batchnorm_init='uniform',\n )\n\n dataset_hparams = hparams.DatasetHparams(\n dataset_name='imagenet',\n b... | [
"0.70342475",
"0.7031786",
"0.6892825",
"0.67746496",
"0.6762069",
"0.6687497",
"0.66754377",
"0.6643588",
"0.6621793",
"0.65395397",
"0.6534683",
"0.6510586",
"0.64588934",
"0.6378265",
"0.63729376",
"0.63572174",
"0.62473166",
"0.62324756",
"0.6184058",
"0.61717397",
"0.612... | 0.74614435 | 0 |
Evaluates the trained model using the specified features and labels. | def evaluate(self, features, labels):
raise NotImplementedError('Not implemented') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def evaluate(model, eval_data, num_labels): \n # Turn on the evaluation state to ignore dropouts\n model.eval()\n results = [predict(model, x) for x, y in eval_data]\n f1_score, accuracy = get_metrics(np.array([y for x, y in eval_data]), results, num_labels)\n return f1_score, accuracy",
"def m... | [
"0.71969485",
"0.6895252",
"0.68876994",
"0.6868299",
"0.6828266",
"0.68280625",
"0.6817962",
"0.6815478",
"0.6739548",
"0.66729695",
"0.66729695",
"0.6669808",
"0.6641863",
"0.65919566",
"0.6583201",
"0.6532106",
"0.6510232",
"0.6506622",
"0.65015924",
"0.64879614",
"0.64562... | 0.8275948 | 0 |
Simple wrapper around sklearn's learning curve module | def learning_curve(self, features, labels):
return learning_curve(self._model, features, labels) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def train(self,features,y):\r\n \r\n if self.learn_type == \"nn\":\r\n #generate supervised dataset\r\n return(self.learner.train_on_batch(features,y))\r\n elif self.learn_type == \"linear\":\r\n grad = 0\r\n n = len(features)\r\n for i in... | [
"0.64221656",
"0.63034314",
"0.6246641",
"0.6199103",
"0.61902195",
"0.6133346",
"0.6075857",
"0.6074158",
"0.6016552",
"0.5998704",
"0.59975034",
"0.59883845",
"0.59740204",
"0.59331024",
"0.5884026",
"0.58812094",
"0.5867041",
"0.58130425",
"0.5809215",
"0.5798471",
"0.5792... | 0.70836437 | 0 |
Create an agent membership | def create_agent_membership(self, context, agent_membership):
am = agent_membership['agent_membership']
with context.session.begin(subtransactions=True):
am_db = AgentMembership(id=am['id'],
ip_address=am['ip_address'])
context.session.add(am_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_member(self, body=None):\r\n return self.post(self.members_path, body=body)",
"def add_member():\n client = RequestManager()\n client.set_method(\"POST\")\n client.set_endpoint(\"/accounts/{0}/memberships\".format(CONFIG_DATA['account_id']))\n body = {\"person_id\": ... | [
"0.6627206",
"0.63848805",
"0.6290456",
"0.6268151",
"0.62504977",
"0.624233",
"0.6192578",
"0.59588885",
"0.5937359",
"0.59215134",
"0.589374",
"0.5893678",
"0.58593506",
"0.58082986",
"0.58055055",
"0.5803748",
"0.580091",
"0.5796165",
"0.5793468",
"0.57622015",
"0.57265323... | 0.7037421 | 0 |
Test load class works correctly and raises right exceptions. | def test_load_class():
full_classname = 'collections.namedtuple'
cls_ = load_class(full_classname)
assert cls_ is collections.namedtuple
with pytest.raises(ValueError):
full_classname = 'collections.Foobar'
load_class(full_classname)
with pytest.raises(ImportError):
full_cl... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_load_testcase(self):\n tests = self.loader.load(\"tests.sampletest.hellotest.HelloTest\")\n self.assertEqual(len(tests), 1)\n from tests.sampletest.hellotest import HelloTest\n\n self.assertEqual(type(tests[0]), HelloTest)",
"def test_load_testcase_in_module(self):\n t... | [
"0.7552986",
"0.7182643",
"0.70636034",
"0.686629",
"0.6754328",
"0.67336494",
"0.6622316",
"0.6577228",
"0.65132713",
"0.6475406",
"0.6446178",
"0.6431292",
"0.6425918",
"0.63992125",
"0.6388809",
"0.6313314",
"0.6301513",
"0.62873274",
"0.6244719",
"0.62361884",
"0.6233843"... | 0.72938436 | 1 |
irq_handler contains the code you want to execute when the interrupt occurs. Define your own callback function here by rewriting the code. We make an LED flash in this example. | def irq_handler():
# open an LED session
with LEDs() as LED:
# specify the LED which you want to control
led = Led.LED1
# specify the LED status
led_on_off = True
# writes values 10 times, which makes LED1 flash for 3 seconds
for x in range(0, 10):
# t... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def irq(self, handler: Callable, trigger: int, hard: bool = False) -> Callable:",
"def enable_irq(state:int):",
"def extirq_cbf(task):\n try:\n if not execute_LM_function_Core(task.split(' ')):\n console_write(\"[IRQ] EXTIRQ execute_LM_function_Core error: {}\".format(task))\n except Ex... | [
"0.6793415",
"0.59784335",
"0.5772505",
"0.5751147",
"0.569456",
"0.56923246",
"0.55878675",
"0.5526748",
"0.53978044",
"0.50646555",
"0.4927286",
"0.4895538",
"0.47954524",
"0.4737531",
"0.4658877",
"0.4636048",
"0.46294534",
"0.46239135",
"0.45867148",
"0.45833647",
"0.4576... | 0.72954494 | 0 |
This property returns the training data, and loads the training data if it doesn't exist. Note that this function returns the training data and labels in the form ([MPS input size, batch, other dimensions], [batch, classifications]) in accordance with how it is used in the MPS and MPSOptimizer classes. If the data is r... | def training_data(self):
if self._training_data is None:
self._load_training_data()
if self._swapped_training_data is None:
self._swapped_training_data = {}
for key, value in self._training_data.items():
self._swapped_training_data[key] = value
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_training_data(self) -> Tuple[List[np.ndarray], np.ndarray]:\n return self._load_set(config.TRAIN_DIR, True)",
"def getTrainingData(self):\n raise NotImplementedError",
"def get_training_data() -> GraphDataset:\n _load_data_if_needed()\n return training_data",
"def get_data_train(... | [
"0.7380025",
"0.71378094",
"0.6946885",
"0.69251007",
"0.6852432",
"0.6813262",
"0.6799918",
"0.6751542",
"0.6742031",
"0.6650401",
"0.6590069",
"0.65826356",
"0.64915186",
"0.6483886",
"0.6470438",
"0.6446683",
"0.6443755",
"0.62918407",
"0.6268519",
"0.6244086",
"0.6243447"... | 0.72757715 | 1 |
Property giving the number of training samples for each key | def num_train_samples(self):
if self._num_training_samples is None:
for key, value in self._training_data.items():
self._num_training_samples[key] = len(value[0])
return self._num_training_samples | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def num_training_examples(self):",
"def get_num_train_samples(self):\n raise NotImplementedError",
"def __len__(self):\n if self.TRAIN_BOOL is True:\n count = len(self.dict_batch_1[b'data'])\n count += len(self.dict_batch_2[b'data'])\n count += len(self.dict_batch... | [
"0.76472265",
"0.72392845",
"0.7154465",
"0.71007866",
"0.6989497",
"0.6887514",
"0.68653405",
"0.6852151",
"0.6844715",
"0.680676",
"0.6782863",
"0.67534184",
"0.6745939",
"0.6720424",
"0.670524",
"0.66739583",
"0.66528374",
"0.66478294",
"0.66011435",
"0.659892",
"0.6594394... | 0.7513668 | 1 |
Property giving the number of test samples | def num_test_samples(self):
if self._num_test_samples is None:
for key, value in self._test_data.items():
self._num_test_samples[key] = len(value[0])
return self._num_test_samples | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _number_of_samples(self):\n return len(self._raw_data.samples)",
"def setTestSampleSize(self, Ntest):\n self.Ntest = Ntest",
"def getNrSamples(self): \r\n return self.numSamples",
"def num_training_examples(self):",
"def sample_count(self):",
"def get_number_of_testing(self):\... | [
"0.76248336",
"0.7584526",
"0.7412485",
"0.74109805",
"0.7401342",
"0.7390789",
"0.72752166",
"0.726213",
"0.7233075",
"0.7224675",
"0.71610683",
"0.71362716",
"0.71249604",
"0.70941573",
"0.7070653",
"0.704998",
"0.70279443",
"0.7010169",
"0.6996375",
"0.6985382",
"0.6942792... | 0.8134777 | 0 |
Highlights currentSelection on stdscr. | def highlightSelection(stdscr, selection):
s = tuple(list(selection.addStrArgs)+[curses.A_REVERSE])
stdscr.addstr(*s) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def switchSelection(stdscr, lastSelection, currentSelection):\n stdscr.addstr(*lastSelection.addStrArgs)\n highlightSelection(stdscr, currentSelection)",
"def draw_selected(self):\n if self.get_selected() is not None and not self.check_if_locked(self.get_selected()):\n self.color_cell(pos... | [
"0.77326286",
"0.6310758",
"0.62849665",
"0.6241305",
"0.6179359",
"0.6145725",
"0.6066579",
"0.5976721",
"0.59747756",
"0.5841172",
"0.5825609",
"0.5814059",
"0.57745796",
"0.5750539",
"0.5745168",
"0.5714649",
"0.56804645",
"0.5667968",
"0.5662644",
"0.56395173",
"0.5605114... | 0.75370693 | 1 |
This initializes the DotStars object by setting a buffer, and creating an SPI object. The start and end frames for the SPI communication are created, and the leds are cleared of values. | def __init__(self, leds):
self.ledcount = leds
# create a buffer
self.buffersize = self.ledcount * 4
self.buffer = bytearray(self.ledcount * 4)
self.emptybuffer = bytearray(self.ledcount * 4)
for i in range(0, self.buffersize, 4):
self.emptybuffer[i] = 0xff
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, spi, dc, rst, led):\n self._spi = spi\n self._spi.open()\n self._spi.set_mode(0)\n self._spi.set_clock_frequency(4000000)\n\n self._dc = dc\n self._rst = rst\n self._led = led\n self._enabled = False",
"def SPIsetup(self):\n self.w... | [
"0.6566145",
"0.6351516",
"0.63373953",
"0.6181888",
"0.61446565",
"0.6111663",
"0.59349567",
"0.57059205",
"0.55544007",
"0.554452",
"0.5522998",
"0.5509588",
"0.5503774",
"0.5380477",
"0.53760433",
"0.5336554",
"0.5321746",
"0.5299691",
"0.52520025",
"0.5248618",
"0.5240898... | 0.74753237 | 0 |
This method clears all the LEDs in the DotStar object | def clearleds(self):
self.buffer = self.emptybuffer[:] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reset(self):\n for tlight in self.trafficLights:\n self.trafficLights[tlight].reset()",
"def clear(tft, oled):\n oled.fill(tft.BLACK)",
"def clear(self):\n self._delayvalue = _CFG[\"delay\"]\n self._colormode = _CFG[\"colormode\"]\n self._delete(\"all\")\n ... | [
"0.7280109",
"0.71445733",
"0.70629704",
"0.7045428",
"0.7045238",
"0.6974367",
"0.6902242",
"0.6812371",
"0.679938",
"0.6789614",
"0.6783468",
"0.6701193",
"0.6695715",
"0.66421294",
"0.6637276",
"0.6621712",
"0.6612257",
"0.6599522",
"0.6587036",
"0.6560823",
"0.65587413",
... | 0.7821158 | 0 |
View all the images in the dataset, on a 3 by X grid size. | def view_images(dataset, size):
images, labels = dataset
assert images.shape[0] == labels.shape[0]
num_images = images.shape[0]
num_cols = 3
num_rows = np.ceil(num_images / num_cols).astype("int")
plt.figure(figsize=size)
for i in range(num_images):
image = images[i]
label =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show_imgs(dataset, n_imgs, plot_size=(15, 15), cmap=None):\n n_cols = int(np.sqrt(n_imgs))\n n_rows = int(np.ceil(np.sqrt(n_imgs)))\n class_idx = dataset.class_to_idx\n idx_class = idx_to_class(class_idx)\n\n fig, axes = plt.subplots(n_rows, n_cols, figsize=plot_size)\n for i, ax in enumerate... | [
"0.6872789",
"0.6706518",
"0.66048354",
"0.65576744",
"0.6477456",
"0.6438162",
"0.64273864",
"0.6386546",
"0.6381494",
"0.63184965",
"0.6311449",
"0.62808603",
"0.6278003",
"0.6259482",
"0.6259482",
"0.62534124",
"0.6243781",
"0.6227257",
"0.6224085",
"0.6216505",
"0.6158989... | 0.760682 | 0 |
Normalises and reshapes the images in the dataset. | def normalise(dataset):
# Scale images to the [0, 1] range
dataset = dataset.astype("float32") / 255
# Make sure images have shape (28, 28, 1)
return np.expand_dims(dataset, -1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def normalize_dataset(self):",
"def normalize_images(data, blend_cat, Args):\n im = data['X_train']['blend_image']\n std = np.std(im)\n mean = np.mean(im)\n data['X_train']['blend_image'] = (im - mean) / std\n data['X_val']['blend_image'] = (data['X_val']['blend_image'] - mean) / std\n data['X_... | [
"0.69572496",
"0.67912114",
"0.67600954",
"0.6746723",
"0.6741553",
"0.6741553",
"0.6712757",
"0.667788",
"0.66753983",
"0.66424495",
"0.6628572",
"0.6604109",
"0.657797",
"0.65456814",
"0.6539488",
"0.64729387",
"0.6469001",
"0.64613545",
"0.6418981",
"0.63990253",
"0.639689... | 0.7404679 | 0 |
Checks the date and time, and then decides if a shift from master to slave (or vice versa) is needed. If necessary, makes the shift. | def main():
date = time.gmtime().tm_mday
if date == 1 or date == 2: # in case it missed once
# shift from slave to master, checking to ensure it hasn't already happened
status = check_status()
if status == 'slave':
slave_to_master()
elif status == 'master':
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __is_valid_move(self, scheduling_unit, turnus, date, person, overtime, depth=0, check_turnuses=[]):\n \n \n if not schedule_utils.is_valid_move (scheduling_unit, turnus, date, person, overtime):\n return False\n \n # if the workplace has the special rule: work in the afternoon, if the n... | [
"0.5707775",
"0.56430596",
"0.5583629",
"0.5324878",
"0.5245917",
"0.5093938",
"0.50450516",
"0.49869803",
"0.4892492",
"0.488806",
"0.4854944",
"0.485275",
"0.48295307",
"0.48010412",
"0.47898087",
"0.4774762",
"0.47731286",
"0.4770391",
"0.47576922",
"0.47565082",
"0.471500... | 0.74977547 | 0 |
Check the status of the application, i.e., whether it is running on the master or slave. Also check to see if there are any issues, like the web dyno on the slave running, or both workers running etc. | def check_status():
# assume no web dynos on master - there should never be a web dyno on master
r = req.get(f"{MASTER_API_URL}/formation/worker", headers=MASTER_API_HEADERS)
if r.status_code != req.codes.ok:
print("Couldn't get master worker formation")
print(r.status_code, ":", r.text)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_configuration_server(self) -> bool:\n return (\n self.container is not None\n and self.container.exec_run(\n \"bash -c 'curl -s --head http://localhost:19071/ApplicationStatus'\"\n )\n .output.decode(\"utf-8\")\n .split(\"\\r\\n... | [
"0.6630676",
"0.6584592",
"0.64988655",
"0.6488543",
"0.6485963",
"0.6476117",
"0.6447399",
"0.63786393",
"0.62928927",
"0.6289477",
"0.6250488",
"0.62484485",
"0.6197466",
"0.6183795",
"0.6161205",
"0.61303514",
"0.61219287",
"0.61159056",
"0.6114376",
"0.609758",
"0.6067191... | 0.6729618 | 0 |
Shift the process from master to slave, shifting data as needed. | def master_to_slave():
print("Shifting from master to slave")
stop_master_worker()
setup_slave_web()
prepare_push()
push_to_slave()
stop_slave_web()
start_slave_worker()
print("DONE!") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def slave_to_master():\n print(\"Shifting from slave to master\")\n stop_slave_worker()\n setup_slave_web()\n pull_from_slave()\n commit_pull_to_db()\n stop_slave_web()\n start_master_worker()\n print(\"DONE!\")",
"def runSlaveRun():\n\n np.set_printoptions(linewidth=1000)\n functio... | [
"0.72516125",
"0.5815426",
"0.567222",
"0.5663159",
"0.54625714",
"0.5429651",
"0.53810555",
"0.53091127",
"0.5294686",
"0.5285994",
"0.51691014",
"0.5157244",
"0.5134187",
"0.512011",
"0.50734735",
"0.50418085",
"0.5016566",
"0.5001079",
"0.4958527",
"0.49188",
"0.49104735",... | 0.7314937 | 0 |
Shift the process from slave to master, shifting data as needed. | def slave_to_master():
print("Shifting from slave to master")
stop_slave_worker()
setup_slave_web()
pull_from_slave()
commit_pull_to_db()
stop_slave_web()
start_master_worker()
print("DONE!") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def master_to_slave():\n print(\"Shifting from master to slave\")\n stop_master_worker()\n setup_slave_web()\n prepare_push()\n push_to_slave()\n stop_slave_web()\n start_slave_worker()\n print(\"DONE!\")",
"def write_master(self, data):\n self._write(self.master_fd, data)",
"def... | [
"0.72428024",
"0.5692221",
"0.56806463",
"0.55942285",
"0.5393446",
"0.5345593",
"0.53245896",
"0.53045934",
"0.5239213",
"0.5215958",
"0.5118116",
"0.5114614",
"0.50847006",
"0.5059445",
"0.5055491",
"0.5023818",
"0.5010442",
"0.5004643",
"0.49860305",
"0.49616227",
"0.49346... | 0.7228141 | 1 |
Sets up the web server on the slave, then checks it. | def setup_slave_web():
print("Starting slave web")
r = req.patch(f"{SLAVE_API_URL}/formation/web", json=API_PAYLOAD_1, headers=SLAVE_API_HEADERS)
if r.status_code != req.codes.ok:
print("Unable to start the web dyno on slave")
print(r.text)
return False
#wait a bit for the web pr... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setup_server(manager):\n if not manager.is_daemon:\n return\n\n web_server_config = manager.config.get('web_server')\n\n if not web_server_config:\n return\n\n web_server = WebServer(\n bind=web_server_config['bind'],\n port=web_server_config['port'],\n )\n\n if we... | [
"0.6809068",
"0.67656696",
"0.6656338",
"0.6610853",
"0.65221626",
"0.6354455",
"0.62950474",
"0.6216161",
"0.62008417",
"0.62003654",
"0.6176954",
"0.601398",
"0.6004903",
"0.5986498",
"0.59861344",
"0.5985435",
"0.5959048",
"0.5956801",
"0.5941647",
"0.58429754",
"0.5814541... | 0.81821865 | 0 |
Stops the web process on the slave. | def stop_slave_web():
print("Stopping slave web")
r = req.patch(f"{SLAVE_API_URL}/formation/web", json=API_PAYLOAD_0, headers=SLAVE_API_HEADERS)
if r.status_code != req.codes.ok:
print("Unable to stop the web dyno on slave")
print(r.text)
return False
#wait a bit for the web proc... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def webserver_stop():\n run(\"kill $(cat %s)\" % GUNICORN_PIDFILE)\n run(\"rm %s\" % GUNICORN_PIDFILE)",
"def stop_slave_worker():\n print(\"Stopping slave worker\")\n r = req.patch(f\"{SLAVE_API_URL}/formation/worker\", json=API_PAYLOAD_0, headers=SLAVE_API_HEADERS)\n if r.status_code != req.code... | [
"0.7413745",
"0.7409462",
"0.70902383",
"0.7082552",
"0.68931115",
"0.68733066",
"0.68609893",
"0.6817112",
"0.67590433",
"0.67129856",
"0.6705761",
"0.6702287",
"0.66915804",
"0.6671726",
"0.6669743",
"0.6660702",
"0.66476685",
"0.66400963",
"0.6629474",
"0.6618239",
"0.6569... | 0.8396582 | 0 |
Starts the worker process on the master. | def start_master_worker():
print("Starting master worker")
r = req.patch(f"{MASTER_API_URL}/formation/worker", json=API_PAYLOAD_1, headers=MASTER_API_HEADERS)
if r.status_code != req.codes.ok:
print("Unable to start the worker dyno on master")
print(r.text)
return False
#wait a b... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def worker(ctx_obj):\n execute(start_worker_command(settings=ctx_obj['settings']))",
"def start(self):\n control_process = mp.Process(target = self._start, args = [])\n control_process.start()",
"def start_slave_worker():\n print(\"Starting slave worker\")\n r = req.patch(f\"{SLAVE_API_U... | [
"0.74038696",
"0.7210624",
"0.70151126",
"0.7001591",
"0.6949406",
"0.6915681",
"0.68317443",
"0.67932683",
"0.6752919",
"0.6713696",
"0.6707904",
"0.66620183",
"0.66078997",
"0.6578205",
"0.647364",
"0.6429986",
"0.63926333",
"0.6350077",
"0.6317507",
"0.6302991",
"0.6230232... | 0.7759477 | 0 |
Stops the worker process on the master. | def stop_master_worker():
print("Stopping master worker")
r = req.patch(f"{MASTER_API_URL}/formation/worker", json=API_PAYLOAD_0, headers=MASTER_API_HEADERS)
if r.status_code != req.codes.ok:
print("Unable to stop the worker dyno on master")
print(r.text)
return False
#wait a bit... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stop(self):\n\n # immediate is necessary if it's in recovery (for now).\n # we don't care the result.\n master = gp.MasterStop(\"Stopping Master Standby\",\n self.datadir, mode='immediate')\n master.run()",
"def stop_slave_worker():\n print(\"Stopp... | [
"0.7388482",
"0.7279379",
"0.7237633",
"0.6967597",
"0.6921898",
"0.68627954",
"0.6821255",
"0.68206173",
"0.67904496",
"0.6728565",
"0.67254424",
"0.67202437",
"0.6709311",
"0.67050105",
"0.6670142",
"0.66601145",
"0.66253245",
"0.6620445",
"0.6605411",
"0.66041267",
"0.6577... | 0.76747125 | 0 |
Starts the worker process on the slave. | def start_slave_worker():
print("Starting slave worker")
r = req.patch(f"{SLAVE_API_URL}/formation/worker", json=API_PAYLOAD_1, headers=SLAVE_API_HEADERS)
if r.status_code != req.codes.ok:
print("Unable to start the worker dyno on slave")
print(r.text)
return False
#wait a bit fo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run_worker(self):\n # TODO(xiejw): To allow execution framework to add train hooks.\n return self._start_distributed_training()",
"def worker(ctx_obj):\n execute(start_worker_command(settings=ctx_obj['settings']))",
"def start_master_worker():\n print(\"Starting master worker\")\n r = req.pa... | [
"0.7050969",
"0.68271756",
"0.6755335",
"0.67251605",
"0.65629065",
"0.65401715",
"0.6436881",
"0.6374149",
"0.6337312",
"0.6323815",
"0.6307696",
"0.6272211",
"0.62686425",
"0.62494606",
"0.6231326",
"0.61917204",
"0.61633587",
"0.61614466",
"0.6132043",
"0.61305064",
"0.612... | 0.7931532 | 0 |
Stops the worker process on the slave. | def stop_slave_worker():
print("Stopping slave worker")
r = req.patch(f"{SLAVE_API_URL}/formation/worker", json=API_PAYLOAD_0, headers=SLAVE_API_HEADERS)
if r.status_code != req.codes.ok:
print("Unable to stop the worker dyno on slave")
print(r.text)
return False
#wait a bit for ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Stop(self):\n if self.child_pid:\n self.data = self.host.Communicate(self.child_pid, echo_error=True,\n kill=True,\n kill_string=IperfServer.KILL_STRING)\n self.child_pid = None",
"def stop(self):\n\n # immediat... | [
"0.7121769",
"0.7078228",
"0.70730764",
"0.703866",
"0.69969434",
"0.6940482",
"0.6888461",
"0.6873332",
"0.6864292",
"0.6846163",
"0.6844958",
"0.6808371",
"0.6796847",
"0.6751896",
"0.6735001",
"0.6733168",
"0.6719779",
"0.67189586",
"0.66959256",
"0.6666449",
"0.6627743",
... | 0.817291 | 0 |
Uses the current cursor position, which is in a code view, and gets the corresponding instruction address that is associated to the code. Returns the start of the function if unable to calculate. | def get_src_to_inst(self) -> int:
# get the Qt document
doc: QCodeDocument = self.document()
# get the current position of the cursor
cursor = self.textCursor()
pos = cursor.position()
# get the node at the associated cursor position
current_node = doc.get_stmt... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_code(func):\n import inspect\n\n raw = \"\".join(inspect.getsource(func))\n found = re.findall(\"(k = .*)\", raw)\n\n if any(found):\n code = found[0]\n return code\n else:\n return \"\"",
"def getInstructionBefore(self, address: ghidra.... | [
"0.6299851",
"0.6007909",
"0.60040885",
"0.6001951",
"0.5926025",
"0.59078115",
"0.5856952",
"0.5770866",
"0.57665575",
"0.57530594",
"0.57365364",
"0.5735565",
"0.5707904",
"0.5673848",
"0.56713",
"0.5665861",
"0.5659602",
"0.5657597",
"0.5647901",
"0.5603577",
"0.5597595",
... | 0.7334392 | 0 |
Calculate a checksum for the given path. Will eventually use this to ensure config has changed before reloading. | def checksum(path):
with open(path, 'r') as f:
return md5(f.read()).digest() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_checksum(path: Union[Path, str]) -> str:\n path = Path(path)\n if not (path.is_file() or path.is_dir()):\n msg.fail(f\"Can't get checksum for {path}: not a file or directory\", exits=1)\n if path.is_file():\n return hashlib.md5(Path(path).read_bytes()).hexdigest()\n else:\n ... | [
"0.7271267",
"0.6893249",
"0.67964584",
"0.6699954",
"0.65897936",
"0.6586321",
"0.6519239",
"0.65081114",
"0.6485526",
"0.6472071",
"0.646679",
"0.6462213",
"0.64450413",
"0.64431435",
"0.63804424",
"0.6329311",
"0.6290257",
"0.62881494",
"0.6251396",
"0.6229306",
"0.6219351... | 0.7938589 | 0 |
Set up inotify if requested. | def _setup_inotify(self, flag):
i = None
if flag:
try:
import inotify.adapters
except ImportError:
raise AssertionError(
'cannot use inotify, package not installed')
else:
i = inotify.adapters.Inot... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start(self):\n self._class_setup()\n\n self._inotify_fd = InotifyFileWatcher._libc.inotify_init()\n if self._inotify_fd < 0:\n error = OSError('failed call to inotify_init')\n error.errno = ctypes.get_errno()\n error.strerror = errno.errorcode[ctypes.get_errno()]\n raise error\n ... | [
"0.68859357",
"0.6521524",
"0.5825635",
"0.5661374",
"0.56051093",
"0.5601565",
"0.55341774",
"0.5521033",
"0.54301476",
"0.53801805",
"0.53308344",
"0.521609",
"0.5213829",
"0.5188312",
"0.51532716",
"0.5120239",
"0.51025105",
"0.5082971",
"0.507481",
"0.50697386",
"0.506352... | 0.7264749 | 0 |
Create watch directory if it does not exist. | def _setup_watch(self, watch):
assert not isfile(watch), 'watch dir is a file'
if pathexists(watch):
return watch
os.makedirs(watch)
if self.chown:
try:
os.chown(watch, *self.chown)
except OSError:
pass # Non-fatal
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_dir(self):\n\n if not os.path.isdir(self.directory):\n os.mkdir(self.directory, 755)\n if not os.path.exists(self.log_file):\n from pathlib import Path\n Path(self.log_file).touch()",
"def start_check():\n if not os.path.exists(outfancy_temp_files):\n ... | [
"0.6459634",
"0.6346766",
"0.6331183",
"0.6299552",
"0.6197254",
"0.6110146",
"0.6098661",
"0.6089687",
"0.6088672",
"0.60865545",
"0.6084467",
"0.6080845",
"0.6065921",
"0.6042916",
"0.603886",
"0.59679985",
"0.5966238",
"0.5957223",
"0.59505254",
"0.5901048",
"0.5883695",
... | 0.77630746 | 0 |
Reload configuration. If reload command is given, run that, otherwise, signal process with HUP. | def reload_command(self):
if self.reload is None:
if not self.check_command():
LOGGER.info('Command dead, restarting...')
self.start_command(wait_for_config=False)
else:
LOGGER.info('Sending HUP signal...')
self.process.sen... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reload_config():\n subprocess.run([SUPERVISOR_CMD, \"reload\"])",
"def nginx_reload():\n log('reload nginx', yellow)\n sudo('/etc/init.d/nginx reload')",
"def reload_config(self):\n pass",
"def command_reload(interface,command,args):\n command_unload(interface,command,args)\n comman... | [
"0.75852543",
"0.6688586",
"0.6681827",
"0.66347086",
"0.633552",
"0.6311228",
"0.6310406",
"0.62902033",
"0.6279588",
"0.6202909",
"0.6199834",
"0.61551714",
"0.6126377",
"0.6089492",
"0.6079683",
"0.60628176",
"0.59531575",
"0.5931519",
"0.5927496",
"0.5915352",
"0.5904567"... | 0.8385148 | 0 |
Return False if command is dead, otherwise True. | def check_command(self):
return self.process is not None and self.process.poll() is None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_dead(self):\n if self.killer:\n if self.killer.stype == 'fire' and not (self.killer in self.pjs.fires):\n return True\n elif self.killer.stype == 'enemy' and self.timeout == 0:\n return True\n else:\n return False",
"def __is_act... | [
"0.6922289",
"0.6847067",
"0.68249875",
"0.66671854",
"0.66655314",
"0.6653957",
"0.65789324",
"0.6558258",
"0.6550506",
"0.649371",
"0.64785314",
"0.64250284",
"0.63963515",
"0.6387006",
"0.6375392",
"0.6337235",
"0.62643814",
"0.62609",
"0.6241368",
"0.6222854",
"0.62103415... | 0.69605875 | 0 |
Get unique list of new config files in watch dir. | def get_config(self):
config = set()
while True:
filenames = self.get_config_files()
for fn in filenames:
if fn not in self.watch_names:
filenames.remove(fn)
if fn in config:
filenames.remove(fn)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_config_files(self):\n flag, i = self.inotify\n\n if flag:\n kwargs = {}\n\n if PY3:\n kwargs['timeout_s'] = 0\n\n filenames = set()\n\n for event in i.event_gen(**kwargs):\n if event is None:\n break\... | [
"0.7831209",
"0.70418906",
"0.66463995",
"0.6577422",
"0.64742094",
"0.64292943",
"0.64021975",
"0.6402068",
"0.63111544",
"0.62958807",
"0.6260233",
"0.61890477",
"0.61561424",
"0.61066765",
"0.610564",
"0.6097907",
"0.6075739",
"0.6075056",
"0.6053437",
"0.6035494",
"0.6028... | 0.7109554 | 1 |
Kill the running command. | def kill(self):
if self.process is not None:
LOGGER.info('Killing command...')
self.process.kill()
self.process = None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def kill(self):\n\n self.proc.kill()",
"def kill(self):\n self._process.kill()",
"def kill(self):\n self._stop_proc(signal.SIGKILL)",
"def kill(self):\n self._update()\n if self.running_mode == \"local\":\n for process in self.processes:\n try:\n ... | [
"0.7861475",
"0.7555022",
"0.749188",
"0.7406674",
"0.72241443",
"0.7057569",
"0.7053252",
"0.7020611",
"0.7016701",
"0.69516635",
"0.693628",
"0.6888209",
"0.6873801",
"0.6854114",
"0.6798234",
"0.6792874",
"0.67909163",
"0.6775448",
"0.674491",
"0.6723775",
"0.6702169",
"... | 0.8239272 | 0 |
Backs up entire configuration. | def backup_config(self):
prev_config = set()
for src in self.config:
dst = '%s.prev' % src
LOGGER.debug('Backing up %s to %s', src, dst)
try:
shutil.copy(src, dst)
except IOError as e:
if e.errno != errno.ENOENT:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def backup(config_file, bakfile):\n return _backup_config(config_file, bakfile)",
"def backup(ctx, project, origin, force):\n\n if not check_main_conf(ctx):\n return\n\n if origin is not None and project is None:\n click.echo(\"--project option is required when --origin is set.\")\n ... | [
"0.6370239",
"0.62242675",
"0.61583614",
"0.61377156",
"0.6079129",
"0.60359734",
"0.59865093",
"0.59671223",
"0.59083843",
"0.5764068",
"0.5725047",
"0.5714281",
"0.56883514",
"0.56292564",
"0.5621002",
"0.5616206",
"0.5596354",
"0.5594662",
"0.55940187",
"0.5514033",
"0.549... | 0.6756827 | 0 |
Backup old config, write new config, test config, HUP or restore. | def test_and_swap(self, config):
LOGGER.info('Attempting to apply new configuration')
backup = self.backup_config()
# We have backed up ALL config files (not just the ones we might
# replace). If any error occurs from here out, we will need to restore
# our config, so we will use... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _backup_config(config_file, bak_path=None):\n try:\n if not bak_path:\n bak_path = config_file+\".bak\"\n with open(config_file, 'r') as oldfile, open(bak_path, 'w') as bakfile:\n tmp = oldfile.read(1024)\n while tmp:\n bakfile.write(tmp)\n ... | [
"0.7156795",
"0.7003359",
"0.67606544",
"0.6459555",
"0.64326864",
"0.63440835",
"0.63262016",
"0.63146156",
"0.62513983",
"0.6244165",
"0.6195551",
"0.61006075",
"0.60527635",
"0.6048218",
"0.60470015",
"0.60405976",
"0.6031093",
"0.59871054",
"0.5954373",
"0.59194183",
"0.5... | 0.72788405 | 0 |
Plot and save histograms from predicted steerings and real steerings. Arguments | def make_and_save_histogramsX(pred_steerings, real_steerings,
img_name = "histogramsX.png"):
pred_steerings = np.array(pred_steerings)
real_steerings = np.array(real_steerings)
max_h = np.maximum(np.max(pred_steerings), np.max(real_steerings))
min_h = np.minimum(np.min(pred_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_and_save_histogramsY(pred_steerings, real_steerings,\n img_name = \"histogramsY.png\"):\n pred_steerings = np.array(pred_steerings)\n real_steerings = np.array(real_steerings)\n max_h = np.maximum(np.max(pred_steerings), np.max(real_steerings))\n min_h = np.minimum(... | [
"0.76754117",
"0.64281666",
"0.6419849",
"0.63231015",
"0.6262315",
"0.62221205",
"0.6151655",
"0.6125331",
"0.6123557",
"0.61125845",
"0.6079311",
"0.60636973",
"0.6062547",
"0.6060509",
"0.6034784",
"0.6033427",
"0.60138935",
"0.6013693",
"0.6010012",
"0.59823984",
"0.59726... | 0.7740116 | 0 |
Plot and save histograms from predicted steerings and real steerings. Arguments | def make_and_save_histogramsY(pred_steerings, real_steerings,
img_name = "histogramsY.png"):
pred_steerings = np.array(pred_steerings)
real_steerings = np.array(real_steerings)
max_h = np.maximum(np.max(pred_steerings), np.max(real_steerings))
min_h = np.minimum(np.min(pred_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_and_save_histogramsX(pred_steerings, real_steerings,\n img_name = \"histogramsX.png\"):\n pred_steerings = np.array(pred_steerings)\n real_steerings = np.array(real_steerings)\n max_h = np.maximum(np.max(pred_steerings), np.max(real_steerings))\n min_h = np.minimum(... | [
"0.7740603",
"0.6428022",
"0.6419536",
"0.6322531",
"0.62623787",
"0.62226415",
"0.61514246",
"0.61257786",
"0.6123551",
"0.6112254",
"0.6079733",
"0.6064892",
"0.6062117",
"0.60601425",
"0.6035143",
"0.6033051",
"0.601378",
"0.6013595",
"0.6009719",
"0.5982897",
"0.59727293"... | 0.7675895 | 1 |
Plot and save confusion matrix computed from predicted and real labels. Arguments | def plot_confusion_matrix(real_labels, pred_prob, classes,
normalize=False,
img_name="confusion.png"):
real_labels = np.array(real_labels)
# Binarize predicted probabilities
pred_prob = np.array(pred_prob)
pred_labels = np.zeros_like(pred_prob)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_confusion_matrix(self, y_true, y_pred, title=None):\r\n\r\n if not title:\r\n title = 'confusion matrix'\r\n\r\n # Compute confusion matrix\r\n\r\n y_pred = np.array(y_pred)\r\n y_true = np.array(y_true)\r\n cm = confusion_matrix(y_true, y_pred)\r\n # O... | [
"0.7909803",
"0.77706945",
"0.7693289",
"0.7669506",
"0.7644297",
"0.7616977",
"0.757757",
"0.75686",
"0.7555622",
"0.7483602",
"0.74831176",
"0.74774474",
"0.7476126",
"0.7471495",
"0.7468893",
"0.7465456",
"0.74556404",
"0.7446722",
"0.74444157",
"0.7443814",
"0.74419767",
... | 0.7841449 | 1 |
Discover and add a Tasmota sensor. | async def async_discover_sensor(tasmota_entity, discovery_hash):
async_add_entities(
[
TasmotaSensor(
tasmota_entity=tasmota_entity, discovery_hash=discovery_hash
)
]
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def async_add_binary_sensor(mac):\n if USB_MOTION_ID in api_stick.devices[mac].features:\n _LOGGER.debug(\"Add binary_sensors for %s\", mac)\n async_add_entities([USBBinarySensor(api_stick.devices[mac])])\n\n # Register services\n platform.async_register_ent... | [
"0.6059688",
"0.583049",
"0.5694654",
"0.5584414",
"0.5579093",
"0.55689627",
"0.55304766",
"0.5517644",
"0.55015105",
"0.550125",
"0.5478783",
"0.54301524",
"0.54066986",
"0.5383559",
"0.5372278",
"0.5371746",
"0.5358791",
"0.53568757",
"0.53443986",
"0.5335553",
"0.5331908"... | 0.65760076 | 0 |
Installs the OpenMPI package on the VM. | def _Install(vm):
vm.Install('build_tools')
vm.Install('wget')
vm.RemoteCommand('wget %s -P %s' % (MPI_URL, INSTALL_DIR))
vm.RemoteCommand('cd %s && tar xvfz %s' % (INSTALL_DIR, MPI_TAR))
make_jobs = vm.NumCpusForBenchmark()
shared_lib_command = ('--enable-shared' if FLAGS.openmpi_enable_shared
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def AptInstall(vm):\n vm.RobustRemoteCommand('sudo apt-get {}'.format(REMOVE_MPI_CMD))\n _Install(vm)",
"def YumInstall(vm):\n vm.RobustRemoteCommand('sudo yum {}'.format(REMOVE_MPI_CMD))\n _Install(vm)",
"def install():\n PackCommandExecutor().pack()\n InstallCommandExecutor().install()",
"def ins... | [
"0.749848",
"0.6820002",
"0.6406495",
"0.6319433",
"0.62312424",
"0.61590135",
"0.61590135",
"0.6028888",
"0.59898764",
"0.5981365",
"0.5926291",
"0.59055406",
"0.5884631",
"0.58507264",
"0.5765704",
"0.5713537",
"0.57048243",
"0.5699972",
"0.5699972",
"0.5667024",
"0.5660338... | 0.80011517 | 0 |
Installs the OpenMPI package on the VM. | def AptInstall(vm):
vm.RobustRemoteCommand('sudo apt-get {}'.format(REMOVE_MPI_CMD))
_Install(vm) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _Install(vm):\n vm.Install('build_tools')\n vm.Install('wget')\n vm.RemoteCommand('wget %s -P %s' % (MPI_URL, INSTALL_DIR))\n vm.RemoteCommand('cd %s && tar xvfz %s' % (INSTALL_DIR, MPI_TAR))\n make_jobs = vm.NumCpusForBenchmark()\n shared_lib_command = ('--enable-shared' if FLAGS.openmpi_enable_shared\n... | [
"0.80011517",
"0.6820002",
"0.6406495",
"0.6319433",
"0.62312424",
"0.61590135",
"0.61590135",
"0.6028888",
"0.59898764",
"0.5981365",
"0.5926291",
"0.59055406",
"0.5884631",
"0.58507264",
"0.5765704",
"0.5713537",
"0.57048243",
"0.5699972",
"0.5699972",
"0.5667024",
"0.56603... | 0.749848 | 1 |
Uninstalls the OpenMPI package on the VM. | def _Uninstall(vm):
vm.RemoteCommand('cd {0} && sudo make uninstall'.format(MPI_DIR)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def AptUninstall(vm):\n remove_str = 'sudo apt-get --purge autoremove -y '\n for package in APT_PACKAGES:\n vm.RemoteCommand(remove_str + package)",
"def AptUninstall(vm):\n _Uninstall(vm)",
"def YumUninstall(vm):\n _Uninstall(vm)",
"def _unprovision_node(self, conn):\n conn.run(f\"rm -rf {EXPO... | [
"0.6643343",
"0.6554691",
"0.6437639",
"0.61634016",
"0.61421573",
"0.6033786",
"0.6024719",
"0.5982157",
"0.59412205",
"0.59231645",
"0.5891756",
"0.5881228",
"0.5796456",
"0.5779653",
"0.57771873",
"0.57449394",
"0.5722418",
"0.57108957",
"0.5706674",
"0.56761074",
"0.56503... | 0.8364465 | 0 |
This method provides an ability to set order book's deep on the fly. If some of deep's parameters is <0 (bid_count or ask_count) then method raise the custom ChangeOrderBookDeepError exception. | def set_deep(self, deep: Deep) -> None:
def is_deep_invalid(var: Deep):
return not isinstance(var, Deep) \
or False in [str(value).isdigit() for value in deep.__dict__.values()] \
or deep.bid_count < 0 \
or deep.ask_count < 0
# Exit ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_overflow_bids_market_default_depth(new_order_book: Callable[[], OrderBook]) -> NoReturn:\n book = new_order_book\n\n for _ in range(book.depth):\n book.add_offer('bids', 1, 1)\n\n assert book.depth == len(book.bids)\n assert not book.asks\n\n # try to put 21th lot into bids\n with... | [
"0.5391954",
"0.52650684",
"0.5231182",
"0.5148186",
"0.46605176",
"0.46045893",
"0.4553652",
"0.44586703",
"0.43845412",
"0.43609735",
"0.4305438",
"0.42446724",
"0.42142078",
"0.40942338",
"0.40583956",
"0.40488294",
"0.40381512",
"0.4022892",
"0.4010043",
"0.40016043",
"0.... | 0.79812324 | 0 |
Private method that provide an ability to sort the orders by price | def __sort_orders_by_price(self):
self.orders = sorted(self.orders, key=lambda o: o.price, reverse=True) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_ordering_by_price_desc(self):\n request = self.factory.get('/api/v1/cars', {'distance': 10000,\n 'ordering': '-price'})\n response = CarAdViewSet.as_view({'get': 'list'})(request)\n self.assertEqual(response.status_code, HTTPStatus.OK... | [
"0.6997947",
"0.6924603",
"0.68009967",
"0.64891934",
"0.64143217",
"0.6405557",
"0.63602364",
"0.62634486",
"0.6196882",
"0.61302906",
"0.60694",
"0.6041694",
"0.5944023",
"0.5943299",
"0.5924566",
"0.59217286",
"0.5914415",
"0.59045845",
"0.58919334",
"0.58767736",
"0.58767... | 0.8428332 | 0 |
This method provide an ability to find order by id and reject it. | def reject_order(self, order: Order) -> None:
order = self.get_order_by_id(order.id)
order.status = OrderStatus.REJECT | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _on_order_not_found(self, msg):\r\n parts = msg[\"id\"].split(\":\")\r\n oid = parts[1]\r\n self.debug(\"### got 'Order not found' for\", oid)\r\n # we are now going to fake a user_order message (the one we\r\n # obviously missed earlier) that will have the effect of\r\n ... | [
"0.6331195",
"0.6186556",
"0.6181075",
"0.6084242",
"0.5875732",
"0.57537323",
"0.5748262",
"0.5568031",
"0.5513399",
"0.5510577",
"0.5493943",
"0.54261667",
"0.54258156",
"0.5360014",
"0.52910525",
"0.5274176",
"0.52361274",
"0.51995444",
"0.5193858",
"0.51862836",
"0.516938... | 0.65955037 | 0 |
This method provide an ability to fill order in order book. This action means that order is completed. | def fill_order(self, order: Order) -> None:
order = self.get_order_by_id(order.id)
order.status = OrderStatus.FILL | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def complete_order(order):\n enroll_user_in_order_items(order)\n\n # If this order included assigned coupons, update them to indicate that they're redeemed\n order_coupon_ids = order.couponredemption_set.values_list(\n \"coupon_version__coupon__id\", flat=True\n )\n if order_coupon_ids:\n ... | [
"0.69658357",
"0.6763817",
"0.6571123",
"0.6434398",
"0.642819",
"0.637576",
"0.63689506",
"0.6323911",
"0.6295991",
"0.6225115",
"0.6218789",
"0.6211016",
"0.619821",
"0.61803144",
"0.61738944",
"0.61684597",
"0.61589706",
"0.6155346",
"0.61527157",
"0.61496073",
"0.61088544... | 0.72761214 | 0 |
Converts the auto incremented id of a ShortURL object and turns it into a shorturl hash | def encode(shorturl_id: int) -> str:
short_resource = []
while shorturl_id > 0:
character_index = shorturl_id % BASE
short_resource.append(CHARACTER_SPACE[character_index])
shorturl_id //= BASE
return "".join(short_resource[::-1]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def shortURLToId(self, shortURL):\n id = 0\n for i in shortURL: \n val_i = ord(i) \n if(val_i >= ord('a') and val_i <= ord('z')): \n id = id*62 + val_i - ord('a') \n elif(val_i >= ord('A') and val_i <= ord('Z')): \n id = id*62 + val_i - o... | [
"0.7222362",
"0.6813473",
"0.6670428",
"0.6613821",
"0.6553491",
"0.6440487",
"0.6438503",
"0.6381131",
"0.6311566",
"0.62947756",
"0.6259774",
"0.62407327",
"0.620263",
"0.61301494",
"0.61228126",
"0.6112265",
"0.6034276",
"0.59468937",
"0.5900785",
"0.5891555",
"0.58526796"... | 0.69266266 | 1 |
Attempt to place mover into contents. Returns a Boolean representation of success. | def contain(self, mover):
# Check if mover can exit old location
old_location = mover.location
if(not old_location):
return False
if(not old_location.allow_exit(mover)):
return False
# Check if mover can enter current location
if(not self.allow_ent... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def move(self) -> bool:\n pass",
"def allow_entry(self, mover):\n return True",
"def test_object_move(self):\n self.assertTrue(self.obj1 in self.room1.contents)\n # use move_to hook\n self.obj1.move_to(self.room2)\n self.assertFalse(self.obj1 in self.room1.contents)\n ... | [
"0.5737424",
"0.5638439",
"0.5441351",
"0.5409434",
"0.5399845",
"0.5309671",
"0.52931213",
"0.5276102",
"0.5168468",
"0.5082271",
"0.50646865",
"0.505076",
"0.50131536",
"0.50104046",
"0.50004804",
"0.4979135",
"0.49734983",
"0.4963041",
"0.49610388",
"0.49543136",
"0.495197... | 0.7234833 | 0 |
Determines if the mover is permitted to enter the room | def allow_entry(self, mover):
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def allowedToEnter(self):\n if base.cr.isPaid():\n return True\n place = base.cr.playGame.getPlace()\n myHoodId = ZoneUtil.getCanonicalHoodId(place.zoneId)\n if myHoodId in \\\n (ToontownGlobals.ToontownCentral,\n ToontownGlobals.MyEstate,\n T... | [
"0.6933369",
"0.6317256",
"0.6274393",
"0.6119734",
"0.6043591",
"0.6006229",
"0.59973824",
"0.5966571",
"0.59650975",
"0.59650975",
"0.5949079",
"0.590017",
"0.58607984",
"0.5843126",
"0.5832102",
"0.58177775",
"0.57856125",
"0.57780486",
"0.5743955",
"0.57223856",
"0.572238... | 0.66670233 | 1 |
Determines if the mover is permitted to exit the room. | def allow_exit(self, mover):
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_exited(self):\n agents = self.board[self.agent_locs_idx]\n return agents & (CellTypes.agent | CellTypes.exit) == CellTypes.exit",
"def can_exit(self) -> bool:\n return False",
"def check_exit(self, position, direction):\n if self.get_room((position[0] + direction[0], positio... | [
"0.6301413",
"0.6263654",
"0.62400985",
"0.60136616",
"0.58825636",
"0.58812755",
"0.58409286",
"0.5794512",
"0.5793184",
"0.5782265",
"0.5782265",
"0.57529366",
"0.5692975",
"0.5673591",
"0.56546485",
"0.56517553",
"0.5650926",
"0.5650613",
"0.5642109",
"0.56175417",
"0.5615... | 0.7196453 | 0 |
Called after the mover has entered the room. | def entered(self, mover):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def exited(self, mover):\n pass",
"def after_turn(self):\n pass",
"def game_over(self):\n self.end_of_level()\n self.message_holder.add_widget(self.you_lose_label)\n Clock.schedule_once(self.goto_menu, 5)",
"def end_of_level(self):\n Clock.unschedule(self.update)\n ... | [
"0.6746905",
"0.6695229",
"0.66767555",
"0.63322276",
"0.627838",
"0.627838",
"0.6254879",
"0.6229721",
"0.6191655",
"0.61626804",
"0.60663325",
"0.6041078",
"0.598377",
"0.59339255",
"0.5903108",
"0.585522",
"0.5828244",
"0.5815816",
"0.5759303",
"0.57528126",
"0.5750263",
... | 0.75459206 | 0 |
Called after the mover has exited the room. | def exited(self, mover):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def leave(self):\n self.pleaseQuit=1",
"def on_pre_leave(self):\n Logger.info('Application: Leaving the Intro screen.')",
"def on_pre_leave(self):\n Logger.info('Application: Leaving the Intro screen.')",
"def endGame(self):\n pass",
"def on_client_exit(self, game) -> None:\n ... | [
"0.6788173",
"0.65788233",
"0.65788233",
"0.65397877",
"0.6511395",
"0.6485533",
"0.6424921",
"0.6411908",
"0.64101607",
"0.6407878",
"0.637953",
"0.63781476",
"0.6357803",
"0.6351377",
"0.63508695",
"0.6343258",
"0.6334145",
"0.63243484",
"0.62887913",
"0.6288441",
"0.627727... | 0.78373396 | 0 |
Creates a tree from list. First element is root value, others are children nodes. (values or subtrees). | def construct(lst):
t = Tree()
t.root = lst[0]
for node in lst[1:]:
if isinstance(node, list):
t.nodes.append(construct(node))
else:
t.nodes.append(node)
return t | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_tree(tree_list, nums):\n\n if len(nums) == 0:\n return tree_list\n next_list = []\n j = 0\n for i in tree_list:\n for _ in range(2):\n if i is not None and j < len(nums):\n if nums[j] is No... | [
"0.70470774",
"0.69341266",
"0.6903691",
"0.6826804",
"0.67401844",
"0.6710746",
"0.65991884",
"0.6522682",
"0.63863814",
"0.6339975",
"0.63145685",
"0.63064444",
"0.6274908",
"0.6264302",
"0.62484676",
"0.62479275",
"0.6221631",
"0.62191725",
"0.6189883",
"0.6159182",
"0.615... | 0.7338503 | 0 |
convert list of dicts to ndarray of type np.float32 | def dicts2ndarray(data_dicts):
# NEVER make any assumption about the order of .keys() return
aps = [ap for ap in data_dicts[0].keys() if ap != 'tag']
aps.sort()
data_num = len(data_dicts)
data_len = len(data_dicts[0][aps[0]])
ndary = np.zeros([data_num, len(aps), data_len], dtype=np.float32)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def translate_pandas_to_numpy(data_list:list) -> list:\n list_size = len(data_list)\n for i in range(list_size):\n data_list[i] = data_list[i].values.astype('float32')\n return data_list",
"def convert_dict_to_ndarray(*dictionaries):\n\n array_list = []\n\n # Loop all dicts\n for dictio... | [
"0.6651815",
"0.65400195",
"0.61362433",
"0.6098978",
"0.60989004",
"0.60879093",
"0.60031056",
"0.59976625",
"0.59976625",
"0.59976625",
"0.59841895",
"0.59794885",
"0.5843597",
"0.5822316",
"0.5761593",
"0.57518655",
"0.57207453",
"0.57119364",
"0.571017",
"0.570412",
"0.56... | 0.70575464 | 0 |
Assembles a list of circuits into a qobj which can be run on the backend. | def assemble_circuits(circuits, run_config=None, qobj_header=None, qobj_id=None):
qobj_header = qobj_header or QobjHeader()
run_config = run_config or RunConfig()
if isinstance(circuits, QuantumCircuit):
circuits = [circuits]
userconfig = QobjConfig(**run_config.to_dict())
experiments = []
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def assemble_circuits(circuits, qobj_id=None, qobj_header=None, run_config=None):\n qobj_config = QasmQobjConfig()\n if run_config:\n qobj_config = QasmQobjConfig(**run_config.to_dict())\n\n # Pack everything into the Qobj\n experiments = []\n max_n_qubits = 0\n max_memory_slots = 0\n f... | [
"0.7279348",
"0.6496389",
"0.59102285",
"0.5772845",
"0.57442355",
"0.5727163",
"0.55746835",
"0.55432576",
"0.55362433",
"0.5509834",
"0.5474253",
"0.5412955",
"0.5407767",
"0.53782344",
"0.53507787",
"0.53283745",
"0.5326846",
"0.5310684",
"0.52896637",
"0.52684003",
"0.526... | 0.69339204 | 1 |
Convert all config sections to have unique names. Adds unique suffixes to config sections for compability with configparser. | def unique_config_sections(config_file):
section_counters = defaultdict(int)
output_stream = io.StringIO()
with open(config_file) as fin:
for line in fin:
if line.startswith('['):
section = line.strip().strip('[]')
_section = section + '_' + str(section_co... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fix_compname_configs(ibs):\n # ibs.MANUAL_CONFIG_SUFFIX = '_MANUAL_' #+ ut.get_computer_name()\n # ibs.MANUAL_CONFIGID = ibs.add_config(ibs.MANUAL_CONFIG_SUFFIX)\n # We need to fix the manual config suffix to not use computer names anymore\n\n configid_list = ibs.get_valid_configids()\n cfgsuff... | [
"0.6045993",
"0.5563847",
"0.5368636",
"0.5358432",
"0.5267798",
"0.51614577",
"0.51502544",
"0.5139199",
"0.5124081",
"0.50915194",
"0.507346",
"0.50681233",
"0.49954256",
"0.4976946",
"0.49577245",
"0.49545503",
"0.4944312",
"0.492063",
"0.4905497",
"0.490392",
"0.48970628"... | 0.5965138 | 1 |
The last value for the W array is correct | def test_W_end(self):
self.assertAlmostEqual(attempt.W[-1], 9.494852380803035) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def w(self) -> np.ndarray:\n return self.array[:, 0] if self.scalar_vector else self.array[:, 3]",
"def get_w(self, i_order):\n\n return np.array([]), np.array([])",
"def w(self) -> float:\n return self.A[0] if self.scalar_vector else self.A[3]",
"def new_w(w, d):\n\n if w.sum() > 0:\... | [
"0.6439141",
"0.6317358",
"0.6140997",
"0.60708946",
"0.60476446",
"0.6045793",
"0.6034233",
"0.5948805",
"0.5945211",
"0.58441013",
"0.58261454",
"0.5818163",
"0.57634544",
"0.5760683",
"0.5717286",
"0.5704453",
"0.5694879",
"0.5665707",
"0.5622648",
"0.56216794",
"0.5620351... | 0.639363 | 1 |
The maxIndex variables are correct | def test_maxIndex(self):
self.assertEqual(attempt.maxIndexZ, 113)
self.assertEqual(attempt.maxIndexW, 134) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def maxQualifiedIndex(self, indices):\n entry = self.getConfig()\n # the leader keep its own record updated to the newest\n indices[self.datacenter_id] = len(self.log) - 1\n # print('!!!!!', indices)\n if entry['config'] == 'single':\n return sorted([indices[x] for x i... | [
"0.7089196",
"0.67561334",
"0.67561334",
"0.67561334",
"0.6644873",
"0.6621024",
"0.65653",
"0.6489624",
"0.64309424",
"0.6412204",
"0.6361595",
"0.63488233",
"0.63382834",
"0.63159776",
"0.62829936",
"0.6254711",
"0.6254558",
"0.6239701",
"0.6237676",
"0.61731935",
"0.616580... | 0.7708999 | 0 |
Checks mount point is owned by swift | def is_ug_swift(d, r):
stats = os.stat(d.mount)
uid = stats.st_uid
gid = stats.st_gid
user = pwd.getpwuid(uid).pw_name
group = grp.getgrgid(gid).gr_name
if user == group == 'swift':
return True
else:
r.msgkey('user', user)
r.msgkey('group', group)
return Fals... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ownercheck(self, userhost):\n if self.cfg and self.cfg.owner:\n if userhost in self.cfg.owner: return True\n return False",
"def _check_mounted_system(self):\n res = self.su_cmd('touch /system/.dwarf_check')\n if res == '':\n res = self._do_adb_command('shell... | [
"0.6451464",
"0.6307461",
"0.6153694",
"0.6151752",
"0.61308235",
"0.6095205",
"0.60757345",
"0.60000616",
"0.5997545",
"0.5997545",
"0.5976451",
"0.59735596",
"0.5972847",
"0.5931066",
"0.59120023",
"0.59047663",
"0.58646756",
"0.58345026",
"0.5809635",
"0.5780444",
"0.57620... | 0.6578928 | 0 |
Checks the relevant swift mount points and diskusage | def main():
results = []
results.extend(check_mounts())
results.extend(diskusage())
return results | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _check_mounted_system(self):\n res = self.su_cmd('touch /system/.dwarf_check')\n if res == '':\n res = self._do_adb_command('shell ls -la /system')\n if '.dwarf_check' in res:\n res = self.su_cmd('rm /system/.dwarf_check')\n if res == '':\n ... | [
"0.65840626",
"0.6307514",
"0.6279391",
"0.626951",
"0.6082033",
"0.60685736",
"0.60032076",
"0.5917685",
"0.5890955",
"0.58835125",
"0.5840331",
"0.58330125",
"0.5823619",
"0.58203804",
"0.5819363",
"0.581247",
"0.58020556",
"0.5750178",
"0.5736998",
"0.5730349",
"0.5725064"... | 0.6437659 | 1 |
Sort variables based on their rank and shift. Note that this relies on all variables having a unique rank. | def sort_variables(variables):
return tuple(sorted(variables, key=lambda v: (v.rank, v.shift))) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sort(self, varnames):\n varnames = self._find_vars(varnames, unique=True, empty_ok=False)\n var_ind_list = list(map(self._varlist.index, varnames))\n new_srtlist = var_ind_list + [None]*(self._nvar - len(varnames))\n if self._srtlist == new_srtlist:\n return\n sort... | [
"0.6356814",
"0.59954023",
"0.5840146",
"0.57373804",
"0.5699405",
"0.56901157",
"0.5626263",
"0.5604119",
"0.55457306",
"0.55165404",
"0.55016434",
"0.5487663",
"0.5474271",
"0.5438897",
"0.5397592",
"0.5390707",
"0.53346616",
"0.5334493",
"0.53060263",
"0.5277838",
"0.51805... | 0.74932057 | 0 |
Given a set of criteria, find the matching variables(s). | def get_matching(variables, strict=True, single=True, **criteria):
matching = []
for var in variables:
for crit_name, crit_info in criteria.items():
if getattr(var, crit_name) == crit_info:
continue
else:
break
else:
matching.ap... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def query_variables(md):\n\n # save as dictionaries with searchers as keys\n x_searchers = {}\n b_target = {}\n\n t_max = 0\n\n for var in md.getVars():\n my_var_name = var.varName\n my_var_value = var.x\n # print('%s %g' % (my_var_name, my_var_value))\n\n if 'x' in my_va... | [
"0.6416395",
"0.6279023",
"0.61213815",
"0.5955996",
"0.5882055",
"0.58465207",
"0.58342683",
"0.5712536",
"0.56871027",
"0.56653214",
"0.54515976",
"0.5413046",
"0.54008603",
"0.5400208",
"0.53811234",
"0.5380468",
"0.53650934",
"0.53530097",
"0.53530097",
"0.5344481",
"0.53... | 0.7268741 | 0 |
Match variable to VariableFactory using rank, name, and units. | def match_factory(variable, factories):
if not isinstance(factories, tuple):
factories = (factories,)
for factory in factories:
if (
variable.rank == factory.rank
and variable.name == factory.name
and variable.units == factory.units
):
ret... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def variable_factory(p, variable_name):\n if isinstance(variable_name, (Variable,)):\n return variable_name\n if not hasattr(p, \"variable_mapping\"):\n setattr(p, \"variable_mapping\", {})\n if variable_name not in p.variable_mapping:\n p.variable_mapping[variable_name] = Variable(va... | [
"0.6039259",
"0.5748577",
"0.5715186",
"0.56820124",
"0.56072986",
"0.5535535",
"0.55185264",
"0.53700167",
"0.5367385",
"0.536188",
"0.53586817",
"0.53523105",
"0.5274955",
"0.5252807",
"0.52485764",
"0.5248227",
"0.5243896",
"0.51856565",
"0.5179017",
"0.517816",
"0.5174382... | 0.6425409 | 0 |
Get the lags for a given VariableFactory. | def get_variable_lags(var_factory):
if var_factory in shifted_variables:
return lags
return (0,) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_shifted_variables(var_factory):\n shifted = []\n for lag in get_variable_lags(var_factory):\n shifted.append(var_factory[lag])\n return tuple(shifted)",
"def lag(self):\n self._assert_counted_at_lag()\n return self._lag",
"def create_predictors(y): # pragma: no cover\n ... | [
"0.67575127",
"0.5803747",
"0.5776367",
"0.54579306",
"0.54395133",
"0.5426974",
"0.53509307",
"0.53438425",
"0.5341233",
"0.52827334",
"0.5247959",
"0.5246997",
"0.5176305",
"0.50930464",
"0.5059406",
"0.50513554",
"0.5010745",
"0.4938749",
"0.4918975",
"0.49158582",
"0.4873... | 0.87622905 | 0 |
Get all possible shifted variables given a VariableFactory. | def get_shifted_variables(var_factory):
shifted = []
for lag in get_variable_lags(var_factory):
shifted.append(var_factory[lag])
return tuple(shifted) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_variable_lags(var_factory):\n if var_factory in shifted_variables:\n return lags\n return (0,)",
"def vars(self):\n return [Var(i,self.dims[i]) for i in range(self.nvar)] # TODO: use stored state info (=1 sometimes)",
"def get_all_variables(self):\n out = []\n for i in se... | [
"0.69359124",
"0.5861063",
"0.5553798",
"0.5553798",
"0.5553798",
"0.5403311",
"0.53172415",
"0.5283232",
"0.5274266",
"0.5179303",
"0.5173764",
"0.51522267",
"0.51142913",
"0.50858605",
"0.5057335",
"0.5056801",
"0.5049597",
"0.50440574",
"0.49971545",
"0.49796465",
"0.49775... | 0.8306546 | 0 |
Returns the path to our major ldso symlink. (Which allows us to change which ldso we are actively using without patching a bunch of binaries) | def ld_linux_path(root):
return os.path.join(root, 'lib', 'ld-linux-xpkg.so') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _find_ld_version():\n if sys.platform == 'darwin':\n return _find_exe_version('ld -v', _MAC_OS_X_LD_VERSION)\n else:\n return _find_exe_version('ld -v')",
"def get_linked_libpython():\n if is_windows():\n return\n libdl = ctypes.CDLL(ctypes.util.find_library(\"dl\"))\n lib... | [
"0.66215503",
"0.6279569",
"0.5894043",
"0.5856724",
"0.5856588",
"0.5700655",
"0.56694955",
"0.55614096",
"0.5547654",
"0.55200994",
"0.5495592",
"0.54438263",
"0.5425426",
"0.5324425",
"0.5300233",
"0.5298378",
"0.52957606",
"0.5281993",
"0.52785194",
"0.5256666",
"0.525556... | 0.6632493 | 0 |
Diagonal distance h_diagonal(n) = min(abs(n.x goal.x), abs(n.y goal.y)) h_straight(n) = (abs(n.x goal.x) + abs(n.y goal.y)) h(n) = D_diagnoal h_diagonal(n) + D_straight (h_straight(n) 2h_diagonal(n))) | def heuristic_cost_estimate(start, goal,d_diagnoal,d_straight):
start_x = start.x
start_y = start.y
goal_x = goal.x
goal_y = goal.y
h_diagonal = min(np.abs(start_x - goal_x),np.abs(start_y - goal_y))
h_straight = np.abs(start_x - goal_x) + np.abs(start_y - goal_y)
h = d_diagnoal * h_diagona... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dist_between(current, neighbor,d_diagnoal,d_straight):\n start_x = current.x\n start_y = current.y\n goal_x = neighbor.x\n goal_y = neighbor.y\n\n h_diagonal = min(np.abs(start_x - goal_x),np.abs(start_y - goal_y))\n h_straight = np.abs(start_x - goal_x) + np.abs(start_y - goal_y)\n h = d_... | [
"0.8049952",
"0.6934964",
"0.69334024",
"0.6747959",
"0.644159",
"0.62714773",
"0.6160783",
"0.6144977",
"0.6144977",
"0.61420053",
"0.6101649",
"0.6096123",
"0.60647726",
"0.6007809",
"0.59770143",
"0.5892348",
"0.5882317",
"0.5860657",
"0.5833256",
"0.58259183",
"0.57475424... | 0.7815696 | 1 |
Diagonal distance h_diagonal(n) = min(abs(n.x goal.x), abs(n.y goal.y)) h_straight(n) = (abs(n.x goal.x) + abs(n.y goal.y)) h(n) = D_diagnoal h_diagonal(n) + D_straight (h_straight(n) 2h_diagonal(n))) | def dist_between(current, neighbor,d_diagnoal,d_straight):
start_x = current.x
start_y = current.y
goal_x = neighbor.x
goal_y = neighbor.y
h_diagonal = min(np.abs(start_x - goal_x),np.abs(start_y - goal_y))
h_straight = np.abs(start_x - goal_x) + np.abs(start_y - goal_y)
h = d_diagnoal * h_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def heuristic_cost_estimate(start, goal,d_diagnoal,d_straight):\n start_x = start.x\n start_y = start.y\n goal_x = goal.x\n goal_y = goal.y\n\n h_diagonal = min(np.abs(start_x - goal_x),np.abs(start_y - goal_y))\n h_straight = np.abs(start_x - goal_x) + np.abs(start_y - goal_y)\n h = d_diagnoa... | [
"0.7815963",
"0.6935118",
"0.69333106",
"0.6748271",
"0.6441967",
"0.6272037",
"0.616098",
"0.614516",
"0.614516",
"0.6142244",
"0.61005026",
"0.6096975",
"0.60649806",
"0.60074985",
"0.59759593",
"0.58921903",
"0.5882251",
"0.58594304",
"0.58325016",
"0.5826039",
"0.57475173... | 0.80509466 | 0 |
convert the path in real to grid, e.g. 21 > 2.15 sx= ix reso + reso/2 | def convertGridPathToReal(pathInGrid, sx, sy, gx, gy, grid_reso = 0.1):
pathInReal = (pathInGrid * grid_reso + grid_reso / 2)
stepNum = pathInReal.shape[1]
# Replace head and tail
pathInReal[:, 0] = [sx, sy]
pathInReal[:, 0] = [sx, sy]
pathInReal[:, stepNum - 1] = [gx, gy]
pathInReal[:, ste... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fifteen():\r\n\r\n currentcell = 1.0\r\n cellpaths = 2.0\r\n \r\n while currentcell < 20.0:\r\n currentcell += 1.0\r\n cellpaths = cellpaths * (4.0 - 2.0/currentcell)\r\n \r\n return cellpaths",
"def gen_grids(self):\n self.dx = self.grid_width / self.grid_resol\n ... | [
"0.5953606",
"0.5806127",
"0.57640606",
"0.5755406",
"0.57439196",
"0.5740067",
"0.5653222",
"0.5591101",
"0.55833936",
"0.5580926",
"0.5577852",
"0.5570575",
"0.5565106",
"0.55632424",
"0.5562481",
"0.5536194",
"0.55283296",
"0.5520637",
"0.5520081",
"0.5514781",
"0.55122167... | 0.7544195 | 0 |
One dimensional exponential cutoff power law derivative with respect to parameters | def fit_deriv(x, amplitude, x_0, alpha, x_cutoff):
xx = x / x_0
xc = x / x_cutoff
d_amplitude = xx ** (-alpha) * np.exp(-xc)
d_x_0 = alpha * amplitude * d_amplitude / x_0
d_alpha = -amplitude * d_amplitude * np.log(xx)
d_x_cutoff = amplitude * x * d_amplitude / x_cutoff... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def energy_function(self, x):\n \n return -T.dot(T.transpose(x), T.dot(self.W, x)) -\\\n T.dot(T.transpose(self.b), x)",
"def exponential(self, data=[], init_lambdas=[1,0.75], max_iteration=500):\r\n xaxis = np.arange(1, len(data)+1)\r\n data = np.array(data)\r\n idx = 1\r\n ... | [
"0.6435805",
"0.641947",
"0.63531476",
"0.6331413",
"0.6303507",
"0.6297258",
"0.62600297",
"0.62595487",
"0.6257403",
"0.6225996",
"0.619326",
"0.6160021",
"0.6141522",
"0.61281365",
"0.6099849",
"0.6092616",
"0.6091917",
"0.6058767",
"0.6058701",
"0.6036378",
"0.60332775",
... | 0.6778236 | 0 |
Generate strong password to add to csv file and clipboard. | def generate_pw():
chars = string.ascii_letters + string.digits + '!@#$%^&*()'
password = ''.join(random.choice(chars) for i in range(16))
pyperclip.copy(password)
print('Password copied to clipboard.')
return password | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def password_generate_strong(self, ctx, delimeter: str = \"\"):\n d = delimeter\n rc = random.choice\n rr = random.randint\n await ctx.send(\n d.join(rc(RANDOM_WORDS).capitalize() for i in range(3)) + f\"{d}{rr(1,1000)}\"\n )",
"def giveReadablePassword():\n ... | [
"0.6699509",
"0.66523397",
"0.66337395",
"0.65883833",
"0.6544499",
"0.651341",
"0.64864033",
"0.6481383",
"0.64227664",
"0.63991195",
"0.63651586",
"0.63424796",
"0.6329188",
"0.6299538",
"0.62843406",
"0.6273658",
"0.62399065",
"0.6230091",
"0.6219999",
"0.6194473",
"0.6178... | 0.7241065 | 0 |
Add new account to pw.csv and generate a strong password. | def main(script):
try:
# ensure user entered account name and user name
account_name = sys.argv[1]
user_name = sys.argv[2]
except IndexError:
print('python add_pw.py [account name] [user name]')
else:
# read in csv file
pw_file = open('pw.csv')
pw_obje... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new_password():\n new_pass = generate_password()\n entry_pass.delete(0, END)\n entry_pass.insert(0, new_pass)",
"def add_user(self, user, pw):\n self.db.execute(\"INSERT INTO user_credentials VALUES (?, ?)\", [user, pw])\n self.db.commit()",
"def save_password(self, new_password):\n... | [
"0.68463534",
"0.6339493",
"0.6226887",
"0.6119043",
"0.6009385",
"0.59483135",
"0.58453876",
"0.5821747",
"0.5782089",
"0.5744898",
"0.5735216",
"0.57338196",
"0.573278",
"0.57301116",
"0.5707284",
"0.5689022",
"0.5674017",
"0.5670386",
"0.56640315",
"0.56365216",
"0.5633996... | 0.6759446 | 1 |
Add Site Static Resource Directory | def addMobileStaticResourceDir(self, dir: str) -> None:
self.__rootMobileResource.addFileSystemRoot(dir) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_dirs_to_static(static_webapp_name):\n static_dir = '$HOME/webapps/%s' % static_webapp_name\n with settings(warn_only=True):\n with cd(static_dir):\n run(\"mkdir static && mkdir media\")\n run(\"rm index.html\")\n run(\"touch index.html\")\n with cd(code_... | [
"0.71481174",
"0.6910498",
"0.66968936",
"0.66562533",
"0.66559666",
"0.65018547",
"0.64497256",
"0.6352136",
"0.6325666",
"0.6246173",
"0.6058434",
"0.6023625",
"0.5898131",
"0.5875398",
"0.58405364",
"0.5814434",
"0.5805225",
"0.57971865",
"0.5774547",
"0.57634854",
"0.5763... | 0.7166486 | 0 |
This function is for viewing the plot of your cost history. | def plot_cost_history(alpha, cost_history):
cost_df = pandas.DataFrame({
'Cost_History': cost_history,
'Iteration': range(len(cost_history))
})
return ggplot(cost_df, aes('Iteration', 'Cost_History')) + geom_point() + ggtitle('Cost History for alpha = %.3f' % alpha ) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_costs(j_history):\n plt.figure(figsize=(14, 8))\n plt.plot(range(len(j_history)), j_history)\n plt.grid(True)\n plt.title('J (Cost)')\n plt.xlabel('Iteration')\n plt.ylabel('Cost function')\n plt.xlim([0, 1.05 * ITERATIONS])\n plt.ylim([4, 7])\n plt.show()\n plt.close()",
"... | [
"0.745946",
"0.7305429",
"0.6926057",
"0.68891627",
"0.6870632",
"0.65292275",
"0.65152884",
"0.65122676",
"0.650241",
"0.6492996",
"0.646902",
"0.6411578",
"0.64004505",
"0.63721967",
"0.63554156",
"0.6354006",
"0.63402677",
"0.6333534",
"0.63082844",
"0.63080597",
"0.629246... | 0.7419536 | 1 |
Searches inside the index for umbra3d | def search_umbra(text):
result = _search_blog('umbra3d', text)
_print_results(result)
return result | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clustering_dbscan_o3d():\n pass",
"def cloud_index():\n import alltheitems.cloud\n return alltheitems.cloud.index()",
"def test_figure3(self):\n\n ssearcher = SimpleSearcher.from_prebuilt_index('msmarco-passage')\n encoder = TctColBertQueryEncoder('castorini/tct_colbert-msmarco')\n ... | [
"0.5886022",
"0.55750906",
"0.5477457",
"0.51528597",
"0.5148673",
"0.5101667",
"0.50694734",
"0.4972866",
"0.4953324",
"0.49039114",
"0.48821348",
"0.48311734",
"0.4818827",
"0.4813475",
"0.47986737",
"0.47905108",
"0.4765872",
"0.47636506",
"0.47565117",
"0.47055826",
"0.46... | 0.6636374 | 0 |
Create an embed with the lyrics | def _lyrics_embed(colour, page: Dict[str, Any], data: Dict[str, Any]) -> discord.Embed:
title = [
x.get("value")
for x in data.get("names")
if x.get("language") == LANGUAGE_MAP.get(page["cultureCode"])
]
em = discord.Embed(
title=title[0] if title ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def embed():",
"async def _create_embed(self, event, info):\n\n e = discord.Embed(url=info.get(\"url\"))\n e.title = \"%s %s!\" % (info.get(\"streamer\"), info.get(\"live_status\"))\n e.add_field(name=\"Stream title\", value=info.get(\"title\"), inline=False)\n e.add_field(name=\"Begi... | [
"0.70255935",
"0.63106394",
"0.62139446",
"0.61759347",
"0.60498273",
"0.60261035",
"0.5952487",
"0.59314024",
"0.5826032",
"0.5814283",
"0.57923996",
"0.5775373",
"0.57529444",
"0.5735012",
"0.56990874",
"0.56855226",
"0.56756103",
"0.5667003",
"0.56360406",
"0.5626547",
"0.... | 0.7571321 | 0 |
Fuse conv and bn into one module. | def _fuse_conv_bn(conv, bn):
conv_w = conv.weight
conv_b = conv.bias if conv.bias is not None else torch.zeros_like(
bn.running_mean)
factor = bn.weight / torch.sqrt(bn.running_var + bn.eps)
conv.weight = nn.Parameter(conv_w *
factor.reshape([conv.out_channels, 1,... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fuse_conv_bn(module):\n last_conv = None\n last_conv_name = None\n\n for name, child in module.named_children():\n if isinstance(child,\n (nn.modules.batchnorm._BatchNorm, nn.SyncBatchNorm)):\n if last_conv is None: # only fuse BN that is after Conv\n ... | [
"0.66424954",
"0.6055714",
"0.602726",
"0.59107614",
"0.5825306",
"0.57937133",
"0.57798207",
"0.5775232",
"0.5716006",
"0.56922126",
"0.5688817",
"0.5679025",
"0.566316",
"0.56493765",
"0.56161374",
"0.5604259",
"0.5571019",
"0.5565932",
"0.5558572",
"0.5545696",
"0.5540742"... | 0.651783 | 1 |
Recursively fuse conv and bn in a module. During inference, the functionary of batch norm layers is turned off but only the mean and var alone channels are used, which exposes the chance to fuse it with the preceding conv layers to save computations and simplify network structures. | def fuse_conv_bn(module):
last_conv = None
last_conv_name = None
for name, child in module.named_children():
if isinstance(child,
(nn.modules.batchnorm._BatchNorm, nn.SyncBatchNorm)):
if last_conv is None: # only fuse BN that is after Conv
continue... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _fuse_conv_bn(conv, bn):\n conv_w = conv.weight\n conv_b = conv.bias if conv.bias is not None else torch.zeros_like(\n bn.running_mean)\n\n factor = bn.weight / torch.sqrt(bn.running_var + bn.eps)\n conv.weight = nn.Parameter(conv_w *\n factor.reshape([conv.out_... | [
"0.695171",
"0.6805263",
"0.6269793",
"0.62578046",
"0.6063939",
"0.6063939",
"0.60563296",
"0.6027096",
"0.60044354",
"0.5954461",
"0.5929739",
"0.5882636",
"0.58481455",
"0.5835012",
"0.5830163",
"0.57766056",
"0.57479167",
"0.5734447",
"0.57262725",
"0.5723586",
"0.5721918... | 0.7612941 | 0 |
Updates this configuration object from a dictionary. | def update_from_dict(self, dct):
if not dct:
return
all_props = self.__class__.CONFIG_PROPERTIES
for key, value in six.iteritems(dct):
attr_config = all_props.get(key)
if attr_config:
setattr(self, key, value)
else:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update(self, config_dict):\r\n self._update(config_dict, allow_new_keys=True)",
"def update(self, config_dict):\n self._update(config_dict, allow_new_keys=True)",
"def update_from_dict(self, dictionary):\n for key in dictionary:\n setattr(self, key, dictionary[key])\n ret... | [
"0.7539606",
"0.7526402",
"0.73409635",
"0.6924898",
"0.6826344",
"0.68139464",
"0.67985266",
"0.6760424",
"0.6756888",
"0.66938514",
"0.65406144",
"0.6525585",
"0.6479391",
"0.64561343",
"0.6436355",
"0.6408912",
"0.6408051",
"0.63989556",
"0.63800776",
"0.63728046",
"0.6356... | 0.7746895 | 0 |
Merges listbased attributes into one list including unique elements from both lists. When ``lists_only`` is set to ``False``, updates dictionaries and overwrites singlevalue attributes. The resulting configuration is 'clean', i.e. input values converted and validated. If the conversion is not possible, a ``ValueError``... | def merge(self, values, lists_only=False):
if isinstance(values, self.__class__):
self.merge_from_obj(values, lists_only=lists_only)
elif isinstance(values, dict):
self.merge_from_dict(values, lists_only=lists_only)
else:
raise ValueError("{0} or dictionary ex... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def merge_from_obj(self, obj, lists_only=False):\n self.clean()\n obj.clean()\n obj_config = obj._config\n all_props = self.__class__.CONFIG_PROPERTIES\n for key, value in six.iteritems(obj_config):\n attr_config = all_props[key]\n attr_type, default, __, me... | [
"0.65139383",
"0.5578662",
"0.5572278",
"0.55066985",
"0.5469693",
"0.53935814",
"0.5371809",
"0.53107864",
"0.5277536",
"0.5260815",
"0.5229918",
"0.52003044",
"0.5156324",
"0.5125335",
"0.5069357",
"0.50458443",
"0.5019574",
"0.4998074",
"0.49735352",
"0.49711102",
"0.49676... | 0.6129385 | 1 |
Creates a copy of the current instance. | def copy(self):
return self.__class__(self) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def copy(self):\n cls = self.__class__\n result = cls.__new__(cls)\n result.__dict__.update(self.__dict__)\n return result",
"def copy(self):\n return self.__class__(dict(self))",
"def copy(self):\n\t\ttemp = self.__class__()\n\t\ttemp.copy_from(self)\n\t\treturn temp",
"de... | [
"0.8445658",
"0.83826053",
"0.8367299",
"0.83550745",
"0.8290682",
"0.82799333",
"0.8262882",
"0.823516",
"0.8217232",
"0.8166611",
"0.8156989",
"0.81500196",
"0.8146055",
"0.8143642",
"0.81333435",
"0.81235075",
"0.8090402",
"0.8090402",
"0.80738163",
"0.8067191",
"0.8032540... | 0.86091197 | 1 |
Cleans the input values of this configuration object. Fields that have gotten updated through properties are converted to configuration values that match the format needed by functions using them. For example, for listlike values it means that input of single strings is transformed into a singleentry list. If this conv... | def clean(self):
all_props = self.__class__.CONFIG_PROPERTIES
for prop_name in self._modified:
attr_config = all_props.get(prop_name)
if attr_config and attr_config.input_func:
self._config[prop_name] = attr_config.input_func(self._config[prop_name])
self.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clean(self, value):\n value = self.validate_to_python(value)\n self.run_validators(value)\n return value",
"def clean(self, value):\n value = self.validate_to_python(value)\n self.run_validators(value)\n return value",
"def clean(cls, value):\n return",
"d... | [
"0.60418636",
"0.60418636",
"0.59051543",
"0.5863725",
"0.5829741",
"0.5760881",
"0.5721319",
"0.5714525",
"0.5582324",
"0.5558668",
"0.5509648",
"0.5507196",
"0.55028373",
"0.54199827",
"0.54151857",
"0.5408943",
"0.5379859",
"0.53760797",
"0.5363679",
"0.53535485",
"0.53409... | 0.6916164 | 0 |
Whether the current object is 'clean', i.e. has no nonconverted input. | def is_clean(self):
return not self._modified | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clean(self) -> bool:\n raise NotImplementedError()",
"def __bool__(self):\n return self.isValid()",
"def __bool__(self):\n return self.is_valid",
"def is_valid(self):\n self.clean()\n return not bool(self.errors)",
"def is_raw(self):\n return not self._isReduce... | [
"0.6872073",
"0.63761157",
"0.63610554",
"0.6312004",
"0.63031477",
"0.63022435",
"0.6240924",
"0.61812806",
"0.61137867",
"0.60905904",
"0.60698545",
"0.6046526",
"0.60410285",
"0.603819",
"0.6018456",
"0.60071707",
"0.60055494",
"0.5978157",
"0.5974375",
"0.59508747",
"0.59... | 0.73114955 | 0 |
Returns the current world size (number of distributed processes). | def world_size() -> int:
return dist.get_world_size() if dist.is_initialized() else 1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_world_size() -> int:\n return collective.get_world_size()",
"def get_world_size():\n if not torch.distributed.is_available():\n return 1\n if not torch.distributed.is_initialized():\n return 1\n return torch.distributed.get_world_size()",
"def size():\n return int(os.enviro... | [
"0.86169875",
"0.8585714",
"0.80531013",
"0.78157955",
"0.7763954",
"0.72711486",
"0.7219287",
"0.69150424",
"0.68911326",
"0.68068975",
"0.671325",
"0.668719",
"0.6650058",
"0.65553606",
"0.6534457",
"0.6533206",
"0.64964646",
"0.6494468",
"0.6457273",
"0.6454149",
"0.644345... | 0.86466646 | 0 |
Decorator that only runs the function on the process with rank 0. | def rank_zero_only(fn):
def wrapped(*args, **kwargs):
if rank() == 0:
return fn(*args, **kwargs)
return wrapped | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rank_zero_only(fn):\n\n @wraps(fn)\n def wrapped_fn(self, *args, **kwargs):\n if self.rank == 0:\n fn(self, *args, **kwargs)\n\n return wrapped_fn",
"def _message_when_root(func):\n\n def decorated(*args, **kwargs):\n from armi import MPI_RANK\n\n if MPI_RANK == 0:... | [
"0.78528255",
"0.66583896",
"0.6142544",
"0.6070626",
"0.6058951",
"0.60186154",
"0.5988285",
"0.5949869",
"0.5930045",
"0.5898354",
"0.5718907",
"0.5713488",
"0.5649635",
"0.55312955",
"0.5502004",
"0.5497844",
"0.547936",
"0.5471152",
"0.539442",
"0.5339954",
"0.53384835",
... | 0.78286487 | 1 |
Equivalent to print, but only runs on the process with rank 0. | def print_rank_zero(*args, **kwargs) -> None:
print(*args, **kwargs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def l_print_no_barrier(*args):\n print(comm.rank, ':', end=' ')\n for i in args:\n print(i, end=' ')\n # noinspection PyArgumentList\n print()",
"def print_on_master(self, msg: str, process_group: ProcessGroup = None):\n rank = dist.get_rank(group=process_group)\n if rank == 0:\n... | [
"0.67231727",
"0.671745",
"0.6413891",
"0.63975346",
"0.6320614",
"0.6140222",
"0.59592324",
"0.5801671",
"0.5788699",
"0.5557892",
"0.54468316",
"0.53032565",
"0.5294671",
"0.5267618",
"0.5237459",
"0.52162343",
"0.51678485",
"0.5136221",
"0.5076834",
"0.5038921",
"0.5038565... | 0.7382136 | 0 |
Identifies uncorrelated samples and updates the arrays of the reduced potential energy and dhdlt retaining data entries of these samples only. 'sta' and 'fin' are the starting and final snapshot positions to be read, both are arrays of dimension K. | def uncorrelate(sta, fin, do_dhdl=False):
if not P.uncorr_threshold:
if P.software.title()=='Sire':
return dhdlt, nsnapshots, None
return dhdlt, nsnapshots, u_klt
u_kln = numpy.zeros([K,K,max(fin-sta)], numpy.float64) # u_kln[k,m,n] is the reduced potential energy of uncorrelated sample inde... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_data_stoichometry(fasta, bams, regions, features, samples, fracs, \n maxReads=1000, strands=\"+-\", nn=1):\n # get storage\n k = 2*nn+1\n fi = 0\n sam = pysam.AlignmentFile(bams[0])\n region2data = {}\n sample2idx = {s: i for i, s in enumerate(samples)}; print(s... | [
"0.5908855",
"0.54569936",
"0.5322768",
"0.5313147",
"0.5301625",
"0.53015983",
"0.5290556",
"0.52887326",
"0.528543",
"0.5255901",
"0.52539086",
"0.52324796",
"0.52108496",
"0.52033883",
"0.5170586",
"0.5168382",
"0.5167442",
"0.51477975",
"0.5144637",
"0.5129123",
"0.511288... | 0.68044555 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.