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 |
|---|---|---|---|---|---|---|
Convert No/Yes to 0/1. | def english_to_binary(english):
# Accepts Yes, Y, yeah, yes sir, etc.
english = english[0].upper()
conversion_dict = {
"N": 0,
"Y": 1}
bit = conversion_dict[english]
return bit | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def yesno(x):\n return \"Yes\" if x else \"No\"",
"def yesno(val):\n if val:\n return 'yes'\n else:\n return 'no'",
"def to_boolean_know(data: bool):\n return 'Yes' if data else 'No'",
"def yesno2bool(value):\n if not isinstance(value, basestring):\n raise Instrume... | [
"0.67184705",
"0.66755366",
"0.66017836",
"0.617354",
"0.61615974",
"0.60380507",
"0.5992757",
"0.5983014",
"0.5912548",
"0.57874084",
"0.57617354",
"0.5754688",
"0.5739412",
"0.57125425",
"0.56879216",
"0.5653845",
"0.56436497",
"0.5569062",
"0.55320245",
"0.55151206",
"0.55... | 0.55284464 | 19 |
It calculates the Value at Risk (VaR) of some time series. It represents the maximum loss with the given confidence level. | def value_at_risk(returns, confidence_level=.05):
# Calculating VaR
return returns.quantile(confidence_level, axis=0, interpolation='higher') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def computeValue(self):\n self.variance = (((self.probability * (100 - self.probability)) / 10000)\n / self.sSize) * ((self.pSize - self.sSize) / (self.pSize - 1))\n self.confidence95 = (1.96 * sqrt(self.variance) * 2) / 2 * 100\n self.confidence99 = (2.58 * sqrt(self.variance) * 2)... | [
"0.64334995",
"0.60175395",
"0.6007088",
"0.5979758",
"0.5979758",
"0.59756696",
"0.5890247",
"0.5751046",
"0.5732126",
"0.57314163",
"0.5655404",
"0.5655404",
"0.56444216",
"0.5623746",
"0.56127524",
"0.5605097",
"0.5597653",
"0.555654",
"0.5500107",
"0.5500107",
"0.54816175... | 0.6976229 | 0 |
Time in ms as a string. | def timestamp():
return str(int(time.time()*1000)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _time_to_string(self, value):\n ms = value / gst.MSECOND\n sec = ms / 1000\n ms = ms % 1000\n min = sec / 60\n sec = sec % 60\n return \"%2dm %2ds %3d\" % (min, sec, ms)",
"def _msToString(self, ms):\n hr, ms = divmod(ms, 3600000)\n mins, ms = divmod(ms... | [
"0.79921466",
"0.78726435",
"0.7471062",
"0.74669486",
"0.73674035",
"0.7364537",
"0.7354643",
"0.73432565",
"0.73232764",
"0.7240258",
"0.7173462",
"0.7156526",
"0.7128444",
"0.70939505",
"0.70792335",
"0.7042628",
"0.7015771",
"0.69898117",
"0.6979718",
"0.69456345",
"0.694... | 0.70135045 | 17 |
Method to find the upper and lower bounds of the shooting angle that will allow the brick to be hit. | def find_shooting_angles(brick_coords, length):
#theta is larger when x is smaller, therefore max theta is
#the angle from the origin to the closest end of the brick,
#with respect to its height
#min theta is the opposite, the angle from origin to the furthest
#end of the brick, with resect to its... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bounds(self):\n return self._bboxes[0][0] #TODO: merge all coverages",
"def angle_bounds (angle, min=0.0, max=360.0):\n while angle < min: angle = angle + 360.0\n while angle > max: angle = angle - 360.0\n return angle",
"def get_bounds(self) -> Tuple[float, float]:\n return (self.__low... | [
"0.6156883",
"0.61045694",
"0.6041437",
"0.60151196",
"0.59985685",
"0.5979841",
"0.5944643",
"0.59291667",
"0.5854284",
"0.58481",
"0.58340085",
"0.57515854",
"0.5746215",
"0.57396394",
"0.5728172",
"0.57222986",
"0.56924266",
"0.56689996",
"0.5606881",
"0.56043553",
"0.5597... | 0.6708758 | 0 |
Create a dataframe with statistics for each grid square. | def compute_grid_stats(self,hgt=300.):
# Group the dataframe by grid square.
gs_grp = self.df.groupby('refl_grid')
# Get a list of the gridsquares in use.
grids = gs_grp.indices.keys()
# Pull out the desired statistics.
dct = {}
dct['counts'] = gs_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def grid_scores( grid_scores_):\n\tp_l = list()\n\tfor s in grid_scores_:\n\t\tp = pd.DataFrame()\n\t\tl = len(s.cv_validation_scores)\n\t\tfor k in list(s.parameters.keys()):\n\t\t\tp[k] = [s.parameters[k]] * l \n\t\tp[\"Unit\"] = range( l)\n\t\tp[\"Score\"] = s.cv_validation_scores\n\t\tp_l.append( p)\n\tp_df... | [
"0.64242315",
"0.62652206",
"0.6241056",
"0.59523046",
"0.59256",
"0.58956575",
"0.58229893",
"0.57883316",
"0.57558167",
"0.5752349",
"0.57522905",
"0.57388777",
"0.5689958",
"0.56535655",
"0.56264573",
"0.56230396",
"0.5608768",
"0.5608768",
"0.5590376",
"0.5584925",
"0.557... | 0.66952294 | 0 |
Return standard color values for gridsquared data. Currently, only foF2 is supported. | def get_grid_data_color(self,key='foF2',encoding='rgba',vals=None):
if vals is None:
vals = self.grid_data[key]
band_data = BandData()
if encoding == 'rgba':
colors = band_data.get_rgba(vals)
elif encoding == 'hex':
colors = band_data.get_hex(v... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getRgbF(self): # real signature unknown; restored from __doc__\n pass",
"def get_cell_color(surface_val):\n \n if surface_val >= 5:\n return \"red\"\n \n if surface_val <= -5:\n return \"blue\"\n \n return \"white\"",
"def colours(self):\r\n dummylist =... | [
"0.5940169",
"0.58697057",
"0.5704972",
"0.5653401",
"0.5599079",
"0.5567608",
"0.5513715",
"0.5488831",
"0.5456243",
"0.5431262",
"0.5423009",
"0.5386802",
"0.5384139",
"0.53801787",
"0.5377494",
"0.53762436",
"0.53195256",
"0.5316937",
"0.5310521",
"0.53002065",
"0.52706456... | 0.48461223 | 92 |
Return standard color values for band values. | def get_band_color(self,vals=None,encoding='rgba'):
if vals is None:
vals = self.df.freq/1000.
band_data = BandData()
if encoding == 'rgba':
colors = band_data.get_rgba(vals)
elif encoding == 'hex':
colors = band_data.get_hex(vals)
ret... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def color(self):\n return tuple(self._to_255(v) for v in self.value)",
"def colorbar2dSpectra():\n return plt.cm.magma",
"def colorscale(self):\n return self['colorscale']",
"def color(self, value=None):\n if value is None:\n value = self.norm_score\n rgb = Score.val... | [
"0.58716565",
"0.5793239",
"0.576455",
"0.5735255",
"0.57211155",
"0.5685909",
"0.56673616",
"0.56390893",
"0.56377536",
"0.5584408",
"0.5575628",
"0.55206573",
"0.55053717",
"0.5498166",
"0.54876125",
"0.5477166",
"0.5475416",
"0.5458804",
"0.54370296",
"0.5412646",
"0.54126... | 0.6235297 | 0 |
Returns the string representation of the model | def to_str(self):
import simplejson as json
if six.PY2:
import sys
reload(sys)
sys.setdefaultencoding("utf-8")
return json.dumps(sanitize_for_serialization(self), ensure_ascii=False) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _repr_model_(self):\n return str(self)",
"def __str__(self):\n\n return str(self.model)",
"def get_model_string(self):\n raise NotImplementedError()",
"def __str__(self):\n return self.model",
"def serialize_model(self):\n return dill.dumps(self.model)",
"def __str_... | [
"0.8603192",
"0.8509214",
"0.82360506",
"0.8049831",
"0.80115575",
"0.79342973",
"0.78785366",
"0.77903765",
"0.77898926",
"0.7746775",
"0.7629959",
"0.7608436",
"0.75825727",
"0.75152564",
"0.7506636",
"0.7504804",
"0.74877965",
"0.7443503",
"0.7435226",
"0.7427192",
"0.7407... | 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 return not self == other",
"def __ne__(self, other: object) -> bool:\n return not self.__eq__(other)",
"def __ne__(self, other):\n return self.__dict__ != other.__dict__",
"def __eq__(self, other):\n return not self.__ne__(other)",
... | [
"0.8410411",
"0.8391477",
"0.8172175",
"0.81410587",
"0.80920255",
"0.8088807",
"0.80676955"
] | 0.0 | -1 |
Update value with new value from slider. This value will never be out of range due to set slider range. | def __check_stim_intens_val(self):
self.logger.debug("running")
new_val_percent = self.tab.get_stim_intens_val()
self.tab.set_stim_intens_val_label(new_val_percent)
self.__changed[1] = self.__calc_percent_to_val(new_val_percent) != self.__current_vals[1]
self.logger.debug("done") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setValue(self, value):\n self.exact_value = value\n # If a new min/max is necessary: Set it to twice the value, to give user leeway\n if value > self._max_value:\n # If the slider range is fixed: Set it to the maximum possible value\n if self.fixed_range:\n ... | [
"0.7625717",
"0.69760025",
"0.6803619",
"0.6757738",
"0.6632314",
"0.66177404",
"0.65653485",
"0.6557665",
"0.65525424",
"0.65496176",
"0.65191567",
"0.65044314",
"0.648212",
"0.6472641",
"0.64312077",
"0.64312077",
"0.6402463",
"0.64013153",
"0.638949",
"0.63777196",
"0.6377... | 0.0 | -1 |
This function just plot history of training model | def display_history(hist):
plt.plot(hist.history['acc'])
plt.plot(hist.history['val_acc'])
plt.title('Model accuracy')
plt.ylabel('Accuracy')
plt.xlabel('Epoch')
plt.legend(['Train', 'Validation'], loc='upper left')
plt.show() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_history(H, epochs):\n plt.style.use(\"fivethirtyeight\")\n plt.figure()\n plt.plot(np.arange(0, epochs), H.history[\"loss\"], label=\"train_loss\")\n plt.plot(np.arange(0, epochs), H.history[\"val_loss\"], label=\"val_loss\")\n plt.plot(np.arange(0, epochs), H.history[\"accuracy\"], label=\... | [
"0.78547424",
"0.78414994",
"0.7790387",
"0.77741784",
"0.7768888",
"0.76783967",
"0.7673559",
"0.76442236",
"0.7634507",
"0.7617992",
"0.760034",
"0.7584517",
"0.75547516",
"0.74747074",
"0.745826",
"0.74542725",
"0.7453964",
"0.743652",
"0.74361193",
"0.7421046",
"0.7385239... | 0.7482103 | 13 |
Encodes a tree to a single string. | def serialize(self, root):
current_row = 0
serialized = []
q = SimpleQueue()
q.put((root, current_row))
while not q.empty():
node, row = q.get()
if current_row != row:
serialized.append(None)
current_row = row
s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def encodeTree(self, tree, key):\n return self.encode(pickle.dumps(tree), key)",
"def serialize(self, root):\n if not root:\n return \"n\"\n s = \"\"\n stack = [root]\n while (stack):\n root = stack.pop(0)\n if root:\n s += str(ro... | [
"0.78278124",
"0.7515946",
"0.71304095",
"0.7053364",
"0.7031874",
"0.6999469",
"0.6999095",
"0.69672054",
"0.69332165",
"0.68838483",
"0.68657243",
"0.68548083",
"0.6809354",
"0.6801677",
"0.67984694",
"0.6773517",
"0.6766546",
"0.6754318",
"0.67507386",
"0.6745785",
"0.6664... | 0.0 | -1 |
Get the current estimated value for the stateaction pair. | def get_q_value(self, state, action):
self.initialize_unknown_state(state)
return self.q_values[state][action] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getValue(self, state):\n\n \"\"\" YOUR CODE HERE \"\"\"\n # initialize best value to 0.0\n best_value = 0.0\n # loop though all possible actions\n for action in self.getLegalActions(state):\n # check if new value is better than previous best\n if best_value < self.getQValue(state, acti... | [
"0.7089748",
"0.6996114",
"0.6971882",
"0.695338",
"0.6940844",
"0.68734974",
"0.68557376",
"0.6816503",
"0.681358",
"0.67922723",
"0.67895526",
"0.6784132",
"0.6784132",
"0.6784132",
"0.6784132",
"0.6784132",
"0.6784132",
"0.6784132",
"0.6784132",
"0.6784132",
"0.6784132",
... | 0.62561405 | 99 |
Randomly determine the number of rooms based on the size | def get_number_of_rooms(self, dungeon_n_rows: int, dungeon_n_cols: int) -> int:
dungeon_area = dungeon_n_rows * dungeon_n_cols
max_room_area = self.room_size_randomizer.max_size ** 2
return min(self.max_num_rooms, dungeon_area // max_room_area) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def randomize_room_size(self, room: Room, *args) -> None:\n pass # pragma: no cover",
"def randomize_room_size(self, room: Room) -> None:\n # Draw the dimensions\n height = random.randint(self.min_size, self.max_size)\n width = random.randint(self.min_size, self.max_size)\n\n ... | [
"0.7803684",
"0.7440508",
"0.7053568",
"0.6821984",
"0.659439",
"0.65464526",
"0.6497607",
"0.6451232",
"0.6447222",
"0.6445402",
"0.6289136",
"0.6230462",
"0.6155319",
"0.61270964",
"0.61241984",
"0.61023194",
"0.60973626",
"0.5985288",
"0.5972363",
"0.5971755",
"0.5953886",... | 0.673287 | 4 |
Registers a user into the system. The registration does not save the actual password but the hashed password of the user for security purposes. | def register_user(self, username, password, full_name):
hashed_password = sha256_crypt.hash(password)
user = self.backend.create_user(username, hashed_password, full_name)
return user | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def db_register_user(form):\n hashed_password = bcrypt.generate_password_hash(form.password.data).decode('utf-8')\n user = User(username=form.username.data, email=form.email.data, password=hashed_password)\n db.session.add(user)\n db.session.commit()\n return True",
"def register_user(self):\n ... | [
"0.7993656",
"0.77687794",
"0.7739607",
"0.76938957",
"0.7687231",
"0.75414467",
"0.7479957",
"0.74667186",
"0.7451251",
"0.7443235",
"0.7440299",
"0.7426349",
"0.74255925",
"0.741323",
"0.7412865",
"0.7402243",
"0.7371936",
"0.73646224",
"0.7313194",
"0.7294225",
"0.7262528"... | 0.75103414 | 6 |
Initialize a new network. | def __init__(self, input_dim=(1, 24, 24),num_classes=2, weight_scale=1e-2, reg=0.0005,
dtype=np.float32, convLayer=16, h5_file=None):
C, H, W = input_dim
#assert H == W
num_filters = [1, 8, 8, 10, 10, 12, 12, 13,13,12, 12, 10, 10, 8, 8, 8, 2]
#num_filters = [1, 1, 1... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_network(self):\n #Create the network\n self.network = Network(\"50.19.23.117\", 8080)",
"def __init__(self, amount_nodes, amount_links):\n self.nodes = {}\n self.__createNetwork__(amount_nodes, amount_links)",
"def init_network(name=NETWORK_NAME, nodes=[\"Alice\",\"Bob\",... | [
"0.8108218",
"0.76692665",
"0.7656324",
"0.76131594",
"0.7444921",
"0.74334115",
"0.7371696",
"0.72837204",
"0.70510834",
"0.7018292",
"0.69512916",
"0.69427025",
"0.6935787",
"0.69219816",
"0.6816404",
"0.6807591",
"0.67830807",
"0.6775899",
"0.67708445",
"0.6768226",
"0.676... | 0.0 | -1 |
Isotropic squared exponential kernel. | def kernel(self,X1, X2, l=1.0, sigma_f=1.0):
sqdist = np.sum(X1 ** 2, 1).reshape(-1, 1) + np.sum(X2 ** 2, 1) - 2 * np.dot(X1, X2.T)
return sigma_f ** 2 * np.exp(-0.5 / l ** 2 * sqdist) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def exponential(x):\n return K.exp(x)",
"def SquareExponential(length_scale):\n\n # only works with python >= 3.6\n # @cpptype(neg_half_inv_l2=np.float32)\n @cpptype([('neg_half_inv_l2', np.float32)])\n class SquareExponentialKernel(Kernel):\n def __init__(self, length_scale):\n ... | [
"0.6700143",
"0.6523642",
"0.6467007",
"0.6382024",
"0.6358466",
"0.6215781",
"0.61409926",
"0.6067087",
"0.6055005",
"0.6048553",
"0.6044241",
"0.59798795",
"0.5974117",
"0.59577143",
"0.5955695",
"0.5940959",
"0.5924524",
"0.59039325",
"0.58986855",
"0.5874644",
"0.5861318"... | 0.0 | -1 |
Return the BeetIdType for an Id value. | def get_type(value):
value_parts = value.split(':')
if len(value_parts) <= 1:
raise ValueError('Invalid Id: {}'.format(value))
id_type = BeetIdType(value_parts[0])
if id_type is BeetIdType.album or id_type is BeetIdType.item:
id_value = int(value_parts[1])
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_id(self, id_):\n return # osid.id.Id",
"def kut_id(self, id=None):\n try:\n int(id)\n except TypeError as e:\n id = self.autodetect_id()\n return id",
"def id(self):\n return self._get_val_int(_BP_ID)",
"def get_id(self):\n return id",
... | [
"0.6504235",
"0.6281657",
"0.6169472",
"0.6100692",
"0.6064284",
"0.60292774",
"0.6007744",
"0.6007744",
"0.59997785",
"0.59997785",
"0.59938055",
"0.59342915",
"0.5900162",
"0.5900162",
"0.5900162",
"0.5900162",
"0.5900162",
"0.58967584",
"0.5863076",
"0.586192",
"0.580985",... | 0.6464563 | 1 |
Return the Subsonic id for a playlist. | def get_playlist_id(playlist_name):
return BeetIdType.playlist.value + ':' + playlist_name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def playlistid(self) -> str:\n return self._playlistid",
"def id(self):\n return self.token[\"playlist_id\"]",
"def get_playlist_id(self, request, view, obj):\n return obj.playlist_id",
"def get_playlist_id(self, request, view, obj):\n # Note, use select_related to avoid making ex... | [
"0.8286737",
"0.81413424",
"0.7799568",
"0.7623245",
"0.7564769",
"0.7372411",
"0.7178732",
"0.7032431",
"0.69686097",
"0.6942343",
"0.6736018",
"0.6722534",
"0.6636103",
"0.65429634",
"0.6368848",
"0.63022256",
"0.6296692",
"0.6206773",
"0.62019825",
"0.61677945",
"0.6108427... | 0.7637657 | 3 |
Find the setting for the preference | def find_setting(self):
raise NotImplementedError | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_setting(self):\n return self._sqt.boolSetting(AM.AsterModule.name, self.key)",
"def get(self, pref_type):\n pref = pref_type(self._sqt)\n return pref.find_setting()",
"def find_by_pref(self,pref):\n return self.root.find_by_pref(pref)",
"def _get_preference(self):\n re... | [
"0.7492986",
"0.7390842",
"0.7146544",
"0.712464",
"0.712464",
"0.712464",
"0.712464",
"0.712464",
"0.712464",
"0.712464",
"0.712464",
"0.712464",
"0.712464",
"0.712464",
"0.712464",
"0.712464",
"0.712464",
"0.712464",
"0.712464",
"0.712464",
"0.712464",
"0.712464",
"0.71... | 0.7901866 | 0 |
Find the bool setting for the preference | def find_setting(self):
return self._sqt.boolSetting(AM.AsterModule.name, self.key) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_bool(self, key):\n self._assert_key(key)\n true_vals = ['true', '1', 'yes', 'on']\n false_vals = ['false', '0', 'no', 'off']\n if self._config_dict[key].lower() in true_vals:\n return True\n elif self._config_dict[key].lower() in false_vals:\n retur... | [
"0.6950668",
"0.6776331",
"0.6630249",
"0.65871185",
"0.6576751",
"0.6516534",
"0.6516534",
"0.6516534",
"0.6516534",
"0.6516534",
"0.6516534",
"0.6516534",
"0.6516534",
"0.6516534",
"0.6516534",
"0.6516534",
"0.6516534",
"0.6516534",
"0.6516534",
"0.6516534",
"0.6516534",
... | 0.7874931 | 0 |
Return the preference setting from its type | def get(self, pref_type):
pref = pref_type(self._sqt)
return pref.find_setting() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_preference(self):\n return self.__preference",
"def _get_preference(self):\n return self.__preference",
"def _get_preference(self):\n return self.__preference",
"def _get_preference(self):\n return self.__preference",
"def _get_preference(self):\n return self.__preference",
"def _... | [
"0.6832504",
"0.6832504",
"0.6832504",
"0.6832504",
"0.6832504",
"0.6832504",
"0.6832504",
"0.6832504",
"0.6832504",
"0.6832504",
"0.6832504",
"0.6832504",
"0.6832504",
"0.6832504",
"0.6832504",
"0.6832504",
"0.6832504",
"0.6832504",
"0.6832504",
"0.6832504",
"0.6832504",
"... | 0.8205916 | 0 |
Calculate edit distance from a to b | def distances(a, b):
# Create empty matrix size of [len(a) + 1 rows][len(b) + 1 columns]
# len(b) columns len(a) rows
# [y][x]
matrix = [[[None for i in range(2)] for x in range(len(b) + 1)] for y in range(len(a) + 1)]
# Initialize top row of ma... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def distance(self):\n return self.ab - self.bb",
"def distance(a, b):\n\treturn (a[0]-b[0])**2 + (a[1]-b[1])**2",
"def distance(a, b):\n\n return math.sqrt(\n (a.x - b.x) ** 2\n + (a.y - b.y) ** 2\n + (a.z - b.z) ** 2\n )",
"def get_distance(a, b):\n\n ... | [
"0.7267784",
"0.71487314",
"0.7142",
"0.70746887",
"0.7031406",
"0.6999146",
"0.697724",
"0.6968724",
"0.69525594",
"0.6925486",
"0.68885666",
"0.68802375",
"0.6877058",
"0.6840532",
"0.679354",
"0.67535484",
"0.6749982",
"0.6701306",
"0.6682034",
"0.66746384",
"0.66687447",
... | 0.6373393 | 55 |
Attempts to retrieve a particular record by sending a GET request to the appropriate endpoint. If successful, the resource object is populated with the data in the response. | def get(self, resource_id=None):
if "GET" not in self.resource.SUPPORTED_METHODS:
raise MethodNotSupportedException("GET method on this resource is not supported")
if resource_id is not None:
response = self.client.get(self.join_path(str(resource_id)))
else:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def retrieve(self, request, pk=None):\n return Response({'http_method': 'GET'})",
"def retrieve(self, request, pk=None):\n return Response({'http_method': 'GET'})",
"def retrieve(self, request, pk=None):\n\n return Response({'http_method': 'GET'})",
"def retrieve(self, request, pk=None):... | [
"0.6851666",
"0.6851666",
"0.683207",
"0.68033206",
"0.6763327",
"0.6720137",
"0.6702408",
"0.6671056",
"0.6631473",
"0.6626023",
"0.66047406",
"0.6582993",
"0.6553487",
"0.65327215",
"0.652562",
"0.6518698",
"0.6517799",
"0.6496802",
"0.64927995",
"0.64927995",
"0.64836454",... | 0.67865384 | 4 |
Attempts to create a new instance of a resource by sending a POST request to the appropriate endpoint. | def create(self, **params):
if "POST" not in self.resource.SUPPORTED_METHODS:
raise MethodNotSupportedException("POST method on this resource is not supported")
if self.resource.id:
raise ObjectAlreadyCreatedException("ID must be None when calling create")
response = se... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def post(self):\n resource = self.__model__.query.filter_by(**request.json).first()\n # resource already exists; don't create it again\n if resource:\n return self._no_content_response()\n instance = self.__model__( # pylint: disable=not-callable\n **request.json)... | [
"0.8020011",
"0.76005673",
"0.73994786",
"0.7189662",
"0.7178764",
"0.71042454",
"0.7005955",
"0.6838932",
"0.6814612",
"0.678172",
"0.6772597",
"0.6772597",
"0.676899",
"0.6752373",
"0.67070127",
"0.66723526",
"0.6654634",
"0.66031903",
"0.6594552",
"0.65778387",
"0.6577247"... | 0.751107 | 2 |
Initialize the Resource by populating attributes based on fields and setting a manager. | def __init__(self, client=None, api_key=None):
self.manager = ResourceManager(self, client=client, api_key=api_key)
for field in self.fields:
setattr(self, field.name, field) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init(self, resource):\n pass",
"def __init__(self, container):\n super(Resource, self).__init__(container)\n # All Creation supporting Resources must update the\n # 'required_creation_parameters' set with the appropriate values.\n self._meta_data['required_creation_paramete... | [
"0.72066534",
"0.7028658",
"0.6770069",
"0.6606507",
"0.65602916",
"0.65219146",
"0.6443649",
"0.6301676",
"0.6301495",
"0.6283402",
"0.6269315",
"0.62674236",
"0.6249764",
"0.621787",
"0.62157536",
"0.61839765",
"0.61690426",
"0.61452603",
"0.6130829",
"0.6115567",
"0.610579... | 0.7661483 | 0 |
Initialize the Job resource with a set of predefined fields. | def __init__(self, client=None, api_key=None):
self.fields = (
Field("id", str),
Field("type", str),
Field("status", str),
Field("request", dateutil.parser.parse),
Field("response", dateutil.parser.parse),
Field("data"),
)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(__self__,\n resource_name: str,\n args: ImportJobArgs,\n opts: Optional[pulumi.ResourceOptions] = None):\n ...",
"def __init__(self):\n\n super(Job, self).__init__()\n\n # Base job traits\n self.type = \"\"\n self.nam... | [
"0.6999006",
"0.69336545",
"0.68961203",
"0.68870026",
"0.682934",
"0.6686358",
"0.6651693",
"0.66237634",
"0.6617607",
"0.6593644",
"0.6592776",
"0.6572872",
"0.6517269",
"0.6509775",
"0.6486559",
"0.6480568",
"0.64653105",
"0.6454992",
"0.6439476",
"0.63661134",
"0.6329133"... | 0.0 | -1 |
Initialize the JobCircuit resource with a predefined field. | def __init__(self, job_id, client=None):
self.id = job_id
self.fields = (Field("circuit"),)
super().__init__(client=client) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(__self__,\n resource_name: str,\n args: ExpressRouteCircuitArgs,\n opts: Optional[pulumi.ResourceOptions] = None):\n ...",
"def __init__(self, client, project_id):\n super(Job, self).__init__(client, project_id)\n self.__client = c... | [
"0.64277226",
"0.6036242",
"0.6034006",
"0.5984377",
"0.59729403",
"0.59454817",
"0.592324",
"0.5896039",
"0.58939385",
"0.5893644",
"0.58723",
"0.5866559",
"0.58474207",
"0.5841645",
"0.58343303",
"0.58270127",
"0.5807759",
"0.5794851",
"0.5794638",
"0.57910556",
"0.5771901"... | 0.74896175 | 0 |
Returns the function g(t)=f(t+dt) | def parameterShift(f,dt):
if hasattr(f,"_func") and hasattr(f,"_dt"):
g = f.copy()
g.dt += dt
return f
def shifted(t):
return _func(t+_dt)
g = shifted
g._func = func;
g._dt = dt
return g | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def timeDerivative(f):\n nt,n = len(f[0]),len(f)\n #odt = 0.5/dt\n odt = 0.5\n g = like(f)\n for i in range(n):\n for it in range(1,nt-1):\n g[i][it] = odt*(f[i][it+1]-f[i][it-1])\n return g",
"def timeDerivative(f):\n n = len(f)\n #odt = 0.5/dt\n odt = 0.5\n g = like(f)\n for i in range(n):\n... | [
"0.7030875",
"0.69970495",
"0.67794275",
"0.67182916",
"0.6695145",
"0.65744585",
"0.6539189",
"0.64649403",
"0.6410594",
"0.6357305",
"0.6357305",
"0.63129294",
"0.6287542",
"0.62527543",
"0.6239713",
"0.6235208",
"0.6230749",
"0.62264967",
"0.61768997",
"0.6152931",
"0.6152... | 0.576646 | 47 |
Removes the element from in front of queue and returns that element. | def pop(self) -> int:
while not self.stack1.empty():
n = self.stack1.pop()
self.stack2.push(n)
popped = self.stack2.pop()
self.front = self.stack2.peek()
return popped | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def front(self):\n if self.is_empty():\n return None\n return self.queue[0]",
"def getfront(self):\n\t\tif self._queue!=[]:\n\t\t\treturn self._queue[0]\n\t\treturn",
"def dequeue(self):\n item = self._queue[0]\n self._queue = self._queue[1:]\n return item",
"def... | [
"0.7973763",
"0.7762207",
"0.77227783",
"0.77152604",
"0.7686406",
"0.76430964",
"0.76407087",
"0.76401305",
"0.76368254",
"0.759925",
"0.75936073",
"0.75864357",
"0.7579586",
"0.7558885",
"0.7552301",
"0.75520134",
"0.75511974",
"0.7528356",
"0.7522579",
"0.75202733",
"0.747... | 0.0 | -1 |
Returns whether the queue is empty. | def empty(self) -> bool:
return self.stack1.empty() and self.stack2.empty() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def IsEmpty(self):\r\n return len(self._queue) == 0",
"def is_empty(self):\n return len(self._queue) == 0",
"def is_empty(self):\n if self.queue:\n return False\n return True",
"def is_empty(self):\n\n return not self._queue",
"def empty(self):\n return len(... | [
"0.9247943",
"0.9223501",
"0.91059995",
"0.9097763",
"0.90676236",
"0.9052901",
"0.9052901",
"0.9025616",
"0.8983479",
"0.8916883",
"0.8911219",
"0.88953906",
"0.8876906",
"0.8842985",
"0.8736577",
"0.8679227",
"0.85199124",
"0.8469787",
"0.8326174",
"0.8311001",
"0.8311001",... | 0.0 | -1 |
Check that the comment entry is present and is a string. | def _check_comment(self, comment=None):
if comment is None:
try:
comment = self.entries['comment']
except KeyError:
self._logger.error(f"{self.ERROR_MESSAGES[self.ERROR_NO_KEY]} The key in question is 'comment'.")
sys.exit(self.ERROR_NO_KEY... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _validate_string(datum, **kwargs):\n return isinstance(datum, str)",
"def is_string(type_arg):\n tpye_arg = type_arg.strip()\n return type_arg == \"char *\" or type_arg == \"const char *\"",
"def is_comment(string):\n chars = list(string)\n\n if len(chars) <= 0:\n return True\n\n i... | [
"0.63137716",
"0.6261596",
"0.62109315",
"0.61747354",
"0.61512774",
"0.6107495",
"0.61064756",
"0.61017275",
"0.6100358",
"0.59867644",
"0.5973914",
"0.59113747",
"0.58983463",
"0.58851945",
"0.5877521",
"0.5854321",
"0.58308345",
"0.5823875",
"0.5799257",
"0.5796156",
"0.57... | 0.7785674 | 0 |
Check that the shifts are either None or a list of three floats. | def _check_shifts(self, shifts=None):
if shifts is None:
try:
shifts = self.entries['shifts']
except KeyError:
self._logger.error(f"{self.ERROR_MESSAGES[self.ERROR_NO_KEY]} The key in question is 'shifts'.")
sys.exit(self.ERROR_NO_KEY)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _check_values(array_or_list: Union[Sequence, np.ndarray], value: Any):\n if value == np.nan:\n assert np.isnan(array_or_list).any() == False, \\\n f\"{array_or_list} should not contain NaN values.\"\n if value is None:\n if type(array_or_list) is list:\n assert np.c... | [
"0.5595113",
"0.558428",
"0.55009675",
"0.53634596",
"0.53626585",
"0.5309797",
"0.5309209",
"0.5280082",
"0.52670914",
"0.52668834",
"0.52639127",
"0.52636176",
"0.5262608",
"0.52625024",
"0.52608865",
"0.52561146",
"0.5252391",
"0.52517986",
"0.52495676",
"0.52495676",
"0.5... | 0.7494933 | 0 |
Check that the divisions are either None or a list of three integers. | def _check_divisions(self, divisions=None):
if divisions is None:
try:
divisions = self.entries['divisions']
except KeyError:
self._logger.error(f"{self.ERROR_MESSAGES[self.ERROR_NO_KEY]} The key in question is 'divisions'.")
sys.exit(self... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def testListDivide():\n\n if listDivide ([1,2,3,4,5]) != 2:\n raise ListDivideException\n elif listDivide ([2,4,6,8,10]) !=5:\n raise ListDivideException\n elif listDivide ([30,54,63,98,100], 10) != 2:\n raise ListDivideException\n elif listDivide ([]) != 0:\n raise ListDivi... | [
"0.60247517",
"0.5909065",
"0.58484024",
"0.5600269",
"0.5548893",
"0.55469036",
"0.5529639",
"0.55221766",
"0.5467473",
"0.5463199",
"0.5451629",
"0.54166543",
"0.5408058",
"0.5349856",
"0.5336759",
"0.53303677",
"0.53176904",
"0.5306571",
"0.5277484",
"0.5273955",
"0.526505... | 0.6846418 | 0 |
Check that the generating_vectors are either None or a list of three lists of three floats. | def _check_generating_vectors(self, generating_vectors=None):
if generating_vectors is None:
try:
generating_vectors = self.entries['generating_vectors']
except KeyError:
self._logger.error(
f"{self.ERROR_MESSAGES[self.ERROR_NO_KEY]} T... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_valid_vectors(self):\n # check source, source radius is fixed unlike detector\n self.assertGreater(self.traj.r_src, 0)\n self.assertGreater(self.traj.r_det, 0)",
"def _check_values(array_or_list: Union[Sequence, np.ndarray], value: Any):\n if value == np.nan:\n assert np.i... | [
"0.6380167",
"0.6051248",
"0.5945037",
"0.5918045",
"0.586222",
"0.5777208",
"0.5773941",
"0.56908137",
"0.5645381",
"0.56357926",
"0.56017107",
"0.55624956",
"0.5556589",
"0.55490595",
"0.5544609",
"0.55267084",
"0.5526624",
"0.55243796",
"0.551554",
"0.5511387",
"0.5493733"... | 0.76029193 | 0 |
Check that the mode flag is valid. | def _check_mode(self, mode=None):
if mode is None:
try:
mode = self.entries['mode']
except KeyError:
self._logger.error(f"{self.ERROR_MESSAGES[self.ERROR_NO_KEY]} The key in question is 'mode'.")
sys.exit(self.ERROR_NO_KEY)
if mode... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _check_mode(mode: str) -> None:\n if not isinstance(mode, str):\n raise TypeError(\"The {0} should be a string. Given: {1!r}\".format(\"mode\", mode))\n\n if mode not in [MODE_RTU, MODE_ASCII]:\n raise ValueError(\n \"Unreconized Modbus mode given. Must \"\n + \"be 'rt... | [
"0.7385545",
"0.6982692",
"0.6719958",
"0.6688089",
"0.6589582",
"0.6504449",
"0.62950045",
"0.62589896",
"0.6251227",
"0.62406397",
"0.6236149",
"0.61590874",
"0.6126104",
"0.6120348",
"0.61043495",
"0.6077016",
"0.59481996",
"0.59481263",
"0.5941681",
"0.59394294",
"0.59348... | 0.7820467 | 0 |
Populate the security provider data structures for the given provider type. | def __build_security_provider_data_structures(name_map, base_path):
for key, value in name_map.iteritems():
SECURITY_PROVIDER_FOLDER_PATHS.append(base_path + '/' + key)
SECURITY_PROVIDER_NAME_MAP[key] = value
mbean_name = value + 'MBean'
SECURITY_PROVIDER_MBEAN_NAME_MAP[mbean_name] =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def provider_type(self, provider_type):\n\n self._provider_type = provider_type",
"def _process_provider(cls, name, items):\n assert 'authentication_type' in items, \"Must have authentication_type specified\"\n\n auth_type = items.pop('authentication_type')\n if auth_type not in AUTHE... | [
"0.6736275",
"0.6277513",
"0.58306414",
"0.5748683",
"0.5669287",
"0.5592937",
"0.55892056",
"0.55847746",
"0.55478907",
"0.5520363",
"0.5468963",
"0.5441536",
"0.54397887",
"0.5419137",
"0.5414788",
"0.5386161",
"0.5383005",
"0.5370912",
"0.53154314",
"0.5303359",
"0.5259622... | 0.5624741 | 5 |
Return a dictionary of the current errors. | def get_errors(loss_p):
error_dict = {'Loss_p': loss_p.item()}
return error_dict | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def errors(self):\n errors = {}\n for c in self._collections:\n for _, results in c.results.iteritems():\n for r in results:\n dev_name = r.device_name()\n if r.status == punc.model.Result.STATUS_ERROR:\n if dev_na... | [
"0.7989455",
"0.79715574",
"0.79219055",
"0.7908355",
"0.78783816",
"0.78783816",
"0.78783816",
"0.782874",
"0.7688629",
"0.7652685",
"0.7652685",
"0.7652685",
"0.76029444",
"0.7564687",
"0.7539288",
"0.7518473",
"0.74675715",
"0.74339646",
"0.7341608",
"0.73324984",
"0.73200... | 0.65086895 | 53 |
Class decorator which enforces that if any subclasses define on of the ``methods``, they must call ``super().()`` or face a ``ValueError`` at runtime. This is unlikely to be useful for concrete test classes, who are not normally subclassed. It should not be used on userfacing code, because it prevents subclasses from b... | def enforce_subclasses_call(
methods: Union[str, Iterable[str]], attr: str = "_enforce_subclasses_call_cache"
) -> Callable[[Type], Type]:
methods = {methods} if isinstance(methods, str) else set(methods)
def initialize_call_memory(self, *_args, **_kwargs):
"""Add the extra attribute used for trac... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wrap_subclass_methods(cls):\n # Only wrap methods who are directly defined in this class; if we're resolving to a method\n # higher up the food chain, then it will already have been wrapped.\n for name in set(cls.__dict__) & methods:\n wrap_method(\n cls,\n ... | [
"0.6863658",
"0.57728535",
"0.57414",
"0.5640234",
"0.5514708",
"0.5503635",
"0.547513",
"0.546478",
"0.5447656",
"0.5441686",
"0.54297745",
"0.53889817",
"0.5336711",
"0.52583593",
"0.52250093",
"0.51972747",
"0.51653004",
"0.51477194",
"0.51343274",
"0.5132549",
"0.5098243"... | 0.7541083 | 0 |
Exponential distribution. lambd is 1.0 divided by the desired mean. It should be nonzero. (The parameter would be called "lambda", but that is a reserved word in Python.) Returned values range from 0 to positive infinity if lambd is positive, and from negative infinity to 0 if lambd is negative. | def expovariate(self, lambd):
return -log(1.0 - self.random())/lambd | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def e(self, x):\n return self._lambda * math.exp(-x * self._lambda)",
"def signed_expovariate(self, mean, lambd):\n x = self.expovariate(lambd)\n if self.random() < 0.5:\n x = -x\n return mean + x",
"def expon_integral(lambd, xmin, xmax):\r\n return np.exp(-xmin / lamb... | [
"0.6795311",
"0.67468673",
"0.6715401",
"0.6478202",
"0.6432352",
"0.6173274",
"0.6147952",
"0.61355215",
"0.607657",
"0.60473555",
"0.60173106",
"0.6017124",
"0.60159326",
"0.58841485",
"0.5879595",
"0.587397",
"0.58730173",
"0.5850056",
"0.58371687",
"0.58351517",
"0.582825... | 0.71128386 | 0 |
Tests behavioral_index() with normal data. | def test_behavioral_index_01(self):
arr = np.array([0, 0, 0, 0, 1, 1, 1, 1, 0, 1])
self.assertEqual(
behaviors.behavioral_index(arr),
5./10
)
self.assertEqual(
behaviors.behavioral_index(arr, method='condensed'),
5./6
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_index(self):\n pass",
"def test_scalar_index_boundary(self):\n self.assertEqual(self.hist[4], 4)\n self.assertEqual(self.hist[5], 5)",
"def test_11_article_model_index(self):\n a = models.Article(**ArticleFixtureFactory.make_article_source())\n assert a.data.get('ind... | [
"0.663258",
"0.6152901",
"0.60900307",
"0.59382427",
"0.5914805",
"0.5820738",
"0.57917076",
"0.576334",
"0.5754767",
"0.5748302",
"0.57108325",
"0.5698431",
"0.56946665",
"0.5694476",
"0.5689401",
"0.5670341",
"0.56393945",
"0.56301004",
"0.55580825",
"0.55478615",
"0.553633... | 0.7362514 | 0 |
Tests bout_boundaries() with singleframe bout. | def test_bout_boundaries_02(self):
arr = np.array([0, 0, 0, 1, 0, 0, 0])
np.testing.assert_array_equal(
behaviors.bout_boundaries(arr),
[[3, 4]]
)
arr2 = np.zeros(arr.size)
b_ixs = behaviors.bout_boundaries(arr)
arr2[b_ixs[0,0]:b_ixs[0,1]... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_bout_boundaries_01(self):\r\n arr = np.array([0, 0, 1, 1, 1, 1, 1, 0, 0, 0])\r\n np.testing.assert_array_equal(\r\n behaviors.bout_boundaries(arr),\r\n [[2, 7]]\r\n )\r\n\r\n arr = np.array([0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1])\r\n np.testing.assert_ar... | [
"0.79882634",
"0.6803076",
"0.63209",
"0.59323573",
"0.58028907",
"0.5674993",
"0.5542458",
"0.55355453",
"0.55290365",
"0.55168974",
"0.5511505",
"0.5412666",
"0.53988254",
"0.53806037",
"0.53708315",
"0.5355019",
"0.5341264",
"0.5339321",
"0.5325786",
"0.52749133",
"0.52636... | 0.75675464 | 1 |
Tests bout_boundaries_ts() with normal data. | def test_bout_boundaries_ts_01(self):
male = fly.Fly(10)
male.add_behavior_from_array(
'behavior_01',
np.array([0, 0, 1, 0, 0, 0, 0, 0, 0, 0])
)
female = fly.Fly()
tracking_sum = ts.FixedCourtshipTrackingSummary()
tracking_sum.male = male
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_bout_boundaries_01(self):\r\n arr = np.array([0, 0, 1, 1, 1, 1, 1, 0, 0, 0])\r\n np.testing.assert_array_equal(\r\n behaviors.bout_boundaries(arr),\r\n [[2, 7]]\r\n )\r\n\r\n arr = np.array([0, 0, 1, 1, 1, 1, 0, 0, 1, 1, 1])\r\n np.testing.assert_ar... | [
"0.6986383",
"0.65901315",
"0.55006224",
"0.5358072",
"0.5349199",
"0.5274781",
"0.5263281",
"0.52492714",
"0.5218602",
"0.5217171",
"0.51862055",
"0.51773065",
"0.515827",
"0.515004",
"0.5148459",
"0.51327056",
"0.5114156",
"0.51095",
"0.5100464",
"0.50826985",
"0.50811106",... | 0.72938055 | 0 |
Create a TAXIIMessage object from a dictonary. This function automatically detects which type of Message should be created based on the 'message_type' key in the dictionary. | def get_message_from_dict(d):
if 'message_type' not in d:
raise ValueError('message_type is a required field!')
message_type = d['message_type']
if message_type == MSG_DISCOVERY_REQUEST:
return DiscoveryRequest.from_dict(d)
if message_type == MSG_DISCOVERY_RESPONSE:
return Disco... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def from_dict(cls, _dict: Dict) -> 'MessageInput':\n args = {}\n if 'message_type' in _dict:\n args['message_type'] = _dict.get('message_type')\n if 'text' in _dict:\n args['text'] = _dict.get('text')\n if 'intents' in _dict:\n args['intents'] = [\n ... | [
"0.7015202",
"0.6858665",
"0.6827568",
"0.6782269",
"0.67328393",
"0.6582629",
"0.6565894",
"0.6510298",
"0.6486146",
"0.64732444",
"0.6436994",
"0.6294055",
"0.616334",
"0.61593485",
"0.61533815",
"0.6152799",
"0.612045",
"0.61170906",
"0.6106903",
"0.6039591",
"0.5986819",
... | 0.6797599 | 3 |
Saves a user in the database | def save(cls, query, data):
cls.cursor.execute(query, data)
cls.con.commit()
result = cls.cursor.fetchone()
if result:
return result | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_user(user):\n user.save_user()",
"def save_user(user):\n user.save_user()",
"def save_user(user):\n User.add_user(user)",
"def save_user(user):\n User.save_user(user)",
"def save_user_account(user):\n user.save_user()",
"def save(cls, user):\n pass",
"def save(self):\... | [
"0.8588267",
"0.8588267",
"0.85677207",
"0.84292585",
"0.79613435",
"0.79455924",
"0.7894022",
"0.7756095",
"0.7720226",
"0.75996435",
"0.7547627",
"0.75383127",
"0.74641466",
"0.7445665",
"0.74321145",
"0.73722184",
"0.7371226",
"0.7344433",
"0.7335836",
"0.7279094",
"0.7269... | 0.0 | -1 |
Convert a row from bigquery into a dictionary, and convert NaN to None | def row_to_dict(row, field_names):
dict_row = {}
for value, field_name in zip(row, field_names):
if value and str(value).lower() == 'nan':
value = None
dict_row[field_name] = value
return dict_row | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_nan_dict(x):\n return {k: v for k, v in x.items() if pd.notnull(v)}",
"def handleNone(df):\n df = df.dropna()\n df = df.reset_index()\n return(df)",
"def cleanse_values(row):\n row = {k: v.strip() for (k, v) in row.items()}\n row = {k: (None if v.lower() == 'null' else v) f... | [
"0.6547895",
"0.60175765",
"0.59360796",
"0.59066874",
"0.59057343",
"0.58344007",
"0.58344007",
"0.57443416",
"0.5729159",
"0.5676192",
"0.5665481",
"0.5651627",
"0.562527",
"0.5604652",
"0.55531824",
"0.55303323",
"0.55266774",
"0.55041194",
"0.55009556",
"0.549511",
"0.549... | 0.66776645 | 0 |
get the course details on the basis of course ID | def getCourseById(self, request):
C = Course.objects.get(courseId=request["courseId"])
return C | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get(id):\n return Course._all[id]",
"def course(course_id):\n\n group_manager = GroupManager(current_user.session)\n course_manager = CourseManager(current_user.session)\n user_manager = UserManager(current_user.session)\n lab_manager = LabManager(current_user.session)\n\n course = cour... | [
"0.800549",
"0.75452167",
"0.7502379",
"0.73000395",
"0.7227616",
"0.70543766",
"0.7048286",
"0.70359915",
"0.7013591",
"0.6931835",
"0.656791",
"0.65120596",
"0.6482833",
"0.6434339",
"0.64270693",
"0.6382952",
"0.638086",
"0.634892",
"0.63104224",
"0.62841445",
"0.62545484"... | 0.82561344 | 0 |
get the course IDs on the basis of course name | def getCoursesByName(self, request):
C = Course.objects.filter(courseName=request["courseName"])
# idList = []
# for obj in C:
# idList.append(obj.courseId)
return C | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def course_id_list(self):\n\n return self.q(css='article.course').attrs('id')",
"def get_course_ids(self):\n return # osid.id.IdList",
"def searchCourseByName(self, name):\n\n return self.sql.select_from_where(\"COURSE\", \"*\", \"TITLE\", self.single_quote_around_str(name))",
"def get_... | [
"0.7069246",
"0.65532345",
"0.6448353",
"0.62455326",
"0.6233011",
"0.62262046",
"0.61624396",
"0.6149638",
"0.61018306",
"0.6080477",
"0.6059166",
"0.60562694",
"0.60450506",
"0.599188",
"0.59915835",
"0.595965",
"0.5938766",
"0.59343857",
"0.5929463",
"0.59284365",
"0.58037... | 0.8045959 | 0 |
Return the tree age in years as an int. | def get_age_years(self) -> int:
return self.__age_years | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_age_in_current_year(self):\n return int(strftime('%Y')) - self._birthday",
"def get_age(self):\n return PRESENT_YEAR - self.year",
"def age (self):\n \n today=datetime.date(2020,1,1)\n \n #这里需要转化成int,不然会TypeError: an integer is required (got type str)\n ... | [
"0.75683343",
"0.7542415",
"0.7474765",
"0.73924714",
"0.7290703",
"0.7284755",
"0.7267541",
"0.7218148",
"0.71254706",
"0.71109265",
"0.71109265",
"0.7095225",
"0.70424265",
"0.6948535",
"0.68972397",
"0.6798194",
"0.6791238",
"0.6788724",
"0.67198575",
"0.6699926",
"0.66383... | 0.77940726 | 0 |
Return the tree circumference in cm as a float. | def get_circumference_cm(self) -> float:
return self.__circumference_cm | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def circumference(self):\n return 2.0 * math.pi * self.__radius",
"def circumference(self):\n # Define doctests for circumference method:\n # Define circumference functionality:\n return round((2 * math.pi * self.radius),2)",
"def getCircumference(self):\n return 2 * math.pi ... | [
"0.7002824",
"0.69140595",
"0.68789476",
"0.6292085",
"0.62124646",
"0.61616933",
"0.61009884",
"0.6089921",
"0.6078302",
"0.6074272",
"0.60599256",
"0.60396504",
"0.60224676",
"0.6018407",
"0.59944403",
"0.5964316",
"0.59259367",
"0.5925509",
"0.5921628",
"0.59193087",
"0.58... | 0.75362027 | 0 |
Set the circumference_cm instance variable of a tree object to new_circumference_cm. | def set_circumference_cm(self, new_circumference_cm: float):
if new_circumference_cm >= 0:
self.__circumference_cm = new_circumference_cm
else:
raise ValueError("circumference_cm must be at least 0.") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_circumference_cm(self) -> float:\n return self.__circumference_cm",
"def _set_equatorial_radius(self, new_equatorial_radius):\n self._equatorial_radius = new_equatorial_radius",
"def _set_equatorial_radius(self, new_equatorial_radius):\n self._equatorial_radius = new_equatorial_rad... | [
"0.5641756",
"0.5554164",
"0.5554164",
"0.5273188",
"0.48286137",
"0.47816578",
"0.47558537",
"0.47399932",
"0.46759206",
"0.46194348",
"0.45935243",
"0.45671934",
"0.4553009",
"0.4533687",
"0.44894952",
"0.447896",
"0.44417614",
"0.44278702",
"0.44223794",
"0.4417895",
"0.44... | 0.82836366 | 0 |
Given a list of ``delimiters`` in hierarchical order, splits ``string`` into a nested list of strings. | def split_string_with_delimiters(string,delimiters,retype=str):
if len(delimiters)>0:
return [split_string_with_delimiters(s,delimiters[1:],retype) for
s in string.split(delimiters[0])]
else:
return retype(string) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def multisplit(string, *delimiters):\n pattern = \"|\".join(map(re.escape, delimiters))\n return re.split(pattern, string)",
"def _split(string, delimiter):\n segment = \"\"\n segments = []\n\n for i, c in enumerate(string):\n if c == delimiter and not _isCharEnclosed(i, string):\n ... | [
"0.7121707",
"0.68631566",
"0.65385795",
"0.6414695",
"0.6267582",
"0.62646174",
"0.6237696",
"0.6197471",
"0.6144159",
"0.6088123",
"0.60451233",
"0.5969555",
"0.592929",
"0.5909599",
"0.5881799",
"0.58107543",
"0.58055615",
"0.57553226",
"0.5739665",
"0.5717311",
"0.5655423... | 0.75391066 | 0 |
disadvantage() rolls two dice and implements a conditional test to return the lower value. | def roll_with_disadvantage(roll_func):
return min(roll_func(), roll_func()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def roll_dice(self):\n die1 = random.randint(1, 6)\n die2 = random.randint(1, 6)\n print(f\"{die1}, {die2}\")\n if die1 == die2:\n print(\"Doubles!\")\n return (die1, die2)",
"def roll_with_advantage(roll_func):\n return max(roll_func(), roll_func())",
"def roll... | [
"0.6352035",
"0.63419634",
"0.6074897",
"0.60646534",
"0.6010474",
"0.59424394",
"0.5681044",
"0.5623944",
"0.5618302",
"0.5613874",
"0.5595243",
"0.55270046",
"0.5524261",
"0.54997474",
"0.5486203",
"0.547092",
"0.5455492",
"0.5444217",
"0.5377491",
"0.53681934",
"0.5315358"... | 0.69678754 | 0 |
Sets the band of this SituationalResult. | def band(self, band):
self._band = band | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_band (self,band_id):\n self._band_index = self._check_band_num(band=band_id)",
"def band(self, band):\n cmd = 'CONFigure:LTE:SIGN:{}:BAND {}'.format(self._bts, band)\n self._cmw.send_and_recv(cmd)",
"def band(self):\n cmd = 'CONFigure:LTE:SIGN:{}:BAND?'.format(self._bts)\n ... | [
"0.6706127",
"0.6671192",
"0.58740133",
"0.5732089",
"0.56198806",
"0.5600382",
"0.5518439",
"0.53686035",
"0.5286444",
"0.52298784",
"0.5180732",
"0.51603496",
"0.50948066",
"0.50911224",
"0.50864804",
"0.50852525",
"0.50850934",
"0.5078196",
"0.50766253",
"0.5071332",
"0.49... | 0.7774308 | 0 |
Sets the completion_date of this SituationalResult. | def completion_date(self, completion_date):
self._completion_date = completion_date | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def completed_date(self, completed_date):\n\n self._completed_date = completed_date",
"def completed_date(self, completed_date):\n self._completed_date = completed_date",
"def set_completed(self, *, completition_date=None):\n self.__status = Flag.Complete\n completition_date = compl... | [
"0.771259",
"0.77042943",
"0.723424",
"0.69376594",
"0.651196",
"0.6411407",
"0.63043815",
"0.6215565",
"0.61775917",
"0.60919446",
"0.60461783",
"0.6036541",
"0.6036541",
"0.600623",
"0.60036355",
"0.59827536",
"0.59827536",
"0.59827536",
"0.59484106",
"0.59484106",
"0.59484... | 0.87288386 | 0 |
Sets the assessment_id of this SituationalResult. | def assessment_id(self, assessment_id):
self._assessment_id = assessment_id | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def assessment_name(self, assessment_name):\n\n self._assessment_name = assessment_name",
"def get_assessment(self, assessment_id):\n return # osid.assessment.Assessment",
"def assign_assessment_to_bank(self, assessment_id, bank_id):\n pass",
"def study_id(self, study_id):\n\n sel... | [
"0.659344",
"0.6220881",
"0.57488406",
"0.5741963",
"0.55984",
"0.5521104",
"0.55095315",
"0.54999095",
"0.543836",
"0.53033066",
"0.5279698",
"0.51672405",
"0.5154334",
"0.50950146",
"0.50950146",
"0.5066819",
"0.5042337",
"0.5025474",
"0.50020707",
"0.49953374",
"0.49541223... | 0.8197667 | 0 |
Sets the assessment_name of this SituationalResult. | def assessment_name(self, assessment_name):
self._assessment_name = assessment_name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def assessment_name(self) -> Optional[pulumi.Input[str]]:\n return pulumi.get(self, \"assessment_name\")",
"def assessment_id(self, assessment_id):\n\n self._assessment_id = assessment_id",
"def experiment_name(self, experiment_name):\n \n self._experiment_name = experiment_name",
... | [
"0.6612444",
"0.6403875",
"0.56936646",
"0.55943066",
"0.5461153",
"0.54390574",
"0.5357544",
"0.53536874",
"0.53520215",
"0.53520215",
"0.53520215",
"0.53520215",
"0.53520215",
"0.53427124",
"0.5337363",
"0.53244",
"0.5297125",
"0.5297125",
"0.5297125",
"0.5297125",
"0.52971... | 0.84559333 | 0 |
Returns the string representation of the model | def to_str(self):
return pprint.pformat(self.to_dict()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _repr_model_(self):\n return str(self)",
"def __str__(self):\n\n return str(self.model)",
"def get_model_string(self):\n raise NotImplementedError()",
"def __str__(self):\n return self.model",
"def serialize_model(self):\n return dill.dumps(self.model)",
"def __str_... | [
"0.86030954",
"0.85091114",
"0.8235956",
"0.80497414",
"0.80114347",
"0.793421",
"0.78784716",
"0.77902746",
"0.7789831",
"0.77466464",
"0.7629886",
"0.7608351",
"0.7582489",
"0.7515188",
"0.75065583",
"0.7504687",
"0.74877244",
"0.744343",
"0.74351317",
"0.74271595",
"0.7407... | 0.0 | -1 |
Returns true if both objects are not equal | def __ne__(self, other):
if not isinstance(other, SituationalResult):
return True
return self.to_dict() != other.to_dict() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __ne__(self, other: object) -> bool:\n return not self == other",
"def __ne__(self, other: object) -> bool:\n return not self.__eq__(other)",
"def __ne__(self, other):\n return self.__dict__ != other.__dict__",
"def __eq__(self, other):\n return not self.__ne__(other)",
... | [
"0.8410764",
"0.8391999",
"0.8172449",
"0.81410354",
"0.80921024",
"0.80890065",
"0.8067889",
"0.8042693",
"0.8042693",
"0.8042693",
"0.8042693",
"0.8042693",
"0.8042693",
"0.8042693",
"0.8042693",
"0.8042693",
"0.8042693",
"0.8042693",
"0.8042693",
"0.8042693",
"0.8042693",
... | 0.0 | -1 |
Returns a color code by name or mIRC number. | def color_code(color, suppresswarning=False):
try:
code = COLORS[color]['code']
except:
# Try number.
try:
codeval = int(color)
start = ''
code = '{}{}'.format(start, str(codeval))
except:
code = None
if code:
return ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def color(name='gray'):\n\n colors = {\n 'orange': '#E86E0A',\n 'red': '#D61E21',\n 'gray': '#7C7C7C',\n 'black': '#000000',\n 'green': '#75D977',\n 'mint': '#47D1A8',\n 'purple': '#C880D1',\n 'indigo': '#5E5AE6',\n 'blue': '#47AEED', # previously ... | [
"0.70423293",
"0.6873483",
"0.6641067",
"0.6557011",
"0.6476394",
"0.63852954",
"0.62916374",
"0.62659",
"0.6184845",
"0.6175524",
"0.6152423",
"0.61169654",
"0.6051994",
"0.60415804",
"0.59658194",
"0.59612656",
"0.5940243",
"0.5880264",
"0.5807768",
"0.58054215",
"0.5796412... | 0.67775863 | 2 |
internal function to make a hex string out of a binary array. binary array might be created from comparison for example, in average hash, each pixel in the image is compared with the average pixel value. If the pixel's value is less than the average it gets a 0 and if it's more it gets a 1. Then we treat this like a st... | def _binary_array_to_hex(arr):
h = 0
s = []
for i, v in enumerate(arr.flatten()):
if v:
h += 2**(i % 8)
if (i % 8) == 7:
s.append(hex(h)[2:].rjust(2, '0'))
h = 0
return "".join(s) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def BinarytoHex(BinaryList):\n return format(int(''.join([str(i) for i in BinaryList]), 2), '#04x')[2:].upper()",
"def numpy2hex(clr):\n\n if len(clr) < 3: return clr\n clr = [int(round(255*c)) for c in clr[:3]]\n return tuple2hex(clr)",
"def bits_to_hex(b):\n b = list(map(str, b))\n return \... | [
"0.6846378",
"0.6548228",
"0.64912283",
"0.62972087",
"0.6287053",
"0.62815183",
"0.6226644",
"0.6030026",
"0.6027426",
"0.5999126",
"0.59882486",
"0.5962001",
"0.59488565",
"0.5919707",
"0.5886599",
"0.5867075",
"0.5810332",
"0.5803501",
"0.57604504",
"0.57598925",
"0.575308... | 0.82103384 | 0 |
Represent TrackRun as string. | def str_repr(self, short=False):
summary = ["<octant.core.{}>".format(type(self.trackrun).__name__)]
summary.append("[{} tracks]".format(len(self.trackrun)))
if short:
return " ".join(summary)
if len(self.trackrun) > 0:
summary.append("\nData columns:")
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __str__(self) -> str:\n\n\t\treturn str(self._runs)",
"def __str__(self):\n track_list = ' + '.join([str(trackpart) for trackpart in self.trackparts_list])\n\n return f'Using track: {track_list}'",
"def to_text(self):\n\n self.to_dict()\n\n if not self.track_dict:\n r... | [
"0.69347817",
"0.6768266",
"0.67127043",
"0.6377476",
"0.6042335",
"0.5896834",
"0.577112",
"0.5717642",
"0.57103395",
"0.5707989",
"0.5668529",
"0.56629455",
"0.5651976",
"0.56492347",
"0.56290406",
"0.5620433",
"0.561909",
"0.56099254",
"0.56028056",
"0.55978847",
"0.559477... | 0.6695452 | 3 |
Represent TrackSettings as string. | def str_repr(self, short=False):
summary = [self.longname]
if self.n_set > 0 and not short:
summary.append("")
summary += [f"{k} = {getattr(self.ts, k, None)}" for k in self.ts._fields]
return "\n".join(summary) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __str__(self):\n track_list = ' + '.join([str(trackpart) for trackpart in self.trackparts_list])\n\n return f'Using track: {track_list}'",
"def __str__(self):\n\t\treturn \"%s %s ( %s )\" % (repr(self), str(self.__class__), str(self.settings))",
"def __repr__(self):\n\n return str(self... | [
"0.6649782",
"0.64673257",
"0.631672",
"0.627294",
"0.62676823",
"0.62676823",
"0.62676823",
"0.62676823",
"0.62676823",
"0.62676823",
"0.62676823",
"0.62676823",
"0.62676823",
"0.62676823",
"0.62676823",
"0.62676823",
"0.62676823",
"0.62676823",
"0.62676823",
"0.62676823",
"... | 0.0 | -1 |
This testing to see whether the signing up works when all the information is provided | def test_registration_with_all_information(self):
response = self.client.post(reverse('aiuts:create_acc'), {"fullname": "Testing01", "password": "Asd,car15"}, follow=True)
self.assertEqual(response.status_code, 200)
self.assertContains(response, "afe600a43cea6bdaf6c362905db6b883 has been created... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_process_signup_existing_user(self):\n\n self.signup()\n result = self.signup()\n\n self.assertEqual(result.status_code, 200)\n self.assertIn('already have an account, please sign in.', result.data)",
"def test_v1signup(self):\n pass",
"def test_user_can_signup(self):... | [
"0.77725476",
"0.77216375",
"0.7509426",
"0.7477858",
"0.74579346",
"0.74421775",
"0.7409367",
"0.7401857",
"0.7394482",
"0.73188156",
"0.7299474",
"0.7296888",
"0.7295848",
"0.7225437",
"0.72186697",
"0.7201944",
"0.71851724",
"0.71560174",
"0.7146927",
"0.71160996",
"0.7111... | 0.71515167 | 18 |
This testing is checking the response of the backend when the required part of the fullname is bypass. To see whether the system will accept with the blank full name or not. | def test_registration_bypass_fullname(self):
response = self.client.post(reverse('aiuts:create_acc'), {"fullname": "", "password": "Asd,car15"}, follow=True)
self.assertEqual(response.status_code, 200)
blank_fullname = User.objects.filter(pk="d41d8cd98f00b204e9800998ecf8427e").exists()
s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_name_validate_full_name(self):\n pass",
"def test_empty_names(self):\n data = self.valid_payload\n data[\"last_name\"] = \"\"\n data[\"first_name\"] = \"\"\n self.client.credentials(\n HTTP_AUTHORIZATION='Bearer EGsnU4Cz3Mx50UCuLrc20mup10s0Gz')\n resp... | [
"0.7967964",
"0.72615904",
"0.7196863",
"0.71535945",
"0.7046113",
"0.6998728",
"0.6894349",
"0.68789566",
"0.6841406",
"0.6790543",
"0.6779519",
"0.67381257",
"0.6729397",
"0.6702404",
"0.668815",
"0.66636634",
"0.6630961",
"0.66091377",
"0.6598598",
"0.65794784",
"0.6544741... | 0.79782766 | 0 |
Given pyconll sentence, return sentence list of (word, tag). | def get_sentence(sentence):
return [(t.form, t.upos) for t in sentence] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def nltk_tagger(sentence):\n\n doc = _NLTK.tag(sentence)\n return [token[1] for token in doc]",
"def tag_sentence(self, sentence: Sequence[str]) -> List[str]:\n # DO NOT IMPLEMENT THIS METHOD HERE\n # Instead, implement it in the subclasses.\n raise NotImplementedError",
"def spacy_t... | [
"0.80486685",
"0.7809316",
"0.7777346",
"0.7020617",
"0.6910053",
"0.69048595",
"0.6830164",
"0.68175703",
"0.6802894",
"0.67971444",
"0.6796614",
"0.67932165",
"0.6697583",
"0.66939574",
"0.66711843",
"0.66553974",
"0.6602364",
"0.65919363",
"0.6587984",
"0.6522677",
"0.6522... | 0.73497766 | 3 |
Returns True if the robot can move right or False if it's at the end of the list. | def can_move_right(self):
return self._position < len(self._list) - 1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def move_right(self):\n self._time += 1\n if self._position < len(self._list) - 1:\n self._position += 1\n return True\n else:\n return False",
"def move_right(self):\n self._time += 1\n if self._position < len(self._list) - 1:\n self... | [
"0.7928889",
"0.7928889",
"0.7928889",
"0.7562439",
"0.7089608",
"0.68691295",
"0.6600383",
"0.65752566",
"0.6564379",
"0.6526628",
"0.6507187",
"0.6377059",
"0.6345643",
"0.6342096",
"0.6342096",
"0.6342096",
"0.6289478",
"0.62746423",
"0.62323236",
"0.6222893",
"0.6215226",... | 0.8452943 | 1 |
See if num is prime. (Slow!) | def isPrimeWithSieve(num):
return not any(num % j == 0 for j in primesLessThan(num)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_prime(num: int) -> bool:\n pass",
"def is_prime_number(num):\n\n for i in range(2, num):\n if num % i == 0:\n return False\n else:\n return True",
"def is_prime(num):\n for i in range(2, num):\n if num % i == 0:\n return False\n return Tr... | [
"0.85176665",
"0.8405778",
"0.83318466",
"0.82934844",
"0.82849574",
"0.8269757",
"0.8266745",
"0.82368606",
"0.8210204",
"0.8187954",
"0.8186012",
"0.8176551",
"0.81628186",
"0.8159641",
"0.8158092",
"0.8149631",
"0.80968094",
"0.8093777",
"0.80627686",
"0.8026564",
"0.79460... | 0.80865353 | 18 |
Sees if a number is prime. (Faster than above is O(sqrt(n) + 1).) | def isPrime(num):
return not any(num % j == 0 for j in range(2,(num**.5) + 1)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def isprime(n):\n if prime(n):\n return True\n else:\n return False",
"def isprime(n):\n if prime(n):\n return True\n else:\n return False",
"def is_prime(number):\n if number == 1:\n return False\n count = 0\n square_root = int(math.sqrt(number))\n fo... | [
"0.8464961",
"0.8464961",
"0.8459587",
"0.83961815",
"0.8376788",
"0.8372982",
"0.83616275",
"0.8347798",
"0.834593",
"0.8334432",
"0.8333399",
"0.83204496",
"0.82900614",
"0.8283175",
"0.82601446",
"0.8259711",
"0.82582355",
"0.82550037",
"0.82456297",
"0.8241415",
"0.823563... | 0.8240755 | 20 |
Draw the item rectangles onto the pygame surface. | def draw_display(self, match_id=None):
self.surface = pygame.Surface((self.width, self.height))
self.surface.fill((195, 195, 195))
border_color = (0, 0, 0)
for i in range(len(self.item_list)):
color = (243, 214, 96)
if match_id is not None:
if self... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def draw(self):\r\n\t\t\r\n\t\tblocks = self.get_blocks()\r\n\r\n\t\tfor b in blocks:\r\n\t\t\tpygame.draw.rect(screen, self.color, b.rect)",
"def _draw(self):\n proportions = self._auto[self._index].proportions()\n for r in range(proportions[0]):\n for c in range(proportions[1]):\n ... | [
"0.7747102",
"0.75166",
"0.736054",
"0.73586476",
"0.73124367",
"0.7215424",
"0.71419567",
"0.70902187",
"0.70738024",
"0.7055774",
"0.70550597",
"0.7007832",
"0.69992524",
"0.69992524",
"0.69992524",
"0.69984454",
"0.69719267",
"0.69514894",
"0.69256186",
"0.69127125",
"0.68... | 0.7352578 | 4 |
Renders the home page of the webapp. | def index():
return render_template('home.html') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def home():\n\treturn render_template('home.html')",
"def home_page():\n return render_template(\"home.html\", app_name=APP_NAME)",
"def home():\n return render_template(\n 'home.html',\n title='Home Page',\n )",
"def home():\r\n return render_template(\"home.html\")",
"def home()... | [
"0.86327827",
"0.85658365",
"0.8541072",
"0.84915763",
"0.848595",
"0.84688723",
"0.8443106",
"0.8414465",
"0.8388431",
"0.83745474",
"0.83745474",
"0.8332423",
"0.8332423",
"0.8332423",
"0.8316817",
"0.8316817",
"0.8316817",
"0.8316817",
"0.8316817",
"0.8316817",
"0.8316817"... | 0.80984277 | 72 |
Renders the login page. | def login():
form = LoginForm()
if form.validate_on_submit():
email = form.email.data
password = form.password.data
if email == model_user.email and password == model_user.password:
return redirect(url_for('bucket_list'))
else:
msg = "wrong credentials... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def login_page():\n\n return render_template(\"login_form.html\")",
"def show_loginpage():\n\n return render_template(\"login_form.html\")",
"def show_login_page():\n\n return render_template(\"login.html\")",
"def login():\n\n return render_template(\"login.html\")",
"def login():\n\n retur... | [
"0.8357843",
"0.82968396",
"0.8281928",
"0.8239968",
"0.8238465",
"0.8236354",
"0.8197123",
"0.81936675",
"0.81936675",
"0.80116373",
"0.79761267",
"0.7972544",
"0.7772338",
"0.7588151",
"0.7554204",
"0.7552091",
"0.75261635",
"0.7512014",
"0.75011915",
"0.7492496",
"0.748162... | 0.0 | -1 |
Returns a new Pig whose weight is the weight of the heavier of this Pig and the other_Pig. | def new_pig(self, other_pig):
# DONE: Implement and test this method.
if self.w > other_pig.w:
newpig = self
else:
newpig = other_pig
return newpig | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def heavier_pig(self, other_pig):\n # DONE: Implement and test this method.\n if self.w > other_pig.w:\n return self\n else:\n return other_pig",
"def weight(self):\n return _pythia8.HEPEUP_weight(self)",
"def avg(self, other, weight=.5):\n if not self._... | [
"0.81528705",
"0.5813938",
"0.5704088",
"0.5636661",
"0.55575657",
"0.55335736",
"0.5513012",
"0.549366",
"0.54807585",
"0.5469827",
"0.5451965",
"0.5445804",
"0.544257",
"0.5428277",
"0.5410297",
"0.540208",
"0.53723055",
"0.5371304",
"0.53523743",
"0.53523743",
"0.5317074",... | 0.6832573 | 1 |
Read ekpy data file. If no ekpy heading exists ('ekpy_heading') defaults to `pandas.read_csv' | def read_ekpy_data(file:str, skiprows:'int or None'=None, return_meta_data=False, return_skiprows=False):
if skiprows is not None:
return pd.read_csv(file, skip_blank_lines=True, skiprows=skiprows)
# if skiprows is None:
with open(file, 'r') as f:
lines = f.readlines()
index=len(lines)+1
for i, line in enumer... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_csv(self):\n # File name and extension\n file_name, file_extension = os.path.splitext(self.isin_eid_data_path)\n # Read input file\n if file_extension == \".csv\":\n return pd.read_csv(self.isin_eid_data_path)\n else:\n raise TypeError(\n ... | [
"0.58789",
"0.5866574",
"0.578275",
"0.56626135",
"0.56529367",
"0.559903",
"0.55465436",
"0.55230874",
"0.5460295",
"0.54320985",
"0.54277414",
"0.53863674",
"0.5314954",
"0.5299295",
"0.5290947",
"0.5278025",
"0.526997",
"0.5223735",
"0.5218167",
"0.52068394",
"0.51866955",... | 0.7253626 | 0 |
Takes 'clusters' and creates a list of colors so a cluster has a color. | def gen_colors(clusters):
import matplotlib.cm as cm
n = len(set(clusters))
colorm = [cm.hsv(i * 1.0 /n, 1) for i in xrange(n)]
return colorm | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def color_clusters(self, cluster_count):\n if cluster_count > 1:\n self.cluster_distance_threshold = self.__get_distance_threshold__(cluster_count)\n rand_color = randomcolor.RandomColor()\n \n to_color = []\n for nodeid, node in self.dendrogram[\"data\... | [
"0.7197265",
"0.65695494",
"0.6514732",
"0.6497715",
"0.6394706",
"0.62692475",
"0.61741334",
"0.6170272",
"0.61557436",
"0.6080548",
"0.6033468",
"0.6032284",
"0.6022515",
"0.6010181",
"0.5946643",
"0.593991",
"0.593321",
"0.5907993",
"0.5903664",
"0.58785045",
"0.5849446",
... | 0.82597846 | 0 |
Helper method which creates a decorator that applies the given subdecorators. Decorators are applied in reverse order given. (dec_1, dec_2, ...) | def sequence(*decorators):
def apply(obj):
for dec in reversed(decorators):
obj = dec(obj)
return obj
return apply | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def chain_decorators(fn, *declist):\n\n for dec in declist[::-1]: # wrap them in the same order as they'd be wrapped if they were used normally\n fn = dec(fn)\n\n @decorator\n def rundecs(_fn, *a, **kw):\n return fn(*a, **kw)\n\n return rundecs",
"def decorator_apply(dec, func):\n\n ... | [
"0.7602675",
"0.58405364",
"0.57953155",
"0.56165874",
"0.5597423",
"0.5541661",
"0.5387001",
"0.5385724",
"0.53551495",
"0.53252107",
"0.53164804",
"0.5284423",
"0.52643454",
"0.5254459",
"0.52053016",
"0.5190946",
"0.51883024",
"0.5175415",
"0.51264673",
"0.5091747",
"0.507... | 0.69694775 | 1 |
group the list into lists of 254 items each. This is due to argument restrictions in python. | def group_arguments(seq, group=254):
return (seq[pos:pos + group] for pos in range(0, len(seq), group)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _group_list(self, mylist):\r\n return [list(v) for i, v in itertools.groupby(mylist, lambda x: x[:4])]",
"def groups(l):\n r = []\n N = len(l)\n if N == 0:\n return r\n Group = l[0].create_group\n\n n = N // nmax\n if n*nmax < N:\n n = n+1\n rest = n*nmax-N\n\n a ... | [
"0.6384118",
"0.6336119",
"0.6015425",
"0.59193814",
"0.5896156",
"0.5889815",
"0.5875685",
"0.57886225",
"0.5720156",
"0.5709483",
"0.5709483",
"0.5594601",
"0.5538955",
"0.5530349",
"0.5529773",
"0.5518747",
"0.5518472",
"0.55165523",
"0.5515967",
"0.55020124",
"0.5500224",... | 0.0 | -1 |
Closes the logger, namely its file. | def close(self, agent, log=print):
if self.save_probas:
self.file.close()
log(f"probability distributions of {agent.__class__.__name__} stored in {self.save_probas}") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def close(self):\n if self.logfile is not None:\n self.logfile.close()\n LoggerUI.printStatus(\"{}closed: {}\".format(protocol.OUTPUT, self.fileinfo))\n self.logfile = None\n self.fileinfo = None",
"def close(self):\n self._log_reader.close()",
"def clo... | [
"0.7455094",
"0.72465426",
"0.71158946",
"0.70953214",
"0.709169",
"0.6841264",
"0.6706893",
"0.6706893",
"0.6630837",
"0.6594332",
"0.6495327",
"0.6488865",
"0.6479615",
"0.6479615",
"0.6479615",
"0.64793056",
"0.64717054",
"0.64599866",
"0.6417317",
"0.640271",
"0.640271",
... | 0.57067496 | 92 |
Duration of analysed video in seconds. | def media_length(self):
return self.metadata["media_info"]["technical"]["duration_s"] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getDuration(video_path):\n return moviepy.editor.VideoFileClip(video_path).duration",
"def duration(self):\n pass",
"def duration(self) -> int:\n return 0",
"def duration(self) -> int:\n return 0",
"def duration(self):\n return 0",
"def get_video_duration(video_file):\n... | [
"0.76009595",
"0.7107313",
"0.70364934",
"0.70364934",
"0.7030806",
"0.701084",
"0.7001091",
"0.6944988",
"0.68640167",
"0.6843546",
"0.6801549",
"0.67911446",
"0.67766184",
"0.6776526",
"0.6762031",
"0.67241883",
"0.66985226",
"0.6696655",
"0.6690726",
"0.66820484",
"0.66691... | 0.60678875 | 87 |
Yields detection_id, detection pairs. | def detections(self, detection_types=None, categories=None, sort_by=None, n_per_type=None):
if detection_types is None:
detection_types = self.metadata["detection_groupings"]["by_detection_type"]
else:
if isinstance(detection_types, str):
detection_types = [detec... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def detection_types(self):\n for detection_type, detection_ids in self.metadata[\"detection_groupings\"][\"by_detection_type\"].items():\n\n yield detection_type, [det_id for det_id in detection_ids if not self.blacklisted(detection_id=det_id)]",
"def detections_gen(self):\n raise NotImp... | [
"0.630082",
"0.6252966",
"0.57499254",
"0.5693094",
"0.5557551",
"0.55285144",
"0.55013067",
"0.54807556",
"0.53848696",
"0.5305449",
"0.5273856",
"0.5267773",
"0.52484566",
"0.5234421",
"0.5233136",
"0.5191139",
"0.51862365",
"0.51814246",
"0.51696074",
"0.51696074",
"0.5153... | 0.58442783 | 2 |
initializes the axis rater ticks and labels are lists of instances of a value rater the first entry in ticks rate the number of ticks, the second the number of subticks, etc.; when there are no ticks of a level or there is not rater for a level, the level is just ignored labels is analogous, but for labels within the r... | def __init__(self, ticks, labels, range, distance):
self.ticks = ticks
self.labels = labels
self.range = range
self.distance = distance | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, xlimits, ylimits, xlabel=None,\n ylabel=None, xticks=6, yticks=6, grid=True):\n self._xlimits = xlimits\n self._ylimits = ylimits\n self._xlabel = xlabel\n self._ylabel = ylabel\n self._xticks = xticks\n self._yticks = yticks\n sel... | [
"0.6544617",
"0.61849535",
"0.60572314",
"0.5947336",
"0.5885919",
"0.58489156",
"0.5830904",
"0.58065",
"0.57963496",
"0.57724965",
"0.57513314",
"0.5738412",
"0.5698394",
"0.56464225",
"0.56129134",
"0.56038576",
"0.560039",
"0.55273974",
"0.550287",
"0.54895806",
"0.548007... | 0.7556761 | 0 |
Return a iterator passing through all nodes in the graph. | def __iter__(self):
for each in self.nodes:
yield each | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __iter__(self):\n # easy enough\n return iter(self._nodes)",
"def __iter__(self):\n return iter(self.nodes)",
"def __iter__(self):\r\n return self.iterNodes()",
"def get_nodes_iter(self):\n\n return self.__nodes.values()",
"def nodes(self):\n for node in self._... | [
"0.7859996",
"0.7731082",
"0.7573988",
"0.7410046",
"0.73863566",
"0.72999",
"0.72799",
"0.72758335",
"0.7269305",
"0.72515243",
"0.72236663",
"0.71876687",
"0.71517706",
"0.7106765",
"0.70396864",
"0.69965327",
"0.69653064",
"0.6962348",
"0.6942738",
"0.6934789",
"0.6898166"... | 0.81479543 | 0 |
Maintains each edge's list of available nodes. | def _set_node_lists(self, new):
for edge in self.edges:
edge._nodes = self.nodes | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_available_nodes(self):\n pass",
"def _all_nodes(self):\n return set(to for from_, to in self.B_edgelist)",
"def _update_nodes(self):\n _linkages = {\n 'x': [],\n 'y': [],\n 'z': []\n }\n _motor = []\n _feasible = []\n for... | [
"0.66284716",
"0.6398206",
"0.6272168",
"0.6247432",
"0.6221939",
"0.6218854",
"0.62003666",
"0.61942524",
"0.6087861",
"0.6063023",
"0.59943664",
"0.59716",
"0.59691197",
"0.5915829",
"0.5882517",
"0.5875115",
"0.58569676",
"0.58556324",
"0.58408594",
"0.5839858",
"0.5817779... | 0.73997766 | 0 |
Converts grayscale images to RGB. It changes NxHxWx1 to a NxHxWx3 array, where N is the number of figures, H is the high and W the width. | def convert_to_rgb(self, images):
dims = np.shape(images)
if not ((len(dims) == 4 and dims[-1] == 1) or len(dims) == 3):
raise ValueError('Unexpected shape for grayscale images:' + str(dims))
if dims[-1] == 1:
# Squeeze channel axis if it exists
rgb_im... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convert_grayscale_to_rgb(x: np.ndarray) -> np.ndarray:\n return np.stack((x, ) * 3, axis=-1)",
"def rgb2gray(np_imgs):\r\n if np_imgs.shape[0]==0:\r\n return np_imgs\r\n\r\n gray_imgs = np.dot(np_imgs,[0.299, 0.587, 0.114])\r\n if len(gray_imgs.shape) < 4:\r\n gray_imgs = gray_imgs[... | [
"0.74704397",
"0.7097807",
"0.7092324",
"0.70426434",
"0.70208013",
"0.6890179",
"0.68712735",
"0.6825667",
"0.6820429",
"0.6790093",
"0.6761051",
"0.67144865",
"0.6707789",
"0.6696012",
"0.6643888",
"0.6569616",
"0.65412724",
"0.6464502",
"0.6452229",
"0.64478",
"0.64343506"... | 0.75122833 | 0 |
Get pretrained BERT model. | def get_bert_model(bert_model, cased, ctx, dropout_prob):
bert_dataset_name = get_bert_dataset_name(cased)
return nlp.model.get_model(
name=bert_model,
dataset_name=bert_dataset_name,
pretrained=True,
ctx=ctx,
use_pooler=False,
use_decoder=False,
use_clas... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_model(self):\n if self.bert_model_name == \"bert-base\":\n model_path = \"bert-base-uncased\"\n elif self.bert_model_name == \"finbert-domain\":\n get_model(\"finbert-domain\")\n model_path = str(Path.cwd()/'model/finbert-domain')\n elif self.bert_model... | [
"0.7836823",
"0.76474816",
"0.7093792",
"0.69987816",
"0.69175017",
"0.68555295",
"0.6839681",
"0.6673413",
"0.66400045",
"0.66064405",
"0.65588087",
"0.64845186",
"0.6462984",
"0.64572245",
"0.6452512",
"0.643207",
"0.6425207",
"0.64117545",
"0.64017814",
"0.639981",
"0.6396... | 0.67202723 | 7 |
return density in cm^3 | def n_of_t(self,t):
A = self.A; B = self.B
tmax = self.cycloidt(2*np.pi)
tflat = self.cycloidt(3*np.pi/2)
try:
assert t >= 0# and t <= tmax
except ValueError:
assert (t >= 0).all()# and (t <= tmax).all()
eta = self.get_eta_from_t(t)
return... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def density(self):\n m = Mass(self.composition.weight, \"amu\")\n return m.to(\"g\") / (self.volume * Length(1, \"ang\").to(\"cm\") ** 3)",
"def density(self):\n constant = AMU_TO_KG * 1000 / 1e-24\n return self.composition.weight / self.volume * constant",
"def density():\n\tpass",... | [
"0.7486128",
"0.7335802",
"0.72875744",
"0.7276545",
"0.6870989",
"0.6824456",
"0.68004376",
"0.6637331",
"0.6497066",
"0.64846146",
"0.6474936",
"0.64492136",
"0.6429534",
"0.634871",
"0.63204426",
"0.629071",
"0.6261045",
"0.62433636",
"0.62428725",
"0.6209576",
"0.62049156... | 0.0 | -1 |
Defines the model (`self.model`) and the optimizer (`self.optimizer`). | def define_model_and_optimizer(self):
print("* Defining model and optimizer.", flush=True)
job_dir = self.C.job_dir
model_dir = self.C.dataset_dir
if self.C.restart:
print("-- Loading model from previous saved state.", flush=True)
self.restart_epoch = util.get_re... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def define_optimizer(self):\n self.optimizer = tf.train.AdamOptimizer(self.config.model.learning_rate, beta1=self.config.model.beta1, beta2=self.config.model.beta2)\n self.train_step = self.optimizer.minimize(self.loss, global_step=self.global_step_tensor)",
"def initialize_model(self):\n if... | [
"0.7298157",
"0.71106887",
"0.710516",
"0.6888144",
"0.6885723",
"0.6877262",
"0.6866994",
"0.6863418",
"0.6826903",
"0.67849165",
"0.6774487",
"0.675146",
"0.67304784",
"0.67266697",
"0.6661022",
"0.6644286",
"0.6643744",
"0.66430414",
"0.6638579",
"0.6638065",
"0.6619308",
... | 0.74551666 | 0 |
Update speed upon collision with the wall. | def wall_collisions(self):
world_size = self.settings["world_size"]
for dim in range(2):
if self.position[dim] - self.radius <= 0 and self.speed[dim] < 0:
self.speed[dim] = - self.speed[dim] * self.bounciness
elif self.position[dim] + self.radius + 1 >= world_size[dim] and self.speed[dim] > 0:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def handle_collision(self):\n if not self.on_wall:\n self.dx = 0\n self.dy = 0\n self.on_wall = True",
"def update(self, walls):\n # apply gravity\n self.rect.y += self.dy\n\n # apply movement\n self.rect.x += self.dx\n\n # adjust our gra... | [
"0.70070285",
"0.69622487",
"0.69142604",
"0.6851026",
"0.6822905",
"0.66605145",
"0.6612264",
"0.66013604",
"0.6578881",
"0.65584266",
"0.6513843",
"0.6490438",
"0.6487595",
"0.64770645",
"0.6472864",
"0.6439027",
"0.6436485",
"0.6424214",
"0.6399415",
"0.63470495",
"0.63448... | 0.765318 | 0 |
Move and bounce of walls. | def step(self, dt):
self.wall_collisions()
self.move(dt) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wall_bounce(self, direction):\n if direction == 'y':\n self.vel_y *= -1\n else:\n # Only when game is over\n self.vel_x *= -1",
"def update(self, walls):\n # apply gravity\n self.rect.y += self.dy\n\n # apply movement\n self.rect.x +=... | [
"0.748991",
"0.7351546",
"0.71724194",
"0.7108411",
"0.70872426",
"0.70738626",
"0.7019701",
"0.69300693",
"0.6922103",
"0.68848395",
"0.6875545",
"0.6858666",
"0.6854031",
"0.6833712",
"0.6780946",
"0.67652464",
"0.67422366",
"0.66817766",
"0.6667657",
"0.6667657",
"0.666125... | 0.65028465 | 26 |
Return observation vector. For all the observation directions it returns representation of the closest object to the hero might be nothing, another object or a wall. Representation of observation for all the directions will be concatenated. | def observe(self):
num_obj_types = len(self.settings["objects"]) + 1 # and wall
max_speed_x, max_speed_y = self.settings["maximum_speed"]
observable_distance = self.settings["observation_line_length"]
relevant_objects = [obj for obj in self.objects
if obj.position.distance(self.hero.position) < observa... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def observation(self):\n\t\tego = self.ego_state.clone()[1:]\n\t\tlane_pos = self.lane_relative_state[1]\n\t\tveh_width = self.veh.shape[1]\n\t\tll_dist = self.lane_width - (lane_pos + veh_width/2)\n\t\trl_dist = lane_pos - veh_width/2\n\n\t\tfar_left_dist = self.lane_loc[-1] - (self.ego_state[1] + veh_width/2)\n\... | [
"0.666297",
"0.57685083",
"0.54763854",
"0.5474745",
"0.54662097",
"0.5451065",
"0.5383716",
"0.5352045",
"0.53304386",
"0.53103346",
"0.52297896",
"0.51413035",
"0.51003873",
"0.5086738",
"0.50641257",
"0.50562096",
"0.50529504",
"0.50495195",
"0.50437474",
"0.50432897",
"0.... | 0.65171283 | 1 |
Fake the remote origin url of a repository | def remote_origin_url(self, cwd):
git_info = read_git_info(cwd=cwd)
return git_info["remote_origin_url"] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_capture_remote_url(self):\n folder = temp_folder()\n url, commit = create_local_git_repo(files={\"conanfile.py\": self.conanfile}, folder=folder)\n\n c = TestClient()\n c.run_command('git clone \"{}\" myclone'.format(folder))\n with c.chdir(\"myclone\"):\n c.r... | [
"0.719918",
"0.70790607",
"0.6915775",
"0.660946",
"0.6554014",
"0.6524782",
"0.6473722",
"0.64573216",
"0.64104813",
"0.6335387",
"0.63247204",
"0.63169885",
"0.6306851",
"0.6292804",
"0.62491775",
"0.62491775",
"0.62288827",
"0.6196025",
"0.61747915",
"0.6171071",
"0.613949... | 0.59688085 | 30 |
Called to calculate the "real time" age an object lived. | def calculageAge(self):
diff = self.endTime - self.startTime
self.age = diff.total_seconds() * 1000 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def age(self):\n\t\treturn time.time() - self.time",
"def age(self):\n return datetime.now() - self.value",
"def getAge(self):\n return time.time() - self.timestamp",
"def age(self):\n return (datetime.utcnow() - self._start_time).total_seconds()",
"def age(self):\n delta = date... | [
"0.79073817",
"0.780077",
"0.77068585",
"0.7643959",
"0.74996644",
"0.73939025",
"0.736725",
"0.7352969",
"0.7241754",
"0.7227862",
"0.7172262",
"0.71468735",
"0.7116755",
"0.710813",
"0.7103099",
"0.7013976",
"0.7013764",
"0.6993629",
"0.6963796",
"0.6963796",
"0.69550836",
... | 0.8258293 | 0 |
Return a filtered hash containting the systemrelated parameters and values | def getSystemData(self, params, prevDataRef=None):
return self.getFilteredData(self.data, params, prevDataRef) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getParameters(self):\n instL = self.getInstances()\n filtered_params = {}\n for nameT,valuesL in self.params.items():\n L = []\n for valL in valuesL:\n if contains_parameter_name_value( instL, nameT, valL ):\n L.append( valL )\n ... | [
"0.64175886",
"0.63003814",
"0.5842975",
"0.58153325",
"0.57446975",
"0.5738374",
"0.5737941",
"0.5717597",
"0.56629145",
"0.5661474",
"0.5593271",
"0.55896413",
"0.5573333",
"0.5567375",
"0.5536009",
"0.5482223",
"0.5465893",
"0.5462944",
"0.54585487",
"0.5454827",
"0.542400... | 0.0 | -1 |
Return a filtered hash containing the jobrelated parameters and values | def getJobData(self, pid, params):
if pid not in self.jobs:
return []
return self.getFilteredData(self.jobs[pid]['DATA'], params) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getParameters(self):\n instL = self.getInstances()\n filtered_params = {}\n for nameT,valuesL in self.params.items():\n L = []\n for valL in valuesL:\n if contains_parameter_name_value( instL, nameT, valL ):\n L.append( valL )\n ... | [
"0.62353086",
"0.593862",
"0.588834",
"0.58498627",
"0.577746",
"0.57629573",
"0.56243926",
"0.5619266",
"0.56173617",
"0.561215",
"0.56029487",
"0.56029487",
"0.56029487",
"0.56029487",
"0.55814224",
"0.5532397",
"0.5493675",
"0.5470301",
"0.5460037",
"0.5439602",
"0.5432650... | 0.5132348 | 65 |
Calculate the velocity and the oriention of each superpixel | def calculateVelocityAndOrientationVectors(labels, shifted_labels, avg_flow,
avg_fst_depth, avg_shifted_depth):
velocity = np.zeros((labels.shape[0], labels.shape[1], 3), dtype=np.float32)
orientation = np.zeros((labels.shape[0], labels.shape[1], 3), dtype=np.f... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculate_velocity(self):\n \n ho = 1e-6\n \n xvel = (self.xmom[self.ind] * self.depth_w) / (self.depth_w**2 + ho)\n yvel = (self.ymom[self.ind] * self.depth_w) / (self.depth_w**2 + ho)\n \n U = num.sqrt(xvel**2. + yvel**2)\n \n return U, xvel, yve... | [
"0.7225813",
"0.67705417",
"0.6758189",
"0.65238196",
"0.6426455",
"0.63600516",
"0.6314387",
"0.6292883",
"0.62649244",
"0.62583125",
"0.62485445",
"0.6203159",
"0.6164253",
"0.6148156",
"0.6141881",
"0.6120606",
"0.60805815",
"0.60323507",
"0.60218084",
"0.60218084",
"0.600... | 0.0 | -1 |
Yield successive nsized chunks from l. | def chunks(l, n):
for i in xrange(0, len(l), n):
yield l[i:i+n] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __chunks(self, l, n):\n for i in range(0, len(l), n):\n yield l[i:i+n]",
"def _chunks(self, l, n):\n for i in xrange(0, len(l), n):\n yield l[i:i+n]",
"def chunk(self, l, n):\n for i in range(0, len(l), n):\n yield l[i:i + n]",
"def chunks(l, n):\n ... | [
"0.80769104",
"0.79787016",
"0.7849851",
"0.78188306",
"0.7765429",
"0.7765429",
"0.7741297",
"0.7681163",
"0.7678313",
"0.76744837",
"0.7659619",
"0.7656609",
"0.7656609",
"0.7656609",
"0.7646568",
"0.76157063",
"0.7584756",
"0.75580937",
"0.75498754",
"0.75498754",
"0.75498... | 0.0 | -1 |
Return True if the array a has a pair of digits which are identical but not part of a larger triple or greater | def has_exactly_doubles(a):
result = False
# nasty one, lots of edge cases
# ok, so we can walk through the case
in_double = False
poison = False
for idx in range(1, len(a)):
this_char = a[idx]
previous_char = a[idx - 1]
if this_char == previous_char:
# ok, it... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def contains_duplicate_2(self, array):\n nums = set()\n for num in array:\n if num in nums:\n return True\n nums.add(num)\n return False",
"def validateTriple(triple):\n\tA, B, pi = triple\n\tfor row in A:\n\t\tif abs(sum(row)-1.0) > .0001:\n\t\t\t return... | [
"0.68157136",
"0.6403129",
"0.63565165",
"0.6334886",
"0.6239469",
"0.6153332",
"0.61522675",
"0.6116675",
"0.6114608",
"0.60225683",
"0.5998087",
"0.59937114",
"0.59897363",
"0.5972122",
"0.5971514",
"0.5966528",
"0.59660816",
"0.59616125",
"0.5958073",
"0.59364897",
"0.5927... | 0.57394445 | 46 |
Displays statistics on the most frequent times of travel. | def time_stats(df):
print('\nCalculating The Most Frequent Times of Travel...\n')
start_time = time.time()
# TO DO: display the most common month
print('Which month is most common?')
popular_month = df['month'].mode()[0]
if popular_month == 1:
popular_month = "january"
elif popular... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def time_stats(df):\r\n\r\n print('\\nThese are the statistics of the most frequent times of travel:\\n')\r\n start_time = time.time()\r\n\r\n # Display the most common month\r\n common_month = df['month'].mode()[0]\r\n print(\"- That's the most common month based on your selection: \" +\r\n ... | [
"0.7974609",
"0.7851373",
"0.7800278",
"0.77821916",
"0.7775073",
"0.7762475",
"0.77532375",
"0.77384645",
"0.77262247",
"0.7718093",
"0.7685153",
"0.7683606",
"0.76808155",
"0.7679881",
"0.7650141",
"0.7644975",
"0.7643931",
"0.76428497",
"0.7629725",
"0.76246285",
"0.762423... | 0.0 | -1 |
Displays statistics on the most popular stations and trip. | def station_stats(df):
print('\nCalculating The Most Popular Stations and Trip...\n')
start_time = time.time()
# TO DO: display most commonly used start station
print('What is the popular start station?\n')
popular_start_station = df['Start Station'].mode()[0]
print('Most Popular start station... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def station_stats(df):\n\n print('\\033[1m' + 'Calculating the most popular stations and trip...\\n' + '\\033[0m')\n start_time = time.time()\n\n # display the most commonly used start station\n\n start_stn = df['Start Station'].mode()[0]\n print('Most popular start station is {}.'.format(start_stn)... | [
"0.7810401",
"0.76733434",
"0.75397694",
"0.74986017",
"0.74904644",
"0.7489439",
"0.7437456",
"0.74303514",
"0.74275905",
"0.74257994",
"0.74133176",
"0.7405224",
"0.7382788",
"0.737964",
"0.7374812",
"0.73664117",
"0.7356313",
"0.7352205",
"0.73247623",
"0.7305465",
"0.7298... | 0.73003286 | 20 |
Displays statistics on the total and average trip duration. | def trip_duration_stats(df):
print('\nCalculating Trip Duration...\n')
start_time = time.time()
# TO DO: display total travel time and mean time of Travel
print('what is the total time of travel and the mean time of travel?\n\n')
df['Start Time'] = pd.to_datetime(df['Start Time'])
df['End T... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def trip_duration_stats(df):\r\n\r\n print('\\nThese are the statistics related to the trips durations:\\n')\r\n start_time = time.time()\r\n\r\n # Display total travel time\r\n total_travel_time = df['Trip Duration'].sum()\r\n print(\"\\n- The total travel time based on your selection is: \" +\r\n ... | [
"0.8269694",
"0.8117981",
"0.804814",
"0.8046616",
"0.7977989",
"0.79627913",
"0.7959311",
"0.79460865",
"0.7936234",
"0.79295456",
"0.79275835",
"0.792675",
"0.79244053",
"0.791991",
"0.79156506",
"0.79151726",
"0.791299",
"0.79074097",
"0.7903686",
"0.79021114",
"0.7892094"... | 0.0 | -1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.