query stringlengths 9 9.05k | document stringlengths 10 222k | metadata dict | negatives listlengths 30 30 | negative_scores listlengths 30 30 | document_score stringlengths 4 10 | document_rank stringclasses 2
values |
|---|---|---|---|---|---|---|
Check second row starts with TYPE (caseinsensitive). | def validate_type_keyword(self):
valid = False
if self.annot_types[0].upper() == "TYPE":
valid = True
if self.annot_types[0] != "TYPE":
msg = f'File keyword "TYPE" provided as {self.annot_types[0]}'
self.store_validation_issue("warn", msg, "format:... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def type_match(cls, line):\n match = Ftype.itype_re.match(line.strip())\n return match",
"def _match_entry_type(self, code_entry, type_tuple):\n matched = False\n if self.loading_from_file:\n type_list = []\n for elem in type_tuple:\n type_list.app... | [
"0.64790285",
"0.6468146",
"0.64528406",
"0.6439068",
"0.62383944",
"0.6123555",
"0.60611904",
"0.6022172",
"0.60128903",
"0.58234835",
"0.5796305",
"0.5774943",
"0.57683223",
"0.5727209",
"0.56927145",
"0.5690744",
"0.5685098",
"0.5670693",
"0.5657422",
"0.5648879",
"0.56445... | 0.6673262 | 0 |
Header and type counts should match. | def validate_against_header_count(self):
valid = False
len_headers = len(
[header for header in self.headers if "Unnamed" not in header]
)
len_annot_type = len(
[
annot_type
for annot_type in self.annot_types
if "Unn... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_check_header(self):\r\n\r\n # Default header, should not generate any errors/warnings\r\n header = ['SampleID', 'BarcodeSequence', 'LinkerPrimerSequence',\r\n 'Description']\r\n errors = []\r\n warnings = []\r\n\r\n errors, warnings = check_header(header... | [
"0.65084815",
"0.6204757",
"0.6197411",
"0.61853856",
"0.6127372",
"0.611669",
"0.6078303",
"0.60777265",
"0.59556013",
"0.5935176",
"0.5927466",
"0.5926229",
"0.5874381",
"0.584954",
"0.5824131",
"0.5819541",
"0.5805356",
"0.57966363",
"0.57934415",
"0.578093",
"0.57493377",... | 0.7336339 | 0 |
Check numeric annotations are not string dtype | def validate_numeric_annots(self):
valid = True
for annot_header in self.file.columns[1:]:
annot_name = annot_header[0]
annot_type = annot_header[1]
column_dtype = self.file.dtypes[annot_header]
if annot_type == "numeric" and column_dtype == "object":
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_like_numeric(self, name):\n if self.is_array(name):\n raise TypeError(\"Cannot test array masks for numeric likeness!\")\n if not self._meta['columns'][name]['type'] == 'string':\n err = \"Column '{}' is not of type string (but {}).\"\n raise TypeError(err.form... | [
"0.69214994",
"0.67782515",
"0.6699579",
"0.65814674",
"0.6571638",
"0.65422213",
"0.6518942",
"0.64787567",
"0.6396439",
"0.637611",
"0.63711864",
"0.634312",
"0.6297147",
"0.62690866",
"0.62252414",
"0.6222278",
"0.6186871",
"0.6175261",
"0.6153596",
"0.6124058",
"0.6118033... | 0.7367969 | 0 |
Search through the successors of a problem to find a goal. The argument open_nodes should be an empty queue. | def graph_search(problem, open_nodes):
explored = [problem.initial]
open_nodes.append(Node(problem.initial))
while len(open_nodes) > 0:
node = open_nodes.pop()
if problem.goal_test(node.state):
#print "Path cost: %d" % node.path_cost
return node.solution()
for... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def graph_search(problem, open_nodes):\n explored = [problem.initial]\n open_nodes.append(Node(problem.initial))\n while len(open_nodes) > 0:\n node = open_nodes.pop()\n if problem.goal_test(node.state):\n #print \"Path cost: %d\" % node.path_cost\n print 'Broj poteza: ... | [
"0.7524506",
"0.6390069",
"0.6312279",
"0.62631655",
"0.62288857",
"0.61792976",
"0.6144662",
"0.61046195",
"0.60863274",
"0.60447466",
"0.60165495",
"0.6000054",
"0.59386504",
"0.5931846",
"0.5931377",
"0.5909588",
"0.5905719",
"0.5900042",
"0.58983403",
"0.58969164",
"0.587... | 0.7382932 | 1 |
Returns a validator of the required type for the specified asset class. | def get_validator(self, analysis_id: str, asset_class: Union[AssetClass, str]) -> BaseValidator:
if not isinstance(asset_class, AssetClass):
asset_classes = sum([economy.asset_classes for economy in self._config.economies], [])
try:
asset_class = next(ac for ac in asset_c... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_validator_class(self):\n return self.validator_class",
"def get_validator(self):\n return self.get_validator_class()(**self.get_validator_kwargs())",
"def _get_validator(self):\n validator_class = self.validator_class or AssertionValidator\n if validator_class:\n ... | [
"0.653391",
"0.64453036",
"0.62696373",
"0.57303554",
"0.5680293",
"0.56693923",
"0.55158603",
"0.53680676",
"0.5308757",
"0.5283247",
"0.5255257",
"0.5211604",
"0.51977885",
"0.5196261",
"0.5182698",
"0.51178056",
"0.5116963",
"0.5112818",
"0.5112818",
"0.50356996",
"0.50244... | 0.73015237 | 0 |
Convert a point cloud into a convex hull trimesh | def trimesh_from_point_cloud(cloud):
points = np.asarray(cloud)
hull = scipy.spatial.ConvexHull(points)
hull = scipy.spatial.ConvexHull(points[hull.vertices])
ru.transforms.counterclockwise_hull(hull)
vertices = hull.points
faces = hull.simplices
return vertices, faces | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convex_hull(points):\n\n # Sort the points lexicographically (tuples are compared lexicographically).\n # Remove duplicates to detect the case we have just one unique point.\n points = sorted(set(points))\n\n # Boring case: no points or a single point, possibly repeated multiple times.\n if len(... | [
"0.67052907",
"0.66870964",
"0.6643811",
"0.66297066",
"0.66177464",
"0.65493083",
"0.6496797",
"0.6406553",
"0.6347456",
"0.62247926",
"0.6148329",
"0.61243004",
"0.6117861",
"0.6099049",
"0.6041913",
"0.60070765",
"0.5967056",
"0.5964386",
"0.5954754",
"0.5928189",
"0.59159... | 0.8171996 | 0 |
The value picker requires to be prepared. It returns a new value function as the preparation result. The eval method of this class therefore raises an error if called. | def eval(self, value: Value) -> Value:
raise NotImplementedError() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prepare(self, values: List[Value]) -> ValueFunction:\n # Pick the most frequent value that satisfies the addition constraints\n # of this picker. Use a scalar_pass_through as the default if no value\n # is selected and the user did not set the raise_error flag when the\n # object wa... | [
"0.70165414",
"0.62445724",
"0.61526734",
"0.61099863",
"0.61099863",
"0.61099863",
"0.6025469",
"0.60112596",
"0.59765506",
"0.58695966",
"0.5844581",
"0.58432573",
"0.58218783",
"0.5818647",
"0.57424766",
"0.57116103",
"0.5665983",
"0.56174535",
"0.5549878",
"0.55391467",
"... | 0.6769919 | 1 |
Optional step to prepare the function for a given set of values. This step allows to compute additional statistics over the set of values. While it is likely that the given set of values represents the values for which the eval() function will be called, this property is not guaranteed. | def prepare(self, values: List[Value]) -> ValueFunction:
# Pick the most frequent value that satisfies the addition constraints
# of this picker. Use a scalar_pass_through as the default if no value
# is selected and the user did not set the raise_error flag when the
# object was constru... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prep_exec(user, value, steps):\n\n logger.debug(f'Running preprocessing for \"{user}\", value \"{value}\" and steps \"{steps}\"')\n for func, step_args in steps.items():\n logger.debug(f'Input value: \"{value}\", func: {func}, args: \"{step_args}\"')\n if func == 'replace':\n if ... | [
"0.5547577",
"0.551395",
"0.54152936",
"0.5406809",
"0.5376129",
"0.53735447",
"0.5350418",
"0.5344096",
"0.53337216",
"0.5283287",
"0.5249842",
"0.52088624",
"0.52085036",
"0.5173359",
"0.51605576",
"0.50833076",
"0.5082002",
"0.5066773",
"0.50656396",
"0.5052529",
"0.504592... | 0.5771836 | 0 |
Return the the most frequent value in the counter. If the counter is empty or contains multiple mostfrequent values the default value is returned or a ValueError is raised. | def pick(
self, values: Counter, default: Optional[Union[Callable, Value]] = None,
raise_error: Optional[bool] = False
) -> Value:
# There are several cases where no value will be selected. One of them
# is the case where there are no values in the list.
if len(values) == 0:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def most_frequent(x):\n return Counter(x).most_common()[0][0]",
"def pick(\n self, values: Counter, default: Optional[Union[Callable, Value]] = None,\n raise_error: Optional[bool] = False\n ) -> Value:\n if len(values) == 1:\n return values.most_common(1)[0][0]\n elif... | [
"0.693529",
"0.66617507",
"0.6557146",
"0.65350777",
"0.6389675",
"0.62581664",
"0.6252149",
"0.6250763",
"0.6164528",
"0.6164528",
"0.6125964",
"0.6097379",
"0.6088174",
"0.6081146",
"0.6081146",
"0.6081146",
"0.6081146",
"0.6081146",
"0.60789716",
"0.60780644",
"0.60496676"... | 0.6736942 | 1 |
Return the only value in the given counter. If the counter contains no value or more than one value the default value is returned or a ValueError is raised. | def pick(
self, values: Counter, default: Optional[Union[Callable, Value]] = None,
raise_error: Optional[bool] = False
) -> Value:
if len(values) == 1:
return values.most_common(1)[0][0]
elif not raise_error:
return default
raise ValueError('received s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pick(\n self, values: Counter, default: Optional[Union[Callable, Value]] = None,\n raise_error: Optional[bool] = False\n ) -> Value:\n # There are several cases where no value will be selected. One of them\n # is the case where there are no values in the list.\n if len(val... | [
"0.6780167",
"0.65177083",
"0.6369465",
"0.61656475",
"0.6136545",
"0.58409417",
"0.5627552",
"0.5581728",
"0.5522702",
"0.55165803",
"0.5494377",
"0.5473663",
"0.546256",
"0.5461268",
"0.5449915",
"0.5404653",
"0.53960216",
"0.53824174",
"0.53578687",
"0.5337809",
"0.5328633... | 0.705603 | 0 |
Make the programs dance according to the moves sequence. Return the list of programs after the dance. | def programs_dance(moves, programs):
for move in moves:
if move[0] == "s":
x = int(move[1:])
programs = programs[-x:] + programs[:-x]
if move[0] == "x":
A, B = move[1:].split("/")
A, B = int(A), int(B)
programs[A], programs[B] = programs[B... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def programs_dance_repeat(moves):\n\n # the dance is a permutation of all programs (because we end up with a list\n # of 16 elements containing \"a\", \"b\", ... \"p\" in different order).\n # Everytime we repeat the dance, we repeat the same permutation. Landau has\n # proved that recursively applying... | [
"0.686738",
"0.659888",
"0.6338046",
"0.57136136",
"0.5700997",
"0.5649385",
"0.54786175",
"0.5333998",
"0.52400976",
"0.522506",
"0.52119786",
"0.52070266",
"0.5192888",
"0.5167975",
"0.5147348",
"0.5142743",
"0.5127947",
"0.5106482",
"0.5051219",
"0.5022123",
"0.5014936",
... | 0.7373071 | 0 |
Open a web browser pointing to a given URL. We use this function instead of Python's `webbrowser` module because this way we can capture stdout/stderr to avoid polluting the terminal with the browser's messages. For example, Chrome always prints things like "Created new window in existing browser session", and those ge... | def open_browser(url):
# Treat Windows separately because:
# 1. /dev/null doesn't exist.
# 2. subprocess.Popen(['start', url]) doesn't actually pop up the
# browser even though 'start url' works from the command prompt.
# Fun!
# Also, use webbrowser if we are on Linux and xdg-open is not inst... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def open_web_browser(url: str):\n Popen(web_browser + [url], stdout=DEVNULL, stderr=DEVNULL)",
"def open_browser(url):\n import webbrowser\n webbrowser.open_new(url)",
"def open_url(url):\n logger.debug('Opening %s', url)\n _stderr = os.dup(2)\n os.close(2)\n _stdout = os.dup(1)\n ... | [
"0.83927095",
"0.8275761",
"0.8007089",
"0.79415",
"0.7877351",
"0.7801657",
"0.74490196",
"0.72737986",
"0.72407854",
"0.7134543",
"0.71054685",
"0.70941466",
"0.7083675",
"0.7056399",
"0.7035345",
"0.69157714",
"0.6792344",
"0.6786104",
"0.67447037",
"0.67428684",
"0.670141... | 0.83015114 | 1 |
Convert a tuple to a list. Leave as is if it's not a tuple. | def _maybe_tuple_to_list(item: Any) -> Any:
if isinstance(item, tuple):
return list(item)
return item | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tuple_to_list(tup):\n return [element for element in tup]",
"def to_list(ls):\r\n if isinstance(ls, (list, tuple)):\r\n return list(ls)\r\n else:\r\n return [ls]",
"def _as_list(arr):\n if not isinstance(arr, (list, tuple)):\n return [arr]\n return arr",
"def t... | [
"0.88657916",
"0.74411047",
"0.73352075",
"0.7089461",
"0.7007401",
"0.6874846",
"0.683141",
"0.6754467",
"0.66321504",
"0.6620295",
"0.6619706",
"0.6607471",
"0.65294397",
"0.6527143",
"0.6508084",
"0.6490082",
"0.64760363",
"0.6465576",
"0.6416606",
"0.6405145",
"0.63494104... | 0.79983497 | 1 |
A clean repr for a class, excluding both values that are likely defaults, and those explicitly default for dataclasses. | def repr_(self: Any) -> str:
classname = self.__class__.__name__
# Most of the falsey value, but excluding 0 and 0.0, since those often have
# semantic meaning within streamlit.
defaults: list[Any] = [None, "", False, [], set(), dict()]
if dataclasses.is_dataclass(self):
fields_vals = (
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dataclassRepr(obj) -> str:\n attrs = dataclassNonDefaults(obj)\n clsName = obj.__class__.__qualname__\n kwargs = ', '.join(f'{k}={v!r}' for k, v in attrs.items())\n return f'{clsName}({kwargs})'",
"def _compact_class_repr(obj):\n dict_str_list = []\n post_repr_string = \"\"\n\n ... | [
"0.7189519",
"0.7120133",
"0.70753986",
"0.6904203",
"0.6853401",
"0.6748134",
"0.672336",
"0.6704162",
"0.66966355",
"0.66837174",
"0.66793245",
"0.6672579",
"0.6659263",
"0.66233885",
"0.6621962",
"0.6614088",
"0.66054744",
"0.65907794",
"0.6589696",
"0.6559397",
"0.6545253... | 0.8041682 | 0 |
Extracts key (caseinsensitive) query params from Dict, and returns them as Set of str. | def extract_key_query_params(
query_params: Dict[str, List[str]], param_key: str
) -> Set[str]:
return set(
[
item.lower()
for sublist in [
[value.lower() for value in query_params[key]]
for key in query_params.keys()
if key.lower()... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_agenda_filter_params(querydict):\n if len(querydict) == 0:\n return None\n\n # Parse group filters from GET parameters. Other params are ignored.\n filt_params = {'show': set(), 'hide': set(), 'showtypes': set(), 'hidetypes': set()}\n\n for key, value in querydict.items():\n if ... | [
"0.5907419",
"0.57911414",
"0.570759",
"0.56520545",
"0.5543385",
"0.54871225",
"0.54643226",
"0.5453567",
"0.5442225",
"0.54348445",
"0.5377928",
"0.5374937",
"0.53677315",
"0.5347859",
"0.5342615",
"0.531042",
"0.5258402",
"0.52570987",
"0.52568936",
"0.5234285",
"0.522745"... | 0.8314894 | 0 |
Apply a function along an axis of the DataFrame using multiprocessing. | def apply_parallel(df, func, **kwargs):
num_workers = cpu_count()
if (df.shape[0] == 1) or (num_workers == 1):
return apply_df((df, func, kwargs))
retLst = Parallel(n_jobs=num_workers)(delayed(apply_df)(
input_args=(d, func, kwargs)) for d in np.array_split(df, num_workers))
return pd.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def apply_over_rows(func, data, **kwargs):\n\n axis = 1\n cpu_cnt = multiprocessing.cpu_count()\n \n chunks = [(func, axis, split_data, kwargs) for split_data in np.array_split(data, cpu_cnt) if split_data.size > 0]\n\n pool = multiprocessing.Pool()\n map_results = pool.starmap(np_apply_along_axi... | [
"0.7176442",
"0.6629305",
"0.6597764",
"0.65963036",
"0.65020716",
"0.64380866",
"0.6403971",
"0.6357005",
"0.6255756",
"0.6197885",
"0.6088578",
"0.6088578",
"0.60554737",
"0.60220635",
"0.6003617",
"0.59359556",
"0.5861543",
"0.57749087",
"0.5750628",
"0.5696482",
"0.564946... | 0.6749158 | 1 |
Get a service from the container by name. | def get_service(service_name):
return Container.services[service_name]() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_service(self, name):\n return self.app.container.get(name)",
"def getService(name):\n return Service.getService(name)",
"def get_service(self,name):\n\t\t#forma segura de obtener un servicio\n\t\ttry:\n\t\t\treturn self._services[name]\n\t\texcept Exception:\n\t\t\treturn None",
"def get_se... | [
"0.8902218",
"0.80127394",
"0.79672956",
"0.7605169",
"0.7597852",
"0.7081052",
"0.6929803",
"0.6918446",
"0.69011825",
"0.6876253",
"0.6819986",
"0.673684",
"0.6736515",
"0.6715733",
"0.6571475",
"0.6518713",
"0.64946944",
"0.64132804",
"0.6366688",
"0.63574386",
"0.6328164"... | 0.8451815 | 1 |
Set a service. You might want to use it when building the container manually in testing or when we need to swap services during tests. | def set_service(service_name, reference):
Container.services[service_name] = reference | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def service(self, service):\n \n self._service = service",
"def setService(self, service):\n self.__service = service\n self.__buttons.setDisabled(False)\n self.name.setText(service.data.name)\n self.threadable.setChecked(service.data.threadable)\n self.min_cores.... | [
"0.73859864",
"0.7380048",
"0.7302922",
"0.706042",
"0.6798804",
"0.6728655",
"0.6715897",
"0.6505851",
"0.64444685",
"0.64222926",
"0.640598",
"0.6388694",
"0.6143635",
"0.6122754",
"0.61195254",
"0.61195254",
"0.6100373",
"0.6081602",
"0.60402346",
"0.60310894",
"0.60134745... | 0.7790586 | 0 |
Get the location service. | def location_service() -> Location.Service:
return Container.get_service('location_service') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_location(\n self,\n ) -> Callable[[locations_pb2.GetLocationRequest], locations_pb2.Location]:\n # Generate a \"stub function\" on-the-fly which will actually make\n # the request.\n # gRPC handles serialization and deserialization, so we just need\n # to pass in the f... | [
"0.70239884",
"0.70239884",
"0.70067424",
"0.6827215",
"0.6646132",
"0.66134334",
"0.6591265",
"0.6547537",
"0.6512482",
"0.6505879",
"0.64422673",
"0.64338136",
"0.6418361",
"0.63520294",
"0.6311977",
"0.6290465",
"0.6288686",
"0.62853724",
"0.62675357",
"0.6257025",
"0.6248... | 0.88339275 | 0 |
Read sequence entries from FASTQ file. Assumes 4 line FASTQ format. Yields (header, seq, second_header, scores) tuples. | def read_fastq(filename, strip_second_header=True):
with open(filename) as fastq:
line = fastq.readline()
if not line.startswith("@"):
raise IOError("Not FASTQ format? First line didn't start with @")
while fastq:
if line.startswith("@"):
header = lin... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_seqs(f):\n while True:\n # Read the sequence ID. If there's nothing to read, then we're done.\n try:\n seq_id = read_line(f)\n except EOFError:\n return\n\n # If we successfully read a sequence ID, then running out of stuff to\n # read means a tr... | [
"0.7212153",
"0.69151074",
"0.6835662",
"0.6782494",
"0.67033434",
"0.6573358",
"0.6569511",
"0.656706",
"0.65398455",
"0.6536874",
"0.63818073",
"0.6355755",
"0.6331096",
"0.63269556",
"0.6277137",
"0.6263182",
"0.6262951",
"0.6222806",
"0.6208045",
"0.62061477",
"0.6205958"... | 0.7422727 | 0 |
Initialize the ImagePool class | def __init__(self, pool_size, p=.5):
self.pool_size = pool_size
if self.pool_size > 0:
self.num_images = 0
self.images = []
self.p = p | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, pool_size):\n self.pool_size = pool_size\n if self.pool_size > 0: # create an empty pool\n self.num_imgs = 0\n self.images = []",
"def initImages(self):\n pass",
"def initImages(self):\n pass",
"def initImages(self):\n pass",
"def... | [
"0.8305123",
"0.7105055",
"0.7105055",
"0.7105055",
"0.70512635",
"0.6938319",
"0.6874643",
"0.6870535",
"0.6862322",
"0.6823763",
"0.6645234",
"0.6544737",
"0.65240043",
"0.6491583",
"0.64782196",
"0.6457286",
"0.64476025",
"0.6440739",
"0.640556",
"0.63887614",
"0.63673085"... | 0.8122454 | 1 |
Return the state utility. v the value vector T transition matrix u utility vector reward for that state gamma discount factor the utility of the state | def return_state_utility(v, T, u, reward, gamma):
action_array = np.zeros(4)
for action in range(0, 4):
action_array[action] = np.sum(np.multiply(u, np.dot(v, T[:, :, action])))
return reward + gamma * np.max(action_array) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def return_state_utility(self, v, T, u, reward, gamma):\n action_array = np.zeros(4)\n for action in range(0, 4):\n action_array[action] = np.sum(np.multiply(u, np.dot(v, T[:,:,action])))\n return reward + gamma * np.max(action_array)",
"def utility(consumption_vector, gamma):\n\n... | [
"0.8345836",
"0.6683496",
"0.6252933",
"0.62017244",
"0.6186437",
"0.6123095",
"0.59839314",
"0.5959301",
"0.59305716",
"0.59045005",
"0.5869483",
"0.58545756",
"0.5837485",
"0.5747787",
"0.572474",
"0.57234555",
"0.57216656",
"0.5709984",
"0.5703631",
"0.56705874",
"0.563368... | 0.8327839 | 1 |
Find all bundles in the input directories. A bundle is a directory that contains files relevant to the bundle. Any directory found in any of the input directories is a bundle, unless it's listed to be ignored. | def find_bundles(self):
defaults = self.config.bundle_defaults
for input_dir in self.engine.input_dirs:
files, bundles = _potential_bundles(input_dir)
bundles = [b for b in bundles if not self.is_ignored_bundle(b)]
for (path, name) in bundles:
prefix,... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_bundles(bundles_dir: Path) -> List[Path]:\n logger.debug(\"scanning: %s\", bundles_dir)\n bundles: List[Path] = []\n for file in bundles_dir.iterdir():\n path = bundles_dir.joinpath(file)\n if path.is_file() and not path.is_symlink():\n if path.suffix == '.yaml' or path.s... | [
"0.7655485",
"0.74458665",
"0.71323603",
"0.57610023",
"0.57382214",
"0.56338155",
"0.5599697",
"0.5540205",
"0.5506582",
"0.54691887",
"0.546027",
"0.5425846",
"0.53950936",
"0.5395085",
"0.5343908",
"0.5325677",
"0.53223604",
"0.5316361",
"0.53162134",
"0.5304278",
"0.52968... | 0.81572235 | 0 |
Create parameter groups which have different learning rate and weight decay rate. Usually weight decay is not performed to `LayerNorm` parameters and biases. To ignore them from weight decaying, it is required to specify different weight decay rate to each parameter group. This function supports not only weight decay s... | def create_param_groups(
model: TransformerMixin,
learning_rate: float,
layerwise_lr_decay: float = 1.0,
weight_decay: float = 0.01,
) -> Iterator[Dict[str, Any]]:
for i, modules in enumerate(reversed(list(model.hierarchical_modules()))):
# While the generator becomes empty after consuming a... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def param_groups_lrd(model, weight_decay=0.05, no_weight_decay_list=[], layer_decay=.75):\n param_group_names = {}\n param_groups = {}\n main_block = [\n i for i, blk in enumerate(model.blocks) \n if not isinstance(blk, (PatchEmbed, PatchMerge))\n ]\n max_layer = len(main_block) + 1\n ... | [
"0.6909425",
"0.65918446",
"0.6530897",
"0.6495904",
"0.64355665",
"0.64215845",
"0.61620945",
"0.6153254",
"0.6153254",
"0.6153254",
"0.6153254",
"0.6151622",
"0.61197025",
"0.60688996",
"0.6052441",
"0.60359275",
"0.60301745",
"0.6007458",
"0.5960928",
"0.59574825",
"0.5957... | 0.75162005 | 0 |
(annotateresult, [str], set([rev, linenum])) > None. write output. annotateresult can be [(node, linenum, path)], or [(node, linenum)] | def write(self, annotatedresult, lines=None, existinglines=None):
pieces = [] # [[str]]
maxwidths = [] # [int]
# calculate padding
for f, sep, name, enc in self.funcmap:
l = [enc(f(x)) for x in annotatedresult]
pieces.append(l)
if name in [b'node', ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _write_keypoint_results(keypoint_results, gt_folder, pred_folder):",
"def _write_annotations(self, anns, rec_id, out_handle):\n format_anns = self._format_keyvals(anns)\n if format_anns:\n print repr(format_anns)\n parts = [rec_id, \"annotation\", \"remark\", \".\", \".\",... | [
"0.6042696",
"0.597556",
"0.5805823",
"0.57127726",
"0.56387293",
"0.56292593",
"0.56071514",
"0.5590312",
"0.55020684",
"0.54928595",
"0.54797286",
"0.5463921",
"0.5452123",
"0.5443026",
"0.54268223",
"0.5424146",
"0.54229",
"0.538764",
"0.53313065",
"0.5287071",
"0.5276209"... | 0.64344114 | 0 |
Test Markovian matrix M for random motion | def test_markovian_matrix():
# load graph
graph_file = 'G7V_test.p'
g = ext.get_graph(graph_file)
v0_target = [1, 5, 7]
init_prob = [0.2, 0.5, 0.3]
b_0, M = cp.my_target_motion(g, v0_target, init_prob)
a = 1 / 3
b = 1 / 4
c = 1 / 2
M_exp = [[a, a, a, 0, 0, 0, 0],
[... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def random_markov_matrix(n_states=5, seed=None):\n if seed is not None:\n np.random.seed(seed)\n t_matrix = np.random.random((n_states, n_states))\n return normalize_markov_matrix(t_matrix)",
"def kmm_init(X, m = 10):\n\n # compute the distances\n XXT = np.dot(X, X.T)\n D = (-2.*XXT + np... | [
"0.6855803",
"0.6170317",
"0.6165354",
"0.59833914",
"0.5961296",
"0.5923251",
"0.5802775",
"0.5732272",
"0.5726327",
"0.5709035",
"0.56884927",
"0.56838375",
"0.5658384",
"0.5651586",
"0.5644555",
"0.5635103",
"0.55962574",
"0.55846393",
"0.5577156",
"0.556965",
"0.5564285",... | 0.7571471 | 0 |
Read CS_STATS_DB.txt into a dictionary. | def read_cs_stats(cs_stats_file=None):
if not cs_stats_file:
file_path_name = os.path.join('data', 'piqc_db', 'CS_STATS_DB.txt')
cs_stats_file = resource_filename(__name__, file_path_name)
cs_stats = defaultdict(_dd)
with open(cs_stats_file, 'r') as fid:
reader = csv.reader(
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def readstatsFile(filename):\r\n contigs = dict()\r\n with open(filename) as f:\r\n for idx, line in enumerate(f):\r\n if idx == 0:\r\n continue\r\n else:\r\n line = line.strip().split()\r\n entry = contigEntry(line)\r\n ... | [
"0.70578414",
"0.6549867",
"0.65315735",
"0.63414013",
"0.63066095",
"0.62973326",
"0.628564",
"0.62751585",
"0.62093854",
"0.61881524",
"0.61376035",
"0.6095829",
"0.6052529",
"0.6050537",
"0.6000555",
"0.5995212",
"0.5950326",
"0.5899939",
"0.5870846",
"0.5865235",
"0.58326... | 0.72520876 | 0 |
Read SEQ_CS_DB.txt into a dictionary. | def read_seq_cs(seq_cs_file=None):
if not read_seq_cs:
file_path_name = os.path.join('data', 'piqc_db', 'SEQ_CS_DB.txt')
seq_cs_file = resource_filename(__name__, file_path_name)
protein_stats = defaultdict(_dd)
with open(seq_cs_file, 'r') as fid:
reader = csv.reader(
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def return_fasta_dic(file):\n seq_dict = {rec.id: rec.seq for rec in SeqIO.parse(file, \"fasta\")}\n return seq_dict",
"def sdf_reader(cls, filename, dbIdentifier = \"LM_ID\"):\n res_dict = {}\n with open(filename) as fp:\n line = fp.readline()\n line_id = \"\"\n ... | [
"0.67171186",
"0.6656155",
"0.6545459",
"0.6502888",
"0.64154184",
"0.6328127",
"0.6304525",
"0.6211741",
"0.61344904",
"0.60686696",
"0.60627896",
"0.60584116",
"0.605379",
"0.6020724",
"0.6011216",
"0.5995271",
"0.5993632",
"0.5968215",
"0.5955838",
"0.595434",
"0.59292406"... | 0.73414546 | 0 |
Checks whether the provided codon pair sequence is the same as the current instance's sequence. | def is_equal(self, codon_pair: 'CodonPair') -> bool:
return self.sequence == codon_pair.sequence | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __eq__(self, sequence):\n try:\n return self.seq == sequence.seq\n except AttributeError:\n return self.seq == sequence",
"def test_horizontal_sequence_match(self):\n dna = self._create_dna()\n\n # Existing codon pair\n correct_codon_pair = dna.data[2]... | [
"0.7677015",
"0.6774553",
"0.6738002",
"0.653054",
"0.64980197",
"0.6477715",
"0.6312358",
"0.6306449",
"0.60412043",
"0.603724",
"0.6026691",
"0.6018993",
"0.5994418",
"0.59883213",
"0.5927918",
"0.5919455",
"0.5879789",
"0.58612",
"0.5777331",
"0.57748216",
"0.577021",
"0... | 0.8138863 | 0 |
Runs a q agent according to a policy | def run_q_agent(policy='ε–greedy', save=False):
agent = Q_Agent()
all_iterations, all_rewards, step_count = agent.train(env, iter_n=1000, policy=policy)
plot_reward(all_iterations, all_rewards)
plot_steps(all_iterations, step_count)
# print("best route is {}".format(agent.test(env)))
# if save:
# save_results(a... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def policy(agent):",
"def main():\n\t# GET THE DIALOG CONTENT\n\tpolicyFlag = int(sys.argv[3])\n\tif policyFlag == 0:\n\t\texistedIterNum = 15000\n\t\texistedThetaFileName = 'algorithms/theta/cycle_tree/of0w1.0g5v0.0625l0.05'\n\telif policyFlag == 1:\n\t\texistedIterNum = 10000\n\t\texistedThetaFileName = 'algor... | [
"0.6876435",
"0.5955523",
"0.5911889",
"0.5824395",
"0.5760219",
"0.56509584",
"0.5590917",
"0.5505955",
"0.5399128",
"0.53948766",
"0.533803",
"0.5278538",
"0.52547157",
"0.52333534",
"0.5220467",
"0.5219742",
"0.52159584",
"0.5158683",
"0.5158683",
"0.51538444",
"0.51449275... | 0.75134844 | 0 |
Grid search for epsilon values | def grid_search_epsilon(environmnet, policy='ε–greedy', parameter='epsilon'):
parameter_values = []
avg_scores = []
avg_steps = []
count = 1
decay_search = [0.5, 0.6, 0.7, 0.8, 0.9, 0.99, 0.99]
for param_num in decay_search:
agent = Q_Agent(exploration_rate_decay=param_num, epsilon=1)
all_iterations, all_re... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def grid_search(verbose):\n\n # Load Ising data.\n Ising_Data = prepare_Ising_DNN()\n\n # Perform grid search over learning rate and number of hidden neurons.\n N_neurons=np.logspace(0,3,4).astype(\"int\") # Check number of neurons over multiple decades.\n learning_rates=np.logspace(-6,-1,6)\n\n ... | [
"0.64619523",
"0.63645667",
"0.63117504",
"0.6302182",
"0.6265374",
"0.6210436",
"0.6196502",
"0.61118454",
"0.60485965",
"0.5978763",
"0.59554803",
"0.5939661",
"0.59020656",
"0.590064",
"0.58981836",
"0.58878756",
"0.5852087",
"0.583355",
"0.58298755",
"0.581822",
"0.579756... | 0.6974383 | 0 |
Grid search for alpha or gamma adjustable via the parameter field | def grid_search_param(environmnet, policy='ε–greedy', parameter='alpha'):
parameter_values = []
avg_scores = []
avg_steps = []
count = 1
for param_num in np.linspace(0.2, 1, 9):
if parameter == 'alpha':
agent = Q_Agent(alpha=param_num)
elif parameter == 'gamma':
agent = Q_Agent(gamma=param_num)
all... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def optimize_parameters(model, grid, X_train, y_train):\n \n tss = TimeSeriesSplit(n_splits=10)\n \n \n print(\"[INFO] performing random search...\")\n searcher = RandomizedSearchCV(estimator=model, n_jobs=-1, n_iter=10, cv=tss,\n param_distributions=grid, scoring=('neg_mean_squared_error'... | [
"0.65744287",
"0.65717167",
"0.63646746",
"0.63449293",
"0.63407516",
"0.63402605",
"0.6306578",
"0.6304495",
"0.62121177",
"0.61693186",
"0.61690474",
"0.612308",
"0.6120908",
"0.60717666",
"0.60632455",
"0.59773374",
"0.59740543",
"0.59672153",
"0.59471637",
"0.59407824",
"... | 0.6937143 | 0 |
Run a function from a JSON configuration file. | def from_config(func):
def decorator(filename):
with open(filename, 'r') as file_in:
config = json.load(file_in)
#'**' takes a dict and extracts its contents and passes them as parameters to a function.
#returns the intial function with new arguments????
return func(**config)
## return the decorated i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run_json(filepath: str, strict: bool = False, debug: bool = False):\n with open(filepath) as jse:\n return _run_file_full(filepath, json.load(jse), strict=strict, debug=debug)",
"def loadOrRun(filename,function,*args):\r\n def loadJSON(filename):\r\n \"saves the data object as a JSON stri... | [
"0.66084445",
"0.6407644",
"0.63467",
"0.61581904",
"0.60092574",
"0.598345",
"0.59722793",
"0.5956131",
"0.5954308",
"0.5941662",
"0.5932535",
"0.591498",
"0.58501685",
"0.58440065",
"0.5826826",
"0.5811874",
"0.5806291",
"0.58042",
"0.58028346",
"0.5802007",
"0.57860994",
... | 0.64805835 | 1 |
make dir for target if not exists | def check_dir(dir):
if not os.path.exists(dir):
print("[+] Creating directory for target..")
os.makedirs(dir) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_dir_if_needed(dir) :\n\tif not exists(dir) :\n\t\tos.makedirs(dir)",
"def _create_target_path(self, path):\n if not os.path.exists(path) and not self._dry_run:\n logging.debug('Creating target path: %s ...', path)\n try:\n os.makedirs(path)\n except... | [
"0.68034095",
"0.67560685",
"0.6606921",
"0.6563995",
"0.6527292",
"0.64223194",
"0.6377783",
"0.6244314",
"0.62305063",
"0.6168337",
"0.6152448",
"0.61484975",
"0.6148379",
"0.6148118",
"0.61456144",
"0.6119509",
"0.6115017",
"0.61067593",
"0.6100698",
"0.6075811",
"0.606537... | 0.6910295 | 0 |
Delete old versions. Deletes all version older than max_age (in days), but keep at least number_to_keep versions (if provided). | def _deleteOldVersionsByAge(self, model, max_age, number_to_keep=None):
adapter = getVersionManagementAdapter(model)
version_ids = self._getOldVersionIds(adapter)
if number_to_keep is not None:
if len(version_ids) < number_to_keep:
return
version_i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_old_tasks(max_task_age=86400):\n from .models import Task\n Task.tasks.delete_old_tasks(max_task_age)",
"def delete_old_job_executions(max_age=604_800):\n DjangoJobExecution.objects.delete_old_job_executions(max_age)",
"def delete_old_job_executions(self,max_age=604_800):\n DjangoJobEx... | [
"0.6747499",
"0.630428",
"0.61896855",
"0.60617626",
"0.6044849",
"0.60199463",
"0.6004267",
"0.5894792",
"0.5767173",
"0.57297707",
"0.5672673",
"0.5610217",
"0.5590678",
"0.55821395",
"0.5529269",
"0.55023366",
"0.53783333",
"0.5341526",
"0.53133875",
"0.5309541",
"0.528700... | 0.8386614 | 0 |
Add a VersionCleanUp object. | def manage_addVersionCleanUp(self, id, max_age, number_to_keep=None, pub_path=None, REQUEST=None):
if not Id(self, id).isValid():
return
object = VersionCleanUp(id, max_age, number_to_keep, pub_path)
self._setObject(id, object)
add_and_edit(self, id, REQUEST, 'manage_workspace')
return... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add(self, bento_name, bento_version):",
"def test_add_creates_a_new_version(self):\n assert Version.objects.count() == 0\n\n response = self.api_client.post(\n reverse('api-v4:company:collection'),\n data={\n 'name': 'Acme',\n 'trading_names':... | [
"0.5118369",
"0.47234404",
"0.4696744",
"0.46895298",
"0.4662823",
"0.46173075",
"0.45860088",
"0.45439854",
"0.45365962",
"0.44729444",
"0.44561625",
"0.44407687",
"0.44306216",
"0.43901408",
"0.43806347",
"0.43179488",
"0.4286722",
"0.42805582",
"0.4237282",
"0.4217605",
"0... | 0.57520276 | 0 |
Id of the order to which order item belongs to | def order_id(self) -> str:
return pulumi.get(self, "order_id") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def order_item_id(self):\n return self._order_item_id",
"def get_orderId(self):\n return self.order_id",
"def get_order(self, order_id):\n for o in self.order_lst:\n if o.get_orderId() == order_id:\n return o",
"def __orderAddItem(self, order, item):\n cu... | [
"0.79556775",
"0.72808146",
"0.6765434",
"0.660433",
"0.6524585",
"0.6514672",
"0.6414797",
"0.6374716",
"0.62987465",
"0.62442917",
"0.62080646",
"0.6187729",
"0.6149205",
"0.6134911",
"0.61215883",
"0.6082091",
"0.608033",
"0.6056877",
"0.6044173",
"0.6038049",
"0.6038049",... | 0.7317869 | 1 |
Represents order item details. | def order_item_details(self) -> 'outputs.OrderItemDetailsResponse':
return pulumi.get(self, "order_item_details") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getOrderInfo(self):\n return self.__orderinfo",
"def __repr__(self):\n return '<Item {0} : {1}>'.format(self.item_id, self.item_name)",
"def __str__(self):\n return f\"Order Number: {self._order_number} \" \\\n f\"Product ID: {self._product_id} \" \\\n f\"It... | [
"0.65966636",
"0.65228593",
"0.64625454",
"0.64385927",
"0.63865703",
"0.6375158",
"0.6255923",
"0.62234324",
"0.6209506",
"0.6200746",
"0.6200746",
"0.6200746",
"0.61848825",
"0.6145128",
"0.606909",
"0.6030651",
"0.60035884",
"0.59987885",
"0.59912914",
"0.59564984",
"0.593... | 0.8343038 | 0 |
Create the sppasPathSettings dictionary. | def __init__(self):
super(sppasPathSettings, self).__init__()
sppas_dir = os.path.dirname(os.path.dirname(
os.path.dirname(os.path.abspath(__file__))))
self.__dict__ = dict(
sppas=sppas_dir,
cli=os.path.join(sppas_dir, "bin"),
etc=os.path.join(sp... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fill_paths_section():\n section = _SectionData(\"Paths\")\n section.props.append((\"ProjectPath\", _property_utils.get_by_type(bpy.types.GlobalSCSProps.scs_project_path)))\n section.props.append((\"\", \"\"))\n section.props.append((\"ShaderPresetsFilePath\", _property_utils.get_by_... | [
"0.60087246",
"0.5748405",
"0.5670348",
"0.56041735",
"0.5581902",
"0.5575019",
"0.5517154",
"0.543762",
"0.5408098",
"0.5370869",
"0.53569716",
"0.5356201",
"0.5351576",
"0.52927434",
"0.52879727",
"0.5272143",
"0.5251382",
"0.5238654",
"0.52089846",
"0.51812327",
"0.5175009... | 0.7366091 | 0 |
Create the sppasSymbolSettings dictionary. | def __init__(self):
super(sppasSymbolSettings, self).__init__()
self.__dict__ = dict(
unk="<UNK>",
phone=sppasSymbolSettings.__phone_symbols(),
ortho=sppasSymbolSettings.__ortho_symbols(),
all=sppasSymbolSettings.__all_symbols()
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self):\n super(sppasSeparatorSettings, self).__init__()\n self.__dict__ = dict(\n phonemes=\"-\", # X-SAMPA standard\n syllables=\".\", # X-SAMPA standard\n variants=\"|\" # used for all alternative tags\n )",
"def __set_symbol_dict(self... | [
"0.6177882",
"0.6098112",
"0.5861852",
"0.56298035",
"0.55247223",
"0.54055923",
"0.52484506",
"0.5247753",
"0.5140226",
"0.5075873",
"0.5013048",
"0.49773616",
"0.49767086",
"0.49665692",
"0.49569914",
"0.49289882",
"0.49187663",
"0.48761186",
"0.485334",
"0.48451963",
"0.48... | 0.6986178 | 0 |
Create the sppasSeparatorSettings dictionary. | def __init__(self):
super(sppasSeparatorSettings, self).__init__()
self.__dict__ = dict(
phonemes="-", # X-SAMPA standard
syllables=".", # X-SAMPA standard
variants="|" # used for all alternative tags
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def split_config(s):\n x = re.split(r\";\", s)\n d = {k: v for (k, v) in [i.split(\"=\") for i in x]}\n return d",
"def __init__(self):\n super(sppasSymbolSettings, self).__init__()\n\n self.__dict__ = dict(\n unk=\"<UNK>\",\n phone=sppasSymbolSettings.__phone_symbols... | [
"0.5260643",
"0.525356",
"0.5215848",
"0.516991",
"0.50845647",
"0.50162953",
"0.50140077",
"0.49808216",
"0.49723732",
"0.49135372",
"0.48305875",
"0.47998127",
"0.47948772",
"0.4775136",
"0.46659538",
"0.46494308",
"0.46151328",
"0.459098",
"0.45890176",
"0.45849705",
"0.45... | 0.7076453 | 0 |
Create the sppasAnnotationsSettings dictionary. | def __init__(self):
super(sppasAnnotationsSettings, self).__init__()
self.__dict__ = dict(
error=-1,
ok=0,
warning=1,
ignore=2,
info=3,
extension=".xra",
# all the types of the annotations implemented into SPPAS
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _setupConfigAnnotation(self):\n annotations = IAnnotations(self)\n settings = annotations.get(\"PLOMINOFIELDCONFIG\", None)\n if not settings:\n annotations[\"PLOMINOFIELDCONFIG\"] = PersistentDict()",
"def annotate(self):\n annotations = {}\n\n text_keys = ['fon... | [
"0.6246945",
"0.5580207",
"0.5511054",
"0.540356",
"0.5270908",
"0.52254593",
"0.5073585",
"0.506146",
"0.49990964",
"0.49935746",
"0.49475783",
"0.49424547",
"0.494058",
"0.49246597",
"0.48960713",
"0.48892942",
"0.487666",
"0.48749858",
"0.48706108",
"0.48693275",
"0.486586... | 0.7178495 | 0 |
Ensures InvalidTwine exceptions are raised when instantiating twines with a missing `name` field in a credential. | def test_fails_on_no_name(self):
invalid_credentials_no_name_twine = """
{
"credentials": [
{
"purpose": "credentials without a name should be invalid"
}
]
}
"""
with self.ass... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_fails_on_name_whitespace(self):\n invalid_credentials_space_in_name_twine = \"\"\"\n {\n \"credentials\": [\n {\n \"name\": \"MY NAME SHOULD NOT HAVE WHITESPACE\",\n \"purpose\": \"Token for accessing a 3rd p... | [
"0.74130327",
"0.738747",
"0.71815866",
"0.68032056",
"0.6659559",
"0.55014026",
"0.54120857",
"0.5409691",
"0.53112495",
"0.52741003",
"0.5249553",
"0.52142566",
"0.5201539",
"0.5198638",
"0.5184421",
"0.5165544",
"0.5151099",
"0.5134139",
"0.51095825",
"0.5082709",
"0.50345... | 0.804954 | 0 |
Ensures InvalidTwine exceptions are raised when instantiating twines with lowercase letters in the `name` field. | def test_fails_on_lowercase_name(self):
invalid_credentials_lowercase_name_twine = """
{
"credentials": [
{
"name": "my_secrets_should_be_uppercase",
"purpose": "Token for accessing a 3rd party API service"
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_fails_on_name_whitespace(self):\n invalid_credentials_space_in_name_twine = \"\"\"\n {\n \"credentials\": [\n {\n \"name\": \"MY NAME SHOULD NOT HAVE WHITESPACE\",\n \"purpose\": \"Token for accessing a 3rd p... | [
"0.70076686",
"0.67873573",
"0.5885564",
"0.5679548",
"0.5635211",
"0.56229067",
"0.56226254",
"0.5432189",
"0.5399895",
"0.5309323",
"0.5305901",
"0.52782226",
"0.52628815",
"0.5226802",
"0.5218749",
"0.51777184",
"0.5158942",
"0.51517725",
"0.5146054",
"0.51410335",
"0.5129... | 0.7393539 | 0 |
Ensures InvalidTwine exceptions are raised when instantiating twines with invalid `credentials` entries (given as a dict, not an array). | def test_fails_on_dict(self):
invalid_credentials_dict_not_array_twine = """
{
"credentials": {
"name": "MY_API_SECRET_KEY",
"purpose": "Token for accessing a 3rd party API service"
}
}
"""
with self... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_missing_credentials(self):\n twine = Twine(source=self.VALID_CREDENTIALS_TWINE)\n with self.assertRaises(exceptions.CredentialNotFound):\n twine.validate_credentials()",
"def test_fails_on_no_name(self):\n invalid_credentials_no_name_twine = \"\"\"\n {\n ... | [
"0.697575",
"0.6677831",
"0.6417075",
"0.6336212",
"0.6142843",
"0.5521954",
"0.5465488",
"0.5218336",
"0.510923",
"0.5068735",
"0.50598174",
"0.50413364",
"0.49665698",
"0.4901049",
"0.489881",
"0.48986685",
"0.48686793",
"0.48420176",
"0.483212",
"0.482264",
"0.4800654",
... | 0.816796 | 0 |
Test that a credential with spaces in its name causes an error to be raised when validated. | def test_fails_on_name_whitespace(self):
invalid_credentials_space_in_name_twine = """
{
"credentials": [
{
"name": "MY NAME SHOULD NOT HAVE WHITESPACE",
"purpose": "Token for accessing a 3rd party API service"
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_fails_on_lowercase_name(self):\n invalid_credentials_lowercase_name_twine = \"\"\"\n {\n \"credentials\": [\n {\n \"name\": \"my_secrets_should_be_uppercase\",\n \"purpose\": \"Token for accessing a 3rd party... | [
"0.69809765",
"0.6814948",
"0.6800434",
"0.6753564",
"0.67290175",
"0.66788775",
"0.66672",
"0.6664221",
"0.6618424",
"0.6606743",
"0.65900725",
"0.64955014",
"0.64765966",
"0.6435095",
"0.64216715",
"0.63738567",
"0.6329089",
"0.6304202",
"0.6260323",
"0.62376004",
"0.623256... | 0.7481926 | 0 |
Test that a twine with no credentials will validate straightforwardly | def test_no_credentials(self):
twine = Twine(source=VALID_SCHEMA_TWINE)
twine.validate_credentials() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_missing_credentials(self):\n twine = Twine(source=self.VALID_CREDENTIALS_TWINE)\n with self.assertRaises(exceptions.CredentialNotFound):\n twine.validate_credentials()",
"def test_fails_on_no_name(self):\n invalid_credentials_no_name_twine = \"\"\"\n {\n ... | [
"0.7983709",
"0.7463932",
"0.7196194",
"0.66048604",
"0.65792054",
"0.6507953",
"0.6496728",
"0.64539534",
"0.6420076",
"0.64187914",
"0.63843936",
"0.6362736",
"0.6358339",
"0.6354229",
"0.635054",
"0.633689",
"0.63293725",
"0.6326599",
"0.6323392",
"0.6293972",
"0.62764823"... | 0.89546365 | 0 |
Test that a twine with credentials will not validate where they are missing from the environment | def test_missing_credentials(self):
twine = Twine(source=self.VALID_CREDENTIALS_TWINE)
with self.assertRaises(exceptions.CredentialNotFound):
twine.validate_credentials() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_no_credentials(self):\n twine = Twine(source=VALID_SCHEMA_TWINE)\n twine.validate_credentials()",
"def test_validate_credentials(self):\n pass",
"def test_credentials(self):\n twine = Twine(source=self.VALID_CREDENTIALS_TWINE)\n with mock.patch.dict(\n os.... | [
"0.8448729",
"0.7432823",
"0.7320278",
"0.7133921",
"0.7086967",
"0.69651437",
"0.68108344",
"0.6735879",
"0.67323744",
"0.6732249",
"0.66041964",
"0.65656185",
"0.65416896",
"0.6481365",
"0.64563084",
"0.64333206",
"0.64308697",
"0.64294356",
"0.6425672",
"0.6420734",
"0.637... | 0.81363463 | 1 |
Return true to indicate it is an analysis recipe. | def isAnalysisRecipe(self):
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __bool__(self):\n # NOTE: self._recipe_patterns implies that self._full_test_name_patterns\n # also has values.\n return bool(self._recipe_patterns)",
"def is_study(self) -> bool:\n return self._path_exist()",
"def is_art(self):\n return 0",
"def is_test(self):\r\n return self.h... | [
"0.62666523",
"0.6137506",
"0.58244854",
"0.5781191",
"0.574423",
"0.57357246",
"0.5734145",
"0.56805617",
"0.5653597",
"0.5640678",
"0.56319505",
"0.5602368",
"0.558393",
"0.55434346",
"0.5528448",
"0.5523418",
"0.5522992",
"0.55209535",
"0.5458485",
"0.54520553",
"0.5434333... | 0.8852331 | 0 |
Get and set Honeybee objects for this recipe. | def hbObjects(self):
return self.__hbObjs | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_all_beer_info(self, beer):\n def try_to_set(beer_value, beer_value_tags):\n \"\"\"\n value is an beer part, eg. name, brewery, abv...\n \"\"\"\n\n try:\n beer_value = self.get_beer_info(beer, beer_value_tags)\n except:\n ... | [
"0.55338407",
"0.4915024",
"0.48632538",
"0.48460168",
"0.48186508",
"0.4810394",
"0.4780939",
"0.4745612",
"0.47219843",
"0.47209832",
"0.471252",
"0.47123778",
"0.46945104",
"0.46865132",
"0.4686169",
"0.46523413",
"0.46248072",
"0.46104926",
"0.45588514",
"0.45483392",
"0.... | 0.5493766 | 1 |
Subfolder for Gridbased analysis. | def subFolder(self):
return self.__folder | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def subdir(self):",
"def identify_folder(self, folder):",
"def __init__(self, root_dir):\n self.paths = glob.glob(root_dir + \"/*.csv\")\n self.target = 'Default'\n # Grouping variable names",
"def gen_folders(rho, kappa, km, pa, analysis, dbase, analysisdbase):\n \n path1 = 'dens... | [
"0.6777862",
"0.57742274",
"0.56692266",
"0.56617254",
"0.5598988",
"0.5576311",
"0.55693084",
"0.5541947",
"0.5537441",
"0.55221516",
"0.5494019",
"0.5455292",
"0.54496187",
"0.5448415",
"0.5379743",
"0.5377243",
"0.53307635",
"0.53052866",
"0.5304346",
"0.5301438",
"0.52794... | 0.59945226 | 1 |
Tests report abort sequence. | def test_report_aborted(self):
context.GLOBAL.zk.url = 'zookeeper://xxx@hhh:123/treadmill/mycell'
treadmill.zkutils.connect.return_value = kazoo.client.KazooClient()
kazoo.client.KazooClient.get_children.return_value = []
kazoo.client.KazooClient.exists.return_value = True
kazoo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def abort(self):\n print(\"abort\")",
"def abort() -> NoReturn:\n raise AbortSignal",
"def testAbort(self):\n Compound(\"asd\",\"dsa\").post_goal()\n result,stream_id=resume()\n outStream=Stream(stream_id)\n self.assertEqual(outStream.readall(),b\"calling an undefined proc... | [
"0.6716217",
"0.66410726",
"0.6576162",
"0.64940333",
"0.6473222",
"0.6468721",
"0.64178926",
"0.6417841",
"0.64083797",
"0.6407146",
"0.63385034",
"0.6316523",
"0.625286",
"0.6245723",
"0.6234035",
"0.61668545",
"0.6159501",
"0.61182106",
"0.60819423",
"0.60687995",
"0.60470... | 0.7312383 | 0 |
Parses a single question line to get the question, answer, points. | def parse_line(line : str) -> Tuple[str, str, int]:
line = line[:-1] # Strips newline character
question_end = line.find(';')
question = line[:question_end]
line = line[question_end+1:]
answer_end = line.find(';')
answer = line[:answer_end]
points = int(line[answer_end+1:])
return que... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_question(save=False):\n\n text = read_screen(save)\n lines = text.splitlines()\n question = \"\"\n options = list()\n flag = False\n\n for line in lines:\n if not flag:\n question = question + \" \" + line\n if '?' in line:\n flag = True\n ... | [
"0.67718875",
"0.6712634",
"0.65364337",
"0.5864423",
"0.5847483",
"0.5773874",
"0.5698345",
"0.5697376",
"0.5691327",
"0.5678002",
"0.56175894",
"0.55869883",
"0.5574885",
"0.557414",
"0.5541787",
"0.545183",
"0.5433768",
"0.54000556",
"0.53831",
"0.5379273",
"0.53674835",
... | 0.7786456 | 0 |
Goes over the file and parses it for topics, questions, answers, and points. | def parse_game_data(file_name : str) -> List[Topic]:
# Opens file.
data = open(file_name, 'r')
# Sets up variables.
current_topic = None
parsed_data = []
# Loops over each line in the file.
for line in data:
# Creates new topic if there is none.
if current_topic is... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_question_data(self):\n section = ''\n subsection = ''\n quest = ''\n # The data falls into 4 cases\n # 1. Sections\n # 2. subsections\n # 3. questions\n # 4. answers.\n\n for line in self.question_data: \n\n if \":\" in line: # cas... | [
"0.6142998",
"0.59906673",
"0.59758234",
"0.5876278",
"0.586069",
"0.5847424",
"0.5810098",
"0.5799173",
"0.56925106",
"0.5667326",
"0.5667199",
"0.5666487",
"0.5645209",
"0.55975074",
"0.5596668",
"0.558996",
"0.55883265",
"0.5587433",
"0.55834574",
"0.5563519",
"0.55622727"... | 0.7204002 | 0 |
Replace a single line in a Retrosheet game record. There are a few extremely unusual events in the Retrosheet game records. Rather than extend the parser to handle these outliers, it's easier to edit the game records. | def replace_line(game_id, old_line, new_line, data_root="data"):
game_file = _retrosheet_filename(game_id, data_root)
if not game_file:
return False
in_game = False
replaced = False
# The Retrosheet game files all have DOS line endings, thus the \r\ns everywhere.
id_line = "id," + game_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update(self, line):",
"def emit_line(handle, data):\n if len(data) > 254:\n if \" PAGE \" in data:\n data = data.replace(\"Record Group Title\", \"Record Group\")\n data = data.replace(\"Series Title\", \"Series\")\n data = data.replace(\n \"Washingto... | [
"0.6377618",
"0.57672954",
"0.5650983",
"0.55986875",
"0.5554422",
"0.552964",
"0.55266875",
"0.5447008",
"0.54305965",
"0.54284734",
"0.54020137",
"0.53595626",
"0.5352936",
"0.53371966",
"0.5334674",
"0.5316807",
"0.5308369",
"0.5302961",
"0.5262078",
"0.52415186",
"0.52414... | 0.70164794 | 0 |
Find the Retrosheet event file associated with a specific game id. | def _retrosheet_filename(game_id, data_root):
# game id is TTTYYYYMMDDN.
team = game_id[:3]
year = game_id[3:7]
file_pattern = year + team + ".EV*"
file_path = os.path.join(data_root, "retrosheet", year, file_pattern)
file_matches = glob.glob(file_path)
return file_matches[0] if len(file_mat... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_game_events(game_id):\n # get relevant information from game id\n year, month, day, rest = game_id.split('_', 3)\n # file\n filename = \"gameday-data/year_%s/month_%s/day_%s/gid_%s/game_events.xml\" % (year, month, day, game_id)\n file = os.path.join(os.path.dirname(__file__), filename)\n ... | [
"0.6557085",
"0.58562005",
"0.5644013",
"0.5632801",
"0.5601126",
"0.5572697",
"0.5525583",
"0.54915553",
"0.5447527",
"0.53783375",
"0.53760546",
"0.53642374",
"0.5363491",
"0.5363254",
"0.5348418",
"0.53273696",
"0.532736",
"0.52711946",
"0.5171613",
"0.5170329",
"0.5160531... | 0.69607824 | 0 |
Remove a specific pitch from an MLB Gameday file. | def remove_pitch(game_id, pitch_id, data_root="data"):
pitch_search = ".//pitch[@id='{}']".format(pitch_id)
return _remove_gameday_object(game_id, pitch_search, data_root) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def removeSndFile(self, filename):\n try:\n sndfile = self.sndfiles[filename]\n except KeyError:\n return\n for ch in range(sndfile.getChannels()):\n w = self.grid.getWaveform(sndfile, ch)\n self.sb.unregisterWaveform(w)\n i = self.grid.ge... | [
"0.58742654",
"0.5855426",
"0.55798006",
"0.55383223",
"0.55276287",
"0.5472701",
"0.5447619",
"0.5394459",
"0.5370778",
"0.5366434",
"0.5324945",
"0.53231245",
"0.527467",
"0.5258175",
"0.5243394",
"0.52243835",
"0.5118364",
"0.5114147",
"0.51103824",
"0.5074999",
"0.5063870... | 0.72860414 | 0 |
Remove a specific atbat (plate appearance) from an MLB Gameday file. | def remove_at_bat(game_id, at_bat_number, data_root="data"):
at_bat_search = ".//atbat[@num='{}']".format(at_bat_number)
return _remove_gameday_object(game_id, at_bat_search, data_root) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_GOs(self):\n\n file = open(self.filename, 'r')\n new_file = open(self.temp_filename, 'w')\n for line in file:\n if \"GO\" not in line and \"go\" not in line:\n new_file.write(line)\n file.close()\n new_file.close()\n self.overwrite_file... | [
"0.57274145",
"0.5688319",
"0.55653524",
"0.5490782",
"0.54542863",
"0.54176486",
"0.5394877",
"0.53888774",
"0.537937",
"0.53694624",
"0.53581434",
"0.5267226",
"0.52356946",
"0.5188904",
"0.5187952",
"0.5185151",
"0.5141263",
"0.5091061",
"0.5076155",
"0.5060907",
"0.504672... | 0.68223554 | 0 |
Generic function for removing an object from a GameDay XML tree. | def _remove_gameday_object(game_id, object_search, data_root):
game_file = _gameday_pitch_filename(game_id, data_root)
# If the file doesn't exist, we're done.
if not game_file:
return False
gameday_tree = ET.parse(game_file)
object_parent_search = object_search + "/.."
target_object = ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def removeNode(self, node):",
"def remove(obj_objectid_or_path_tuple):",
"def removeNode(cTag, nTag): #@NoSelf",
"def remove_node(self, key) -> Node:",
"def remove(node, key):\n if isinstance(node, (Document, Object)):\n data = dict(node._data)\n elif isinstance(node, Array):\n data = ... | [
"0.6602599",
"0.6462782",
"0.6186652",
"0.61536914",
"0.6146855",
"0.611321",
"0.60302156",
"0.6008009",
"0.59822714",
"0.59518236",
"0.59233105",
"0.5828505",
"0.58067214",
"0.57641745",
"0.5744235",
"0.57227075",
"0.5717567",
"0.5680329",
"0.5668207",
"0.5643355",
"0.561414... | 0.74025536 | 0 |
Get the filename of the GameDay PitchFx file associated with a given Retrosheet game_id. | def _gameday_pitch_filename(game_id, data_root):
year = game_id[3:7]
filename = os.path.join(data_root, "gameday", "pitches", year, game_id + ".xml")
return filename if os.path.exists(filename) else None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _retrosheet_filename(game_id, data_root):\n # game id is TTTYYYYMMDDN.\n team = game_id[:3]\n year = game_id[3:7]\n file_pattern = year + team + \".EV*\"\n file_path = os.path.join(data_root, \"retrosheet\", year, file_pattern)\n file_matches = glob.glob(file_path)\n return file_matches[0]... | [
"0.81765527",
"0.7027017",
"0.6883412",
"0.6669271",
"0.66651946",
"0.64135945",
"0.64090705",
"0.63942695",
"0.6356634",
"0.63335884",
"0.63259274",
"0.6317817",
"0.63174456",
"0.63015467",
"0.63015467",
"0.63015467",
"0.6288798",
"0.6259826",
"0.62433845",
"0.620116",
"0.61... | 0.78359383 | 1 |
Score posts and write to a file | def scoreIndPosts(fileName,scoredRecords,outdir='scoreFiles'):
fOut = codecs.open(outdir+"/"+fileName, encoding="utf-8",mode="wb")
for term in scoredRecords:
record = term[0][1]
score = term[1]
buffer = [record.lat,record.lon,record.text,score,record.user,record.dt,record.img]
bu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def record_score(self, score):\n file_name = self.config_folder + self.score_file\n score_file = open(file_name,'a+')\n epoch_time = int(time.time())\n entry = \"%s %s %s %s\\n\" % ( epoch_time, score['word'], score['attempts'], score['time'])\n score_file.write(entry)\n s... | [
"0.6252783",
"0.6213814",
"0.61999786",
"0.61730194",
"0.61651516",
"0.59293675",
"0.58362263",
"0.57879233",
"0.5779395",
"0.5755033",
"0.57450944",
"0.5706841",
"0.5702476",
"0.5690584",
"0.56833225",
"0.56411505",
"0.56099224",
"0.5605955",
"0.55187505",
"0.5516568",
"0.55... | 0.6944355 | 0 |
Create clusters based out record locations, and collect total background activity for each cluster. | def clusterByLocation(sc,records,scoredRecords,fClusterSearchEpsilon,nMinClusterPoints,nMinClusterUnique,fileName,outdir='scoreFiles'):
# assign clusters and filter out non clustered records
recordList = map(lambda term: ScoreRecord(term[0][1],term[1]),scoredRecords)
assignToCluster(recordList, fClusterSea... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clusterByDayAndLocation(sc,records,scoredRecords,fClusterSearchEpsilon,nMinClusterPoints,nMinClusterUnique,fileName,outdir='scoreFiles'):\n\n # collect records by date\n dateDict = {}\n for term in scoredRecords:\n score = term[1]\n rowObj = term[0][1]\n record = ScoreRecord(rowOb... | [
"0.6428443",
"0.6201558",
"0.6183678",
"0.6133433",
"0.60738987",
"0.6023125",
"0.59979093",
"0.5905386",
"0.58786607",
"0.586553",
"0.58641756",
"0.581033",
"0.5804024",
"0.5740974",
"0.57238835",
"0.5721504",
"0.5705737",
"0.5699841",
"0.56598645",
"0.56548136",
"0.5634424"... | 0.65387386 | 0 |
Cluster records by date, then by location. Collect background for each cluster. | def clusterByDayAndLocation(sc,records,scoredRecords,fClusterSearchEpsilon,nMinClusterPoints,nMinClusterUnique,fileName,outdir='scoreFiles'):
# collect records by date
dateDict = {}
for term in scoredRecords:
score = term[1]
rowObj = term[0][1]
record = ScoreRecord(rowObj,score)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clusterByLocation(sc,records,scoredRecords,fClusterSearchEpsilon,nMinClusterPoints,nMinClusterUnique,fileName,outdir='scoreFiles'):\n\n # assign clusters and filter out non clustered records\n recordList = map(lambda term: ScoreRecord(term[0][1],term[1]),scoredRecords)\n assignToCluster(recordList, fC... | [
"0.6444694",
"0.6161407",
"0.5971471",
"0.5933066",
"0.59021205",
"0.5807744",
"0.5798495",
"0.5761836",
"0.5738159",
"0.5695437",
"0.5663556",
"0.56580466",
"0.5524309",
"0.54998505",
"0.54739374",
"0.539962",
"0.5340455",
"0.5335975",
"0.5320181",
"0.5311649",
"0.53031826",... | 0.7242086 | 0 |
Initialize layer 4 object with n4 neurons, L stimuli, k neurons with initial activation (unless given_weight_matrix provided), and weightMatrix. If given_weight_matrix is provided (not None), it must either be in the form of a string containing n4L values separated by commas, or in the form of a numpy array of the corr... | def __init__(self, n4, L, k, randomize=False, non_k=-1, given_weight_matrix = None):
self.n4 = n4
self.L = L
self.k = k
self.weightMatrix = numpy.full((self.n4, self.L), non_k, dtype=numpy.int16)
# initializing from the start
if given_weight_matrix == None:
if randomize == "True":
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_weights(self, load_weights=None):\n if load_weights:\n # TODO\n pass\n else:\n # x: lower layer nodes n\n # y: current layer nodes n\n x = self.weights_shape[1]\n y = self.weights_shape[0]\n self.weights = np.random.randn(y, x) / np.sqrt(x) # pylint: disable=no-mem... | [
"0.6231484",
"0.6089778",
"0.6056054",
"0.5963621",
"0.5886334",
"0.5820676",
"0.5771657",
"0.5767608",
"0.5750672",
"0.57492733",
"0.57492733",
"0.57492733",
"0.57218105",
"0.57083887",
"0.5692032",
"0.56874746",
"0.5682025",
"0.5658114",
"0.5629865",
"0.56158614",
"0.561077... | 0.7725477 | 0 |
Initializes a layer 2/3 object with n23 neurons connected to n4 neurons from layer 4. If initialized from scratch, creates (n23, n4) inputWeightMatrix with weights chosen by Gaussian distribution with mean provided and stdv = 1/sqrt(n4), and (n23, n23) recurrentWeightMatrix with weights chosen by Gaussian with stdv = 1... | def __init__(self, n23, n4, mean, stdp_eta, given_weight_matrices = None):
self.n23 = n23
self.n4 = n4
self.eta = stdp_eta
# initialize from scratch
if given_weight_matrices == None:
# create input weight matrix with weights chosen by Gaussian distribution
stdv = 1/math.sqrt(n4)
s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, n4, L, k, randomize=False, non_k=-1, given_weight_matrix = None):\n\n self.n4 = n4\n self.L = L\n self.k = k\n self.weightMatrix = numpy.full((self.n4, self.L), non_k, dtype=numpy.int16)\n\n # initializing from the start\n if given_weight_matrix == None: \n if randomize ==... | [
"0.6748135",
"0.6196504",
"0.60606045",
"0.6022062",
"0.5988512",
"0.59108657",
"0.5899774",
"0.5732108",
"0.57222277",
"0.5711475",
"0.5679732",
"0.567782",
"0.56572145",
"0.5647979",
"0.5580845",
"0.55331516",
"0.55207545",
"0.54946977",
"0.54929435",
"0.5477036",
"0.544032... | 0.6818799 | 0 |
Computes the value of the Ackley N. 2 function. | def ackleyn2fcn(x: np.ndarray) -> np.ndarray:
n = x.shape[1]
assert n == 2, "Ackley N. 2 function is only defined on a 2D space."
X = x[:, 0]
Y = x[:, 1]
scores = -200 * np.exp(-0.02 * np.sqrt(X**2 + Y**2))
return scores | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ackleyfcn(x: np.ndarray) -> np.ndarray:\n n = x.shape[1]\n ninverse = 1 / n\n sum1 = np.sum(x**2, axis=1)\n sum2 = np.sum(np.cos(2 * np.pi * x), axis=1)\n\n scores = (\n 20\n + np.exp(1)\n - (20 * np.exp(-0.2 * np.sqrt(ninverse * sum1)))\n - np.exp(ninverse * sum2)\n ... | [
"0.69176775",
"0.6458127",
"0.637345",
"0.63647753",
"0.6339026",
"0.6283615",
"0.597819",
"0.596691",
"0.59666824",
"0.5933999",
"0.58560383",
"0.58266884",
"0.581447",
"0.58061564",
"0.5804224",
"0.5804224",
"0.5775688",
"0.57572407",
"0.57556826",
"0.5742976",
"0.57366097"... | 0.73194706 | 0 |
Computes the value of the Ackley N. 3 function for the input 2D array x. | def ackleyn3fcn(x: np.ndarray) -> np.ndarray:
n = x.shape[1]
assert n == 2, "Ackley N. 3 function is only defined on a 2D space."
X = x[:, 0]
Y = x[:, 1]
scores = -200 * np.exp(-0.2 * np.sqrt(X**2 + Y**2)) + 5 * np.exp(
np.cos(3 * X) + np.sin(3 * Y)
)
return scores | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ackleyfcn(x: np.ndarray) -> np.ndarray:\n n = x.shape[1]\n ninverse = 1 / n\n sum1 = np.sum(x**2, axis=1)\n sum2 = np.sum(np.cos(2 * np.pi * x), axis=1)\n\n scores = (\n 20\n + np.exp(1)\n - (20 * np.exp(-0.2 * np.sqrt(ninverse * sum1)))\n - np.exp(ninverse * sum2)\n ... | [
"0.71131384",
"0.7080986",
"0.68824565",
"0.6590959",
"0.6570487",
"0.65148807",
"0.6491085",
"0.6439845",
"0.6419968",
"0.6382817",
"0.63634527",
"0.6325192",
"0.6299976",
"0.6225131",
"0.62189204",
"0.61752546",
"0.61059386",
"0.6071731",
"0.6070238",
"0.60444754",
"0.60157... | 0.82286155 | 0 |
Computes the value of the Alpine N. 1 function. | def alpinen1fcn(x: np.ndarray) -> np.ndarray:
scores = np.sum(np.abs(x * np.sin(x) + 0.1 * x), axis=1)
return scores | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def agnesi(x):\n return 1/(1+x**2)",
"def i1(x):\n return tt.switch(tt.lt(x, 5), x / 2 + x**3 / 16 + x**5 / 384 + x**7 / 18432 +\n x**9 / 1474560 + x**11 / 176947200 + x**13 / 29727129600,\n np.e**x / (2 * np.pi * x)**0.5 * (1 - 3 / (8 * x) + 15 / (128 * x**2) + 315 ... | [
"0.6762097",
"0.6380153",
"0.6379103",
"0.6328421",
"0.6306139",
"0.6265947",
"0.6168021",
"0.616329",
"0.6106425",
"0.6075689",
"0.6023337",
"0.5996576",
"0.59957474",
"0.59889215",
"0.5983466",
"0.5963702",
"0.5943999",
"0.5937857",
"0.5932254",
"0.5930673",
"0.5905919",
... | 0.6393041 | 1 |
Computes the value of the Bird function. | def birdfcn(x: np.ndarray) -> np.ndarray:
n = x.shape[1]
assert n == 2, "Bird function is only defined on a 2D space."
X = x[:, 0]
Y = x[:, 1]
scores = (
np.sin(X) * np.exp((1 - np.cos(Y)) ** 2)
+ np.cos(Y) * np.exp((1 - np.sin(X)) ** 2)
+ (X - Y) ** 2
)
return sco... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def value(self) -> float:",
"def frobenius(self, value):\n return sum(self.hadamard(value))",
"def f_2b(c):\n Ri = calc_R(*c)\n return Ri - Ri.mean()",
"def _fv(self):\n return self.beta * (self.x ** self.c)",
"def calculate(self) -> float:",
"def calculate_value(self):\n b... | [
"0.62157565",
"0.61000055",
"0.5938534",
"0.591877",
"0.5915328",
"0.591287",
"0.5907085",
"0.5904664",
"0.59032845",
"0.59032845",
"0.59032845",
"0.5893077",
"0.5845072",
"0.58323133",
"0.5824914",
"0.5812263",
"0.5784041",
"0.56897634",
"0.5683892",
"0.56837213",
"0.5680520... | 0.63659126 | 0 |
Computes the value of the Brown benchmark function. | def brownfcn(x: np.ndarray) -> np.ndarray:
n = x.shape[1]
scores = np.zeros((x.shape[0], 1))
x = x**2
for i in range(n - 1):
scores += x[:, i] ** (x[:, i + 1] + 1) + x[:, i + 1] ** (x[:, i] + 1)
return scores | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_iterative_fibonacci_benchmark(benchmark):\n computed_iterative_value = benchmark(\n fibonacci.compute_iterative_fibonacci, value=19\n )\n assert computed_iterative_value == 4181",
"def umbrae(self, benchmark: np.ndarray = None):\n return self.mbrae(benchmark) / (1 - self.mbrae(ben... | [
"0.58839524",
"0.5864812",
"0.5855859",
"0.5855859",
"0.5855859",
"0.58000326",
"0.5797898",
"0.57472223",
"0.57217085",
"0.57217085",
"0.57217085",
"0.5698569",
"0.5668719",
"0.56317365",
"0.5620562",
"0.56012905",
"0.55659354",
"0.55567366",
"0.55391717",
"0.55355984",
"0.5... | 0.60762244 | 0 |
Computes the value of the Bukin N. 6 benchmark function. | def bukinn6fcn(x: np.ndarray) -> np.ndarray:
n = x.shape[1]
assert n == 2, "The Bukin N. 6 functions is only defined on a 2D space."
X = x[:, 0]
X2 = X**2
Y = x[:, 1]
scores = 100 * np.sqrt(np.abs(Y - 0.01 * X2)) + 0.01 * np.abs(X + 10)
return scores | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def umbrae(self, benchmark: np.ndarray = None):\n return self.mbrae(benchmark) / (1 - self.mbrae(benchmark))",
"def test_iterative_fibonacci_benchmark(benchmark):\n computed_iterative_value = benchmark(\n fibonacci.compute_iterative_fibonacci, value=19\n )\n assert computed_iterative_value... | [
"0.62188923",
"0.6052524",
"0.58289576",
"0.5815371",
"0.5722309",
"0.5721898",
"0.57153416",
"0.5683684",
"0.56586534",
"0.5653131",
"0.5639933",
"0.56267744",
"0.56190807",
"0.5615924",
"0.5603205",
"0.55863786",
"0.5572346",
"0.5564396",
"0.5561132",
"0.5536885",
"0.553402... | 0.614312 | 1 |
Computes the value of the DeckkersAarts function. | def deckkersaartsfcn(x: np.ndarray) -> np.ndarray:
n = x.shape[1]
assert (
n == 2
), "The Deckkers-Aarts function is defined only on the 2-D space."
X = x[:, 0]
Y = x[:, 1]
scores = (
(100000 * X**2)
+ Y**2
- (X**2 + Y**2) ** 2
+ (10**-5) * (X**2 + Y**2)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def acer(scores, labels, th_eer_dev):\n\n bpcer_value = bpcer(scores, labels, th_eer_dev)\n apcer_value = apcer(scores, labels, th_eer_dev)\n\n return (apcer_value + bpcer_value) / 2",
"def calculate_value(self, hand):\n global FACE_CARDS\n #could refactor the 2 hand possiblities into meth... | [
"0.6282712",
"0.56966543",
"0.5525235",
"0.5470965",
"0.546019",
"0.54266745",
"0.54141587",
"0.541118",
"0.53911686",
"0.5386711",
"0.5373921",
"0.5327535",
"0.5291792",
"0.52754617",
"0.5248742",
"0.5245169",
"0.5237053",
"0.5210211",
"0.52036965",
"0.52030534",
"0.5193857"... | 0.72814083 | 0 |
Computes the value of the DropWave benchmark function. | def dropwavefcn(x: np.ndarray) -> np.ndarray:
n = x.shape[1]
assert n == 2, "Drop-Wave function is only defined on a 2D space."
X = x[:, 0]
Y = x[:, 1]
numeratorcomp = 1 + np.cos(12 * np.sqrt(X**2 + Y**2))
denumeratorcom = (0.5 * (X**2 + Y**2)) + 2
scores = -numeratorcomp / denumeratorco... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _Dropout(self, name, drop_prob):\n return super()._Dropout(name, keep_prob=1.0 - drop_prob)",
"def _variational_recurrent_dropout_value(\n self, index, value, noise, keep_prob):\n # uniform [keep_prob, 1.0 + keep_prob)\n random_tensor = keep_prob + noise\n\n # 0. if [keep_prob, 1.0) and 1. i... | [
"0.6128839",
"0.572413",
"0.5709935",
"0.5709872",
"0.56486803",
"0.5527675",
"0.5484452",
"0.5440913",
"0.5400075",
"0.53806657",
"0.53685033",
"0.5292394",
"0.5290849",
"0.5273905",
"0.5258611",
"0.5255367",
"0.5255367",
"0.52552176",
"0.52420527",
"0.52351946",
"0.52293426... | 0.66314936 | 0 |
Computes the value of the Egg Crate function. | def eggcratefcn(x: np.ndarray) -> np.ndarray:
n = x.shape[1]
assert n == 2, "The Egg Crate function is defined only on the 2-D space."
X = x[:, 0]
Y = x[:, 1]
scores = X**2 + Y**2 + (25 * (np.sin(X) ** 2 + np.sin(Y) ** 2))
return scores | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _etaE_cool(self,x):\n return self._eta_sfr_scaling(x,'E_cool')",
"def value(self): \r\n c = self.nd1() * self.s * math.exp(-self.div * self.t)\r\n c -= self.nd2() * self.x * math.exp(-self.rf * self.t)\r\n \r\n return c",
"def coefficient(self) -> float:\n ...",
... | [
"0.61959255",
"0.6059382",
"0.60031843",
"0.5825309",
"0.5762202",
"0.5708059",
"0.56912273",
"0.56546324",
"0.56546324",
"0.56546324",
"0.56289184",
"0.5621966",
"0.56168187",
"0.5588245",
"0.55878764",
"0.5573941",
"0.5562231",
"0.5556365",
"0.5552045",
"0.5513167",
"0.5511... | 0.6491572 | 0 |
Computes the value of the GoldsteinPrice benchmark function. | def goldsteinpricefcn(x: np.ndarray) -> np.ndarray:
assert (
x.shape[1] == 2
), "The Goldstein-Price function is only defined on a 2D space."
X = x[:, 0]
Y = x[:, 1]
scores = (
1
+ ((X + Y + 1) ** 2)
* (
19
- (14 * X)
+ (3 * (X**2... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_price():\n return uniform(1.0, 350.0)",
"def vanilla_call_price(S, K, r, v, T):\n return S * norm_cdf(d_j(1, S, K, r, v, T)) - \\\n K*exp(-r*T) * norm_cdf(d_j(2, S, K, r, v, T))",
"def price(function):\n\t\tdef wrapper( self , *args, **kwargs) :\n\t\t\tresult = function( self , *args, ... | [
"0.6454277",
"0.59855956",
"0.5907033",
"0.58404166",
"0.5704696",
"0.5682961",
"0.5613935",
"0.5594099",
"0.5522262",
"0.5517457",
"0.54792166",
"0.54271406",
"0.5392998",
"0.5390746",
"0.5389863",
"0.5381264",
"0.5339678",
"0.52653164",
"0.5257292",
"0.5252111",
"0.52463305... | 0.6798362 | 0 |
Computes the value of the Holder table benchmark function. | def holdertablefcn(x: np.ndarray) -> np.ndarray:
if x.shape[1] != 2:
raise ValueError(
"The Holder table function is only defined on a 2D space."
)
X = x[:, 0]
Y = x[:, 1]
expcomponent = np.exp(np.abs(1 - (np.sqrt(X**2 + Y**2) / np.pi)))
scores = -np.abs(np.sin(X) * np... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def makeEvalTable(table):\n\n def score(game, player):\n row, col = game.get_player_location(player)\n return table[row][col]\n\n return score",
"def get_hash_value(table, prime, multiplier, start, length):\n y = pow(multiplier, length, prime)\n hash_value = (table[start+length] - y*tab... | [
"0.5728557",
"0.5510459",
"0.54146624",
"0.53776073",
"0.5343859",
"0.52959925",
"0.52901924",
"0.52901924",
"0.5236166",
"0.52144665",
"0.51988643",
"0.5194935",
"0.51848775",
"0.5184278",
"0.51594096",
"0.51474845",
"0.5145104",
"0.5135731",
"0.5133904",
"0.51118636",
"0.50... | 0.58341366 | 0 |
Computes the value of the Keane function at point X. | def keanefcn(x: np.ndarray) -> np.ndarray:
if x.shape[1] != 2:
raise ValueError("Keane function is defined only on a 2D space.")
X = x[:, 0]
Y = x[:, 1]
numeratorcomp = (np.sin(X - Y) ** 2) * (np.sin(X + Y) ** 2)
denominatorcomp = np.sqrt(X**2 + Y**2)
scores = -numeratorcomp / denominat... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fn(self, x):\n\n return math.exp(x*2) - math.exp(x) - 2",
"def fn(self, x):\n\n return math.exp(x*2) - math.exp(x) - 2",
"def _etaE(self,x):\n return self._etaE_cool(x) + self._etaE_hot(x)",
"def calculate_value(self, x: np.array) -> np.array:\n pass",
"def F(x):\n return... | [
"0.6538336",
"0.6538336",
"0.6439046",
"0.63711065",
"0.62708193",
"0.6267937",
"0.6255762",
"0.62172955",
"0.6212823",
"0.6204894",
"0.6189031",
"0.61885595",
"0.61549956",
"0.61377037",
"0.6124945",
"0.6109614",
"0.6095445",
"0.6086641",
"0.60696435",
"0.60470665",
"0.60260... | 0.736174 | 0 |
Computes the value of the Leon function. | def leonfcn(x: np.ndarray) -> np.ndarray:
assert x.shape[1] == 2, "Leon function is defined only on a 2D space."
X = x[:, 0]
Y = x[:, 1]
scores = 100 * ((Y - X**3) ** 2) + ((1 - X) ** 2)
return scores | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lam(E):\n return (12398.4/E)*1e-10",
"def lnlambda(Te, nev, debug=True):\n if debug:\n return 14.9-0.5*np.log(nev/1.e20)+np.log(Te/1.e3)\n else:\n return 15.0",
"def ln(x):\n return log(x, const.e)",
"def levin(x):\n summ = 0\n for t, l in x: # for the time and length of e... | [
"0.71083283",
"0.6841011",
"0.6754866",
"0.6585607",
"0.6510151",
"0.6480202",
"0.63509923",
"0.6263351",
"0.6239935",
"0.623093",
"0.6215461",
"0.61932355",
"0.61932355",
"0.61932355",
"0.61932355",
"0.61932355",
"0.61932355",
"0.61932355",
"0.61932355",
"0.6170976",
"0.6145... | 0.7008245 | 1 |
Computes the value of the McCormick benchmark function. | def mccormickfcn(x: np.ndarray) -> np.ndarray:
n = x.shape[1]
assert n == 2, "The McCormick function is only defined on a 2D space."
X = x[:, 0]
Y = x[:, 1]
scores = np.sin(X + Y) + ((X - Y) ** 2) - 1.5 * X + 2.5 * Y + 1
return scores | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def benchmark(self):\n logger.info(self.benchmark.__doc__)\n return self.run(self.benchmark_profile())",
"def mcc(self):\n tp = self.tp\n tn = self.tn\n fp = self.fp\n fn = self.fn\n return tp * tn / np.sqrt((tp + fp) * (tp + fn) * (tn + fp) * (tn + fn))",
"def ... | [
"0.5770976",
"0.5770158",
"0.55952823",
"0.5576308",
"0.5566546",
"0.55660033",
"0.5532023",
"0.55215895",
"0.55072695",
"0.5494697",
"0.54881865",
"0.54793864",
"0.54528296",
"0.5441196",
"0.5392271",
"0.539023",
"0.53821266",
"0.53817576",
"0.5328282",
"0.5295335",
"0.52841... | 0.5956978 | 0 |
Computes the value of the Powell Sum benchmark function. | def powellsumfcn(x: np.ndarray) -> np.ndarray:
n = x.shape[1]
absx = np.abs(x)
scores = np.zeros((x.shape[0], 1))
for i in range(n):
scores += absx[:, i] ** (i + 1)
return scores | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def self_powers():\n return sum([i ** i for i in range(1, 1001)]) % (10 ** 10)",
"def __pow__(self,n):\r\n\t\t\r\n\t\t# take power\r\n\t\tp = self.power(n)\r\n\t\t\r\n\t\treturn p",
"def my_func(x, y):\n result = 0\n pow_res = 1\n while y:\n pow_res= pow_res*x\n y +=1\n\n result = ... | [
"0.6347018",
"0.6229894",
"0.62252164",
"0.6215887",
"0.6177252",
"0.6054167",
"0.6053199",
"0.6033465",
"0.6014136",
"0.6013015",
"0.6006774",
"0.5996021",
"0.5962144",
"0.59423846",
"0.59210175",
"0.59095675",
"0.59080166",
"0.58695114",
"0.58438224",
"0.5842833",
"0.583151... | 0.6359862 | 0 |
Computes the value of the Schaffer N. 1 function. | def schaffern1fcn(x: np.ndarray) -> np.ndarray:
if x.shape[1] != 2:
raise ValueError(
"Schaffer function N. 1 is defined only on a 2D space."
)
X = x[:, 0]
Y = x[:, 1]
numeratorcomp = (np.sin((X**2 + Y**2) ** 2) ** 2) - 0.5
denominatorcomp = (1 + 0.001 * (X**2 + Y**2)) *... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def f1(x):\n return x**3 - 2*x + 2",
"def schaffern2fcn(x: np.ndarray) -> np.ndarray:\n\n n = x.shape[1]\n assert n == 2, \"The Schaffer N. 2 function is only defined on a 2D space.\"\n X = x[:, 0]\n Y = x[:, 1]\n\n sincomponent = np.sin((X**2) - (Y**2)) ** 2\n\n scores = 0.5 + ((sincomponen... | [
"0.6584917",
"0.6481896",
"0.6439764",
"0.6361834",
"0.6296292",
"0.6277372",
"0.6264745",
"0.62383217",
"0.62380254",
"0.62370884",
"0.6223405",
"0.62178963",
"0.6210311",
"0.6188163",
"0.6187111",
"0.6183105",
"0.6168933",
"0.61622983",
"0.61582285",
"0.6157296",
"0.6156587... | 0.72900873 | 0 |
Computes the value of the Schaffer N. 3 function. | def schaffern3fcn(x: np.ndarray) -> np.ndarray:
n = x.shape[1]
assert n == 2, "Schaffer function N. 3 is only defined on a 2D space."
X = x[:, 0]
Y = x[:, 1]
numeratorcomp = (np.sin(np.cos(np.abs(X**2 - Y**2))) ** 2) - 0.5
denominatorcomp = (1 + 0.001 * (X**2 + Y**2)) ** 2
scores = 0.5 + n... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def f3(x):\n return 1 / (1 + x**2)",
"def func_kc_318(n, series):\n if series == \"3D3\":\n try:\n return 2*np.pi/(wl_3D3[str(n)]*1e-9)\n except:\n return 0",
"def cube(n):\n return n**3",
"def f3(b, R):\n term1 = pow(R + 1, b, MOD) * (R * R + 3 * R + 1)\n t... | [
"0.74744457",
"0.6518171",
"0.6489711",
"0.64741915",
"0.64540005",
"0.6449841",
"0.644796",
"0.6340615",
"0.6331995",
"0.63147026",
"0.63090485",
"0.6262408",
"0.6224505",
"0.620137",
"0.618007",
"0.6168297",
"0.6155648",
"0.613928",
"0.613021",
"0.6118226",
"0.61180747",
... | 0.7101236 | 1 |
Computes the value of the Schaffer N. 4 function at point x. | def schaffern4fcn(x: np.ndarray) -> np.ndarray:
n = x.shape[1]
assert n == 2, "Schaffer function N. 4 is only defined on a 2D space."
X = x[:, 0]
Y = x[:, 1]
numeratorcomp = (np.cos(np.sin(np.abs(X**2 - Y**2))) ** 2) - 0.5
denominatorcomp = (1 + 0.001 * (X**2 + Y**2)) ** 2
scores = 0.5 + nu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def f4(x):\n return sin(x)/x",
"def f(x):\n\treturn (sc.log(x**2+5)*sc.cos(0.8*x)+3.5*x)/(sc.e**(x/10))",
"def dmy_fn(x):\n return 0.4*(2.0*(np.exp(x*4) + np.exp(-x*4)) - 8 + 0.6*x - 6*x**2)",
"def fn(x):\n\n # coefficients\n A = 728.0\n B = 0.317\n C = 0.486\n D = -8.99 * 1.6\n\n # fun... | [
"0.7411017",
"0.6930048",
"0.6921486",
"0.68591356",
"0.6732464",
"0.6713869",
"0.6674995",
"0.66693866",
"0.66382813",
"0.6634043",
"0.654799",
"0.654799",
"0.6531488",
"0.6457593",
"0.6456023",
"0.6454233",
"0.63749677",
"0.63643724",
"0.6359662",
"0.63468224",
"0.6337963",... | 0.729069 | 1 |
Computes the value of the Shubert 3 function. | def shubert3fcn(x: np.ndarray) -> np.ndarray:
n = x.shape[1]
scores = np.zeros((x.shape[0], 1))
for i in range(n):
for j in range(1, 6):
scores += j * np.sin(((j + 1) * x[:, i]) + j)
return scores | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def f3(x):\n return 1 / (1 + x**2)",
"def shubertfcn(x: np.ndarray) -> np.ndarray:\n n = x.shape[1]\n scores = np.ones((x.shape[0], 1))\n\n for i in range(n):\n inner_sum = 0\n for j in range(1, 6):\n inner_sum += j * np.cos((j + 1) * x[:, i] + j)\n scores *= inner_sum... | [
"0.67103696",
"0.6679727",
"0.6464011",
"0.6439688",
"0.6187991",
"0.6187991",
"0.59943545",
"0.5992829",
"0.59830207",
"0.5973727",
"0.5971992",
"0.5933024",
"0.58851564",
"0.58715343",
"0.5860081",
"0.5854105",
"0.5847598",
"0.58417004",
"0.5839464",
"0.58362097",
"0.579205... | 0.71903616 | 0 |
Computes the value of the Shubert 4 function. | def shubert4fcn(x: np.ndarray) -> np.ndarray:
n = x.shape[1]
scores = np.zeros((x.shape[0], 1))
for i in range(n):
for j in range(5):
scores += np.cos(((j + 1) * x[:, i]) + j)
return scores | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def f4(x):\n return sin(x)/x",
"def shubertfcn(x: np.ndarray) -> np.ndarray:\n n = x.shape[1]\n scores = np.ones((x.shape[0], 1))\n\n for i in range(n):\n inner_sum = 0\n for j in range(1, 6):\n inner_sum += j * np.cos((j + 1) * x[:, i] + j)\n scores *= inner_sum.resha... | [
"0.65850025",
"0.6414383",
"0.6267197",
"0.6143289",
"0.6041491",
"0.59965014",
"0.5941413",
"0.583031",
"0.58264554",
"0.5805695",
"0.57920116",
"0.57718754",
"0.5769053",
"0.5765886",
"0.5733159",
"0.57282025",
"0.57223207",
"0.5714412",
"0.5708586",
"0.56958693",
"0.568474... | 0.6952701 | 0 |
Computes the value of the Shubert function. | def shubertfcn(x: np.ndarray) -> np.ndarray:
n = x.shape[1]
scores = np.ones((x.shape[0], 1))
for i in range(n):
inner_sum = 0
for j in range(1, 6):
inner_sum += j * np.cos((j + 1) * x[:, i] + j)
scores *= inner_sum.reshape(-1, 1)
return scores | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def shubert4fcn(x: np.ndarray) -> np.ndarray:\n n = x.shape[1]\n\n scores = np.zeros((x.shape[0], 1))\n for i in range(n):\n for j in range(5):\n scores += np.cos(((j + 1) * x[:, i]) + j)\n\n return scores",
"def shubert3fcn(x: np.ndarray) -> np.ndarray:\n n = x.shape[1]\n sco... | [
"0.6036054",
"0.59692407",
"0.5690276",
"0.56251836",
"0.56005764",
"0.55349207",
"0.55294967",
"0.55255604",
"0.54892075",
"0.544754",
"0.5445382",
"0.54386884",
"0.5400716",
"0.53974473",
"0.5393435",
"0.53867686",
"0.5385275",
"0.5374094",
"0.536902",
"0.5364023",
"0.53605... | 0.66850483 | 0 |
Computes the value of the Threehump camel benchmark function. | def threehumpcamelfcn(x: np.ndarray) -> np.ndarray:
if x.shape[1] != 2:
raise ValueError(
"The Three-hump camel function is only defined on a 2D space."
)
X = x[:, 0]
Y = x[:, 1]
scores = (2 * X**2) - (1.05 * (X**4)) + ((X**6) / 6) + X * Y + Y**2
return scores | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def six_hump_camelback(x):\n x1 = x[0]\n x2 = x[1]\n f = ((4 - 2.1 * x1**2 + x1**4 / 3.) * x1**2 + x1 * x2 +\n (-4 + 4 * x2**2) * x2**2)\n return f",
"def six_hump_camel_func(x, y):\n x1 = x\n x2 = y\n term1 = (4-2.1*x1**2+(x1**4)/3) * x1**2\n term2 = x1*x2\n term3 = (-4+4*x2**... | [
"0.65246534",
"0.62460667",
"0.56958663",
"0.5641738",
"0.5523373",
"0.5515263",
"0.5511726",
"0.5428479",
"0.5419111",
"0.5397308",
"0.5288829",
"0.52887386",
"0.52807057",
"0.5219157",
"0.51658237",
"0.5157768",
"0.50924194",
"0.50732046",
"0.50634",
"0.5055845",
"0.5021174... | 0.6466864 | 1 |
Computes the value of the XinShe Yang N. 2 function. | def xinsheyangn2fcn(x: np.ndarray) -> np.ndarray:
scores = np.sum(np.abs(x), axis=1) * np.exp(-np.sum(np.sin(x**2), axis=1))
return scores | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def xinsheyangn4fcn(x: np.ndarray) -> np.ndarray:\n scores = (\n np.sum(np.sin(x) ** 2, axis=1) - np.exp(-np.sum(x**2, axis=1))\n ) * np.exp(-np.sum(np.sin(np.sqrt(np.abs(x))) ** 2, axis=1))\n return scores",
"def bohachevskyn2fcn(x: np.ndarray) -> np.ndarray:\n if x.shape[1] != 2:\n ra... | [
"0.6648352",
"0.65743804",
"0.6560823",
"0.6545158",
"0.648172",
"0.6461327",
"0.64112175",
"0.635012",
"0.6345721",
"0.6344422",
"0.6305214",
"0.63038725",
"0.62823474",
"0.6258571",
"0.6252152",
"0.62473077",
"0.62473077",
"0.6185643",
"0.61826897",
"0.6179014",
"0.6156176"... | 0.6836535 | 0 |
Computes the value of the XinShe Yang N. 3 function. The XinShe Yang N. 3 function is a parametric function and it is behaviour can be controlled with two additional parameters 'beta' and 'm'. In this implementation, the parameters are optional and when not given, their default value will be used. | def xinsheyangn3fcn(x: np.ndarray, beta: float = 15, m: int = 5) -> np.ndarray:
scores = np.exp(-np.sum((x / beta) ** (2 * m), axis=1)) - (
2 * np.exp(-np.sum(x**2, axis=1)) * np.prod(np.cos(x) ** 2, axis=1)
)
return scores | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def zeta(z, x, beta2):\n return 3 * (4* z**2 - beta2 * x**2) / 4 / beta2 / (1+x)",
"def nu(x, beta2):\n return 3 * (1 - beta2 - beta2*x) / beta2 / (1+x)",
"def m(z, x, beta2):\n \n omega3 = cbrt(Omega(z, x, beta2))\n return (-nu(x, beta2)/3\n + (zeta(z, x, beta2)/3 + nu(x, beta2)**2/36) /... | [
"0.5960531",
"0.59579235",
"0.594145",
"0.5776535",
"0.5766115",
"0.5765016",
"0.56158847",
"0.5581558",
"0.5576643",
"0.55603576",
"0.54778695",
"0.54582995",
"0.5426359",
"0.54223317",
"0.53915703",
"0.5337394",
"0.5310446",
"0.5306095",
"0.52791536",
"0.5278431",
"0.526386... | 0.7284796 | 0 |
Computes the value of the XinShe Yang N. 4 function. | def xinsheyangn4fcn(x: np.ndarray) -> np.ndarray:
scores = (
np.sum(np.sin(x) ** 2, axis=1) - np.exp(-np.sum(x**2, axis=1))
) * np.exp(-np.sum(np.sin(np.sqrt(np.abs(x))) ** 2, axis=1))
return scores | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def y(x):\n x1, x2, x3, x4 = x[:, 0], x[:, 1], x[:, 2], x[:, 3]\n return 1 + 0.3 * x1 - 0.6 * x2 ** 2 - 0.2 * x3 ** 3 + 0.5 * x4 ** 4",
"def xinsheyangn2fcn(x: np.ndarray) -> np.ndarray:\n scores = np.sum(np.abs(x), axis=1) * np.exp(-np.sum(np.sin(x**2), axis=1))\n return scores",
"def y01(... | [
"0.668845",
"0.6647849",
"0.6566709",
"0.6517151",
"0.64531726",
"0.6408301",
"0.63384175",
"0.62697124",
"0.6264157",
"0.6249124",
"0.6214744",
"0.6191742",
"0.61775064",
"0.6158654",
"0.6135535",
"0.61292064",
"0.6120068",
"0.60744154",
"0.60744154",
"0.60713613",
"0.604125... | 0.7001907 | 0 |
Computes the value of Zakharov benchmark function. | def zakharovfcn(x: np.ndarray) -> np.ndarray:
n = x.shape[1]
comp1 = np.sum(x**2, axis=1)
comp2 = np.sum(0.5 * np.arange(1, n + 1) * x, axis=1)
scores = comp1 + comp2**2 + comp2**4
return scores | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def zscore(vals):",
"def test_zakharov(self):\n fun = get_problem('zakharov', 2, -5, 10)\n self.assertAlmostEqual(fun(np.zeros(2)), 0.0)",
"def pz_fn(self, z):\n pass",
"def run():\n return estimate(0,1,0)",
"def benchmark(func, inputs):\n t0 = time.clock()\n results... | [
"0.62017846",
"0.5999605",
"0.570642",
"0.5594325",
"0.54792374",
"0.54449856",
"0.54310775",
"0.54199517",
"0.53514165",
"0.5341001",
"0.5316022",
"0.5285323",
"0.5281742",
"0.5273071",
"0.52640337",
"0.52511394",
"0.52270186",
"0.5220056",
"0.5187535",
"0.51850915",
"0.5172... | 0.6244812 | 0 |
Get the Vagrant version. | def version():
with settings(hide('running', 'warnings'), warn_only=True):
res = local('vagrant --version', capture=True)
if res.failed:
return None
line = res.splitlines()[-1]
version = re.match(r'Vagrant (?:v(?:ersion )?)?(.*)', line).group(1)
return tuple(_to_int(part) for part in... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def vagrant_check_version(self):\n # note: we do not raise any AnsibleCliError from this function because\n # AnsibleCliError are used to trigger stuffs when they are catched. In\n # this case, we do not want trigger anything if something fails.\n try:\n output = exec_shell([... | [
"0.74387556",
"0.70418996",
"0.67030704",
"0.65834874",
"0.6550676",
"0.65437007",
"0.65120745",
"0.6484319",
"0.6448412",
"0.639148",
"0.6359417",
"0.63544106",
"0.6324436",
"0.6311355",
"0.62821597",
"0.62745804",
"0.6264706",
"0.62633675",
"0.624769",
"0.624769",
"0.624769... | 0.8651006 | 0 |
Get the SSH parameters for connecting to a vagrant VM named `name`. If `name` is empty, this tries to infer the correct name from `env.host_string` so that you can retrieve the vagrant ssh configuration on the currently specified `env.host_string`. | def ssh_config(name=''):
name = _name_or_host_string(name)
with settings(hide('running')):
output = local('vagrant ssh-config %s' % name, capture=True)
config = {}
for line in output.splitlines()[1:]:
key, value = line.strip().split(' ', 1)
config[key] = value
return config | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ssh_config(name=''):\n with settings(hide('running')):\n output = local('vagrant ssh-config %s' % name, capture=True)\n\n config = {}\n for line in output.splitlines()[1:]:\n key, value = line.strip().split(' ', 2)\n config[key] = value\n return config",
"def vagrant(name='')... | [
"0.7195036",
"0.7150112",
"0.68741906",
"0.67810583",
"0.6166713",
"0.5530551",
"0.535039",
"0.5291446",
"0.51381147",
"0.5065083",
"0.5062822",
"0.5053029",
"0.5051671",
"0.5051671",
"0.5026425",
"0.5011109",
"0.5007627",
"0.50017583",
"0.498156",
"0.49498692",
"0.4938522",
... | 0.74045503 | 0 |
Get the list of vagrant base boxes | def base_boxes():
return sorted(list(set([name for name, provider in _box_list()]))) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_all_vms(self):\n available_servers = self.connection.compute.servers()\n if available_servers:\n vm_names = [server.name for server in available_servers]\n return vm_names\n else:\n return []",
"def get_volume_list():\n return parse_list_output(Pop... | [
"0.6057725",
"0.6006748",
"0.59834456",
"0.59822416",
"0.5976379",
"0.5792459",
"0.5784408",
"0.57825434",
"0.5764939",
"0.5750458",
"0.5730363",
"0.56795543",
"0.5621686",
"0.5515135",
"0.5514301",
"0.54984146",
"0.5496172",
"0.5495021",
"0.54623616",
"0.5458488",
"0.5435005... | 0.7076144 | 0 |
Execute all the listener functions, thus updating the views. | def UpdateViews(self):
for eachf in self._listeners:
eachf(self) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Update(self):\n\n # note this function should be overloaded; this line is simply\n # indicating that the overloaded function should normally call\n # UpdateViews before returning.\n self.UpdateViews()",
"def update_state(self):\n for listener in self.listeners:\n ... | [
"0.6506938",
"0.6475875",
"0.6278699",
"0.6200263",
"0.6145531",
"0.6118782",
"0.6060468",
"0.60568935",
"0.6023579",
"0.60233647",
"0.60134614",
"0.60046166",
"0.5974811",
"0.595886",
"0.5952984",
"0.5927636",
"0.59088475",
"0.5899794",
"0.5830107",
"0.58081716",
"0.5799081"... | 0.79930174 | 0 |
Return list of all live orders. | def GetLiveOrders(self):
return self._lorders | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_all_orders():\n response = requests.get(\n settings.SHOPIFY_ORDERS_URL,\n auth=(settings.SHOPIFY_API_KEY, settings.SHOPIFY_PASSWORD),\n )\n return response.json()[\"orders\"]",
"def get_all_orders():",
"async def get_live_orders(cls, session, account, **kwargs) -> List:\n ... | [
"0.7707643",
"0.7667428",
"0.7658947",
"0.75866383",
"0.7377521",
"0.7328183",
"0.7327643",
"0.7260218",
"0.70364296",
"0.69945556",
"0.69348824",
"0.6864351",
"0.6842969",
"0.68146753",
"0.6798657",
"0.67922896",
"0.678773",
"0.67566943",
"0.6748724",
"0.67423004",
"0.674088... | 0.8092857 | 0 |
Return list of new orders. | def GetNewOrders(self):
return self._neworders | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_all_orders():",
"def get_new_orders(self):\n\n # note we only get orders from the strategies with UPDATED =\n # True, i.e. only those which got new pricing information this\n # tick. Among other reasons, this is because some strategies\n # (e.g. MMStrategy) need to be fed new... | [
"0.74729395",
"0.74539167",
"0.74031377",
"0.7344486",
"0.72234035",
"0.70264506",
"0.6961467",
"0.68642104",
"0.68007994",
"0.6781083",
"0.67340666",
"0.66880363",
"0.6685029",
"0.66132927",
"0.6605937",
"0.65675074",
"0.65672517",
"0.64113915",
"0.6400077",
"0.63966846",
"0... | 0.81945354 | 0 |
Return the particular BDAQ and BF selection objects with a certain BDAQ name. | def GetSelsByBDAQName(self, bdaqname):
indx = self._selindx[bdaqname]
return self._bdaqsels[indx], self._bfsels[indx] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def choose(builders, spec):\n\n candidates = search(builders, spec)\n buildername = get_builder(candidates, spec.values()[0])\n\n if not buildername:\n return None\n\n blder = [b for b in builders if b['name'] == buildername][0]\n\n return blder",
"def extract_BeambyName(self,model, obj_refs):\n s... | [
"0.53738785",
"0.5316094",
"0.52343273",
"0.51395816",
"0.51282924",
"0.50690675",
"0.5064134",
"0.50137335",
"0.49794972",
"0.49367946",
"0.49148154",
"0.49025884",
"0.48544526",
"0.48440778",
"0.48206478",
"0.4760076",
"0.47415245",
"0.4735587",
"0.47309318",
"0.47255597",
... | 0.6857059 | 0 |
Return lists bdaqsels, bfsels. | def GetSels(self):
return self._bdaqsels, self._bfsels | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def GetSelsByBDAQName(self, bdaqname):\n\n indx = self._selindx[bdaqname]\n\n return self._bdaqsels[indx], self._bfsels[indx]",
"def get_BBands(sma, stdev):\n\tupper_band = sma + 2*stdev\n\tlower_band = sma - 2*stdev\n\treturn upper_band, lower_band",
"def GetSMSeries(b_series, parameters):\n\tre... | [
"0.60715675",
"0.5650012",
"0.56104875",
"0.55681455",
"0.55067873",
"0.54696906",
"0.54564637",
"0.54534453",
"0.5335074",
"0.53299665",
"0.5325118",
"0.52960455",
"0.5292493",
"0.5263537",
"0.52545935",
"0.5242498",
"0.52169585",
"0.52039987",
"0.5202558",
"0.52015525",
"0.... | 0.6320389 | 0 |
Fetch matching markets for a particular event name. If refresh is True, update the matching markets first by using the BDAQ and BF APIs. | def Update(self, ename, refresh=False):
if refresh:
# use BDAQ and BF api to get list of matching markets
self._mmarks = self._mupdater.update_market_information(ename)
else:
self._mmarks = self._mstore.get_matches(ename)
# remove matching markets that don't... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def fetch_markets(self, params={}):\n response = await self.publicGetInstrumentActiveAndIndices(params)\n #\n # [\n # {\n # \"symbol\": \"LTCUSDT\",\n # \"rootSymbol\": \"LTC\",\n # \"state\": \"Open\",\n # \"typ\": \"FFW... | [
"0.56654906",
"0.55907327",
"0.55267626",
"0.54456544",
"0.5352846",
"0.52956",
"0.525859",
"0.5254869",
"0.5236004",
"0.52171665",
"0.51943916",
"0.5191885",
"0.5170072",
"0.5153939",
"0.51423573",
"0.5078429",
"0.50783694",
"0.5072425",
"0.5065305",
"0.5059639",
"0.5034104"... | 0.6419082 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.