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 |
|---|---|---|---|---|---|---|
Provides an interface between the attributes of the particle and special names that indicate components of Cartesian3DVectors (like px and vy) and also E. | def getValueFromFieldname(self,fieldname):
if hasattr(self,fieldname): #Standard attributes.
value = getattr(self,fieldname)
if not isinstance(value,Cartesian3DVector):
return value
if fieldname == "E": #Interprets E as energy
return self.getEnergy()
momentum_direction = fieldname.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def particle(*args, attribute: Union[AnyStr, bool]=\"\", cache: bool=True, conserve: Union[float,\n bool]=0.0, count: bool=True, deleteCache: bool=True, dynamicAttrList: bool=True,\n floatValue: float=0.0, gridSpacing: Union[float, List[float], bool]=0.0, inherit:\n Union[float,... | [
"0.69919753",
"0.6405855",
"0.62593144",
"0.61442405",
"0.61225903",
"0.6092437",
"0.60041267",
"0.6002357",
"0.59736216",
"0.5897076",
"0.58307093",
"0.5758628",
"0.5707094",
"0.56946874",
"0.56833655",
"0.5604477",
"0.55983365",
"0.55983365",
"0.55954325",
"0.5576338",
"0.5... | 0.61414677 | 4 |
Method checks to see if the passed in table name string exists in the current database. It returns True if it exists, False if it does not. | def checkTable(self, in_table_name):
phrase1 = "SELECT count(*) FROM sqlite_master"
phrase2 = "type='table' AND name='{}';".format(in_table_name)
self.cursor.execute("{} WHERE {}".format(phrase1, phrase2))
return self.cursor.fetchone()[0] == 1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def table_exists(self, table_name):\n\t\tif self.__dbfile is None:\n\t\t\treturn False\n\n\t\tcursor = self._conn.cursor()\n\t\tcursor.execute(\"SELECT name FROM sqlite_master WHERE type='table' ORDER BY name\")\n\t\ttables = [t[0] for t in cursor.fetchall()]\n\t\treturn table_name in tables",
"def table_exists(... | [
"0.83923465",
"0.82972556",
"0.8278821",
"0.8274654",
"0.82192963",
"0.8217764",
"0.8186757",
"0.8178282",
"0.8156295",
"0.8109164",
"0.8107967",
"0.80721045",
"0.80646104",
"0.8026469",
"0.802129",
"0.80188996",
"0.80120194",
"0.80039436",
"0.80017114",
"0.7960525",
"0.79349... | 0.7938891 | 20 |
Method is used to close the datbase connection. | def close(self):
self.connection.close() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def close(self): \n self.connection.close()",
"def close_connection(self):\n self.conn.close()",
"def close(self):\n self.conn.close()",
"def close(self):\n self.conn.close()",
"def close(self):\n self.conn.close()",
"def close(self):\n if self._dbopen:\n ... | [
"0.76934767",
"0.7693177",
"0.76594555",
"0.76594555",
"0.76594555",
"0.7659069",
"0.76558864",
"0.76259303",
"0.7590795",
"0.7583945",
"0.75826347",
"0.7569925",
"0.75540674",
"0.75540674",
"0.7544967",
"0.75250846",
"0.747603",
"0.7474878",
"0.74587214",
"0.7453189",
"0.744... | 0.74739313 | 23 |
Given two object's attributes, if they are equivalent, return valueEquivalent object, else return None. | def index_equivalent_value(indexer, obj1, attr1, obj2, attr2):
eq_conds = indexer.index_by_type(ValueEquivalence)
for cond in eq_conds:
r = cond.relationship
obj_list = r.obj_list
attr_list = r.attr_list
if obj1 in obj_list and obj2 in obj_list \
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __eq__(self, other):\n return (other is not None and\n self.name == other.name and\n self.type is other.type and\n dict.__eq__(self.attrs, other.attrs))",
"def equivalent(self, other):\n return id(self) == id(other)",
"def __eq__(self, other):\n ... | [
"0.5685698",
"0.5675666",
"0.5655813",
"0.5637368",
"0.56083894",
"0.5590845",
"0.55894345",
"0.55642265",
"0.5532535",
"0.54979646",
"0.54707646",
"0.54639596",
"0.5456215",
"0.54445344",
"0.5434761",
"0.54320115",
"0.54219925",
"0.53839636",
"0.5355038",
"0.5354938",
"0.534... | 0.6405555 | 0 |
inserts a new Node into the correct sorted position in the list | def sorted_insert(self, value):
if self.__head is None:
self.__head = Node(value, None)
elif value < self.__head.data:
self.__head = Node(value, self.__head)
else:
n = self.__head
while n.next_node is not None and n.next_node.data <= value:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sorted_insert(self, value):\n new = Node(value)\n if self.__head is None:\n self.__head = new\n return\n\n cur = self.__head\n if new.data < cur.data:\n new.next_node = self.__head\n self.__head = new\n return\n\n while (... | [
"0.78369576",
"0.7744504",
"0.7545904",
"0.71255237",
"0.70642745",
"0.7023171",
"0.6979266",
"0.6962061",
"0.69382703",
"0.69353247",
"0.6934543",
"0.6922758",
"0.6913487",
"0.6889499",
"0.68763757",
"0.68518615",
"0.68382025",
"0.6819735",
"0.6807978",
"0.6803154",
"0.67937... | 0.7756591 | 1 |
Create a Flask application using the app factory pattern. | def create_app(settings_override=None):
app = Flask(__name__, instance_relative_config=True)
app.config.from_object('config.settings')
app.config.from_pyfile('settings.py', silent=True)
if settings_override:
app.config.update(settings_override)
extensions(app)
@app.before_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_app():\n app = Flask(__name__)\n app.config.from_object('app.configs.config')\n app.config.from_object('app.configs.settings')\n return app",
"def create_app(config=Config):\r\n # Initialise app and configuration\r\n app = Flask(__name__)\r\n app.config.from_object(config)\r\n\r\n... | [
"0.8629991",
"0.8587432",
"0.8567094",
"0.8560846",
"0.8548992",
"0.8533256",
"0.8532855",
"0.85154873",
"0.8468547",
"0.84618294",
"0.84501874",
"0.8400496",
"0.83925307",
"0.8380182",
"0.8366697",
"0.8356823",
"0.8333603",
"0.83313555",
"0.8325678",
"0.8316702",
"0.8298241"... | 0.7829071 | 69 |
Improves default OpenCV imshow method by adding the possibility to correctly visualize small images without them being stretched. This is accomplished by adding a border around the image. | def imshow(window_name, image, border_color=(0, 0, 0)):
minimum_window_width = 400
minimum_window_height = 50
if len(image.shape) == 2:
height, width = image.shape
elif len(image.shape) == 3:
height, width, _ = image.shape
else:
raise ValueError('Invalid image: wrong shape')... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plt_show_image(image):\r\n plt.imshow(image)\r\n plt.axis('off')\r\n plt.axis('image')\r\n plt.tight_layout(pad=0)",
"def visualizeImg(img):\n plt.figure(figsize=(10,4))\n plt.imshow(img)\n plt.show()",
"def figshow(img,hsize=400,title='hoge'):\n shape = img.shape\n ratio=shape[0]/shap... | [
"0.70863444",
"0.70714533",
"0.6992935",
"0.69540083",
"0.68937224",
"0.68658483",
"0.66895604",
"0.66291314",
"0.6627189",
"0.65255374",
"0.6474028",
"0.6418489",
"0.63437307",
"0.6293873",
"0.6281903",
"0.6276204",
"0.6274199",
"0.6251514",
"0.62197226",
"0.6217757",
"0.621... | 0.69175327 | 4 |
Xavier initialization of network weights | def xavier_init(shape, constant=1):
# https://stackoverflow.com/questions/33640581/how-to-do-xavier-initialization-on-tensorflow
low = -constant*np.sqrt(1.0/np.sum(shape))
high = constant*np.sqrt(1.0/np.sum(shape))
return tf.random_uniform(shape, minval=low, maxval=high, dtype=tf.float32) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _init_weights(self):\n nn.init.xavier_normal_(self.out.weight)",
"def init_weight(self):\r\n xavier_init(self.output_proj, distribution='uniform', bias=0.)",
"def initialize_weights_xavier(self):\n\t\tself.weights = [np.random.uniform(-1/sqrt(size1), 1/sqrt(size1)) for size1, size2 in zip(sel... | [
"0.8129632",
"0.8015472",
"0.7956181",
"0.7529412",
"0.7290586",
"0.717985",
"0.7132147",
"0.69870454",
"0.69868577",
"0.69820243",
"0.6976076",
"0.6973984",
"0.6950588",
"0.6943784",
"0.6942138",
"0.69342655",
"0.69187987",
"0.69155324",
"0.69155324",
"0.69155324",
"0.690602... | 0.0 | -1 |
Get absolute path to resource, works for dev and for PyInstaller | def resource_path(self, relative_path):
try:
# PyInstaller creates a temp folder and stores path in _MEIPASS
base_path = sys._MEIPASS
except Exception:
base_path = os.path.abspath(".")
return os.path.join(base_path, relative_path) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_resource_path():\n return os.path.join(os.path.dirname(__file__), \"resources\") + os.path.sep",
"def resourcePath(relative):\r\n try:\r\n # PyInstaller creates a temp folder and stores path in _MEIPASS\r\n base_path = sys._MEIPASS\r\n except Exception:\r\n base_path = os.pa... | [
"0.8369681",
"0.8280762",
"0.82485825",
"0.813948",
"0.81143844",
"0.8098669",
"0.8094155",
"0.8079872",
"0.80678046",
"0.80674845",
"0.8062606",
"0.8062606",
"0.8062606",
"0.8062606",
"0.8062606",
"0.8062606",
"0.8062606",
"0.80572",
"0.80545497",
"0.8044992",
"0.8044992",
... | 0.78708136 | 44 |
Returns only the published items in the current queryset. | def get_published(self):
return self.filter(status="P") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_query_set(self):\n return super(PublishedManager, self).get_query_set().filter(is_published=True)",
"def published_posts(self) -> Type[QuerySet]:\n return Post.objects.filter(published__lt=timezone.now()).order_by('-published')",
"def index_queryset(self, using=None):\n return self... | [
"0.81438744",
"0.74145734",
"0.7291102",
"0.7291102",
"0.72220045",
"0.70331186",
"0.69521487",
"0.69521487",
"0.68891364",
"0.6855959",
"0.6855959",
"0.6768951",
"0.6750259",
"0.66901994",
"0.66622055",
"0.664425",
"0.66379416",
"0.65942293",
"0.65942293",
"0.65942293",
"0.6... | 0.72986066 | 2 |
Returns only the items marked as DRAFT in the current queryset. | def get_drafts(self):
return self.filter(status="D") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def filter_depleted(self, queryset, name, value):\n if str2bool(value):\n return queryset.filter(quantity__lte=0)\n else:\n return queryset.exclude(quantity__lte=0)",
"def get_queryset(self):\n q_kwargs = {\n \"awardsearch__latest_transaction__isnull\": True,... | [
"0.5909098",
"0.5792004",
"0.5494555",
"0.5467982",
"0.5406529",
"0.53282803",
"0.5287305",
"0.5213981",
"0.52133185",
"0.5204236",
"0.51955587",
"0.5119305",
"0.5100358",
"0.5100358",
"0.5060742",
"0.5060468",
"0.5059339",
"0.5052783",
"0.50426376",
"0.5017745",
"0.5008243",... | 0.56377304 | 2 |
Returns a list with the countries from the database | def getCountries(self):
return self.__getColumnData(Q_COUNTRIES, 'country') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def countries(cls) -> list[str]:\n\n with cls.cursor() as cur:\n cur.execute(\"SELECT country_code FROM countries;\")\n return list(row[0] for row in cur.fetchall())",
"def countries():\r\n\r\n # Use Pandas to perform the sql query\r\n results = db.session.query(Worldmapdata.to... | [
"0.85628647",
"0.8101554",
"0.7953373",
"0.7906936",
"0.762694",
"0.74032",
"0.73778915",
"0.72730756",
"0.72724813",
"0.7005522",
"0.6980284",
"0.6805332",
"0.6681277",
"0.6641916",
"0.6639538",
"0.66072136",
"0.66072136",
"0.6593001",
"0.6559602",
"0.65143824",
"0.65030825"... | 0.7606515 | 5 |
Get an mturk client for usage with mturk_utils | def _get_client(self, requester_name: str) -> Any:
return self.datastore.get_client_for_requester(requester_name) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_client():\n return Client(__address, authkey='strumamor')",
"def get_client(self):\n return self.client",
"def _client():\n nonlocal client\n if not client:\n client = twitter.Twitter(authenticator)\n return client",
"def get_client():\n client = soundclou... | [
"0.62090933",
"0.6118014",
"0.6089065",
"0.6075879",
"0.5911714",
"0.58852077",
"0.58716124",
"0.58710784",
"0.58672416",
"0.58672416",
"0.5771589",
"0.57349956",
"0.56708616",
"0.5649908",
"0.559883",
"0.55752206",
"0.5573978",
"0.555764",
"0.5534941",
"0.5528498",
"0.552448... | 0.5781972 | 10 |
Return the path to the `wrap_crowd_source.js` file for this provider to be deployed to the server | def get_wrapper_js_path(cls):
return os.path.join(os.path.dirname(__file__), "wrap_crowd_source.js") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def path(self):\n return os.path.join(FLOWJS_PATH, self.filename)",
"def path(self) -> str:\n return self.src + \"/\"",
"def generate_js_dir():\n\n return pkg_resources.resource_filename('linkedin.mobster.har.visualization.js', None)",
"def _get_path_to_front_end():\n dpath = os.path.join(o... | [
"0.6506409",
"0.64245355",
"0.6378719",
"0.62935174",
"0.6221082",
"0.62140304",
"0.621297",
"0.62058437",
"0.62000644",
"0.6144617",
"0.61140627",
"0.6102424",
"0.60733247",
"0.6052207",
"0.6030184",
"0.5986458",
"0.5984777",
"0.59069264",
"0.5870313",
"0.5858279",
"0.584577... | 0.8392228 | 0 |
Return the quadratic form preserved by the orthogonal group. | def invariant_quadratic_form(self):
from sage.matrix.constructor import identity_matrix
m = identity_matrix(self.base_ring(), self.degree())
m.set_immutable()
return m | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def invariant_quadratic_form(self):\n m = self.gap().InvariantQuadraticForm()['matrix'].matrix()\n m.set_immutable()\n return m",
"def getQuadOp(self):\n return self.basis2grid(np.eye(self.nb), axis = 0)",
"def Q(self):\n self.dualEigenmatrix()",
"def get_Q_c(dim):\n np.... | [
"0.6096417",
"0.56024075",
"0.55070233",
"0.5403502",
"0.5311804",
"0.5298959",
"0.5238195",
"0.5185676",
"0.5149036",
"0.5116379",
"0.51027095",
"0.5101817",
"0.50973207",
"0.50780195",
"0.50576276",
"0.50555134",
"0.505467",
"0.5054126",
"0.50283444",
"0.5016813",
"0.500739... | 0.608305 | 1 |
Return the quadratic form preserved by the orthogonal group. | def invariant_quadratic_form(self):
m = self.gap().InvariantQuadraticForm()['matrix'].matrix()
m.set_immutable()
return m | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def invariant_quadratic_form(self):\n from sage.matrix.constructor import identity_matrix\n m = identity_matrix(self.base_ring(), self.degree())\n m.set_immutable()\n return m",
"def getQuadOp(self):\n return self.basis2grid(np.eye(self.nb), axis = 0)",
"def Q(self):\n ... | [
"0.6080858",
"0.5600769",
"0.550645",
"0.5401144",
"0.5314119",
"0.53019667",
"0.5246059",
"0.51906383",
"0.51455516",
"0.5117674",
"0.5107267",
"0.51031226",
"0.5094862",
"0.50805855",
"0.50642264",
"0.50582856",
"0.5055545",
"0.5054465",
"0.5027284",
"0.5016461",
"0.5003758... | 0.60962576 | 0 |
Yield successive nsized chunks from arr. | def chunks(arr, n):
for i in range(0, len(arr), n):
yield arr[i:i + n] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def chunks(arr, n):\n for i in range(0, len(arr), n):\n yield arr[i:i + n]",
"def iterate_array_in_chunks(arr, size: int):\n for i in range(0, len(arr), size):\n yield arr[i:i+size]",
"def chunks(array, size: int):\r\n for i in range(0, len(array), size):\r\n yield array[i:i + size]",
... | [
"0.8175373",
"0.7678264",
"0.7453133",
"0.71820194",
"0.7092048",
"0.708483",
"0.70187324",
"0.6972917",
"0.69657755",
"0.6954322",
"0.694991",
"0.6949137",
"0.6945697",
"0.67928576",
"0.67697114",
"0.6767295",
"0.67591834",
"0.6755951",
"0.6751896",
"0.6748143",
"0.6748143",... | 0.8161355 | 1 |
Sigmoid scaled to logarithm of maximum sales scaled by 20%. | def act_sigmoid_scaled(x):
return tf.nn.sigmoid(x) * tf.math.log(max_sales) * 1.2 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def asigmoid(x):\n return -log(1 / x - 1)",
"def sigmoid(x):\r\n return 1 / (1 + np.exp(-x))",
"def sigmoid(x):\n return 1 / (1 + (e**(-x))) #changed the '-' to a '+' because it didnt work otherwise\n #return 1 / (1 + math.exp(-x))",
"def sigmoid(x):\n\treturn 1 / (1 + m.exp(-x))",
"def sigmoid... | [
"0.7279069",
"0.7055931",
"0.70535105",
"0.7038796",
"0.70300955",
"0.702078",
"0.7003955",
"0.6995886",
"0.6995886",
"0.6995886",
"0.6995886",
"0.6995886",
"0.6995886",
"0.69868886",
"0.69819033",
"0.69805765",
"0.6973958",
"0.6969267",
"0.6968753",
"0.6966772",
"0.69632316"... | 0.8239424 | 0 |
Get months and days until the next birthday. Approximate, as it does not count specific month durations, but approximates to the nearest 30 days | def get_next_birthday(birthday, today):
try:
next_birthday = birthday.replace(year=today.year)
except ValueError:
# not a leapyear, no february 29th; use the day before
next_birthday = birthday.replace(day=28, year=today.year)
if next_birthday < today: # next year
try:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_delta_30_days(self):\n input_ = (datetime.date(1996, 4, 1), datetime.date(1996, 5, 1))\n output = self.expander._get_next_days(*input_)\n expected = 30\n actual = (output[-1] - output[0]).days\n\n self.assertEqual(expected, actual)",
"def nextDay(year, month, day):\n ... | [
"0.6288889",
"0.60788447",
"0.60556895",
"0.5999455",
"0.5990442",
"0.5966739",
"0.59565675",
"0.59494776",
"0.5947355",
"0.5923941",
"0.5923883",
"0.5864053",
"0.58600646",
"0.58422095",
"0.5839163",
"0.5800275",
"0.57847387",
"0.57738745",
"0.5772187",
"0.5763912",
"0.57611... | 0.67215574 | 0 |
returns the new position of the camera, and never moves beyond the boundaries. | def update(self):
next_x = self.__pos[0] + self.__speed[0]
next_y = self.__pos[1] + self.__speed[1]
boundary_left = 0
boundary_right = LEVEL_WIDTH - SCREEN_WIDTH
boundary_top = 0
boundary_bottom = LEVEL_HEIGHT - SCREEN_HEIGHT
if next_x < boundary_left:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def camera_position(self):\n return CameraPosition(\n scale_point(self.camera, self.camera.position, invert=True),\n scale_point(self.camera, self.camera.focal_point, invert=True),\n self.camera.up,\n )",
"def adjust_camera(self):\n pose = deepcopy(self.data[... | [
"0.7439344",
"0.70752126",
"0.6709478",
"0.6644974",
"0.6638568",
"0.6428228",
"0.6418587",
"0.63851464",
"0.6370127",
"0.6293537",
"0.62235427",
"0.6212449",
"0.61700857",
"0.6145567",
"0.61447865",
"0.6073914",
"0.6051704",
"0.6033434",
"0.60299134",
"0.6029275",
"0.5996692... | 0.0 | -1 |
Create a mat3 from three vec3 by taking them as columns. | def three_vec3_to_mat3(f: vec3, l: vec3, u: vec3) -> mat3:
return mat3(f[0], l[0], u[0], f[1], l[1], u[1], f[2], l[2], u[2]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getMat3(self):\r\n m11,m12,m13,m14,m21,m22,m23,m24,m31,m32,m33,m34,m41,m42,m43,m44 = self.mlist\r\n return _mat3(m11,m12,m13,\r\n m21,m22,m23,\r\n m31,m32,m33)",
"def vector3(x, y, z):\n return np.array([x, y, z], dtype=float)",
"def vector3(x, y, z)... | [
"0.69429797",
"0.67079175",
"0.6656125",
"0.64689475",
"0.6413699",
"0.6411789",
"0.6236136",
"0.61622447",
"0.61589396",
"0.6035048",
"0.6026264",
"0.6024904",
"0.6005236",
"0.6000067",
"0.5996003",
"0.59812057",
"0.5907016",
"0.58996314",
"0.58707803",
"0.5864417",
"0.58078... | 0.805996 | 0 |
Allows us to fetch the undisputed hero of the trilogy, R2D2. | def get_hero(root, _info, episode):
if episode == 5:
return luke # Luke is the hero of Episode V
return artoo # Artoo is the hero otherwise | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_hero(self, uuid, hero):\n\n # I can't wait for case statements in python (3.10)\n if hero == Heroes.BULK:\n return Bulk(self.api_key, uuid)\n\n elif hero == Heroes.GENERAL_CLUCK:\n return GeneralCluck(self.api_key, uuid)\n\n elif hero == Heroes.CAKE_MONSTER... | [
"0.58030725",
"0.56142896",
"0.50956094",
"0.4873844",
"0.48610187",
"0.48471308",
"0.4828985",
"0.47979692",
"0.47733366",
"0.4772596",
"0.47679102",
"0.47579518",
"0.47457954",
"0.47345772",
"0.47205684",
"0.4719958",
"0.4691983",
"0.46911335",
"0.4688468",
"0.46847045",
"0... | 0.5789425 | 1 |
Imports a JSON file and returns a Python dictionary | def import_secrets_file(path_to_file) -> dict:
if not os.path.exists(path_to_file):
raise Exception(f"Specified file '{path_to_file}' does not exist")
with open(path_to_file) as file_object:
return json.load(file_object) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def import_json(self) -> dict:\n with open(self.path, encoding=\"utf8\") as json_file:\n return json.load(json_file)",
"def importJSON(path_to_json) -> dict:\n try:\n with open(path_to_json, 'r') as f:\n json_data = json.load(f)\n return(json_data)\n except Except... | [
"0.85891896",
"0.8294126",
"0.7883314",
"0.78677744",
"0.7862479",
"0.7810096",
"0.773051",
"0.7715923",
"0.7708804",
"0.7706261",
"0.7698648",
"0.7689351",
"0.7685956",
"0.76815856",
"0.76681316",
"0.76516634",
"0.76461405",
"0.7635216",
"0.76350874",
"0.7632074",
"0.7598816... | 0.0 | -1 |
Imports and parses a JSON file and returns a decrypted JSON dictionary | def parse_secrets_file(self, path_to_file) -> dict:
config = self.import_secrets_file(path_to_file)
self.traverse_and_decrypt(config)
return config | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def import_json(self) -> dict:\n with open(self.path, encoding=\"utf8\") as json_file:\n return json.load(json_file)",
"def read_json(file: str) -> Dict[str, Dict[str, Dict[str, str]]]:\n if os.path.exists(file):\n with open(file, 'r') as input_file:\n return json.load(inpu... | [
"0.7496803",
"0.72200453",
"0.7114453",
"0.7054943",
"0.70100874",
"0.6946409",
"0.69438595",
"0.6932254",
"0.6931001",
"0.6927639",
"0.6910518",
"0.69079775",
"0.69079775",
"0.6903936",
"0.68912214",
"0.6884152",
"0.68780774",
"0.6877773",
"0.68740386",
"0.6871525",
"0.68643... | 0.0 | -1 |
View function for home page of site. | def index(request):
# Generate counts of some of the main objects
projects = Project.objects.all()
projects = projects[0:4]
press = Press.objects.all().count()
# Available books (status = 'a')
# num_instances_available=BookInstance.objects.filter(status__exact='a').count()
# num_authors=Auth... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def home(request):\n\treturn render(request, \"compta/home.html\")",
"def home_page(request):\r\n return render(request, 'ez_main/home_page.html')",
"def home(request):\r\n return render(request, 'home.html')",
"def homepage(request):\n\treturn render(request, 'core/homepage.html')",
"def homepage(req... | [
"0.8493426",
"0.84268916",
"0.83415145",
"0.83306193",
"0.82976943",
"0.8295291",
"0.8276345",
"0.82545686",
"0.82155704",
"0.8132563",
"0.81246215",
"0.81224865",
"0.8121264",
"0.81049734",
"0.8098485",
"0.80935514",
"0.80935514",
"0.80935514",
"0.80935514",
"0.80935514",
"0... | 0.0 | -1 |
Get or set max_frame_skip. | def max_frame_skip(self):
return self._max_frame_skip | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def max_skip_interval(self):\n if not self.frame_skipping_allowed:\n return 0\n skip = (self.frame_rate_ctrl_sup >> 1) & 0x7\n if skip == 0:\n return -1\n return skip * 0.5",
"def get_max_frames(self):\n return 8",
"def capture_limit(self):\n retu... | [
"0.6708408",
"0.6518767",
"0.6184949",
"0.58162093",
"0.5772068",
"0.5741289",
"0.57290554",
"0.5702153",
"0.56506157",
"0.5638185",
"0.5628019",
"0.56244713",
"0.5580224",
"0.5580224",
"0.5577683",
"0.55365443",
"0.55287576",
"0.5512605",
"0.5510468",
"0.5507034",
"0.5507034... | 0.8373689 | 0 |
Set window caption for both Pygame clock and GameClock. | def set_caption():
if USE_PYGAME_CLOCK:
pygame.display.set_caption(
'Loop=Pygame Kill=%s MaxFPS=%d Runtime:[FPS=%d Balls=%d]' % (
DO_KILL, PYGAME_FPS, pygame_clock.get_fps(), len(sprite_group)))
else:
pygame.display.set_caption(
' '... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_caption(self, title=None, icon=None):\n pygame.display.set_caption(title if title is not None else \"Game\")\n\n if icon is not None:\n pygame.display.set_icon(self.__manager.get_image(icon))",
"def display_fps(self):\n template = \"{} - FPS: {:.2f}\"\n caption = te... | [
"0.7012242",
"0.6379176",
"0.6298891",
"0.6189515",
"0.6189515",
"0.61771625",
"0.6154267",
"0.61143386",
"0.6017634",
"0.593406",
"0.5787212",
"0.57735145",
"0.5733958",
"0.57310814",
"0.5718029",
"0.5701014",
"0.57004046",
"0.56815714",
"0.56677616",
"0.56650573",
"0.564746... | 0.78642577 | 0 |
Batch generator, yields slice indices | def batches(set_name):
global num_batches, args, ds_sizes
# num_batches = how many batches in each dataset(train, valid, test)
# ds_sizes = dataset_sizes
for b in range(num_batches[set_name]):
bi = b * args.batch_size # one batch mul batch_size
bj = (b + 1) * args.batch_size
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __iter__(self):\n batch = []\n for i_batch in range(self.episode_num):\n classes = torch.randperm(len(self.idx_list))[: self.way_num]\n for c in classes:\n idxes = self.idx_list[c.item()]\n pos = torch.randperm(idxes.size(0))[: self.image_num]\n... | [
"0.7030558",
"0.699595",
"0.69298756",
"0.68601197",
"0.6832218",
"0.6795262",
"0.6717477",
"0.6661854",
"0.65953773",
"0.65926987",
"0.654558",
"0.6481695",
"0.64709574",
"0.644917",
"0.6448157",
"0.644437",
"0.643661",
"0.64290035",
"0.64193326",
"0.64193326",
"0.64183414",... | 0.0 | -1 |
Test case for the validate_str_substitution function when there are too many specifiers for a multiple values. | def test_too_many_specifiers(self):
template = '{0} too {1} many {2}'
value_count = 2
msg = ('The number of "{}" specifiers in the formatter '
'exceeds the number of source fields.')
with six.assertRaisesRegex(self, ValidationError, msg):
validate_str_substitut... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_mult_specifiers_missing(self):\n template = '{0} too few {1}'\n value_count = 3\n msg = ('The formatter contains too few \"{}\" '\n 'specifiers for the number of source fields.')\n with six.assertRaisesRegex(self, ValidationError, msg):\n validate_str_s... | [
"0.77387667",
"0.704363",
"0.70252943",
"0.6271981",
"0.6192022",
"0.6164257",
"0.60407287",
"0.60207987",
"0.5852523",
"0.58169687",
"0.57305413",
"0.5712452",
"0.5707186",
"0.57060534",
"0.5697903",
"0.56634915",
"0.5498339",
"0.549623",
"0.54948443",
"0.5450721",
"0.544724... | 0.75915784 | 1 |
Test case for a field name with a space. | def test_white_space(self):
with self.assertRaises(ValidationError):
field_name_validator('user id') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_name_field(self):\n field = self.record.find('field[@name=\\'name\\']')\n self.assertEqual(field.text, 'GUH-ADT', 'Incorrect Name Field')",
"def test_white_space(self):\n with self.assertRaises(ValidationError):\n db_name_validator('http log')",
"def test_nonreserved_na... | [
"0.70056397",
"0.67619824",
"0.6710414",
"0.6692096",
"0.66895425",
"0.6589791",
"0.6458364",
"0.64133483",
"0.6384269",
"0.6309959",
"0.6281411",
"0.6173597",
"0.61537987",
"0.6149685",
"0.61195415",
"0.6065407",
"0.60509354",
"0.60304695",
"0.5992413",
"0.5987188",
"0.59464... | 0.7365769 | 0 |
Test case for a valid field name. | def test_no_errors(self):
try:
field_name_validator('good_field_name')
except ValidationError:
self.fail('Field name raised ValidationError unexpectedly') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_nonreserved_name(self):\n try:\n field_name_validator('_identifier')\n except ValidationError:\n self.fail('Field name raised ValidationError unexpectedly')",
"def test_reserved_name(self):\n with self.assertRaises(ValidationError):\n field_name_vali... | [
"0.8004557",
"0.7859619",
"0.7581208",
"0.7289784",
"0.7268989",
"0.71208143",
"0.70402896",
"0.6968805",
"0.6939666",
"0.69157976",
"0.6897933",
"0.6821266",
"0.6778675",
"0.675043",
"0.66696423",
"0.66601723",
"0.66555065",
"0.6599102",
"0.6596775",
"0.6596287",
"0.65885437... | 0.6981006 | 7 |
Test case for an invalid file type. | def test_invalid(self):
mock_fieldfile = Mock()
mock_fieldfile.name = 'bad_file_name.pem.jar'
with self.assertRaises(ValidationError):
key_file_validator(mock_fieldfile) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_invalid_file_type(barred_tac_list_importer):\n expect_failure(barred_tac_list_importer, exc_message='Wrong suffix')",
"def is_file_type_error(self):\n return self._tag == 'file_type_error'",
"def check_filekind(self):\n assert self.filekind in self.obs_package.FILEKINDS, \\\n ... | [
"0.77751774",
"0.77320075",
"0.76051164",
"0.73831254",
"0.729394",
"0.726827",
"0.7230198",
"0.720948",
"0.7105418",
"0.7041137",
"0.70369047",
"0.7023472",
"0.6942793",
"0.69416946",
"0.69330204",
"0.691751",
"0.68991613",
"0.6882623",
"0.6814948",
"0.6789643",
"0.67172736"... | 0.0 | -1 |
Estimate the discretization error for a given solution. The discretization error could be the error w.r.t. the analytical solution of the given problem or the model reduction error w.r.t. a corresponding highdimensional |Discretization|. | def estimate(self, U, mu=None):
raise NotImplementedError | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def numerical_discretization_error(h,phi,verbose=True):\n \n # Constants\n F_s = 1.25\n C_low = 0.95\n C_hi = 3.05\n delta_M = max(abs(phi[1]-phi[0]),abs(phi[2]-phi[1]),abs(phi[2]-phi[0]))\n \n # Mesh refinement ratios\n r21 = h[1]/h[0]\n r32 = h[2]/h[1]\n \n # Result ratios\n ... | [
"0.627564",
"0.5707004",
"0.5562071",
"0.5482781",
"0.5396282",
"0.53853613",
"0.5310517",
"0.5307367",
"0.53047454",
"0.5276714",
"0.5242953",
"0.5207475",
"0.51973164",
"0.5190131",
"0.518041",
"0.5155854",
"0.5143549",
"0.51388776",
"0.5138767",
"0.51260996",
"0.5121044",
... | 0.0 | -1 |
save_json(NAME) save json as NAME | def save_json(self, file):
with open(file, 'w', encoding='utf8') as f:
json.dump(self, f, ensure_ascii=False) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save_as_json(self, json_name):\r\n with open(json_name, \"w\") as outfile:\r\n json.dump(self.pet_file, outfile) # save create json file with current information\r\n self.pet_file_name = json_name # set name to passed name\r",
"def save_json(dict_obj, path, name):\n if 'txt'... | [
"0.8079377",
"0.79723835",
"0.77595055",
"0.7578833",
"0.7560741",
"0.7484027",
"0.7448826",
"0.73992825",
"0.7389294",
"0.73578846",
"0.7246028",
"0.72265",
"0.72163373",
"0.72155607",
"0.71672624",
"0.7108248",
"0.7074579",
"0.70703423",
"0.7061496",
"0.70600367",
"0.702755... | 0.67047083 | 56 |
Renders the home page. | def home(request):
assert isinstance(request, HttpRequest)
#Curr_Weather = WeatherUndergroundAPI.GetWeatherCurrent('ID', 'KIDA')
Curr_Weather = Weather.GetCurrentWeather()
context = {
'title': 'Heretic Family',
'Year': datetime.now().year,
'Temp_String': Curr... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def render_home():\r\n\treturn render_template(\"index.html\")",
"def home():\n\n return render_template('home_page.html')",
"def home():\n\n return render_template(\"home.html\")",
"def home():\n return render_template('home.html')",
"def home():\n return render_template('home.html')",
"def ... | [
"0.85574406",
"0.853399",
"0.8351404",
"0.82762724",
"0.82762724",
"0.82762724",
"0.82762724",
"0.82762724",
"0.82762724",
"0.82762724",
"0.82762724",
"0.82762724",
"0.82762724",
"0.82762724",
"0.82762724",
"0.82762724",
"0.82762724",
"0.82762724",
"0.82762724",
"0.827363",
"... | 0.0 | -1 |
If given an integer, get the human EnsemblRelease object for that Ensembl version. If given a string, return latest EnsemblRelease which has an equivalent reference. If the given name is a UCSC genome (e.g. hg19) then convert it to the equivalent Ensembl reference (e.g. GRCh37). If given a PyEnsembl Genome, simply use ... | def infer_genome(genome_object_string_or_int):
converted_ucsc_to_ensembl = False
if isinstance(genome_object_string_or_int, Genome):
genome = genome_object_string_or_int
elif is_integer(genome_object_string_or_int):
genome = cached_ensembl_release(genome_object_string_or_int)
elif is_st... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def infer_genome_for_reference_name(reference_name):\n converted_ucsc_to_ensembl = False\n reference_name = infer_reference_name(reference_name)\n if is_ucsc_reference_name(reference_name):\n if reference_name not in ucsc_to_ensembl_reference_names:\n raise ValueError(\n \... | [
"0.6439983",
"0.5448234",
"0.52595913",
"0.48241457",
"0.48233008",
"0.47625998",
"0.47586852",
"0.473882",
"0.47120637",
"0.4677732",
"0.467509",
"0.4669614",
"0.46572727",
"0.4632468",
"0.4614374",
"0.4588308",
"0.4553197",
"0.4529159",
"0.4483664",
"0.44710606",
"0.4470605... | 0.58101034 | 1 |
Home page with auth links. | def home(request):
if request.user.is_authenticated():
return HttpResponse("{0} <a href='/accounts/logout'>exit</a>".format(request.user))
else:
return HttpResponse("<a href='/login/vk-oauth2/'>login with VK</a>") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index(request):\n\n\tif request.user.is_authenticated:\n\t\treturn HttpResponseRedirect('home')\n\treturn HttpResponseRedirect('login')",
"def homepage():\n if g.user:\n return redirect(f\"/user/{g.user.id}\")\n else:\n return redirect(\"/landing\")",
"def home(request):\n if request... | [
"0.7620997",
"0.757061",
"0.7545057",
"0.75089806",
"0.7498317",
"0.74462444",
"0.74266213",
"0.73984593",
"0.7378062",
"0.7289403",
"0.7249242",
"0.7248388",
"0.72273856",
"0.7214283",
"0.7200972",
"0.7195424",
"0.71573",
"0.7152052",
"0.7133126",
"0.7122047",
"0.7100568",
... | 0.7823744 | 0 |
Home page with auth links. | def homefb(request):
if request.user.is_authenticated():
return HttpResponse("{0} <a href='/accounts/logout'>exit</a>".format(request.user))
else:
return HttpResponse("<a href='/login/facebook/?next=https://chepolina.pythonanywhere.com/'>login with Facebook</a>") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def home(request):\n if request.user.is_authenticated():\n return HttpResponse(\"{0} <a href='/accounts/logout'>exit</a>\".format(request.user))\n else:\n return HttpResponse(\"<a href='/login/vk-oauth2/'>login with VK</a>\")",
"def index(request):\n\n\tif request.user.is_authenticated:\n\t\t... | [
"0.7823744",
"0.7620997",
"0.757061",
"0.7545057",
"0.75089806",
"0.7498317",
"0.74462444",
"0.74266213",
"0.73984593",
"0.7378062",
"0.7289403",
"0.7249242",
"0.7248388",
"0.72273856",
"0.7214283",
"0.7200972",
"0.7195424",
"0.71573",
"0.7152052",
"0.7133126",
"0.7122047",
... | 0.7061074 | 22 |
Saves model and training parameters at '{checkpoint_dir}/last_checkpoint.pytorch'. If is_best==True saves '{checkpoint_dir}/best_checkpoint.pytorch' as well. | def save_checkpoint(state, is_best, checkpoint_dir, logger=None):
def log_info(message):
if logger is not None:
logger.info(message)
if not os.path.exists(checkpoint_dir):
log_info(
f"Checkpoint directory does not exists. Creating {checkpoint_dir}")
os.mkdir(che... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _save_checkpoint(self, epoch, is_best=False):\n arch = type(self.model).__name__\n state = {\n 'arch': arch,\n 'epoch': epoch,\n 'state_dict': self.model.state_dict(),\n 'optimizer': self.optimizer.state_dict(),\n 'config': self.config\n ... | [
"0.8560058",
"0.84478235",
"0.84433365",
"0.84393",
"0.8236336",
"0.8221738",
"0.8211303",
"0.8210968",
"0.81995684",
"0.8180039",
"0.81656176",
"0.8162459",
"0.813964",
"0.8074217",
"0.80320376",
"0.8005862",
"0.79756457",
"0.797337",
"0.79720265",
"0.7961165",
"0.7862326",
... | 0.806235 | 14 |
Defines specification for the dataflow type that will be managed in Pipeline Manager. | def get_nodes(
nodes: Dict[str, Node] = None,
io_mapping: Dict[str, Dict] = None
) -> Tuple[Dict[str, Node], Dict[str, Dict]]:
raise NotImplementedError | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getInputSpecification(cls):\n inputSpecification = super(NDCartesianSpline, cls).getInputSpecification()\n\n DataFilenameParameterInput = InputData.parameterInputFactory(\"dataFilename\", contentType=InputTypes.StringType)\n DataFilenameParameterInput.addParam(\"type\", InputTypes.StringType, True)\n ... | [
"0.61493516",
"0.61357504",
"0.6109861",
"0.6057048",
"0.6022401",
"0.59787",
"0.59637356",
"0.5783145",
"0.56910044",
"0.56606996",
"0.56378406",
"0.56321895",
"0.5570197",
"0.5563179",
"0.555496",
"0.55389154",
"0.55381036",
"0.5518952",
"0.5509683",
"0.55075073",
"0.549833... | 0.0 | -1 |
This function concatenates two dictionaries. | def concat_two_batches(batch1, batch2):
with tf.name_scope('concat_batch'):
if 'y' in batch1 and isinstance(batch1['y'], tf.Tensor):
return {'x': tf.concat([batch1['x'], batch2['x']], axis=0),
'y': tf.concat([batch1['y'], batch2['y']], axis=0)}
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def concat_dict(d1, d2):\n if d1 is None:\n return d2\n if d2 is None:\n return d1\n else:\n assert set(d1.keys()) == set(d2.keys())\n return {k: np.concatenate([d1[k], d2[k]], axis=0) for k in d1}",
"def concatDic(dic1, dic2):\n pass",
"def concat_dicts(self, dict1, dic... | [
"0.8238723",
"0.82264555",
"0.8129423",
"0.8108462",
"0.8108462",
"0.78634924",
"0.785589",
"0.7854571",
"0.7802969",
"0.7745862",
"0.7745862",
"0.7745862",
"0.7745862",
"0.7745862",
"0.7745862",
"0.7745862",
"0.7745862",
"0.77315646",
"0.76827085",
"0.7563227",
"0.7563227",
... | 0.0 | -1 |
Return the output of the specified layer for input `x`. `layer` is specified by layer index (between 0 and `nb_layers 1`) or by name. The number of layers can be determined by counting the results returned by calling `layer_names`. This function is not supported for this detector. | def get_activations(
self, x: np.ndarray, layer: Union[int, str], batch_size: int, framework: bool = False
) -> np.ndarray:
raise NotImplementedError | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_layer_outputs(model, input_data, layer_name=None, layer_idx=None,\n layer=None, learning_phase=0):\n\n _validate_args(layer_name, layer_idx, layer)\n layer = get_layer(model, layer_name, layer_idx)\n if TF_KERAS:\n layers_fn = K.function([model.input], [layer.output])\n... | [
"0.6524441",
"0.6197736",
"0.6030136",
"0.59972733",
"0.5923338",
"0.5923338",
"0.5888904",
"0.5882687",
"0.5862411",
"0.5853007",
"0.58437616",
"0.57841027",
"0.5766418",
"0.5766418",
"0.5738731",
"0.57326937",
"0.57088745",
"0.5701298",
"0.56855685",
"0.56625485",
"0.565098... | 0.0 | -1 |
Merges edges e1 and e2 together. An edge is a sequence where the first two elements are [source, target]. An edge may have additional elements. | def merge(e1, e2):
assert permissible(e1, e2)
return [e1[0], e2[1], None] # A merged edge has not been added, so it has no ID. | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_edge(self, v1, v2):\n pass # TODO",
"def add_edge(self, node1: Node, node2: Node):\n self.__add_edge(node1, node2)\n self.__add_edge(node2, node1)",
"def e(src, dst):\n edge = pydot.Edge(src, dst)\n graph.add_edge(edge)",
"def _append_source_and_target(self, graph):\n g... | [
"0.65857697",
"0.6536037",
"0.64098305",
"0.63119984",
"0.6236003",
"0.6228107",
"0.61946976",
"0.61817974",
"0.6142903",
"0.61362994",
"0.6070242",
"0.60662323",
"0.60038453",
"0.5995417",
"0.59614384",
"0.59572506",
"0.5942834",
"0.5903284",
"0.5892013",
"0.58893585",
"0.58... | 0.76180565 | 0 |
Computes the real distance between two vertices, given their vertex IDs. | def vertex_distance(self, v1, v2):
return utils.real_distance(self.node_locations[v1], self.node_locations[v2]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def distance(v1, v2):\r\n return magnitude(*subtract(v2, v1))",
"def _vector_dist(self, vec1, vec2):\r\n return sqrt(sum([(float(v1) - float(v2)) ** 2 for v1, v2 in\r\n zip(vec1, vec2)]))",
"def dist(v1: vect2d, v2: vect2d) -> float:\n d = ((v2.x - v1.x)**2 + (v2.y - v1.y)**2... | [
"0.6689806",
"0.6653809",
"0.66066384",
"0.6561086",
"0.6508852",
"0.65006506",
"0.6498293",
"0.6445875",
"0.64357215",
"0.64178735",
"0.638211",
"0.6373817",
"0.63566583",
"0.63436407",
"0.63207",
"0.63198066",
"0.63142335",
"0.6303946",
"0.6285145",
"0.62819755",
"0.6276703... | 0.7256061 | 0 |
Returns a list of dictionaries containing the attributes of each vertex. | def export_nodes(self):
return ['lon', 'lat', 'speed', 'heading'], \
[{'speed': self.node_speed_limit[v],
'lon': self.node_locations[v][0],
'lat': self.node_locations[v][1],
'heading': self.node_heading[v]} for v in self.graph.vertices()] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def obtener_vertices(self):\n return list(self.vertices.keys())",
"def get_vertices(self):\n return list(self.vertices.keys())",
"def list_vertices(self):\n return list(self.graph_dict.keys())",
"def vertices(self):\n return list(self.graph_dict.keys())",
"def vertices(self):\r\... | [
"0.7173167",
"0.70198685",
"0.6987175",
"0.68630767",
"0.68467695",
"0.6823045",
"0.67938685",
"0.67938685",
"0.67938685",
"0.6745322",
"0.67419744",
"0.67080706",
"0.6677524",
"0.6659934",
"0.6604973",
"0.6591036",
"0.6533811",
"0.65335304",
"0.6531588",
"0.64844906",
"0.644... | 0.0 | -1 |
Caclulate distance between two lat lons in NM | def calcDistance(lat1, lon1, lat2, lon2):
yDistance = (lat2 - lat1) * nauticalMilePerLat
xDistance = (math.cos(lat1 * rad) + math.cos(lat2 * rad)) * (lon2 - lon1) * (nauticalMilePerLongitude / 2)
distance = math.sqrt( yDistance**2 + xDistance**2 )
return distance * milesPerNauticalMile | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculateDistanceBetweenPoints(lat1,lon1,lat2,lon2):\n\treturn Geodesic.WGS84.Inverse(lat1,lon1, lat2, lon2)['s12']",
"def get_distance(lat1, lon1, lat2, lon2):\n phi1 = math.radians(lat1)\n phi2 = math.radians(lat2)\n d_phi = math.radians(lat2 - lat1)\n d_lam = math.radians(lon2 - lon1)\n a =... | [
"0.7470505",
"0.7318639",
"0.72677976",
"0.7265814",
"0.72458845",
"0.72337663",
"0.72066087",
"0.71915007",
"0.71915007",
"0.71915007",
"0.71915007",
"0.71915007",
"0.7188688",
"0.7186311",
"0.7182924",
"0.71657574",
"0.7155414",
"0.71550226",
"0.715047",
"0.7138319",
"0.712... | 0.7105262 | 22 |
Adds an edge to a graph. It also updates the vertex and edge indices. | def addEdge(self, edge):
startVertex = edge.startVertex
endVertex = edge.endVertex
startVertexNumber = startVertex.vertexNumber
endVertexNumber = endVertex.vertexNumber
vertexIndex = self.vertexIndex
parentIndex = self.parentIndex
parentEdgeIndex = self... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_edge(self, edge):\n if(self.has_edge(edge) == 0):\n self.__graph_dict[edge[0]].append(edge[1])",
"def addEdge(self, e):\n v = e.either()\n w = e.other(v)\n self._validateVertex(v)\n self._validateVertex(w)\n self._adj[v].add(e)\n self._adj[w].add(e)\n self._E += 1",... | [
"0.7931591",
"0.7710648",
"0.765884",
"0.7640651",
"0.7638104",
"0.76042837",
"0.7584622",
"0.75763017",
"0.7558737",
"0.7516333",
"0.7502787",
"0.7501524",
"0.7441771",
"0.7436214",
"0.74305826",
"0.73736656",
"0.73678005",
"0.73582536",
"0.7196776",
"0.7183749",
"0.7175221"... | 0.7184071 | 19 |
Adds a vertex. Should be used with care vertexNumber Vertex number of vertex to be added | def addVertex(self, vertexNumber):
try:
self.vertexIndex[vertexNumber]
raise VertexError(vertexNumber, ErrorMessages.vertexAlreadyExists)
except KeyError:
self.vertexIndex[vertexNumber] = Vertex(vertexNumber)
return | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_vertex(self, vertex):\n raise NotImplementedError",
"def add_vertex(self, vertex_id):\n pass # TODO",
"def add_vertex(self, vertex_name: n):\n new_vertex = Vertex(vertex_name)\n self._graph[new_vertex.name] = new_vertex",
"def add_vertex(self, vertex):\n if isinsta... | [
"0.8566502",
"0.8523629",
"0.83188754",
"0.8200118",
"0.8128653",
"0.800311",
"0.79475987",
"0.782539",
"0.78067344",
"0.77300024",
"0.77215284",
"0.7704437",
"0.76251054",
"0.75979304",
"0.75907624",
"0.7584836",
"0.75778896",
"0.7523712",
"0.7489197",
"0.74780303",
"0.74146... | 0.8199532 | 4 |
Get all graph edges edgeIndex Dictionary of edges, indexed by edge number | def getEdges(self):
return self.edgeIndex | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def nodeid_to_index(G):\n\n d = {node_id: i for i, node_id in enumerate(G.nodes)}\n\n return d",
"def edges_key(graph):\n return tuple(graph.edges())",
"def eligible_edges_with_indexes(self):\n return enumerate(self.edges)",
"def eligible_edges_with_indexes(self):\n return list(map... | [
"0.71351886",
"0.7115467",
"0.7056002",
"0.690152",
"0.6852002",
"0.68138236",
"0.6796628",
"0.6732841",
"0.67086375",
"0.67066216",
"0.6702431",
"0.668753",
"0.6638807",
"0.6626828",
"0.6621127",
"0.66192484",
"0.6605798",
"0.6580035",
"0.6560157",
"0.6544798",
"0.6537302",
... | 0.69350237 | 3 |
Get all graph vertices vertexIndex Dictionary of vertices, indexed by vertex number | def getVertices(self):
return self.vertexIndex | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getVertexNumbers(self):\n return self.vertexIndex.keys()",
"def index_vertices(vertexlist, graph):\n return_list = list()\n for vertex in vertexlist:\n return_list.append(graph.vs.find(name=vertex).index)\n return return_list",
"def get_vertex_keys(self):\n return self.vertLis... | [
"0.81264883",
"0.74522066",
"0.7378788",
"0.7355847",
"0.73054576",
"0.7292257",
"0.7225575",
"0.72073984",
"0.71973234",
"0.71973234",
"0.71973234",
"0.714475",
"0.71303815",
"0.70494425",
"0.7038835",
"0.70384014",
"0.70047694",
"0.6988673",
"0.6975936",
"0.6909543",
"0.685... | 0.7104188 | 13 |
Get all graph vertex numbers an array consisting of all the vertices numbers | def getVertexNumbers(self):
return self.vertexIndex.keys() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def vertices(self):\n return list(self.__graph.values())",
"def vertices(self):\n return list(self._graph)",
"def vertices(self):\n return list(self.graph_dict.keys())",
"def get_vertices(self):\n return self.graph.keys()",
"def vertices(self):\r\n return list(self.__grap... | [
"0.7608723",
"0.7587752",
"0.7485285",
"0.7477596",
"0.7420833",
"0.7383841",
"0.73785895",
"0.73764884",
"0.73764884",
"0.73764884",
"0.73442924",
"0.7276738",
"0.7180534",
"0.7058785",
"0.7030377",
"0.6955908",
"0.69398487",
"0.6928327",
"0.6922639",
"0.69173735",
"0.690185... | 0.779428 | 0 |
Get the last edge number __lastEdgeNumber the last edge number assigned to edges. | def getLastEdgeNumber(self):
return self.__lastEdgeNumber | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def last_edge(self):\n return self._edge",
"def last_index(self) -> int:\n return self._last_index",
"def last_node(self):\n return self._array[self._size-1]",
"def get_max(self):\n return self.max[-1]",
"def get_last_framenumber(self):\n return self._frame_number",
"de... | [
"0.7556472",
"0.6783178",
"0.6715328",
"0.66097325",
"0.6586115",
"0.65181774",
"0.65079015",
"0.64952546",
"0.6433164",
"0.6431386",
"0.6372128",
"0.6369549",
"0.6354774",
"0.6353139",
"0.63428015",
"0.6339895",
"0.63355786",
"0.62993526",
"0.6290487",
"0.6267261",
"0.626365... | 0.8791472 | 0 |
Overriden this method to add media namespace(needed because we added media tags) | def rss_attributes(self):
return {u"version": self._version,
u"xmlns:media": u"http://search.yahoo.com/mrss/",
"xmlns:atom": u"http://www.w3.org/2005/Atom"
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _media_processing(self):\n self.set_property('processing_type', 'media')",
"def uses_media(self):\n return True",
"def add_media_object(self, name, align, w_cm, h_cm, alt='', style_name=None, crop=None):\n raise NotImplementedError",
"def test_replace_namespaced_image_stream_tag(self... | [
"0.62332565",
"0.6003843",
"0.5945977",
"0.58772814",
"0.5708445",
"0.5647985",
"0.5641738",
"0.5593008",
"0.5593008",
"0.5569203",
"0.55206114",
"0.5439861",
"0.543839",
"0.54310626",
"0.54095936",
"0.54014105",
"0.5384686",
"0.53386885",
"0.53309345",
"0.525692",
"0.5239419... | 0.0 | -1 |
Convenience function to report start of the day | def report_day(epoch_time):
time = datetime.fromtimestamp(epoch_time)
print("---- {} ({}) ----".format(time, epoch_time)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cal_start(self):\n return self.datetime_start",
"def starting_date(self):\n return datetime.date(2016, 1, 4)",
"def start1(self): \n return self.ddmmyyyy(self.rowTime.start)",
"def start_date(self) -> str:\n return pulumi.get(self, \"start_date\")",
"def start_date(self) -> ... | [
"0.75035185",
"0.7324098",
"0.71959496",
"0.7061483",
"0.7061483",
"0.696112",
"0.6929423",
"0.69252634",
"0.6868955",
"0.68662024",
"0.68507046",
"0.68214434",
"0.68214434",
"0.68214434",
"0.68214434",
"0.6817186",
"0.68047047",
"0.6784255",
"0.6782483",
"0.6782483",
"0.6766... | 0.0 | -1 |
Root view of the package index, handle incoming actions from distutils or redirect to a more user friendly view | def root(request, fallback_view=None, **kwargs):
if request.method == 'POST':
if request.META['CONTENT_TYPE'] == 'text/xml':
log.debug('XMLRPC request received')
return parse_xmlrpc_request(request)
log.debug('Distutils request received')
parse_distutils_request(reque... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def index(self):\n return render_template('main/index.html')",
"def index():\n print('This is the root of the app, should have something better')\n return 'Root, this is where some front end would go on a server'",
"def index():\n pass",
"def index():\n return \"This is root!!!!\"",
"def... | [
"0.6674808",
"0.6664821",
"0.6583092",
"0.6525493",
"0.65066767",
"0.646967",
"0.63950604",
"0.63758546",
"0.63500893",
"0.6338224",
"0.6326445",
"0.6326445",
"0.631983",
"0.63187796",
"0.63164634",
"0.63074344",
"0.6295102",
"0.6282723",
"0.6271082",
"0.6254746",
"0.6254746"... | 0.66448176 | 2 |
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
name = dictionary.get('name')
scheduling = meraki.models.scheduling_model.SchedulingModel.from_dictionary(dictionary.get('schedulin... | {
"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.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.7801407",... | 0.8118749 | 3 |
Detect LF or CRLF newlines in a string by looking at the end of the first line | def detect_newline(string: str) -> str:
first_lf_pos = string.find("\n")
if first_lf_pos > 0 and string[first_lf_pos - 1] == "\r":
return "\r\n"
return "\n" | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def detect_nl(string_or_lines, line_end=None):\n if line_end is None:\n line_end = '\\n' if (string_or_lines and\n string_or_lines[-1].endswith('\\n')) else ''\n return line_end",
"def is_eof(line):\n return line == \"\"",
"def _has_newline(line) -> bool:\n if line... | [
"0.7394444",
"0.68073046",
"0.6609574",
"0.625732",
"0.6152909",
"0.61358434",
"0.60357213",
"0.59975314",
"0.5993197",
"0.58893144",
"0.58762205",
"0.5856547",
"0.585503",
"0.58519197",
"0.5804647",
"0.58043027",
"0.5777561",
"0.57619953",
"0.5737633",
"0.5732159",
"0.570855... | 0.7932517 | 0 |
Join a list of lines back, adding a linefeed after each line This is the reverse of ``str.splitlines()``. | def joinlines(lines: Iterable[str], newline: str = "\n") -> str:
return "".join(f"{line}{newline}" for line in lines) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def join_lines(strings):\n liness = [string.splitlines() for string in strings]\n return '\\n'.join(''.join(lines) for lines in zip(*liness))",
"def join_lines(lst):\n out = \"\"\n for line in lst:\n if line.startswith(\"[\") and line.endswith(\"]\"):\n out = f\"{out}\\n{line}\\n\"\... | [
"0.68668073",
"0.6618031",
"0.6415966",
"0.6370114",
"0.6345548",
"0.6344231",
"0.6172707",
"0.60735846",
"0.60735846",
"0.5951289",
"0.59325594",
"0.5896327",
"0.5874852",
"0.58594126",
"0.58511895",
"0.5841074",
"0.5720319",
"0.5712678",
"0.56969863",
"0.5684662",
"0.566502... | 0.76907945 | 0 |
Returns the index of a column. | def column_index(self, column_name: str) -> int:
return self._column_indices[column_name] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_index(self, column):\r\n\r\n\t\treturn self.columns.index(column)",
"def getColIdx(self, col):\n try:\n return int(col)\n except:\n return ord(col)-ord('a')",
"def getColIdx(self, col):\n try: \n return int(col)\n except:\n return ... | [
"0.8619392",
"0.8429728",
"0.84154207",
"0.83312255",
"0.80317616",
"0.76882744",
"0.75399107",
"0.74809426",
"0.7480255",
"0.7480255",
"0.7480255",
"0.7480255",
"0.7480255",
"0.7480255",
"0.7480255",
"0.7480255",
"0.7480255",
"0.7480255",
"0.7480255",
"0.7480255",
"0.7480255... | 0.8449339 | 1 |
Returns a new column group schema with properly recased member names. | def recase_schema(
obj: ColumnGroupSchema, uncasefold: Mapping[str, str]
) -> ColumnGroupSchema:
if isinstance(obj, str):
return uncasefold[obj.casefold()]
if isinstance(obj, collections.abc.Mapping):
return {key: recase_schema(value, uncasefold) for key, value in obj.items()}
return [re... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_column_family_name_generation(self):\r\n class TestModel(Model):\r\n id = columns.UUID(primary_key=True, default=lambda:uuid4())\r\n text = columns.Text()\r\n\r\n assert TestModel.column_family_name(include_keyspace=False) == 'test_model'",
"def test_new_columns(self... | [
"0.5103442",
"0.5068711",
"0.5054673",
"0.5048149",
"0.5021421",
"0.49743184",
"0.49688938",
"0.49561247",
"0.49495164",
"0.4924085",
"0.49119753",
"0.48623934",
"0.48522207",
"0.4816956",
"0.47880214",
"0.4778498",
"0.47763094",
"0.47636637",
"0.4746027",
"0.47379166",
"0.47... | 0.5384115 | 0 |
Return a list of column groups that match the given column names. | def get_matched_colgroups(column_names: Iterable[str]) -> List[ColumnGroupRule]:
casefold_to_normal = {name.casefold(): name for name in column_names}
matched_colgroups = []
for group in COLUMN_GROUPS:
try:
new_schema = recase_schema(group.schema, casefold_to_normal)
except KeyE... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_matching_columns(self, columns):\n result = []\n for column in columns:\n if self.match(column):\n result.append(column)\n return result",
"def get_sorted_columns_and_groups(\n columns: Collection[str], colgroups: Iterable[ColumnGroupRule]\n) -> List[Unio... | [
"0.7152319",
"0.62195057",
"0.620709",
"0.6017562",
"0.59982556",
"0.59308577",
"0.581594",
"0.5789305",
"0.57864106",
"0.57861966",
"0.57049054",
"0.5701381",
"0.56945986",
"0.5563272",
"0.5550737",
"0.55381936",
"0.54624593",
"0.5457094",
"0.54433465",
"0.541781",
"0.541461... | 0.77742374 | 0 |
Increase the indentation level by one | def indent(self, increment=1):
# increase the indentation level
self._level += increment
# and adjust the margin filler
self.leader = self._indenter * self._level
# all done
return self | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _increaseindentation(self):\n self._indentlist.append(self._curindent)\n if not self._equalsigns[-1]:\n self._curindent = self._curindent + self._indent",
"def increase_code_indent(self) -> None:\n self._parent_node.increase_code_indent()",
"def indent(self):\n self.i... | [
"0.8237046",
"0.79159904",
"0.78635204",
"0.78635204",
"0.7170532",
"0.687158",
"0.6782295",
"0.6777727",
"0.67730385",
"0.6723844",
"0.6679106",
"0.65906405",
"0.6579315",
"0.6548523",
"0.6477567",
"0.64704555",
"0.64276993",
"0.63955116",
"0.6369951",
"0.63511485",
"0.63365... | 0.75003016 | 4 |
This function prints and plots the confusion matrix. Normalization can be applied by setting `normalize=True`. | def plot_confusion_matrix(cm, classes,
normalize=False,
title='Confusion matrix',
cmap=plt.cm.Blues):
plt.imshow(cm, interpolation='nearest', cmap=cmap)
plt.title(title)
plt.colorbar()
tick_marks = np.arange(len(classes))
... | {
"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.8195649",
"0.8095532",
"0.803007",
"0.8019817",
"0.7994959",
"0.7991904",
"0.79818887",
"0.79766536",
"0.7961735",
"0.7957412",
"0.79385704",
"0.7935568",
"0.79352015",
"0.7932079",
"0.79270303",
"0.7925357",
"0.79243845",
"0.7923781",
"0.792341",
"0.79226786",
"0.7918532"... | 0.0 | -1 |
Test function to check equality of two SciPy Compressed Sparse Row (CSR) matrices. | def test__csr_matrix_equal(self):
matrix_a = sparse.csr_matrix(([1.0], ([0], [0])), shape=(2, 2))
matrix_b = sparse.csr_matrix(([1.0], ([0], [0])), shape=(2, 2))
matrix_c = sparse.csr_matrix(([1.0], ([1], [0])), shape=(2, 2))
self.assertEqual(decaydata._csr_matrix_equal(matrix_a, matrix... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_check_sparse(self):\n x, x_rand, s = self.create_testdata()\n task = mmRDTR()\n #check that a dense array x is passed thru unchanged\n check = task.check_sparse(x)\n self.assertEqual(np.all(check==x),True)\n #check that a sparse matrix s is converted to a numpy ar... | [
"0.75255007",
"0.70881766",
"0.6936769",
"0.6748501",
"0.6725134",
"0.6625221",
"0.6262431",
"0.62476075",
"0.6242845",
"0.6235576",
"0.6234698",
"0.6216757",
"0.617656",
"0.6069728",
"0.6065661",
"0.6020067",
"0.5997353",
"0.59542704",
"0.5946027",
"0.59227175",
"0.5916793",... | 0.8238183 | 0 |
Test instantiation of DecayData objects. | def test_decaydata_instantiation(self):
# pylint: disable=too-many-statements
# check instantiation from sub-package
data = decaydata.DecayData("icrp107", load_sympy=False)
self.assertEqual(data.dataset, "icrp107")
self.assertEqual(data.hldata[0][0], 100.5)
self.assertE... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_init(self):\n xtal_model_data = XtalModelData(self.params)\n\n assert xtal_model_data.pdb == self.params.input.pdb\n\n assert xtal_model_data.mtz == self.params.input.mtz\n\n # TODO Assert utilised method calls of these classes\n # Assert is innstance causses issues if c... | [
"0.67739683",
"0.6569035",
"0.6552307",
"0.64942336",
"0.6327415",
"0.62917715",
"0.62742186",
"0.6183184",
"0.6181641",
"0.6171357",
"0.61660767",
"0.6160217",
"0.61252683",
"0.61206543",
"0.611989",
"0.60632426",
"0.6022004",
"0.60123825",
"0.6011048",
"0.5974161",
"0.59692... | 0.6696012 | 1 |
Creates a full URL for provided REST endpoint | def public_rest_url(path_url: str, domain: str = CONSTANTS.DEFAULT_DOMAIN) -> str:
return CONSTANTS.FTX_BASE_URL + path_url | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _construct_url(self, endpoint):\n return self.base_url + self.api_path + endpoint.strip('/')",
"def add_url(self, endpoint):\n api = r'(?P<resource_name>%s)/(?P<endpoint>%s)%s$' % (\n self._meta.resource_name, endpoint, trailing_slash())\n endpoint = endpoint.replace('/', '_')... | [
"0.8243008",
"0.7940678",
"0.7839511",
"0.7784653",
"0.7773007",
"0.7571946",
"0.7517695",
"0.74843836",
"0.7477074",
"0.71473217",
"0.71329594",
"0.700247",
"0.69765604",
"0.6937978",
"0.68577546",
"0.68577546",
"0.68535316",
"0.6826645",
"0.6775876",
"0.67483515",
"0.671751... | 0.722862 | 9 |
Return the total number of items in stock. | def stock_count(self):
return self.stock_level_records.aggregate(models.Sum("stock_level"))[
"stock_level__sum"
] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_numStocks(self):\n return len(self.DoS)",
"def num_items(self):\n num_items = 0\n for line in self.lines.all():\n num_items += line.quantity\n return num_items",
"def count_items(self):\n count = 0\n for o in self.order_lst:\n count += o.c... | [
"0.7388547",
"0.7379074",
"0.7302415",
"0.7249715",
"0.71613944",
"0.7151938",
"0.7118709",
"0.7084765",
"0.7064341",
"0.70529896",
"0.7047173",
"0.6938453",
"0.6902857",
"0.6891417",
"0.68682635",
"0.68492645",
"0.6829879",
"0.6824458",
"0.6810021",
"0.67641544",
"0.6744819"... | 0.7622305 | 0 |
Return the total number of items in stock. | def stock_value(self):
return self.stock_level_records.aggregate(models.Sum("stock_value"))[
"stock_value__sum"
] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stock_count(self):\n return self.stock_level_records.aggregate(models.Sum(\"stock_level\"))[\n \"stock_level__sum\"\n ]",
"def get_numStocks(self):\n return len(self.DoS)",
"def num_items(self):\n num_items = 0\n for line in self.lines.all():\n num_i... | [
"0.76232326",
"0.7390424",
"0.7380012",
"0.7304414",
"0.72493184",
"0.7163424",
"0.7153582",
"0.71206063",
"0.7087765",
"0.7064969",
"0.7055602",
"0.7045999",
"0.6940769",
"0.69043976",
"0.68898976",
"0.6872859",
"0.6847202",
"0.68326193",
"0.68248373",
"0.6814781",
"0.676685... | 0.0 | -1 |
Set the stock value attribute. | def save(self, *args, **kwargs):
self.stock_value = self.purchase_price * self.stock_level
super().save(*args, **kwargs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_value (self):\n raise NotImplementedError",
"def value(self, value):\n self.set_data(value)",
"def set_value(self, value):\n self.value = value",
"def set_value(self, value):\n self.value = value",
"def set_value(self, value):\n self.value = value",
"def set_val... | [
"0.69734466",
"0.696847",
"0.68452173",
"0.68452173",
"0.68452173",
"0.67967826",
"0.67967826",
"0.6740443",
"0.67321837",
"0.67065233",
"0.6690324",
"0.66863203",
"0.66863203",
"0.66863203",
"0.66863203",
"0.66863203",
"0.66863203",
"0.6581731",
"0.65605265",
"0.6555424",
"0... | 0.6415544 | 30 |
Search for user groups. | def search_user_groups(self, fields=None, q=None):
params = {}
if fields:
params.update({"f": fields})
page_num = 1
page_size = 1
total = 2
if q:
params['q'] = q
while page_num * page_size < total:
resp = self.sonarqube.make... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _find_groups_for_user(email):\n return [g['name'] for g in groups.find({\"users\":email})]",
"def groupfinder(user_id, request):\n ret = DBSession.query(User).filter_by(user_id=user_id).all()\n if len(ret) == 0:\n return None\n user = ret[0]\n groups = [x.group_name for x in user.groups... | [
"0.73511565",
"0.7229867",
"0.69564825",
"0.6768786",
"0.67485344",
"0.66775644",
"0.6652841",
"0.6642174",
"0.6529533",
"0.65077156",
"0.649436",
"0.64233947",
"0.6402569",
"0.63738227",
"0.63667256",
"0.63541615",
"0.63374853",
"0.6292058",
"0.62379146",
"0.62174886",
"0.62... | 0.723609 | 1 |
Delete a group. The default groups cannot be deleted. | def delete_group(self, group_name):
params = {
'name': group_name
}
self.sonarqube.make_call('post', API_USER_GROUPS_DELETE_ENDPOINT, **params) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete_group(self, group):\n raise NotImplementedError('delete_group')",
"def deleteGroup(groupName):\r\n Group.deleteGroup(groupName)",
"def delete_group(self, group_name):\r\n params = {'GroupName' : group_name}\r\n return self.get_response('DeleteGroup', params)",
"def dele... | [
"0.85996777",
"0.8159453",
"0.8094092",
"0.8003237",
"0.7968093",
"0.79495174",
"0.7904916",
"0.78762573",
"0.78659636",
"0.7856635",
"0.7844608",
"0.7742248",
"0.7673185",
"0.76722735",
"0.7644875",
"0.75909734",
"0.75873613",
"0.7455524",
"0.7453251",
"0.7440715",
"0.740857... | 0.7488563 | 17 |
generic safe_load wrapper for yaml archive | def load_yaml(fname: str) -> dict:
try:
with open(fname, 'r') as f:
dataMap = yaml.safe_load(f)
except IOError as e:
print(f"Cannot open YAML file {fname}")
print(f"IOError: {e}")
return dataMap | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _yaml_load(src):\n if not isinstance(src, str):\n try:\n src_name = src.name\n except AttributeError:\n src_name = '<yaml stringio>'\n # Force-load file streams as that allows the parser to print\n # much more context when it encounters an error\n src... | [
"0.6901544",
"0.68751246",
"0.6811836",
"0.6714929",
"0.65805846",
"0.64860374",
"0.64731103",
"0.6400237",
"0.6396996",
"0.6364283",
"0.6343225",
"0.6317528",
"0.6310397",
"0.6309815",
"0.627029",
"0.6269992",
"0.6267566",
"0.6227912",
"0.6218515",
"0.62127984",
"0.6194398",... | 0.5706396 | 67 |
Get listing of all possible platform combinations matching current platform. | def get_platform_combinations():
mapped_osname = platform_map(g_osname)
mapped_osarch = g_osarch
ret = [mapped_osname]
while True:
ret += [mapped_osarch, mapped_osname + "-" + mapped_osarch]
mapped_osarch = platform_map_iterate(mapped_osarch)
if not mapped_osarch:
break
return sorted(ret, re... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_platforms(self):\n if self.platform == 'All':\n return PLATFORMS\n else:\n return self.platform.split(':')",
"def Platforms():\n return platforms",
"def get_matched_platforms(self, platform):\n raise NotImplemented",
"def list_platforms(self):\n re... | [
"0.75622964",
"0.7488366",
"0.73613954",
"0.73313236",
"0.70974034",
"0.7095553",
"0.68632317",
"0.6859219",
"0.6778722",
"0.66186064",
"0.6585389",
"0.6424543",
"0.6370951",
"0.6341034",
"0.6313573",
"0.6301878",
"0.6198991",
"0.6172565",
"0.6147571",
"0.6089287",
"0.6066857... | 0.7619742 | 0 |
Get name of this. | def get_name(self):
return self.__name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_name(self):\n\n\t\treturn self.__name",
"def get_name(self):\n\t\treturn self.__name",
"def get_name(self):\n return self.__name",
"def get_name(self):\n return self.__name",
"def get_name(self):\n return self.__name",
"def get_name(self):\r\n return self.__name",
"d... | [
"0.8951983",
"0.8944317",
"0.8875192",
"0.8875192",
"0.8875192",
"0.8853432",
"0.8853432",
"0.8853432",
"0.8853432",
"0.8840195",
"0.8840195",
"0.8840195",
"0.8840195",
"0.8840195",
"0.8840195",
"0.8840195",
"0.88327646",
"0.8828548",
"0.88084143",
"0.87896115",
"0.87753177",... | 0.8720406 | 34 |
Get size of this. | def get_size(self):
return self.__size | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_size(self) -> int:\n return self.__size",
"def get_size(self):\r\n return self.__size",
"def __get_size(self):\n return self.__size",
"def get_size(self):\n return self.__size",
"def get_size(self):\n return self.__size",
"def getsize(self):\n return self... | [
"0.9127883",
"0.9068546",
"0.90625155",
"0.90456945",
"0.90456945",
"0.89912534",
"0.8973999",
"0.8956639",
"0.8939666",
"0.8939666",
"0.8939666",
"0.8939666",
"0.8939666",
"0.8937572",
"0.8937572",
"0.8937572",
"0.8922063",
"0.8922063",
"0.88883835",
"0.88623357",
"0.8858647... | 0.8919639 | 18 |
Tell if this is reconstructable. | def reconstructable(self, accept_label_post):
if self.__name:
return False
if self.__label_pre:
return False
if self.__label_post and not accept_label_post:
return False
if "" != self.__desc:
return False
if -1 != self.__original_size:
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def can_retransform(self):\r\n return self._can_retransform",
"def can_redefine(self):\r\n return self._can_redefine",
"def isSetReversible(self):\n return _libsbml.Reaction_isSetReversible(self)",
"def is_reloading(self):\n if self.gun_interface:\n return self.gun_interface.is... | [
"0.6744048",
"0.66146284",
"0.6188276",
"0.57828975",
"0.5694032",
"0.5631945",
"0.557074",
"0.5546739",
"0.55337346",
"0.5440852",
"0.54309857",
"0.5416869",
"0.5373752",
"0.5332476",
"0.53195643",
"0.5305508",
"0.52682155",
"0.52674127",
"0.52559596",
"0.52428925",
"0.52333... | 0.6559855 | 2 |
Get cumulative size of data. | def size(self):
ret = 0
for ii in self.__data:
ret += int(ii.get_size())
return ret | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __len__(self):\n return len(self.cumulative_length)",
"def totalsize(self):\n return sum([sz for sz in self.iterate()])",
"def get_size(self):\n cum_size = 0\n for stream in self.__streams.values():\n cum_size += sys.getsizeof(stream)\n for trace in stream:... | [
"0.7311951",
"0.69841903",
"0.69333625",
"0.6806765",
"0.67907125",
"0.66829747",
"0.66719043",
"0.667019",
"0.6664927",
"0.6657343",
"0.6629253",
"0.66140056",
"0.66115147",
"0.6600715",
"0.65852046",
"0.6567605",
"0.65446043",
"0.653561",
"0.651902",
"0.651902",
"0.651902",... | 0.71465605 | 1 |
Get function prototype for given symbol. | def generate_prototype(self):
apientry = ""
if self.__name[:2] == "gl":
apientry = "DNLOAD_APIENTRY "
params = "void"
if self.__parameters:
params = ", ".join(self.__parameters)
return "(%s (%s*)(%s))" % (self.__returntype, apientry, params) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getFunctionSymbol(self, symbol):\n if ( symbol in list(self.dict.keys()) and self.dict[symbol][\"type\"] == \"func\"):\n return self.dict[symbol]\n return None",
"def parse_prototype(text):\n m = re_symbol.match(text)\n if not m:\n raise ValueError(\"Invalid function nam... | [
"0.6904165",
"0.6144968",
"0.56690747",
"0.56596625",
"0.54507565",
"0.5377261",
"0.53632045",
"0.53068024",
"0.5263871",
"0.52638155",
"0.51988244",
"0.51778233",
"0.5152622",
"0.5146418",
"0.51227",
"0.51007426",
"0.51006484",
"0.50757515",
"0.50592107",
"0.5056987",
"0.503... | 0.0 | -1 |
Get indentation for given level. | def get_indent(op):
ret = ""
for ii in range(op):
# Would tab be better?
ret += " "
return ret | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def indentation(self):\n return self.options.indentation_char * sum(self._indentation_levels)",
"def get_level(self, level):\n return",
"def indent(str, level):\n if level == 0: return str\n return \"\\n\".join(\"\\t\" * level + line for line in str.splitlines())",
"def indent(self, modif... | [
"0.65550226",
"0.6416344",
"0.6308598",
"0.61756605",
"0.6079057",
"0.5995147",
"0.5980143",
"0.59340185",
"0.59190285",
"0.5891826",
"0.5825542",
"0.57668513",
"0.56207246",
"0.56166",
"0.56153184",
"0.5561847",
"0.55430686",
"0.55430686",
"0.55430686",
"0.55430686",
"0.5539... | 0.49400732 | 70 |
Serialize a single boolean. | def addBool(self, b):
self._buf.push(_B_STRUCT.pack(b)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def write_boolean(self, boolean: bool) -> None:\n self.write(bytearray([bool(boolean)]))",
"def writeBoolean(self, value: bool):\n self.writeByte(1 if value else 0)",
"def write_bool(self, b: bool) -> None:\n self.buffer += struct.pack(\"<?\", b)",
"def _writeBool(self, val):\n se... | [
"0.77929187",
"0.76032776",
"0.7370491",
"0.7330124",
"0.72378254",
"0.71882665",
"0.7108701",
"0.71003276",
"0.70521367",
"0.7029195",
"0.6907123",
"0.6870375",
"0.68519986",
"0.67760545",
"0.6765555",
"0.6760042",
"0.6709866",
"0.66931534",
"0.66845185",
"0.66162974",
"0.66... | 0.6348585 | 35 |
Deserialize a single boolean. | def getBool(self):
try:
data, n = self._buf.pop(_B_LEN)
if n != _B_LEN:
raise SerializationError('There is not enough data left.')
return bool(_B_STRUCT.unpack(data)[0])
except StructError as e:
raise Serialization... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def deserialize(value, **kwargs):\n try:\n if isinstance(value, str) and \\\n value.lower() in ['true', 'yes', 'on']:\n return True\n elif isinstance(value, str) and \\\n value.lower() in ['false', 'no', 'off']:\n retu... | [
"0.79400104",
"0.74832255",
"0.7224446",
"0.7112827",
"0.6987627",
"0.6961213",
"0.68758327",
"0.68499094",
"0.6832832",
"0.6799196",
"0.67943746",
"0.67744946",
"0.6773111",
"0.66822505",
"0.6674439",
"0.666423",
"0.6651678",
"0.66023916",
"0.6597125",
"0.6585264",
"0.657865... | 0.70406437 | 4 |
Deserialize a single float. | def getFloat(self):
try:
data, n = self._buf.pop(_F_LEN)
if n != _F_LEN:
raise SerializationError('There is not enough data left.')
return _F_STRUCT.unpack(data)[0]
except StructError as e:
raise SerializationError... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_float(self):\n return self._packers[\"f\"].unpack(self.read(4))[0]",
"def readFloat(self) -> float:\n return self._unpack('!f', 4)",
"def read_float(stream, writer_schema=None, reader_schema=None): # noqa\n return unpack('<f', stream.read(4))[0]",
"def test_deserialize_float_value(... | [
"0.74769074",
"0.7387994",
"0.7351711",
"0.6980962",
"0.6840877",
"0.67874324",
"0.67615104",
"0.6487746",
"0.64785",
"0.6448749",
"0.64223176",
"0.6356875",
"0.63376343",
"0.6331015",
"0.6319609",
"0.63133174",
"0.63013625",
"0.6262091",
"0.6233303",
"0.6209672",
"0.6181696"... | 0.72874576 | 3 |
Internally used method to get a part of the message as string. | def _getStr(self, length):
element, n = self._buf.pop(length)
if n != length:
raise SerializationError('There is not enough data left.')
return element | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def message(self) -> str:\n return self.fields.get('msg', self.raw_string)",
"def _get_message(self):\n return self.__message",
"def get_message(self):\n return self.msg",
"def getMessage():\n return message",
"def message(self):\n return self._message",
"def msg(self):\n\t\tre... | [
"0.69575095",
"0.6956784",
"0.69352585",
"0.69030523",
"0.6879262",
"0.6869154",
"0.68218803",
"0.670414",
"0.670414",
"0.6696315",
"0.6696315",
"0.6696315",
"0.6696315",
"0.6696315",
"0.6696315",
"0.6686749",
"0.6643288",
"0.6643288",
"0.6643288",
"0.6643288",
"0.6643288",
... | 0.0 | -1 |
Get the FIFO containing the remaining data. | def getFIFO(self):
return self._buf | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pop_sm(self):\r\n while True:\r\n # wait to receive a read request\r\n req = yield self.r_in_pipe.get()\r\n # model read latency\r\n #for i in range(self.read_latency):\r\n yield self.wait_sys_clks(self.read_latency)\r\n # try to read hea... | [
"0.66020125",
"0.636941",
"0.6243222",
"0.6241263",
"0.62131983",
"0.61683995",
"0.61492604",
"0.6086427",
"0.6028599",
"0.60279167",
"0.59935087",
"0.5981691",
"0.592324",
"0.5900166",
"0.5897246",
"0.5897135",
"0.58534783",
"0.58517134",
"0.58464026",
"0.5846327",
"0.583631... | 0.7588719 | 0 |
Throws InventoryError if parameters.kapitan.vars.target is not set, or target does not have a corresponding yaml file in inventory_path | def validate_matching_target_name(target_filename, target_obj, inventory_path):
logger.debug("validating target name matches the name of yml file %s", target_filename)
try:
target_name = target_obj["vars"]["target"]
except KeyError:
error_message = (
f'Target missing: target "{ta... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_load_no_project():\n\n assert_raises(Exception, inventory.load, PROJECT_NAME)",
"def test_save_bad_inventory2():\n config_ = {\"schema\": \"avalon-core:config-1.0\"}\n inventory_ = {\"schema\": \"avalon-core:inventory-1.0\"}\n\n assert_raises(\n schema.ValidationError,\n invent... | [
"0.59209937",
"0.58351403",
"0.5828817",
"0.5822175",
"0.5749177",
"0.53923494",
"0.5376362",
"0.5310131",
"0.5305096",
"0.5227773",
"0.52149165",
"0.5206028",
"0.5184792",
"0.5184778",
"0.5163969",
"0.51631105",
"0.5145897",
"0.5138561",
"0.5133494",
"0.5131321",
"0.51094306... | 0.5682999 | 5 |
Return whether this rule can return meaningful result, given the `options` dict. If some options are missing, then rule shouldn't be matched against, and this function returns False. | def matching_supported(self, options=None):
if self.is_comment:
return False
if self.is_html_rule: # HTML rules are not supported yet
return False
options = options or {}
keys = set(options.keys())
if not keys.issuperset(self._options_keys):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_correct_options(options):\n\n has_correct = False\n\n for option in options:\n if option.get('correct') is True:\n has_correct = True\n\n if not has_correct:\n return c('error_need_correct')",
"def is_valid(option_set):\n area = get_area(option_set)\n duration = ge... | [
"0.7036239",
"0.6364745",
"0.630673",
"0.62812024",
"0.62683153",
"0.6259693",
"0.6234793",
"0.6227847",
"0.60607165",
"0.60000026",
"0.589558",
"0.5893934",
"0.58001876",
"0.5755991",
"0.5750212",
"0.56371593",
"0.5628357",
"0.5605693",
"0.55971205",
"0.55375344",
"0.5512098... | 0.7264887 | 0 |
Return if ``url``/``options`` are matched by rules defined by ``general_re``, ``domain_required_rules`` and ``rules_with_options``. ``general_re`` is a compiled regex for rules without options. | def _matches(self, url, options,
general_re, domain_required_rules, rules_with_options):
if general_re and general_re.search(url):
return True
rules = []
if 'domain' in options and domain_required_rules:
src_domain = options['domain']
for dom... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def match_url(self, url, options=None):\n options = options or {}\n for optname in self.options:\n if optname == 'match-case': # TODO\n continue\n\n if optname not in options:\n raise ValueError(\"Rule requires option %s\" % optname)\n\n ... | [
"0.7129203",
"0.6051058",
"0.59464043",
"0.5634629",
"0.54661834",
"0.5397589",
"0.52203137",
"0.51650745",
"0.51156276",
"0.5050364",
"0.503326",
"0.50111085",
"0.49953815",
"0.49490905",
"0.49296597",
"0.4923371",
"0.4901476",
"0.48993343",
"0.4895032",
"0.48770002",
"0.486... | 0.8040253 | 0 |
Test for instantiation of the ``EventCategory`` model. | def test_instantiation(self):
event_category = EventCategory()
self.assertTrue(event_category) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_create(self):\n self.assertTrue(Category.objects.exists())",
"def test_create_category(self):\n pass",
"def test_create_cat_object():\n from .scripts.initializedb import create_cat_object\n cat_object = create_cat_object(\"a\", \"b\", \"c\", \"c\")\n assert isinstance(cat_object... | [
"0.6978919",
"0.6868121",
"0.6853159",
"0.65846586",
"0.6305626",
"0.6129511",
"0.61253476",
"0.6032864",
"0.6030713",
"0.6030447",
"0.6020336",
"0.60164493",
"0.5996522",
"0.59632874",
"0.59564805",
"0.59418356",
"0.59381324",
"0.59206843",
"0.5914982",
"0.5893996",
"0.58798... | 0.84762317 | 0 |
Test for instantiation of the ``Occurrence`` model. | def test_instantiation(self):
occurrence = Occurrence()
self.assertTrue(occurrence) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_create_occurrence(self):\n occurrence = self.event._create_occurrence(now())\n self.assertEqual(type(occurrence), Occurrence, msg=(\n 'Method ``_create_occurrence`` did not output the right type.'))",
"def test_create_occurrence_without_event(self):\n Occurrence()",
"de... | [
"0.7281463",
"0.7146957",
"0.6939361",
"0.6078205",
"0.60280645",
"0.5968112",
"0.5939474",
"0.5871335",
"0.58672935",
"0.58392227",
"0.5837775",
"0.5699185",
"0.5650896",
"0.561712",
"0.5564759",
"0.5489304",
"0.5464864",
"0.5424573",
"0.54069865",
"0.53881294",
"0.53848237"... | 0.78691727 | 0 |
Generate a filename based on the given parameters. | def _gen_fname(self, basename, cwd=None, suffix=None, change_ext=True,
ext='.mif'):
if basename == '':
msg = 'Unable to generate filename for command %s. ' % self.cmd
msg += 'basename is not set!'
raise ValueError(msg)
if cwd is None:
c... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _generate_filename(doc_type, login, *args):\n filename = []\n filename.append(doc_type)\n filename.append(login)\n for item in args:\n filename.append(item)\n filename.append(datetime.datetime.now().isoformat(timespec='microseconds'))\n filename = '_... | [
"0.76038855",
"0.74714875",
"0.7428159",
"0.74156386",
"0.737633",
"0.72863644",
"0.7268317",
"0.72336495",
"0.72164226",
"0.72159445",
"0.7191817",
"0.717569",
"0.7169469",
"0.70664084",
"0.70464534",
"0.7040761",
"0.70302564",
"0.7018421",
"0.6987019",
"0.6985401",
"0.69444... | 0.6561952 | 44 |
Generate a filename based on the given parameters. | def _gen_fname(self, basename, cwd=None, suffix=None, change_ext=True,
ext='.mif'):
if basename == '':
msg = 'Unable to generate filename for command %s. ' % self.cmd
msg += 'basename is not set!'
raise ValueError(msg)
if cwd is None:
c... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _generate_filename(doc_type, login, *args):\n filename = []\n filename.append(doc_type)\n filename.append(login)\n for item in args:\n filename.append(item)\n filename.append(datetime.datetime.now().isoformat(timespec='microseconds'))\n filename = '_... | [
"0.76042557",
"0.74721336",
"0.7428368",
"0.74158543",
"0.7377124",
"0.72866356",
"0.72689134",
"0.72342443",
"0.7217181",
"0.72163254",
"0.71925366",
"0.7176111",
"0.71697724",
"0.7066605",
"0.70470846",
"0.7041149",
"0.7030538",
"0.701924",
"0.6987508",
"0.6985752",
"0.6944... | 0.65627617 | 43 |
Sort tweets by popularity. Tweets must be sorted in descending order. A tweet is more popular than the other if it has more retweets. If the retweets are even, the newer tweet is the more popular one. >Tweet1 has 10 retweets. >Tweet2 has 30 retweets. >30 is bigger than 10 > tweet2 is the more popular one. | def sort_by_popularity(tweets: list) -> list:
tweets_by_popularity = sorted(tweets, key=lambda x: (x.retweets, -x.time), reverse=True) # Use lambda functions when an anonymous function is required for a short period of time.
return tweets_by_popularity | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sort_hashtags_by_popularity(tweets: list) -> list:\n hashtags_by_popularity = {}\n pattern = r\"#\\w+\"\n for tweet in tweets:\n find_hashtag = re.findall(pattern, tweet.content)\n if not find_hashtag:\n continue\n else:\n for ht in find_hashtag:\n ... | [
"0.72086954",
"0.6634835",
"0.6537147",
"0.6512715",
"0.638781",
"0.61812156",
"0.6161245",
"0.61347455",
"0.60856587",
"0.60808486",
"0.6046317",
"0.6040352",
"0.6021192",
"0.59636885",
"0.5714501",
"0.5635846",
"0.56224364",
"0.55373555",
"0.55107176",
"0.5509282",
"0.54656... | 0.81967425 | 0 |
Calculate the context vector and attention distribution from the decoder state. | def q_attention(decoder_state, coverage=None):
with variable_scope.variable_scope("Question_Attention"):
# Pass the decoder state through a linear layer (this is W_s s_t + b_attn in the paper)
decoder_features = linear(decoder_state, attention_vec_size, True) # shape (batch_size, attention_vec_siz... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def attention(self, decoder_state, coverage=None):\n with tf.variable_scope(\"attention_compute\"):\n attn_size = 2*self.hidden_dim\n batch_size = tf.shape(self.encoder_states)[0]\n # Reshape encoder_states (need to insert a dim)\n encoder_states = tf.expand_dims(... | [
"0.6434249",
"0.6233957",
"0.61137545",
"0.60123605",
"0.59904397",
"0.5962933",
"0.5948498",
"0.5918534",
"0.58688605",
"0.58655345",
"0.5805446",
"0.5757829",
"0.57023203",
"0.5693168",
"0.5652662",
"0.56198937",
"0.55608445",
"0.55564976",
"0.55499417",
"0.5531495",
"0.550... | 0.5155466 | 36 |
Calculate the context vector and attention distribution from the decoder state. | def r_attention(decoder_state, sent_attention, coverage=None):
with variable_scope.variable_scope("Review_Attention"):
# Pass the decoder state through a linear layer (this is W_s s_t + b_attn in the paper)
decoder_features = linear(decoder_state, attention_vec_size, True) # shape (batch_size, att... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def attention(self, decoder_state, coverage=None):\n with tf.variable_scope(\"attention_compute\"):\n attn_size = 2*self.hidden_dim\n batch_size = tf.shape(self.encoder_states)[0]\n # Reshape encoder_states (need to insert a dim)\n encoder_states = tf.expand_dims(... | [
"0.64342564",
"0.623488",
"0.6114128",
"0.60125464",
"0.59909666",
"0.5965301",
"0.5948194",
"0.59192175",
"0.5869493",
"0.5865634",
"0.5805824",
"0.5757865",
"0.5702304",
"0.5691548",
"0.56203043",
"0.5561481",
"0.55568236",
"0.5550382",
"0.5530452",
"0.5506292",
"0.54951066... | 0.5653915 | 14 |
Take softmax of e then apply enc_padding_mask and renormalize | def masked_attention_q(e, padding_mask):
attn_dist = nn_ops.softmax(e)+1e-8 # take softmax. shape (batch_size, attn_length)
attn_dist *= padding_mask # apply mask
masked_sums = tf.reduce_sum(attn_dist, axis=1) # shape (batch_size)
return attn_dist / tf.reshape(masked_sums, [-1, 1]) # re-normalize | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def softmax(x):\r\n e_x = np.exp(x - np.expand_dims(np.max(x, axis=-1), axis=-1))\r\n return e_x / np.expand_dims(e_x.sum(axis=-1), axis=-1) # only difference\r",
"def softmax_with_xentropy(z):\n\treturn softmax(z)",
"def softmax(x):\n \"\"\"\"\"\"\n return exp(x) / sum(exp(x), axis=0)",
... | [
"0.66436917",
"0.6544238",
"0.64621603",
"0.6389953",
"0.63802594",
"0.63618845",
"0.6348898",
"0.632555",
"0.63057154",
"0.6304174",
"0.6293008",
"0.6290128",
"0.6290128",
"0.62895083",
"0.62895083",
"0.6287029",
"0.6287029",
"0.62851834",
"0.6263683",
"0.6261414",
"0.625115... | 0.6041341 | 90 |
Initializes all of the checkers, sets the appropriate checkers as enabled/disabled, and returns a list of checker objects | def get_checker_list(req_collection, fuzzing_requests, enable_list, disable_list, set_enable_first, custom_checkers, enable_default_checkers=True):
# Add any custom checkers
for custom_checker_file_path in custom_checkers:
try:
spec = importlib.util.spec_from_file_location('custom_checkers',... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_checkers(config):\n\n checkers = []\n if 'checkers' in config:\n for checker_name, checker_config in config['checkers'].iteritems():\n if checker_name in __checkers:\n configs = None\n if type(checker_config) == list:\n configs = c... | [
"0.6699315",
"0.6395436",
"0.63412344",
"0.60727763",
"0.56841475",
"0.55224925",
"0.55192196",
"0.5488269",
"0.5434302",
"0.54231703",
"0.54006433",
"0.5392882",
"0.5381138",
"0.5368976",
"0.5326031",
"0.5325076",
"0.5321039",
"0.5291186",
"0.52409154",
"0.5226855",
"0.52060... | 0.691162 | 0 |
Add audio into video | def add_audio_to_video(audio_path: Union[str, Path],
video_path: Union[str, Path],
out_video_path: [str, Path]) -> Path:
command = 'ffmpeg -loglevel warning -y -i "{}" -i "{}" -c:v copy -c:a copy -shortest {}'.format(
video_path.as_posix(),
audio_path.as... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def merge(video_path, audio_path):\n video_clip = VideoFileClip(video_path)\n audio_clip = AudioFileClip(audio_path)\n final_video = video_clip.set_audio(audio_clip)\n final_video.write_videofile(video_path[:-10] + '.mp4')\n\n os.remove(video_path)\n os.remove(audio_path)\n video_clip.close()\... | [
"0.6910271",
"0.67769235",
"0.6389155",
"0.6350832",
"0.6250503",
"0.6208691",
"0.6035442",
"0.6025434",
"0.59924924",
"0.5967374",
"0.5936128",
"0.58909",
"0.5874258",
"0.5863902",
"0.5850794",
"0.5841139",
"0.58296484",
"0.57920176",
"0.57917464",
"0.57635725",
"0.5748044",... | 0.7074231 | 0 |
RNN decoder with attention for the sequencetosequence model. In this context "attention" means that, during decoding, the RNN can look up information in the additional tensor attention_states, and it does this by focusing on a few entries from the tensor. | def attention_decoder(decoder_inputs,
attention_states,
cell,
output_size=None,
dtype=None,
scope=None):
if not decoder_inputs:
raise ValueError("Must provide at least 1 input to attention decoder."... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def rnn_decoder_with_attention(decoder_inputs, initial_state, cell, loop_function,attention_states,scope=None):#3D Tensor [batch_size x attn_length x attn_size]\n with tf.variable_scope(scope or \"rnn_decoder\"):\n print(\"rnn_decoder_with_attention started...\")\n state = initial_state #[batch_s... | [
"0.6773182",
"0.6564511",
"0.6561908",
"0.6376276",
"0.63077044",
"0.6283391",
"0.6223468",
"0.62045705",
"0.6160511",
"0.6138831",
"0.6120125",
"0.61135036",
"0.6056597",
"0.605465",
"0.5925291",
"0.59229475",
"0.59167665",
"0.5900185",
"0.5874088",
"0.58464354",
"0.58195466... | 0.6350812 | 4 |
Put attention masks on hidden using hidden_features and query. | def attention(query, step):
if nest.is_sequence(query): # If the query is a tuple, flatten it.
query_list = nest.flatten(query)
query = array_ops.concat(query_list, 1)
_tmp = math_ops.matmul(query, w) + b
_tmp = array_ops.reshape(_tmp, [-... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _compute_masked_hidden(self, hidden, mask):\r\n mask = mask.unsqueeze(-1).expand_as(hidden)\r\n hidden_masked = hidden[mask].contiguous().view(-1, hidden.size(-1))\r\n return hidden_masked",
"def reset_hidden(hidden, mask):\n if len(mask) != 0:\n hidden[:, mask,... | [
"0.65520513",
"0.6279056",
"0.59793246",
"0.592145",
"0.59021497",
"0.5858487",
"0.58122665",
"0.57702357",
"0.5737185",
"0.5702718",
"0.56893426",
"0.56797564",
"0.56737244",
"0.558707",
"0.55822736",
"0.5555634",
"0.554214",
"0.55337656",
"0.54494065",
"0.54184794",
"0.5418... | 0.6114558 | 2 |
Initialize input parameters for the atmospheric simulation. | def initPointingSequence(self):
if not self.opsim_visits:
self.readOpsimData()
# Number of visits
self.npoints = len(self.opsim_visits)
# Starting date
self.mjds = self.opsim_visits[0]['expMJD']
# Ending date
self.mjde = self.opsim_visits[-1]['expMJD'] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initializeParameters(self):\r\n\t\tself.input_raster.enabled = True\r\n\t\tself.approach.enabled = True\r\n\t\tself.predefined_pattern.enabled = False\r\n\t\tself.predefined_pattern.value = 'Mexican Hat wavelet'\r\n\t\tself.pattern_workspace.enabled = False\r\n\t\tself.point_matrix_size.enabled = False\r\n\t\t... | [
"0.7224466",
"0.7123327",
"0.6966959",
"0.6875013",
"0.678513",
"0.66819763",
"0.66784626",
"0.66745144",
"0.6629842",
"0.6624583",
"0.66185343",
"0.6594805",
"0.65763736",
"0.6572434",
"0.65524334",
"0.65504616",
"0.6494172",
"0.6492695",
"0.64819425",
"0.64684516",
"0.64559... | 0.0 | -1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.