query stringlengths 10 2k | document stringlengths 20 51.2k | metadata dict | negatives listlengths 0 101 | negative_scores listlengths 0 101 | document_score stringlengths 3 10 | document_rank stringclasses 102
values |
|---|---|---|---|---|---|---|
Closes this database connection. | def close(self):
if getattr(self, "_db", None) is not None:
self._db.close()
self._db = None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def close_database(self):\n if self._conn is not None:\n self._conn.close()\n self._conn = None",
"def close_db_connection(cls):\n db.close()",
"def close(self):\n Log.debug('DB -> close')\n # 关闭数据库连接\n self.conn.close()",
"def close(self):\n if... | [
"0.8292057",
"0.8254112",
"0.82229376",
"0.8203255",
"0.818026",
"0.8166083",
"0.81160486",
"0.7871417",
"0.78436184",
"0.784009",
"0.77772814",
"0.7746946",
"0.7742204",
"0.7729554",
"0.77030843",
"0.76807404",
"0.76142853",
"0.7602529",
"0.7572504",
"0.75648904",
"0.7560619... | 0.7857391 | 9 |
Calls appropriate batch normalization and nonlinearity per spin. | def __call__(self,
inputs,
use_running_stats = None,
weights = None):
use_running_stats = nn.module.merge_param(
"use_running_stats", self.use_running_stats, use_running_stats)
options = dict(use_running_stats=use_running_stats,
momentum=s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def trainFreezeBN(self):\n\t\tprint(\"Freezing Mean/Var of BatchNorm2D.\")\n\t\tprint(\"Freezing Weight/Bias of BatchNorm2D.\")\n\t\tfor m in self.modules():\n\t\t\tif isinstance(m, nn.BatchNorm2d):\n\t\t\t\tm.eval()\n\t\t\t\tm.weight.requires_grad = False\n\t\t\t\tm.bias.requires_grad = False",
"def trainFreeze... | [
"0.610934",
"0.610934",
"0.6089211",
"0.59906036",
"0.5958602",
"0.59169674",
"0.5912325",
"0.59053653",
"0.5844011",
"0.58218527",
"0.5807071",
"0.58024067",
"0.578536",
"0.5726637",
"0.56897175",
"0.5684495",
"0.56827366",
"0.56807595",
"0.5677488",
"0.5669911",
"0.5664865"... | 0.59345806 | 5 |
Determines whether this link is supposed to create or delete instances if Link is NOT Reference Only. | def operation_type(self) -> pulumi.Output[Optional[str]]:
return pulumi.get(self, "operation_type") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_reference(self):\n return self.resource.is_reference()",
"def should_link(self, item):\r\n return item.__class__ in self.class_map.keys()",
"def can_delete(self):\r\n return True",
"def can_create(self):\n return True",
"def _is_new_(self):\n\n #we can't call get_h... | [
"0.6457671",
"0.627264",
"0.6272201",
"0.61743826",
"0.6076601",
"0.6023808",
"0.6011778",
"0.5999035",
"0.59932876",
"0.5970208",
"0.59380466",
"0.5904979",
"0.58851933",
"0.5873558",
"0.586441",
"0.5854824",
"0.5818373",
"0.5808217",
"0.5806707",
"0.5803792",
"0.578034",
... | 0.0 | -1 |
Return a list of (row, col) tuples for all empty squares | def get_empty_squares(self):
return self.empty_squares | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_empty_squares(self):\n empty = []\n for row in range(self._dim):\n for col in range(self._dim):\n if self._board[row][col] == EMPTY:\n empty.append((row, col))\n return empty",
"def get_empty_square(self) -> list:\n empty_square = [... | [
"0.8532588",
"0.83627236",
"0.78150517",
"0.7793476",
"0.77439314",
"0.7630907",
"0.7579457",
"0.75065297",
"0.749984",
"0.7407822",
"0.73935884",
"0.73155934",
"0.7242781",
"0.722334",
"0.71962243",
"0.7147634",
"0.71350807",
"0.7135068",
"0.7130342",
"0.7115903",
"0.7019478... | 0.71530014 | 15 |
Initialize RefstackClient testcase object. | def __init__(self, **kwargs):
if "case_name" not in kwargs:
kwargs["case_name"] = "refstack_defcore"
super(RefstackClient, self).__init__(**kwargs)
self.tempestconf = None
self.conf_path = pkg_resources.resource_filename(
'functest',
'opnfv_tests/opens... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, test_obj: 'T0TestBase') -> None:\n\n self.test_obj = test_obj\n self.client = test_obj.client",
"def setUp(self):\n rand = ''.join(\n [random\n .choice(string.ascii_letters + string.digits) for n in range(16)])\n self.secret_key = 'sk_test_16c... | [
"0.7151209",
"0.71416396",
"0.70165515",
"0.69479185",
"0.6943517",
"0.69131297",
"0.68953377",
"0.6856646",
"0.68197656",
"0.6793531",
"0.67636156",
"0.67554057",
"0.67353255",
"0.67280155",
"0.6714732",
"0.6714732",
"0.6714732",
"0.6714732",
"0.66944665",
"0.6693208",
"0.66... | 0.73974526 | 0 |
Consultants (Organizations) are created correctly for Projects. | def test_consultants_created(self):
# Currently, there is just 1 Organization in the database, the org_existing
org_existing = OrganizationFactory(name='Existing Organization')
self.assertEqual(Organization.objects.count(), 1)
self.call_command(filename='power_plant_import/tests/data/si... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_add_organization(self):\n pass",
"def test_organizations_list(self):\n pass",
"def test_retrieve_l_organizations(self):\n pass",
"def test_get_organization(self):\n pass",
"def test_contractors_created(self):\n # Currently, there is just 1 Organization in the dat... | [
"0.6770899",
"0.62152624",
"0.6094451",
"0.6006055",
"0.5955119",
"0.59256893",
"0.592104",
"0.5873205",
"0.5827631",
"0.578727",
"0.57774466",
"0.5772597",
"0.575855",
"0.57573235",
"0.57523036",
"0.57215995",
"0.57184935",
"0.5634152",
"0.5633261",
"0.5627746",
"0.56043124"... | 0.71415645 | 0 |
Rows with invalid data do not create PowerPlants or Projects. | def test_invlaid_data(self):
# Currently, there are no PowerPlant or Project objects in the database
self.assertEqual(PowerPlant.objects.count(), 0)
self.assertEqual(Project.objects.count(), 0)
# Call the command with invalid data.
# The first row is for a power plant, but it ha... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_invalid_type(self):\n self.call_command(filename='power_plant_import/tests/data/invalid_type.csv')\n\n # No PowerPlants or Projects were created during the test\n self.assertEqual(PowerPlant.objects.count(), 0)\n self.assertEqual(Project.objects.count(), 0)",
"def test_projec... | [
"0.6567699",
"0.61686087",
"0.6072309",
"0.5975067",
"0.597474",
"0.5946168",
"0.59293604",
"0.5920904",
"0.5876645",
"0.581999",
"0.5799501",
"0.5741603",
"0.57203054",
"0.57117236",
"0.5683868",
"0.56452745",
"0.55956626",
"0.5564877",
"0.5563789",
"0.5558036",
"0.5525236",... | 0.5911876 | 8 |
Return a timer with a stop call, or a newly made unstarted timer. | def endTimer(event_name):
master = MasterTimer.getMasterTimer()
if event_name in master.timers:
timer = master.timers[event_name]
timer.stop()
else:
timer = _Timer(event_name, False)
return timer | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _stop_timer(self):\n time_now = _now()\n diff = time_now - self._start_time\n self._start_time = None\n return _convert_to_timedelta(diff)",
"def get_timer_from_timeout(timeout):\n if hasattr(timeout, 'has_expired'):\n timer = timeout\n else:\n timer = SimpleTi... | [
"0.7308102",
"0.6811684",
"0.6721641",
"0.6649449",
"0.6575756",
"0.6532927",
"0.6309846",
"0.61744195",
"0.61624783",
"0.6096043",
"0.6043148",
"0.6029161",
"0.59562224",
"0.59510964",
"0.5920834",
"0.59038204",
"0.58900726",
"0.57766813",
"0.5708203",
"0.56774163",
"0.56720... | 0.58986723 | 16 |
The elapsed time since this timer was asked to report itself. | def timeSinceReport(self):
return self.time - self.reportedTotal | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def elapsed_time(self):\n return self.__elapsed_time",
"def get_time_elapsed(self):\n return self.__time_elapsed",
"def elapsed(self):\n return self.__last_time() - self.__start",
"def elapsed(self):\r\n if self._elapsed is None:\r\n raise ValueError('Timer has not been finished ... | [
"0.8436722",
"0.840812",
"0.83837754",
"0.82684904",
"0.8240633",
"0.8097314",
"0.8042736",
"0.79614717",
"0.7945342",
"0.7931191",
"0.79184383",
"0.790697",
"0.78811765",
"0.78145885",
"0.7767657",
"0.77359086",
"0.7702625",
"0.7687121",
"0.7664181",
"0.7624429",
"0.7624296"... | 0.77596116 | 15 |
This function prints and plots the confusion matrix. Normalization can be applied by setting `normalize=True`. | def plot_confusion_matrix(cm, classes,
normalize=False,
title='Confusion matrix',
cmap=plt.cm.Blues):
if normalize:
cm = cm.astype('float') / cm.sum(axis=1)[:, np.newaxis]
print("Normalized confusion matrix")
else:
print('Confusion matrix, without normalization')
print(cm)
plt.imshow... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_confusion_matrix(cm, classes=[0,1], normalize=False, title='Confusion matrix', print_matrix=False):\n\n if normalize:\n cm = cm.astype('float') / cm.sum(axis=1)[:, np.newaxis]\n print(\"Normalized confusion matrix\")\n else:\n print('Confusion matrix, without normalization')\n\n... | [
"0.8195189",
"0.8096179",
"0.80311364",
"0.80207354",
"0.79955184",
"0.799279",
"0.7982649",
"0.7977064",
"0.7962826",
"0.7958447",
"0.7939309",
"0.79364014",
"0.7936101",
"0.7932949",
"0.7927847",
"0.792615",
"0.7925553",
"0.79244494",
"0.7924244",
"0.79234385",
"0.79194653"... | 0.7819069 | 88 |
Checks that `true_positive_rate` calculates the right quantity. | def test_true_positive_rate(self):
# For the penalty, the default loss is hinge.
expected_penalty_numerator = np.sum(
np.maximum(
0.0, 1.0 + self._penalty_predictions) * (self._penalty_labels > 0.0)
* self._penalty_weights * self._penalty_predicate)
expected_penalty_denominator =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def true_positive_rate(y_true, y_pred):\n p = np.sum(y_true == 1)\n tp = np.sum((y_pred == y_true) & (y_true == 1))\n return tp / p",
"def test_positive_prediction_rate(self):\n # For the penalty, the default loss is hinge.\n expected_penalty_numerator = np.sum(\n np.maximum(0.0, 1.0 + self... | [
"0.6658805",
"0.6581026",
"0.6370896",
"0.6348186",
"0.6128158",
"0.60835314",
"0.58902365",
"0.57238466",
"0.5701457",
"0.5701457",
"0.5701457",
"0.57012624",
"0.5700885",
"0.56846875",
"0.5609275",
"0.56021744",
"0.55271196",
"0.5504725",
"0.54718995",
"0.5463325",
"0.54444... | 0.73354685 | 0 |
Checks that `false_negative_rate` calculates the right quantity. | def test_false_negative_rate(self):
# For the penalty, the default loss is hinge.
expected_penalty_numerator = np.sum(
np.maximum(
0.0, 1.0 - self._penalty_predictions) * (self._penalty_labels > 0.0)
* self._penalty_weights * self._penalty_predicate)
expected_penalty_denominator ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_true_negative_rate(self):\n # For the penalty, the default loss is hinge.\n expected_penalty_numerator = np.sum(\n np.maximum(0.0, 1.0 - self._penalty_predictions) *\n (self._penalty_labels <= 0.0) * self._penalty_weights *\n self._penalty_predicate)\n expected_penalty_denomi... | [
"0.69367796",
"0.6845681",
"0.6583077",
"0.63754237",
"0.6370199",
"0.6309129",
"0.6271165",
"0.61818767",
"0.61776894",
"0.6168362",
"0.61545473",
"0.60782593",
"0.60687685",
"0.6046428",
"0.59589374",
"0.5782035",
"0.57387525",
"0.57364154",
"0.57125586",
"0.5693986",
"0.56... | 0.7223628 | 0 |
Checks that `false_positive_rate` calculates the right quantity. | def test_false_positive_rate(self):
# For the penalty, the default loss is hinge.
expected_penalty_numerator = np.sum(
np.maximum(0.0, 1.0 + self._penalty_predictions) *
(self._penalty_labels <= 0.0) * self._penalty_weights *
self._penalty_predicate)
expected_penalty_denominator = np... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_false_negative_rate(self):\n # For the penalty, the default loss is hinge.\n expected_penalty_numerator = np.sum(\n np.maximum(\n 0.0, 1.0 - self._penalty_predictions) * (self._penalty_labels > 0.0)\n * self._penalty_weights * self._penalty_predicate)\n expected_penalty_d... | [
"0.69273347",
"0.6807434",
"0.6373466",
"0.63313377",
"0.62142867",
"0.6209263",
"0.6167277",
"0.61652184",
"0.6142858",
"0.60831636",
"0.60272557",
"0.60091174",
"0.59308374",
"0.5822954",
"0.5807675",
"0.57631344",
"0.57631344",
"0.57631344",
"0.5752043",
"0.5733503",
"0.57... | 0.70606786 | 0 |
Checks that `true_negative_rate` calculates the right quantity. | def test_true_negative_rate(self):
# For the penalty, the default loss is hinge.
expected_penalty_numerator = np.sum(
np.maximum(0.0, 1.0 - self._penalty_predictions) *
(self._penalty_labels <= 0.0) * self._penalty_weights *
self._penalty_predicate)
expected_penalty_denominator = np.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_false_negative_rate(self):\n # For the penalty, the default loss is hinge.\n expected_penalty_numerator = np.sum(\n np.maximum(\n 0.0, 1.0 - self._penalty_predictions) * (self._penalty_labels > 0.0)\n * self._penalty_weights * self._penalty_predicate)\n expected_penalty_d... | [
"0.7044762",
"0.7018165",
"0.6688207",
"0.6672359",
"0.64299405",
"0.6127128",
"0.6076327",
"0.60389954",
"0.60201216",
"0.5942615",
"0.5936452",
"0.59114635",
"0.5910207",
"0.58915055",
"0.58838934",
"0.58603233",
"0.5844695",
"0.5823794",
"0.5798668",
"0.5798668",
"0.579866... | 0.7309332 | 0 |
Convert class labels from scalars to onehot vectors. | def dense_to_one_hot(labels_dense, num_classes):
num_labels = labels_dense.shape[0]
index_offset = numpy.arange(num_labels) * num_classes
labels_one_hot = numpy.zeros((num_labels, num_classes))
labels_one_hot.flat[index_offset + labels_dense.ravel()] = 1
return labels_one_hot | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def one_hot(labels, classes=None):\n return K.utils.to_categorical(labels, classes)",
"def one_hot(labels, classes=None):\n\n one_hot_ = K.utils.to_categorical(labels, classes)\n return(one_hot_)",
"def to_onehot(labels: torch.Tensor, num_classes: int) -> torch.Tensor:\n if len(labels.size()) == 1:... | [
"0.8250402",
"0.807683",
"0.80523187",
"0.7977843",
"0.7908335",
"0.7900327",
"0.7892233",
"0.7869711",
"0.7849721",
"0.7849721",
"0.7826951",
"0.7826122",
"0.77677035",
"0.7765413",
"0.77540547",
"0.77540547",
"0.77540547",
"0.77489346",
"0.7742955",
"0.7737176",
"0.77226317... | 0.76354444 | 35 |
Test that CustomerMiddleware creates an anonymous Customer for AnonymousUser. | def test_create_new_anonymous_customer(self):
request = self.factory.get('/', follow=True)
request.user = AnonymousUser()
request.session = {'session_key': 'anon1234'}
self.cm.process_request(request)
self.assertTrue(request.customer)
self.assertEqual(request.customer.use... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_dispatch_anonymous_user(self):\n class MyView(LoginRequiredViewMixin, View):\n def get(view, *args, **kwargs):\n self.fail('Should not be reached')\n\n request = RequestFactory().request()\n request.user = AnonymousUser()\n\n view = MyView.as_view()\n ... | [
"0.66848654",
"0.66743237",
"0.6319463",
"0.61627126",
"0.6083965",
"0.6068414",
"0.5973531",
"0.5942034",
"0.5918092",
"0.59007686",
"0.5846884",
"0.58068055",
"0.5799393",
"0.57922816",
"0.57795775",
"0.5752047",
"0.57138",
"0.5712001",
"0.57104814",
"0.5677759",
"0.5667316... | 0.82599217 | 0 |
Test that CustomerMiddleware sets an existing Customer for loggedin User (Bart). | def test_set_existing_customer(self):
request = self.factory.get('/', follow=True)
request.user = self.bart
request.session = {'session_key': 'bart1234'}
self.cm.process_request(request)
self.assertEqual(request.customer, self.bart.customer) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_create_new_auth_customer(self):\n request = self.factory.get('/', follow=True)\n request.user = self.lisa\n request.session = {'session_key': 'lisa1234'}\n self.cm.process_request(request)\n self.assertEqual(request.customer.user, self.lisa)",
"def test_associate_custo... | [
"0.7788062",
"0.7678765",
"0.7220174",
"0.71187156",
"0.69154286",
"0.63328475",
"0.61579543",
"0.6146961",
"0.6108324",
"0.6090526",
"0.6077178",
"0.60656",
"0.60335237",
"0.60284406",
"0.5971079",
"0.5955781",
"0.5935511",
"0.5916114",
"0.5886868",
"0.58795065",
"0.58795065... | 0.8028817 | 0 |
Test that when logging in as a user without existing customer account, the anonymous interim customer object is associated with the loggedin user. | def test_associate_customer_on_login(self):
request = self.factory.post('/shop/auth/login/', follow=True)
request.user = self.lisa
customer = Customer()
customer.save()
request.session = {
'session_key': 'lisa_swap',
SESSION_KEY: customer.pk,
}
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_create_new_anonymous_customer(self):\n request = self.factory.get('/', follow=True)\n request.user = AnonymousUser()\n request.session = {'session_key': 'anon1234'}\n self.cm.process_request(request)\n self.assertTrue(request.customer)\n self.assertEqual(request.c... | [
"0.8249809",
"0.7377318",
"0.7274653",
"0.7205266",
"0.69361496",
"0.6646588",
"0.6448878",
"0.6410444",
"0.6401412",
"0.63848424",
"0.6377872",
"0.6306819",
"0.6273924",
"0.6271465",
"0.6163699",
"0.6159099",
"0.61488837",
"0.6145883",
"0.6118318",
"0.61178684",
"0.6108707",... | 0.71719354 | 4 |
Test that when logging in, an existing cart's Customer reference is set to the new loggedin User's Customer | def test_keep_cart_on_login(self):
request = self.factory.post('/shop/auth/login', follow=True)
request.customer = Customer()
request.customer.save()
request.session = {'session_key': 'keep_cart'}
request.user = self.bart
old_cart = Cart.objects.get_from_request(request)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_set_existing_customer(self):\n request = self.factory.get('/', follow=True)\n request.user = self.bart\n request.session = {'session_key': 'bart1234'}\n self.cm.process_request(request)\n self.assertEqual(request.customer, self.bart.customer)",
"def test_associate_cust... | [
"0.7802173",
"0.77496004",
"0.74576735",
"0.73553795",
"0.6802973",
"0.63349295",
"0.62567306",
"0.62399876",
"0.6228322",
"0.61859185",
"0.61859185",
"0.61154795",
"0.6021684",
"0.5978343",
"0.59782624",
"0.5958144",
"0.594907",
"0.59467286",
"0.59438723",
"0.5919838",
"0.59... | 0.6877997 | 4 |
Adds the hour and minute before a string. This is used to ensure that moderators can tell the exact time that something happened. | def modlog_msg(self, msg: str) -> str:
return '`[{0.hour:02d}:{0.minute:02d}]` {1}'.format(datetime.datetime.utcnow(), msg) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_minutes(self):\n r = self.minute + self.value\n x = int((r / 60))\n\n self.hour = self.hour + x\n self.minute = r - (60 * x)\n\n cycles = int(self.hour / 12)\n if cycles > 0:\n if (cycles % 2) == 0:\n pass\n else:\n ... | [
"0.5950847",
"0.5649144",
"0.5645065",
"0.5616217",
"0.5442537",
"0.54361314",
"0.534542",
"0.5302587",
"0.52932274",
"0.5268911",
"0.5246752",
"0.5246392",
"0.52284795",
"0.52279586",
"0.52072847",
"0.5161985",
"0.5160679",
"0.51543665",
"0.5150068",
"0.51262903",
"0.5088238... | 0.50652087 | 23 |
Endpoint for retrieving a single user record from DB. A successful call returns JSON object with the desired record | async def read_user(user_id: str = Path(..., description="ID value of the desired user"), db_handler: DBHandler = Depends(database_dependency)):
user_record = await db_handler.select_user(user_id=user_id)
user_record = init_BaseUser(user_record)
return user_record | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_user(user_id=None):\n users = storage.all('User')\n user = users.get('User' + \".\" + user_id)\n if user is None:\n abort(404)\n else:\n return jsonify(user.to_dict()), 200",
"def get(self):\n\n user_id = get_jwt_identity()\n user = user_crud.get(user_id)\n ... | [
"0.75204885",
"0.7466428",
"0.7402241",
"0.7303481",
"0.72708744",
"0.7231919",
"0.72199965",
"0.7189568",
"0.71801466",
"0.714877",
"0.71357745",
"0.71146417",
"0.710119",
"0.7087601",
"0.7082582",
"0.7080638",
"0.7072403",
"0.70364934",
"0.70248055",
"0.7019246",
"0.6998656... | 0.63700145 | 89 |
Endpoint for inserting a new team member record into the DB. A successful call returns JSON object with the inserted record | async def add_team_member(team_id: str = Path(..., description="ID value of the desired team"),
user_id: str = Body(..., description="ID value of the desired user", embed=True),
db_handler: DBHandler = Depends(database_dependency)):
try:
inserted_record = ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def create_team(new_team: BaseTeam, db_handler: DBHandler = Depends(database_dependency)):\n try:\n inserted_record = await db_handler.insert_team(new_team=new_team)\n inserted_record = init_BaseTeam(inserted_record)\n except DBHandlerException as e:\n return JSONResponse(status_co... | [
"0.7641702",
"0.72795147",
"0.7206079",
"0.6948133",
"0.6827328",
"0.6669098",
"0.6571304",
"0.6532592",
"0.64999944",
"0.6420415",
"0.63993156",
"0.63885784",
"0.63823146",
"0.63642377",
"0.62873036",
"0.6278181",
"0.62134385",
"0.61848176",
"0.6167753",
"0.6143918",
"0.6132... | 0.73009366 | 1 |
Compute the vector cross product from three vertices of a triangle. Three points are given by their position vectors p, q, and r. | def unit_normals(p,q,r):
vx1 = p[0] - r[0] # x1 - x3.
vy1 = p[1] - r[1] # y1 - y3.
vz1 = p[2] - r[2] # z1 - z3.
vx2 = q[0] - r[0] # x2 - x3.
vy2 = q[1] - r[1] # y2 - y3.
vz2 = q[2] - r[2] # z2 - z3.
vnx = vy1*vz2 - vz1*vy2
vny = vz1*vx2 - vx1*vz2
vnz = vx1*vy2 - vy... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cross_pts_triangle(p1, p2, p3):\n return (p1[:, 0] - p3[0]) * (p2[1] - p3[1]) - (p2[0] - p3[0]) * (p1[:, 1] - p3[1])",
"def crossProduct(p1, p2, p3):\n return (\n -(p1[1]*p2[0]) + p1[0]*p2[1] +\n p1[1]*p3[0] - p2[1]*p3[0] -\n p1[0]*p3[1] + p2[0]*p3[1]\n )",
... | [
"0.7696804",
"0.7601102",
"0.7524363",
"0.71018696",
"0.7035936",
"0.70119935",
"0.68141055",
"0.6792178",
"0.67879146",
"0.67370766",
"0.6658608",
"0.66128504",
"0.65993136",
"0.65971744",
"0.65799236",
"0.65235364",
"0.6490221",
"0.6421809",
"0.64204156",
"0.6376075",
"0.63... | 0.0 | -1 |
Checks if the server has set the auto roles to false | def check_shelve_file(serverName: int):
with shelve.open(shelve_file) as db:
if str(serverName) in db:
data = db[str(serverName)]
return data | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_admin(self):\n return Role.query.get(2) in self.roles",
"def is_administrator(self):\n return False",
"def _has_keystone_role(self, role):\n return False",
"def test_server_administrator():\n if is_server_administrator():\n return True\n raise False",
"def is_admin():\n ... | [
"0.6385331",
"0.6351433",
"0.6261768",
"0.6068112",
"0.60344034",
"0.5983918",
"0.5945717",
"0.5907292",
"0.58524466",
"0.5820304",
"0.5820172",
"0.5802127",
"0.57744503",
"0.5772351",
"0.57107747",
"0.56992275",
"0.5686283",
"0.5686201",
"0.5679841",
"0.567387",
"0.566749",
... | 0.0 | -1 |
Checks if the verified role exists in the guild | async def check_verify_role(ctx: Context):
verified = get(ctx.guild.roles, name='verified')
if verified is None:
await ctx.send(f'{ctx.guild.owner.mention} the verified role doesn\'t exist. Please type `!build` to configure the server for verification')
return
return veri... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_role(role):\n return role in all_roles",
"def hasRole():\n conn = iamConn()\n try:\n conn.get_role(getArgs().role_name)\n return True\n except boto.exception.BotoServerError:\n return False",
"def has_role(self, role):\n return False",
"def has_role(self, rol... | [
"0.71678346",
"0.69229215",
"0.68815637",
"0.6664999",
"0.66306615",
"0.6589084",
"0.6530082",
"0.64616317",
"0.64274174",
"0.6373684",
"0.63677007",
"0.6342548",
"0.6322434",
"0.62350863",
"0.6185856",
"0.6176664",
"0.61649406",
"0.6129348",
"0.61267126",
"0.60836804",
"0.60... | 0.748057 | 0 |
Calculate the Haversine distance. Examples >>> origin = (48.1372, 11.5756) >>> destination = (52.5186, 13.4083) >>> round(distance(origin, destination), 1) 504.2 | def distance(origin, destination): ## https://stackoverflow.com/questions/44743075/calculate-the-distance-between-two-coordinates-with-python
lat1, lon1 = origin
lat2, lon2 = destination
radius = 6371*0.62 # miles
dlat = math.radians(lat2 - lat1)
dlon = math.radians(lon2 - lon1)
a = (math.sin(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def haversine(origin, destination):\n lat1, lon1 = origin\n lat2, lon2 = destination\n radius = 6371000\n dlat = math.radians(lat2 - lat1)\n dlon = math.radians(lon2 - lon1)\n a = math.sin(dlat / 2) * math.sin(dlat / 2) + math.cos(math.radians(lat1)) * math.cos(\n math.radians(lat2)) * mat... | [
"0.8053308",
"0.78129685",
"0.7796539",
"0.77796614",
"0.7750506",
"0.745093",
"0.7350291",
"0.7321472",
"0.7009749",
"0.69546205",
"0.6945083",
"0.6817444",
"0.67876995",
"0.6734275",
"0.6615256",
"0.65530384",
"0.6349515",
"0.63281745",
"0.629635",
"0.6289431",
"0.62837744"... | 0.7707631 | 5 |
Reverses sequences according to their lengths. Inputs should have size ``T x B x `` if ``batch_first`` is False, or ``B x T x `` if True. T is the length of the longest sequence (or larger), B is the batch size, and is any number of dimensions (including 0). | def reverse_padded_sequence(inputs, lengths, batch_first=True):
if not batch_first:
inputs = inputs.transpose(0, 1)
if inputs.size(0) != len(lengths):
raise ValueError('inputs incompatible with lengths.')
reversed_indices = [list(range(inputs.size(1)))
for _ in range... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _reverse_seq(input_seq, lengths):\r\n if lengths is None:\r\n return list(reversed(input_seq))\r\n\r\n flat_input_seq = tuple(nest.flatten(input_) for input_ in input_seq)\r\n\r\n flat_results = [[] for _ in range(len(input_seq))]\r\n for sequence in zip(*flat_input_seq):\r\n input_sh... | [
"0.70199233",
"0.6962687",
"0.66273946",
"0.58645326",
"0.58560705",
"0.5768499",
"0.57513493",
"0.5722611",
"0.5722611",
"0.57105404",
"0.5650213",
"0.54637444",
"0.5365972",
"0.53542304",
"0.53526706",
"0.52790236",
"0.527679",
"0.5250749",
"0.51268",
"0.5109292",
"0.507859... | 0.7303368 | 0 |
Minimum value of given dtype. | def min(self):
if self.kind == 'u':
return 0
else:
try:
val = iinfo._min_vals[self.key]
except KeyError:
val = int(-(1 << (self.bits-1)))
iinfo._min_vals[self.key] = val
return val | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def min_value(dtype):\n return _api_internal._min_value(dtype)",
"def MinimumValue(self):\n datatype = self.NumPyDataType\n if issubclass(datatype, numpy.integer):\n return numpy.iinfo(datatype).min\n elif issubclass(datatype, numpy.floating):\n return -numpy.inf\n ... | [
"0.89836437",
"0.7967805",
"0.70639545",
"0.6908168",
"0.6825716",
"0.6807564",
"0.67371494",
"0.673398",
"0.6700779",
"0.66341376",
"0.6609646",
"0.6594608",
"0.65847456",
"0.65847456",
"0.65721744",
"0.65721744",
"0.65162694",
"0.65081006",
"0.64851487",
"0.6452686",
"0.644... | 0.6448551 | 20 |
Maximum value of given dtype. | def max(self):
try:
val = iinfo._max_vals[self.key]
except KeyError:
if self.kind == 'u':
val = int((1 << self.bits) - 1)
else:
val = int((1 << (self.bits-1)) - 1)
iinfo._max_vals[self.key] = val
return val | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def max_value(dtype):\n return _api_internal._max_value(dtype)",
"def MaximumValue(self):\n datatype = self.NumPyDataType\n if issubclass(datatype, numpy.integer):\n return numpy.iinfo(datatype).max\n elif issubclass(datatype, numpy.floating):\n return numpy.inf\n ... | [
"0.90775704",
"0.8017499",
"0.70144606",
"0.69562256",
"0.69543195",
"0.68937004",
"0.6892016",
"0.6722029",
"0.66489303",
"0.6634152",
"0.6634152",
"0.66192836",
"0.6556985",
"0.65388906",
"0.65357316",
"0.65297335",
"0.65059525",
"0.64996517",
"0.6390727",
"0.6390727",
"0.6... | 0.6515405 | 16 |
Matain the max heap property. >>> Array = [1,5,8,3,7,9,10] >>> minHeapify(Array,1) >>> Array == [1,3,8,5,7,9,10] True >>> Array = [6,5,8,3,7,9,10] >>> minHeapify(Array,0) >>> Array == [5,3,8,6,7,9,10] True | def minHeapify(Array,i):
left = 2*i + 1
right = 2*i + 2
largest = i
if left < len(Array) and Array[left] < Array[i]:
largest = left
if right < len(Array) and Array[right] < Array[largest]:
largest = right
if largest !=i:
Array[largest],Array[i] = Array[i],Array[largest]
minHeapify(Array,largest) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def min_heap(self): \n \n for pos in range(self.size//2, 0, -1): \n self.min_heapify(pos)",
"def build_max_heap(a):\r\n for i in range(math.floor((len(a) - 1)/2), -1, -1):\r\n max_heapify(a, i)",
"def build_max_heap(A):\r\n i = int((len(A)-2)//2)\r\n while i >= 0:\r\n ... | [
"0.7442588",
"0.7402216",
"0.72634447",
"0.7163537",
"0.71227235",
"0.7120371",
"0.71158093",
"0.7106134",
"0.7074383",
"0.7032668",
"0.7012826",
"0.69046843",
"0.6878939",
"0.687714",
"0.68665594",
"0.6845171",
"0.6838036",
"0.6830494",
"0.6830494",
"0.6794365",
"0.6775898",... | 0.7344561 | 2 |
Find the package version for the given path. | def find_version(*file_paths):
version_file = Path(__file__).parent.joinpath(*file_paths)
with open(str(version_file), 'r') as openf:
data = openf.read()
version_match = re.search(
r"^__version__ = ['\"]([^'\"]*)['\"]",
data,
re.M,
)
if version_match:
return v... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def version(path):\n here = os.path.abspath(os.path.dirname(__file__))\n with open(os.path.join(here, path), encoding='utf-8') as f:\n version_file = f.read()\n version_match = re.search(r\"\"\"^__version__ = ['\"]([^'\"]*)['\"]\"\"\",\n version_file, re.M)\n if vers... | [
"0.76413447",
"0.74150264",
"0.73089415",
"0.7129078",
"0.7115831",
"0.709077",
"0.70391893",
"0.7027472",
"0.69897014",
"0.69447",
"0.69238067",
"0.6821995",
"0.67566204",
"0.6742662",
"0.6740767",
"0.67404836",
"0.6732557",
"0.6684963",
"0.6653338",
"0.6653338",
"0.6653338"... | 0.70987165 | 5 |
Creates and returns dict of envoy_response attributes. Called by utils.processor.Puller.call_git_pull(). | def log_envoy_output( log, envoy_response ):
return_dict = {
u'status_code': envoy_response.status_code, # int
u'std_out': envoy_response.std_out.decode(u'utf-8'),
u'std_err': envoy_response.std_err.decode(u'utf-8'),
u'command': envoy_response.command, # list
u'history': en... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_response_dict(self):\n return {\n \"release\": self.settings['bookstore'][\"release\"],\n \"features\": self.settings['bookstore'][\"features\"],\n }",
"def _generate_response_dict(self, response):\n\n R = response\n response_dict = {'content': R.conten... | [
"0.6229333",
"0.6046886",
"0.58004105",
"0.57961494",
"0.5623594",
"0.5623594",
"0.5609082",
"0.5560782",
"0.55360967",
"0.552981",
"0.5522733",
"0.5483679",
"0.54760885",
"0.5441807",
"0.53389406",
"0.5325819",
"0.532098",
"0.5316211",
"0.5315149",
"0.5313212",
"0.53089595",... | 0.5407646 | 14 |
Update a post if the current user is the author. | def update(id):
post = get_post(id)
db = get_db()
cur = db.cursor()
if request.method == 'POST':
title = request.form['title']
body = request.form['body']
error = None
cur.execute('SELECT id FROM novel.post WHERE title = %s', title)
newId = cur.fetcho... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update(self, request, pk=None):\n user = RareUser.objects.get(user=request.auth.user)\n\n # Do mostly the same thing as POST, but instead of\n # creating a new instance of Post, get the Post record\n # from the database whose primary key is `pk`\n post = Post.objects.get(pk=p... | [
"0.6402288",
"0.63080543",
"0.6191634",
"0.6187933",
"0.6152581",
"0.61517787",
"0.6136023",
"0.61076",
"0.60637295",
"0.5993216",
"0.59245545",
"0.591297",
"0.59033036",
"0.5816044",
"0.57806003",
"0.5779193",
"0.57767224",
"0.57723206",
"0.57613695",
"0.5746237",
"0.5740192... | 0.542684 | 62 |
Delete a post. Ensures that the post exists and that the logged in user is the author of the post. | def delete(id):
get_post(id)
db = get_db()
db.cursor().execute('DELETE FROM novel.post WHERE id = %s', id)
db.commit()
return redirect(url_for('novel.index')) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_post(request, post_id):\n post = Post.objects.get(id=post_id)\n\n check_post_owner(request, post)\n post.delete()\n\n return redirect('/posts')",
"def delete_post(post_id):\n\n if CURRENT_USER_KEY not in session:\n raise Unauthorized()\n\n post = Post.query.get_or_404(post_id)... | [
"0.82031965",
"0.8147868",
"0.79974276",
"0.79791605",
"0.795231",
"0.7889284",
"0.7818166",
"0.780275",
"0.7791886",
"0.7790292",
"0.77895135",
"0.7640452",
"0.7622604",
"0.7566871",
"0.74835986",
"0.7420969",
"0.74029267",
"0.7326913",
"0.72961706",
"0.71755576",
"0.7161776... | 0.7017775 | 23 |
Builds a PyTorch Dataloader object | def build_dataloader(bs, shfle):
# change get_labels to correct version (classification vs regression)
dataset = TensorDataset(rand_data(), get_labels())
dataset = TensorDataset(rand_data(), get_regression_labels())
return DataLoader(dataset, batch_size=bs, shuffle=shfle, num_workers=0) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def train_dataloader(self) -> torch.utils.data.DataLoader: \n return torch.utils.data.DataLoader(self.dataset_train, **self.dl_kwargs)",
"def create_dataloader(data):\r\n input_ids = torch.LongTensor([sent['input_ids'] for sent in data])\r\n input_mask = torch.LongTensor([sent['input_mask'] ... | [
"0.8046251",
"0.74321216",
"0.7341278",
"0.73085946",
"0.7288378",
"0.72358453",
"0.72225565",
"0.7170456",
"0.70702946",
"0.7028993",
"0.69924915",
"0.69673496",
"0.6957077",
"0.6950341",
"0.68063205",
"0.67877775",
"0.67685115",
"0.6757724",
"0.674397",
"0.6724243",
"0.6699... | 0.72019047 | 7 |
Create all tables in database and create current database session | def reload(self):
Base.metadata.create_all(self.__engine)
session_factory = sessionmaker(bind=self.__engine,
expire_on_commit=False)
self.__session = scoped_session(session_factory) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_tables():\n db.create_all()",
"def create_tables():\n db.create_all()",
"def create_database_tables():\n with APP.app_context():\n DB.create_all()",
"def create_tables():\n db.create_all()",
"def create_all_tables():\n\tcommon_db.create_all_tables()",
"def create_db_... | [
"0.8049168",
"0.8049168",
"0.8024238",
"0.80076814",
"0.7956346",
"0.79367965",
"0.78759164",
"0.78558576",
"0.7780272",
"0.7654988",
"0.7645599",
"0.7629547",
"0.75928605",
"0.7591247",
"0.75902015",
"0.75724673",
"0.75527364",
"0.7506863",
"0.7409671",
"0.7409671",
"0.74096... | 0.0 | -1 |
Closes the current session | def close(self):
self.__session.close() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def close(self):\n self.sess.close()\n print(\"Current session closed!\")",
"def close_session(self):\n self.sess.close()",
"def close(self):\n self.session.close()",
"def close(self):\n self.session.close()\n self.session = None",
"def close(self):\n self._... | [
"0.82210684",
"0.8132242",
"0.8031977",
"0.79735833",
"0.7861661",
"0.7861661",
"0.7861661",
"0.769321",
"0.7653232",
"0.75665855",
"0.75637054",
"0.7518347",
"0.7420302",
"0.73805135",
"0.7335653",
"0.7326202",
"0.7310997",
"0.7309239",
"0.73042953",
"0.7270649",
"0.72555393... | 0.7939186 | 7 |
Lookup user by ID. Returns User object. | def lookup_user(self, google_subscriber_id):
return self.known_users.get(google_subscriber_id) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_user_by_id(id: str) -> User:\n\n # Find the id user in the database, else return None\n return User.query.get(int(id))",
"def get_user_by_id(self, id):\n\t\treturn self.users.get(id)",
"def find_by_id(cls, _id):\n ## Setup Connection & Cursor\n connection, cursor = Database... | [
"0.8432802",
"0.8334855",
"0.8268179",
"0.8236622",
"0.81780833",
"0.8112108",
"0.8074029",
"0.80414814",
"0.8034395",
"0.80083025",
"0.79854715",
"0.79854715",
"0.79854715",
"0.79854715",
"0.79370934",
"0.7932096",
"0.7932072",
"0.7932072",
"0.7932072",
"0.7932072",
"0.79196... | 0.0 | -1 |
Require that the XRequestedWith header is present. | def csrf_protection(fn):
def protected(*args):
if 'X-Requested-With' in request.headers:
return fn(*args)
else:
return "X-Requested-With header missing", HTTPStatus.FORBIDDEN
return protected | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _check_cors_headers(self, res):\r\n self.assertEqual(res.headers['access-control-allow-origin'], '*')\r\n self.assertEqual(\r\n res.headers['access-control-allow-headers'], 'X-Requested-With')",
"def _check_cors_headers(self, res):\r\n self.assertEqual(res.headers['access-cont... | [
"0.6085809",
"0.6085809",
"0.59580404",
"0.58415264",
"0.58149356",
"0.57102525",
"0.5582455",
"0.55146587",
"0.55080587",
"0.54917204",
"0.5482148",
"0.5482148",
"0.5466235",
"0.5437134",
"0.53966707",
"0.53478366",
"0.53412646",
"0.53360385",
"0.53072786",
"0.53047436",
"0.... | 0.5225086 | 28 |
Feature Likelihoods work by taking the amount a word appears in a class and dividing by the total number of unique words across all classes to get an average appearance rate (perclass). This is done using dictionaries. Each unique word is iterated through each class and then added to the dictionary with the word as the... | def featureLikelihood():
# Lists
words = []
finalWords = []
posWords = []
negWords = []
featureListPos = []
featureListNeg = []
# Counters
posCount = 0.0
negCount = 0.0
# Temporary Lists for formating
featureListPosFormat = []
featureListNegFormat = []
# Strings
s = " "
posStri... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def score(self, data):\n\n score_mappings = {\n \"0\": np.log(self.class_zero_doc_count / self.total_docs),\n \"1\": np.log(self.class_one_doc_count / self.total_docs)\n }\n\n features = self.featurize(data)\n\n for f in features:\n\n if(f[0] in self.class_zero):\n cond_prob_zero ... | [
"0.6706344",
"0.66332144",
"0.65734005",
"0.65337044",
"0.65242285",
"0.64811975",
"0.6421563",
"0.64030236",
"0.63964957",
"0.63382864",
"0.62973624",
"0.62641805",
"0.62209976",
"0.61703384",
"0.61535525",
"0.610564",
"0.6103358",
"0.60829455",
"0.6063234",
"0.6063234",
"0.... | 0.7408255 | 0 |
Iterate over each comment and extract data from each comment using get_comment_data() function. | def make_parsed_comments(self):
if not hasattr(self, 'separated_comments'):
self.separated_comments = self.separate_comments()
# build comments list of dictionaries, one dictionary for each article
self.comments = []
for self.separated_comment in self.separated_comme... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_comments():\n comments = list(get_comments(TEST_SUBREDDIT, TEST_START_DATE, TEST_END_DATE, TEST_MAX))\n\n # prints the dictionary of variables for each comment\n for x in comments:\n print(x.d_)",
"def get_comment_data(self, comment):\n # remove double spaces but not triple on... | [
"0.7332372",
"0.7074068",
"0.70301205",
"0.6994612",
"0.6979778",
"0.68328553",
"0.67220294",
"0.6697474",
"0.65514123",
"0.65284103",
"0.65092796",
"0.64646816",
"0.6449869",
"0.6434129",
"0.6432593",
"0.63737774",
"0.63255346",
"0.63207877",
"0.6295385",
"0.6278651",
"0.626... | 0.67260534 | 6 |
Strip nonalphanumeric characters to makes name safe to be used as filename. | def _clean_filename(name):
return re.sub("[^\\w .]", "", name) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sanitize_filename(file_path: str) -> str:\n file_name = file_path.lower().replace(\" \", \"_\").replace(\".\", \"_\")\n file_name = \"\".join(\n [\n i if i in (string.ascii_letters + string.digits + \"_\") else \"\"\n for i in file_name\n ]\n )\n return file_name... | [
"0.80946064",
"0.80480504",
"0.80395657",
"0.79483396",
"0.7940658",
"0.7863757",
"0.7839006",
"0.7819667",
"0.78089964",
"0.779706",
"0.77634895",
"0.7745419",
"0.7708361",
"0.77045447",
"0.7613121",
"0.7604243",
"0.75968415",
"0.7548353",
"0.75364566",
"0.7526289",
"0.75052... | 0.8493206 | 0 |
Return a new Project instance, deepcopying all the attributes. | def copy(self):
p = Project()
p.name = self.name
p.path = self.path
p._plugin = self._plugin
p.stage = self.stage.copy()
p.stage.project = p
for sprite in self.sprites:
s = sprite.copy()
s.project = p
p.sprites.append(s)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_instance(self, include_optional):\n # model = openapi_client.models.project.Project() # noqa: E501\n if include_optional :\n return Project(\n budget_amount = 10000, \n budget_time = 60, \n customer_id = 56, \n hourly_ra... | [
"0.7216631",
"0.71525055",
"0.6624169",
"0.6593631",
"0.6498652",
"0.6467549",
"0.64277905",
"0.6352878",
"0.63396776",
"0.63274384",
"0.62370574",
"0.61986554",
"0.61330616",
"0.6122775",
"0.61147434",
"0.61070347",
"0.6096353",
"0.609321",
"0.60842913",
"0.60530573",
"0.605... | 0.7906274 | 0 |
Return a new instance, deepcopying all the attributes. | def copy(self, o=None):
if o is None: o = self.__class__(self.project)
o.scripts = [s.copy() for s in self.scripts]
o.variables = dict((n, v.copy()) for (n, v) in self.variables.items())
o.lists = dict((n, l.copy()) for (n, l) in self.lists.items())
o.costumes = [c.copy() for c i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def copy(self):\n new = self.__class__(integration=None, data=None)\n for attribute, value in self.__dict__.items():\n if attribute in self.referenced_attributes:\n setattr(new, attribute, value)\n elif hasattr(value, 'copy'):\n setattr(new, attribu... | [
"0.8368815",
"0.8091118",
"0.8079612",
"0.79395074",
"0.78100175",
"0.7808361",
"0.7793221",
"0.7696886",
"0.76492363",
"0.7640317",
"0.7601366",
"0.75700897",
"0.756656",
"0.75661445",
"0.75605375",
"0.7550344",
"0.75373673",
"0.7535898",
"0.75326896",
"0.7523898",
"0.751940... | 0.0 | -1 |
Return a new instance, deepcopying all the attributes. | def copy(self):
o = self.__class__(self.project, self.name)
Scriptable.copy(self, o)
o.position = tuple(self.position)
o.direction = self.direction
o.rotation_style = self.rotation_style
o.size = self.size
o.is_draggable = self.is_draggable
o.is_visible = ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def copy(self):\n new = self.__class__(integration=None, data=None)\n for attribute, value in self.__dict__.items():\n if attribute in self.referenced_attributes:\n setattr(new, attribute, value)\n elif hasattr(value, 'copy'):\n setattr(new, attribu... | [
"0.8368815",
"0.8091118",
"0.8079612",
"0.79395074",
"0.78100175",
"0.7808361",
"0.7793221",
"0.7696886",
"0.76492363",
"0.7640317",
"0.7601366",
"0.75700897",
"0.756656",
"0.75661445",
"0.75605375",
"0.7550344",
"0.75373673",
"0.7535898",
"0.75326896",
"0.7523898",
"0.751940... | 0.0 | -1 |
Returns True if any of the plugins have the given command. | def has_command(self, command):
for pbt in self._plugins.values():
if pbt.command == command:
return True
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def command_registered(self, command: str) -> bool:\n return command in self._commands",
"def has_commands(self) -> bool:\n return len(self.commands) > 0",
"def has_command_with_name(self, command_name):\n return command_name in self.commands",
"def is_configured(command):\n return co... | [
"0.7463818",
"0.7279998",
"0.71572435",
"0.6972467",
"0.6797064",
"0.67461526",
"0.66978073",
"0.66571355",
"0.6595021",
"0.65834886",
"0.65720695",
"0.65717274",
"0.6486513",
"0.6465487",
"0.6460167",
"0.64471656",
"0.63926286",
"0.6382024",
"0.6352107",
"0.61823845",
"0.616... | 0.8573095 | 0 |
Return a new Block instance with the same attributes. | def copy(self):
args = []
for arg in self.args:
if isinstance(arg, Block):
arg = arg.copy()
elif isinstance(arg, list):
arg = [b.copy() for b in arg]
args.append(arg)
return Block(self.type, *args) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new_block(self):\n child = Block(self, py3_wrapper=self.py3_wrapper)\n self.add(child)\n return child",
"def gen_new_block(self):\n block = BasicBlock()\n self.blocks.append(block)\n return block",
"def create_block(self):\n return poet_transaction_block.Poe... | [
"0.7536758",
"0.73994404",
"0.7051436",
"0.67192554",
"0.66903394",
"0.6678634",
"0.65945905",
"0.65464205",
"0.654345",
"0.6499044",
"0.64730847",
"0.6446289",
"0.64232606",
"0.6347958",
"0.6339046",
"0.62819964",
"0.62518865",
"0.6250901",
"0.6225476",
"0.6197408",
"0.61812... | 0.68223715 | 3 |
The raw file contents as a string. | def contents(self):
if not self._contents:
if self._path:
# Read file into memory so we don't run out of file descriptors
f = open(self._path, "rb")
self._contents = f.read()
f.close()
elif self._pil_image:
#... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def raw_body(self):\n return file_ops.read_utf8(self.raw_file_name)",
"def read_raw(file_path):\n file = open(file_path, 'rb')\n content = file.read()\n file.close()\n return content",
"def raw_content(self, file_name):\n if file_name not in self._raw_content:\n raise FileN... | [
"0.7860723",
"0.7441076",
"0.7291069",
"0.7247528",
"0.7225412",
"0.7222198",
"0.7203476",
"0.71992844",
"0.7106849",
"0.7090295",
"0.70793235",
"0.7050471",
"0.7013505",
"0.7013505",
"0.7002724",
"0.6990316",
"0.6982773",
"0.69800353",
"0.6942982",
"0.6925801",
"0.69040364",... | 0.66987157 | 36 |
Return a new Image instance with the given size. | def resize(self, size):
return Image(self.pil_image.resize(size, PIL.Image.ANTIALIAS)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new(self, size, fill):\n return Image(PIL.Image.new(\"RGB\", size, fill))",
"def new(mode, size, color=0):\r\n\r\n _check_size(size)\r\n\r\n if color is None:\r\n # don't initialize\r\n _im = Image()._new(mode, size)\r\n return Image(_im)\r\n\r\n if type(color).__name__ =... | [
"0.74299407",
"0.71332496",
"0.66240644",
"0.66213405",
"0.61818314",
"0.6128221",
"0.612808",
"0.6053513",
"0.59906405",
"0.59292006",
"0.5915368",
"0.589351",
"0.5858819",
"0.584907",
"0.578464",
"0.5779175",
"0.5767449",
"0.57649523",
"0.5754808",
"0.574792",
"0.5723836",
... | 0.7715182 | 0 |
The raw file contents as a string. | def contents(self):
if not self._contents:
if self._path:
# Read file into memory so we don't run out of file descriptors
f = open(self._path, "rb")
self._contents = f.read()
f.close()
return self._contents | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def raw_body(self):\n return file_ops.read_utf8(self.raw_file_name)",
"def read_raw(file_path):\n file = open(file_path, 'rb')\n content = file.read()\n file.close()\n return content",
"def raw_content(self, file_name):\n if file_name not in self._raw_content:\n raise FileN... | [
"0.7860723",
"0.7441076",
"0.7291069",
"0.7247528",
"0.7225412",
"0.7222198",
"0.7203476",
"0.71992844",
"0.7106849",
"0.7090295",
"0.70793235",
"0.7050471",
"0.7013505",
"0.7013505",
"0.7002724",
"0.6990316",
"0.69800353",
"0.6942982",
"0.6925801",
"0.69040364",
"0.68848693"... | 0.6982773 | 16 |
Transform documents to document ids. Uses the vocabulary learned by fit. | def transform(self, nodelist, word_list, labels):
word_ids = []
node_ids = []
entry_ids = []
# first entry is pad so skipping index 0
for index in range(1,len(nodelist)):
node_ids.append(self._node_vocab.token_to_id(nodelist[index]))
word_ids.append(torch.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def docs2ids(self):\n self.docs = [ [self.vocab[word] for word in doc] for doc in self.docs]",
"def fit(self, documents):\n # Get a list of all the unique tokens that appear\n vocab = list({\n token for doc in documents\n for token in self.tokenizer(doc)\n if... | [
"0.78432965",
"0.7000663",
"0.69749004",
"0.6788437",
"0.6596391",
"0.6499104",
"0.6462402",
"0.63590664",
"0.63344616",
"0.63179237",
"0.62937015",
"0.62158763",
"0.6208575",
"0.6172077",
"0.6092886",
"0.6073852",
"0.6065319",
"0.60377",
"0.60144186",
"0.60141927",
"0.601198... | 0.0 | -1 |
Pads nested sequences to the same length. This function transforms a list of list sequences into a 3D Numpy array of shape `(num_samples, max_sent_len, max_word_len)`. | def pad_nested_sequences_2(sequences, dtype='int32'):
max_item_len = 0
max_sent_len = 0
max_word_len = 0
for item in sequences:
max_item_len = max(len(item), max_item_len)
for sent in item:
max_sent_len = max(len(sent), max_sent_len)
for word in sent:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pad_sequences(sequences):\n max_len = max(s.shape[0] for s in sequences)\n padded = []\n for seq in sequences:\n zero_pad = np.concatenate(\n [seq, np.zeros((max_len - seq.shape[0], ) + seq.shape[1:])])\n padded.append(zero_pad[np.newaxis, :])\n\n return np.concatenate(padd... | [
"0.6786531",
"0.6401596",
"0.63986963",
"0.6298268",
"0.6223134",
"0.6165001",
"0.61590457",
"0.61563927",
"0.60780656",
"0.6067173",
"0.6012639",
"0.5970407",
"0.5952945",
"0.58720696",
"0.57874423",
"0.5768235",
"0.57276255",
"0.5727428",
"0.57177216",
"0.57092017",
"0.5702... | 0.7720116 | 0 |
Add token to vocabulary. | def add_token(self, token):
token = self.process_token(token)
self._token_count.update([token]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_token(self,token):\n\t\tif not token:\n\t\t\tlogging.error(\"Token cannot be empty!\")\n\t\t\texit()\n\n\t\tself.tokens.append(token.lower())\n\t\t#self.user_defined_token = token.lower()",
"def add_embedding(self, token, embedding):\n self.word2idx[token] = self.vocab_size\n self.vocab_siz... | [
"0.74729335",
"0.7234671",
"0.6903962",
"0.65249616",
"0.6521398",
"0.650715",
"0.650715",
"0.65013736",
"0.64981705",
"0.6494259",
"0.642393",
"0.6422184",
"0.6393605",
"0.6326445",
"0.632267",
"0.6252545",
"0.6232168",
"0.6224262",
"0.61765915",
"0.61676633",
"0.613436",
... | 0.68857247 | 3 |
Get the token_id of given token. | def token_to_id(self, token):
token = self.process_token(token)
return self._token2id.get(token, len(self._token2id) - 1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def token_to_id(self, token):\n token = self.process_token(token)\n return self.token2id.get(token, len(self.token2id) - 1)",
"def token_to_id(self, token):\r\n return self.encoder.get(token, self.encoder.get(self.unk_token))",
"def token_id(self) -> Optional[pulumi.Input[int]]:\n r... | [
"0.82989067",
"0.7979915",
"0.7922241",
"0.7840658",
"0.7576964",
"0.7306817",
"0.7158743",
"0.715114",
"0.7099519",
"0.6801345",
"0.6638258",
"0.65516716",
"0.65167975",
"0.64725715",
"0.6458122",
"0.64344007",
"0.6429334",
"0.6406695",
"0.6379266",
"0.6309874",
"0.62972295"... | 0.83112437 | 0 |
Returns the block which encloses each node at a given depth. This only makes sense if the branches of the provided tree use the ``<`` operator as a split rule. | def iter_blocks(tree, limits, depth=-1):
if depth == 0 or isinstance(tree, Leaf):
yield (tree, limits)
return
on, at = tree.split.on, tree.split.at
l_limits = {**limits, on: (limits[on][0], at)} if on in limits else limits
yield from iter_blocks(tree=tree.left, limits=l_limits, depth=d... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def represent_tree_branches(self, levels):\r\n for level in levels[:-1]:\r\n branch = []\r\n prev_child_mid = 0 \r\n for node in level:\r\n curr_child_mid = node.children[0].str_pos + len(str(node.children[0].keys))//2\r\n space_between_children... | [
"0.55095315",
"0.5351905",
"0.5294218",
"0.52384305",
"0.51760787",
"0.5160343",
"0.51137555",
"0.5089668",
"0.50840867",
"0.50597936",
"0.50450677",
"0.50373584",
"0.50080186",
"0.49802253",
"0.4968421",
"0.49674702",
"0.4965215",
"0.4948287",
"0.49374282",
"0.49295837",
"0.... | 0.5393795 | 1 |
Returns n items from the pool which do not appear in a_as_set. | def PickFromPool(n, pool, a_as_set):
assert isinstance(a_as_set, set)
# Remove the ones that are in A.
filtered_pool = list(filter(lambda x: x not in a_as_set, pool))
# Pick N random numbers out of the pool.
return random.sample(filtered_pool, k=n) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def discard_pools ( self, count ):\n for i in range ( count ):\n if not self.discard_pool():\n return i\n else:\n return count",
"def complement(self, aset):\n return self.all_n.difference(aset)",
"def unused(permutation, nb_elements):\n return tuple(set(range(nb_... | [
"0.6043328",
"0.59999216",
"0.5927136",
"0.56547827",
"0.5543426",
"0.55371153",
"0.54656863",
"0.5449808",
"0.5442581",
"0.5441616",
"0.54403806",
"0.5440226",
"0.5425959",
"0.5414929",
"0.53234166",
"0.5321045",
"0.5302203",
"0.52697027",
"0.5229382",
"0.5225017",
"0.521797... | 0.70686746 | 0 |
Update mock_s3_fs (which is just a dictionary mapping bucket to key to contents) with a map from bucket name to key name to data and time last modified. | def add_mock_s3_data(mock_s3_fs, data, time_modified=None):
if time_modified is None:
time_modified = datetime.utcnow()
for bucket_name, key_name_to_bytes in data.iteritems():
mock_s3_fs.setdefault(bucket_name, {'keys': {}, 'location': ''})
bucket = mock_s3_fs[bucket_name]
for k... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update():\n\n metadata = _init()\n\n if S3_SYNC_ON_UPDATE:\n # sync the buckets to the local cache\n log.info(\"Syncing local cache from S3...\")\n for saltenv, env_meta in metadata.items():\n for bucket_files in _find_files(env_meta):\n for bucket, files in... | [
"0.6477593",
"0.58820546",
"0.5846673",
"0.5762668",
"0.5695114",
"0.5686465",
"0.5676517",
"0.56270915",
"0.5614456",
"0.5606306",
"0.55928564",
"0.5591715",
"0.5589946",
"0.55652535",
"0.55367",
"0.5509119",
"0.5495699",
"0.5492591",
"0.54299265",
"0.5426835",
"0.54265183",... | 0.78062475 | 0 |
Returns a dictionary from key to data representing the state of this bucket. | def mock_state(self):
if self.name in self.connection.mock_s3_fs:
return self.connection.mock_s3_fs[self.name]['keys']
else:
raise boto.exception.S3ResponseError(404, 'Not Found') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __getstate__(self):\n return dict(self.items())",
"def __getstate__(self):\n return dict(self.items())",
"def get_state(self) -> dict:\n return {\n \"name\": self.name,\n \"namespace\": self.namespace,\n \"args\": self.args,\n \"kwargs\": sel... | [
"0.7184382",
"0.7184382",
"0.69821644",
"0.69549227",
"0.689041",
"0.6856496",
"0.6848155",
"0.67642736",
"0.671032",
"0.66058415",
"0.6602773",
"0.65959823",
"0.6522606",
"0.65018773",
"0.6484786",
"0.6482396",
"0.6480916",
"0.64688045",
"0.64624137",
"0.6457508",
"0.6447871... | 0.0 | -1 |
Convert a datetime to ISO8601 format. | def to_iso8601(when):
return when.strftime(boto.utils.ISO8601) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def datetime_to_iso8601(date_time):\n assert not date_time.utcoffset()\n return date_time.strftime('%Y-%m-%dT%H:%M:%S.%f') + 'Z'",
"def format_datetime(self, datetime):\n return datetime.isoformat()",
"def datetime_to_isoformat(obj: datetime.datetime) -> str:\n return obj.replace(tzinfo=datetim... | [
"0.809647",
"0.7928091",
"0.77804065",
"0.7651685",
"0.7635066",
"0.7418882",
"0.74084014",
"0.73377186",
"0.7302427",
"0.7164118",
"0.7067867",
"0.6908184",
"0.6872752",
"0.68654495",
"0.686369",
"0.68489695",
"0.6834109",
"0.68263865",
"0.6789046",
"0.67770064",
"0.67657244... | 0.7383531 | 7 |
Create a mock version of EmrConnection. Most of these args are the same as for the real EmrConnection, and are ignored. By default, jobs will run to conclusion, and if their output dir is on S3, create a single empty output file. You can manually decide that some jobs will fail, or give them different output by setting... | def __init__(self, aws_access_key_id=None, aws_secret_access_key=None,
is_secure=True, port=None, proxy=None, proxy_port=None,
proxy_user=None, proxy_pass=None, debug=0,
https_connection_factory=None, region=None,
mock_s3_fs=None, mock_emr_job_flows=No... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_build_mockenv(testcase, test_mode, verbose, connections_file,\n default_namespace, mock_files, exp_dep_files,\n exp_classes, exp_providers, exp_stdout_lines,\n exp_stdout_lines_all, exp_stderr_lines):\n\n # The connections file is used b... | [
"0.5726862",
"0.53230107",
"0.53207815",
"0.5299193",
"0.52512777",
"0.5243936",
"0.5150493",
"0.5072373",
"0.5039666",
"0.50006425",
"0.49996206",
"0.49859005",
"0.49797344",
"0.49727598",
"0.49652404",
"0.49560136",
"0.4947567",
"0.49435195",
"0.49139443",
"0.49043238",
"0.... | 0.6906124 | 0 |
Return the subset of resources to which `task` could be submitted to. Note that the result subset could be empty (no resource can accomodate task's requirements). The default implementation uses the task's `compatible_resources` method to retain only the resources that satisfy the task's requirements. If `task` does no... | def filter(self, task, resources):
gc3libs.log.debug(
"Performing matching of resource(s) %s to task '%s' ...",
str.join(',', (r.name for r in resources)), task)
# keep only compatible resources
try:
compatible_resources = task.compatible_resources(resources)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_resource_tasks(self, existing, desired):\n unmanaged = {\n name: resource for name, resource in list(existing.items())\n if resource.whitelist is True\n }\n managed = {\n name: resource for name, resource in list(existing.items())\n if resou... | [
"0.59152967",
"0.57319427",
"0.56433326",
"0.5632408",
"0.54375494",
"0.54336274",
"0.54195744",
"0.53225803",
"0.53204966",
"0.53163177",
"0.5284135",
"0.52696943",
"0.5261301",
"0.52562416",
"0.52455366",
"0.5233198",
"0.5227293",
"0.52187794",
"0.52114743",
"0.52014023",
"... | 0.7712798 | 0 |
Implementation of `free` on generic `Task` objects. | def __free_task(self, task, **extra_args):
return task.free(**extra_args) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def free(self, task, **extra_args):\n self._core.free(task)",
"def free(self, app, **extra_args):\n assert isinstance(\n app, Task), \"Core.free: passed an `app` argument which\" \\\n \" is not a `Task` instance.\"\n if isinstance(app, Application):\n return ... | [
"0.77377737",
"0.6671546",
"0.6193569",
"0.59479296",
"0.59479296",
"0.5761685",
"0.573504",
"0.5712799",
"0.56533164",
"0.5429318",
"0.53521",
"0.53091395",
"0.53081894",
"0.52330285",
"0.5215529",
"0.5203118",
"0.517941",
"0.517012",
"0.5146617",
"0.51352525",
"0.5098966",
... | 0.8227064 | 0 |
Update the state of a given set of resources. Each resource object in the returned list will have its `updated` attribute set to `True` if the update operation succeeded, or `False` if it failed. Optional argument `resources` should be a subset of the resources configured in this `Core` instance (the actual | def update_resources(self, resources=all, **extra_args):
if resources is all:
resources = self.resources.values()
for lrms in self.resources.itervalues():
try:
if not lrms.enabled:
continue
# auto_enable_auth = extra_args.get(
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_from_resources(self, resources):\n for resource in resources:\n cmpt_name = resource['component']\n cmpt = self.get_component(cmpt_name)\n cmpt.update_from_index(resource)",
"def update_resources(self, request):\n request.worker.update_resources(request.m... | [
"0.7048088",
"0.68757516",
"0.64546895",
"0.63831866",
"0.6026745",
"0.5988969",
"0.5904604",
"0.5785076",
"0.5770061",
"0.57578737",
"0.5680139",
"0.5680139",
"0.5680139",
"0.5680139",
"0.55832434",
"0.5555675",
"0.55483896",
"0.5494435",
"0.54294586",
"0.5354055",
"0.532552... | 0.779008 | 0 |
Return the "queue" object to which `task` should be added or removed. | def __get_task_queue(self, task):
state = task.execution.state
if Run.State.NEW == state:
return self._new
elif state in [Run.State.SUBMITTED,
Run.State.RUNNING,
Run.State.UNKNOWN]:
return self._in_flight
elif Run.Stat... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_queue(self, task_name):\n for name, queue in self.queues.items():\n if task_name in queue:\n return name\n return self.default_queue",
"def get(self, task_id=None):\n if task_id:\n item = self.find(task_id)\n self.queue.remove(item)\n ... | [
"0.74984604",
"0.73740643",
"0.7210032",
"0.7138595",
"0.7138595",
"0.7138595",
"0.7138595",
"0.7138595",
"0.7138595",
"0.7138595",
"0.7138595",
"0.7138595",
"0.7138595",
"0.7138595",
"0.7138595",
"0.7138595",
"0.7138595",
"0.7138595",
"0.7022472",
"0.70222056",
"0.6947423",
... | 0.7825473 | 0 |
function to check if arg is a sequence and if not return it as a sequence of type defined by seq_type, also if the arg is a sequence and the seq_type is different to the arg type change the arg type to | def to_sequence(arg, seq_type=None):
def return_type(t):
if t:
if t is tuple:
return (arg, ) if arg else tuple()
elif t is dict:
return {arg: True} if arg else dict()
elif t is set:
return {arg, } if arg else set()
r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _is_proper_sequence(seq):\n return (isinstance(seq, collections.abc.Sequence) and\n not isinstance(seq, str))",
"def is_seq_of(seq, expected_type, seq_type=None):\n if seq_type is None:\n exp_seq_type = abc.Sequence\n else:\n assert isinstance(seq_type, type)\n exp_se... | [
"0.7048978",
"0.65860873",
"0.6574346",
"0.6464543",
"0.6455618",
"0.6436927",
"0.6380795",
"0.6257902",
"0.6146337",
"0.6130334",
"0.6124085",
"0.6077264",
"0.60568476",
"0.5940078",
"0.5924707",
"0.5902315",
"0.58780205",
"0.58504236",
"0.5838647",
"0.5795873",
"0.5774803",... | 0.8393408 | 0 |
Generates rows of elements from the list of values. The values can be in row or column order meaning that if we get 1,2,3,4,5,6 with rows=2 and row order=True then we will generate [1,2,3],[4,5,6], but for row_order=False we will generate [1,3,5],[2,4,6] as it will be in column order | def list_to_matrix_index_generator(values, rows=None, columns=None, row_order=True):
import math
values_length = len(values)
assert (rows is not None or columns is not None)
assert (rows is None or columns is None or ((rows * columns) >= values_length))
num_cols = columns
num_rows = rows
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def from_value_rowids_bridge(values,\n value_rowids=None,\n nrows=None,\n validate=True):\n return tf.RaggedTensor.from_value_rowids(\n values,\n value_rowids=value_rowids,\n nrows=nrows\n ,\n validate=val... | [
"0.61188406",
"0.59484595",
"0.5915201",
"0.5890757",
"0.58135366",
"0.57653135",
"0.57468224",
"0.5725723",
"0.57140774",
"0.5699199",
"0.5560281",
"0.5464769",
"0.5439684",
"0.5438656",
"0.5437691",
"0.5382813",
"0.53813064",
"0.534492",
"0.5291814",
"0.5273047",
"0.5253283... | 0.66675407 | 0 |
Dumps a dictionay json_object to file_object, adding a trailing newline, hence creating a json line format. | def json_dump_line(json_object, file_object):
json.dump(json_object, file_object)
file_object.write('\n') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dump_json(object, filename):\n import json\n\n filename = filename if filename.endswith('.json') else (filename + '.json')\n\n with open(filename, 'w') as f:\n json.dump(object, f, indent=4)",
"def save_json(self, file: Union[str, TextIO]) -> None:\n if hasattr(file, 'w... | [
"0.7230381",
"0.7168676",
"0.6953142",
"0.6859603",
"0.68569684",
"0.6848547",
"0.68326",
"0.67735463",
"0.6734369",
"0.6712644",
"0.668636",
"0.6663076",
"0.6636362",
"0.66312325",
"0.662516",
"0.6607062",
"0.6585858",
"0.65848774",
"0.6563936",
"0.6559908",
"0.65435946",
... | 0.86214465 | 0 |
List all comments for the given publication | def get_publication_comments(project, publication_id):
connection = db_engine.connect()
publications = get_table("publication")
publication_comments = get_table("publication_comment")
statement = select([publications.c.publication_comment_id]).where(publications.c.id == int_or_none(publication_id))
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def commentList(post):\n comments = Comment.objects.all().filter(post=post).order_by('-published')\n remote_comments = RemoteComment.objects.all().filter(post=post).order_by('published')\n comment_list = list()\n\n if comments:\n for comment in comments:\n comment_dict = dict()\n ... | [
"0.62323225",
"0.61163723",
"0.595245",
"0.59143114",
"0.5911291",
"0.57608",
"0.574519",
"0.56935185",
"0.5643901",
"0.55876124",
"0.55732495",
"0.554478",
"0.5534601",
"0.5533338",
"0.54624593",
"0.54621977",
"0.54591435",
"0.5431179",
"0.5419164",
"0.5419164",
"0.5419164",... | 0.7334161 | 0 |
Method to get month | def get_month(self, indate):
return indate.strftime("%B") + "-" + indate.strftime("%Y") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_month():\n return handle_invalid_inputs(question_3, months)",
"def getMonth(self):\n return _libsbml.Date_getMonth(self)",
"def date_month(date):\n return date.month",
"def month(self):\n return gocept.month.Month(self.calendar_month, self.calendar_year)",
"def month(self):\n ... | [
"0.8086576",
"0.8002205",
"0.7984373",
"0.7974861",
"0.7934924",
"0.7934924",
"0.79122186",
"0.7886652",
"0.7879902",
"0.7818692",
"0.7818692",
"0.7817003",
"0.7805717",
"0.7688297",
"0.76712424",
"0.75677025",
"0.7469194",
"0.7461936",
"0.7399832",
"0.73693633",
"0.7364474",... | 0.76314014 | 15 |
Train autoencoder, or load from save file. model The autoencoder model to train. dataset Dataset to train the autoencoder on. iterations Number of epochs to train the autoencoder for. lr Initial learning rate. device Device to train the autoencoder on "cuda" or "cpu". save_fn Save the trained model to this filename. lo... | def train_ae(
model,
dataset,
iterations=10,
lr=0.001,
device='cpu',
save_fn="mnist-cae",
load_path="./models/saved_models/mnist-cae.h5"
):
model.train()
if load_path:
if os.path.isfile(load_path):
model.load_state_dict(torch.l... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def train(X_train, y_train, save_model='model.h5'):\n \n # Hyperparameters\n batch_size = 32\n epochs = 30\n learning_rate = 0.001\n \n # Loading model from model.py\n model = m(input_height=IMAGE_HEIGHT, input_width=IMAGE_WIDTH)\n \n # Plot model as image\n plot_model(model, to_fi... | [
"0.70724666",
"0.65211344",
"0.6469351",
"0.64565045",
"0.6387511",
"0.6386832",
"0.6360796",
"0.6302913",
"0.629286",
"0.62609565",
"0.61705846",
"0.6164463",
"0.6157023",
"0.61479944",
"0.61340076",
"0.6128263",
"0.61214095",
"0.61079574",
"0.6092489",
"0.6090521",
"0.60777... | 0.642947 | 4 |
Calculates the accuracy for a set of prediction and targets. predictions Softmax'ed output values of the network. targets One hot target vectors | def get_accuracy(predictions, targets):
accuracy = (predictions.argmax(1).cpu().numpy() ==
targets.cpu().numpy()).sum()/(predictions.shape[0])
return accuracy | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def accuracy(predictions, targets):\n\n ########################\n # PUT YOUR CODE HERE #\n #######################\n i1 = np.arange(0, len(targets), 1)\n i2 = np.argmax(predictions, axis = 1)\n accuracy = targets[i1, i2].sum()/targets.sum()\n ########################\n # END OF YOUR CODE #\n ########... | [
"0.8132433",
"0.81215614",
"0.80249375",
"0.78621995",
"0.7839711",
"0.7760333",
"0.7696801",
"0.76615036",
"0.7652527",
"0.7629226",
"0.7579975",
"0.75517714",
"0.7540051",
"0.7516909",
"0.7486663",
"0.7482437",
"0.7482437",
"0.7481824",
"0.7472463",
"0.74041873",
"0.7398515... | 0.769629 | 7 |
The CDF of the Normal distribution cannot be written in an elementary manner, but we can write it using Python's ERF (Error Function) | def normal_cdf(x: float, mu: float = 0, sigma: float = 1) -> float:
return (1 + math.erf((x - mu) / math.sqrt(2) / sigma)) / 2 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cdf(s, x):\r\n x = Basic.sympify(x)\r\n return (1+erf((x-s.mu)/(s.sigma*sqrt(2))))/2",
"def F_std_coeff(d):\n return (d ** 2 - 1) / 4",
"def _normal_distribution_cdf(x, stddev):\n return 0.5 * (1.0 + tf.erf(x / (math.sqrt(2) * stddev + 1e-20)))",
"def cdf_normal(x: float, mean: float ... | [
"0.6452322",
"0.6238491",
"0.6203963",
"0.61198807",
"0.61091924",
"0.6022523",
"0.59861195",
"0.5968825",
"0.59581625",
"0.5936213",
"0.5910307",
"0.59087646",
"0.5888402",
"0.58851177",
"0.5870652",
"0.58184093",
"0.57949775",
"0.57912487",
"0.5786685",
"0.57569283",
"0.574... | 0.5917945 | 10 |
Find approximate inverse using binary search. We need to invert normal_cdf to find the value corresponding to a specified probability (pvalue). There's no simple way to compute its inverse, but normal_cdf is continuous and strictly increasing, so we can use a Binary Search. This function repeatedly bisects intervals un... | def inverse_normal_cdf(p: float, mu: float = 0, sigma: float = 1, tolerance: float = 0.00001) -> float:
# If not standard, compute standard and rescale
if mu != 0 or sigma != 1:
return mu + sigma * inverse_normal_cdf(p, tolerance=tolerance)
# normal_cdf(-10) is very close to 0, normal_cdf(10) is ve... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def inverse_normal_cdf(p: float, mu: float = 0, sigma: float = 1, tolerance: float = 0.00001) -> float:\n # if not standard, compute standard and rescale \n if mu != 0 or sigma != 1:\n return mu + sigma * inverse_normal_cdf(p, tolerance=tolerance)\n low_z = -10.0 # normal_cdf(-10) is very close to ... | [
"0.73627687",
"0.7348246",
"0.7322289",
"0.73182213",
"0.73152447",
"0.73042977",
"0.6306959",
"0.62360305",
"0.6162065",
"0.61166424",
"0.61166424",
"0.61166424",
"0.61166424",
"0.61166424",
"0.5998157",
"0.58902067",
"0.5800062",
"0.57430977",
"0.56172043",
"0.5604081",
"0.... | 0.7173955 | 6 |
Gets the value of a given key from the given .env If the .env path given doesn't exist, fails | def get_key(dotenv_path, key_to_get, verbose=False):
key_to_get = str(key_to_get)
if not os.path.exists(dotenv_path):
if verbose:
warnings.warn(f"Can't read {dotenv_path}, it doesn't exist.")
return None
dotenv_as_dict = dotenv_values(dotenv_path)
if key_to_get in dotenv_as_d... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_value(key:str):\n value = environ.get(key)\n if value == None or len(str(value)) == 0:\n raise ValueError('Missing env: '+key)\n return value",
"def get_env_or_exception(key):\n \n value = os.getenv(key)\n if value is None:\n raise ImproperlyConfigured(f'{key} env variable is not se... | [
"0.8068645",
"0.77403206",
"0.75215095",
"0.7504879",
"0.73318964",
"0.72472286",
"0.72316545",
"0.70931005",
"0.7091405",
"0.70628726",
"0.70577234",
"0.70411646",
"0.70023954",
"0.69945455",
"0.6869868",
"0.68147236",
"0.6724244",
"0.6717994",
"0.6705121",
"0.6697287",
"0.6... | 0.79316026 | 1 |
Adds or Updates a key/value to the given .env If the .env path given doesn't exist, fails instead of risking creating an orphan .env somewhere in the filesystem | def set_key(dotenv_path, key_to_set, value_to_set, quote_mode='always', verbose=False):
key_to_set = str(key_to_set)
value_to_set = str(value_to_set).strip("'").strip('"')
if not os.path.exists(dotenv_path):
if verbose:
warnings.warn(f"Can't write to {dotenv_path}, it doesn't exist.")
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_env_var(key: str, value: Optional[str]) -> None:\n if value is None:\n os.environ.pop(key, None)\n else:\n os.environ[key] = value",
"def add_to_env(self, path, value):\n name = [MakeEnvironArgs.CONFIG]\n for element in path:\n name.append(MakeEnvironArgs.DOT)... | [
"0.69486195",
"0.6700295",
"0.6674098",
"0.6609809",
"0.6512184",
"0.645946",
"0.6454694",
"0.6445529",
"0.64125276",
"0.62982476",
"0.6283096",
"0.6248327",
"0.6210113",
"0.6206742",
"0.6146337",
"0.6100504",
"0.6089014",
"0.60793036",
"0.6075443",
"0.59682024",
"0.59312075"... | 0.6522593 | 4 |
get appropriate value for a variable name. first search in environ, if not found, then look into the dotenv variables | def _replacement(name):
ret = os.getenv(name, values.get(name, ""))
return ret | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def env_get_var_value(var_name, allow_missing=False):\n if allow_missing:\n if var_name not in os.environ.keys():\n return None\n assert var_name in os.environ.keys(), \"Please supply %s in environment\" % var_name\n return os.environ[var_name]",
"def get_var(var_name: str):\n retur... | [
"0.7775684",
"0.75476724",
"0.74586326",
"0.73979783",
"0.7216004",
"0.7208108",
"0.7202661",
"0.7179572",
"0.71767974",
"0.71557033",
"0.71374506",
"0.71374506",
"0.7115239",
"0.71134275",
"0.71021557",
"0.71001744",
"0.70845777",
"0.7063937",
"0.7061789",
"0.70264226",
"0.7... | 0.0 | -1 |
Returns the quote format depending on the quote_mode. This determines if the key value will be quoted when written to the env file. | def _get_format(value, quote_mode='always'):
formats = {'always': '{key}="{value}"\n', 'auto': '{key}={value}\n'}
if quote_mode not in formats.keys():
return KeyError(f'quote_mode {quote_mode} is invalid')
_mode = quote_mode
if quote_mode == 'auto' and ' ' in value:
_mode = 'always'
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_quotes(self):\n # However ignore the 'true' autodetection setting.\n jscs_quotes = self.jscs_options.get('validateQuoteMarks')\n if isinstance(jscs_quotes, dict):\n jscs_quotes = jscs_quotes.get('mark')\n if jscs_quotes and jscs_quotes is not True:\n return... | [
"0.6321128",
"0.59838575",
"0.57248956",
"0.5650812",
"0.5599616",
"0.5582387",
"0.55575794",
"0.55405056",
"0.54948664",
"0.5439705",
"0.5414198",
"0.5396",
"0.5394686",
"0.5381312",
"0.53518337",
"0.5274584",
"0.5267027",
"0.5267027",
"0.5242387",
"0.5236885",
"0.51373994",... | 0.72505355 | 0 |
Get absolute path to resource, works for dev and for PyInstaller | def resource_path(relative_path):
base_path = getattr(sys, '_MEIPASS', os.path.dirname(os.path.abspath(__file__)))
return os.path.join(base_path, relative_path) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_resource_path():\n return os.path.join(os.path.dirname(__file__), \"resources\") + os.path.sep",
"def resourcePath(relative):\r\n try:\r\n # PyInstaller creates a temp folder and stores path in _MEIPASS\r\n base_path = sys._MEIPASS\r\n except Exception:\r\n base_path = os.pa... | [
"0.83695436",
"0.8280479",
"0.82485795",
"0.8139178",
"0.8114118",
"0.80985415",
"0.80940944",
"0.80797124",
"0.80677074",
"0.80673695",
"0.8062465",
"0.8062465",
"0.8062465",
"0.8062465",
"0.8062465",
"0.8062465",
"0.8062465",
"0.80569947",
"0.80545217",
"0.80448323",
"0.804... | 0.78359824 | 46 |
The current actual cache size. This will never exceed the cache limit. | def cache_size(self):
return len(self._cache) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cache_size(self):\n return self.cachesize",
"def get_size(self):\n return len(self.cache)",
"def cache_size(self):\n return 0",
"def size(self):\n\t\treturn len(self.cache)",
"def size(self):\n return len(self.cache)",
"def size(self):\n return len(self._cache)",
... | [
"0.9155071",
"0.8727969",
"0.8717595",
"0.8202836",
"0.81059057",
"0.80476886",
"0.79619515",
"0.788144",
"0.78358954",
"0.7622818",
"0.7481525",
"0.7452956",
"0.74094784",
"0.73729867",
"0.7335562",
"0.7320767",
"0.73149246",
"0.73127484",
"0.73113734",
"0.73113734",
"0.7299... | 0.85850865 | 3 |
Check if user is moderator of topic's forum. | def pybb_topic_moderated_by(topic, user): # pragma: no cover
warnings.warn("pybb_topic_moderated_by filter is deprecated and will be removed in later releases. "
"Use pybb_may_moderate_topic(user, topic) filter instead",
DeprecationWarning)
return perms.may_moderate_topic(us... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_moderator(self):\n return self.user_type == 'M'",
"def can_be_moderated_by(user):\n return user.is_active and user.is_staff and (\n user.has_perm('blog.change_membership') or\n user.has_perm('blog.change_blog'))",
"def has_moderate_permission(self, request):\n ... | [
"0.7360903",
"0.7311989",
"0.67013294",
"0.66893333",
"0.6678436",
"0.6626432",
"0.66086555",
"0.65984946",
"0.65898514",
"0.65772164",
"0.6560292",
"0.6560292",
"0.65061677",
"0.644432",
"0.64154136",
"0.6414608",
"0.6409314",
"0.63567257",
"0.63491493",
"0.6347192",
"0.6327... | 0.61275697 | 38 |
Check if the post is writed by the user. | def pybb_posted_by(post, user):
return post.user == user | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_func(self):\r\n post = self.get_object()\r\n if self.request.user == post.author:\r\n return True\r\n return False",
"def test_func(self):\r\n post = self.get_object()\r\n if self.request.user == post.author:\r\n return True\r\n return Fals... | [
"0.7419491",
"0.7419491",
"0.7419491",
"0.7415364",
"0.72742873",
"0.72742873",
"0.7225979",
"0.7106989",
"0.7091387",
"0.6954094",
"0.68706393",
"0.6801878",
"0.6796568",
"0.6708634",
"0.66842324",
"0.6597913",
"0.6590575",
"0.6562148",
"0.6528499",
"0.647906",
"0.64599687",... | 0.68487465 | 11 |
Check if forum has unread messages. | def pybb_forum_unread(forums, user):
forum_list = list(forums)
if user.is_authenticated:
for forum in forum_list:
forum.unread = forum.topic_count > 0
forum_marks = ForumReadTracker.objects.filter(
user=user,
forum__in=forum_list
).select_related('foru... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_unread(self):\n return bool(self.read_at is None)",
"def has_messages(self) -> bool:\n return self._has_messages",
"def has_message_available(self):\n return not self.feedback_log.empty()",
"def find_unread(mailbox):\n # Not checking here would make the case where there are mes... | [
"0.713136",
"0.659425",
"0.65302306",
"0.6529479",
"0.6508989",
"0.650743",
"0.6493157",
"0.62064165",
"0.6199817",
"0.6164346",
"0.61179763",
"0.60906595",
"0.59650207",
"0.5944937",
"0.593439",
"0.5931103",
"0.5893609",
"0.5892659",
"0.58801484",
"0.5848921",
"0.58308434",
... | 0.679188 | 1 |
Public method to return the lexer language. lexer language (string) | def language(self):
return "QSS" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def language(self):\n # type: () -> string_types\n return self._language",
"def language(self):\n # type: () -> string_types\n return self._language",
"def get_language(benchmark):\n config = benchmark_config.get_config(benchmark)\n return config.get('language', 'c++')",
"de... | [
"0.7208835",
"0.7208835",
"0.7156863",
"0.71012175",
"0.7032455",
"0.70024896",
"0.6982773",
"0.6952151",
"0.68650776",
"0.6864989",
"0.6842548",
"0.68045396",
"0.6776188",
"0.6771242",
"0.6766674",
"0.6766029",
"0.6766029",
"0.67408603",
"0.67248905",
"0.6722382",
"0.6687545... | 0.5778868 | 83 |
Returns the angular distance to the given star. | def get_distance(self, star):
if self == star:
return 0
a_car = self.get_cartesian_coords()
b_car = star.get_cartesian_coords()
dab = math.degrees(math.acos(a_car[0] * b_car[0] +
a_car[1] * b_car[1] +
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_distance(self, star):\n if self.centroid == star.centroid:\n print(\"distance for same star\")\n return 0\n\n unitary_a = self.get_unitary_vector()\n unitary_b = star.get_unitary_vector()\n dab = math.degrees(math.acos(unitary_a[0] * unitary_b[0] +\n ... | [
"0.7570158",
"0.74710685",
"0.63009876",
"0.62413085",
"0.61806667",
"0.6104424",
"0.6104424",
"0.6104424",
"0.6104424",
"0.59014094",
"0.58771276",
"0.5841265",
"0.58124405",
"0.5807581",
"0.57929885",
"0.57694036",
"0.5694616",
"0.5573738",
"0.5554221",
"0.55339587",
"0.548... | 0.747844 | 1 |
Sets a well known name. | def set_name(self, name):
self.name = name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_name(self, newname=\"\"):\n self.name = newname",
"def set_name(self, name):\n self.name = name # overwrite the existing name with the input name",
"def set_name(self, name):\n self.name = name # overwrite the existing name with the input name",
"def set_name(self, name):\n\t\t... | [
"0.82287246",
"0.82091844",
"0.82091844",
"0.81850624",
"0.8103783",
"0.80813247",
"0.8074633",
"0.80129755",
"0.8001172",
"0.7957393",
"0.79295677",
"0.7908989",
"0.78935605",
"0.7891852",
"0.7891852",
"0.78900516",
"0.78900516",
"0.7889269",
"0.7874363",
"0.7874363",
"0.787... | 0.80462176 | 10 |
load requirements from a pip requirements file. (replacing from pip.req import parse_requirements) | def parse_requirements(filename):
lineiter = (line.strip() for line in open(filename))
return [line for line in lineiter if line and not line.startswith("#")] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_requirements_from_pipfile():\n lineiter = (line.strip() for line in open('Pipfile'))\n requirements_pipfile_style = [line for line in lineiter]\n start_index = requirements_pipfile_style.index('[packages]') + 1\n end_index = requirements_pipfile_style.index('[requires]') - 1\n requirements... | [
"0.76271045",
"0.7227356",
"0.72101384",
"0.7009797",
"0.70095426",
"0.6991186",
"0.69519174",
"0.68540776",
"0.68540776",
"0.6818392",
"0.6804214",
"0.67739236",
"0.676988",
"0.67168874",
"0.66903436",
"0.6668028",
"0.6600803",
"0.6577202",
"0.6576607",
"0.65587044",
"0.6555... | 0.5869388 | 76 |
The name of the solver. | def name(self):
return NotImplemented | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __str__(self):\n return self.name + \"-\" + SatSolver.getName(self.satSolver)",
"def getName(satSolver):\n if satSolver == SatSolver.LINGELING:\n return \"lingeling\"\n elif satSolver == SatSolver.MINISAT:\n return \"minisat\"\n elif satSolver == SatSolver.PI... | [
"0.7075065",
"0.6923393",
"0.66534317",
"0.65357727",
"0.64830935",
"0.64577514",
"0.64566576",
"0.64563495",
"0.6404059",
"0.6391155",
"0.6370548",
"0.6363768",
"0.6361679",
"0.6361679",
"0.6361679",
"0.6361679",
"0.6361679",
"0.6361679",
"0.6361679",
"0.6361679",
"0.6361679... | 0.0 | -1 |
Constructs the training op needed to train the autoencoder model. | def unsupervised_optimizer(loss, lr=4e-4):
train_op = tf.train.AdamOptimizer(learning_rate=lr).minimize(loss)
return train_op | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_train_op(self, loss, params):\n raise NotImplementedError()",
"def _build_train_op(self):\n replay_action_one_hot = tf.one_hot(\n self._replay.actions, self.num_actions, 1., 0., name='action_one_hot')\n replay_chosen_q = tf.reduce_sum(\n self._replay_net_outputs.q_values * re... | [
"0.74289596",
"0.7136129",
"0.7082573",
"0.7067862",
"0.6927649",
"0.6927649",
"0.6896374",
"0.6825041",
"0.6820336",
"0.66924655",
"0.6646014",
"0.6457538",
"0.64328086",
"0.64295614",
"0.6416945",
"0.6407494",
"0.63783485",
"0.63524264",
"0.63366103",
"0.63150287",
"0.62827... | 0.0 | -1 |
Constructor method that initializes an object of type Model that can be used for simulation purposes or within an estimation algorithm. | def __init__(self, fmu_file = None, result_handler = None, solver = None, atol = 1e-6, rtol = 1e-4, verbose = None, offset = None):
# Reference to the FMU, that will be loaded using pyfmi
self.fmu = None
self.fmu_file = fmu_file
# List of parameters
self.parameters = []
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, model: Model1D):\n self._model = model",
"def __init__(self, model):\n self._model = model",
"def __init__(self, model: Optional[Model] = None) -> None:\n self.model = model",
"def __init__(self, model: MT):\n self.model: Final[MT] = model",
"def __init__(self... | [
"0.8028428",
"0.7744366",
"0.7727983",
"0.7678281",
"0.7660476",
"0.7660476",
"0.7619852",
"0.7578641",
"0.7578641",
"0.7578641",
"0.7578641",
"0.7578641",
"0.75595134",
"0.75595134",
"0.75595134",
"0.75595134",
"0.7525139",
"0.7525139",
"0.74929553",
"0.7338385",
"0.73182285... | 0.0 | -1 |
This method returns the name of the FMU associated to the model. | def get_fmu_name(self):
return self.name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def model_name(self) -> str:\n return self.profile_device.model_name",
"def name(self) -> str:\n return self._name(self.model).decode(\"utf-8\")",
"def get_name(self):\n modelTree = self.model.find(xmlns + 'Model')\n return modelTree.attrib['name']",
"def get_fmu(self):\n r... | [
"0.6965377",
"0.67993325",
"0.6783643",
"0.67573243",
"0.6698869",
"0.66983575",
"0.66676384",
"0.6638809",
"0.66288906",
"0.6583042",
"0.6550568",
"0.6541573",
"0.6526077",
"0.64550626",
"0.64208704",
"0.63848835",
"0.63797104",
"0.6377766",
"0.6375838",
"0.63180774",
"0.631... | 0.8160747 | 0 |
Return the list of input variables associated to the FMU that have been selected. | def get_inputs(self):
return self.inputs | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_input_var_names(self):\n return self._input_var_names",
"def get_input_names(self):\n inputNames = []\n for inVar in self.inputs:\n # inVar is of type InOutVar and the object that it contains is a PyFMI variable\n inputNames.append(inVar.get_object().name)\n ... | [
"0.7140298",
"0.70327085",
"0.6827329",
"0.6705671",
"0.6564756",
"0.63881093",
"0.6377287",
"0.63288367",
"0.63288367",
"0.63207257",
"0.6286647",
"0.6249854",
"0.62387407",
"0.62230396",
"0.62193453",
"0.6200909",
"0.61881137",
"0.6160711",
"0.6155932",
"0.615429",
"0.61532... | 0.0 | -1 |
This method returns a list containing the names of the input variables associated to this model. | def get_input_names(self):
inputNames = []
for inVar in self.inputs:
# inVar is of type InOutVar and the object that it contains is a PyFMI variable
inputNames.append(inVar.get_object().name)
return inputNames | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_input_var_names(self):\n return self._input_var_names",
"def variables(self):\n return [i.name for i in self.inputs + self.outputs]",
"def get_input_names(self):\n return self._input_names",
"def inputs(self) -> List[str]:\n return self._model.inputs",
"def input_names(self)... | [
"0.8817218",
"0.82165456",
"0.78843963",
"0.7648153",
"0.76415455",
"0.7593992",
"0.753027",
"0.75198704",
"0.7511978",
"0.7335007",
"0.7330876",
"0.72293276",
"0.72293276",
"0.72138613",
"0.7205519",
"0.71472096",
"0.71311224",
"0.7127566",
"0.71160954",
"0.7097137",
"0.7096... | 0.8599254 | 1 |
This method return a vector that contains the values of the observed state variables of the model. The observed outputs are listed in the object variable ``self.outputs`` and are identified by the flag ``measured = True``. | def get_measured_outputs_values(self):
obsOut = numpy.zeros(self.get_num_measured_outputs())
i = 0
for o in self.outputs:
if o.is_measured_output():
obsOut[i] = o.read_value_in_fmu(self.fmu)
i += 1
return obsOut | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_state_observed_values(self):\n obsState = numpy.zeros(self.get_num_variables())\n i = 0\n for v in self.variables:\n obsState[i] = v.read_value_in_fmu(self.fmu)\n i += 1\n return obsState",
"def compute_output_from_current_state(self):\n\n assert s... | [
"0.733973",
"0.6696109",
"0.6516212",
"0.63888776",
"0.63822395",
"0.63464373",
"0.6343479",
"0.62684894",
"0.6249437",
"0.61632043",
"0.6150953",
"0.6133713",
"0.6121414",
"0.61208993",
"0.61162865",
"0.6065764",
"0.60472757",
"0.60450715",
"0.60206664",
"0.600493",
"0.60036... | 0.7302166 | 1 |
This method returns the total number of output variables of the FMU associated to this model. | def get_num_outputs(self):
return len(self.outputs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def GetNumberOfVariables(self):\n\n # nvar = 0\n # for i in self.variables_order:\n # # DO NOT COUNT VARIABLES THAT GET CONDENSED OUT\n # if i!=0:\n # if mesh.element_type == \"tri\":\n # nvar += (i+1)*(i+2) // 2\n # elif mesh.ele... | [
"0.7170796",
"0.7088196",
"0.7071247",
"0.70615214",
"0.7038386",
"0.7030121",
"0.6971648",
"0.69083774",
"0.69080603",
"0.6905927",
"0.6905927",
"0.68992007",
"0.6895264",
"0.6892653",
"0.6881445",
"0.6874362",
"0.68551844",
"0.6797669",
"0.6771106",
"0.67615867",
"0.6747868... | 0.6903007 | 11 |
This method returns the total number of measured output variables of the FMU associated to this model. | def get_num_measured_outputs(self):
i = 0
for o in self.outputs:
if o.is_measured_output():
i += 1
return i | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def GetNumberOfVariables(self):\n\n # nvar = 0\n # for i in self.variables_order:\n # # DO NOT COUNT VARIABLES THAT GET CONDENSED OUT\n # if i!=0:\n # if mesh.element_type == \"tri\":\n # nvar += (i+1)*(i+2) // 2\n # elif mesh.ele... | [
"0.67659473",
"0.6715641",
"0.65664643",
"0.6553919",
"0.6552804",
"0.65488786",
"0.6519742",
"0.6518154",
"0.6518154",
"0.6518154",
"0.64912057",
"0.6480123",
"0.64657",
"0.64256054",
"0.63979375",
"0.6395449",
"0.6381647",
"0.6380125",
"0.6380125",
"0.6379901",
"0.63787377"... | 0.71431494 | 0 |
This method returns the number of state variables of the FMU model that will be estimated or identified. | def get_num_variables(self):
return len(self.variables) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def GetNumberOfVariables(self):\n\n # nvar = 0\n # for i in self.variables_order:\n # # DO NOT COUNT VARIABLES THAT GET CONDENSED OUT\n # if i!=0:\n # if mesh.element_type == \"tri\":\n # nvar += (i+1)*(i+2) // 2\n # elif mesh.ele... | [
"0.723949",
"0.72366834",
"0.7120854",
"0.70445025",
"0.69900167",
"0.6970696",
"0.6949395",
"0.68859226",
"0.68605465",
"0.685635",
"0.6837514",
"0.6791073",
"0.67834073",
"0.6760186",
"0.6745004",
"0.6705674",
"0.66892487",
"0.6659677",
"0.6653375",
"0.6645705",
"0.6621294"... | 0.7249912 | 0 |
This method returns the total number of states variables of the FMU associated to this model. | def get_num_states(self):
return self.N_STATES | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def countVars(self):\n return len(self.initializedVars[\"GF\"]) + len(self.initializedVars[\"LF\"]) + len(self.initializedVars[\"TF\"])",
"def GetNumberOfVariables(self):\n\n # nvar = 0\n # for i in self.variables_order:\n # # DO NOT COUNT VARIABLES THAT GET CONDENSED OUT\n ... | [
"0.72870374",
"0.721491",
"0.7136512",
"0.71300715",
"0.70986295",
"0.70551556",
"0.7034584",
"0.70330304",
"0.6876152",
"0.6856854",
"0.68298686",
"0.6808821",
"0.6804557",
"0.6773006",
"0.67691636",
"0.67256844",
"0.67054415",
"0.66747946",
"0.66642404",
"0.65330017",
"0.65... | 0.6989126 | 8 |
Return the list of output variables associated to the FMU. | def get_outputs(self):
return self.outputs | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def variables(self):\n return [i.name for i in self.inputs + self.outputs]",
"def get_output_names(self):\n outputNames = []\n for outVar in self.outputs:\n # outVar is of type InOutVar and the object that it contains is a PyFMI variable\n outputNames.append(outVar.get_... | [
"0.7414261",
"0.73020613",
"0.72324204",
"0.70996207",
"0.706696",
"0.6951988",
"0.67120993",
"0.6660931",
"0.6641178",
"0.6599569",
"0.6560452",
"0.64949995",
"0.64615136",
"0.6405778",
"0.6391889",
"0.6374551",
"0.6367353",
"0.6343694",
"0.63425493",
"0.63332427",
"0.632965... | 0.6022471 | 69 |
This method returns a list of names of the outputs of the model. | def get_output_names(self):
outputNames = []
for outVar in self.outputs:
# outVar is of type InOutVar and the object that it contains is a PyFMI variable
outputNames.append(outVar.get_object().name)
return outputNames | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def output(self) -> List[str]:\n return self._model.output",
"def getOutputsNames(self):\n self.layersNames = self.net.getLayerNames()\n # Get the names of the output layers, i.e. the layers with unconnected outputs\n return [self.layersNames[i[0] - 1] for i in self.net.getUnconnected... | [
"0.8018012",
"0.78388023",
"0.7755714",
"0.76345754",
"0.75985235",
"0.75267464",
"0.7478465",
"0.74776655",
"0.7360807",
"0.7322865",
"0.7322793",
"0.7322793",
"0.7297575",
"0.72829586",
"0.727196",
"0.7259471",
"0.72565675",
"0.7251729",
"0.72415364",
"0.7206489",
"0.708508... | 0.8010352 | 1 |
This method return an array that contains the maximum values that the estimated parameters can assume. | def get_parameters_max(self):
maxValues = numpy.zeros(self.get_num_parameters())
i = 0
for p in self.parameters:
maxValues[i] = p.get_max_value()
i += 1
return maxValues | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_state_observed_max(self):\n maxValues = numpy.zeros(self.get_num_variables())\n i = 0\n for v in self.variables:\n maxValues[i] = v.get_max_value()\n i += 1\n return maxValues",
"def best_params(self):\n return self.X[np.argmax(self.y.numpy())]",
... | [
"0.75945216",
"0.7181459",
"0.69449997",
"0.6806576",
"0.6770933",
"0.6770933",
"0.67263216",
"0.6655445",
"0.66346705",
"0.6584481",
"0.65707064",
"0.6570439",
"0.6543426",
"0.6530506",
"0.6502705",
"0.64874744",
"0.64774853",
"0.6468077",
"0.6466289",
"0.6423649",
"0.641507... | 0.8431865 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.