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 |
|---|---|---|---|---|---|---|
The Box will be infinitely long in the Xmin direction. | def OpenXmin(self, *args):
return _Bnd.Bnd_Box2d_OpenXmin(self, *args) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def OpenXmin(self, *args):\n return _Bnd.Bnd_Box_OpenXmin(self, *args)",
"def getExceedingBoxLeft(self):\n return self.exceedingBoxLeft",
"def Enlarge(self, *args):\n return _Bnd.Bnd_Box_Enlarge(self, *args)",
"def border_box_x(self):\n return self.position_x + self.margin_left",
... | [
"0.6149742",
"0.60559994",
"0.6020259",
"0.5976126",
"0.59716755",
"0.5889193",
"0.57990485",
"0.57875115",
"0.5767166",
"0.5739479",
"0.5734423",
"0.5726509",
"0.5693281",
"0.5690171",
"0.56393594",
"0.5623579",
"0.5611095",
"0.5610097",
"0.5605397",
"0.5599212",
"0.55992025... | 0.5774676 | 8 |
The Box will be infinitely long in the Xmax direction. | def OpenXmax(self, *args):
return _Bnd.Bnd_Box2d_OpenXmax(self, *args) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def OpenXmax(self, *args):\n return _Bnd.Bnd_Box_OpenXmax(self, *args)",
"def maxX(self):\n return max(self.getx())",
"def OpenZmax(self, *args):\n return _Bnd.Bnd_Box_OpenZmax(self, *args)",
"def box(self, x, y, w, h):\n\t\tpass",
"def Enlarge(self, *args):\n return _Bnd.Bnd_Bo... | [
"0.66187024",
"0.6261644",
"0.60251194",
"0.6024042",
"0.5991394",
"0.59028155",
"0.5848488",
"0.5836814",
"0.58127296",
"0.5742369",
"0.5726949",
"0.5705193",
"0.5701415",
"0.5697101",
"0.56800365",
"0.5658571",
"0.5657183",
"0.56504625",
"0.5633488",
"0.55961084",
"0.559494... | 0.61941034 | 2 |
The Box will be infinitely long in the Ymin direction. | def OpenYmin(self, *args):
return _Bnd.Bnd_Box2d_OpenYmin(self, *args) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update(self):\r\n self.rect.y += 12\r\n\r\n if self.rect.y > 500:\r\n self.rect.y = random.randrange(-1000, -60)",
"def OpenYmin(self, *args):\n return _Bnd.Bnd_Box_OpenYmin(self, *args)",
"def toTk(self,y):\r\n if y == maxValue: return 0\r\n tk_y = Size\r\n ... | [
"0.61599433",
"0.6040832",
"0.60307753",
"0.60124314",
"0.60111356",
"0.5884094",
"0.5876776",
"0.58584434",
"0.5852212",
"0.5842076",
"0.5823089",
"0.578724",
"0.578579",
"0.57838476",
"0.5775516",
"0.57717913",
"0.57692885",
"0.576792",
"0.5721756",
"0.571879",
"0.57182455"... | 0.5780859 | 14 |
The Box will be infinitely long in the Ymax direction. | def OpenYmax(self, *args):
return _Bnd.Bnd_Box2d_OpenYmax(self, *args) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def OpenYmax(self, *args):\n return _Bnd.Bnd_Box_OpenYmax(self, *args)",
"def getMaxY(self):\n return self.maxy",
"def border_box_y(self):\n return self.position_y + self.margin_top",
"def get_y(self):\n\t\treturn self._collision_rect.y + 25",
"def toTk(self,y):\r\n if y == maxV... | [
"0.66685474",
"0.6230028",
"0.6222791",
"0.61861676",
"0.6174867",
"0.6119746",
"0.60493153",
"0.6023609",
"0.6016024",
"0.60131276",
"0.59843224",
"0.59717095",
"0.5969215",
"0.5916809",
"0.58939904",
"0.5888222",
"0.5881595",
"0.5874942",
"0.5867335",
"0.5859166",
"0.585772... | 0.6508069 | 1 |
Returns true if this bounding box is open in the Xmax direction. | def IsOpenXmax(self, *args):
return _Bnd.Bnd_Box2d_IsOpenXmax(self, *args) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def IsOpenXmax(self, *args):\n return _Bnd.Bnd_Box_IsOpenXmax(self, *args)",
"def IsOpenXmin(self, *args):\n return _Bnd.Bnd_Box_IsOpenXmin(self, *args)",
"def IsOpenYmax(self, *args):\n return _Bnd.Bnd_Box_IsOpenYmax(self, *args)",
"def IsOpenXmin(self, *args):\n return _Bnd.Bnd_... | [
"0.8650418",
"0.7708037",
"0.75882566",
"0.7518821",
"0.7484127",
"0.7229682",
"0.7218617",
"0.6906463",
"0.6807362",
"0.65920174",
"0.6567638",
"0.6388174",
"0.63586354",
"0.6303765",
"0.6267946",
"0.61094725",
"0.61094725",
"0.6062759",
"0.5992613",
"0.5967686",
"0.5936086"... | 0.84815514 | 1 |
Returns True if the 2d pnt is out . | def IsOut(self, *args):
return _Bnd.Bnd_Box2d_IsOut(self, *args) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_2d(self) -> bool:\n return self.layers == 1 and self.times == 1",
"def check_2x2_solved(self):\n return self._grid[0][0] == 0 and self._grid[0][1] == 1 \\\n and self._grid[1][0] == self._width*1 and self._grid[1][1] == (1 + self._width * 1)",
"def IsOut(self, *args):\n ... | [
"0.68558764",
"0.65999925",
"0.6532571",
"0.6215357",
"0.6178642",
"0.60518456",
"0.6027423",
"0.6027423",
"0.6018433",
"0.5992683",
"0.5992683",
"0.5957578",
"0.5906453",
"0.5888954",
"0.5846709",
"0.5844243",
"0.58411825",
"0.5836872",
"0.5815548",
"0.5801672",
"0.57690907"... | 0.73486304 | 0 |
Returns the V parameter on shape | def V(self, *args):
return _Bnd.Bnd_Sphere_V(self, *args) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_V(self):\n return self.V",
"def V(self):\n return self._V",
"def V(self):\n return self._V",
"def V(self):\n return self._V",
"def V_var(self) -> Optional[np.ndarray]:\n\n def _retrieve(fm: VariationalFM) -> np.ndarray:\n return fm.V_var\n\n retu... | [
"0.7176973",
"0.6764946",
"0.6764946",
"0.6764946",
"0.6740722",
"0.6524945",
"0.64464873",
"0.6433711",
"0.64150953",
"0.612257",
"0.61033416",
"0.6071266",
"0.6062135",
"0.6032268",
"0.60114896",
"0.6008144",
"0.59795374",
"0.59702677",
"0.5964269",
"0.59550136",
"0.5930177... | 0.5516566 | 68 |
Converts human size to raw bytes. | def to_bytes(size, power=1024, sep=' '):
if not size:
return 0
size, suffix = size.split(sep, 1)
suffix = suffix[0]
try:
factor = {
'K': power,
'M': power**2,
'G': power**3,
'T': power**4,
'P': power**5,
}[suffix]
ex... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def humanbytes(size):\n # https://stackoverflow.com/a/49361727/4723940\n if not size:\n return \"\"\n # 2 ** 10 = 1024\n power = 2**10\n raised_to_pow = 0\n dict_power_n = {0: \"\", 1: \"Ki\", 2: \"Mi\", 3: \"Gi\", 4: \"Ti\"}\n while size > power:\n size /= power\n raised_... | [
"0.7551596",
"0.74305725",
"0.6996852",
"0.69877595",
"0.69326645",
"0.6904758",
"0.68815845",
"0.6836061",
"0.6653596",
"0.6633852",
"0.65997845",
"0.6589997",
"0.6584985",
"0.655749",
"0.65532583",
"0.65532583",
"0.6518818",
"0.65026194",
"0.64946115",
"0.64925283",
"0.6469... | 0.5870953 | 80 |
Deep merges one dict (u) into another (d). | def deep_merge(d, u):
stack = [(d, u)]
while stack:
d, u = stack.pop(0)
for k, v in u.items():
if not isinstance(v, collections.abc.Mapping):
d[k] = v
else:
dv = d.setdefault(k, {})
if not isinstance(dv, collections.abc.Mapp... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def deep_merge(d1, d2):\n for k, v in d1.copy().items():\n if k in d2:\n if all(isinstance(e, MutableMapping) for e in (v, d2[k])):\n d2[k] = ConfigManager.deep_merge(v, d2[k])\n\n if k == \"*\":\n for _k, _v in d2.items():\n ... | [
"0.7787253",
"0.76782864",
"0.76569384",
"0.7640773",
"0.7549339",
"0.74524367",
"0.7436307",
"0.7434447",
"0.7411334",
"0.7377388",
"0.73726463",
"0.73076856",
"0.7300631",
"0.7296037",
"0.7272856",
"0.7259761",
"0.7259761",
"0.7259761",
"0.72239405",
"0.721918",
"0.7217711"... | 0.88200444 | 0 |
Returns n inches in mm | def inches(n):
return n * 25.4 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def inches_to_mm(inches):\n mm = inches * 25.4\n return mm",
"def inches_to_mm(inches):\n\tmm=inches*25.4\n\treturn mm",
"def cm2inch(size):\n return size / 2.54",
"def cm2inch(size):\n return size / 2.54",
"def cm2inch(size):\n return size / 2.54",
"def mm_to_inche... | [
"0.7811637",
"0.7772696",
"0.7425956",
"0.7425956",
"0.7425956",
"0.7162269",
"0.71501285",
"0.68918973",
"0.68142784",
"0.6613716",
"0.6584105",
"0.65016294",
"0.6259031",
"0.62176377",
"0.62047887",
"0.6189544",
"0.61699003",
"0.6157781",
"0.61545616",
"0.60760623",
"0.6047... | 0.85428476 | 0 |
Searches all the not uniq items in the 'list', and returns whith a list of pairs. e.g. (3, 15) means 15 is three times. | def search_not_uniq(list):
not_uniq = {}
for i in set(list):
count = list.count(i)
if count != 1:
not_uniq[i] = count
return not_uniq | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_pairs(my_list):\n return [(current, my_list[idx + 1] if - 1 else None) for idx, current in enumerate(my_list) if idx < len(my_list) - 1]",
"def __unordered_pairs(l):\n\n return [(l[i], l[j]) for i in range(len(l) - 1) for j in range(i + 1, len(l))]",
"def list_to_pairs(l):\n return {(l[2*i],... | [
"0.7174017",
"0.6870864",
"0.67969817",
"0.6594823",
"0.6562065",
"0.6511249",
"0.6508608",
"0.64417917",
"0.64305633",
"0.6430308",
"0.6417646",
"0.6409151",
"0.63901544",
"0.6376144",
"0.6371336",
"0.6370985",
"0.6324909",
"0.63188666",
"0.6288483",
"0.6284568",
"0.62677413... | 0.6749724 | 3 |
This test is designed to ensure that the stats in a yahoo league are tracked in our player record model. test_stat_categorie_maps_to_player_record() returns True if all the stat_categories mapping have attributes on the player record table | def compare_stat_categorie_maps_to_player_record(self,sc_map):
player_record = PlayerRecord()
mapped_sc = []
for sc in sc_map:
if hasattr(player_record, sc_map[sc]):
mapped_sc.append(sc_map[sc])
else:
print("No player record attribute fou... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_hasUniqueCategoryValues(self):\r\n obs = self.overview_map.hasUniqueCategoryValues('Treatment')\r\n self.assertEqual(obs, False)\r\n\r\n obs = self.overview_map.hasUniqueCategoryValues('DOB')\r\n self.assertEqual(obs, False)\r\n\r\n obs = self.overview_map.hasUniqueCateg... | [
"0.5461009",
"0.5447617",
"0.5395552",
"0.52879405",
"0.526125",
"0.52468425",
"0.52432746",
"0.5205837",
"0.5179049",
"0.5148527",
"0.51441634",
"0.51413816",
"0.5109449",
"0.5108265",
"0.5103245",
"0.5102577",
"0.5102577",
"0.5095103",
"0.5074291",
"0.50672054",
"0.5060275"... | 0.7482615 | 0 |
convert ``r,phi`` to ``x,y`` | def to_cartesian(r, phi):
x = r*np.cos(phi)
y = r*np.sin(phi)
return x, y | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def polar_to_xy(r, theta):\r\n x = r*np.cos(theta)\r\n y = r*np.sin(theta)\r\n return x, y",
"def make_cartesian(r: float, phi: float):\n x = r*np.cos(phi)\n y = r*np.sin(phi)\n return x, y",
"def polar2cartesian(phi, r):\n phi_radians = radians(phi)\n x = r*cos(phi_radians)... | [
"0.7185958",
"0.6981702",
"0.69398457",
"0.6625258",
"0.64972186",
"0.6435958",
"0.6418018",
"0.6313123",
"0.62885135",
"0.61631876",
"0.61570853",
"0.6152783",
"0.614585",
"0.6126815",
"0.60812986",
"0.60257787",
"0.6005319",
"0.5997155",
"0.59835446",
"0.5957166",
"0.595048... | 0.7212485 | 0 |
``x_0 = (r0, phi0)`` | def add_reflex_1(self, A=500, sigma=(5, 6), x0=(220, -20)):
rot = x0[1]
rot_rad = np.deg2rad(rot)
r = x0[0]
sigma = (sigma[0], np.deg2rad(sigma[0]))
self.map += np.asarray(np.round(
gaussian2d_polar(self._X_centered, self._Y_centered,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def phi0(self, x):\n return (1-(1-x)**(4/3))**(3/2)/(2*np.sqrt(2))",
"def get_x0(self, x0):\n pass",
"def x0(self, x0):\n self._x0 = base.getvector(x0, 3)",
"def __init__(self, x0, r):\n self.x, self.r = x0, r",
"def x0(self):\n return self.params['x0']",
"def get_x0(self... | [
"0.6773015",
"0.67065674",
"0.65427595",
"0.641969",
"0.64076906",
"0.64018947",
"0.62991786",
"0.6063497",
"0.6063497",
"0.59850806",
"0.58149034",
"0.5756096",
"0.571053",
"0.57066786",
"0.5703834",
"0.5679786",
"0.5662409",
"0.55801475",
"0.55776656",
"0.5533589",
"0.54922... | 0.0 | -1 |
``x_0 = (r0, phi0)`` | def add_reflex_2(self, A=750, sigma=(6, 8), x0=(260, -20)):
rot = x0[1]
rot_rad = np.deg2rad(rot)
r = x0[0]
sigma = (sigma[0], np.deg2rad(sigma[0]))
angle = np.deg2rad(30)
self.map += np.asarray(np.round(
gaussian2d_polar(self._X_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def phi0(self, x):\n return (1-(1-x)**(4/3))**(3/2)/(2*np.sqrt(2))",
"def get_x0(self, x0):\n pass",
"def x0(self, x0):\n self._x0 = base.getvector(x0, 3)",
"def __init__(self, x0, r):\n self.x, self.r = x0, r",
"def x0(self):\n return self.params['x0']",
"def get_x0(self... | [
"0.67714995",
"0.6707333",
"0.65417373",
"0.64180106",
"0.6407907",
"0.6401735",
"0.6299775",
"0.6063766",
"0.6063766",
"0.5983661",
"0.5812017",
"0.5753992",
"0.5712608",
"0.57058954",
"0.57038194",
"0.567843",
"0.5662948",
"0.557786",
"0.55757797",
"0.55325687",
"0.54888517... | 0.0 | -1 |
Create a square grid of integers of gaussian shape e.g. gaussian_grid() returns array([[ 1, 4, 7, 4, 1], [ 4, 20, 33, 20, 4], [ 7, 33, 55, 33, 7], [ 4, 20, 33, 20, 4], [ 1, 4, 7, 4, 1]]) | def gaussian_grid(size = 5):
m = size/2
n = m+1 # remember python is 'upto' n in the range below
x, y = mgrid[-m:n,-m:n]
# multiply by a factor to get 1 in the corner of the grid
# ie for a 5x5 grid fac*exp(-0.5*(2**2 + 2**2)) = 1
fac = 10
#exp(m**2)
#g = fac*exp(-0.5*(x**2 + y**2))
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gaussian_grid(size=5):\n m = size / 2\n n = m + 1 # Remember python is 'upto' n in the range below\n x, y = mgrid[0 - m:n, m:n]\n # Multiply by a factor to get 1 in the corner of the grid\n # i.e., for a 5x5 grid -> fac * exp(-0.5 * (2**2 + 2**2)) = 1\n fac = exp(m ** 2)\n g = fac * exp(-0... | [
"0.7230437",
"0.70491654",
"0.6896554",
"0.6797775",
"0.67517984",
"0.67414147",
"0.67176104",
"0.65884995",
"0.65601015",
"0.65246475",
"0.65204054",
"0.65018106",
"0.64924335",
"0.6470169",
"0.6438982",
"0.64149153",
"0.64113516",
"0.64110416",
"0.6285341",
"0.62719643",
"0... | 0.72480434 | 0 |
Format a time delta. | def format_seconds(total_sec):
delt = timedelta(seconds=total_sec)
days = delt.days
hours, rem = divmod(delt.seconds, 3600)
minutes, seconds = divmod(rem, 60)
if seconds == 0:
return '<1 s'
s = '%s s' % seconds
if minutes:
s = '%d m ' % minutes + s
if hours:
s = '... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delta_fmt(delta):\n secs = delta.total_seconds()\n\n if secs < 60:\n return '%0.2d secs' % secs\n\n hours = 0\n if secs > 3600:\n hours = secs / 3600.0\n secs -= int(hours) * 3600\n\n mins = secs / 60\n secs -= mins * 60\n\n return '%0.2d:%0.2d' % (hours, mins)",
"de... | [
"0.8048436",
"0.7500681",
"0.7436088",
"0.70671225",
"0.66903746",
"0.664867",
"0.66028833",
"0.66019565",
"0.6593098",
"0.65595055",
"0.65538734",
"0.6531699",
"0.6524049",
"0.6466254",
"0.6441042",
"0.6434041",
"0.64218915",
"0.63657796",
"0.62945265",
"0.62735516",
"0.6193... | 0.5669779 | 72 |
Convert a SQLAlchemy query result to a DataFrame. | def to_df(query, cols=None):
# Try to get column names
if cols is None:
cols = [x['name'] for x in query.column_descriptions]
data = [{k: v for k, v in zip(cols, x)} for x in query]
if len(data) == 0:
return pd.DataFrame()
return pd.DataFrame(data).loc[:, cols] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_query_result_to_df(self, query):\r\n try:\r\n return pd.read_sql_query(query, self.conn)\r\n except pd.pandas.io.sql.DatabaseError:\r\n print('Execution failed. Database error')",
"def query_to_df(query):\n df = pd.DataFrame(query.all())\n df.columns = [x['name']... | [
"0.7974691",
"0.782032",
"0.7771702",
"0.74412435",
"0.7411473",
"0.73821586",
"0.71370083",
"0.7129238",
"0.71088064",
"0.7095191",
"0.7056418",
"0.7052933",
"0.70033854",
"0.69785625",
"0.6957465",
"0.67488027",
"0.6739285",
"0.6708781",
"0.6693363",
"0.6657111",
"0.663588"... | 0.69362646 | 15 |
Create app, instantiate test client, drop DB after use. | def app():
application = create_app(**TEST_SETTINGS)
application.test_client_class = TestClient
application.client = application.test_client()
# Using __get__ binds the function to the application instance
application.user = user.__get__(application) # pylint: disable=E1121
application.admin =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tearDown(self):\n self.app = create_app()\n self.client = self.app.test_client\n setup_db(self.app, TEST_DB_PATH)\n\n # binds the app to the current context\n with self.app.app_context():\n # create all tables\n db.drop_all()",
"def testing_app() -> Fl... | [
"0.7991045",
"0.7906864",
"0.7849773",
"0.7790533",
"0.7781965",
"0.7752498",
"0.7750667",
"0.77222246",
"0.7707221",
"0.76910377",
"0.7633471",
"0.7610287",
"0.7609026",
"0.7591962",
"0.75794077",
"0.7558541",
"0.7519672",
"0.7518701",
"0.75097805",
"0.7500525",
"0.74830943"... | 0.7674222 | 10 |
Computes the sigmoid of z | def sigmoid(z):
### START CODE HERE ### ( approx. 4 lines of code)
# Create a placeholder for x. Name it 'x'.
x = tf.placeholder(tf.float32, name='x')
# compute sigmoid(x)
sigmoid = tf.sigmoid(x)
# Create a session, and run it. Please use the method 2 explained above.
# You should use a f... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sigmoid(z):\r\n \r\n return vSigmoid(z);",
"def sigmoid(z): \n return 1/(1 + np.e**(-z))",
"def sigmoid(z):\r\n \r\n return 1.0 / (1.0+np.exp(-z))",
"def sigmoid(z):\n return 1 / (1 + e ** -z)",
"def sigmoid(z):\n return 1 / (1 + np.exp(-1 * z))",
"def sigmoid(z):\n\treturn 1.0... | [
"0.9170252",
"0.91089714",
"0.90431756",
"0.9018412",
"0.8966501",
"0.89645237",
"0.8948541",
"0.89334434",
"0.89220953",
"0.8913508",
"0.89105606",
"0.88974535",
"0.8868145",
"0.8850713",
"0.8850039",
"0.8849412",
"0.88442266",
"0.88433564",
"0.8821012",
"0.8819344",
"0.8813... | 0.0 | -1 |
Computes nll loss for the given lists of question and ctx vectors. Note that although hard_negative_idx_per_question in not currently in use, one can use it for the loss modifications. For example weighted NLL with different factors for hard vs regular negatives. | def calc(
self,
q_vectors: T,
ctx_vectors: T,
positive_idx_per_question: list,
hard_negatice_idx_per_question: list = None,
) -> Tuple[T, int]:
scores = self.get_scores(q_vectors, ctx_vectors)
if len(q_vectors.size()) > 1:
q_num = q_vectors.size(0... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def nll_loss(predictions, targets, weights, reduction, ignore_index):\n return cpp.nn.nll_loss(predictions, targets, weights, reduction, ignore_index)",
"def nll_loss(\n inputs,\n axis=1,\n ignore_index=None,\n reduction='valid',\n **kwargs\n):\n args = ArgHelper.parse(locals())\n args['r... | [
"0.63996506",
"0.6294848",
"0.615721",
"0.61047953",
"0.58329815",
"0.5752247",
"0.5723549",
"0.5715525",
"0.5715525",
"0.5715525",
"0.5715525",
"0.5654054",
"0.5613011",
"0.5537946",
"0.55138993",
"0.5495847",
"0.54890305",
"0.5485944",
"0.5472924",
"0.5472407",
"0.54426104"... | 0.6830779 | 0 |
Returns a batch iterator over random Gaussian data. | def make_gaussian_dataset(batch_size: int,
input_dim: int,
seed: int = 0) -> base.BatchIterator:
sample_fn = jax.jit(lambda x: jax.random.normal(x, [batch_size, input_dim]))
def batch_iterator():
rng = hk.PRNGSequence(seed)
while True:
x = sample_fn(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gaussian_gen(ngaussian, nd, batchSize, seed, random=True):\n torch.manual_seed(seed)\n np.random.seed(seed)\n\n means, covars, weights = get_means_covars(nd, ngaussian, random)\n while True:\n # yield multi_normal.sample((batchSize,))\n yield mm_gaussian(batchSize, means, covars, weig... | [
"0.7013998",
"0.6690056",
"0.66480947",
"0.65792656",
"0.6513333",
"0.633388",
"0.62997884",
"0.6229444",
"0.62281525",
"0.62077874",
"0.6189904",
"0.61739624",
"0.6168776",
"0.6137008",
"0.6131274",
"0.6103353",
"0.60992235",
"0.6098085",
"0.60685813",
"0.6066413",
"0.606349... | 0.7828929 | 0 |
Add a callback for a signal. | def subscribe_signal(self, callback, path, interface, member):
self.signal_callbacks[(path, interface, member)] = callback | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fl_add_signal_callback(sglnum, pyfn_SignalHandler, userdata):\n #FL_SIGNAL_HANDLER = cty.CFUNCTYPE(None, cty.c_int, cty.c_void_p)\n _fl_add_signal_callback = library.cfuncproto(\n library.load_so_libforms(), \"fl_add_signal_callback\", \\\n None, [cty.c_int, xfdata.FL_SIGNAL_HANDLER, cty.c_... | [
"0.7264618",
"0.7046521",
"0.67510474",
"0.6673538",
"0.66259676",
"0.66065484",
"0.6518581",
"0.64805484",
"0.6445092",
"0.63558203",
"0.63544405",
"0.63536763",
"0.6331421",
"0.62464553",
"0.62405044",
"0.6237263",
"0.6205944",
"0.61962056",
"0.61716676",
"0.61559975",
"0.6... | 0.7003299 | 2 |
Test rejecting unauthorized requests. | def test_unauthorized_request(
app,
sample_histogram_query_data,
users,
queries_config,
custom_permission_factory,
which_user,
expected_code,
):
def client_req(user):
with app.test_client() as client:
headers = [
("Content-Type", "application/json"),
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_unauthorized(self):\n self._error_test(fitbit_exceptions.HTTPUnauthorized)",
"def test_user_not_authorized(self):\n response = self.client.post(self.url)\n self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)",
"def test_if_not_available_for_unauthorized(self):\r\n ... | [
"0.7930071",
"0.7877716",
"0.7473721",
"0.7468487",
"0.74605954",
"0.74363685",
"0.74180716",
"0.7410151",
"0.74099183",
"0.73789054",
"0.73595685",
"0.73567754",
"0.73277503",
"0.73277503",
"0.7242594",
"0.7241575",
"0.72240204",
"0.7201577",
"0.7196082",
"0.71945584",
"0.71... | 0.0 | -1 |
Returns current silences list | def amtool_silences(self, mess, args):
helper = AmtoolHelper(
alertmanager_address=self.config['server_address'])
result = helper.get_silences()
return {"silences": result} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getSilence(self):\n return self.__silence",
"def silence(self) -> list[str]:\n if self._silence is None:\n print(self.__class__.silence.__doc__)\n raise SilSubProblemError(\n \"The *silence* property has not been set (see above).\"\n )\n re... | [
"0.64256454",
"0.62111056",
"0.5945464",
"0.5746703",
"0.5671169",
"0.5633065",
"0.56152606",
"0.5595529",
"0.5451854",
"0.54360914",
"0.54170954",
"0.54022837",
"0.53819567",
"0.5363648",
"0.5361411",
"0.53340733",
"0.5307792",
"0.5294918",
"0.5275808",
"0.5262512",
"0.52267... | 0.6065061 | 2 |
Create a new, empty, evaluation tree. | def __init__(self, items=[]):
super(TermEvalTree, self).__init__(items) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def evaluate(self, tree):\n\t\tpass",
"def create_expr(self, exprcls, ast, params=None, nopush=False):\n if params is None:\n expr = exprcls(self.current_parent, ast=ast)\n else:\n expr = exprcls(self.current_parent, ast=ast, **params)\n if not nopush:\n self... | [
"0.61534745",
"0.613051",
"0.61201304",
"0.58557874",
"0.5804677",
"0.5803692",
"0.5782211",
"0.5778226",
"0.57311255",
"0.5698479",
"0.5681894",
"0.5668863",
"0.56675756",
"0.56252235",
"0.561142",
"0.5610517",
"0.55718136",
"0.5516273",
"0.55090255",
"0.54896533",
"0.548830... | 0.53173447 | 42 |
Split this tree into subtrees in order to reduce the maximum size of any tree (useful for limiting memory consumption or for using multiple cores). Must specify either maxSubTreeSize or numSubTrees. | def split(self, elIndicesDict, maxSubTreeSize=None, numSubTrees=None, verbosity=0):
#dbList = self.generate_circuit_list()
tm = _time.time()
printer = _VerbosityPrinter.build_printer(verbosity)
if (maxSubTreeSize is None and numSubTrees is None) or \
(maxSubTreeSize is not No... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def split(self, elIndicesDict, maxSubTreeSize=None, numSubTrees=None, verbosity=0):\n #dbList = self.generate_circuit_list()\n tm = _time.time()\n printer = _VerbosityPrinter.build_printer(verbosity)\n\n if (maxSubTreeSize is None and numSubTrees is None) or \\\n (maxSubTreeSi... | [
"0.612445",
"0.57817036",
"0.55767655",
"0.5573259",
"0.5446567",
"0.5407228",
"0.5319436",
"0.52336556",
"0.5156939",
"0.5057983",
"0.5050872",
"0.50443584",
"0.50443584",
"0.49832764",
"0.4979916",
"0.49100825",
"0.4865076",
"0.48417714",
"0.47893655",
"0.47693476",
"0.4755... | 0.6239668 | 0 |
Create a copy of this evaluation tree. | def copy(self):
cpy = self._copyBase(TermEvalTree(self[:]))
return cpy | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def copy(self):\n cpy = self._copyBase(MapEvalTree(self[:]))\n cpy.cachesize = self.cachesize # member specific to MapEvalTree\n return cpy",
"def __copy__(self) -> 'Tree':\n return non_recursive_tree_copy(self)",
"def copy(self):\n node_new = Node(self.state.copy(), self.pa... | [
"0.7287765",
"0.6828944",
"0.6567195",
"0.6477056",
"0.64676905",
"0.6458334",
"0.63910806",
"0.6382213",
"0.63544357",
"0.6347705",
"0.62880975",
"0.62553304",
"0.62302727",
"0.620122",
"0.61473227",
"0.61250377",
"0.6098586",
"0.60982025",
"0.6052151",
"0.60474586",
"0.5953... | 0.75811714 | 0 |
Encode the ensemble into CSV data. Each line is a value with a the datetime, KEY, subsystem config, subsystem code, bin and beam number. | def encode_csv(self,
is_ensemble_data=True,
is_ancillary_data=True,
is_amplitude=True,
is_correlation=True,
is_beam_velocity=True,
is_instrument_velocity=True,
is_earth_velocity=True,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def encode_csv(self, dt, ss_code, ss_config, blank, bin_size):\r\n str_result = []\r\n\r\n for beam in range(self.element_multiplier):\r\n for bin_num in range(self.num_elements):\r\n # Get the value\r\n val = self.Amplitude[bin_num][beam]\r\n\r\n ... | [
"0.66174453",
"0.6232857",
"0.59570146",
"0.5839512",
"0.57570165",
"0.5737734",
"0.563033",
"0.5566788",
"0.54548496",
"0.5448341",
"0.54375726",
"0.5428334",
"0.54278255",
"0.5414356",
"0.54064476",
"0.5400729",
"0.5382999",
"0.53818715",
"0.5376231",
"0.5365959",
"0.532182... | 0.7242299 | 0 |
Calculate the magnitude of the water current. | def calculate_magnitude(east, north, vertical):
if not Ensemble.is_bad_velocity(east) and not Ensemble.is_bad_velocity(north) and not Ensemble.is_bad_velocity(vertical):
return math.sqrt((east*east) + (north*north) + (vertical*vertical))
else:
return Ensemble.BadVelocity | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def magnitude(self):\n\t\treturn sqrt(self.dot(self))",
"def magnitude(self): # @todo @caution check: something wrong?\n\n return (math.sqrt(reduce(lambda x, y: x+y,\n [x**2 for x in self.vector])))",
"def calculate_magnitude(self, band, system='AB'):\n\n if system not in ('AB', 'V... | [
"0.7202431",
"0.71782404",
"0.71533036",
"0.71288294",
"0.71042",
"0.7062428",
"0.7040869",
"0.7040869",
"0.7018303",
"0.69488895",
"0.6895417",
"0.67627156",
"0.6689087",
"0.66681236",
"0.6639145",
"0.6598193",
"0.65726405",
"0.6491566",
"0.6464247",
"0.64553946",
"0.6430863... | 0.0 | -1 |
Convert the given Int32 value to 4 bytes. | def int32_to_bytes(value):
return struct.pack("i", value) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def int32_t(n):\n return int(n).to_bytes(4, byteorder='little', signed=True)",
"def int32_to_bytes(x):\n return x.to_bytes(4, 'little')",
"def uint32_t(n):\n return int(n).to_bytes(4, byteorder='little', signed=False)",
"def p32(value: int, endian: str = \"little\") -> bytes:\n return pack(value,... | [
"0.79040617",
"0.7796502",
"0.7350686",
"0.7304055",
"0.7253622",
"0.7185108",
"0.7105476",
"0.70497894",
"0.6981153",
"0.69356984",
"0.66281474",
"0.6532184",
"0.6504955",
"0.6503289",
"0.64240265",
"0.640567",
"0.62851393",
"0.61281306",
"0.6124896",
"0.60982025",
"0.607839... | 0.77152675 | 2 |
Get the dataset size. | def GetDataSetSize(ds_type, name_len, num_elements, element_multipler):
# Number of bytes in the data type
datatype_size = 4
if ds_type == 50: # Byte Datatype
datatype_size = 1
elif ds_type == 20: # Int Datatype
datatype_size = 4
elif ds_type == 1... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def dataset_size(self):\n return self.dataset.size",
"def get_size(self):\n return self._data_size",
"def dataset_size(self):\n if not self._dataset_size:\n # pylint: disable=attribute-defined-outside-init\n self._dataset_size = count_file_lines(\n self... | [
"0.91403663",
"0.849389",
"0.8391036",
"0.8105561",
"0.8068119",
"0.80425644",
"0.7977297",
"0.78925276",
"0.78925276",
"0.78925276",
"0.78925276",
"0.78908396",
"0.78482926",
"0.78434086",
"0.7824782",
"0.7820051",
"0.7820051",
"0.7820051",
"0.7820051",
"0.7820051",
"0.77534... | 0.73454875 | 96 |
Test EndpointNotFound behavior. A missing endpoint entry should not explode. | def test_missing_endpoint(self, req):
req.side_effect = ks_exc.EndpointNotFound()
self.client._get_resource_provider(self.context, "fake")
# reset the call count to demonstrate that future calls still
# work
req.reset_mock()
self.client._get_resource_provider(self.contex... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_unknown_routes():\n response = client.get(\"/unknown_endpoint\",\n headers={\"content-type\": \"application/json\"})\n assert response.status_code == status.HTTP_404_NOT_FOUND\n assert response.json() == {\"detail\": \"Not Found\"}",
"def test_not_found(self):\n ... | [
"0.70272326",
"0.6987068",
"0.68113345",
"0.671871",
"0.6663649",
"0.6604881",
"0.66024923",
"0.65763974",
"0.6547228",
"0.6545441",
"0.6503224",
"0.6484738",
"0.6479871",
"0.64623535",
"0.6448783",
"0.64476264",
"0.6418116",
"0.64123875",
"0.64085877",
"0.6393279",
"0.638925... | 0.76004606 | 0 |
Tests that the method which manipulates an existing doubledup allocation for a move operation to remove the source host results in sending placement the proper payload to PUT /allocations/{consumer_uuid} call. | def test_remove_provider_from_inst_alloc_no_shared(self):
get_resp_mock = mock.Mock(status_code=200)
get_resp_mock.json.side_effect = [
{
'allocations': {
uuids.source: {
'resource_provider_generation': 42,
'resources': {
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_move_from_empty_source(self, mock_info):\n source_consumer_data = {\"allocations\": {}}\n source_rsp = mock.Mock()\n source_rsp.json.return_value = source_consumer_data\n self.mock_get.side_effect = [source_rsp, self.target_rsp]\n\n resp = self.client.move_allocations(\n... | [
"0.6858059",
"0.646567",
"0.61765456",
"0.6135598",
"0.6034987",
"0.58021337",
"0.5659526",
"0.55025584",
"0.54636395",
"0.54448915",
"0.5430589",
"0.5416377",
"0.54057884",
"0.53967476",
"0.5385351",
"0.5379422",
"0.5374467",
"0.5368022",
"0.5365991",
"0.5365116",
"0.5358431... | 0.655027 | 1 |
Tests that the method which manipulates an existing doubledup allocation with DISK_GB being consumed from a shared storage provider for a move operation to remove the source host results in sending placement the proper payload to PUT /allocations/{consumer_uuid} call. | def test_remove_provider_from_inst_alloc_with_shared(self):
get_resp_mock = mock.Mock(status_code=200)
get_resp_mock.json.side_effect = [
{
'allocations': {
uuids.source: {
'resource_provider_generation': 42,
'resources': {
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_remove_provider_from_inst_alloc_no_shared(self):\n get_resp_mock = mock.Mock(status_code=200)\n get_resp_mock.json.side_effect = [\n {\n 'allocations': {\n uuids.source: {\n 'resource_provider_generation': 42,\n 'reso... | [
"0.69323504",
"0.6891966",
"0.67952687",
"0.6316012",
"0.6152829",
"0.6024215",
"0.5933684",
"0.5874035",
"0.5679327",
"0.56697303",
"0.56345683",
"0.56261957",
"0.559165",
"0.55735576",
"0.5564316",
"0.553406",
"0.54666656",
"0.5445933",
"0.54440683",
"0.5409861",
"0.5393886... | 0.69750386 | 0 |
Given a cause_id, gbd_round_id, and codcorrect version id, return a dataframe of imputed LnASDR fit for use in the given round. This function applies to steps 4+iterative for GBD 2019 and steps 1+iterative for GBD 2020. It can retrieve cause specific LnASDR for all combinations of cause and codcorrect version ever used... | def read_lnasdr(cause_id, codcorrect_version_id, gbd_round_id):
fname = FPATH_TEMPLATE.format(
cause_id=cause_id, codcorrect_version_id=codcorrect_version_id
)
fpath = Path(ASDR_DIR.format(
GBD_ROUND=gbd_round_from_gbd_round_id(gbd_round_id))) / Path(fname)
log = logging.getLogger(__nam... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_computed_dataframe(self, df):\n df = add_nid_metadata(df, ['data_type_id'], **self.cache_options)\n has_verbal_autopsy = self.VA in df['data_type_id'].unique()\n\n if self.needs_bridging(has_verbal_autopsy):\n sheet_name = self.get_sheet_name(has_verbal_autopsy)\n ... | [
"0.5293278",
"0.5200785",
"0.50221",
"0.48358947",
"0.4826578",
"0.48214978",
"0.47929785",
"0.47698998",
"0.47030774",
"0.46369737",
"0.45942262",
"0.4534991",
"0.45256627",
"0.45027718",
"0.44576678",
"0.44565728",
"0.44255874",
"0.4414522",
"0.43951112",
"0.4391517",
"0.43... | 0.65341944 | 0 |
Uses { EmojiParserparseFromUnicode(String, EmojiParser.EmojiTransformer)} to parse unicode emojis to ASCII string " ||emoji_alias|| ". | def parse_unicode_emojis_to_alias(text):
#return EmojiParser.parseFromUnicode(text, EMOJI_ALIAS_TRANSFORMER)
return text | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test__parse_emoji():\n unicode_emoji = BUILTIN_EMOJIS['heart']\n custom_emoji = Emoji.precreate(202305240006, name = 'Yukari')\n \n for input_data, expected_output in (\n ({}, None),\n ({'emoji_name': None}, None),\n ({'emoji_name': unicode_emoji.unicode}, unicode_emoji),\n ... | [
"0.66105366",
"0.659297",
"0.6433123",
"0.621881",
"0.60683155",
"0.6063009",
"0.5913747",
"0.5899762",
"0.58437294",
"0.5842089",
"0.5787891",
"0.5740258",
"0.5731933",
"0.5727554",
"0.5722948",
"0.5651183",
"0.56351733",
"0.5634066",
"0.5627088",
"0.5624991",
"0.5617374",
... | 0.7690029 | 0 |
Replaces repeating characters in String | def remove_repeating_characters(text):
return RegexFilters.replace_repeating_characters(text, "$1") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_repeating_char(self, text):\n return re.sub(r'(.)\\2+', r'\\1', text)",
"def repeat(s):\r\n\r\n return s",
"def _process_repeaters(self, s: str) -> str:\r\n while self._color_and_repeater_regexp.search(s):\r\n s = self._insert_reset_char(s)\r\n s = self._match_... | [
"0.7625324",
"0.70385396",
"0.68327165",
"0.67074865",
"0.6671211",
"0.6620018",
"0.6579727",
"0.65698737",
"0.6556426",
"0.64036167",
"0.6353906",
"0.6293374",
"0.62665826",
"0.6252373",
"0.6201967",
"0.61807525",
"0.61644185",
"0.6126935",
"0.61254996",
"0.6121367",
"0.6062... | 0.78152174 | 0 |
Convert open3d.geometry.PointCloud object to [4, N] array [x_1 , x_2 , .. ] xyz_v = [y_1 , y_2 , .. ] [z_1 , z_2 , .. ] [ 1 , 1 , .. ] | def cvt_pcd(self,pcd, sem_label,in_view_constraints=True):
# The [N,3] downsampled array
pts_3d = np.asarray(pcd.points)
if in_view_constraints:
h_points = self.hv_in_range(pts_3d[:,0], pts_3d[:,1], [-50,50], fov_type='h')
pts_3d = pts_3d[h_points]
sem_label ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convertcloud(points):\n pcd = open3d.geometry.PointCloud()\n pcd.points = open3d.utility.Vector3dVector(points)\n return pcd",
"def cvt2array(tuples):\n rc = []\n for t in tuples:\n rc.append(point3d(np.float32(t[X]), np.float32(t[Y]), np.float32(t[Z])))\n return rc",... | [
"0.7286944",
"0.72601116",
"0.68690187",
"0.68104565",
"0.67531294",
"0.62464756",
"0.6229352",
"0.62074524",
"0.6174182",
"0.6156095",
"0.6154968",
"0.60703796",
"0.6045163",
"0.6010847",
"0.6007154",
"0.59702325",
"0.596738",
"0.5966244",
"0.59505725",
"0.5926261",
"0.59219... | 0.0 | -1 |
Create "dots" plot. If grid_nrow OR grid_ncol is given, will attempt to create grid to fit ndots with given nrow/ncol. Will both are given, will raise error if cannot form a grid to fit ndots. If none are given, will create a square grid to fit ndots. | def dots_plot(ndots, filled_dots,
grid_nrow=None,
grid_ncol=None,
grid_width=10,
grid_height=10,
c_unfilled="#bdc3c7",
c_filled="#2980b9",
marker="o",
marker_size=10,
show_label=True,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_gridSpec(nrow, ncol, wspace=None, hspace=None):\n grid = plt.GridSpec(nrows=nrow, ncols=ncol, wspace=wspace, hspace=hspace)\n yield grid",
"def generate_grid(nrows, ncols, ndots):\n\n # Validation\n if nrows * ncols < ndots:\n raise Exception(\"ndots must be <= than grid size\")\n\n rows = np.ar... | [
"0.64554465",
"0.6188541",
"0.59159935",
"0.5662064",
"0.5634788",
"0.56104046",
"0.5601841",
"0.55912083",
"0.5485552",
"0.5462076",
"0.5438313",
"0.54247725",
"0.53843087",
"0.5330758",
"0.5316493",
"0.53010905",
"0.52846634",
"0.5279323",
"0.5276318",
"0.52738416",
"0.5268... | 0.7458604 | 0 |
Small utility function to make float mor pretty | def get_pretty(value: float, accuracy: int = 3):
return ('%.' + str(accuracy) + 'f') % value | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def short_float_fmt(x):\n return '{0:f}'.format(x).rstrip('0').rstrip('.')",
"def pretty_float(x):\n return ('%f' % x).rstrip('0').rstrip('.')",
"def float_format(self):\n ...",
"def pretty_float(v: Union[float, int], n_sigfigs: Optional[int] = 5) -> str:\n\t\tv0 = v.__class__(v)\n\t\t# first, h... | [
"0.7308965",
"0.7273764",
"0.7253805",
"0.71120894",
"0.70108885",
"0.6830543",
"0.67025244",
"0.6560071",
"0.6550757",
"0.6452444",
"0.6407769",
"0.640091",
"0.640091",
"0.640091",
"0.640091",
"0.63605934",
"0.63605934",
"0.6355612",
"0.63300234",
"0.6308148",
"0.6308046",
... | 0.6246705 | 25 |
View Controller for the Home Page | def home_page():
return "<h4>Welcome !</h4><br><a href='/fetch'>View Results</a>" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def home(request):\n\treturn render(request, \"compta/home.html\")",
"def home(request):\r\n return render(request, 'home.html')",
"def home(self, *args, **kwargs):\n pass",
"def home():\n\n\treturn render_template('index.html', title='Home Page',\n\t\t\t\t\t\t year=datetime.now().year)",
"def ... | [
"0.8044922",
"0.77770954",
"0.77151424",
"0.7628626",
"0.7612775",
"0.7584397",
"0.7581766",
"0.7579866",
"0.7551894",
"0.7532357",
"0.75280464",
"0.75207704",
"0.75172997",
"0.75143486",
"0.7514253",
"0.749323",
"0.7488179",
"0.7481498",
"0.7476854",
"0.7466943",
"0.74641633... | 0.0 | -1 |
Converts dict object to protobuf binary message | def _dict_to_binary(self, json_dict):
message = self.message_class()
try:
message = json_format.ParseDict(json_dict, message)
binary = message.SerializeToString()
except json_format.ParseError:
# TODO log
return None
return binary | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _object2proto(self) -> UpdateGroupMessage_PB:\n return UpdateGroupMessage_PB(\n msg_id=serialize(self.id),\n address=serialize(self.address),\n content=json.dumps(self.content),\n reply_to=serialize(self.reply_to),\n )",
"def obj2bytes(obj: StunPacket... | [
"0.6372832",
"0.6337417",
"0.62945145",
"0.6277781",
"0.62265205",
"0.6193138",
"0.6138635",
"0.6138635",
"0.6100963",
"0.60570735",
"0.60413253",
"0.60410964",
"0.5986436",
"0.5962294",
"0.59443873",
"0.5911412",
"0.5903815",
"0.58655643",
"0.58190984",
"0.5718694",
"0.56962... | 0.6985256 | 0 |
Write JSON formatted contents of library to 'somebooks.json'. | def save_to_json(library: list, json_file_name) -> None:
contents = convert_library_to_json(library)
with open(json_file_name, 'w') as file_object:
json.dump(contents, file_object) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_out():\n os.replace(\"recipes.json\", \".recipes.json.backup\")\n with open(\"recipes.json\", \"w\") as recipes_file:\n json.dump(recipebook.to_json_list(),recipes_file)",
"def write():\n output_data = book_list_manipulation()\n\n # Create data directory\n try:\n os.mkdir(D... | [
"0.67941064",
"0.6712227",
"0.6681812",
"0.65013814",
"0.6446298",
"0.64201915",
"0.64201915",
"0.63656104",
"0.6346884",
"0.6337916",
"0.6337192",
"0.63276",
"0.6277764",
"0.62762684",
"0.62488043",
"0.6212861",
"0.62078017",
"0.61899835",
"0.61881804",
"0.618683",
"0.617121... | 0.78346264 | 0 |
Test functions in this module (get_area_average() and compare_area()). | def test(filename):
# Load the image and pixel data for the file
image, pixels = load_image(str(filename))
# compare the areas in the image using module functions
test_area = get_area_average(pixels, 50, 600, 620, 50)
expected_area = get_area_average(pixels, 1500, 600, 300, 300)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_area(self):\n r1 = Rectangle(3, 2)\n self.assertEqual(r1.area(), 6)\n\n r2 = Rectangle(2, 10)\n self.assertEqual(r2.area(), 20)\n\n r3 = Rectangle(10, 10)\n self.assertEqual(r3.area(), 100)",
"def test_area():\n N_GRID = 1000\n kind_list = [\"linear\", \"p... | [
"0.73618317",
"0.7269199",
"0.7166619",
"0.71577805",
"0.71140015",
"0.6944461",
"0.6937703",
"0.6937703",
"0.6930448",
"0.6888293",
"0.68665016",
"0.686071",
"0.67991424",
"0.6780735",
"0.67760044",
"0.6773737",
"0.6762509",
"0.67396736",
"0.6698852",
"0.6695314",
"0.667968"... | 0.75115806 | 0 |
Compute softmax values for each sets of scores in x. subtract max too avoid after exponentiation numerical issues. | def softmax(x):
e_x = np.exp(x - np.max(x))
return old_div(e_x, e_x.sum()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _compute_softmax(scores):\n if not scores:\n return []\n\n max_score = None\n for score in scores:\n if max_score is None or score > max_score:\n max_score = score\n\n exp_scores = []\n total_sum = 0.0\n for score in scores:\n x = np.exp(score - max_score)\n exp_scores.append(x)\n tot... | [
"0.8152114",
"0.8118244",
"0.80973",
"0.80973",
"0.80973",
"0.80973",
"0.8042568",
"0.8007471",
"0.7914464",
"0.77501804",
"0.7747145",
"0.77428544",
"0.774038",
"0.77277666",
"0.77192086",
"0.77058256",
"0.7705577",
"0.76773155",
"0.76773155",
"0.76694804",
"0.7666126",
"0... | 0.7649423 | 23 |
Register identified player categories to CSV file. | def register_player_categories(player_categories_d, player_ids, use_complex_categories=False):
print("Registering player categories to CSV file... ", end='', flush=True)
categories_d = {}
if not use_complex_categories: # Register players in main category CSV files only
for player_name, player_categ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_categories():\n\n print('load_categories')\n\n Category.query.delete()\n\n for row in open(\"seed_data/categories.csv\"):\n name = row.rstrip()\n\n cat = Category(name=name)\n\n db.session.add(cat)\n\n db.session.commit()",
"def save(self, cat):\n with open(self.f... | [
"0.6143419",
"0.5891509",
"0.5818831",
"0.5806062",
"0.5790886",
"0.576683",
"0.56881076",
"0.5677344",
"0.56752986",
"0.5628243",
"0.56071",
"0.5570015",
"0.5521694",
"0.5426678",
"0.54253393",
"0.5416517",
"0.5409569",
"0.5392249",
"0.53697574",
"0.5360144",
"0.5353606",
... | 0.74887174 | 0 |
Initialize the error object. | def __init__(self, error: List[Error] = None, info: Dict = None):
self.error = error if error is not None else []
self.info = info if info is not None else {}
self.is_valid = True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, error = ''):\n IPRO_Error.__init__(self, error)",
"def __init__(self, error = ''):\n IPRO_Error.__init__(self, error)",
"def __init__(self, error = ''):\n IPRO_Error.__init__(self, error)",
"def __init__(self, error_msg):\n super(SdkException, self).__init__()\n... | [
"0.778123",
"0.778123",
"0.778123",
"0.77303314",
"0.7431539",
"0.7166465",
"0.7118429",
"0.7089138",
"0.6994154",
"0.69397247",
"0.6926841",
"0.6894145",
"0.6851899",
"0.6850147",
"0.68288684",
"0.6765819",
"0.67592484",
"0.673861",
"0.6720681",
"0.67007667",
"0.66677237",
... | 0.6777851 | 15 |
This function make camel case string | def string_to_camel_case(string:str) -> str:
result_camel_case = str()
sym = iter(string)
for symb in sym:
if symb == "_":
symbol = next(sym)
symb = "" + symbol.upper()
result_camel_case += symb
return result_camel_case | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def camel(s):\n return s[0].upper() + s[1:]",
"def _to_camel_case(text: str) -> str:\n return \"\".join(word.title() for word in text.split(\"_\"))",
"def camel_case(value: str, **kwargs: Any) -> str:\n result = \"\".join(map(str.title, split_words(value)))\n return result[0].lower() + result[1:]",... | [
"0.78228825",
"0.78217906",
"0.7805806",
"0.7798621",
"0.7528946",
"0.74601084",
"0.74245834",
"0.74177057",
"0.7398569",
"0.73950356",
"0.7389722",
"0.7380134",
"0.734875",
"0.7347254",
"0.7338537",
"0.7324779",
"0.7272588",
"0.7259691",
"0.7251684",
"0.72307914",
"0.7215484... | 0.72231823 | 20 |
Load the pretrained Swin Transformer model states and prepare the model for image segmentation. Paramters | def load_swin_model(model_path, cfg_path):
# set up model config
model = init_detector(cfg_path, model_path, device='cuda:0')
return model | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_pretrained_layers(self):\n # Current state of base\n state_dict = self.state_dict()\n param_names = list(state_dict.keys())\n\n # Pretrained VGG base\n pth = VGG_WEIGHT_PATH\n pretrained_state_dict = torch.load(pth)\n pretrained_param_names = list(pretraine... | [
"0.6587504",
"0.6576317",
"0.6479643",
"0.64297354",
"0.63592225",
"0.63479906",
"0.63324994",
"0.6324293",
"0.63152117",
"0.6262596",
"0.6247061",
"0.62149227",
"0.62089145",
"0.6163013",
"0.6152904",
"0.61286426",
"0.6125572",
"0.61083937",
"0.60951775",
"0.60933113",
"0.60... | 0.0 | -1 |
Returns ratio of dissociations due to flux in band1 over flux in band2. | def dissoc_ratio(spec, species, band1, band2, dissoc_only=True):
cspec = cum_dissoc_spec(spec, species, dissoc_only=dissoc_only)
we = utils.wedges(spec)
integral = lambda band: np.diff(np.interp(band, we, cspec))
I1, I2 = list(map(integral, [band1, band2]))
return I1/I2 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sqrDiffWellFluoro(fluoro1,fluoro2):\n dist = 0\n count = 0\n x1 = [math.log(x) for x in fluoro1]\n x2 = [math.log(x) for x in fluoro2]\n while count < len(fluoro1):\n dist += math.pow(x1[count]-x2[count],2)\n count += 1\n return dist",
"def evaluate_field_diff(smdf1, smdf2, fi... | [
"0.5974529",
"0.5709754",
"0.56822765",
"0.5665941",
"0.56608135",
"0.55868787",
"0.5531199",
"0.5527557",
"0.54777175",
"0.54597014",
"0.5449504",
"0.54419273",
"0.54338074",
"0.54292613",
"0.5425127",
"0.5414442",
"0.54116666",
"0.54115736",
"0.539807",
"0.5345666",
"0.5337... | 0.6866517 | 0 |
Deformable conv2D operator in NCHW layout. | def deformable_conv2d_nchw(
data, offset, kernel, strides, padding, dilation, deformable_groups, groups, out_dtype
):
if out_dtype is None:
out_dtype = data.dtype
if isinstance(strides, int):
stride_h = stride_w = strides
else:
stride_h, stride_w = strides
if isinstance(dil... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convert_depthwise_conv2d(self, op):\n return self.convert_conv(op, \"depthwise\")",
"def convert_conv2d(g, op, block):\n\n dilations = op.attr(\"dilations\")\n groups = op.attr(\"groups\")\n paddings = op.attr(\"paddings\")\n padding_algorithm = op.attr(\"padding_algorithm\")\n strides ... | [
"0.6914209",
"0.681887",
"0.6647935",
"0.6633788",
"0.6497158",
"0.64200926",
"0.63852674",
"0.63647985",
"0.63478374",
"0.63002294",
"0.6267007",
"0.626647",
"0.62638384",
"0.6260785",
"0.62600344",
"0.6254607",
"0.6249518",
"0.62469304",
"0.6228835",
"0.6217561",
"0.6210741... | 0.0 | -1 |
Deformable conv2D operator in NHWC layout. | def deformable_conv2d_nhwc(
data, offset, kernel, strides, padding, dilation, deformable_groups, groups, out_dtype
):
if out_dtype is None:
out_dtype = data.dtype
if isinstance(strides, int):
stride_h = stride_w = strides
else:
stride_h, stride_w = strides
if isinstance(dil... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convert_conv2d(g, op, block):\n\n dilations = op.attr(\"dilations\")\n groups = op.attr(\"groups\")\n paddings = op.attr(\"paddings\")\n padding_algorithm = op.attr(\"padding_algorithm\")\n strides = op.attr(\"strides\")\n\n kernel = g.get_node(op.input(\"Filter\")[0])\n input_x = g.get_no... | [
"0.6924233",
"0.6878214",
"0.68353266",
"0.6753608",
"0.6732085",
"0.6699978",
"0.66800994",
"0.6465988",
"0.6420144",
"0.64079714",
"0.6401289",
"0.63805044",
"0.6378001",
"0.6361325",
"0.6354381",
"0.6333672",
"0.63279164",
"0.63256884",
"0.6314015",
"0.629172",
"0.6291327"... | 0.0 | -1 |
Modulated Deformable conv2D operator in NCHW layout. | def modulated_deformable_conv2d_nchw(
data, offset, mask, kernel, strides, padding, dilation, deformable_groups, groups, out_dtype
):
if out_dtype is None:
out_dtype = data.dtype
if isinstance(strides, int):
stride_h = stride_w = strides
else:
stride_h, stride_w = strides
i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convert_conv2d(g, op, block):\n\n dilations = op.attr(\"dilations\")\n groups = op.attr(\"groups\")\n paddings = op.attr(\"paddings\")\n padding_algorithm = op.attr(\"padding_algorithm\")\n strides = op.attr(\"strides\")\n\n kernel = g.get_node(op.input(\"Filter\")[0])\n input_x = g.get_no... | [
"0.6828529",
"0.67575896",
"0.6594705",
"0.65607363",
"0.65589213",
"0.6528172",
"0.6451237",
"0.64489007",
"0.6440598",
"0.6432712",
"0.64226335",
"0.6388169",
"0.6362342",
"0.62699884",
"0.6259978",
"0.6253116",
"0.6241763",
"0.6232873",
"0.62303174",
"0.62289196",
"0.62165... | 0.60770565 | 31 |
Computation of prominence ratio according to ECMA74, annex D.10 for an amplitude or complex frequency spectrum. The TPR value is calculated according to ECMATR/108 | def pr_ecma_freq(spectrum, freqs, prominence=True):
if len(spectrum) != len(freqs) :
raise ValueError('Input spectrum and frequency axis must have the same size')
# Compute spectrum dB values
spectrum_db = amp2db(np.abs(spectrum), ref=2e-5)
# Compute PR values
tones... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pfcr2pfxtRatio():\n init()\n \n pfcr = \"MNXT\"\n pfxt = \"PFXT\"\n \n nbins = 100\n hr = ROOT.TH1D(\"hr\", \"PFCR/PFXT\", nbins, 0., 20.)\n \n cfPfcr = float(detInfo[pfcr.lower()][2])\n indPfcr = int(detInfo[pfcr.lower()][0])\n cfPfxt = float(detInfo[pfxt.lower()][2])\n ind... | [
"0.6527266",
"0.645789",
"0.6082491",
"0.5948877",
"0.5939551",
"0.5919086",
"0.5898634",
"0.5872601",
"0.5855628",
"0.58549035",
"0.58467454",
"0.584536",
"0.58290124",
"0.5793778",
"0.579017",
"0.5765589",
"0.5757814",
"0.57338727",
"0.57225055",
"0.5714937",
"0.5690466",
... | 0.6276012 | 2 |
Return the given mb in bytes \param mb megabytes value, either integer or float \return bytes integer value | def mb2bytes(mb):
return int( mb * (1<<20) ) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bytesToMB(bytes):\n bytes = int(bytes)\n mb = str(bytes/(1024*1024.0)).split(\".\")[0] + \".\" + \\\n str(bytes/(1024*1024.0)).split(\".\")[1][:2]\n return float(mb)",
"def test_bytes_to_mbytes(self):\n assert smdba.postgresqlgate.PgSQLGate._bt_to_mb(0x... | [
"0.7436616",
"0.7215821",
"0.69146925",
"0.68662626",
"0.6686623",
"0.6576723",
"0.6553818",
"0.64720297",
"0.630044",
"0.6281297",
"0.6252555",
"0.62334657",
"0.62304634",
"0.6220218",
"0.6219026",
"0.61765367",
"0.6167844",
"0.6167844",
"0.61511856",
"0.61511856",
"0.61461"... | 0.79053813 | 0 |
Return the given file name without its file type extension | def strip_extension(filename):
return filename.rsplit('.',1)[-2] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def filename_strip_ext(filename):\n base = os.path.basename(filename)\n # Strip file extension\n return os.path.splitext(base)[0]",
"def name_sans_ext(self) -> str:\n return os.path.splitext(self.path)[0]",
"def clean_filename(file):\r\n\r\n return file.split('.')[0]",
"def get_file_name(f... | [
"0.8455022",
"0.8272778",
"0.81052935",
"0.7889851",
"0.7885302",
"0.7783055",
"0.77773535",
"0.77472246",
"0.77421254",
"0.7719816",
"0.7714679",
"0.769115",
"0.7676718",
"0.7669863",
"0.7644738",
"0.76340246",
"0.76293457",
"0.760549",
"0.7575833",
"0.7569268",
"0.75627786"... | 0.8085748 | 3 |
Return the relative path of a file to a directory. | def get_relative_path(dir, full_path):
if dir[-1] == '/' or dir[-1] == ':':
return full_path[ len(dir) : ]
else:
return full_path[ len(dir)+1 : ] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def file_directory(file):\n return os.path.dirname(os.path.realpath(file))",
"def get_relative_path(self, file_path):\n file_path = os.path.abspath(file_path)\n if self.base_dir is not None:\n file_path = file_path.replace(os.path.abspath(self.base_dir), \"\")\n assert file_pat... | [
"0.79369354",
"0.78443545",
"0.7681555",
"0.7584519",
"0.75486296",
"0.7506685",
"0.7384888",
"0.73440295",
"0.73185885",
"0.7179872",
"0.7149346",
"0.71370625",
"0.71160865",
"0.71030444",
"0.7090903",
"0.70788646",
"0.7074281",
"0.7071575",
"0.7067113",
"0.7050872",
"0.7044... | 0.724314 | 9 |
Same as Nebula mangle path, but giving paths without the special directories '.' and '..' | def mangle_path(path):
# Remove assigns
path = servers.get_file_server().manglepath( str(path) )
# Remove parent special directories
path = os.path.abspath( path )
# Convert path to Nebula format (slashes instead of backslashes)
path = servers.get_file_server().manglepath( str(path) )
# Conv... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def native(path):\n path = _os.path.sep.join(path.split('/'))\n return _os.path.normpath(_os.path.join(root, path))",
"def normpath(path: Union[str, BasePathLike]) -> str:\n # convertion to string in order to allow receiving non string objects\n return os.path.relpath(str(path))",
"def normpath (pa... | [
"0.67952025",
"0.67307246",
"0.66611874",
"0.65603596",
"0.6546353",
"0.65275925",
"0.6517664",
"0.64836204",
"0.6476119",
"0.64441717",
"0.6436163",
"0.6433354",
"0.6404632",
"0.6371606",
"0.63631254",
"0.63177294",
"0.6302908",
"0.6285278",
"0.627473",
"0.62700146",
"0.6248... | 0.71329486 | 0 |
Get a Spark session in a way that supports running locally or in Data Flow. | def get_dataflow_spark_session(app_name="DataFlow", file_location=None, profile_name=None, spark_config={}):
if in_dataflow():
spark_builder = SparkSession.builder.appName(app_name)
else:
# Import OCI.
try:
import oci
except:
raise Exception(
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getOrCreate(self) -> \"SparkSession\":\n return SparkSession(connectionString=self._options[\"spark.connect.location\"])",
"def get_active_spark_session() -> Optional[SparkSession]:\n if is_spark_context_stopped():\n return None\n return SparkSession.getActiveSession()",
"def create... | [
"0.79376125",
"0.7623519",
"0.75844926",
"0.7518808",
"0.7452375",
"0.7307466",
"0.7277361",
"0.7220452",
"0.71681154",
"0.7041723",
"0.7041723",
"0.7041723",
"0.7041723",
"0.7041723",
"0.7041723",
"0.7041723",
"0.7041723",
"0.7041723",
"0.7031369",
"0.70046675",
"0.69975275"... | 0.7419343 | 5 |
Mark that PCA analysis needs to be rerun. This method also clears the results from the previous PCA. | def _mark_cache_invalid(self):
self.cache_valid = False
self.pca_results = None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _clear_results(self):\n # Schedule existing analysis results for deletion next save call\n for key in self._analysis_results.keys():\n self._deleted_analysis_results.append(key)\n self._analysis_results = ThreadSafeOrderedDict()\n # Schedule existing figures for deletion ... | [
"0.6270399",
"0.61902213",
"0.59944075",
"0.5966293",
"0.5911498",
"0.5834439",
"0.58139515",
"0.58131194",
"0.5798462",
"0.5785009",
"0.5776583",
"0.5773485",
"0.5725095",
"0.5716123",
"0.5711999",
"0.5688346",
"0.56815124",
"0.5672664",
"0.56682754",
"0.56552327",
"0.565515... | 0.5383897 | 64 |
Determine if object_ is a lyse.Run instance or similar. This method is used to determine if an object is similar to a lyse.Run instance. This is mainly used for interpretting arguments to methods in this class. In particular it is used to figure out if something like a numpy array is provided as an image, or if a lyse.... | def _is_run_type(cls, object_):
# Do a string comparison instead of using isinstance() to avoid needing
# to import lyse or other modules with these classes.
return (type(object_).__name__ in cls._RUN_TYPES) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _is_repeatedshot_type(cls, object_):\n return (type(object_).__name__ in ['RepeatedShot'])",
"def isclassinstance(object):\n if not hasattr(object, \"__class__\"):\n return False\n if isbuiltin(object.__class__):\n return False\n return True",
"def isclass(object):\n if not... | [
"0.6063975",
"0.6060396",
"0.58042234",
"0.57719535",
"0.56707263",
"0.5664598",
"0.56621164",
"0.55818546",
"0.55812025",
"0.5580095",
"0.55463207",
"0.54774797",
"0.5409012",
"0.5402747",
"0.5350518",
"0.53228813",
"0.5321007",
"0.53067243",
"0.5291581",
"0.52734035",
"0.52... | 0.843441 | 0 |
Determine if object_ is a RepeatedShot instance. This method determines if object_ is an instance of our custom RepeatedShot class. This is a distinct method from _is_run_type() because they need to be handled slightly differently since they contain multiple images. | def _is_repeatedshot_type(cls, object_):
return (type(object_).__name__ in ['RepeatedShot']) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _is_run_type(cls, object_):\n # Do a string comparison instead of using isinstance() to avoid needing\n # to import lyse or other modules with these classes.\n return (type(object_).__name__ in cls._RUN_TYPES)",
"def __is_type_instance( self, instance_type ):\n for index, instance... | [
"0.6818754",
"0.599205",
"0.5925885",
"0.5738632",
"0.5730448",
"0.56635624",
"0.5652772",
"0.5644911",
"0.561143",
"0.55758536",
"0.5550535",
"0.5539059",
"0.54788357",
"0.5454034",
"0.5453979",
"0.5425489",
"0.5402651",
"0.5390146",
"0.53733283",
"0.5333188",
"0.5321255",
... | 0.86113185 | 0 |
Get the mean beam image calculated during PCA. Will be returned as a 2D array. Note that calling this method will run the PCA analysis if it has not yet been run. | def get_pca_mean_beam(self):
return self.get_pca_images()[0] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_pca_images(self):\n mean_vector, principal_components, variances = self.pca()\n shape = self.image_shape + (principal_components.shape[1],)\n principal_component_images = principal_components.reshape(shape)\n principal_component_images = np.moveaxis(\n principal_compo... | [
"0.68503416",
"0.66262984",
"0.6625393",
"0.65327656",
"0.6316808",
"0.6314991",
"0.6228263",
"0.60785574",
"0.607594",
"0.6068922",
"0.5956958",
"0.5946902",
"0.5916866",
"0.5872937",
"0.5870806",
"0.5868154",
"0.5829432",
"0.58169025",
"0.578779",
"0.5783356",
"0.57669353",... | 0.8502905 | 0 |
Save cached PCA results to disk. | def save_pca(self, filepath):
mean_beam, principal_components, variances = self.pca()
image_shape = np.array(self.image_shape)
with open(filepath, 'wb') as f:
np.save(f, image_shape)
np.save(f, mean_beam)
np.save(f, principal_components)
np.save(f,... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _save_pca_matrix(self, filename):\n\n np.savetxt(filename, self.pca_matrix, delimiter=\",\")",
"def save_outputs(self):\n write_pickled(join(self.output_folder, \"results.pkl\"), self.get_results())",
"def output_cache(cc):\n\n out_file = os.path.join(cc.scene_dir, 'output', cc.scene_id+'_... | [
"0.6452552",
"0.62851304",
"0.6265904",
"0.6168414",
"0.6065707",
"0.588655",
"0.58652025",
"0.5815887",
"0.57938355",
"0.5752202",
"0.57140005",
"0.57098246",
"0.5691539",
"0.5651883",
"0.5645643",
"0.5644559",
"0.56236345",
"0.5622598",
"0.5614969",
"0.55879456",
"0.5576362... | 0.70057505 | 0 |
Display the mean beam image as a false color plot. | def plot_mean_beam(self, *args, **kwargs):
# Get the principal components.
mean_beam = self.get_pca_mean_beam()
# Generate the plot
axes = self.plot_image(mean_beam, *args, **kwargs)
axes.set_title("Mean Beam Image")
# Return the axes of the plot.
return axes | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_img():\n plt.subplot(121)\n plt.imshow(data.data.numpy()[0,].squeeze())\n plt.subplot(122)\n plt.imshow(dec_mean.view(-1,28,28).data.numpy()[0,].squeeze())\n\n plt.show()\n plt.pause(1e-6)\n plt.gcf().clear()\n sample = model.sample_z(data) \n plt.imshow(sample)",
"def imsh... | [
"0.6679711",
"0.6550966",
"0.6530197",
"0.65128887",
"0.6451824",
"0.64170814",
"0.6386277",
"0.6378754",
"0.63160205",
"0.63069475",
"0.62929595",
"0.6285503",
"0.6214592",
"0.6185149",
"0.6180264",
"0.6180264",
"0.6180264",
"0.61731994",
"0.61706",
"0.61528397",
"0.61357915... | 0.7516682 | 0 |
Display an image as a false color plot. | def plot_image(self, image, axes=None, colorbar=True, imshow_args={}):
# Set up new axes if necessary.
if axes is None:
fig = plt.figure()
axes = fig.add_subplot(111)
# Plot the image.
# Set options, without overwriting caller settings.
imshow_args = {
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_image(image):\n plt.imshow(image, cmap=\"gray\", interpolation=\"nearest\")\n plt.axis(\"off\")",
"def plot_color_image(image):\n plt.imshow(image, interpolation=\"nearest\")\n plt.axis(\"off\")",
"def plt_show_image(image):\r\n plt.imshow(image)\r\n plt.axis('off')\r\n plt.axis('... | [
"0.81219697",
"0.80883837",
"0.7722984",
"0.75321466",
"0.7406405",
"0.7353721",
"0.7305321",
"0.7279725",
"0.72698563",
"0.72698563",
"0.72698563",
"0.72024333",
"0.7159563",
"0.7019339",
"0.6976837",
"0.6918304",
"0.6870019",
"0.68663275",
"0.6810255",
"0.67992514",
"0.6778... | 0.0 | -1 |
Test if process ID is a number and `@`sign is included. | def test_get_pid_and_server():
assert re.match("^[0-9]+@[a-zA-Z0-9_]+", util.get_pid_and_server()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isnum(self, x):\n\n return x in '1234567890.-'",
"def number_only(number):\n number = number.replace(' ', '')\n result = re.match(r\"^[0-9]+$\", number)\n if not result:\n return True\n return False",
"def only_int(p):\r\n if p.isdigit():\r\n return T... | [
"0.6474449",
"0.6189617",
"0.61746675",
"0.6157363",
"0.613703",
"0.60712403",
"0.60144657",
"0.6004903",
"0.58547246",
"0.5835505",
"0.5829507",
"0.5828928",
"0.57841563",
"0.57808536",
"0.57669",
"0.5766838",
"0.5755105",
"0.5753852",
"0.57278836",
"0.5726764",
"0.5699714",... | 0.5300073 | 71 |
A relaxed version of ``__eq__``, in which only nonderived dimensions are compared for equality. | def is_compatible(self, other):
return self.intervals == other.intervals and\
self.nonderived_directions == other.nonderived_directions | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __eq__(self, other):\n if self.n != other.n or self.m != other.m:\n raise TypeError(\"Illegal dimensions for eq operator (%s x %s - %s x %s)\" %\n (self.n, self.m, other.n, other.m))\n return self.values == other.values",
"def __eq__(self, other):\r\n ... | [
"0.7762042",
"0.74444467",
"0.72101843",
"0.72101843",
"0.72101843",
"0.72101843",
"0.72101843",
"0.72101843",
"0.72101843",
"0.72101843",
"0.72101843",
"0.72101843",
"0.72101843",
"0.72101843",
"0.72101843",
"0.72101843",
"0.72101843",
"0.72101843",
"0.72101843",
"0.72101843",... | 0.0 | -1 |
Returns center cropped image | def center_crop(img, dim):
# https://gist.github.com/Nannigalaxy/35dd1d0722f29672e68b700bc5d44767
width, height = img.shape[1], img.shape[0]
# process crop width and height for max available dimension
crop_width = dim[0] if dim[0] < img.shape[1] else img.shape[1]
crop_height = dim[1] if dim[1] < img.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def crop_center(image, cropx, cropy):\n x,y = image.shape\n startx = x//2 - cropx//2\n starty = y//2 - cropy//2 \n return image[startx:startx+cropx, starty:starty+cropy]",
"def crop_center_img(self):\n # TODO Task 1.1\n img = self.data\n img_with_missing_crop = np.copy(img)\n ... | [
"0.7963459",
"0.7638151",
"0.76044345",
"0.74087983",
"0.740208",
"0.7284791",
"0.728289",
"0.7279314",
"0.7261671",
"0.72432995",
"0.7205581",
"0.72042626",
"0.7200235",
"0.7156868",
"0.7101748",
"0.70445836",
"0.696327",
"0.69575727",
"0.6903975",
"0.69010776",
"0.68450946"... | 0.66767377 | 32 |
Return counts of total pair trawlers and trawler pairs. | def compute_detection_counts(kinds, valid_mask, aoi_mask, scene_counts):
scene_counts = np.maximum(scene_counts, 1)
if len(kinds):
pairs = (kinds == 'pair_trawlers')
singles = (kinds == 'single_trawler')
scales = (kinds == 'pair_trawlers') * 2 + (kinds == 'single_trawler')
aoi_pt... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tx_counts(self) -> Dict[str, Dict[str, int]]:\n agent_pbk_to_name = self.game.configuration.agent_pbk_to_name\n result = {agent_name: 0 for agent_name in agent_pbk_to_name.values()}\n results = {\"seller\": result.copy(), \"buyer\": result.copy()}\n\n temp_game = Game(self.game.conf... | [
"0.59497243",
"0.5537722",
"0.5499426",
"0.54982406",
"0.54982406",
"0.5488811",
"0.54234195",
"0.54162526",
"0.534",
"0.5294098",
"0.527548",
"0.52749014",
"0.525896",
"0.5250165",
"0.5247916",
"0.52285326",
"0.5212973",
"0.51814866",
"0.5133893",
"0.5106483",
"0.51005536",
... | 0.0 | -1 |
Compute the gradient of the cost function w.r.t. the feature matrix self.theta | def compute_grads(self, X, y):
grads = np.zeros_like(self.theta)
sigsoftk = self.softmax_mat(X)
m = X.shape[1]
for k in range(self.nclasses):
# To compute the gradient we sum over every training
# example, i.e., sum(axis=1)
grad = ((sigsoftk - y)[k,:] ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gradient(self, theta):\n pass",
"def gradient(self, theta):\n pass",
"def logit_cost_grad(self, theta, X, y):\n\n grad = np.zeros(len(theta))\n\n ### YOUR CODE HERE\n sig = utils.sigmoid(theta)\n # sig = np.subtract(sig, y)\n sig = sig - y\n grad = np... | [
"0.8161107",
"0.8161107",
"0.81329745",
"0.81069064",
"0.8050006",
"0.7979979",
"0.7959363",
"0.79376876",
"0.7749863",
"0.77251774",
"0.76677454",
"0.7646409",
"0.76458144",
"0.763517",
"0.7630948",
"0.75446135",
"0.75322455",
"0.74703735",
"0.7450802",
"0.7411786",
"0.73923... | 0.0 | -1 |
Given a direction, two patterns, and a pattern catalog, return True if we overlap pattern two on top of pattern one and the intersection of the two patterns is an exact match. | def is_valid_overlap_xy(dir_id, p1, p2, pattern_catalog, pattern_width, adjacency_directions):
#dir_corrected = (0 - adjacency_directions[dir_id].x, 0 - adjacency_directions[dir_id].y)
dir_corrected = (0 + adjacency_directions[dir_id].x, 0 + adjacency_directions[dir_id].y)
dimensions = (1,0)
not_a_numbe... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def conflateable(seg1, seg2, segment_pairs):\n for segment_pair in segment_pairs:\n seg_set = set(segment_pair)\n if seg1 in seg_set and seg2 in seg_set:\n return True\n return False",
"def compatible(pattern1, pattern2, direction):\n if direction == 0:\n ... | [
"0.6123055",
"0.6094962",
"0.5857792",
"0.5839089",
"0.57844794",
"0.5691257",
"0.5668334",
"0.5651952",
"0.5649129",
"0.5632027",
"0.56156564",
"0.55987436",
"0.5598101",
"0.5577707",
"0.55506974",
"0.5550451",
"0.5535778",
"0.5530083",
"0.5526925",
"0.552425",
"0.5506287",
... | 0.71406496 | 0 |
Converts Miles to Kilometers and sets label text to calculated value | def calculate():
miles = float(input_field.get())
lbl_km.config(text=str(miles*1.609)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def miles_to_kilometers(miles):\n #convert miles to km:\n return miles*1.60934",
"def test_kilometers_to_miles(self) -> None:\n kilometers = 5\n metric = \"kilometers\"\n\n self.assertEqual(\"3.11\", f\"{to_miles(metric, kilometers):.2f}\")\n\n kilometers = 0\n metric = \... | [
"0.71072197",
"0.70170546",
"0.6874664",
"0.6871716",
"0.6826592",
"0.6797197",
"0.6733025",
"0.66788435",
"0.6575972",
"0.65458626",
"0.6405684",
"0.6351761",
"0.6272232",
"0.62671566",
"0.6240767",
"0.623134",
"0.6089299",
"0.60149765",
"0.5985503",
"0.58742446",
"0.5803793... | 0.828475 | 0 |
Describe a local training job. | def describe_training_job(self, TrainingJobName):
response = {'ResourceConfig': {'InstanceCount': self.train_container.instance_count},
'TrainingJobStatus': 'Completed',
'TrainingStartTime': datetime.datetime.now(),
'TrainingEndTime': datetime.datetime... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def describe_training_job(TrainingJobName=None):\n pass",
"def describe_labeling_job(LabelingJobName=None):\n pass",
"def describe_job(self):\n # GET /jobs/{job_id}\n pass",
"def describe_hyper_parameter_tuning_job(HyperParameterTuningJobName=None):\n pass",
"def describe_text_transl... | [
"0.8363346",
"0.734393",
"0.66061383",
"0.63555974",
"0.6215679",
"0.6177397",
"0.6125503",
"0.60209006",
"0.60206497",
"0.59501815",
"0.590491",
"0.5895755",
"0.5885618",
"0.5858112",
"0.58550334",
"0.5823724",
"0.58194655",
"0.575156",
"0.575156",
"0.5742599",
"0.56821734",... | 0.6566312 | 3 |
Plot an example of sigmoid | def plot_sigmoid():
X = np.linspace(-10, 10, 100)
sX = sigmoid(X)
plt.figure(figsize=(15,5))
plt.xlabel(r'$\theta^Tx^{(i)}$')
plt.ylabel(r'$h(x^{(i)}, \theta)$')
plt.plot(X, sX)
plt.show() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def figure_10_12_b():\n xs = np.arange(-6,6,0.1)\n plt.plot(xs,sigmoid(xs))\n x=2.5\n plt.scatter(x,sigmoid(x))\n plt.plot(xs,logistic_lower_bound(xs,x))\n plt.show()",
"def sigmoid(x):\n return 1 / (1 + exp(-x))",
"def sigmoid(x):\n return 1 / (1 + exp(-x))",
"def sigmoid(x):\r\n ... | [
"0.8030348",
"0.7459372",
"0.7459372",
"0.7390504",
"0.73787713",
"0.73716944",
"0.7367749",
"0.73669165",
"0.73649716",
"0.73445565",
"0.73352456",
"0.73352456",
"0.73352456",
"0.73352456",
"0.73352456",
"0.73352456",
"0.7325473",
"0.7324465",
"0.730983",
"0.73001784",
"0.72... | 0.9086316 | 0 |
Computes the precision for the specified values of k | def accuracy(output, target, topk=(1,)):
maxk = max(topk)
batch_size = target.size(0)
_, pred = output.topk(maxk, 1, True, True)
pred = pred.t()
correct = pred.eq(target.view(1, -1).expand_as(pred))
res = []
for k in topk:
correct_k = correct[:k].view(-1).float().sum(0).item()
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def precision(gt, pred, k):\n k = min(len(pred), k)\n den = min(len(gt), k)\n return sum([int(pred[i] in gt) for i in range(k)]) / den",
"def precision_at_k(r, k):\n assert k >= 1\n r = np.asarray(r)[:k] != 0\n if r.size != k:\n raise ValueError('Relevance score length < k')\... | [
"0.7643041",
"0.7418986",
"0.7418119",
"0.7270918",
"0.7245867",
"0.7244652",
"0.72375184",
"0.72214437",
"0.7210162",
"0.7058879",
"0.6851859",
"0.6786372",
"0.6783499",
"0.67681795",
"0.6727462",
"0.67179555",
"0.67179555",
"0.67179555",
"0.67179555",
"0.67179555",
"0.67179... | 0.0 | -1 |
Creates a new shot line from the given origin to the given point. | def __init__(self, origin, end, alpha=DEFAULT_ALPHA, fade_rate=DEFAULT_FADE_RATE, thickness=DEFAULT_THICKNESS, color=DEFAULT_COLOR):
super(ShotLine, self).__init__()
self.origin = origin
self.end = end
self.alpha = alpha
self.fade_rate = float(fade_rate) / 1000
self.thick... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def line_to(self, point: Onion[Tuple[float, float], Point2D, Point3D, Point]):\n start_point = self.last_point\n end_point = _point_2d(point)\n self._segments.append(Line3D.create(start_point, end_point))",
"def shotAtAngle(origin, angle, alpha=DEFAULT_ALPHA, fade_rate=DEFAULT_FADE_RATE):\n ... | [
"0.63009834",
"0.6096479",
"0.592125",
"0.5772418",
"0.5729049",
"0.5620878",
"0.5601629",
"0.5574255",
"0.55161643",
"0.55039394",
"0.5496343",
"0.54637295",
"0.54475015",
"0.5443609",
"0.5418516",
"0.5408607",
"0.5398306",
"0.53906083",
"0.53747797",
"0.537216",
"0.53679943... | 0.6255954 | 1 |
Creates a shot line traveling from the given origin at the given angle until it hits an enemy. This will return a tuple containing the shot line and the enemy. You must also pass this function an enemy manager whose enemies should be checked for hits. You may specify the maximum bullet travel distance with the shot_ran... | def toEnemy(origin, angle, enemy_mgr, shot_range=DEFAULT_RANGE, extra_dist=DEFAULT_EXTRA_DIST, **kwargs):
# Trace the line until it hits something.
# check_dist specifies how far to jump between each check. This will reduce how many times we have to check.
# By doing this, we significantly reduce the amount... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def throughEnemies(origin, angle, enemy_mgr, shot_range=DEFAULT_RANGE, **kwargs):\n # Trace the line until it hits something.\n # See the comment about check_dist above.\n check_dist = 16\n shot_slope = Vector(math.cos(math.radians(angle)), -math.sin(math.radians(angle)))*check_dist\n check_pos = to... | [
"0.7278352",
"0.64249337",
"0.5539806",
"0.5538173",
"0.5387117",
"0.523258",
"0.52153623",
"0.5097411",
"0.5038053",
"0.4985667",
"0.49746048",
"0.4967651",
"0.49065998",
"0.4881003",
"0.48305634",
"0.48246595",
"0.4797242",
"0.47825658",
"0.47787392",
"0.47703522",
"0.47190... | 0.77704954 | 0 |
Wrapper for AttaCut Fast and Reasonably Accurate Word Tokenizer for Thai | def segment(text: str, model: str = "attacut-sc") -> List[str]:
if not text or not isinstance(text, str):
return []
_tokenizer = AttacutTokenizer(model)
return _tokenizer.tokenize(text) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def preprocess_sent(sent):\n #tokenized = word_tokenize(sent.lower())\n tokenizer = Tok()\n tokenized = tokenizer.tokenize(sent.lower())\n return tokenized",
"def get_tokenizer(stories, word_table):\n tokens_all = []\n for story, query, answer, task_id in stories:\n for sentence in story... | [
"0.65250134",
"0.6506513",
"0.6453489",
"0.6349921",
"0.62915426",
"0.6265368",
"0.6249727",
"0.619711",
"0.61563087",
"0.61398464",
"0.6084419",
"0.60737765",
"0.607187",
"0.60616946",
"0.6043579",
"0.6040567",
"0.60357857",
"0.6005005",
"0.59989035",
"0.5990072",
"0.5981920... | 0.0 | -1 |
computing IoU xmin, ymin, xmax, ymax | def compute_iou(rec1, rec2):
rec1[0] = float(rec1[0])
rec1[1] = float(rec1[1])
rec1[2] = float(rec1[2])
rec1[3] = float(rec1[3])
print("rec1, xmin,ymin:(%d,%d) xmax, ymax:(%d,%d)"%(rec1[0], rec1[1],rec1[2],rec1[3]))
print("rec2, xmin,ymin:(%d,%d) xmax, ymax:(%d,%d)"%(rec2[0], rec2[1],rec2[2],rec... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _iou(self, bb_test,bb_gt):\n xx1 = np.maximum(bb_test[0], bb_gt[0])\n yy1 = np.maximum(bb_test[1], bb_gt[1])\n xx2 = np.minimum(bb_test[2], bb_gt[2])\n yy2 = np.minimum(bb_test[3], bb_gt[3])\n w = np.maximum(0., xx2 - xx1)\n h = np.maximum(0., yy2 - yy1)\n wh = ... | [
"0.6434358",
"0.63876253",
"0.63340557",
"0.6282999",
"0.6263213",
"0.6116927",
"0.60978514",
"0.6022237",
"0.6008914",
"0.59950554",
"0.5985981",
"0.5966883",
"0.5923819",
"0.5902815",
"0.58979046",
"0.5866241",
"0.5840261",
"0.58378077",
"0.5809833",
"0.5805607",
"0.5798039... | 0.62093836 | 5 |
Swap the positions of two characters in a string | def swap_position(puzzle: str, from_index: int, to_index: int) -> str:
puzzle_list = list(puzzle)
# Used to swap the positons of the chracters in the array
puzzle_list[from_index], puzzle_list[to_index] = (
puzzle_list[to_index],
puzzle_list[from_index],
)
return "".join(puz... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def encryptionSwap(text, index1, index2):\n s = text\n transformedChar = \"\"\n\n swapIndex1 = s[index1]\n swapIndex2 = s[index2]\n\n prevText = s[:index1]\n midText = s[(index1+1):index2]\n endText = s[(index2+1):]\n\n transformedChar = prevText + swapIndex2 + midText + swapIndex1 + endTex... | [
"0.715326",
"0.69606435",
"0.6952456",
"0.6868907",
"0.67250884",
"0.66518354",
"0.66463965",
"0.65613747",
"0.6485961",
"0.6391889",
"0.63708633",
"0.6349042",
"0.6333542",
"0.63127226",
"0.62922347",
"0.6244852",
"0.62375045",
"0.61770195",
"0.6140371",
"0.61266106",
"0.612... | 0.62313116 | 17 |
Initializes weights to randomly selected ones. | def initWeights(self):
self.weights = []
self.bias = []
for i, dim in enumerate(self.dimensions[1:]):
self.weights.append(np.random.uniform(-1,1,(self.dimensions[i],dim)))
self.bias.append(np.random.uniform(-1,1,dim)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def default_weight_initializer(self):\n self.biases = [np.random.randn(y, 1) for y in self.sizes[1:]]\n self.weights = [np.random.randn(y, x)/np.sqrt(x)\n for x, y in zip(self.sizes[:-1], self.sizes[1:])]",
"def InitWeights(self):\n self.w = -1 + 2 * np.random.rand(sel... | [
"0.830088",
"0.8106974",
"0.80594665",
"0.8048732",
"0.7973337",
"0.7958445",
"0.7923005",
"0.79205847",
"0.7853558",
"0.7851621",
"0.78394485",
"0.7813727",
"0.7791037",
"0.7781642",
"0.7605329",
"0.75471747",
"0.75438994",
"0.75333905",
"0.75022024",
"0.7492063",
"0.7488693... | 0.8140313 | 1 |
Changes weights to be around the ones provided by shp. This is used to generate offspring from the shp provided. | def copyWeights(self, shp, stray = 0, colour = (240,100,100)):
self.weights = []
self.bias = []
if(stray == 0): # straight copy
for i, wt in enumerate(shp.weights):
self.weights.append(wt.copy())
for i,bs in enumerate(shp.bias):
self.bias.a... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def copyWeightsExper(self, shp, stray = 0, colour = (240,100,100)):\n self.copyWeights(shp, stray = stray, colour = colour)\n for wt in self.weights:\n i = np.random.randint(wt.shape[0])\n j = np.random.randint(wt.shape[1])\n wt[i,j] = np.random.uniform(-1,1,1)\n ... | [
"0.7041162",
"0.65645933",
"0.6378492",
"0.63738847",
"0.6341806",
"0.622586",
"0.6213727",
"0.60888124",
"0.6087517",
"0.6082563",
"0.60552853",
"0.5985946",
"0.5974113",
"0.5966959",
"0.5957351",
"0.5916344",
"0.58965003",
"0.5877744",
"0.5872765",
"0.5836537",
"0.5829642",... | 0.693266 | 1 |
version of copyWeights() that only take 1 element of each weight matrix and changes it absolutely to a new value, regardless of the input value. | def copyWeightsExper(self, shp, stray = 0, colour = (240,100,100)):
self.copyWeights(shp, stray = stray, colour = colour)
for wt in self.weights:
i = np.random.randint(wt.shape[0])
j = np.random.randint(wt.shape[1])
wt[i,j] = np.random.uniform(-1,1,1)
for bs i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def copy_weights(self):\n return copy.deepcopy(self.weights_ih), copy.deepcopy(self.weights_ho)",
"def hard_copy_weights(self, target, source):\n for target_param, param in zip(target.parameters(), source.parameters()):\n target_param.data.copy_(param.data)",
"def normalizeWeights(self... | [
"0.7002011",
"0.6879236",
"0.67828685",
"0.6656836",
"0.65387666",
"0.6333125",
"0.6322166",
"0.629663",
"0.62595266",
"0.62483966",
"0.62285846",
"0.6194986",
"0.6153844",
"0.61504567",
"0.6144958",
"0.6125564",
"0.61214596",
"0.61007637",
"0.6095712",
"0.607384",
"0.607336"... | 0.57926285 | 41 |
Returns the current ship position as a tuple of integers | def getIntPos(self):
return (int(self.pos[0]),int(self.pos[1])) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_pos(self) -> tuple:\n return self.pos",
"def get_position(self) -> typing.Tuple[int, int]:\n raise NotImplementedError",
"def get_coords(self) -> Tuple[int]:\r\n return self.file, self.rank",
"def coordinates(self) -> Tuple[int, int]:\n return self.x, self.y",
"def get_p... | [
"0.7341177",
"0.7200967",
"0.71909124",
"0.7100945",
"0.7060518",
"0.69802684",
"0.6963608",
"0.6939057",
"0.6817084",
"0.6786425",
"0.67661196",
"0.6756637",
"0.6697585",
"0.665994",
"0.66421515",
"0.66309017",
"0.66010374",
"0.65941644",
"0.659156",
"0.65712994",
"0.6533125... | 0.7346198 | 0 |
Return an array of the given shape and dtype filled with ones. | def ones(shape: tuple, dtype: np.dtype, order: str = 'C', allocator=drv.mem_alloc):
out = gpuarray.GPUArray(shape, dtype, allocator, order=order)
o = np.ones((), dtype)
out.fill(o)
return out | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ones(shape, dtype=None):\n\n return full(shape, 1, dtype)",
"def ones(shape, dtype=None):\r\n if not isinstance(shape, (list, tuple, TensorVariable)):\r\n shape = [shape]\r\n if dtype is None:\r\n dtype = config.floatX\r\n return alloc(numpy.array(1, dtype=dtype), *shape)",
"def o... | [
"0.8584159",
"0.8484917",
"0.81037515",
"0.8066067",
"0.80635613",
"0.78293806",
"0.7592348",
"0.7535861",
"0.7535861",
"0.7490128",
"0.7472371",
"0.74602735",
"0.74329233",
"0.7309876",
"0.72846764",
"0.7241494",
"0.7196",
"0.7062805",
"0.70211536",
"0.7003842",
"0.69979644"... | 0.7642338 | 6 |
Compute the sum along the specified axis. | def sum_gpu(
x_gpu: gpuarray.GPUArray,
axis: int = None,
out: gpuarray.GPUArray = None,
keepdims: bool = False,
calc_mean: bool = False,
ddof: int = 0
) -> gpuarray.GPUArray:
assert isinstance(ddof, numbers.Integral)
if axis is None or len(x_gpu.shape) <= 1:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sum(tensor, axis=None):\n raise NotImplementedError",
"def sum(self, axis=None, keepdims=False):\n return F.Sum.apply(self, axis, keepdims)",
"def sum(self, axis: int = 0):\r\n self.values = self.values.sum(axis=axis)\r\n self.layers = [None]\r\n return self.copy()",
"d... | [
"0.8128596",
"0.79579294",
"0.7781102",
"0.7558087",
"0.7473695",
"0.74137914",
"0.7381376",
"0.73511857",
"0.7201773",
"0.7127504",
"0.69339126",
"0.6753328",
"0.674404",
"0.67009723",
"0.66545206",
"0.66333914",
"0.66175956",
"0.6575717",
"0.65181714",
"0.650503",
"0.647526... | 0.0 | -1 |
Uses Rescaling Method (xmin(X))/(max(X)min(X)) to normalize the data set | def Rescaling_Normalization(data: pd.DataFrame) -> pd.DataFrame:
labels = data.pop('Labels')
norm_data = (data - data.min()) / (data.max() - data.min())
norm_data['Labels'] = labels
return norm_data | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def normalize(x):\n # TODO: Implement Function\n data_max = np.max(x)\n data_min = np.min(x)\n x = (x - data_min) / (data_max - data_min)\n return x",
"def normalize(self,x,xmin,xmax):\n return (x-xmin)/(xmax-xmin)",
"def normalize(x, min_x, max_x):\n\treturn (x - min_x) / (max_x - mi... | [
"0.82514304",
"0.79993814",
"0.7850011",
"0.7839024",
"0.7757047",
"0.7677804",
"0.7677804",
"0.76516336",
"0.76386595",
"0.7610676",
"0.75835884",
"0.7537762",
"0.7497532",
"0.7467388",
"0.7455064",
"0.74113506",
"0.73814034",
"0.73743045",
"0.7359983",
"0.73518115",
"0.7340... | 0.6814351 | 66 |
converts data (numpy array) that has onehot encoded categories in its last dimension to category indices (with the other dimensions remaining) | def from_one_hot_to_category_indices(data: ndarray):
return np.argmax(data, axis=-1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def indices_to_one_hot(data, nb_classes):\n\ttargets = np.array(data).reshape(-1)\n\treturn np.eye(nb_classes)[targets]",
"def indices_to_one_hot(data, nb_classes):\n targets = np.array(data).reshape(-1)\n return np.eye(nb_classes)[targets]",
"def indices_to_one_hot(data, nb_classes):\n targets = np.a... | [
"0.76681525",
"0.76309854",
"0.76309854",
"0.76309854",
"0.76309854",
"0.7334187",
"0.7311324",
"0.72474855",
"0.7202543",
"0.7199169",
"0.7192213",
"0.71736515",
"0.71654564",
"0.7138912",
"0.71137965",
"0.708408",
"0.7082651",
"0.70444226",
"0.7039511",
"0.7019328",
"0.7008... | 0.8689355 | 0 |
Return the rate density for q, including f_bin and malmquist bias | def _malmquist_q_lngamma(self, gamma, f_bin):
func = np.poly1d(self.malm_pars[::-1])
const_factor = (1 - gamma) / (self.high_q ** (1 - gamma) - self.low_q ** (1 - gamma))
integral = np.sum(
[p * const_factor / (i + 1 - gamma) * (self.high_q ** (i + 1 - gamma) - self.low_q ** (i + 1 -... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def density(temp,pres):\n g_p = liq_g(0,1,temp,pres)\n dliq = g_p**(-1)\n return dliq",
"def Q(self):\n return np.array(list(self.center_frequencies)) \\\n / np.array(list(self.bandwidths))",
"def b(q):\n if q == 0 or q == 1:\n return float(0.0)\n return -(q * log2(q)... | [
"0.6526074",
"0.601527",
"0.5992198",
"0.5986421",
"0.59018826",
"0.5891574",
"0.5886646",
"0.5874722",
"0.58352107",
"0.5830237",
"0.5828314",
"0.58241194",
"0.5772418",
"0.57328796",
"0.56996655",
"0.56438416",
"0.56393325",
"0.5635219",
"0.5631988",
"0.5618872",
"0.5602189... | 0.0 | -1 |
Remove temporary directories and test conda env. | def teardown_test_env():
if not keep_tmp_dirs:
print('\nCleaning up temporary directories...')
shutil.rmtree(tmp_elm_dpath, ignore_errors=True)
shutil.rmtree(tmp_elm_examples_dpath, ignore_errors=True)
print('Removing conda environment used for testing...')
s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clean_up_temp_dir():\n files = glob.glob(f'{CONFIG_DIR}/tmp/*')\n for f in files:\n try:\n os.remove(f)\n except Exception:\n pass",
"def cleanup_tox_environments(tox_dir: str, command_array: str) -> None:\n if \"--cov-append\" in command_a... | [
"0.7477139",
"0.7282243",
"0.7233276",
"0.7186198",
"0.7083509",
"0.70632094",
"0.7054803",
"0.69754696",
"0.6933649",
"0.6852207",
"0.6848033",
"0.6827005",
"0.6818069",
"0.6814824",
"0.6814522",
"0.68024087",
"0.67896783",
"0.67687935",
"0.6759842",
"0.6759306",
"0.6759306"... | 0.8183083 | 0 |
Verifies shape inputs in reshape are properly imported | def test_reshape_plain_text_conversion(self):
class Net(torch.nn.Module):
def __init__(self):
super().__init__()
self.fc1 = torch.nn.Linear(4, 4)
def forward(self, x):
# (1, 4) is stored in a constant module
out = x.reshap... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _check_shape(input_shape):\n msg = ('Input to FlattenAxis must be 5D with dimensions: '\n '(n_observations, n_spatial_0, n_spatial_1, n_temporal, '\n 'n_features), but received shape: {}'.format(input_shape))\n assert len(input_shape) == 5, msg",
"def _check_shape(in... | [
"0.7390682",
"0.7349965",
"0.6976115",
"0.695844",
"0.6835194",
"0.6597007",
"0.6578576",
"0.6463081",
"0.6454531",
"0.6453658",
"0.64483976",
"0.6421449",
"0.64169073",
"0.63749385",
"0.63287026",
"0.6311869",
"0.6301827",
"0.62947226",
"0.6284791",
"0.6280287",
"0.62444764"... | 0.0 | -1 |
Returns true if both objects are equal | def __eq__(self, other):
if not isinstance(other, PoliciesPeripheralsUsbDeviceCommon):
return False
return self.__dict__ == other.__dict__ | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __eq__(self, other):\n return are_equal(self, other)",
"def __eq__(self, other):\n return are_equal(self, other)",
"def __eq__(self,other):\n try: return self.object==other.object and isinstance(self,type(other))\n except: return False",
"def __eq__(self, other):\n if i... | [
"0.8088132",
"0.8088132",
"0.8054589",
"0.7982687",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
... | 0.0 | -1 |
Returns true if both objects are not equal | def __ne__(self, other):
return not self == other | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __ne__(self, other: object) -> bool:\n if self.__eq__(other):\n return False\n return True",
"def __ne__(self, other: object) -> bool:\n return not self.__eq__(other)",
"def __ne__(self, other) -> bool:\n return not self.__eq__(other)",
"def __eq__(self, other):\n ... | [
"0.845611",
"0.8391477",
"0.8144138",
"0.81410587",
"0.8132492",
"0.8093973",
"0.80920255",
"0.80920255",
"0.80920255",
"0.8085325",
"0.8085325",
"0.8076365",
"0.8076365",
"0.8065748"
] | 0.0 | -1 |
Method to view a single shopping list | def get_single_list(current_user, id):
if request.content_type == 'application/json':
try:
int(id)
except ValueError:
return response('failed', 'Please provide a valid ShoppingList Id', 400)
else:
shoplist = ShoppingList.query.filter_by(user_id=current_use... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def shop(request):\n return render(request, 'shop/shop.html')",
"def get(self):\n items = self.request.get_all(\"food\")\n # pases the value in item variable into the jinja2 template\n self.render(\"shopping_list.html\", items=items)",
"def index(request):\n return render(request, 's... | [
"0.7041904",
"0.69466335",
"0.6658593",
"0.65421015",
"0.65386415",
"0.64889246",
"0.6468317",
"0.646398",
"0.64386576",
"0.6436462",
"0.63468236",
"0.63406044",
"0.62979925",
"0.6265284",
"0.6232084",
"0.6206315",
"0.6177075",
"0.61700743",
"0.61650306",
"0.61641103",
"0.616... | 0.59253645 | 45 |
Retrieves user by id | def users_id(user_id):
obj = storage.get(User, user_id)
if obj is None:
abort(404)
return jsonify(obj.to_dict()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_user_by_id(self, id):\n\t\treturn self.users.get(id)",
"def get_user(id):\n pass",
"def get(id):\n return User.query.filter_by(id=id).first()",
"def get(self, id):\n\t\ttry:\n\t\t\tflask_app.logger.debug('We are getting the user: %d', id)\n\t\t\treturn user_service.get(id)\n\t\texcept Asser... | [
"0.8669667",
"0.8583676",
"0.8578365",
"0.8571038",
"0.83665395",
"0.8360695",
"0.8281764",
"0.82566285",
"0.82395405",
"0.8231309",
"0.8211623",
"0.8136258",
"0.81260496",
"0.81073004",
"0.80853456",
"0.8043391",
"0.8005892",
"0.79987067",
"0.797756",
"0.797756",
"0.797756",... | 0.0 | -1 |
Called when the user specifies an intent for this skill | def on_intent(intent_request, session):
print("on_intent requestId=" + intent_request['requestId'] +
", sessionId=" + session['sessionId'])
intent = intent_request['intent']
intent_name = intent_request['intent']['name']
# Dispatch to your skill's intent handlers
if intent_name == "NewM... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def on_intent(intent_request, session):\n\n intent = intent_request['intent']\n intent_name = intent_request['intent']['name']\n\n # Dispatch to your skill's intent handlers\n\n if intent_name not in skillmap:\n intent_name = \"NullSkill\"\n\n if intent_name in skillmap:\n try:\n ... | [
"0.7143966",
"0.6956116",
"0.6949057",
"0.6905333",
"0.68928874",
"0.67641324",
"0.6754843",
"0.6722764",
"0.6720773",
"0.67161995",
"0.6699252",
"0.6691263",
"0.6670276",
"0.6645522",
"0.6642719",
"0.6638686",
"0.6607724",
"0.6594981",
"0.6575682",
"0.6570076",
"0.65620786",... | 0.6509534 | 28 |
given a sklearn confusion matrix (cm), make a nice plot Arguments | def plot_confusion_matrix(cm,
target_names,
title='Confusion matrix',
cmap=None,
normalize=True):
import matplotlib.pyplot as plt
import numpy as np
import itertools
accuracy = np.trace(cm) ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_confusion_matrix(cm, class_names):\n figure = plt.figure(figsize=(10, 10))\n plt.imshow(cm, interpolation='nearest', cmap=plt.cm.Blues)\n plt.title(\"Confusion matrix\")\n plt.colorbar()\n tick_marks = np.arange(len(class_names))\n plt.xticks(tick_marks, class_names, rotation=45)\n plt.yticks(tick_... | [
"0.79997694",
"0.79955804",
"0.7947871",
"0.79360676",
"0.79129595",
"0.7897813",
"0.7879448",
"0.786082",
"0.786082",
"0.78540397",
"0.78501374",
"0.78499055",
"0.78404397",
"0.7835427",
"0.7828328",
"0.78253037",
"0.78049725",
"0.78017557",
"0.77822274",
"0.77789044",
"0.77... | 0.0 | -1 |
Sometimes you get an URL by a user that just isn't a real URL because it contains unsafe characters like ' ' and so on. This function can fix some of the problems in a similar way browsers | def url_fix(s, charset='utf-8'):
if isinstance(s, unicode):
s = s.encode(charset, 'ignore')
scheme, netloc, path, qs, anchor = urlparse.urlsplit(s)
path = urllib.quote(path, '/%')
qs = urllib.quote_plus(qs, ':&=')
return urlparse.urlunsplit((scheme, netloc, path, qs, anchor)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clean_url(url):\r\n s = url\r\n url = url.encode('utf8')\r\n url = ''.join([urllib.quote(c) if ord(c) >= 127 else c for c in url])\r\n return url",
"def sanitize_url(self, url):\r\n if not self.markdown.safeMode:\r\n # Return immediately bipassing parsing.\r\n return ... | [
"0.7528187",
"0.74440855",
"0.7276908",
"0.7201769",
"0.7050244",
"0.702548",
"0.7006525",
"0.6976845",
"0.69176257",
"0.691757",
"0.6873923",
"0.679334",
"0.67786276",
"0.6718079",
"0.6692045",
"0.66769314",
"0.665277",
"0.6649466",
"0.6602803",
"0.656471",
"0.65415454",
"... | 0.6285419 | 35 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.