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 |
|---|---|---|---|---|---|---|
This function takes an image as its first argument, a message as its second argument, and returns an encoded image as its result. The input image is a rectangular twodimensional list of pixels, in zerobased rowmajor order. Each pixel is a 3element tuple of integers in the range [0,255]. Input message is a string of ASC... | def encode(image,message):
bitstream = bits.message_to_bits(message)
new_image = []
i = 0
# Set counter i to keep track of index location in bitstream
# The ith bit is encoded
for row in image:
# First 'for' loop iterates over each row-list
# Empty list intialised for each new ro... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def encode(self, message: str) -> None:\n image = self._original_image.copy()\n width, height = image.size\n pixels = image.load()\n\n binary_string = self._str_to_binary_string(message + self._end_message)\n tribit_list = self._split(binary_string, 3)\n\n for x_pixel in r... | [
"0.8035475",
"0.75983036",
"0.73957735",
"0.70629686",
"0.6740143",
"0.6663131",
"0.66422814",
"0.6604274",
"0.6529792",
"0.6521943",
"0.6508798",
"0.620289",
"0.6130727",
"0.60682267",
"0.59764594",
"0.591512",
"0.58244956",
"0.5808739",
"0.57512033",
"0.5699584",
"0.5699379... | 0.79802555 | 1 |
Add an iterator to the scheduler. | def add(self, ev_iter):
if not self.tm:
# Lazily initialize the clock if necessary.
self.tm = self._now()
return self._enqueue(ev_iter, Time(0)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_iterator(self,\r\n entrylist,\r\n keyset=None):\r\n\r\n if keyset is None:\r\n keyset = set()\r\n\r\n self.default_dict['iterators'].append(entrylist)\r\n self.iter_list_iterator = cycle(list\r\n ... | [
"0.5857544",
"0.5717766",
"0.56646436",
"0.5641688",
"0.5589841",
"0.5448254",
"0.54332507",
"0.54236865",
"0.53901005",
"0.5381826",
"0.5361284",
"0.532146",
"0.52987945",
"0.52723515",
"0.518757",
"0.51739174",
"0.51473904",
"0.51468354",
"0.512206",
"0.5084052",
"0.5019393... | 0.64778364 | 0 |
Yield from a generator, then yields an extra Beat. | def _fill_time(beats, shard, *args, **kwargs):
total = 0
for delay in shard(*args, **kwargs):
total += delay.count
yield delay
yield Beat(beats - total) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __iter__(self):\n yield from self.gen",
"def test_nested_yield():\n yield (yield (yield 1))",
"def __call__(self):\n yield from self",
"def simple_generator():\n yield 'horse'\n # just going to do it...\n yield 'cow'\n yield 'mouse'",
"def fluor_yield(self):\n return... | [
"0.623003",
"0.61388046",
"0.6097662",
"0.60695386",
"0.59670126",
"0.5955384",
"0.59386474",
"0.5937994",
"0.5934757",
"0.5875621",
"0.5812488",
"0.5800179",
"0.57920396",
"0.57903063",
"0.57847905",
"0.57584846",
"0.573116",
"0.56926155",
"0.56609154",
"0.5658048",
"0.56545... | 0.0 | -1 |
Convert points to vectors with respect to origin. | def points2vectos(pts, origin=None):
pts = np.array(pts)
return pts - (origin or np.zeros_like(pts)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def vectos2points(vecs, origin=None):\n vecs = np.array(vecs)\n return vecs + (origin or np.zeros_like(vecs))",
"def cvt_points_to_vector(points):\n\n return numpy.hstack(points)",
"def _convert_coords_to_coordinates(self, vect) -> np.ndarray:\n # create empty vector of necessary shape\n ... | [
"0.7279037",
"0.7181686",
"0.6480365",
"0.6461387",
"0.6377752",
"0.63240445",
"0.62984496",
"0.625294",
"0.6246376",
"0.6177244",
"0.6140478",
"0.6085727",
"0.6072549",
"0.6068359",
"0.6063862",
"0.59986955",
"0.59736574",
"0.5968835",
"0.5964173",
"0.59240794",
"0.5916746",... | 0.80408895 | 0 |
Convert points to vectors with respect to origin. | def vectos2points(vecs, origin=None):
vecs = np.array(vecs)
return vecs + (origin or np.zeros_like(vecs)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def points2vectos(pts, origin=None):\n pts = np.array(pts)\n return pts - (origin or np.zeros_like(pts))",
"def cvt_points_to_vector(points):\n\n return numpy.hstack(points)",
"def _convert_coords_to_coordinates(self, vect) -> np.ndarray:\n # create empty vector of necessary shape\n # on... | [
"0.8040917",
"0.71816397",
"0.6480457",
"0.6461564",
"0.6377839",
"0.6323915",
"0.62984294",
"0.6253044",
"0.6246448",
"0.61773616",
"0.6140706",
"0.60856843",
"0.6072838",
"0.606839",
"0.6064175",
"0.599893",
"0.5973575",
"0.596885",
"0.5964229",
"0.59240353",
"0.5917052",
... | 0.72790813 | 1 |
Convert a float returned by time.time() to a Timestamp. | def to_Timestamp(time):
# type: (Union[int, float]) -> timestamp_pb2.Timestamp
seconds = int(time)
nanos = int((time - seconds) * 10**9)
return timestamp_pb2.Timestamp(seconds=seconds, nanos=nanos) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def from_Timestamp(timestamp):\n # type: (timestamp_pb2.Timestamp) -> float\n return timestamp.seconds + float(timestamp.nanos) / 10**9",
"def to_timestamp(date_time: datetime, unit: TimeUnit = TimeUnit.SECONDS) -> float:\n return date_time.replace(tzinfo=timezone.utc).timestamp() * (1000 ** int(unit))"... | [
"0.7091272",
"0.6970927",
"0.67656",
"0.6736811",
"0.6570321",
"0.64772624",
"0.6433413",
"0.63894194",
"0.6310766",
"0.62458706",
"0.6195516",
"0.61046326",
"0.6091296",
"0.6068229",
"0.60519564",
"0.60447913",
"0.60322297",
"0.5941902",
"0.59417284",
"0.5940961",
"0.5918196... | 0.6937482 | 2 |
Convert a Timestamp to a float expressed as seconds since the epoch. | def from_Timestamp(timestamp):
# type: (timestamp_pb2.Timestamp) -> float
return timestamp.seconds + float(timestamp.nanos) / 10**9 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ts_to_epoch_seconds(t) -> float:\n return t.astype(int) / 1e9",
"def datetime_to_float(t, epoch=None):\n if epoch is None:\n epoch = np.datetime64(0, \"s\")\n return (t - epoch) / np.timedelta64(1, \"s\")",
"def _convert_sfx_timestamp(ts: int) -> float:\n return float(ts) / 1000",
"def... | [
"0.76476985",
"0.70599985",
"0.6822996",
"0.6810652",
"0.6677402",
"0.6539019",
"0.65201676",
"0.64337784",
"0.63623315",
"0.63037324",
"0.62800807",
"0.6275198",
"0.62700856",
"0.6257447",
"0.62532806",
"0.6175159",
"0.61186975",
"0.61176866",
"0.6032098",
"0.60160214",
"0.6... | 0.7417649 | 1 |
Takes a text, normalizes, tokenizes, removes stop words, lemmatizes, and returns a list of tokens | def tokenize(text):
tokens = word_tokenize(text)
lemmatizer = WordNetLemmatizer()
clean_tokens = []
for token in tokens:
clean_token = lemmatizer.lemmatize(token).lower().strip()
clean_tokens.append(clean_token)
return clean_tokens | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tokenize(text):\n \n tokens = word_tokenize(text)\n \n STOPWORDS = list(set(stopwords.words('english')))\n # remove short words\n tokens = [token for token in tokens if len(token) > 2]\n # remove stopwords\n tokens = [token for token in tokens if token not in STOPWORDS]\n \n lemma... | [
"0.8880861",
"0.88718086",
"0.8863741",
"0.8859053",
"0.8848089",
"0.8827691",
"0.8771861",
"0.8754438",
"0.87020147",
"0.86540705",
"0.86540705",
"0.8562643",
"0.8507187",
"0.8506917",
"0.84713215",
"0.84636164",
"0.8372892",
"0.8372756",
"0.82993954",
"0.82152784",
"0.82059... | 0.8868206 | 2 |
Find schema classes that directly inherit from the given class | def child_classes(self):
response = check_defined(self, inspect.stack()[0][3])
if not response:
return response
children = self.se.full_class_only_graph.successors(self.uri)
result = restructure_output(self,
children,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_all_classes(self):\n classes = list(self.extended_class_only_graph.nodes())\n classes = [SchemaClass(_cls, self) for _cls in classes]\n return classes",
"def FindChilds(self,cls):\n childs = []\n for i in self.classes:\n if self.InheritsFrom(cls,i):\n ... | [
"0.67787",
"0.66347706",
"0.65711945",
"0.6385068",
"0.63349605",
"0.6257887",
"0.6248021",
"0.6212487",
"0.6212487",
"0.62122655",
"0.6191026",
"0.6182615",
"0.6179116",
"0.6169857",
"0.6151207",
"0.6149352",
"0.61170167",
"0.6081054",
"0.60337293",
"0.603095",
"0.6026763",
... | 0.5389973 | 73 |
return the unicode representation of obj | def safe_unicode(obj, *args):
try:
return unicode(obj, *args)
except UnicodeDecodeError:
# obj is byte string
ascii_text = str(obj).encode('string_escape')
return unicode(ascii_text) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def u(obj):\n return obj if isinstance(obj, unicode) else unicode(obj) # noqa: F821 pylint: disable=undefined-variable",
"def u(obj):\n return obj if isinstance(obj, str) else str(obj)",
"def format_result(self,obj):\n return unicode(obj)",
"def as_unicode(obj):\n if sys.version_... | [
"0.8202679",
"0.7991012",
"0.79736567",
"0.791281",
"0.78867394",
"0.780464",
"0.76903355",
"0.76376015",
"0.7569767",
"0.7512156",
"0.7512156",
"0.7431973",
"0.73928916",
"0.73723996",
"0.7335776",
"0.73016804",
"0.72937953",
"0.7242186",
"0.7237758",
"0.72199875",
"0.715162... | 0.743078 | 17 |
Opens a web page. | def open(self, address, method='get', headers=None, auth=None, body=None,
default_popup_response=None):
headers = headers or {}
body = body or QByteArray()
try:
method = getattr(QNetworkAccessManager,
"%sOperation" % method.capitalize())
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def open(url):\r\n webbrowser.open(url)",
"def openurl(url):\n\n # Open the URL\n webbrowser.open(url)",
"def open_in_browser(self):\n webbrowser.open(self.url)",
"def open_browser(url):\n import webbrowser\n webbrowser.open_new(url)",
"def openSite(url):\n\timport webbrowser\n\twebbr... | [
"0.84771913",
"0.81717765",
"0.80043155",
"0.7960315",
"0.7793779",
"0.77153826",
"0.77102727",
"0.7638561",
"0.76185226",
"0.74696404",
"0.74527323",
"0.73409784",
"0.7335251",
"0.73170376",
"0.72998154",
"0.72779375",
"0.72426766",
"0.72322506",
"0.72171026",
"0.71737957",
... | 0.605095 | 84 |
Retrieve a list of vehicles | async def get(self):
raise NotImplementedError() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_retrieve_vehicle_list(self):\n Vehicle.objects.create(\n user=self.user,\n type='Ambulance',\n license_plate='AA-123-AA'\n )\n Vehicle.objects.create(\n user=self.user,\n type='VSL',\n license_plate='BB-123-BB'\n ... | [
"0.7543337",
"0.73812944",
"0.72395086",
"0.72003675",
"0.68838125",
"0.67902404",
"0.67018306",
"0.65143114",
"0.6300367",
"0.62233746",
"0.6179688",
"0.61151135",
"0.61150056",
"0.6110019",
"0.60510814",
"0.6020869",
"0.59907234",
"0.59765357",
"0.5972661",
"0.597257",
"0.5... | 0.0 | -1 |
Test checks is user is not able to register the same email twice and asserts if email validation message is received. | def test_already_registered_email_validation(self):
main_page = pages.mainpage.MainPage(self.driver)
main_page.click_sign_in_button()
sign_in_page = pages.signinpage.SignInPage(self.driver)
sign_in_page.enter_create_account_email_addres('test@test.test')
sign_in_page.cl... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_registeration_invalid_email(self):\n response = self.signup_a_user(self.user_invalid_email)\n self.assertEqual(response.status_code, status.HTTP_400_BAD_REQUEST)\n self.assertEqual(response.data[\"errors\"][\"email\"],\n [\"Enter a valid email address.\"]\n ... | [
"0.80271155",
"0.8017307",
"0.8006958",
"0.7909201",
"0.78807163",
"0.78034794",
"0.771716",
"0.7697668",
"0.76950425",
"0.766892",
"0.7658171",
"0.7621606",
"0.7616331",
"0.76113194",
"0.75984687",
"0.7574882",
"0.75368726",
"0.7535076",
"0.7523863",
"0.75028586",
"0.7467668... | 0.84831756 | 0 |
Test the generated values are stopping at the bottom of the range | def test_generator_downward(narrow_power_range):
with patch('random.randint', side_effect=lambda a,b: -1):
range_min, range_max = narrow_power_range
for msg in it.islice(generate_msgs(range_min, range_max), 0, 5):
pass
power = Message.parse(msg).power
assert power == rang... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_in_range_0_1():\n g = RG.larger_random()\n assert 0 <= next(g) <= 1",
"def test_outside_bottom_range(self):\n input_ = [\n self.indicator_record(date=datetime.date(2000, 2, 1), value=0.13),\n self.indicator_record(date=datetime.date(2000, 3, 1), value=0.22),\n ]... | [
"0.6774707",
"0.672971",
"0.65376085",
"0.64734113",
"0.64634174",
"0.6373937",
"0.63686466",
"0.6325752",
"0.62904257",
"0.619089",
"0.61635673",
"0.61374617",
"0.6096412",
"0.6086861",
"0.60331875",
"0.59954566",
"0.59430116",
"0.5938593",
"0.59290916",
"0.5925981",
"0.5909... | 0.648905 | 3 |
Resize a face image to the proper size for training and detection. | def resize(image):
return cv2.resize(image,
(FACE_WIDTH, FACE_HEIGHT),
interpolation=cv2.INTER_LANCZOS4) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def normalize_face(image: Image, face):\n y, x, h, w = face['box']\n cropped_face = image[x:x + w, y:y + h]\n\n left_eye = face['keypoints']['left_eye']\n right_eye = face['keypoints']['right_eye']\n aligned_face = align(cropped_face, left_eye, right_eye)\n aligned_face = cv2.resize(aligned_face,... | [
"0.6494418",
"0.64226705",
"0.63477206",
"0.62940675",
"0.62889427",
"0.6211562",
"0.6189234",
"0.61869866",
"0.61501527",
"0.6126207",
"0.6117579",
"0.60776395",
"0.60661775",
"0.6044011",
"0.60382354",
"0.60379624",
"0.6021614",
"0.60077566",
"0.60058826",
"0.6003356",
"0.5... | 0.7539469 | 0 |
Instantiates the ResNeXt50 architecture. | def ResNeXt50(
include_top=True,
weights="imagenet",
input_tensor=None,
input_shape=None,
pooling=None,
classes=1000,
use_mixstyle=False,
**kwargs
):
def stack_fn(x):
x = stack1(x, 64, 3, stride1=1, groups=32, base_width=4, name="conv2")
if use_mixstyle:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_resnet(num_classes: int) -> nn.Module:\n model = models.resnet50(pretrained=True)\n num_features = model.fc.in_features\n model.fc = nn.Linear(num_features, num_classes)\n\n return model",
"def resnext50(**kwargs):\n model = ResNeXt(Bottleneck, [3, 4, 6, 3], **kwargs)\n return model",
... | [
"0.6452079",
"0.6326047",
"0.62945724",
"0.61543065",
"0.61452574",
"0.60441744",
"0.6009424",
"0.5961785",
"0.5953016",
"0.5953016",
"0.5926561",
"0.5905063",
"0.5904158",
"0.5895198",
"0.5857563",
"0.58541715",
"0.58398294",
"0.5820878",
"0.5800037",
"0.5775248",
"0.5775248... | 0.5764962 | 23 |
Instantiates the ResNeXt101 architecture. | def ResNeXt101(
include_top=True,
weights="imagenet",
input_tensor=None,
input_shape=None,
pooling=None,
classes=1000,
use_mixstyle=False,
**kwargs
):
def stack_fn(x):
x = stack1(x, 64, 3, stride1=1, groups=32, base_width=8, name="conv2")
if use_mixstyle:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self):\n self.device = torch.device(\"cuda\") if torch.cuda.is_available() else torch.device(\"cpu\")\n \n self.model = models.resnet101() \n self.model.load_state_dict(torch.load(WEIGHTS_DIR))\n \n self.model.to(self.device)\n \n self.mod... | [
"0.650877",
"0.6452939",
"0.63198304",
"0.62908334",
"0.62391293",
"0.62391293",
"0.6136111",
"0.612876",
"0.612876",
"0.612876",
"0.612876",
"0.6125899",
"0.6113061",
"0.6103419",
"0.60791",
"0.6042972",
"0.6022252",
"0.5943431",
"0.5930061",
"0.5888006",
"0.58871007",
"0.... | 0.5813597 | 27 |
Overriding formatTime to add milliseconds parsing | def formatTime(self, record, datefmt=None):
ct = self.converter(record.created)
_format = datefmt or self.default_time_format
s = ct.strftime(_format)
return s | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def format_time(self, data):\r\n if self.datetime_formatting == 'rfc-2822':\r\n return format_time(data)\r\n\r\n return data.isoformat()",
"def test_with_milliseconds(self):\n for seconds, expected_output in [(0, '0:00:00'), (1, '0:00:01'), (1.337, '0:00:01.337'), (2.9, '0:00:02.9... | [
"0.6643678",
"0.6631879",
"0.65980744",
"0.65456975",
"0.64786726",
"0.64368325",
"0.64322895",
"0.64187175",
"0.6407697",
"0.6399003",
"0.6356267",
"0.63393575",
"0.6323309",
"0.62726957",
"0.62404954",
"0.6239472",
"0.6224243",
"0.6217381",
"0.61946875",
"0.61870706",
"0.61... | 0.6010655 | 36 |
Validate if a user is admin approver | def validate_approver(self, request):
if not handler.dataHelper.check_admin_approver(request.session['id']):
handler.logHelper.log_it_visit(request, __name__ + '.validate_approver', authorized=False)
raise PermissionDenied('You cannot access this page!') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def user_is_admin(user):\n return user in admins",
"def get_is_admin(self, obj):\n try:\n user = self.context.get('request').user\n except Exception:\n # raise serializers.ValidationError('Could not access request.user')\n return False\n if user == obj.adm... | [
"0.7343811",
"0.7280713",
"0.72587657",
"0.7233173",
"0.7212742",
"0.7202139",
"0.72017366",
"0.72017366",
"0.716209",
"0.715174",
"0.7142367",
"0.7133783",
"0.7126629",
"0.7104559",
"0.705934",
"0.7050312",
"0.70352775",
"0.70339596",
"0.703263",
"0.7014971",
"0.7005256",
... | 0.7331095 | 1 |
Set the API key on the client. This is called by `mailgun.initialize()`. | def set_api_key(self, api_key):
self.api_key = api_key
self.session.auth = ("api", api_key) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def SetAPIKey(self, api_key):\n self._api_key = api_key",
"def SetAPIKey(self, api_key):\n self._api_key = api_key",
"def api_key(self, api_key):\n\n self._api_key = api_key",
"def api_key_set(self, api_key):\n self.request('/v1.1/auth_key', 'POST', body={'auth_key': api_key})",
"def Se... | [
"0.80788827",
"0.80788827",
"0.75358075",
"0.7387178",
"0.7364855",
"0.7167141",
"0.71619916",
"0.70561785",
"0.6943225",
"0.69115114",
"0.6748287",
"0.6632716",
"0.66156375",
"0.6595295",
"0.6583848",
"0.65817964",
"0.6568781",
"0.65456975",
"0.6542169",
"0.6521806",
"0.6473... | 0.7415496 | 3 |
Returns numpy 3L ndarray to represent the rgb image. | def get_image():
bgr = np.frombuffer(
stream.read_frame().get_buffer_as_uint8(), dtype=np.uint8
).reshape(RESOLUTIONY, RESOLUTIONX, 3)
rgb = cv2.cvtColor(bgr, cv2.COLOR_BGR2RGB)
return rgb | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _colored_img_to_arr(image, verbose=False):\n height, width = image.size\n arr = np.array(image.getdata())\n arr = arr.reshape(3, height, width)\n r = arr[0]\n g = arr[1]\n b = arr[2]\n return r, g, b",
"def carla_rgb_image_to_ndarray(image: carla.Image) -> np.ndarray: # pylint: disable=... | [
"0.75838524",
"0.7516015",
"0.73026794",
"0.7285404",
"0.6906746",
"0.66959107",
"0.6663701",
"0.66299367",
"0.66216075",
"0.65953135",
"0.6589506",
"0.65549886",
"0.6515875",
"0.65000916",
"0.6467254",
"0.6461241",
"0.6444572",
"0.64122206",
"0.63171595",
"0.6316792",
"0.630... | 0.0 | -1 |
Transform from the sampling variable `z` to the constrained variable `Theta`. I.e., this is the function g s.t. Theta = g(z) This uses the sigmoid function | def transform(self, z):
y = sigmoid(z)
Theta = self.lower + y * (self.range)
return Theta | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sigmoid(x, theta):\n\tz = x @ theta\n\th = 1/(1+np.exp(-z))\n\treturn h, z",
"def sigmoid(z):\n g = (1 + np.exp(-z))**-1\n return g",
"def activation(z):\n # formula for sigmoid\n return 1 / (1 + np.exp(-z))",
"def sigmoid(z):\n g = 1/(1 + np.exp(-z))\n return g",
"def sigmoid(z):\r\n... | [
"0.65609765",
"0.64471066",
"0.64213264",
"0.6411414",
"0.6397644",
"0.6355635",
"0.63372713",
"0.6335278",
"0.63330626",
"0.63283205",
"0.63005805",
"0.62937176",
"0.6286193",
"0.628362",
"0.6280163",
"0.6272361",
"0.62667996",
"0.623872",
"0.6230573",
"0.62182564",
"0.62162... | 0.6669576 | 0 |
Returns the class of a known agent given its name. | def get_agent_class(alg):
if alg == "PPORND":
# TODO: testing
return rnd.PPORNDAgent
else:
return rllibagent.get_agent_class(alg) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_solver_agent_class(aname, sctx):\n # Check for solver agent context\n if not isinstance(sctx, Context):\n raise CpoException(\"Unknown solving agent '\" + aname + \"'. Check config.context.solver.agent parameter.\")\n cpath = sctx.class_name\n if cpath is None:\n raise CpoSolverE... | [
"0.7246576",
"0.68631124",
"0.67594624",
"0.62658536",
"0.5996586",
"0.5988717",
"0.59041923",
"0.58803797",
"0.57611984",
"0.5756276",
"0.5739658",
"0.5727094",
"0.5713569",
"0.5691428",
"0.56868",
"0.56513464",
"0.5610456",
"0.5580588",
"0.55570257",
"0.5547508",
"0.5517348... | 0.6848864 | 2 |
Test that a token is created for the user | def test_create_token_for_user(self):
payload = {'email': 'test@test.com', 'password': 'testpass'}
create_user(**payload)
res = self.client.post(TOKEN_URL, payload)
self.assertIn('token', res.data)
self.assertEqual(res.status_code, status.HTTP_200_OK) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_create_token_valid(self):\n create_mock_user(**self.mock_user)\n res = self.client.post(TOKEN_URL, self.mock_user)\n\n self.assertEqual(res.status_code, status.HTTP_200_OK)\n self.assertIn('token', res.data)",
"def test_create_token_for_user(self):\n payload = {'email'... | [
"0.8524954",
"0.8461728",
"0.84151304",
"0.8412818",
"0.8412537",
"0.8401617",
"0.825214",
"0.8243027",
"0.82033753",
"0.8139369",
"0.7937181",
"0.79370046",
"0.79301524",
"0.78969824",
"0.7844167",
"0.78259856",
"0.7804769",
"0.7752505",
"0.77294105",
"0.7720604",
"0.7707844... | 0.8460548 | 2 |
Test if token cannot be created for non existing user | def create_token_no_user(self):
payload = {'email': 'test@test.com', 'password': 'testpass'}
res = self.client.post(TOKEN_URL, payload)
self.assertNotIn('token', res.data)
self.assertEqual(res.status_code, status.HTTP_400_BAD_REQUEST) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_create_token_no_user(self):\n res = self.client.post(TOKEN_URL, self.mock_user)\n\n self.assertEqual(res.status_code, status.HTTP_400_BAD_REQUEST)\n self.assertNotIn('token', res.data)",
"def test_create_token_invalid_credantials(self):\n create_user(email='test@test1.com', p... | [
"0.7681337",
"0.7662509",
"0.76268595",
"0.76023793",
"0.7488713",
"0.7454086",
"0.73918617",
"0.73558986",
"0.73449874",
"0.73345476",
"0.7280788",
"0.7273546",
"0.7269564",
"0.7238822",
"0.7208064",
"0.71697235",
"0.71632683",
"0.71516407",
"0.7148836",
"0.7099057",
"0.7077... | 0.7412932 | 6 |
unit vector of direction | def direction(self):
len = self.length()
if len == 0.0:
uvec = pos.Pos(np.transpose(np.array([0, 0, 0])))
else:
uvec = pos.Pos(np.transpose(np.array([(self.end.x - self.start.x) / len,
(self.end.y - self.start.y) / len,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unit(direction):\r\n return Vector(0, -1).rotate(direction)",
"def unit(self):\r\n return Vector(self.x/self.length(), self.y/self.length())",
"def getUnitVector(self):\n return Vector.createFromPolar(1, self.angle)",
"def unit():\n return Vec2d(0, 1)",
"def unit_vector(self,vec... | [
"0.78144944",
"0.7513425",
"0.7506202",
"0.7472759",
"0.7374162",
"0.7308719",
"0.72919494",
"0.72745925",
"0.72745925",
"0.72745925",
"0.7254689",
"0.72480965",
"0.72426075",
"0.7224638",
"0.720472",
"0.7155619",
"0.7155619",
"0.7155619",
"0.7155619",
"0.7155619",
"0.7155619... | 0.81711584 | 0 |
Initializes statistics of the quantization configuration. | def __init__(self, quantized_edges_in_cfg: int, total_edges_in_cfg: int):
self.quantized_edges_in_cfg = quantized_edges_in_cfg
self.total_edges_in_cfg = total_edges_in_cfg | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _initialise_sufficient_statistics(self):\n stats = super()._initialise_sufficient_statistics()\n\n stats['B'] = {\n 'numer': [\n np.zeros((self.n_states, self.n_features[i]))\n for i in range(self.n_emissions)\n ],\n 'denom': [\n ... | [
"0.6642968",
"0.66331184",
"0.6396733",
"0.6393765",
"0.6314768",
"0.63113195",
"0.62071943",
"0.61641467",
"0.61519825",
"0.6052036",
"0.6037014",
"0.5988868",
"0.5968318",
"0.59603447",
"0.59549534",
"0.59546906",
"0.59225476",
"0.5905849",
"0.589714",
"0.5869006",
"0.58610... | 0.6265865 | 6 |
Open up the firefox browser with the changed settings | def open_firefox():
driver = install_firefox_proxy(LOCALHOST, PROXY_PORT_NUMBER)
driver.get(STARTING_WEBSITE) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start_firefox(self):\n fp = webdriver.firefox.firefox_profile.FirefoxProfile(\"/Users/robertvesco/Library/Application Support/Firefox/Profiles/j2rjfnw0.default\")\n # fp.set_preference(\"browser.download.folderList\",2)\n # fp.set_preference(\"browser.download.manager.showWhenStarting\",Fa... | [
"0.74291867",
"0.72324246",
"0.71067905",
"0.6956668",
"0.6875938",
"0.68615866",
"0.67650497",
"0.6663033",
"0.6617198",
"0.66035146",
"0.6580904",
"0.6445877",
"0.64290655",
"0.63920945",
"0.63766664",
"0.63761926",
"0.63313526",
"0.62975186",
"0.6294422",
"0.6277276",
"0.6... | 0.7570395 | 0 |
Take file path as string; return text as string. Takes a string that is a file path, opens the file, and turns the file's contents as one string of text. | def open_and_read_file(file_path):
# your code goes here
return open(file_path).read() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def open_and_read_file(file_path):\n\n # your code goes here\n text_file = open(file_path)\n text_string= text_file.read()\n text_file.close()\n return text_string",
"def open_and_read_file(file_path):\n\n text_file = open(file_path)\n full_text = text_file.read()\n\n return full_text",
... | [
"0.8070401",
"0.8048571",
"0.8014242",
"0.7991605",
"0.79222405",
"0.7865305",
"0.7799686",
"0.76798695",
"0.76596016",
"0.76136386",
"0.7608241",
"0.7570674",
"0.75405407",
"0.75296026",
"0.75042003",
"0.75040174",
"0.75001454",
"0.7413869",
"0.7371218",
"0.7360526",
"0.7329... | 0.70130706 | 31 |
Function that tests whether a number is prime or not Assumes that its argument is a nonnegative integer | def primenumber(x):
if x >= 2:
for y in range(2,x):
if not (x % y):
return False
else:
return False
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isprime(n):\r\n\treturn is_prime(n)",
"def isprime(n):\n\treturn is_prime(n)",
"def is_prime(number: int):\n\n for index in range(2, (number//2) + 1):\n if number%index == 0:\n return False\n return True",
"def is_prime(number):\n #for i in range(2, ceil(sqrt(number))):\n fo... | [
"0.8543114",
"0.8507734",
"0.8405594",
"0.8382795",
"0.8357778",
"0.8349601",
"0.8342153",
"0.8262349",
"0.8258146",
"0.8256443",
"0.82424873",
"0.82318836",
"0.82282084",
"0.82180285",
"0.82093054",
"0.82070726",
"0.82053334",
"0.8179067",
"0.8172",
"0.81697625",
"0.81544566... | 0.8111767 | 26 |
Set the audio source to upload | def input(self, source) -> None:
if source is self._source:
return
self._source = source
if self._socket is not None:
self._output.input = source | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_audio_output_source(self) -> None:\n # noinspection PyUnresolvedReferences\n self.media.set_audio_output(self.audio_output_source[0])",
"def audio(self, audio):\n\n self._audio = audio",
"def set_source(self, source):\n self.data['source'] = source",
"def src(self, src):\n... | [
"0.68669534",
"0.6784023",
"0.62514645",
"0.6168281",
"0.6150682",
"0.6064059",
"0.6001553",
"0.59715",
"0.59715",
"0.59715",
"0.59715",
"0.59715",
"0.59715",
"0.59715",
"0.59138143",
"0.5891897",
"0.58791924",
"0.56939435",
"0.56857973",
"0.5680518",
"0.5668107",
"0.564878... | 0.52000797 | 43 |
Converts the literal string to an array of characters. | def visit_String(self, node: String) -> Constant:
content = node.value
return Constant(
ArrayType(IntType(8), len(content)), bytearray(content.encode("utf8"))
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_char_array(s):\n if type(s) != bytes:\n raise ValueError('Input to to_char_array function should be in bytes')\n char_array = []\n tokens = s.split(b' ')\n for token in tokens:\n char_array.append(ord(' '))\n if isemoji(token):\n char_array.append(token)\n ... | [
"0.67918444",
"0.6001077",
"0.598543",
"0.598543",
"0.5908053",
"0.5823861",
"0.5783843",
"0.5777176",
"0.5741602",
"0.5741461",
"0.56955314",
"0.56822306",
"0.545586",
"0.5440234",
"0.5349828",
"0.5343308",
"0.5337624",
"0.53268456",
"0.532029",
"0.5317174",
"0.53049827",
... | 0.5279114 | 22 |
Method for Gaussian basis functions | def phi_gauss(self,x,i):
s = 0.1
return np.exp(-(x-self.mu[i])**2/(2*s)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _gaussian_distribution(self, x: ndarray, mu: float, sigma: float) -> ndarray:\n return 1 / (np.sqrt(2 * np.pi) * sigma) * np.exp(\n -np.power(\n (x - mu) / sigma, 2) / 2)",
"def gaussian(pars, x):\n A, b, mu, sigma = pars\n # return b + A/(np.sqrt(2*np.pi)*sigma**2) \\\... | [
"0.73245084",
"0.7167677",
"0.7090188",
"0.70637226",
"0.7007368",
"0.69903475",
"0.69168925",
"0.6890452",
"0.6867276",
"0.6831375",
"0.6825345",
"0.67868847",
"0.6692413",
"0.66898215",
"0.66419065",
"0.65925837",
"0.6532936",
"0.65328044",
"0.6511047",
"0.64904565",
"0.645... | 0.6436608 | 22 |
Set the value of the AWSAccessKeyId input for this Choreo. ((required, string) The Access Key ID provided by Amazon Web Services.) | def set_AWSAccessKeyId(self, value):
super(DescribeEvaluationsInputSet, self)._set_input('AWSAccessKeyId', value) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_AWSAccessKeyId(self, value):\n super(PutBucketWebsiteRedirectInputSet, self)._set_input('AWSAccessKeyId', value)",
"def set_AWSAccessKeyId(self, value):\n super(ListOrdersInputSet, self)._set_input('AWSAccessKeyId', value)",
"def set_AWSSecretKeyId(self, value):\n super(PutBucketWe... | [
"0.7104365",
"0.670574",
"0.54290736",
"0.4763764",
"0.46066543",
"0.45942682",
"0.4573278",
"0.44696304",
"0.42463297",
"0.41910797",
"0.4121396",
"0.41118574",
"0.41118246",
"0.41078496",
"0.40651414",
"0.39654788",
"0.3949998",
"0.3915381",
"0.38742703",
"0.38381338",
"0.3... | 0.7271952 | 0 |
Set the value of the AWSSecretKeyId input for this Choreo. ((required, string) The Secret Key ID provided by Amazon Web Services.) | def set_AWSSecretKeyId(self, value):
super(DescribeEvaluationsInputSet, self)._set_input('AWSSecretKeyId', value) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_AWSSecretKeyId(self, value):\n super(PutBucketWebsiteRedirectInputSet, self)._set_input('AWSSecretKeyId', value)",
"def set_AWSSecretKeyId(self, value):\n super(ListOrdersInputSet, self)._set_input('AWSSecretKeyId', value)",
"def vpc_id(self, vpc_id):\n self._vpc_id = vpc_id",
"d... | [
"0.70653677",
"0.64680517",
"0.5467659",
"0.53357255",
"0.519113",
"0.48395202",
"0.48395202",
"0.48395202",
"0.48395202",
"0.48395202",
"0.48395202",
"0.47276294",
"0.46416038",
"0.46416038",
"0.46416038",
"0.46416038",
"0.46416038",
"0.46416038",
"0.46416038",
"0.46416038",
... | 0.7017521 | 1 |
Set the value of the Limit input for this Choreo. ((optional, integer) The maximum number of Evaluation to include in the result.) | def set_Limit(self, value):
super(DescribeEvaluationsInputSet, self)._set_input('Limit', value) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def limit(self, limit):\n self._evaluated = False\n self._limit = limit\n return self",
"def limit(self, limit):\n\n self._limit = limit",
"def limit(self, limit):\n\n self._limit = limit",
"def limit(self, limit):\n\n self._limit = limit",
"def limit(self, limit):\n se... | [
"0.756601",
"0.739913",
"0.739913",
"0.739913",
"0.73868585",
"0.7291402",
"0.7285003",
"0.7284535",
"0.7276556",
"0.7187044",
"0.71773756",
"0.6794542",
"0.67642534",
"0.67469335",
"0.67231935",
"0.6551755",
"0.65457106",
"0.65314436",
"0.65156215",
"0.65032333",
"0.64907116... | 0.8321138 | 0 |
Post the comment if a user is authenticated or register a user and send a confirmation email. On signal django.contrib.comments.signals.comment_was_posted check if the user is authenticated or if settings.COMMENTS_PLUS_CONFIRM_EMAIL is False. In both cases will post the comment. Otherwise will send a confirmation email... | def on_comment_was_posted(sender, comment, target, user_data, request, **kwargs):
if comment.user:
if request.user.is_authenticated() and request.user.is_active:
comment.is_public = True
comment.save()
notify_comment_followers(comment)
else:
# Send con... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send_confirmation(self):\r\n c.user.email_validated = False\r\n c.user.confirmation_code = random_key(6)\r\n c.user._commit()\r\n emailer.confirmation_email(c.user)",
"def send_confirmation_email(user_pk):\n pass",
"def handle_email_confirmed(sender, **kwargs):\n email = k... | [
"0.62738943",
"0.6217694",
"0.60081863",
"0.5912046",
"0.5910667",
"0.58530176",
"0.58312094",
"0.5827509",
"0.5782223",
"0.5732543",
"0.57109827",
"0.5667533",
"0.56669414",
"0.55942637",
"0.5580668",
"0.556979",
"0.5556668",
"0.55385983",
"0.5519171",
"0.5481538",
"0.546203... | 0.7403591 | 0 |
Helper method to fetch standard authorization headers for HTTP calls | def _create_auth_headers(self):
auth_headers = {**self.get_headers()}
auth_headers['Authorization'] = 'Bearer ' + self.get_access_token()
return auth_headers | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _auth_headers(self):\n if self.token_str:\n return {'Authorization': 'Bearer {}'.format(self.token_str)}\n else:\n return {}",
"def _filter_headers(self):\n return [\"Authorization\"]",
"def get_auth_headers():\n\n auth_type = \"Basic\"\n if request.headers.... | [
"0.7494799",
"0.7452784",
"0.72116005",
"0.7169295",
"0.709308",
"0.70923996",
"0.70923996",
"0.6992154",
"0.698419",
"0.6981654",
"0.6935693",
"0.6933057",
"0.6920291",
"0.68945146",
"0.6883424",
"0.68617594",
"0.6818815",
"0.68151796",
"0.67909646",
"0.67704535",
"0.6744233... | 0.7085436 | 7 |
Calculate the DamerauLevenshtein distance between sequences. This method has not been modified from the original. | def dameraulevenshtein(seq1, seq2):
# codesnippet:D0DE4716-B6E6-4161-9219-2903BF8F547F
# Conceptually, this is based on a len(seq1) + 1 * len(seq2) + 1 matrix.
# However, only the current and two previous rows are needed at once,
# so we only store those.
oneago = None
thisrow = list(range(1, le... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _pairwise_dist(self,seq1,seq2):\n \n return jf.damerau_levenshtein_distance(str(seq1), str(seq2))",
"def damerau_levenshtein_distance(s1, s2):\n\n utils.check_for_none(s1, s2)\n utils.check_for_type(str, s1, s2)\n\n # s1 = utils.unicode_normalize(s1)\n # s2 = utils.unicode_normalize(s2)... | [
"0.77456445",
"0.7482568",
"0.72803795",
"0.70616484",
"0.70351017",
"0.7000577",
"0.6948406",
"0.6945717",
"0.693348",
"0.6927695",
"0.68048203",
"0.6769492",
"0.6605301",
"0.6601379",
"0.6566778",
"0.6550859",
"0.6518887",
"0.64883065",
"0.6478665",
"0.64404523",
"0.6418025... | 0.6774849 | 12 |
Gets a collection of `InputExample`s for the train set. | def get_train_examples(self, data_dir):
raise NotImplementedError() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_train_inputs(self, example):\n return example",
"def get_train_examples(self):\n raise NotImplementedError()",
"def get_train_examples(self, input_file):\r\n raise NotImplementedError()",
"def _create_examples(self, data, set_type):\n examples = []\n for (i, elem) in en... | [
"0.73520875",
"0.71751475",
"0.7129197",
"0.65614134",
"0.64212877",
"0.6405135",
"0.63425314",
"0.62901545",
"0.62817335",
"0.6251415",
"0.62492913",
"0.6234461",
"0.6223327",
"0.6223327",
"0.6207626",
"0.6207626",
"0.6207626",
"0.6207626",
"0.6207626",
"0.6207626",
"0.62076... | 0.624856 | 19 |
Gets a collection of `InputExample`s for the dev set. | def get_dev_examples(self, data_dir):
raise NotImplementedError() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_dev_examples(self, input_file):\r\n raise NotImplementedError()",
"def get_train_inputs(self, example):\n return example",
"def get_examples(self, env):\n return self.fam.c_get_examples(self, env)",
"def get_dev_examples(self):\n raise NotImplementedError()",
"def _create_ex... | [
"0.68096465",
"0.6588737",
"0.65564847",
"0.6552217",
"0.64253366",
"0.63810265",
"0.62574667",
"0.6191878",
"0.6116491",
"0.6095453",
"0.6055614",
"0.60522205",
"0.5989836",
"0.5925129",
"0.5923725",
"0.5920712",
"0.59178066",
"0.5915606",
"0.5915606",
"0.5915606",
"0.591560... | 0.5994734 | 20 |
Initialise weights of the model. | def weights_init(m):
if(type(m) == nn.ConvTranspose2d or type(m) == nn.Conv2d):
nn.init.normal_(m.weight.data, 0.0, 0.02)
elif(type(m) == nn.BatchNorm2d):
nn.init.normal_(m.weight.data, 1.0, 0.02)
nn.init.constant_(m.bias.data, 0) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_weights(self):\n # Initialize weights\n self.apply(self._init_weights)",
"def init_weights(self):\n # Initialize weights\n self.apply(self._init_weights)\n # Tie weights if needed\n self.tie_weights()",
"def init_weights(model):\n ...",
"def _initiali... | [
"0.89567375",
"0.886887",
"0.8826689",
"0.8780918",
"0.86556786",
"0.8612574",
"0.8415544",
"0.83593154",
"0.83498186",
"0.8244973",
"0.82133013",
"0.81863946",
"0.81863946",
"0.81863946",
"0.8184066",
"0.8172649",
"0.81617653",
"0.8131936",
"0.810196",
"0.80817103",
"0.80725... | 0.7174033 | 100 |
Return a random CSP nonce. | def _GetCspNonce():
nonce_length = constants.NONCE_LENGTH
return base64.b64encode(os.urandom(nonce_length * 2))[:nonce_length] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def nonce():\n return random.randint(0, 4294967295)",
"def nonce():\n return random.randint(0, 4294967295)",
"def GetCspNonce():\n NONCE_LENGTH = 16\n return base64.b64encode(os.urandom(NONCE_LENGTH))",
"def generate_nonce():\n return uuid4().hex",
"def generateNonce():\r\n hash = hashlib... | [
"0.8504862",
"0.8504862",
"0.8166305",
"0.7706056",
"0.76114184",
"0.7591807",
"0.7588979",
"0.7588979",
"0.7520779",
"0.7492774",
"0.73420286",
"0.7290476",
"0.71159905",
"0.708678",
"0.6812986",
"0.6789632",
"0.67217386",
"0.6657192",
"0.63802373",
"0.6274009",
"0.62509227"... | 0.8055352 | 3 |
Tests the fetch_flow_cell method of the backup API when no flow cell requested | def test_fetch_flow_cell_no_flow_cells_requested(
mock_store,
mock_check_processing,
mock_get_first_flow_cell,
caplog,
):
caplog.set_level(logging.INFO)
# GIVEN we check if a flow cell needs to be retrieved from PDC
backup_api = BackupAPI(
encryption_api=mock.Mock(),
encryp... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_first_flow_cell_no_flow_cell_requested(mock_store):\n # GIVEN status-db needs to be checked for flow cells to be retrieved from PDC\n backup_api = BackupAPI(\n encryption_api=mock.Mock(),\n encrypt_dir=mock.Mock(),\n status=mock_store,\n tar_api=mock.Mock(),\n ... | [
"0.76466525",
"0.7073562",
"0.70720565",
"0.68131894",
"0.6754199",
"0.6731079",
"0.58012086",
"0.5638415",
"0.5635327",
"0.55462366",
"0.5517047",
"0.54374236",
"0.5432456",
"0.5406341",
"0.5390496",
"0.5378049",
"0.5334612",
"0.5334612",
"0.5334612",
"0.53073645",
"0.530337... | 0.8076312 | 0 |
Tests the fetch_flow_cell method of the backup API when given a flow cell | def test_fetch_flow_cell_retrieve_specified_flow_cell(
mock_store,
mock_flow_cell,
mock_tar,
mock_get_first_flow_cell,
mock_check_processing,
mock_get_archived_key,
mock_get_archived_flow_cell,
archived_key,
archived_flow_cell,
cg_context,
caplog,
):
caplog.set_level(log... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_fetch_flow_cell_retrieve_next_flow_cell(\n mock_store,\n mock_flow_cell,\n mock_tar,\n mock_get_first_flow_cell,\n mock_get_archived_encryption_key_path,\n mock_get_archived_flow_cell_path,\n mock_create_rta_complete,\n archived_key,\n archived_flow_cell,\n cg_context,\n c... | [
"0.7662352",
"0.7575681",
"0.7461114",
"0.6768999",
"0.6736528",
"0.62814814",
"0.5912851",
"0.52316755",
"0.51894015",
"0.51874906",
"0.5157359",
"0.5153549",
"0.51255226",
"0.5124505",
"0.5096331",
"0.50845057",
"0.5076995",
"0.50703084",
"0.50535536",
"0.5011814",
"0.49884... | 0.774101 | 0 |
Read in file as DataFrame. Manipulate data using Pandas commmands | def prob2(file='budget.csv'):
#Read the file
df = pd.read_csv(file)
#Changing the food column to be at the begnning
food = df['Groceries']
df.drop(labels=['Groceries'], axis=1,inplace = True)
df.insert(0, 'Groceries', food)
#Sort the values, change the rent, and then change the fir... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run(self) -> pd.DataFrame:\n with open(self.file_path, 'r') as in_file:\n headers = in_file.readline()\n headers = headers.replace(\"\\n\", \"\")\n\n if ',' in headers:\n headers = headers.split(',')\n else:\n headers = headers.sp... | [
"0.7453123",
"0.7101015",
"0.70850056",
"0.69780535",
"0.69780535",
"0.69780535",
"0.6938775",
"0.69001156",
"0.6802459",
"0.6795595",
"0.67925733",
"0.6762523",
"0.675967",
"0.6753451",
"0.6749574",
"0.67226076",
"0.6711756",
"0.6665776",
"0.66152984",
"0.66023004",
"0.65930... | 0.0 | -1 |
Displays the afcp project homepage. | def afcp(request):
name = "afcp"
lang_url = Language.get_lang_prefix(request)
ctxt_dict = { "page_name" : name, }
ctxt_dict.update(_get_common_context_dict(request))
ctxt = Context(ctxt_dict)
tmpl = loader.get_template("%s/project/%s/%s.html" % (Config.APP_NAME, lang_url, name))
retu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def homepage():\n return render_template('home/index.html', \n title=\"Bem vindo!\")",
"def home():\n\n\treturn render_template('index.html', title='Home Page',\n\t\t\t\t\t\t year=datetime.now().year)",
"def home():\n return render_template(\n 'index.html',\n ti... | [
"0.73547196",
"0.7292402",
"0.7241089",
"0.7206792",
"0.71560013",
"0.71428573",
"0.7124738",
"0.71192884",
"0.71192884",
"0.71192884",
"0.71192884",
"0.71192884",
"0.71192884",
"0.71192884",
"0.71192884",
"0.71192884",
"0.71192884",
"0.7084635",
"0.70705605",
"0.7020103",
"0... | 0.66345954 | 54 |
Displays the carto project homepage. | def carto(request):
name = "carto"
lang_url = Language.get_lang_prefix(request)
ctxt_dict = { "page_name" : name,}
ctxt_dict.update(_get_common_context_dict(request))
ctxt = Context(ctxt_dict)
tmpl = loader.get_template("%s/project/%s/%s.html" % (Config.APP_NAME, lang_url, name) )
r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def homepage():\n return render_template('home/index.html', \n title=\"Bem vindo!\")",
"def home():\r\n return render_template(\r\n 'index.html',\r\n title='Home Page',\r\n year=datetime.now().year,\r\n )",
"def home():\n\n\treturn render_template('index... | [
"0.7456514",
"0.72809756",
"0.72546417",
"0.7211395",
"0.7207757",
"0.7207757",
"0.7207757",
"0.7207757",
"0.7207757",
"0.7207757",
"0.7207757",
"0.7207757",
"0.7207757",
"0.7207757",
"0.71818304",
"0.71732986",
"0.71289843",
"0.71273565",
"0.7115241",
"0.7065476",
"0.7057485... | 0.68062073 | 40 |
Displays the mobicours project homepage. | def mobicours(request):
name = "mobicours"
lang_url = Language.get_lang_prefix(request)
ctxt_dict = { "page_name" : name,}
ctxt_dict.update(_get_common_context_dict(request))
ctxt = Context(ctxt_dict)
tmpl = loader.get_template("%s/project/%s/%s.html" % (Config.APP_NAME, lang_url, name) ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def homepage():\n return render_template('home/index.html', \n title=\"Bem vindo!\")",
"def home():\n return render_template(\n 'index.html',\n title='Automation Center',\n year=datetime.now().year,\n message='Welcome to the Automation Center'\n )",... | [
"0.76724184",
"0.7487635",
"0.7431997",
"0.7401969",
"0.73670435",
"0.73378855",
"0.73378855",
"0.73378855",
"0.73378855",
"0.73378855",
"0.73378855",
"0.73378855",
"0.73378855",
"0.73378855",
"0.73378855",
"0.7327832",
"0.7307156",
"0.72886926",
"0.72686934",
"0.72603357",
"... | 0.0 | -1 |
Displays the html5 project homepage. | def html5(request):
name = "html5"
lang_url = Language.get_lang_prefix(request)
ctxt_dict = { "page_name" : name,}
ctxt_dict.update(_get_common_context_dict(request))
ctxt = Context(ctxt_dict)
tmpl = loader.get_template("%s/project/%s/%s.html" % (Config.APP_NAME, lang_url, name) )
r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def homepage():\n return render_template('home/index.html', \n title=\"Bem vindo!\")",
"def home():\n\n\treturn render_template('index.html', title='Home Page',\n\t\t\t\t\t\t year=datetime.now().year)",
"def home():\r\n return render_template(\r\n 'index.html',\r\n ... | [
"0.7686121",
"0.758568",
"0.7541412",
"0.74641067",
"0.74641067",
"0.74641067",
"0.74641067",
"0.74641067",
"0.74641067",
"0.74641067",
"0.74641067",
"0.74641067",
"0.74641067",
"0.74443954",
"0.743427",
"0.7423564",
"0.739023",
"0.7385348",
"0.738128",
"0.738128",
"0.7347604... | 0.69504786 | 90 |
Checks if the edge leads to the node. | def to_node(self, b):
return b == self.__node_b | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def will_hit_edge(self, direction):\n return ((self.position <= 0 and direction.is_left()) or \n (self.position >= self.scene.step_count - 1 and \n direction.is_right()))",
"def node_is_edge(self, node: MazeCell) -> bool:\n return node.x == 0 or node.x == se... | [
"0.69692284",
"0.68357277",
"0.676105",
"0.66595846",
"0.6445428",
"0.6410767",
"0.64092326",
"0.63676697",
"0.63467574",
"0.6338903",
"0.6296717",
"0.6281144",
"0.6240963",
"0.62401104",
"0.62319493",
"0.62224686",
"0.62109953",
"0.61909854",
"0.61685145",
"0.6162262",
"0.61... | 0.0 | -1 |
Check if the edge contains a node. | def contains(self, node):
return node == self.__node_a or node == self.__node_b | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_node(self, node: str) -> bool:\n return self.graph.has_node(node)",
"def has_node(self, name):\n return self.source_net.has_node(name)",
"def has_edge(self, otherNode):\n\t\t\treturn otherNode in self.edges",
"def has_node(self, n):\n return n in self.node_dict",
"def has_edge(... | [
"0.76269287",
"0.73338515",
"0.7294742",
"0.72421235",
"0.71129614",
"0.7080761",
"0.7057409",
"0.70362866",
"0.6960561",
"0.6941918",
"0.69306356",
"0.6921623",
"0.6885248",
"0.6869267",
"0.68475395",
"0.6813294",
"0.6790347",
"0.6731187",
"0.6577797",
"0.6577797",
"0.656231... | 0.6212116 | 39 |
Return the trainer class type for this model. | def trainer(self):
return self._trainer | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_class(self):\n return self.meta_model.get_class()",
"def model_type(self):\n return self._model_type",
"def type(self):\r\n return self.__class__.__name__",
"def type(cls):\n return cls.__name__",
"def get_class(self):\n return devices.get_class(self.type)",
"de... | [
"0.6418248",
"0.6410044",
"0.6344989",
"0.6324669",
"0.63029313",
"0.6264835",
"0.624946",
"0.6234999",
"0.6231836",
"0.6225505",
"0.6211312",
"0.6211312",
"0.6205268",
"0.6205268",
"0.6205268",
"0.6201543",
"0.6188644",
"0.61699045",
"0.616401",
"0.6120787",
"0.6120787",
"... | 0.61909777 | 16 |
Return the loader class type for this model. | def loader(self):
return self._loader | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def loader(self):\n return self.loader_class()",
"def LoadType(self):\n\t\treturn self._get_attribute('loadType')",
"def loader(self):\r\n return self._loader",
"def loader(self):\n if \"loader\" in self.recipe:\n return self.recipe[\"loader\"]\n else:\n rais... | [
"0.8152848",
"0.7598738",
"0.67873484",
"0.66609",
"0.6565252",
"0.6484381",
"0.64656454",
"0.6376899",
"0.63160294",
"0.6273909",
"0.6265965",
"0.62523335",
"0.62523335",
"0.6249389",
"0.6244096",
"0.62047994",
"0.61918443",
"0.6180449",
"0.61538845",
"0.6143384",
"0.6136849... | 0.6573153 | 4 |
Only courses from the student are included. | def test_only_students_courses(self):
user = self.make_user()
enrollment = EnrollmentFactory(grade_level__school_year__school=user.school)
course = CourseFactory(grade_levels=[enrollment.grade_level])
grade = GradeFactory(
score=50,
student=enrollment.student,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_all_student_courses(cls, user):\n member_record = CourseMember.objects.filter(user=user)\n member_teacher = member_record.filter(type = 3)\n student_list = []\n\n for member in member_teacher:\n if member.course.pk not in student_list:\n student_list.ap... | [
"0.6618804",
"0.64641005",
"0.6445853",
"0.6318329",
"0.6195899",
"0.6100687",
"0.60383",
"0.60066366",
"0.6003645",
"0.59513146",
"0.5943377",
"0.58665353",
"0.5839517",
"0.582441",
"0.5807285",
"0.5800824",
"0.57874686",
"0.5779561",
"0.57418174",
"0.5741107",
"0.57199305",... | 0.6853221 | 0 |
Saves all price data associated with the given symbol as a .csv file in the directory given by The .csv file shares the same name as the symbol, and if a file already exists with that name it will be overwritten | def save(symbol: str, start: dt.datetime, end: dt.datetime, listener: Listener, dir: str) -> None:
df = get_data(symbol, start, end)
if df is None:
msg = Message()
msg.add_line("*****************************")
msg.add_line(f"KeyError fetching data for {symbol}")
msg.add_line("**... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def SaveToCSV(self):\n import csv \n csvfile = open(f\"Cache/{self.symbol}.csv\", \"w\", newline='')\n writer = csv.writer(csvfile, delimiter=',')\n writer.writerow([self.symbol, self.name, self.market])\n writer.writerow(['Latest P/E Ratio:', self.pe_ratio])\n writer.writ... | [
"0.6868613",
"0.6845032",
"0.6563909",
"0.65624005",
"0.6550674",
"0.6550674",
"0.6550674",
"0.6447093",
"0.6433437",
"0.6433437",
"0.6414533",
"0.6366519",
"0.63639814",
"0.6275334",
"0.6261317",
"0.62274325",
"0.6213075",
"0.616469",
"0.61559045",
"0.6151497",
"0.6122395",
... | 0.7300796 | 0 |
Sets the transactionType of this ReqMargin. | def transactionType(self, transactionType):
allowed_values = ["BUY", "SELL"] # noqa: E501
if self.local_vars_configuration.client_side_validation and transactionType not in allowed_values: # noqa: E501
raise ValueError(
"Invalid value for `transactionType` ({0}), must b... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def marginType(self, marginType):\n\n self._marginType = marginType",
"def transaction_type(self, transaction_type):\n if transaction_type is None:\n raise ValueError(\"Invalid value for `transaction_type`, must not be `None`\") # noqa: E501\n\n self._transaction_type = transacti... | [
"0.75225896",
"0.7104439",
"0.5953585",
"0.5618892",
"0.5603344",
"0.55622107",
"0.554837",
"0.548764",
"0.548764",
"0.548764",
"0.548764",
"0.5483106",
"0.5474244",
"0.547192",
"0.547192",
"0.5471074",
"0.5428332",
"0.5389023",
"0.53565896",
"0.5346712",
"0.5304005",
"0.53... | 0.70203733 | 2 |
Returns true if both objects are equal | def __eq__(self, other):
if not isinstance(other, ReqMargin):
return False
return self.to_dict() == other.to_dict() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __eq__(self, other):\n return are_equal(self, other)",
"def __eq__(self, other):\n return are_equal(self, other)",
"def __eq__(self,other):\n try: return self.object==other.object and isinstance(self,type(other))\n except: return False",
"def __eq__(self, other):\n if i... | [
"0.8088132",
"0.8088132",
"0.8054589",
"0.7982687",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
... | 0.0 | -1 |
Returns true if both objects are not equal | def __ne__(self, other):
if not isinstance(other, ReqMargin):
return True
return self.to_dict() != other.to_dict() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __ne__(self, other: object) -> bool:\n if self.__eq__(other):\n return False\n return True",
"def __ne__(self, other: object) -> bool:\n return not self.__eq__(other)",
"def __ne__(self, other) -> bool:\n return not self.__eq__(other)",
"def __eq__(self, other):\n ... | [
"0.84560555",
"0.83913696",
"0.8143685",
"0.81403786",
"0.8131871",
"0.8093231",
"0.80915105",
"0.80915105",
"0.80915105",
"0.8084564",
"0.8084564",
"0.8075547",
"0.8075547",
"0.8065006",
"0.80417657",
"0.80417657",
"0.80417657",
"0.80417657",
"0.80417657",
"0.80417657",
"0.8... | 0.0 | -1 |
Create and save a User with the given email and password. | def _create_user(self, email, password, **extra_fields):
if not email:
raise ValueError('The given email must be set')
email = self.normalize_email(email)
user = self.model(email=email, **extra_fields)
user.set_password(password)
user.save(using=self._db)
retu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _create_user(self, email, password, **extra_fields):\n if not email:\n raise ValueError('The given email must be set')\n email = self.normalize_email(email)\n user = self.model(email=email, **extra_fields)\n user.set_password(password)\n user.save(using=self._db)\n return user",
"def... | [
"0.85445017",
"0.8511888",
"0.850827",
"0.85025996",
"0.8502548",
"0.84896004",
"0.84896004",
"0.84888655",
"0.84888655",
"0.84888655",
"0.8486028",
"0.84772795",
"0.84767693",
"0.84570897",
"0.84570897",
"0.84570897",
"0.84544164",
"0.84484667",
"0.8445246",
"0.84436035",
"0... | 0.8475504 | 16 |
Check to see if the given table exists. | def table_exists(self, dbname, tablename):
if not hasattr(self, 'existing_table_names'):
self.cursor.execute(
"SELECT schemaname, tablename FROM pg_tables WHERE schemaname NOT LIKE 'pg_%';")
self.existing_table_names = set()
for schema, table in self.cursor:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def checkIfTableExists(self, table):\n\n self.__open()\n query = \"SHOW TABLES LIKE '{}'\".format(table)\n self.__cursor.execute(query)\n result = self.__cursor.fetchall()\n self.__close()\n if result:\n return True\n else:\n return False",
"... | [
"0.8648239",
"0.8514944",
"0.848032",
"0.84725845",
"0.84555036",
"0.8402358",
"0.83563274",
"0.8289422",
"0.828628",
"0.8276604",
"0.8270114",
"0.8241215",
"0.82020384",
"0.81609267",
"0.8132133",
"0.8117493",
"0.809274",
"0.8090508",
"0.8075683",
"0.8066388",
"0.8044391",
... | 0.7831848 | 30 |
Calculates the option price. | def calc_price(p_counts, K, r, T, M, option):
if p_counts.shape[0] == 0: # not possible to exercise any option
return (0)
if option == 'Call':
price = np.mean(p_counts[:, -1] - K) * np.exp(-1 * r * T) * (p_counts.shape[0] / M)
elif option == 'Put':
price = np.mean(K - p_counts[:, -1... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute(self):\r\n \r\n if self.option_type == \"European call\":\r\n option_price = BS_call(self.S0, self.K, self.T_scaled, self.vola, self.div_yield, r=self.rf)\r\n \r\n elif self.option_type == \"European put\":\r\n option_price = BS_put(self.S0, self.K, sel... | [
"0.76367223",
"0.7147284",
"0.70083195",
"0.6921717",
"0.68525887",
"0.666896",
"0.6623128",
"0.65680563",
"0.65300274",
"0.65231174",
"0.65183604",
"0.65183604",
"0.65183604",
"0.6512061",
"0.6497633",
"0.6484666",
"0.64641064",
"0.64586693",
"0.63557273",
"0.63533294",
"0.6... | 0.63528895 | 20 |
makeminchart() makes the '2D array' for the minimization algorithm. Such as Array[states][states], filling at first with blanks or '.' then distinguishing final states. This function also creates a list of dictionaries for transitions at each state. | def makeminchart(state_num, accepted_list, alphabet, tran_list):
list_of_dict = []
push_dict = {}
for state in range(state_num):
i = 0
LOGF.write("MIN: ")
while i < len(alphabet):
LOGF.write(f"At {state} reading {alphabet[i]} -> {tran_list[state][i]} ")
push_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __create_transition_matrices(self):\r\n max_current = 2\r\n self.transition_lists = {}\r\n for x in range(self.pond_size[0]):\r\n for y in range(self.pond_size[1]):\r\n current_state = (x, y)\r\n transitions_list = []\r\n for i in ran... | [
"0.6132602",
"0.5847541",
"0.56529236",
"0.5524049",
"0.5510777",
"0.5477011",
"0.54291475",
"0.5412938",
"0.5335768",
"0.52950364",
"0.5279695",
"0.5173663",
"0.5122238",
"0.5120422",
"0.50890434",
"0.50758535",
"0.50477564",
"0.49832642",
"0.49818787",
"0.49799865",
"0.4978... | 0.7292627 | 0 |
Justifies floats based on longest string in column | def justify_column(column):
formatted_strings = ['{:,.3f}'.format(v) for v in column]
justify = len(max(formatted_strings, key=len))
column_strings = [s.rjust(justify) for s in formatted_strings]
return (column_strings, justify) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def short_float_fmt(x):\n return '{0:f}'.format(x).rstrip('0').rstrip('.')",
"def format_string(x):\n \n if 1.0>abs(x)>0.0: \n lg = log(abs(x))/log(10)\n \n # Number of digits\n d = -int(floor(lg))\n\n return '%%.%df' %d\n else:\n return '%.f'",
"def pret... | [
"0.6024202",
"0.59804237",
"0.5939797",
"0.5933137",
"0.58739984",
"0.5782951",
"0.5719135",
"0.5675223",
"0.564872",
"0.56321424",
"0.5623431",
"0.56086934",
"0.55577564",
"0.5549747",
"0.5541105",
"0.5537039",
"0.5536534",
"0.5513489",
"0.5504557",
"0.54822385",
"0.54811215... | 0.72303987 | 0 |
Accumulate gradients over multiple steps. This enables training with larger effective batch sizes. Note that currently, gradient accumulation is not supported when the `model_state` is in used, e.g., for models that have batch normalization and store batch statistics in the `model_state`. | def accumulate_grads_microbatched(
compute_gradient_fn: Callable[
[TrainState, Dict[str, jnp.ndarray], jnp.ndarray], Tuple[Any,
jnp.ndarray]],
metrics_fn: Callable[[jnp.ndarray, Dict[str, jnp.ndarray]],
Dict[str, T... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def accumulate_grad_ms(session, model, verbose=True):\n start_time = time.time()\n iters = 0\n\n # zeros initial state for all devices\n state = []\n for k in range(model.gpu_num):\n state.append(session.run(model.initial_state(k)))\n\n # evaluate loss and final state for all devices\n ... | [
"0.6805614",
"0.6690428",
"0.6686358",
"0.6651639",
"0.6534115",
"0.64493334",
"0.63416004",
"0.6261245",
"0.622897",
"0.6204802",
"0.61994636",
"0.6156619",
"0.6136418",
"0.6132453",
"0.6130482",
"0.61278564",
"0.6110918",
"0.61008257",
"0.6080869",
"0.6072765",
"0.6060173",... | 0.68060184 | 0 |
Restores the last checkpoint. First restores the checkpoint, which is an instance of TrainState that holds the state of training. | def restore_checkpoint(checkpoint_path: str,
train_state: Optional[TrainState] = None,
assert_exist: bool = False,
step: Optional[int] = None) -> Tuple[TrainState, int]:
if assert_exist:
glob_path = os.path.join(checkpoint_path, 'checkpoint_*')
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _restore_training_state(self, restore_state):\n self.load_state_dict(restore_state[\"model\"])\n self.optimizer.load_state_dict(restore_state[\"optimizer\"])\n self.lr_scheduler.load_state_dict(restore_state[\"lr_scheduler\"])\n start_iteration = restore_state[\"iteration\"] + 1\n ... | [
"0.81033087",
"0.78220725",
"0.76829267",
"0.76361626",
"0.7611152",
"0.76100844",
"0.7569638",
"0.7482326",
"0.73689926",
"0.7360784",
"0.7315668",
"0.7083321",
"0.70796275",
"0.7054261",
"0.69793594",
"0.69614524",
"0.6887874",
"0.68296915",
"0.68205667",
"0.6816287",
"0.67... | 0.6499909 | 38 |
Format time in hours/minutes/seconds. | def hms(s):
if s < 60:
return f'{s:.0f}s'
m, s = divmod(s, 60)
if m < 60:
return f'{m:.0f}m{s:.0f}s'
h, m = divmod(m, 60)
return f'{h:.0f}h{m:.0f}m' # Seconds intentionally omitted. | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def format_time(self, time):\n hours = time // 3600\n time = time - hours*3600\n minutes = time // 60\n seconds = time - minutes*60\n return ('%d:%d:%d' %(hours, minutes, seconds))",
"def format_time(self, time):\n hh = time[0:2]\n mm = time[2:4]\n ss = tim... | [
"0.876349",
"0.8126339",
"0.79132056",
"0.78442883",
"0.77146816",
"0.756667",
"0.7464062",
"0.74592304",
"0.7392785",
"0.7376773",
"0.7369484",
"0.73565865",
"0.7240116",
"0.72350097",
"0.71383935",
"0.70422465",
"0.7031393",
"0.69354814",
"0.6918944",
"0.6906704",
"0.688844... | 0.0 | -1 |
Returns the total duration for all the entries | def get_duration(self):
duration = 0
for entry in self.entries:
duration += entry.get_duration()
return duration | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_duration(self):\n durations = [series_episode.duration for series_episode in SeriesEpisode.objects.filter(series=self)]\n return reduce(lambda x, y: x + y, durations) if len(durations) > 0 else 0",
"def totalEventDuration(self):\r\n if self.events == None:\r\n raise Exception('even... | [
"0.72145844",
"0.7010849",
"0.7010789",
"0.6947392",
"0.6824434",
"0.67319953",
"0.67004997",
"0.66870165",
"0.6670582",
"0.6647913",
"0.65663767",
"0.6557122",
"0.64768034",
"0.6474971",
"0.6450206",
"0.64241695",
"0.6405245",
"0.6379713",
"0.6379713",
"0.6364159",
"0.634288... | 0.8360089 | 0 |
Give an Integer 'n'. Check if 'n' is Prime or Not | def isPrime(n: int) -> bool:
if n == 1:
return False
# handle boundary conditions
if n == 2 or n == 3:
return True
# Now check for divisibility of n by 2 & 3
if n % 2 == 0 or n % 3 == 0:
return False
i = 5
while (i * i <= n):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isprime(n):\r\n\treturn is_prime(n)",
"def isprime(n):\n\treturn is_prime(n)",
"def isPrime(n: int):\n if n <= 1:\n return False\n\n for i in range(2, n-1):\n if n % i == 0:\n # print(\"{} is divisable by {}\".format(n, i))\n return False\n\n return True",
"de... | [
"0.8198642",
"0.8160744",
"0.8103518",
"0.8041924",
"0.78751063",
"0.7871441",
"0.78625196",
"0.7845565",
"0.78305626",
"0.7800497",
"0.77827823",
"0.7775146",
"0.7771268",
"0.7759929",
"0.7758009",
"0.7752976",
"0.7749522",
"0.7719067",
"0.7717313",
"0.771148",
"0.77031744",... | 0.78346676 | 8 |
Returns the reversed string | def reverse(s):
flag=0
n=len(s)
for i in range(len(s)):
if s[i]!=s[n-i-1]:
flag=1
return -1
return 1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reverse_string(sen):\n return sen[::-1]",
"def task10_string_reversed(text):\n return text[::-1]",
"def string_reverse(text):\n rev_text = text[::-1]\n return rev_text",
"def reverse(string):\n return string[::-1]",
"def reverse_string( str ):\n return str[::-1]",
"def reverse(s):\n ... | [
"0.82443935",
"0.82277477",
"0.8134193",
"0.8049377",
"0.801654",
"0.79969287",
"0.79390687",
"0.78791577",
"0.787183",
"0.7842969",
"0.78013134",
"0.7770631",
"0.75758153",
"0.7565447",
"0.74938715",
"0.7485335",
"0.7466111",
"0.7460988",
"0.74085873",
"0.7343565",
"0.732857... | 0.0 | -1 |
Return True if the given cell forms a corridor, False otherwise. | def is_corridor_cell(cell: Cell) -> bool:
open_walls = list(cell.open_walls)
return len(open_walls) == 2 and open_walls[0].opposite == open_walls[1] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_cell(self, c, d):\n if (c[0] == self.nrows-1 and d == NORTH) or \\\n (c[1] == self.ncols-1 and d == EAST) or \\\n (c[0] == 0 and d == SOUTH) or \\\n (c[1] == 0 and d == WEST): return False\n else: return True",
"def is_rectangular_cornered(self):\... | [
"0.6540174",
"0.6449871",
"0.6325526",
"0.63020104",
"0.6153835",
"0.6135756",
"0.6113616",
"0.6099736",
"0.6017621",
"0.6005863",
"0.5941391",
"0.5921235",
"0.58877885",
"0.58568686",
"0.58559203",
"0.57904273",
"0.5782265",
"0.5774573",
"0.5773795",
"0.5713921",
"0.5700616"... | 0.8533116 | 0 |
Return True if the given cell is part of the solution to the maze, False otherwise. | def is_in_solution(self, cell: Cell) -> bool:
while cell in self.prev_cells:
cell = self.prev_cells[cell]
return cell == self.maze.start_cell | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_solved(self, grid: list):\n # Iterates over rows\n for i in range(9):\n\n if 0 in grid[i]: # Looks for 0s\n return False\n for j in range(9):\n if not self.validate_cell(grid, i, j): # validates each cell\n return False\n... | [
"0.70650506",
"0.69313353",
"0.69147974",
"0.69142085",
"0.6822784",
"0.6812688",
"0.6770937",
"0.6710431",
"0.66348237",
"0.66229784",
"0.66122484",
"0.65948856",
"0.6540202",
"0.6512552",
"0.6508893",
"0.65019876",
"0.6492557",
"0.64876837",
"0.6477174",
"0.6466677",
"0.646... | 0.83473915 | 0 |
Verifiy that the values entered into the two password fields match. Note that an error here will end up in ``non_field_errors()`` because it doesn't apply to a single field. | def clean_password1(self):
if 'password1' in self.cleaned_data and 'password2' in self.cleaned_data:
if self.cleaned_data['password1'] != self.cleaned_data['password2']:
raise forms.ValidationError(_("The two password fields didn't match."))
return self.cleaned_data['password... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clean_password(self):\n password1 = self.cleaned_data.get('password1')\n password2 = self.cleaned_data.get('password2')\n if password1 and password2 and password1 != password2:\n raise forms.ValidationError('Passwords do not match')\n return password2",
"def clean(self)... | [
"0.79399025",
"0.78749835",
"0.78695035",
"0.78401047",
"0.78401047",
"0.7653222",
"0.76381606",
"0.76270497",
"0.7620142",
"0.76103264",
"0.75970584",
"0.75902796",
"0.7566968",
"0.75656545",
"0.75656545",
"0.7564056",
"0.75482935",
"0.7527657",
"0.7465165",
"0.7378404",
"0.... | 0.7735471 | 5 |
Verifiy that the values entered into the two password fields match. Note that an error here will end up in ``non_field_errors()`` because it doesn't apply to a single field. | def clean_password2(self):
if 'password1' in self.cleaned_data and 'password2' in self.cleaned_data:
if self.cleaned_data['password1'] != self.cleaned_data['password2']:
raise forms.ValidationError(_("The two password fields didn't match."))
return self.cleaned_data['password... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clean_password(self):\n password1 = self.cleaned_data.get('password1')\n password2 = self.cleaned_data.get('password2')\n if password1 and password2 and password1 != password2:\n raise forms.ValidationError('Passwords do not match')\n return password2",
"def clean(self)... | [
"0.7940086",
"0.7875071",
"0.7869033",
"0.7840069",
"0.7840069",
"0.77356064",
"0.7653496",
"0.7638424",
"0.76268595",
"0.7620595",
"0.76104516",
"0.75970405",
"0.7590136",
"0.75667995",
"0.7566083",
"0.7566083",
"0.7564348",
"0.75278497",
"0.74662095",
"0.7378596",
"0.737647... | 0.75485694 | 17 |
Validate that the supplied email address is unique for the site. | def clean_email(self):
if User.objects.filter(email__iexact=self.cleaned_data['email']):
raise forms.ValidationError(_("This email address is already in use. Please supply a different email address."))
return self.cleaned_data['email'] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_unique_email(email):\n if AssociatedEmail.objects.filter(email=email.lower(), is_primary_email=False):\n raise ValidationError(_(\"User with this email already exists.\"),\n code='email_not_unique',)\n if User.objects.filter(email=email.lower()):\n rais... | [
"0.7853141",
"0.7655458",
"0.75150234",
"0.74791735",
"0.73846847",
"0.7384654",
"0.7372314",
"0.73539346",
"0.72824067",
"0.7252353",
"0.7246325",
"0.7239674",
"0.71946406",
"0.71906227",
"0.71826446",
"0.71657395",
"0.71555",
"0.7150741",
"0.71265936",
"0.7107152",
"0.70523... | 0.71271753 | 19 |
Get reset observation of one agent. | def get_init_state(self, agent_index=0):
return self.init_state | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reset(self):\r\n self.env.reset()\r\n return self.env.get_obs()",
"def reset(self):\n obs = self.gym.reset()\n # self.step = 1\n agent_obs = self.featurize(obs[self.gym.training_agent])\n # self.observations_history = [agent_obs]\n return agent... | [
"0.69305277",
"0.6889251",
"0.6642398",
"0.663601",
"0.6448351",
"0.6424154",
"0.63667905",
"0.6332754",
"0.6256444",
"0.617472",
"0.6144033",
"0.6091263",
"0.6057199",
"0.60010976",
"0.60010976",
"0.60010976",
"0.60010976",
"0.60010976",
"0.60010976",
"0.5987585",
"0.5976154... | 0.0 | -1 |
Construct from JSON serializable dictionary. | def from_dict(cls, dic: Dict[str, Any]) -> "CircuitStatus":
invalid = ValueError(f"Dictionary invalid format for CircuitStatus: {dic}")
if "message" not in dic or "status" not in dic:
raise invalid
try:
status = next(s for s in StatusEnum if dic["status"] == s.name)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _from_dict(cls, _dict):\n return cls.from_dict(_dict)",
"def _from_dict(cls, _dict):\n return cls.from_dict(_dict)",
"def _from_dict(cls, _dict):\n return cls.from_dict(_dict)",
"def _from_dict(cls, _dict):\n return cls.from_dict(_dict)",
"def _from_dict(cls, _dict):\n ... | [
"0.78353554",
"0.78353554",
"0.78353554",
"0.78353554",
"0.78353554",
"0.78353554",
"0.78353554",
"0.78353554",
"0.78353554",
"0.78353554",
"0.78353554",
"0.78353554",
"0.78353554",
"0.78353554",
"0.78353554",
"0.78353554",
"0.78353554",
"0.78353554",
"0.78353554",
"0.78353554"... | 0.0 | -1 |
Return a list of stopwords. | def stopwords(self):
with open(STOPWORDS_LIST, 'r') as content:
return content.read().splitlines() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getStopWords(self):\n\t\treturn self.stop_words",
"def get_stop_words(self):\n self._normalize_params()\n return self.stop_words",
"def stop_words():\n return get_stop_words('es') + get_stop_words('ca') + get_stop_words('en')",
"def getStopWords(spacy_model):\r\n # for languages avail... | [
"0.80183303",
"0.7935059",
"0.7833137",
"0.7742285",
"0.7672211",
"0.7653882",
"0.7648324",
"0.76216197",
"0.75930315",
"0.75855726",
"0.75824696",
"0.7582171",
"0.7564129",
"0.7564129",
"0.7564129",
"0.7564129",
"0.7542082",
"0.75192523",
"0.750828",
"0.74936754",
"0.7476700... | 0.8135261 | 0 |
Return a list of stopwords regexes. | def stopwords_regex(self):
regexes = list()
for stopword in self.stopwords():
regexes.append(r'\b' + stopword + r'\b')
return re.compile('|'.join(regexes), re.IGNORECASE) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_stopwords(texts):\n return [[word for word in simple_preprocess(str(doc)) if word not in stop_words] for doc in texts]",
"def stopwords(self):\n with open(STOPWORDS_LIST, 'r') as content:\n return content.read().splitlines()",
"def getStopWords(spacy_model):\r\n # for languag... | [
"0.72328895",
"0.7009559",
"0.6998379",
"0.6984287",
"0.69771034",
"0.6937841",
"0.6913659",
"0.6911223",
"0.69025785",
"0.6847499",
"0.6834423",
"0.68144864",
"0.67818624",
"0.67697954",
"0.67694366",
"0.6762042",
"0.67602473",
"0.6753589",
"0.6725645",
"0.6709671",
"0.67076... | 0.8547441 | 0 |
Return a list of sentences extracted text. | def sentences(self):
return re.compile(r'[.!?;:,\t\(\)\"\']|\s-\s').split(self.text) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_sentences(text):\n \n return text.split('.')",
"def get_sentences(self):\n return [s for s in self.text.split('\\n')]",
"def sentences(self) -> List[str]:\n\t\treturn [self.text[start:end] for start, end in self.tokenizations]",
"def sentences(self) -> List[str]:\n\t\treturn [self.text[s... | [
"0.8159513",
"0.81392026",
"0.811708",
"0.811708",
"0.8096535",
"0.7950198",
"0.7830358",
"0.768475",
"0.76302695",
"0.762875",
"0.7552444",
"0.75276166",
"0.75273335",
"0.7491967",
"0.7435566",
"0.7345262",
"0.73101324",
"0.72664016",
"0.71766925",
"0.7151291",
"0.7099539",
... | 0.7176672 | 19 |
Return a list of candidate phrases after removing stopwords. | def candidate_keywords(self):
candidate_phrases = list()
for sentence in self.sentences():
candidate_sentence = re.sub(self.stopwords_regex(), '|', sentence)
phrases = candidate_sentence.split("|")
for phrase in phrases:
phrase = remove_white_spaces(ph... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_stopwords(words):\n new_words = []\n for word in words:\n if word not in stopword_list:\n new_words.append(word)\n return new_words",
"def remove_stopwords(words):\n new_words = []\n for word in words:\n # print(word)\n if word not in stopwords.words('eng... | [
"0.7129888",
"0.7121099",
"0.7118686",
"0.7105003",
"0.70779693",
"0.70764947",
"0.7066196",
"0.7057191",
"0.7054901",
"0.7054066",
"0.7054066",
"0.7054066",
"0.7054066",
"0.7053666",
"0.7018846",
"0.6960813",
"0.6952573",
"0.69311273",
"0.68818533",
"0.6869682",
"0.6869543",... | 0.79372203 | 0 |
Construct a metric descriptor object. Metric descriptors specify the schema for a particular metric type. This factory method is used most often in conjunction with the metric | def metric_descriptor(self, type_,
metric_kind=MetricKind.METRIC_KIND_UNSPECIFIED,
value_type=ValueType.VALUE_TYPE_UNSPECIFIED,
labels=(), unit='', description='', display_name=''):
return MetricDescriptor(
self, type_,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create(self,\n metric_type,\n metric_kind='GAUGE',\n value_type='DOUBLE',\n description='N/A'):\n descriptor = ga_metric.MetricDescriptor()\n if metric_type.startswith('custom.googleapis.com/'):\n descriptor.type = metric_type\n ... | [
"0.6902602",
"0.6316135",
"0.60902125",
"0.59332067",
"0.5791282",
"0.56261283",
"0.554669",
"0.5527022",
"0.5511639",
"0.5488757",
"0.5417418",
"0.5416267",
"0.5416267",
"0.53924924",
"0.5252333",
"0.52448076",
"0.5243567",
"0.52266634",
"0.52178025",
"0.520232",
"0.514006",... | 0.69381905 | 0 |
Extend the time dimension of a dataset. | def extrude(ncpath, times):
d = netCDF4.Dataset(ncpath, 'r+')
# Get time
t_dim = d.dimensions['time']
t = d.variables['time']
t_len = t.shape[0]
assert t.axis == 'T'
assert t.dimensions == ('time', )
# For each axis containing time
for varname in d.variables:
if varname == ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_timedim(data, date=\"1970-01-01\"):\n if isinstance(data, xr.DataArray):\n if \"time\" in data.dims:\n raise ValueError(\n \"You trying to add time dimension to the DataArray that already have it. \\\nThe reason migh be that you trying to use 2d variable (e.g. `a_ice`) \... | [
"0.70578873",
"0.6964185",
"0.67469174",
"0.6274863",
"0.6118526",
"0.61001897",
"0.59803003",
"0.59752023",
"0.5851942",
"0.5794596",
"0.57715553",
"0.56831056",
"0.5649539",
"0.562341",
"0.5599042",
"0.551403",
"0.5481535",
"0.54648775",
"0.5418445",
"0.54000306",
"0.535806... | 0.5026887 | 45 |
Returns a string with the name of the file this snapshot came from. | def get_snapshot_file_name(self) -> str:
return self._file_name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_file_name(self):\n return str(self.get_file())",
"def file_name(self):\n return self.lib.file_name",
"def get_name(self):\n return self._file.name",
"def file_name(self):\n return self.__file_name",
"def get_name(self):\n return self.file_name",
"def get_file_na... | [
"0.78627145",
"0.7667334",
"0.75771815",
"0.7565735",
"0.74653196",
"0.74567014",
"0.7455653",
"0.7455653",
"0.7455653",
"0.7455653",
"0.7455653",
"0.74417967",
"0.7420556",
"0.7337409",
"0.7306227",
"0.7305571",
"0.7300885",
"0.72668666",
"0.7263516",
"0.7259557",
"0.7175466... | 0.8594554 | 0 |
Returns the UUID (Universally unique identifier) of the snapshot. | def get_snapshot_uuid(self) -> str:
return self._snapshot_uuid | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def snapshot_id(self) -> Optional[str]:\n return pulumi.get(self, \"snapshot_id\")",
"def snapshot_id(self) -> Optional[str]:\n return pulumi.get(self, \"snapshot_id\")",
"def unique_id(self):\n return f\"{DOMAIN}_{self._cam_name}_{self._obj_name}_snapshot\"",
"def uuid(self):\n i... | [
"0.74095905",
"0.74095905",
"0.7402462",
"0.70816904",
"0.7008879",
"0.69700396",
"0.69700396",
"0.6944538",
"0.6944538",
"0.6909454",
"0.68951243",
"0.689053",
"0.6880583",
"0.685903",
"0.6854571",
"0.6854571",
"0.6854571",
"0.68290895",
"0.678117",
"0.678117",
"0.678117",
... | 0.86906743 | 0 |
Return a dictionary where the keys are KappaAgents, their names, and their value is the abundance in the snapshot of those agents. | def get_composition(self) -> Dict[KappaAgent, int]:
agent_types = self.get_agent_types_present()
composition = dict(zip(agent_types, [0] * len(agent_types)))
for agent_type in agent_types:
for kappa_complex, abundance in self.get_all_complexes_and_abundances():
comple... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getAllAgents(self):\n agent_dict ={}\n for member in self.membership.listMembers():\n if member.has_role('Agent'):\n agent_id = member.getUserName()\n agent_dict[agent_id]={}\n agent_dict[agent_id]['email'] = member.getProperty('email')\n ... | [
"0.6195268",
"0.5773157",
"0.57649857",
"0.57022685",
"0.55246246",
"0.5450289",
"0.53932554",
"0.537561",
"0.52606887",
"0.5238125",
"0.5220953",
"0.5207238",
"0.51730573",
"0.5117874",
"0.50806826",
"0.50105894",
"0.5007906",
"0.4990404",
"0.49821913",
"0.49742517",
"0.4969... | 0.6564878 | 0 |
Returns a list of KappaComplexes with the smallest complexes, measured in number of constituting agents. | def get_smallest_complexes(self) -> List[Tuple[KappaComplex, int]]:
min_known_size = min(self._known_sizes)
return self.get_complexes_of_size(min_known_size) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_least_abundant_complexes(self) -> List[KappaComplex]:\n min_abundance = min(self.get_all_abundances())\n return self.get_complexes_with_abundance(min_abundance)",
"def get_largest_complexes(self) -> List[Tuple[KappaComplex, int]]:\n max_known_size = max(self._known_sizes)\n re... | [
"0.73400503",
"0.6329653",
"0.6327066",
"0.6217808",
"0.56852955",
"0.56500447",
"0.56454617",
"0.5372324",
"0.5272733",
"0.5179536",
"0.5171102",
"0.5085684",
"0.50774664",
"0.5051941",
"0.50314397",
"0.5028969",
"0.50027126",
"0.5000677",
"0.49590215",
"0.49588647",
"0.4958... | 0.80265826 | 0 |
Creates pandas DataFrame with the columns 'title' and 'context' | def __title_context_df(data):
if isinstance(data, str):
data = __load_data(data)
data_dict = __title_context_dict(data)
d = {'title':list(data_dict.keys()), 'context':list(data_dict.values())}
return pd.DataFrame(data=d) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def df(self) -> \"pandas.DataFrame\":\n titles = []\n comments = []\n alternative_codes = []\n for cat in self.values():\n titles.append(cat.title)\n comments.append(cat.comment)\n alternative_codes.append(cat.codes[1:])\n return pandas.DataFrame(... | [
"0.7308931",
"0.6816382",
"0.67639107",
"0.6571725",
"0.65596604",
"0.6310241",
"0.6217754",
"0.62006086",
"0.6145315",
"0.60660315",
"0.60385853",
"0.6029322",
"0.59674954",
"0.59593254",
"0.5956902",
"0.5934144",
"0.58981246",
"0.5888828",
"0.58634996",
"0.585971",
"0.58596... | 0.8376451 | 0 |
Load the pretrained ResNet152 and replace top fc layer. | def __init__(self):
# def __init__(self, embed_size, input_channels):
super(SignificanceCNN, self).__init__()
# self.conv0 = nn.Conv2d(1, 1, (1, 3), padding=(0,0))
self.conv0 = nn.Conv3d(1, 64, (1, 3, 3), padding=(0, 1, 1))
self.bn0 = nn.BatchNorm3d(64)
self.lrelu = nn.LeakyR... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def resnet152(pretrained=False, **kwargs):\n model = ResNet(Bottleneck, [3, 8, 36, 3], **kwargs)\n if pretrained:\n model.load_state_dict(model_zoo.load_url(model_urls['resnet152']))\n fc = transfer_fc(model.fc)\n model.fc = fc\n return model",
"def resnet152(pretrained=False):\n model =... | [
"0.7173052",
"0.6806408",
"0.67975897",
"0.67849594",
"0.67489475",
"0.67489475",
"0.67489475",
"0.67489475",
"0.67324644",
"0.6507087",
"0.6507087",
"0.64752775",
"0.63904417",
"0.62846625",
"0.62234324",
"0.61872536",
"0.6139846",
"0.61031175",
"0.6084447",
"0.60670197",
"0... | 0.0 | -1 |
Load the pretrained ResNet152 and replace top fc layer. | def __init__(self):
# def __init__(self, embed_size, input_channels):
super(OffsetCNN, self).__init__()
self.conv0 = nn.Conv3d(1, 1, (1, 1, 1), padding=(0,0,0))
self.bn0 = nn.BatchNorm3d(1)
self.lrelu = nn.LeakyReLU() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def resnet152(pretrained=False, **kwargs):\n model = ResNet(Bottleneck, [3, 8, 36, 3], **kwargs)\n if pretrained:\n model.load_state_dict(model_zoo.load_url(model_urls['resnet152']))\n fc = transfer_fc(model.fc)\n model.fc = fc\n return model",
"def resnet152(pretrained=False):\n model =... | [
"0.71717614",
"0.68050086",
"0.6795982",
"0.6783461",
"0.6747499",
"0.6747499",
"0.6747499",
"0.6747499",
"0.6731696",
"0.6505926",
"0.6505926",
"0.6473903",
"0.6388989",
"0.6283384",
"0.6222945",
"0.61859405",
"0.6139957",
"0.610276",
"0.60838705",
"0.60681355",
"0.60395557"... | 0.0 | -1 |
Load the pretrained ResNet152 and replace top fc layer. | def __init__(self):
# def __init__(self, embed_size, input_channels):
super(EncoderCNN, self).__init__()
self.off_model = OffsetCNN()
self.sig_model = SignificanceCNN()
self.sigmoid = nn.Sigmoid()
self.W = nn.Conv3d(1, 1, (5, 1, 1)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def resnet152(pretrained=False, **kwargs):\n model = ResNet(Bottleneck, [3, 8, 36, 3], **kwargs)\n if pretrained:\n model.load_state_dict(model_zoo.load_url(model_urls['resnet152']))\n fc = transfer_fc(model.fc)\n model.fc = fc\n return model",
"def resnet152(pretrained=False):\n model =... | [
"0.7173052",
"0.6806408",
"0.67975897",
"0.67849594",
"0.67489475",
"0.67489475",
"0.67489475",
"0.67489475",
"0.67324644",
"0.6507087",
"0.6507087",
"0.64752775",
"0.63904417",
"0.62846625",
"0.62234324",
"0.61872536",
"0.6139846",
"0.61031175",
"0.6084447",
"0.60670197",
"0... | 0.0 | -1 |
Returns the postfix form of the infix expression found in `expr` | def infix_to_postfix(expr):
ops = Stack()
postfix = []
toks = expr.split()
def tests(chr):
if chr.isdigit():
postfix.append(chr)
elif chr == '(':
ops.push('(')
elif ops.peek() == '(' or ops.empty():
ops.push(chr)
elif chr ==')':
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def infix_to_postfix(expr):\n # you may find the following precedence dictionary useful\n prec = {'*': 2, '/': 2,\n '+': 1, '-': 1}\n ops = Stack()\n postfix = []\n toks = expr.split()\n ### BEGIN SOLUTION\n opp = {'*', '/','+', '-'}\n for x in toks:\n if str.isdigit(x):\n... | [
"0.7979371",
"0.7801753",
"0.76920533",
"0.7429643",
"0.7404279",
"0.7347274",
"0.7156811",
"0.7048756",
"0.6956311",
"0.6874034",
"0.68503463",
"0.67862564",
"0.67233485",
"0.6722634",
"0.6648669",
"0.6607104",
"0.65920854",
"0.6575015",
"0.65612596",
"0.65422934",
"0.649845... | 0.81900203 | 0 |
A layer of fixed quantum gates. | def non_parametrized_layer():
qml.RX(a, wires=0)
qml.RX(b, wires=1)
qml.RX(a, wires=1)
qml.CNOT(wires=[0, 1])
qml.CNOT(wires=[1, 2])
qml.RZ(a, wires=0)
qml.Hadamard(wires=1)
qml.CNOT(wires=[0, 1])
qml.RZ(b, wires=1)
qml.Hadamard(wires=0) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def m_fixed(self):\n self.mx_free = self.my_free = self.mz_free = False\n return self",
"def circuit():\n np.random.seed(1967)\n for gates in gates_per_layers:\n for gate in gates:\n qml.apply(gate)\n return qml.expval(qml.PauliZ(0)... | [
"0.60187334",
"0.5921436",
"0.588638",
"0.5844476",
"0.5676609",
"0.56277174",
"0.55278414",
"0.54314363",
"0.53742474",
"0.5373335",
"0.535794",
"0.5349831",
"0.5345843",
"0.5345003",
"0.5329945",
"0.53295755",
"0.5295241",
"0.52944255",
"0.52826804",
"0.5271433",
"0.5230254... | 0.0 | -1 |
Returns the minimax action using self.depth and self.evaluationFunction | def getAction(self, gameState):
def Minimaxer(sucGameState, depth, curAgent, alpha, beta):
if sucGameState.isWin() or sucGameState.isLose():
return self.evaluationFunction(sucGameState)
if depth == 0:
return self.evaluationFunction(sucGameState)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getAction(self, gameState: GameState):\n _max = float(\"-inf\")\n action = None\n for move in gameState.getLegalActions(0):\n util = minimax(self.evaluationFunction, 1, 0,\n gameState.generateSuccessor(0, move), self.depth)\n if util > _max o... | [
"0.7482665",
"0.7383559",
"0.71806973",
"0.7110041",
"0.70884514",
"0.70683014",
"0.7048308",
"0.70055133",
"0.69651455",
"0.69642085",
"0.69604385",
"0.6945924",
"0.68998593",
"0.6895832",
"0.688605",
"0.6826282",
"0.6767276",
"0.6758028",
"0.6751636",
"0.6705453",
"0.670453... | 0.70694935 | 5 |
Return a temporary directory to use. This is in /tmp, and is based on a hash of our path so individual installations of the therm software get distinct temp directories. | def getTempDir():
return "/tmp/therm-%08X" % abs(hash(__file__.replace("pyc", "py"))) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tempdir():\n\n # Create a directory and return the path\n return tempfile.mkdtemp()",
"def get_temp_dir():\n return tempfile.mkdtemp()",
"def get_disk_temp_dir():\n td = tempfile.gettempdir()\n if sys.platform.startswith(\"win\"):\n return td0\n elif get_fstype(td) in TEMP_FS_L... | [
"0.8495071",
"0.83200717",
"0.8178644",
"0.80747664",
"0.8064805",
"0.8030486",
"0.8025406",
"0.79993594",
"0.7944096",
"0.7880901",
"0.78765285",
"0.78482145",
"0.77432275",
"0.7723845",
"0.7718095",
"0.76883525",
"0.76659167",
"0.76555634",
"0.76253504",
"0.75908023",
"0.75... | 0.7793531 | 12 |
Get the final file name for a particular stamp | def getFile(self, stamp):
name = escapeForPath(str(stamp))
return os.path.join(self.path, name) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_full_filename(dirname, name, ext, tmstamp=False):\n fill = '_' + str_current_time() if tmstamp else ''\n fmt = '/{}{}{}' if ext.startswith('.') else '/{}{}.{}'\n return resolve(dirname) + fmt.format(name, fill, ext)",
"def generate_file_name(entry):\n return str_for_file(u'{name}, {year}, {ti... | [
"0.71959406",
"0.70504427",
"0.67456603",
"0.6679539",
"0.66736937",
"0.66631633",
"0.66526586",
"0.6651539",
"0.66300154",
"0.6582215",
"0.6574201",
"0.654179",
"0.65304476",
"0.65158415",
"0.65105104",
"0.65032816",
"0.65018743",
"0.64880764",
"0.64841837",
"0.6483245",
"0.... | 0.75780493 | 0 |
Graph a linearly interpolated color range, given the minimum and maximum data values with their corresponding color. Data outside the minimum and maximum gets clamped. | def graphColorRange(min, minColor, max, maxColor, numSlices=96, id=[0]):
l = (graphColorSlice("-INF", min, minColor, id=id) +
graphColorSlice(max, "INF", maxColor, id=id))
prevAlpha = 0
while prevAlpha < 1:
alpha = prevAlpha + 1.0 / numSlices
l += graphColorSlice(prevAlpha*(max-min)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Gradient( x=np.linspace(0,1,2), min=None, max=None ):\n if min is None:\n min = x.min()\n if max is None:\n max = x.max()-min\n else:\n max -= min\n x_ = x - min\n x_ /= max\n return cmap_gradient( x_ )",
"def getColorRange(self):\n vmax=self.data_matrix.max()\n ... | [
"0.68583965",
"0.67864037",
"0.6641653",
"0.65886205",
"0.6504273",
"0.6478504",
"0.6402714",
"0.6184089",
"0.61669815",
"0.61511713",
"0.6102146",
"0.60649437",
"0.60212636",
"0.60205156",
"0.6006258",
"0.60000473",
"0.5952037",
"0.5911756",
"0.5908469",
"0.5898268",
"0.5896... | 0.7914002 | 0 |
Convert period to space Split on whitespace Strip punctuation (on termini) Discard <=1 letter strings Discard <=3 letter strings that are ALL CAPS If one string remains, return | def simplify_fore_name(name, lower=False):
if pandas.isna(name):
return None
assert isinstance(name, str)
name_ = name.replace(".", " ")
words = name_.split()
for word in words:
word = word.strip(string.punctuation)
if len(word) <= 1:
continue
if word.uppe... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clean_text(txt):\n s = ''\n for c in txt:\n if c != '.' and c != ',' and c != '!' and c != '?':\n s += c\n s = s.lower().split()\n return s",
"def split_capital(phrase):\n format_capital = []\n #words = [phrase]\n #format_capital.append(words[0].isupper())\n \n #w... | [
"0.65916926",
"0.65460664",
"0.64216894",
"0.61216366",
"0.6110138",
"0.60285413",
"0.6018607",
"0.60054356",
"0.59966284",
"0.59271777",
"0.5897811",
"0.58950365",
"0.5892016",
"0.5865377",
"0.5840663",
"0.5838178",
"0.58330154",
"0.58330154",
"0.5832933",
"0.5829084",
"0.58... | 0.0 | -1 |
Returns the state of the PWM generators. either YPwmOutput.ENABLED_FALSE or YPwmOutput.ENABLED_TRUE, according to the state of the PWM generators On failure, throws an exception or returns YPwmOutput.ENABLED_INVALID. | def get_enabled(self):
# res
if self._cacheExpiration <= YAPI.GetTickCount():
if self.load(YAPI._yapiContext.GetCacheValidity()) != YAPI.SUCCESS:
return YPwmOutput.ENABLED_INVALID
res = self._enabled
return res | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_enabledAtPowerOn(self):\n # res\n if self._cacheExpiration <= YAPI.GetTickCount():\n if self.load(YAPI._yapiContext.GetCacheValidity()) != YAPI.SUCCESS:\n return YPwmOutput.ENABLEDATPOWERON_INVALID\n res = self._enabledAtPowerOn\n return res",
"def en... | [
"0.6460491",
"0.6218517",
"0.61133194",
"0.60958964",
"0.60958964",
"0.60958964",
"0.60958964",
"0.60930115",
"0.601774",
"0.57817495",
"0.5781317",
"0.57693666",
"0.5740077",
"0.57321876",
"0.5724095",
"0.5715709",
"0.568941",
"0.5675089",
"0.56743646",
"0.56711113",
"0.5655... | 0.698795 | 0 |
Stops or starts the PWM. | def set_enabled(self, newval):
rest_val = "1" if newval > 0 else "0"
return self._setAttr("enabled", rest_val) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _set_pwm(self, raw_values):\n for i in range(len(self._pins)):\n self._pi.set_PWM_dutycycle(self._pins[i], raw_values[i])",
"def stop(self):\n\n self.pwm_forward.ChangeDutyCycle(0)\n self.pwm_backward.ChangeDutyCycle(0)",
"def stop(self):\n\n self.pwm_forward.ChangeDu... | [
"0.6456578",
"0.63840175",
"0.6355833",
"0.62954",
"0.62623394",
"0.62459445",
"0.6218827",
"0.6144759",
"0.6095936",
"0.60519993",
"0.6028778",
"0.59527725",
"0.5910808",
"0.5908418",
"0.58276016",
"0.5799032",
"0.57789254",
"0.57457155",
"0.57240844",
"0.5722997",
"0.570177... | 0.0 | -1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.