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 |
|---|---|---|---|---|---|---|
Load an image from file into a numpy array. Puts image into numpy array to feed into tensorflow graph. Note that by convention we put it into a numpy array with shape (height, width, channels), where channels=3 for RGB. | def load_image_into_numpy_array(self, path):
return np.array(Image.open(path)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_image_into_numpy_array(path):\n img_data = tf.io.gfile.GFile(path, 'rb').read()\n image = Image.open(BytesIO(img_data))\n (im_width, im_height) = image.size\n return np.array(image.getdata()).reshape(\n (im_height, im_width, 3)).astype(np.uint8)",
"def load_image(filename):\n im = ... | [
"0.78659755",
"0.7861697",
"0.77747613",
"0.77205914",
"0.7699286",
"0.767454",
"0.7561714",
"0.74691284",
"0.74643666",
"0.73706603",
"0.7249045",
"0.7197173",
"0.7168892",
"0.7087635",
"0.70575356",
"0.70345956",
"0.70195484",
"0.69729465",
"0.69144195",
"0.6882334",
"0.682... | 0.7452068 | 9 |
Takes an image and uses model (a trained TensorFlow model) to make a prediction. | def detect_fn(self, image_path):
request_body = self._get_json_input(image_path)
preds = self.predict_json(project=inferenceAPI.PROJECT,
region=inferenceAPI.REGION,
instances=request_body,
version = self.model_version)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def predict(model: str, image_name: str):\n Model = load_model.load_model()\n try:\n prediction = Model.predict(model_name=model, file=image_name)\n parr = \"model used: \" + model + \" \"\n logging.log(name=predict.__name__, result=prediction, parm=parr)\n return {\"Predict... | [
"0.7698371",
"0.7686347",
"0.76717275",
"0.76608413",
"0.76316744",
"0.7550953",
"0.75484556",
"0.75336397",
"0.75272596",
"0.743846",
"0.7426297",
"0.7334667",
"0.73179674",
"0.72683024",
"0.7263245",
"0.7247243",
"0.7231002",
"0.7213424",
"0.71534",
"0.71414787",
"0.7126263... | 0.0 | -1 |
encrypts a share given the provided shared key receiver_id added as argument to the hash function to ensure that shares from A>B and B>A are encrypted using a different key | def encrypt_share(share: int, receiver_id: int, shared_key: PointG1) -> int:
sx = shared_key[0]
hx = keccak_256(sx.to_bytes(32, "big") + receiver_id.to_bytes(32, "big")).digest()
return share ^ int.from_bytes(hx, "big") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __encrypt_symmetric_key_with_public_key(\n self, symmetric_key, encoded_public_key\n ):\n public_key = self.__decode_key(PublicKey, encoded_public_key)\n user_box = SealedBox(public_key)\n enc_key = user_box.encrypt(symmetric_key)\n return enc_key",
"def _hash(self, key)... | [
"0.563471",
"0.561582",
"0.5548968",
"0.55295044",
"0.5515818",
"0.546811",
"0.5466693",
"0.5458466",
"0.54471123",
"0.54060084",
"0.5384334",
"0.5371587",
"0.5349698",
"0.5331301",
"0.53306776",
"0.53276926",
"0.5323389",
"0.5318075",
"0.52703154",
"0.52600783",
"0.5217061",... | 0.8312542 | 0 |
Return settings as configured in the configlet | def getSettings():
registry = queryUtility(IRegistry)
if registry is None:
return None
return registry.forInterface(ISettings) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def config(self) -> Dict[str, Any]:\n return self._config",
"def settings(self):\r\n return self.application.settings",
"def settings(self):\r\n return self.application.settings",
"def configurations(self):\n return Configurations(self.connect, Template, User)",
"def get_setting... | [
"0.72954583",
"0.7277437",
"0.7277437",
"0.725997",
"0.7243983",
"0.7176749",
"0.7176749",
"0.7176749",
"0.7176749",
"0.71756893",
"0.7165986",
"0.70959747",
"0.707636",
"0.7028076",
"0.7027449",
"0.70253164",
"0.70161754",
"0.7011244",
"0.70102674",
"0.6990734",
"0.6990734",... | 0.0 | -1 |
Get raw data file. | def get_ap_file(self, path, key):
with open(path, 'r') as readfile:
data = json.load(readfile)
return data[key]['del'] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_raw_data(path: str):\n with open(path, \"r\") as f:\n return f.read()",
"def _get_raw_data(fname):\n\n path = _get_data_path(fname)\n\n if not os.path.isfile(path):\n _download()\n\n return codecs.open(path, 'r', encoding='utf-8')",
"def get_data(self):\n return self.fi... | [
"0.78954643",
"0.7578575",
"0.7419691",
"0.7368007",
"0.71787477",
"0.7043334",
"0.69938034",
"0.6984341",
"0.69817",
"0.69009596",
"0.6870263",
"0.6845593",
"0.6828915",
"0.6828915",
"0.6772758",
"0.67228127",
"0.67228127",
"0.67228127",
"0.67228127",
"0.6638676",
"0.663638"... | 0.0 | -1 |
Initiliazer for the bias. Generates random but constant bias for the weights. | def __init__(self, minval=0, maxval=None, seed=None, dtype=dtypes.float32):
self.minval = minval
self.maxval = maxval
self.seed = seed
self.dtype = dtypes.as_dtype(dtype) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def biasinitializer(self):\n def init(shape, rng, *a, **kw):\n return _np.zeros(shape)\n return init",
"def biasinitializer(self):\n def init(shape, *a, **kw):\n return _np.zeros(shape)\n return init",
"def biasinitializer(self):\n def init(shape, *a, **... | [
"0.77106947",
"0.7602397",
"0.7602397",
"0.7602397",
"0.74721456",
"0.7421492",
"0.7421492",
"0.73459893",
"0.7336251",
"0.72949386",
"0.7289175",
"0.7287018",
"0.7271561",
"0.7147211",
"0.70782983",
"0.705996",
"0.6939413",
"0.6912697",
"0.679017",
"0.6772831",
"0.6765018",
... | 0.0 | -1 |
Unpacks list type element (with 'list' column name attribute) into a list of dictionari | def unpackListElement(elem):
result = []
keywds = [x.strip() for x in elem.get('list').split(',')]
ncols = len(keywds)
if elem.text:
data = elem.text.split()
else:
data = []
if len(set(keywds)) == len(keywds):
# no duplicate keywords
nlines = len(data) // ncols
ind = 0
for ii in r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _unpack_lists(input_list):\r\n return [item[0] for item in input_list]\r\n # return [ast.literal_eval(item)[0] for item in input_list]\r",
"def extract_listpairs_fieldvalue(fieldvalue, val_cast = int, key_cast = int):\n return list((key_cast(k),val_cast(v)) for k,v in zbl_io.unpack_listpairs_field(f... | [
"0.6343996",
"0.6277087",
"0.60123163",
"0.5851322",
"0.5760527",
"0.5642267",
"0.5582689",
"0.5578201",
"0.557134",
"0.5570546",
"0.55663127",
"0.55358285",
"0.552562",
"0.5522733",
"0.5516093",
"0.55026567",
"0.5487035",
"0.546865",
"0.5463905",
"0.5435344",
"0.5427386",
... | 0.6981333 | 0 |
Get JSON object representation. | def getJsonableObject(self):
raise NotImplementedError() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getJSON(self):\r\n \r\n return json.dumps(self.__dict__)",
"def getJSON(self):\n return json.dumps(self)",
"def get_json(self):\n return json.dumps(self.__dict__)",
"def json(self):\n return json.dumps(self.get_dict())",
"def jsonify(self):\n jsonObject = self.... | [
"0.8490764",
"0.83273536",
"0.8325055",
"0.8277134",
"0.82571566",
"0.81908685",
"0.8100712",
"0.8068618",
"0.8057305",
"0.8015479",
"0.7952224",
"0.7917042",
"0.7909419",
"0.78909624",
"0.7834087",
"0.7815498",
"0.7805965",
"0.7805965",
"0.7805965",
"0.7805965",
"0.7805965",... | 0.0 | -1 |
Return interviews where current user is participated. | def get_queryset(self):
current_user = self.request.user
params = self.kwargs
company = get_object_or_404(Company, pk=params['company_pk'])
queryset = Interview.objects.filter(
Q(candidate=current_user) |
Q(interviewees__in=[current_user.id]),
vacancy... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def participants(self):\n return (\n self.eventparticipant_set.filter(going=True)\n .exclude(type=EventParticipant.ORGANIZER)\n .select_related(\"user\")\n )",
"def current_actors(self):\n return self.participants.filter(initiative=self.current_initiative)",
... | [
"0.59546024",
"0.595287",
"0.57663095",
"0.5559573",
"0.5554289",
"0.55353576",
"0.54983115",
"0.5490366",
"0.54478866",
"0.5375219",
"0.5369827",
"0.5319649",
"0.5269346",
"0.52454805",
"0.52280766",
"0.5210841",
"0.51905876",
"0.51331025",
"0.51045233",
"0.5101073",
"0.5097... | 0.6037128 | 0 |
Read dataset by specifying additional na values to recognize and columns to remove rows with na cells | def load_and_preprocess_data(file_name: str, target_columns: List[str]) -> pd.DataFrame:
df = pd.read_csv(file_name, na_values='na')
df.dropna(subset=target_columns, inplace=True)
return df | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clean_dataset(dataset):\n dataset = dataset.dropna()\n return dataset",
"def remove_nan_rows(self, collist):\n\n try:\n new_df = self.df\n numberofNa = new_df[collist].isnull().sum()\n new_df = new_df.dropna(subset=collist)\n logging.info('Cleaned NaN rows from {} columns.'.forma... | [
"0.6765163",
"0.66973263",
"0.65904737",
"0.652521",
"0.6356947",
"0.63246334",
"0.6323753",
"0.62690204",
"0.6208949",
"0.6184554",
"0.6170129",
"0.61618304",
"0.612701",
"0.6102346",
"0.60448444",
"0.6025004",
"0.59932196",
"0.5990632",
"0.5981095",
"0.5968468",
"0.5961914"... | 0.57303125 | 34 |
Creating About window containing info about the app. | def about(self):
logging.info("Opened ''About''")
self.win = About()
self.win.exec_() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def about_window():\n about.About_Window()",
"def about():\r\n db.About(main_window)",
"def onAboutClicked(self):\n WalkLibraryUI.aboutWin = AboutWindow()\n WalkLibraryUI.aboutWin.showUI()",
"def show_about_dialog(self, _):\n\n about_dialog = Gtk.AboutDialog()\n abou... | [
"0.84198415",
"0.8000213",
"0.7800736",
"0.77822125",
"0.7756718",
"0.77485156",
"0.770609",
"0.7679952",
"0.76280814",
"0.7616372",
"0.7603535",
"0.76020277",
"0.75293803",
"0.7528434",
"0.7525125",
"0.74823207",
"0.7422989",
"0.7422989",
"0.7422989",
"0.7422989",
"0.7422989... | 0.809665 | 1 |
Stops the current playing song. | def stop(self):
logging.info("Stopping the track.")
self.player.stop()
self.time_bar.setValue(0)
self.lb_time.setText("0:0 / 0:0")
if self.settings["style"] == "normal":
self.set_btn_icon([self.btn_play], [self.appctxt.get_resource("icons/normal/play.png")])
e... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def media_player_stop_song(self):\n self._send_key(86) # stop",
"def _stop(self):\n try:\n self.player.stop()\n except:\n pass\n self.playing = None\n self._clean()",
"def media_player_stop_song(self):\n pass",
"def stop_music(self, event):\n ... | [
"0.81305933",
"0.77901334",
"0.77622896",
"0.7675222",
"0.7657071",
"0.7633419",
"0.7599263",
"0.7577521",
"0.75607055",
"0.75246865",
"0.7503647",
"0.74905246",
"0.74890494",
"0.74443734",
"0.74009776",
"0.73972523",
"0.7370144",
"0.73538864",
"0.7343094",
"0.72550917",
"0.7... | 0.74647146 | 13 |
Given a vector of alphas, compute the primal weight vector. | def weight_vector(x, y, alpha):
w = zeros(len(x[0]))
temp = np.array(np.multiply(
np.matrix(np.multiply(alpha, y)).T, np.matrix(x)))
for i in range(len(x)):
w += temp[i, :]
return w | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def weight_vector(x, y, alpha):\n\n w = zeros(len(x[0]))\n\n # w = alpha * y * x\n for i, (alphav, yv) in enumerate(zip(alpha, y)):\n for j, xv in enumerate(x[i]):\n w[j] += alphav * yv * xv\n\n return w",
"def layer_weights(alphas):\n return alphas * layer_visibility(alphas)",
"... | [
"0.64374995",
"0.60425085",
"0.5929849",
"0.57444084",
"0.5690551",
"0.56418",
"0.55996644",
"0.5569063",
"0.5568763",
"0.55606174",
"0.5550427",
"0.5536265",
"0.55356413",
"0.5511618",
"0.5503406",
"0.55005914",
"0.5489969",
"0.5488274",
"0.5487809",
"0.5478734",
"0.5464777"... | 0.611956 | 1 |
Sets the media_item_id of this MediaItem. | def media_item_id(self, media_item_id):
self._media_item_id = media_item_id | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def media_id(self, media_id):\n\n self._media_id = media_id",
"def item_id(self, item_id):\n\n self._item_id = item_id",
"def item_id(self, item_id):\n if item_id is None:\n raise ValueError(\"Invalid value for `item_id`, must not be `None`\")\n\n self._item_id = item_id"... | [
"0.7558818",
"0.72207487",
"0.6978869",
"0.6698099",
"0.61738336",
"0.60212743",
"0.5964754",
"0.58038014",
"0.55031544",
"0.54754555",
"0.54754555",
"0.5424819",
"0.53899807",
"0.5333818",
"0.532378",
"0.5238865",
"0.5238865",
"0.5238865",
"0.5229973",
"0.52142894",
"0.52054... | 0.9049416 | 0 |
Sets the descriptor of this MediaItem. | def descriptor(self, descriptor):
self._descriptor = descriptor | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def descriptor(self, descriptor: str):\n\n self._descriptor = descriptor",
"def descriptor_value(self, descriptor_value: str):\n\n self._descriptor_value = descriptor_value",
"def add_media_field(self, name, descriptor):\n # Defer import to prevent circular dependency\n from beets i... | [
"0.6879821",
"0.5951572",
"0.56532365",
"0.5438246",
"0.542281",
"0.5420066",
"0.5416042",
"0.5390641",
"0.5363436",
"0.535512",
"0.5342384",
"0.53150845",
"0.5291048",
"0.5291048",
"0.5286114",
"0.5264058",
"0.5241686",
"0.5191431",
"0.5191431",
"0.5173624",
"0.5159734",
"... | 0.684087 | 1 |
Sets the sharding of this MediaItem. | def sharding(self, sharding):
self._sharding = sharding | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def shard_id(self, shard_id):\n\n self._shard_id = shard_id",
"def set_shard_dimension(self, shard_dimension):\n if self._frozen:\n if self._shard_dimension != shard_dimension:\n raise ValueError(\n \"Can't set shard dimension to %d since it has been frozen to \"\n \"u... | [
"0.6593863",
"0.59646094",
"0.5848748",
"0.539681",
"0.5189311",
"0.51364046",
"0.5068846",
"0.50352585",
"0.49558023",
"0.48652235",
"0.48613772",
"0.47254044",
"0.46811643",
"0.4680495",
"0.46324104",
"0.46181342",
"0.4601996",
"0.45903483",
"0.4586982",
"0.45756438",
"0.45... | 0.7651323 | 0 |
Sets the image of this MediaItem. | def image(self, image):
self._image = image | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_image(self, image):\n self.image = image",
"def set_image(self, image):\r\n raise NotImplementedError",
"def setImage(self):\n item = self.Listbox.currentItem().text().split(\":\")[0]\n fname = f\"images/{item}.png\"\n if os.path.isfile(fname):\n pixmap = Q... | [
"0.7883231",
"0.7344503",
"0.73280823",
"0.71865207",
"0.7034917",
"0.701262",
"0.69616836",
"0.6937512",
"0.6931354",
"0.6930499",
"0.6929661",
"0.6913242",
"0.6794965",
"0.66930354",
"0.66024506",
"0.65933424",
"0.6520973",
"0.63254863",
"0.6263272",
"0.625517",
"0.62255067... | 0.69825566 | 7 |
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.8602374",
"0.85093755",
"0.8237104",
"0.8050309",
"0.80128866",
"0.79348034",
"0.78766525",
"0.77898884",
"0.7786461",
"0.7745792",
"0.7627315",
"0.76055235",
"0.757999",
"0.7514394",
"0.75038797",
"0.75035286",
"0.74850684",
"0.7440529",
"0.74325883",
"0.74239755",
"0.740... | 0.0 | -1 |
Returns true if both objects are not equal | def __ne__(self, other):
if not isinstance(other, MediaItem):
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.8410411",
"0.8391477",
"0.8172175",
"0.81410587",
"0.80920255",
"0.8088807",
"0.80676955",
"0.8042487",
"0.8042487",
"0.8042487",
"0.8042487",
"0.8042487",
"0.8042487",
"0.8042487",
"0.8042487",
"0.8042487",
"0.8042487",
"0.8042487",
"0.8042487",
"0.8042487",
"0.8042487",
... | 0.0 | -1 |
Checks if x looks like a FASTA label line. | def is_fasta_label(x):
return x.startswith('>') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def label_check(in_str):\n #TODO\n return True",
"def test_label(self):\n k, v = self.sym.parse_label('2 3 12 0 1 1 1 0 foobar')\n # values of 1 aren't used by parser\n self.assertEqual(k, 'label')\n self.assertEqual(v.type, 'label')\n self.assertEqual((v.x, v.y), (2, 3))... | [
"0.6486298",
"0.61633533",
"0.6125523",
"0.6068589",
"0.6017038",
"0.6017038",
"0.59959024",
"0.5985124",
"0.5957307",
"0.59481335",
"0.5886572",
"0.5858996",
"0.5796002",
"0.57645166",
"0.5689082",
"0.56579053",
"0.5611983",
"0.554851",
"0.55360204",
"0.55323035",
"0.5503343... | 0.7870896 | 0 |
Checks if x is blank or a FASTA comment line. | def is_blank_or_comment(x):
return (not x) or x.startswith('#') or x.isspace() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _is_an_empty_line(self, line):\n if len(line) == 0:\n return True\n if line[0] == \"#\": # It is a comment\n return True\n return False",
"def _rule(line):\n return not (_empty(line) or _comment(line))",
"def _comment(line):\n return line.startswith(\"#\")",
... | [
"0.76346916",
"0.71290505",
"0.70618385",
"0.7058893",
"0.7058893",
"0.7042813",
"0.6939018",
"0.6936035",
"0.69202274",
"0.69092387",
"0.6900273",
"0.681404",
"0.67844325",
"0.673929",
"0.66532505",
"0.65858185",
"0.6548426",
"0.6538742",
"0.65172607",
"0.65136254",
"0.65069... | 0.8125432 | 0 |
A MetaLinear layer. Applies the same functionality of a standard linearlayer with the added functionality of being able to receive a parameter dictionary at the forward pass which allows the convolution to use external weights instead of the internal ones stored in the linear layer. Useful for inner loop optimization i... | def __init__(self, in_features, out_features, use_bias=True):
super(MetaLinearLayer, self).__init__()
self.use_bias = use_bias
self.weights = nn.Parameter(torch.ones(out_features, in_features))
nn.init.xavier_uniform_(self.weights)
if self.use_bias:
self.bias = nn.Pa... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, num_in_filters, num_out_filters, use_bias, activation):\n super(MetaLinearLayer, self).__init__()\n self.use_bias = use_bias\n self.weights = nn.Parameter(torch.ones(num_out_filters, num_in_filters))\n nn.init.xavier_uniform_(self.weights)\n if self.use_bias:\n... | [
"0.6338094",
"0.56937116",
"0.5681309",
"0.5681309",
"0.5629101",
"0.56058663",
"0.55561715",
"0.55274695",
"0.5500678",
"0.5491265",
"0.54907024",
"0.5443231",
"0.54309916",
"0.5418113",
"0.5411106",
"0.54005146",
"0.5399592",
"0.53783053",
"0.53598666",
"0.53467584",
"0.531... | 0.61330694 | 1 |
Raise a StopIteration if the normal stop condition is met. Raise an AbnormalStopIteration if the abnormal stop condition is met. | def _check_stop_conditions(self):
self.normal_stop_condition(self)
try:
self.abnormal_stop_condition(self)
except StopIteration as e:
raise AbnormalStopIteration(e) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _check_stop_iteration_inside_generator(self, node):\n frame = node.frame()\n if not isinstance(frame, astroid.FunctionDef) or not frame.is_generator():\n return\n if utils.node_ignores_exception(node, StopIteration):\n return\n if not node.exc:\n ret... | [
"0.691626",
"0.6666252",
"0.64234143",
"0.63916814",
"0.6309626",
"0.6260447",
"0.6132417",
"0.60145813",
"0.5966444",
"0.59367174",
"0.59171796",
"0.58726096",
"0.5852172",
"0.5848818",
"0.5815448",
"0.5696608",
"0.56697315",
"0.5656545",
"0.5636637",
"0.5626481",
"0.5616736... | 0.77545613 | 0 |
Return a readable representation for use with eg. select widgets. | def label_from_instance(self, obj):
desc = smart_unicode(obj)
ident = smart_unicode(self.to_native(obj))
if desc == ident:
return desc
return "%s - %s" % (desc, ident) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __repr__(self):\n if not self._obj_strings:\n return '<Select (no data loaded)>'\n\n if len(self._obj_strings) == 1:\n return '<Select {0}>'.format(self._obj_strings[0])\n\n return '<Select ({0} sources):\\n {1}>'.format(\n len(self._obj_strings),\n ... | [
"0.73406893",
"0.68944657",
"0.6789946",
"0.66376805",
"0.66243005",
"0.6594826",
"0.6587387",
"0.6530298",
"0.65274423",
"0.6525591",
"0.6511471",
"0.64462274",
"0.64222383",
"0.6416284",
"0.6395762",
"0.639442",
"0.6385234",
"0.63754374",
"0.63753194",
"0.63753194",
"0.6375... | 0.0 | -1 |
Return a readable representation for use with eg. select widgets. | def label_from_instance(self, obj):
desc = smart_unicode(obj)
ident = smart_unicode(self.to_native(obj.pk))
if desc == ident:
return desc
return "%s - %s" % (desc, ident) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __repr__(self):\n if not self._obj_strings:\n return '<Select (no data loaded)>'\n\n if len(self._obj_strings) == 1:\n return '<Select {0}>'.format(self._obj_strings[0])\n\n return '<Select ({0} sources):\\n {1}>'.format(\n len(self._obj_strings),\n ... | [
"0.73406893",
"0.68944657",
"0.6789946",
"0.66376805",
"0.66243005",
"0.6594826",
"0.6587387",
"0.6530298",
"0.65274423",
"0.6525591",
"0.6511471",
"0.64462274",
"0.64222383",
"0.6416284",
"0.6395762",
"0.639442",
"0.6385234",
"0.63754374",
"0.63753194",
"0.63753194",
"0.6375... | 0.0 | -1 |
Return a readable representation for use with eg. select widgets. | def label_from_instance(self, obj):
desc = smart_unicode(obj)
ident = smart_unicode(self.to_native(obj.pk))
if desc == ident:
return desc
return "%s - %s" % (desc, ident) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __repr__(self):\n if not self._obj_strings:\n return '<Select (no data loaded)>'\n\n if len(self._obj_strings) == 1:\n return '<Select {0}>'.format(self._obj_strings[0])\n\n return '<Select ({0} sources):\\n {1}>'.format(\n len(self._obj_strings),\n ... | [
"0.73406893",
"0.68944657",
"0.6789946",
"0.66376805",
"0.66243005",
"0.6594826",
"0.6587387",
"0.6530298",
"0.65274423",
"0.6525591",
"0.6511471",
"0.64462274",
"0.64222383",
"0.6416284",
"0.6395762",
"0.639442",
"0.6385234",
"0.63754374",
"0.63753194",
"0.63753194",
"0.6375... | 0.0 | -1 |
Setup the default logging stream to an internal StringIO instance, so that we can examine log output as we want. | def setUp(self):
logger_dict = logging.getLogger().manager.loggerDict
logging._acquireLock()
try:
self.saved_handlers = logging._handlers.copy()
self.saved_handler_list = logging._handlerList[:]
self.saved_loggers = logger_dict.copy()
self.s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setup(logging_file_str=None, log_file=None):\n global logging_file\n assert (logging_file_str is None or log_file is None), \"Either logging_file_str or log_file must be None.\"\n assert (logging_file_str is not None or log_file is not None),\\\n \"One of logging_file_str or log_file must be no... | [
"0.6614043",
"0.65590096",
"0.64627767",
"0.6454704",
"0.64531136",
"0.6391567",
"0.6320912",
"0.6303769",
"0.6296272",
"0.62706494",
"0.626333",
"0.62575185",
"0.6203383",
"0.61978966",
"0.61570984",
"0.61047417",
"0.61033964",
"0.60849714",
"0.60630846",
"0.60178995",
"0.60... | 0.64611936 | 3 |
Remove our logging stream, and restore the original logging level. | def tearDown(self):
self.stream.close()
self.root_logger.removeHandler(self.root_hdlr)
while self.root_logger.handlers:
h = self.root_logger.handlers[0]
self.root_logger.removeHandler(h)
h.close()
self.root_logger.setLevel(self.original_logging_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def undo_logger_setup():\n root_logger.removeHandler(handler)\n gym.logger.setLevel(logging.NOTSET)",
"def remove(self, level, logger):\n self.config[level].discard(logger)\n logger.close()",
"def stop_logging(self):\n self.file_handler.close()\n self.file_logger.handlers.clea... | [
"0.70798105",
"0.6767343",
"0.67070276",
"0.67025614",
"0.65677726",
"0.6530929",
"0.6422761",
"0.63771135",
"0.6296096",
"0.6241451",
"0.6233145",
"0.6230229",
"0.6216796",
"0.6059935",
"0.60186285",
"0.6014685",
"0.59408104",
"0.58669436",
"0.58594954",
"0.58557874",
"0.584... | 0.67208314 | 2 |
This function creates the resnet50 relation network | def create_resnet_relation_net(self, scope_name="relation_resnet50"):
with tf.variable_scope(scope_name):
self.output_resnet50_relation, end_points = resnet_v2_50(self.relation_inputs_ph, num_classes=100)
N = tf.slice(tf.shape(self.entity_inputs_ph), [0], [1], name="N_relation")
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _init_create_networks(self):\n backbone = BackBone(self._opt)\n output_sizes = [self._output_size_per_task[x] for x in self._opt.tasks]\n output_feature_dim = backbone.output_feature_dim\n classifiers = [Head(output_feature_dim, self._opt.hidden_size, output_sizes[i]) for i in range... | [
"0.75844723",
"0.6856573",
"0.6713875",
"0.6636712",
"0.6629446",
"0.66153145",
"0.6525673",
"0.64792484",
"0.64791226",
"0.6463004",
"0.6448483",
"0.64436996",
"0.6404706",
"0.6400446",
"0.6385761",
"0.63790756",
"0.6368492",
"0.6349486",
"0.63419884",
"0.63225347",
"0.63225... | 0.77012724 | 0 |
This function creates the resnet50 entity network | def create_resnet_entity_net(self, scope_name="entity_resnet50"):
with tf.variable_scope(scope_name):
self.output_resnet50_entity, end_points = resnet_v2_50(self.entity_inputs_ph, num_classes=300)
N = tf.slice(tf.shape(self.entity_inputs_ph), [0], [1], name="N_entity")
M = tf... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _init_create_networks(self):\n backbone = BackBone(self._opt)\n output_sizes = [self._output_size_per_task[x] for x in self._opt.tasks]\n output_feature_dim = backbone.output_feature_dim\n classifiers = [Head(output_feature_dim, self._opt.hidden_size, output_sizes[i]) for i in range... | [
"0.6960315",
"0.69569176",
"0.6930094",
"0.6594813",
"0.6506344",
"0.64251065",
"0.63735557",
"0.63483894",
"0.6334298",
"0.6312453",
"0.6312163",
"0.62920237",
"0.627473",
"0.62579113",
"0.62518257",
"0.6245853",
"0.6170803",
"0.6152045",
"0.6152045",
"0.6152045",
"0.6147923... | 0.77050245 | 0 |
ResNet50 model of [1]. See resnet_v2() for arg and return description. | def resnet_v2_18(self, inputs,
num_classes=None,
is_training=True,
global_pool=True,
output_stride=None,
spatial_squeeze=True,
reuse=None,
scope='resnet_v2_50'):
blo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def resnet50(self):\n\n base_model = ResNet50(weights=self.weights, include_top=self.include_top,\n pooling=self.pooling)\n x = base_model.layers[-1]\n out = Dense(units=self.num_classes, activation=self.activation, name='output',\n use_bias=True... | [
"0.7780199",
"0.7447661",
"0.74412704",
"0.74412704",
"0.74412704",
"0.74398273",
"0.72743595",
"0.7271733",
"0.7248632",
"0.72014797",
"0.71903265",
"0.71903265",
"0.7167613",
"0.7167613",
"0.7167613",
"0.7075395",
"0.706199",
"0.7058464",
"0.7050073",
"0.70314723",
"0.69725... | 0.0 | -1 |
Helper function for creating a resnet_v2 bottleneck block. | def resnet_v2_block(self, scope, base_depth, num_units, stride):
return resnet_utils.Block(scope, self.bottle, [{
'depth': base_depth * 1,
'depth_bottleneck': base_depth,
'stride': 1
}] * (num_units - 1) + [{
'depth': base_depth * 1,
'depth_bot... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, block_name, in_dim, out_dim, radius, layer_ind, config):\n super(GraphResnetBottleneckBlock, self).__init__()\n\n # Get other parameters\n self.bn_momentum = config.batch_norm_momentum\n self.use_bn = config.use_batch_norm\n self.block_name = block_name\n ... | [
"0.61518556",
"0.61413914",
"0.6138519",
"0.6108494",
"0.6108063",
"0.60825807",
"0.60636705",
"0.59943223",
"0.59849626",
"0.5953491",
"0.5951686",
"0.5950446",
"0.5869077",
"0.5867221",
"0.5843587",
"0.5836809",
"0.5799749",
"0.57901806",
"0.5731104",
"0.5699163",
"0.569910... | 0.7243921 | 0 |
Casting to IamDataFrame and returning as `timeseries()` yields original frame | def test_init_df(test_pd_df, index):
# set a value to `nan` to check that timeseries columns are ordered correctly
test_pd_df.loc[0, test_pd_df.columns[5]] = np.nan
# any number of columns can be set as index
df = test_pd_df.copy() if index is None else test_pd_df.set_index(index)
obs = IamDataFra... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def datetime_frame() -> DataFrame:\n return DataFrame(tm.getTimeSeriesData())",
"def get_time_series(self):\n pass",
"def fixture_time_series_df():\n return pd.read_csv('tests/time-series.csv',\n dtype={\n 'timestamp': 'float64',\n ... | [
"0.69285536",
"0.65236884",
"0.64515543",
"0.6237191",
"0.6226743",
"0.62148273",
"0.62127537",
"0.61629176",
"0.6161151",
"0.6157798",
"0.61501426",
"0.6112416",
"0.61075175",
"0.6091285",
"0.60784936",
"0.6032844",
"0.60125005",
"0.6007545",
"0.599542",
"0.5983716",
"0.5973... | 0.0 | -1 |
2D autocorrelation remove mean perpatch (not global GT) normalize stddev to 1 | def autocorrelation(x):
x = (x - np.mean(x))/np.std(x)
# x = np.pad(x, [(50,50),(50,50)], mode='constant')
f = fft2(x)
p = np.abs(f)**2
pi = ifft2(p)
pi = np.fft.fftshift(pi)
return pi.real | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def normalized_autocorrelation(image: np.array) -> np.array:\n\n if len(image.shape) != 2:\n raise ValueError(\"image must be a 2D array\")\n\n image = image - np.mean(image)\n autocorrelation = signal.correlate2d(image, image, mode=\"same\")\n\n if np.max(autocorrelation) == 0:\n raise V... | [
"0.65011996",
"0.6043661",
"0.5792551",
"0.5667877",
"0.55571985",
"0.5520611",
"0.55054307",
"0.5479623",
"0.547551",
"0.5467136",
"0.5440156",
"0.542377",
"0.54011416",
"0.53883076",
"0.5385465",
"0.538223",
"0.5377617",
"0.5342362",
"0.5328077",
"0.5318414",
"0.5283257",
... | 0.561103 | 4 |
Initialize a new ``WrappingLogFormatter``. | def __init__(self, format=None, date_format=None, max_width=79):
self.wrapper = textwrap.TextWrapper(width=max_width,
subsequent_indent=' ')
logging.Formatter.__init__(self, format, date_format) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, fmt: str = \"\", use_color: bool = True):\n logging.Formatter.__init__(self, fmt)\n self._use_color = use_color",
"def __init__(self, log_file=None, timestamp=False):\n PlainTextFormatter.__init__(self)\n # Initialise here so that there is always one when we start l... | [
"0.67641026",
"0.672637",
"0.61740506",
"0.6139211",
"0.6136671",
"0.61284405",
"0.6120142",
"0.6110043",
"0.607943",
"0.5992726",
"0.5987453",
"0.59255826",
"0.5921138",
"0.5883652",
"0.58753484",
"0.58684164",
"0.5859159",
"0.58383924",
"0.58156943",
"0.5809715",
"0.58092",... | 0.7998826 | 0 |
Lists all registered customers | def get(self):
return get_all_customers()
'''
@api.doc('delete_all_leads')
@token_required
@api.doc(security='apikey')
@api.doc('delete all leads')
def delete(self):
""" Deletes all leads """
delete_all_leads()
return "all leads deleted"
'... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list(self, **params):\n\n _, _, customers = self.http_client.get(\"/customers\", params=params)\n return customers",
"def see_customer_list(self):\n customer_list = self._customer_service.get_customer_list()\n self._system.clear_screen()\n print(\"\\t ___ _ ... | [
"0.8136927",
"0.7866159",
"0.7851061",
"0.7658823",
"0.744478",
"0.7390663",
"0.7372647",
"0.73345804",
"0.715048",
"0.6997396",
"0.6948954",
"0.68553585",
"0.6847724",
"0.67764795",
"0.6753757",
"0.6612843",
"0.654855",
"0.6547148",
"0.6513467",
"0.64660156",
"0.6447025",
... | 0.0 | -1 |
Construct the LargeSpaces object. A LargeSpaces object stores all relevant data and provides routines to divide spaces into occupied and virtual as well as into sub spaces and the recombination of these subspaces. | def __init__(self, settings_dict: Optional[Dict[str, Any]] = None):
self.seed: Optional[int] = None
"""sets the seed for np.random. Should not be modified."""
self.max_orbitals: int = 20
"""maximum number of orbitals per active space. Active spaces contain the same number of orbitals."""... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, size, large_size=40, scale=0.1):\n self.size = size\n self.large_size = large_size\n # scale is size of each grid cell\n self.scale = 0.1\n self.small_num_cells = math.ceil(self.size / self.scale)\n self.small_map = np.zeros([self.small_num_cells, self.s... | [
"0.609436",
"0.5928205",
"0.5834363",
"0.55863315",
"0.552484",
"0.55021083",
"0.5494944",
"0.5494541",
"0.5480311",
"0.5479469",
"0.5446498",
"0.5436853",
"0.5417309",
"0.5399051",
"0.5393325",
"0.533114",
"0.5330615",
"0.532071",
"0.53107125",
"0.53070927",
"0.5300227",
"... | 0.0 | -1 |
Separate the valence active space into occupied and virtual orbitals. The information for the separation is provided by an ActiveSpace and Molecule object. | def separate_space(self, cas: ActiveSpace, molecule: Molecule) -> Tuple[List[int], List[int]]:
occupied_orbitals = []
virtual_orbitals = []
for i in cas.orbital_indices:
if molecule.occupation[i] == 0:
virtual_orbitals.append(i)
else:
occup... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_spaces(self):\r\n self.V = VectorElement(self.u_element[0], self.mesh.ufl_cell(), self.u_element[1])\r\n self.INC = FiniteElement(self.inc_element[0], self.mesh.ufl_cell(), self.inc_element[1])\r\n self.ETVF = FiniteElement(self.etvf_element[0], self.mesh.ufl_cell(), self.etvf_element[... | [
"0.5663804",
"0.5433354",
"0.5406641",
"0.5399771",
"0.5042621",
"0.4992",
"0.48929492",
"0.48250532",
"0.48112178",
"0.4785049",
"0.4778039",
"0.47731423",
"0.47712502",
"0.47590992",
"0.47455353",
"0.47441152",
"0.47024998",
"0.46515834",
"0.4636008",
"0.46274117",
"0.46174... | 0.7018494 | 0 |
Returns a config loaded from the path specified. Ideally, this config is readonly. However, there will be no restrictions placed, so the user can modify and save the config if it wishes | def load_config(path):
class LoadedConfig(Config):
"""
Helper class to act as the config for the specified path
"""
def rel_filepath(self) -> str:
return path
@classmethod
def config_map(cls):
return {}
return LoadedConfig() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get(self, path):\n\n config = get_config(self.config, path)\n\n return config",
"def get_config():\r\n cfg = eval(open(config_path).read())\r\n return cfg",
"def _get_config(path: str) -> configparser.ConfigParser:\n config = configparser.ConfigParser()\n config.read(path)\n\n ... | [
"0.8225621",
"0.77862054",
"0.7728976",
"0.77269",
"0.7681481",
"0.74454325",
"0.74099255",
"0.7385947",
"0.72657055",
"0.72610855",
"0.7241277",
"0.716828",
"0.7159496",
"0.71465033",
"0.704885",
"0.7044989",
"0.70386803",
"0.69795233",
"0.6971736",
"0.69558877",
"0.69550943... | 0.7315384 | 8 |
pick one value at random according to probabilities proportional to values. | def random_choice(values, size=1):
values_normalized = values / values.sum()
values_normalized_with0 = np.zeros(len(values) + 1)
values_normalized_with0[1:] = values_normalized
choice = np.where(values_normalized_with0.cumsum() > np.random.rand())[0][0] - 1
return choice | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pick(self, prob):\n return _pythia8.Rndm_pick(self, prob)",
"def prob_choose(choices, probs):\r\n\r\n ae_list = []\r\n for chi in range(len(choices)):\r\n ae_list += [choices[chi]] * int(probs[chi] * 1000)\r\n choice = np.random.choice(ae_list)\r\n\r\n return choice",
"def weighte... | [
"0.7363526",
"0.7266788",
"0.7238834",
"0.7181584",
"0.71409583",
"0.70162034",
"0.6999639",
"0.6995804",
"0.69581807",
"0.6794771",
"0.678703",
"0.6786408",
"0.6776476",
"0.6765008",
"0.6752559",
"0.6722586",
"0.6695014",
"0.6680775",
"0.6672298",
"0.6667695",
"0.6621603",
... | 0.6598921 | 23 |
Computes the loss function of a given mapping. This is the 'energy_function' of simulated annealing. | def loss_function(mapping12):
global dm1, dm2
loss = np.linalg.norm(dm1[np.triu_indices(size1)] - dm2[mapping12[:,None], mapping12][np.triu_indices(size1)])
return loss | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute_loss(self, loss_fn, output, target):\n return loss_fn(output, target)",
"def compute_loss(self, loss_fn, output, target):\n\n return loss_fn(output, target.long())",
"def apply_edge_weights(\n self, loss_matrix: torch.Tensor, weight_map: torch.Tensor\n ) -> torch.Tensor:\n ... | [
"0.60675293",
"0.5950823",
"0.5943313",
"0.59000057",
"0.5882182",
"0.58434844",
"0.5763717",
"0.57503474",
"0.57450056",
"0.5718299",
"0.5717941",
"0.56917405",
"0.5685436",
"0.56802344",
"0.5666036",
"0.5664754",
"0.5618865",
"0.56024355",
"0.5571781",
"0.55675364",
"0.5532... | 0.68344027 | 0 |
Since this type is immutable, we don't need to deepcopy it. Actually deep copying would intefere with the use of deepcopy by JsonObjectWrapper. | def __deepcopy__(self, memo):
return self | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def copy(self) -> 'JSONData':\n\n return type(self)(self.data)",
"def __copy__(self):\n return self.copy()",
"def copy(self):\r\n from copy import deepcopy\r\n return deepcopy(self)",
"def deepcopy(self):\n return deepcopy(self)",
"def deepcopy(self):\n return self... | [
"0.6967058",
"0.6286319",
"0.6224412",
"0.620475",
"0.6197305",
"0.6187282",
"0.6187282",
"0.61712295",
"0.6114789",
"0.6074695",
"0.6074695",
"0.60693127",
"0.6066071",
"0.60614663",
"0.60524035",
"0.60174286",
"0.60174286",
"0.60174286",
"0.6014638",
"0.6012048",
"0.6012048... | 0.0 | -1 |
Splits array of 2D vectors into 5 arrays, listed below. xcomponent ycomponent magnitude sine of direction cosine of direction N = number of vectors | def _split_vector_column(input_table, conversion_factor=1.):
input_column = list(input_table)[0]
num_vectors = len(input_table.index)
x_components = numpy.full(num_vectors, numpy.nan)
y_components = numpy.full(num_vectors, numpy.nan)
for i in range(num_vectors):
x_components[i] = input_tab... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def unit_vectors(exif_obj):\n camera_yaw = exif_obj[\"camera_yaw\"]\n lat, lon = exif_obj[\"img_lat\"], exif_obj[\"img_lon\"]\n declination = geomag.declination(lat, lon)\n camera_yaw += declination # compensate for magnetic variation\n alpha = camera_yaw * np.pi / 180\n n = [-np.cos(alpha), -np... | [
"0.59873825",
"0.5952881",
"0.5715054",
"0.558125",
"0.5555606",
"0.5530053",
"0.549663",
"0.54628086",
"0.538554",
"0.5357635",
"0.53491247",
"0.5343268",
"0.52715015",
"0.52529687",
"0.5250628",
"0.5238442",
"0.5234016",
"0.52248955",
"0.52165705",
"0.52079415",
"0.5204662"... | 0.54249555 | 8 |
Replaces sentinel values with NaN. | def _sentinels_to_nan(statistic_table_sharppy, metadata_table):
statistic_names_sharppy = metadata_table[
SHARPPY_STATISTIC_NAME_COLUMN].values.tolist()
num_soundings = len(statistic_table_sharppy.index)
for this_name in list(statistic_table_sharppy):
if this_name not in statistic_names_sh... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def replace_nans(self) -> None:\n self.data.replace(self.nan_value, np.nan, inplace=True)",
"def fix_empty_values(self, df):\n return df.replace([None, \"\", \"nan\"], np.NaN)",
"def set_nan_or_inf_to_zero( array ):\n array[ np.isinf( array ) + np.isnan( array ) ] = 0\n \n return array",... | [
"0.7602672",
"0.70684284",
"0.6951822",
"0.684728",
"0.6751075",
"0.67479306",
"0.67359775",
"0.67032087",
"0.6628438",
"0.6619945",
"0.6615053",
"0.6599673",
"0.6580057",
"0.64921314",
"0.64915586",
"0.6466795",
"0.6462592",
"0.6457376",
"0.6378782",
"0.63741475",
"0.6371239... | 0.0 | -1 |
Adds vector suffix to statistic name. | def add_vector_suffix_to_stat_name(basic_statistic_name, vector_suffix):
error_checking.assert_is_string(vector_suffix)
error_checking.assert_is_string(basic_statistic_name)
if vector_suffix not in VECTOR_SUFFIXES:
error_string = (
'\n\n{0:s}\nValid vector suffixes (listed above) do no... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_vector_suffix_from_stat_name(statistic_name, metadata_table):\n\n check_statistic_name(\n statistic_name=statistic_name, metadata_table=metadata_table)\n\n all_basic_stat_names = metadata_table[STATISTIC_NAME_COLUMN].values\n if statistic_name in all_basic_stat_names:\n return sta... | [
"0.7639785",
"0.59512895",
"0.5874074",
"0.5867149",
"0.5763061",
"0.5642398",
"0.55191773",
"0.5483739",
"0.5340687",
"0.5334209",
"0.5284943",
"0.5266761",
"0.5236807",
"0.5233503",
"0.5205855",
"0.51946056",
"0.519407",
"0.5161402",
"0.5141254",
"0.513",
"0.51237667",
"0... | 0.84912354 | 0 |
Calculates Kelly Criterion Adjusted Ratio, using a 99CI interval for a Line of a DataFrame with specific data, such as columns 'count' and 'sum', and where name is the ratio. The adjusted ratio is half of the normal ratio, it is used to mitigate damage caused by incorrect evaluations. It doesn't have that big of an imp... | def kelly_adj_ratio(self, df_line, inverse):
# Get easy variable names
n_trades, n_win_trades, ratio = df_line['count'], df_line['sum'], df_line.name[1]
# Calculates 99 CI probability taking into account if it is a normal or inverted trade
proba = ci_99_inverse_or_not(inverse, n_trades,... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def df_return_rate(self, df):\n # Initializes variables\n balance = 1\n end_balances, start_balances = [], []\n\n # Runs calculations row by row\n for index, row in df.iterrows():\n # Get starting balance\n start_balances.append(balance)\n\n # Rou... | [
"0.55496025",
"0.5535608",
"0.5390369",
"0.5266079",
"0.5190256",
"0.5167909",
"0.5105043",
"0.5088867",
"0.5087079",
"0.5082275",
"0.50736904",
"0.50445974",
"0.50317246",
"0.5026143",
"0.50072956",
"0.4973569",
"0.4918868",
"0.49156263",
"0.49012277",
"0.4890208",
"0.488665... | 0.64910966 | 0 |
Returns accuracy metric using predictions. If prediction proba is 1 it will consider a winning trade, else it will consider as a losing trade. | def accuracy_classifier(predictions, y):
predictions = np.where(predictions >= 0.5, 1, 0)
return accuracy_proba(predictions, y) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def accuracy_proba(predictions, y):\n # TODO this metric might be better evaluated putting values together into brackets\n return 1 - (y - predictions).abs().mean(), y.count()",
"def accuracy(y_true, y_pred):\n y_pred = y_pred.argmax(dim=1)\n y_true, y_pred = _tensor2float(y_true, y_pred)\n result... | [
"0.7724423",
"0.7499372",
"0.749273",
"0.7489315",
"0.7483127",
"0.7429082",
"0.7395645",
"0.7369115",
"0.7353696",
"0.73146814",
"0.72870666",
"0.72782224",
"0.7274487",
"0.7264929",
"0.726244",
"0.72415644",
"0.724014",
"0.7239047",
"0.7217819",
"0.7216937",
"0.7209613",
... | 0.7761334 | 0 |
Generator that yields elements of a list. If all list values are yielded, it resets and start from the beginning. | def list_cycler(lst: list) -> Generator[list, None, None]:
while True:
yield from lst | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _iterator_from_list(self):\n for x in self.list():\n yield x",
"def list_generator(input_list):\n\n logger.debug(\"list generator called\")\n\n while len(input_list) > 0:\n for item in input_list:\n logger.debug(\"list now has {} items\".format(len(input_list... | [
"0.747432",
"0.6872373",
"0.67957824",
"0.6628563",
"0.66019416",
"0.6576553",
"0.65606165",
"0.65461046",
"0.6486321",
"0.64537406",
"0.6432403",
"0.63944596",
"0.63351953",
"0.6334026",
"0.6312512",
"0.62893414",
"0.6287581",
"0.6287509",
"0.62704235",
"0.6246122",
"0.62322... | 0.71728736 | 1 |
r"""Enable label propagation by freezing attention_weights with sparsemax. In addition to the normal forward pass in a sparsemaxlayer, this class stores the attention weights after each forward pass. These weights can then be reused for label propagation. | def __init__(
self,
in_feats,
out_feats,
num_heads,
feat_drop=0.,
attn_drop=0.,
negative_slope=0.2,
residual=False,
activation=None,
p_norm=0.5,
lambda_sparsemax=None,
test_level=None,
**kwargs,
):
super(LabelPropSparseGATConv,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Sparse_Non_Neg_AE(x_train, x_valid, **kwargs):\n # Unload parameters\n modelpath = kwargs.get('modelpath',None)\n train_thresh = kwargs.get('train_thresh',None)\n num_hidden = kwargs.get('num_hidden',196)\n alpha = kwargs.get('alpha',0.003)\n beta = kwargs.get('beta',3)\n tau = kwargs.get(... | [
"0.55615264",
"0.5483242",
"0.5477861",
"0.5454455",
"0.5450984",
"0.5348665",
"0.5337699",
"0.5323179",
"0.5315915",
"0.52970976",
"0.52885157",
"0.52819854",
"0.5271208",
"0.5242074",
"0.5223425",
"0.5219957",
"0.5203571",
"0.51810277",
"0.51470464",
"0.51245403",
"0.510500... | 0.5375329 | 5 |
Construct a new UInt32 type from a BinaryParser. | def from_parser(
cls: Type[UInt32], parser: BinaryParser, _length_hint: Optional[int] = None
) -> UInt32:
return cls(parser.read(_WIDTH)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def from_parser(\n cls: Type[UInt64], parser: BinaryParser, _length_hint: Optional[int] = None\n ) -> UInt64:\n return cls(parser.read(_WIDTH))",
"def from_value(cls: Type[UInt32], value: Union[str, int]) -> UInt32:\n if not isinstance(value, (str, int)):\n raise XRPLBinaryCode... | [
"0.6962356",
"0.66413534",
"0.62999564",
"0.6239756",
"0.61584175",
"0.5935066",
"0.58959186",
"0.5724854",
"0.5669743",
"0.56628376",
"0.56498426",
"0.55765915",
"0.55549645",
"0.55191183",
"0.5460149",
"0.5450479",
"0.5400776",
"0.53720593",
"0.5339867",
"0.5333234",
"0.533... | 0.79925627 | 0 |
Construct a new UInt32 type from a number. | def from_value(cls: Type[UInt32], value: Union[str, int]) -> UInt32:
if not isinstance(value, (str, int)):
raise XRPLBinaryCodecException(
"Invalid type to construct a UInt32: expected str or int,"
" received {value.__class__.__name__}."
)
if isin... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def toUInt32(self): # real signature unknown; restored from __doc__\n pass",
"def uint32_pack(n):\n return struct.pack('<L', n)",
"def uint32_t(n):\n return int(n).to_bytes(4, byteorder='little', signed=False)",
"def AppendUInt32(self, field_number, unsigned_value):\n self._AppendTag(field_nu... | [
"0.6742025",
"0.66905326",
"0.6665505",
"0.63602173",
"0.6270607",
"0.6178989",
"0.6161489",
"0.60448384",
"0.5970526",
"0.59511817",
"0.5900175",
"0.58884364",
"0.5771878",
"0.5737646",
"0.57353693",
"0.57107896",
"0.5698095",
"0.56402856",
"0.5638701",
"0.55990016",
"0.5596... | 0.76626176 | 0 |
Gaussian Error Linear Unit. Original Implementation of the gelu activation function in Google Bert repo when initially created. | def gelu(x):
cdf = 0.5 * (1.0 + tf.math.erf(x / tf.math.sqrt(2.0)))
return x * cdf | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def gelu(x): # noqa\n return x * 0.5 * (1.0 + torch.erf(x / math.sqrt(2.0)))",
"def gelu(x):\n\n return x * 0.5 * (1.0 + torch.erf(x / math.sqrt(2.0)))",
"def gelu(x):\r\n return x * 0.5 * (1.0 + torch.erf(x / math.sqrt(2.0)))",
"def gelu(x):\n c = math.sqrt(2 / math.pi)\n return 0.5 * x * (1 ... | [
"0.7209178",
"0.71837944",
"0.71707743",
"0.71460795",
"0.7143974",
"0.7143974",
"0.7143974",
"0.7143974",
"0.7143974",
"0.7143974",
"0.7143974",
"0.7143974",
"0.70996964",
"0.6985216",
"0.6985216",
"0.69510156",
"0.6945256",
"0.690232",
"0.6882215",
"0.6882215",
"0.6863921",... | 0.69834 | 15 |
Returns the percentage of the board that has been fully connected. | def getConnectedness( self ):
connectedCells = self.numConnected()
return connectedCells/float( len( self.getCellType( END )) + connectedCells ) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def Percentage_of_Board_Filled(game):\n spaces_empty = game.get_blank_spaces()\n return round((len(spaces_empty) / 49) * 100)",
"def win_percentage(self, return_on_div_by_zero='n/a'):\n if self.battle_count() > 0:\n return 100.0 * float(self.win_count()) / float(self.battle_count())\n ... | [
"0.7427877",
"0.6589533",
"0.62547505",
"0.6235049",
"0.62159264",
"0.62030584",
"0.62014997",
"0.61798364",
"0.6141166",
"0.6108918",
"0.6086357",
"0.60862046",
"0.6053572",
"0.5982025",
"0.5966693",
"0.5963417",
"0.5963325",
"0.5963325",
"0.596257",
"0.5933951",
"0.59315145... | 0.7022009 | 1 |
Returns the set of valid connection patterns for a given pair of endpoints. | def getConnections( self, startPos, endPos ):
# Get the cells at the specified positions.
startCell = self.getCellAt( startPos )
endCell = self.getCellAt( endPos )
# There are no valid connections if the two cells are:
# 1) Not of equal value,
if startCell.getValue() != endCell.getValue(): return []
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __generate_connections(self):\n connections = []\n for member in self.__network_dict:\n for partner in self.__network_dict[member]:\n if {partner, member} not in connections:\n connections.append({member, partner})\n return connections",
"def ... | [
"0.5862742",
"0.5797366",
"0.5689225",
"0.56151134",
"0.560369",
"0.5599222",
"0.553514",
"0.54564977",
"0.5440415",
"0.53241175",
"0.53163725",
"0.5298894",
"0.5188991",
"0.51882607",
"0.51868665",
"0.51843125",
"0.51400805",
"0.51248944",
"0.5113612",
"0.5097165",
"0.509092... | 0.5393172 | 9 |
Gets the id of this ParcelAccount. | def id(self):
return self._id | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def account_id(self):\n\n return self._account_id.value",
"def account_id(self):\n return self._account_id",
"def account_id(self):\n return self._account_id",
"def account_id(self) -> pulumi.Output[int]:\n return pulumi.get(self, \"account_id\")",
"def account_id(self) -> Optio... | [
"0.79508346",
"0.7891134",
"0.7891134",
"0.77904207",
"0.75536925",
"0.7525925",
"0.7525925",
"0.7525925",
"0.7525925",
"0.7408733",
"0.7408733",
"0.7095385",
"0.7095385",
"0.7095385",
"0.7095385",
"0.70255506",
"0.7020314",
"0.7020314",
"0.6994459",
"0.6994459",
"0.6994459",... | 0.0 | -1 |
Sets the id of this ParcelAccount. | def id(self, id):
self._id = id | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def account_id(self, account_id):\n\n self._account_id = account_id",
"def account_id(self, account_id):\n\n self._account_id = account_id",
"def account_id(self, account_id):\n\n self._account_id = account_id",
"def account_id(self, account_id):\n\n self._account_id = account_id"... | [
"0.6742391",
"0.6742391",
"0.6742391",
"0.6742391",
"0.6742391",
"0.6742391",
"0.6742391",
"0.6724791",
"0.66940933",
"0.66798985",
"0.66798985",
"0.66798985",
"0.66798985",
"0.66798985",
"0.6659544",
"0.6659544",
"0.6659544",
"0.66488373",
"0.6636484",
"0.6636484",
"0.663648... | 0.0 | -1 |
Gets the create_date of this ParcelAccount. | def create_date(self):
return self._create_date | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getCreateDate(self):\n return self.create_date",
"def creation_date(self):\n return self._creation_date",
"def creation_date(self):\n return self._creation_date",
"def creation_date(self) -> str:\n return pulumi.get(self, \"creation_date\")",
"def creation_date(self) -> str:... | [
"0.8033578",
"0.7367857",
"0.7367857",
"0.7358855",
"0.7358855",
"0.72361356",
"0.72361356",
"0.71857464",
"0.71857464",
"0.70371073",
"0.7001321",
"0.7001321",
"0.7001321",
"0.696594",
"0.6946669",
"0.6922144",
"0.69088477",
"0.68564296",
"0.68564296",
"0.664394",
"0.6630107... | 0.80682015 | 0 |
Sets the create_date of this ParcelAccount. | def create_date(self, create_date):
self._create_date = create_date | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_date(self, create_date):\n\n self._create_date = create_date",
"def create_date(self, create_date):\n\n self._create_date = create_date",
"def create_date(self, create_date):\n\n self._create_date = create_date",
"def create_date(self, create_date):\n\n self._create_dat... | [
"0.7917557",
"0.7917557",
"0.7917557",
"0.7917557",
"0.7917557",
"0.6903782",
"0.6903782",
"0.6903782",
"0.67072755",
"0.664251",
"0.664251",
"0.664251",
"0.65056103",
"0.64543694",
"0.6422851",
"0.6422851",
"0.60926396",
"0.60256654",
"0.59674877",
"0.59674877",
"0.59265846"... | 0.7877711 | 5 |
Sets the modify_date of this ParcelAccount. | def modify_date(self, modify_date):
self._modify_date = modify_date | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def modify_date(self, modify_date):\n\n self._modify_date = modify_date",
"def modified_date(self, modified_date):\n \n self._modified_date = modified_date",
"def modified_date(self, modified_date):\n\n self._modified_date = modified_date",
"def modify_date(self):\n return ... | [
"0.8201885",
"0.6910356",
"0.6892762",
"0.67630696",
"0.67630696",
"0.67630696",
"0.67503816",
"0.6685062",
"0.66542983",
"0.66542983",
"0.66542983",
"0.66542983",
"0.66542983",
"0.63906866",
"0.59670115",
"0.5732911",
"0.564506",
"0.5543282",
"0.5468975",
"0.544943",
"0.5409... | 0.814444 | 1 |
Gets the carrier of this ParcelAccount. | def carrier(self):
return self._carrier | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getCarrier(self):\n return _yarp.Contact_getCarrier(self)",
"def carrier_class(self):\n return self._carrier_class",
"def get_carrier():\n return getattr(_local, 'carrier', None)",
"def byCarrier(*args):\n return _yarp.Contact_byCarrier(*args)",
"def Contact_byCarrier(*args):\n ... | [
"0.8147697",
"0.75465894",
"0.68543977",
"0.6221489",
"0.585599",
"0.5492869",
"0.5492869",
"0.5337685",
"0.5281316",
"0.5228246",
"0.522389",
"0.5209755",
"0.5198352",
"0.51080745",
"0.51069564",
"0.51069564",
"0.51069564",
"0.50896376",
"0.5088046",
"0.5087682",
"0.5087682"... | 0.7758308 | 1 |
Gets the client of this ParcelAccount. | def client(self):
return self._client | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_client(self):\n return self.__client",
"def get_client(self):\n return self.client",
"def get_client(self):\n return self.client",
"def get_account(self):\n return self._account",
"def get_account(self):\n return self._account",
"def get_client(self):\n r... | [
"0.72367084",
"0.71725893",
"0.71725893",
"0.69471496",
"0.69471496",
"0.6890099",
"0.6863244",
"0.68138623",
"0.6707947",
"0.6662281",
"0.661891",
"0.6582568",
"0.6573222",
"0.65691245",
"0.65649986",
"0.65649986",
"0.65649986",
"0.65649986",
"0.65649986",
"0.6510218",
"0.64... | 0.665043 | 10 |
Gets the name of this ParcelAccount. | def name(self):
return self._name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def account_name(self) -> str:\n return pulumi.get(self, \"account_name\")",
"def account_name(self) -> str:\n return pulumi.get(self, \"account_name\")",
"def account_name(self) -> str:\n return pulumi.get(self, \"account_name\")",
"def account_name(self) -> str:\n return pulumi.... | [
"0.8514846",
"0.85146445",
"0.85146445",
"0.85146445",
"0.85146445",
"0.85146445",
"0.85146445",
"0.85146445",
"0.85146445",
"0.85146445",
"0.85146445",
"0.85146445",
"0.85146445",
"0.85146445",
"0.85146445",
"0.85146445",
"0.85146445",
"0.85146445",
"0.8514514",
"0.8514514",
... | 0.0 | -1 |
Sets the name of this ParcelAccount. | def name(self, name):
self._name = name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def account_name(self, account_name):\n\n self._account_name = account_name",
"def account_name(self, account_name):\n\n self._account_name = account_name",
"def account_name(self, account_name):\n\n self._account_name = account_name",
"def account_name(self, account_name):\n\n se... | [
"0.76506394",
"0.76506394",
"0.76506394",
"0.76506394",
"0.74961543",
"0.74961543",
"0.74961543",
"0.74961543",
"0.74961543",
"0.74961543",
"0.7466035",
"0.7466035",
"0.7466035",
"0.7466035",
"0.7466035",
"0.7398929",
"0.73639226",
"0.7294533",
"0.7279478",
"0.7207734",
"0.71... | 0.0 | -1 |
Gets the manifest_partner_id of this ParcelAccount. | def manifest_partner_id(self):
return self._manifest_partner_id | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def partnerid(self):\n return self._partnerid",
"def manifest_partner_id(self, manifest_partner_id):\n self._manifest_partner_id = manifest_partner_id",
"def partnerkey(self):\n return self._partnerkey",
"def _get_partner_id(self, credit_account):\n # use partner of salary rule or... | [
"0.7337113",
"0.6996189",
"0.66085327",
"0.6303675",
"0.62532943",
"0.614944",
"0.6058755",
"0.60379916",
"0.60379916",
"0.60090435",
"0.59994644",
"0.59097487",
"0.57448447",
"0.57135665",
"0.5678185",
"0.5651905",
"0.5642789",
"0.5642789",
"0.55906624",
"0.55896723",
"0.558... | 0.87369114 | 0 |
Returns the string representation of the model | def to_str(self):
return 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.8602374",
"0.85093755",
"0.8237104",
"0.8050309",
"0.80128866",
"0.79348034",
"0.78766525",
"0.77898884",
"0.7786461",
"0.7745792",
"0.7627315",
"0.76055235",
"0.757999",
"0.7514394",
"0.75038797",
"0.75035286",
"0.74850684",
"0.7440529",
"0.74325883",
"0.74239755",
"0.740... | 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 |
Get td tags with specific attributes. | def get_td_data(soup, *args):
td_data = soup.find_all("td", headers=args)
return td_data | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_td_from_tr(tr):\n return tr.find_all('td')",
"def get_attributes(sn):\n table_name = ns.get_unique_tn(sn)\n attribs = []\n cursor = ns.get_attribs(sn)\n while cursor.forward():\n rec = cursor.current\n node = rec['end_node']\n ansible_id = next(iter(node.labels))\n ... | [
"0.5948023",
"0.56230587",
"0.557889",
"0.54998225",
"0.53987134",
"0.5371272",
"0.52876365",
"0.52612984",
"0.5242586",
"0.5178829",
"0.51733613",
"0.5153496",
"0.51218265",
"0.5115649",
"0.511176",
"0.51019996",
"0.50816065",
"0.507154",
"0.5041368",
"0.50135684",
"0.500262... | 0.6592756 | 0 |
Initialize this doubly linked list and append the given items, if any. | def __init__(self, iterable=None):
self.head = None # First node
self.tail = None # Last node
self.size = 0 # Number of nodes
# Append the given items
if iterable is not None:
for item in iterable:
self.append(item) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, items=None):\n # Initialize a new linked list to store the items\n self.list = LinkedList()\n # self.size property is _size()\n if items is not None:\n for item in items:\n self.add(item)",
"def __init__(self, items: List) -> None:\n ... | [
"0.76024354",
"0.71807194",
"0.71778685",
"0.7058141",
"0.690261",
"0.6860252",
"0.6787536",
"0.6689922",
"0.6558482",
"0.65494084",
"0.65473443",
"0.65473443",
"0.6423871",
"0.63997465",
"0.6395288",
"0.63728994",
"0.6298721",
"0.6297288",
"0.62842923",
"0.62711674",
"0.6239... | 0.6243652 | 21 |
Return True if this linked list is empty, or False. | def is_empty(self):
return self.head is None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_empty(self):\n return self.head.next is None",
"def isEmpty(self):\n return True if self.head is None else False",
"def isEmpty(self) -> bool:\n return self.head == None",
"def isEmpty(self) -> bool:\n return self.head == None",
"def is_empty(self):\n return self.h... | [
"0.88283503",
"0.87898487",
"0.87222123",
"0.87222123",
"0.8680919",
"0.8676428",
"0.8637684",
"0.86295927",
"0.8571739",
"0.85667664",
"0.8563026",
"0.84859544",
"0.84719425",
"0.8466275",
"0.84423196",
"0.84339637",
"0.8361087",
"0.8342684",
"0.83384484",
"0.8312394",
"0.82... | 0.85825473 | 13 |
Convert a serializable class to a dict to be encoded into JSON. | def default(self, o: 'typevars.Serializable') -> 'typevars.Serialized': # Default __init__ can shadow it, but we don't - pylint: disable=method-hidden
if isinstance(o, enum.Enum):
return o.value
try:
identifier = _SERIALIAZABLE_CLASSES_BY_CLASS[o.__class__]
return dict(o.to_json(), __identif... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def serialize_to_dict(dataclass) -> Dict:\n return jsons.loads(jsons.dumps(dataclass))",
"def to_dict(_class):\n return_dict = {\n 'name': _class.identifier(),\n 'description': _class.description()\n }\n\n return return_dict",
"def class_to_json(obj):\n ... | [
"0.82407075",
"0.75823563",
"0.75725806",
"0.7561199",
"0.7561199",
"0.7561199",
"0.7561199",
"0.7561199",
"0.7544062",
"0.75289005",
"0.74683607",
"0.7455137",
"0.74028176",
"0.7388693",
"0.73430187",
"0.7258573",
"0.7215643",
"0.72050965",
"0.71500605",
"0.71424013",
"0.710... | 0.0 | -1 |
Convert a dict deserialized from JSON to the serializable class. | def from_dict(data: 'Dict[str, Any]') -> 'typevars.Serializable':
if '__identifier' in data:
try:
cls = _SERIALIAZABLE_CLASSES_BY_IDENTIFIER[data['__identifier']]
return cls.from_json(data)
except KeyError:
pass
return data | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def from_dict(cls: T, d: Dict) -> T:\n return jsons.loads(jsons.dumps(d), cls)",
"def deserialize(json, cls=None):\n LOGGER.debug('deserialize(%s)', json)\n\n out = simplejson.loads(json)\n\n if isinstance(out, dict) and cls is not None:\n return cls(**out)\n\n return out",
"def from_... | [
"0.75206465",
"0.72698724",
"0.71678597",
"0.6910024",
"0.6853347",
"0.6836811",
"0.6583332",
"0.6475149",
"0.6427111",
"0.6409142",
"0.6404339",
"0.6402402",
"0.6402402",
"0.6402402",
"0.63837534",
"0.63837534",
"0.63837534",
"0.6378695",
"0.63784856",
"0.63784856",
"0.63784... | 0.71362764 | 3 |
Loads data for the specified city and filters by month and day if applicable. | def load_data(city, month='all', day='all'):
df=pd.read_csv(CITY_DATA[city])
df['Start Time'] = pd.to_datetime(df['Start Time'])
df['month'] = df['Start Time'].dt.month
df['day_of_week'] = df['Start Time'].dt.weekday_name
if month != 'all':
months = ['january', 'february', 'march', 'april',... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_city_data(city, month, day):\n df = pd.read_csv(CITY_DATA[city])\n #extract month, day, hour from start time\n df['month'] = pd.to_datetime(df['Start Time']).dt.month_name()\n df['day'] = pd.to_datetime(df['Start Time']).dt.weekday\n df['hour'] = pd.to_datetime(df['Start Time']).dt.hour\n\n... | [
"0.8318361",
"0.82271224",
"0.81508607",
"0.8080068",
"0.80428296",
"0.8017885",
"0.80014753",
"0.7990486",
"0.797958",
"0.7977929",
"0.79723334",
"0.7956904",
"0.7956301",
"0.7948598",
"0.79312575",
"0.7918757",
"0.791296",
"0.79119456",
"0.79050934",
"0.79031867",
"0.79028"... | 0.7838081 | 31 |
Displays statistics on the most frequent times of travel. | def time_stats(df):
print('\nCalculating The Most Frequent Times of Travel...')
start_time = time.time()
start_time = time.time()
df['Start Time'] = pd.to_datetime(df['Start Time'])
# TO DO: display the most common month
df['month'] = df['Start Time'].dt.month
# find the most popular h... | {
"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.7369063 | 58 |
Displays statistics on the most popular stations and trip. | def station_stats(df):
print('\nCalculating The Most Popular Stations and Trip...')
start_time = time.time()
# TO DO: display most commonly used start station
start_station = df['Start Station'].mode()[0]
print('\nThe Most commonly used start station:{}'.format(start_station))
# TO DO: displa... | {
"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.7809938",
"0.76727635",
"0.7538624",
"0.74982685",
"0.7490305",
"0.74887866",
"0.7436869",
"0.7429845",
"0.74274427",
"0.7425571",
"0.74126786",
"0.7404592",
"0.7382532",
"0.7379482",
"0.73747545",
"0.7365935",
"0.73561436",
"0.7351966",
"0.7324152",
"0.7304813",
"0.729985... | 0.719564 | 44 |
Displays statistics on the total and average trip duration. | def trip_duration_stats(df):
print('\nCalculating Trip Duration...')
start_time = time.time()
# TO DO: display total travel time
#total_time=df.groupby(['Trip Duration']).sum()
total_time=df['Trip Duration'].sum()
print('\nTotal travel time {}'.format(total_time))
# TO DO: display mean tra... | {
"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.82707965",
"0.8119091",
"0.8049175",
"0.8048038",
"0.7979004",
"0.79636914",
"0.79603153",
"0.79473746",
"0.7937292",
"0.79305714",
"0.7928642",
"0.79278976",
"0.792559",
"0.79207975",
"0.7916774",
"0.7914015",
"0.7908496",
"0.7904813",
"0.7903085",
"0.7893187",
"0.7891844... | 0.7916438 | 15 |
Returns if `AudioPlayer` is playing audio | def is_playing(self) -> bool:
if self._voice is None or self._current is None:
return False
return self._voice.is_playing() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_playing(self):\n return self.audio.is_playing()",
"def isPlaying(self): \n return mixer.music.get_busy()",
"def hasAudio(self):\n return _yarp.IAudioVisualStream_hasAudio(self)",
"async def audio_playing(ctx):\n client = ctx.guild.voice_client\n if client and client.c... | [
"0.7965092",
"0.7911339",
"0.7785641",
"0.77567667",
"0.7652531",
"0.7495772",
"0.739419",
"0.7212712",
"0.70888126",
"0.70541966",
"0.70372945",
"0.7004168",
"0.6980049",
"0.69508356",
"0.69304025",
"0.6912492",
"0.69066876",
"0.6877348",
"0.6784431",
"0.6713166",
"0.6652241... | 0.72610235 | 7 |
Gets the voice client for audio player | def voice(self) -> Optional[VoiceClient]:
return self._voice | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def get_current_voice_channel(self, ctx):\n if self.use_lavalink:\n if ctx.guild and ctx.guild.me.voice:\n return ctx.guild.me.voice.channel\n return None\n return next(iter(vc for vc in ctx.bot.voice_clients if vc.guild.id == ctx.guild.id), None)",
"def g... | [
"0.65320325",
"0.62338823",
"0.6206882",
"0.61567247",
"0.6093584",
"0.6072382",
"0.6065661",
"0.60564077",
"0.5910239",
"0.5873581",
"0.58530354",
"0.5791985",
"0.5782191",
"0.57520485",
"0.5737149",
"0.57247853",
"0.5711014",
"0.568178",
"0.5675462",
"0.56425965",
"0.560747... | 0.7585358 | 0 |
Returns current `Song` or `Episode` that is being played | def current(self) -> Optional[QueuedItem]:
if self._current is not None:
return self._current
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getPlaying(self):\r\n return self.musicPlaying",
"async def get_current_song(self):\n async with self.client_session.get(f\"{self.backend_url}/api/playing\") as response:\n if response.status == 200:\n data = await response.json()\n return data\n ... | [
"0.7222836",
"0.71180505",
"0.67767453",
"0.67030066",
"0.66385835",
"0.65405136",
"0.6357778",
"0.6321524",
"0.63168055",
"0.631477",
"0.6260473",
"0.625955",
"0.624804",
"0.62259716",
"0.6221011",
"0.6187005",
"0.6169379",
"0.6142813",
"0.6137409",
"0.61364233",
"0.61080253... | 0.5558343 | 86 |
Gets current volume level | def volume(self) -> float:
return self._volume | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def volume_level(self):\n return self._volume",
"def volume_level(self):\n return self._volume",
"def volume_level(self):\n return self._volume",
"def volume_level(self):\n return self._volume_entity.volume_level",
"def volume_level(self):\n if \"volume\" in self._status:\n ... | [
"0.880265",
"0.86800593",
"0.860672",
"0.8441833",
"0.8426595",
"0.8426381",
"0.8424851",
"0.83168745",
"0.8209187",
"0.8184622",
"0.8081644",
"0.80652565",
"0.7724719",
"0.7721017",
"0.7561368",
"0.7556339",
"0.74092126",
"0.7377027",
"0.733516",
"0.72914207",
"0.7257521",
... | 0.6836312 | 46 |
Checks if a given expression has a correct combination of opening and closing parentheses. (a+b)c returns True, ((a+b) returns False. | def correct_parentheses(expression):
# BEGIN_YOUR_CODE
var_st = list()
for var_c in iter(expression):
if var_c == '(':
var_st.append(var_c)
elif var_c == ')':
try:
var_st.pop()
except IndexError:
return False
return len... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def nested_parentheses(expression):\n # BEGIN_YOUR_CODE \n if expression == \"\":\n return True\n if expression.startswith('(') and expression.endswith(')'):\n return nested_parentheses(expression[1:-1])\n else:\n return False\n #raise Exception(\"Not implemented yet\")\n # ... | [
"0.7529658",
"0.74289614",
"0.7324947",
"0.7285546",
"0.7282958",
"0.722516",
"0.7136635",
"0.70943433",
"0.709205",
"0.6882615",
"0.6831236",
"0.68140864",
"0.68103313",
"0.67808485",
"0.6751935",
"0.6734755",
"0.6709322",
"0.66918814",
"0.6686957",
"0.66567445",
"0.6547247"... | 0.7166861 | 6 |
Normalize a namespace and return, if possible. | def normalize_prefix(prefix: str, *, curie=None, xref=None) -> Optional[str]:
for string_transformation in (lambda x: x, str.lower, str.upper, str.casefold):
namespace_transformed = string_transformation(prefix)
if namespace_transformed in SYNONYM_TO_KEY:
return SYNONYM_TO_KEY[namespace_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __parse_namespace(self):\n if self.manifest.has_option('config', 'namespace'):\n return self.manifest.get('config', 'namespace')\n elif self.manifest.has_option('config', 'source'):\n return NAMESPACE_REGEX.search(self.manifest.get('config', 'source')).groups()[0]\n e... | [
"0.6370233",
"0.63398445",
"0.58566093",
"0.56716233",
"0.56716233",
"0.56716233",
"0.56716233",
"0.56716233",
"0.56716233",
"0.56716233",
"0.56716233",
"0.55937797",
"0.5587277",
"0.5543985",
"0.55385023",
"0.54871875",
"0.5463789",
"0.5463789",
"0.5463789",
"0.5447987",
"0.... | 0.55644405 | 13 |
Normalize dashes in a string. | def normalize_dashes(s: str) -> str:
return s. \
replace(FIGURE_DASH, NORMAL_DASH). \
replace(EN_DASH, NORMAL_DASH). \
replace(EM_DASH, NORMAL_DASH). \
replace(HORIZONAL_BAR, NORMAL_DASH) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sanitize(s):\n safe = ascii_letters + digits + \"_-\"\n return \"-\".join(\"\".join(c if c in safe else \" \" for c in s).lower().split())",
"def dasherize(word: str) -> str:\n return word.replace(\"_\", \"-\")",
"def slugify(cls, string):\n string = unicodedata.normalize('NFKD', unicode(st... | [
"0.7208797",
"0.71655774",
"0.70281035",
"0.6947069",
"0.67817146",
"0.677677",
"0.6712229",
"0.6708548",
"0.66866827",
"0.6633371",
"0.66018623",
"0.65484565",
"0.65468204",
"0.6480964",
"0.6430933",
"0.6382256",
"0.6374688",
"0.6351171",
"0.63510793",
"0.628711",
"0.6232597... | 0.6759624 | 6 |
A helper for bounce which checks the validity of a bounce point candidate. Return True if halving t_0 brings one closer to the domain. | def bounce_compare(domain, path_vector, incident_point, t_0):
polar_1 = lambda theta: domain.polar(theta)[0]
polar_2 = lambda theta: domain.polar(theta)[1]
path_vec_1 = lambda t: fadd(fmul(path_vector[0], t),
incident_point[0])
path_vec_2 = lambda t: fadd(fmul(path_vecto... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_valid(self):\n return self.LOWER_SPEED_BOUNDARY <= self._average_speed <= self.UPPER_SPEED_BOUNDARY",
"def _get_is_in_bounds(self, timepoint):\n if timepoint is None:\n return False\n if self.start_point is not None and timepoint < self.start_point:\n return Fals... | [
"0.6122501",
"0.5942022",
"0.5938295",
"0.59374535",
"0.5891383",
"0.57814354",
"0.57793033",
"0.577685",
"0.57686293",
"0.5720492",
"0.5717896",
"0.5703242",
"0.5692034",
"0.5681013",
"0.5633242",
"0.5621877",
"0.56213427",
"0.56028557",
"0.55964416",
"0.55955386",
"0.559292... | 0.6178261 | 0 |
Returns the difference in polar angle between the q and q + 1 st bounces along with the penalty incurred by bouncing below the top half of the domain. | def check_q_bounce_down(domain, q, inc_angle):
last_bounce = bounce_q_times_top_half(domain, q, inc_angle)
following_bounce = bounce(domain, last_bounce[0][0], last_bounce[0][1])
return (fsub(fadd(last_bounce[0][0], following_bounce[0]), 1),
last_bounce[1]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_q_bounce_opp(domain, q, inc_angle):\n\n final_theta = bounce_q_times_top_half(domain, q, inc_angle)\n return (fsub(final_theta[0][0], 1 / 2), final_theta[1])",
"def bounce_q_times_top_half(domain, q, inc_angle):\n\n cur_pt = (0, inc_angle)\n penalty = 0\n i = 0\n while i < q:\n ... | [
"0.69128263",
"0.64342624",
"0.611619",
"0.6066639",
"0.6032176",
"0.6010112",
"0.59277964",
"0.57852966",
"0.57308394",
"0.5725218",
"0.5706045",
"0.569933",
"0.5698545",
"0.5674528",
"0.56238204",
"0.56211936",
"0.5590502",
"0.5585246",
"0.5564944",
"0.5561692",
"0.5529289"... | 0.57129306 | 10 |
Returns an angle theta such that bounce is periodic of period q on input theta, beginning at the marked point. Assumed that q is odd. | def generate_orbit_odd(domain, q):
bounce_end = lambda bounce_angle: check_q_bounce_down(domain, (q - 1) / 2,
bounce_angle)
newton_start_point = lazutkin_weight(domain, 0) / q
found_root = 0
# Make sure the root found isn't the point of inciden... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_q_bounce_opp(domain, q, inc_angle):\n\n final_theta = bounce_q_times_top_half(domain, q, inc_angle)\n return (fsub(final_theta[0][0], 1 / 2), final_theta[1])",
"def bounce_q_times(domain, q, inc_angle):\n\n cur_pt = (0, inc_angle)\n i = 0\n while i < q:\n cur_pt = bounce(domain, c... | [
"0.7065891",
"0.669906",
"0.62232953",
"0.6144213",
"0.6037644",
"0.5980232",
"0.59781224",
"0.5947732",
"0.5921638",
"0.58909464",
"0.58445495",
"0.5828536",
"0.5826227",
"0.5786517",
"0.57841504",
"0.5767878",
"0.5745177",
"0.5736877",
"0.5716519",
"0.5689345",
"0.56820124"... | 0.608924 | 4 |
Returns an angle theta such that bounce is periodic of period q on input theta, beginning at the marked point. Assumed that q is even. | def generate_orbit_even(domain, q):
if q == 2:
return fdiv(pi, 2)
bounce_end = lambda bounce_angle: check_q_bounce_opp(domain, q / 2,
bounce_angle)
newton_start_point = lazutkin_weight(domain, 0) / q
found_root = 0
# Make sure the r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_q_bounce_opp(domain, q, inc_angle):\n\n final_theta = bounce_q_times_top_half(domain, q, inc_angle)\n return (fsub(final_theta[0][0], 1 / 2), final_theta[1])",
"def bounce_q_times(domain, q, inc_angle):\n\n cur_pt = (0, inc_angle)\n i = 0\n while i < q:\n cur_pt = bounce(domain, c... | [
"0.70120955",
"0.65946454",
"0.62678915",
"0.6141421",
"0.6072964",
"0.6036965",
"0.5997696",
"0.59956336",
"0.5902273",
"0.58778214",
"0.5871177",
"0.5865336",
"0.58581704",
"0.58554065",
"0.58290285",
"0.5805487",
"0.5779418",
"0.5751377",
"0.57424057",
"0.5715179",
"0.5687... | 0.5964376 | 8 |
Returns cos of the outgoing angle at position i of the orbit s. | def cos_outgoing_angle(domain, i, s):
if (i >= len(s)):
raise Exception("i must be < len(s).\n")
if (i == len(s) - 1):
# Add a dummy value to allow for odd and even cases
# A slight hack to make the function more general
s = s.copy()
if (not almosteq(s[i], (1 / 2))):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cos(direction):\r\n return int(abs(2 - direction) - 1)",
"def cosine(self):\n return math.cos(self.angle)",
"def cos(angle):\n return math.cos(angles.deg_to_rad(angle))",
"def cos(self):\n return self._unop(\"cos\")",
"def cos(angle):\n return np.cos(2 * np.pi * angle)",
... | [
"0.7153685",
"0.7068885",
"0.7009242",
"0.69848865",
"0.69690347",
"0.69399285",
"0.6802047",
"0.67188495",
"0.6702678",
"0.6654921",
"0.662525",
"0.6535118",
"0.6527502",
"0.65143865",
"0.6490091",
"0.6486773",
"0.6417184",
"0.63585806",
"0.6178962",
"0.6173574",
"0.6167396"... | 0.813878 | 0 |
Compute gradient of softDTW w.r.t. D by dynamic programming. Returns | def grad(self):
if not self.computed:
raise ValueError("Needs to call compute() first.")
m, n = self.D.shape
# Add an extra row and an extra column to D.
# Needed to deal with edge cases in the recursion.
D = numpy.vstack((self.D, numpy.zeros(n)))
D = numpy.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_gradient(self, dh):\n bsize = self.x.shape[0]\n\n self.dw = np.dot(self.x.T, dh) / bsize\n self.d_bias = dh.mean(axis=0)\n\n self.dx = np.dot(dh, self.w.T)\n return self.dx",
"def grad(self):\n if not self.computed:\n raise ValueError(\"Needs to cal... | [
"0.78030115",
"0.72193545",
"0.71016914",
"0.70569474",
"0.69505394",
"0.6862043",
"0.68501943",
"0.68292755",
"0.68225867",
"0.6810458",
"0.6809593",
"0.6799794",
"0.67754143",
"0.67745465",
"0.6773187",
"0.677256",
"0.67495745",
"0.674538",
"0.6743278",
"0.67401844",
"0.671... | 0.7209044 | 2 |
Output the value as JSON | def as_json(value):
return safe_json(value, indent=1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __str__(self):\n return json.dumps(self.value)",
"def json(self, value):\n # represent as a string\n return self.string(value)",
"def json_value(self) -> str:\n return json.dumps(self.string_value(), ensure_ascii=False)",
"def serialize(self, value):\n return json.dumps(val... | [
"0.794382",
"0.78266585",
"0.77360475",
"0.76974124",
"0.73231417",
"0.73191047",
"0.73163104",
"0.7227467",
"0.7192498",
"0.71771497",
"0.7158439",
"0.712156",
"0.7119548",
"0.71064943",
"0.70943385",
"0.70607185",
"0.70385146",
"0.70385146",
"0.7028383",
"0.7022681",
"0.702... | 0.7117122 | 13 |
Continuum convolution integral with direct kernel function. | def convint(t, f, kernel, kernel_param):
if len(t) != len(f):
raise Exception('convint: input t and f should be same length')
N = len(f)
y = np.empty(N)
for n in range(0,N):
u = t[0:n+1]
integrand = kernel(t[n] - u, **kernel_param) * f[0:n+1]
y[n] = trapz(x... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def integral_image(x):\n return x.cumsum(1).cumsum(0)",
"def get_forward_integrate_kernel(nb_dir,dt,width,height,ds,stream,diffCoef=0.001,Cm=1.):\n\tdt, kernelA, kernelB = get_one_step_explicit_synchronous_splitting_w_Istim_kernel(nb_dir,dt,width,height,ds,stream,diffCoef=diffCoef,Cm=Cm)\n\n\t@cuda.jit('void(... | [
"0.6545009",
"0.64436793",
"0.6424022",
"0.6420053",
"0.6393128",
"0.639241",
"0.6356944",
"0.6160018",
"0.6128839",
"0.61201864",
"0.60888",
"0.6073279",
"0.6047887",
"0.602169",
"0.5951562",
"0.5927264",
"0.5922091",
"0.5909392",
"0.5883964",
"0.5877659",
"0.58758706",
"0... | 0.5971747 | 14 |
Finite difference laplacian matrix. [[1. 2. 1. ... 0. 0. 0.] [ 0. 1. 2. ... 0. 0. 0.] ... [ 0. 0. 0. ... 2. 1. 0.] [ 0. 0. 0. ... 1. 2. 1.]] | def grad2matrix(N):
G = np.eye(N) # last elements are just diagonal
v = np.array([-1,2,-1])
#for i in np.arange(1,N): # rows
# ind = np.arange(i-1,i+2)
for i in np.arange(0,N): # rows
ind = np.arange(i,i+3)
if ind[-1] < N:
G[i,ind] = v
return G | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute_L_matrix(self):\n self.L = np.diag(self.z) - self.K\n logg.info('compute graph Laplacian')",
"def laplacian(A, n=-1): \n\n if (n<=0):\n n = A.shape[0]\n \n laplacian_graph = np.zeros(shape=(n, n))\n for i in range(0, n):\n for j in range(0, n):\n ... | [
"0.6841146",
"0.6772252",
"0.65374184",
"0.63556904",
"0.6217618",
"0.6202796",
"0.6200527",
"0.6180973",
"0.61182547",
"0.61079615",
"0.6101214",
"0.6009204",
"0.6000062",
"0.59956014",
"0.59870076",
"0.5985771",
"0.59656185",
"0.5949082",
"0.59417033",
"0.58863354",
"0.5866... | 0.0 | -1 |
Tikhonov ||Lf||^2 regularized Least Squares deconvolution. | def tikhonov_deconv(y, kernel, alpha=1e-6, regmatrix='grad2', positive=True, mass_conserve=True):
if (len(y) != len(kernel)):
raise Exception('Tikhonov_deconv: y and kernel with different lengths')
# Make it column vector
y = y.reshape(-1, 1)
N = len(y)
C = convmatrix(kernel)
C = C[0:N... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def RL_deconv_cont(t, y, kernel, kernel_param, iterations=4, mass_conserve=True, EPS=1e-15):\n\n y_mass = trapz(x=t, y=y)\n x_hat = copy.deepcopy(y)\n x_hat[x_hat < EPS] = EPS\n \n r = np.ones(y.shape)\n\n # Iterate towards ML estimate for the latent signal\n for i in range(iterations):\... | [
"0.6354124",
"0.6096718",
"0.5968044",
"0.5717965",
"0.56869614",
"0.56671876",
"0.5660603",
"0.5653617",
"0.56401044",
"0.5626539",
"0.5625533",
"0.56144005",
"0.5601738",
"0.5548635",
"0.55248886",
"0.55126524",
"0.55024195",
"0.54884076",
"0.5484545",
"0.5473529",
"0.54637... | 0.5414138 | 31 |
RichardsonLucy (EMiteration) 1D deconvolution y = x () h | def RL_deconv(y, kernel, iterations=4, mass_conserve=True):
y_mass = np.sum(y)
x_hat = np.ones(y.shape)
r = np.ones(y.shape)
# Iterate towards ML estimate for the latent signal
for i in range(iterations):
y_hat = conv_(x_hat, kernel)
r[y_hat > 0] = y[y_hat > 0] / y_hat[y_ha... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def RL_deconv_cont(t, y, kernel, kernel_param, iterations=4, mass_conserve=True, EPS=1e-15):\n\n y_mass = trapz(x=t, y=y)\n x_hat = copy.deepcopy(y)\n x_hat[x_hat < EPS] = EPS\n \n r = np.ones(y.shape)\n\n # Iterate towards ML estimate for the latent signal\n for i in range(iterations):\... | [
"0.6530308",
"0.60572654",
"0.60344833",
"0.5940491",
"0.58816636",
"0.5876461",
"0.5803518",
"0.5794792",
"0.577935",
"0.5773424",
"0.57715774",
"0.57639176",
"0.57600737",
"0.5738699",
"0.57386357",
"0.5734627",
"0.57317007",
"0.5717328",
"0.5693697",
"0.5689245",
"0.568876... | 0.6850248 | 0 |
RichardsonLucy (EMiteration) continuum 1D deconvolution y = x () h | def RL_deconv_cont(t, y, kernel, kernel_param, iterations=4, mass_conserve=True, EPS=1e-15):
y_mass = trapz(x=t, y=y)
x_hat = copy.deepcopy(y)
x_hat[x_hat < EPS] = EPS
r = np.ones(y.shape)
# Iterate towards ML estimate for the latent signal
for i in range(iterations):
y_hat... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def RL_deconv(y, kernel, iterations=4, mass_conserve=True):\n y_mass = np.sum(y)\n x_hat = np.ones(y.shape)\n r = np.ones(y.shape)\n\n # Iterate towards ML estimate for the latent signal\n for i in range(iterations):\n\n y_hat = conv_(x_hat, kernel)\n r[y_hat > 0] = y[y_hat > 0... | [
"0.68367976",
"0.6108032",
"0.5985192",
"0.5926163",
"0.59068155",
"0.578375",
"0.57779175",
"0.577066",
"0.5759526",
"0.5737747",
"0.573444",
"0.5732118",
"0.572841",
"0.57266515",
"0.5722497",
"0.571708",
"0.5716313",
"0.5699313",
"0.56882757",
"0.56865984",
"0.5685416",
... | 0.6646299 | 1 |
CDF integral from continuum pdf | def cdfint(t, df):
y = np.empty(shape=(0,))
for i,v in enumerate(t, start=1):
integral = trapz(x=t[0:i], y=df[0:i])
y = np.append(y, integral)
return y | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pdf2cdf(da):\n return da.cumsum(dim='bin_edge') / da.sum(dim='bin_edge')",
"def compute_cdf(self, **kwargs):\n x = symbols('x', integer=True, cls=Dummy)\n z = symbols('z', real=True, cls=Dummy)\n left_bound = self.set.inf\n\n # CDF is integral of PDF from left bound to z\n ... | [
"0.70959",
"0.70626104",
"0.69610155",
"0.6800734",
"0.67375106",
"0.66626066",
"0.6591811",
"0.6552592",
"0.6552592",
"0.6552592",
"0.6508422",
"0.64821297",
"0.6395654",
"0.6392442",
"0.6318039",
"0.62954634",
"0.62857807",
"0.6227659",
"0.6204441",
"0.6186855",
"0.6175358"... | 0.61777467 | 20 |
Dicretized CDF function. Computes F(x) = percentile from a discretized CDF F(x) array | def cdf_function(cdf, xarr, x):
val = np.zeros(len(x))
ind = np.zeros(len(x))
for k in range(len(x)):
val[k],ind[k] = nearest_of_sorted(xarr, x[k])
return val, ind | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cdf(x, dfn, dfd):\n with mp.extradps(5):\n x = mp.mpf(x)\n if x <= 0:\n return mp.zero\n dfn = mp.mpf(dfn)\n dfd = mp.mpf(dfd)\n dfnx = dfn * x\n return mp.betainc(dfn/2, dfd/2, x2=dfnx/(dfnx + dfd),\n regularized=True)",
"def p... | [
"0.7081011",
"0.7005689",
"0.6783385",
"0.666511",
"0.66302574",
"0.65836006",
"0.6530319",
"0.64930373",
"0.6489081",
"0.64821225",
"0.6434273",
"0.64137",
"0.64137",
"0.64137",
"0.6404787",
"0.6323601",
"0.6246453",
"0.62456816",
"0.6197413",
"0.61888444",
"0.61810654",
"... | 0.6351699 | 15 |
Buy shares of stock. | def buy():
if request.method == "POST":
quote = lookup(request.form.get("stock"))
if not quote:
return apology("Quote not found")
try:
shares = int(request.form.get("nshares"))
except ValueError:
return apology("Shares must be an integer")
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _buy(self, stock, sig, day):\n\n idx = self.ncs.index(stock)\n # Calculate the maximum possible number of stock unit the current cash can buy\n available_unit = self.state[0] // self.stock_price.loc[day][stock]\n num_share = min(available_unit, int(sig))\n # Deduct the traded... | [
"0.76301324",
"0.7502408",
"0.7236989",
"0.7207942",
"0.7114527",
"0.70767576",
"0.69973654",
"0.69242626",
"0.689434",
"0.6883444",
"0.6877218",
"0.6861987",
"0.68398005",
"0.676523",
"0.67641747",
"0.6747415",
"0.6719282",
"0.6717512",
"0.6702265",
"0.6663467",
"0.66509014"... | 0.69008964 | 8 |
Sell shares of stock. | def sell():
user = current_user()
port = load_portfolios(user)
if not port:
return apology("You do not have any stocks yet")
prices = set_prices(port)
investment = sum([prices[k] for k, v in prices.items()])
total = investment + int(user["cash"])
if request.method == "POST":
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _sell(self, stock, sig, day):\n\n # Get the index of the stock\n idx = self.ncs.index(stock)\n\n # Only need to sell the unit recommended by the trading agent, not necessarily all stock unit.\n num_share = min(abs(int(sig)), self.state[idx + 1])\n commission = dp.Trading.comm... | [
"0.75993884",
"0.7556052",
"0.7169684",
"0.71026254",
"0.7070919",
"0.7027189",
"0.7023418",
"0.70094424",
"0.7004945",
"0.693865",
"0.68726695",
"0.6850753",
"0.6847375",
"0.6847375",
"0.68454576",
"0.6827991",
"0.6827005",
"0.6802886",
"0.6797255",
"0.67546636",
"0.6750404"... | 0.6753963 | 20 |
convert a structured numpy array into a csv, possibly prepending a 'names' column | def table2csv(fil, table, names=None):
names = [None,] if not names else names
with open(fil, 'wb') as f:
fw = csv.writer(f)
fw.writerow(("object",) + table.dtype.names )
for obj, row in itertools.izip_longest(names, table):
fw.writerow( [obj,] + [r for r in row] ) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def numpy_to_csv(array, dst):\n with open(dst, 'w') as f:\n w = csv.writer(f, delimiter=',', quotechar='|',\n quoting=csv.QUOTE_MINIMAL)\n\n for row in array:\n w.writerow(row)",
"def save_csv(file_name, array):\n np.savetxt(file_name, array, delimiter=\",\")"... | [
"0.7357954",
"0.65711415",
"0.6373912",
"0.62279445",
"0.594819",
"0.5937351",
"0.5874647",
"0.5837374",
"0.5795655",
"0.57782453",
"0.5759954",
"0.5728941",
"0.57221186",
"0.5701853",
"0.5681257",
"0.5673999",
"0.565141",
"0.56346345",
"0.56204844",
"0.5572057",
"0.556498",
... | 0.6072416 | 4 |
Returns the recommended size for the widget. This implementation of the recommended size always consider there is an icon. In this way it avoid to update the layout when the waiting icon is displayed. | def sizeHint(self):
self.ensurePolished()
w = 0
h = 0
opt = qt.QStyleOptionButton()
self.initStyleOption(opt)
# Content with icon
# no condition, assume that there is an icon to avoid blinking
# when the widget switch to waiting state
ih = opt.i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def min_size(child: UIWidget) -> Tuple[float, float]:\n h_allowed, v_allowed = UIBoxLayout._layouting_allowed(child)\n shmn_w, shmn_h = child.size_hint_min or (None, None)\n shmn_w = shmn_w or 0 if h_allowed else child.width\n shmn_h = shmn_h or 0 if v_allowed else child... | [
"0.6626963",
"0.6470563",
"0.62772423",
"0.6254808",
"0.62088895",
"0.6168131",
"0.6168131",
"0.60849315",
"0.60563904",
"0.60503745",
"0.6049331",
"0.6007825",
"0.5997559",
"0.59700733",
"0.5933562",
"0.59171283",
"0.58454514",
"0.58270013",
"0.58184046",
"0.5814044",
"0.579... | 0.63782394 | 2 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.