query stringlengths 10 2k | document stringlengths 20 51.2k | metadata dict | negatives listlengths 0 101 | negative_scores listlengths 0 101 | document_score stringlengths 3 10 | document_rank stringclasses 102
values |
|---|---|---|---|---|---|---|
Add a peak to this cluster. | def add(self, peak):
self.peaks.append(peak)
self.end = max(self.end, peak.end)
self.len = self.start - self.end
self.count += 1
self.pops.append(peak.pop)
# Get average fold change and log10p
self.fold_change = (self.fold_change+peak.fold_change)/2
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def foundPeak(self, peak):\n\n self.sequence.append({\"type\": \"foundPeak\", \"coord\": peak})",
"def peak(self):\n pass",
"def set_peak(self, p):\n self.peak = p",
"def peak(self):\n return self.peak",
"def peak(self):\n\n return self._data[0]",
"def peakFinder(self, ... | [
"0.6952894",
"0.6380414",
"0.6218962",
"0.5416108",
"0.5400935",
"0.5379657",
"0.53623825",
"0.5355127",
"0.5292391",
"0.51798177",
"0.51113623",
"0.50968796",
"0.5028456",
"0.5016791",
"0.49638537",
"0.4945158",
"0.48710155",
"0.4830253",
"0.4813596",
"0.47821036",
"0.475357... | 0.7404187 | 0 |
Return file handle of file regardless of zipped or not. Text mode enforced for compatibility with python2. | def open_zipped(infile, mode='r'):
mode = mode[0] + 't'
p2mode = mode
if hasattr(infile, 'write'):
return infile
if isinstance(infile, str):
if infile.endswith('.gz'):
return gzip.open(infile, mode)
if infile.endswith('.bz2'):
if hasattr(bz2, 'open'):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def zip_open_text(zip, filename):\n if isinstance(zip, FakeZip):\n return zip.open(filename)\n else:\n # Wrap the zip file to decode.\n return io.TextIOWrapper(zip.open(filename, 'r'), encoding='utf8')",
"def _get_file_handle(\n filepath,\n mode,\n *,\n compression=None,\n ... | [
"0.64964736",
"0.64299065",
"0.6348069",
"0.62734354",
"0.61643595",
"0.6111869",
"0.61030376",
"0.60944647",
"0.5920198",
"0.58220613",
"0.57453364",
"0.5724395",
"0.5721311",
"0.5685008",
"0.567374",
"0.5657052",
"0.56300277",
"0.5614082",
"0.5614082",
"0.56082886",
"0.5586... | 0.6201446 | 4 |
return list of all groups id's where player is the owner | def get_groups_of_player(self, player: str) -> list:
return [group for group in self._groups if self._groups[group]['player'] == player] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_groups(self):\n user_node = self.get()\n grouplist = []\n if user_node:\n for rel in graph.match(start_node=user_node, rel_type='in'):\n grouplist.append(Usergroup(id=rel.end_node()['id']))\n return grouplist",
"def get_groups(self, obj):\n gro... | [
"0.6568522",
"0.65168047",
"0.64288473",
"0.6422493",
"0.6243459",
"0.6239092",
"0.61937416",
"0.61693347",
"0.6161194",
"0.6145746",
"0.6113854",
"0.6108952",
"0.6093858",
"0.6059349",
"0.6035539",
"0.60080665",
"0.59834534",
"0.5961168",
"0.59402305",
"0.58921856",
"0.58681... | 0.7803114 | 0 |
Get information about current playing item | def NowPlaying(self):
self.logger.debug("Fetching currently playing information")
try:
xbmc = Server(self.url('/jsonrpc', True))
player = xbmc.Player.GetActivePlayers()[0]
playerid = player['playerid']
if player['type'] == 'video':
playerp... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_music_info(self):\n return self.get(COMMAND_UIC, 'GetMusicInfo')",
"def get_item(self):\n return self.item",
"def get_item(self):\n return self.item",
"def current_song():\n T = get_template('webview/t/now_playing.html')\n R = T.render(Context({ 'now_playing' : songname }))... | [
"0.67777663",
"0.6668891",
"0.6668891",
"0.63178694",
"0.63054585",
"0.6297474",
"0.6271164",
"0.6243441",
"0.62359065",
"0.61851037",
"0.6185019",
"0.6183303",
"0.6180103",
"0.61662066",
"0.6115445",
"0.6060738",
"0.60542786",
"0.60418993",
"0.6037503",
"0.6008975",
"0.60042... | 0.7455609 | 0 |
Check if the argument `arg_name` is mandatory. | def is_mandatory_arg(self, arg_name):
return arg_name in self.get_mandatory_args() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mandatory_argument(value, arg_name):\n if (value is None) or (value == \"\"):\n sys.stderr.write(\"The \" + arg_name + \" argument is mandatory.\\n\")\n sys.exit(\"Invalid input\")",
"def has_arg(self, arg_name):\n raise NotImplementedError(\"ICallable.has_arg\")",
"def _check_args(... | [
"0.7754579",
"0.70682615",
"0.6923531",
"0.68402016",
"0.6792005",
"0.67807925",
"0.65515625",
"0.65259904",
"0.64652187",
"0.644721",
"0.6427926",
"0.6339972",
"0.62767094",
"0.62161946",
"0.6090793",
"0.6080348",
"0.60725844",
"0.6066505",
"0.6065314",
"0.6064399",
"0.60621... | 0.8900179 | 0 |
Sum an array over the latitude and longitude dimensions. | def _sum_over_lat_lon(arr):
return arr.sum(internal_names.LAT_STR).sum(internal_names.LON_STR) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def geo_m_accumulate(data_array):\n dst = DataOperation.geo_m(data_array)\n sum = 0\n count = 0\n data = np.zeros(dst.size)\n for d in dst:\n sum += d\n data[count] = sum\n count += 1\n return data",
"def _gu_sum(a, **kwds):\n return n... | [
"0.64502245",
"0.6207058",
"0.60490465",
"0.58714014",
"0.5825379",
"0.5756719",
"0.5718592",
"0.5710989",
"0.5643108",
"0.56417847",
"0.56413555",
"0.56291634",
"0.56116784",
"0.55120707",
"0.55063874",
"0.5505126",
"0.5470343",
"0.5461687",
"0.5458216",
"0.5439408",
"0.5425... | 0.78578496 | 0 |
Instantiate a Region object. If a region spans across the endpoint of the data's longitude array (i.e. it crosses the Prime Meridian for data with longitudes spanning 0 to 360), it must be defined as the union of two sections extending to the east and to the west of the Prime Meridian. | def __init__(self, name='', description='', lon_bounds=[], lat_bounds=[],
mask_bounds=[], do_land_mask=False):
self.name = name
self.description = description
if lon_bounds and lat_bounds and not mask_bounds:
self.mask_bounds = [(lat_bounds, lon_bounds)]
else... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_region(self):\n\n coords = self.convert_coords()\n log.debug(coords)\n viz_keywords = ['color', 'dash', 'dashlist', 'width', 'font', 'symsize',\n 'symbol', 'symsize', 'fontsize', 'fontstyle', 'usetex',\n 'labelpos', 'labeloff', 'linewidth', ... | [
"0.63053006",
"0.61687976",
"0.6125895",
"0.6087599",
"0.58740324",
"0.580751",
"0.5777614",
"0.57774085",
"0.5741435",
"0.57384056",
"0.57265013",
"0.5713294",
"0.5701933",
"0.56727165",
"0.5537091",
"0.543792",
"0.54341775",
"0.5381034",
"0.5349791",
"0.53306013",
"0.532360... | 0.0 | -1 |
Standard deviation of regionaverage timeseries. | def std(self, data):
ts_ = self.ts(data)
if 'year' not in ts_.coords:
return ts_
return ts_.std('year') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def std_deviation(array):\n if not array or len(array) == 1:\n return 0\n\n average = AGGREGATES['mean_arithmetic'](array)\n variance = map(lambda x: (x-average)**2,array)\n stdev = AGGREGATES['mean_arithmetic'](variance)\n return math.sqrt(stdev)",
"def stddev(r):\n avg = average(r)\n ... | [
"0.73579425",
"0.73224527",
"0.7210962",
"0.7085255",
"0.70257044",
"0.70104164",
"0.7002761",
"0.6999386",
"0.6996699",
"0.6960966",
"0.6922874",
"0.6914699",
"0.68882704",
"0.68609214",
"0.6852386",
"0.6829597",
"0.681832",
"0.6818129",
"0.6817461",
"0.6782195",
"0.67674816... | 0.66603476 | 32 |
A port of the functionality of in_cksum() from ping.c Ideally this would act on the string as a series of 16bit ints (host packed), but this works. Network data is bigendian, hosts are typically littleendian | def calculate_checksum(source_string):
countTo = (int(len(source_string) / 2)) * 2
sum = 0
count = 0
# Handle bytes in pairs (decoding as short ints)
loByte = 0
hiByte = 0
while count < countTo:
if (byteorder == "little... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _checksum(source_string):\n if (len(source_string) % 2):\n source_string += \"\\x00\"\n converted = array.array(\"H\", source_string)\n if sys.byteorder == \"big\":\n converted.bytewap()\n val = sum(converted)\n\n val &= 0xffffffff # Truncate val to 32 bits (a variance from ping.c... | [
"0.6901242",
"0.6826661",
"0.6166087",
"0.6124918",
"0.60836464",
"0.59694684",
"0.5967868",
"0.59589195",
"0.5887343",
"0.58318347",
"0.5816561",
"0.5809599",
"0.57735616",
"0.5735805",
"0.5701893",
"0.5671904",
"0.5660636",
"0.56178164",
"0.56142515",
"0.56102103",
"0.55950... | 0.662299 | 2 |
Tests to check that the ip binary is both existing and executable | def is_exe(fpath):
import os
return os.path.isfile(fpath) and os.access(fpath, os.X_OK) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_azurecli_binary_exists(host):\n host.file(PACKAGE_BINARY).exists",
"def check_binary(self):\n if shutil.which(self.binary):\n return True\n else:\n logging.warning(R+'The supplied binary or path does not exist... Exiting'+W)\n exit(1)",
"def checkForBi... | [
"0.6890221",
"0.66422766",
"0.6618069",
"0.66121614",
"0.64765495",
"0.6438529",
"0.632655",
"0.6285194",
"0.6247665",
"0.61838907",
"0.61346996",
"0.6055075",
"0.60460854",
"0.60087377",
"0.59815407",
"0.5950691",
"0.5943396",
"0.5911114",
"0.58980256",
"0.58867633",
"0.5882... | 0.0 | -1 |
Tests that a valid nickname is deemed valid | def test__check_invalid_nickname__valid_name(self):
self.assertEqual(
first=trainercode.format_trainer_code("111122223333"),
second="1111 2222 3333"
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_nickname(self, nickname):\n for char in nickname:\n if not char.isdigit() and not char.isalpha():\n raise serializers.ValidationError(\"Nickname contains characters that are not numbers nor letters.\")\n\n return nickname",
"def is_valid_nick_name(nick):\n ... | [
"0.78913736",
"0.7589311",
"0.73727137",
"0.7255789",
"0.725182",
"0.7126826",
"0.70817244",
"0.704509",
"0.7013513",
"0.69120085",
"0.6886412",
"0.68635315",
"0.68081886",
"0.67777926",
"0.67737234",
"0.672804",
"0.67146164",
"0.66870165",
"0.6686512",
"0.6677102",
"0.666763... | 0.8228256 | 0 |
Name of the broker. | def broker_name(self) -> Optional[pulumi.Input[str]]:
return pulumi.get(self, "broker_name") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def broker_name(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"broker_name\")",
"def name(self):\n return \"{} {}\".format(self._clientname, self._name)",
"def describe_broker(BrokerId=None):\n pass",
"def delivery_channel_name(self) -> str:\n return pulumi.get(self, \"deliv... | [
"0.8728616",
"0.6610538",
"0.6537796",
"0.65365344",
"0.65365344",
"0.65365344",
"0.6383963",
"0.6353745",
"0.6351735",
"0.6351735",
"0.6303344",
"0.6276458",
"0.622978",
"0.6229164",
"0.6202573",
"0.62012804",
"0.61884606",
"0.6156356",
"0.61429304",
"0.6103458",
"0.60999596... | 0.83233035 | 2 |
List of subnet IDs in which to launch the broker. A `SINGLE_INSTANCE` deployment requires one subnet. An `ACTIVE_STANDBY_MULTI_AZ` deployment requires multiple subnets. | def subnet_ids(self) -> Optional[pulumi.Input[Sequence[pulumi.Input[str]]]]:
return pulumi.get(self, "subnet_ids") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def subnets(self) -> Optional[pulumi.Input[Sequence[pulumi.Input['ResourceIdArgs']]]]:\n return pulumi.get(self, \"subnets\")",
"def subnets(self) -> Sequence[str]:\n return pulumi.get(self, \"subnets\")",
"def subnets(self) -> pulumi.Input[Sequence[pulumi.Input[str]]]:\n return pulumi.get... | [
"0.75503856",
"0.75484973",
"0.74949217",
"0.7348017",
"0.7348017",
"0.7348017",
"0.7342196",
"0.7189892",
"0.7189892",
"0.7166254",
"0.70746905",
"0.70746905",
"0.70746905",
"0.7070669",
"0.7033409",
"0.6867835",
"0.68383294",
"0.68383294",
"0.67263055",
"0.6678942",
"0.6672... | 0.7413906 | 5 |
Map of tags to assign to the broker. If configured with a provider `default_tags` configuration block present, tags with matching keys will overwrite those defined at the providerlevel. | def tags(self) -> Optional[pulumi.Input[Mapping[str, pulumi.Input[str]]]]:
return pulumi.get(self, "tags") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tags(self) -> Mapping[str, Any]:\n return pulumi.get(self, \"tags\")",
"def tags(self) -> Mapping[str, Any]:\n return pulumi.get(self, \"tags\")",
"def tags(self) -> Mapping[str, str]:\n return pulumi.get(self, \"tags\")",
"def tags(self) -> Mapping[str, str]:\n return pulumi.... | [
"0.606254",
"0.606254",
"0.60574615",
"0.60574615",
"0.60574615",
"0.60574615",
"0.58956105",
"0.58736855",
"0.5815294",
"0.5806402",
"0.57935935",
"0.57886183",
"0.57753205",
"0.5653901",
"0.56476367",
"0.56439185",
"0.55700433",
"0.554056",
"0.554056",
"0.554056",
"0.546022... | 0.0 | -1 |
ARN of the broker. | def arn(self) -> Optional[pulumi.Input[str]]:
return pulumi.get(self, "arn") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def broker_name(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"broker_name\")",
"def topic_arn(self) -> str:\n return pulumi.get(self, \"topic_arn\")",
"def topic_arn(self) -> str:\n return self[\"Sns\"][\"TopicArn\"]",
"def base_topicarn ( self ) :\n if not self.topic_arn... | [
"0.69551474",
"0.67289007",
"0.6443844",
"0.6407738",
"0.6339225",
"0.6283615",
"0.6270799",
"0.6270799",
"0.6257132",
"0.61897296",
"0.61897296",
"0.61897296",
"0.61897296",
"0.61897296",
"0.61897296",
"0.61897296",
"0.61897296",
"0.61897296",
"0.61897296",
"0.61897296",
"0.... | 0.5454213 | 80 |
Name of the broker. | def broker_name(self) -> Optional[pulumi.Input[str]]:
return pulumi.get(self, "broker_name") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def broker_name(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"broker_name\")",
"def name(self):\n return \"{} {}\".format(self._clientname, self._name)",
"def describe_broker(BrokerId=None):\n pass",
"def delivery_channel_name(self) -> str:\n return pulumi.get(self, \"deliv... | [
"0.8728616",
"0.6610538",
"0.6537796",
"0.65365344",
"0.65365344",
"0.65365344",
"0.6383963",
"0.6353745",
"0.6351735",
"0.6351735",
"0.6303344",
"0.6276458",
"0.622978",
"0.6229164",
"0.6202573",
"0.62012804",
"0.61884606",
"0.6156356",
"0.61429304",
"0.6103458",
"0.60999596... | 0.83233035 | 1 |
List of subnet IDs in which to launch the broker. A `SINGLE_INSTANCE` deployment requires one subnet. An `ACTIVE_STANDBY_MULTI_AZ` deployment requires multiple subnets. | def subnet_ids(self) -> Optional[pulumi.Input[Sequence[pulumi.Input[str]]]]:
return pulumi.get(self, "subnet_ids") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def subnets(self) -> Optional[pulumi.Input[Sequence[pulumi.Input['ResourceIdArgs']]]]:\n return pulumi.get(self, \"subnets\")",
"def subnets(self) -> Sequence[str]:\n return pulumi.get(self, \"subnets\")",
"def subnets(self) -> pulumi.Input[Sequence[pulumi.Input[str]]]:\n return pulumi.get... | [
"0.75503856",
"0.75484973",
"0.74949217",
"0.7348017",
"0.7348017",
"0.7348017",
"0.7342196",
"0.7189892",
"0.7189892",
"0.7166254",
"0.70746905",
"0.70746905",
"0.70746905",
"0.7070669",
"0.7033409",
"0.6867835",
"0.68383294",
"0.68383294",
"0.67263055",
"0.6678942",
"0.6672... | 0.7413906 | 4 |
Map of tags to assign to the broker. If configured with a provider `default_tags` configuration block present, tags with matching keys will overwrite those defined at the providerlevel. | def tags(self) -> Optional[pulumi.Input[Mapping[str, pulumi.Input[str]]]]:
return pulumi.get(self, "tags") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tags(self) -> Mapping[str, Any]:\n return pulumi.get(self, \"tags\")",
"def tags(self) -> Mapping[str, Any]:\n return pulumi.get(self, \"tags\")",
"def tags(self) -> Mapping[str, str]:\n return pulumi.get(self, \"tags\")",
"def tags(self) -> Mapping[str, str]:\n return pulumi.... | [
"0.606254",
"0.606254",
"0.60574615",
"0.60574615",
"0.60574615",
"0.60574615",
"0.58956105",
"0.58736855",
"0.5815294",
"0.5806402",
"0.57935935",
"0.57886183",
"0.57753205",
"0.5653901",
"0.56476367",
"0.56439185",
"0.55700433",
"0.554056",
"0.554056",
"0.554056",
"0.546022... | 0.0 | -1 |
A map of tags assigned to the resource, including those inherited from the provider `default_tags` configuration block. | def tags_all(self) -> Optional[pulumi.Input[Mapping[str, pulumi.Input[str]]]]:
return pulumi.get(self, "tags_all") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tags(self) -> Mapping[str, Any]:\n return pulumi.get(self, \"tags\")",
"def tags(self) -> Mapping[str, Any]:\n return pulumi.get(self, \"tags\")",
"def tags(self) -> Mapping[str, str]:\n return pulumi.get(self, \"tags\")",
"def tags(self) -> Mapping[str, str]:\n return pulumi.... | [
"0.7442922",
"0.7442922",
"0.74372643",
"0.74372643",
"0.74372643",
"0.74372643",
"0.71595305",
"0.7096487",
"0.70816255",
"0.70577693",
"0.69300693",
"0.6916472",
"0.68235135",
"0.67972314",
"0.67532057",
"0.6701463",
"0.66302735",
"0.66302735",
"0.66302735",
"0.66302735",
"... | 0.0 | -1 |
Get an existing Broker resource's state with the given name, id, and optional extra properties used to qualify the lookup. | def get(resource_name: str,
id: pulumi.Input[str],
opts: Optional[pulumi.ResourceOptions] = None,
apply_immediately: Optional[pulumi.Input[bool]] = None,
arn: Optional[pulumi.Input[str]] = None,
authentication_strategy: Optional[pulumi.Input[str]] = None,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_state_by_id(state_id):\n my_state = storage.get('State', state_id)\n if my_state is None:\n abort(404)\n return jsonify(my_state.to_dict())",
"def get_state_by_id(state_id):\n state = storage.get(State, state_id)\n if not state:\n abort(404)\n return jsonify(state.to_dict(... | [
"0.58474654",
"0.5841396",
"0.58206564",
"0.5734607",
"0.5674083",
"0.563005",
"0.56278497",
"0.555021",
"0.5538892",
"0.5452593",
"0.5434635",
"0.5374448",
"0.5358285",
"0.5334165",
"0.532351",
"0.52982545",
"0.5272039",
"0.52711546",
"0.5222293",
"0.51918983",
"0.51530343",... | 0.5958051 | 0 |
ARN of the broker. | def arn(self) -> pulumi.Output[str]:
return pulumi.get(self, "arn") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def broker_name(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"broker_name\")",
"def topic_arn(self) -> str:\n return pulumi.get(self, \"topic_arn\")",
"def topic_arn(self) -> str:\n return self[\"Sns\"][\"TopicArn\"]",
"def base_topicarn ( self ) :\n if not self.topic_arn... | [
"0.69551474",
"0.67289007",
"0.6443844",
"0.6407738",
"0.6339225",
"0.6283615",
"0.6270799",
"0.6270799",
"0.6257132",
"0.6172612",
"0.6156959",
"0.6156959",
"0.6156959",
"0.6156959",
"0.6156959",
"0.6146207",
"0.6146207",
"0.61393595",
"0.58863443",
"0.58863443",
"0.58863443... | 0.61897296 | 30 |
Name of the broker. | def broker_name(self) -> pulumi.Output[str]:
return pulumi.get(self, "broker_name") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def broker_name(self) -> Optional[pulumi.Input[str]]:\n return pulumi.get(self, \"broker_name\")",
"def broker_name(self) -> Optional[pulumi.Input[str]]:\n return pulumi.get(self, \"broker_name\")",
"def name(self):\n return \"{} {}\".format(self._clientname, self._name)",
"def describe_... | [
"0.83233035",
"0.83233035",
"0.6610538",
"0.6537796",
"0.65365344",
"0.65365344",
"0.65365344",
"0.6383963",
"0.6353745",
"0.6351735",
"0.6351735",
"0.6303344",
"0.6276458",
"0.622978",
"0.6229164",
"0.6202573",
"0.62012804",
"0.61884606",
"0.6156356",
"0.61429304",
"0.610345... | 0.8728616 | 0 |
List of subnet IDs in which to launch the broker. A `SINGLE_INSTANCE` deployment requires one subnet. An `ACTIVE_STANDBY_MULTI_AZ` deployment requires multiple subnets. | def subnet_ids(self) -> pulumi.Output[Sequence[str]]:
return pulumi.get(self, "subnet_ids") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def subnets(self) -> Optional[pulumi.Input[Sequence[pulumi.Input['ResourceIdArgs']]]]:\n return pulumi.get(self, \"subnets\")",
"def subnets(self) -> Sequence[str]:\n return pulumi.get(self, \"subnets\")",
"def subnets(self) -> pulumi.Input[Sequence[pulumi.Input[str]]]:\n return pulumi.get... | [
"0.75503856",
"0.75484973",
"0.74949217",
"0.7413906",
"0.7413906",
"0.7413906",
"0.7348017",
"0.7348017",
"0.7348017",
"0.7342196",
"0.7189892",
"0.7189892",
"0.7166254",
"0.7070669",
"0.7033409",
"0.6867835",
"0.68383294",
"0.68383294",
"0.67263055",
"0.6678942",
"0.6672491... | 0.70746905 | 15 |
Map of tags to assign to the broker. If configured with a provider `default_tags` configuration block present, tags with matching keys will overwrite those defined at the providerlevel. | def tags(self) -> pulumi.Output[Optional[Mapping[str, str]]]:
return pulumi.get(self, "tags") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tags(self) -> Mapping[str, Any]:\n return pulumi.get(self, \"tags\")",
"def tags(self) -> Mapping[str, Any]:\n return pulumi.get(self, \"tags\")",
"def tags(self) -> Mapping[str, str]:\n return pulumi.get(self, \"tags\")",
"def tags(self) -> Mapping[str, str]:\n return pulumi.... | [
"0.606254",
"0.606254",
"0.60574615",
"0.60574615",
"0.60574615",
"0.60574615",
"0.58956105",
"0.58736855",
"0.5815294",
"0.5806402",
"0.57935935",
"0.57886183",
"0.57753205",
"0.5653901",
"0.56476367",
"0.56439185",
"0.55700433",
"0.554056",
"0.554056",
"0.554056",
"0.543255... | 0.54602206 | 45 |
A map of tags assigned to the resource, including those inherited from the provider `default_tags` configuration block. | def tags_all(self) -> pulumi.Output[Mapping[str, str]]:
return pulumi.get(self, "tags_all") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tags(self) -> Mapping[str, Any]:\n return pulumi.get(self, \"tags\")",
"def tags(self) -> Mapping[str, Any]:\n return pulumi.get(self, \"tags\")",
"def tags(self) -> Mapping[str, str]:\n return pulumi.get(self, \"tags\")",
"def tags(self) -> Mapping[str, str]:\n return pulumi.... | [
"0.7442922",
"0.7442922",
"0.74372643",
"0.74372643",
"0.74372643",
"0.74372643",
"0.71595305",
"0.7096487",
"0.70816255",
"0.70577693",
"0.69300693",
"0.6916472",
"0.68235135",
"0.67972314",
"0.67532057",
"0.6701463",
"0.66302735",
"0.66302735",
"0.66302735",
"0.66302735",
"... | 0.64104486 | 63 |
Returns formated timedelta string representation | def convert_timedelta(item):
if isinstance(item, timedelta):
seconds = int(item.total_seconds())
hours, remainder = divmod(seconds, 3600)
minutes, seconds = divmod(remainder, 60)
formated = '{}h {}m {}s'.format(hours, minutes, seconds)
else:
raise TypeError(item, '... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def timedelta_to_str(obj):\n seconds = int(obj.seconds) % 60\n minutes = int(obj.seconds / 60) % 60\n hours = int(obj.seconds / 3600) % 24\n return '%d %02d:%02d:%02d' % (obj.days, hours, minutes, seconds)",
"def timedelta_to_string(td: datetime.timedelta) -> str:\n return str(td)",
"def timedel... | [
"0.74144894",
"0.73528314",
"0.7307537",
"0.7288194",
"0.72773784",
"0.7070185",
"0.6843803",
"0.68035924",
"0.6795394",
"0.6678191",
"0.66690946",
"0.65893155",
"0.6561124",
"0.65476084",
"0.6545894",
"0.6495852",
"0.64728785",
"0.6436285",
"0.64282244",
"0.6426938",
"0.6426... | 0.6994802 | 6 |
Returns datetime object. Function used to convert string to datetime object. If date_string is already a datetime object just returns it. | def _convert_date(date_string, s_format='%Y-%m-%d'):
if isinstance(date_string, str):
return datetime.strptime(date_string, s_format)
elif isinstance(date_string, datetime):
return date_string
else:
raise TypeError(date_string, 'is not a string or datetime object') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def datetime_from_string(date_string):\n try:\n return datetime.datetime.strptime(date_string, date_format)\n except Exception as e:\n print(\"Got exception parsing date {} with format {} {}\"\n .format(date_string, date_format, e))",
"def get_strptime(date_string: str) -> dt.datet... | [
"0.8040265",
"0.78717506",
"0.781886",
"0.77506477",
"0.7701899",
"0.7701899",
"0.76960564",
"0.7671397",
"0.7650383",
"0.76367456",
"0.7630254",
"0.7624333",
"0.75221795",
"0.7506938",
"0.7483182",
"0.74683553",
"0.74263096",
"0.7317703",
"0.73175424",
"0.727061",
"0.7242163... | 0.73399264 | 17 |
Summarize values of two defaultdicts. Function sumarize two defaultdicts values if they both have similar keys or just adds key and value if don't | def _update_default_dict(main, other):
for k, v in other.items():
main[k] += v | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def combine_and_count(a: dict, b: dict) -> dict:\r\n if not a:\r\n return b\r\n\r\n if not b:\r\n return a\r\n\r\n # check overlapping keys\r\n overlap_keys = [key for key in a if key in b]\r\n\r\n combined = a | b\r\n\r\n for key in overlap_keys:\r\n combined[key] += a[key]\... | [
"0.73068297",
"0.7038657",
"0.6947184",
"0.6885608",
"0.68774766",
"0.68165267",
"0.663558",
"0.65204126",
"0.64888173",
"0.6467172",
"0.6461064",
"0.6358043",
"0.63158417",
"0.6300903",
"0.6259106",
"0.62307036",
"0.6204824",
"0.6195062",
"0.616329",
"0.61411226",
"0.6138271... | 0.66640764 | 6 |
Overloaded equality operator for the class | def __eq__(self, other):
return str(self) == str(other) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __eq__(self, *args):\r\n pass",
"def __eq__(self, *args):\r\n pass",
"def __eq__(self, *args):\r\n pass",
"def __eq__(self, *args):\r\n pass",
"def __eq__(self, *args):\r\n pass",
"def __eq__(self, *args):\r\n pass",
"def __eq__(self, *args):\r\n pas... | [
"0.8396269",
"0.8396269",
"0.8396269",
"0.8396269",
"0.8396269",
"0.8396269",
"0.8396269",
"0.8396269",
"0.8396269",
"0.8396269",
"0.8396269",
"0.8360098",
"0.8360098",
"0.8360098",
"0.8360098",
"0.8360098",
"0.8360098",
"0.8360098",
"0.8360098",
"0.8360098",
"0.8360098",
"... | 0.0 | -1 |
Return whether the episode should terminate. Terminate if max_step steps have passed | def get_reward_termination(self, task, env):
done = env.current_step >= self.max_step
success = False
return self.reward, done, success | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _termination(self):\n if self._never_terminate:\n return False\n\n if self._counter >= self._max_steps:\n return True\n\n return self.is_fallen() # terminates automatically when in fallen state",
"def _check_episode_end_condition(self):\n vehicles = self._get_available_vehicles()\n... | [
"0.7581827",
"0.70965433",
"0.7037806",
"0.70207846",
"0.7004036",
"0.70007825",
"0.68862116",
"0.67529184",
"0.65158343",
"0.6487399",
"0.6444401",
"0.6424382",
"0.64164233",
"0.6408329",
"0.634589",
"0.6321121",
"0.63011533",
"0.62767315",
"0.6198808",
"0.616694",
"0.613246... | 0.0 | -1 |
Creates a new AnalysisRequest object | def __init__(self, request_id: str):
self.request_id = request_id | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def newRequest(self):\n return Request( )",
"def create_analysis(\n self,\n request: contact_center_insights.CreateAnalysisRequest = None,\n *,\n parent: str = None,\n analysis: resources.Analysis = None,\n retry: retries.Retry = gapic_v1.method.DEFAULT,\n ... | [
"0.6017797",
"0.59626925",
"0.59556144",
"0.5861292",
"0.57329386",
"0.569805",
"0.569805",
"0.569805",
"0.569805",
"0.569805",
"0.569805",
"0.569805",
"0.569805",
"0.569805",
"0.569805",
"0.569805",
"0.569805",
"0.569805",
"0.569805",
"0.569805",
"0.569805",
"0.569805",
... | 0.0 | -1 |
From group name, get group UUID | def _get_group_uuid(self, nova, name):
hints = {}
try:
groups = nova.server_groups.list()
for group in groups:
gname = getattr(group, 'name', '')
if name == gname:
hints['group'] = getattr(group, 'id', '')
except Excepti... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_group(self, group_name):\n\n return self._group[group_name]",
"def group_id(self) -> str:\n return pulumi.get(self, \"group_id\")",
"def group_id(self) -> str:\n return pulumi.get(self, \"group_id\")",
"def get_group_name(\n group_id: BSONObjectId,\n tkn: Token = Depends(from_a... | [
"0.6951393",
"0.68161505",
"0.68161505",
"0.67960966",
"0.6780895",
"0.67358655",
"0.6651917",
"0.6610393",
"0.6601873",
"0.6585751",
"0.6553352",
"0.65283877",
"0.6505381",
"0.6484785",
"0.6481061",
"0.64764214",
"0.64747655",
"0.63902175",
"0.63843095",
"0.63664514",
"0.635... | 0.64547014 | 17 |
Add headers to both force latest IE rendering engine or Chrome Frame, and also to cache the rendered page for 10 minutes. | def add_header(response):
response.headers['Cache-Control'] = 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0, max-age=0'
response.headers['Pragma'] = 'no-cache'
response.headers['Expires'] = '-1'
return response | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_header(response):\n response.headers['X-UA-Compatible'] = 'IE=Edge,chrome=1'\n response.headers['Cache-Control'] = 'public, max-age=60'\n return response",
"def add_header(response):\n response.headers['X-UA-Compatible'] = 'IE=Edge,chrome=1'\n response.headers['Cache-Control'] = 'public, m... | [
"0.8221727",
"0.8220911",
"0.8220911",
"0.8220911",
"0.8220911",
"0.81940746",
"0.8161616",
"0.8161616",
"0.8161616",
"0.8161616",
"0.8161616",
"0.8161616",
"0.8161616",
"0.8161616",
"0.8161616",
"0.8161616",
"0.8161616",
"0.8161616",
"0.8161616",
"0.8161616",
"0.8161616",
... | 0.72363365 | 38 |
Test create_app without passing test config. | def test_config():
# assert create_app().testing
assert create_app("testing", settings={
"TESTING": True,
"SQLALCHEMY_TRACK_MODIFICATIONS": False
}).testing | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_create_app():\n assert not create_app().testing\n assert create_app({'TESTING': True}).testing",
"def test_config():\n assert not sample.create_app().testing\n assert sample.create_app({\"TESTING\": True}).testing",
"def test_config():\n assert not create_app().testing\n assert creat... | [
"0.88498396",
"0.8132289",
"0.8124712",
"0.803595",
"0.8010812",
"0.76881677",
"0.76236284",
"0.7604287",
"0.7598619",
"0.75018466",
"0.73570627",
"0.73001164",
"0.7252014",
"0.7214372",
"0.7185277",
"0.7180016",
"0.71766704",
"0.71629363",
"0.71615326",
"0.71521",
"0.7067521... | 0.7561507 | 9 |
Called when the user specifies an intent for this skill | def on_intent(intent_request, session):
print("on_intent requestId=" + intent_request['requestId'] +
", sessionId=" + session['sessionId'])
intent = intent_request['intent']
intent_name = intent_request['intent']['name']
# Dispatch to your skill's intent handlers
if intent_name == "Rand... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def on_intent(intent_request, session):\n\n intent = intent_request['intent']\n intent_name = intent_request['intent']['name']\n\n # Dispatch to your skill's intent handlers\n\n if intent_name not in skillmap:\n intent_name = \"NullSkill\"\n\n if intent_name in skillmap:\n try:\n ... | [
"0.7143966",
"0.6956116",
"0.6949057",
"0.6905333",
"0.68928874",
"0.67641324",
"0.6754843",
"0.6722764",
"0.6720773",
"0.67161995",
"0.6699252",
"0.6691263",
"0.6670276",
"0.6645522",
"0.6642719",
"0.6638686",
"0.6607724",
"0.6594981",
"0.6575682",
"0.6570076",
"0.65620786",... | 0.6510799 | 27 |
The proportion of samples that have been lost. | def get_dropout_rate(data, sample_period=None):
if sample_period is None:
sample_period = get_sample_period(data)
N_SAMPLES = 100
if len(data) < N_SAMPLES:
raise TooFewSamplesError
index = _get_index(data)
assert(index[-1] > index[0])
duration = index[-1] - index[0]
n_expec... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_probability_loss(self):\n return sum(self._loss)/len(self._loss)",
"def GetProportion(self):\r\n\r\n return self.proportion",
"def winning_percentage(self):\n return float(len(self.wins))/len((self.wins+self.losses))",
"def get_loss(self):\n return self.loss / self.cnt",
... | [
"0.70687175",
"0.7034177",
"0.6614869",
"0.65577173",
"0.65507036",
"0.6548132",
"0.6483958",
"0.6473325",
"0.6423944",
"0.63829404",
"0.63606644",
"0.6357249",
"0.6311645",
"0.6290148",
"0.6276209",
"0.6270897",
"0.6252563",
"0.6250081",
"0.6250081",
"0.62403184",
"0.6224787... | 0.0 | -1 |
Find the Levenshtein distance between two Strings. Python version of Levenshtein distance method implemented in Java at | def levenshtein_distance(s: Union[bytes, str], t: Union[bytes, str]) -> int:
if s is None or t is None:
raise ValueError("Strings must not be None")
n = len(s)
m = len(t)
if n == 0:
return m
elif m == 0:
return n
if n > m:
tmp = s
s = t
t = tmp
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def levenshtein_distance(s1,s2):\n\n\t\tif len(s1) < len(s2):\n\t\t\treturn Searcher.levenshtein_distance(s2, s1)\n\n\t\t# len(s1) >= len(s2)\n\t\tif len(s2) == 0:\n\t\t\treturn len(s1)\n\n\t\tprevious_row = range(len(s2) + 1)\n\t\tfor i, c1 in enumerate(s1):\n\t\t\tcurrent_row = [i + 1]\n\t\t\tfor j, c2 in enumer... | [
"0.83297145",
"0.8327251",
"0.8115644",
"0.8046201",
"0.80442786",
"0.804366",
"0.8013871",
"0.7989521",
"0.7872376",
"0.7792652",
"0.7784483",
"0.77689654",
"0.7667645",
"0.7634608",
"0.76198804",
"0.7619774",
"0.7507073",
"0.7492066",
"0.7447954",
"0.7440172",
"0.7401199",
... | 0.7339986 | 22 |
Returns a Motion Cloud movie as a 3D matrix from a given envelope. It first creates a random phase spectrum, multiplies with the envelope and then it computes the inverse FFT to obtain the spatiotemporal stimulus. | def random_cloud(envelope, seed=None, impulse=False, events=None, do_amp=True, do_mask=False):
(N_X, N_Y, N_frame) = envelope.shape
amps = 1.
if impulse:
fx, fy, ft = get_grids(N_X, N_Y, N_frame)
phase = -2*np.pi*(N_X/2*fx + N_Y/2*fy + N_frame/2*ft)
F_events = np.exp(1j * phase)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def music(csi_corr, csi_target, Ntx, Nrx, d_tx, d_rx, t):\n\n In = 0\n s = phase_correction(csi_corr, csi_target)\n s_lin = (s[:, :, 0, t:t + 2].reshape(6, 2, order='F'))\n\n '''Compute the covariance matrix and the eigendecompositon'''\n R_hat = np.cov(s_lin)\n D, Q = ln.eig(R_hat)\n\n '''Sor... | [
"0.51922804",
"0.50948226",
"0.50926536",
"0.50071335",
"0.50039333",
"0.4938448",
"0.49112144",
"0.49058267",
"0.4886002",
"0.4854153",
"0.48483717",
"0.47905207",
"0.4748071",
"0.4738337",
"0.47351697",
"0.47317702",
"0.47304097",
"0.47149524",
"0.46758437",
"0.46521857",
"... | 0.5928419 | 0 |
This function prints and plots the confusion matrix. Normalization can be applied by setting `normalize=True`. | def plot_confusion_matrix(cm, classes, normalize=False, title='Confusion matrix', cmap=None):
if normalize:
# cm = cm.T
cm = cm.astype('float') / cm.sum(axis=1)[:, np.newaxis]
# cm = cm.T
print("Normalized confusion matrix")
else:
print('Confusion matrix, without normaliz... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_confusion_matrix(cm, classes=[0,1], normalize=False, title='Confusion matrix', print_matrix=False):\n\n if normalize:\n cm = cm.astype('float') / cm.sum(axis=1)[:, np.newaxis]\n print(\"Normalized confusion matrix\")\n else:\n print('Confusion matrix, without normalization')\n\n... | [
"0.8194862",
"0.80949175",
"0.8029915",
"0.8019153",
"0.79941195",
"0.7991258",
"0.7980955",
"0.7976606",
"0.79610753",
"0.79590565",
"0.79378676",
"0.7934962",
"0.7934504",
"0.79313844",
"0.7926313",
"0.7924577",
"0.79241234",
"0.7923211",
"0.7923023",
"0.7921931",
"0.791787... | 0.7869866 | 39 |
Return True if the queen at column c clashes with any queen to its left. | def col_clashes(bs, c):
for i in range(c): # Look at all columns to the left of c
if share_diagonal(i, bs[i], c, bs[c]):
return True
return False # No clashes - col c has a safe placement | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isfree(col,queens):\n if col in queens:\n return False\n elif any([ abs(col-col1)==len(queens)-index for index,col1 in enumerate(queens)]):\n #c[r]==c[j]; r-j==c[r]-c[j]; r-j==c[j]-c[r]\n # col is the colomn to check; len(queens) just be the row index of col, dont subtract 1\n ... | [
"0.77055407",
"0.72922397",
"0.7145801",
"0.70153964",
"0.6985228",
"0.6902115",
"0.66958386",
"0.65576535",
"0.6551649",
"0.6548673",
"0.6523149",
"0.6523149",
"0.6522317",
"0.6519715",
"0.65155363",
"0.6512403",
"0.6512403",
"0.65036315",
"0.64987516",
"0.6493879",
"0.64932... | 0.6501785 | 18 |
Initialize the matplotlib figure and GridPlot object. | def __init__(
self,
*,
fig: Optional[Figure] = None,
axes: Optional[Union[np.ndarray, Axes]] = None,
y_names: List[str],
layout: Optional[Tuple[int, int]] = None,
figsize: Optional[Tuple[int, int]] = None,
):
if isinstance(y_names, str):
raise TypeError("`y_names` ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_plot(self):\n self.dpi = 100\n self.fig = Figure((5.0, 5.0), dpi = self.dpi)\n\n self.main_plot = self.fig.add_subplot(111)\n self.main_plot.set_axis_bgcolor('black')\n self.main_plot.set_title('Dynamic venous flow view', size = 12)\n\n pylab.setp(self.main_plot.g... | [
"0.7536752",
"0.7196492",
"0.7190278",
"0.71868855",
"0.71805996",
"0.70625436",
"0.70282066",
"0.70282066",
"0.69899327",
"0.69891554",
"0.6923905",
"0.68701833",
"0.6838461",
"0.6760895",
"0.6759643",
"0.67508215",
"0.6697638",
"0.66482455",
"0.66034454",
"0.6595117",
"0.65... | 0.6142369 | 41 |
Return a grid of subplots (always a 2D ndarray). | def axes(self) -> np.ndarray: # array[Axes]
return self._axes | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def subplots(\n self,\n nrows=1,\n ncols=1,\n width_ratios=None,\n height_ratios=None,\n wspace=None,\n hspace=None,\n ):\n if width_ratios is not None and len(width_ratios) != ncols:\n raise ValueError(\n \"Expected the given num... | [
"0.7304047",
"0.7254653",
"0.72422755",
"0.7179701",
"0.71366996",
"0.7044677",
"0.6823591",
"0.6676199",
"0.6587275",
"0.64933026",
"0.6481466",
"0.6339463",
"0.633844",
"0.63063467",
"0.6275917",
"0.62279123",
"0.6191162",
"0.61514986",
"0.61210155",
"0.61203027",
"0.611277... | 0.0 | -1 |
Return a flattened ndarray of inactive subplots, whose length equals `prod(self.axes.shape) self.n_plots`. | def axes_inactive(self) -> np.ndarray:
return self.axes.flat[self.n_plots:] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def axes_active(self) -> np.ndarray: # array[Axes]\n return self.axes.flat[:self.n_plots]",
"def trim_axes(axes, N):\n if N>1:\n axes = axes.flat\n for ax in axes[N:]:\n ax.remove()\n return axes[:N]\n else:\n return [axes]",
"def get_plots(self):\n retur... | [
"0.72921747",
"0.59275514",
"0.5794449",
"0.56709194",
"0.5659157",
"0.55580115",
"0.5506378",
"0.549707",
"0.5492854",
"0.5442966",
"0.5355067",
"0.5355067",
"0.5304853",
"0.5271664",
"0.5269523",
"0.52568686",
"0.5246508",
"0.5213127",
"0.52067137",
"0.5192821",
"0.5182257"... | 0.7877082 | 0 |
Test that env settings can be retrieved, or if not then a default value is returned. | def test_get_setting(monkeypatch):
random_key = uuid()
default_value, actual_value = "foo", "bar"
assert helpers.get_setting(random_key, default_value) == default_value
monkeypatch.setenv(random_key, actual_value)
assert helpers.get_setting(random_key, default_value) == actual_value | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get(self, env: yaenv.Env):\n assert env.get('BLANK', 'default') == ''\n assert env.get('MISSING') is None\n assert env.get('MISSING', 'default') == 'default'",
"def env(*vars, **kwargs):\n for v in vars:\n value = os.environ.get(v)\n if value:\n return va... | [
"0.70710206",
"0.7011443",
"0.6983878",
"0.69824255",
"0.69612914",
"0.69612914",
"0.6923273",
"0.6879512",
"0.68406063",
"0.6804731",
"0.6786106",
"0.67596006",
"0.6723182",
"0.67197627",
"0.6629905",
"0.6599743",
"0.6583553",
"0.6572079",
"0.65530443",
"0.6550808",
"0.65293... | 0.6491509 | 25 |
Test that settings are correctly loaded into the Flask app. | def test_app_settings(monkeypatch):
cache_default_timeout = randint(100, 1200)
cache_type = choice(["null", "simple", "redis"])
flask_secret_key = token_urlsafe(16)
testing = bool(randint(0, 1))
monkeypatch.setenv("CACHE_DEFAULT_TIMEOUT", str(cache_default_timeout))
monkeypatch.setenv("CACHE_TYP... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_test_config(self):\r\n\r\n app = create_app('movieapp.settings.TestConfig')\r\n\r\n assert app.config['DEBUG'] is True\r\n assert app.config['SQLALCHEMY_ECHO'] is True\r\n assert app.config['CACHE_TYPE'] == 'null'",
"def test_app_is_testing(self):\n self.assertFalse(ap... | [
"0.75946486",
"0.75625217",
"0.7519716",
"0.74718064",
"0.7446341",
"0.72706926",
"0.71636003",
"0.70559764",
"0.7020328",
"0.698516",
"0.698516",
"0.6969537",
"0.6964495",
"0.69616747",
"0.69612527",
"0.69421375",
"0.69421375",
"0.69185895",
"0.69110566",
"0.6893109",
"0.687... | 0.7779113 | 0 |
Returns starting state of the board. | def initial_state():
return [[EMPTY, EMPTY, EMPTY],
[EMPTY, EMPTY, EMPTY],
[EMPTY, EMPTY, EMPTY]] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start_state(self):\r\n return np.zeros(self.board_size, dtype=np.int8)",
"def start_state():\n return chess.Board()",
"def startingState(self):\n # Returns starting position and 4 false because no corners are visited yet\n return (self.startingPosition, (False, False, False, False))... | [
"0.8081514",
"0.7890486",
"0.7534929",
"0.72789717",
"0.72789717",
"0.72262055",
"0.72262055",
"0.72262055",
"0.72262055",
"0.72262055",
"0.72262055",
"0.72262055",
"0.72262055",
"0.72262055",
"0.72262055",
"0.72262055",
"0.72262055",
"0.72262055",
"0.72262055",
"0.72262055",
... | 0.0 | -1 |
Returns player who has the next turn on a board. | def player(board):
#X ALWAYS gets first move, alternates with each additional move
curr_moves = actions(board)
if (board == initial_state()):
return X
if(len(curr_moves) % 2 == 0):
return O
else:
return X | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def next_player(board, prev_player):\n opp = Othello.opponent(prev_player)\n if Othello.any_legal_move(opp, board):\n return opp\n elif Othello.any_legal_move(prev_player, board):\n return prev_player\n return None",
"def next_player(self,board, prev_player):\r\n... | [
"0.7911148",
"0.7521969",
"0.74204457",
"0.73687756",
"0.71954805",
"0.69775087",
"0.69621766",
"0.69253695",
"0.69208723",
"0.69010353",
"0.6845991",
"0.6841043",
"0.6838282",
"0.68265843",
"0.67751175",
"0.67751175",
"0.6769739",
"0.6713109",
"0.67060393",
"0.66561204",
"0.... | 0.6521695 | 26 |
Returns the optimal action for the current player on the board. | def minimax(board):
current_player = player(board)
if(terminal(board)):
return None
if (board == initial_state()):
x = random.choice([0, 2])
y = random.choice([0, 2])
return(x, y)
if(current_player == X):
v = -math.inf
for action in actions(board):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_best_action(self):\n if self.bestAction is None:\n self.calculate_best_action()\n return self.bestAction",
"def getAction(self, gameState: GameState):\n _max = float(\"-inf\")\n action = None\n for move in gameState.getLegalActions(0):\n util = min... | [
"0.7766856",
"0.76323676",
"0.75855315",
"0.75285065",
"0.75175256",
"0.74667144",
"0.7460485",
"0.74263537",
"0.7416421",
"0.73943585",
"0.7375846",
"0.7333894",
"0.73147565",
"0.7306611",
"0.7284639",
"0.72650313",
"0.72650313",
"0.7250975",
"0.72331834",
"0.7203267",
"0.71... | 0.0 | -1 |
Get the request structure for list of entities. | def list_to_request(entities: Sequence[Union[Entity, StepCollection]]) -> List[RequestType]:
request_dicts = []
for entity in entities:
if isinstance(entity, Entity):
request_dicts.append(entity.to_request())
elif isinstance(entity, StepCollection):
request_dicts.extend(e... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getRequestList(self):\n\n result = RequestsDAO().getRequests()\n mapped_result = []\n\n if not result:\n return jsonify(Error=\"NOT FOUND\"), 404\n\n else:\n for r in result:\n mapped_result.append(self.mapToUserRequestDict(r))\n\n ret... | [
"0.6224929",
"0.6217253",
"0.61349475",
"0.6079711",
"0.60549563",
"0.5875875",
"0.5855828",
"0.58397305",
"0.5826141",
"0.58037436",
"0.58037436",
"0.58037436",
"0.57790506",
"0.57790506",
"0.5772978",
"0.5772978",
"0.5713536",
"0.5696873",
"0.562451",
"0.56143486",
"0.55720... | 0.7075147 | 0 |
Open the input word list file and return the file object. If input_file is None, then we just return sys.stdin. | def open_input_file(input_file):
if input_file:
if not os.path.isfile(input_file):
sys.stderr.write(
"ERROR! Input file (%s) is not a normal file.\n" % input_file)
sys.exit(1)
try:
return codecs.open(input_file, "r", "utf8")
except:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def openInputFile(infile, *args):\n if infile is None:\n logging.info(\"Reading input from STDIN\")\n return sys.stdin\n\n if isinstance(infile, str):\n if urlRE.match(infile):\n import urllib2\n return urllib2.urlopen(infile)\n if len(infile)>3 and infile[-3... | [
"0.69666266",
"0.69087464",
"0.66441137",
"0.6496703",
"0.6385994",
"0.63825643",
"0.62801826",
"0.6275751",
"0.6205489",
"0.60920316",
"0.6043968",
"0.6026387",
"0.597928",
"0.59514",
"0.59138834",
"0.58076197",
"0.5806814",
"0.5700559",
"0.56787676",
"0.56601083",
"0.563108... | 0.75980544 | 0 |
Takes as input a ND tensor, where N >= 3. It downscales the input video by the specified factor, by keeping only the maximum value of nonoverlapping patches of size (ds[0],ds[1],ds[2]) (time, height, width) | def max_pool_3d(input, ds, ignore_border=False):
if input.ndim < 3:
raise NotImplementedError('max_pool_3d requires a dimension >= 3')
# extract nr dimensions
vid_dim = input.ndim
# max pool in two different steps, so we can use the 2d implementation of
# downsamplefactormax. First maxpool... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def upscale(x, n):\n if n == 1:\n return x\n x_shape = tf.shape(x)\n height, width = x_shape[1], x_shape[2]\n return tf.image.resize_nearest_neighbor(x, [n * height, n * width])\n # return tf.batch_to_space(tf.tile(x, [n**2, 1, 1, 1]), [[0, 0], [0, 0]], n)",
"def max_pool_2d(input, ds, ignore_border=Fals... | [
"0.58566093",
"0.5847041",
"0.5815044",
"0.57028204",
"0.5666426",
"0.56636876",
"0.54923755",
"0.54436594",
"0.5427133",
"0.5388685",
"0.5376357",
"0.5370685",
"0.53169405",
"0.52993727",
"0.5272983",
"0.5270929",
"0.5267408",
"0.5251892",
"0.52470976",
"0.5237011",
"0.51959... | 0.6798123 | 0 |
Disables the LED matrix. All LED's are switched off. | def disable():
ret = _LIB.led_matrix_click_disable()
if ret < 0:
raise Exception("led matrix click disable failed") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def turn_off(self):\n print(\"Turning the lights off\")\n self.led.all_off()\n self.client.publish(STATE_TOPIC, OFF) #publish",
"def _led_disable():\n # type: () -> None\n GPIO.output(LED_nOE, GPIO.HIGH)",
"def turn_off(self):\n GPIO.output(self.gpio, False) # turn off light"... | [
"0.74292153",
"0.7150311",
"0.71218115",
"0.7097676",
"0.70667136",
"0.6875131",
"0.6841519",
"0.6801441",
"0.679131",
"0.67708206",
"0.6768421",
"0.67139024",
"0.6702695",
"0.66928625",
"0.6660404",
"0.66271096",
"0.66114485",
"0.65515655",
"0.654366",
"0.6529631",
"0.652925... | 0.78311884 | 0 |
Get the cluster main label | def get_label (self):
most_frequent = None
frequences = {}
most_frequent = None
for label in self._labels:
if frequences.has_key(label):
frequences[label] += 1
else:
frequences[label] = 0
freq = None
for l... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_label(self):\n return self.job[self.label_key]",
"def _get_label(self):\n return self.label",
"def get_cluster_name(cls):\n\n mid = Machineid()\n if mid.is_sps_cluster:\n return cls.SPS\n if mid.is_spts_cluster:\n return cls.SPTS\n if mid.... | [
"0.71604896",
"0.7156659",
"0.711994",
"0.70542175",
"0.70542175",
"0.70542175",
"0.70542175",
"0.702552",
"0.7006214",
"0.69977146",
"0.69818366",
"0.6951561",
"0.6949971",
"0.6949292",
"0.6944529",
"0.6944529",
"0.6944529",
"0.6944529",
"0.6944529",
"0.6944529",
"0.6944529"... | 0.0 | -1 |
Applies `op` to the `flat_values` of one or more RaggedTensors. Replaces any `RaggedTensor` in `args` or `kwargs` with its `flat_values` tensor (which collapses all ragged dimensions), and then calls `op`. Returns a `RaggedTensor` that is constructed from the input `RaggedTensor`s' `nested_row_splits` and the value ret... | def map_flat_values(op, *args, **kwargs):
# Replace RaggedTensors with their values; and collect the partitions tensors
# from each RaggedTensor.
partition_lists = []
flat_values_nrows = []
inner_args = _replace_ragged_with_flat_values(args, partition_lists,
fla... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _replace_ragged_with_flat_values(value, partition_lists, flat_values_nrows):\n # Base case\n if ragged_tensor.is_ragged(value):\n value = ragged_tensor.convert_to_tensor_or_ragged_tensor(value)\n partition_lists.append(value._nested_row_partitions) # pylint: disable=protected-access\n nrows = tenso... | [
"0.58905184",
"0.50941586",
"0.5034008",
"0.50086904",
"0.48855546",
"0.47923228",
"0.4791662",
"0.4785154",
"0.47354266",
"0.47063193",
"0.47051123",
"0.4682232",
"0.4642244",
"0.4612512",
"0.46040416",
"0.4579073",
"0.45764583",
"0.45676824",
"0.45488873",
"0.45210654",
"0.... | 0.8251573 | 0 |
Replace RaggedTensors with their flat_values, and record their partitions. Returns a copy of `value`, with any nested `RaggedTensor`s replaced by their `flat_values` tensor. Looks inside lists, tuples, and dicts. Appends each `RaggedTensor`'s `RowPartition`s to `partition_lists`. | def _replace_ragged_with_flat_values(value, partition_lists, flat_values_nrows):
# Base case
if ragged_tensor.is_ragged(value):
value = ragged_tensor.convert_to_tensor_or_ragged_tensor(value)
partition_lists.append(value._nested_row_partitions) # pylint: disable=protected-access
nrows = tensor_shape.di... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def map_flat_values(op, *args, **kwargs):\n # Replace RaggedTensors with their values; and collect the partitions tensors\n # from each RaggedTensor.\n partition_lists = []\n flat_values_nrows = []\n inner_args = _replace_ragged_with_flat_values(args, partition_lists,\n ... | [
"0.6881033",
"0.61487126",
"0.57602715",
"0.5700375",
"0.5536173",
"0.5507936",
"0.53469265",
"0.5063189",
"0.5023042",
"0.50201434",
"0.5018325",
"0.49882728",
"0.49735722",
"0.4941061",
"0.48811442",
"0.48353505",
"0.47892997",
"0.4760579",
"0.47469118",
"0.47372139",
"0.47... | 0.8572067 | 0 |
The device against which the job was run. | def device(self):
return self.broker.device(**{"JobDetailID": self.JobDetailID}) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def device(self):\n return self._vars[0].device",
"def device(self):\n return next(self.parameters()).device",
"def device(self):\n return next(self.parameters()).device",
"def device(self):\n return next(self.parameters()).device",
"def device(self):\n return next(self.param... | [
"0.83943903",
"0.83879054",
"0.83879054",
"0.83879054",
"0.83879054",
"0.83879054",
"0.82321364",
"0.8225333",
"0.8215564",
"0.8180785",
"0.80171067",
"0.8003143",
"0.7923292",
"0.7919176",
"0.79105085",
"0.7863221",
"0.78355986",
"0.76112944",
"0.75542474",
"0.7546913",
"0.7... | 0.8198492 | 9 |
The device against which the job was run. | def infradevice(self):
return self.broker.infradevice(**{"JobDetailID": self.JobDetailID}) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def device(self):\n return self._vars[0].device",
"def device(self):\n return next(self.parameters()).device",
"def device(self):\n return next(self.parameters()).device",
"def device(self):\n return next(self.parameters()).device",
"def device(self):\n return next(self.param... | [
"0.83943903",
"0.83879054",
"0.83879054",
"0.83879054",
"0.83879054",
"0.83879054",
"0.82321364",
"0.8225333",
"0.8215564",
"0.8198492",
"0.8180785",
"0.80171067",
"0.8003143",
"0.7923292",
"0.7919176",
"0.79105085",
"0.7863221",
"0.78355986",
"0.76112944",
"0.75542474",
"0.7... | 0.661275 | 87 |
Application of the adjoint operator to a vector. Computes (A^)y for a given vector y from the codomain. | def adj(self, y):
pass | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def adot(a, b): \n return sp.inner(a.ravel().conj(), b.ravel())",
"def adjoint(self) -> 'MultiVector':\n # The multivector created by reversing all multiplications\n return self._newMV(self.layout.adjoint_func(self.value))",
"def vec_dot(x, y):\r\n return sum(a * b for a, b in zip(x, y))",... | [
"0.6331265",
"0.60137206",
"0.5912388",
"0.59052134",
"0.58590674",
"0.5856081",
"0.5846921",
"0.57862145",
"0.5785192",
"0.57703084",
"0.57580215",
"0.5710117",
"0.57094914",
"0.5647398",
"0.5644571",
"0.5638333",
"0.5636922",
"0.562523",
"0.5611404",
"0.5597268",
"0.5545397... | 0.5282028 | 77 |
Calculate the great circle distance between two points on the earth (specified in decimal degrees) | def haversine(x):
# convert decimal degrees to radians
for i in x:
if i == None:
return None
lat1, lon1, lat2, lon2 = list(map(np.radians, [x[0], x[1], x[2], x[3]]))
# haversine formula
dlon = lon2 - lon1
dlat = lat2 - lat1
a = np.sin(dlat / 2) ** 2 + np.cos(lat1) * np.c... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def great_circle(lat_1, long_1, lat_2, long_2):\n long_1 = m.radians(long_1)\n lat_1 = m.radians(lat_1)\n long_2 = m.radians(long_2)\n lat_2 = m.radians(lat_2)\n\n d = 2 * 6367.45 * m.asin(\n m.sqrt(haversine(lat_2 - lat_1)\n + m.cos(lat_1)*m.cos(lat_2) *\n haversine(long... | [
"0.81450045",
"0.7863265",
"0.76322985",
"0.76064754",
"0.75978696",
"0.75965863",
"0.75944835",
"0.75720793",
"0.75630087",
"0.7555095",
"0.7528691",
"0.7517629",
"0.7492963",
"0.7467739",
"0.7452678",
"0.7434477",
"0.73914117",
"0.7357736",
"0.73484355",
"0.73318124",
"0.73... | 0.0 | -1 |
Method getting product's nutriscore ID. | def get_nutriscore(self):
db.execute("SELECT nutriscore_id FROM Product WHERE id = %s",
(self.id,))
self.nutriscore = db.fetch()[0] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def product_id(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"product_id\")",
"def product_id(self) -> pulumi.Input[str]:\n return pulumi.get(self, \"product_id\")",
"def product_id(self):\n return self._product_id",
"def product_id(self):\n return self._product_id",
"... | [
"0.77723044",
"0.7449794",
"0.74374616",
"0.74374616",
"0.74374616",
"0.74374616",
"0.732073",
"0.70184064",
"0.69368744",
"0.6890182",
"0.67340386",
"0.65285313",
"0.6444514",
"0.6386144",
"0.6330298",
"0.6330298",
"0.6238861",
"0.6213666",
"0.62134933",
"0.6209786",
"0.6109... | 0.74196374 | 6 |
Get the default location for a thing. | def default_location(self, thing):
if isinstance(thing, Agent):
return (1, 1)
else:
get_rand = lambda arg: random.choice(range(1, arg-1))
while True:
xloc, yloc = (get_rand(self.width), get_rand(self.height))
if (1, 1) == (xloc, yloc):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def default_location(self, thing):\n return None",
"def default_location(self, thing):\n return None",
"def default_location(self, thing):\n return None",
"def default_location(self, thing):\n return random.choice([loc_A, loc_B])",
"def default_location(self, thing):\n re... | [
"0.8686049",
"0.8686049",
"0.8686049",
"0.8045653",
"0.8045653",
"0.7563369",
"0.73235804",
"0.67967564",
"0.67370534",
"0.6690137",
"0.6638082",
"0.6621053",
"0.66186607",
"0.66186607",
"0.66186607",
"0.6617872",
"0.6578346",
"0.65268564",
"0.64841",
"0.6444653",
"0.64130384... | 0.7032851 | 7 |
Compute the output height of a torch.nn.Conv2d, assuming NCHW format. This requires knowing the input height. Because NCHW format makes this very easy to mix up, this is a seperate function from conv2d_output_height. It also works on torch.nn.MaxPool2d. This function implements the formula described in the torch.nn.Con... | def output_height_2d(layer, height):
assert isinstance(layer, (torch.nn.Conv2d, torch.nn.MaxPool2d))
padding = _value_at_axis(layer.padding, 0)
dilation = _value_at_axis(layer.dilation, 0)
kernel_size = _value_at_axis(layer.kernel_size, 0)
stride = _value_at_axis(layer.stride, 0)
return math.flo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def conv2d_output_shape(height, width, filter_height, filter_width, out_channels, stride):\n return (out_channels, ((height - filter_height) / stride + 1), ((width - filter_width) / stride + 1))",
"def _output_size_conv2d(conv, size):\n o_size = np.array(size) + 2 * np.array(conv.padding)\n o_size -= np... | [
"0.67586565",
"0.6545094",
"0.65356714",
"0.63673604",
"0.6244041",
"0.6244041",
"0.6170728",
"0.6155149",
"0.6129938",
"0.5961064",
"0.59450907",
"0.59450907",
"0.59450907",
"0.5940992",
"0.59360725",
"0.5914094",
"0.59030193",
"0.5870342",
"0.57871354",
"0.5761146",
"0.5743... | 0.7067752 | 0 |
Compute the output width of a torch.nn.Conv2d, assuming NCHW format. This requires knowing the input width. Because NCHW format makes this very easy to mix up, this is a seperate function from conv2d_output_height. It also works on torch.nn.MaxPool2d. This function implements the formula described in the torch.nn.Conv2... | def output_width_2d(layer, width):
assert isinstance(layer, (torch.nn.Conv2d, torch.nn.MaxPool2d))
padding = _value_at_axis(layer.padding, 1)
dilation = _value_at_axis(layer.dilation, 1)
kernel_size = _value_at_axis(layer.kernel_size, 1)
stride = _value_at_axis(layer.stride, 1)
return math.floor... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _output_size_conv2d(conv, size):\n o_size = np.array(size) + 2 * np.array(conv.padding)\n o_size -= np.array(conv.dilation) * (np.array(conv.kernel_size) - 1)\n o_size -= 1\n o_size = o_size / np.array(conv.stride) + 1\n return np.floor(o_size)",
"def conv2d_output_shape(height, width, filter_... | [
"0.71252257",
"0.6865731",
"0.6858309",
"0.6858309",
"0.65181834",
"0.6498349",
"0.649154",
"0.64886934",
"0.6349364",
"0.6312991",
"0.6306007",
"0.6292105",
"0.62589157",
"0.6207056",
"0.61827743",
"0.6178904",
"0.6136974",
"0.61354136",
"0.6117296",
"0.6117296",
"0.6117296"... | 0.71432614 | 0 |
Return a sample, sampled from this TanhNormal Distribution. | def sample(self, sample_shape=torch.Size()):
with torch.no_grad():
return self.rsample(sample_shape=sample_shape) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_sample(self):\n mu = self._get_mean()\n sample = self.random.normal(mu)\n return sample",
"def _get_sample(self):\n mu = self._get_mean().reshape((1, self.out_dim))\n sigma = self.variables[\"s\"]\n sample = self.random.normal(mu, sigma)\n sample = sample... | [
"0.7998289",
"0.7842812",
"0.7748903",
"0.7524445",
"0.7492324",
"0.73508835",
"0.72046816",
"0.7183297",
"0.71665144",
"0.69742036",
"0.6967657",
"0.6936659",
"0.6928369",
"0.689816",
"0.689816",
"0.689816",
"0.689816",
"0.689816",
"0.6850898",
"0.6827285",
"0.67973536",
"... | 0.6278723 | 69 |
Return a sample, sampled from this TanhNormal Distribution. | def rsample(self, sample_shape=torch.Size()):
z = self._normal.rsample(sample_shape)
return torch.tanh(z) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_sample(self):\n mu = self._get_mean()\n sample = self.random.normal(mu)\n return sample",
"def _get_sample(self):\n mu = self._get_mean().reshape((1, self.out_dim))\n sigma = self.variables[\"s\"]\n sample = self.random.normal(mu, sigma)\n sample = sample... | [
"0.7998289",
"0.7842812",
"0.7748903",
"0.7524445",
"0.7492324",
"0.73508835",
"0.72046816",
"0.7183297",
"0.71665144",
"0.69742036",
"0.6967657",
"0.6936659",
"0.6928369",
"0.689816",
"0.689816",
"0.689816",
"0.689816",
"0.689816",
"0.6850898",
"0.6827285",
"0.67973536",
"... | 0.0 | -1 |
Return a sample, sampled from this TanhNormal distribution. Returns the sampled value before the tanh transform is applied and the sampled value with the tanh transform applied to it. | def rsample_with_pre_tanh_value(self, sample_shape=torch.Size()):
z = self._normal.rsample(sample_shape)
return z, torch.tanh(z) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sample(self, return_pretanh_value=False):\n z = self.gmm.sample().detach()\n\n if return_pretanh_value:\n return torch.tanh(z), z\n else:\n return torch.tanh(z)",
"def _get_sample(self):\n mu = self._get_mean()\n sample = self.random.normal(mu)\n ... | [
"0.7045227",
"0.6643862",
"0.661791",
"0.6559539",
"0.64037824",
"0.63933057",
"0.6303293",
"0.62149936",
"0.61520743",
"0.61195123",
"0.60475385",
"0.6021716",
"0.60064816",
"0.59601545",
"0.59327734",
"0.59178597",
"0.58999103",
"0.5853273",
"0.58399326",
"0.58273923",
"0.5... | 0.684629 | 1 |
Returns the CDF at the value. Returns the cumulative density/mass function evaluated at `value` on the underlying normal distribution. | def cdf(self, value):
return self._normal.cdf(value) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cdf(self, value):\n cdf = torch.where(\n value < 1., \n self.base.cdf(value), \n torch.ones_like(value) # all of the mass\n )\n cdf = torch.where(value < 0., torch.zeros_like(cdf), cdf)\n return cdf",
"def cdf(self, value=None):\n ... | [
"0.81373006",
"0.81329435",
"0.7053435",
"0.6949887",
"0.6798191",
"0.6798191",
"0.6743553",
"0.67353845",
"0.66956973",
"0.6630497",
"0.660014",
"0.65874225",
"0.6499921",
"0.6458189",
"0.64000773",
"0.63886636",
"0.6379384",
"0.6256264",
"0.62064976",
"0.61630267",
"0.60968... | 0.856838 | 0 |
Returns the icdf function evaluated at `value`. Returns the icdf function evaluated at `value` on the underlying normal distribution. | def icdf(self, value):
return self._normal.icdf(value) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cdf(self, value):\n return self._normal.cdf(value)",
"def icdf(self, value, avg=False):\n\n if not self.fp_init:\n self._init_full_props()\n if isinstance(value, float):\n value = t.tensor(value).to(dtype = self.dtype, device=self.device)#.unsqueeze(-1)#.unsqueeze(-... | [
"0.72333896",
"0.66934586",
"0.664089",
"0.65650505",
"0.65522",
"0.63574195",
"0.62464124",
"0.62368834",
"0.6186738",
"0.59597504",
"0.5895068",
"0.58603346",
"0.5838809",
"0.5797628",
"0.5797428",
"0.57342076",
"0.5686313",
"0.56025434",
"0.55522335",
"0.55234224",
"0.5523... | 0.7998645 | 0 |
Construct a new TanhNormal distribution from a normal distribution. | def _from_distribution(cls, new_normal):
new = cls(torch.zeros(1), torch.zeros(1))
new._normal = new_normal
return new | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def he_normal(seed=None):\n # pylint: disable=line-too-long\n # pylint: enable=line-too-long\n return lambda shape, dtype, batch_ndims=0: _initialize( # pylint: disable=g-long-lambda\n shape, dtype, batch_ndims,\n scale=2., mode='fan_in', distribution='truncated_normal', seed=seed)",
"def _base_dis... | [
"0.6454655",
"0.6355096",
"0.6289681",
"0.62268305",
"0.6169032",
"0.6101354",
"0.60796565",
"0.60796565",
"0.6068122",
"0.6049477",
"0.6044005",
"0.6040817",
"0.6035759",
"0.60352576",
"0.59746313",
"0.5857746",
"0.5842183",
"0.58302766",
"0.5819444",
"0.5812787",
"0.5802669... | 0.6965061 | 0 |
Returns a new TanhNormal distribution. (or populates an existing instance provided by a derived class) with batch dimensions expanded to `batch_shape`. This method calls | def expand(self, batch_shape, _instance=None):
new_normal = self._normal.expand(batch_shape, _instance)
new = self._from_distribution(new_normal)
return new | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __call__(self, *args, **kwargs):\n return tfd.Normal(loc=self.mu, scale=tf.eye(self.size)), self.mu",
"def _get_batch(self, batch_size=1):\n\t\t# Build samples from a normal distribution with zero mean\n\t\t# and variance of one.\n\t\trandom = torch.randn(batch_size)\n\t\tx = self._make_features(random)\n... | [
"0.66755587",
"0.6333017",
"0.6261871",
"0.6244066",
"0.61328435",
"0.59586996",
"0.58858806",
"0.5879122",
"0.586914",
"0.5858788",
"0.58411443",
"0.58339906",
"0.5766042",
"0.573976",
"0.5728738",
"0.57225204",
"0.57009685",
"0.5699366",
"0.5611609",
"0.5609239",
"0.5575837... | 0.68449855 | 0 |
Returns the global device that torch.Tensors should be placed on. | def global_device():
global _DEVICE
return _DEVICE | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def device():\n return torch.device('cuda:0' if torch.cuda.is_available() else 'cpu')",
"def get_default_device():\n device = torch.device(\"cuda\" if torch.cuda.is_available() else \"cpu\")\n return device",
"def get_device():\n import torch\n\n if torch.cuda.is_available():\n ... | [
"0.7927794",
"0.790405",
"0.78334385",
"0.7824908",
"0.7824908",
"0.7824908",
"0.7824908",
"0.7808479",
"0.77662355",
"0.7717447",
"0.76212174",
"0.7361139",
"0.7326816",
"0.73079854",
"0.7287433",
"0.7227104",
"0.72168684",
"0.7199564",
"0.7069759",
"0.70641893",
"0.7060081"... | 0.7698877 | 10 |
Append single transition to the current context. | def update_context(self, timestep):
o = torch.as_tensor(timestep.observation[None, None, ...], device=global_device()).float()
a = torch.as_tensor(timestep.action[None, None, ...], device=global_device()).float()
r = torch.as_tensor(np.array([timestep.reward])[None, None, ...], device=global_dev... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add(self, state, action, reward, next_state, done):\n e = self.transition(state, action, reward, next_state, done)\n self.buffer.append(e)",
"def push(self, transition, instance=0):\n self.memory.put(transition)",
"def push(self, transition, *args, **kwargs):\n raise NotImplemen... | [
"0.67034715",
"0.64400506",
"0.6407242",
"0.6395189",
"0.6333643",
"0.6177075",
"0.61750966",
"0.6168164",
"0.61126125",
"0.6044615",
"0.6044615",
"0.58084846",
"0.5725783",
"0.5719482",
"0.56473804",
"0.56341976",
"0.56253994",
"0.5618466",
"0.56035244",
"0.5594931",
"0.5588... | 0.0 | -1 |
Sample action from the policy, conditioned on the task embedding. | def get_action(self, obs):
z = self.z
obs = torch.as_tensor(obs[None], device=global_device()).float()
obs_in = torch.cat([obs, z], dim=1)
action, info = self._policy.get_action(obs_in)
return action, info | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start_step_policy(self, observation):\n log.info(\"Random action\")\n _ = observation\n action = self.env.action_space.sample()\n return action",
"def sampleAction(self, game_info):\n pState = torch.Tensor(game_info['p_state'])\n legalActions = torch.Tensor(game_info... | [
"0.7224492",
"0.7145083",
"0.712341",
"0.6978279",
"0.68931067",
"0.68927395",
"0.68423647",
"0.67885727",
"0.6771046",
"0.670903",
"0.667441",
"0.665535",
"0.66477776",
"0.65515167",
"0.6511037",
"0.64361537",
"0.6433321",
"0.6410071",
"0.64010894",
"0.6392426",
"0.6385707",... | 0.0 | -1 |
Numpy arrays to PyTorch tensors. | def np_to_torch(array):
tensor = torch.from_numpy(array)
if tensor.dtype != torch.float32:
tensor = tensor.float()
return tensor | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def np2tensor(array, device=None):\n tensor = torch.from_numpy(array)\n return tensor",
"def transpose_to_pytorch(array: np.ndarray) -> np.ndarray:\n shape = (\n DIM_NN['batch'],\n DIM_NN['channels'],\n DIM_NN['depth'],\n DIM_NN['height'],\n DIM_NN['width'],\n )\n ... | [
"0.746771",
"0.7162682",
"0.7031392",
"0.69994986",
"0.672084",
"0.654441",
"0.65428984",
"0.6538737",
"0.6412483",
"0.6412483",
"0.6412483",
"0.6394862",
"0.6394862",
"0.6331952",
"0.63312197",
"0.63106656",
"0.62869483",
"0.6254502",
"0.6227219",
"0.62162215",
"0.6191168",
... | 0.7657822 | 0 |
Downloads the keras model from the url provided. Arguments | def downloadModel(url):
print('Model download started...')
fileName = url.split('/')[-1]
filePath = f'../kerasModels/{fileName}'
if not os.path.exists(os.path.dirname(filePath)):
try:
os.makedirs(os.path.dirname(fileName))
except OSError as exc:
if exc.errno != e... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def download_model_from_url(\n url: str = typer.Argument(..., help='The link to a model'),\n path: Path = typer.Argument(..., file_okay=True, help='The saved path and file name.')\n):\n\n from modelci.hub.registrar import download_model_from_url\n\n download_model_from_url(url, path)\n typer... | [
"0.7541133",
"0.7043842",
"0.69337887",
"0.68987656",
"0.68111223",
"0.6804341",
"0.67991847",
"0.67405045",
"0.66448855",
"0.65763366",
"0.6502837",
"0.6490908",
"0.6452319",
"0.6402259",
"0.6343985",
"0.6297874",
"0.6281097",
"0.62647754",
"0.6254215",
"0.6241432",
"0.62136... | 0.78551733 | 0 |
Given a document root as stored in the db, this function will return an array of all child documents. | def get_all_documents(root_name):
# Using our db connection, get all documents with the root, **root_name**
documents = db.child(root_name).get()
# The **doc_list** will eventually be a list of document objects
# formatted in a more workable manner than the OrderedDicts that we get. \* <br>
doc_list = []
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def all_documents(self):\n return [item[0] for item in\n self.sql_session.query(Document).values(Document.id)]",
"def _get_documents(self) -> Iterable[dict]:\n\n return self._db[\"documents\"]",
"def getchildren(self):\n return self.root.getchildren()",
"def get_children(s... | [
"0.66113776",
"0.6512009",
"0.65081656",
"0.6267396",
"0.62382126",
"0.61985",
"0.6104843",
"0.6092379",
"0.6087452",
"0.60752064",
"0.6053975",
"0.60261023",
"0.6010659",
"0.60009974",
"0.5994695",
"0.5986459",
"0.5975035",
"0.59590566",
"0.59313375",
"0.5922037",
"0.5912757... | 0.7554137 | 0 |
Computes the histogram of the input image | def compute_histogram(self, image):
hist = [0] * 256
[h, w] = image.shape
print(h,w)
i = 0
while i < 256:
for row in range(h):
for col in range(w):
if image[row, col] == i:
hist[i] += 1
#print(his... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute_histogram(self, image):\n\n hist = [0] * 256\n x, y = image.shape[:2]\n #print(image.shape)\n for i in range(x):\n for j in range(y):\n hist[image[i, j]] += 1\n\n return hist",
"def hist(img):\n bottom_half = img[img.shape[0]//2:,:] # 0:... | [
"0.82736444",
"0.8064423",
"0.8037536",
"0.7930632",
"0.76470864",
"0.7604351",
"0.75007343",
"0.73157203",
"0.7244618",
"0.71898323",
"0.7063043",
"0.6988698",
"0.69718844",
"0.69492954",
"0.6931104",
"0.6850683",
"0.6834464",
"0.6798194",
"0.6795921",
"0.6792963",
"0.677200... | 0.8042533 | 2 |
Comptues the binary image of the the input image based on histogram analysis and thresholding take as input | def binarize(self, image, threshold):
bin_img = image.copy()
[h, w] = bin_img.shape
opt_threshold = threshold
print(opt_threshold)
for row in range(h):
for col in range(w):
if bin_img[row, col] > opt_threshold: #greater than threshld white(general)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def binarize(self, image, threshold):\n bin_img = image.copy()\n for i in range(image.shape[0]):\n for j in range(image.shape[1]):\n if image[i, j] >= threshold:\n bin_img[i, j] = 0\n else:\n bin_img[i, j] = 255\n r... | [
"0.7313494",
"0.727349",
"0.7154536",
"0.70358247",
"0.6959854",
"0.68780637",
"0.68720067",
"0.68675977",
"0.6862011",
"0.68446094",
"0.68052274",
"0.67665195",
"0.6766293",
"0.67088926",
"0.66867805",
"0.66724813",
"0.6671647",
"0.66591763",
"0.6615787",
"0.66022474",
"0.65... | 0.76806265 | 0 |
Checks if the auto update service is enable_on_reboot on the VM | def is_auto_update_service_installed(self, install_check_cmd):
self.composite_logger.log_debug("Checking if auto update service is installed...")
code, out = self.env_layer.run_command_output(install_check_cmd, False, False)
self.composite_logger.log_debug(" - Code: " + str(code) + ", Output: \n... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_service_set_to_enable_on_reboot(self, command):\n self.composite_logger.log_debug(\"Checking if auto update service is set to enable on reboot...\")\n code, out = self.env_layer.run_command_output(command, False, False)\n self.composite_logger.log_debug(\" - Code: \" + str(code) + \", O... | [
"0.83913594",
"0.7520064",
"0.7445612",
"0.68281204",
"0.6648872",
"0.66161555",
"0.6524987",
"0.6457033",
"0.6389063",
"0.62379265",
"0.6159933",
"0.61143976",
"0.60994196",
"0.6091484",
"0.6081966",
"0.60404265",
"0.6007859",
"0.59858376",
"0.59765625",
"0.5974475",
"0.5932... | 0.696775 | 3 |
Get number of resources for the given node. | def getNumForNode(self, node, resourceType=None):
return len(self.getForNode(node, resourceType)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def count(self, resource):\n return len(self.all(resource))",
"def get_children_count(cur, node):\n sql = \"\"\"\n SELECT\n COUNT(*)\n FROM\n nodes\n WHERE\n parent=%s;\n \"\"\"\n cur.execute(sql, (str(node), ))\n result = cur.fetchone()\n return result['... | [
"0.6942366",
"0.68160576",
"0.6759424",
"0.6742038",
"0.65458816",
"0.65458816",
"0.6451336",
"0.6440532",
"0.6440414",
"0.6440414",
"0.6424699",
"0.63875806",
"0.62739694",
"0.6212865",
"0.6207482",
"0.61690944",
"0.6125102",
"0.6112109",
"0.60914487",
"0.6072903",
"0.603811... | 0.7681628 | 0 |
Returns if x is a line vector | def is_line_vec(x):
return x.ndim == 1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_vector(x):\r\n return len(x.shape) == 1",
"def isline(l):\n return isinstance(l,list) and len(l) == 2 \\\n and ispoint(l[0]) and ispoint(l[1])",
"def is_vector(self):\n return len(self.coeffs.shape[self.sdim:]) == 1",
"def isAnyLineAt(self, x, y):\n return (self.isLineAt(x, ... | [
"0.7318772",
"0.70347726",
"0.6813595",
"0.6661464",
"0.6655709",
"0.66003424",
"0.66003424",
"0.65703124",
"0.6501752",
"0.6425515",
"0.63541573",
"0.62394893",
"0.6196948",
"0.6122228",
"0.6111727",
"0.6060558",
"0.5943779",
"0.590312",
"0.5894377",
"0.5886347",
"0.5849381"... | 0.8678551 | 0 |
Returns if x is a vector with (strictly) increasing values | def is_increasing_vec(x):
return jnp.all(jnp.diff(x) > 0) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_nonincreasing_vec(x):\n return jnp.all(jnp.diff(x) <= 0)",
"def is_decreasing_vec(x):\n return jnp.all(jnp.diff(x) < 0)",
"def is_nondecreasing_vec(x):\n return jnp.all(jnp.diff(x) >= 0)",
"def is_strictly_increasing(a):\n return np.all(np.diff(a) > 0)",
"def increasing(data):\n retur... | [
"0.77735466",
"0.76834404",
"0.7547428",
"0.7222248",
"0.689625",
"0.6661161",
"0.6551474",
"0.65255845",
"0.6474087",
"0.64734685",
"0.6412531",
"0.62575585",
"0.6223273",
"0.6214999",
"0.6173246",
"0.6161648",
"0.6124167",
"0.6124167",
"0.6119906",
"0.6095253",
"0.60752106"... | 0.8209932 | 0 |
Returns if x is a vector with nonincreasing values | def is_nonincreasing_vec(x):
return jnp.all(jnp.diff(x) <= 0) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_nondecreasing_vec(x):\n return jnp.all(jnp.diff(x) >= 0)",
"def is_increasing_vec(x):\n return jnp.all(jnp.diff(x) > 0)",
"def is_decreasing_vec(x):\n return jnp.all(jnp.diff(x) < 0)",
"def is_strictly_increasing(a):\n return np.all(np.diff(a) > 0)",
"def isnegative(x):\n if x < 0 :\n... | [
"0.8488845",
"0.8168255",
"0.80972946",
"0.7044522",
"0.65920085",
"0.6579653",
"0.65360093",
"0.64840376",
"0.64633423",
"0.64599055",
"0.6389071",
"0.6362141",
"0.63620883",
"0.6303656",
"0.62858564",
"0.6238266",
"0.61703837",
"0.61620253",
"0.6153845",
"0.6145223",
"0.612... | 0.8637021 | 0 |
Returns if x is a vector with equal values | def has_equal_values_vec(x):
return jnp.all(x == x[0]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_vector(x):\r\n return len(x.shape) == 1",
"def testEquals(self):\n v1 = Vector(3, 4, 5)\n assert (v1 == [3, 4, 5])\n assert (v1 != [0, 2, 4])\n v2 = Vector(3.0, 4.0, 5.000)\n assert (v1 == v2)\n v3 = Vector(2, 2)\n assert v1 != v3",
"def equal(self, x)... | [
"0.6959696",
"0.6736299",
"0.6717924",
"0.65841",
"0.64839286",
"0.6394011",
"0.637222",
"0.6325009",
"0.6307421",
"0.62646866",
"0.62550586",
"0.617889",
"0.6145178",
"0.6109711",
"0.6082822",
"0.6079916",
"0.6073307",
"0.60381484",
"0.6007522",
"0.5980817",
"0.5969379",
"... | 0.8356515 | 0 |
Converts a line vector to a column vector | def to_col_vec(x):
assert x.ndim == 1
return jnp.expand_dims(x, 1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _colvec(x):\n x = np.atleast_1d(x)\n return x[:, None]",
"def col(self, i):\n return Vector([row[i] for row in self.data])",
"def vector_line(self):\n assert len(self.xcoords) == 2\n diff_x = self.xcoords[1] - self.xcoords[0]\n diff_z = self.zcoords[1] - self.z... | [
"0.6698258",
"0.65644085",
"0.65443087",
"0.6507199",
"0.6473032",
"0.63910407",
"0.62793183",
"0.6259065",
"0.6121611",
"0.6104566",
"0.6102995",
"0.6007699",
"0.6005219",
"0.59967834",
"0.5979476",
"0.5973361",
"0.596417",
"0.5955236",
"0.59308064",
"0.59209263",
"0.5918016... | 0.6259775 | 7 |
Returns a unit vector in ith dimension for the standard coordinate system | def vec_unit(n, i):
return jnp.zeros(n).at[i].set(1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unit():\n return Vec2d(0, 1)",
"def unit(self):\r\n return Vector(self.x/self.length(), self.y/self.length())",
"def to_unit(self):\n if self.is_zero():\n return Vector(0,0,0)\n else:\n magnitude = self.l2_norm()\n return Vector(self.x/magnitude,... | [
"0.7735446",
"0.7390393",
"0.7160047",
"0.71379507",
"0.70428914",
"0.70428914",
"0.70428914",
"0.7021703",
"0.69872844",
"0.69510007",
"0.69510007",
"0.69510007",
"0.69510007",
"0.69510007",
"0.69510007",
"0.69510007",
"0.69510007",
"0.69510007",
"0.69510007",
"0.69510007",
... | 0.59104747 | 67 |
Right shift the contents of the vector | def vec_shift_right(x):
return jnp.zeros_like(x).at[1:].set(x[:-1]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def vec_rotate_right(x):\n return jnp.roll(x, 1)",
"def shift_right(self):\n self.pointer = (self.pointer + 1) % len(self.data)",
"def vec_shift_left(x):\n return jnp.zeros_like(x).at[0:-1].set(x[1:])",
"def vec_shift_right_n(x, n):\n return jnp.zeros_like(x).at[n:].set(x[:-n])",
"def vec_r... | [
"0.74227875",
"0.7008702",
"0.67520916",
"0.6741145",
"0.671371",
"0.65788853",
"0.657209",
"0.636291",
"0.6354332",
"0.62614614",
"0.6199991",
"0.61862296",
"0.6182634",
"0.6179469",
"0.6151821",
"0.6139111",
"0.60783416",
"0.60385096",
"0.60254526",
"0.6023933",
"0.6009376"... | 0.8077497 | 0 |
Left shift the contents of the vector | def vec_shift_left(x):
return jnp.zeros_like(x).at[0:-1].set(x[1:]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def vec_shift_right(x):\n return jnp.zeros_like(x).at[1:].set(x[:-1])",
"def vec_rotate_left(x):\n return jnp.roll(x, -1)",
"def vec_rotate_right(x):\n return jnp.roll(x, 1)",
"def shift(self, shift_vector, inplace=False):\n if len(self.vertices) == 0:\n raise GGeoError('cannot shi... | [
"0.76559925",
"0.7226969",
"0.67600715",
"0.6736687",
"0.66364413",
"0.6594939",
"0.64988995",
"0.64787215",
"0.64436054",
"0.640513",
"0.6337259",
"0.6305275",
"0.62912095",
"0.6229094",
"0.62002164",
"0.6198291",
"0.61754423",
"0.61272913",
"0.6120745",
"0.60527754",
"0.603... | 0.7746941 | 0 |
Left shift the contents of the vector by n places | def vec_shift_left_n(x, n):
return jnp.zeros_like(x).at[0:-n].set(x[n:]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def vec_shift_right_n(x, n):\n return jnp.zeros_like(x).at[n:].set(x[:-n])",
"def shift(a, n=1):\n return a[n:] + a[:n]",
"def vec_rotate_left_n(x, n):\n return jnp.roll(x, -n)",
"def vec_rotate_right_n(x, n):\n return jnp.roll(x, n)",
"def shift(xs, n):\n e = np.empty_like(xs)\n if n >= ... | [
"0.7926303",
"0.7835327",
"0.76371765",
"0.7231364",
"0.71568394",
"0.69230956",
"0.69173783",
"0.685816",
"0.685816",
"0.6854778",
"0.67303336",
"0.67303336",
"0.6705286",
"0.66911525",
"0.662501",
"0.6615008",
"0.6609778",
"0.65472424",
"0.649368",
"0.6425879",
"0.63407624"... | 0.8086534 | 0 |
Returns the central part of a vector of a specified length | def vec_centered(x, length):
cur_len = len(x)
length = min(cur_len, length)
start = (len(x) - length) // 2
end = start + length
return x[start:end] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mid_point(self, vector):\n return self.eval_2pts(vector, 0.5)",
"def unit_vector(vector):\n assert(vector != [0,0])\n return vector / np.linalg.norm(vector)",
"def unit_vector(vector):\r\n return vector / np.linalg.norm(vector)",
"def unit_vector(vector):\r\n return vector / np.linalg.... | [
"0.6605002",
"0.6272887",
"0.6215661",
"0.6215661",
"0.6215661",
"0.62071174",
"0.62071174",
"0.62071174",
"0.62071174",
"0.62071174",
"0.62071174",
"0.62071174",
"0.62071174",
"0.62071174",
"0.62071174",
"0.62071174",
"0.61762536",
"0.6144691",
"0.61167395",
"0.60959315",
"0... | 0.7731614 | 0 |
Computes a probability mass function from a given vector | def vec_to_pmf(a):
s = jnp.sum(a) * 1.
return a / s | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_probability(x,mu,var):\n m,n = np.atleast_2d(x).shape\n variance = np.diag(var)\n factor = 1.0/((2*np.pi)**(n/2.0) * np.linalg.det(variance)**0.5)\n p = np.array([ factor * np.exp( (-0.5) * ((xx).T @ np.linalg.inv(variance) @ (xx)).sum() ) for xx in np.atleast_2d(x-mu)])\n return p",
"def ... | [
"0.6657569",
"0.6639386",
"0.65446126",
"0.65427697",
"0.6480422",
"0.6465506",
"0.6346475",
"0.62492263",
"0.6184395",
"0.6178397",
"0.6164373",
"0.61155885",
"0.60912615",
"0.60704386",
"0.6053747",
"0.6040162",
"0.6032478",
"0.60078126",
"0.60037005",
"0.59988767",
"0.5968... | 0.69556713 | 0 |
Computes a cumulative mass function from a given vector | def vec_to_cmf(a):
s = jnp.sum(a) * 1.
# normalize
a = a / s
# generate the CMF
return jnp.cumsum(a) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def custom_np_function(vector):\n summation = 0\n for item in vector:\n summation += item ** 2\n return summation",
"def calcMomentumFromVelocity(self):\n if self.mass is None:\n raise CoordinateVector(\"The particle mass needs to be specified to calculate the particle momentum from veloc... | [
"0.65208346",
"0.641715",
"0.5931126",
"0.5929662",
"0.5916127",
"0.58981115",
"0.5871822",
"0.5861446",
"0.58560264",
"0.5843584",
"0.5833268",
"0.5819571",
"0.57770246",
"0.57463765",
"0.5703675",
"0.5698386",
"0.5697855",
"0.5693897",
"0.5669646",
"0.5664808",
"0.56470555"... | 0.6606852 | 0 |
Left shift the contents of the vector | def cbuf_push_left(buf, val):
return buf.at[1:].set(buf[:-1]).at[0].set(val) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def vec_shift_left(x):\n return jnp.zeros_like(x).at[0:-1].set(x[1:])",
"def vec_shift_right(x):\n return jnp.zeros_like(x).at[1:].set(x[:-1])",
"def vec_rotate_left(x):\n return jnp.roll(x, -1)",
"def vec_rotate_right(x):\n return jnp.roll(x, 1)",
"def shift(self, shift_vector, inplace=False):... | [
"0.7746941",
"0.76559925",
"0.7226969",
"0.67600715",
"0.6736687",
"0.66364413",
"0.6594939",
"0.64988995",
"0.64787215",
"0.64436054",
"0.640513",
"0.6337259",
"0.6305275",
"0.62912095",
"0.6229094",
"0.62002164",
"0.6198291",
"0.61754423",
"0.61272913",
"0.6120745",
"0.6052... | 0.0 | -1 |
Left shift the contents of the vector | def cbuf_push_right(buf, val):
return buf.at[:-1].set(buf[1:]).at[-1].set(val) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def vec_shift_left(x):\n return jnp.zeros_like(x).at[0:-1].set(x[1:])",
"def vec_shift_right(x):\n return jnp.zeros_like(x).at[1:].set(x[:-1])",
"def vec_rotate_left(x):\n return jnp.roll(x, -1)",
"def vec_rotate_right(x):\n return jnp.roll(x, 1)",
"def shift(self, shift_vector, inplace=False):... | [
"0.7746941",
"0.76559925",
"0.7226969",
"0.67600715",
"0.6736687",
"0.66364413",
"0.6594939",
"0.64988995",
"0.64787215",
"0.64436054",
"0.640513",
"0.6337259",
"0.6305275",
"0.62912095",
"0.6229094",
"0.62002164",
"0.6198291",
"0.61754423",
"0.61272913",
"0.6120745",
"0.6052... | 0.0 | -1 |
Checks if x is a min heap | def is_min_heap(x):
n = len(x)
idx = jnp.arange(1, n, dtype=int)
parents = (idx-1) // 2
return jnp.all(x[parents] <= x[1:]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_max_heap(x):\n n = len(x)\n idx = jnp.arange(1, n, dtype=int)\n parents = (idx-1) // 2\n return jnp.all(x[parents] >= x[1:])",
"def min_heap(self): \n \n for pos in range(self.size//2, 0, -1): \n self.min_heapify(pos)",
"def heapify(x):\n pass",
"def min_heapify(self,... | [
"0.7123914",
"0.6827665",
"0.65061194",
"0.64888835",
"0.6423431",
"0.64178413",
"0.6403038",
"0.63220936",
"0.6310775",
"0.623755",
"0.61982036",
"0.61665004",
"0.6097122",
"0.6049346",
"0.6044598",
"0.6029829",
"0.5975115",
"0.5953446",
"0.5911516",
"0.5898301",
"0.58380467... | 0.8512507 | 0 |
Returns the index of the left child | def left_child_idx(idx):
return (idx << 1) + 1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_left_child_index(self):\n return (2 * self.index) + 1",
"def left_child(self, index):\n return 2 * index + 1",
"def left_child(self, index):\n return 2 * index",
"def get_left_child_index(self, parent):\n return 2*parent+1",
"def leftChild(self, pos):\n return... | [
"0.92512465",
"0.8947772",
"0.8826891",
"0.87518626",
"0.8361981",
"0.8361981",
"0.8360912",
"0.7980738",
"0.7829544",
"0.7797249",
"0.7730859",
"0.7611618",
"0.75685126",
"0.7400831",
"0.7389259",
"0.7362745",
"0.7343726",
"0.72990113",
"0.7226029",
"0.7170904",
"0.71376586"... | 0.8276688 | 7 |
Returns the index of the right child | def right_child_idx(idx):
return (idx + 1) << 1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_right_child_index(self):\n return (2 * self.index) + 2",
"def get_right_child_index(self, parent):\n return 2*parent+2",
"def right_child(self, index):\n return 2 * index + 1",
"def right_child(self, index):\n return 2 * index + 2",
"def right_child(self, pos): \n ... | [
"0.9172102",
"0.8854869",
"0.87777513",
"0.867917",
"0.84217525",
"0.83991",
"0.83991",
"0.8107605",
"0.78409326",
"0.7703145",
"0.769417",
"0.758315",
"0.7561745",
"0.74584305",
"0.74520445",
"0.72334725",
"0.72197473",
"0.7207952",
"0.7179746",
"0.71431094",
"0.71211493",
... | 0.8335453 | 7 |
Return the index of the largest value between a parent and its children | def largest_plr(x, idx):
l = (idx << 1) + 1
r = (idx + 1) << 1
largest = jnp.where(x[idx] < x[l], l, idx)
largest = jnp.where(x[largest] < x[r], r, largest)
return largest | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def max_child(self, index):\n if self.empty():\n return None\n if self._has_left(index):\n left = self._left(index)\n large = left\n if self._has_right(index):\n right = self._right(index)\n if self._data[right] == self._data[l... | [
"0.7674155",
"0.76735413",
"0.7172528",
"0.7167502",
"0.70155597",
"0.6976711",
"0.6932303",
"0.691233",
"0.6876073",
"0.687408",
"0.6855974",
"0.683167",
"0.680894",
"0.6774955",
"0.6743871",
"0.6741475",
"0.67109",
"0.6709332",
"0.66989976",
"0.6674324",
"0.66686666",
"0.... | 0.0 | -1 |
Heapifies a subtree starting from a given node | def heapify_subtree(x, idx):
n = len(x)
n2 = n >> 1
def body_func(state):
x, idx, _ = state
largest = largest_plr(x, idx)
change = largest != idx
x = lax.cond(change,
lambda x: vec_swap_entries(x, largest, idx),
lambda x: x,
x)
ret... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def min_heapify(self, pos): \n \n # If the node is a non-leaf node and greater \n # than any of its child \n if not self.is_leaf(pos): \n if (self.Heap[pos] > self.Heap[self.left_child(pos)] or \n self.Heap[pos] > self.Heap[self.right_child(pos)]): \n \n ... | [
"0.730668",
"0.7233791",
"0.6870105",
"0.68508685",
"0.6771289",
"0.67139894",
"0.66019195",
"0.65518856",
"0.6536261",
"0.6514367",
"0.6467823",
"0.6361919",
"0.6342516",
"0.6341134",
"0.6329597",
"0.6328174",
"0.6314242",
"0.62666494",
"0.62335044",
"0.62251323",
"0.620571"... | 0.6990611 | 2 |
Returns a random quote to be displayed on the community sandwich page | def random_quote():
quotes = [
"Growth is never by mere chance; it is the result of forces working together.\n-James Cash Penney",
"We cannot accomplish all that we need to do without working together\n-Bill Richardson",
"The power of one, if fearless and focused, is formidable, but the powe... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_random_inspirational_quote(self):\n return random.choice(self.inspirational_quotes)",
"def get_random_quote() -> Dict:\n quote = random.choice(quote_dict[\"quotes\"])\n return quote",
"def get_random_quote():\n with open (\"./data/quotes.txt\", \"r\") as quotes:\n\n all_quotes = ... | [
"0.7840503",
"0.76459634",
"0.7557797",
"0.74808735",
"0.7117414",
"0.7083641",
"0.6864093",
"0.6830333",
"0.6722464",
"0.6641399",
"0.64240575",
"0.6358891",
"0.6341214",
"0.6230407",
"0.6228168",
"0.62198406",
"0.6171568",
"0.6139154",
"0.61251044",
"0.61234236",
"0.6101212... | 0.8133398 | 0 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.