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 |
|---|---|---|---|---|---|---|
Gets the updated_at of this CertificateIssuerConfigResponse. Updated UTC time RFC3339. | def updated_at(self):
return self._updated_at | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def updated_at(self) -> str:\n return pulumi.get(self, \"updated_at\")",
"def updated_at(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"updated_at\")",
"def updated_at(self) -> \"datetime\":\n return self._attrs.get(\"updatedAt\")",
"def updated_at(self) -> \"datetime\":\n ... | [
"0.73506427",
"0.715898",
"0.7100679",
"0.7100679",
"0.7100679",
"0.7018171",
"0.6888015",
"0.68220514",
"0.6803116",
"0.63659805",
"0.63659805",
"0.6330348",
"0.63060933",
"0.61930877",
"0.6183297",
"0.6172325",
"0.6172325",
"0.6172325",
"0.6103981",
"0.6070368",
"0.6070368"... | 0.71472675 | 4 |
Sets the updated_at of this CertificateIssuerConfigResponse. Updated UTC time RFC3339. | def updated_at(self, updated_at):
self._updated_at = updated_at | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def updated_at(self, updated_at: \"datetime\"):\n self._attrs[\"updatedAt\"] = updated_at",
"def updated_at(self, updated_at: \"datetime\"):\n self._attrs[\"updatedAt\"] = updated_at",
"def updated_at(self, updated_at: \"datetime\"):\n self._attrs[\"updatedAt\"] = updated_at",
"def updat... | [
"0.694067",
"0.694067",
"0.694067",
"0.6891271",
"0.5975634",
"0.5975634",
"0.5975634",
"0.5853229",
"0.58427864",
"0.5759983",
"0.5759983",
"0.5759983",
"0.5637823",
"0.5634766",
"0.555831",
"0.555831",
"0.5553483",
"0.55533445",
"0.5480445",
"0.5391885",
"0.5391885",
"0.5... | 0.671559 | 10 |
Returns true if both objects are equal | def __eq__(self, other):
if not isinstance(other, CertificateIssuerConfigResponse):
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.8088132",
"0.8088132",
"0.8054589",
"0.7982687",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
... | 0.0 | -1 |
Returns true if both objects are not equal | def __ne__(self, other):
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 |
Parse json contents of string or file object or file path and return python nested dict/lists | def read_json(file_or_path):
try:
with (open(file_or_path, 'r') if isinstance(file_or_path, (str, bytes)) else file_or_path) as f:
obj = json.load(f)
except IOError:
obj = json.loads(file_or_path)
return obj | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_json(file: str) -> Union[Dict, List]:\n\n with open(file, 'r') as f:\n return json.load(f)",
"def parse(content):\n return json.loads(content)",
"def parse_json(json_path):\n with open(json_path, 'r') as f:\n out = json.load(f)\n return out",
"def parse_json_from_path(self... | [
"0.69833916",
"0.6981901",
"0.6813848",
"0.68020767",
"0.66726",
"0.6618895",
"0.66178703",
"0.6576203",
"0.6557808",
"0.65109396",
"0.6482295",
"0.64803284",
"0.64774996",
"0.645726",
"0.6433491",
"0.64215857",
"0.64088345",
"0.63850725",
"0.63476187",
"0.63388616",
"0.63352... | 0.5977701 | 81 |
Create and configure a new app instance for each test. | def application():
configure_app(app)
yield app | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_app():\n param = {\n 'DEBUG': True,\n 'TESTING': True\n }\n _app = create_app(settings_override=param)\n\n ctx = _app.app_context()\n ctx.push()\n yield _app\n ctx.pop()",
"def create_app(self):\n app.config.from_object('config.TestingConfig')\n return ap... | [
"0.7984731",
"0.7973278",
"0.7952626",
"0.7774617",
"0.7610121",
"0.75586873",
"0.7514867",
"0.748489",
"0.7457632",
"0.7457632",
"0.7457632",
"0.7423435",
"0.74221593",
"0.7392862",
"0.7378533",
"0.73515075",
"0.7331986",
"0.7303747",
"0.7297693",
"0.7282327",
"0.7275915",
... | 0.0 | -1 |
This method loads single quoted JSON data. Regular JSON expects double quotes. | def load_tweets_backup(filename):
try:
with open(filename, 'r') as f:
data = ast.literal_eval(f.read())
except:
print('ERROR in load_tweets_backup.')
return data | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_json_str(self, json_text: str):\n\n self.data = json.loads(json_text)",
"def load_json(self):\n\n self.load_json_str(self.get_json_str())",
"def loads(s, **kwargs):\n return json.loads(uncomment(s), **kwargs)",
"def load_json(json_string):\n return json.loads(json_string)",
"de... | [
"0.6823782",
"0.66725",
"0.66355604",
"0.6598095",
"0.65581",
"0.64663523",
"0.63912237",
"0.6387891",
"0.6383104",
"0.6369684",
"0.63369566",
"0.6322721",
"0.6294473",
"0.626813",
"0.6236858",
"0.6158787",
"0.6148142",
"0.610176",
"0.60993975",
"0.6071879",
"0.60679597",
"... | 0.0 | -1 |
Repeat a string or unicode. Note that this assumes that 'mul' > 0. | def string_repeat(s, mul):
result = None
factor = 1
assert mul > 0
limit = mul >> 1
while True:
if mul & factor:
if result is None:
result = s
else:
result = s + result
if factor > limit:
break
s += s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def repeat(s):\r\n\r\n return s",
"def repeat_string_n_times(string, count):\r\n return string * int(count)",
"def repeat(word, repetitions):\n return word * repetitions",
"def repeat(s, exclaim):\n\n result = s*3\n\n if exclaim:\n result = result + '!!!'\n\n return result",
"d... | [
"0.7310655",
"0.6922782",
"0.69223285",
"0.68544596",
"0.6760396",
"0.65352315",
"0.6488594",
"0.63779044",
"0.62650377",
"0.62292916",
"0.61778146",
"0.60747796",
"0.597115",
"0.5962785",
"0.5887884",
"0.5881692",
"0.586663",
"0.58591336",
"0.5817762",
"0.574391",
"0.5726259... | 0.80343235 | 0 |
Creates the initial hidden and cell states for the decoder's LSTM based on the encoded images. | def init_hidden_state(self, batch_size):
h = torch.zeros(batch_size, self.decoder_dim).to(device) # (batch_size, decoder_dim)
c = torch.zeros(batch_size, self.decoder_dim).to(device)
return h, c | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize_decoder_states(self, memory):\n\n B = memory.size(0)\n\n self.attention_hidden = Variable(memory.data.new(\n B, hparams.decoder_lstm_dim).zero_())\n self.attention_cell = Variable(memory.data.new(\n B, hparams.decoder_lstm_dim).zero_())\n\n self.deco... | [
"0.6975042",
"0.6901735",
"0.67877775",
"0.6781514",
"0.6678807",
"0.6639256",
"0.663141",
"0.6551407",
"0.64969134",
"0.64087147",
"0.63737124",
"0.6342426",
"0.632464",
"0.6303485",
"0.6302927",
"0.6292375",
"0.6287289",
"0.6264216",
"0.6244336",
"0.6208146",
"0.61865085",
... | 0.65343064 | 10 |
Determines whether this UasTelemetry is equivalent to another. This differs from the Django __eq__() method which simply compares primary keys. This method compares the field values. | def duplicate(self, other):
return (self.uas_position.duplicate(other.uas_position) and
self.uas_heading == other.uas_heading) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __eq__(self, other):\n\n try:\n return self.raw_field == other.raw_field\n except AttributeError:\n return False",
"def __eq__(self, other: 'StorageRecord') -> bool:\n\n return self.type == other.type and self.id == other.id and self.value == other.value and self.ta... | [
"0.7515961",
"0.7406073",
"0.73793536",
"0.73394936",
"0.7316688",
"0.7292974",
"0.726842",
"0.72569215",
"0.7249255",
"0.7196512",
"0.7195537",
"0.71878946",
"0.71592134",
"0.7154364",
"0.7146037",
"0.713802",
"0.7133125",
"0.71040404",
"0.70799816",
"0.70745766",
"0.7072809... | 0.0 | -1 |
Sets the name of this TripRequestResponseJourneyLegPathDescription. | def name(self, name):
self._name = name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setPath(self, name, value):\n response = self.extendPath(name, value, True, True)\n return response",
"def set_res_name(self, res_name):\n assert isinstance(res_name, str)\n for atm in self.iter_alt_loc():\n atm.res_name = res_name",
"def set_name(self, name: str) -> ... | [
"0.5583948",
"0.544036",
"0.5121346",
"0.49790826",
"0.49696904",
"0.49466002",
"0.49463606",
"0.49327672",
"0.48889735",
"0.48875338",
"0.48683396",
"0.48683396",
"0.4863583",
"0.4863583",
"0.4863583",
"0.4863583",
"0.4856975",
"0.4856975",
"0.4856975",
"0.4856975",
"0.48569... | 0.0 | -1 |
Sets the cum_distance of this TripRequestResponseJourneyLegPathDescription. | def cum_distance(self, cum_distance):
self._cum_distance = cum_distance | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cum_duration(self, cum_duration):\n\n self._cum_duration = cum_duration",
"def distance_down(self, distance_down):\n\n self._distance_down = distance_down",
"def from_cumulative(self, cumulative):\n return self._dist_cls.from_cumulative(self._edges, cumulative)",
"def setAboveDistanc... | [
"0.5975861",
"0.47773686",
"0.45074475",
"0.43782586",
"0.42682508",
"0.42238513",
"0.41836348",
"0.41769943",
"0.41422468",
"0.41351217",
"0.40921238",
"0.4085998",
"0.40513286",
"0.4046183",
"0.4044072",
"0.4000373",
"0.39987105",
"0.39613968",
"0.39522165",
"0.3892229",
"0... | 0.746701 | 0 |
Returns true if both objects are equal | def __eq__(self, other):
if not isinstance(other, TripRequestResponseJourneyLegPathDescription):
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.8088132",
"0.8088132",
"0.8054589",
"0.7982687",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
... | 0.0 | -1 |
Returns true if both objects are not equal | def __ne__(self, other):
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 |
retourne la distance quadratique entre vec1 et vec2 | def squaredDistance(vec1, vec2):
return (distance.euclidean(vec1, vec2))**2 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _vector_dist(self, vec1, vec2):\r\n return sqrt(sum([(float(v1) - float(v2)) ** 2 for v1, v2 in\r\n zip(vec1, vec2)]))",
"def dist(v1: vect2d, v2: vect2d) -> float:\n d = ((v2.x - v1.x)**2 + (v2.y - v1.y)**2) ** 0.5\n return d",
"def dist4(a,b): # compute distance betw... | [
"0.78222024",
"0.7592095",
"0.7233088",
"0.7194678",
"0.7156333",
"0.7123794",
"0.71145225",
"0.70520526",
"0.7016162",
"0.7010722",
"0.70031416",
"0.69947135",
"0.69702244",
"0.69496596",
"0.693915",
"0.69019765",
"0.6890305",
"0.68726665",
"0.6866751",
"0.6865381",
"0.68477... | 0.66780293 | 54 |
Computes the precision for the specified values of k | def accuracy_topk(output, target, topk=(5,10)):
maxk = max(topk)
batch_size = target.size(0)
_, pred = output.topk(maxk, 1, True, True)
pred = pred.t()
correct = pred.eq(target.view(1, -1).expand_as(pred))
res = []
for k in topk:
correct_k = correct[:k].view(-1).float().sum(0, keep... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def precision(gt, pred, k):\n k = min(len(pred), k)\n den = min(len(gt), k)\n return sum([int(pred[i] in gt) for i in range(k)]) / den",
"def precision_at_k(r, k):\n assert k >= 1\n r = np.asarray(r)[:k] != 0\n if r.size != k:\n raise ValueError('Relevance score length < k')\... | [
"0.76427615",
"0.74189496",
"0.7418079",
"0.72710466",
"0.72456723",
"0.72446615",
"0.7237539",
"0.72213703",
"0.7210107",
"0.7058935",
"0.6852219",
"0.6786084",
"0.67836976",
"0.6768417",
"0.67273885",
"0.67181736",
"0.67181736",
"0.67181736",
"0.67181736",
"0.67181736",
"0.... | 0.0 | -1 |
Create a normalized and zero padded version of vector. | def fix_norm_and_length(vector):
# normalize
norm_vector = vector / np.linalg.norm(vector)
# pad with zeros
num_bits = get_bits_needed(len(vector))
state_vector = np.zeros(2 ** num_bits, dtype=complex)
for i in range(len(vector)):
state_vector[i] = norm_vector[i]
return state_vecto... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_normalized_vector(vector):\n # WARN: Zero length may cause problems!\n vector_lenght = get_vector_length(vector)\n if vector_lenght != 0:\n return np.divide(vector, get_vector_length(vector))\n else:\n return [0, 0]",
"def normalize(vec):\n return vec / length(vec)",
"def u... | [
"0.70246047",
"0.70194066",
"0.6918075",
"0.68365806",
"0.6820238",
"0.67836416",
"0.67591155",
"0.67064404",
"0.67064404",
"0.67064404",
"0.67030865",
"0.6667601",
"0.6667601",
"0.6667601",
"0.6667601",
"0.6667601",
"0.6667601",
"0.6667601",
"0.6667601",
"0.6667601",
"0.6667... | 0.67405796 | 7 |
Find all code blocks in a markdown file. From a list of strings describing the lines in a markdown file, find a list of the start and end line numbers for each of the code blocks. | def locate_code_blocks(lines):
stripped_lines = [l.strip() for l in lines]
code_block_indexes = [i for i, l in enumerate(stripped_lines,1) if l.startswith('```')]
nblock_indexes = len(code_block_indexes)
assert nblock_indexes % 2 == 0
return [b for b in zip(code_block_indexes[::2], code_block_indexe... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extract_blocks(lines):\n py_block = False\n block = []\n for line in lines:\n # start of py block\n if line.strip() == '```python':\n py_block = True\n if block:\n yield block, 'md'\n block = []\n\n # exiting py block\n el... | [
"0.67364955",
"0.6414372",
"0.62196326",
"0.62039214",
"0.6171617",
"0.61284465",
"0.60596067",
"0.6012683",
"0.60080594",
"0.6006515",
"0.5998357",
"0.5946354",
"0.58616126",
"0.58356",
"0.5821288",
"0.5818811",
"0.58099604",
"0.5807164",
"0.58057564",
"0.5801836",
"0.579095... | 0.74991506 | 0 |
Calculate Q exp(LLam) Q.T | def propagator(Lam, L, Q):
#MM = np.dot(np.diag(np.exp(L*Lam)),Q.T) # slow version
MM = np.multiply(np.exp(L*Lam)[:,None],Q.T)
MM = np.dot(Q,MM)
return MM | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def qi(self, tl, psi_l):\n\t try: \n\t ans = .622*esat(tl)/P_ATM*exp(psi_l*1000000.*VW/R/tl)\n\t except OverflowError:\n\t ans = 0.\n\t return ans",
"def exp(q):\n normv = amplitude(q[:,:3])\n res = np.zeros_like(q)\n res[:,3:] = np.exp(q[:,3:]) * np.cos(normv)\n res[:,:3] = n... | [
"0.6869311",
"0.6478639",
"0.62067354",
"0.6158706",
"0.6130907",
"0.6035837",
"0.60316235",
"0.6030535",
"0.60081697",
"0.599614",
"0.599392",
"0.5978956",
"0.59752256",
"0.59148777",
"0.5896771",
"0.58937496",
"0.5879383",
"0.58761597",
"0.5861196",
"0.58523756",
"0.5839685... | 0.6641371 | 1 |
Get raw encoding of color grid | def get_raw(self) -> bytearray:
img_bytes = bytearray()
for i in range(self.grid_size[0]):
if self.grid[i] is not None:
for j in range(self.grid_size[1]):
if self.grid[i][j] is not None:
color = self.grid[i][j]
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def raw_image(self):\n return self.data16.transpose()",
"def rgb_image(self):\n z3 = self.z[:,:,newaxis]\n return z3 * self.c",
"def denormalise(self):\n return self.map_channels(lambda component: int(round(255 * component)))",
"def cmap(self):\n return self.pixels.get_cmap... | [
"0.65539974",
"0.6196728",
"0.60972804",
"0.6052077",
"0.6024733",
"0.6020551",
"0.5966794",
"0.5950901",
"0.5919673",
"0.5863035",
"0.5824772",
"0.58033454",
"0.57521725",
"0.57195854",
"0.57186157",
"0.5716955",
"0.5664958",
"0.5663728",
"0.56570363",
"0.56567574",
"0.56528... | 0.7415464 | 0 |
Get the JSON representation of the color grid | def get_data_structure_representation(self) -> dict:
byte_buff = self.get_rle()
encoding = "RLE"
if len(byte_buff) > self.grid_size[0] * self.grid_size[1] * 4:
encoding = "RAW"
byte_buff = self.get_raw()
print("RAW ran")
else:
print("RLE r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_json_data(self):\n return {\n \"tile_width\": self.tile_width,\n \"tile_height\": self.tile_height,\n \"num_x\": self.num_tiles_x,\n \"num_y\": self.num_tiles_y,\n \"ids\": self._id_to_pos,\n \"png\": {\n \"color\": qima... | [
"0.6672208",
"0.634182",
"0.62290907",
"0.6117115",
"0.6117115",
"0.60697925",
"0.59832174",
"0.58805984",
"0.58739686",
"0.58671224",
"0.5864128",
"0.58607143",
"0.5810956",
"0.5784442",
"0.57600033",
"0.57500637",
"0.57446563",
"0.57386565",
"0.5713047",
"0.5662122",
"0.565... | 0.5533593 | 31 |
module that check if an object is exactly the same given class | def is_same_class(obj, a_class):
if type(obj) == a_class:
return True
else:
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_same_class(obj, a_class):\n return type(obj) == a_class",
"def is_same_class(obj, a_class):\n return type(obj) == a_class",
"def is_same_class(obj, a_class):\n return(type(obj) == a_class)",
"def is_same_class(obj, a_class):\n return (type(obj) == a_class)",
"def is_same_class(obj, a_cla... | [
"0.84199136",
"0.84199136",
"0.8392058",
"0.8323487",
"0.8314209",
"0.83020157",
"0.83020157",
"0.82819116",
"0.8260241",
"0.8211731",
"0.81893593",
"0.6865129",
"0.68460315",
"0.6769862",
"0.6725414",
"0.66981024",
"0.6687329",
"0.66861904",
"0.6660726",
"0.6656239",
"0.6604... | 0.82728845 | 8 |
Returns a list of all words that can be formed by removing one letter. | def children(word, word_dict):
res = []
for i in range(len(word)):
child = word[:i]+word[i+1:]
if child in word_dict:
res.append(child)
return res | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def words_without_letter(l):\n\treturn {w for w in word_set if has_no_letter(w, l)}",
"def get_words(line):\n try:\n alphabet = \"abcdefghijklmnopqrstuvwqyz \"\n lineL = list(line.lower())\n for word in lineL:\n if word not in alphabet:\n lineL.remove(word)\n ... | [
"0.7705909",
"0.72633255",
"0.72510403",
"0.7213267",
"0.69401634",
"0.6932698",
"0.6928758",
"0.6915684",
"0.69088906",
"0.67821014",
"0.67729175",
"0.67685664",
"0.6759613",
"0.67568547",
"0.6728959",
"0.6727601",
"0.67037684",
"0.6666379",
"0.66501397",
"0.66295815",
"0.66... | 0.0 | -1 |
Line1 is a list of data points Line2 is a list of data points x_labels are labels that correspond to the data points in line1 and line2 | def twoline(file_name, title, line1, line1_label, line2, line2_label, x_labels):
line_chart = pygal.Line(include_x_axis=True)
line_chart.title = title
line_chart.x_labels = x_labels
line_chart.add(line1_label, line1)
line_chart.add(line2_label, line2)
line_chart.render_to_file(file_name)
ret... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plotTwoValues(x, y1, y2, xlabel, y1label, y2label, title, filename):\n\timport matplotlib.ticker as tkr\n\t\n\tplt.close()\n\tplt.rc('text', usetex=True)\n\t#change plot style, add spines\n\t#sns.set_style(\"white\")\n\tsns.set_style(\"ticks\")\n\tsns.despine(top = True) \n\t\n\t#plot with two axes:\n\tfig, ax... | [
"0.61340135",
"0.61177164",
"0.60888654",
"0.6064538",
"0.6063148",
"0.5998084",
"0.5995294",
"0.59688437",
"0.5964659",
"0.59353346",
"0.5920735",
"0.5920249",
"0.5858832",
"0.5814418",
"0.57995886",
"0.5790561",
"0.5790561",
"0.5772129",
"0.57554275",
"0.5693162",
"0.568774... | 0.65004426 | 0 |
Remove duplicates from an iterable. Preserves order. | def uniq(iterable, key=lambda x: x):
keys = set()
res = []
for x in iterable:
k = key(x)
if k in keys:
continue
res.append(x)
keys.add(k)
return res
# Enumerate the list to restore order lately; reduce the sorted list; restore order
# def append_uniq... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def eliminate_duplicates(iterable):\n class NoElement: pass\n\n prev_elem = NoElement\n for elem in sorted(iterable):\n if prev_elem is NoElement:\n prev_elem = elem\n yield elem\n continue\n\n if prev_elem != elem:\n prev_elem = elem\n ... | [
"0.8117462",
"0.8056292",
"0.77816135",
"0.7745527",
"0.7648538",
"0.7337834",
"0.7307825",
"0.7203185",
"0.71760714",
"0.71727204",
"0.71042377",
"0.70982724",
"0.7009782",
"0.6971396",
"0.6926903",
"0.6924849",
"0.68843484",
"0.6818887",
"0.68180394",
"0.6799225",
"0.677793... | 0.7368153 | 5 |
Checks if relative_file should be ignored by DirDiff(). | def Ignore(self, relative_file):
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Ignore(self, relative_file):\n return Whitelisted(relative_file)",
"def is_already_ignored(file_rel, ignore_filename):\n with open(ignore_filename) as ignore_file:\n for line in ignore_file:\n l = line.strip()\n if l == file_rel:\n return True\n ... | [
"0.670953",
"0.6588702",
"0.65310127",
"0.63558495",
"0.6191111",
"0.61526126",
"0.60274726",
"0.60079014",
"0.5973519",
"0.593282",
"0.5882248",
"0.5876046",
"0.5819646",
"0.5777593",
"0.5766464",
"0.57632685",
"0.57522416",
"0.5733617",
"0.5680575",
"0.56652373",
"0.5638383... | 0.778776 | 0 |
Checks if relative_file should be ignored by DirDiff(). | def Ignore(self, relative_file):
return Whitelisted(relative_file) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Ignore(self, relative_file):\n return False",
"def is_already_ignored(file_rel, ignore_filename):\n with open(ignore_filename) as ignore_file:\n for line in ignore_file:\n l = line.strip()\n if l == file_rel:\n return True\n return False",
"d... | [
"0.77861655",
"0.65884745",
"0.65313303",
"0.6356108",
"0.61923015",
"0.6152365",
"0.60268635",
"0.6008553",
"0.5972737",
"0.5931915",
"0.58833545",
"0.58771074",
"0.58196115",
"0.5778174",
"0.5766879",
"0.576381",
"0.5751953",
"0.57336855",
"0.5680093",
"0.5665812",
"0.56391... | 0.6708453 | 1 |
Writes Zserio varuint32 type to the bit stream. | def write(writer: BitStreamWriter, value: int) -> None:
writer.writeVarUInt32(value) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_u32(self):\n pass",
"def write_uint32(self,value):\n packed = struct.pack('!I',value)\n self.data.extend(packed)",
"def _EncodeVarint32(out_file, value):\n bits = value & 0x7F\n value >>= 7\n while value:\n out_file.write(struct.pack(\"<B\", 0x80 | bits))\n ... | [
"0.71795434",
"0.6929138",
"0.65883416",
"0.6567401",
"0.64859104",
"0.62897635",
"0.60490274",
"0.6017212",
"0.6002599",
"0.6000675",
"0.591613",
"0.589193",
"0.5774199",
"0.5753027",
"0.57453746",
"0.5737186",
"0.5691683",
"0.56696606",
"0.5526324",
"0.5512977",
"0.54323274... | 0.6626458 | 2 |
Construct the Collator object. | def __init__(self, repo_url, creds, branch, repo_path=None, validate=True):
parsed = urlparse(repo_url)
self.scheme = parsed.scheme
self.hostname = parsed.hostname
self.org, self.repo = parsed.path.strip('/').split('/')
self.creds = creds
self.branch = branch
self... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, sorter=None):\n self.entries = dict()\n self.super_entries = dict()\n self.sort = sorter\n with open(os.path.join(ROOT, 'database', 'cjk-decomp.txt')) as f:\n for row in f:\n entry, _, components = re.match('(.+):(.+)\\((.*)\\)', row).groups(... | [
"0.5330372",
"0.5230429",
"0.5222493",
"0.51747125",
"0.50707406",
"0.5004906",
"0.49929914",
"0.4988634",
"0.49576563",
"0.4917596",
"0.4917596",
"0.48948464",
"0.48530063",
"0.4813804",
"0.47854206",
"0.4759283",
"0.47545695",
"0.47424915",
"0.47264642",
"0.47170636",
"0.47... | 0.0 | -1 |
Provide the local OS path to the Git repo. | def local_path(self):
if self.repo_path:
return self.repo_path
tmpdir = PurePath(tempfile.gettempdir())
return str(tmpdir.joinpath('harvest', self.org, self.repo)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getGitPath() -> osp:\n current_dir = osp.dirname(osp.realpath(__file__))\n git_dir = osp.dirname(osp.dirname(current_dir))\n return git_dir",
"def base_path(self):\n return \"/repos/{}/{}\".format(self.owner, self.label)",
"def get_local_repository_path():\n result = subprocess.run(\"cmd... | [
"0.7499934",
"0.714734",
"0.7007326",
"0.6929778",
"0.6883732",
"0.67024565",
"0.66419846",
"0.6603354",
"0.65852267",
"0.65443957",
"0.65101755",
"0.6466407",
"0.6447189",
"0.63673073",
"0.6367237",
"0.6323739",
"0.6304783",
"0.62921035",
"0.62831604",
"0.623652",
"0.623424"... | 0.7789014 | 0 |
Test the dtypes for the generated columns. | def test_dtype_consistent(self):
sp_file = os.path.join("tests", "data", "geolife", "geolife_staypoints.csv")
sp = ti.read_staypoints_csv(sp_file, tz="utc", index_col="id", crs="epsg:4326")
#
sp, locs = sp.as_staypoints.generate_locations(
method="dbscan", epsilon=10, num_sam... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_column_types(self):\n table = 'test_table_cols'\n\n columnPythonTypes = {'col1': float,\n 'col2': datetime.datetime,\n 'col3': str,\n 'col4': str\n }\n columnDBTypes = {... | [
"0.73763406",
"0.7242593",
"0.702694",
"0.6961495",
"0.68932813",
"0.68749714",
"0.67689896",
"0.6765226",
"0.67454576",
"0.67063856",
"0.6634231",
"0.65503603",
"0.6529327",
"0.6510893",
"0.6508303",
"0.64882666",
"0.645702",
"0.64301383",
"0.6423842",
"0.641008",
"0.6407383... | 0.0 | -1 |
Look through the buckets cache file for a match. If the field is found, it is retrieved from S3 only if its cached version is missing, or if the MD5 does not match. | def find_file(path, saltenv="base", **kwargs):
if "env" in kwargs:
# "env" is not supported; Use "saltenv".
kwargs.pop("env")
fnd = {"bucket": None, "path": None}
metadata = _init()
if not metadata or saltenv not in metadata:
return fnd
env_files = _find_files(metadata[sal... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_file_from_s3(metadata, saltenv, bucket_name, path, cached_file_path):\n (\n key,\n keyid,\n service_url,\n verify_ssl,\n kms_keyid,\n location,\n path_style,\n https_enable,\n ) = _get_s3_key()\n\n # check the local cache...\n if os.path.... | [
"0.64502406",
"0.6369566",
"0.6146239",
"0.60513973",
"0.58733475",
"0.5827854",
"0.57595646",
"0.5751846",
"0.5699449",
"0.5630594",
"0.56228304",
"0.5603064",
"0.5591488",
"0.55496836",
"0.55435586",
"0.5535343",
"0.5535343",
"0.5532699",
"0.55178446",
"0.55082726",
"0.5496... | 0.51030934 | 61 |
Return the direct parent address deduced from the current address. If the address is "a/b/c", the parent's address will be "a/b". A page with an address like "a" will have the root (empty string) as a parent address. The root itself will have no parent (None). | def parent_address(self):
address = self.address
if address.startswith("/"):
address = address[1:]
if address.endswith("/"):
address = address[:-1]
if "/" in address:
# Return everything before the last / sign
return address.rsplit("/", 1)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parent_address(address):\n if len(address) >= 1:\n return address[0:-1]\n else:\n return ''",
"def parent(self):\n address = self.parent_address\n try:\n parent = Page.objects.get(address=address)\n except Page.DoesNotExist:\n parent = None\n\n ... | [
"0.76109797",
"0.70212144",
"0.6506567",
"0.648497",
"0.64494073",
"0.62795436",
"0.62178636",
"0.6215338",
"0.6213075",
"0.6192549",
"0.6184291",
"0.61787736",
"0.61710316",
"0.61499715",
"0.6145134",
"0.61018944",
"0.60936004",
"0.6089709",
"0.60835576",
"0.605543",
"0.6025... | 0.81701136 | 0 |
Return all the parent pages, ordered by hierarchy. If this is not the root page (with an empty address), then the first list element will be the root. Next will be all pages in the hierarchy of this page. For instance, if the | def parents(self):
addresses = self.parent_addresses
q = models.Q()
for address in addresses:
q |= models.Q(address=address)
if addresses:
pages = Page.objects.filter(q)
# Order the pages in a hierarchy
pages = sorted(list(pages), key=lam... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def link_parent_objects(self, pages):\n pages = list(pages)\n page_dict = {}\n\n for p in pages:\n page_dict[p.id] = p\n\n for p in pages:\n if p.parent_id is None:\n p.parent = None\n else:\n p.parent = page_dict[p.parent_i... | [
"0.71108454",
"0.63267136",
"0.62213033",
"0.62030804",
"0.6191464",
"0.6114534",
"0.60946476",
"0.60883665",
"0.6085012",
"0.60794914",
"0.6070403",
"0.60663694",
"0.6047924",
"0.603508",
"0.59988827",
"0.59390867",
"0.5915551",
"0.5891579",
"0.5883355",
"0.5872775",
"0.5867... | 0.77723676 | 0 |
Return the last part of the address after the last /. | def part_address(self):
address = self.address
if address.startswith("/"):
address = address[1:]
if address.endswith("/"):
address = address[:-1]
if not address:
return "root"
elif "/" in address:
return address.rsplit("/", 1)[1]
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_last_part_of_path(path: str) -> str:\n multi_os_path = path.replace(\"\\\\\", \"/\")\n return re.search(\"(?:[^/](?!/))+$\", multi_os_path).group(0)",
"def last_segment(account_name):\n return account_name.split(':')[-1]",
"def findLastSlash(self, string):\n back_num = 1\n start ... | [
"0.7471042",
"0.71310365",
"0.69578654",
"0.6956308",
"0.65693825",
"0.65447676",
"0.6467592",
"0.6440627",
"0.64331454",
"0.6432801",
"0.6387493",
"0.6327111",
"0.6315765",
"0.6306885",
"0.6305199",
"0.6268419",
"0.6226335",
"0.6180331",
"0.6176576",
"0.6173586",
"0.61707777... | 0.75153506 | 0 |
Return True if the user can access the page. | def access(self, user, can="read"):
if can == "read":
permission = self.can_read
elif can == "write":
permission = self.can_write
else:
raise ValueError("Invalid access: {}".format(can))
# However, the settings for `WIKI_ALLOW_*` takes precedence
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def can_view(self, user):\r\n return True",
"def current_user_has_access(self):\n return self.user_has_access(users.get_current_user())",
"def can_be_viewed_by(self,user):\n return True",
"def is_visible(cls, request):\n if cls.permission_required:\n return request.user.has... | [
"0.80747867",
"0.78138167",
"0.76863205",
"0.7671137",
"0.758718",
"0.749587",
"0.7475387",
"0.7432369",
"0.73819697",
"0.7354547",
"0.73447746",
"0.7330135",
"0.7330135",
"0.7330135",
"0.7261933",
"0.7242863",
"0.7217003",
"0.72159606",
"0.72138315",
"0.7206499",
"0.7177401"... | 0.7141685 | 24 |
Fixture for creating FastAPI app. | async def fastapi_app(
dbsession: AsyncSession,
demo_config: Config,
demo_context: Context,
demo_file_staging_queue: FileStagingQueue,
demo_jwt_decoder: JwtDecoder,
) -> FastAPI:
application = get_app()
application.dependency_overrides[get_db_session] = lambda: dbsession
application.depe... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def app():\n app = create_app(schema=create_schema())\n with app.test_request_context():\n yield app",
"def create_app():\n app = FastAPI()\n configure_rest_server(app=app, router_configs=WEB_SERVICES_ROUTER_CONFIGS, db_configs=DB_CONFIGS)\n return app",
"def app(app_environment: EnvVarsD... | [
"0.77965",
"0.77702016",
"0.7722283",
"0.75347424",
"0.75249815",
"0.7317291",
"0.72343785",
"0.72199124",
"0.715276",
"0.71218604",
"0.7108509",
"0.7108509",
"0.7108509",
"0.7035622",
"0.7022176",
"0.7019368",
"0.69945043",
"0.698767",
"0.6982074",
"0.6945574",
"0.6921123",
... | 0.64997727 | 88 |
Set the maximum number of days during which a password is valid. See man passwd. | def set_maxdays(name, maxdays):
pre_info = info(name)
if maxdays == pre_info["max"]:
return True
cmd = "passwd -x {} {}".format(maxdays, name)
__salt__["cmd.run"](cmd, python_shell=False)
post_info = info(name)
if post_info["max"] != pre_info["max"]:
return post_info["max"] == ma... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_password_expire(self):\n user_dn = \"cn=skip,ou=nerdherd,dc=bonsai,dc=test\"\n cli = LDAPClient(\"ldap://%s\" % self.ipaddr)\n cli.set_password_policy(True)\n cli.set_credentials(\"SIMPLE\", (user_dn, \"p@ssword\"))\n conn, ctrl = cli.connect()\n entry = conn.sear... | [
"0.6250974",
"0.61837417",
"0.5833606",
"0.57658756",
"0.57623106",
"0.57040536",
"0.5682619",
"0.55853856",
"0.5552156",
"0.5519017",
"0.5453559",
"0.5427901",
"0.5395076",
"0.5386614",
"0.5377064",
"0.5363855",
"0.5344328",
"0.53150344",
"0.5291052",
"0.52541804",
"0.525338... | 0.78651005 | 0 |
Set the password for a named user. The password must be a properly defined | def set_password(name, password):
s_file = "/etc/shadow"
ret = {}
if not os.path.isfile(s_file):
return ret
lines = []
with salt.utils.files.fopen(s_file, "r") as ifile:
for line in ifile:
comps = line.strip().split(":")
if comps[0] != name:
li... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setpassword(self, pwd):\n pass",
"def set_password(self, password):\n self.password = password",
"def set_password(self, password):\n self.PASSWORD = password",
"def set_password(self, password):\n self.authentication.password = password",
"def changeUserPassword(self, name,... | [
"0.80373293",
"0.78608465",
"0.77628756",
"0.77247113",
"0.77052885",
"0.77021646",
"0.7577442",
"0.7530736",
"0.7526811",
"0.7521498",
"0.75001174",
"0.74924165",
"0.7484496",
"0.7466715",
"0.7457635",
"0.74422216",
"0.7441741",
"0.73979795",
"0.7383191",
"0.73550516",
"0.73... | 0.7464782 | 14 |
This function builds a simple example and shows the process by starting from an dummy table | def example():
joined_table = [[1900, 170, 10], [0, 120, 10], [0, 120, 100], [2010, 120, 10], [1650, 200, 10]]
remove_columns = [2]
example_table = [[1900, 170], [0, 120]]
annotated_table = query.decorate_table(example_table, remove_columns, joined_table)
joined_schema = ["I SHOULD NOT BE VISIBLE"... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def table_example():\n\n print(\"\\nExample making a new table from scratch:\\n\")\n # Make a new (empty) table object\n tbl = table(\"A table with random data\")\n # Add three columns called \"x\", \"x^2\" and \"1/x\"\n tbl.addcolumn(\"x\")\n tbl.addcolumn(\"x^2\")\n tbl.addcolumn(\"1/x\")\n ... | [
"0.7035208",
"0.6883163",
"0.67469096",
"0.6519562",
"0.633887",
"0.6331327",
"0.63076437",
"0.62640625",
"0.6241894",
"0.6109136",
"0.6099785",
"0.6099011",
"0.6081215",
"0.60376215",
"0.5983178",
"0.5970715",
"0.5949976",
"0.593491",
"0.59066916",
"0.587207",
"0.58708096",
... | 0.0 | -1 |
Find the next time / day to run the cron given the current time | def find_next_run_time(self, cron_hour, cron_minute, current_hour,
current_minute, hour_delta, minute_delta):
NOW = 0
LAST_HOUR_OF_DAY = 23
EVERY_MINUTE = u'*'
EVERY_HOUR = u'*'
CURRENT_DAY = u'today'
NEXT_DAY = u'tomorrow'
if cron_minu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def schedule(self):\n\n crontab = self._crontab\n return datetime.now() + timedelta(\n seconds=math.ceil(\n crontab.next(default_utc=False)\n )\n )",
"def next(self):\n\n crontab = self._crontab\n return math.ceil(crontab.next(default_utc=Fa... | [
"0.7082748",
"0.6955729",
"0.6909674",
"0.6668627",
"0.66338456",
"0.6590951",
"0.65107644",
"0.6369025",
"0.6337233",
"0.6337233",
"0.6031546",
"0.6031546",
"0.60300016",
"0.60300016",
"0.60182625",
"0.6003544",
"0.59623736",
"0.5959805",
"0.5906022",
"0.5903393",
"0.5870757... | 0.81791216 | 0 |
Create a formatted date string | def format_date(self, hour, minute):
SINGLE_DIGIT = 9
PADDING_DIGIT = u'0'
TIME_SEPARATOR = u':'
hour = unicode(hour)
minute = (unicode(minute)
if minute > SINGLE_DIGIT
else PADDING_DIGIT + unicode(minute))
date = TIME_SEPARATOR.join(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def date() -> str:\n\n return datetime.strftime(datetime.today(), _fmt)",
"def date_string(date):\n day = date.day\n month = date.month\n year = date.year\n formatted_string = str(month) + \"/\"\n formatted_string += str(day) + \"/\"\n formatted_string += str(year)\n return formatted_stri... | [
"0.7840573",
"0.7779449",
"0.7725975",
"0.74672097",
"0.7401226",
"0.7360538",
"0.72889614",
"0.72726303",
"0.72125286",
"0.7210942",
"0.7129319",
"0.7089475",
"0.7070776",
"0.7070776",
"0.70581776",
"0.699876",
"0.6949775",
"0.69451755",
"0.6930531",
"0.69303715",
"0.6918962... | 0.0 | -1 |
Empirical CDF (x, y) generator | def ecdf(data):
x = np.sort(data)
cdf = np.linspace(0, 1, len(x))
return cdf, x | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cdf(x, point):\n raise NotImplementedError(\"The cdf method has not yet been implemented.\")",
"def cdf(self,x):\n coordinate = distribution1D.vectord_cxx(len(x))\n for i in range(len(x)):\n coordinate[i] = x[i]\n cdfValue = self._distribution.cdf(coordinate)\n return cdfValue",
"de... | [
"0.6323324",
"0.63156885",
"0.63156885",
"0.6303814",
"0.6268706",
"0.62100124",
"0.6159366",
"0.60543627",
"0.6024784",
"0.59377104",
"0.59365284",
"0.59210986",
"0.5870835",
"0.58200634",
"0.5793498",
"0.57904786",
"0.5770672",
"0.57494646",
"0.57364416",
"0.5731092",
"0.57... | 0.62353605 | 5 |
If the vector contains numbers whose numbers are [0, 1] then this is transformation that properly handles the difference in how the variance of the kind of a feature is computed. x_norm = (x mu) / sqrt(mu (1 mu)) | def normalise_percents(x: np.ndarray or pd.Series, should_impute=False) -> np.ndarray or pd.Series:
# NOTE Currently python doesn't allow you to write this as 0 <= x <= 1
assert (0 <= x[~np.isnan(x)]).all() and (x[~np.isnan(x)] <= 1).all(), 'Values must be [0, 1]'
mu = np.nanmean(x)
if should_impute:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def vector_normalize(x):\n mag = math.sqrt(vector_dot(x, x))\n return [float(i) / mag for i in x]",
"def vecnorm(X) :\n\tXtemp = X - np.min(X)\n\tXnorm = Xtemp * 2 / np.max(Xtemp) - 1\n\treturn Xnorm",
"def normalize(vector):\n return vector / np.linalg.norm(vector)",
"def normalize(x):\n\n x... | [
"0.74264014",
"0.7404532",
"0.7006374",
"0.69798654",
"0.6978168",
"0.6945071",
"0.6945071",
"0.69413334",
"0.6929225",
"0.6915152",
"0.68706095",
"0.68543404",
"0.683409",
"0.680389",
"0.6802249",
"0.6800682",
"0.6783044",
"0.675486",
"0.67526144",
"0.67006624",
"0.66236293"... | 0.0 | -1 |
Takes in an array of characters in infix notation and returns an array of the same expression in postfix notation. | def toPostfix (self,infix):
postfix = []
stack = []
# Loop over characters in the input string
for char in infix:
# If char is a number add it to postfix
if isFloat(char):
postfix.append(char)
# If its a special number add it to postfix... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def infix_to_postfix(infix_expr):\n # Append adds new item to list\n # Concat creates a new list every time instead\n\n opstack = StackArray()\n res = []\n lstr = infix_expr.split()\n # l_para = r_para = 0\n # operator precedence dict\n prec = { # higher val = higher prec\n \"(\" : 4... | [
"0.7558118",
"0.7078522",
"0.7011911",
"0.69275826",
"0.6924146",
"0.6870807",
"0.6854964",
"0.68373585",
"0.6797975",
"0.6752513",
"0.67022526",
"0.6645195",
"0.66399765",
"0.66213095",
"0.6603758",
"0.65511185",
"0.6515123",
"0.6442614",
"0.6399889",
"0.63701683",
"0.634722... | 0.6659009 | 11 |
Return the connector with label 'label'. If label is already a connector, it just returns the connector | def connector_by_label(self, label):
# return label, if it is already a connector
if isinstance(label, ArduinoSwitchControlConnector):
return label
# if the label is an input, return the input
elif label in self.inputs:
return self.inputs[label]
# if the l... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_legend(self, label):\n try:\n return next(leg for leg in self.legends if leg.label == label)\n except StopIteration:\n return None",
"def next(self, value):\n\t\tif self.is_threshold_true(value): #testing if the threshold condition is met\n\t\t\ttry: #trying to be sure... | [
"0.5988546",
"0.59118974",
"0.5866014",
"0.57709306",
"0.5751925",
"0.5744539",
"0.57358396",
"0.5731276",
"0.5672983",
"0.56525475",
"0.56485885",
"0.55657595",
"0.54899764",
"0.54848546",
"0.5479509",
"0.54742557",
"0.5387092",
"0.5362233",
"0.53138536",
"0.5277592",
"0.527... | 0.8234057 | 0 |
Create a route and add it to the routes dictionary | def _add_route(self, connections):
route = ArduinoSwitchControlRoute(connections)
if route.input.label not in self.routes:
self.routes[route.input.label] = {route.output.label: [route]}
elif route.output.label not in self.routes[route.input.label]:
self.routes[route.input... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_routes(self):\n pass",
"def add_route(self, route: Route, routing_url: str, methods: typing.Iterable[str] = (\"GET\",)):\n # Create an endpoint name for the route.\n route.routing_url = routing_url\n route.methods = methods\n # Add it to the list of routes to add later.... | [
"0.75110686",
"0.7458591",
"0.73835146",
"0.72081",
"0.7159818",
"0.70936894",
"0.7021684",
"0.6901304",
"0.68598646",
"0.67858976",
"0.6774338",
"0.6691051",
"0.6658312",
"0.6626322",
"0.65774846",
"0.6576588",
"0.65486085",
"0.6531361",
"0.65131605",
"0.6496556",
"0.6456906... | 0.6716273 | 11 |
Create a string for the Genre. This is required to display genre in Admin | def display_genre(self):
return ', '.join(genre.name for genre in self.genre.all()[:3]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def display_genre(self):\n \n # Get first 3 genres and join to a string.\n return ', '.join([ genre.name for genre in self.genre.all()[:3] ])",
"def display_genre(self):\n return ', '.join([ genre.name for genre in self.genre.all()[:3] ])",
"def display_genre(self):\n retu... | [
"0.73033166",
"0.6990355",
"0.69701594",
"0.6930422",
"0.6915598",
"0.6827643",
"0.6806863",
"0.67590684",
"0.6660133",
"0.6609264",
"0.66054493",
"0.64957887",
"0.63967633",
"0.6385569",
"0.6239431",
"0.6219362",
"0.60696435",
"0.6056624",
"0.60528976",
"0.6049401",
"0.60484... | 0.7101371 | 1 |
tokenize text and return Tensor of token IDs | def _tokenize_text(self, text: str) -> torch.Tensor:
# specify max length truncation to avoid IndexError due to exceeding length
return torch.tensor(self.tokenizer.encode(text, max_length=self.max_len, truncation=True)).unsqueeze(0) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_ids(cls, text):\n tokens = TokenizerContainer.TOKENIZER.tokenize(text)\n token_ids = TokenizerContainer.TOKENIZER.convert_tokens_to_ids(tokens)\n input_ids = token_ids + [0] * (cls.MAX_LEN-len(token_ids))\n return tokens, input_ids",
"def identity_tokenizer(text):\n return ... | [
"0.7625905",
"0.7528897",
"0.7187174",
"0.717211",
"0.71701217",
"0.7136371",
"0.7055938",
"0.6973813",
"0.6962903",
"0.6872934",
"0.68579376",
"0.6722189",
"0.67131203",
"0.6693592",
"0.66824037",
"0.66818154",
"0.6681238",
"0.6674619",
"0.6646261",
"0.66326636",
"0.66262335... | 0.710097 | 6 |
calcul_xy_array function calculates xy point to crop image according to varios parameters this function empisizses minimal crops | def calcul_xy_array(img_x, img_y, tile_x, tile_y):
array = []
modu_x = img_x % tile_x
modu_y = img_y % tile_y
div_x = img_x // tile_x
div_y = img_y // tile_y
current_x = 0
current_y = 0
for i in range(div_y):
for j in range(div_x):
array.append((current_x, current_y... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calcul_xyz_array(img_x, img_y, tile_x, tile_y, cross_x=0, cross_y=0):\n array = []\n\n modu_x = cross_x\n modu_y = cross_y\n current_x = 0\n current_y = 0\n\n while current_y + tile_y <= img_y:\n\n while current_x + tile_x <= img_x:\n\n array.append((current_x, current_y))\n... | [
"0.62918663",
"0.59897083",
"0.589296",
"0.5858555",
"0.58506364",
"0.5756055",
"0.57436585",
"0.5733566",
"0.572034",
"0.57197464",
"0.571418",
"0.5698101",
"0.56696355",
"0.56631607",
"0.565198",
"0.5638193",
"0.5615365",
"0.5605501",
"0.5601639",
"0.5598386",
"0.5587683",
... | 0.6741146 | 0 |
Returns ``True`` if the set has no elements in common with ``other``. Sets(also OrderedSets) are disjoint if and only if their intersection is the empty set. | def is_disjoint(self, other):
for element in other:
if element in self:
return False
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_disjoint(self, other):\n return self.intersect(other) == S.EmptySet",
"def is_disjoint(self, other):\n if not isinstance(other, SetPy):\n raise TypeError(\"Can only be disjoint with another SetPy\")\n return set_combinations.SetIntersect(self, other).cardinality() == 0",
... | [
"0.8482522",
"0.8251271",
"0.7338489",
"0.7121076",
"0.6896841",
"0.6781653",
"0.66817737",
"0.6627249",
"0.6555604",
"0.6488465",
"0.64796954",
"0.64539194",
"0.643535",
"0.6405576",
"0.63989204",
"0.63969433",
"0.63552",
"0.6311285",
"0.62773293",
"0.6222137",
"0.62200254",... | 0.7427231 | 2 |
Create an empty mock database with all the necessary tables. | def mock_db() -> Iterable[sqlite3.Connection]:
with sqlite3.connect(":memory:") as conn:
initialize_database(conn)
yield conn | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_empty_db():\r\n drop_db()\r\n database.create_tables([Customer])\r\n database.close()",
"def setUp(self):\n db.create_all()",
"def setUp(self):\n db.drop_all() # clean up the last tests\n db.create_all() # make our sqlalchemy tables",
"def _initTestingDB(): \n f... | [
"0.80761915",
"0.80277145",
"0.77839726",
"0.77212346",
"0.7690953",
"0.76794016",
"0.76792336",
"0.7669546",
"0.7639703",
"0.7616845",
"0.75365347",
"0.75365347",
"0.75365347",
"0.75257266",
"0.7519232",
"0.7519232",
"0.7519232",
"0.7519232",
"0.7519232",
"0.7519232",
"0.751... | 0.0 | -1 |
Get all peak informations including centroid, width, intersection with baseline, area (intensity) | def getPeakInformations(hist, peaks, baselines):
centroids = []
widths = []
intersectionsList = []
areas = []
for (i, p) in enumerate(peaks):
baseline = baselines[i]
width, intersections = getWidth(hist, p, baseline)
cent = getCentroid(hist, p, intersections)
areas.a... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def incandPeakInfo(self):\t\r\n\t\tself.incandBaseline = (np.mean(self.wideBandIncandData[0:10]))\r\n\t\t\t\t\r\n\t\traw_incand_max = np.amax(self.wideBandIncandData)\r\n\t\tincand_max = raw_incand_max - self.incandBaseline\r\n\t\tincand_max_index = np.argmax(self.wideBandIncandData)\r\n\t\t\r\n\t\tself.incandMax ... | [
"0.64989",
"0.6485825",
"0.6444918",
"0.6409422",
"0.64071286",
"0.63856786",
"0.6343341",
"0.6315446",
"0.6241474",
"0.62322104",
"0.60951096",
"0.6060293",
"0.6054478",
"0.6047564",
"0.60356694",
"0.6005472",
"0.59538835",
"0.59099555",
"0.59079224",
"0.5863672",
"0.5851379... | 0.7475382 | 0 |
Initialize a set of quaternions (to be summed over the last dimension) randomly. This method produces a uniform distribution of rotations. | def projected_quaternion_initializer(shape, dtype=None):
assert shape[1] == 4
(num_rotations, _, quaternion_dim) = shape
# http://planning.cs.uiuc.edu/node198.html
(u1, u2, u3) = tf.random.uniform((3, num_rotations), maxval=1.)
r = tf.sqrt(1 - u1)*tf.sin(2*math.pi*u2)
x = tf.sqrt(1 - u1)*tf.cos... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_queries_random(self, number_queries):\n random_quaternions = tfg.quaternion.normalized_random_uniform(\n (number_queries,))\n random_rotations = tfg.rotation_matrix_3d.from_quaternion(\n random_quaternions)\n random_rotations = tf.cast(random_rotations, tf.float32)\n return r... | [
"0.7286116",
"0.724883",
"0.7177093",
"0.70647335",
"0.70409805",
"0.70113873",
"0.67600745",
"0.6688123",
"0.6657766",
"0.64939237",
"0.6301644",
"0.6276243",
"0.62408674",
"0.6230662",
"0.618708",
"0.6140072",
"0.60930246",
"0.6067635",
"0.5968336",
"0.5933476",
"0.5933476"... | 0.6612282 | 9 |
Returns the tree item at the given index and role. | def data(self, index, role):
if not index.isValid():
return None
col = index.column()
tree_item = index.internalPointer()
obj = tree_item.obj
if role == Qt.DisplayRole:
try:
attr = self._attr_cols[col].data_fn(tree_item)
#... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_item(self, index: int) -> _T:\n return self.index_to_item[index]",
"def GetItem(self,index):\r\n return self.itemId_item[self.gList.GetItemData(index)]",
"def __getitem__(self, index: int) -> T:\n node_at_index = self.__get_node_at_index(index)\n return node_at_index.item",
... | [
"0.674443",
"0.6507644",
"0.6443466",
"0.64145774",
"0.64087194",
"0.6348386",
"0.62932366",
"0.60373384",
"0.60297745",
"0.60282725",
"0.5992685",
"0.5923381",
"0.59075636",
"0.58989227",
"0.5844554",
"0.5818023",
"0.5815859",
"0.5814787",
"0.57980925",
"0.57829016",
"0.5766... | 0.57335407 | 22 |
Get item handler for the given index. | def get_key(self, proxy_index):
return self.treeItem(proxy_index) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_item(self, index: int) -> _T:\n return self.index_to_item[index]",
"def get_item(self, index):\n if index == 0:\n raise IndexError(\"<{0}> Index start as 1\".format(type(self).__name__))\n index = self.get_index(index)\n res = self.get_item_type()()\n self.ge... | [
"0.64511156",
"0.644189",
"0.60153353",
"0.59869826",
"0.5972518",
"0.5878667",
"0.58729964",
"0.5871374",
"0.582551",
"0.57866263",
"0.5753614",
"0.5745258",
"0.5720659",
"0.57183975",
"0.57140183",
"0.5709074",
"0.5685909",
"0.5685909",
"0.5611351",
"0.55572706",
"0.5551654... | 0.53637743 | 32 |
Check that the file name checker helper function properly checks / adds file extensions. | def test_fname():
assert fname('data', 'json') == 'data.json'
assert fname('data.json', 'json') == 'data.json'
assert fname('pic', 'png') == 'pic.png'
assert fname('pic.png', 'png') == 'pic.png'
assert fname('report.pdf', 'pdf') == 'report.pdf'
assert fname('report.png', 'pdf') == 'report.png' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_file_name_extensions(self, file_name, input_output):\n file_type = FileTypes ()\n extension_types = file_type.get_extension_types ()\n for extension in extension_types:\n if file_name.endswith (extension):\n if input_output == 'input':\n s... | [
"0.7883958",
"0.75611335",
"0.7380167",
"0.73467886",
"0.73041046",
"0.72771317",
"0.7264603",
"0.72286856",
"0.7187826",
"0.7182048",
"0.7182048",
"0.7178175",
"0.71725744",
"0.7169548",
"0.716252",
"0.71486044",
"0.7147043",
"0.7147043",
"0.7147043",
"0.7147043",
"0.7147043... | 0.0 | -1 |
Test loading JSON file, with str file specifier. Loads files from test_save_fm_str. | def test_load_json_str():
file_name = 'test_fooof_all'
data = load_json(file_name, TEST_DATA_PATH)
assert data | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_loader_loads_from_str():\n base_json = '{\"foo\": \"bar\"}'\n json_test = {\"foo\": \"bar\"}\n assert whenzat.loader(base_json, from_file=False) == json_test",
"def test_loader_loads_from_file():\n base_json = 'tests/test_json.json'\n json_test = {\"foo\": \"bar\"}\n assert whenzat.loa... | [
"0.73777825",
"0.7376165",
"0.7230088",
"0.70725197",
"0.68765694",
"0.67263544",
"0.670362",
"0.66817373",
"0.6622015",
"0.64939463",
"0.6477334",
"0.6474819",
"0.6438596",
"0.6438438",
"0.64371306",
"0.64021796",
"0.6400643",
"0.63922054",
"0.6382423",
"0.63679767",
"0.6360... | 0.76864314 | 0 |
Test loading JSON file, with file object file specifier. Loads files from test_save_fm_str. | def test_load_json_fobj():
file_name = 'test_fooof_all'
with open(os.path.join(TEST_DATA_PATH, file_name + '.json'), 'r') as f_obj:
data = load_json(f_obj, '')
assert data | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_loader_loads_from_file():\n base_json = 'tests/test_json.json'\n json_test = {\"foo\": \"bar\"}\n assert whenzat.loader(base_json) == json_test",
"def test_load_file_contents():\n\n file_name = 'test_fooof_all'\n loaded_data = load_json(file_name, TEST_DATA_PATH)\n\n # Check settings\n... | [
"0.75258416",
"0.7465203",
"0.7410815",
"0.7406534",
"0.7405664",
"0.7307532",
"0.7127531",
"0.70336926",
"0.6979452",
"0.68026793",
"0.66483885",
"0.6642713",
"0.6637348",
"0.66363496",
"0.66358185",
"0.66351014",
"0.6620436",
"0.6594246",
"0.6544583",
"0.6537851",
"0.651892... | 0.7832351 | 0 |
Restore the original log configuration. | def tearDown(self):
self.logger.handlers = self.orig_handlers
self.logger.level = self.level
self.rt_logger.handlers = self.orig_root_handlers
self.rt_logger.level = self.root_level | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def restore_config(self):\n self._clear_previous_windows_assigment()\n self._restart_i3_config()",
"def revert_logging(self):\n if self._previous_action_logging_setting is not None:\n self.action_logging_enabled = self._previous_action_logging_setting\n self._previous_a... | [
"0.7123501",
"0.6727215",
"0.6610408",
"0.65163714",
"0.6412238",
"0.62831604",
"0.6218266",
"0.6191524",
"0.6045214",
"0.59747887",
"0.59591055",
"0.58994496",
"0.58450556",
"0.5834434",
"0.5805508",
"0.58017045",
"0.57987106",
"0.5776211",
"0.573384",
"0.57305247",
"0.57214... | 0.58486915 | 12 |
Render a ggplot as an image | def gg_to_img(g: ggplot, **kwargs) -> PIL.Image.Image:
g.draw()
return plt_to_img(**kwargs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_plot_as_image(self):\r\n plt.savefig(ROOT_DIR + '/presentation/images/' + self.folder + '/' + self.generated_image_name + '.png',\r\n bbox_inches='tight')",
"def plot_into_img_widget(img_widget, figure):\n buf = cStringIO.StringIO()\n figure.savefig(buf, format='png', dpi... | [
"0.6554129",
"0.65464324",
"0.64893293",
"0.6452757",
"0.6416033",
"0.6383917",
"0.6378029",
"0.6378029",
"0.6378029",
"0.6375705",
"0.63691914",
"0.63691914",
"0.6321307",
"0.6269392",
"0.6269392",
"0.62294483",
"0.62288004",
"0.62105227",
"0.62105227",
"0.62105227",
"0.6197... | 0.79084647 | 0 |
Repeat mpl_cmap_concat(cmaps) to have n colors | def mpl_cmap_repeat(n: int, *cmaps: Union[str, mpl.colors.ListedColormap]) -> mpl.colors.ListedColormap:
cmap = mpl_cmap_concat(*cmaps)
colors = (cmap.colors * (1 + n // len(cmap.colors)))[:n]
return mpl.colors.ListedColormap(colors) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_n_colors(n, cmap_name='tab20'):\n pt_region_colormap = plt.get_cmap(cmap_name)\n max_i = len(pt_region_colormap.colors)\n return [pt_region_colormap(i % max_i) for i in range(n)]",
"def get_color_map(n):\n jet = plt.get_cmap('jet')\n cNorm = colors.Normalize(vmin=0, vmax=n-1)\n sc... | [
"0.74020565",
"0.73613",
"0.68641955",
"0.6692054",
"0.661377",
"0.6541813",
"0.6484327",
"0.64687973",
"0.64588034",
"0.6437179",
"0.64368224",
"0.6434781",
"0.6389428",
"0.63242435",
"0.62578416",
"0.62549824",
"0.62529665",
"0.6158926",
"0.61354136",
"0.61077076",
"0.61062... | 0.86303645 | 0 |
Render the current figure as a (PIL) image Take dummy arg to support expression usage `plt_to_img(...)` as well as statement usage `...; plt_to_img()` | def plt_to_img(dummy: any = None, **kwargs) -> PIL.Image.Image:
return PIL.Image.open(plot_to_file(**kwargs)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plt_to_ipy_img(dummy: any = None, **kwargs) -> IPython.display.Image:\n return IPython.display.Image(filename=plot_to_file(**kwargs))",
"def render_pylab(figure, fmt=\"jpg\"):\n if not callable(getattr(figure, \"savefig\", None)):\n return None\n output = StringIO()\n figure.savefig(output... | [
"0.8149433",
"0.71991897",
"0.68451166",
"0.673614",
"0.6686397",
"0.66476566",
"0.66191614",
"0.6591109",
"0.65812457",
"0.6573919",
"0.6573919",
"0.6573919",
"0.6569402",
"0.6569254",
"0.6569254",
"0.64321697",
"0.6406493",
"0.63874584",
"0.6369979",
"0.6341378",
"0.6337907... | 0.81259215 | 1 |
Like plt_to_img but make an IPython Image instead of a PIL Image | def plt_to_ipy_img(dummy: any = None, **kwargs) -> IPython.display.Image:
return IPython.display.Image(filename=plot_to_file(**kwargs)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plt_to_img(dummy: any = None, **kwargs) -> PIL.Image.Image:\n return PIL.Image.open(plot_to_file(**kwargs))",
"def plot_to_image(figure):\n\t# Save the plot to a PNG in memory.\n\tbuf = io.BytesIO()\n\tplt.savefig(buf, format='png')\n\t# Closing the figure prevents it from being displayed directly inside\... | [
"0.8060336",
"0.75551385",
"0.74884987",
"0.73595905",
"0.73515654",
"0.73515654",
"0.73515654",
"0.7310224",
"0.7310224",
"0.7308095",
"0.72436786",
"0.7110329",
"0.71054316",
"0.69950163",
"0.6891017",
"0.68174624",
"0.6725987",
"0.6634947",
"0.6464275",
"0.63643175",
"0.63... | 0.8214967 | 0 |
plt.imshow with sane defaults | def plot_img(X: np.ndarray, **kwargs):
kwargs.setdefault('origin', 'lower') # Sane default
plt.imshow(X, **kwargs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dat_imshow(x):\n plt.imshow(x,interpolation='nearest',aspect='auto')",
"def imshow(self):\n axes([0, 0, 1, 1], xticks=[], yticks=[])\n imshow(self.rgb_image())",
"def _show(self, a):\n fig = plt.figure()\n fig.set_size_inches((2, 2))\n ax = plt.Axes(fig, [0., 0., 1... | [
"0.76821333",
"0.7383634",
"0.7355236",
"0.73525053",
"0.7248383",
"0.7156302",
"0.70230836",
"0.6989671",
"0.6956777",
"0.68749624",
"0.6862426",
"0.67880374",
"0.67704684",
"0.6764542",
"0.6749863",
"0.6740264",
"0.67389166",
"0.67389166",
"0.67389166",
"0.6729384",
"0.6696... | 0.70693696 | 6 |
Create and save a user with the given username, email, and password. | def _create_user(self, email, username, password, gender=2, **extra_fields):
if not email:
raise ValueError('The given email must be set')
email = self.normalize_email(email)
username = self.model.normalize_username(username)
user = self.model(email=email, username=username,... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _create_user(self, email, password,username, **extra_fields):\r\n if not email:\r\n raise ValueError('The given email must be set')\r\n if not username:\r\n raise ValueError('The given username must be set')\r\n email = self.normalize_email(email)\r\n user = se... | [
"0.8596651",
"0.8440805",
"0.8426653",
"0.842342",
"0.84064573",
"0.83936125",
"0.83879197",
"0.83420223",
"0.8334317",
"0.83325297",
"0.8322284",
"0.82890344",
"0.8282186",
"0.82750225",
"0.8269599",
"0.8267712",
"0.81639",
"0.81596565",
"0.8158627",
"0.8142537",
"0.8136805"... | 0.78382444 | 100 |
Return recipe detail url | def detail_url(recipe_id): # /api/recipe/recipes/ID
return reverse('recipe:recipe-detail', args = [recipe_id]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_detail_URL(recipe_id):\n return reverse('recipeapp:recipe-detail', args=[recipe_id])",
"def detail_url(recipe_id):\n return reverse('recipe:recipe-detail',args=[recipe_id])",
"def detail_url(recipe_id):\n return reverse('recipe:recipe-detail', args=[recipe_id])",
"def detail_url(recipe_id):\... | [
"0.85382056",
"0.85175544",
"0.8516057",
"0.8516057",
"0.8516057",
"0.8485883",
"0.7961948",
"0.7941685",
"0.7200663",
"0.6732586",
"0.6619213",
"0.66146713",
"0.6565162",
"0.6563302",
"0.6547823",
"0.6515735",
"0.6505814",
"0.6500015",
"0.6446416",
"0.6442284",
"0.64314175",... | 0.8467275 | 6 |
Test retrieving a list of recipes | def test_retrieve_recipes(self):
sample_recipe(user = self.user)
sample_recipe(user = self.user)
res = self.client.get(RECIPE_URL)
recipes = Recipe.objects.all().order_by('-id')
serializer = RecipeSerializer(recipes, many=True) # many=true returns the data as a list
se... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_recipe_information_bulk(self):\n pass",
"def test_retrieve_recipes(self):\n sample_recipe(name=\"Avocado toast\")\n sample_recipe(name='Baklava')\n\n res = self.client.get(RECIPES_URL)\n\n recipes = Recipe.objects.all()\n serializer = RecipeSerializer(recipe... | [
"0.81033486",
"0.79853475",
"0.79804796",
"0.79704607",
"0.7895004",
"0.78374314",
"0.76769125",
"0.767323",
"0.74180543",
"0.73952913",
"0.73141986",
"0.72933966",
"0.7182399",
"0.71717864",
"0.7072997",
"0.70101357",
"0.6926858",
"0.6895275",
"0.689",
"0.6882748",
"0.687709... | 0.78925663 | 5 |
Test retrieving recipes for authenticated user | def test_recipes_limited_to_user(self):
user2 = get_user_model().objects.create_user(
email = 'test2@gmail.com',
password = '123465',
)
sample_recipe(user = user2)
sample_recipe(user = self.user)
res = self.client.get(RECIPE_URL)
recipes = Recipe... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_recipe_limited_to_user(self):\n user2 = get_user_model().objects.create_user(\n 'test@gmail.com',\n 'password3456',\n )\n sample_recipe(self.user)\n sample_recipe(user2)\n\n res = self.client.get(RECIPE_URL)\n\n recipes = Recipe.objects.filte... | [
"0.8132782",
"0.8016161",
"0.799972",
"0.79516006",
"0.7939386",
"0.79077315",
"0.7842916",
"0.77679795",
"0.76749337",
"0.7433105",
"0.7431812",
"0.7412918",
"0.7326992",
"0.7156867",
"0.7122375",
"0.71120375",
"0.7111092",
"0.71065676",
"0.7100709",
"0.685798",
"0.68199605"... | 0.8023137 | 1 |
Test creating recipe with ingredients | def test_create_recipe_with_ingredients(self):
ingredient1 = sample_ingredient(user=self.user, name = 'bla')
ingredient2 = sample_ingredient(user=self.user, name = 'blaa')
payload = {
'title': 'red curry',
'ingredients': [ingredient1.id, ingredient2.id],
'time... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_creating_recipe_with_ingredients(self):\n ingredient1 = sample_ingredients(user=self.user, name='Prawns')\n ingredient2 = sample_ingredients(user=self.user, name='Garlic')\n\n payload = {\n 'title': 'Avocado lime cheesecake',\n 'time_minutes': 20,\n 'p... | [
"0.8825509",
"0.84078807",
"0.8278052",
"0.821998",
"0.818701",
"0.8048869",
"0.78536355",
"0.78462386",
"0.7843251",
"0.78242916",
"0.7535233",
"0.75127876",
"0.75123227",
"0.74753714",
"0.7442225",
"0.7428843",
"0.73928785",
"0.73488337",
"0.73260677",
"0.7291473",
"0.72718... | 0.82071775 | 4 |
Test updating a recipe with put | def test_full_update_recipe(self):
recipe = sample_recipe(user=self.user)
recipe.tags.add(sample_tag(user=self.user))
payload = {
'title': 'Spaghetti',
'time_minutes': 25,
'price': 5.00,
}
url = detail_url(recipe.id)
self.client.put(url... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_full_update_recipe(self):\n recipe = sample_recipe(user=self.user)\n recipe.tag.add(sample_tag(user=self.user))\n payload = {\n 'title':'chicken noodles',\n 'time_minutes':50,\n 'price':12.67,\n }\n url = detail_url(recipe.id)\n se... | [
"0.78566587",
"0.7752075",
"0.7712868",
"0.77045786",
"0.7525884",
"0.748222",
"0.74381965",
"0.7429547",
"0.73584735",
"0.73346174",
"0.7303786",
"0.73017454",
"0.71913356",
"0.7174521",
"0.7124352",
"0.7124352",
"0.7124352",
"0.7121711",
"0.7092275",
"0.7064242",
"0.7031531... | 0.77277243 | 2 |
Test uploading an image to recipe | def test_upload_image_to_recipe(self):
url = image_upload_url(self.recipe.id)
# we will create a temp file, write an image to it, then upload that file through the API endpoint
with tempfile.NamedTemporaryFile(suffix = '.jpg') as ntf: # create a file in the system that we can write to (in a rand... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_uploading_image_to_recipe(self):\n url = image_upload_url(self.recipe.id)\n with tempfile.NamedTemporaryFile(suffix='.jpg') as ntf:\n img = Image.new('RGB',(10,10))\n img.save(ntf,format='JPEG')\n ntf.seek(0)\n res = self.client.post(url, {'image':... | [
"0.86700606",
"0.8635865",
"0.8499466",
"0.8485353",
"0.78114253",
"0.7783709",
"0.77733296",
"0.76543945",
"0.7583468",
"0.75644386",
"0.74843514",
"0.7406042",
"0.733126",
"0.73294336",
"0.7199716",
"0.71662664",
"0.7152698",
"0.70980304",
"0.70972466",
"0.6977602",
"0.6969... | 0.8491053 | 3 |
Test uploading an invalid image | def test_upload_image_bad_request(self):
url = image_upload_url(self.recipe.id)
res = self.client.post(url, {'image': 'notimage'}, format = 'multipart')
self.assertEqual(res.status_code, status.HTTP_400_BAD_REQUEST) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_upload_bad_file(self):\n url = image_upload_url(self.reteta.id)\n res = self.client.post(url, {'image': 'notimage'}, format='multipart')\n self.assertEqual(res.status_code, status.HTTP_400_BAD_REQUEST)",
"def test_upload_invalid_image_field(self):\n url = create_upload_image_... | [
"0.86194044",
"0.8567676",
"0.8433633",
"0.8430187",
"0.8360368",
"0.83143234",
"0.82901424",
"0.82888144",
"0.82306975",
"0.81376487",
"0.7897103",
"0.75692457",
"0.7536378",
"0.74416286",
"0.73935485",
"0.7353074",
"0.72465086",
"0.7230261",
"0.72119063",
"0.72095186",
"0.7... | 0.83053386 | 6 |
Test returning recipes with specific ingredients | def test_filter_recipe_by_ingredients(self):
recipe1 = sample_recipe(user=self.user, title='bla')
recipe2 = sample_recipe(user=self.user, title='blaaaa')
recipe3 = sample_recipe(user=self.user, title='blaaaaaaaa')
ingredient1 = sample_ingredient(user=self.user, name = 'bom')
ingr... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_search_recipes_by_ingredients(self):\n pass",
"def test_get_recipe_ingredients_by_id(self):\n pass",
"def test_creating_recipe_with_ingredients(self):\n ingredient1 = sample_ingredients(user=self.user, name='Prawns')\n ingredient2 = sample_ingredients(user=self.user, name='... | [
"0.8336177",
"0.78261787",
"0.77616054",
"0.774864",
"0.76189923",
"0.7600667",
"0.75203025",
"0.744761",
"0.7295739",
"0.7280468",
"0.72636646",
"0.7255317",
"0.71768695",
"0.71739113",
"0.7104669",
"0.708287",
"0.70755357",
"0.7046724",
"0.70242774",
"0.69891816",
"0.694636... | 0.73577106 | 8 |
Computes the precision for the specified values of k | def accuracy(output, target, topk=(1,)):
maxk = max(topk)
batch_size = target.size(0)
_, pred = output.topk(maxk, 1, True, True)
pred = pred.t()
correct = pred.eq(target.view(1, -1).expand_as(pred))
res = []
for k in topk:
correct_k = correct[:k].view(-1).float().sum(0, keepdim=Tru... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def precision(gt, pred, k):\n k = min(len(pred), k)\n den = min(len(gt), k)\n return sum([int(pred[i] in gt) for i in range(k)]) / den",
"def precision_at_k(r, k):\n assert k >= 1\n r = np.asarray(r)[:k] != 0\n if r.size != k:\n raise ValueError('Relevance score length < k')\... | [
"0.76427615",
"0.74189496",
"0.7418079",
"0.72710466",
"0.72456723",
"0.72446615",
"0.7237539",
"0.72213703",
"0.7210107",
"0.7058935",
"0.6852219",
"0.6786084",
"0.67836976",
"0.6768417",
"0.67273885",
"0.67181736",
"0.67181736",
"0.67181736",
"0.67181736",
"0.67181736",
"0.... | 0.0 | -1 |
Return a string representation of this stack | def __repr__(self):
return 'Stack({})'.format(self.length()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __repr__(self):\n return str(self.stack)",
"def __repr__(self):\n return str(self._stack_items)",
"def __str__(self):\n stackStr = \"Stack: <- \"\n if self.size <= 3:\n for val in self.data:\n stackStr = stackStr + str(val) + \" \"\n else:\n ... | [
"0.88021517",
"0.8512891",
"0.8345638",
"0.83416456",
"0.83416456",
"0.83317596",
"0.82302666",
"0.8212493",
"0.81768715",
"0.80605805",
"0.7728859",
"0.7728859",
"0.7728859",
"0.7728859",
"0.75519186",
"0.7246458",
"0.7197881",
"0.7185586",
"0.71225804",
"0.7104178",
"0.7060... | 0.79534423 | 10 |
Return the number of items in this stack | def length(self):
return self.linked_list.length() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def size(self): #returns the size or number of items in the stack\n if self.is_empty():\n return 0\n else:\n return self.num_items",
"def size(self):\n return self.N # Number of items in the stack",
"def size(self):\n return len(self._stack_items... | [
"0.8939227",
"0.8611404",
"0.85516477",
"0.82096124",
"0.82096124",
"0.81896573",
"0.80963135",
"0.8073885",
"0.8064417",
"0.80576104",
"0.7967561",
"0.7967561",
"0.78993255",
"0.78804374",
"0.7823916",
"0.77923346",
"0.7788647",
"0.7575975",
"0.75706893",
"0.7564803",
"0.755... | 0.0 | -1 |
Return the top item on this stack without removing it, or None if this stack is empty | def peek(self):
if self.is_empty():
return None
return self.linked_list.head.data | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def top(self):\n try:\n if self.size() > 0:\n return self.items[len(self.items) - 1]\n else:\n raise IndexError('Cannot get top item, stack is empty.')\n except IndexError as err:\n print(err)\n raise",
"def top(self):\n ... | [
"0.8428943",
"0.83861",
"0.83731574",
"0.83613783",
"0.8317286",
"0.8236488",
"0.81668663",
"0.8126783",
"0.8065668",
"0.8062606",
"0.8062606",
"0.80485976",
"0.8035517",
"0.80332375",
"0.8030455",
"0.80003124",
"0.7992426",
"0.79613566",
"0.7948055",
"0.7858303",
"0.7849597"... | 0.0 | -1 |
Return the top item and remove it from this stack, or raise ValueError if this stack is empty | def pop(self):
if self.is_empty():
raise ValueError
item = self.linked_list.head
self.linked_list.head = item.next
item.next = None
self.linked_list.node_count -= 1
return item.data | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pop(self):\n try:\n if self.size() > 0:\n top = self.top()\n self.items.pop()\n return top\n else:\n raise IndexError('Cannot pop item, stack is empty.')\n except IndexError as err:\n print(err)\n ... | [
"0.8317962",
"0.8118133",
"0.79350066",
"0.7909736",
"0.7878401",
"0.7877539",
"0.7830187",
"0.7814436",
"0.77917266",
"0.7735623",
"0.77264434",
"0.76868576",
"0.76760757",
"0.76719135",
"0.76673764",
"0.76625746",
"0.7597333",
"0.7593962",
"0.7572603",
"0.75130045",
"0.7468... | 0.0 | -1 |
Evaluate the state of the network. | def _eval_network(opts, step, network, sampler, criterion, name):
out_dir = os.path.join(opts["flags"].out_dir, "predictions", name)
total_loss = 0
if sampler.batch_idx.empty():
sampler.reset()
for i in range(sampler.num_batch):
inputs = sampler.get_minibatch()
num_frames = inpu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def evaluate(self, state):\n abstract",
"def evaluate(self) :\n for inp in self.inStates :\n if inp.getState() == 1 : return 1\n return 0",
"def evaluate(self) :\n for inp in self.inStates :\n if inp.getState() == 0 : return 0\n return 1",
"def evaluat... | [
"0.74112093",
"0.70588297",
"0.6899987",
"0.68873715",
"0.6779742",
"0.6657663",
"0.6569626",
"0.6552569",
"0.6487224",
"0.64455",
"0.6415692",
"0.6404486",
"0.6403002",
"0.63851297",
"0.6338195",
"0.6336563",
"0.6336563",
"0.629135",
"0.62471503",
"0.62129676",
"0.6190847",
... | 0.0 | -1 |
1hot encodes a tensor | def to_categorical(y, num_classes):
return np.eye(num_classes, dtype='uint8')[y] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def one_hot_encode(x):\n # TODO: Implement Function\n output = np.zeros((len(x), 10))\n \n for i, j in enumerate(x):\n output[i,j] = 1\n \n return output",
"def one_hot_encode(self, arr, n_labels):\n one_hot = np.zeros((np.multiply(*arr.shape), n_labels), dtype=np.float32)\... | [
"0.82578593",
"0.8061468",
"0.80140257",
"0.7917851",
"0.7914897",
"0.7883416",
"0.78429884",
"0.78089696",
"0.7765784",
"0.77376443",
"0.77376443",
"0.7733915",
"0.7728651",
"0.77133274",
"0.7686273",
"0.76797515",
"0.75851345",
"0.7560708",
"0.75560004",
"0.75353223",
"0.75... | 0.0 | -1 |
combine unsigned ints read from a bit stream into one unsigned number, reading data as bigendian | def combine_bytes(data):
copy = data[:]
copy.reverse()
return sum(x << n*8 for n, x in enumerate(copy)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_unsigned_integer(stream, size):\n\t\n\tvalue = 0\n\tfor i in xrange(0, size):\n\t\tbyte = ord(stream.read(1))\n\t\tvalue = (value << 8) | byte\n\treturn value",
"def _unpack_uvarint(data: bytes) -> Tuple[int, int]:\n shift = 0\n result = 0\n n = 0\n for b in data:\n n += 1\n re... | [
"0.6928272",
"0.6872669",
"0.6872669",
"0.66999763",
"0.6667149",
"0.6208907",
"0.62032974",
"0.61897427",
"0.61488444",
"0.60985625",
"0.60595274",
"0.6054974",
"0.60500926",
"0.6031135",
"0.5993187",
"0.59668046",
"0.5945269",
"0.5929245",
"0.590426",
"0.5901376",
"0.589111... | 0.68466026 | 3 |
Given a node index, return the list of indices of nodes from which hashes must be drawn. If first or last is specified, eliminate any node indices outside of that range. | def sources(self, index, first=None, last=None):
return sorted([ index + o for o in self.soffsets[index % self.p]
if (first is None or index+o >= first) and (last is None or index+o <= last) ]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def node_ids(self):\n # From: https://stackoverflow.com/questions/17415086/combine-consecutive-numbers-into-range-tuples\n groups = groupby(self.nodes.keys(), key=lambda item, c=count():item-next(c))\n temp = [list(g) for k, g in groups]\n return \"+\".join(\"{}-{}\".format(x[0], x[-1])... | [
"0.56695485",
"0.56025463",
"0.5569894",
"0.5530438",
"0.55079234",
"0.54982793",
"0.547392",
"0.5442931",
"0.54056287",
"0.54014844",
"0.53910404",
"0.5367651",
"0.53653526",
"0.53443533",
"0.5342611",
"0.53324443",
"0.5325862",
"0.5303529",
"0.5294532",
"0.5265312",
"0.5238... | 0.5767544 | 0 |
Given a node index, return the list of indices of nodes into which its hash must be placed. If first or last is specified, eliminate any node indices outside of that range. | def destinations(self, index, first=None, last=None):
return [ index + o for o in self.doffsets[index % self.p]
if (first is None or index+o >= first) and (last is None or index+o <= last) ] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _occupation_set(index):\n indices = set()\n\n # For bit manipulation we need to count from 1 rather than 0\n index += 1\n\n indices.add(index - 1)\n parent = index & (index - 1)\n index -= 1\n while index != parent:\n indices.add(index - 1)\n # Remove least significant one fr... | [
"0.57507855",
"0.5680255",
"0.55556613",
"0.55077046",
"0.54741836",
"0.5451544",
"0.54514635",
"0.543012",
"0.5406862",
"0.5403836",
"0.53645164",
"0.5354016",
"0.5353449",
"0.5322745",
"0.53200257",
"0.53136533",
"0.52859485",
"0.5284067",
"0.5275993",
"0.5258216",
"0.52121... | 0.5433693 | 7 |
Sample an implicit function over a structured point set. Uses ``vtk.vtkSampleFunction`` This method evaluates an implicit function and normals at each point in a ``vtk.vtkStructuredPoints``. The user can specify the sample dimensions and location in space to perform the sampling. To create closed surfaces (in conjuncti... | def sample_function(
function: _vtk.vtkImplicitFunction,
bounds: Sequence[float] = (-1.0, 1.0, -1.0, 1.0, -1.0, 1.0),
dim: Sequence[int] = (50, 50, 50),
compute_normals: bool = False,
output_type: np.dtype = np.double, # type: ignore
capping: bool = False,
cap_value: float = sys.float_info.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sample(self, point, n_samples=1):\n raise NotImplementedError(\"The sample method is not yet implemented.\")",
"def sample(f, *var_args):\n if len(var_args) == 1:\n return sample2d(f, var_args[0])\n elif len(var_args) == 2:\n return sample3d(f, var_args[0], var_args[1])\n else:\... | [
"0.566838",
"0.56506944",
"0.5361372",
"0.5212485",
"0.51781523",
"0.51290935",
"0.50389427",
"0.4963418",
"0.49593338",
"0.49545744",
"0.49289173",
"0.49129",
"0.49051726",
"0.48667166",
"0.48581916",
"0.48334667",
"0.48254326",
"0.48128986",
"0.47999626",
"0.4788792",
"0.47... | 0.6284732 | 0 |
Converts an infix expression to an equivalent postfix expression | def infix_to_postfix(input_str): # postfix requires that all operators proceed after the two operands that they work on
"""Input argument: a string containing an infix expression where tokens are
space separated. Tokens are either operators + - * / ** << >> or numbers (integers or floats)
Returns a Stri... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def infix_to_postfix(expr):\n # you may find the following precedence dictionary useful\n prec = {'*': 2, '/': 2,\n '+': 1, '-': 1}\n ops = Stack()\n postfix = []\n toks = expr.split()\n ### BEGIN SOLUTION\n opp = {'*', '/','+', '-'}\n for x in toks:\n if str.isdigit(x):\n... | [
"0.84862375",
"0.84411806",
"0.83714604",
"0.8317929",
"0.82398987",
"0.81870633",
"0.8186237",
"0.80231375",
"0.79577357",
"0.7864633",
"0.7835132",
"0.78280944",
"0.7824718",
"0.7773667",
"0.7717247",
"0.7704904",
"0.7704374",
"0.75154626",
"0.74926025",
"0.7488175",
"0.736... | 0.8037474 | 7 |
Converts a prefix expression to an equivalent postfix expression | def prefix_to_postfix(input_str): # prefix requires that all operators precede the two operands that they work on
"""Input argument: a string containing a prefix expression where tokens are
space separated. Tokens are either operators + - * / ** << >> or numbers (integers or floats)
Returns a String cont... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prefix_to_postfix(input_str: str) -> Any:\n \"\"\"Input argument: a string containing a prefix expression where tokens are \n space separated. Tokens are either operators + - * / ** << >> or numbers (integers or floats)\n Returns a String containing a postfix expression(tokens are space separated)\"\... | [
"0.7910258",
"0.76971376",
"0.7632609",
"0.7532239",
"0.7315681",
"0.72970444",
"0.7143097",
"0.70798165",
"0.696402",
"0.6858957",
"0.68345267",
"0.6814766",
"0.6807553",
"0.67959464",
"0.67956793",
"0.6742072",
"0.67193323",
"0.6619255",
"0.65679264",
"0.65528035",
"0.64230... | 0.7671706 | 2 |
Return the configuration from `config` and `state`. If the extension's configuration has a value other than "auto" (which is translated into the class `Recollection`), return this value, otherwise the saved value from the state variable. | def _get_config(self, state, controller, option):
config = self.config.get(f'{controller}.{option}', Recollection)
if config is Recollection:
s = state.get(controller, {}).get(option, None)
else:
s = config
logger.debug(
"_get_config(%s, %s, %s) = %s",... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_config() -> Config:\n return get_or_set('config', build_configuration)",
"def get_config() -> Optional[Config]:\n return CurrentConfig.get()",
"def get_config(config):\n global _config\n return _config",
"def get_config():\n return _config",
"def _get_config(self):\n return self._... | [
"0.7013418",
"0.6891643",
"0.6853772",
"0.6777893",
"0.6720835",
"0.6720835",
"0.6720835",
"0.6720835",
"0.6720835",
"0.6720835",
"0.6720835",
"0.6720835",
"0.6720835",
"0.6720835",
"0.6720835",
"0.6720835",
"0.6720835",
"0.6720835",
"0.6720835",
"0.6720835",
"0.6720835",
"... | 0.71906984 | 0 |
Write the state to a json file. | def write_state(self, state, file):
try:
with open(file, 'w') as f:
json.dump(state, f)
except IOError as e:
logger.error(
"Cannot open state file '%s' for writing: %s",
file, e)
except Exception as e:
logger.err... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_to_file(self):\n with open('learning_player/states.json') as json_file:\n states = json.load(json_file)\n\n states.append(self.__dict__)\n with open('learning_player/states.json', 'w') as json_file:\n json.dump(states, json_file)",
"def saveStateOfThisRun(self... | [
"0.8270986",
"0.7794114",
"0.77099705",
"0.7600188",
"0.7585349",
"0.75544494",
"0.7553102",
"0.74732256",
"0.74434435",
"0.741947",
"0.7328562",
"0.7327419",
"0.72887045",
"0.72612464",
"0.7229592",
"0.71862876",
"0.71855694",
"0.7161913",
"0.7161913",
"0.7161913",
"0.712077... | 0.86429155 | 0 |
Returns True or False indicating whether or not the specified target is busy. `target_id` is a target ID (or None for the first target) | def target_is_busy(self, target_id=0):
try:
target = self.target(target_id=target_id)
except:
raise NoSuchTargetException()
return target['state'] == "running" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def target_is_valid(self, target_id=0):\n try:\n target = self.target(target_id=target_id)\n except:\n return False\n return target['state'] != \"invalid\"",
"def target_exists(self, target_id=0):\n try:\n target = self.target(target_id=target_id)\n ... | [
"0.7083309",
"0.66177404",
"0.6520715",
"0.6164742",
"0.60301095",
"0.59567654",
"0.58135223",
"0.5720924",
"0.57065755",
"0.55763435",
"0.5504121",
"0.54620534",
"0.5459577",
"0.5459136",
"0.5457219",
"0.54071206",
"0.5406778",
"0.5355014",
"0.5302238",
"0.52814466",
"0.5275... | 0.86267734 | 0 |
CHECKING IF USER DETAILS ALREADY EXIST | def test_already_existing_user(self):
self.user.registration(
"Githeri", "githeri.man@yahoo.com", "iwantgitheri", "iwantgitheri")
msg = self.user.registration("Githeri",
"githeri.man@yahoo.com",
"iwantgitheri",
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_user_if_exists(self):\n user = User.objects.create(username=self.username)\n actual = get_user_if_exists(None, self.details, user=user)\n self.assertDictEqual(actual, {'is_new': False})",
"def _has_data(cls):\n return User.objects.count() > 0",
"def user_exists(self,uni... | [
"0.7120176",
"0.70901453",
"0.7059865",
"0.68934196",
"0.68896997",
"0.6880093",
"0.6863692",
"0.68182296",
"0.6751712",
"0.67213714",
"0.6720498",
"0.67177105",
"0.6694013",
"0.66854155",
"0.6685036",
"0.6682257",
"0.66495514",
"0.6624711",
"0.66221464",
"0.65893036",
"0.658... | 0.6039411 | 87 |
Generate a random string of fixed length | def genMsg(self):
return os.urandom(self.messageSize) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _generate_random_string(length: int):\n\tall_chars = string.ascii_letters + string.digits\n\treturn ''.join(random.choices(all_chars, k=length))",
"def generate_random_string(length=6):\n n = int(length / 2 + 1)\n x = binascii.hexlify(os.urandom(n))\n s = x[:length]\n return s.decode(\"utf-8\")",... | [
"0.8678726",
"0.85725635",
"0.8546959",
"0.852769",
"0.85201234",
"0.84315515",
"0.84307504",
"0.84138894",
"0.84099346",
"0.8388408",
"0.8344307",
"0.8342706",
"0.83389807",
"0.8332531",
"0.83217525",
"0.829651",
"0.829245",
"0.8281027",
"0.8280717",
"0.8279932",
"0.8263646"... | 0.0 | -1 |
Get a COE cluster by name or ID. | def get_coe_cluster(self, name_or_id, filters=None):
return _utils._get_entity(self, 'coe_cluster', name_or_id, filters) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_cluster(self,cluster_name,project_id=''):\n print( f'>>>>>>{self.project_id}')\n if project_id == '':\n project_id = self.project_id\n return self.get('{}/groups/{}/clusters/{}'.format(ApiVersion.A1.value,project_id,cluster_name))",
"def show_cluster(name: str) -> Cluster:\n environment ... | [
"0.7207319",
"0.71878326",
"0.7160077",
"0.70927954",
"0.7061884",
"0.6977045",
"0.6878093",
"0.6857844",
"0.68132865",
"0.6691251",
"0.66535586",
"0.6591472",
"0.6578208",
"0.6529788",
"0.64571756",
"0.6396079",
"0.6396057",
"0.6388732",
"0.6335889",
"0.6332657",
"0.6322989"... | 0.77385813 | 0 |
Get details about the CA certificate for a cluster by name or ID. | def get_coe_cluster_certificate(self, cluster_id):
return (
self.container_infrastructure_management.get_cluster_certificate(
cluster_id
)
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_database_ca(cluster_id: Optional[str] = None,\n opts: Optional[pulumi.InvokeOptions] = None) -> AwaitableGetDatabaseCaResult:\n __args__ = dict()\n __args__['clusterId'] = cluster_id\n opts = pulumi.InvokeOptions.merge(_utilities.get_invoke_opts_defaults(), opts)\n __ret__ = ... | [
"0.66048604",
"0.6386321",
"0.63464445",
"0.6285547",
"0.6187846",
"0.6114005",
"0.6114005",
"0.5819813",
"0.5746102",
"0.5740798",
"0.57380414",
"0.5684526",
"0.5592041",
"0.55871445",
"0.5570815",
"0.5529668",
"0.5506295",
"0.55015206",
"0.54997844",
"0.54760474",
"0.547521... | 0.724365 | 0 |
Get a cluster template by name or ID. | def get_cluster_template(self, name_or_id, filters=None, detail=False):
return _utils._get_entity(
self,
'cluster_template',
name_or_id,
filters=filters,
detail=detail,
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_kubernetes_cluster_template(self, id: str) -> dto.KubernetesClusterTemplate:\n raise errors.UnsupportedOperationError(\n \"Operation not supported for provider '{}'\".format(self.provider_name)\n )",
"def find_template_by_id(context, id):\n admin = context.getAdministrationSe... | [
"0.7409614",
"0.71715623",
"0.7106603",
"0.7072171",
"0.70463616",
"0.69070536",
"0.6860884",
"0.66583115",
"0.6598726",
"0.65511876",
"0.6513724",
"0.6478427",
"0.64676917",
"0.64584345",
"0.6451628",
"0.64360094",
"0.63890415",
"0.6380846",
"0.6341766",
"0.63381404",
"0.624... | 0.7906712 | 0 |
Iterates over a JSON to tranfsorm each element into a column. | def unnest_json(row_obj):
row = {}
for keys, value in iterate_dict(row_obj):
row[".".join(keys)] = value if value is not None else ''
return row | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __parse_json(df):\n\t\tcol_names = ['genres', 'production_companies', 'production_countries', 'cast', 'crew', 'spoken_languages',\n\t\t\t\t\t 'Keywords']\n\t\tvalue_names = ['name', 'name', 'iso_3166_1', 'name', 'name', 'name', 'name']\n\t\tfor col_name, value_name in zip(col_names, value_names):\n\t\t\t# df[c... | [
"0.61111945",
"0.5891938",
"0.577148",
"0.5539794",
"0.5530381",
"0.5472374",
"0.5375547",
"0.5357542",
"0.52405936",
"0.5234833",
"0.5218989",
"0.5130315",
"0.5128122",
"0.5116927",
"0.51161134",
"0.51108575",
"0.5097938",
"0.50966936",
"0.5023819",
"0.5005069",
"0.4988093",... | 0.5146833 | 11 |
Gets the RNN Cell | def get_cell(self, hidden_size, layer_num=1, dropout_keep_prob=None):
cells = []
for i in range(layer_num):
cell = tc.rnn.LSTMCell(num_units=hidden_size, state_is_tuple=True)
if dropout_keep_prob is not None:
cell = tc.rnn.DropoutWrapper(cell,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_rnn_cells(self) -> List[mx.rnn.BaseRNNCell]:\n return self.forward_rnn.get_rnn_cells() + self.reverse_rnn.get_rnn_cells()",
"def get_rnn_cells(self):\n return [self.rnn]",
"def cell(self):\n return self._cell",
"def _rnn_cells(self) -> RNNCellTuple:\n return(RNN_CELL_TYPES[sel... | [
"0.7071522",
"0.7056599",
"0.66891766",
"0.6675554",
"0.65457195",
"0.64880717",
"0.62699527",
"0.62504494",
"0.62408656",
"0.62313527",
"0.6226283",
"0.6213678",
"0.6135361",
"0.61141884",
"0.6108216",
"0.60593724",
"0.60573167",
"0.60551786",
"0.6010514",
"0.600054",
"0.598... | 0.0 | -1 |
Save the current Moderator state to a checkpoint file. | def save_checkpoint(self, name):
timestamp = datetime.datetime.now(self.time_zone).strftime("%Y-%m-%d_%H:%M:%S")
backup_dir = os.path.join(os.path.dirname(self.path), "backups")
checkpoint_path = os.path.join(backup_dir, "%s_%s.pickle" % (timestamp, name))
pickle.dump(self, open(checkpoint_path, "wb")) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def saveCheckpoint(self):\n time_stamp = time.strftime('%Y%m%d%H%M%S', time.gmtime())\n state_filename = os.path.join(self.saving_dir, 'checkpoint.' + time_stamp + '.pth.tar')\n mem_filename = os.path.join(self.saving_dir, 'memory.' + time_stamp + '.pth.tar')\n state = self.getSavingSta... | [
"0.7800833",
"0.77669865",
"0.7756615",
"0.7656153",
"0.76019496",
"0.7557086",
"0.75027186",
"0.7448348",
"0.744359",
"0.7431431",
"0.7386233",
"0.7312102",
"0.7297267",
"0.7296062",
"0.72138",
"0.7208526",
"0.71802557",
"0.71801674",
"0.7167179",
"0.7150605",
"0.71342236",
... | 0.6787339 | 49 |
Return the subject to use for phaserelated announcements. | def current_subject(self):
return "%s: %s" % (self.name, self.phase) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_subject(self):\n return self._subject",
"def subject(self):\n if \"subject\" in self._prop_dict:\n return self._prop_dict[\"subject\"]\n else:\n return None",
"def subject(self):\n return self._subject",
"def subject(self) -> pulumi.Output[str]:\n ... | [
"0.7917484",
"0.7905421",
"0.784974",
"0.78295887",
"0.78191876",
"0.7738317",
"0.7706493",
"0.76699775",
"0.7619518",
"0.7619518",
"0.74976015",
"0.74263394",
"0.73006403",
"0.72648025",
"0.70124346",
"0.70124346",
"0.6999631",
"0.6942836",
"0.68542796",
"0.6685712",
"0.6386... | 0.6965679 | 17 |
Changes the draft message on the Telegram servers. The changes are reflected in this object. Changing only individual attributes like for example the ``reply_to_msg_id`` should be done by providing the current | def set_message(self, text, no_webpage=None, reply_to_msg_id=None, entities=None):
result = self._client(SaveDraftRequest(
peer=self._peer,
message=text,
no_webpage=no_webpage,
reply_to_msg_id=reply_to_msg_id,
entities=entities
))
if r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def set_message(\n self, text=None, reply_to=0, parse_mode=(),\n link_preview=None):\n if text is None:\n text = self._text\n\n if reply_to == 0:\n reply_to = self.reply_to_msg_id\n\n if link_preview is None:\n link_preview = self.li... | [
"0.65542597",
"0.632359",
"0.60106605",
"0.5982928",
"0.58589375",
"0.5721104",
"0.5651137",
"0.56021875",
"0.5580924",
"0.55722326",
"0.5456161",
"0.5437725",
"0.5418407",
"0.5398267",
"0.5398267",
"0.5398267",
"0.5398267",
"0.5398267",
"0.5398267",
"0.5398267",
"0.5398267",... | 0.6506645 | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.