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 |
|---|---|---|---|---|---|---|
Return the heuristic value for a given state. Default heuristic function used is h(n) = number of misplaced tiles | def h(self, node):
return sum(s != g for (s, g) in zip(node.state, self.goal)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def heuristic(state, puzzle):\n h = 0\n for i in range(puzzle.dimension):\n for j in range(puzzle.dimension):\n # (0, 0) -> 1 as value, (0, 2) -> 3 as value, etc\n value = i * puzzle.dimension + j + 1\n if value == puzzle.dimension ** 2: # value is ' '\n ... | [
"0.77346325",
"0.7654883",
"0.74284846",
"0.73011035",
"0.7242607",
"0.7046602",
"0.7026075",
"0.697503",
"0.68184316",
"0.6818057",
"0.674383",
"0.6740973",
"0.6732053",
"0.6711918",
"0.66688246",
"0.66471696",
"0.6638178",
"0.6495556",
"0.64928424",
"0.64860433",
"0.646674"... | 0.0 | -1 |
Load a dictionary of objects from a json file. This function loads a dictionary of objects from a json file. The | def json_load_dict(file, serializable_class=None):
read_dict = json.load(file)
if serializable_class:
try:
read_dict = dict([(k, serializable_class.json_deserialize(o)) \
for (k, o) in read_dict.items()])
except AttributeError:
raise TypeError... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load(self):\n with io.open(self.filename, encoding='utf-8') as f:\n self.load_from_dict(json.loads(f.read()))",
"def load_json(file_path):\n\n \n with open(file_path, 'r') as json_file:\n # print(file_path)\n dictionary = json.loads(json_file.read())\n\n return dictio... | [
"0.7506544",
"0.74715936",
"0.7309802",
"0.72842115",
"0.7261859",
"0.719322",
"0.71890604",
"0.71666133",
"0.7100827",
"0.7082036",
"0.7029916",
"0.70243615",
"0.7017344",
"0.6971616",
"0.6960963",
"0.69577605",
"0.69365466",
"0.69328463",
"0.69187915",
"0.6917001",
"0.68741... | 0.66113627 | 70 |
Load object from a deserialized json object. This method should load object from data returned by | def json_deserialize(json_object):
raise NotImplementedError('json_deserialize must be overriden') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_json(self):\n\n self.load_json_str(self.get_json_str())",
"def test_load_an_object_json_file(self):\n from test.resources import object_json\n self.assertEqual(object_json._data, {'answer': 42})\n self.assertEqual(len(object_json), 1)\n self.assertEqual(object_json['an... | [
"0.68574446",
"0.68526304",
"0.67517924",
"0.6714143",
"0.6706278",
"0.6699001",
"0.6689056",
"0.6678043",
"0.6648171",
"0.65466624",
"0.6534616",
"0.6517503",
"0.6515564",
"0.6510992",
"0.64804906",
"0.64561087",
"0.64272976",
"0.6400208",
"0.63936055",
"0.6375655",
"0.63674... | 0.6943058 | 0 |
Returns an asynchronous iterator that yields chunks of size n. Python3.5 available for Python 3.5+ only | def iter_chunked(self, n: int) -> AsyncStreamIterator[bytes]:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def chunks(l, n): # noqa: E741\n for i in range(0, len(l), n):\n yield l[i : i + n] # noqa: E203",
"def chunks(seq: Sequence[T], n: int) -> Iterator[Sequence[T]]:\n for i in range(0, len(seq), n):\n yield seq[i:i + n]",
"def chunks(iterable: Iterable, n: int = 1000, cls: T... | [
"0.71770084",
"0.714404",
"0.7130353",
"0.7025188",
"0.70212555",
"0.70097613",
"0.70097613",
"0.700124",
"0.6995675",
"0.6995675",
"0.6995675",
"0.6995675",
"0.6995675",
"0.69865084",
"0.6983201",
"0.69800216",
"0.6975258",
"0.69691044",
"0.69691044",
"0.6964514",
"0.6963392... | 0.8406365 | 0 |
Generate split data with temporal_basket_split. Generate split data with temporal_basket_split method. | def make_temporal_basket_split(
self, data=None, test_rate=0.1, n_negative=100, by_user=False, n_test=10
):
if data is None:
data = self.load_interaction()
if not isinstance(data, pd.DataFrame):
raise RuntimeError("data is not a type of DataFrame")
if DEFAUL... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_temporal_basket_split(\n self,\n test_rate=0.1,\n n_negative=100,\n by_user=False,\n n_test=10,\n download=False,\n force_redo=False,\n ):\n processed_temporal_basket_split_path = os.path.join(\n self.processed_path, \"temporal_basket\"... | [
"0.6783587",
"0.6612773",
"0.6102922",
"0.58242923",
"0.5757818",
"0.5713793",
"0.5695739",
"0.5482762",
"0.5446944",
"0.53853124",
"0.5376321",
"0.5373172",
"0.53675795",
"0.535025",
"0.53106225",
"0.5301982",
"0.5292067",
"0.5278453",
"0.5264799",
"0.5236665",
"0.52323955",... | 0.7527967 | 0 |
Create and return a fake RiakObject. | def riak_object(self, modelcls, key):
bucket_name = self.bucket_name(modelcls)
riak_object = FakeRiakObject(self._state, bucket_name, key)
riak_object.set_content_type("application/json")
riak_object.set_data({'$VERSION': modelcls.VERSION})
return riak_object | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_object():\n return object()",
"def construct_fake(self, name: str) -> ResponsibleFake:\n fake: NaiveFake = getattr(self.faker, name)\n return lru_cache(maxsize=None)(lambda _: fake())",
"def _mkObject(self):\n return ImmutableObject(\n store=self.store,\n ... | [
"0.6498993",
"0.6185029",
"0.6068252",
"0.5993571",
"0.59780276",
"0.5866788",
"0.58306056",
"0.5774978",
"0.57056415",
"0.566206",
"0.5632154",
"0.5630083",
"0.56242526",
"0.55080545",
"0.55028653",
"0.54455763",
"0.5429836",
"0.54195917",
"0.54066926",
"0.5395255",
"0.53947... | 0.71742576 | 0 |
Construct and return an index page object. | def _return_index_page(self, bucket_name, index_name, start_value,
end_value, return_terms, max_results, results,
continuation):
if not return_terms:
results = [key for _, key in results]
return FakeMemoryIndexPage(self, continuation, res... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index():\n\n return {\n 'page': 'index',\n }",
"def get_index():\n return render_template('index.html')",
"def index():\n return render_template('pages/index.html', isNav=True)",
"def index_page(data):\n main_index = [html.H1(\"INDEX\"),\n html.Div([html.A(\"Charact... | [
"0.71548754",
"0.64618194",
"0.6436049",
"0.6369808",
"0.6298626",
"0.6282117",
"0.6282117",
"0.6282117",
"0.62155414",
"0.6210448",
"0.6186697",
"0.61463696",
"0.60686356",
"0.606648",
"0.6062112",
"0.60497737",
"0.60472274",
"0.60227215",
"0.6021287",
"0.6020807",
"0.600525... | 0.67040664 | 1 |
Take a string and return a valid filename constructed from it. | def format_filename(s):
valid_chars = "-_.() %s%s" % (string.ascii_letters, string.digits)
filename = ''.join(c for c in s if c in valid_chars)
filename = filename.replace(' ', '_') # I don't like spaces in filenames.
return filename | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def format_filename(s: str):\n # from: https://gist.github.com/seanh/93666\n\n valid_chars = \"-_.() %s%s\" % (string.ascii_letters, string.digits)\n filename = ''.join(c for c in s if c in valid_chars)\n filename = filename.replace(' ', '_') # I don't like spaces in filenames.\n return filename",
... | [
"0.79578626",
"0.7950373",
"0.78903204",
"0.7826596",
"0.7820293",
"0.76784",
"0.7637565",
"0.7621958",
"0.7454506",
"0.7445902",
"0.74298054",
"0.74010444",
"0.7303567",
"0.72452104",
"0.71115357",
"0.70342577",
"0.6890423",
"0.6883135",
"0.68203956",
"0.67677194",
"0.674243... | 0.7780477 | 7 |
Constructs a Configuration, validating the values in `dictionary`, expecting paths to be within `location`. | def load_from_dict(
cls, dictionary: Dict[str, Any], *, location: Path
) -> "Configuration":
schema = {
"type": "object",
"additionalProperties": False,
"required": ["destination", "namespace", "requirements"],
"properties": {
"destina... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_config(location):\n if not os.path.exists(location):\n full_path = os.path.abspath(location)\n logging.fatal('Config not found - expected a configfile at: [{loc}] - exiting.'.format(loc=full_path))\n sys.exit(1)",
"def __init__(self, location=None, parent=None, **kwargs):\n ... | [
"0.5855621",
"0.5390428",
"0.5295843",
"0.52190936",
"0.51966506",
"0.51655555",
"0.513441",
"0.5131885",
"0.5109062",
"0.5101511",
"0.5075852",
"0.50618964",
"0.49730387",
"0.49712208",
"0.4969562",
"0.49658695",
"0.49602363",
"0.4941562",
"0.49261326",
"0.4875033",
"0.48718... | 0.74685436 | 0 |
Iterate through given lines iterator (file object or list of lines) and return ngram frequencies. The return value is a dict mapping the length of the ngram to a collections.Counter object of ngram tuple and number of times that ngram occurred. Returned dict includes ngrams of length min_length to max_length. | def count_ngrams(lines, min_length=2, max_length=4):
lengths = range(min_length, max_length + 1)
ngrams = {length: collections.Counter() for length in lengths}
queue = collections.deque(maxlen=max_length)
# Helper function to add n-grams at start of current queue to dict
def add_queue():
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def count_ngrams(self, lines, min_length=2, max_length=4):\n self.lengths = range(min_length, max_length + 1)\n self.ngrams = {length: collections.Counter() for length in lengths}\n self.queue = collections.deque(maxlen=max_length)",
"def count_ngrams(lines, min_length=1, max_length=4):\n ... | [
"0.7684961",
"0.76285505",
"0.73904157",
"0.680265",
"0.67729276",
"0.67621726",
"0.6700955",
"0.6661531",
"0.66487426",
"0.659852",
"0.6427865",
"0.6388674",
"0.63881356",
"0.6381354",
"0.63468874",
"0.63448745",
"0.6335181",
"0.6334952",
"0.63114697",
"0.6289899",
"0.628243... | 0.78236645 | 0 |
Computes the area under the precisionrecall curve. | def prc_auc(targets: List[int], preds: List[float]) -> float:
precision, recall, _ = precision_recall_curve(targets, preds)
return auc(recall, precision) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pr_auc_score(precision: list, recall: list) -> float:\n return quadrature_calculator(recall, precision)",
"def compute_ap(recall, precision):\r\n # correct AP calculation\r\n # first append sentinel values at the end\r\n mrec = np.concatenate(([0.0], recall, [1.0]))\r\n mpre = np.concatenate((... | [
"0.8208191",
"0.79268074",
"0.79202956",
"0.790217",
"0.790217",
"0.78619045",
"0.7840341",
"0.75207496",
"0.74233323",
"0.7329511",
"0.73156524",
"0.708228",
"0.7062399",
"0.7015234",
"0.6936933",
"0.68373823",
"0.6776866",
"0.6753741",
"0.6667789",
"0.6637576",
"0.6547334",... | 0.67768353 | 18 |
Computes the accuracy of a binary prediction task using a given threshold for generating hard predictions. Alternatively, computes accuracy for a multiclass prediction task by picking the largest probability. | def accuracy(targets: List[int], preds: Union[List[float], List[List[float]]],
threshold: float = 0.5) -> float:
if type(preds[0]) == list: # multiclass
hard_preds = [p.index(max(p)) for p in preds]
else:
hard_preds = [1 if p > threshold else 0 for p in preds] # binary prediction... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def accuracy(targets: List[int],\n preds: Union[List[float], List[List[float]]],\n threshold: float = 0.5) -> float:\n if type(preds[0]) == list: # multiclass\n hard_preds = [p.index(max(p)) for p in preds]\n else:\n hard_preds = [1 if p > threshold else 0 for p in pred... | [
"0.7709991",
"0.7511051",
"0.7276398",
"0.70488864",
"0.70320666",
"0.69131315",
"0.6908888",
"0.68309194",
"0.6726362",
"0.67168456",
"0.6644039",
"0.6570016",
"0.64819574",
"0.6433799",
"0.643102",
"0.64011323",
"0.6399237",
"0.6395455",
"0.6382157",
"0.63656",
"0.63620985"... | 0.7749667 | 0 |
Builds a PyTorch Optimizer. | def build_optimizer(model: nn.Module, args: Namespace) -> Optimizer:
params = [{'params': model.parameters(), 'lr': args.init_lr, 'weight_decay': 0}]
return Adam(params) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_optimizer(cfg: CfgNode, model: torch.nn.Module) -> torch.optim.Optimizer:\n norm_module_types = (\n torch.nn.BatchNorm1d,\n torch.nn.BatchNorm2d,\n torch.nn.BatchNorm3d,\n torch.nn.SyncBatchNorm,\n # NaiveSyncBatchNorm inherits from BatchNorm2d\n torch.nn.Grou... | [
"0.6598968",
"0.6491794",
"0.64786536",
"0.6437391",
"0.63047016",
"0.61300355",
"0.60748035",
"0.6072925",
"0.598902",
"0.5971825",
"0.59371614",
"0.5908207",
"0.5907911",
"0.5886632",
"0.5873024",
"0.58706564",
"0.5867648",
"0.58661216",
"0.5852822",
"0.5833402",
"0.579277"... | 0.66013163 | 0 |
Builds a PyTorch learning rate scheduler. | def build_lr_scheduler(optimizer: Optimizer, args: Namespace,
total_epochs: List[int] = None) -> _LRScheduler:
# Learning rate scheduler
return NoamLR(
optimizer=optimizer,
warmup_epochs=[args.warmup_epochs],
total_epochs=total_epochs or [args.epochs] * args.num_lr... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def scheduler_creator(optimizer, config):\n return torch.optim.lr_scheduler.StepLR(optimizer, step_size=5, gamma=0.9)",
"def make_lr_scheduler(lr: float, final_lr: float, n_epochs: int,\n verbose: int = 1) -> keras.callbacks.LearningRateScheduler:\n schedule = build_schedule(lr, final_... | [
"0.7930454",
"0.7270104",
"0.72256047",
"0.7176108",
"0.7084193",
"0.70634633",
"0.7060095",
"0.70600694",
"0.7007854",
"0.69914424",
"0.6941896",
"0.6919559",
"0.69080704",
"0.6861845",
"0.6807765",
"0.67986774",
"0.6795805",
"0.6786529",
"0.67793083",
"0.67793083",
"0.67736... | 0.7315069 | 1 |
Test that a given password policy is valid according to the first stars' rules. | def test_validate_first_star_policy(policy: str, expected: bool):
assert day2.validate_first_star_policy(policy) == expected | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_pwd_policy1(processed):\n policy, letter, pwd = processed\n return pwd.count(letter) in policy",
"def check_pwd_policy2(processed):\n policy, letter, pwd = processed\n idx1 = policy[0] - 1\n idx2 = policy[-1] - 1\n return (pwd[idx1] == letter) ^ (pwd[idx2] == letter)",
"def test_val... | [
"0.7051201",
"0.70007664",
"0.69529474",
"0.68343574",
"0.66242343",
"0.6584886",
"0.6536774",
"0.6471579",
"0.64339715",
"0.64224905",
"0.63708144",
"0.6358362",
"0.6347376",
"0.63193583",
"0.6316809",
"0.63018954",
"0.6277832",
"0.6274736",
"0.6211703",
"0.61495656",
"0.613... | 0.65974146 | 5 |
Test that a given password policy is valid according to the second stars' rules. | def test_validate_second_star_policy(policy: str, expected: bool):
assert day2.validate_second_star_policy(policy) == expected | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_pwd_policy2(processed):\n policy, letter, pwd = processed\n idx1 = policy[0] - 1\n idx2 = policy[-1] - 1\n return (pwd[idx1] == letter) ^ (pwd[idx2] == letter)",
"def check_pwd_policy1(processed):\n policy, letter, pwd = processed\n return pwd.count(letter) in policy",
"def test_che... | [
"0.7291398",
"0.69760734",
"0.6725762",
"0.6681516",
"0.6674957",
"0.660869",
"0.659909",
"0.6551593",
"0.64916486",
"0.64302176",
"0.6377811",
"0.63685375",
"0.6358652",
"0.6352963",
"0.6323817",
"0.62727654",
"0.6260491",
"0.6254762",
"0.6252222",
"0.6249409",
"0.6229831",
... | 0.7226481 | 1 |
Gets all the articles | def articles():
entries = []
cur = g.db.execute(
"""
SELECT entries.location FROM categories
INNER JOIN entries ON
entries.slug = categories.slug AND
entries.published = categories.published
WHERE categories.category='{category}'
ORDER BY entries.pub... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_articles(db:Session):\n return db.query(ArticleModel).all()",
"def articles(self):\n return self.get_queryset().filter(content_type__model='article').order_by('-articles__published_at')",
"def articles(self):\n return articles.Articles(self)",
"def articles(self):\r\n retu... | [
"0.8152243",
"0.79722065",
"0.7871781",
"0.7833883",
"0.769121",
"0.75862175",
"0.75804",
"0.7577904",
"0.74154687",
"0.7402131",
"0.7390644",
"0.73225033",
"0.732051",
"0.73135287",
"0.7283619",
"0.712267",
"0.7118482",
"0.7115349",
"0.70855975",
"0.70765924",
"0.7034778",
... | 0.63388735 | 51 |
Removes the filename extension | def clean_filename(file):
return file.split('.')[0] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strip_extension(filename):\n return filename.rsplit('.',1)[-2]",
"def filename_strip_ext(filename):\n base = os.path.basename(filename)\n # Strip file extension\n return os.path.splitext(base)[0]",
"def clear_ext(x):\r\n return os.path.splitext(os.path.basename(x))[0]",
"def remove_extensi... | [
"0.8577537",
"0.8402366",
"0.82835704",
"0.7953714",
"0.75720996",
"0.74829245",
"0.74663013",
"0.7405754",
"0.7345079",
"0.73050994",
"0.7301551",
"0.7291763",
"0.7096758",
"0.7093853",
"0.7092374",
"0.7085213",
"0.70423526",
"0.70324636",
"0.69982874",
"0.6982967",
"0.69548... | 0.7704698 | 4 |
Returns the block containing addr. If the block is not present, it calls read on the next level store. | def _load_block(self, addr):
ret_block = None
tag, set_index, offset = self._decompose(addr)
if set_index not in self._d:
self._d[set_index] = []
block_list = self._d[set_index]
for tag_, block in block_list:
if tag == tag_:
self._track(a... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read(self, addr: str) -> dict:\n for block in self.__mem:\n if block['address'] == addr:\n return block\n\n return {}",
"def getBlock(self, addr: ghidra.program.model.address.Address) -> ghidra.program.model.mem.MemoryBlock:\n ...",
"def get_block(self, chunk,... | [
"0.71545273",
"0.6975174",
"0.66679907",
"0.65838784",
"0.6459256",
"0.634004",
"0.633193",
"0.63195604",
"0.6292701",
"0.6288051",
"0.6278899",
"0.62583405",
"0.6253954",
"0.6194434",
"0.61794126",
"0.60847723",
"0.6075524",
"0.6063847",
"0.6043325",
"0.6032997",
"0.5892681"... | 0.76011753 | 0 |
Get a grid entry. | async def get(self, grid_id):
ret = await self.db.grids.find_one({'grid_id':grid_id},
projection={'_id':False})
if not ret:
self.send_error(404, reason="Grid not found")
else:
self.write(ret)
self.finish() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getObject(self, row, column, gameGrid=None):\n if not gameGrid:\n gameGrid = self.gameGrid\n return gameGrid.getItem(row, column)",
"def get_tile(self, row, col):\n # replace with your code\n return self._grid[row][col]",
"def get_tile(self, row, col):\n # repl... | [
"0.67409325",
"0.6644148",
"0.6644148",
"0.6644148",
"0.66041654",
"0.65990686",
"0.65252686",
"0.6521284",
"0.64955336",
"0.64949054",
"0.6484982",
"0.645304",
"0.6406731",
"0.6405405",
"0.6397506",
"0.6296497",
"0.6248816",
"0.622451",
"0.6198434",
"0.61945254",
"0.6157268"... | 0.60561895 | 31 |
Get absolute path to resource, works for dev and for PyInstaller | def resource_path(relative_path):
try:
# PyInstaller creates a temp folder and stores path in _MEIPASS
base_path = sys._MEIPASS
except Exception:
base_path = os.path.abspath(".")
return os.path.join(base_path, relative_path) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_resource_path():\n return os.path.join(os.path.dirname(__file__), \"resources\") + os.path.sep",
"def resourcePath(relative):\r\n try:\r\n # PyInstaller creates a temp folder and stores path in _MEIPASS\r\n base_path = sys._MEIPASS\r\n except Exception:\r\n base_path = os.pa... | [
"0.83704215",
"0.8281178",
"0.8249269",
"0.81396633",
"0.8114569",
"0.80989784",
"0.8094434",
"0.80801415",
"0.8068151",
"0.8067846",
"0.8057441",
"0.8054995",
"0.80453163",
"0.80453163",
"0.80453163",
"0.80453163",
"0.80453163",
"0.80453163",
"0.80453163",
"0.80453163",
"0.8... | 0.8062881 | 16 |
Random weights drawn from a Gaussian | def norm_weight(nin, nout=None, scale=0.01, ortho=True):
if nout is None:
nout = nin
if nout == nin and ortho:
W = ortho_weight(nin)
else:
W = scale * numpy.random.randn(nin, nout)
return W.astype('float32') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_gaussian_random(self):\n u1 = generateRandom()\n u2 = generateRandom()\n if u1 < 1e-6:\n u1 = 1e-6\n return sqrt(-2 * log(u1)) * cos(2 * pi * u2)",
"def randomizeWeights(self, rand_distr):\n raise NotImplementedError",
"def _random_weight_initialization(se... | [
"0.69253546",
"0.6907757",
"0.6906672",
"0.6900726",
"0.6889791",
"0.6867258",
"0.6847343",
"0.6796425",
"0.67804855",
"0.6768728",
"0.67305326",
"0.6666161",
"0.6633314",
"0.66207737",
"0.65838647",
"0.65782684",
"0.655484",
"0.65189344",
"0.65089655",
"0.6487783",
"0.647785... | 0.0 | -1 |
Convert string to datetime object. | def _get_datetime(dt_value):
result = None
if result is None:
result = _get_datetime_from_format(dt_value, "%Y-%m-%d %H:%M:%S.%f %z")
if result is None:
result = _get_datetime_from_format(dt_value, "%Y-%m-%d %H:%M:%S.%f")
if result is None:
result = _get_datetime_from_format(dt_value, "%Y-%m-%d %H:%... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def str_to_datetime(str):\n\n\treturn (datetime.strptime(str, \"%Y-%m-%dT%H:%M:%S.%fZ\"))",
"def str2date(s):\n return datetime.strptime(s.decode(), \"%Y-%m-%d %H:%M:%S\")",
"def str_to_datetime(str):\n if not str:\n return str\n return datetime.datetime.strptime(str.split(\".\")[0], DEFAUL... | [
"0.78559595",
"0.7806504",
"0.76967424",
"0.76847774",
"0.7623683",
"0.7548493",
"0.7525062",
"0.7456067",
"0.744933",
"0.7443482",
"0.743952",
"0.7422947",
"0.73081374",
"0.7255298",
"0.72483724",
"0.7230942",
"0.72260016",
"0.722573",
"0.7221167",
"0.72035706",
"0.71921664"... | 0.0 | -1 |
Returns event data matching the event label specified or None. | def _get_last_event(device_event_file_path, event_label, timeout=1.0):
result = None
timedout = False
file_exists, remaining_timeout = _wait_for_event_file(device_event_file_path,
timeout)
if not file_exists:
timedout = True
return result, timedou... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _getData(self, label):\n\n try:\n return self._data[label]\n except KeyError:\n try:\n field = ATOMIC_FIELDS[label]\n except KeyError:\n return None\n else:\n return getattr(self, '_get' + field.meth_pl)()",
... | [
"0.6986888",
"0.6744777",
"0.6611872",
"0.6522634",
"0.6315734",
"0.6216993",
"0.6191255",
"0.5773424",
"0.57695127",
"0.57607955",
"0.5585442",
"0.55435276",
"0.55417466",
"0.54313314",
"0.54313314",
"0.5372679",
"0.535484",
"0.53264093",
"0.5309692",
"0.5295486",
"0.5274525... | 0.51357186 | 32 |
r"""Return the matching group of the event label regex if one is found. | def get_last_event_state(self,
event_label,
event_name=None,
raise_error=False,
timeout=1.0,
group_index=0):
if not event_name:
event_name = event_label
result = self.get_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def group(self, group_num):\n if self.rematch is None:\n return None\n else:\n return self.rematch.group(group_num)",
"def _reg_catch(reg_ex, text, group_id=1):\n\n\tmatch = re.search(reg_ex, text)\n\tif match:\n\t\treturn match.group(group_id)\n\telse:\n\t\treturn None",
"d... | [
"0.6243117",
"0.60847455",
"0.6034069",
"0.60160875",
"0.5840702",
"0.5764992",
"0.56929356",
"0.56208205",
"0.5490368",
"0.5478569",
"0.5462098",
"0.5397177",
"0.53950393",
"0.53933126",
"0.53859985",
"0.5336552",
"0.5291058",
"0.52490413",
"0.5186651",
"0.5180022",
"0.51639... | 0.5116134 | 27 |
Locates a datetime.datetime closest to target datetime. | def _nearest_datetime(self, datetime_list, target_datetime):
if not datetime_list:
raise errors.ParserError(
"Input parameter datetime_list length is zero. Required"
" parameters: [datetime.datetime], datetime.datetime")
work_list = [entry for entry in datetime_list if entry < target_d... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _closest_date(target_dt, date_list, before_target=None) -> datetime.date | None:\n\n def time_before(d):\n return target_dt - d if d <= target_dt else datetime.timedelta.max\n\n def time_after(d):\n return d - target_dt if d >= target_dt else datetime.timedelta.max\n\n def any_time(d):\n... | [
"0.6702089",
"0.6500694",
"0.64598507",
"0.585127",
"0.57860357",
"0.56574386",
"0.5651094",
"0.56321347",
"0.56310844",
"0.55818236",
"0.5565437",
"0.554823",
"0.54743797",
"0.5420503",
"0.5417901",
"0.526718",
"0.52564967",
"0.52448344",
"0.52256316",
"0.5214709",
"0.519476... | 0.7585258 | 0 |
This function constructs the URL to a user's profile. | def get_profile_url(lookup_value, lookup_type="id"):
if lookup_type == "username":
username = lookup_value
else:
username = get_username(lookup_value, lookup_type)
profile_url = f"{base_url}/people/{username}"
return profile_url | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def profile_url(self):\n return reverse(\"auth_profile\", args=[self.user.username])",
"def get_absolute_url(self):\n return '/profile/%s' % self.id",
"def get_absolute_url(self):\n\n return reverse('profile', args=[str(self.user.username)])",
"def get_absolute_url(self):\n return... | [
"0.8227132",
"0.7430972",
"0.71914357",
"0.6894003",
"0.6826512",
"0.6684108",
"0.6663101",
"0.6608801",
"0.6577758",
"0.6514719",
"0.6459156",
"0.64151084",
"0.6401612",
"0.63838965",
"0.63838965",
"0.63838965",
"0.6374063",
"0.6371142",
"0.6349622",
"0.6319628",
"0.6292984"... | 0.7533327 | 1 |
Assess if Docker should be used based on the value of args. | def should_use_docker(dockerize_pip: DockerizePipArgTypeDef = None) -> bool:
if isinstance(dockerize_pip, bool):
return dockerize_pip
if isinstance(dockerize_pip, str):
if dockerize_pip == "non-linux" and not sys.platform.startswith("linux"):
return True
try:
ret... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _is_docker(self) -> bool:\n from hubble.executor.helper import is_valid_docker_uri\n\n uses = getattr(self.args, 'uses', '')\n return is_valid_docker_uri(uses)",
"def docker_allow_fallback():\n return False",
"def req_build(container):\n try:\n return 'dock... | [
"0.75592434",
"0.6791129",
"0.641314",
"0.63690114",
"0.6301101",
"0.61071885",
"0.60725427",
"0.60477525",
"0.58751506",
"0.5770867",
"0.5769221",
"0.5697177",
"0.5614681",
"0.55873924",
"0.55785286",
"0.55209535",
"0.5489136",
"0.545635",
"0.53722596",
"0.5362115",
"0.53584... | 0.6928599 | 1 |
Return the appropriate region to use when uploading functions. Select the appropriate region for the bucket where lambdas are uploaded in. | def select_bucket_region(
custom_bucket: Optional[str],
hook_region: Optional[str],
cfngin_bucket_region: Optional[str],
provider_region: str,
) -> str:
region = None
region = hook_region if custom_bucket else cfngin_bucket_region
return region or provider_region | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def function_region(self) -> str:\n return pulumi.get(self, \"function_region\")",
"def load_aws_region_name() -> str:\n session = boto3.session.Session()\n region_name = (\n click.get_current_context().params.get(\"region\") or session.region_name\n )\n return region_name",
"def regi... | [
"0.7334205",
"0.6579131",
"0.6273241",
"0.6175507",
"0.6165684",
"0.6162876",
"0.6162876",
"0.6162876",
"0.6162876",
"0.6162876",
"0.6162876",
"0.6162876",
"0.6162876",
"0.6162876",
"0.6162876",
"0.6162876",
"0.6162876",
"0.6162876",
"0.61409694",
"0.6136126",
"0.6130676",
... | 0.71261233 | 1 |
remove distracting whitespaces and newline characters | def bs_preprocess(html):
pat = re.compile('(^[\s]+)|([\s]+$)', re.MULTILINE)
html = re.sub(pat, '', html) # remove leading and trailing whitespaces
html = re.sub('\n', ' ', html) # convert newlines to spaces
# this preserves newline delimiters
html = re.sub(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clean_whitespace(text):\n return text\n #return re.sub(r'\\r\\n|\\n', \"\\t\", text)",
"def removeSingleChars(self) -> None:\n self.text = re.sub('\\s[^\\n\\s]\\s', ' ', self.text)",
"def _removeWhitespaces(self, s):\n return s.translate({ord(c): None for c in string.whitespace})",
"... | [
"0.7512734",
"0.74011576",
"0.73931",
"0.7392397",
"0.72668093",
"0.7214466",
"0.71911186",
"0.7189776",
"0.7180525",
"0.7179743",
"0.7165845",
"0.7156132",
"0.71512353",
"0.7145525",
"0.7124246",
"0.71108913",
"0.7079354",
"0.7075042",
"0.7049608",
"0.70375574",
"0.70324016"... | 0.0 | -1 |
View function for home page of site. | def index(request, template_name='index.html'):
context_dict = {}
model = Uni
column_headers = ['rank', 'name', 'location', 'city', 'scores_overall']
check_fields = ['scores_citations', 'scores_industry_income', 'scores_international_outlook', 'scores_research', 'scores_teaching', 'stats_student_staff_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def home(request):\n\treturn render(request, \"compta/home.html\")",
"def home_page(request):\r\n return render(request, 'ez_main/home_page.html')",
"def home(request):\r\n return render(request, 'home.html')",
"def homepage(request):\n\treturn render(request, 'core/homepage.html')",
"def homepage(req... | [
"0.8493426",
"0.84268916",
"0.83415145",
"0.83306193",
"0.82976943",
"0.8295291",
"0.8276345",
"0.82545686",
"0.82155704",
"0.8132563",
"0.81246215",
"0.81224865",
"0.8121264",
"0.81049734",
"0.8098485",
"0.80935514",
"0.80935514",
"0.80935514",
"0.80935514",
"0.80935514",
"0... | 0.0 | -1 |
Create an array of the given shape and populate it with random samples from a uniform distribution over [0, 1). | def test_data():
batch_size = 10
input_dim = 28
test_data = np.random.rand(batch_size, input_dim)
return test_data | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def random_init(self, shape):\n return np.random.randn(shape[0],shape[1])*0.01",
"def ndarray(self, shape=(None,), dtype=\"float64\"):\n shape = tuple(i if i is not None else self.int(20) for i in shape)\n return (100 * self.rng.random(numpy.prod(shape))\n - 50).reshape(shape)... | [
"0.7742863",
"0.7600855",
"0.7438788",
"0.73372513",
"0.73372513",
"0.7225661",
"0.70718646",
"0.6932274",
"0.689363",
"0.6843742",
"0.68274975",
"0.6786792",
"0.67669463",
"0.6762449",
"0.6760896",
"0.6744737",
"0.6633466",
"0.66286033",
"0.66112137",
"0.6599423",
"0.6539307... | 0.0 | -1 |
Return a representation of this enumeration value. | def __repr__(self):
return (('<%s "%s" (0x%x)>' if self.makehex else '<%s "%s" (%d)>') %
(self.__class__.__name__, self.name, self.value)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __repr__(self):\n return str(self.value)",
"def __repr__(self):\n return str(self.value)",
"def __repr__(self) -> str:\n return self.value",
"def __repr__(self):\n return \"{}(value={})\".format(self.__class__.__name__, self.value)",
"def __repr__(self):\n return \"{}... | [
"0.7571263",
"0.7571263",
"0.75241333",
"0.7411102",
"0.7411102",
"0.72029716",
"0.71417725",
"0.71417725",
"0.71417725",
"0.71417725",
"0.71417725",
"0.71417725",
"0.7103676",
"0.7103676",
"0.7054559",
"0.7053413",
"0.70528144",
"0.70528144",
"0.70528144",
"0.70528144",
"0.7... | 0.7048697 | 21 |
Determine the number of options contained within the ``EnumSet`` instance. | def __len__(self):
return len(self.by_value) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_num_of_choices(self) -> int:\n return len(self._choices)",
"def choices(self):\n self._choices = self.getChoices()\n return len(self._choices)",
"def __len__(self):\n return len(self._enums)",
"def __len__(self):\n return len(self._opts) + len(self._groups)",
"def... | [
"0.71791655",
"0.692308",
"0.68106925",
"0.6607",
"0.65172154",
"0.64987546",
"0.64216137",
"0.63446486",
"0.620711",
"0.61528575",
"0.6135118",
"0.60672617",
"0.60482633",
"0.6048155",
"0.60394466",
"0.5983859",
"0.59663296",
"0.59662783",
"0.5944988",
"0.594224",
"0.58795",... | 0.56543607 | 33 |
Determine if the ``FlagSet`` instance contains the specified flags. | def __contains__(self, flag):
if isinstance(flag, six.integer_types):
# Pretty easy
return (self.bitflags & flag) == flag
elif isinstance(flag, six.string_types):
# Simple string
return flag in self.flags
else:
try:
# M... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def flagSet():\r\n for flag in flags:\r\n if flags[flag]:\r\n return True\r\n return False",
"def has(self, *options: str) -> bool:\n return bool(self.flags & self.mask(*options))",
"def supports_feature(flags: Set[str], feature: str) -> bool:\n\n if not isinstance(feature, st... | [
"0.7395332",
"0.70454514",
"0.6428682",
"0.6359156",
"0.63465047",
"0.62633365",
"0.5987054",
"0.5924127",
"0.590645",
"0.5763223",
"0.571385",
"0.5619686",
"0.54595345",
"0.5436726",
"0.5432826",
"0.54285216",
"0.5423442",
"0.54006237",
"0.53594786",
"0.5264322",
"0.52434474... | 0.7988177 | 0 |
Discard a flag on the ``FlagSet`` instance. | def discard(self, flag):
try:
# Resolve the flag
flag = self.eset[flag]
except KeyError:
return
# Save the current bitflags
previous = self.bitflags
self.bitflags &= ~int(flag)
self.flags.discard(str(flag))
# Call the notifi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setDiscardFlag(self, flag, on=True):\r\n if on:\r\n self.__data.discardFlags |= flag\r\n else:\r\n self.__data.discardFlags &= ~flag",
"def setDiscardFlags(self, flags):\r\n self.__data.discardFlags = flags",
"def discard(self, item):\n try:\n se... | [
"0.7705357",
"0.7167262",
"0.65679157",
"0.61577463",
"0.61577463",
"0.6107064",
"0.6039238",
"0.59883547",
"0.59009844",
"0.5894775",
"0.56465137",
"0.55505514",
"0.54692906",
"0.5387131",
"0.5349529",
"0.53450084",
"0.5329477",
"0.53255093",
"0.5220295",
"0.5217501",
"0.518... | 0.7911526 | 0 |
Canonicalize a value. This implementation returns the corresponding ``Enum`` value from the ``EnumSet`` specified at initialization. | def prepare(self, instance, value):
try:
return self.eset[value]
except KeyError:
raise AttributeError(
'Invalid value for attribute %s: %r' % (self.attr_name, value)
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_python(self, value):\n if isinstance(value, self.enum_class):\n return value\n value = super(self.__class__, self).to_python(value)\n if isinstance(value, int):\n return self.enum_class(value)\n assert value is None\n return None",
"def get_prep_val... | [
"0.57567173",
"0.5645661",
"0.54367954",
"0.53182817",
"0.5155281",
"0.5131945",
"0.50391257",
"0.4990143",
"0.494559",
"0.49313572",
"0.4926061",
"0.49163398",
"0.48853543",
"0.4877798",
"0.48573652",
"0.4844941",
"0.47871658",
"0.4778595",
"0.47566354",
"0.47526324",
"0.472... | 0.0 | -1 |
Initialize a ``FlagSetAttr`` instance. | def __init__(self, eset, invalidator='invalidate'):
# Initialize the superclass
super(FlagSetAttr, self).__init__(invalidator)
# Save the EnumSet
self.eset = eset | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, eset, flags=None):\n\n # Store the EnumSet\n self.eset = eset\n\n # Initialize the flags\n self.bitflags = 0\n self.flags = set()\n\n # Routine to call if we're modified\n self._notify = None\n\n # Process the flags that were set\n i... | [
"0.6014541",
"0.5964356",
"0.5957173",
"0.5914509",
"0.58628297",
"0.58485585",
"0.5797345",
"0.5684662",
"0.5607551",
"0.55607164",
"0.5557966",
"0.53762037",
"0.53533566",
"0.5348422",
"0.5291797",
"0.52211326",
"0.52210116",
"0.52180463",
"0.5195433",
"0.5183904",
"0.51824... | 0.6945288 | 0 |
Model of a damped pendulum | def damped_pendulum(pos):
def x_dot(x, y):
return y
def y_dot(x, y):
return -0.1*y - np.sin(x)
return np.array([x_dot(pos[0], pos[1]), y_dot(pos[0], pos[1])]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, pendulum, name=\"Pendulum\", dt=0.01):\n super().__init__(name=name)\n self.pendulum = pendulum\n self.dt = dt",
"def _model(self, t, theta, period, tmpid):\n template = self.templates[tmpid]\n phase = (t / period - theta[2]) % 1\n return theta[0] + th... | [
"0.6389757",
"0.62570584",
"0.6251534",
"0.6018877",
"0.5953172",
"0.58293605",
"0.58160734",
"0.5796524",
"0.57523537",
"0.56851745",
"0.56645703",
"0.5663768",
"0.56319314",
"0.562755",
"0.55919474",
"0.55872536",
"0.5567067",
"0.55479765",
"0.5503377",
"0.54973847",
"0.549... | 0.6742539 | 0 |
Hard sigmoid function For a given value u as input, it gives hard sigmoid of u as output. | def hard_sigmoid(u):
if u > 1:
ro = 1
elif u < 0:
ro = 0
else:
ro = u
return ro | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hard_sigmoid_derivative(u):\r\n if u > 1:\r\n ro = 0\r\n elif u < 0:\r\n ro = 0\r\n else:\r\n ro = 1\r\n return ro",
"def sigmoid(x):\n return 1 / (1 - (power(e,-x)))",
"def sigmoid(z):\r\n \r\n return vSigmoid(z);",
"def sigmoid(x):\n return 1 / (1 + exp(-x)... | [
"0.8340554",
"0.7792559",
"0.77599376",
"0.7747133",
"0.7747133",
"0.76981646",
"0.7667149",
"0.7664956",
"0.7651496",
"0.76462394",
"0.76462394",
"0.76407063",
"0.7631713",
"0.76259273",
"0.76033205",
"0.76024806",
"0.7595583",
"0.7590885",
"0.7590708",
"0.7586715",
"0.75819... | 0.83319825 | 1 |
Hard sigmoid function for an array of values For a given array u as input, it gives hard sigmoid of u as output. | def hard_sigmoid_array(u):
ro = np.zeros(len(u))
for i in np.arange(len(u)):
ro[i] = hard_sigmoid(u[i])
return ro | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sigmoid(t):\n return np.exp(t)/(1+np.exp(t))",
"def sigmoid(x: np.ndarray \n ) -> np.ndarray:\n return 1/(1+np.exp(-x))",
"def sigmoid(values, gain, shift):\n import numpy as np\n\n tiny = 0.000000001\n\n # Make sure argument is a numpy array\n if type(values) != np.ndarr... | [
"0.7557232",
"0.75521666",
"0.7530991",
"0.75062776",
"0.74866426",
"0.7473698",
"0.74650526",
"0.7455005",
"0.7455005",
"0.7455005",
"0.7455005",
"0.7455005",
"0.7455005",
"0.74319494",
"0.7427566",
"0.7409621",
"0.74043214",
"0.7399037",
"0.7392596",
"0.7390544",
"0.7388159... | 0.8358422 | 0 |
Derivative of hard sigmoid function For a given value u as input, it gives hard sigmoid derivative of u as output. | def hard_sigmoid_derivative(u):
if u > 1:
ro = 0
elif u < 0:
ro = 0
else:
ro = 1
return ro | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def derivative_sigmoid(x):\n return x * (1 - x)",
"def derivative_sigmoid(x):\n return x * (1 - x)",
"def sigmoid_derivative(x):\n return x * (1-x)",
"def sigmoid_derivative(x):\n return x * (1.0 - x)",
"def sigmoid_derivative(x):\n\n return sigmoid(x) * (1 - sigmoid(x))",
"def sigmoid_der... | [
"0.7970959",
"0.7970959",
"0.79495186",
"0.7897426",
"0.7845998",
"0.7710246",
"0.7476678",
"0.7226657",
"0.7202913",
"0.71984",
"0.70288426",
"0.69358486",
"0.6927546",
"0.69059795",
"0.6862626",
"0.6840817",
"0.6803506",
"0.6792324",
"0.6756603",
"0.67067933",
"0.6668996",
... | 0.8027031 | 0 |
Returns the cumulative returns of a portfolio. | def cumulative_returns(shares_allocation, capital, test_data):
# list of DataFrames of cumulative returns for each stock
daily_returns = []
# iterates over every stock in the portfolio
for stock in shares_allocation.index:
# multiples shares by share prices in the validation dataset
d... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cumulative_returns(self):\n return (1 + self.pct_change).cumprod()",
"def calculate_cumulative_returns_by_group(quantile_ret_ts: pd.DataFrame):\n # 1_period_return 5_period_return 10_period_return\n # factor_quantile Date\n # 1 2010-06-17 0.... | [
"0.80346304",
"0.7117688",
"0.7020555",
"0.68004584",
"0.6599235",
"0.65987766",
"0.65317065",
"0.6378568",
"0.6267627",
"0.61863387",
"0.6161118",
"0.61232454",
"0.61232454",
"0.6069886",
"0.60389215",
"0.6008858",
"0.5964947",
"0.5934377",
"0.591715",
"0.5849632",
"0.582511... | 0.76559335 | 1 |
Returns the daily return on investment. | def portfolio_daily_roi(shares_allocation, capital, test_data):
# computes the cumulative returns
cumulative_daily_returns = cumulative_returns(
shares_allocation,
capital,
test_data
)
# calculates daily return on investment
daily_roi = cumulative_daily_returns.apply(
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fetch_daily(self, dname, *args, **kwargs):\n if dname != 'returnsN':\n return super(QuoteFetcher, self).fetch_daily(dname, *args, **kwargs)\n\n N, date = args[:2]\n if 'offset' in kwargs:\n offset = kwargs.pop('offset')\n else:\n offset = args[-1] i... | [
"0.6251522",
"0.62175494",
"0.6184673",
"0.6074017",
"0.60315067",
"0.5999271",
"0.59204483",
"0.58649945",
"0.58231676",
"0.5821116",
"0.58064353",
"0.57915264",
"0.5759449",
"0.5746898",
"0.5705196",
"0.5705196",
"0.56715834",
"0.5593716",
"0.5593335",
"0.55523324",
"0.5540... | 0.56852764 | 16 |
Returns the daily running 252day maximum. | def daily_rolling_max(cumulative_returns, window=252, min_periods=1):
return cumulative_returns.rolling(
window=window,
min_periods=min_periods
).max() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def obtain_daily_maximum(data=pd.DataFrame()):\n return data.resample(\"D\").max()",
"def _max_days(self):\n # type: (...) -> Union[int, Tuple[int]]\n\n return self.value.max_days",
"def max_days(self):\n # This can be refined, as there are at max 2 consecutive months with 31\n #... | [
"0.73749036",
"0.7217937",
"0.70836467",
"0.667602",
"0.6598183",
"0.6598183",
"0.6532576",
"0.64994997",
"0.6396165",
"0.6396148",
"0.62458897",
"0.6223828",
"0.61432564",
"0.6141461",
"0.6097955",
"0.60674804",
"0.58854157",
"0.58501315",
"0.5818336",
"0.5808526",
"0.575486... | 0.6340012 | 10 |
Returns the daily running 252day maximum daily drawdown. | def max_daily_rolling_drawdown(daily_drawdown, window=252, min_periods=1):
return daily_drawdown.rolling(
window=window,
min_periods=min_periods
).min() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lifetime_max_drawdown(daily_drawdown):\n\n return round(daily_drawdown.min()*100, 2)",
"def max_drawdown_date(self) -> dt.date:\n mdd_date = (self.tsdf / self.tsdf.expanding(min_periods=1).max()).idxmin().values[0].astype(dt.datetime)\n return dt.datetime.fromtimestamp(mdd_date / 1e9).date()... | [
"0.8053372",
"0.7309904",
"0.7136397",
"0.6945596",
"0.66620314",
"0.65847397",
"0.65381736",
"0.6391821",
"0.623571",
"0.61597496",
"0.59037566",
"0.5875009",
"0.5865871",
"0.58287054",
"0.5795373",
"0.5767846",
"0.57399833",
"0.56995285",
"0.5673958",
"0.56637424",
"0.56529... | 0.7519542 | 1 |
Returns the lifetime maximum drawdown. | def lifetime_max_drawdown(daily_drawdown):
return round(daily_drawdown.min()*100, 2) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def MaxLifetime(self):\r\n\t\treturn self._get_attribute('maxLifetime')",
"def max_age(self):\n return 120 if self.realtime else 1800",
"def max(self):\n\n return time_stat(self, stat=\"max\")",
"def max_frame_age(self) -> float:\n return self._max_frame_age",
"def max_time(self):\n ... | [
"0.70438933",
"0.6749617",
"0.6718662",
"0.6696578",
"0.6525013",
"0.64177185",
"0.6395959",
"0.63215995",
"0.6261537",
"0.6258824",
"0.6245386",
"0.61703086",
"0.6164336",
"0.6164336",
"0.6155133",
"0.6142087",
"0.6137692",
"0.6115013",
"0.60518104",
"0.60164064",
"0.5985856... | 0.7830443 | 0 |
Returns the lifetime maximum drawdown. | def returns_over_max_drawdown(tot_returns_dict, year, lifetime_maximum_drawdown):
return round(tot_returns_dict[year] / abs(lifetime_maximum_drawdown), 2) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lifetime_max_drawdown(daily_drawdown):\n\n return round(daily_drawdown.min()*100, 2)",
"def MaxLifetime(self):\r\n\t\treturn self._get_attribute('maxLifetime')",
"def max_age(self):\n return 120 if self.realtime else 1800",
"def max(self):\n\n return time_stat(self, stat=\"max\")",
"def ma... | [
"0.7830443",
"0.70438933",
"0.6749617",
"0.6718662",
"0.6696578",
"0.6525013",
"0.64177185",
"0.6395959",
"0.63215995",
"0.6261537",
"0.6258824",
"0.6245386",
"0.61703086",
"0.6164336",
"0.6164336",
"0.6155133",
"0.6142087",
"0.6115013",
"0.60518104",
"0.60164064",
"0.5985856... | 0.6137692 | 17 |
Retrieve the id of this object from the database. | def get_id(self) -> int:
query = '''SELECT id
FROM ESLReceipts
WHERE Transaction_Number=? AND Date=? AND Description=?
AND Memo=? AND Amount_Debit=?
AND Amount_Credit=? AND Balan... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_id(self):\n return self.id",
"def get_id(self):\n return self.id",
"def get_id(self):\n return self.id",
"def get_id(self):\n return self.id",
"def get_id(self):\n return self.id",
"def get_id(self):\n return self.id",
"def get_id(self):\n return... | [
"0.8268289",
"0.8268289",
"0.8268289",
"0.8268289",
"0.8268289",
"0.8268289",
"0.8268289",
"0.8268289",
"0.8268289",
"0.8268289",
"0.8268289",
"0.8268289",
"0.8268289",
"0.8268289",
"0.8268289",
"0.8268289",
"0.8268289",
"0.82324207",
"0.82324207",
"0.8194997",
"0.81552595",
... | 0.0 | -1 |
Retrieve the string representation of this objects' type. | def get_type(self) -> str:
return Tables.ESL.name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def type_as_string(self):\n return self.properties.get('TypeAsString', None)",
"def type_name(self) -> str: # pragma: no cover\n return repr_type(self.type_obj)",
"def getTypeString(self):\n return '_'.join(self.types)",
"def type(self) -> str:\n return self._type",
"def type(s... | [
"0.8733057",
"0.8553197",
"0.85377437",
"0.8325933",
"0.8325933",
"0.8325933",
"0.8290743",
"0.8279878",
"0.82764584",
"0.82569075",
"0.82285696",
"0.82285696",
"0.8195347",
"0.81576073",
"0.8149313",
"0.8138784",
"0.8124178",
"0.81017655",
"0.8085337",
"0.8024441",
"0.792285... | 0.0 | -1 |
Returns root endpoint HTML | def hello_world():
keyword_query = 'Gamestop' # Change it to something you're interested in!
article_data = get_article_data(keyword_query)
return render_template(
"index.html",
topic=keyword_query,
headlines=article_data['headlines'],
snippets=article_data['snippets'],
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_root():\r\n return render_template(\"index.html\"), 200",
"def root(self):\n return self.app.get('/',headers=self.headers)",
"def root():\n return render_template('index.html')",
"def root():\n return render_template('index.html')",
"def root():\n return render_template('index.ht... | [
"0.7781494",
"0.7524314",
"0.7460347",
"0.7460347",
"0.7460347",
"0.73451215",
"0.73225725",
"0.7263215",
"0.72324246",
"0.7196254",
"0.71309966",
"0.7130514",
"0.70534015",
"0.6958472",
"0.695357",
"0.6901402",
"0.6869037",
"0.68371344",
"0.68197304",
"0.6809037",
"0.6803652... | 0.0 | -1 |
Method that converts data and labels to instances of class torch.utils.data.DataLoader | def init_loaders(self, *args, **kwargs):
# Convert the data to Dataset
dataset_dict = self.init_datasets(*args, **kwargs)
# If the Dataset implements collate_fn, that is used. Otherwise, default_collate is used
if hasattr(dataset_dict["train"], "collate_fn") and callable(
g... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dataloaders():\n # train data path\n data_train = '../dataset/train/'\n # set transformations\n train_transforms = transforms.Compose([\n transforms.Resize((224, 224)),\n transforms.ToTensor(),\n transforms.Normalize([0.485, 0.456, 0.406],\n ... | [
"0.74957144",
"0.74059236",
"0.73900753",
"0.73697627",
"0.7280223",
"0.7249118",
"0.7240241",
"0.71756315",
"0.70918363",
"0.7086592",
"0.7085246",
"0.7044244",
"0.7007126",
"0.6970048",
"0.69508225",
"0.6943519",
"0.69286335",
"0.6925529",
"0.6924148",
"0.6876771",
"0.68674... | 0.6935648 | 16 |
Creates data loaders from inputs for use at prediction time | def init_loaders_predict(self, data_dict, label_dict):
return self.init_loaders(data_dict, label_dict) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_data_loaders(args, tokenizer):\n personachat = get_dataset(tokenizer, args.dataset_path, args.dataset_cache, args.train_lang)\n _ = personachat.pop(\"test\", None)\n logger.info(\"Build inputs and labels\")\n datasets = {\"train\": [], \"valid\": []}\n\n if args.train_lang in [\"En\", \"Fr\"... | [
"0.74005574",
"0.7197881",
"0.7158881",
"0.6972034",
"0.6917558",
"0.68405676",
"0.6837874",
"0.678532",
"0.6781111",
"0.6738349",
"0.67170435",
"0.67128015",
"0.66842",
"0.6673706",
"0.6673443",
"0.6654735",
"0.6637798",
"0.659848",
"0.65955985",
"0.6593302",
"0.6554777",
... | 0.6874065 | 5 |
Initialize the weights with Glorot initilization | def weights_init(m):
if (
isinstance(m, nn.Linear)
or isinstance(m, nn.EmbeddingBag)
or isinstance(m, nn.Embedding)
or isinstance(m, SparseLinear)
):
nn.init.xavier_normal_(m.weight) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_weight(self):\n init_bn(self.norm0)",
"def _initialize_weights(self):\n pass",
"def init_weights(self):\n # Initialize weights\n self.apply(self._init_weights)",
"def init_weights(self, init_w=3e-3):\n self.l3.weight.data.uniform_(-init_w, init_w)\n self.l3.... | [
"0.77464277",
"0.77000946",
"0.7654312",
"0.7586706",
"0.7586706",
"0.7573792",
"0.7558622",
"0.7346543",
"0.73462576",
"0.73323685",
"0.72910225",
"0.7271283",
"0.7249364",
"0.7227278",
"0.72014505",
"0.71860826",
"0.71860826",
"0.71860826",
"0.7170588",
"0.7168318",
"0.7163... | 0.0 | -1 |
A learning rate scheduler | def init_scheduler(self):
gamma = self.config_dict.get("gamma")
if gamma is None:
return None
else:
return torch.optim.lr_scheduler.ExponentialLR(self.optimizer, gamma=gamma) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def scheduler(epoch_idx, lr):\n new_lr = lr\n if (epoch_idx == 60 or epoch_idx == 120 or epoch_idx == 160\n or epoch_idx == 260 or epoch_idx == 320 or epoch_idx == 360):\n new_lr *= 0.2\n \"\"\"\n if epoch_idx == 200:\n new_lr = 0.1\n \"\"\"\n return new_lr",
"def update_le... | [
"0.77524346",
"0.7731428",
"0.76842254",
"0.7560328",
"0.75120646",
"0.7460543",
"0.7310491",
"0.7296485",
"0.7284341",
"0.7246998",
"0.72235614",
"0.7219927",
"0.72191936",
"0.7198546",
"0.7141376",
"0.7127686",
"0.711566",
"0.7062372",
"0.70451397",
"0.7035816",
"0.70277953... | 0.0 | -1 |
Creates data loaders from inputs | def init_datasets(self, data_dict, label_dict):
## If data is count, then convert any sparse inputs to sparse tensors
convert_sparse = self.config_dict.get("sparse_mode") == "count"
splits = data_dict.keys()
dataset_dict = {
key: ArrayDataset(
data_dict[key]... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_data_loaders(args, tokenizer):\n personachat = get_dataset(tokenizer, args.dataset_path, args.dataset_cache, args.train_lang)\n _ = personachat.pop(\"test\", None)\n logger.info(\"Build inputs and labels\")\n datasets = {\"train\": [], \"valid\": []}\n\n if args.train_lang in [\"En\", \"Fr\"... | [
"0.7164973",
"0.6952015",
"0.6815742",
"0.6736966",
"0.66130817",
"0.65923643",
"0.65912664",
"0.6540567",
"0.6521354",
"0.6456177",
"0.6426",
"0.6398036",
"0.6369821",
"0.6331816",
"0.63271666",
"0.63155395",
"0.62999266",
"0.62793946",
"0.6273316",
"0.6219768",
"0.621602",
... | 0.0 | -1 |
Creates data loaders from inputs | def init_datasets(self, data_dict, label_dict):
splits = data_dict.keys()
dataset_dict = {
key: ArrayDataset(data_dict[key], torch.LongTensor(label_dict[key]))
for key in splits
}
return dataset_dict | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_data_loaders(args, tokenizer):\n personachat = get_dataset(tokenizer, args.dataset_path, args.dataset_cache, args.train_lang)\n _ = personachat.pop(\"test\", None)\n logger.info(\"Build inputs and labels\")\n datasets = {\"train\": [], \"valid\": []}\n\n if args.train_lang in [\"En\", \"Fr\"... | [
"0.7164973",
"0.6952015",
"0.6815742",
"0.6736966",
"0.66130817",
"0.65923643",
"0.65912664",
"0.6540567",
"0.6521354",
"0.6456177",
"0.6426",
"0.6398036",
"0.6369821",
"0.6331816",
"0.63271666",
"0.63155395",
"0.62999266",
"0.62793946",
"0.6273316",
"0.6219768",
"0.621602",
... | 0.0 | -1 |
Creates data loaders from inputs | def init_datasets(self, data_dict, label_dict):
splits = data_dict.keys()
dataset_dict = {
key: ArrayDataset(
data_dict[key], torch.LongTensor(label_dict[key]), convert_sparse=False
)
for key in splits
}
return dataset_dict | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_data_loaders(args, tokenizer):\n personachat = get_dataset(tokenizer, args.dataset_path, args.dataset_cache, args.train_lang)\n _ = personachat.pop(\"test\", None)\n logger.info(\"Build inputs and labels\")\n datasets = {\"train\": [], \"valid\": []}\n\n if args.train_lang in [\"En\", \"Fr\"... | [
"0.7164973",
"0.6952015",
"0.6815742",
"0.6736966",
"0.66130817",
"0.65923643",
"0.65912664",
"0.6540567",
"0.6521354",
"0.6456177",
"0.6426",
"0.6398036",
"0.6369821",
"0.6331816",
"0.63271666",
"0.63155395",
"0.62999266",
"0.62793946",
"0.6273316",
"0.6219768",
"0.621602",
... | 0.0 | -1 |
Adjust the learning rate of the params of an optimizer. | def adjust_learning_rate(optimizer, global_step, base_lr, lr_decay_rate=0.1, lr_decay_steps=6e4):
lr = base_lr * (lr_decay_rate ** (global_step/lr_decay_steps))
if lr < 1e-6:
lr = 1e-6
for param_group in optimizer.param_groups:
param_group['lr'] = lr | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def adjust_learning_rate(self, optimizer, epoch, args):\n lr = args.learning_rate * (0.1 ** (epoch // 30))\n # print(lr)\n for param_group in optimizer.param_groups:\n param_group['lr'] = lr",
"def adjust_learning_rate(args, optimizer, epoch):\n if (epoch*3==args.epochs) or (ep... | [
"0.84753436",
"0.84628916",
"0.8429673",
"0.83984476",
"0.83933645",
"0.8341199",
"0.8315756",
"0.82856673",
"0.8283146",
"0.8277514",
"0.8277514",
"0.8277514",
"0.82710576",
"0.8265629",
"0.8265629",
"0.8265629",
"0.8256059",
"0.8221603",
"0.8218627",
"0.821692",
"0.82004076... | 0.0 | -1 |
Return the email address to satisfy FlaskLogin's requirements. | def get_id(self):
return self.email | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def email(self) -> Optional[str]:\n return pulumi.get(self, \"email\")",
"def email(self) -> Optional[str]:\n return pulumi.get(self, \"email\")",
"def email(self) -> Optional[str]:\n return pulumi.get(self, \"email\")",
"def email(self) -> Optional[str]:\n return pulumi.get(self,... | [
"0.74636996",
"0.74636996",
"0.74636996",
"0.74636996",
"0.744493",
"0.744493",
"0.744493",
"0.7439936",
"0.7439936",
"0.7439936",
"0.7439936",
"0.7439936",
"0.7439936",
"0.7439936",
"0.7421634",
"0.72910833",
"0.7233626",
"0.7228416",
"0.72064245",
"0.7176058",
"0.71472573",... | 0.0 | -1 |
Return True if the user is authenticated. | def is_authenticated(self):
return self.authenticated | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_authenticated(self):\n return self.user is not None and self.state == AuthenticationOptions.authenticated",
"def is_authenticated(self):\n return bool(get_auth_token())",
"def is_authenticated(self):\n return True",
"def is_authenticated(self):\n return True",
"def is_aut... | [
"0.8739372",
"0.87086535",
"0.86574197",
"0.86574197",
"0.86574197",
"0.86574197",
"0.86574197",
"0.86574197",
"0.86574197",
"0.8613915",
"0.8609252",
"0.8578436",
"0.83723366",
"0.83587176",
"0.8258534",
"0.82273275",
"0.8209421",
"0.8200795",
"0.8174884",
"0.81280386",
"0.8... | 0.8580474 | 23 |
False, as anonymous users aren't supported. | def is_anonymous(self):
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_anonymous():\n return False",
"def is_anonymous(self):\r\n return False",
"def is_anonymous(self):\n return False",
"def is_anonymous_access_allowed(self):\n return self._is_anonymous_access_allowed",
"def is_authenticated(self):\n return False",
"def _is_anonymous_u... | [
"0.8561902",
"0.8379807",
"0.8245341",
"0.78152746",
"0.7576769",
"0.72893053",
"0.72617674",
"0.72353363",
"0.72353363",
"0.72353363",
"0.72353363",
"0.72353363",
"0.72353363",
"0.72353363",
"0.72341543",
"0.7159127",
"0.710755",
"0.70946115",
"0.70573515",
"0.7021494",
"0.7... | 0.8359887 | 18 |
Unhide the match comment. | def unhide(comment_id):
schema = ModerateMatchCommentRequest()
try:
req = schema.load(request.get_json())
except ValidationError as e:
abort(400, str(e.normalized_messages()))
initiator = user_service.find_active_user(req['initiator_id'])
if not initiator:
abort(400, 'Initia... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unhide_comment(comment_id: MatchCommentID, initiator_id: UserID) -> None:\n comment = DbMatchComment.query.get(comment_id)\n if comment is None:\n raise ValueError('Unknown match comment ID')\n\n comment.hidden = False\n comment.hidden_at = None\n comment.hidden_by_id = None\n\n db.ses... | [
"0.70979667",
"0.65529567",
"0.6209326",
"0.61320955",
"0.60730875",
"0.6047574",
"0.6014774",
"0.5923895",
"0.5921565",
"0.5790912",
"0.57796824",
"0.57351196",
"0.56272805",
"0.5621866",
"0.5553992",
"0.5522723",
"0.54890823",
"0.54295117",
"0.5421029",
"0.5381388",
"0.5304... | 0.7044827 | 1 |
Load a string in YAML format. | def load_yaml(content):
from yaml import load, FullLoader
return load(content, Loader=FullLoader) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def from_yaml_string(cls, string):\n return cls(_yaml_load(string))",
"def _yaml_load(src):\n if not isinstance(src, str):\n try:\n src_name = src.name\n except AttributeError:\n src_name = '<yaml stringio>'\n # Force-load file streams as that allows the parse... | [
"0.7954442",
"0.756084",
"0.72663134",
"0.72186196",
"0.72009647",
"0.71363896",
"0.7074121",
"0.7060779",
"0.7014209",
"0.69570035",
"0.69149274",
"0.6834525",
"0.6805121",
"0.6780684",
"0.6779875",
"0.6770773",
"0.6749694",
"0.672829",
"0.67155385",
"0.66844296",
"0.6665231... | 0.72355795 | 3 |
Return ``QuerySet`` with related content preloaded. | def base_queryset(self):
return self.get_query_set().select_related(
'product_class',
).prefetch_related(
'variants',
'product_options',
'product_class__options',
'stockrecords',
'images',
).all() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setup_eager_loading(cls, queryset):\n queryset = queryset.prefetch_related('keywords_str')\n queryset = queryset.prefetch_related('tags_str')\n # queryset = queryset.prefetch_related('keywords')\n # queryset = queryset.prefetch_related('tags')\n return queryset",
"def get_p... | [
"0.679683",
"0.6397021",
"0.6240532",
"0.60717916",
"0.60220003",
"0.5965624",
"0.5962794",
"0.58966774",
"0.58433366",
"0.5831678",
"0.5744291",
"0.572757",
"0.56999606",
"0.56916636",
"0.5684065",
"0.56319755",
"0.5624948",
"0.5520748",
"0.5506694",
"0.54910636",
"0.5474627... | 0.5304603 | 29 |
Returns an argparse instance | def cmdline_parser():
# http://docs.python.org/dev/howto/argparse.html
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--verbose",
action="store_true",
help="Be verbose")
parser.add_argument("--debug",
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_parser():\n p = argparse.ArgumentParser(description='such a good program')\n p.add_argument('infile')\n p.add_argument('outfile')\n return p",
"def get_parser():\n\n parser = parser.ArgumentParser()\n return parser",
"def arg_parser():\n import argparse\n return argparse... | [
"0.7767424",
"0.77440184",
"0.7693054",
"0.75894576",
"0.75894576",
"0.74071556",
"0.7322823",
"0.73185104",
"0.7240093",
"0.7232856",
"0.72174203",
"0.72085565",
"0.72033024",
"0.71685386",
"0.71665",
"0.7139135",
"0.7130057",
"0.7107946",
"0.71069175",
"0.7100661",
"0.70824... | 0.0 | -1 |
return the current OBC configuration | def getObcType():
return simuConfig["OBC"] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def config(self):\r\n return self._config",
"def get_config(self):\n if self.allow_reco():\n return self.chs_config()\n else:\n return self.get_config_j(self.id)",
"def config(self):\n return self._config",
"def get_config(self):\n return self.config",
"def ... | [
"0.76223904",
"0.758794",
"0.7562929",
"0.7540094",
"0.7497914",
"0.74324155",
"0.74324155",
"0.74324155",
"0.74324155",
"0.74324155",
"0.74324155",
"0.74324155",
"0.74324155",
"0.74324155",
"0.74324155",
"0.74324155",
"0.74324155",
"0.74324155",
"0.74324155",
"0.74324155",
"... | 0.0 | -1 |
Creates a new ball | def create_ball():
balls.append(gen_ball())
generate_velocity(balls) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_ball():\n ball = Ball()\n # Starting position of the ball.\n # Take into account the ball size so we don't spawn on the edge.\n ball.x = random.randrange(BALL_SIZE, SCREEN_WIDTH - BALL_SIZE)\n ball.y = random.randrange(BALL_SIZE, SCREEN_HEIGHT - BALL_SIZE)\n\n # Speed and direction of re... | [
"0.78910744",
"0.7773026",
"0.75718427",
"0.729235",
"0.71304464",
"0.7016827",
"0.68962",
"0.68675226",
"0.68090975",
"0.67911744",
"0.6787879",
"0.67824346",
"0.6752662",
"0.6746393",
"0.6635242",
"0.6631885",
"0.65989226",
"0.64579904",
"0.64246917",
"0.6302894",
"0.630126... | 0.7948333 | 0 |
Returns the path of the global configuration file | def get_global_config_path():
return "/etc/dapsenv/dapsenv.conf" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_config_file_location():\n\n return './' + CONFIG_FILE_NAME",
"def get_config_path():\n\n root = os.path.dirname(os.path.abspath(__file__))[:-5]\n config_path = os.path.join(root, 'config.ini')\n\n return config_path",
"def configPath(self):\n return os.path.dirname(__file__)",
"def... | [
"0.8170498",
"0.8149112",
"0.8113216",
"0.7989826",
"0.7970176",
"0.79333484",
"0.7824644",
"0.7777473",
"0.77438056",
"0.7719309",
"0.7697185",
"0.76197577",
"0.7570368",
"0.7545556",
"0.75374484",
"0.7467858",
"0.74403304",
"0.74283",
"0.7358495",
"0.73165745",
"0.7294852",... | 0.8346807 | 0 |
Asks user to specify a city, month, and day to analyze. | def get_filters():
print("Hello there! Let's explore some data!")
legit_cities = ['chicago', 'new york city', 'washington'] # cities im gonna accept
city = input("\nWhich city do you want to analyze? Chicago, New York City or Washington?\n").lower()
while city not in legit_cities:
print("There... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Raw_Data(city,month,day):\n print(\"The city you have entered is: \",city)\n print(\"The month you have entered is: \",month)\n print(\"The day you have entered is: \",day)",
"def get_filters():\n city = None\n month = None\n day = None\n while day == None:\n # TO DO: get user input f... | [
"0.667135",
"0.65355784",
"0.6372491",
"0.6349019",
"0.63104576",
"0.62870693",
"0.6259983",
"0.62297434",
"0.62112975",
"0.62049454",
"0.6181796",
"0.6170252",
"0.6170224",
"0.6159359",
"0.61588275",
"0.6153817",
"0.61454034",
"0.61345667",
"0.61054",
"0.61033493",
"0.609148... | 0.6459417 | 2 |
Loads data for the specified city and filters by month and day if applicable. | def load_data(city, month, day):
data = pd.read_csv("{}.csv".format(city))
data.drop(data.columns[0], axis = 1, inplace = True) #dropping this strange column
data['Start Time'] = pd.to_datetime(data['Start Time'], format='%Y-%m-%d %H:%M:%S')
data['End Time'] = pd.to_datetime(data['End Time'], format... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_data(city, month, day):\n df = pd.read_csv(CITY_DATA [city])\n \n # convert the Start Time column to datetime\n df['Start Time'] = pd.to_datetime(df['Start Time'])\n \n # extract month and day of week from Start Time to create new columns\n df['month'] = df['Start Time'].dt.month\n ... | [
"0.81320685",
"0.8108889",
"0.8045821",
"0.8042514",
"0.80090284",
"0.80071104",
"0.79991937",
"0.7998333",
"0.7988789",
"0.797905",
"0.79737365",
"0.79610896",
"0.7956163",
"0.7947432",
"0.79463065",
"0.7908287",
"0.7908229",
"0.7904569",
"0.7900715",
"0.78930074",
"0.788921... | 0.73460114 | 97 |
Displays statistics on the most frequent times of travel. | def time_stats(df):
print("="*40)
print('\nCalculating The Most Frequent Times of Travel...\n')
start_time = time.time()
most_freq_hour = str(df.groupby(['hour'])['Start Time'].count().idxmax())
high_hour_qty = str(df.groupby(['hour'])['Start Time'].count().max())
if len(df['weekday'].unique... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def time_stats(df):\n\n print('\\nDisplaying the statistics on the most frequent times of '\n 'travel...\\n')\n start_time = time.time()\n\n # display the most common month\n most_common_month = df['Month'].mode()[0]\n print('For the selected filter, the month with the most travels is: ' +\... | [
"0.80247396",
"0.80233026",
"0.7915788",
"0.78266186",
"0.7822246",
"0.78143597",
"0.77659196",
"0.7740343",
"0.773628",
"0.77344066",
"0.76867086",
"0.7668633",
"0.7651731",
"0.7644636",
"0.76399267",
"0.76367253",
"0.7625196",
"0.7623158",
"0.7612803",
"0.76002145",
"0.7583... | 0.0 | -1 |
Displays statistics on the most popular stations and trip. | def station_stats(df):
print('\nCalculating The Most Popular Stations and Trip...\n')
start_time = time.time()
# TO DO: display most commonly used start station
start_station_high_freq = df.groupby(['Start Station'])['Start Time'].count().idxmax()
start_station_high_qty = df.groupby(['Start Statio... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def station_stats(df):\n\n print('\\nCalculating The Most Popular Stations and Trip...\\n')\n start_time = time.time()\n\n # display most commonly used start station\n print(popular_start_station(df))\n\n # display most commonly used end station\n print(popular_end_station(df))\n\n # display m... | [
"0.7815675",
"0.7662213",
"0.7553417",
"0.74914914",
"0.74748665",
"0.7446617",
"0.7428588",
"0.74237514",
"0.74177027",
"0.7400495",
"0.7387161",
"0.7385634",
"0.73647535",
"0.735934",
"0.73566747",
"0.73548365",
"0.7351854",
"0.7351274",
"0.735057",
"0.73421645",
"0.7340198... | 0.69124997 | 83 |
Displays statistics on the total and average trip duration. | def trip_duration_stats(df):
print('\nCalculating Trip Duration...\n')
start_time = time.time()
df['time'] = df['End Time'] - df['Start Time']
# TO DO: display total travel time
print("Total travel time in that period of time: {}".format(df['time'].sum()))
print("Average time of journey: {}".f... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def trip_duration_stats(data):\n print('\\nCalculating Trip Duration...\\n')\n start_time = time.time()\n # display total travel time\n total_trip_time= data['Trip Duration'].sum()\n print('The Total Travel Time is {} Hours'. format(total_trip_time/3600))\n # display mean travel time\n avg_tri... | [
"0.8141812",
"0.8024182",
"0.80032814",
"0.7948688",
"0.79363805",
"0.79301584",
"0.7925556",
"0.79139745",
"0.79132074",
"0.79069036",
"0.79044855",
"0.7899693",
"0.78905743",
"0.7888294",
"0.78858185",
"0.7883996",
"0.78832155",
"0.7881429",
"0.7872763",
"0.78675747",
"0.78... | 0.76539797 | 78 |
Add the mask to the provided face, and return the face with mask. | def apply_mask(face: np.array, mask: np.array) -> np.array:
mask_h, mask_w, _ = mask.shape
face_h, face_w, _ = face.shape
# Resize the mask to fit on face
factor = min(face_h / mask_h, face_w / mask_w)
new_mask_w = int(factor * mask_w)
new_mask_h = int(factor * mask_h)
new_mask_shape = (new... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_face(self, face):\n try:\n face_idx = self.faces.index(face)\n return self.faces[face_idx]\n except Exception:\n self.faces.append(face)\n return face",
"def add_mask(self, bg, mask):\n # if mask is to tall for the background image, decreas... | [
"0.68112254",
"0.61941063",
"0.61160135",
"0.5863433",
"0.5680295",
"0.56591696",
"0.5506171",
"0.5495523",
"0.5465617",
"0.54287475",
"0.540982",
"0.5407283",
"0.5399397",
"0.53711027",
"0.53566027",
"0.52766466",
"0.5251095",
"0.52477425",
"0.5221825",
"0.521897",
"0.516831... | 0.7651554 | 0 |
Receive yaml string, update instance state with its value | def post_exec_command(self, env_out):
env_at_footer = yaml.safe_load(env_out)
newdir = env_at_footer["pwd"]
newenv = env_at_footer["env"]
self.update_workdir(newdir)
self.update_env(newenv)
if "code" in env_at_footer:
return env_at_footer["code"]
els... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __setstate__(self, d):\n self.temp_yaml = None\n self.__dict__.update(d)",
"def from_yaml(self, yaml):\n self.hwAddress = yaml.get('hwAddress')\n if self.hwAddress:\n self.hwAddress = self.hwAddress.lower()\n self.ip = yaml.get('IP')\n self.formulas = {}\n... | [
"0.61438406",
"0.6056736",
"0.5877559",
"0.5833056",
"0.58151037",
"0.5771336",
"0.5758185",
"0.5707733",
"0.56915504",
"0.5662397",
"0.5634253",
"0.5543256",
"0.5499675",
"0.5443834",
"0.5396185",
"0.5373637",
"0.534983",
"0.5343931",
"0.53255194",
"0.5319177",
"0.5310332",
... | 0.0 | -1 |
Copy this config, replacing the regions with those in the `regions` parameter. | def copy_with_regions(self, regions):
new = copy.deepcopy(self)
new.regions = []
for region in regions:
new.regions.append(self._parse_region(region))
return new | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def regions(self, regions):\n self._regions = regions",
"def copy(self, **kwargs):\n # type: (...) -> SalusConfig\n return deepcopy(self).update(**kwargs)",
"def update_region_config(cls, body: CloudAccountRegionConfigurationViewModel) -> Dict:\n\t\tpass",
"def __copy__(self):\n r... | [
"0.61411893",
"0.6017079",
"0.60054064",
"0.5572163",
"0.5489599",
"0.54806817",
"0.54680604",
"0.54073626",
"0.5361858",
"0.5301637",
"0.5257151",
"0.4999279",
"0.49944136",
"0.49855417",
"0.4982498",
"0.49822417",
"0.49773163",
"0.49644902",
"0.49597627",
"0.49420026",
"0.4... | 0.728114 | 0 |
The number of tokens in the corpus. | def M(self) -> int:
m_tokens = sum(self.values())
return m_tokens | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def corpus_size():\n return ix.doc_count()",
"def length(self):\n return len(self.tokens)",
"def get_token_count():\r\n tokens = cache.get('tokens-number')\r\n\r\n if tokens is None:\r\n tokens = 0\r\n tweets = mongo_coll_tweets.find({}, {'text': 1})\r\n for tweet in tweets:\r\... | [
"0.806606",
"0.7887896",
"0.77023524",
"0.76616067",
"0.7650494",
"0.75955534",
"0.75822",
"0.75771636",
"0.7513522",
"0.7409987",
"0.7341951",
"0.7302427",
"0.7302427",
"0.7294214",
"0.7235468",
"0.72276926",
"0.7198542",
"0.7188423",
"0.716213",
"0.7112996",
"0.70776194",
... | 0.63286906 | 84 |
Entropy content of this corpus, based on wordfrequency distribution. | def entropy(self, base: int = None):
# shannon entropy in nats
fdist_ = self.fdist
fdist_["prob"] = fdist_["freq"] / fdist_["freq"].sum()
fdist_["logp"] = np.log(fdist_["prob"])
fdist_["nats"] = -fdist_["prob"] * fdist_["logp"]
entropy_ = fdist_["nats"].sum()
# ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def word_entropy(self, doc, lemmatized=False):\n # filter out words\n words = [token for token in doc if not token.is_punct and \"'\" not in token.text and not token.is_space]\n # create bag of words\n if lemmatized:\n list_words = [w.lemma_ for w in words]\n else:\n ... | [
"0.71550137",
"0.7075918",
"0.6877915",
"0.6864271",
"0.68232894",
"0.6782823",
"0.6778635",
"0.67370933",
"0.67321175",
"0.6719566",
"0.6655286",
"0.66454005",
"0.6627845",
"0.66105163",
"0.6608293",
"0.65667075",
"0.65590805",
"0.6539854",
"0.651763",
"0.65124595",
"0.65088... | 0.58525765 | 92 |
Destroy blank temp database after each test. | def tearDown(self):
os.close(self.db_fd)
os.unlink(app.app.config['DATABASE']) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tearDown(self):\r\n empty_db()",
"def tearDown(self):\r\n empty_db()",
"def tearDown(self):\r\n empty_db()",
"def tearDown(self):\r\n empty_db()",
"def tearDown(self):\r\n empty_db()",
"def tearDown(self):\r\n empty_db()",
"def tearDown(self):\n app.... | [
"0.78953713",
"0.78953713",
"0.78953713",
"0.78953713",
"0.78953713",
"0.78953713",
"0.7880197",
"0.78739846",
"0.78739846",
"0.78739846",
"0.78739846",
"0.78739846",
"0.78739846",
"0.78739846",
"0.78739846",
"0.78739846",
"0.7790146",
"0.7782551",
"0.7782551",
"0.776434",
"0... | 0.747593 | 36 |
consider there are 5 points in YAxis, if we give 4/5 in `yAxisPos`, Paddle we positioned at 4th place + + | 1 . | | 2 . | | 3 . | | 4 . (canvas_height yAxisPos) | def __init__(self, myCanvas, color, paddleW, paddleH, yAxisPos):
self.canvas = myCanvas
self.id = myCanvas.create_rectangle(0, 0, paddleW, paddleH, fill=color)
# Getting height and width of current window
self.canvas_width = self.canvas.winfo_width()
self.canvas_height = self.ca... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pos_y(self, *args, **kwargs) -> Any:\n pass",
"def calculate_y_pos(value, sensor):\n if GraphModel.check_value(value, sensor):\n return ((32 - int(value)) * 12.5) + 50 if sensor == 't' else 450 - (int(value) / 10 * 40)\n return",
"def checkYPos(self, *args):\n x = sel... | [
"0.66333294",
"0.64487386",
"0.62421274",
"0.6238937",
"0.6220619",
"0.6194612",
"0.6183145",
"0.61616826",
"0.61470264",
"0.60619056",
"0.60619056",
"0.6048159",
"0.60376287",
"0.6028491",
"0.60157543",
"0.6014515",
"0.60117626",
"0.6009412",
"0.6004599",
"0.5994862",
"0.598... | 0.5968976 | 21 |
Keep path to last data directory selected in a YAML in config | def save_last_data_location(self, dir_name):
# TODO think about where to keep the config yaml file
config_file_name = "cicada/config/config.yaml"
config_dict = None
if os.path.isfile(config_file_name):
with open(config_file_name, 'r') as stream:
config_dict = ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def patch_yaml_path(options):\n if '/' not in options['config_yaml']:\n dir_name = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))\n options['config_yaml'] = os.path.join(dir_name, options['config_yaml'])\n return options",
"def configs() -> Path:\n return TEST_RO... | [
"0.6551428",
"0.6194027",
"0.6087345",
"0.6048823",
"0.5975001",
"0.5923837",
"0.5874789",
"0.5872855",
"0.5858172",
"0.58444166",
"0.57109195",
"0.56871974",
"0.56857955",
"0.567317",
"0.5672065",
"0.56700754",
"0.5640668",
"0.561254",
"0.55931914",
"0.5587805",
"0.55854946"... | 0.7011594 | 0 |
Get a HyperHelpAuthor setting from a cached settings object. | def hha_setting(key):
default = hha_setting.default.get(key, None)
return hha_setting.obj.get(key, default) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def apply_authoring_settings(view):\n # Ensure help files with no header get the appropriate syntax set\n view.assign_syntax(hh_syntax(\"HyperHelp-Help.sublime-syntax\"))\n\n author_view_settings = hha_setting(\"author_view_settings\")\n settings = view.settings()\n for option in author_view_setting... | [
"0.6095596",
"0.5634342",
"0.5394313",
"0.52192473",
"0.52102685",
"0.52102685",
"0.51438564",
"0.512326",
"0.5084381",
"0.50817287",
"0.50310844",
"0.5022928",
"0.50225395",
"0.5015123",
"0.50020033",
"0.49942827",
"0.49935323",
"0.49907595",
"0.49438605",
"0.49339852",
"0.4... | 0.5041114 | 10 |
subtract the arg from the value. | def subtract(value, arg):
try:
return int(value) - int(arg)
except (ValueError, TypeError):
try:
return value - arg
except Exception:
return "" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def subtract(self, value):\n return self.number - value",
"def subtract(val, otherval=None):\n if otherval is None:\n return val\n\n try:\n answer = val - int(otherval)\n return answer\n except ValueError:\n return val",
"def subtract(*args):\n\n # TODO: Fill ... | [
"0.7714425",
"0.71640867",
"0.71093124",
"0.69877523",
"0.69389325",
"0.6776049",
"0.67269045",
"0.6721766",
"0.6658199",
"0.6658199",
"0.66268027",
"0.66268027",
"0.66268027",
"0.66232294",
"0.66111463",
"0.6543256",
"0.65196186",
"0.6496731",
"0.6493978",
"0.6485772",
"0.64... | 0.7948222 | 0 |
Checks if all mines have been flagged. | def won(self):
return self.mines_found == self.mines | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mark_mines(self, cells):\r\n for cell in cells:\r\n row, col = cell\r\n self.mine_field[row][col] = 'x'\r\n self.mines_left -= 1\r\n return",
"def known_mines(self):\n self.mines",
"def all_bees_raised_flag(self):\n pos, com, success = self.perce... | [
"0.6496075",
"0.6441596",
"0.62646043",
"0.61920667",
"0.5948475",
"0.59368217",
"0.5887279",
"0.58706886",
"0.58314085",
"0.5809972",
"0.579444",
"0.5790966",
"0.5783772",
"0.5762287",
"0.5746479",
"0.57060987",
"0.56872654",
"0.56198263",
"0.5619175",
"0.5610368",
"0.560209... | 0.67849445 | 5 |
Marks the specified amount for the given order as paid. This allows to hook in more complex behaviors (like saving a history of payments in a Payment model) The optional save argument allows backends to explicitly not save the order yet | def confirm_payment(self, order, amount, transaction_id, backend, description, save=True):
#! TODO this bit should probably be in the "if save..." block below. Check rest of code base first
OrderPayment.objects.get_or_create(
order=order,
amount=Decimal(amount),
trans... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def paid(self, paid):\n\n self._paid = paid",
"def transaction_amount_paid(self, transaction_amount_paid):\n\n self._transaction_amount_paid = transaction_amount_paid",
"def paid_interest(self, paid_interest):\n\n self._paid_interest = paid_interest",
"def save(self, *args, **kwargs):\n ... | [
"0.6905266",
"0.6039232",
"0.6021345",
"0.59171605",
"0.5789729",
"0.57723475",
"0.5649608",
"0.5606408",
"0.5603221",
"0.5592143",
"0.554666",
"0.5468819",
"0.5401203",
"0.5376429",
"0.5343095",
"0.5258786",
"0.52550066",
"0.523511",
"0.5198044",
"0.51331836",
"0.51278967",
... | 0.66326064 | 1 |
Set initial location of the central controller. | def main():
location = gen_Location("0.856901647439813,14.08447265625")
add_location(location) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def simulator_window_center(self, value: str) -> None:\n self.set_capability(SIMULATOR_WINDOW_CENTER, value)",
"def _configure_main(self, client):\n width = self._get_main_width()\n height = self.screen_rect.height\n left = self.screen_rect.x\n top = self.screen_rect.y\n\n ... | [
"0.5979996",
"0.5911836",
"0.5897334",
"0.5872533",
"0.5869994",
"0.5820433",
"0.58033293",
"0.57864046",
"0.57571167",
"0.5735946",
"0.57304484",
"0.5696587",
"0.56753886",
"0.56547064",
"0.5641599",
"0.5622692",
"0.5616644",
"0.56052744",
"0.56052464",
"0.5605135",
"0.56011... | 0.0 | -1 |
Returns a set of SparseVectorDimensions which are each assigned a transformation function appropriate for standardizing the respective dimension. | def generateStandardizedColumns(self, data_set, columns):
cstat = data_set.colStats()
stdDevs = np.sqrt(cstat.variance())
means = cstat.mean()
normalizingFactors = map(lambda x: x if x != 0.0 else 1.0, stdDevs)
result = []
for col, mean, nf in zip(columns, means, normaliz... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_scale_features_standardize(self):\n data = array([[0.564, 20.661], [-18.512, 41.168], [-0.009, 20.440]])\n cdata = CData(data)\n\n # correct answer computed in Mathematica\n # TODO: can we compute the right answer in Python?\n answer = array([[0.60355, -0.568043], [-1.15... | [
"0.58996356",
"0.5885209",
"0.562922",
"0.5424146",
"0.5354879",
"0.5301714",
"0.52051574",
"0.5184689",
"0.51839614",
"0.51808983",
"0.5156929",
"0.5156137",
"0.5154081",
"0.51329243",
"0.5126789",
"0.50431347",
"0.49799955",
"0.4977521",
"0.4954653",
"0.4950907",
"0.4950194... | 0.60437644 | 0 |
Create and return a SQLAlchemy engine object | def get_engine(self, connection_string):
if connection_string not in sqlengines:
sqlengines[connection_string] = create_engine(
self.get_connection_string())
return sqlengines[connection_string] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_engine(self):\n connection_string = f'postgresql://{self.user}:{self.password}@{self.host}/{self.database_name}'\n return create_engine(connection_string)",
"def get_engine(db_params: Dict[str, str]) -> sa.engine:\r\n db_uri = get_uri(db_params)\r\n return sa.create_engine(db_uri)"... | [
"0.81582",
"0.8151789",
"0.8096098",
"0.8074667",
"0.78949046",
"0.7888775",
"0.78016627",
"0.7694161",
"0.7633024",
"0.7619185",
"0.75568897",
"0.7526892",
"0.75230956",
"0.75139517",
"0.751324",
"0.7408494",
"0.7328666",
"0.73017824",
"0.7291083",
"0.7289729",
"0.7289729",
... | 0.0 | -1 |
Run a PostGIS query and return results as a GeoDataFrame | def df_from_postgis(engine, query, params, geocolumn, epsg):
data = geopandas.GeoDataFrame.from_postgis(
query,
engine,
geom_col=geocolumn,
crs={'init': 'epsg:{}'.format(epsg)},
params=params)
return data | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def queryToPDTable(postgreSql_selectQuery):\n\n import os\n import psycopg2\n import pandas as pd\n\n #basic query function to the database using environmental variables for\n #the user name and password\n conn=psycopg2.connect(host=\"postgis1\",\n dbname=\"sdad\",\n ... | [
"0.68622106",
"0.6783693",
"0.6631549",
"0.65065295",
"0.64609385",
"0.6398335",
"0.63537514",
"0.63044345",
"0.629543",
"0.6189722",
"0.6184706",
"0.61680967",
"0.6097106",
"0.6089787",
"0.60863835",
"0.60695153",
"0.60299134",
"0.6028463",
"0.6016495",
"0.5989992",
"0.59744... | 0.83570623 | 0 |
Get appropriate DataFrame column name and readable axis label. | def _axis_labels(self, data_name: str) -> Tuple[str, str]:
# Single activity attributes (column name must be present in summary dataframe)
if data_name == 'distance':
if self.config.distance_unit == 'km':
return 'distance_2d_km', 'Distance (km)'
elif self.config.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_label ( self ):\n if self._label is not None:\n return self._label\n return 'Column %d' % (self.index + 1)",
"def _label(self, column):\n # XXX\n return column",
"def _get_column_name(df, name='agg'):\n while name in df.columns:\n name += '_'\n retur... | [
"0.6837961",
"0.66392434",
"0.6530014",
"0.6514728",
"0.6507803",
"0.6419064",
"0.636666",
"0.63305116",
"0.62810653",
"0.62264484",
"0.62251216",
"0.62186813",
"0.62026006",
"0.61959815",
"0.61305",
"0.6121797",
"0.6063063",
"0.6025661",
"0.60128766",
"0.60128766",
"0.596436... | 0.62674105 | 9 |
A configurable scatterplot of all activities. | def main_scatterplot(self) -> Component:
logger.debug('Generating main scatterplot.')
x_dropdown = dcc.Dropdown('overview_main_scatterplot_x_dropdown', options=[
{'label': 'Distance', 'value': 'distance'},
{'label': 'Average speed', 'value': 'mean_speed'},
{'label': ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def show_scatter(self):\n plt.scatter(self.a1[:, 0], self.a1[:, 1], c=\"red\", alpha=0.5, s=10)\n plt.scatter(self.a2[:, 0], self.a2[:, 1], c=\"blue\", alpha=0.5, s=10)\n plt.scatter(0, 0, marker=\"D\", c=\"black\", alpha=0.8)\n plt.scatter(2, 2, marker=\"D\", c=\"black\", alpha=0.8)\n ... | [
"0.67238843",
"0.6708577",
"0.66642416",
"0.6630281",
"0.630712",
"0.63052666",
"0.6298917",
"0.6278833",
"0.6265205",
"0.6168853",
"0.6166783",
"0.6123382",
"0.61222416",
"0.6115842",
"0.6083699",
"0.60783607",
"0.607288",
"0.6068224",
"0.6062484",
"0.6058355",
"0.6018583",
... | 0.7072408 | 0 |
Extracts square patches of patch_dim by patch_dim from the data. Returns a patch_dim^2 by numpatches matrix. | def extract_patches(data,patch_dim):
m = data.shape[0]
im_x = data.shape[1]
im_y = data.shape[2]
assert im_x%float(patch_dim)==0 and im_y%float(patch_dim)==0, \
"patch_size must divide x and y dimensions of image"
numpatchs = m*(im_x/patch_dim)*(im_y/patch_dim)
patch_size = patch_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def patches_sampling(self, image, patch_size, stride):\n h, w = image.shape[2:4]\n patches = []\n for i in range(0, h - patch_size + 1, stride):\n for j in range(0, w - patch_size + 1, stride):\n patches.append(image[:, :, i:i + patch_size, j:j + patch_size])\n ... | [
"0.6891319",
"0.6779682",
"0.66917896",
"0.6450875",
"0.64256436",
"0.6412834",
"0.6366795",
"0.63452667",
"0.6342837",
"0.6332445",
"0.63294715",
"0.6287567",
"0.62787473",
"0.6240202",
"0.6159606",
"0.6138685",
"0.606784",
"0.60129994",
"0.597121",
"0.5943119",
"0.59225255"... | 0.7664922 | 0 |
Determine the index of the top of climb altitude. Returns The index of the first cruising altitude. | def top_of_climb_index(self):
return self.altitudes.argmax() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def top_of_descent_index(self):\n tod = self.altitudes.argmax()\n # if the altitude profile is not just a climb\n # and there is a cruising section\n if (tod < len(self.altitudes) - 1) and \\\n (self.altitudes[tod] == self.altitudes[tod + 1]):\n tod += 1\n\n ... | [
"0.82650274",
"0.6586973",
"0.64087886",
"0.63747007",
"0.63523763",
"0.62209785",
"0.60802037",
"0.6078412",
"0.60293245",
"0.60026336",
"0.59891087",
"0.5984468",
"0.5980566",
"0.5978508",
"0.5973972",
"0.59719825",
"0.59692377",
"0.5964401",
"0.59599084",
"0.59111434",
"0.... | 0.84036976 | 0 |
Determine the index of the top of climb altitude. Returns The index of the last cruising altitude. | def top_of_descent_index(self):
tod = self.altitudes.argmax()
# if the altitude profile is not just a climb
# and there is a cruising section
if (tod < len(self.altitudes) - 1) and \
(self.altitudes[tod] == self.altitudes[tod + 1]):
tod += 1
return to... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def top_of_climb_index(self):\n return self.altitudes.argmax()",
"def alt_index(self) -> Optional[int]:\n if not self.is_hom_alt():\n return None\n return max(self.allele1, self.allele2) - 1",
"def top_offset(self):\n raise NotImplementedError",
"def top(self):\n ... | [
"0.845523",
"0.66592854",
"0.6438688",
"0.64357513",
"0.64272976",
"0.64195174",
"0.6181029",
"0.6179077",
"0.6126768",
"0.61237574",
"0.6112536",
"0.61075664",
"0.61017954",
"0.60960674",
"0.60574836",
"0.6043104",
"0.60421985",
"0.6038397",
"0.6038397",
"0.60144544",
"0.601... | 0.82606477 | 1 |
Return pandas dataframe with annual, quarterly, monthly or daily data. | def get_frame(freq: str):
url = 'http://minikep-db.herokuapp.com/api/frame?freq={}'.format(freq)
return pd.read_csv(url, converters={0: pd.to_datetime}, index_col=0) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_time_series_data():\r\n # Grab the requested years and columns from the query arguments\r\n ls_year = [int(year) for year in request.args.getlist(\"n\")]\r\n ls_col = request.args.getlist(\"m\")\r\n\r\n # Generate a list of all the months we need to get\r\n all_years = [str(year) for year in... | [
"0.61230016",
"0.6044962",
"0.59703547",
"0.5963478",
"0.5958542",
"0.59389883",
"0.5922768",
"0.5885662",
"0.58801645",
"0.58436364",
"0.5840979",
"0.58044046",
"0.57593805",
"0.57528985",
"0.5697548",
"0.5684046",
"0.5673133",
"0.564309",
"0.56324506",
"0.56079215",
"0.5598... | 0.0 | -1 |
Return a string representation of the config. | def __str__(self):
# top row
result = ' '
result = '\n ' + '-' * (self.DIM*2+5) + '\n'
# board rows
for row in range(self.DIM):
if row is 3 or row is 6:
result += '|' + '-' * (self.DIM*2+5) + '|' + '\n'
# result +... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __str__():\n return str(_config)",
"def __str__(self):\n config_str = 'Configurations\\n'\n config_str += pprint.pformat(self.__dict__)\n return config_str",
"def __repr__(self) -> str:\n return json.dumps(self._config)",
"def str(self):\n\n list_of_entries = ['{0} n... | [
"0.85173273",
"0.8513157",
"0.8259779",
"0.7956899",
"0.77279353",
"0.7583788",
"0.7550117",
"0.7511544",
"0.7511544",
"0.7487914",
"0.74800324",
"0.74372464",
"0.7417465",
"0.737675",
"0.73606914",
"0.7319001",
"0.72816837",
"0.7248459",
"0.7144512",
"0.7063809",
"0.68749636... | 0.0 | -1 |
forward pass of the layer | def forward(self, x):
return torch.conv_transpose2d(input=x,
weight=self.weight * self.scale, # scale the weight on runtime
bias=self.bias if self.use_bias else None,
stride=self.stride,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def forward(self, input):\n return self.layers(input)",
"def forward(self, x):\n return self.layers(x)",
"def __feed_forward(self, X):\n # go over all layers\n for layer in self.__layers:\n X = layer.compute_act(X)\n\n return X",
"def _forward(self):\n\n t... | [
"0.7367367",
"0.73399484",
"0.7315237",
"0.72809756",
"0.7266685",
"0.72531646",
"0.72451967",
"0.7235675",
"0.72132516",
"0.7186353",
"0.7180268",
"0.7173166",
"0.71502644",
"0.7145505",
"0.7143514",
"0.71366554",
"0.7135957",
"0.7118842",
"0.70899886",
"0.70655066",
"0.7061... | 0.0 | -1 |
forward pass of the layer | def forward(self, x, alpha=1e-8):
batch_size, _, height, width = x.shape
# [B x C x H x W] Subtract mean over batch.
y = x - x.mean(dim=0, keepdim=True)
# [1 x C x H x W] Calc standard deviation over batch
y = torch.sqrt(y.pow(2.).mean(dim=0, keepdim=False) + alpha)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def forward(self, input):\n return self.layers(input)",
"def forward(self, x):\n return self.layers(x)",
"def __feed_forward(self, X):\n # go over all layers\n for layer in self.__layers:\n X = layer.compute_act(X)\n\n return X",
"def _forward(self):\n\n t... | [
"0.7367367",
"0.73399484",
"0.7315237",
"0.72809756",
"0.7266685",
"0.72531646",
"0.72451967",
"0.7235675",
"0.72132516",
"0.7186353",
"0.7180268",
"0.7173166",
"0.71502644",
"0.7145505",
"0.7143514",
"0.71366554",
"0.7135957",
"0.7118842",
"0.70899886",
"0.70655066",
"0.7061... | 0.0 | -1 |
create u_{xx} matrix operator using central differences. No flux boundaries assumed. | def create_Uxx_mat(x):
dx = x[1] - x[0]
x_int = np.arange(1,len(x)-1,dtype=int)
#create u_{xx} matrix operator
Uxx_mat_row = np.hstack((x_int,x_int,x_int))
Uxx_mat_col = np.hstack((x_int-1,x_int,x_int+1))
Uxx_entry = (1/(dx**2))*np.hstack((np.ones(len(x)-2),-2*np.ones(len(x)-2),(np.on... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_Ux_mat(x):\n \n dx = x[1] - x[0]\n \n ## upwind method based on left cells moving right\n ## and right cells moving left (similar to a scratch assay)\n '''x_int = np.arange(1,len(x)-1,dtype=int)\n Ux_mat_row = np.hstack((x_int, x_int))\n Ux_mat_col = np.hstack((x_int, x_int[:len(... | [
"0.62446815",
"0.62316376",
"0.6046306",
"0.6005687",
"0.59617823",
"0.5938628",
"0.59300697",
"0.58108884",
"0.5771789",
"0.5753315",
"0.5722855",
"0.5706403",
"0.56890017",
"0.5678955",
"0.5677416",
"0.5673115",
"0.5672235",
"0.56281036",
"0.5621129",
"0.56142914",
"0.55678... | 0.69822335 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.