query stringlengths 10 2k | document stringlengths 20 51.2k | metadata dict | negatives listlengths 0 101 | negative_scores listlengths 0 101 | document_score stringlengths 3 10 | document_rank stringclasses 102
values |
|---|---|---|---|---|---|---|
Return the current size of internal memory. | def __len__(self):
return len(self.memory) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getSize(self) -> int:\n return len(self.mem)",
"def getSize(self):\n return self.bf.memory()",
"def memsize(self):\n return self.xlist(\"get-memsize\")[1][0] * 1024",
"def size(self):\n size = 0\n size += self.data.size * sys.getsizeof(self.data)\n return size / ... | [
"0.8573752",
"0.82169205",
"0.8200361",
"0.8087402",
"0.8021614",
"0.7890747",
"0.78219426",
"0.78017354",
"0.77905464",
"0.7758844",
"0.77559924",
"0.77559924",
"0.775519",
"0.77544576",
"0.7733221",
"0.7732168",
"0.7720068",
"0.77145016",
"0.77092093",
"0.77077913",
"0.7697... | 0.75127405 | 57 |
Create a WeMoDevice instance. | def create_pywemo_device(pywemo_registry, pywemo_model):
cls = getattr(pywemo, pywemo_model)
device = create_autospec(cls, instance=True)
device.host = MOCK_HOST
device.port = MOCK_PORT
device.name = MOCK_NAME
device.serial_number = MOCK_SERIAL_NUMBER
device.model_name = pywemo_model.replace... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def createDevice(self):\n deviceName = self.options.device\n self.log.info(\"Looking for %s\", deviceName)\n ip = ipunwrap(deviceName)\n if not isip(ip):\n try:\n ip = yield getHostByName(deviceName)\n except socket.error as ex:\n self... | [
"0.6979325",
"0.6969494",
"0.69279915",
"0.6697995",
"0.64664435",
"0.64664435",
"0.64532006",
"0.6452956",
"0.61701924",
"0.6123077",
"0.60617",
"0.6022968",
"0.6019177",
"0.6003418",
"0.5994704",
"0.59622884",
"0.59211713",
"0.5915887",
"0.5875939",
"0.5863109",
"0.58471197... | 0.7106339 | 0 |
takes in single channel image and returns its filtered image | def filter_sinc_channel(img, mask_circle_diameter=40.0):
dft_image = cv2.dft(np.float32(img), flags=cv2.DFT_COMPLEX_OUTPUT)
dft_shift = np.fft.fftshift(dft_image)
mask = np.zeros((img.shape[0], img.shape[1], 2), dtype=np.uint8)
circle_center = (int(img.shape[0] / 2), int(img.shape[1] / 2))
points_x,... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def filtering(image):\n output = np.array(image)\n for x in xrange(0,1):\n bilateralFilter_img = cv2.bilateralFilter(output,5, 75, 75)\n\n return bilateralFilter_img",
"def filter_image(img):\n return cv2.bilateralFilter(img, 9, 50, 50)",
"def custom_filter(image: Image) -> Image:\n image... | [
"0.7590697",
"0.7579986",
"0.74054664",
"0.7184011",
"0.7175308",
"0.7068393",
"0.706228",
"0.69902253",
"0.69761366",
"0.6754231",
"0.67055255",
"0.66707313",
"0.66542345",
"0.6605028",
"0.6521483",
"0.6521347",
"0.6521347",
"0.65176535",
"0.6515441",
"0.6492547",
"0.6485968... | 0.0 | -1 |
Create a negative path from the source to a random neighbor. | def _get_easy_negative_path(self, scan_id, path):
g, d = self._graphs[scan_id], self._distances[scan_id]
source, goal = path[0], path[-1]
# get valid neighbors within 4 and 6 hops and greater than 3m from the goal
max_hops, min_hops, min_distance = 6, 4, 3
neighbors = nx.single_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_hard_negative_path(self, scan_id, path):\n g, d = self._graphs[scan_id], self._distances[scan_id]\n offset = np.random.randint(1, len(path) - 1)\n source, goal = path[offset], path[-1]\n\n # get valid neighbors within 4 and 6 hops and greater than 3m from the goal\n max_... | [
"0.6949671",
"0.6315474",
"0.5942192",
"0.5929039",
"0.5828919",
"0.56675005",
"0.56124395",
"0.5601444",
"0.5512754",
"0.54970336",
"0.5454087",
"0.5393641",
"0.5342276",
"0.5340866",
"0.5325405",
"0.52940774",
"0.529315",
"0.5278507",
"0.52612984",
"0.5237378",
"0.52128506"... | 0.6671322 | 1 |
Create a negative path that starts along the path then goes to a random neighbor. | def _get_hard_negative_path(self, scan_id, path):
g, d = self._graphs[scan_id], self._distances[scan_id]
offset = np.random.randint(1, len(path) - 1)
source, goal = path[offset], path[-1]
# get valid neighbors within 4 and 6 hops and greater than 3m from the goal
max_hops, min_h... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_easy_negative_path(self, scan_id, path):\n g, d = self._graphs[scan_id], self._distances[scan_id]\n source, goal = path[0], path[-1]\n\n # get valid neighbors within 4 and 6 hops and greater than 3m from the goal\n max_hops, min_hops, min_distance = 6, 4, 3\n neighbors =... | [
"0.67538655",
"0.6313133",
"0.6284355",
"0.627728",
"0.6218492",
"0.6182821",
"0.61107945",
"0.6069016",
"0.5802694",
"0.5775509",
"0.5691818",
"0.56777906",
"0.5651772",
"0.5632896",
"0.56143737",
"0.5603061",
"0.554976",
"0.55230093",
"0.5520119",
"0.5504714",
"0.54974747",... | 0.6926614 | 0 |
Create a negative path by swapping one of the viewpoints randomly. | def _get_backup_negative_path(self, scan_id, path):
negative_path = path[:] # copy path
swap_index = np.random.randint(len(negative_path))
swap_image_id = np.random.choice(list(self._viewpoints[scan_id] - set(path)))
negative_path[swap_index] = swap_image_id
return negative_pat... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mutate(self):\n # swap two cities in the path\n first = random.randrange(len(self.path))\n second = random.choice([i for i in range(len(self.path)) if i != first])\n tmp = self.path[first]\n self.path[first] = self.path[second]\n self.path[second] = tmp",
"def decrem... | [
"0.6211992",
"0.6139775",
"0.6108279",
"0.579733",
"0.56937534",
"0.5638884",
"0.5549893",
"0.5543935",
"0.55129814",
"0.5506386",
"0.54785573",
"0.54631406",
"0.5439866",
"0.5413279",
"0.5412733",
"0.53877205",
"0.5377846",
"0.5355373",
"0.53548074",
"0.5347682",
"0.53378224... | 0.67209977 | 0 |
Get features for a given path. | def _get_path_features(self, scan_id, path, first_heading):
headings = get_headings(self._graphs[scan_id], path, first_heading)
# for next headings duplicate the last
next_headings = headings[1:] + [headings[-1]]
path_length = min(len(path), self._max_path_length)
path_features,... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_all_features_from_path(path):\n\n data, sr, file_name = get_data(path)\n\n features = get_all_features_from_data(data, sr)\n\n return [file_name] + features",
"def get_features_by_image_path(path_to_image: str) -> t.Dict[str, torch.Tensor]:\r\n image_data = loader(path_to_image)\r\n with t... | [
"0.79351115",
"0.6615956",
"0.645515",
"0.6429322",
"0.6428331",
"0.6403526",
"0.63582647",
"0.6303315",
"0.6202913",
"0.6200943",
"0.6167978",
"0.61569124",
"0.6139376",
"0.61316806",
"0.6129238",
"0.61110646",
"0.61109895",
"0.60972047",
"0.6086738",
"0.6076351",
"0.6050064... | 0.63635606 | 6 |
Returns the area of the square | def area(self):
return int(self.__size) * int(self.__size) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def square_area(side):\n return side**2",
"def area(self):\n return(self.__width * self.__height)",
"def area(width, height):\n return width * height",
"def area(self):\n area = self.__width * self.__height\n return area",
"def findArea(self):\n\n a, b = self.sides\n ... | [
"0.82916456",
"0.8142852",
"0.8130899",
"0.81287146",
"0.8103277",
"0.8081276",
"0.8078793",
"0.80734193",
"0.8035203",
"0.802752",
"0.802752",
"0.8023302",
"0.8011109",
"0.8005454",
"0.80037534",
"0.7954123",
"0.7944111",
"0.7944111",
"0.7944111",
"0.79368186",
"0.79368186",... | 0.7616927 | 66 |
Test that invalid URLs, or those that do not follow a specific format are not treated as a special case. | def test_invalid_url_formats_in_message_respect_max_length(self, custom_check):
urls = ('www.example.com', 'invalid:/www.example.com')
for url in urls:
result = custom_check.run(
{
'commits': [
{
'stats':... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_non_url(self):\n for url in ['not-a-url', 'http://not-a-url', 'https://not-a-url']:\n yield self.check_url_raises, url",
"def test_validate_url_non_google_doc():\n url_not_a_google_doc = 'https://not-a-google-doc.com'\n assert validate_url(url_not_a_google_doc) is False",
"def ... | [
"0.7551601",
"0.75008017",
"0.7416675",
"0.7350243",
"0.7282661",
"0.7188756",
"0.71761644",
"0.6950575",
"0.69120955",
"0.6846826",
"0.68459594",
"0.6837864",
"0.6835412",
"0.68341583",
"0.6830114",
"0.68287134",
"0.6804755",
"0.67899966",
"0.6771376",
"0.67198443",
"0.67002... | 0.6656918 | 23 |
Sign of the number; 1, 0 or 1 | def sgn(x) -> int:
if x > 0:
return 1
if x < 0:
return -1
return 0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sign(num: float):\n return 1 if num >= 0 else -1",
"def _sign(self, number):\n return cmp(number,0)",
"def sign(self):\n return 1 - 2 * self._ltz()",
"def sign(x):\n if x >= 0:\n return 1\n else:\n return -1",
"def sign(x):\n if x >= 0:\n return 1\n return ... | [
"0.84922457",
"0.8201882",
"0.8110207",
"0.807229",
"0.8038881",
"0.7961936",
"0.793839",
"0.78780055",
"0.78209555",
"0.7654399",
"0.74612725",
"0.7452525",
"0.72622633",
"0.7193294",
"0.70806974",
"0.7006637",
"0.69394064",
"0.6901046",
"0.68992543",
"0.6864174",
"0.6761238... | 0.58665586 | 73 |
Whether two floating point numbers are equal. Epsilon = 10^12 | def fp_eq(x: float, y: float) -> bool:
return fabs(x-y) < 10**-12 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def almost_equal(x, y):\n return abs(x-y) < FP_PREC",
"def almost_eq(e1,e2) :\n\treturn round(e1-e2,4) == 0.0",
"def _same(p1,p2,prec=0.0001):\n #return num.all(num.equal(p1,p2))\n t1 = num.fabs(p1[0]-p2[0]) < prec\n t2 = num.fabs(p1[1]-p2[1]) < prec\n if t1 and t2:\n ... | [
"0.7790273",
"0.77249455",
"0.7590512",
"0.75876886",
"0.75591",
"0.75169545",
"0.7490431",
"0.74748975",
"0.744136",
"0.71324843",
"0.7114323",
"0.7081868",
"0.70735383",
"0.70727074",
"0.70311004",
"0.700937",
"0.6988842",
"0.6954459",
"0.69383615",
"0.6913378",
"0.6877883"... | 0.81073457 | 0 |
Whether one floating point is lesser than the other and not equal. | def fp_lt(x: float, y: float) -> bool:
return not fp_eq(x, y) and x < y | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isGE(self, a : float, b : float) -> bool:\n return (a >= b - self.tol * max(abs(a), abs(b), 1.0)) #and (a >= b - 0.1)",
"def fp_gt(x: float, y: float) -> bool:\n return not fp_eq(x, y) and x > y",
"def less(value1, value2):\n number1 = FloatConverter.to_nullable_float(value1)\n numb... | [
"0.7885711",
"0.77801955",
"0.766003",
"0.765407",
"0.76113784",
"0.7489459",
"0.7471796",
"0.7386086",
"0.7314204",
"0.72951937",
"0.7188735",
"0.714852",
"0.7093572",
"0.7043863",
"0.70429265",
"0.70106715",
"0.6941966",
"0.6901486",
"0.6901313",
"0.68965113",
"0.68830496",... | 0.8250106 | 0 |
Whether one floating point is lesser than the other and not equal. | def fp_gt(x: float, y: float) -> bool:
return not fp_eq(x, y) and x > y | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fp_lt(x: float, y: float) -> bool:\n return not fp_eq(x, y) and x < y",
"def isGE(self, a : float, b : float) -> bool:\n return (a >= b - self.tol * max(abs(a), abs(b), 1.0)) #and (a >= b - 0.1)",
"def less(value1, value2):\n number1 = FloatConverter.to_nullable_float(value1)\n numb... | [
"0.8250106",
"0.7885711",
"0.766003",
"0.765407",
"0.76113784",
"0.7489459",
"0.7471796",
"0.7386086",
"0.7314204",
"0.72951937",
"0.7188735",
"0.714852",
"0.7093572",
"0.7043863",
"0.70429265",
"0.70106715",
"0.6941966",
"0.6901486",
"0.6901313",
"0.68965113",
"0.68830496",
... | 0.77801955 | 2 |
Haversine formula. Distance between two lat/lon points in meters. | def haversine(pos1: Position, pos2: Position, radius: float) -> float:
dlon = pos2.lon - pos1.lon
dlat = pos2.lat - pos1.lat
a = sin(dlat/2)**2 + cos(pos1.lat) * cos(pos2.lat) * sin(dlon/2)**2
return 2 * asin(sqrt(a)) * radius | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def haversine(lon1, lat1, lon2, lat2): \r\n lon1, lat1, lon2, lat2 = map(radians, [lon1, lat1, lon2, lat2]) \r\n #print 34\r\n dlon = lon2 - lon1 \r\n dlat = lat2 - lat1 \r\n a = sin(dlat/2)**2 + cos(lat1) * cos(lat2) * sin(dlon/2)**2 \r\n c = 2 * atan(sqrt(a)/sqrt(1-a)) \r\n r = 637... | [
"0.8449889",
"0.8395916",
"0.8379287",
"0.8367029",
"0.83662117",
"0.8363496",
"0.8362872",
"0.83386964",
"0.8327431",
"0.83269835",
"0.8287061",
"0.8269741",
"0.825335",
"0.82446206",
"0.8237512",
"0.8233819",
"0.82322216",
"0.8229987",
"0.82235116",
"0.8222867",
"0.8216212"... | 0.76495206 | 80 |
Initialize a premined blockchain for use by the test. Create a cache of a 200blocklong chain (with wallet) for MAX_NODES Afterward, create num_nodes copies from the cache. | def _initialize_chain(self, test_dir, num_nodes, cachedir, extra_args=None, stderr=None):
assert num_nodes <= MAX_NODES
create_cache = False
for i in range(MAX_NODES):
if not os.path.isdir(os.path.join(cachedir, 'node' + str(i))):
create_cache = True
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, public_key, node_id):\n # Our starting block for the blockchain\n genesis_block = Block(0, '', [], [], [], 100, 0)\n # Initializing our (empty) blockchain list\n self.chain = [genesis_block]\n # Unhandled transactions\n self.__open_transactions = []\n ... | [
"0.6295902",
"0.61665285",
"0.59151757",
"0.5836084",
"0.5798645",
"0.57585114",
"0.5758475",
"0.5683243",
"0.5674482",
"0.56719446",
"0.56386983",
"0.55849296",
"0.557282",
"0.5552743",
"0.5531975",
"0.5500357",
"0.5483222",
"0.54699636",
"0.5445604",
"0.54446316",
"0.542925... | 0.6339188 | 0 |
Is this package in the output of 'pip freeze'? | def package_in_frozen(package_name, frozen_output):
# Look for either:
#
# PACKAGE-NAME==
#
# or:
#
# blah_blah#egg=package_name-version
#
pattern = r"(?mi)^{pkg}==|#egg={pkg_under}-".format(
pkg=re.escape(package_name),
pkg_under=re.escape(package_name.replace("-... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _package_available(package_name: str) -> bool:\n try:\n return find_spec(package_name) is not None\n except ModuleNotFoundError:\n return False",
"def _is_package_installed(name):\n\n command = [\n sys.executable,\n '-m', 'pip',\n 'show', '--quiet',\n name,\... | [
"0.7385979",
"0.73618233",
"0.7319043",
"0.7116039",
"0.7111637",
"0.7095251",
"0.7034042",
"0.70042217",
"0.7000459",
"0.69762516",
"0.69757324",
"0.69757324",
"0.6974673",
"0.69583064",
"0.69517165",
"0.6942311",
"0.6926903",
"0.6890541",
"0.68792504",
"0.68278736",
"0.6719... | 0.6490038 | 29 |
Get Sparv data path from config file. | def read_sparv_config():
data = {}
if sparv_config_file.is_file():
try:
with open(sparv_config_file, encoding="utf-8") as f:
data = yaml.load(f, Loader=yaml.FullLoader)
except:
data = {}
return data | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_data_path(name):\n js = open('config.json').read()\n data = json.loads(js)\n return os.path.expanduser(data[name]['data_path'])",
"def config_path(self):\n if os.path.exists(self._config_path):\n if pyhocon.ConfigFactory.parse_file(self._config_path):\n return os... | [
"0.6566849",
"0.65321064",
"0.6358356",
"0.6332933",
"0.6307411",
"0.62524223",
"0.62229335",
"0.62165177",
"0.61986035",
"0.61933744",
"0.6170848",
"0.6089747",
"0.60827637",
"0.60757047",
"0.6057296",
"0.6017485",
"0.601708",
"0.5993128",
"0.59785646",
"0.5962027",
"0.59534... | 0.59009796 | 27 |
Get location of directory containing Sparv models, binaries and other files. | def get_data_path(subpath: Union[str, Path] = "") -> Optional[Path]:
global data_dir
if not data_dir:
# Environment variable overrides config
data_dir_str = os.environ.get(data_dir_env) or read_sparv_config().get("sparv_data")
if data_dir_str:
data_dir = Path(data_dir_str).e... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def base_dir():\n return os.path.join(TrainFile.base_dir(), 'model')",
"def get_bin_dir():\n return os.path.abspath(os.path.join(get_root_dir(), 'bin/'))",
"def output_dir(self):\n return os.path.join(self.checkpoint_dir, self.model_dir)",
"def get_install_dir(self):\n return EventGen... | [
"0.68704474",
"0.6758443",
"0.67347515",
"0.6670471",
"0.6602026",
"0.6587618",
"0.65568507",
"0.6503984",
"0.6472025",
"0.64619815",
"0.6435073",
"0.64157987",
"0.6393991",
"0.63832104",
"0.6375732",
"0.6373274",
"0.6342713",
"0.63319594",
"0.6326641",
"0.63038784",
"0.62744... | 0.0 | -1 |
Transforms a variable sized list of arrays to a rectangular array by padding the arrays accordingly with the given padding value. | def pad_data(data: List[np.ndarray], padding_value) -> List[tf.Tensor]:
paddings = np.array([0, np.max(list(datapoint.shape[0] for datapoint in data))]).reshape((1, -1))
return list(
tf.pad(datapoint, paddings=paddings - np.array((0, len(datapoint))), mode='CONSTANT',
constant_values=padd... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_to_padded_array(x_list, pad_type='edge', dt='float32'):\n n_items = len(x_list)\n max_sequence_length = max(map(lambda x: x.shape[0], x_list))\n other_dims = x_list[0].shape[1:]\n X = np.zeros((n_items, max_sequence_length) + other_dims, dt)\n for i, x in enumerate(x_list):\n pad_sta... | [
"0.69096273",
"0.66828376",
"0.6568966",
"0.65320784",
"0.65285623",
"0.6496416",
"0.64390767",
"0.64080936",
"0.6280034",
"0.62532794",
"0.6188187",
"0.6164986",
"0.61580384",
"0.61549556",
"0.61429626",
"0.6118807",
"0.61010903",
"0.6096081",
"0.607194",
"0.6065543",
"0.605... | 0.6143269 | 14 |
Get a list of openstack controllers Returns list of controller names see NDL_API for other details | def get_controllers(self):
s = self._NDL_API('getcontrollers', {})
return s.split(",") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def controllers(self):\n output = self.run_json('/call show all')\n\n try:\n controllers = output['Controllers']\n except KeyError:\n raise StorcliException('Output is missing Controllers segment')\n\n return [c['Response Data'] for c in controllers]",
"def get_c... | [
"0.779671",
"0.73064417",
"0.6901195",
"0.6888313",
"0.6001293",
"0.59080946",
"0.58274674",
"0.5818716",
"0.57552016",
"0.5643199",
"0.55913943",
"0.5554745",
"0.55441964",
"0.54850614",
"0.5469831",
"0.5450695",
"0.53808284",
"0.5361371",
"0.5357271",
"0.532952",
"0.5313359... | 0.792972 | 0 |
Returns the minimax action using self.depth and self.evaluationFunction | def getAction(self, gameState):
"*** YOUR CODE HERE ***"
def minValue(gameState, agent, depth, alpha, beta):
minVal = float('inf')
for action in gameState.getLegalActions(agent):
successor = gameState.generateSuccessor(agent, action)
if agent == ga... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getAction(self, gameState: GameState):\n _max = float(\"-inf\")\n action = None\n for move in gameState.getLegalActions(0):\n util = minimax(self.evaluationFunction, 1, 0,\n gameState.generateSuccessor(0, move), self.depth)\n if util > _max o... | [
"0.7482665",
"0.7383559",
"0.71806973",
"0.7110041",
"0.70884514",
"0.70694935",
"0.70683014",
"0.7048308",
"0.70055133",
"0.69651455",
"0.69642085",
"0.69604385",
"0.6945924",
"0.68998593",
"0.6895832",
"0.688605",
"0.6826282",
"0.6767276",
"0.6758028",
"0.6751636",
"0.67054... | 0.6307419 | 78 |
Returns a Stream object wrapping the dataset at `path`. `chunk_size` is the size of the chunk in which values are yielded; the bigger the better, as long as it fits in the memory. If `num_samples` is specified, it returns up to that many elements. | def stream_channel(self, path, chunk_size=1000000, num_samples=None, verbose=False):
def gen(path, chunk_size):
dataset = self.file[path]
if num_samples != None:
length = num_samples
else:
length = len(dataset)
offset = 0
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gen_chunk(self, path: pathlib.Path, chunk_size: int = 4096) \\\n -> Iterator[bytes]:\n\n with open(path, 'rb') as f:\n yield f.read(chunk_size)\n yield f.read()",
"def chunk_generator(input_file, chunksize = 100000, dataset_name = \"\") :\n\n with h5py.File(input_fi... | [
"0.6306511",
"0.61508876",
"0.6149109",
"0.5949633",
"0.58010083",
"0.5604665",
"0.54888386",
"0.5464916",
"0.54498684",
"0.54498684",
"0.5439023",
"0.53936875",
"0.5352236",
"0.53444123",
"0.5337886",
"0.5295888",
"0.52500737",
"0.52484035",
"0.5240565",
"0.5201321",
"0.5185... | 0.73735285 | 0 |
Return a Stream object wrapping a concatenation od datasets at `paths`. Each dataset must be 1d or 2d (if 2d, then time is the vertical axis), and they are stacked as columns. In theory should be faster than multiple `stream_channel` and `merge` calls, but depends on the number of datasets and on the `chunk_size`. | def stream_channels(self, paths, chunk_size=10000000, verbose=False):
def gen(paths, chunk_size):
datasets = [self.file[path] for path in paths]
length = len(datasets[0]) # Assume all are the same size
offset = 0
col_sizes = [dataset.shape[0] if dataset.ndim>1 els... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def concatenate_from_paths(cls, paths, schema, **kwargs):\n streams = [open(path, \"rU\") for path in paths]\n return cls.concatenate_from_streams(streams, schema, **kwargs)",
"def concatenate(paths):\n # if only one path object just return copy\n if len(paths) == 1:\n return paths[0].... | [
"0.64080966",
"0.6242597",
"0.61970395",
"0.6169942",
"0.58028203",
"0.57118344",
"0.53240854",
"0.5300275",
"0.529831",
"0.5271258",
"0.5241104",
"0.5220966",
"0.519327",
"0.5187537",
"0.51033413",
"0.50501066",
"0.50359243",
"0.50144637",
"0.50018805",
"0.49417612",
"0.4893... | 0.759247 | 0 |
Returns a numpy array of first `numElems` elements of the stream without consuming them from the stream. | def peek(self, numElems):
self._ensureNumElems(numElems)
# Take either numElems, or the entire head if not enough elements.
last = min(self.head.shape[0], numElems)
return self.head[:last] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read(self,numElems):\n self._ensureNumElems(numElems)\n # Take either numElems, or the entire head if not enough elements.\n last = min(self.head.shape[0], numElems)\n res = self.head[:last]\n self.head = self.head[last:]\n return res",
"def _asarray(source, size):\n... | [
"0.70644504",
"0.56574523",
"0.55341256",
"0.5463243",
"0.5460688",
"0.5437747",
"0.5390174",
"0.5380804",
"0.5321297",
"0.5283705",
"0.52784705",
"0.5272602",
"0.52671504",
"0.5253575",
"0.5215722",
"0.5198634",
"0.51869345",
"0.51869345",
"0.5149594",
"0.5149594",
"0.514220... | 0.70416373 | 1 |
Consumes first `numElems` elements of the stream and returns a numpy array with them. 1d data is concatenated, 2d data is stacked vertically. | def read(self,numElems):
self._ensureNumElems(numElems)
# Take either numElems, or the entire head if not enough elements.
last = min(self.head.shape[0], numElems)
res = self.head[:last]
self.head = self.head[last:]
return res | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def merge(*args, chunk_size=None):\n if chunk_size == None:\n chunk_size = args[0].chunk_size\n def gen():\n while True:\n # When stacking, arrays must be of similar shapes,\n # therefore we first stack all 1d arrays, and then stack them\n ... | [
"0.5822116",
"0.5563216",
"0.5531794",
"0.54539394",
"0.54513526",
"0.54001474",
"0.5296485",
"0.5250147",
"0.52496076",
"0.51933104",
"0.5150464",
"0.51436824",
"0.5129348",
"0.5126586",
"0.508596",
"0.5084975",
"0.5050267",
"0.50400627",
"0.5027853",
"0.5010467",
"0.5008419... | 0.5975388 | 0 |
Place a piece (sprite) on the board | def piece( slot, x, y ):
#print( 'piece x,y = %s, %s' % (x,y) )
global images
i = (4 * slot)
j = images[slot & 0xf] * 2
bw = (slot >> 4) & 1
gd.sprite(i, x, y, j, bw, 0)
gd.sprite(i + 1, x + 16, y, j + 1, bw, 0)
gd.sprite(i + 2, x, y + 16, j + 12, bw, 0)
gd.sprite(i + 3, x + 16, y + 16, j + 13, bw, 0) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def draw_piece(self):\n self.screen.blit(self.image, self.rect)",
"def place_at(self, row, col, piece):\n self.board[row + PADDING][col + PADDING] = piece",
"def place_piece(self, move, piece):\r\n if len(move) > 1:\r\n self.board[move[1][0]][move[1][1]] = ' '\r\n self.bo... | [
"0.75555396",
"0.7513637",
"0.7450242",
"0.74135655",
"0.7406118",
"0.7317528",
"0.7212788",
"0.7206841",
"0.71792126",
"0.7166997",
"0.71481895",
"0.6956051",
"0.69257796",
"0.68178844",
"0.68178844",
"0.6780405",
"0.669677",
"0.66774845",
"0.6633246",
"0.66113526",
"0.65779... | 0.7273403 | 6 |
Convenience function to get the path to the instance config. | def get_instance_config_path():
return join(settings.PROJECT_DIR, "conf", "eoxserver.conf") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def path(self):\n return os.path.join(self.config.get('path', os.getcwd()))",
"def cfg_path(self):\n return self._cfg_path",
"def get_config_path(self):\n\t\treturn call_sdk_function('PrlFoundVmInfo_GetConfigPath', self.handle)",
"def get_config_path(config):\n section = config.sections()[0]... | [
"0.74873763",
"0.73683774",
"0.7295674",
"0.72576624",
"0.70503014",
"0.69795734",
"0.6871692",
"0.6870429",
"0.68692046",
"0.68461007",
"0.6752746",
"0.6733424",
"0.66958183",
"0.6675214",
"0.6665934",
"0.66556245",
"0.66281676",
"0.6578932",
"0.6543936",
"0.654296",
"0.6468... | 0.8381718 | 0 |
Turn the Fortran format string into a float | def string_to_float(in_str):
if "D" not in in_str:
in_str = in_str.replace("-","D-")
out_float = float(in_str.replace("D", "E"))
return out_float | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ffloat(string):\n try:\n return float(string.strip())\n except:\n return 0",
"def stof(fstr):\n return float(fstr.replace(',', '.'))",
"def read_float(v):\n if v.strip() == '':\n return 0.\n try:\n return float(v)\n except ValueError:\n # ENDF6 may omit th... | [
"0.7453782",
"0.73610944",
"0.7324272",
"0.7323958",
"0.7254898",
"0.7230739",
"0.716408",
"0.7113251",
"0.7076061",
"0.70330656",
"0.6993943",
"0.69850624",
"0.69437283",
"0.6923919",
"0.6920324",
"0.6903942",
"0.6851412",
"0.6831058",
"0.68195987",
"0.6810032",
"0.67939925"... | 0.65519345 | 35 |
Return the x and y vectors for alpha and beta | def trans_coeffs(file_name, exci_info):
ntrans_a = exci_info.nocc_a * exci_info.nvirt_a
ntrans_b = exci_info.nocc_b * exci_info.nvirt_b
ntrans_tot = ntrans_a + ntrans_b
raw_array = read_gauss_rwf(file_name)
# list of transition coefficients. Each element is 1 excitation
exci_coeffs_add = []
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_alpha_beta(self, a, b):\n beta = a / b\n alpha = a * beta\n return alpha, beta",
"def _get_alpha_beta(self):\n alpha = tf.nn.softplus(self.alpha_prime)\n beta = -alpha + tf.nn.softplus(self.beta_prime)\n return alpha, beta",
"def _get_alpha_vec(x, y, tris_pts):\n n... | [
"0.68735784",
"0.68204397",
"0.67867076",
"0.6299598",
"0.6199403",
"0.61011344",
"0.60152775",
"0.59740174",
"0.59481496",
"0.5925536",
"0.58475786",
"0.5844231",
"0.5831517",
"0.57823837",
"0.5778254",
"0.5776628",
"0.57758147",
"0.57320166",
"0.5696956",
"0.5686293",
"0.55... | 0.0 | -1 |
Wraps a ModelViewSet method for course validation. Course validation includes checking existence of selected course and checking that the authorized user belongs to selected course. | def access_validation(self, request, *args, **kwargs):
course_id = self.kwargs.get('course_id')
user = self.request.user
user_role_id = getattr(user, user.role).id
course_role_dict = {
'teacher': Course.objects.filter(Q(teachers__id=user_role_id) & Q(id=course_id)),
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _validate_course(self):\n # Verify that the selected mode is valid for the given course .\n course_details = self.cleaned_data.get(self.Fields.COURSE)\n if course_details:\n course_mode = self.cleaned_data.get(self.Fields.COURSE_MODE)\n if not course_mode:\n ... | [
"0.5590755",
"0.53617436",
"0.5145853",
"0.51159775",
"0.508113",
"0.5050647",
"0.5046381",
"0.4923978",
"0.48529267",
"0.48208934",
"0.47914517",
"0.47747445",
"0.47612217",
"0.47533214",
"0.47438258",
"0.4708966",
"0.46987057",
"0.46812943",
"0.46761858",
"0.46756464",
"0.4... | 0.66286105 | 0 |
Factory for building TensorFlow data generators for loading time series data. | def seq2seq_generator(data_path: str, batch_size: int = 256, shuffle: bool = True) -> tf.data.Dataset:
# Load data
with h5py.File(data_path, 'r') as hf:
x = np.array(hf.get('X'))
y = np.array(hf.get('y'))
x = x[..., np.newaxis]
y = y[..., np.newaxis]
# Tensorflow dataset
data ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_tf_data(self) -> tf.data.Dataset:\n dataset = tf.data.Dataset.from_generator(\n generator=lambda: self.pipeline,\n output_types=self.model.output_types(),\n output_shapes=self.model.output_shapes())\n return dataset.repeat().batch(self.batch_size)",
"def ... | [
"0.66462356",
"0.64967215",
"0.64925647",
"0.64921045",
"0.6476613",
"0.6314732",
"0.6290138",
"0.627915",
"0.627915",
"0.62301713",
"0.6161398",
"0.6133778",
"0.61250055",
"0.6109148",
"0.60952944",
"0.60284424",
"0.6001974",
"0.59873",
"0.5963512",
"0.594026",
"0.59273034",... | 0.5460467 | 93 |
Factory for building TensorFlow data generators for loading time series data. | def gan_generator(data_path: str, batch_size: int = 256, shuffle: bool = True) -> tf.data.Dataset:
# Load data
with h5py.File(data_path, 'r') as hf:
x = np.array(hf.get('X'))
y = np.array(hf.get('y'))
combined = np.c_[x, y]
sc_train = MinMaxScaler()
combined = sc_train.fit_transfo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_tf_data(self) -> tf.data.Dataset:\n dataset = tf.data.Dataset.from_generator(\n generator=lambda: self.pipeline,\n output_types=self.model.output_types(),\n output_shapes=self.model.output_shapes())\n return dataset.repeat().batch(self.batch_size)",
"def ... | [
"0.66462356",
"0.64967215",
"0.64925647",
"0.64921045",
"0.6476613",
"0.6314732",
"0.6290138",
"0.627915",
"0.627915",
"0.62301713",
"0.6161398",
"0.6133778",
"0.61250055",
"0.6109148",
"0.60952944",
"0.60284424",
"0.6001974",
"0.59873",
"0.5963512",
"0.594026",
"0.59273034",... | 0.0 | -1 |
Factory for building TensorFlow data generators for loading time series and their extracted features. | def cgan_generator(data_path: str, features_path: str, batch_size: int = 256, shuffle: bool = True) -> tf.data.Dataset:
# Load data
with h5py.File(data_path, 'r') as hf:
x = np.array(hf.get('X'))
y = np.array(hf.get('y'))
combined = np.c_[x, y]
with h5py.File(features_path, 'r') as hf... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _create_tf_datasets(self, split, batch_size):\n out_types = (tf.int32, tf.float32, tf.float32, tf.int32, tf.bool)\n # out_shapes has an additional batch dim (None) and 3 or 1 scenes.\n out_shapes = ((None, None, 2), (None, None, 2, 3), (None, None, 2, 4),\n (None, None... | [
"0.67443097",
"0.66661745",
"0.6650237",
"0.6623372",
"0.64999294",
"0.6340058",
"0.63001215",
"0.6259694",
"0.6207655",
"0.6194978",
"0.6185427",
"0.6185427",
"0.6167378",
"0.6102306",
"0.60838675",
"0.6078142",
"0.60687983",
"0.606182",
"0.6061444",
"0.6024734",
"0.60079116... | 0.0 | -1 |
Factory for building TensorFlow data generators for loading time series and their extracted features. | def cgan_generator_2(data_path: str, features_path: str, batch_size: int = 256, shuffle: bool = True) -> tf.data.Dataset:
# Load data
with h5py.File(data_path, 'r') as hf:
x = np.array(hf.get('X'))
y = np.array(hf.get('y'))
combined = np.c_[x, y][:, :2]
with h5py.File(features_path, '... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _create_tf_datasets(self, split, batch_size):\n out_types = (tf.int32, tf.float32, tf.float32, tf.int32, tf.bool)\n # out_shapes has an additional batch dim (None) and 3 or 1 scenes.\n out_shapes = ((None, None, 2), (None, None, 2, 3), (None, None, 2, 4),\n (None, None... | [
"0.67443097",
"0.66661745",
"0.6650237",
"0.6623372",
"0.64999294",
"0.6340058",
"0.63001215",
"0.6259694",
"0.6207655",
"0.6194978",
"0.6185427",
"0.6185427",
"0.6167378",
"0.6102306",
"0.60838675",
"0.6078142",
"0.60687983",
"0.606182",
"0.6061444",
"0.6024734",
"0.60079116... | 0.0 | -1 |
return ISO8601 compliant date/time format. Should be migrated to Pilot 2 | def timestamp():
tmptz = time.timezone
sign_str = '+'
if tmptz > 0:
sign_str = '-'
tmptz_hours = int(tmptz / 3600)
return str("%s%s%02d:%02d" % (time.strftime("%Y-%m-%dT%H:%M:%S", time.localtime()), sign_str, abs(tmptz_hours),
int(tmptz / 60 - tmptz_hours *... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ISO8601(self):\n if self.timezoneNaive():\n return \"%0.4d-%0.2d-%0.2dT%0.2d:%0.2d:%0.2d\" % (\n self._year, self._month, self._day,\n self._hour, self._minute, self._second)\n tzoffset = _tzoffset2iso8601zone(_tzoffset(self._tz, self._t))\n return ... | [
"0.8031052",
"0.7549923",
"0.75283825",
"0.75212055",
"0.74224776",
"0.739377",
"0.73147774",
"0.7279895",
"0.71151495",
"0.70583504",
"0.70411354",
"0.7027823",
"0.6999905",
"0.6988748",
"0.69877434",
"0.69846934",
"0.69693106",
"0.69264823",
"0.6895225",
"0.6885199",
"0.686... | 0.0 | -1 |
Get all the bad channels for a given plane in the detector. | def GetBadChannelsPlane(self, tracker, station, plane):
planeid = self._getPlaneRef(tracker, station, plane)
return self.badplanelookup[planeid] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _pick_bad_channels(event, params):\n # Both bad lists are updated. params['info'] used for colors.\n bads = params['raw'].info['bads']\n params['info']['bads'] = _select_bads(event, params, bads)\n _plot_update_raw_proj(params, None)",
"def GeneratePlaneBadLookup(self, lookup):\n badplanel... | [
"0.61248296",
"0.5950472",
"0.5560963",
"0.5281573",
"0.5241824",
"0.51673263",
"0.51415074",
"0.51146936",
"0.5025403",
"0.5021278",
"0.4939192",
"0.4880686",
"0.48577687",
"0.48271984",
"0.48190108",
"0.48058408",
"0.47965816",
"0.47965375",
"0.4664127",
"0.46545315",
"0.46... | 0.72485226 | 0 |
Plot confusion matrix for each categories | def plot_confusion_matrix(conf_matrix_list, labels, cm_file_path):
logging.info("run plot_confusion_matrix")
# construct plot figure with 36 subplots in a square grid
fig, ax = plt.subplots(6, 6, figsize=(12, 7))
# for each categories' name and confusion matrices
for axes, cm, label in zip(ax.fla... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_confusion_matrix(self):\r\n interp = ClassificationInterpretation.from_learner(self.learn)\r\n interp.plot_confusion_matrix()",
"def plot_confusion_matrix(cm, classes, acc,\n cmap=plt.cm.Reds):\n\n plt.figure(figsize=(10, 8))\n title = 'Confusion ... | [
"0.79958206",
"0.7797282",
"0.772547",
"0.7710784",
"0.7693405",
"0.76933295",
"0.7672207",
"0.76644045",
"0.7661321",
"0.76542395",
"0.76526475",
"0.76429826",
"0.7642122",
"0.7639309",
"0.76285523",
"0.76215076",
"0.76143986",
"0.7613713",
"0.76110595",
"0.76022375",
"0.760... | 0.0 | -1 |
Report the percentage of correct predictions of a model applied on a set of labels. | def report_prediction_accuracy(y, tx, w_best, verbose=True):
predictions = tx.dot(w_best)
predictions[predictions >= 0] = 1
predictions[predictions < 0] = -1
correct_percentage = np.sum(predictions == y) / float(len(predictions))
if verbose:
print('Percentage of correct predictions is: ', co... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def label_accuracies(preds, labels):\n num_correct = num_correct_fun(preds, labels)\n return (num_correct / preds.size(0)) * 100.0",
"def label_errors(preds, labels):\n num_correct = num_correct_fun(preds, labels)\n return (1.0 - num_correct / preds.size(0)) * 100.0",
"def accuracy(labels, predicti... | [
"0.7871242",
"0.7692111",
"0.7465326",
"0.74451435",
"0.7433113",
"0.740562",
"0.7334789",
"0.7317563",
"0.7218029",
"0.7211699",
"0.7210559",
"0.717335",
"0.71672153",
"0.71659905",
"0.7144537",
"0.7124623",
"0.7090912",
"0.7079722",
"0.70773655",
"0.70764416",
"0.7057367",
... | 0.67366594 | 45 |
Report the percentage of correct predictions of a model that is applied on a set of labels. This method specifically works for logistic regression since the prediction assumes that labels are between 0 and 1. | def report_prediction_accuracy_logistic(y, tx, w_best, verbose=True):
predictions = tx.dot(w_best)
predictions[predictions > 0.5] = 1
predictions[predictions <= 0.5] = 0
correct_percentage = np.sum(predictions == y) / float(len(predictions))
if verbose:
print('Percentage of correct predictio... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def label_accuracies(preds, labels):\n num_correct = num_correct_fun(preds, labels)\n return (num_correct / preds.size(0)) * 100.0",
"def accuracy(labels, predictions):\n if len(labels) != len(predictions):\n return -1\n\n correct = 0\n total = 0\n\n for i,v in enumerate(predictions):\... | [
"0.79064804",
"0.76377076",
"0.7626569",
"0.75967944",
"0.756062",
"0.7556763",
"0.7539606",
"0.7503543",
"0.7439626",
"0.74320936",
"0.7431187",
"0.7404015",
"0.73755205",
"0.7307937",
"0.7298856",
"0.7289553",
"0.7263754",
"0.7205337",
"0.71940637",
"0.7182078",
"0.71450794... | 0.66843253 | 64 |
Starting Adventure then moving once to the WEST. | def move_once():
try:
check50.run(run_command).stdout(room_1_description)
except check50.Failure as error:
raise check50.Failure(f"Expected the description of initial room when Adventure starts.\n {error}")
check50.run(run_command).stdin("WEST").stdout(room_2_description) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def play_game(self):\n # need everyone to pass to move to next phase?\n self.deal_cards()\n self.plant_food()",
"def plant_food(self):\n self.phase.set(0)\n #self.broadcast_phase()\n self.players[self.first_player].take_turn()",
"def play_game(self):\n playe... | [
"0.7167774",
"0.66325593",
"0.65417296",
"0.65364516",
"0.6524741",
"0.6523999",
"0.6479118",
"0.64517695",
"0.6447917",
"0.6422094",
"0.6379985",
"0.6359189",
"0.63509166",
"0.63466007",
"0.63339067",
"0.6290509",
"0.6269523",
"0.62450963",
"0.62108606",
"0.6197317",
"0.6192... | 0.6674562 | 1 |
Initialize an image model object | def __init__(self, model_path, gpu_fraction=1.0,
input_name = 'input_1:0',
output_name = 'output_node0:0',
optimize = True,
optimizer_args = None):
# Create session first with requested gpu_fraction parameter
config = tf.compat.v1.Conf... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, image):\n self.image = image",
"def __init__(self, img):\n self.img = img",
"def __init__(self, image: np.ndarray) -> None:\n self.image = image",
"def __init__(self):\n super(HybridImageModel, self).__init__()",
"def __init__(self, image1, image2):\n self.... | [
"0.7717652",
"0.76432824",
"0.74131936",
"0.7357223",
"0.7033353",
"0.6875327",
"0.6811336",
"0.6811336",
"0.6811336",
"0.6700828",
"0.66547954",
"0.66336644",
"0.6597151",
"0.6580927",
"0.6541128",
"0.6539228",
"0.6539032",
"0.6528956",
"0.6523666",
"0.6508041",
"0.6503518",... | 0.0 | -1 |
Returns the shape of the input image for this network | def inputShape(self):
return self.input_shape | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_input_shape(self):\n return self.network.inputs[self.input_blob].shape",
"def input_shape(self):\n return self._ipt_shape",
"def input_shape(self) ->torch.Size:\n pass",
"def shape(self):\n return self._img.shape",
"def shape(self):\n return self.image.shape",
"... | [
"0.8649809",
"0.8356472",
"0.813365",
"0.8117253",
"0.808485",
"0.79884",
"0.79884",
"0.7955736",
"0.79366237",
"0.7844177",
"0.7808833",
"0.7590165",
"0.7590165",
"0.7590165",
"0.75398207",
"0.75398207",
"0.75398207",
"0.74360204",
"0.74095434",
"0.7397343",
"0.7394603",
"... | 0.837068 | 1 |
Assert a slot site cannot be modified if there is a flyer placement. | def test_modify_slot_site(self):
slot = SLOT_FACTORY.create_slot()
FlyerPlacement.objects.create(site_id=2, slot=slot,
send_date=next_flyer_date())
slot.site = Site.objects.get(id=3)
with self.assertRaises(ValidationError) as context_manager:
slot.save()
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_slot_flyer_placem_bad(self):\n slot = SLOT_FACTORY.create_slot()\n FlyerPlacement.objects.create(site_id=2, slot=slot,\n send_date=next_flyer_date())\n slot.site_id = 3\n with self.assertRaises(ValidationError) as context_manager:\n slot.clean()\n ... | [
"0.78633815",
"0.7079916",
"0.62983745",
"0.597745",
"0.5886045",
"0.5840207",
"0.58233327",
"0.5821704",
"0.56852794",
"0.5625556",
"0.56186026",
"0.55756253",
"0.55640936",
"0.55611664",
"0.55611014",
"0.5516117",
"0.551059",
"0.550255",
"0.5499364",
"0.54895204",
"0.543866... | 0.78529 | 1 |
Assert a slot cannot be modified such that its start date is after the start_datetime of one of its slot_time_frames. | def test_modify_slot_start_late(self):
coupon = COUPON_FACTORY.create_coupon()
slot = Slot.objects.create(site_id=2,
business_id=coupon.offer.business.id,
start_date=datetime.date.today(),
end_date=datetime.date.today() + datetime.timedelta(2))
SlotTimeFrame.o... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_valid_not_modified(self):\n coupon = COUPON_FACTORY.create_coupon()\n past_date = datetime.datetime.now() - datetime.timedelta(60)\n slot = Slot.objects.create(site_id=2,\n business_id=coupon.offer.business.id,\n start_date=past_date,\n end_date=past_d... | [
"0.7740584",
"0.76618403",
"0.71000266",
"0.7085148",
"0.673704",
"0.67104626",
"0.6623965",
"0.63351166",
"0.63146013",
"0.61352897",
"0.6095809",
"0.6070038",
"0.5997575",
"0.5982856",
"0.58851403",
"0.584132",
"0.58356845",
"0.58175594",
"0.5735563",
"0.570813",
"0.5682675... | 0.79038787 | 0 |
Assert a slot with flyer placements cannot change sites. | def test_slot_flyer_placem_bad(self):
slot = SLOT_FACTORY.create_slot()
FlyerPlacement.objects.create(site_id=2, slot=slot,
send_date=next_flyer_date())
slot.site_id = 3
with self.assertRaises(ValidationError) as context_manager:
slot.clean()
self.fail... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_modify_slot_site(self):\n slot = SLOT_FACTORY.create_slot()\n FlyerPlacement.objects.create(site_id=2, slot=slot,\n send_date=next_flyer_date())\n slot.site = Site.objects.get(id=3)\n with self.assertRaises(ValidationError) as context_manager:\n slot.save(... | [
"0.7681225",
"0.70491904",
"0.59680027",
"0.5935951",
"0.5884749",
"0.57971174",
"0.56998223",
"0.5658399",
"0.5636538",
"0.55817765",
"0.5558177",
"0.5510633",
"0.5483465",
"0.54643154",
"0.5458033",
"0.5448332",
"0.54309213",
"0.54027927",
"0.5353414",
"0.534754",
"0.532739... | 0.76242644 | 1 |
Return a dictionary of Landsat path/rows and their geometries | def path_row_wkt_func(input_path, path_field='PATH', row_field='ROW',
tile_fmt='p{0:02d}r{1:02d}'):
output_dict = dict()
input_ds = ogr.Open(input_path, 0)
input_lyr = input_ds.GetLayer()
input_ftr = input_lyr.GetNextFeature()
while input_ftr:
path = input_ftr.GetFieldA... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_shape_dicts(route_short_name, septa_fn):\n \n #modify this path to a sqlite file with\n #the gtfs data in it. \n #to create this file, i used\n #https://github.com/jarondl/pygtfs.git\n e = create_engine(septa_fn)\n Session = sessionmaker(bind = e)\n s = Session()\n\n route_block_... | [
"0.6615435",
"0.5902735",
"0.562384",
"0.5622782",
"0.55859905",
"0.55605197",
"0.5548617",
"0.5479241",
"0.5414328",
"0.5374981",
"0.53623295",
"0.53474003",
"0.53458613",
"0.5343928",
"0.5325275",
"0.5320268",
"0.5293182",
"0.528168",
"0.52514654",
"0.5247206",
"0.5237352",... | 0.551659 | 7 |
Gets the SIM 928 voltage output value from the selected source. | def get_voltage(self, c):
if 'slot_number' in c.keys():
slot_number = c['slot_number']
yield self.open_comm(c, slot_number)
yield self.write(c, 'VOLT?')
voltage = yield self.read(c)
yield self.close_comm(c, slot_number)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def voltage(self):\n return self.outputValue()",
"def voltage(self):\n\t\treturn self._voltage",
"def read_actual_voltage(self):\n function_string = 'V' + self.output + 'O?'\n value_string = self.scpi_comm(function_string)\n LOGGER.warn(value_string)\n time.sleep(0.1) # This ... | [
"0.76975703",
"0.7170357",
"0.7167381",
"0.7091971",
"0.707882",
"0.7049874",
"0.70478016",
"0.70135254",
"0.70114994",
"0.68997383",
"0.687818",
"0.6862341",
"0.67574966",
"0.67447245",
"0.67127234",
"0.6700612",
"0.6648761",
"0.663301",
"0.6542766",
"0.6483619",
"0.64784473... | 0.64835197 | 20 |
Gets SIM 928 voltage output state for the selected slot number. | def get_output_state(self, c):
if 'slot_number' in c.keys():
slot_number = c['slot_number']
if 'output_state' not in c.keys():
try:
output_state = yield self.query(c,
slot_number,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def voltage(self):\n return self.outputValue()",
"def get_voltage(self, c):\n if 'slot_number' in c.keys():\n slot_number = c['slot_number'] \n yield self.open_comm(c, slot_number)\n yield self.write(c, 'VOLT?')\n voltage = yield self.read(c)\n... | [
"0.63390845",
"0.60011977",
"0.58982235",
"0.5888021",
"0.5868136",
"0.5811036",
"0.5797195",
"0.57788026",
"0.5743811",
"0.57337487",
"0.57333994",
"0.57218057",
"0.5718227",
"0.5710561",
"0.5702051",
"0.5701623",
"0.56224227",
"0.5603312",
"0.5540073",
"0.5531823",
"0.55259... | 0.61963123 | 1 |
returns all courses mapped to Course class | def get_courses():
courses = []
courses_recs = Course._file.read_db()
for course in courses_recs["courses"]:
courses.append(Course(**course))
return courses | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_courses(self):\r\n\r\n return self.def_ms.get_courses()",
"def get_courses(self, depth=0):\r\n return self.courses.values()",
"def getCoursesList(self, pageSize=100):\n results = self.service.courses().list(pageSize=pageSize).execute()\n self.courses = results.get('courses',... | [
"0.76317406",
"0.7433428",
"0.70438474",
"0.70121115",
"0.7001081",
"0.6907132",
"0.69066805",
"0.6872299",
"0.68508995",
"0.6741409",
"0.6687205",
"0.66742456",
"0.66447455",
"0.663649",
"0.6608549",
"0.6571368",
"0.65176916",
"0.65051067",
"0.64989233",
"0.6480629",
"0.6468... | 0.78154653 | 0 |
returns the list of students | def get_list_of_students(self):
return self._students | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_students(self) -> List['Student']:\n return self.students.values()",
"def students(self):\n return self._parser.students",
"def students(self):\n\t\treturn self.grade_set.all().distinct()",
"def create_students():\n\n\t# create empty list\n\tstudent_list = []\n\n\t# import student class... | [
"0.82873625",
"0.7877513",
"0.7858565",
"0.76923436",
"0.7558353",
"0.7541415",
"0.75404143",
"0.74475265",
"0.7419316",
"0.74162376",
"0.7408174",
"0.74036086",
"0.7260754",
"0.7233279",
"0.721486",
"0.70674795",
"0.69724274",
"0.6957563",
"0.69317955",
"0.6908784",
"0.68980... | 0.8491717 | 0 |
checks whether student is in students list of course | def is_student_enrolled(self, student_email):
if not self.is_course_exists():
print("Course with name - {} does not exist".format(self._course_name))
return
course = self.get_course()
for s in course._students:
if s == student_email:
return Tru... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __contains__(self,x):\n dbg('_gradelist[..].__contains__(',x,')')\n nems = self._grades #assuming x is a Grade\n if not isinstance(x,Grade): \n #probably looking for a name!\n nems = [q.name for q in self._grades]\n dbg('_gradelist[..].__contains__.nems = ',*ne... | [
"0.6483951",
"0.6436867",
"0.6400396",
"0.6397378",
"0.6390898",
"0.6349866",
"0.6244952",
"0.6189546",
"0.61033106",
"0.60985065",
"0.6055721",
"0.60426754",
"0.6002529",
"0.59932625",
"0.5960789",
"0.59526426",
"0.5951925",
"0.5945947",
"0.58917737",
"0.584523",
"0.58390075... | 0.6804614 | 0 |
Keep only words that pass normalizeOrRemoveWord(), return them as a list | def filterWords(text):
words = text.split()
out = []
for w in words:
w = normalizeOrRemoveWord(w)
if w != None:
out.append(w)
return out | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stopword_filter(words):\n new_words = []\n for w in words:\n if w in stopwords.words(\"german\"): continue\n else: new_words += [w]\n return new_words",
"def stopword_removal(words):\n stops = set(stopwords.words('english'))\n words = [w for w in words if w not in stops]\n ret... | [
"0.7268136",
"0.72538286",
"0.71622425",
"0.7162114",
"0.7100072",
"0.70469993",
"0.70404196",
"0.7009588",
"0.7008717",
"0.69970953",
"0.6989197",
"0.69874895",
"0.69810474",
"0.69805336",
"0.69651985",
"0.69546914",
"0.69517297",
"0.6946344",
"0.69410586",
"0.6937314",
"0.6... | 0.8376103 | 0 |
Setup object from dictionary with parameters. | def _setup_from_parameters(self,params):
# SHOULD WE CHECK HERE THAT INPUT PARAMETERS HAVE SAME KP / Z_STAR ?
# copy input dictionary
self.linP_params=params.copy()
# will add polynomial describing the log power, around kp_kms
linP_kms_2=0.5*params['alpha_star']
linP_k... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setup(self, **kwargs):\n\n for k, v in kwargs.items():\n setattr(self, k, v)",
"def __init__(self, *args, **kwargs):\n for dictionary in [_ for _ in args if isinstance(_, dict)]:\n for key in dictionary:\n setattr(self, key, dictionary[key])\n for key... | [
"0.70206964",
"0.6965815",
"0.69603235",
"0.69603235",
"0.69522285",
"0.6949055",
"0.6882688",
"0.6882688",
"0.6882688",
"0.6820064",
"0.6809252",
"0.678246",
"0.67785233",
"0.6767497",
"0.6759825",
"0.67578596",
"0.6750979",
"0.672112",
"0.6680001",
"0.6644889",
"0.66397643"... | 0.0 | -1 |
Remove URLs from a sample string | def remove_url(sample):
sample["full_text"] = re.sub(r"http\S+", "", sample["full_text"])
return sample | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_URL(sample):\n return re.sub(r\"http\\S+\", \"\", sample)",
"def remove_url(tweet):\n return re.sub(r\"http\\S+\", \"URL\", tweet)",
"def remove_urls(text):\n text = re.sub('(?P<url>https?://[^\\s]+)', '', text)\n return text",
"def remove_urls(text):\n pass",
"def remove_... | [
"0.8735943",
"0.8024629",
"0.7941175",
"0.79276586",
"0.79134667",
"0.79063195",
"0.7805464",
"0.7790042",
"0.7647424",
"0.7633826",
"0.75397545",
"0.75013065",
"0.74350727",
"0.7431088",
"0.7386092",
"0.7302479",
"0.73011416",
"0.7291912",
"0.71393806",
"0.7134624",
"0.71004... | 0.8012376 | 2 |
Returns True if the elements of s when sorted are consecutive integers. | def all_consecutive(s):
for (x, y) in pairwise(sorted(s)):
if y - x != 1:
return False
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def consecutive_ints(ints):\n\n if len(ints) == 0:\n return False\n\n for k in range(len(ints) - 1):\n diff = abs(ints[k] - ints[k+1])\n if diff == 1:\n return True\n\n return False",
"def is_sorted(seq):\n return all(seq[i-1] < seq[i] for i in range(1, len(seq)))",
... | [
"0.74098265",
"0.6928977",
"0.6897801",
"0.6615658",
"0.6598261",
"0.6550628",
"0.64529496",
"0.63946664",
"0.6385006",
"0.6371796",
"0.6316305",
"0.620914",
"0.61585253",
"0.6138976",
"0.6135714",
"0.61216",
"0.60529387",
"0.6033719",
"0.6021474",
"0.6008208",
"0.60057026",
... | 0.74789083 | 0 |
Opens a new database connection if there is none yet for the current application context. | def get_db():
top = _app_ctx_stack.top
if not hasattr(top, 'sqlite_db'):
top.sqlite_db = sqlite3.connect(app.config['DATABASE'])
top.sqlite_db.row_factory = sqlite3.Row
return top.sqlite_db | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def db_open():\n if not hasattr(g, 'sqlite_db'):\n g.sqlite_db = db_connect()\n return g.sqlite_db",
"def open_database(self):\n if self._conn is None:\n self._conn = sqlite3.connect(self._db_path)",
"def open_db(db_name: str = DB_NAME) -> DBConnection:\n return sqlite3.connec... | [
"0.7737639",
"0.7582971",
"0.73180443",
"0.71693045",
"0.70220166",
"0.6966687",
"0.6954785",
"0.69486743",
"0.6897534",
"0.6842663",
"0.68292314",
"0.68191963",
"0.680592",
"0.67950195",
"0.67697805",
"0.6762173",
"0.6751266",
"0.6746273",
"0.67316663",
"0.670031",
"0.668866... | 0.66702753 | 25 |
Verify that an import fails if the imported mojom does not exist. | def testMissingImport(self):
a = 'a.mojom'
self.WriteFile(
a, """\
module a;
import "non-existent.mojom";
struct Bar {};""")
with self.assertRaisesRegexp(ValueError, "does not exist"):
self.ParseMojoms([a]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def testCheckImportsMissing(self):\n a = 'a.mojom'\n a_metadata = 'out/a.build_metadata'\n b = 'b.mojom'\n b_metadata = 'out/b.build_metadata'\n self.WriteFile(a_metadata,\n json.dumps({\n \"sources\": [self.GetPath(a)],\n \"deps\": []\n ... | [
"0.7461903",
"0.7275904",
"0.7138814",
"0.7113217",
"0.7079737",
"0.7037294",
"0.6944042",
"0.69142383",
"0.69015855",
"0.6836902",
"0.67599964",
"0.67475903",
"0.672928",
"0.6668213",
"0.6656134",
"0.6639959",
"0.661349",
"0.6529497",
"0.65285075",
"0.6489404",
"0.6438373",
... | 0.7223841 | 2 |
Verify that an import fails if the imported mojom is not in the set of mojoms provided to the parser on this execution AND there is no preexisting parsed output module already on disk for it. | def testUnparsedImport(self):
a = 'a.mojom'
b = 'b.mojom'
self.WriteFile(a, """\
module a;
struct Bar {};""")
self.WriteFile(
b, """\
module b;
import "a.mojom";
struct Foo { a.Bar bar; };""")
# a.mojom has not been parsed yet, so its import will fail... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def testCheckImportsMissing(self):\n a = 'a.mojom'\n a_metadata = 'out/a.build_metadata'\n b = 'b.mojom'\n b_metadata = 'out/b.build_metadata'\n self.WriteFile(a_metadata,\n json.dumps({\n \"sources\": [self.GetPath(a)],\n \"deps\": []\n ... | [
"0.74225783",
"0.68580514",
"0.6681641",
"0.6539058",
"0.64829755",
"0.6467921",
"0.64035505",
"0.6367649",
"0.6337716",
"0.6335164",
"0.6315197",
"0.62826014",
"0.62718916",
"0.6251536",
"0.6232602",
"0.61881936",
"0.6141252",
"0.61133844",
"0.60503674",
"0.6040266",
"0.5895... | 0.67000496 | 2 |
Redefinition of queryset for the view | def get_queryset(self):
if 'person_id' in self.request.GET:
queryset = Question.objects.all()
if 'my_questions' in self.request.GET:
queryset = (queryset.filter(creator__id=self.request.GET['person_id']))
if 'search_autor' in self.request.GET:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_queryset(self, request, queryset):\n\n return queryset",
"def get_queryset(self):\n return None",
"def get_queryset(self):\n return None",
"def get_queryset(self):\n return \"asdf\"",
"def get_queryset(self):\n return Data.objects.all()",
"def get_queryset(self)... | [
"0.77580863",
"0.74919105",
"0.74919105",
"0.73191786",
"0.6982991",
"0.69799757",
"0.6945096",
"0.68940383",
"0.680753",
"0.6797859",
"0.678566",
"0.67554003",
"0.67505884",
"0.6738525",
"0.6705272",
"0.6696201",
"0.66655976",
"0.66646045",
"0.6662832",
"0.6613625",
"0.65990... | 0.0 | -1 |
Redefinition of queryset for the view | def get_queryset(self):
if 'person_id' in self.request.GET:
queryset = (Answer.objects
.filter(creator__id=self.request.GET['person_id']))
elif 'question_id' in self.request.GET:
queryset = (Answer.objects.filter(question__id=self.request
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_queryset(self, request, queryset):\n\n return queryset",
"def get_queryset(self):\n return None",
"def get_queryset(self):\n return None",
"def get_queryset(self):\n return \"asdf\"",
"def get_queryset(self):\n return Data.objects.all()",
"def get_queryset(self)... | [
"0.77580863",
"0.74919105",
"0.74919105",
"0.73191786",
"0.6982991",
"0.69799757",
"0.6945096",
"0.68940383",
"0.680753",
"0.6797859",
"0.678566",
"0.67554003",
"0.67505884",
"0.6738525",
"0.6705272",
"0.6696201",
"0.66655976",
"0.66646045",
"0.6662832",
"0.6613625",
"0.65990... | 0.0 | -1 |
Provide instance for basic Flask app. | def app(request):
app = flask.Flask(__name__)
return app | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init():\n server = Flask(__name__)\n \n return server",
"def make_server() -> Flask:\n app: Flask = Flask(__name__)\n return app",
"def create_app(self):\r\n self.app = Flask(__name__, instance_relative_config=True)\r\n\r\n # Init the secret key of the app -it is a must... | [
"0.75798887",
"0.74666655",
"0.7463826",
"0.7460829",
"0.74291706",
"0.7410541",
"0.7389104",
"0.7237898",
"0.7182087",
"0.71570164",
"0.7135041",
"0.7120906",
"0.7097216",
"0.7068",
"0.7042895",
"0.7027653",
"0.7025276",
"0.7003195",
"0.69872",
"0.6977798",
"0.69745773",
"... | 0.7255322 | 7 |
Return basic Flask app with an established app context. | def testapp(request, app):
ctx = app.app_context()
ctx.push()
def teardown():
ctx.pop()
request.addfinalizer(teardown)
return app | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def app():\n app = create_app()\n return app",
"def app():\n return create_app()",
"def create_app(testing=False, cli=False):\n app = Flask(__name__)\n app.config.from_object(\"flask_cli.config\")\n\n if testing is True:\n app.config[\"TESTING\"] = True\n\n configure_extensions(app,... | [
"0.836939",
"0.8277128",
"0.7886538",
"0.78150755",
"0.7811015",
"0.7809284",
"0.7780888",
"0.77743506",
"0.77714014",
"0.77698404",
"0.7747037",
"0.77430415",
"0.77399004",
"0.7714849",
"0.7702316",
"0.7672012",
"0.7665288",
"0.7633971",
"0.76006365",
"0.7599737",
"0.7596087... | 0.0 | -1 |
Test Triple Exponential Moving Average. | def test_tema(self):
periods = 200
tema = qufilab.tema(self.close, periods)
tema_talib = talib.TEMA(self.close, periods)
np.testing.assert_allclose(tema, tema_talib, rtol = self.tolerance) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_3a(self):\n known_values = {\n 1: 0,\n 12: 3,\n 23: 2,\n 1024: 31\n }\n\n for number, expected in known_values.items():\n actual = advent_3a(number)\n message = (\"Testing input '{}', expected '{}' but got '{}'\"\n ... | [
"0.62892723",
"0.62653625",
"0.6246335",
"0.6077951",
"0.6063664",
"0.5991172",
"0.59591246",
"0.5884438",
"0.5875656",
"0.5835546",
"0.58348143",
"0.5810547",
"0.560417",
"0.55650103",
"0.5556142",
"0.54927886",
"0.54201156",
"0.5416584",
"0.54040563",
"0.5380211",
"0.537744... | 0.57951003 | 12 |
Connect to the MQTT client | def connect_mqtt():
### TODO: Connect to the MQTT client ###
client = mqtt.Client("41")
client.connect(MQTT_HOST,port=MQTT_PORT, keepalive=MQTT_KEEPALIVE_INTERVAL)
return client | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mqtt_connect():\n global mqtt_client\n logging.debug('connecting to mqtt broker %s', config['mqtt']['host'])\n mqtt_client = paho.Client()\n mqtt_client.tls_set()\n mqtt_client.on_connect = mqtt_on_connect\n mqtt_client.on_message = mqtt_on_message\n mqtt_client.username_pw_set(config['mqtt']['username'... | [
"0.85796714",
"0.8428635",
"0.7963951",
"0.7920447",
"0.7794714",
"0.75743264",
"0.74649715",
"0.74649715",
"0.7373413",
"0.73696387",
"0.7346389",
"0.7338156",
"0.7331327",
"0.72875684",
"0.7278879",
"0.7223587",
"0.7214293",
"0.7207479",
"0.712503",
"0.7106952",
"0.70867497... | 0.8601595 | 0 |
Preprocess input image for inference. Changes image shape from [HxWxC] to [1xCxHxW]. You may need to change code according to your model requirements. | def preprocessing(image, w, h):
image = cv2.resize(image, (w, h))
image = np.transpose(image, (2, 0, 1))
image = image.reshape(1, 3, h, w)
return image | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def preprocess(self, img):\n img_ = image.load_img(img, target_size=(299, 299))\n img_ = image.img_to_array(img_)\n img_ = np.expand_dims(img_, axis=0)\n img_ = preprocess_input(img_)\n return img_",
"def preprocess(self, image, input_shape):\n # image = cv2.cvtColor(ima... | [
"0.8091709",
"0.7933292",
"0.77311146",
"0.76915485",
"0.7511666",
"0.7508585",
"0.747994",
"0.7455124",
"0.7425685",
"0.7403951",
"0.7355058",
"0.72795254",
"0.72446",
"0.7205273",
"0.7186801",
"0.71853864",
"0.7184433",
"0.7161172",
"0.71598864",
"0.71541595",
"0.71163017",... | 0.7058314 | 22 |
Initialize class with number of input features, conv layers. | def __init__(
self, config: SimpleGCNConfig = SimpleGCNConfig(name="simplegcn")
):
super().__init__()
self.edge_lengthscale = config.edge_lengthscale
self.weight_edges = config.weight_edges
self.atom_embedding = nn.Linear(
config.atom_input_features, config.width... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, the_input_shape, num_classes):\n self.the_input_shape = the_input_shape\n self.num_classes = num_classes",
"def __init__(self, n_features, n_templates, n_template_nodes, n_classes, n_hidden_layers, feature_init_mean=0., feature_init_std=1.):\n super().__init__()\n\n ... | [
"0.7326099",
"0.72048867",
"0.7200758",
"0.7153407",
"0.7141172",
"0.7130546",
"0.71173173",
"0.7074235",
"0.70174074",
"0.69571537",
"0.6955571",
"0.693834",
"0.6916583",
"0.69123095",
"0.6880345",
"0.686464",
"0.685392",
"0.6850391",
"0.6845464",
"0.6842833",
"0.68404406",
... | 0.64696527 | 70 |
Transforms the vertices and normals of the mesh such that the origin of the resulting mesh's coordinate frame is at the centroid and the principal axes are aligned with the vertical Z, Y, and X axes. | def _standardize_pose(self):
self.mesh_.center_vertices_bb()
vertex_array_cent = np.array(self.mesh_.vertices())
# find principal axes
pca = sklearn.decomposition.PCA(n_components = 3)
pca.fit(vertex_array_cent)
# count num vertices on side of origin wrt principal axes
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculateMeshNormal(mesh_face_vertices):\n mesh_normal = []\n for mesh in mesh_face_vertices:\n v1x = mesh[1, 0] - mesh[0, 0]\n v1y = mesh[1, 1] - mesh[0, 1]\n v1z = mesh[1, 2] - mesh[0, 2]\n v2x = mesh[2, 0] - mesh[1, 0]\n v2y = mesh[2, 1] - mesh[1, 1]\n v2z = m... | [
"0.6525593",
"0.64589655",
"0.63386613",
"0.6272838",
"0.60727006",
"0.60694283",
"0.60694283",
"0.6056767",
"0.59369475",
"0.59097",
"0.5874956",
"0.5852677",
"0.5843772",
"0.580823",
"0.579929",
"0.57796335",
"0.57417923",
"0.5740103",
"0.5715549",
"0.56859803",
"0.5633433"... | 0.7241301 | 0 |
Creates an in memory repository for the client cards. | def __init__(self):
self.__storage = {} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new_from_cards():\n log_request(request)\n data = request.json\n \n if not valid_params(['username', 'deck_name', 'description', 'cards', 'session_id'], data):\n logging.debug(\"Missing parameters\")\n return jsonify({'error' : 500})\n \n username = data['username']\n dec... | [
"0.5652824",
"0.56190675",
"0.55942696",
"0.55875534",
"0.5555107",
"0.5541201",
"0.5514296",
"0.54700917",
"0.53988624",
"0.53588414",
"0.53367114",
"0.53283167",
"0.5327179",
"0.5315572",
"0.5284003",
"0.52683854",
"0.52603686",
"0.5238103",
"0.5178416",
"0.5176272",
"0.515... | 0.0 | -1 |
Create the package name from a filename that contains the whole path. | def extract_suite_name(file_path, project_name):
suite_name = str(project_name) + "."
suite_name = suite_name + os.path.splitext(str(file_path).replace(os_sep, "."))[0]
return suite_name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _format_filename(filename: str) -> str:\n stdlib = (\n f\"{sys.prefix}/lib/python{sys.version_info.major}.{sys.version_info.minor}/\"\n )\n site_pkg = f\"{sys.prefix}/lib/python{sys.version_info.major}.{sys.version_info.minor}/site-packages/\"\n home = f\"{Path.home()}/\"\n cwd = f\"{Path... | [
"0.7358309",
"0.6815504",
"0.68074465",
"0.6752537",
"0.6749479",
"0.66622144",
"0.6656041",
"0.6618932",
"0.659578",
"0.65727305",
"0.6527444",
"0.651673",
"0.6509434",
"0.64720184",
"0.64376783",
"0.643493",
"0.63837117",
"0.63672787",
"0.63419753",
"0.63081545",
"0.6299007... | 0.5913786 | 93 |
this function splits a dataset into n = len(split_list) disjointed datasets | def split_simple_json_language_model_dataset(dataset: SimpleJsonLanguageModelDataset, split_list):
import numpy as np
# create a list of lengths [0.1, 0.4, 0.5] -> [100, 500, 1000(=len_data)]
split_list = np.multiply(np.cumsum(split_list), len(dataset)).astype("int").tolist()
# list of shuffled indices ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def split_simplified_json_acceptor_dataset(dataset: SimpleJsonAcceptorDataset, split_list):\n import numpy as np\n # create a list of lengths [0.1, 0.4, 0.5] -> [100, 500, 1000(=len_data)]\n split_list = np.multiply(np.cumsum(split_list), len(dataset)).astype(\"int\").tolist()\n # list of shuffled indi... | [
"0.7199985",
"0.7183539",
"0.702069",
"0.6972421",
"0.6942974",
"0.69273907",
"0.68854773",
"0.6841575",
"0.6778787",
"0.6740829",
"0.67270815",
"0.671384",
"0.6676607",
"0.65896827",
"0.65881675",
"0.6561787",
"0.65356535",
"0.65280485",
"0.6517825",
"0.6500705",
"0.6474087"... | 0.69952285 | 3 |
this function splits a dataset into n = len(split_list) disjointed datasets | def split_simplified_json_acceptor_dataset(dataset: SimpleJsonAcceptorDataset, split_list):
import numpy as np
# create a list of lengths [0.1, 0.4, 0.5] -> [100, 500, 1000(=len_data)]
split_list = np.multiply(np.cumsum(split_list), len(dataset)).astype("int").tolist()
# list of shuffled indices to samp... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def split_data(self):\r\n print('split data')\r\n np.random.shuffle(self.dataList)\r\n l = len(self.dataList)/self.fold\r\n self.dataList = [self.dataList[i*l: (i+1)*l] for i in range(self.fold-1)] + [self.dataList[(self.fold-1)*l:]] # each element in the list is splitted data list\r",... | [
"0.7184243",
"0.7020519",
"0.69961977",
"0.69733965",
"0.6942246",
"0.692669",
"0.68858796",
"0.6841991",
"0.6778319",
"0.6740616",
"0.67276645",
"0.6713794",
"0.66745126",
"0.65899247",
"0.65868694",
"0.65617746",
"0.6536151",
"0.65287596",
"0.65183157",
"0.6500121",
"0.6475... | 0.7201067 | 0 |
Convert a snake case string to camel case. | def snake_to_camel_case(snake_str: str) -> str:
words = snake_str.strip("_").split("_")
return words[0] + "".join(word[:1].upper() + word[1:] for word in words[1:]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def snake_to_camel(snake_str):\n title_str = snake_str.split('_')\n return ' '.join(title_str).title()",
"def snake_to_camel_case(string: str):\n return ''.join(string_component.title() for string_component in string.split('_'))",
"def snake_to_camel(string):\n \n camel_case = []\n\n for ... | [
"0.83920556",
"0.82715195",
"0.8106933",
"0.8031035",
"0.80189705",
"0.7861413",
"0.78282315",
"0.7821179",
"0.7792496",
"0.7754196",
"0.7745883",
"0.773233",
"0.77296615",
"0.76856786",
"0.7622103",
"0.754372",
"0.75140065",
"0.7498547",
"0.7498547",
"0.7460533",
"0.74504083... | 0.85066724 | 0 |
Get the head node id. Iterate through all nodes in the ray cluster and return the node id of the first alive node with head node resource. | def get_head_node_id() -> str:
head_node_id = None
for node in ray.nodes():
if HEAD_NODE_RESOURCE_NAME in node["Resources"] and node["Alive"]:
head_node_id = node["NodeID"]
break
assert head_node_id is not None, "Cannot find alive head node."
return head_node_id | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def loadHeadId(self):\n rec = self.db.selectById(self.tableName, 1)\n if rec:\n self.headId = rec['childId']\n return self.headId\n print('Error! No first sublist record found.')\n return None",
"def get_head_node_ip(self):\n dashboard_root = self.get_by_id(Da... | [
"0.671215",
"0.6701873",
"0.66886413",
"0.6480033",
"0.64682245",
"0.6271473",
"0.6268742",
"0.62582123",
"0.6184551",
"0.601184",
"0.6004681",
"0.60040486",
"0.5910604",
"0.59034836",
"0.582966",
"0.58114076",
"0.5793033",
"0.57766134",
"0.57257324",
"0.57257324",
"0.5710767... | 0.8895967 | 0 |
Create array of zeros | def fitstart(self):
return np.zeros(self.exog.shape[1]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def zeros(n):\n return [0 for i in range(n)]",
"def zeros_like(data):\n return _make.zeros_like(data)",
"def zero(self):\n return np.zeros([self.nx])",
"def zeros(dim):\n\n return np.zeros(dim, dtype='uint8')",
"def zerovec(self, X):\n return np.zeros(X.size())",
"def value_zeros(s... | [
"0.7918194",
"0.7747626",
"0.7739681",
"0.7654799",
"0.7569704",
"0.75592136",
"0.7489521",
"0.746419",
"0.74546695",
"0.7445473",
"0.7386749",
"0.73800087",
"0.73686373",
"0.73237073",
"0.7277108",
"0.7277108",
"0.72404116",
"0.7231769",
"0.7210081",
"0.71698105",
"0.7169139... | 0.0 | -1 |
month = Month to be predicted, expected format MM year = Year of month to be predicted, expected format yyyy | def get_predictions(year, month):
start_date = str(year)+"-"+str(month)+"-01"
end_date = str(year)+"-"+str(month)+"-"+str(monthrange(year, month)[1])
date_range = pd.date_range(start_date,end_date, freq='D').strftime("%Y-%m-%d").tolist()
# predictfunction
# do predictions
pred_arr = []
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_month():\n return handle_invalid_inputs(question_3, months)",
"def month(self):\n return 0",
"def month(self):\n return 0",
"def year_month(cls,\n year: typing.Union[int, str],\n month: typing.Union[int, str])->str:\n yearstr: str\n i... | [
"0.7081572",
"0.6782309",
"0.6782309",
"0.6686441",
"0.66647196",
"0.65147257",
"0.64489126",
"0.644196",
"0.6401168",
"0.6366427",
"0.63189125",
"0.63072455",
"0.6286175",
"0.6273243",
"0.62700665",
"0.6258982",
"0.62423307",
"0.6233265",
"0.62054217",
"0.6195906",
"0.619390... | 0.56801903 | 78 |
Creates an ArgumentParser to read the options for this script from sys.argv | def make_argument_parser():
parser = argparse.ArgumentParser()
parser.add_argument("data_directory",
help="Directory where the data files live.")
parser.add_argument("out", help="Output directory of files.")
parser.add_argument("-t", "--test", action="store_true",
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_command_line(self, argv):\n from optparse import OptionParser\n usage = \"usage: %prog [options]\"\n parser = OptionParser(usage)\n\n (options, args) = parser.parse_args(argv)",
"def _init_parser():\n\t\n\t_parser = argparse.ArgumentParser()\n\t_parser.add_argument(\"--pull\... | [
"0.77495533",
"0.7427968",
"0.7407757",
"0.73361915",
"0.73148197",
"0.7309196",
"0.72941315",
"0.729033",
"0.7288606",
"0.72717685",
"0.72671",
"0.72608715",
"0.7257929",
"0.72291887",
"0.72102225",
"0.7202624",
"0.71952707",
"0.7194806",
"0.71738976",
"0.71731013",
"0.71731... | 0.7051707 | 29 |
Read a file and return its contents as a list. \n and \r are removed from the end of each line. | def contents(filepath):
f = open(filepath, 'r')
rval = [x.rstrip("\r\n") for x in f.readlines()]
f.close()
return rval | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def file_to_list(file_name):\r\n fr = open(file_name, encoding = 'utf-8')\r\n l = [line.strip() for line in fr]\r\n fr.close()\r\n return l",
"def get_file_contents_as_list(file_name):\n with open(file_name) as file:\n data = file.read().splitlines()\n return data",
"def re... | [
"0.8080656",
"0.80013096",
"0.7955879",
"0.7927518",
"0.79060733",
"0.78917086",
"0.78774464",
"0.78428364",
"0.7833556",
"0.7824648",
"0.78093654",
"0.7790631",
"0.7751445",
"0.77492845",
"0.7687986",
"0.767622",
"0.76651824",
"0.7643231",
"0.76290494",
"0.76240045",
"0.7562... | 0.76262283 | 19 |
Compute probability of negative correlation matrix. | def npm(self):
num_subjects = self.nw.shape[2]
self.P = np.sum(self.nw < 0, axis=2) / num_subjects
return self | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _corrtheoerr(self, nvar):\n min_var = self.proje_var.argsort()[:nvar]\n proje_cov_inv = np.linalg.inv(self.proje_cov[min_var][:, min_var])\n return 1/np.sum(proje_cov_inv)",
"def mp_corr(self):\n a, c, d, b = self.to_ccw()\n p1, q1 = a + b, c + d\n p2, q2 = a + c, b ... | [
"0.59116715",
"0.5833177",
"0.5826051",
"0.58201087",
"0.58058614",
"0.5800813",
"0.5748519",
"0.57311296",
"0.5694853",
"0.56917757",
"0.5683683",
"0.56661004",
"0.56511396",
"0.562607",
"0.5620447",
"0.561948",
"0.5592494",
"0.55850726",
"0.5572602",
"0.5567935",
"0.5556673... | 0.0 | -1 |
Compute distance to origin of embedding. | def distance_to_origin(self):
self.D = edist(self.isomap,
np.zeros([1, self.isomap.shape[1]])).flatten() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def distance_to_origin(self):\n return np.sqrt(self.x ** 2 + self.y ** 2)",
"def distance_from_origin(self):\n return ((self.x ** 2) + (self.y ** 2)) **0.5",
"def distance_from_origin(self):\n return ((self.x ** 2) + (self.y ** 2)) ** 0.5",
"def distance_from_origin(self):\n return ... | [
"0.79157805",
"0.7855354",
"0.7848784",
"0.7848784",
"0.7848784",
"0.7848784",
"0.7848784",
"0.7848784",
"0.7848784",
"0.7840683",
"0.76216936",
"0.75263345",
"0.7159884",
"0.6941558",
"0.6691831",
"0.6689198",
"0.6631622",
"0.6624444",
"0.66191137",
"0.6532472",
"0.6530253",... | 0.73793375 | 12 |
Transforms Tensor to numpy. | def make_np(x: Union[Tensor, np.ndarray, Number]) -> np.ndarray:
if isinstance(x, np.ndarray):
return x
if np.isscalar(x):
return np.array([x])
if isinstance(x, Tensor):
return x.detach().cpu().numpy()
raise NotImplementedError(
"Got {}, but numpy array, scalar, or torch ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_numpy(tensor):\n raise NotImplementedError",
"def _torch_to_numpy(tensor):\n return tensor.detach().cpu().numpy()",
"def numpy(x):\n if isinstance(x, torch.Tensor):\n x = x.detach().cpu().numpy()\n elif isinstance(x, tf.Tensor):\n x = x.numpy()\n return x.astype(np.floa... | [
"0.865773",
"0.79550344",
"0.7905405",
"0.7781543",
"0.77757764",
"0.76597416",
"0.7593022",
"0.7478778",
"0.7463445",
"0.7421553",
"0.7364014",
"0.72990674",
"0.7292116",
"0.7270427",
"0.7156812",
"0.71258116",
"0.70515126",
"0.69874114",
"0.690894",
"0.6898046",
"0.6866942"... | 0.7213085 | 14 |
Exponential decay factor alpha for a given tau (decay window size [s]). | def _calculate_norm_alpha(sr: int, hop_size: int, tau: float):
dt = hop_size / sr
return math.exp(-dt / tau) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_exp_decay(self, alpha: float):\n x = np.linspace(0, 1, 100)\n y = np.exp(alpha * x)\n\n alpha_guess = guess.exp_decay(x, y)\n\n self.assertAlmostEqualAbsolute(alpha_guess, alpha)",
"def set_decay_rate(self,alpha):\n if not isinstance(alpha,np.ndarray):\n alp... | [
"0.6965109",
"0.68987036",
"0.68590426",
"0.6759444",
"0.65288174",
"0.649881",
"0.64560324",
"0.6417596",
"0.6402563",
"0.63517445",
"0.6323861",
"0.63229555",
"0.63160884",
"0.627504",
"0.62685233",
"0.6263686",
"0.6241628",
"0.62409884",
"0.6184035",
"0.61641264",
"0.61613... | 0.64983374 | 6 |
strip any whitespace then outter characters. | def parse_tuple(tuple_string):
return tuple_string.strip().strip("\"[]") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def strip_space():\n pass",
"def _removeWhitespaces(self, s):\n return s.translate({ord(c): None for c in string.whitespace})",
"def strip_other_charcter():\n pass",
"def strip_whitespace(self, text):\n\t\treturn text.strip()",
"def _StripWS(s):\r\n return re.sub('\\s+', '', s)",
"def _Stri... | [
"0.7748556",
"0.75171465",
"0.7503736",
"0.74134153",
"0.7404506",
"0.7404506",
"0.73442906",
"0.7074216",
"0.7074161",
"0.7064353",
"0.7038751",
"0.70189506",
"0.70023394",
"0.7000071",
"0.6998789",
"0.6950758",
"0.69427323",
"0.6892519",
"0.68918943",
"0.6854954",
"0.685420... | 0.0 | -1 |
download dataset file and return dictionary including training/validation split | def get_dataset(data_name: str = 'wnut_17', label_to_id: dict = None, allow_update: bool=True):
label_to_id = dict() if label_to_id is None else label_to_id
data_path = os.path.join(CACHE_DIR, data_name)
def decode_file(file_name, _label_to_id: dict):
inputs, labels = [], []
with open(os.pa... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def download_dataset(\n dataset: Literal['penntreebank', 'wikitext2', 'wikitext103'],\n data_dir: str,\n) -> tuple[IterableDataset[str], IterableDataset[str], IterableDataset[str]]:\n datasets = {}\n for split in ('train', 'valid', 'test'):\n if dataset.lower() == 'penntreebank':\n da... | [
"0.68258333",
"0.66840726",
"0.65688664",
"0.6510446",
"0.63808805",
"0.63656235",
"0.6340215",
"0.63361245",
"0.6316002",
"0.62699366",
"0.62672967",
"0.626569",
"0.62558717",
"0.623332",
"0.6233109",
"0.62287945",
"0.61991155",
"0.61916643",
"0.61909544",
"0.61437",
"0.6125... | 0.0 | -1 |
Modify setup.cfg to add install_requires and pytest settings | def modify_setupcfg(struct, opts):
opts["namespace"] = [PYSCAFFOLDEXT_NS]
setupcfg_path = [opts["project"], "setup.cfg"]
struct = helpers.modify(struct, setupcfg_path, add_install_requires)
struct = helpers.modify(struct, setupcfg_path, add_pytest_requirements)
struct = helpers.modify(struct, setupc... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_pytest_requirements(setupcfg_str):\n setupcfg = ConfigUpdater()\n setupcfg.read_string(setupcfg_str)\n extras_require = setupcfg['options.extras_require']\n extras_require['testing'].set_values(['flake8',\n 'pytest',\n ... | [
"0.7890031",
"0.6854879",
"0.67244124",
"0.66400105",
"0.6521497",
"0.6349635",
"0.630472",
"0.63008094",
"0.6271522",
"0.62125844",
"0.62074906",
"0.6204412",
"0.6204412",
"0.6204412",
"0.60907084",
"0.6055785",
"0.60537934",
"0.60504746",
"0.6031955",
"0.5960534",
"0.595468... | 0.7287702 | 1 |
Lays out a [N, H, W, C] image array as a single image grid. | def _make_grid(imarray, cols=4, pad=1, padval=255):
pad = int(pad)
if pad < 0:
raise ValueError('pad must be non-negative')
cols = int(cols)
assert cols >= 1
N, H, W, C = imarray.shape
rows = N // cols + int(N % cols != 0)
batch_pad = rows * cols - N
assert batch_pad >= 0
pos... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def grid_image(output):\n grid = []\n for data in output:\n grid += [make_grid(data, nrow=5, normalize=True)]\n return grid",
"def create_grid(images, n_rows=4, n_cols=4):\n k = min(n_rows * n_cols, len(images))\n indices = [i for i in range(k)]\n return _create_grid(images, indices, n_r... | [
"0.7380985",
"0.722367",
"0.72193944",
"0.7196341",
"0.67317426",
"0.6663164",
"0.66591406",
"0.6534534",
"0.6519759",
"0.64165",
"0.6377872",
"0.6377872",
"0.63755167",
"0.6347957",
"0.6319809",
"0.6286931",
"0.6279665",
"0.6227293",
"0.6221285",
"0.6218103",
"0.6216886",
... | 0.66335875 | 7 |
Visualizes the images in realonly mode. | def _real_only_visualize(fake_img, real_img, caption, num, num_per_caption, num_per_row, model):
real_img = _post_process(real_img, model)
grid = _make_grid(real_img, cols=num_per_row)
grid = tf.convert_to_tensor(grid, dtype=tf.uint8)
return real_img, grid | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def displayImages(self):\n\n plt.figure(figsize=(8,6))\n plt.subplot(1,2,1)\n plt.imshow( self.original_image, cmap=\"gray\")\n plt.title(\"Original Image\")\n plt.subplot(1,2,2)\n plt.imshow( self.blurred_image, cmap=\"gray\")\n plt.title(\"Blurred Image\")",
"de... | [
"0.7178462",
"0.71104944",
"0.6729432",
"0.66617453",
"0.66121",
"0.661191",
"0.66069067",
"0.65909886",
"0.6518474",
"0.65091676",
"0.6508016",
"0.64301366",
"0.64213306",
"0.641656",
"0.6413523",
"0.64044183",
"0.6391974",
"0.637897",
"0.6373977",
"0.636835",
"0.6360143",
... | 0.66745794 | 3 |
Return a string of the content of the class. | def __str__(self):
return (
"API Name: {apiName:s}\n"
"API Username: {apiUser:s}\n"
"API Password: {apiPass:s}\n"
"API URL: {apiURL:s}\n"
"Data Path: {dataPath:s}\n"
).format(
apiName = self.apiName,
apiUser... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __str__(self):\n return repr(self.content)",
"def content(self) -> str:\r\n return self._content",
"def __str__(self):\n return ''.join(self.contents)",
"def contents(self) -> str:\n return(self._contents)",
"def __repr__(self):\n return repr(self.contents)",
"def __rep... | [
"0.7037365",
"0.68746835",
"0.68527365",
"0.6778612",
"0.6742392",
"0.66767204",
"0.66615826",
"0.66602737",
"0.66602737",
"0.66533655",
"0.6577777",
"0.6568595",
"0.65343",
"0.6533232",
"0.6533232",
"0.6533232",
"0.65317065",
"0.6512414",
"0.6512365",
"0.6512365",
"0.6499095... | 0.0 | -1 |
is.find_boxes_under_coord(num,num) > [Box] Returns all of the boxes underneath image location (x,y). | def find_boxes_under_coord(self,x,y):
return tuple(r[self.box_col] for r in self.model if rect_contains(r[self.box_col].rect,x,y)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def box_in_image(box, image):\r\n rows = image.shape[0]\r\n cols = image.shape[1]\r\n return box[0] >= 0 and box[1] >= 0 and box[2] <= cols and box[3] <= rows",
"def _boxes_in_bbox(self, document):\n bbox = self._bbox\n boxes = document.get_boxes()\n return [box for box ... | [
"0.68882775",
"0.6715736",
"0.66976124",
"0.6626913",
"0.65848416",
"0.65710986",
"0.64194447",
"0.63852483",
"0.63555825",
"0.6348769",
"0.63056386",
"0.62108004",
"0.6199009",
"0.6186366",
"0.617191",
"0.61693555",
"0.6151418",
"0.6103108",
"0.6093899",
"0.60877305",
"0.607... | 0.7961827 | 0 |
Insert an element at the nth position in the Linkedlist. | def insert_middle(self, ele, position):
if position == 0 and not self.head:
new_node = Node(ele)
new_node.next = new_node
self.head = new_node
elif position > self.length():
raise LinkedListException
else:
current = self.head
prev = self.head
counter = 0
while... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def insert(self, index, value):\n # check the validity of index\n if index < 0 or index > self.n: # larger than no. of items\n print(\"Index Error; please input valid index\")\n return\n # if index==0, same as push_front\n if index==0:\n self.push_front... | [
"0.7506879",
"0.7337873",
"0.73338896",
"0.72380835",
"0.7225943",
"0.7213076",
"0.7169024",
"0.7167143",
"0.71494186",
"0.71048874",
"0.71001285",
"0.70599335",
"0.705492",
"0.69927484",
"0.6959111",
"0.69580513",
"0.694763",
"0.6937996",
"0.693408",
"0.6920292",
"0.6916921"... | 0.6204685 | 63 |
Get the current experiment id. | def get_job_id():
# Get yarn application or K8s experiment ID when running distributed training
if env.get_env(_JOB_ID_ENV_VAR) is not None:
return env.get_env(_JOB_ID_ENV_VAR)
else: # set Random ID when running local training
job_id = uuid.uuid4().hex
os.environ[_JOB_ID_ENV_VAR] = ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_experiment_id(experiment_name: str, config: SQAConfig) -> Optional[int]:\n exp_sqa_class = config.class_to_sqa_class[Experiment]\n with session_scope() as session:\n sqa_experiment_id = (\n session.query(exp_sqa_class.id) # pyre-ignore\n .filter_by(name=experiment_name)... | [
"0.7000055",
"0.6813342",
"0.6809691",
"0.6809691",
"0.6809691",
"0.6809691",
"0.6809691",
"0.6809691",
"0.6809691",
"0.6809691",
"0.6809691",
"0.6809691",
"0.6809691",
"0.6809691",
"0.6809691",
"0.6809691",
"0.6809691",
"0.6809691",
"0.6809691",
"0.6809691",
"0.6809691",
"... | 0.0 | -1 |
Initialize the transition parameters. The parameters will be initialized randomly from a uniform distribution between 0.1 and 0.1. | def reset_parameters(self) -> None:
nn.init.uniform_(self.start_transitions, -0.1, 0.1)
nn.init.uniform_(self.end_transitions, -0.1, 0.1)
nn.init.uniform_(self.transitions, -0.1, 0.1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reset_parameters(self, init_transitions) -> None:\n nn.init.uniform_(self.start_transitions, -0.1, 0.1)\n nn.init.uniform_(self.end_transitions, -0.1, 0.1)\n if not init_transitions:\n nn.init.uniform_(self.transitions, -0.1, 0.1)",
"def __init__(self, transition, time_steps):... | [
"0.73451084",
"0.7069381",
"0.69564855",
"0.6894689",
"0.68848574",
"0.68810326",
"0.6771471",
"0.67523175",
"0.66436225",
"0.65703744",
"0.6535196",
"0.6523617",
"0.64791125",
"0.647577",
"0.64482796",
"0.6446289",
"0.6442313",
"0.6434945",
"0.6431381",
"0.64138424",
"0.6407... | 0.73760986 | 0 |
Check representation of a transformed dimension. | def test_repr_format(self):
t = Identity()
assert t.repr_format("asfa") == "asfa" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_dimension(dimension, transform=None):\n if isinstance(dimension, Dimension):\n return dimension\n\n if not isinstance(dimension, (list, tuple, np.ndarray)):\n raise ValueError(\"Dimension has to be a list or tuple.\")\n\n # A `Dimension` described by a single value is assumed to be... | [
"0.6601862",
"0.6167027",
"0.6046284",
"0.60089576",
"0.59311587",
"0.59085476",
"0.5894478",
"0.5852796",
"0.5845249",
"0.5781944",
"0.57811064",
"0.5660137",
"0.5646089",
"0.561485",
"0.55891615",
"0.55763173",
"0.5574433",
"0.55693966",
"0.5557644",
"0.5556008",
"0.5466861... | 0.0 | -1 |
Check representation of a transformed dimension. | def test_repr_format(self):
t = Reverse(Quantize())
assert t.repr_format("asfa") == "ReverseQuantize(asfa)" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_dimension(dimension, transform=None):\n if isinstance(dimension, Dimension):\n return dimension\n\n if not isinstance(dimension, (list, tuple, np.ndarray)):\n raise ValueError(\"Dimension has to be a list or tuple.\")\n\n # A `Dimension` described by a single value is assumed to be... | [
"0.66009927",
"0.61655766",
"0.60451436",
"0.6008891",
"0.59300977",
"0.5907829",
"0.5893205",
"0.58523893",
"0.5844773",
"0.578081",
"0.57806385",
"0.5659487",
"0.56460017",
"0.56143785",
"0.5587609",
"0.55753785",
"0.55740553",
"0.55687946",
"0.55569714",
"0.55546796",
"0.5... | 0.0 | -1 |
Check representation of a transformed dimension. | def test_repr_format(self):
t = Compose([Enumerate([2, "asfa", "ipsi"]), OneHotEncode(3)], "categorical")
assert t.repr_format("asfa") == "OneHotEncode(Enumerate(asfa))" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_dimension(dimension, transform=None):\n if isinstance(dimension, Dimension):\n return dimension\n\n if not isinstance(dimension, (list, tuple, np.ndarray)):\n raise ValueError(\"Dimension has to be a list or tuple.\")\n\n # A `Dimension` described by a single value is assumed to be... | [
"0.6601862",
"0.6167027",
"0.6046284",
"0.60089576",
"0.59311587",
"0.59085476",
"0.5894478",
"0.5852796",
"0.5845249",
"0.5781944",
"0.57811064",
"0.5660137",
"0.5646089",
"0.561485",
"0.55891615",
"0.55763173",
"0.5574433",
"0.55693966",
"0.5557644",
"0.5556008",
"0.5466861... | 0.0 | -1 |
Check representation of a transformed dimension. | def test_repr_format(self):
t = Precision()
assert t.repr_format("asfa") == "Precision(4, asfa)" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_dimension(dimension, transform=None):\n if isinstance(dimension, Dimension):\n return dimension\n\n if not isinstance(dimension, (list, tuple, np.ndarray)):\n raise ValueError(\"Dimension has to be a list or tuple.\")\n\n # A `Dimension` described by a single value is assumed to be... | [
"0.66009927",
"0.61655766",
"0.60451436",
"0.6008891",
"0.59300977",
"0.5907829",
"0.5893205",
"0.58523893",
"0.5844773",
"0.578081",
"0.57806385",
"0.5659487",
"0.56460017",
"0.56143785",
"0.5587609",
"0.55753785",
"0.55740553",
"0.55687946",
"0.55569714",
"0.55546796",
"0.5... | 0.0 | -1 |
Check representation of a transformed dimension. | def test_repr_format(self):
t = Quantize()
assert t.repr_format("asfa") == "Quantize(asfa)" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_dimension(dimension, transform=None):\n if isinstance(dimension, Dimension):\n return dimension\n\n if not isinstance(dimension, (list, tuple, np.ndarray)):\n raise ValueError(\"Dimension has to be a list or tuple.\")\n\n # A `Dimension` described by a single value is assumed to be... | [
"0.6601862",
"0.6167027",
"0.6046284",
"0.60089576",
"0.59311587",
"0.59085476",
"0.5894478",
"0.5852796",
"0.5845249",
"0.5781944",
"0.57811064",
"0.5660137",
"0.5646089",
"0.561485",
"0.55891615",
"0.55763173",
"0.5574433",
"0.55693966",
"0.5557644",
"0.5556008",
"0.5466861... | 0.0 | -1 |
Check representation of a transformed dimension. | def test_repr_format(self):
t = Enumerate([2, "asfa", "ipsi"])
assert t.repr_format("asfa") == "Enumerate(asfa)" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_dimension(dimension, transform=None):\n if isinstance(dimension, Dimension):\n return dimension\n\n if not isinstance(dimension, (list, tuple, np.ndarray)):\n raise ValueError(\"Dimension has to be a list or tuple.\")\n\n # A `Dimension` described by a single value is assumed to be... | [
"0.66009927",
"0.61655766",
"0.60451436",
"0.6008891",
"0.59300977",
"0.5907829",
"0.5893205",
"0.58523893",
"0.5844773",
"0.578081",
"0.57806385",
"0.5659487",
"0.56460017",
"0.56143785",
"0.5587609",
"0.55753785",
"0.55740553",
"0.55687946",
"0.55569714",
"0.55546796",
"0.5... | 0.0 | -1 |
Check representation of a transformed dimension. | def test_repr_format(self):
t = OneHotEncode(3)
assert t.repr_format("asfa") == "OneHotEncode(asfa)" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_dimension(dimension, transform=None):\n if isinstance(dimension, Dimension):\n return dimension\n\n if not isinstance(dimension, (list, tuple, np.ndarray)):\n raise ValueError(\"Dimension has to be a list or tuple.\")\n\n # A `Dimension` described by a single value is assumed to be... | [
"0.6601862",
"0.6167027",
"0.6046284",
"0.60089576",
"0.59311587",
"0.59085476",
"0.5894478",
"0.5852796",
"0.5845249",
"0.5781944",
"0.57811064",
"0.5660137",
"0.5646089",
"0.561485",
"0.55891615",
"0.55763173",
"0.5574433",
"0.55693966",
"0.5557644",
"0.5556008",
"0.5466861... | 0.0 | -1 |
Check representation of a transformed dimension. | def test_repr_format(self):
t = Linearize()
assert t.repr_format(1.0) == "Linearize(1.0)" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_dimension(dimension, transform=None):\n if isinstance(dimension, Dimension):\n return dimension\n\n if not isinstance(dimension, (list, tuple, np.ndarray)):\n raise ValueError(\"Dimension has to be a list or tuple.\")\n\n # A `Dimension` described by a single value is assumed to be... | [
"0.6601862",
"0.6167027",
"0.6046284",
"0.60089576",
"0.59311587",
"0.59085476",
"0.5894478",
"0.5852796",
"0.5845249",
"0.5781944",
"0.57811064",
"0.5660137",
"0.5646089",
"0.561485",
"0.55891615",
"0.55763173",
"0.5574433",
"0.55693966",
"0.5557644",
"0.5556008",
"0.5466861... | 0.0 | -1 |
Check representation of a transformed dimension. | def test_repr_format(self):
shape = (3, 4, 5)
index = (0, 2, 1)
t = View(shape=shape, index=index)
assert t.repr_format(1.0) == "View(shape=(3, 4, 5), index=(0, 2, 1), 1.0)" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_dimension(dimension, transform=None):\n if isinstance(dimension, Dimension):\n return dimension\n\n if not isinstance(dimension, (list, tuple, np.ndarray)):\n raise ValueError(\"Dimension has to be a list or tuple.\")\n\n # A `Dimension` described by a single value is assumed to be... | [
"0.66009927",
"0.61655766",
"0.60451436",
"0.6008891",
"0.59300977",
"0.5907829",
"0.5893205",
"0.58523893",
"0.5844773",
"0.578081",
"0.57806385",
"0.5659487",
"0.56460017",
"0.56143785",
"0.5587609",
"0.55753785",
"0.55740553",
"0.55687946",
"0.55569714",
"0.55546796",
"0.5... | 0.0 | -1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.