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 |
|---|---|---|---|---|---|---|
Set up a temp directory for testing. | def setUpModule():
global _tmpdir, tmpdir
_tmpdir = tempfile.TemporaryDirectory(prefix='file2wsb-', dir=TEMP_DIR)
tmpdir = os.path.realpath(_tmpdir.name)
# mock out user config
global mockings
mockings = [
mock.patch('webscrapbook.scrapbook.host.WSB_USER_DIR', os.path.join(tmpdir, 'wsb'... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setUp(self):\n tempDir.safe_mkdir(parents=True)\n os.chdir(tempDir.as_posix())",
"def setUp(self):\n chdir(mkdtemp())",
"def setUp(self):\n chdir(mkdtemp())",
"def setUp(self):\n self.tmpdir = mkdtemp()",
"def _temp_dir(self):\n tmp_dir = os.path.join(self.output_dir, ... | [
"0.82280314",
"0.81841147",
"0.81841147",
"0.81678545",
"0.8139471",
"0.81385905",
"0.7840445",
"0.7834105",
"0.7817591",
"0.7772681",
"0.77716535",
"0.776926",
"0.7738703",
"0.7700955",
"0.7664431",
"0.7656435",
"0.7622847",
"0.7622847",
"0.7622847",
"0.7622847",
"0.7622847"... | 0.0 | -1 |
/index.html should be indexed as single html page | def test_path04(self):
index_file = os.path.join(self.test_input, 'index.html')
with open(index_file, 'w', encoding='UTF-8') as fh:
fh.write("""\
<!DOCTYPE html>
<html
data-scrapbook-create="20200101000000000"
data-scrapbook-modify="20200101000000000"
data-scrapbook-source="http:... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index():\n return render_template('index.html'), 200",
"def index():\n\n return render_template(\"index.html\"), 200",
"def index():\n return render_template('index.html', name=urlpath)",
"def index(path):\n return render_template('index.html')",
"def index():\r\n return render_template(... | [
"0.8175236",
"0.809993",
"0.79296154",
"0.7902949",
"0.7893555",
"0.7893555",
"0.7882533",
"0.7882533",
"0.7882533",
"0.7882533",
"0.7882533",
"0.7882533",
"0.7882533",
"0.7882533",
"0.7882533",
"0.7882533",
"0.7882533",
"0.7882533",
"0.7882533",
"0.7882533",
"0.7882533",
"... | 0.0 | -1 |
/index.html should be indexed as single html page (no preserve filename) | def test_path05(self):
index_file = os.path.join(self.test_input, 'index.html')
with open(index_file, 'w', encoding='UTF-8') as fh:
fh.write("""\
<!DOCTYPE html>
<html
data-scrapbook-create="20200101000000000"
data-scrapbook-modify="20200101000000000"
data-scrapbook-source="http:... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index():\n return render_template('index.html', name=urlpath)",
"def index(path):\n return render_template('index.html')",
"def index():\n return render_template('index.html'), 200",
"def index():\n\n return render_template(\"index.html\"), 200",
"def index(self):\n single = os.path.... | [
"0.7623815",
"0.7601156",
"0.7590888",
"0.754448",
"0.7523031",
"0.73938936",
"0.73938936",
"0.73938936",
"0.73938936",
"0.73938936",
"0.73938936",
"0.73938936",
"0.73938936",
"0.73938936",
"0.73938936",
"0.73938936",
"0.73938936",
"0.73938936",
"0.73938936",
"0.73938936",
"0... | 0.0 | -1 |
Test for index.html + index.files | def test_supporting_folder03(self):
content = """\
<!DOCTYPE html>
<html
data-scrapbook-create="20200101000000000"
data-scrapbook-modify="20200101000000000"
data-scrapbook-source="http://example.com">
<head>
<meta charset="UTF-8">
<title>MyTitle 中文</title>
</head>
<body>
page content
<img src="index... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_indexhtml(self):\n url = self.baseurl + \"/main\"\n req = urllib2.urlopen(url, None, 3)\n self.assertTrue( req.getcode() == 200 , \"200 OK Not FOUND!\")",
"def test_get_index_html(self):\n response = self.setup_get_html_test('/api/index')\n self.assertEqual(respon... | [
"0.678658",
"0.67763066",
"0.6747226",
"0.67106247",
"0.6703753",
"0.6623195",
"0.6584315",
"0.6561927",
"0.6525597",
"0.65201545",
"0.6480207",
"0.6461054",
"0.64556354",
"0.6450089",
"0.6448718",
"0.63859427",
"0.63633466",
"0.6352176",
"0.6341868",
"0.6315424",
"0.63123494... | 0.0 | -1 |
Recursive function that searches board using BFS to arrange board into completed state. Will return True if board state is valid, False otherwise. | def solve_one(board: Board, col: int) -> bool:
#Completed board found
if col >= board.size:
return True
for row in range(board.size):
#check if position is valid
if check_constraints(board=board, row=row, col=col):
#update board and continue BFS
board.mark_til... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def solve_board(bd):\n if is_solved(bd):\n print_board(bd)\n return\n elif len(next_valid_boards(bd)) == 0:\n return False\n else:\n for board in next_valid_boards(bd):\n solve_board(board)",
"def solve(board):\r\n cell = firstEmptyCell(board)\r\n # Base case... | [
"0.77282536",
"0.73264444",
"0.7000896",
"0.69538593",
"0.6858888",
"0.6837002",
"0.68201536",
"0.6792205",
"0.6656148",
"0.66102374",
"0.6531137",
"0.652615",
"0.6515099",
"0.65131074",
"0.6506144",
"0.6397463",
"0.6394992",
"0.6375773",
"0.6354864",
"0.63455105",
"0.6331997... | 0.70698464 | 2 |
An iterator that returns the sentences of the file, sentence by sentence. | def read_sents_from_file(f):
sent = []
for line in f:
line = line.strip()
if line == "":
if sent != []:
yield 'SENT', Sentence(sent)
sent = []
elif line.startswith('#'):
yield 'COMMENT', line
else:
sen... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_file(path, tok=False):\n with open_file(path) as f:\n for line in f.readlines():\n words = split_sentence(line.strip(), tok)\n yield words",
"def __iter__(self):\n try:\n # Assume it is a file-like object and try treating it as such\n # Things... | [
"0.7161799",
"0.7025496",
"0.7017131",
"0.696656",
"0.69571555",
"0.68146664",
"0.6805858",
"0.67500025",
"0.6744824",
"0.6728755",
"0.6711102",
"0.6699643",
"0.6513958",
"0.65000755",
"0.64986897",
"0.64944035",
"0.64402246",
"0.64144605",
"0.6382444",
"0.6294962",
"0.629273... | 0.6741544 | 9 |
returns all the words according to their order up to (and excluding) index. if index1 is specified, it is the first index excluded. indices starts at 1. exclude are indices which should not be included. | def word_range(self, index2, index1 = 1, excludes = []):
if index2 == None:
return [w for w in self._words[(index1-1):] if w.get_field('index') not in excludes]
else:
return [w for w in self._words[(index1-1):(index2-1)] if w.get_field('index') not in excludes] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_words(self, indices):\n return [self.get_word(index) for index in indices]",
"def discard_index_from_word(self,word,index):\r\n\r\n # with shelf\r\n if self.using_shelf:\r\n\r\n if word in self.word_dict:\r\n\r\n self.word_dict[word].discard(str(index))\r\n\r\n\... | [
"0.63825005",
"0.5716196",
"0.5704339",
"0.570063",
"0.55774564",
"0.5425571",
"0.5421561",
"0.5339368",
"0.5332147",
"0.52510107",
"0.51849765",
"0.51843214",
"0.5171006",
"0.5151682",
"0.5135764",
"0.51164097",
"0.5067143",
"0.5058145",
"0.50476366",
"0.5024044",
"0.5022896... | 0.76524466 | 0 |
Get all values of a tag, separated by commas. Synthetic tags are supported, but will be slower. If the value is numeric, that is returned rather than a list. | def comma(self, key):
if "~" in key or key == "title": v = self(key, u"")
else: v = self.get(key, u"")
if isinstance(v, int): return v
elif isinstance(v, float): return v
else: return v.replace("\n", ", ") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_values_for_tag(self, tag_name: str):\n tag_items = self.soup.find_all(tag_name)\n tag_item_values = []\n for tag_item in tag_items:\n tag_item_value = tag_item.text.strip()\n tag_item_values.append(tag_item_value)\n return tag_item_values",
"def values(se... | [
"0.6898492",
"0.6752605",
"0.67243916",
"0.65668666",
"0.6548974",
"0.64409435",
"0.6383386",
"0.63431716",
"0.63115895",
"0.6308061",
"0.6306396",
"0.6282927",
"0.6241907",
"0.6216663",
"0.6216663",
"0.6216663",
"0.6216663",
"0.6216663",
"0.6216663",
"0.6216663",
"0.6216663"... | 0.0 | -1 |
Return true if the file still exists (or we can't tell). | def exists(self):
return os.path.exists(self["~filename"]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def file_exist() -> bool:\n pass",
"def file_exists(self):\r\n if os.path.exists(self.file_path):\r\n return True\r\n else:\r\n return False",
"def is_file_exists(self):\n pass",
"def file_exists(self):\n if os.path.isfile(self.file_name):\n ... | [
"0.8184961",
"0.81244195",
"0.7966194",
"0.79247195",
"0.7886281",
"0.78531945",
"0.78232455",
"0.77711385",
"0.7766655",
"0.7609779",
"0.7601513",
"0.76000506",
"0.75798994",
"0.7568198",
"0.7537173",
"0.75048125",
"0.74945295",
"0.7478121",
"0.74433047",
"0.7442183",
"0.743... | 0.7529262 | 15 |
Return a filelike containing cover image data, or None if no cover is available. | def find_cover(self):
base = self('~dirname')
fns = []
# We can't pass 'base' alone to glob.glob because it probably
# contains confusing metacharacters, and Python's glob doesn't
# support any kind of escaping, so chdir and use relative
# paths with known safe strings.
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fetch_cover(self) -> None:\n self.cover_path = None\n if self.cover_url is None:\n Logger.Logger.log('No cover picture found for this song.')\n return\n Logger.Logger.log('Retrieving cover picture from iTunes...')\n url_hash: str = md5(self.cover_url.encode('ut... | [
"0.6740641",
"0.6593455",
"0.6593455",
"0.6571732",
"0.6498089",
"0.6442134",
"0.6124212",
"0.6079169",
"0.564317",
"0.563015",
"0.56076217",
"0.55659676",
"0.55245286",
"0.5505889",
"0.5498474",
"0.5395122",
"0.536623",
"0.53467226",
"0.5307045",
"0.5305403",
"0.5199144",
... | 0.60502124 | 8 |
Get header Authorization with format 'Bearer ' and verified token, when Authorization header exists | def __init__(self,Authorization: str = Header(None)):
if Authorization:
if re.match(r"Bearer\s",Authorization) and len(Authorization.split(' ')) == 2 and Authorization.split(' ')[1]:
self._TOKEN = Authorization.split(' ')[1]
# verified token and check if token is revo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_token_auth_header():\n auth = request.headers.get(\"Authorization\", None)\n if not auth:\n return \"authorization_header_missing\"\n\n parts = auth.split()\n\n if parts[0].lower() != \"bearer\":\n return \"invalid_header\"\n elif len(parts) == 1:\n return \"invalid_head... | [
"0.8208527",
"0.8164839",
"0.8061588",
"0.80602556",
"0.80197966",
"0.80114347",
"0.7890021",
"0.78764117",
"0.77753234",
"0.7667898",
"0.76604",
"0.75980234",
"0.7515313",
"0.7464311",
"0.74507695",
"0.7376131",
"0.7326579",
"0.73195815",
"0.7286364",
"0.7221495",
"0.7181381... | 0.611741 | 98 |
this will return the python dictionary which has all of the claims of the JWT that is accessing the endpoint. If no JWT is currently present, return None instead | def get_raw_jwt(self) -> Optional[Dict[str,Union[str,int,bool]]]:
if self._TOKEN:
return self._verified_token(encoded_token=self._TOKEN)
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get(self):\n return {\"claims\": g.claims}, 200",
"def claims_payload(self):\n payload = {\n 'iss': self.iss,\n 'aud': self.aud,\n 'sub': self.sub,\n 'exp': self._get_expiration(self.seconds)\n }\n optional_claims = {}\n self.iat ... | [
"0.7460872",
"0.6873547",
"0.6687421",
"0.6450038",
"0.6356257",
"0.634184",
"0.62446004",
"0.618168",
"0.6181301",
"0.60470104",
"0.59939283",
"0.5953063",
"0.593004",
"0.5881625",
"0.5881625",
"0.5847889",
"0.58469194",
"0.5805723",
"0.58040833",
"0.5796962",
"0.57891345",
... | 0.6350017 | 5 |
this will return the identity of the JWT that is accessing this endpoint. If no JWT is present, `None` is returned instead. | def get_jwt_identity(self) -> Optional[Union[str,int]]:
if self._TOKEN:
return self._verified_token(encoded_token=self._TOKEN)['identity']
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def identify(self, request):\n token = self.get_jwt(request)\n if token is None:\n return NO_IDENTITY\n claims_set = self.decode_jwt(token)\n if claims_set is None:\n return NO_IDENTITY\n userid = self.get_userid(claims_set)\n if userid is None:\n ... | [
"0.70289034",
"0.6928368",
"0.6793597",
"0.6786364",
"0.6773409",
"0.66784173",
"0.65962744",
"0.65870714",
"0.6579432",
"0.65572035",
"0.65319324",
"0.6515003",
"0.65029866",
"0.64833766",
"0.6478915",
"0.6455512",
"0.64157045",
"0.64157045",
"0.64157045",
"0.6399692",
"0.63... | 0.8276206 | 0 |
Two Checkable objects are equal if they are both instances of Checkable and their path and type members are equal. | def __eq__(self, other):
return (isinstance(other, self.__class__) and
(self.path == other.path) and
(self.type == other.type)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __eq__(self, other):\n return (type(self) == type(other) and\n self.base_location == other.base_location and\n self.fold_path == other.fold_path and\n self.field == other.field)",
"def _is_equal_same_type(self, other):\n return True",
"def __eq__(s... | [
"0.6915357",
"0.6728832",
"0.6705545",
"0.66510165",
"0.6636584",
"0.6613173",
"0.657287",
"0.64689076",
"0.6464241",
"0.6459427",
"0.6379008",
"0.6372271",
"0.63576674",
"0.63561606",
"0.63522404",
"0.63522404",
"0.63457227",
"0.63236344",
"0.6321421",
"0.6316687",
"0.630925... | 0.7409354 | 0 |
Check PUT request to /machines/n | def test_00_update_machine(self):
client = self.client
# We are going to set the 'os' field to none, remove the 'uname'
# parameter and add the 'new_parameter' parameter.
# Make sure none of those things happened yet:
machine_before = check_json(client, 'api/db_default/v4/nts/ma... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_PUT4(self):\n payload = {\n \"make\": \"Nissan\",\n \"model\": \"Skyline\",\n \"year\": 1999,\n \"price\": 2200\n }\n r = requests.put(self.address + \"/loremipsum/42\", json=payload)\n self.assertEqual(r.status_code, 400)",
"def te... | [
"0.6498788",
"0.6311897",
"0.621146",
"0.61908615",
"0.60430944",
"0.60329336",
"0.5922315",
"0.5825019",
"0.58214986",
"0.5738808",
"0.5728082",
"0.5725793",
"0.57116634",
"0.5710377",
"0.57013303",
"0.56959975",
"0.5649691",
"0.56474864",
"0.5645631",
"0.5643753",
"0.564365... | 0.65473825 | 0 |
forward propagation for the [LINEAR>RELU](L1)>LINEAR>SOFTMAX computation | def L_model_forward(X, parameters, use_batchnorm, dropout):
layer_input = X
caches = []
dropout_cache = {} # cache for dropout layer
batchnorm_cache = {} # cache for batchnorm layer
num_layers = len([key for key in parameters.keys() if key.startswith('W')])
use_dropout = dropout != 1
for l... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def forward(self):\n R = self.LP.cost.R\n A = self.LP.dyn.A\n B = self.LP.dyn.B\n\n x = self.LP.x0\n self.x[0] = x\n for i in range(self.LP.N):\n u = - np.linalg.inv(R+B.T.dot(self.V[i+1]).dot(B)).dot(.5*B.T.dot(self.W[i+1]) \\\n ... | [
"0.7141811",
"0.6971135",
"0.68190175",
"0.6817701",
"0.68029964",
"0.6763727",
"0.67440575",
"0.67070395",
"0.67022884",
"0.6702213",
"0.66749895",
"0.66638404",
"0.6646219",
"0.66409504",
"0.6637451",
"0.659987",
"0.6587822",
"0.6581278",
"0.65710264",
"0.65610534",
"0.6555... | 0.0 | -1 |
Determine if a user is the owner of this item | def is_owned_by(self, user):
return user and user.id == self.user_id | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_user_is_owner(self):\n return self._tag == 'user_is_owner'",
"def is_owner(self):\n return self._is_owner",
"def isOwner(id, userId):\n db = core.connect()\n return db[id][\"createdBy\"] == userId",
"def is_owner_or_privileged_user(obj_user, request):\n return (\n obj_use... | [
"0.82411355",
"0.78081083",
"0.77607113",
"0.7493236",
"0.7440345",
"0.74044",
"0.7298314",
"0.7225871",
"0.7051769",
"0.7045904",
"0.6983884",
"0.69805896",
"0.69568664",
"0.69337523",
"0.6910503",
"0.68598694",
"0.6804645",
"0.6795904",
"0.6763131",
"0.67533875",
"0.6730954... | 0.7951948 | 1 |
Sets the group_id of this InstanceGroupAlertThresholdInfo. | def group_id(self, group_id):
self._group_id = group_id | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def group_id(self, group_id: int):\n if group_id is None:\n raise ValueError(\"Invalid value for `group_id`, must not be `None`\") # noqa: E501\n\n self._group_id = group_id",
"def set_group(self, group):\n self._group = group",
"def group_identifier(self, group_identifier):\n\... | [
"0.6625129",
"0.6483147",
"0.6369715",
"0.6350013",
"0.62197506",
"0.6186042",
"0.6175823",
"0.6148991",
"0.6120183",
"0.6120183",
"0.6120183",
"0.6101785",
"0.60226786",
"0.5998119",
"0.5876282",
"0.58322394",
"0.5783288",
"0.57195795",
"0.56357884",
"0.5605676",
"0.5571473"... | 0.6986193 | 0 |
Returns true if both objects are equal | def __eq__(self, other):
if not isinstance(other, InstanceGroupAlertThresholdInfo):
return False
return self.__dict__ == other.__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.8089204",
"0.8089204",
"0.8055265",
"0.7983358",
"0.7967577",
"0.7967577",
"0.7967577",
"0.7967577",
"0.7967577",
"0.7967577",
"0.7967577",
"0.7967577",
"0.7967577",
"0.7967577",
"0.7967577",
"0.7967577",
"0.7967577",
"0.7967577",
"0.7967577",
"0.7967577",
"0.7967577",
"... | 0.0 | -1 |
Returns true if both objects are not equal | def __ne__(self, other):
return not self == other | {
"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.845611",
"0.8391477",
"0.8144138",
"0.81410587",
"0.8132492",
"0.8093973",
"0.80920255",
"0.80920255",
"0.80920255",
"0.8085325",
"0.8085325",
"0.8076365",
"0.8076365",
"0.8065748"
] | 0.0 | -1 |
True if WAV file with prefix already exists. | def has_wav(wav_names, wav_prefix):
for wav_name in wav_names:
if wav_name.startswith(wav_prefix):
return True
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def file_exists(file_name: str, prefix: str = DATA_FOLDER) -> bool:\n return os.path.exists(os.path.join(prefix, file_name))",
"def _verify_prefix(prefix, files):\n for f in files:\n f = os.path.join(prefix, f)\n if not os.path.exists(f):\n return False\n else:\n return T... | [
"0.748665",
"0.6814777",
"0.6803682",
"0.67134756",
"0.66180056",
"0.6417238",
"0.6335828",
"0.62772924",
"0.6247934",
"0.62339735",
"0.6226547",
"0.6206521",
"0.6129599",
"0.6090805",
"0.60846996",
"0.60844284",
"0.60389096",
"0.6027108",
"0.6025807",
"0.59792745",
"0.594652... | 0.6941869 | 1 |
Add a new entity to the database | def cli(ctx, entity, params={}):
return ctx.gi.entity.add_entity(entity, params=params) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add(self):\n\n db.session.add(self)\n db.session.commit()",
"def add(self):\n\n db.session.add(self)\n db.session.commit()",
"def insert(self):\n db.session.add(self)\n db.session.commit()",
"def insert(self):\n db.session.add(self)\n db.session.com... | [
"0.75364685",
"0.75364685",
"0.74287236",
"0.74287236",
"0.74287236",
"0.72293323",
"0.7170237",
"0.6986252",
"0.69303054",
"0.69303054",
"0.69303054",
"0.69303054",
"0.691889",
"0.6888759",
"0.6886509",
"0.6878717",
"0.6878717",
"0.6878717",
"0.6878717",
"0.6878717",
"0.6878... | 0.68658704 | 27 |
Close the BLE connection | def close_connection(devCtrl, nodeId):
try:
devCtrl.CloseSession(nodeId)
except exceptions.ChipStackException as ex:
log.error("Close session failed: {}".format(str(ex)))
return False
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def close(self):\n self.conn.close()\n print ('Connection to Arduino closed')",
"def close_ble(devCtrl):\n try:\n devCtrl.CloseBLEConnection()\n except exceptions.ChipStackException as ex:\n log.error(\"Close BLE connection failed: {}\".format(str(ex)))\n return False\n\n... | [
"0.76488936",
"0.750535",
"0.7220792",
"0.71518064",
"0.7125571",
"0.71131086",
"0.7094663",
"0.707349",
"0.7031625",
"0.70154417",
"0.70039314",
"0.69736725",
"0.69321936",
"0.6911058",
"0.689003",
"0.68686855",
"0.6860969",
"0.6849809",
"0.6844113",
"0.6831018",
"0.6828791"... | 0.0 | -1 |
Close the BLE connection | def close_ble(devCtrl):
try:
devCtrl.CloseBLEConnection()
except exceptions.ChipStackException as ex:
log.error("Close BLE connection failed: {}".format(str(ex)))
return False
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def close(self):\n self.conn.close()\n print ('Connection to Arduino closed')",
"def close(self):\n self.device.disconnect()",
"def close_UDP_connection(self):\n self.beacon.stop_beaconing()",
"def close_connection(self):\n\n self._connection.close()\n print(\"Closed... | [
"0.7648404",
"0.72206706",
"0.7151947",
"0.712473",
"0.7112784",
"0.7093994",
"0.7073598",
"0.7030705",
"0.7015032",
"0.7003379",
"0.69738656",
"0.6932682",
"0.6910231",
"0.68892825",
"0.6868482",
"0.6860314",
"0.68491244",
"0.68431157",
"0.68312156",
"0.6828063",
"0.6828063"... | 0.7505992 | 1 |
Return list of random colors for number of classes given. | def get_colors_for_classes(num_classes):
# Use previously generated colors if num_classes is the same.
if (hasattr(get_colors_for_classes, "colors") and
len(get_colors_for_classes.colors) == num_classes):
return get_colors_for_classes.colors
hsv_tuples = [(float(x) / num_classes, 1., 1.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_colors_for_classes(num_classes):\n # Use previously generated colors if num_classes is the same.\n if (hasattr(_get_colors_for_classes, \"colors\") and\n len(_get_colors_for_classes.colors) == num_classes):\n return _get_colors_for_classes.colors\n\n hsv_tuples = [(x / num_class... | [
"0.79241276",
"0.77728426",
"0.74452984",
"0.7418036",
"0.7350331",
"0.73058707",
"0.7200909",
"0.7189055",
"0.7189055",
"0.7189055",
"0.7157736",
"0.71494246",
"0.7112276",
"0.710539",
"0.7090242",
"0.7040318",
"0.70354927",
"0.70328844",
"0.7028532",
"0.69534725",
"0.671434... | 0.7893131 | 1 |
Draw bounding boxes on image. Draw bounding boxes with class name and optional box score on image. | def draw_boxes(image, boxes, box_classes, class_names, scores=None):
image = Image.fromarray(np.floor(image * 255 + 0.5).astype('uint8'))
colors = get_colors_for_classes(len(class_names))
for i, c in list(enumerate(box_classes)):
box_class = class_names[c]
box = boxes[i]
color = c... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def draw_bbox(image, bboxes, masks, class_ids, class_names, scores, colors, show_label=True, show_mask=True):\n image_h, image_w, _ = image.shape\n\n for i, bbox in enumerate(bboxes):\n y1, x1, y2, x2 = bbox[i]\n coor = np.array([x1, y1, x2, y2], dtype=np.int32)\n fontScale = 0.5\n ... | [
"0.8048925",
"0.8039922",
"0.7849713",
"0.77353173",
"0.7682384",
"0.7672278",
"0.76612216",
"0.7632736",
"0.753168",
"0.7508182",
"0.7461573",
"0.74024516",
"0.73876053",
"0.7337455",
"0.7298474",
"0.72888345",
"0.72672486",
"0.725559",
"0.72299457",
"0.7154428",
"0.714662",... | 0.725673 | 17 |
Creates a dataset from clustering, with clusters as labels. | def cluster_assign(images_lists, dataset):
assert images_lists is not None
pseudolabels = []
image_indexes = []
for cluster, images in enumerate(images_lists):
image_indexes.extend(images)
pseudolabels.extend([cluster] * len(images))
print(image_indexes)
print(pseudolabels)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clustering(dataset, logger):\n all_instances = dataset\n meta_dataset = collections.defaultdict(list)\n for instance in all_instances:\n meta_dataset[instance['label']].append(instance['coordinate'])\n\n tasklist = map(\n lambda item, meta_dataset=meta_dataset, logger=logger: (\n ... | [
"0.66757774",
"0.66610694",
"0.65991",
"0.6557876",
"0.64502925",
"0.6312922",
"0.6270404",
"0.62135",
"0.61585027",
"0.6089941",
"0.6045741",
"0.6045648",
"0.59243184",
"0.59149444",
"0.5909877",
"0.5841596",
"0.58407015",
"0.58361083",
"0.58230233",
"0.5815119",
"0.5773118"... | 0.56196934 | 38 |
Return the proper rigid transformation matrix for rotations around x, y and z axes as well as the translation matrix that best fit the initial coordinate positions in R3 (I) to the final coordinate positions (F) | def lstsq_transforms_3D(I, F):
# Make sure there are the same number of point coordinates to work on
assert len(I) == len(F)
# Do not assume you were given matrix objects (could be nupy arrays)
I = np.asmatrix(I)
F = np.asmatrix(F)
# Determine the centroid for the intial and final positions
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rotation_matrix3(angle_x=0, angle_y=0, angle_z=0):\n if angle_x != 0:\n c, s = cos(angle_x), sin(angle_x)\n r = np.array([[1, 0, 0], [0, c, -s], [0, s, c]])\n else:\n r = np.identity(3)\n\n if angle_y != 0:\n c, s = cos(angle_y), sin(angle_y)\n r = r.dot(np.array([[c... | [
"0.67761785",
"0.65117806",
"0.64945704",
"0.6467658",
"0.64627135",
"0.644483",
"0.64102155",
"0.6315236",
"0.6296413",
"0.6264743",
"0.6260057",
"0.6250155",
"0.6201082",
"0.61843824",
"0.6183239",
"0.6179971",
"0.61747867",
"0.6096732",
"0.6072997",
"0.6057361",
"0.6054528... | 0.67914224 | 0 |
Given a stochastic policy (can also be deterministic where only one action has probability 1), sample an action according to the policy. | def sample_action(policy, state):
nS, nA = policy.shape
all_actions = np.arange(nA)
return np.random.choice(all_actions, p=policy[state]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def policy_action(self, s):\n return np.random.choice(np.arange(self.act_dim), 1, p=self.actor.predict(s).ravel())[0]",
"def act(observation):\n current_policy = sess.run(policy, {observation_: [observation]})\n action = np.random.choice(action_size, p=current_policy[0])\n return action",
"def sample... | [
"0.76172495",
"0.7458652",
"0.7410241",
"0.73976505",
"0.7306838",
"0.7277143",
"0.72694063",
"0.7265282",
"0.7241371",
"0.7094816",
"0.70797557",
"0.7068558",
"0.70468986",
"0.69768244",
"0.6976157",
"0.6975811",
"0.6972807",
"0.69726926",
"0.69210523",
"0.6900162",
"0.68957... | 0.82211757 | 0 |
Update the current Q_values and n_visits by generating one random episode and using the given policy and the Monte Carlo firstvisit approach. | def mc_policy_evaluation(env, policy, Q_value, n_visits, gamma=0.9):
nS = env.nS # number of states
nA = env.nA # number of actions
episode = generate_episode(env, policy)
# print(episode)
returns = generate_returns(episode, gamma=gamma)
# print(returns)
visit_flag = np.zeros((nS, nA))
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def random_exploration_step(self, sess):\n episode_reward = 0.0\n episode_len = 0 #num of action\n \n # random policy\n random_policy = np.zeros((1,2*self.ACTION_DIM))\n \n #for each episode reset first\n state = self.env.reset()\n for t in range(self.... | [
"0.6324065",
"0.6098686",
"0.60141045",
"0.5985013",
"0.59692585",
"0.5911743",
"0.59014285",
"0.5888724",
"0.58445644",
"0.5820852",
"0.5799219",
"0.5735414",
"0.57261926",
"0.5712934",
"0.5669004",
"0.5667261",
"0.56378853",
"0.5634835",
"0.562897",
"0.56219757",
"0.5617962... | 0.67298025 | 0 |
This function implements the firstvisit Monte Carlo GLIE policy iteration for finding the optimal policy. | def mc_glie(env, iterations=1000, gamma=0.9):
nS = env.nS # number of states
nA = env.nA # number of actions
Q_value = np.zeros((nS, nA))
n_visits = np.zeros((nS, nA))
policy = np.ones((env.nS,env.nA))/env.nA # initially all actions are equally likely
epsilon = 1
#########################... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def policyIteration(P,R,gamma,theta,initial_policy,max_iter=1000000):\n policy_stable = False\n policy = np.copy(initial_policy)\n num_iter = 0\n \n while (not policy_stable) and num_iter < max_iter:\n num_iter += 1\n print('Policy Iteration: ', num_iter)\n # policy evaluation\n... | [
"0.7208102",
"0.6978242",
"0.673698",
"0.6727668",
"0.6638739",
"0.6603273",
"0.65591717",
"0.64325315",
"0.64012706",
"0.63805157",
"0.63082665",
"0.62950313",
"0.6292177",
"0.6281833",
"0.6245398",
"0.6233458",
"0.61992306",
"0.61883295",
"0.61743367",
"0.61594707",
"0.6139... | 0.7001228 | 1 |
This property returns all the web elements found using the selector. | def web_elements(self):
if isinstance(self._selector, tuple):
return self._driver.find_elements(*self._selector) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_elements(self, selector):\n self._wait_element_localed(self.driver, selector)\n elements = self.driver.find_elements(*self._selector_to_by(selector))\n\n return elements",
"def elements_by_selector(self, selector):\n pass",
"def all(self, selector: Union[str, Tuple[str, str]... | [
"0.8191631",
"0.80652785",
"0.7510166",
"0.6999241",
"0.6966576",
"0.6864166",
"0.68177134",
"0.67944765",
"0.6623982",
"0.65527856",
"0.65240455",
"0.64156914",
"0.6334467",
"0.63140255",
"0.62894785",
"0.62756807",
"0.6215948",
"0.6167909",
"0.6166797",
"0.61052644",
"0.605... | 0.8064747 | 2 |
This property returns any element which matches the selector. It is different to the web_element such that it returns any HTML element. Used typically when elements are not displayed in the UI | def element(self):
if isinstance(self._selector, tuple):
return self._driver.find_element(*self._selector) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def web_element(self):\n logger.debug(\"Calling web_element property\")\n if isinstance(self._selector, tuple):\n return self._wait_until_clickable()\n elif isinstance(self._selector, str):\n return self._find_element_possibilities()\n elif isinstance(self._selecto... | [
"0.77799356",
"0.75177175",
"0.73531884",
"0.7069362",
"0.6773588",
"0.6585182",
"0.6454815",
"0.63495713",
"0.6247358",
"0.62160915",
"0.6201584",
"0.61763185",
"0.6145288",
"0.6121011",
"0.6109734",
"0.60522276",
"0.5978438",
"0.5976837",
"0.5944049",
"0.5944049",
"0.593210... | 0.7472934 | 2 |
Produce features vector, based on lexicon functions for 'terms' Returns | def vectorize(self, terms):
features = {}
if self.parameters[LexiconFeature.PARAM_ENABLED] == 'false':
return features
tones = []
if (self.terms_used == 'all'):
tones = [self.get_tone(term) for term in terms]
elif (self.used_terms == 'hashtags_only'):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lexicon_features(tokens, feats):\n# feats['neg_words'] = 0;\n# feats['pos_words'] = 0;\n# tokens = list([token.lower() for token in tokens])\n# feats['neg_words'] , feats['pos_words'] = np.count_nonzero(np.in1d(tokens, list(neg_words))), np.count_nonzero(np.in1d(tokens, list(pos_words)))\n n... | [
"0.68236864",
"0.66771597",
"0.6668694",
"0.66266924",
"0.64177775",
"0.6348321",
"0.62602246",
"0.6250945",
"0.62357837",
"0.61196184",
"0.61116177",
"0.60956204",
"0.6087665",
"0.6076376",
"0.6076332",
"0.6054606",
"0.6037456",
"0.60171205",
"0.6008711",
"0.60050887",
"0.59... | 0.725985 | 0 |
Returns the LocationConstraint for the bucket. | def get_bucket_location(bucket):
response = bucket.connection.make_request('GET', bucket.name,
query_args='location')
body = response.read()
if response.status == 200:
rs = ResultSet(bucket)
h = handler.XmlHandler(rs, bucket)
xml.sax.parseS... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_bucket_location(Bucket=None):\n pass",
"def get_location(self):\r\n response = self.connection.make_request('GET', self.name,\r\n query_args='location')\r\n body = response.read()\r\n if response.status == 200:\r\n rs = Res... | [
"0.6895107",
"0.6616331",
"0.6059428",
"0.5990876",
"0.57012147",
"0.5671858",
"0.5632316",
"0.5616731",
"0.5540776",
"0.55364716",
"0.55364716",
"0.5495368",
"0.54948586",
"0.54882956",
"0.5462999",
"0.54402316",
"0.5436771",
"0.5430717",
"0.5413113",
"0.5404235",
"0.5372473... | 0.74779344 | 0 |
Return a list of user groups associated with username. Groups are constructed from roles and services associated | def user_groups(username, auth_filename='auth.csv'):
with open(auth_filename) as auth_file:
return ['.'.join(row[1:]) for row in csv.reader(auth_file) if len(row) > 2 and row[0] == username] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getUserGroups(self, username):\r\n return self.getUser(username).groups",
"def get_groups(self, username):\n return []",
"def get_groups(self, username):\n groups = []\n for group in grp.getgrall():\n if username in group.gr_mem:\n groups.append(group.g... | [
"0.82726526",
"0.8155874",
"0.8089359",
"0.75880903",
"0.75523174",
"0.7403961",
"0.72026587",
"0.71911705",
"0.7130615",
"0.7061922",
"0.69798803",
"0.69717443",
"0.6931875",
"0.68511534",
"0.68132466",
"0.6775281",
"0.67604357",
"0.6725294",
"0.6714943",
"0.67132396",
"0.66... | 0.6908754 | 13 |
returns a datetime from a given date | def date_datetime():
date = input("give date in mon/day/year format(month like jan feb): ")
return datetime.datetime.strptime(date, "%b/%d/%Y") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convert_date_to_datetime(date):\n return datetime.combine(date, dtime()) if date else None",
"def from_date(cls, date: dt.date) -> Date:\n return cls(date.year, date.month, date.day)",
"def to_datetime(self,date):\n\n dt = datetime.datetime(date.year,date.month,date.day)\n return ti... | [
"0.72118396",
"0.70504284",
"0.7027643",
"0.70043343",
"0.6709168",
"0.6701289",
"0.6683388",
"0.66782665",
"0.65599096",
"0.6559364",
"0.6553439",
"0.65041",
"0.6466162",
"0.64028054",
"0.6367168",
"0.63389647",
"0.62916404",
"0.6273541",
"0.62649083",
"0.62494445",
"0.62057... | 0.60886854 | 24 |
returns the next 5 days after current | def next_5_days(today=datetime.datetime.now().date()):
print("today: {}".format(today))
for num in range(1, 6):
print("{} day: {}".format(num, today + datetime.timedelta(num))) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_next_day(self):\n pass",
"def next_day(date):\n return date + datetime.timedelta(days=1)",
"def next_day(date):\n return date + datetime.timedelta(days=1)",
"def _round_to_next_five_minutes(now):\n matching_seconds = [0]\n matching_minutes = [0, 5, 10, 15, 20, 25, 30, 35, 4... | [
"0.6900271",
"0.64603114",
"0.64603114",
"0.6293266",
"0.61161035",
"0.60058874",
"0.5884386",
"0.5866997",
"0.58579814",
"0.58439195",
"0.5815814",
"0.58079684",
"0.57249385",
"0.5703252",
"0.57002324",
"0.55797976",
"0.55355394",
"0.5503512",
"0.5492222",
"0.54756784",
"0.5... | 0.79529405 | 0 |
A realvalued parameter between 0 and 1 which specifies the fraction of observed samples to include when computing the objective value. alpha = 1 corresponds to a standard observable expectation value. alpha = 0 corresponds to only using the single sample with the lowest energy. alpha = 0.5 corresponds to ranking each o... | def alpha(self) -> float:
return self._alpha | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def optimal_alpha():\n\n # When I checked all of alphas, -0.01 was the best\n alpha = -0.01\n # np.random.choice([-0.06, -0.01, 0.04, 0.1])\n return alpha",
"def discounting(self, alpha):\n if not (0 <= alpha <= 1):\n raise ValueError(\n \"alpha: \" + str(alpha) + \"\... | [
"0.71326655",
"0.6428808",
"0.64284134",
"0.64284134",
"0.63004595",
"0.6290893",
"0.6232834",
"0.61827135",
"0.6138497",
"0.6124055",
"0.6104101",
"0.6036203",
"0.6031201",
"0.60121316",
"0.59991443",
"0.5985552",
"0.5963212",
"0.5944854",
"0.59419835",
"0.59419835",
"0.5932... | 0.60499626 | 11 |
Return the morphemes in ``form`` as a list of tuples of the form (pos, (mb, mg)). | def _extract_morphemes_from_form(self, form, morpheme_splitter):
morphemes = []
if not form.syntactic_category_string:
return morphemes
sc_words = form.syntactic_category_string.split()
mb_words = form.morpheme_break.split()
mg_words = form.morpheme_gloss.split()
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_word_and_lemma(token):\n form_element = token.find('form')\n lemma_element = token.find('lemma')\n\n return normalize(form_element.text), normalize(lemma_element.text)",
"def get_list_morphemes(query, xmlword):\n xml_result = xmlword.findall(query)\n morphemes = []\n if xml_result:\n ... | [
"0.58147407",
"0.56838614",
"0.54359984",
"0.5389081",
"0.5368632",
"0.5286518",
"0.5277314",
"0.52698386",
"0.52584255",
"0.5251554",
"0.524231",
"0.5237886",
"0.5232115",
"0.52186847",
"0.52186847",
"0.520753",
"0.5176963",
"0.5171292",
"0.51237464",
"0.5122681",
"0.5116980... | 0.7343909 | 0 |
Return the candidate foma regex name with all reserved symbols removed and suffixed by "Cat". This prevents conflicts between regex names and symbols in regexes. | def _get_valid_foma_regex_name(self, candidate):
if candidate == self.unknown_category:
return 'unknownCat'
name = self.delete_foma_reserved_symbols(candidate)
if not name:
return None
return u'%sCat' % name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _bcl_scrub_name(name):\n return re.sub('[^0-9a-zA-Z\\-\\_]+', '_', name)",
"def clean_protein_class_name(name):\n v = REGEX_SUB_PARENS.sub('', name).strip()\n return v",
"def clean_name(name: str) -> str:\n if not re.match(\"[a-zA-Z_]\", name[0]):\n name = \"_\" + name\n name = re... | [
"0.63068724",
"0.6270292",
"0.6245129",
"0.62003124",
"0.6129868",
"0.60867137",
"0.60399836",
"0.60031724",
"0.5946209",
"0.59379786",
"0.5931429",
"0.5925795",
"0.59257156",
"0.59213316",
"0.5919047",
"0.59150004",
"0.59094125",
"0.5894956",
"0.5893804",
"0.5883148",
"0.584... | 0.7958506 | 0 |
Testing that sum of subarray of empty array gives zero. | def test_sum_of_empty_array():
assert find_maximal_subarray_sum([], 3) == 0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_running_sum_multi_zeros(self):\n argument = [0,0,0,0]\n expected = [0,0,0,0]\n sums.running_sum(argument)\n self.assertEqual(expected,argument,\"the list contains only zeros\")",
"def test_nan_keyword(self):\n # If array has any nan's then the output will return all ze... | [
"0.64921224",
"0.64407086",
"0.64237857",
"0.63968",
"0.6368193",
"0.6329318",
"0.6301644",
"0.6268394",
"0.62099016",
"0.6163177",
"0.6145186",
"0.61342496",
"0.61126256",
"0.61076885",
"0.60806316",
"0.6041509",
"0.6004659",
"0.6000859",
"0.59981006",
"0.59977776",
"0.59805... | 0.81779027 | 0 |
Adds a strike for user with the specified reason. The date is set to when this method was called. | def add_strike(self, user: discord.User, moderator: discord.User, reason: str, severity: int) -> int:
timestamp = date.today()
self.create_default_strike_entry(user)
def data_interaction(cursor: Cursor):
sql = f"SELECT * FROM {StrikeConsts.STRIKE_TABLE} WHERE id=%s LIMIT 1;"
cursor.execute(sql, (us... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_default_strike_entry(self, user: discord.User):\n\t\t\n\t\tdef data_interaction(cur: Cursor):\n\t\t\tsql = f\"INSERT INTO {StrikeConsts.STRIKE_TABLE} ({StrikeConsts.ID}, {StrikeConsts.USERNAME}, {StrikeConsts.STRIKE_COUNT}) \" \\\n\t\t\t f\"VALUES (%(id)s, %(username)s, %(count)s);\"\n\t\t\t\n\t\t\... | [
"0.5940755",
"0.58392996",
"0.55196035",
"0.52646595",
"0.5228166",
"0.51912254",
"0.5031385",
"0.5027474",
"0.50135434",
"0.49835312",
"0.4972575",
"0.48883745",
"0.48468983",
"0.48331195",
"0.48097357",
"0.47637686",
"0.47543308",
"0.47518492",
"0.47477335",
"0.47397766",
"... | 0.73728085 | 0 |
Creates and returns a random variable drawn from a Gamma distribution parameterized with a and b parameters. | def define_variable(alpha=0., beta=1., shape=None, rand_gen=None,
dtype=None, ctx=None):
dist = Gamma(alpha=alpha, beta=beta, rand_gen=rand_gen,
dtype=dtype, ctx=ctx)
dist._generate_outputs(shape=shape)
return dist.random_variable | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def igamrnd(a, b, size=None):\n return 1 / np.random.gamma(shape=a, scale=1 / b, size=size)",
"def sample_from(self):\n return numpy.random.gamma(self.k, self.theta)",
"def gamma(gp_link=None,beta=1.):\r\n if gp_link is None:\r\n gp_link = noise_models.gp_transformations.Log_ex_1()\r\n a... | [
"0.70502055",
"0.655765",
"0.6459294",
"0.64293224",
"0.6322975",
"0.6249043",
"0.6249043",
"0.6249043",
"0.620794",
"0.61811465",
"0.61344296",
"0.6127608",
"0.6089981",
"0.60739034",
"0.6036704",
"0.6034039",
"0.60200995",
"0.5967395",
"0.5959213",
"0.5893347",
"0.5819978",... | 0.7307354 | 0 |
Clears the stack up to the special sentinel value MARK this allows for cleanup of the stack after a block of code, preserving the older values. If the stack is not empty, returns the last value on the stack non destructively, else, MARK itself is returned. | def cleartomark():
stack = currentframe().f_back.f_locals.setdefault(SN, [])
obj = object()
while obj is not MARK:
try:
obj = stack.pop()
except IndexError:
pass
if stack:
return stack[-1]
return MARK | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def popclear():\n stack = currentframe().f_back.f_locals.setdefault(SN, [])\n result = stack.pop()\n stack[:] = []\n return result",
"def clear(self):\n del self.stack[:]\n return self.stack",
"def pop(self):\n return self.stack.pop(0)",
"def stack_pop(self):\n value =... | [
"0.70104563",
"0.64276445",
"0.6325197",
"0.6289077",
"0.6185706",
"0.6179209",
"0.61486197",
"0.61228406",
"0.6117527",
"0.6113645",
"0.60791165",
"0.606747",
"0.60643464",
"0.6043668",
"0.6043186",
"0.60343355",
"0.60317737",
"0.6029982",
"0.602161",
"0.6021122",
"0.6009865... | 0.77129495 | 0 |
Get density of states. | def get_dos(
w=[],
grid=[2, 1, 1],
proj=None,
efermi=0.0,
xrange=None,
nenergy=100,
sig=0.02,
use_dask=True,
filename="dos.png",
savefig=True,
):
nwan = int(np.ceil(np.log2(w.nwan))) ** 2
kpoints = generate_kgrid(grid=grid)
nk = len(kpoints)
q_vals = np.zeros((nk,... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getDensityOfStates(self, Elist):\n\t\treturn _modes.freerotor_densityofstates(Elist, self.frequencies, 1 if self.linear else 0)",
"def density(self):\n return self.get_density()",
"def density(self):\n return self._density",
"def density( self ) :\n return self.__density",
"def den... | [
"0.7689513",
"0.75037783",
"0.7381172",
"0.7279821",
"0.7279821",
"0.7279821",
"0.72270185",
"0.72221994",
"0.71254504",
"0.7001701",
"0.68406",
"0.67129564",
"0.6669618",
"0.6665591",
"0.65723467",
"0.65348047",
"0.6527615",
"0.6443201",
"0.6439889",
"0.6330572",
"0.632248",... | 0.0 | -1 |
List all the recipes in the store and return those which should be readable by GUEST. | def get_public_bags(store):
usersign = {'name': 'GUEST', 'roles': []}
for bag in store.list_bags():
try:
bag = store.get(bag)
bag.policy.allows(usersign, 'read')
yield bag
except PermissionsError:
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_public_recipes(store):\n usersign = {'name': 'GUEST', 'roles': []}\n for recipe in store.list_recipes():\n try:\n recipe = store.get(recipe)\n recipe.policy.allows(usersign, 'read')\n for bag, _ in recipe.get_recipe():\n bag = store.get(Bag(bag))... | [
"0.76964444",
"0.7178451",
"0.7061518",
"0.6979523",
"0.69457453",
"0.67722195",
"0.6663875",
"0.657542",
"0.6550435",
"0.6545059",
"0.65359837",
"0.6452364",
"0.6324026",
"0.62622213",
"0.62573004",
"0.62421024",
"0.6155147",
"0.6154735",
"0.6109884",
"0.6069054",
"0.5927774... | 0.0 | -1 |
List all the recipes in the store and return those which should be readable by GUEST. Note that this ignores recipe templates. Which is fine, for now, they are ambiguity, so suck. | def get_public_recipes(store):
usersign = {'name': 'GUEST', 'roles': []}
for recipe in store.list_recipes():
try:
recipe = store.get(recipe)
recipe.policy.allows(usersign, 'read')
for bag, _ in recipe.get_recipe():
bag = store.get(Bag(bag))
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def recipes():\n # pylint: disable=redefined-outer-name\n recipes = list(mongo.db.recipes.find().sort('_id', -1))\n return render_template(\n \"recipes.html\", page_title=\"All Recipes\", recipes=recipes)",
"def recipes():\n recipes = mongo.db.recipes.find()\n return render_template(\"recip... | [
"0.7348648",
"0.7106998",
"0.69026744",
"0.6879527",
"0.6707948",
"0.6612626",
"0.6576166",
"0.65112346",
"0.6503445",
"0.6475029",
"0.6474828",
"0.6472471",
"0.63253295",
"0.6254878",
"0.61243224",
"0.61049175",
"0.61014044",
"0.6058553",
"0.60287017",
"0.5994146",
"0.598017... | 0.7512579 | 0 |
Retrieve pandas object stored in file, optionally based on where criteria. | def get_data(self, key, **kwargs):
with self.read():
return self.handle.select(key, **kwargs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_data(filename):\r\n return pd.read_csv(filename)",
"def read_and_set(self):\n self.df = self.run_find(self.qry, self.hide_fields)\n return",
"def _read(**kwargs) -> DataFrame:\n Engine.subscribe(_update_engine)\n\n try:\n pd_obj = FactoryDispatcher.read_csv_glob(**kwargs)\... | [
"0.59077495",
"0.58867884",
"0.58784926",
"0.586454",
"0.5861955",
"0.58526886",
"0.58220464",
"0.58106816",
"0.57946545",
"0.5775198",
"0.5757459",
"0.57562244",
"0.5723937",
"0.57097787",
"0.56990784",
"0.5690766",
"0.5688127",
"0.56869537",
"0.56827784",
"0.56583816",
"0.5... | 0.0 | -1 |
The path where to store the caseconfigs | def queries_path(tmpdir):
return Path(tmpdir) / "queries" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def configPath(self):\n return os.path.dirname(__file__)",
"def configs() -> Path:\n return TEST_ROOT.parent / \"fixtures\" / \"configs\"",
"def path(self):\n return os.path.join(self.config.get('path', os.getcwd()))",
"def config_data_path(experiment_name: str) -> Path: # pragma: no cover\... | [
"0.7085196",
"0.7017633",
"0.6834094",
"0.68101525",
"0.67765975",
"0.6726758",
"0.6704613",
"0.6673323",
"0.66722745",
"0.66695684",
"0.665197",
"0.6616868",
"0.66053104",
"0.65901065",
"0.6569443",
"0.65481025",
"0.65282905",
"0.6520829",
"0.6503334",
"0.6474747",
"0.641098... | 0.0 | -1 |
Compares against another course for equality. | def __eq__(self, rhs):
result = False
if self.code == rhs.code:
result = True
return result | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compare_courses(course1, course2):\n print(\"Comparing \\\"{}\\\" and \\\"{}\\\"...\".format(\n course1.course_title_, course2.course_title_))\n\n # First check conflicting dates\n latest_start = max(course1.appointments_[0].date_,\n course2.appointments_[0].date_)\n\n ... | [
"0.6364526",
"0.61878604",
"0.61009264",
"0.60839206",
"0.6028799",
"0.5944694",
"0.5866015",
"0.5862093",
"0.58309627",
"0.5735316",
"0.57270813",
"0.5726784",
"0.5704336",
"0.56927407",
"0.55345815",
"0.5524358",
"0.5506018",
"0.55047405",
"0.5493372",
"0.54911005",
"0.5480... | 0.0 | -1 |
Determines if this course precedes another. If course IDs don't match (using already defined == operator), compares courses by code then by term. | def __lt__(self, rhs):
if self == rhs:
result = False
else:
result = (self.code.lower(), self.term.lower()) < (rhs.code.lower(), rhs.term.lower())
return result | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def comes_before(a, b):\n if a.freq < b.freq:\n return True\n elif a.freq == b.freq:\n if a.char < b.char:\n return True\n else:\n return False\n return False",
"def compare(self, other):\n # First, compare sections\n if (self.section != \"\" or o... | [
"0.576735",
"0.5741548",
"0.569056",
"0.55834633",
"0.5536755",
"0.5508478",
"0.54997295",
"0.54997295",
"0.54535544",
"0.5437814",
"0.5421814",
"0.53294677",
"0.5329459",
"0.52837306",
"0.5277425",
"0.5276019",
"0.52673167",
"0.5222141",
"0.52207196",
"0.5203367",
"0.5201033... | 0.5904595 | 0 |
Determines if this course precedes is or equal to another. Uses already defined == and < operators. | def __le__(self, rhs):
result = (self == rhs or self < rhs)
return result | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __le__(self, other):\n return self < other or self == other",
"def __le__(self, other):\n if other is not None and self is not None:\n return self < other or self == other\n return False",
"def __lt__(self, other):\n return self <= other and self != other",
"def __l... | [
"0.7211356",
"0.70943373",
"0.70780027",
"0.70780027",
"0.7071528",
"0.70372325",
"0.7023567",
"0.7004412",
"0.70010513",
"0.6993688",
"0.6986106",
"0.6970065",
"0.69483924",
"0.69227874",
"0.68972087",
"0.689545",
"0.6881526",
"0.6870718",
"0.68672305",
"0.6852598",
"0.68045... | 0.700708 | 7 |
Transform acqiris error codes into string describing the error. | def transformErr2Str(self,*args):
error_code = c_int32(args[0])
error_str = create_string_buffer("\000"*1024)
status = self.__acqiris_QuantroDLL1.transformErr2Str(self.__instrumentID,error_code,error_str)
return str(error_str) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def error_str(messages: Iterable[Error]) -> str:\n return '\\n\\n'.join(str(m) for m in messages if is_error(m.code))",
"def error_str(rc):\n return f\"{rc}: {mqtt.error_string(rc)}\"",
"def error_str(rc):\n\treturn '{}: {}'.format(rc, mqtt.error_string(rc))",
"def error_str(rc):\n return '{}: {}'.f... | [
"0.68803596",
"0.6718115",
"0.66823685",
"0.6571047",
"0.6493036",
"0.6453954",
"0.64318144",
"0.6414869",
"0.63903797",
"0.6269663",
"0.6260574",
"0.6227959",
"0.62241024",
"0.6152825",
"0.6050756",
"0.6049243",
"0.60238194",
"0.60162467",
"0.59864527",
"0.59211874",
"0.5896... | 0.70205504 | 0 |
Get the current configuration of the board by calling configAll with parameter set=False. | def getConfigAll(self):
return self.configAll(False) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_full_config(self):\n return self._read_config()",
"def config(self):\n return \"\\n\".join([ c.config(True) for p, c in self.configs_ ])",
"def chs_config(self):\n conf = set()\n for j in self.get_fd_j(self.id):\n if self.get_config_j(j) != constants.NOT_PARTICIPA... | [
"0.6595298",
"0.64282554",
"0.623093",
"0.62283707",
"0.6193708",
"0.6061647",
"0.5968711",
"0.5951119",
"0.59106636",
"0.586158",
"0.5847362",
"0.5841465",
"0.58098966",
"0.58019644",
"0.5759226",
"0.574595",
"0.574595",
"0.574595",
"0.574595",
"0.574595",
"0.574595",
"0.5... | 0.772687 | 0 |
Sends a 401 response that enables basic auth | def authenticate():
return Response(
'Could not verify your access level for that URL.\n'
'You have to login with proper credentials', 401,
{'WWW-Authenticate': 'Basic realm="Login Required"'}) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def authenticate():\n return Response('Not Authorized', 401, {'WWW-Authenticate': 'Basic realm=\"api\"'})",
"def authenticate():\n return Response(\n '', 401, {'WWW-Authenticate': 'Basic realm=\"Login Required\"'}\n )",
"def authenticate():\n return Response(\n 'You have to login with pro... | [
"0.8095378",
"0.80943215",
"0.7960329",
"0.785324",
"0.7844362",
"0.78259075",
"0.77677304",
"0.77562714",
"0.7749071",
"0.7749071",
"0.7749071",
"0.7749071",
"0.7749071",
"0.7749071",
"0.7749071",
"0.7749071",
"0.77206504",
"0.7669128",
"0.7665531",
"0.7650957",
"0.7616053",... | 0.7812201 | 13 |
Format number in a compact way when the value is above 1000. | def compact_number(value: int) -> str:
value = float('{:.3g}'.format(value))
magnitude = 0
while abs(value) >= 1000:
magnitude += 1
value /= 1000.0
return '{}{}'.format(
'{:f}'.format(value).rstrip('0').rstrip('.'), ['', 'K', 'M', 'B', 'T'][magnitude]
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def format_number(number):\r\n if number >= 1000 and number % 1000 == 0:\r\n return \"%dk\" % (number/1000)\r\n else:\r\n return str(number)",
"def shorten_number(self, number):\n if number < 1000:\n return number\n elif number >= 1000 and number < 1000000:\n ... | [
"0.76871496",
"0.7390677",
"0.699673",
"0.6994698",
"0.67716944",
"0.66960204",
"0.6628655",
"0.6549821",
"0.65444523",
"0.65080965",
"0.64273596",
"0.6406417",
"0.63823897",
"0.6368421",
"0.63520324",
"0.6345631",
"0.6329038",
"0.6262472",
"0.6245468",
"0.6237604",
"0.623669... | 0.801438 | 0 |
Look for tags and replace the inner text with the URL path without scheme. | def clean_url_path(markup):
soup = BeautifulSoup(markup, "html.parser")
elements = soup.find_all('a')
for url in elements:
url_href = url.get('href')
if url.string:
url_string = url.string.replace('\n', '').replace(' ', '')
# Only clean links where the URL matches ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __replace_href(self, tag):\n if \"<a href=\" in str(tag.contents):\n if len(tag.contents) > 1:\n tag = concatenate(list(tag.contents))\n else:\n tag = str(tag.contents)[1:len(str(tag.contents)) - 1]\n for k, v in self.rules.items():\n ... | [
"0.63446766",
"0.6314422",
"0.6291748",
"0.6119823",
"0.610221",
"0.60937196",
"0.6042687",
"0.60344034",
"0.58457905",
"0.57106227",
"0.5698361",
"0.5672926",
"0.55836785",
"0.5526397",
"0.54966843",
"0.5465055",
"0.5459175",
"0.54395914",
"0.54390657",
"0.54262066",
"0.5424... | 0.5891816 | 8 |
The maximum depth of a tree is the longest branch from root to a leaf | def max_depth(node):
if not node:
return 0
return max(max_depth(node.left), max_depth(node.right)) + 1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def max_depth(self) -> int:\n return 0",
"def max_tree_depth(self):\n\n depths = np.array([leaf.tree_depth for leaf in self.leaves])\n\n return depths.max()",
"def _max_depth(self):\n max_depth = 0\n for node, data in self.traverse():\n max_depth = max(max_depth, d... | [
"0.82482386",
"0.8221488",
"0.81522626",
"0.79232025",
"0.78752714",
"0.7754381",
"0.77362984",
"0.77302516",
"0.77207714",
"0.7705198",
"0.76775783",
"0.7582622",
"0.7489839",
"0.74818146",
"0.7475471",
"0.74376416",
"0.7383777",
"0.73820764",
"0.7374716",
"0.7320382",
"0.73... | 0.7725694 | 8 |
A channelsfirst variant of the class activation map algorithm, with heatmaps superimposed over the most recent frame of the state's stack. | def decision_heatmaps(obs):
global model
assert obs > 4 and obs < 1788, "Chosen observation is outside the range of the demonstration episode."
saved_observations = np.load('saved_observations.npy')
state = saved_observations[obs-3:obs+1]
state_batch = np.expand_dims(state, axis=0)
q_vals = mode... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def output_heatmap(model, last_conv_layer, img):\n # predict the image class\n preds = model.predict(img)\n # find the class index\n index = np.argmax(preds[0])\n # This is the entry in the prediction vector\n target_output = model.output[:, index]\n # get the last conv layer\n last_conv_la... | [
"0.6264523",
"0.6030405",
"0.6015534",
"0.5969295",
"0.56912106",
"0.56116927",
"0.5596886",
"0.5552296",
"0.5535078",
"0.54790634",
"0.5458686",
"0.5457513",
"0.54497224",
"0.5439064",
"0.5426339",
"0.54152817",
"0.5378797",
"0.5363226",
"0.5360707",
"0.53159046",
"0.5270802... | 0.5603246 | 6 |
Gets or sets id associated with the model's saved pie chart | def pie_id(self):
return self._pie_id | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_plot(self):\n self.pie_id = str(uuid.uuid4().hex)\n self.pie.savefig(str(self.pie_id + \"{}\").format(\".png\"))\n\n if self.verbose:\n print(\n \"Pie chart saved at \" + (\n str(self.pie_id + \"{}\").format(\".png\")))",
"def persistent_... | [
"0.5875689",
"0.58461374",
"0.57373834",
"0.5689515",
"0.5662969",
"0.5652583",
"0.56460154",
"0.5599396",
"0.55843323",
"0.55144775",
"0.5467855",
"0.5464172",
"0.5443967",
"0.5433211",
"0.54237384",
"0.5421992",
"0.5421992",
"0.5421992",
"0.5421992",
"0.5417219",
"0.5416916... | 0.7633769 | 0 |
Gets or sets id associated with the model's saved processed image | def compressed_image_id(self):
return self._compressed_image_id | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def image_id(self):\n return self._image_id",
"def image_id(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"image_id\")",
"def image_id(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"image_id\")",
"def image_id(self) -> pulumi.Input[str]:\n return pulumi.get(sel... | [
"0.70509654",
"0.6905005",
"0.6905005",
"0.68619835",
"0.68619835",
"0.6851425",
"0.6839988",
"0.6783901",
"0.6783901",
"0.6592247",
"0.6464418",
"0.63917774",
"0.6389704",
"0.638672",
"0.63725424",
"0.6362323",
"0.63501585",
"0.6333589",
"0.6320914",
"0.629358",
"0.6290424",... | 0.0 | -1 |
Calculates euclidean distance between point A & B on the given axis | def _euclid_distance(self, A, B, axis=1):
return np.linalg.norm(A - B, axis=axis) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def euclidean_distance(a, b, axis=1):\n return np.sum((a-b)**2, axis=axis)**.5\n #NOTE: the below be preferred for \"big\" comparisons in dim 1 of b\n #return np.apply_along_axis(np.linalg.norm, axis, doca-docb)",
"def euclidean_distance(a, b):\n return np.linalg.norm(a - b)",
"def _euclideanDistan... | [
"0.7904193",
"0.7511328",
"0.7509317",
"0.7428187",
"0.7398175",
"0.7370523",
"0.7368689",
"0.73160404",
"0.73073065",
"0.72651476",
"0.7256067",
"0.72435904",
"0.7191737",
"0.7189179",
"0.7175002",
"0.7169314",
"0.7150315",
"0.7147072",
"0.71344846",
"0.7096926",
"0.7051432"... | 0.8114539 | 0 |
Return a list of server actions | def server_actions(self, server):
server_id = resource2.Resource._get_id(server)
return list(self._list(_server_action.ServerAction, paginated=False,
instance_uuid=server_id)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def actions(self):\n return self._action_list",
"def get_actions(self):\n return []",
"def get_list_of_actions(self):\n return self.actions",
"def get_actions(self):\n return self.agent.get_actions()",
"def actions(self) -> List[str]:\n return list(self.__endpoints.keys()... | [
"0.7599956",
"0.757498",
"0.755644",
"0.7372434",
"0.7298682",
"0.7206183",
"0.7201757",
"0.71988875",
"0.71988875",
"0.7111715",
"0.70211554",
"0.7021073",
"0.7021073",
"0.7021073",
"0.7007965",
"0.6988531",
"0.6948211",
"0.6891981",
"0.6884457",
"0.6851774",
"0.6831917",
... | 0.794708 | 0 |
Return a list of flavors | def flavors(self, details=True):
flv = _flavor.FlavorDetail if details else _flavor.Flavor
return list(self._list(flv, paginated=True)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def flavors(self, **kwargs):\n raise NotImplementedError",
"def flavors(self, **query):\n return self._list(_flavor.Flavor, **query)",
"def flavors(self, **kwargs):\n if kwargs is None:\n result = self.get_list(self.cloudman.compute.flavors(),\n ... | [
"0.8162577",
"0.8091025",
"0.7936373",
"0.77149993",
"0.7508365",
"0.75026155",
"0.7392585",
"0.71951663",
"0.70461494",
"0.69983953",
"0.6945024",
"0.6797356",
"0.66096956",
"0.65740734",
"0.65690035",
"0.6423431",
"0.636852",
"0.62043095",
"0.6170371",
"0.6148227",
"0.61308... | 0.82144785 | 0 |
Reduce `value` across replicas. In `OneDeviceStrategy`, there is only one replica, so if axis=None, value is simply returned. If axis is specified as something other than None, such as axis=0, value is reduced along that axis and returned. | def reduce(self, reduce_op, value, axis): # pylint: disable=useless-super-delegation
return super(OneDeviceStrategy, self).reduce(reduce_op, value, axis) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _reduce(self, values):\n\n if self.dim is None:\n return values\n\n if isinstance(self.dim, str):\n dim = [self.dim]\n else:\n dim = self.dim\n\n if self.reduce_func is None:\n for d in values.dims:\n if d not in dim:\n ... | [
"0.65499896",
"0.5844143",
"0.54774225",
"0.5386483",
"0.5281023",
"0.5223725",
"0.52096236",
"0.5204711",
"0.5111603",
"0.50826293",
"0.50759596",
"0.50570375",
"0.50428176",
"0.49935594",
"0.49668908",
"0.49656737",
"0.49555114",
"0.48809808",
"0.48602632",
"0.48541635",
"0... | 0.6969084 | 0 |
Deserialize a json string into a record. | def deserialize_json(self, json_string):
return self._json_deserializer.from_json(json_string) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def from_json(cls, string):\n dct = json.loads(string)\n return cls.from_dict(dct)",
"def from_json_str(cls, json_str):\n return cls.from_json(simplejson.loads(json_str))",
"def from_json(cls, json_string:str):\n data = json.loads(json_string)\n validate(data, schema)\n in... | [
"0.73661613",
"0.7288288",
"0.72556204",
"0.71633255",
"0.7158838",
"0.70748484",
"0.70748484",
"0.70001185",
"0.69921964",
"0.69642997",
"0.69209135",
"0.68863696",
"0.68328375",
"0.68313986",
"0.6799468",
"0.6782272",
"0.6736741",
"0.6736741",
"0.6736741",
"0.670689",
"0.67... | 0.7326417 | 1 |
Serialize the provided record to a json string. | def serialize_to_json(self, record, pretty=False):
return self._json_serializer.to_json(record) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_json(self, record: Mapping[str, Any]) -> str:\n return self.json_lib.dumps(record, cls=ObjectEncoder)",
"def encode_record(record):\n return json.dumps(record)",
"def as_json(self) -> str:\n return json.dumps(self, cls=_RecordingJSONEncoder)",
"def _jsonify(self):\n return self... | [
"0.86904675",
"0.82909167",
"0.7377918",
"0.7208765",
"0.714593",
"0.7024267",
"0.6772957",
"0.6768682",
"0.6686019",
"0.6656075",
"0.65982586",
"0.6579808",
"0.6572477",
"0.6572477",
"0.6565103",
"0.65621084",
"0.65403545",
"0.65065384",
"0.65065384",
"0.65065384",
"0.650653... | 0.8402327 | 1 |
Records are deserialized into dicts. Every field value is deserialized based on it's schema. If a value is None, remove the key from the dict. | def _deserialize_record(self, schema, annotated_datum):
if not isinstance(annotated_datum, dict):
raise AvroTypeException(schema, annotated_datum)
result = {}
for field in schema.fields:
val = self._deserialize_data(field.type, annotated_datum.get(field.name))
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_null_fields(self):\n with open(self.schema_path, 'r') as file_obj:\n schema_data = yaml.safe_load(file_obj)\n schema_fields = schema_data.get('mapping').keys()\n for field in schema_fields:\n # We want to keep 'false' and 0 values, and avoid removing fields tha... | [
"0.677799",
"0.6556858",
"0.6460971",
"0.6361198",
"0.63543034",
"0.6258531",
"0.6254243",
"0.6033949",
"0.6006472",
"0.59355485",
"0.58489096",
"0.58462524",
"0.5840271",
"0.5839861",
"0.5817775",
"0.57366276",
"0.569283",
"0.5668188",
"0.5583587",
"0.5581457",
"0.55775857",... | 0.6332799 | 5 |
Get spectrum for a point source at `sky_coord` in `observation` Equivalent to point source photometry for isolated sources. For extended source, this will underestimate the actual source flux in every channel. In case of crowding, the resulting photometry is likely contaminated by neighbors. Yields the spectrum of a PS... | def get_psf_spectrum(sky_coord, observations):
if not hasattr(observations, "__iter__"):
observations = (observations,)
spectra = []
for obs in observations:
pixel = obs.frame.get_pixel(sky_coord)
index = np.round(pixel).astype(np.int)
psf = obs.frame.psf.get_model()
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_compact_source(\n sky_coord, frame, observations,\n):\n\n # get PSF-corrected center pixel spectrum\n spectrum = get_pixel_spectrum(sky_coord, observations, correct_psf=True)\n\n # position in frame coordinates\n center = frame.get_pixel(sky_coord)\n center_index = np.round(center).astyp... | [
"0.6342599",
"0.62005764",
"0.546012",
"0.49986172",
"0.49152887",
"0.4865297",
"0.48441795",
"0.4588716",
"0.4559841",
"0.45597166",
"0.44415948",
"0.43898666",
"0.43676534",
"0.4345639",
"0.4314768",
"0.42824453",
"0.42720845",
"0.42583585",
"0.425259",
"0.42157105",
"0.420... | 0.6839771 | 0 |
Converts a datetime instance to an HTTP date string. | def dt_to_http(dt):
# Tue, 15 Nov 1994 12:45:26 GMT
return dt.strftime('%a, %d %b %Y %H:%M:%S GMT') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def httpdate(date_obj):\n return date_obj.strftime(\"%a, %d %b %Y %H:%M:%S GMT\")",
"def http_date(d=None):\n if not d:\n d = datetime.datetime.utcnow()\n return d.strftime(\"%a, %d %b %Y %H:%M:%S GMT\")",
"def http_date(epoch_seconds=None):\n return formatdate(epoch_seconds, usegmt=True)",
... | [
"0.7713853",
"0.7332208",
"0.70437896",
"0.6922133",
"0.6747088",
"0.6668171",
"0.66501325",
"0.65764105",
"0.65757513",
"0.6552553",
"0.64978844",
"0.6476732",
"0.6476732",
"0.6463548",
"0.64511156",
"0.6350205",
"0.63386303",
"0.62687445",
"0.6252092",
"0.62239647",
"0.6220... | 0.7187551 | 2 |
Decay learning rate by a factor of 0.1 every lr_decay_epoch epochs. | def lr_scheduler(optimizer, epoch, init_lr=0.1, lr_decay_epoch=100):
if epoch % lr_decay_epoch == 0 and epoch > 1:
for param_group in optimizer.param_groups:
param_group['lr'] = param_group['lr'] * 0.1
return optimizer | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def step_decay(epoch):\n # initial_lrate = 1.0 # no longer needed\n #drop = 0.5\n #epochs_drop = number_epoch_drop\n #lrate = init_lr * math.pow(drop,\n #math.floor((1+epoch)/epochs_drop))\n lr = learning_rate\n if epoch >= 60:\n lr *= 1e-1\n print('Learning rate: ', lr)\n return ... | [
"0.8267032",
"0.817787",
"0.7811334",
"0.77599347",
"0.7718619",
"0.76941955",
"0.76941955",
"0.76048756",
"0.7584959",
"0.7552754",
"0.7523071",
"0.7496418",
"0.7490477",
"0.7466124",
"0.741067",
"0.73949176",
"0.73907655",
"0.73902607",
"0.7385446",
"0.7383554",
"0.7375278"... | 0.0 | -1 |
Converts dict with 1 or 2D np.ndarrays into DataFrame with 2level MultiIndex of (name, column index) where all values are 2D. | def DataFrame(dat):
keys = dat.keys()
l = []
for key in keys:
v = dat[key]
assert type(v) is np.ndarray and v.ndim <= 2 and v.ndim >= 1, \
'%s must be np.ndarray with 1 <= ndim <= 2 !' % key
if v.ndim == 1:
ix = pd.MultiIndex.from_product([[key]] + [[0]])
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_dataframe(self, dictionary_to_convert, cols):\n\n dataframe_converted = pd.DataFrame.from_dict(dictionary_to_convert, orient='index', columns = cols)\n dataframe_converted = dataframe_converted.reset_index()\n dataframe_converted = dataframe_converted.drop(columns=['index'])\n\n return dataf... | [
"0.64820296",
"0.6467414",
"0.6449887",
"0.6440341",
"0.64038",
"0.63855696",
"0.63684607",
"0.6338557",
"0.6273332",
"0.62182885",
"0.6172479",
"0.61613816",
"0.6125782",
"0.6124435",
"0.6068894",
"0.59901106",
"0.5937304",
"0.5926173",
"0.59152913",
"0.59100395",
"0.5894276... | 0.76058686 | 0 |
Permute last ndim_en of tensor v to the first | def permute2st(v, ndim_en=1):
nd = v.ndim
return v.transpose([*range(-ndim_en, 0)] + [*range(nd - ndim_en)]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def permute2en(v, ndim_st=1):\n nd = v.ndim\n return v.transpose([*range(ndim_st, nd)] + [*range(ndim_st)])",
"def permute(ts: Tensor, axes) -> Tensor:\n permute_op = PermuteOp(axes)\n return permute_op(ts, None)",
"def nprepeat_col(v: np.ndarray, n: int) -> np.ndarray:\n return np.repeat(v[:, n... | [
"0.7623115",
"0.59662473",
"0.5959169",
"0.5898509",
"0.5819368",
"0.58176833",
"0.58088595",
"0.5797371",
"0.57729113",
"0.57669604",
"0.57242614",
"0.5680608",
"0.5661869",
"0.56478035",
"0.5632521",
"0.56198776",
"0.5606073",
"0.55933654",
"0.5564315",
"0.555158",
"0.55243... | 0.76365453 | 0 |
Permute last ndim_en of tensor v to the first | def permute2en(v, ndim_st=1):
nd = v.ndim
return v.transpose([*range(ndim_st, nd)] + [*range(ndim_st)]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def permute2st(v, ndim_en=1):\n nd = v.ndim\n return v.transpose([*range(-ndim_en, 0)] + [*range(nd - ndim_en)])",
"def permute(ts: Tensor, axes) -> Tensor:\n permute_op = PermuteOp(axes)\n return permute_op(ts, None)",
"def nprepeat_col(v: np.ndarray, n: int) -> np.ndarray:\n return np.repeat(v... | [
"0.76367944",
"0.597025",
"0.5959497",
"0.5895297",
"0.5818711",
"0.5817098",
"0.5807277",
"0.5793939",
"0.577013",
"0.5763799",
"0.572054",
"0.5683351",
"0.5659322",
"0.56507766",
"0.56357646",
"0.562312",
"0.56086713",
"0.55932945",
"0.55618966",
"0.55534154",
"0.5524951",
... | 0.7622537 | 1 |
Quantile starting from 0. Array is flattened first. | def quantilize(v, n_quantile=5, return_summary=False, fallback_to_unique=True):
v = np.array(v)
if fallback_to_unique:
x, ix = uniquetol(v, return_inverse=True)
if (not fallback_to_unique) or len(x) > n_quantile:
n = v.size
ix = np.int32(np.ceil((stats.rankdata(v, method='ordi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def default_quantile():\n return np.logspace(-5, 0, 100)",
"def _process_quantiles(x, dim):\r\n x = np.asarray(x, dtype=float)\r\n\r\n if x.ndim == 0:\r\n x = x[np.newaxis]\r\n elif x.ndim == 1:\r\n if dim == 1:\r\n x = x[:, np.newaxis]\r\n else:\r\n x = x[n... | [
"0.6978719",
"0.695851",
"0.68486243",
"0.68089414",
"0.67864954",
"0.6656643",
"0.6599436",
"0.65406555",
"0.6499224",
"0.6445675",
"0.64453185",
"0.6440523",
"0.64031124",
"0.6378727",
"0.6378727",
"0.6378727",
"0.6352302",
"0.634383",
"0.6299707",
"0.6290659",
"0.625094",
... | 0.5626984 | 59 |
Circular variance = 1 length of the resultant vector. p is assumed to sum to 1 along dim, and is assumed to correspond to [0, 1/n, 2/n, ..., (n1)/n] 2 pi radian, where n = p.shape[dim] | def circvar_distrib(p: np.ndarray, dim=-1, keepdim=False) -> np.ndarray:
n = p.shape[dim]
th = vec_on(np.linspace(0., 1. - 1. / n, n), dim, p.ndim)
c = np.cos(th * 2. * np.pi)
s = np.sin(th * 2. * np.pi)
c1 = np.sum(p * c, dim, keepdims=keepdim)
s1 = np.sum(p * s, dim, keepdims=keepdim)
retu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def perp_vector(p, q, r):\n v = cross(q - r, q - p)\n return v / mod(v) + q",
"def calculate_variance(n, p):\n return p * (1 - p) / n",
"def nac_w_variance(r):\n if (r == 0):\n return 0\n else:\n return (1 - np.tanh(r) / r) * (r - np.tanh(r / 2)) * (1 / (2 * r))",
"def global_cov... | [
"0.64747906",
"0.6181501",
"0.59122",
"0.57438964",
"0.5688284",
"0.5669726",
"0.5563126",
"0.55509853",
"0.5525727",
"0.5524796",
"0.54997736",
"0.548221",
"0.5462976",
"0.54608697",
"0.54309666",
"0.54225516",
"0.53416914",
"0.53296477",
"0.53076845",
"0.52887464",
"0.52691... | 0.6595069 | 0 |
convert object arrays into arrays of v.flatten()[0].dtype | def cell2array(v: Union[nptyp.ArrayLike, Sequence]) -> np.ndarray:
if not isinstance(v, np.ndarray):
v = np.array(v)
shape = v.shape + v.flatten()[0].shape
v = v.flatten()
return np.stack([v1.astype(v[0].dtype) for v1 in v]).reshape(shape) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convert_array(self, v, t):\n return v.asnumpy()",
"def _asarray(v):\n try:\n return np.asarray(v)\n except ValueError:\n return np.asarray(v, dtype=object)",
"def convert_array(self, v, t):\n return interpreter.TensorValue(tvm.ndarray.array(v, self.context))",
"def deser... | [
"0.73833704",
"0.67619586",
"0.67222756",
"0.671945",
"0.67013395",
"0.6670719",
"0.6600655",
"0.65491354",
"0.6439471",
"0.64264256",
"0.63711953",
"0.63179934",
"0.6288179",
"0.62624216",
"0.6200096",
"0.61745286",
"0.61610997",
"0.6092813",
"0.60647464",
"0.60557204",
"0.6... | 0.6512258 | 8 |
Run f in parallel with meshgrid of inputs along each input's first dimension and return the expanded outputs. See demo_vectorize_par() for examples. Use np2.arrayobj1d(array) as an input, along with meshgrid_input=False, to enforce 1D input and output. If you get an error like __THE_PROCESS_HAS_FORKED_AND_YOU_CANNOT_US... | def vectorize_par(
f: Callable, inputs: Iterable,
pool: Pool = None, processes=None, chunksize=1,
nout=None, otypes: Union[Sequence[Type], Type] = None,
use_starmap=True, meshgrid_input=True,
) -> Tuple[Union[Mapping[Any, Any], np.ndarray, Sequence[Any]], ...]:
if isinstance(inputs, dict):
r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parfor(func, in_list, out_shape=None, n_jobs=-1, engine=\"joblib\",\n backend=\"threading\", func_args=[], func_kwargs={}):\n if n_jobs == -1:\n n_jobs = multiprocessing.cpu_count()\n n_jobs = n_jobs - 1\n\n if engine == \"joblib\":\n p = joblib.Parallel(n_jobs=n_jobs, back... | [
"0.64849424",
"0.62994325",
"0.61680865",
"0.61379546",
"0.604238",
"0.5956376",
"0.59559816",
"0.5936612",
"0.5922286",
"0.58798885",
"0.5764644",
"0.57521546",
"0.57034993",
"0.5699877",
"0.56866086",
"0.5682758",
"0.56609267",
"0.56314003",
"0.5611092",
"0.5580291",
"0.556... | 0.7485692 | 0 |
Get a list of all APIprovided styles which are not yet mapped | def unmapped(self, request):
queryset = Beer.objects.exclude(
api_vendor_style__in=Subquery(
models.TapListProviderStyleMapping.objects.values(
'provider_style_name',
),
),
).values('api_vendor_style').distinct()
return ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def std_styles(self):\n return [DXFEngine.style(name, font=f) for name, f in std.styles() ]",
"def getStyles(self):\r\n return self.styles",
"def get_styles(u):\n stat, ds_request = u.request(method = 'GET',\n path = 'rest/styles.json',\n pay... | [
"0.69718194",
"0.68190813",
"0.6728004",
"0.66616017",
"0.6561181",
"0.606006",
"0.5961343",
"0.59115165",
"0.5906456",
"0.5860419",
"0.5854782",
"0.57972246",
"0.57808274",
"0.5763052",
"0.5748301",
"0.5714286",
"0.5706808",
"0.56944966",
"0.5691365",
"0.5662225",
"0.5542509... | 0.6423049 | 5 |
Split text in list of phrase | def splitInPhrase(self,text):
return self._support.splitInPhrase(text) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def split(text):\n doc = nlp(text)\n sentences = [x.text_with_ws for x in doc.sents]\n return sentences",
"def splitInSentence(self,text):\n return self._support.splitInPhrase(text)",
"def split_sentences(text: str) -> List[str]:\n return sent_tokenize(text)",
"def split_wo... | [
"0.7497834",
"0.7398664",
"0.72781366",
"0.71476",
"0.7111505",
"0.70786947",
"0.6990575",
"0.69830275",
"0.6918834",
"0.68000585",
"0.679357",
"0.67560184",
"0.6747853",
"0.6741868",
"0.67308164",
"0.67218643",
"0.672159",
"0.6704256",
"0.66543514",
"0.6647406",
"0.6642784",... | 0.7886572 | 0 |
Remove all stop words, the stops words are found in file stopWords | def removeStopWords(self,phrase):
if("stopWord" in self._classes):
return self._stopWord.removeStopWord(phrase) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rm_stopwords(file_path, word_dict):\n\n # read stop word dict and save in stop_dict\n stop_dict = {}\n with open(word_dict) as d:\n for word in d:\n stop_dict[word.strip(\"\\n\")] = 1\n # remove tmp file if exists\n if os.path.exists(file_path + \".tmp\"):\n os.remove(fi... | [
"0.79110277",
"0.78750706",
"0.7869787",
"0.78620666",
"0.77896464",
"0.77511376",
"0.7654372",
"0.7624255",
"0.76038593",
"0.7567821",
"0.75662535",
"0.75530076",
"0.75314283",
"0.75314283",
"0.75314283",
"0.75314283",
"0.75224894",
"0.75080645",
"0.7507103",
"0.75063217",
"... | 0.6799327 | 72 |
True if has been modified | def is_modified(filename, file_mod_time):
return os.path.exists(filename) and file_mod_time != os.path.getmtime(filename) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_modified(self) -> bool:\n return bool(self._modified)",
"def is_modified(self):\n return len(self.modified_fields) > 0",
"def has_been_modified(self):\n return self._has_been_modified",
"def isDirty(self):\n\t#@DEBUG christophe have to fix denoising optionnal issue prior to set... | [
"0.81744564",
"0.7981893",
"0.7867308",
"0.78334576",
"0.75799304",
"0.7573073",
"0.7536009",
"0.7535478",
"0.75141275",
"0.74929947",
"0.7437154",
"0.742234",
"0.7402752",
"0.73563343",
"0.732903",
"0.7328915",
"0.731857",
"0.7317162",
"0.7267117",
"0.7219847",
"0.7203871",
... | 0.0 | -1 |
Return a string that represents this block. | def __str__(self):
return 'MLBlock - {}'.format(self.name) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __str__(self):\r\n return (str(self.blockNum) + \" \" + str(self.coords))",
"def __str__(self):\n return_string = \"Block Number: {}\\nTimestamp: {}\\nDifficulty: {}\\nNonce: {}\\nPrevious Hash: {}\\nMerkle Root \" \\\n \"Hash: {}\\n\".format(self.block_number, self.times... | [
"0.7361766",
"0.72424126",
"0.7202666",
"0.7164559",
"0.7129507",
"0.7001096",
"0.6944876",
"0.69135505",
"0.6818379",
"0.6772175",
"0.6772175",
"0.6772175",
"0.6763517",
"0.67375344",
"0.6714563",
"0.6625147",
"0.66039515",
"0.65673274",
"0.65442365",
"0.65442365",
"0.654423... | 0.7779626 | 0 |
Return a printable representation of the TLV object. See `TLV.__repr__()` for more information. | def __repr__(self):
return "PortIdTLV(" + repr(self.subtype) + ", " + repr(self.value) + ")" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __repr__(self):\n return \"PortDescriptionTLV(\" + repr(self.value) + \")\"",
"def __repr__(self):\n return \"SystemDescriptionTLV(\" + repr(self.value) + \")\"",
"def __repr__(self):\n return \"SystemNameTLV(\" + repr(self.value) + \")\"",
"def __repr__ (self):\n\t\tStr = \"\"\n\t\t... | [
"0.70692617",
"0.6986607",
"0.6928978",
"0.6383552",
"0.6234387",
"0.6219421",
"0.62085736",
"0.6201015",
"0.6113969",
"0.607938",
"0.6075122",
"0.6074956",
"0.6071525",
"0.6063966",
"0.60575783",
"0.60532314",
"0.60364604",
"0.60299855",
"0.60267687",
"0.60267687",
"0.602191... | 0.7246423 | 0 |
Replace all tags in the cache with the given collection. tags should be a collection of (id, name, desc) tuples. | def replace_all_tags(tags):
with postgres, postgres.cursor() as cur:
cur.execute("truncate mustard.tags");
psycopg2.extras.execute_values(cur,
"insert into mustard.tags (id, english_name, english_desc) values %s",
tags)
cur.execute("update mustard.status set tags_updated = now()") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tags(self, tags):\n\n self._tags = tags",
"def tags(self, tags):\n\n self._tags = tags",
"def tags(self, tags):\n\n self._tags = tags",
"def tags(self, tags):\n\n self._tags = tags",
"def tags(self, tags):\n\n self._tags = tags",
"def tags(self, tags):\n\n se... | [
"0.60102594",
"0.60102594",
"0.60102594",
"0.60102594",
"0.60102594",
"0.60102594",
"0.60102594",
"0.60102594",
"0.60102594",
"0.60102594",
"0.6001482",
"0.5974982",
"0.5974982",
"0.5974982",
"0.58648616",
"0.5780452",
"0.5772083",
"0.57190984",
"0.56708807",
"0.5657332",
"0.... | 0.6118948 | 0 |
The primary value associated with the parsed data. | def value(self) -> ParsedT:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_value(self, data):\n value = data['value']\n return value",
"def value(self):\r\n return self._data['value']",
"def value(self):\n return self.get_data(\"value\")",
"def _value(self):\n if self.data is None:\n return self._original_value\n elif sel... | [
"0.6921919",
"0.669995",
"0.66521835",
"0.6582425",
"0.6516001",
"0.6506979",
"0.65048724",
"0.6436209",
"0.64144915",
"0.64029324",
"0.63953066",
"0.6377803",
"0.63697875",
"0.63655865",
"0.6360935",
"0.63588023",
"0.63195723",
"0.63195723",
"0.63087213",
"0.6306354",
"0.630... | 0.0 | -1 |
Adds subnet CIDR to `subnets` if it's not there | def rule_40_extend_subnet_cidr(session):
config, conn = session["config"], session["conn"]
def append_cidr(config_side, conn_vpc):
cidr = conn_vpc.get_all_subnets([
config_side["res"]["subnet_id"]
])[0].cidr_block
for user_cidr in config_side["ipsec"]["subnets"]:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def subnets(self, subnets):\n\n self._subnets = subnets",
"def subnets(self) -> Optional[pulumi.Input[Sequence[pulumi.Input['ResourceIdArgs']]]]:\n return pulumi.get(self, \"subnets\")",
"def subnets(self) -> Optional[pulumi.Input[Sequence[pulumi.Input[str]]]]:\n return pulumi.get(self, \"... | [
"0.65587884",
"0.6554208",
"0.6517296",
"0.6477895",
"0.64118046",
"0.630475",
"0.6242727",
"0.6223621",
"0.6219066",
"0.6200233",
"0.6163743",
"0.6142352",
"0.6137879",
"0.6135572",
"0.6126134",
"0.61213744",
"0.61082613",
"0.60970885",
"0.60804445",
"0.6003785",
"0.5991626"... | 0.64780617 | 3 |
Logistic regression using gradient descent | def logistic_regression(y, tx, initial_w, max_iters, gamma, SGD=False, batch_size=-1) :
w_start = initial_w
w = w_start
loss_old = 0.0
for n_iter in range(max_iters):
loss = compute_logistic_loss(y, tx, w)
gradient = compute_logistic_gradient(y, tx, w)
w = w - gamma * gradient
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def logistic_regression(y, tx, initial_w, max_iters, gamma, verbose=False):\n return gradient_descent(y, tx, initial_w, max_iters, gamma, \n compute_logistic_loss, compute_logistic_gradient, verbose=verbose)",
"def logit_cost_grad(self, theta, X, y):\n\n grad = np.zeros(len(t... | [
"0.7806816",
"0.7683251",
"0.76300657",
"0.755224",
"0.7487062",
"0.7340621",
"0.7301625",
"0.7280634",
"0.7277446",
"0.7258249",
"0.7253478",
"0.7249984",
"0.7247254",
"0.7238215",
"0.7232508",
"0.7188665",
"0.71744543",
"0.7170769",
"0.7136113",
"0.7134905",
"0.7132616",
... | 0.715796 | 18 |
Discard stdout (i.e. write to null device) or optionally write to given filelike object. | def silence(file_object=None):
if file_object is None:
file_object = open(os.devnull, 'w')
old_stdout = sys.stdout
try:
sys.stdout = file_object
yield
finally:
sys.stdout = old_stdout | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def suppress_stdout():\n original_stdout = sys.stdout\n sys.stdout = open(os.devnull, 'w')\n yield\n sys.stdout.close()\n sys.stdout = original_stdout",
"def suppress(self):\n with open(os.devnull, \"w\") as devnull:\n osout = sys.stdout\n sys.stdout = devnull\n ... | [
"0.6170332",
"0.615873",
"0.615218",
"0.58471596",
"0.5734382",
"0.57039547",
"0.55149066",
"0.5513777",
"0.53469884",
"0.53363186",
"0.5331979",
"0.5330783",
"0.5262583",
"0.5251293",
"0.5246196",
"0.51960766",
"0.5139911",
"0.5109161",
"0.50373137",
"0.4990873",
"0.49789912... | 0.6976567 | 0 |
Export the array as an integer, which can be used later to access index. You can access any index by (array >> SHIFT_RIGHT_X_BITS) & ((1 << BITS) 1) | def export(self):
n = 0
pushed = 0
for i in self.data:
if i.is_null:
break
n |= i.value << pushed
pushed += i.max_bits
return n | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_integer_from(bool_array: List[bool]) -> int:\n return_value = 0\n for i in range(0, MAX_BIT_LENGTH - 1):\n return_value |= (1 << i) if bool_array[i] else 0\n return return_value",
"def recursive_index_decode(int_array, max=32767, min=-32768):\n out_arr = []\n decoded_val = 0\n fo... | [
"0.58742857",
"0.5816403",
"0.56263757",
"0.54573166",
"0.5456624",
"0.5433063",
"0.53819877",
"0.5377201",
"0.53712153",
"0.5365168",
"0.53407836",
"0.5334036",
"0.52952635",
"0.5225554",
"0.5202124",
"0.51853746",
"0.51842684",
"0.5172125",
"0.516975",
"0.5155031",
"0.51414... | 0.50767606 | 24 |
Get the left side of the grid. | def get_left_side(grid):
right = int(grid.width / 2)
left_side = Grid(
grid=grid, crop=Crop(left=0, right=right, top=0, bottom=0))
left_side.find_grid_lines()
left_side.vert_insert_line(0, distance=-80)
left_side.get_cells()
left_side.get_row_labels()
return left_side | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def left(self):\n x, y = (self.loc[0] - 1, self.loc[1])\n\n if x < 0:\n return None # None\n\n return self.garden.cells[y][x]",
"def getLeft(self):\n return self.left",
"def left(self):\n return self.points['topLeft'].x",
"def left(self):\n return self.po... | [
"0.8008214",
"0.7496677",
"0.74735487",
"0.74735487",
"0.7342526",
"0.7317307",
"0.72882146",
"0.72631836",
"0.7165834",
"0.7083153",
"0.7072821",
"0.6997166",
"0.69850814",
"0.69850814",
"0.6979697",
"0.6976821",
"0.69732606",
"0.69189125",
"0.6853326",
"0.6850248",
"0.67746... | 0.8825382 | 0 |
Load settings from a yaml file. | def load_persistent_settings(path):
settings = {}
if path.exists():
with open(path, "r") as f:
persistent = yaml.load(f)
if persistent:
settings.update(persistent)
return settings | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load(self, file):\n self.__log(f'Starting to load settings from {file}', 'warning')\n contents = load_yaml(file)\n for item in contents:\n if item == 'options':\n self.__log(f'Found options in {file}, loading them', 'warning')\n for i in contents[it... | [
"0.7866566",
"0.75181365",
"0.7386355",
"0.7378116",
"0.7356894",
"0.73331743",
"0.72779673",
"0.72596663",
"0.72180146",
"0.71789515",
"0.71264505",
"0.7118496",
"0.7109579",
"0.710947",
"0.7098261",
"0.70973206",
"0.70846194",
"0.70825106",
"0.7076435",
"0.7062472",
"0.7052... | 0.6522323 | 86 |
Test whether the ranges are not equal. | def __ne__(self, other):
try:
self._check_title(other)
except ValueError:
return True
return (
other.min_row != self.min_row
or self.max_row != other.max_row
or other.min_col != self.min_col
or self.max_col != other.max_col... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_unequality(self):\n self.assertFalse(Record(1, 2) != Record(1, 2))\n self.assertTrue(Record(1, 2) != Record(1, 3))\n self.assertTrue(Record(1, 2) != Record(2, 2))\n self.assertTrue(Record(1, 2) != Record(3, 4))",
"def are_not_equal(value1, value2):\n return not ObjectC... | [
"0.667366",
"0.66572547",
"0.64324784",
"0.6354575",
"0.6335398",
"0.6333553",
"0.6327267",
"0.63267684",
"0.63244444",
"0.63053644",
"0.6278204",
"0.6256689",
"0.6256177",
"0.6252188",
"0.6246045",
"0.62222344",
"0.62143415",
"0.6209268",
"0.6208924",
"0.6192214",
"0.6188057... | 0.6383879 | 3 |
Return ``True`` if the range has no elements in common with other. Ranges are disjoint if and only if their intersection is the empty range. | def isdisjoint(self, other):
self._check_title(other)
# sort by top-left vertex
if self.bounds > other.bounds:
i = self
self = other
other = i
return (self.max_col, self.max_row) < (other.min_col, other.max_row) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isdisjoint(self, other: Union[Rangelike, Iterable[Rangelike]]) -> bool:\n # convert to RangeSet\n other = RangeSet._to_rangeset(other)\n # O(n^2) comparison\n # TODO improve efficiency by mergesort/short-circuiting\n return all(rng1.isdisjoint(rng2) for rng1 in self._ranges f... | [
"0.7895135",
"0.7882997",
"0.7341286",
"0.72247195",
"0.71013904",
"0.69204265",
"0.6867103",
"0.6737981",
"0.6662065",
"0.6628665",
"0.6551233",
"0.6466774",
"0.6455735",
"0.6455663",
"0.64100254",
"0.6401096",
"0.63920355",
"0.6370906",
"0.6358321",
"0.6334969",
"0.633048",... | 0.62241095 | 26 |
Found if a position is safe or atacked by other Queen | def isSafe(board, row, col, n):
""" veriying the row on left side """
for i in range(col):
if board[row][i] == 1:
return False
""" veriying upper diagonal on left side """
for i,j in zip(range(row,-1,-1), range(col,-1,-1)):
if board[i][j] == 1:
return False
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_queen_attacked(x1, y1, x2, y2):\n attacked_fields = queen_attack(x1, y1)\n second_queen_position = [x2, y2]\n if second_queen_position in attacked_fields:\n return True\n return False",
"def can_attack(self, aq: object) -> bool:\n if self.row == aq.row and self.column == aq.colum... | [
"0.7220475",
"0.65940225",
"0.654497",
"0.6343221",
"0.6315509",
"0.62895334",
"0.62539554",
"0.61632097",
"0.6153741",
"0.61339235",
"0.6112998",
"0.6099076",
"0.60610545",
"0.60534215",
"0.60377926",
"0.6021167",
"0.6005671",
"0.6002714",
"0.60024583",
"0.5991882",
"0.59850... | 0.0 | -1 |
Queries and returns a player who is sending a card to the discard pile. | def indicate_discard_card(whose_turn,players):
cards_to_choose_from = players[whose_turn].hand.cards
players[whose_turn].hand.print_cards()
chosen_to_discard = int(input('Select a card to discard. Type a number. '))
return chosen_to_discard | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def player_card(self):\n card = random.choice(self.hand.cards)\n self.hand.cards.remove(card)\n print(f\"{self.name}:{card!r:<3} \", end=\"\")\n return card",
"def discard(self):\n # Would need more logic...\n # Should be specified, won't use in 'war'\n return sel... | [
"0.6640066",
"0.6235302",
"0.61671466",
"0.6153342",
"0.6145789",
"0.61096895",
"0.61080736",
"0.60347116",
"0.5985957",
"0.58938724",
"0.5879169",
"0.58719957",
"0.58469254",
"0.58398753",
"0.5788006",
"0.5780579",
"0.57238597",
"0.5695369",
"0.5688318",
"0.56730545",
"0.566... | 0.6516594 | 1 |
Convert MAC address from binary to string. | def bytes_to_mac_str(buff):
if len(buff) != DataDescription.B_SEQ_MAC_LEN:
raise TypeError("Invalid input")
return "%02X:%02X:%02X:%02X:%02X:%02X" % buff | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mac_ntoa(mac):\n return '%.2x:%.2x:%.2x:%.2x:%.2x:%.2x' % tuple(map(ord, list(mac)))",
"def mac_aton(str):\n macbytes = [int(i, 16) for i in str.split(':')]\n return struct.pack('6B', *macbytes)",
"def get_mac_string():\n mac_int = getnode()\n mac_str = ':'.join((\"%012x\" % mac_int)[i:i + 2] f... | [
"0.7306157",
"0.7243065",
"0.7233606",
"0.71241945",
"0.7091124",
"0.699399",
"0.6909801",
"0.6861011",
"0.6823753",
"0.6784645",
"0.678168",
"0.678168",
"0.678168",
"0.678168",
"0.671803",
"0.67102516",
"0.67028487",
"0.65724105",
"0.63206655",
"0.6312491",
"0.6287714",
"0... | 0.74490213 | 0 |
Convert MAC address from string to binary format. | def mac_to_tuple_of_bytes(value):
if not isinstance(value, basestring):
Convert.logger.warn(
"Failed - expect string value '%s', received type '%s'",
value, type(value))
return None
try:
new_value = []
for item in value.spl... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mac_aton(str):\n macbytes = [int(i, 16) for i in str.split(':')]\n return struct.pack('6B', *macbytes)",
"def mac_pton(s):\n return binascii.unhexlify(s.replace(\":\", \"\"))",
"def bytes_to_mac_str(buff):\n if len(buff) != DataDescription.B_SEQ_MAC_LEN:\n raise TypeError(\"Invalid... | [
"0.7997964",
"0.6975739",
"0.6787054",
"0.666748",
"0.6449225",
"0.64451766",
"0.64179796",
"0.64129966",
"0.63917625",
"0.6382136",
"0.6344773",
"0.6226473",
"0.6226473",
"0.6226473",
"0.6226473",
"0.61442584",
"0.61230683",
"0.6067114",
"0.60551107",
"0.5998103",
"0.5936193... | 0.59579927 | 20 |
from timestamp to utc string. | def pack_timestamp_to_string(timestamp):
dt = datetime.utcfromtimestamp(timestamp)
return pack("!HBBBBBB", dt.year, dt.month, dt.day, dt.hour,
dt.minute, dt.second, dt.microsecond / 100000) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def timestamptostr(ts):\n return datetimetostr(utcfromtimestamp(ts))",
"def convertToUsersTimeZone(self, timestamp):\n user = self.zport.dmd.ZenUsers.getUserSettings()\n if user.timezone:\n utc_dt = pytz.utc.localize(datetime.utcfromtimestamp(int(timestamp)))\n tz = pytz.ti... | [
"0.7502774",
"0.7266336",
"0.7096135",
"0.69645643",
"0.6952461",
"0.6952461",
"0.6952461",
"0.6896272",
"0.68772167",
"0.6833872",
"0.6810736",
"0.680625",
"0.6790773",
"0.67586875",
"0.674915",
"0.6747772",
"0.67431664",
"0.67257255",
"0.667348",
"0.66647536",
"0.664801",
... | 0.6209548 | 48 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.