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 |
|---|---|---|---|---|---|---|
backward pass including resetting gradients, gradient calculation and optimizer step | def backward_pass(self, loss):
self.optimizer.zero_grad()
self.optimizer.backward(loss)
self.optimizer.step() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def backward_and_step(self, loss):\n self.opt.zero_grad()\n loss.backward()\n self.opt.step()",
"def on_iter_backward(self, runner):\n runner.optimizer.zero_grad()\n runner.loss.backward()\n runner.optimizer.step()",
"def optimize(self, loss):\n loss.backward()\... | [
"0.79875684",
"0.7893537",
"0.7643079",
"0.76038754",
"0.7600277",
"0.7584493",
"0.7584493",
"0.7568484",
"0.7383987",
"0.73573744",
"0.73573744",
"0.73371553",
"0.7309111",
"0.7307651",
"0.7282246",
"0.72703415",
"0.7244259",
"0.7227183",
"0.7168998",
"0.7139221",
"0.7132038... | 0.77561975 | 2 |
Plot an offline scatter plot colored according to the categories in the 'name' column. | def offline_plotly_scatter3d(df, x=0, y=1, z=-1):
data = []
# clusters = []
colors = ['rgb(228,26,28)', 'rgb(55,126,184)', 'rgb(77,175,74)']
# df.columns = clean_columns(df.columns)
x = get_array(df, x, default=0)
y = get_array(df, y, default=1)
z = get_array(df, z, default=-1)
for i i... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_scatter(\r\n self,\r\n name: str,\r\n data: Union[Dict, DataFrame],\r\n mapping: Dict = {\r\n \"x\": \"x\",\r\n \"y\": \"y\",\r\n \"z\": \"z\",\r\n \"c\": \"c\",\r\n \"cs\": \"cs\",\r\n \"s\": \"s\",\r\n ... | [
"0.6647969",
"0.64370847",
"0.6414702",
"0.6337711",
"0.632223",
"0.626393",
"0.6231332",
"0.6227046",
"0.61336267",
"0.61144465",
"0.61051357",
"0.6103127",
"0.6064104",
"0.6033297",
"0.60206234",
"0.5994302",
"0.59881645",
"0.5983651",
"0.59512687",
"0.5940645",
"0.59322536... | 0.61147153 | 9 |
r""" Write a plotly scatter plot to HTML file that doesn't require server >>> from nlpia.loaders import get_data | def offline_plotly_data(data, filename=None, config=None, validate=True,
default_width='100%', default_height=525, global_requirejs=False):
config_default = dict(DEFAULT_PLOTLY_CONFIG)
if config is not None:
config_default.update(config)
with open(os.path.join(DATA_PATH, 'plo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def showPlotlyScatter(self, DataFrame, x_axis, y_axis, saving_directory):\r\n fig = px.scatter(DataFrame, x = x_axis, y=y_axis, hover_name= DataFrame.index, color= 'Lib_Tag_contour_ratio',\r\n hover_data= ['Contour_soma_ratio_Lib', 'Lib_Tag_contour_ratio', 'ImgNameInfor_Lib'], width=... | [
"0.76672214",
"0.6979819",
"0.6428057",
"0.6412158",
"0.6389086",
"0.6368543",
"0.6284895",
"0.6268731",
"0.6265308",
"0.6260518",
"0.6255768",
"0.623742",
"0.6134501",
"0.6121691",
"0.6094893",
"0.6089103",
"0.6081132",
"0.60801375",
"0.60656464",
"0.60282373",
"0.602177",
... | 0.62138456 | 12 |
Define state as a max between given value and current state | def state(self, value: Mapping[str, Any]):
if not self._cursor_value:
self._cursor_value = value[self.cursor_field]
else:
self._cursor_value = max(value[self.cursor_field], self.state[self.cursor_field]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def state_max(self) -> float:\n raise NotImplementedError",
"def max_value(gameState):\n if terminal_test(gameState): return -1",
"def max_value(self, state, max_alpha, max_beta, max_depth):\r\n if state.terminal_test():\r\n return state.utility(0)\r\n if max_depth <=0 :\r\n ... | [
"0.8046037",
"0.73848",
"0.71485466",
"0.6830914",
"0.6804619",
"0.67381334",
"0.67381334",
"0.6720939",
"0.66726005",
"0.66294926",
"0.660929",
"0.6552503",
"0.6487182",
"0.64636034",
"0.6463524",
"0.6461794",
"0.6461518",
"0.64550906",
"0.64550906",
"0.63911355",
"0.6373331... | 0.6045415 | 56 |
Return a Dash Bio VolcanoPlot figure. | def VolcanoPlot(
dataframe,
effect_size='EFFECTSIZE',
p='P',
snp='SNP',
gene='GENE',
annotation=None,
logp=True,
xlabel=None,
ylabel='-log10(p)',
point_size=5,
col=None,
effect_size_line=None,
effect_size_line_color=... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_plot(chart: Chart) -> Figure:\n factory = ChartFactory(recipes=ChartService.get_supported_recipes(),\n data_frame_service=CommonServiceProvider.DataFrameService)\n plot = factory.create_object(document=chart)\n\n return plot",
"def init_plot(self):\... | [
"0.6578634",
"0.6476686",
"0.6263365",
"0.6253599",
"0.6116642",
"0.61098856",
"0.6105884",
"0.6092421",
"0.6086809",
"0.6062914",
"0.6020976",
"0.5964846",
"0.59199643",
"0.5901562",
"0.58989584",
"0.58851963",
"0.58734053",
"0.58660364",
"0.5818487",
"0.5813982",
"0.5798204... | 0.0 | -1 |
Retrieves and parses command line arguments. This function returns these args as an ArgumentParser object. | def get_input_args():
parser = argparse.ArgumentParser(description='Get NN arguments')
#Define arguments
parser.add_argument('input', type=str, help='image to process and predict')
parser.add_argument('checkpoint', type=str, help='cnn to load')
parser.add_argument('--top_k', default=1, type=int, hel... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_arguments():\n\n args = Arguments()\n parser = argparse.ArgumentParser(\"Update river flow directions\")\n parser.add_argument('python_config_filename',\n metavar='python-config-filename',\n help='Full path to python configuration file',\n ... | [
"0.7915089",
"0.7874073",
"0.78260416",
"0.7797556",
"0.77465063",
"0.7733761",
"0.7704409",
"0.7616255",
"0.7606398",
"0.7600025",
"0.7593232",
"0.7591966",
"0.7583916",
"0.7553946",
"0.7553946",
"0.7524609",
"0.7522585",
"0.75094384",
"0.74847585",
"0.74738586",
"0.74711",
... | 0.0 | -1 |
Handle ``PUT`` on a single recipe URI. | def put(environ, start_response):
recipe_name = web.get_route_value(environ, 'recipe_name')
recipe_name = web.handle_extension(environ, recipe_name)
recipe = Recipe(recipe_name)
store = environ['tiddlyweb.store']
length, _ = web.content_length_and_type(environ)
usersign = environ['tiddlyweb.us... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def put(self, user, recipe_id):\n data = request.json\n return update_recipe(data=data, user=user, recipe_id=recipe_id)",
"def _put(self, path=\"\", **kwargs):\n uri = force_json(self.uri + path)\n return self.client.request(uri, method=\"PUT\", **kwargs)",
"def put(self, url_pattern):\... | [
"0.71065557",
"0.66814363",
"0.66313374",
"0.6571021",
"0.6509408",
"0.6506947",
"0.65000474",
"0.65000474",
"0.65000474",
"0.64999396",
"0.6412483",
"0.63742685",
"0.6357377",
"0.633969",
"0.63349664",
"0.6286264",
"0.62348366",
"0.6229589",
"0.6206279",
"0.6148418",
"0.6145... | 0.66022515 | 3 |
Returns the absolute class name for a class. | def get_full_path_to_class(cls: Type) -> str:
mod = cls.__module__
name = cls.__name__
return f"{mod}.{name}" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def full_classname(cls: type) -> str:\n return ClassImporter.full_classname(cls)",
"def class_name(cls):\n return cls.__name__",
"def class_name(cls):\n return cls.__name__",
"def _get_classname(cls):\n return cls.__name__",
"def fullname(cls):\n module = cls.__module__\n if modul... | [
"0.77173656",
"0.7697317",
"0.7697317",
"0.7480543",
"0.74526787",
"0.74023646",
"0.73802257",
"0.73693806",
"0.73423505",
"0.72857124",
"0.7243512",
"0.7195636",
"0.7194401",
"0.7151744",
"0.71017313",
"0.70673543",
"0.7065925",
"0.6992451",
"0.6990851",
"0.6953785",
"0.6945... | 0.77794665 | 0 |
Validate email asynchronously by ajax, and check if it's already been taken or not. | def validate_email(request):
# get submitted email.
email = request.GET.get('email', None)
try:
# check if an account with this email already exists, in case of editing user's profile.
is_email_taken = User.objects.filter(email__iexact=email).exclude(email__iexact=request.user.email).ex... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_register_email():\n email = request.args.get('email')\n if not email:\n return jsonify({'valid': False, 'error': 'Please provide an email address'})\n user = User.query.filter_by(email=email).first()\n if user:\n # The email already exists\n return jsonify({'valid': Fa... | [
"0.65383947",
"0.6499649",
"0.6324313",
"0.6295229",
"0.6286601",
"0.62575096",
"0.6187424",
"0.6180632",
"0.6177483",
"0.6150864",
"0.6137513",
"0.61340624",
"0.6101222",
"0.6099478",
"0.60955364",
"0.6081559",
"0.60776854",
"0.60604846",
"0.6054821",
"0.60535175",
"0.605278... | 0.70670396 | 1 |
Returns the transport used by the client instance. | def transport(self) -> MetadataServiceTransport:
return self._client.transport | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def transport(self):\n return self._transport",
"def transport(self) -> TraceServiceTransport:\n return self._client.transport",
"def transport(self) -> ServiceControllerTransport:\n return self._client.transport",
"def transport(self) -> Controller2Transport:\n return self._clien... | [
"0.82946277",
"0.7887542",
"0.773594",
"0.76806635",
"0.7674273",
"0.76357967",
"0.7558095",
"0.7551682",
"0.75303864",
"0.74958986",
"0.7488142",
"0.7436853",
"0.7423566",
"0.7368433",
"0.73340607",
"0.721926",
"0.7109823",
"0.7102308",
"0.68808985",
"0.68144",
"0.6671675",
... | 0.773068 | 3 |
See if a given path matches the ignore patterns | def should_ignore_path(path):
for p in config.compiled_ignore_patterns:
if p.match(path):
return True
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _ignore(path):\n return any(re.match(pattern, path) for pattern in ignore)",
"def ignore_patterns(self, relpath):\n names = relpath.split('/')\n for name in names:\n for pattern in self.ignore:\n if fnmatch.fnmatch(name, pattern):\n return Tru... | [
"0.8779983",
"0.8005157",
"0.79781073",
"0.7942744",
"0.7879924",
"0.78770757",
"0.7858875",
"0.7844425",
"0.77100796",
"0.7588514",
"0.7498782",
"0.74969023",
"0.7493798",
"0.73175395",
"0.7297367",
"0.7267061",
"0.6970554",
"0.6960759",
"0.6912652",
"0.6853699",
"0.6604795"... | 0.8342056 | 1 |
should compare the same object as equal to itself | def test_object_equal(self):
test = self.Test({ 'id': 1, 'name': 'foo' })
self.assertEqual(test, test) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __eq__(self, obj):\r\n return assert_(self.obj == obj, '%r != %r' % (self.obj, obj))",
"def testEquality(self):\n pass",
"def __eq__(self,*args):\r\n pass",
"def __eq__(self,*args):\r\n pass",
"def __eq__(self,*args):\r\n pass",
"def __eq__(self,*args):\r\n pass",
"def __eq__(self... | [
"0.7900897",
"0.78575915",
"0.7766319",
"0.7766319",
"0.7766319",
"0.7766319",
"0.7766319",
"0.7766319",
"0.7766319",
"0.7766319",
"0.7766319",
"0.7766319",
"0.7766319",
"0.7766319",
"0.7766319",
"0.7766319",
"0.7766319",
"0.7766319",
"0.7766319",
"0.7766319",
"0.7766319",
... | 0.0 | -1 |
should compare two differnt objects with the same attributes as equal | def test_attributes_equal(self):
test1 = self.Test({ 'id': 2, 'name': 'Poop Head' })
test2 = self.Test({ 'id': 2, 'name': 'Poop Head' })
self.assertEqual(test1, test2) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_compare() -> None:\n\n obj = SpecificLocation()\n obj2 = SpecificLocation()\n\n assert obj != obj2\n\n obj._id = obj2.id\n\n assert obj == obj2",
"def testEquality(self):\n pass",
"def __eq__(self, other):\n for attr in self._attrs_to_save:\n try:\n if getatt... | [
"0.7704253",
"0.76825106",
"0.75898856",
"0.750284",
"0.7445646",
"0.7417055",
"0.7417055",
"0.7417055",
"0.7417055",
"0.7417055",
"0.7417055",
"0.7417055",
"0.7417055",
"0.7417055",
"0.7417055",
"0.7417055",
"0.7417055",
"0.7417055",
"0.7417055",
"0.7417055",
"0.7417055",
... | 0.78216887 | 0 |
Check that a nonNone default value forces the field to be required. | def test_config_option_implicitly_required():
class Config(config.Config):
a = config.option(int, default=12, help="")
c = config.structure({}, Config)
assert c.a == 12
with pytest.raises(config.ConfigError):
config.structure({"a": None}, Config) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_required(self):\r\n return self.default == self.NotSpecified",
"def required(self) -> bool:\n return self._default is None",
"def _validate_usage_of_optional(self) -> None:\n # Because None can be the default value, None cannot be used to to indicate no default. This is why we need ... | [
"0.765269",
"0.7354304",
"0.7213254",
"0.7161627",
"0.7039247",
"0.693941",
"0.693941",
"0.69136155",
"0.6909671",
"0.68963367",
"0.68777597",
"0.68144995",
"0.66802996",
"0.6677432",
"0.66603875",
"0.6642277",
"0.6600587",
"0.65716815",
"0.6554937",
"0.65450525",
"0.6544976"... | 0.0 | -1 |
Check that long lists are split onto multiple lines. | def _test_config_generator_list_wrap():
class Config(config.Config):
a = config.option_list(str, default=["abcdefghijklmnopqrstuvwxyz" for _ in range(2)], help="")
b = config.option_list(str, default=["abcdefghijklmnopqrstuvwxyz" for _ in range(5)], help="")
abcdefghijklmnopqrstuvwxyzabcdefg... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def checkLines(list, max_length):\n problems = []\n for i in range(len(list)):\n lineLength = len(list[i])\n if lineLength > max_length:\n problems.append((i, lineLength))\n return problems",
"def test_with_big_lists(self):\n\n self.check_markdown(\n '''\n ... | [
"0.71146876",
"0.6971321",
"0.6198594",
"0.61937034",
"0.6099612",
"0.60898215",
"0.6007359",
"0.5999892",
"0.59859943",
"0.5977612",
"0.5969444",
"0.59251034",
"0.58803207",
"0.58783567",
"0.58511686",
"0.58475137",
"0.58333355",
"0.5833152",
"0.58261544",
"0.58165604",
"0.5... | 0.0 | -1 |
Return the age of log file. | def getLastAccessTime(logFileLocation):
lastAccessTime = 0
try:
lastAccessTime = os.path.getmtime(logFileLocation)
lastAccessTime = datetime.fromtimestamp(lastAccessTime)
except OSError as e:
return S_ERROR('Failed to access logfile %s: %r' % (logFileLocation, e))
now = datetime.now()... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_file_age(self, filepath):\n try:\n fileage = os.path.getmtime(filepath)\n return fileage\n except:\n return 0",
"def file_creation_age(file_path):\n current_time = datetime.now()\n # Seconds passed since the file was created\n seconds_passed = (curr... | [
"0.7921006",
"0.72193176",
"0.6971554",
"0.68579304",
"0.6819083",
"0.6711168",
"0.65471953",
"0.6530719",
"0.65250534",
"0.6502438",
"0.64730096",
"0.64608926",
"0.645851",
"0.645851",
"0.645851",
"0.645851",
"0.64432013",
"0.6396569",
"0.6395261",
"0.63865286",
"0.638536",
... | 0.6537003 | 7 |
Gets final hidden layer of encoder. | def get_sequence_output(self):
return self.sequence_output | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_hidden(self, encoder_final):\n\n #print(\"encoder final shape\")\n #print(encoder_final[0].size())\n if encoder_final is None:\n return None # start with zeros\n\n return (torch.tanh(self.bridge_hidden(encoder_final[0])),\n torch.tanh(self.bridge_cell... | [
"0.7006583",
"0.6922263",
"0.68968236",
"0.6708588",
"0.66544545",
"0.6611878",
"0.6299378",
"0.62945074",
"0.6275004",
"0.6104302",
"0.61022246",
"0.6074981",
"0.60732865",
"0.6060805",
"0.6057162",
"0.603394",
"0.603394",
"0.6012982",
"0.600515",
"0.5962949",
"0.59489095",
... | 0.0 | -1 |
Gets output of the embedding lookup (i.e., input to the transformer). | def get_embedding_output(self):
return self.embedding_output | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def call(self,\n inputs: tf.Tensor,\n **kwargs):\n # one dim case\n # out = self.embeddings[inputs[0]]\n\n # this feels like cheating, read docs for explanation\n out = embedding_ops.embedding_lookup(self.embeddings, inputs)\n return out",
"def link(self... | [
"0.6986077",
"0.66996443",
"0.6534779",
"0.63396305",
"0.63027084",
"0.6292289",
"0.62163746",
"0.617486",
"0.61579096",
"0.6146358",
"0.59466267",
"0.5914946",
"0.5910499",
"0.5906703",
"0.5886634",
"0.5854984",
"0.58413535",
"0.58183324",
"0.58064854",
"0.5781095",
"0.57791... | 0.7624228 | 0 |
returns a string representation of the BSOption object | def __repr__(self):
s = 's = $%.2f, x = $%.2f, t = %.2f(years), sigma = %.3f, rf = %.3f, div = %.2f' % (self.s, self.x, self.t, self.sigma,self.rf, self.div)
return s | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __repr__(self):\n s = \"BSEuroPutOption, value = $%.2f, \\n\" %(self.value())\n s += \"parameters = (s = $%.2f, x = $%.2f, t = %.2f (years), sigma = %.3f, rf = %.3f) \" %(self.s, self.x, self.t, self.sigma, self.rf)\n return s",
"def __repr__(self):\r\n s = 'BSEuroCallOption, valu... | [
"0.773787",
"0.7642516",
"0.73350155",
"0.69675976",
"0.67735463",
"0.66991156",
"0.65292543",
"0.6447828",
"0.64417344",
"0.62740463",
"0.6220378",
"0.6197939",
"0.61706156",
"0.61609906",
"0.6159872",
"0.6159872",
"0.6157702",
"0.6157702",
"0.6157702",
"0.6157702",
"0.61577... | 0.0 | -1 |
wraps a string in bold tags | def embolden(string):
return "<b>"+string+"</b>" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def bold(self, string):\n return self.wrap(bold(string))",
"def bold(string):\n return BOLD + string + END",
"def bold(string):\n return BOLD + string + RESETFORMAT",
"def bold(string: str) -> str:\n return f\"**{string}**\"",
"def bold(self, s):\n return '\\x02%s\\x02' % s",
"def ... | [
"0.87868154",
"0.8213891",
"0.8043244",
"0.7600959",
"0.7528518",
"0.7392987",
"0.72981036",
"0.72303003",
"0.7189153",
"0.6988467",
"0.6918687",
"0.6858584",
"0.6844231",
"0.67710716",
"0.6743111",
"0.66819763",
"0.66660804",
"0.66519225",
"0.655517",
"0.6445993",
"0.6390534... | 0.7965965 | 3 |
Log of |det(dz/dx)| for the current batch. Format is batchsize x 1 or a number | def log_det_Jxz(self):
return self.log_det_xz | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def log_den(self, X):\n raise NotImplementedError()",
"def log_det_precisions(self):\n return tf.math.log(-2 * self.nat2)",
"def _log_det_observation_precision(self):\n num_data = self.prior_ssm.num_transitions + 1\n return tf.cast(num_data, default_float()) * tf.linalg.logdet(self.... | [
"0.71187943",
"0.67451066",
"0.6715801",
"0.6668082",
"0.65741295",
"0.65189755",
"0.65014344",
"0.6493583",
"0.6431923",
"0.6407491",
"0.6342445",
"0.6339861",
"0.6335362",
"0.62958735",
"0.62867486",
"0.6285825",
"0.62625396",
"0.6259284",
"0.62589186",
"0.6242301",
"0.6185... | 0.615125 | 24 |
Log of |det(dz/dx)| for the current batch. Format is batchsize x 1 or a number | def log_det_Jxz(self):
#return self.log_det_xz.output
log_det_Jxzs = []
for l in self.layers:
if hasattr(l, 'log_det_Jxz'):
log_det_Jxzs.append(l.log_det_Jxz)
if len(log_det_Jxzs) == 0:
return tf.ones((self.output_z.shape[0],))
if len(log_d... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def log_den(self, X):\n raise NotImplementedError()",
"def log_det_precisions(self):\n return tf.math.log(-2 * self.nat2)",
"def _log_det_observation_precision(self):\n num_data = self.prior_ssm.num_transitions + 1\n return tf.cast(num_data, default_float()) * tf.linalg.logdet(self.... | [
"0.71187943",
"0.67451066",
"0.6715801",
"0.6668082",
"0.65741295",
"0.65189755",
"0.65014344",
"0.6493583",
"0.6431923",
"0.6342445",
"0.6339861",
"0.6335362",
"0.62958735",
"0.62867486",
"0.6285825",
"0.62625396",
"0.6259284",
"0.62589186",
"0.6242301",
"0.618504",
"0.61512... | 0.6407491 | 9 |
Returns the log likelihood of z|x assuming a Normal distribution in z | def log_likelihood_z_normal(self, std=1.0):
#return self.log_det_Jxz - self.dim * tf.log(std) - (0.5 / (std**2)) * tf.reduce_sum(self.output_z**2, axis=1)
return self.log_det_Jxz - (0.5 / (std**2)) * tf.reduce_sum(self.output_z**2, axis=1) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def log_likelihood_z_lognormal(self, std=1.0):\n #return self.log_det_Jxz - self.dim * tf.log(std) - (0.5 / (std**2)) * tf.reduce_sum(self.output_z**2, axis=1)\n from deep_boltzmann.util import logreg\n logz = logreg(self.output_z, a=0.001, tf=True)\n ll = self.log_det_Jxz \\\n ... | [
"0.8374299",
"0.8052101",
"0.79414874",
"0.77996266",
"0.7722635",
"0.7595908",
"0.75002396",
"0.7361595",
"0.7192974",
"0.7176539",
"0.7117403",
"0.70730937",
"0.6979778",
"0.6979778",
"0.69058716",
"0.6886596",
"0.6834999",
"0.6824994",
"0.68220884",
"0.68017113",
"0.679667... | 0.79881 | 2 |
Returns the log likelihood of z|x assuming a Normal distribution in z | def log_likelihood_z_lognormal(self, std=1.0):
#return self.log_det_Jxz - self.dim * tf.log(std) - (0.5 / (std**2)) * tf.reduce_sum(self.output_z**2, axis=1)
from deep_boltzmann.util import logreg
logz = logreg(self.output_z, a=0.001, tf=True)
ll = self.log_det_Jxz \
- (0.5 ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def log_likelihood_z_uniform(self, std=1.0):\n return self.log_det_Jxz - self.dim * (tf.log(std) + 0.5*tf.log(12.0))",
"def log_likelihood_z_normal(self, std=1.0):\n #return self.log_det_Jxz - self.dim * tf.log(std) - (0.5 / (std**2)) * tf.reduce_sum(self.output_z**2, axis=1)\n return self.l... | [
"0.8052101",
"0.79881",
"0.79414874",
"0.77996266",
"0.7722635",
"0.7595908",
"0.75002396",
"0.7361595",
"0.7192974",
"0.7176539",
"0.7117403",
"0.70730937",
"0.6979778",
"0.6979778",
"0.69058716",
"0.6886596",
"0.6834999",
"0.6824994",
"0.68220884",
"0.68017113",
"0.6796676"... | 0.8374299 | 0 |
Returns the log likelihood of z|x assuming a Normal distribution in z | def reg_Jzx_uniform(self):
#return self.log_det_Jxz - self.dim * tf.log(std) - (0.5 / (std**2)) * tf.reduce_sum(self.output_z**2, axis=1)
Jmean = tf.reduce_mean(self.log_det_Jzx, axis=0, keepdims=True)
Jdev = tf.reduce_mean((self.log_det_Jzx - Jmean) ** 2, axis=1, keepdims=False)
return ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def log_likelihood_z_lognormal(self, std=1.0):\n #return self.log_det_Jxz - self.dim * tf.log(std) - (0.5 / (std**2)) * tf.reduce_sum(self.output_z**2, axis=1)\n from deep_boltzmann.util import logreg\n logz = logreg(self.output_z, a=0.001, tf=True)\n ll = self.log_det_Jxz \\\n ... | [
"0.8374299",
"0.8052101",
"0.79881",
"0.79414874",
"0.77996266",
"0.7722635",
"0.7595908",
"0.75002396",
"0.7361595",
"0.7192974",
"0.7176539",
"0.7117403",
"0.70730937",
"0.6979778",
"0.6979778",
"0.69058716",
"0.6886596",
"0.6834999",
"0.6824994",
"0.68220884",
"0.68017113"... | 0.0 | -1 |
Returns the log likelihood of z|x assuming a Normal distribution in z | def reg_Jxz_uniform(self):
#return self.log_det_Jxz - self.dim * tf.log(std) - (0.5 / (std**2)) * tf.reduce_sum(self.output_z**2, axis=1)
Jmean = tf.reduce_mean(self.log_det_Jxz, axis=0, keepdims=True)
Jdev = tf.reduce_mean((self.log_det_Jxz - Jmean) ** 2, axis=1, keepdims=False)
return ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def log_likelihood_z_lognormal(self, std=1.0):\n #return self.log_det_Jxz - self.dim * tf.log(std) - (0.5 / (std**2)) * tf.reduce_sum(self.output_z**2, axis=1)\n from deep_boltzmann.util import logreg\n logz = logreg(self.output_z, a=0.001, tf=True)\n ll = self.log_det_Jxz \\\n ... | [
"0.8374299",
"0.8052101",
"0.79881",
"0.79414874",
"0.77996266",
"0.7722635",
"0.7595908",
"0.75002396",
"0.7361595",
"0.7192974",
"0.7176539",
"0.7117403",
"0.70730937",
"0.6979778",
"0.6979778",
"0.69058716",
"0.6886596",
"0.6834999",
"0.6824994",
"0.68220884",
"0.68017113"... | 0.0 | -1 |
Invertible net where we have an energy function that defines p(x) | def __init__(self, energy_model, layers, prior='normal'):
self.energy_model = energy_model
super().__init__(energy_model.dim, layers, prior=prior) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def energy_function(self, x):\n \n return -T.dot(T.transpose(x), T.dot(self.W, x)) -\\\n T.dot(T.transpose(self.b), x)",
"def internalenergy(temp,pres):\n g = liq_g(0,0,temp,pres)\n g_t = liq_g(1,0,temp,pres)\n g_p = liq_g(0,1,temp,pres)\n u = g - temp*g_t - pres*g_p\n return u",
... | [
"0.7419931",
"0.6364436",
"0.63051885",
"0.62710774",
"0.621931",
"0.62186414",
"0.62151223",
"0.62044203",
"0.6196682",
"0.61875093",
"0.61738515",
"0.6169365",
"0.61257505",
"0.5988364",
"0.59833175",
"0.5979683",
"0.5969756",
"0.59552884",
"0.5948937",
"0.59143233",
"0.591... | 0.0 | -1 |
Computes the KL divergence with respect to z|x and the Boltzmann distribution | def log_KL_x(self, high_energy, max_energy, temperature_factors=1.0, explore=1.0):
from deep_boltzmann.util import linlogcut
x = self.output_x
# compute energy
E = self.energy_model.energy_tf(x) / temperature_factors
# regularize using log
Ereg = linlogcut(E, high_energy,... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def zkl_divergence(x, y, gamma):\n return np.sum([p_i*np.log(p_i/q_i) if q_i > 0 and p_i > 0 else p_i*gamma for (p_i, q_i) in zip(x, y)])",
"def kl_divergence(self) -> Tensor:\n return self.variational_strategy.kl_divergence().sum(dim=1).mean()",
"def kl_divergence(self, params_q, params_p):\n ... | [
"0.73194885",
"0.6800601",
"0.67152596",
"0.6631074",
"0.66211325",
"0.6593218",
"0.6564153",
"0.65228987",
"0.645516",
"0.64504325",
"0.6438612",
"0.64207846",
"0.6419551",
"0.6389412",
"0.63832414",
"0.6372765",
"0.63522947",
"0.6304835",
"0.62614137",
"0.62560815",
"0.6215... | 0.0 | -1 |
returns the area value of the Rectangle instance | def area(self):
return self.width * self.height | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def area(self):\n area = self.__width * self.__height\n return area",
"def area(self):\n area = self.__length * self.__width\n\n return area",
"def area(self):\n\n bbox = self.bbox\n area = Box.calculate_bbox_area(bbox, bbox_type=self.bbox_type)\n\n return area"... | [
"0.83310723",
"0.81932074",
"0.81750834",
"0.8110704",
"0.80919284",
"0.80919284",
"0.80919284",
"0.8070869",
"0.8053275",
"0.8053275",
"0.80387294",
"0.8026858",
"0.8020334",
"0.79981726",
"0.79934233",
"0.7991301",
"0.7991301",
"0.7991301",
"0.7991301",
"0.7991301",
"0.7990... | 0.7918754 | 36 |
overrides str function to print str representation of class rectangle | def __str__(self):
mge = "[Rectangle] ({}) {}/{} - {}/{}"
return mge.format(self.id, self.x, self.y, self.width, self.height) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __str__(self):\n string = \"[{}] ({}) {}/{} - {}\"\n if type(self) == Rectangle:\n return \"{}/{}\".format(string.format(self.__class__.__name__,\n self.id, self.__x, self.__y,\n self.__width)... | [
"0.8251934",
"0.8214726",
"0.81540245",
"0.8065911",
"0.80575407",
"0.80536073",
"0.80328065",
"0.8016705",
"0.8016491",
"0.80012286",
"0.80012286",
"0.79967195",
"0.79961205",
"0.79776675",
"0.7970977",
"0.7962452",
"0.7899565",
"0.7866911",
"0.78044516",
"0.77260256",
"0.76... | 0.8070847 | 3 |
Test exception is thrown for invalid units. | def test_convert_invalid_unit():
with pytest.raises(ValueError):
pressure_util.convert(5, INVALID_SYMBOL, VALID_SYMBOL)
with pytest.raises(ValueError):
pressure_util.convert(5, VALID_SYMBOL, INVALID_SYMBOL) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_invalid_units(self):\n with self.assertRaises(ValueError):\n UnitSystem(SYSTEM_NAME, INVALID_UNIT, LENGTH_METERS, VOLUME_LITERS,\n MASS_GRAMS)\n\n with self.assertRaises(ValueError):\n UnitSystem(SYSTEM_NAME, TEMP_CELSIUS, INVALID_UNIT, VOLUME_LITE... | [
"0.83258957",
"0.78139675",
"0.7631574",
"0.7581068",
"0.7342938",
"0.73141116",
"0.7308235",
"0.71758366",
"0.71450865",
"0.7093651",
"0.66453815",
"0.6619058",
"0.6604569",
"0.6598635",
"0.65867835",
"0.65744275",
"0.6570968",
"0.65651435",
"0.6536017",
"0.65293854",
"0.651... | 0.7282412 | 7 |
Will Returns Human Readable DateTime. | def getHumanReadableDateTime():
date = str(datetime.now(tz=pytz.UTC))
date = date.replace(' ', '_')
date = date.split(".")[0]
return date | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def friendly_date(self):\n return self.created_at.strftime(\"%a %b %#d %Y, %#I:%M %p\")",
"def friendly_date(self):\n\n return self.created_at.strftime(\"%a %b %-d %Y, %-I:%M %p\")",
"def get_date():\n\n return datetime.datetime.utcnow().isoformat()",
"def absolute_datetime(self):\n r... | [
"0.7558249",
"0.73753095",
"0.7270854",
"0.72556067",
"0.7236502",
"0.69647145",
"0.69028884",
"0.6853402",
"0.6826819",
"0.67846227",
"0.67596346",
"0.67223966",
"0.67189515",
"0.66683745",
"0.66611874",
"0.66576046",
"0.6645584",
"0.6644672",
"0.6642109",
"0.66390145",
"0.6... | 0.766314 | 0 |
Test that TIMESTAMP must not be used in the statements within the batch. | def only_one_timestamp_is_valid_test(self):
cursor = self.prepare()
assert_invalid(cursor, """
BEGIN BATCH USING TIMESTAMP 1111111111111111
INSERT INTO users (id, firstname, lastname) VALUES (0, 'Jack', 'Sparrow') USING TIMESTAMP 2
INSERT INTO users (id, firstname, la... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def only_one_timestamp_is_valid_test(self):\n session = self.prepare()\n assert_invalid(session, \"\"\"\n BEGIN BATCH USING TIMESTAMP 1111111111111111\n INSERT INTO users (id, firstname, lastname) VALUES (0, 'Jack', 'Sparrow') USING TIMESTAMP 2\n INSERT INTO users (id... | [
"0.7904787",
"0.71067333",
"0.6986716",
"0.6976093",
"0.6880897",
"0.6803434",
"0.6787158",
"0.6714683",
"0.6622782",
"0.6593199",
"0.6530206",
"0.6484508",
"0.6398412",
"0.62318414",
"0.6182994",
"0.6158569",
"0.60348415",
"0.59716976",
"0.5915833",
"0.5877905",
"0.581155",
... | 0.7978012 | 0 |
Create and return a sim from a jsonfile. | def sim_from_json(load_file, save_file):
with open(load_file, 'r', encoding='utf-8') as f:
data = f.read()
sim = simulation.Simulation.from_dict(json.loads(data), save_file)
return sim | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_new_sim(save_file):\n sim = simulation.Simulation(save_file, 10)\n return sim",
"def create_from_metadata(filename):\n with open(filename, 'r') as f:\n metadata = json.load(f)\n \n station = Station(\n metadata['name'],\n metadata['lat'],\n ... | [
"0.6553135",
"0.6365268",
"0.62937886",
"0.62749624",
"0.6254183",
"0.62221086",
"0.6218566",
"0.6198294",
"0.61360425",
"0.61343396",
"0.6109643",
"0.60871655",
"0.60871655",
"0.60871655",
"0.60868955",
"0.60771596",
"0.60673934",
"0.60392594",
"0.60215837",
"0.6014046",
"0.... | 0.80850667 | 0 |
Checks if a reference in a link belong to the same domain of main url | def __verify(self, href):
# change main url to avoid mistakes with http ou https
main = self.main_url.replace('https://', '').replace('http://', '')
forbiden = {"#", 'None'} # forbidden possible urls
if (href is None) or (href in forbiden):
return False
for item in [... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def same_domain(url1, url2):\n return urlparse.urlparse(url1).netloc == urlparse.urlparse(url2).netloc",
"def same_website(url_rec, u_rec):\n if isinstance(url_rec, string_types):\n url_rec = urlparse(url_rec)\n if isinstance(u_rec, string_types):\n u_rec = urlparse(u_rec)\n return (url... | [
"0.73090917",
"0.70712996",
"0.70522904",
"0.7006926",
"0.6926046",
"0.6848531",
"0.67798823",
"0.67535424",
"0.67276394",
"0.6687812",
"0.6677988",
"0.66523504",
"0.6609374",
"0.66068655",
"0.6594529",
"0.6583367",
"0.65833193",
"0.6549116",
"0.6488906",
"0.6482358",
"0.6473... | 0.62617743 | 25 |
Check if the href has the main url in it | def __add_main_site(self, href):
if self.main_url[8:] not in href:
return self.main_url + href
else:
return href | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_href(href):\n if bool(pattern.match(href)):\n if os.path.basename(urlparse.urlparse(href).path) not in file_list:\n return True\n return False",
"def is_href_valid(self, link):\n url = str(link['href'])\n # if it doesn't lead to a wiki page\n ... | [
"0.69956183",
"0.68633586",
"0.68588614",
"0.66229093",
"0.65787816",
"0.65394324",
"0.6412674",
"0.640948",
"0.6317994",
"0.6302858",
"0.6262675",
"0.62462294",
"0.62462294",
"0.62462294",
"0.6228748",
"0.6209845",
"0.61823964",
"0.61536324",
"0.61516476",
"0.61339986",
"0.6... | 0.69899434 | 1 |
Add `word` to trie | def add(self, word):
current_node = self.root
for char in word:
if char not in current_node.children: # checks if that char does not already exists in the children Trie
current_node.children[char] = TrieNode() # if it doesnt add it to the children dict
curren... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def addWord(self, word): \n\n # make trie for new word\n self.root.makeTrie(word)",
"def addWord(self, word):\n trie = self.trie\n for c in word:\n if c in trie.children:\n trie = trie.children[c]\n else:\n new_trie_node = TrieNode... | [
"0.9127098",
"0.91074383",
"0.907848",
"0.9077506",
"0.9059536",
"0.89692134",
"0.8944615",
"0.8935418",
"0.89311486",
"0.8908895",
"0.8865934",
"0.8834281",
"0.86890453",
"0.8627298",
"0.85813296",
"0.8530083",
"0.8507056",
"0.8489907",
"0.8469678",
"0.84570843",
"0.8452666"... | 0.8752977 | 12 |
Returns a dictionary representing the attributes of the program. Key is the name of the attribute and value is the value of the attribute. | def to_dict(self):
return {
"id": self.id,
"name": self.name,
"author": self.author,
"description": self.description
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_attributes(self) -> Dict[str, str]:\n pass",
"def to_dict(self):\n d = {}\n i = 0\n for entry in self.entries:\n d[i] = {}\n attributes = self.get_attribute_list()\n print (attributes)\n for data in attributes:\n d[i][... | [
"0.71279955",
"0.67011595",
"0.665576",
"0.660114",
"0.6585935",
"0.6542855",
"0.65284044",
"0.6526208",
"0.65027374",
"0.6495729",
"0.6495729",
"0.6495729",
"0.6458114",
"0.6431774",
"0.64283174",
"0.6409028",
"0.6380068",
"0.63597655",
"0.63487995",
"0.62992585",
"0.6290295... | 0.0 | -1 |
The cidr of the transit router. | def cidr(self) -> pulumi.Input[str]:
return pulumi.get(self, "cidr") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cidr(self):\n return self._cidr",
"def cidr(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"cidr\")",
"def cidr(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"cidr\")",
"def cidr(self) -> Optional[pulumi.Input[str]]:\n return pulumi.get(self, \"cidr\")",
"... | [
"0.86945623",
"0.84156954",
"0.84156954",
"0.82303774",
"0.82303774",
"0.82095766",
"0.8059019",
"0.7728895",
"0.75288427",
"0.7408683",
"0.7408683",
"0.7383583",
"0.73424345",
"0.7186849",
"0.7111201",
"0.7111201",
"0.7068118",
"0.7031968",
"0.6957247",
"0.6957247",
"0.69572... | 0.8289765 | 4 |
The cidr of the transit router. | def cidr(self) -> Optional[pulumi.Input[str]]:
return pulumi.get(self, "cidr") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cidr(self):\n return self._cidr",
"def cidr(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"cidr\")",
"def cidr(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"cidr\")",
"def cidr(self) -> pulumi.Input[str]:\n return pulumi.get(self, \"cidr\")",
"def cidr(s... | [
"0.86945623",
"0.84156954",
"0.84156954",
"0.8289765",
"0.8289765",
"0.82095766",
"0.8059019",
"0.7728895",
"0.75288427",
"0.7408683",
"0.7408683",
"0.7383583",
"0.73424345",
"0.7186849",
"0.7111201",
"0.7111201",
"0.7068118",
"0.7031968",
"0.6957247",
"0.6957247",
"0.6957247... | 0.82303774 | 6 |
The ID of the transit router cidr. | def transit_router_cidr_id(self) -> Optional[pulumi.Input[str]]:
return pulumi.get(self, "transit_router_cidr_id") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def transit_router_cidr_id(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"transit_router_cidr_id\")",
"def cidr(self):\n return self._cidr",
"def cidr(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"cidr\")",
"def cidr(self) -> pulumi.Output[str]:\n return pulum... | [
"0.89109325",
"0.7703837",
"0.7297802",
"0.7297802",
"0.723002",
"0.723002",
"0.71625143",
"0.7045166",
"0.7045166",
"0.68017185",
"0.67541784",
"0.6753667",
"0.6753667",
"0.6690866",
"0.6689298",
"0.6671992",
"0.6671992",
"0.6665464",
"0.6660024",
"0.66118807",
"0.66118807",... | 0.869731 | 1 |
The cidr of the transit router. | def cidr(self) -> pulumi.Output[str]:
return pulumi.get(self, "cidr") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cidr(self):\n return self._cidr",
"def cidr(self) -> pulumi.Input[str]:\n return pulumi.get(self, \"cidr\")",
"def cidr(self) -> pulumi.Input[str]:\n return pulumi.get(self, \"cidr\")",
"def cidr(self) -> Optional[pulumi.Input[str]]:\n return pulumi.get(self, \"cidr\")",
"de... | [
"0.86945623",
"0.8289765",
"0.8289765",
"0.82303774",
"0.82303774",
"0.82095766",
"0.8059019",
"0.7728895",
"0.75288427",
"0.7408683",
"0.7408683",
"0.7383583",
"0.73424345",
"0.7186849",
"0.7111201",
"0.7111201",
"0.7068118",
"0.7031968",
"0.6957247",
"0.6957247",
"0.6957247... | 0.84156954 | 2 |
The ID of the transit router cidr. | def transit_router_cidr_id(self) -> pulumi.Output[str]:
return pulumi.get(self, "transit_router_cidr_id") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def transit_router_cidr_id(self) -> Optional[pulumi.Input[str]]:\n return pulumi.get(self, \"transit_router_cidr_id\")",
"def cidr(self):\n return self._cidr",
"def cidr(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"cidr\")",
"def cidr(self) -> pulumi.Output[str]:\n ret... | [
"0.869731",
"0.7703837",
"0.7297802",
"0.7297802",
"0.723002",
"0.723002",
"0.71625143",
"0.7045166",
"0.7045166",
"0.68017185",
"0.67541784",
"0.6753667",
"0.6753667",
"0.6690866",
"0.6689298",
"0.6671992",
"0.6671992",
"0.6665464",
"0.6660024",
"0.66118807",
"0.66118807",
... | 0.89109325 | 0 |
Return the name of the PAF file loaded. | def getFileName(self):
return self.__fileName | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def name(self):\n return self._fname",
"def name(self):\n return self._fname",
"def name(self):\n return self._filename",
"def file_name(self):\n return self.lib.file_name",
"def get_file_name(self):\n return str(self.get_file())",
"def fname(self):\n return self... | [
"0.69864136",
"0.69864136",
"0.67658955",
"0.67350715",
"0.6675594",
"0.66285104",
"0.6600638",
"0.6597094",
"0.6595896",
"0.6512657",
"0.65045893",
"0.6471858",
"0.6470602",
"0.64446634",
"0.64239305",
"0.6421222",
"0.6418822",
"0.6401332",
"0.6394702",
"0.6394702",
"0.63947... | 0.6091893 | 54 |
Get the total number of keys stored in the object. | def getNoOfKeys(self):
return len(self.__keyList) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getNumberOfKeys(self) -> int:\n ...",
"def num_keys(self):\n return len(self.counter.keys())",
"def num_keys(self):\r\n return len(self.keys)",
"def __len__(self) -> int:\n return len(self._keys)",
"def __len__(self):\n total_objs = 0\n\n if self._shelve is not... | [
"0.8489995",
"0.83136815",
"0.8244224",
"0.7823753",
"0.77050674",
"0.769447",
"0.76926863",
"0.76926863",
"0.75723815",
"0.7553226",
"0.7507134",
"0.74596965",
"0.7294216",
"0.7262225",
"0.7257589",
"0.7257589",
"0.7237478",
"0.7237478",
"0.7194681",
"0.71627206",
"0.7126126... | 0.8165317 | 3 |
Return the flag indicating if repetition is allowed. | def getAllowRepetition(self):
return self.__allowRepetition | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_repetition(self):\n return self.id == 1",
"def isRepeated(self):\n return self._field.label == FieldDescriptor.LABEL_REPEATED",
"def is_repetition(self, num: int = 3) -> bool:\n\n if sum(self.history_board == self.board_fen()) == num:\n return True\n return False",... | [
"0.764577",
"0.6795931",
"0.6595148",
"0.60707384",
"0.6029471",
"0.60087514",
"0.599845",
"0.5987798",
"0.5855593",
"0.58078754",
"0.5796856",
"0.5702858",
"0.5668323",
"0.5661821",
"0.55755746",
"0.55629903",
"0.5538213",
"0.55026335",
"0.54799193",
"0.5477639",
"0.54690456... | 0.76677424 | 0 |
Distance between two lat/lon coordinates projected on a spheroid | def distance_latlon(tup1: tuple, tup2: tuple, earth_rad: float = 6373000) -> float:
lat1 = m.radians(abs(tup1[1]))
lon1 = m.radians(abs(tup1[0]))
lat2 = m.radians(abs(tup2[1]))
lon2 = m.radians(abs(tup2[0]))
dlon = lon2 - lon1
dlat = lat2 - lat1
a = m.sin(dlat / 2)**2 + m.cos(lat1) * m.cos... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculateDistanceBetweenPoints(lat1,lon1,lat2,lon2):\n\treturn Geodesic.WGS84.Inverse(lat1,lon1, lat2, lon2)['s12']",
"def distance(lat1, lon1, lat2, lon2):\n lon1, lat1 = math.radians(lon1), math.radians(lat1)\n lon2, lat2 = math.radians(lon2), math.radians(lat2)\n a = (math.sin((lat2 - lat1) / 2) ... | [
"0.75498575",
"0.729747",
"0.72824806",
"0.7265181",
"0.724874",
"0.7180079",
"0.71699756",
"0.7165861",
"0.71531",
"0.7145098",
"0.7129435",
"0.7119439",
"0.71142054",
"0.7099639",
"0.70838326",
"0.70574117",
"0.7045297",
"0.7008661",
"0.6995822",
"0.6995074",
"0.6987675",
... | 0.0 | -1 |
Administrators can delete inviteonly streams they aren't on | def test_archive_invite_only_stream_youre_not_on(self) -> None:
priv_stream = self.set_up_stream_for_archiving(
"privstream", subscribed=False, invite_only=True
)
self.archive_stream(priv_stream) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_delete_private_stream(self) -> None:\n stream = self.set_up_stream_for_archiving(\"newstream\", invite_only=True)\n self.archive_stream(stream)",
"def test_gather_subscriptions_excludes_deactivated_streams(self) -> None:\n realm = get_realm(\"zulip\")\n admin_user = self.exam... | [
"0.6664117",
"0.6240776",
"0.60496444",
"0.5912443",
"0.57832325",
"0.57769877",
"0.5746485",
"0.57452554",
"0.57219535",
"0.57131195",
"0.5665658",
"0.5631652",
"0.56143326",
"0.5597946",
"0.55795497",
"0.5577534",
"0.55647653",
"0.5506596",
"0.5494334",
"0.54667556",
"0.544... | 0.6763206 | 0 |
Updating the color property requires a `stream_id` key. | def test_set_color_missing_stream_id(self) -> None:
test_user = self.example_user("hamlet")
self.login_user(test_user)
result = self.api_post(
test_user,
"/api/v1/users/me/subscriptions/properties",
{
"subscription_data": orjson.dumps(
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_set_stream_color(self) -> None:\n test_user = self.example_user(\"hamlet\")\n self.login_user(test_user)\n\n old_subs, _ = gather_subscriptions(test_user)\n sub = old_subs[0]\n stream_id = sub[\"stream_id\"]\n new_color = \"#ffffff\" # TODO: ensure that this is d... | [
"0.70078856",
"0.6476678",
"0.6111998",
"0.60711956",
"0.60025185",
"0.58830035",
"0.5754468",
"0.56907576",
"0.56872857",
"0.565988",
"0.5650987",
"0.5626631",
"0.5622829",
"0.55978036",
"0.5592417",
"0.55915725",
"0.55909044",
"0.5537058",
"0.5530871",
"0.5528548",
"0.55036... | 0.6878284 | 1 |
A POST request to /api/v1/users/me/subscriptions/properties with stream_id and pin_to_top data pins the stream. | def test_set_pin_to_top(self) -> None:
user = self.example_user("hamlet")
self.login_user(user)
old_subs, _ = gather_subscriptions(user)
sub = old_subs[0]
stream_id = sub["stream_id"]
new_pin_to_top = not sub["pin_to_top"]
result = self.api_post(
user... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_ignored_parameters_in_subscriptions_properties_endpoint(self) -> None:\n test_user = self.example_user(\"hamlet\")\n self.login_user(test_user)\n\n subs = gather_subscriptions(test_user)[0]\n sub = subs[0]\n result = self.api_post(\n test_user,\n \"... | [
"0.56599194",
"0.48024607",
"0.48013276",
"0.47004077",
"0.4630014",
"0.46227482",
"0.46119663",
"0.4530242",
"0.4516009",
"0.45030025",
"0.44971225",
"0.44511876",
"0.4423986",
"0.44014698",
"0.43774408",
"0.43677157",
"0.43298918",
"0.43298918",
"0.43298918",
"0.43298918",
... | 0.6797759 | 0 |
Helper function to make up random stream names. It takes existing_stream_names and randomly appends a digit to the end of each, but avoids names of streams already in the realm. | def make_random_stream_names(self, existing_stream_names: List[str]) -> List[str]:
all_stream_names = [stream.name for stream in Stream.objects.filter(realm=self.test_realm)]
return [
random_stream
for stream in existing_stream_names
if (random_stream := stream + str(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def random_name_maker():\n new_out = ''\n for i in range(10):\n random_letter_or_number = random.randint(1, 2)\n if random_letter_or_number is 1:\n new_out += random_letter(letters)\n if random_letter_or_number is 2:\n new_out += str(random.randint(0, 9))\n if ne... | [
"0.6981561",
"0.6697233",
"0.6468715",
"0.63905436",
"0.6360237",
"0.6352137",
"0.63334024",
"0.62855977",
"0.6284564",
"0.62686986",
"0.625523",
"0.6244355",
"0.62091166",
"0.616273",
"0.6158709",
"0.61443776",
"0.6112437",
"0.60870415",
"0.60631084",
"0.6027959",
"0.6023615... | 0.80670154 | 0 |
Calling /api/v1/users/me/subscriptions should successfully return your subscriptions. | def test_successful_subscriptions_list(self) -> None:
result = self.api_get(self.test_user, "/api/v1/users/me/subscriptions")
json = self.assert_json_success(result)
self.assertIn("subscriptions", json)
for stream in json["subscriptions"]:
self.assertIsInstance(stream["name"]... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_subscriptions(self):\n url = '{}/v2/subscriptions'.format(self.url)\n r = requests.get(url, headers=self.headers_v2)\n return r.json()",
"def GetSubscriptions(self):\n\n return self.__GetJson(\"/subscriptions\", True)",
"def getAllSubscriptions(self):\n return self.re... | [
"0.8144859",
"0.8080085",
"0.753917",
"0.7472736",
"0.74356574",
"0.7425074",
"0.7326258",
"0.7290427",
"0.72422725",
"0.72076344",
"0.7205777",
"0.7129678",
"0.7062176",
"0.7000477",
"0.6924673",
"0.690489",
"0.6899301",
"0.6891315",
"0.688916",
"0.68891406",
"0.6884861",
... | 0.69122624 | 15 |
Calling /api/v1/users/me/subscriptions should successfully return your subscriptions. | def test_successful_subscriptions_list_subscribers(self) -> None:
result = self.api_get(
self.test_user,
"/api/v1/users/me/subscriptions",
{"include_subscribers": "true"},
)
json = self.assert_json_success(result)
self.assertIn("subscriptions", json)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_subscriptions(self):\n url = '{}/v2/subscriptions'.format(self.url)\n r = requests.get(url, headers=self.headers_v2)\n return r.json()",
"def GetSubscriptions(self):\n\n return self.__GetJson(\"/subscriptions\", True)",
"def getAllSubscriptions(self):\n return self.re... | [
"0.81450135",
"0.80804527",
"0.7539602",
"0.7473697",
"0.74352664",
"0.74259174",
"0.73258245",
"0.72908443",
"0.72081023",
"0.72055966",
"0.7130386",
"0.7062666",
"0.6999427",
"0.6925712",
"0.69119036",
"0.6905554",
"0.6898973",
"0.6891666",
"0.68895954",
"0.68895924",
"0.68... | 0.72423065 | 8 |
Check result of adding subscriptions. You can add subscriptions for yourself or possibly many principals, which is why emails map to subscriptions in the result. The result json is of the form | def helper_check_subs_before_and_after_add(
self,
subscriptions: List[str],
other_params: Dict[str, Any],
subscribed: List[str],
already_subscribed: List[str],
email: str,
new_subs: List[str],
realm: Realm,
invite_only: bool = False,
) -> None:... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_successful_subscriptions_list_subscribers(self) -> None:\n result = self.api_get(\n self.test_user,\n \"/api/v1/users/me/subscriptions\",\n {\"include_subscribers\": \"true\"},\n )\n json = self.assert_json_success(result)\n self.assertIn(\"subs... | [
"0.7130931",
"0.69147635",
"0.6768238",
"0.6549792",
"0.654823",
"0.65064013",
"0.6385411",
"0.63293594",
"0.6299312",
"0.62949014",
"0.6287627",
"0.6226601",
"0.62041754",
"0.6202195",
"0.6181561",
"0.6171163",
"0.6150765",
"0.6141041",
"0.61129403",
"0.61062837",
"0.6097066... | 0.6149947 | 17 |
Calling POST /json/users/me/subscriptions should successfully add streams, and should determine which are new subscriptions vs which were already subscribed. We add 2 new streams to the list of subscriptions and confirm the right number of events are generated. | def test_successful_subscriptions_add(self) -> None:
self.assertNotEqual(len(self.streams), 0) # necessary for full test coverage
add_streams = ["Verona2", "Denmark5"]
self.assertNotEqual(len(add_streams), 0) # necessary for full test coverage
# Three events should be sent for each str... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_successful_subscriptions_list_subscribers(self) -> None:\n result = self.api_get(\n self.test_user,\n \"/api/v1/users/me/subscriptions\",\n {\"include_subscribers\": \"true\"},\n )\n json = self.assert_json_success(result)\n self.assertIn(\"subs... | [
"0.717763",
"0.7158886",
"0.71441585",
"0.7035714",
"0.6945121",
"0.6822684",
"0.6777781",
"0.6714275",
"0.6705861",
"0.6696176",
"0.6685204",
"0.6677935",
"0.6547026",
"0.6546108",
"0.6535456",
"0.6457611",
"0.6455697",
"0.64337426",
"0.6414346",
"0.632618",
"0.63250893",
... | 0.7921093 | 0 |
Calling POST /json/users/me/subscriptions should successfully add streams, and should determine which are new subscriptions vs which were already subscribed. We add 2 new streams to the list of subscriptions and confirm the right number of events are generated. | def test_successful_subscriptions_add_with_announce(self) -> None:
self.assertNotEqual(len(self.streams), 0)
add_streams = ["Verona2", "Denmark5"]
self.assertNotEqual(len(add_streams), 0)
other_params = {
"announce": "true",
}
notifications_stream = get_stream... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_successful_subscriptions_add(self) -> None:\n self.assertNotEqual(len(self.streams), 0) # necessary for full test coverage\n add_streams = [\"Verona2\", \"Denmark5\"]\n self.assertNotEqual(len(add_streams), 0) # necessary for full test coverage\n # Three events should be sent... | [
"0.7920902",
"0.7176356",
"0.7157634",
"0.7142682",
"0.70347446",
"0.6944182",
"0.6822046",
"0.677652",
"0.671374",
"0.6705235",
"0.66835475",
"0.66768354",
"0.6545783",
"0.6545584",
"0.65340286",
"0.6455415",
"0.6455104",
"0.6432786",
"0.6412988",
"0.6324999",
"0.63248",
"... | 0.6695861 | 10 |
Calling POST /json/users/me/subscriptions on a stream whose name is >60 characters should return a JSON error. | def test_subscriptions_add_too_long(self) -> None:
# character limit is 60 characters
long_stream_name = "a" * 61
result = self.common_subscribe_to_streams(
self.test_user, [long_stream_name], allow_fail=True
)
self.assert_json_error(result, "Stream name too long (lim... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_invalid_stream_name(self) -> None:\n user = self.example_user(\"hamlet\")\n self.login_user(user)\n\n # For Cc category\n post_data_cc = {\n \"subscriptions\": orjson.dumps(\n [{\"name\": \"new\\n\\rstream\", \"description\": \"this is description\"}]\... | [
"0.6738403",
"0.6642602",
"0.65963423",
"0.655746",
"0.607935",
"0.5906915",
"0.5860505",
"0.5780331",
"0.5758636",
"0.57439435",
"0.5719216",
"0.56340575",
"0.55549365",
"0.5535053",
"0.5503758",
"0.5449273",
"0.54328763",
"0.54120636",
"0.5390392",
"0.53853905",
"0.537376",... | 0.7018307 | 0 |
Calling POST /json/users/me/subscriptions on a stream whose name contains null characters should return a JSON error. | def test_subscriptions_add_stream_with_null(self) -> None:
stream_name = "abc\000"
result = self.common_subscribe_to_streams(self.test_user, [stream_name], allow_fail=True)
self.assert_json_error(result, "Invalid character in stream name, at position 4!") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_subscriptions_exist_invalid_name(self) -> None:\n # currently, the only invalid stream name is the empty string\n invalid_stream_name = \"\"\n result = self.client_post(\"/json/subscriptions/exists\", {\"stream\": invalid_stream_name})\n self.assert_json_error(result, \"Stream ... | [
"0.7375475",
"0.7373949",
"0.700352",
"0.6818443",
"0.6164667",
"0.6038913",
"0.60387886",
"0.59878784",
"0.5935023",
"0.5873667",
"0.58409816",
"0.58177614",
"0.5775577",
"0.5766666",
"0.5693673",
"0.5679732",
"0.5644016",
"0.5605385",
"0.5601995",
"0.55457056",
"0.5545033",... | 0.742995 | 0 |
Calling POST /json/users/me/subscriptions on a stream whose name is invalid (as defined by valid_stream_name in zerver/views.py) should return a JSON error. | def test_subscriptions_add_invalid_stream(self) -> None:
# currently, the only invalid name is the empty string
invalid_stream_name = ""
result = self.common_subscribe_to_streams(
self.test_user, [invalid_stream_name], allow_fail=True
)
self.assert_json_error(result, ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_subscriptions_exist_invalid_name(self) -> None:\n # currently, the only invalid stream name is the empty string\n invalid_stream_name = \"\"\n result = self.client_post(\"/json/subscriptions/exists\", {\"stream\": invalid_stream_name})\n self.assert_json_error(result, \"Stream ... | [
"0.79770297",
"0.75760555",
"0.74482304",
"0.67799103",
"0.6697741",
"0.65327716",
"0.651602",
"0.6351088",
"0.61946285",
"0.6149539",
"0.5957199",
"0.59285265",
"0.5907205",
"0.59010005",
"0.586105",
"0.58405405",
"0.5786538",
"0.5720232",
"0.5688661",
"0.5686802",
"0.565880... | 0.79464895 | 1 |
If you try to send a message to an inviteonly stream to which you aren't subscribed, you'll get a 400. | def test_must_be_subbed_to_send(self) -> None:
user = self.example_user("hamlet")
self.login_user(user)
# Create Saxony as an invite-only stream.
self.assert_json_success(
self.common_subscribe_to_streams(user, ["Saxony"], invite_only=True)
)
cordelia = self.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def MessageStream(self, request, context):\n context.code(beta_interfaces.StatusCode.UNIMPLEMENTED)",
"def test_api_invalid_stream_id(self) -> None:\n user = self.example_user(\"hamlet\")\n self.login_user(user)\n result = self.api_patch(\n user,\n \"/api/v1/users/me... | [
"0.6293259",
"0.59939694",
"0.583926",
"0.583926",
"0.5817611",
"0.57378423",
"0.57314265",
"0.56171936",
"0.5575522",
"0.55697405",
"0.55582094",
"0.55378836",
"0.5523586",
"0.55209494",
"0.55193776",
"0.54837644",
"0.542238",
"0.5398714",
"0.53846693",
"0.53584003",
"0.5357... | 0.6104145 | 1 |
gather_subscriptions returns correct results with only 3 queries (We also use this test to verify subscription notifications to folks who get subscribed to streams.) | def test_gather_subscriptions(self) -> None:
hamlet = self.example_user("hamlet")
cordelia = self.example_user("cordelia")
othello = self.example_user("othello")
polonius = self.example_user("polonius")
streams = [f"stream_{i}" for i in range(10)]
for stream_name in stre... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_subscriptions(self):\n pass",
"def test_gather_subscriptions_excludes_deactivated_streams(self) -> None:\n realm = get_realm(\"zulip\")\n admin_user = self.example_user(\"iago\")\n non_admin_user = self.example_user(\"cordelia\")\n\n self.login_user(admin_user)\n\n... | [
"0.7180152",
"0.6905832",
"0.6743077",
"0.67010003",
"0.65475225",
"0.64838743",
"0.6447682",
"0.6446434",
"0.6360256",
"0.6235385",
"0.619644",
"0.6192966",
"0.61648875",
"0.6107395",
"0.6103083",
"0.6091207",
"0.6071036",
"0.60488987",
"0.6043497",
"0.60429054",
"0.6023643"... | 0.7423093 | 0 |
Gets the resource of this LakeFormationPolicy. | def resource(self):
return self._resource | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getResource(self):\n\n return self.__resource;",
"def getResource(self):\n return self.__resource;",
"def resource(self):\n return self.properties.get('resource',\n Entity(self.context, ResourcePath(\"resource\", self.resource_path)))",
"def resource... | [
"0.6940666",
"0.68735254",
"0.6825298",
"0.66122407",
"0.66122407",
"0.66122407",
"0.65922594",
"0.6402076",
"0.63630456",
"0.62961394",
"0.6286782",
"0.62815034",
"0.6264297",
"0.6256555",
"0.6240997",
"0.6134626",
"0.6119135",
"0.60838306",
"0.60838306",
"0.60838306",
"0.60... | 0.70141596 | 1 |
Returns true if both objects are equal | def __eq__(self, other):
if not isinstance(other, LakeFormationPolicy):
return False
return self.__dict__ == other.__dict__ | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __eq__(self, other):\n return are_equal(self, other)",
"def __eq__(self, other):\n return are_equal(self, other)",
"def __eq__(self,other):\n try: return self.object==other.object and isinstance(self,type(other))\n except: return False",
"def __eq__(self, other):\n if i... | [
"0.8088132",
"0.8088132",
"0.8054589",
"0.7982687",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
... | 0.0 | -1 |
Returns true if both objects are not equal | def __ne__(self, other):
return not self == other | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __ne__(self, other: object) -> bool:\n if self.__eq__(other):\n return False\n return True",
"def __ne__(self, other: object) -> bool:\n return not self.__eq__(other)",
"def __ne__(self, other) -> bool:\n return not self.__eq__(other)",
"def __eq__(self, other):\n ... | [
"0.845611",
"0.8391477",
"0.8144138",
"0.81410587",
"0.8132492",
"0.8093973",
"0.80920255",
"0.80920255",
"0.80920255",
"0.8085325",
"0.8085325",
"0.8076365",
"0.8076365",
"0.8065748"
] | 0.0 | -1 |
Calls exit_error_invalid_args_count() if args doesn't contain valid_count arguments. | def assert_args_count(args: list, valid_count: int) -> None:
supplied_count = args_count(args)
if (supplied_count != valid_count):
exit_error_invalid_args_count(valid_count, supplied_count) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def exit_error_invalid_args_count(valid_count: int, supplied_count: Optional[int] = None):\n\n\tmessage = f\"Invalid count of arguments. Program takes: {valid_count}.\"\n\tif (supplied_count != None):\n\t\tmessage = f\"{message} Supplied: {supplied_count}.\"\n\n\texit_error(message)",
"def __check_arg_count(self... | [
"0.8674835",
"0.7590196",
"0.66188866",
"0.6567171",
"0.65399253",
"0.6533574",
"0.6511294",
"0.64092904",
"0.6383142",
"0.6349497",
"0.63258755",
"0.6298191",
"0.6251684",
"0.62324464",
"0.6230083",
"0.62045735",
"0.618855",
"0.6183508",
"0.6101015",
"0.6092013",
"0.6090904"... | 0.81885666 | 1 |
Create an error string based on passed in error. | def unexpected_error_msg(error):
return 'Unexpected response: ' + pprint.pformat(vars(error)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def error_str(rc):\n return f\"{rc}: {mqtt.error_string(rc)}\"",
"def formatError(self,error):\n return '<font color=\"#f00\"><b><i>%s</i></b></font><br />\\n' % error",
"def build_error_msg(error_body: dict) -> str:\n ret_error_msg = ''\n for error in error_body:\n if error.get('field')... | [
"0.73095274",
"0.7287764",
"0.7283417",
"0.72543347",
"0.722687",
"0.7192914",
"0.7162707",
"0.71475774",
"0.6909231",
"0.68945414",
"0.6826777",
"0.67673916",
"0.6751678",
"0.66334087",
"0.65950435",
"0.65620273",
"0.65329736",
"0.64930344",
"0.646986",
"0.6468229",
"0.64511... | 0.6655718 | 13 |
Convert PlayerState to 3d array, according to setting or self.expand_setting | def state_to_image(
self,
state: PlayerState,
setting: Optional[ImageSetting] = None
) -> ndarray:
if setting is None:
setting = self.image_setting
return setting.expand(state) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_state(self):\n return np.append(self.game.game_board.get_board(),\n [self.game.player_1.color, self.game.player_2.color])[None, :]",
"def get_passable_state(self, state):\n # If multiple states are passed in\n if type(state) == list:\n # Add current... | [
"0.6340508",
"0.62073725",
"0.618363",
"0.6177575",
"0.6138544",
"0.61023897",
"0.6046654",
"0.59052515",
"0.5891819",
"0.5770476",
"0.57467777",
"0.5720701",
"0.57008666",
"0.5657188",
"0.559825",
"0.5590466",
"0.558708",
"0.55682117",
"0.55242723",
"0.55225",
"0.55225",
"... | 0.60218805 | 7 |
Just returns class name. | def name(self):
return self.__class__.__name__ | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def class_name(cls):\n return cls.__name__",
"def class_name(cls):\n return cls.__name__",
"def f_get_class_name(self):\n return self.__class__.__name__",
"def _get_classname(cls):\n return cls.__name__",
"def className(self):\n namevalue = self.__class__.__name__\n return... | [
"0.8612257",
"0.8612257",
"0.8451329",
"0.83691615",
"0.8278599",
"0.82737917",
"0.82489824",
"0.823736",
"0.82339054",
"0.80835176",
"0.8046143",
"0.78692305",
"0.7866261",
"0.7865424",
"0.7831046",
"0.78142464",
"0.7782266",
"0.7758106",
"0.7757658",
"0.76917195",
"0.767915... | 0.737087 | 38 |
Store the callback and register the listener. | def __init__(self, callback):
# Log the <instance>.__init__ message
listeners_logger.log_info(
'{0}.__init__<{1}>'.format(self.name, callback))
# Is the callback callable?
if not callable(callback):
# Raise an error
raise TypeError(
"... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def register(self, callback):\n self.callback = callback",
"def register_callback(self, callback):\n self.callbacks.add(callback)",
"def register_callback(self, callback: Callable[[], None]) -> None:\r\n print(\"register callback called\")\r\n self._callbacks.add(callback)",
"def ... | [
"0.78042704",
"0.7554645",
"0.7513273",
"0.74824274",
"0.74610966",
"0.73876834",
"0.72888297",
"0.7193799",
"0.7074786",
"0.7057321",
"0.7050894",
"0.7049262",
"0.70204175",
"0.6999958",
"0.6977152",
"0.6968809",
"0.69556",
"0.68905157",
"0.68640995",
"0.67902434",
"0.665619... | 0.58753824 | 82 |
Return the class name of the instance. | def name(self):
return self.__class__.__name__ | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def instance_class_name(instance):\n return class_name(instance.__class__)",
"def instance_class_name(instance):\n return class_name(instance.__class__)",
"def class_name(self) -> str:\n return pulumi.get(self, \"class_name\")",
"def class_name(self) -> str:\n return self.__class__.__name... | [
"0.8799161",
"0.8799161",
"0.87755907",
"0.87683207",
"0.87542987",
"0.8736012",
"0.86318684",
"0.84855556",
"0.84855556",
"0.8368539",
"0.82676184",
"0.820745",
"0.8119777",
"0.8075108",
"0.7962",
"0.79305005",
"0.79238296",
"0.79238296",
"0.78899693",
"0.7871995",
"0.784024... | 0.7852438 | 24 |
This function prints and plots the confusion matrix. Normalization can be applied by setting `normalize=True`. | def plot_df_heatmap(df, normalize=None, title='Heat-map',
cmap=plt.cm.Blues, colorbar=False):
rows = df.index.values
columns = df.columns.values
M = df.values
if normalize == 'rows':
M = M.astype('float') / M.sum(axis=1)[:, np.newaxis]
if normalize == 'cols':
M =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_confusion_matrix(cm, classes=[0,1], normalize=False, title='Confusion matrix', print_matrix=False):\n\n if normalize:\n cm = cm.astype('float') / cm.sum(axis=1)[:, np.newaxis]\n print(\"Normalized confusion matrix\")\n else:\n print('Confusion matrix, without normalization')\n\n... | [
"0.8193267",
"0.80943453",
"0.80284286",
"0.8018051",
"0.79932356",
"0.79901975",
"0.79797465",
"0.79750663",
"0.795993",
"0.79564947",
"0.79366505",
"0.79336995",
"0.7933488",
"0.79303867",
"0.79252106",
"0.7923493",
"0.7923058",
"0.79224193",
"0.79219115",
"0.79209906",
"0.... | 0.0 | -1 |
Assert requesting invalid parameters results in an exception. | def test_requesting_invalid_parameters(self):
self.parameter_store.client.get_parameters.return_value = {
"Parameters": [{"Name": "/test/foo", "Value": "foo_ssm_value_1"}],
"InvalidParameters": ["/test/bar"],
}
with self.assertRaises(
InvalidParametersError, ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_errors_on_bad_argument(self):\n self.assertRaises(Exception, Scope, 'foo')\n self.assertRaises(Exception, Scope, 1)\n self.assertRaises(Exception, Scope, [])\n self.assertRaises(Exception, Scope, tuple())",
"def testInvalidParams(self):\n h = self.getHandler()\n ... | [
"0.7220977",
"0.71887904",
"0.71345854",
"0.71127766",
"0.7086793",
"0.7021756",
"0.69963616",
"0.6944303",
"0.6936527",
"0.68840283",
"0.67962795",
"0.6784033",
"0.6778048",
"0.6777017",
"0.6776899",
"0.6776899",
"0.6776899",
"0.67491376",
"0.6744045",
"0.6727338",
"0.671990... | 0.7838738 | 0 |
get current app user info | def describe_users(self, **ignore):
action = const.ACTION_DESCRIBE_USERS
body = {}
return self.send_request(action, body) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def current_user_info():\n\n return current_user",
"def user_info(self):\n return self.auth.get_user_by_session()",
"def user_info(self):\n \n return self.auth.get_user_by_session()",
"def user_info(self):\r\n param = {}\r\n param['appid'] = self.apiKey\r\n param['non... | [
"0.8442659",
"0.83636963",
"0.8012747",
"0.7752025",
"0.7639662",
"0.762777",
"0.7581481",
"0.7564358",
"0.7219679",
"0.71680075",
"0.71646273",
"0.71396494",
"0.713194",
"0.7125246",
"0.7124216",
"0.71189857",
"0.7115819",
"0.71047884",
"0.71043926",
"0.70980585",
"0.7090471... | 0.0 | -1 |
Test normalization for new user email | def test_normalize_new_user_email(self):
email = "test@BLABLA.COM"
user = get_user_model().objects.create_user(
email=email,
password="123test"
)
self.assertEqual(user.email, email.lower()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_new_user_email_normalize(self):\n email = \"test@TadfhaafGRGS.pl\"\n user = get_user_model().objects.create_user(email, \"test123123123123\")\n\n self.assertEqual(email.lower(), user.email)",
"def test_new_user_email_normalized(self):\n email = 'test@GOOGLE.COM'\n user... | [
"0.8116695",
"0.8054276",
"0.7982595",
"0.7963752",
"0.79546344",
"0.7947971",
"0.7947971",
"0.7947971",
"0.7938652",
"0.79311675",
"0.7912408",
"0.7895399",
"0.7895248",
"0.78682977",
"0.77912503",
"0.77497125",
"0.7558612",
"0.753155",
"0.73046637",
"0.6872949",
"0.6853035"... | 0.79868704 | 2 |
Test the institute string representation | def test_institute_name(self):
institute = models.Institute.objects.create(
name='Fachbereich 1'
)
self.assertEqual(str(institute), institute.name) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_speciality_str_representation(speciality):\n assert str(speciality) == \"Electrical\"",
"def test_string_representation(self):\n test_school_program = SchoolProgram.objects.get(id=self.school_program.id)\n self.assertEqual(str(test_school_program), \"Test School 1 - MS Computer Science\... | [
"0.6579445",
"0.6534256",
"0.6420383",
"0.63152367",
"0.62751704",
"0.6232238",
"0.62182575",
"0.61887026",
"0.6175775",
"0.615586",
"0.614336",
"0.6088651",
"0.60442436",
"0.60341144",
"0.6010713",
"0.60005987",
"0.59967566",
"0.599461",
"0.5977255",
"0.59763044",
"0.5971291... | 0.71835446 | 0 |
Compute the DamerauLevenshtein distance between two given strings (s1 and s2) | def damerau_levenshtein_distance(comp_sec):
s1 = comp_sec['log_trace']
s2 = comp_sec['sim_trace']
p1 = comp_sec['proc_log_trace']
p2 = comp_sec['proc_sim_trace']
w1 = comp_sec['wait_log_trace']
w2 = comp_sec['wait_sim_trace']
d = {}
lenstr1 = len(s1)
lenstr2 = len(s2)
for i in ra... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def damerau_levenshtein_distance(s1, s2):\n\n utils.check_for_none(s1, s2)\n utils.check_for_type(str, s1, s2)\n\n # s1 = utils.unicode_normalize(s1)\n # s2 = utils.unicode_normalize(s2)\n\n n1, n2 = len(s1), len(s2)\n infinite = n1 + n2\n\n char_arr = defaultdict(int)\n dp = [[0] * (n2 + 2... | [
"0.869066",
"0.8614351",
"0.85402244",
"0.8427282",
"0.83570415",
"0.8123967",
"0.8115778",
"0.80783546",
"0.8030132",
"0.79762626",
"0.79697436",
"0.7839574",
"0.7833915",
"0.78226405",
"0.76690876",
"0.76484764",
"0.7633547",
"0.76100206",
"0.7577636",
"0.7529228",
"0.75243... | 0.73576826 | 29 |
Count the English and Chinese characters in the text. | def stats_text(test):
stats_text_en(test)
stats_text_cn(test) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getWordCharCount(w):\r\n rus = len(re.findall(r\"[а-я]\",w))\r\n eng = len(re.findall(r\"[a-z]\",w))\r\n c = len(w) \r\n return c, rus, eng",
"def count_characters(text):\n counted_characters = initialize_dictionary_with_characters()\n for char in next_uppercase_character(text.upper()):\... | [
"0.7445302",
"0.69162",
"0.6891924",
"0.68405837",
"0.68298715",
"0.67733335",
"0.66587394",
"0.66328967",
"0.6575748",
"0.64793336",
"0.6435962",
"0.6396239",
"0.6356924",
"0.6310573",
"0.63030386",
"0.6237408",
"0.62349933",
"0.62160414",
"0.61313826",
"0.61192393",
"0.6108... | 0.5676822 | 56 |
Yield successive nsized chunks from l. | def chunks(_class, l, n):
# CITE: http://stackoverflow.com/questions/312443/how-do-you-split-a-list-into-evenly-sized-chunks-in-python
for i in xrange(0, len(l), n):
yield l[i:i+n] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _chunk(self, l, n):\n for i in range(0, len(l) + 1, n):\n yield l[i:i + n]",
"def chunks(self, l, n):\n for i in range(0, len(l), n):\n yield l[i:i + n]",
"def __chunks(l, n):\n for i in range(0, len(l), n):\n yield l[i:i + n]",
"def get_chunks(self, ... | [
"0.8038813",
"0.79248375",
"0.7923423",
"0.7885103",
"0.78773195",
"0.7815877",
"0.77655786",
"0.77556044",
"0.77441615",
"0.7731815",
"0.77288336",
"0.772473",
"0.77028215",
"0.76889825",
"0.76889825",
"0.7664208",
"0.76570904",
"0.7655856",
"0.7655856",
"0.76458347",
"0.764... | 0.7547221 | 23 |
If the savedir option was specified, save the facts into a JSON file. If the savedir option was specified, save the facts into a JSON file named savedir/hostnamefacts.json. The filename begins with the value of the hostname fact returned from the Junos device, which might be different than the value of the host option ... | def save_facts(junos_module, facts):
if junos_module.params.get('savedir') is not None:
save_dir = junos_module.params.get('savedir')
file_name = '%s-facts.json' % (facts['hostname'])
file_path = os.path.normpath(os.path.join(save_dir, file_name))
junos_module.logger.debug("Saving fa... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save(self, savedir='.', savename='savehyperparams.json'):\n\n with open(os.path.join(savedir, savename), mode='w') as f:\n json.dump(self, f, indent=1, sort_keys=True)",
"def save(self):\r\n if not self.filename:\r\n raise IOError(errors['NoConfigFileYet'])\r\n self.onSave()\r\n stuff ... | [
"0.63701177",
"0.59545135",
"0.59300727",
"0.57568806",
"0.5676412",
"0.5674643",
"0.5669946",
"0.56519395",
"0.559214",
"0.5569398",
"0.5562959",
"0.5552393",
"0.5486326",
"0.54521614",
"0.5442608",
"0.5419135",
"0.5403201",
"0.538388",
"0.5360428",
"0.5349281",
"0.5343762",... | 0.7009845 | 0 |
Check whether user is logged in. | def logincheck(userid):
if userid:
is_loggedin = db_is_loggedin.find_one({"user": str(userid)})
if is_loggedin:
if is_loggedin.get("is_loggedin") == True:
msg = {'id':str(userid)}
return jsonify(msg)
else:
msg = {"status" : { "t... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_logged_in():\n return 'user' in session",
"def logged_in():\n\n if current_user.is_authenticated:\n return True\n\n return False",
"def logged_in(self):\n return self.auth.get_user_by_session() is not None",
"def isLoggedIn(self):\n session = self.getSession()\n if ses... | [
"0.8550264",
"0.8430865",
"0.842565",
"0.8422171",
"0.8322607",
"0.819919",
"0.8186215",
"0.81482023",
"0.8146313",
"0.8123521",
"0.8088509",
"0.8048632",
"0.80032516",
"0.79818857",
"0.79768604",
"0.7788634",
"0.7776764",
"0.7730989",
"0.7611326",
"0.7557335",
"0.7529689",
... | 0.0 | -1 |
computes the unit vector pointing from lower ball center to upper ball center | def _compute_e_S1S2(self, x):
psi = x[PSI_IDX]
return np.array([-np.sin(psi), np.cos(psi)]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def center(self):\n return (self.upper_right + self.lower_left) * 0.5",
"def center(self):\n return self._lower + 0.5 * (self._upper - self._lower)",
"def unit(self):\r\n return Vector(self.x/self.length(), self.y/self.length())",
"def center(self):\n try: \n return sel... | [
"0.6872381",
"0.68100834",
"0.67631817",
"0.67245555",
"0.65239817",
"0.6494609",
"0.6443005",
"0.64135104",
"0.64113754",
"0.6337893",
"0.6320479",
"0.6291351",
"0.62604433",
"0.6256253",
"0.6245519",
"0.6242754",
"0.622877",
"0.62194383",
"0.62183803",
"0.6168003",
"0.61501... | 0.0 | -1 |
Sets the CPU cores online. core_str a comma separated string, e.g., '3,45,1217'. | def set_cpus(core_str, **kwargs):
online_cores = osutil.parse_cpus(core_str)
offline_cores = POSSIBLE_CPUS - online_cores
for online in online_cores:
set_cpu(online, True, **kwargs)
for offline in offline_cores:
set_cpu(offline, False, **kwargs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_cores(core_str):\n num_cores = os.cpu_count()\n cores = []\n\n # remove spaces\n core_str.replace(\" \", \"\")\n\n # check if not a range\n if '-' not in core_str:\n cores = list(map(int, core_str.strip().split(',')))\n else:\n # parse range e.g. 2-8\n core_str =... | [
"0.73372155",
"0.7310295",
"0.6643412",
"0.6626668",
"0.65938044",
"0.63784826",
"0.59542745",
"0.5920172",
"0.5911205",
"0.59079194",
"0.59014875",
"0.5893901",
"0.58581024",
"0.5835143",
"0.57641816",
"0.5763135",
"0.57614833",
"0.5733904",
"0.57221043",
"0.56940997",
"0.56... | 0.8449324 | 0 |
Sets the learning rate to the initial LR decayed by 10 every 30 epochs | def adjust_learning_rate(optimizer, epoch):
lr = ln * (0.1 ** (epoch // 30))
for param_group in optimizer.param_groups:
param_group['lr'] = lr
print("learning rate",lr) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def adjust_learning_rate(init_lr, optimizer, epoch, n=100):\n init_lr = init_lr * (0.1 ** (epoch // n))\n print('learning rate : ', init_lr)\n for param_group in optimizer.param_groups:\n param_group['lr'] = init_lr",
"def adjust_learning_rate(start_lr, optimizer, epoch, total_epoch_num):\n #l... | [
"0.7912687",
"0.7905959",
"0.78493804",
"0.7774463",
"0.7733429",
"0.77317816",
"0.77222574",
"0.7721507",
"0.77187335",
"0.7708529",
"0.7692733",
"0.7673676",
"0.7664876",
"0.7664876",
"0.7664876",
"0.7654353",
"0.7641349",
"0.7639046",
"0.76369894",
"0.76252246",
"0.7623980... | 0.76182985 | 22 |
Sets the Robot in its init linear and angular speeds and lands the robot. Its preparing it to be reseted in the world. | def _set_init_pose(self):
#raw_input("INIT SPEED PRESS")
self.move_base(self.init_linear_speed_vector,
self.init_angular_turn_speed,
epsilon=0.05,
update_rate=10)
# We Issue the landing command to be sure it starts landing
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def RobotInit():\n names = [\"Body\"]\n angles = [-0.038392066955566406, 0.1349501609802246, 1.1964781284332275, 0.07512402534484863, -1.4926238059997559, -1.3391400575637817, 0.11500811576843262, 0.029999971389770508, -0.25766992568969727, -0.09506607055664062, -0.9694461822509766, 2.086198091506958, -1.168... | [
"0.75950617",
"0.6647208",
"0.65068054",
"0.6385469",
"0.63689643",
"0.63154316",
"0.6292906",
"0.6234735",
"0.6220041",
"0.6218668",
"0.61124223",
"0.608446",
"0.59954256",
"0.5981306",
"0.596997",
"0.59697676",
"0.5934296",
"0.59194297",
"0.59165907",
"0.58841455",
"0.58739... | 0.6033536 | 12 |
It return True if the current position is similar to the desired poistion | def is_in_desired_position(self, current_position, epsilon=0.05):
is_in_desired_pos = False
x_pos_plus = self.desired_point.x + epsilon
x_pos_minus = self.desired_point.x - epsilon
y_pos_plus = self.desired_point.y + epsilon
y_pos_minus = self.desired_point.y - epsilon
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pos_updated(self,next_pos):\n #if (int(self.oldx) == int(self.x) and int(self.oldy) == int(self.y)):\n if (int(next_pos[0]) == int(self.x) and int(next_pos[1]) == int(self.y)):\n return False\n else:\n return True",
"def _is_same_position(pos1, pos2, position_tolera... | [
"0.69115007",
"0.68410575",
"0.6825698",
"0.67856675",
"0.6757303",
"0.67277765",
"0.6570753",
"0.6469137",
"0.6418816",
"0.6416482",
"0.6415362",
"0.6399218",
"0.63933295",
"0.63761955",
"0.6374004",
"0.6358661",
"0.6349378",
"0.6335092",
"0.6335092",
"0.6335092",
"0.6333265... | 0.7078556 | 0 |
Calculates the distance from the current position to the desired point | def get_distance_from_desired_point(self, current_position):
distance = self.get_distance_from_point(current_position,
self.desired_point)
return distance | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def distance(self, pt):\n return math.sqrt((self.x - pt.x) ** 2 + (self.y - pt.y) ** 2)",
"def distance_from_origin(self):\n return ((self.x ** 2) + (self.y ** 2)) ** 0.5",
"def distance_from_origin(self):\n return ((self.x ** 2) + (self.y ** 2)) ** 0.5",
"def distance_from_origin(self):... | [
"0.7346128",
"0.731828",
"0.731828",
"0.731828",
"0.731828",
"0.731828",
"0.731828",
"0.731828",
"0.73132807",
"0.72944164",
"0.71887475",
"0.7186599",
"0.71590424",
"0.7147138",
"0.7131293",
"0.71132797",
"0.7097374",
"0.7084736",
"0.7078828",
"0.7063655",
"0.70475334",
"0... | 0.76051444 | 0 |
Compute softmax values for each sets of scores in x. | def softmax(x):
e_x = np.exp(x - np.max(x))
return e_x / e_x.sum() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def softmax(self, scores):\n\n\n # for each sample, for each class ,caclulate\n # np.exp(scores) : still (n_samples, n_classes)\n\n # axis = 1\n # a00, a01, a02 as a sinlge one to perfrom np_sum\n # which is the same sample \n # sum_exp : still (n_samples, 1)\n\n # ... | [
"0.7797116",
"0.77627903",
"0.7760451",
"0.7757387",
"0.7658399",
"0.7658399",
"0.7658399",
"0.7658399",
"0.7587644",
"0.7433347",
"0.7409716",
"0.73956805",
"0.73604953",
"0.7319298",
"0.72706646",
"0.72645944",
"0.7263417",
"0.72585905",
"0.7231768",
"0.7216702",
"0.7203891... | 0.70925397 | 50 |
straight line distance between two points in a Euclidean coordinate space e.g. a feature space. | def euclidean_distance(x1: np.ndarray, x2: np.ndarray) -> float:
return np.sqrt(np.square(x1 - x2).sum()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _distance(point, line_point1, line_point2):\n vec1 = line_point1 - point\n vec2 = line_point2 - point\n distance = np.abs(np.cross(vec1,vec2)) / np.linalg.norm(line_point1-line_point2)\n return distance",
"def DistPoint2Line(point,line_point1, line_point2=np.array(... | [
"0.7952062",
"0.7525102",
"0.7453301",
"0.7429792",
"0.7418775",
"0.7415094",
"0.7403794",
"0.73924583",
"0.7381779",
"0.7359141",
"0.73035294",
"0.7301587",
"0.73015547",
"0.7298834",
"0.7297628",
"0.7297396",
"0.72963643",
"0.7254442",
"0.72385156",
"0.72384953",
"0.7232203... | 0.71057475 | 37 |
Add a new release for a product. | def post(self, *args):
logger.error('Got post: ' + str(args))
params = self.parse_query_string(args[0])
params.update(web.input())
logger.error("Updated: " + str(params))
module = self.get_module(params)
impl = module.ProductsBuilds(config=self.context)
return ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_product(self, product):\n return self._make_post_request(self._urls['products'],\n data=dict(name=product))",
"def add_product(self):\n self.owner.new_product(self.barcode, self.description, self.price, self._add_product_callback)",
"def add_product(c... | [
"0.7091566",
"0.70914793",
"0.6958363",
"0.67327523",
"0.6539886",
"0.6467688",
"0.6131478",
"0.6114782",
"0.61115146",
"0.60866904",
"0.60793644",
"0.60439855",
"0.6017617",
"0.5999243",
"0.5988778",
"0.5954206",
"0.5937554",
"0.59226936",
"0.5881873",
"0.5875701",
"0.586743... | 0.0 | -1 |
Return the absolute path to the Yank examples relevant to tests. | def examples_paths():
data_dir = utils.get_data_filename(os.path.join('tests', 'data'))
p_xylene_dir = os.path.join(data_dir, 'p-xylene-implicit')
p_xylene_gro_dir = os.path.join(data_dir, 'p-xylene-gromacs-example')
ben_tol_dir = os.path.join(data_dir, 'benzene-toluene-explicit')
abl_imatinib_dir =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def example(*paths):\n\n return normpath(join(dirname(__file__), '..', 'examples', *paths))",
"def demo_paths(self):\n base_path = os.path.join(self.module.__path__[0], 'demo')\n paths = []\n if os.path.isdir(base_path):\n for item in os.listdir(base_path):\n # T... | [
"0.69857866",
"0.6951751",
"0.69368917",
"0.69149333",
"0.6842322",
"0.67351085",
"0.6657477",
"0.6593035",
"0.6593035",
"0.6529103",
"0.65016854",
"0.643783",
"0.64166296",
"0.63100636",
"0.62847763",
"0.62658906",
"0.62341464",
"0.62297225",
"0.6222524",
"0.6222524",
"0.622... | 0.65520775 | 9 |
Shortcut to load a string YAML script with YankLoader. | def yank_load(script):
return yaml.load(textwrap.dedent(script), Loader=YankLoader) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load(text: str, options: Dict[str, str]) -> object:\n raise LoaderMissingError(\"Yaml is not installed on the system\") from e",
"def _yaml_load(src):\n if not isinstance(src, str):\n try:\n src_name = src.name\n except AttributeError:\n src_name = '<yaml stringi... | [
"0.7225238",
"0.6605227",
"0.6434789",
"0.6399626",
"0.6207976",
"0.61847734",
"0.6158957",
"0.6107499",
"0.6091338",
"0.60904574",
"0.6063863",
"0.6007807",
"0.59752643",
"0.59543926",
"0.5953989",
"0.5953346",
"0.59267884",
"0.59171915",
"0.59042287",
"0.59009194",
"0.58557... | 0.85281694 | 0 |
Return a YAML template script as a dict. | def get_template_script(output_dir='.', keep_schrodinger=False, keep_openeye=False,
systems='all'):
paths = examples_paths()
template_script = """
---
options:
output_dir: {output_dir}
default_number_of_iterations: 0
temperature: 300*kelvin
pressur... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _dump_template(self, utils_image) -> Dict[str, str]:\n cmd = f\"docker run -i --rm --entrypoint python {utils_image}\"\n p = Popen(cmd, shell=True, stdin=PIPE, stdout=PIPE, stderr=STDOUT)\n out, _ = p.communicate(input=SCRIPT.encode())\n output = out.decode()\n if p.returncod... | [
"0.6922057",
"0.61569935",
"0.6087802",
"0.60847634",
"0.6082051",
"0.6035808",
"0.60351944",
"0.6034335",
"0.6021336",
"0.60006374",
"0.59688115",
"0.5929819",
"0.5893664",
"0.5814114",
"0.57786685",
"0.5685127",
"0.5677246",
"0.56715894",
"0.5670791",
"0.5643206",
"0.563532... | 0.51889396 | 70 |
Constructor for the AccountListItem class | def __init__(self,
account_id=None,
name=None,
org_no=None,
uni_customer_no=None,
created=None,
last_modified=None,
dealer_id=None,
dealer_name=None,
dealer_r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, label, account):\n self.label = label\n self.account = account",
"def __init__(self, **attrs):\n \n self.list_id = None\n self.name = None\n self.items = None\n \n super().__init__(**attrs)",
"def __init__(self, account, usernames, pass... | [
"0.651222",
"0.6364023",
"0.62543774",
"0.6212344",
"0.61654687",
"0.6161466",
"0.61279845",
"0.609977",
"0.6068368",
"0.60269785",
"0.60225785",
"0.595548",
"0.5939002",
"0.59120816",
"0.59078544",
"0.58994925",
"0.5890735",
"0.5852034",
"0.58481157",
"0.5821581",
"0.575197"... | 0.5634941 | 30 |
Creates an instance of this model from a dictionary | def from_dictionary(cls,
dictionary):
if dictionary is None:
return None
# Extract variables from the dictionary
account_id = dictionary.get('AccountId')
name = dictionary.get('Name')
org_no = dictionary.get('OrgNo')
uni_custo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def from_dictionary(cls,\n dictionary):\n if dictionary is None:\n return None\n\n # Extract variables from the dictionary\n id = dictionary.get('id')\n name = dictionary.get('name')\n mtype = dictionary.get('type')\n usage_bytes = diction... | [
"0.83181584",
"0.8168118",
"0.8168118",
"0.8118749",
"0.8089047",
"0.79787344",
"0.7949278",
"0.79231393",
"0.7898951",
"0.78923255",
"0.788838",
"0.7882321",
"0.7882212",
"0.7876749",
"0.78585315",
"0.7836853",
"0.7801407",
"0.7801407",
"0.7801407",
"0.7801407",
"0.7801407",... | 0.7593293 | 76 |
Test for empty email | def test_empty_email(self):
data = json.dumps({"email": "", "password":"123456"})
response = self.client().post('/api/v1/login', data=data, content_type='application/json')
self.assertEqual(response.status_code, 400) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_clean_email_empty(self):\n\n raw_email = 'from=<>'\n result = clean_email(raw_email)\n self.assertEqual(result, '')",
"def test_blank_email(self):\n rv = self.signup('Bo', 'Theo', '', 'Bo1995', 'Bo1995')\n self.assertIn(b'Field must be between 6 and 30 characters long.... | [
"0.77955014",
"0.7693157",
"0.7532362",
"0.72958565",
"0.7288139",
"0.72227544",
"0.71208423",
"0.70768875",
"0.6989508",
"0.6954569",
"0.69398016",
"0.69027865",
"0.6884465",
"0.6873435",
"0.6871869",
"0.6848071",
"0.68388176",
"0.68012255",
"0.6772865",
"0.6754429",
"0.6751... | 0.0 | -1 |
Test for incorrect email | def test_wrong_email(self):
data = json.dumps({"email": "teest@gmail", "password":"123456"})
response = self.client().post('/api/v1/login', data=data, content_type='application/json')
self.assertEqual(response.status_code, 400) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_invalid_email_when_logging_in(self):\n pass",
"def test_invalid_email(self):\n rv = self.login('Bo_wrong@example.com', 'Bo1995')\n self.assertIn(b'Invalid email! Please try again', rv.data)",
"def test_is_invalid_email(self):\n self.assertFalse(is_valid_email('helloworld'))... | [
"0.7902976",
"0.7847005",
"0.76883894",
"0.7645581",
"0.76052487",
"0.75022167",
"0.74303573",
"0.73778874",
"0.73682797",
"0.7344549",
"0.7335895",
"0.73258513",
"0.72927576",
"0.72526973",
"0.7241079",
"0.7199696",
"0.7199261",
"0.7198963",
"0.719499",
"0.71446145",
"0.7085... | 0.0 | -1 |
Applies a random fluctuation to probability of choosing various actions | def apply_temperature(self, policy, turn):
tau = np.power(self.play_conf.tau_decay_rate, turn + 1)
if tau < 0.1:
tau = 0
if tau == 0:
action = np.argmax(policy)
ret = np.zeros(self.num_labels)
ret[action] = 1.0
return ret
else:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def act(self, state):\n\t\trand_val = np.random.rand()\n\t\tif not self.is_eval and rand_val <= self.epsilon: # Do a random action only in train phase\n\t\t\treturn random.randrange(self.action_size)\n\n\t\tif self.firstIter: # If this is the first iteration, just do a \"hold\" action\n\t\t\tself.firstIter = Fal... | [
"0.6852549",
"0.67137545",
"0.6607374",
"0.6546696",
"0.6511509",
"0.6496077",
"0.64109474",
"0.64084953",
"0.63825977",
"0.63825977",
"0.6365748",
"0.6345696",
"0.63126934",
"0.62963766",
"0.62795913",
"0.6267994",
"0.6224856",
"0.62234503",
"0.6217564",
"0.61723757",
"0.616... | 0.0 | -1 |
Takes a single beer json object in the BreweryDB API format, and flattens and condenses to be added into a dataset. | def flatten_json_data(beer_json):
if 'available' in beer_json:
if 'name' in beer_json['available']:
beer_json['available_name'] = beer_json['available']['name']
del beer_json['available']
if 'glass' in beer_json:
if 'name' in beer_json['glass']:
beer_json['glass_n... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_beer_dataset():\n\n if not os.path.exists(FLATTENED_BEER_DATA_DIRECTORY):\n os.makedirs(FLATTENED_BEER_DATA_DIRECTORY)\n\n dataset = {'data': [], 'labels': []}\n\n # Iterate over all beer data files in given directory\n outfile_name = os.path.join(FLATTENED_BEER_DATA_DIRECTORY, \"fl... | [
"0.6246394",
"0.5746826",
"0.5266993",
"0.5251296",
"0.5181351",
"0.5062932",
"0.50010294",
"0.4927658",
"0.4856369",
"0.4802005",
"0.48007274",
"0.47419307",
"0.46885136",
"0.46709275",
"0.46338934",
"0.46282893",
"0.46241337",
"0.4616807",
"0.45828068",
"0.45682055",
"0.453... | 0.6159948 | 1 |
OCR model with CNN encoder and LSTMCTC decoder | def __init__(self,
weights_path,
config_path=DEFAULT_CONFIG_PATH):
self.weights = weights_path
self.config = process_config(config_path)
self._load_vocab()
self.model = CTCModel(self.config)
self.model.load(self.weights) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def TextRCNN2(inputs, lstm_size=256, cnns=[(32,1), (32,3), (64,5), (128,7)]):\n tf_input, cnn_feats = cnn_backbone(inputs=inputs, cnns=cnns)\n\n tf_x = tf.keras.layers.concatenate(cnn_feats)\n tf_x = tf.keras.layers.CuDNNLSTM(lstm_size, return_sequences=True)(tf_x)\n tf_x = tf.keras.layers.CuDNNLSTM(lstm_size,... | [
"0.67379427",
"0.66781217",
"0.66422606",
"0.66043746",
"0.65879875",
"0.6472509",
"0.6460497",
"0.64511395",
"0.6390109",
"0.637296",
"0.63723516",
"0.63524055",
"0.63343376",
"0.6329777",
"0.62748414",
"0.62732655",
"0.6252659",
"0.623355",
"0.62017417",
"0.6168842",
"0.616... | 0.0 | -1 |
Yield successive nsized chunks from l. | def chunks(l, n):
for i in xrange(0, len(l), n):
yield l[i:i+n] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _chunk(self, l, n):\n for i in range(0, len(l) + 1, n):\n yield l[i:i + n]",
"def chunks(self, l, n):\n for i in range(0, len(l), n):\n yield l[i:i + n]",
"def __chunks(l, n):\n for i in range(0, len(l), n):\n yield l[i:i + n]",
"def get_chunks(self, ... | [
"0.80388075",
"0.7924573",
"0.79226995",
"0.788447",
"0.7877021",
"0.781505",
"0.7764907",
"0.77549165",
"0.7743869",
"0.7731126",
"0.77281487",
"0.77241385",
"0.77024275",
"0.7688614",
"0.7688614",
"0.7663561",
"0.7656419",
"0.76552874",
"0.76552874",
"0.76452404",
"0.764524... | 0.0 | -1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.