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 |
|---|---|---|---|---|---|---|
Helper function to calculate a player's distance from Board center | def get_distances_from_center(center_coordinates, p_coordinates):
center_y, center_x = center_coordinates
p_y, p_x = p_coordinates
return (p_y - center_y)**2 + (p_x - center_x)**2 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __distance_from_center__(game, player):\n x,y = game.get_player_location(player)\n return sqrt( (x - game.width/2)**2 + (y - game.height/2)**2 )",
"def distMe_Players(self, player):\n return self.playerPos.distance(player)",
"def centerness(game, player):\n w, h = game.width / 2., game.heig... | [
"0.83418405",
"0.7415835",
"0.7069332",
"0.69432056",
"0.68129027",
"0.67615765",
"0.66179675",
"0.6609212",
"0.65337384",
"0.65257406",
"0.65257406",
"0.65257406",
"0.65257406",
"0.65257406",
"0.65257406",
"0.65257406",
"0.6524911",
"0.64706314",
"0.6453762",
"0.6437889",
"0... | 0.0 | -1 |
The heuristic value of a game state from the point of view of the given player. This is the best heuristic function for my project submission. It returns improved when improved isn't zero. Otherwise, it returns the sum of weighted differences of improved, center_dist_diff, and improved_next. | def custom_score(game, player):
if game.is_loser(player):
return float("-inf")
if game.is_winner(player):
return float("inf")
# First obtain the improved score
player_legal_moves = game.get_legal_moves(player)
opponent = game.get_opponent(player)
opponent_legal_mov... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculate_utility(state, player):\n thisPlayer = player\n \n if state.winner() == (not thisPlayer):\n return -BigInitialValue\n if state.winner() == thisPlayer:\n return BigInitialValue\n return calculate_possible_fours(state, thisPlayer) - calculate_possible_fours(state, not thisP... | [
"0.77526975",
"0.72867596",
"0.7086798",
"0.69712675",
"0.687997",
"0.6879898",
"0.68406343",
"0.6828652",
"0.6822819",
"0.67437017",
"0.67295605",
"0.6662307",
"0.66408926",
"0.6614673",
"0.66126406",
"0.66005534",
"0.65924233",
"0.6578525",
"0.656726",
"0.6559729",
"0.65475... | 0.7131086 | 2 |
Calculate the heuristic value of a game state from the point of view of the given player. This first, naive attempt at a heuristics function simply uses two features, move_count_difference and weighted_distance_from_center. The former is the difference between the of the player's and the opponent's legal_moves. The lat... | def custom_score_3(game, player):
if game.is_loser(player):
return float("-inf")
if game.is_winner(player):
return float("inf")
player_legal_moves = game.get_legal_moves(player)
opponent = game.get_opponent(player)
opponent_legal_moves = game.get_legal_moves(oppon... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def custom_score(game, player):\n \n if game.is_loser(player):\n return float(\"-inf\")\n\n if game.is_winner(player):\n return float(\"inf\")\n \n # First obtain the improved score\n player_legal_moves = game.get_legal_moves(player)\n opponent = game.get_opponent(player)\n ... | [
"0.72831476",
"0.68793374",
"0.67940086",
"0.6790203",
"0.6782819",
"0.6749319",
"0.67148226",
"0.6698215",
"0.6686758",
"0.6642835",
"0.66311014",
"0.6608248",
"0.6588663",
"0.6582112",
"0.65786815",
"0.6519227",
"0.6508407",
"0.6480575",
"0.6472067",
"0.6449402",
"0.6413044... | 0.7244675 | 1 |
Construct a dictionary out of nonnull keys (from attributes property) present on this object | def get_non_null_attributes(self) -> dict:
return {
key: getattr(self, key, None)
for key in sorted(self.attributes)
if getattr(self, key, None) is not None
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_attributes(self):\n \n retdict = {}\n retdict['s'] = str(self.s)\n if self.t != None:\n retdict['t'] = str(self.t)\n retdict['a'] = str(self.a)\n retdict['b'] = str(self.b)\n retdict['c'] = str(self.c)\n retdict['d'] = str(self.d)\n retu... | [
"0.7535603",
"0.7395065",
"0.7343714",
"0.7284807",
"0.72176325",
"0.719122",
"0.7164409",
"0.7138397",
"0.70722413",
"0.7036349",
"0.7004519",
"0.6974758",
"0.6972536",
"0.6964211",
"0.69521683",
"0.6946444",
"0.6879561",
"0.6855296",
"0.6855296",
"0.6855296",
"0.6813498",
... | 0.8192219 | 0 |
Dry run test after sqlite database and config files have been created. | def test_0():
sync.gen_multi_fake_data()#default is only one randomly selected data set
sync.main(testing=True) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setUp(self):\n self.db_fd, app.app.config['DATABASE'] = tempfile.mkstemp()\n app.app.config['TESTING'] = True\n self.app = app.app.test_client()\n app.init_db()",
"def setUp(self):\n\n app.config.from_object(config['testing'])\n db.create_all()",
"def setUp(self):\... | [
"0.7496376",
"0.7476935",
"0.74588054",
"0.7307874",
"0.7296027",
"0.7292134",
"0.7264974",
"0.72396195",
"0.72386837",
"0.7223599",
"0.72183",
"0.71838194",
"0.7182503",
"0.7167747",
"0.7164882",
"0.71506345",
"0.71506345",
"0.71506345",
"0.70994866",
"0.709525",
"0.70486456... | 0.0 | -1 |
Makes sure `obj` is a list or otherwise converts it to a list with a single element. | def as_list(obj):
return obj if isinstance(obj, list) else [obj] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _to_list(obj):\n if not isinstance(obj, list):\n return [obj]\n else:\n return obj",
"def coerce_to_list(obj) -> list:\n if obj is None:\n return []\n elif isinstance(obj, list):\n return obj\n else:\n return [obj]",
"def listify(obj):\n if obj is None:\... | [
"0.8782757",
"0.8695313",
"0.84343314",
"0.83834887",
"0.83834887",
"0.83834887",
"0.82847327",
"0.79024965",
"0.7804947",
"0.7790739",
"0.75876015",
"0.75796974",
"0.7518073",
"0.7392727",
"0.7334581",
"0.7038185",
"0.69770944",
"0.69687474",
"0.69501996",
"0.69477516",
"0.6... | 0.86098546 | 2 |
Make sure that `obj` is a tuple or a list and eventually converts it into a list with a single element | def as_tuple_or_list(obj):
return obj if isinstance(obj, (list, tuple)) else [obj] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _to_list(obj):\n if not isinstance(obj, list):\n return [obj]\n else:\n return obj",
"def listify(obj):\n return obj if isinstance(obj, (list, tuple, type(None))) else [obj]",
"def ensure_list(obj, allow_tuple=True):\n if isinstance(obj, list):\n return obj\n\n elif allo... | [
"0.80849165",
"0.8083497",
"0.8063976",
"0.8044245",
"0.8044245",
"0.8044245",
"0.7875883",
"0.7852227",
"0.7842887",
"0.77127916",
"0.74556947",
"0.7438182",
"0.73459095",
"0.71298283",
"0.6979588",
"0.6973043",
"0.6936041",
"0.6905337",
"0.6848072",
"0.68262106",
"0.6818398... | 0.8643511 | 0 |
Replace chars that are not accepted by tensorflow namings (eg. variable_scope) | def _tf_string_replace(_str):
return _str.replace('[', 'p').replace(']', 'q').replace(',', 'c').replace('(', 'p').replace(')', 'q').replace(
' ', '') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fix_varname(s):\n t = str(s).translate(TRANS_VARS)\n if t[0] not in VALID_CHARS1:\n t = '_%s' % t\n while t.endswith('_'):\n t = t[:-1]\n return t",
"def _clean_non_alphanumeric_chars(self):\n\n for i,variable in enumerate(self.model_description.modelVariables):\n ... | [
"0.68004704",
"0.66907066",
"0.6572055",
"0.6531297",
"0.647845",
"0.6362549",
"0.6339756",
"0.6328275",
"0.6242392",
"0.61816573",
"0.6178083",
"0.61616343",
"0.6138614",
"0.61260927",
"0.60587096",
"0.6053856",
"0.60527307",
"0.6041325",
"0.60343987",
"0.60279536",
"0.60171... | 0.6596584 | 2 |
Utility methods for getting a `RandomState` object. | def get_rand_state(rand):
if isinstance(rand, np.random.RandomState):
return rand
elif isinstance(rand, (int, np.ndarray, list)) or rand is None:
return np.random.RandomState(rand)
else:
raise ValueError('parameter rand {} has wrong type'.format(rand)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_random_state(self):\n self._validate_random_state()\n return deepcopy(self.random_state)",
"def __RandomState_ctor():\r\n return RandomState(seed=0)",
"def ensure_rng(random_state=None):\n if random_state is None:\n random_state = np.random.RandomState()\n elif isinstance... | [
"0.77282196",
"0.73647755",
"0.70511997",
"0.70511997",
"0.7029731",
"0.70017827",
"0.69902503",
"0.6789867",
"0.67606354",
"0.67363393",
"0.6671872",
"0.6639084",
"0.65553796",
"0.6515009",
"0.6461115",
"0.64309955",
"0.64224917",
"0.6388954",
"0.6383388",
"0.638125",
"0.636... | 0.7537855 | 1 |
Return current transformation anchor. | def get_transformation_anchor(self) -> ViewportAnchorStr:
return VIEWPORT_ANCHOR.inverse[self.transformationAnchor()] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def anchor(self):\n return self._anchor",
"def getAnchor(self):\n return self.anchor",
"def anchor_position(self):\n return self._anchor_x, self._anchor_y",
"def anchor(self) -> Optional[Vertex]:\n return self._anchor",
"def anchor_x(self):\n return self._anchor_x",
"de... | [
"0.7781264",
"0.76299345",
"0.7148469",
"0.7124744",
"0.7005277",
"0.69731665",
"0.6786387",
"0.64587736",
"0.6404696",
"0.6314038",
"0.62900585",
"0.5991087",
"0.5953311",
"0.5953311",
"0.58701324",
"0.5862512",
"0.580695",
"0.57901114",
"0.57578504",
"0.5757281",
"0.5752834... | 0.8055587 | 0 |
Return current drag mode. | def get_drag_mode(self) -> DragModeStr:
return DRAG_MODE.inverse[self.dragMode()] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_mode(self):\r\n return self.mode",
"def getmode(self):\n return self.mode",
"def getMode(self):\n return self._mode",
"def get_mode(self):\r\n return self._api.get_mode()",
"def get_drawing_mode(self) -> int:\n return self._drawing_mode",
"def mode(self):\r\n ... | [
"0.6869745",
"0.6826914",
"0.679277",
"0.6712881",
"0.66982436",
"0.6691498",
"0.6691498",
"0.6691498",
"0.66389006",
"0.66389006",
"0.66389006",
"0.66033685",
"0.6536546",
"0.65094626",
"0.6470906",
"0.6454116",
"0.6433566",
"0.6423743",
"0.6418996",
"0.64064056",
"0.6404308... | 0.84794974 | 0 |
Return current rubberband selection mode. | def get_rubberband_selection_mode(self) -> constants.ItemSelectionModeStr:
return constants.ITEM_SELECTION_MODE.inverse[self.rubberBandSelectionMode()] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getSelMode(self):\n if self.rbTreeMode.isChecked():\n return 'treeMode'\n elif self.rbStepMode.isChecked():\n return 'stepMode'",
"def set_rubberband_selection_mode(\n self, mode: constants.ItemSelectionModeStr | constants.ItemSelectionMode\n ):\n self.set... | [
"0.74210715",
"0.68902916",
"0.6660755",
"0.6656128",
"0.65943927",
"0.65938497",
"0.65843797",
"0.65843797",
"0.65843797",
"0.6563425",
"0.6503458",
"0.6503458",
"0.6503458",
"0.6466377",
"0.64369035",
"0.6434178",
"0.6405684",
"0.6388908",
"0.6388908",
"0.63870275",
"0.6382... | 0.8301072 | 0 |
Constructs a single leaf node or a subtree with nested structure according to the input parameters. | def __handle_primitive_event_or_nested_structure(self, tree_plan_leaf: TreePlanLeafNode,
current_operator: PatternStructure,
sliding_window: timedelta, parent: Node,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def construct_tree():\n root = TreeNode(5)\n root.left = TreeNode(3)\n root.right = TreeNode(8)\n root.left.left = TreeNode(2)\n root.left.right = TreeNode(4)\n root.right.left = TreeNode(7)\n return root",
"def build():\n r = TreeNode(1)\n r.left = TreeNode(2)\n r.left.left = TreeN... | [
"0.706279",
"0.69218695",
"0.67534494",
"0.6700244",
"0.66193956",
"0.6508946",
"0.6501352",
"0.64710057",
"0.64578164",
"0.6433424",
"0.62719804",
"0.6259056",
"0.6200987",
"0.61569226",
"0.61513495",
"0.6139787",
"0.613722",
"0.61265904",
"0.60880893",
"0.60810226",
"0.6075... | 0.0 | -1 |
Get absolute path to resource, works for dev and for PyInstaller | def resource_path(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.8370207",
"0.8280719",
"0.8248514",
"0.81387657",
"0.8113593",
"0.8098866",
"0.80943495",
"0.80799586",
"0.8067939",
"0.8067573",
"0.8062756",
"0.8062756",
"0.8062756",
"0.8062756",
"0.8062756",
"0.8062756",
"0.8062756",
"0.8056859",
"0.80546963",
"0.80450433",
"0.80450433... | 0.804045 | 34 |
Gets and sets the color | def color(self):
if "color" in self._prop_dict:
return self._prop_dict["color"]
else:
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_color(self):\n return self.color",
"def get_color(self):\r\n return self.__color",
"def _get_color(self):\n return self.__color",
"def _get_color(self):\n return self.__color",
"def _get_color(self):\n return self.__color",
"def _get_color(self):\n return self.__color",
... | [
"0.81033754",
"0.8060258",
"0.80215126",
"0.80215126",
"0.80215126",
"0.80215126",
"0.7981099",
"0.79312044",
"0.78427434",
"0.78427434",
"0.782316",
"0.7791557",
"0.7788385",
"0.77252346",
"0.768904",
"0.7683609",
"0.76746655",
"0.76408124",
"0.7624196",
"0.7624196",
"0.7623... | 0.73293006 | 37 |
Z is 2D and a softmax is taken over the second dimension for each sample separately. | def softmax(Z):
# Change the dynamic range before normalization, to avoid precision errors
Z -= Z.max(1)[:, np.newaxis]
expZ = np.exp(Z)
return expZ / expZ.sum(1)[:, np.newaxis] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def softmax(Z):\r\n\r\n\r\n eZ = np.exp(Z)\r\n return eZ / np.sum(eZ, axis=0, keepdims=True)",
"def softmax(self, z):\n assert len(z.shape) == 2\n s = np.max(z, axis=1)\n s = s[:, np.newaxis] # necessary step to do broadcasting\n e_x = np.exp(z - s)\n div = np.sum(e_x, ax... | [
"0.8141109",
"0.7987492",
"0.792851",
"0.76633453",
"0.7527341",
"0.7422397",
"0.71650666",
"0.700119",
"0.6790702",
"0.6679098",
"0.6658465",
"0.66281104",
"0.66271204",
"0.6623226",
"0.6618013",
"0.6589807",
"0.65728474",
"0.6551427",
"0.6551427",
"0.6547686",
"0.6542946",
... | 0.75870776 | 4 |
shrink learning rate for pytorch | def adjust_learning_rate(optimizer, lr):
for param_group in optimizer.param_groups:
param_group['lr'] = lr | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def adjust_learning_rate(optimizer, epoch, args):\n \"\"\"Comes from pytorch demo\"\"\"\n lr = args.lr * (0.1 ** (epoch // 30))\n for param_group in optimizer.param_groups:\n param_group['lr'] = lr",
"def adjust_learning_rate(optimizer: torch.optim.SGD, epoch: int, args: Namespace):\n lr = arg... | [
"0.70258707",
"0.66770476",
"0.6552609",
"0.6552609",
"0.6430445",
"0.6358964",
"0.6305415",
"0.62916064",
"0.6268514",
"0.6245931",
"0.6218186",
"0.62054217",
"0.6199067",
"0.619252",
"0.6189025",
"0.6184419",
"0.6183442",
"0.6183442",
"0.6183442",
"0.61829084",
"0.61766845"... | 0.0 | -1 |
__init__( \ consumer_key, consumer_secret, access_token, access_token_secret, \ chunk_size=512, daemon=False, max_retries=inf, proxy=None, \ verify=True \ ) | def __init__(self, consumer_key, consumer_secret, access_token,
access_token_secret, **kwargs):
self.consumer_key = consumer_key
self.consumer_secret = consumer_secret
self.access_token = access_token
self.access_token_secret = access_token_secret
super().__init_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, consumer_key, consumer_secret, access_token, access_token_secret):\n self.api = self.getAPI(consumer_key, consumer_secret, access_token, access_token_secret)",
"def __init__(self, client_id: str, client_secret: str, access_token_publish_url: str, access_token: str = None):\n\n se... | [
"0.7182906",
"0.7002253",
"0.69706017",
"0.68810153",
"0.684382",
"0.6795037",
"0.6770775",
"0.6761326",
"0.67433584",
"0.669004",
"0.66869366",
"0.66045785",
"0.6545967",
"0.6515904",
"0.64842695",
"0.64701635",
"0.6450271",
"0.6431595",
"0.6416579",
"0.6416124",
"0.6393467"... | 0.7408473 | 0 |
Test the search method without providing a location or a query. Test whether an InvalidSearchParameterError is raised. | def test_search_nolocation_noquery(objectsearch):
with pytest.raises(InvalidSearchParameterError):
objectsearch.search(location=None, query=None) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_search_no_params_error(self):\n self.assertRaises(\n TypeError,\n lambda: self.t['Scrubs'].search()\n )",
"def test_search_both_location_query_wrongquerytype(objectsearch):\n with pytest.raises(InvalidSearchParameterError):\n objectsearch.search(location=(1,... | [
"0.7818408",
"0.77760595",
"0.76732063",
"0.7401069",
"0.73630285",
"0.71866363",
"0.6956381",
"0.69343483",
"0.6908892",
"0.6705745",
"0.66950035",
"0.66846746",
"0.66823906",
"0.668041",
"0.668041",
"0.668041",
"0.6673813",
"0.6644635",
"0.6607593",
"0.655413",
"0.6500011",... | 0.8584957 | 0 |
Sets the guild for the bot | async def set_guild(ctx):
await Config.set_main_guild(ctx.guild)
await ctx.send("Successfully set guild") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def guild(self, guild):\n\n self._guild = guild",
"def guild(self, *args, **kwargs) -> Guild:\n return Guild(self.handle, *args, **kwargs)",
"async def _guild(self, ctx):\n if await self.config.guild(ctx.guild).guild():\n await self.config.guild(ctx.guild).guild.set(False)\n ... | [
"0.83077747",
"0.680455",
"0.639584",
"0.6185229",
"0.61639476",
"0.61100554",
"0.6045145",
"0.60157543",
"0.60081375",
"0.6004219",
"0.59627056",
"0.59197116",
"0.58597255",
"0.57822275",
"0.5768209",
"0.5753494",
"0.57439935",
"0.5736192",
"0.5734578",
"0.57074624",
"0.5707... | 0.8652816 | 0 |
Standardise units for all columns in a table in a copy. Calls `~gammapy.utils.units.standardise_unit`. | def table_standardise_units_copy(table):
# Note: we could add an `inplace` option (or variant of this function)
# See https://github.com/astropy/astropy/issues/6098
table = Table(table)
return table_standardise_units_inplace(table) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def table_standardise_units_inplace(table):\n for column in table.columns.values():\n if column.unit:\n column.unit = standardise_unit(column.unit)\n\n return table",
"def standardize(column):\n # Finish the function so that it returns the z-scores\n z_score = (column - column.mean(... | [
"0.85352224",
"0.6109359",
"0.6088695",
"0.6076267",
"0.6027858",
"0.5971317",
"0.5885152",
"0.57951915",
"0.5789675",
"0.5765868",
"0.5763006",
"0.57615453",
"0.5759644",
"0.5749426",
"0.5734463",
"0.56731135",
"0.5669903",
"0.56570536",
"0.5566425",
"0.55194336",
"0.5508961... | 0.8780834 | 0 |
Obtain the distribution function from normalized weights (nonvectorized). | def _distribution_singular(y_eval, w_q_pdf, y, theta_y, clip=True):
# (n, d_y)
all_cdf = 0.5 * (1 + _erf((y_eval - y) / (np.sqrt(2) * theta_y)))
# (n,)
each_cdf = np.prod(all_cdf, axis=1)
# (n_q,) or constant
cdf = np.dot(each_cdf, w_q_pdf)
# Clip the distribution if required
return ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def distr(weights, gamma=0.0, rnd=1):\n the_sum = float(sum(weights))\n if rnd % 100000 == 0:\n for itr in range(len(weights)):\n weights[itr] /= the_sum\n\n return tuple((1.0 - gamma) * (w / the_sum) + (gamma / len(weights)) for w in weights)",
"def xavier_normal(weight_shape):\n i... | [
"0.6246884",
"0.6177136",
"0.6169401",
"0.6083064",
"0.60306054",
"0.6012865",
"0.5990865",
"0.5966773",
"0.596188",
"0.59283006",
"0.59136873",
"0.5901932",
"0.5855925",
"0.58477116",
"0.5830643",
"0.5826757",
"0.5824749",
"0.5823703",
"0.5817142",
"0.58106625",
"0.580615",
... | 0.0 | -1 |
can_live_drag(game_object) Determine if an Object can be dragged in Live Mode. | def can_drag_object_in_live_mode(game_object: GameObject) -> bool:
if game_object is None:
return False
live_drag_component: LiveDragComponent = CommonComponentUtils.get_component(game_object, CommonComponentType.LIVE_DRAG)
if live_drag_component is None:
return False
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def enable_object_drag_in_live_mode(game_object: GameObject) -> bool:\n if game_object is None:\n return False\n live_drag_component: LiveDragComponent = CommonComponentUtils.get_component(game_object, CommonComponentType.LIVE_DRAG)\n if live_drag_component is None:\n ret... | [
"0.82034254",
"0.76057714",
"0.58987194",
"0.56915605",
"0.5571646",
"0.5491064",
"0.54579043",
"0.5391438",
"0.538689",
"0.52793515",
"0.5277907",
"0.52515966",
"0.52454454",
"0.52071834",
"0.52055055",
"0.520099",
"0.5141398",
"0.51149994",
"0.51072127",
"0.5094389",
"0.509... | 0.886564 | 0 |
generates random 15 character alphanumeric username | def generate_username():
return ''.join(choice(ascii_letters + digits) for _ in range(15)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def random_username():\n return str(uuid.uuid4().hex.upper())",
"def create_random_username() -> str:\n return str(uuid.uuid4())",
"def generate_username(size=10, chars=string.ascii_lowercase + string.digits):\n suffix = gen_random_string(size, chars)\n return 'k8s-console-temp-user-' + suf... | [
"0.86865",
"0.8620362",
"0.8457643",
"0.7849848",
"0.7815554",
"0.77229327",
"0.7572678",
"0.75386006",
"0.75330293",
"0.7528683",
"0.7486343",
"0.7474857",
"0.7402542",
"0.7387599",
"0.7371379",
"0.73662907",
"0.73073256",
"0.72862846",
"0.7246816",
"0.7233331",
"0.7208186",... | 0.94060826 | 0 |
Return the mesh index in the gltf array. | def getMeshIndex(gltf, idname):
if gltf.get('meshes') is None:
return -1
index = 0
for mesh in gltf['meshes']:
key = 'id' if mesh.get('id') != None else 'name'
if mesh.get(key) == idname:
return index
index += 1
return -1 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getLightIndex(gltf, idname):\n\n v3dExt = appendExtension(gltf, 'S8S_v3d_data', gltf)\n\n if v3dExt.get('lights') == None:\n return -1\n\n lights = v3dExt['lights']\n\n index = 0\n for light in lights:\n key = 'id' if light.get('id') != None else 'name'\n if light.get(key) =... | [
"0.6680122",
"0.6545495",
"0.6189974",
"0.6185222",
"0.61643434",
"0.61613697",
"0.61266553",
"0.60020375",
"0.5993789",
"0.5993789",
"0.59893304",
"0.5923313",
"0.5912613",
"0.5900714",
"0.5873933",
"0.5855457",
"0.58518887",
"0.5846281",
"0.5794656",
"0.579023",
"0.57899666... | 0.73593104 | 0 |
Initializes the row and col attributes. | def __init__(self, row = 0, col = 0):
self.row = row
self.col = col | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, row:int, col:int):\n\t\tself.__row = row\n\t\tself.__col = col",
"def __init__(\n self, rows, columns, header_row=False, header_column=False, style=''\n ):\n self.rows = rows\n self.columns = columns\n self.header_row = header_row\n self.header_column = header_column\n sel... | [
"0.74533826",
"0.69797194",
"0.67673874",
"0.67090523",
"0.6609822",
"0.66024715",
"0.6597809",
"0.65546775",
"0.6553186",
"0.6536631",
"0.6518966",
"0.6503177",
"0.65031123",
"0.6488014",
"0.645256",
"0.64521456",
"0.644584",
"0.64437234",
"0.64187557",
"0.63865876",
"0.6370... | 0.76908904 | 0 |
Compares this object with another Point object. | def __eq__(self, other):
try:
return self.row == other.row and self.col == other.col
except AttributeError: # Can also take a tuple (row, col)
return self.row == other[0] and self.col == other[1] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __eq__(self, other):\n return self.point == other.point",
"def __eq__(self, other):\n return sorted(self.points) == sorted(other.points)",
"def __eq__(self, other):\n return self.points == other.points",
"def __cmp__(self, secondPoint):\n return __cmp__(self.value, secondPoint... | [
"0.76736975",
"0.7586969",
"0.7473909",
"0.72574496",
"0.7236272",
"0.7214949",
"0.71414495",
"0.7123068",
"0.68182063",
"0.6777468",
"0.67605436",
"0.67397696",
"0.6711596",
"0.670086",
"0.668472",
"0.6672582",
"0.66609097",
"0.6548615",
"0.6548615",
"0.65131426",
"0.6513142... | 0.0 | -1 |
Set up the Geizwatch sensor. | def setup_platform(hass, config, add_entities, discovery_info=None):
name = config.get(CONF_NAME)
description = config.get(CONF_DESCRIPTION)
product_id = config.get(CONF_PRODUCT_ID)
domain = config.get(CONF_LOCALE)
add_entities([Geizwatch(name, description, product_id, domain)], True) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setUp(self):\n self.sensor = Sensor('127.1.1.3', 9000)",
"def setUp(self):\n self.ser = Serial()\n self.device_obj = ZBSensor(self.ser)",
"def __init__(self):\n self._read_calibration_data()\n self.configure_sensor(\n TemperatureOversamplings.x08,\n ... | [
"0.69532573",
"0.67188686",
"0.67124456",
"0.6527411",
"0.6515273",
"0.64921665",
"0.649107",
"0.6457051",
"0.6359164",
"0.63100576",
"0.6305752",
"0.6282697",
"0.62676764",
"0.6255828",
"0.62550384",
"0.62015045",
"0.6181486",
"0.61765635",
"0.6152586",
"0.6149572",
"0.61337... | 0.0 | -1 |
Return the name of the sensor. | def name(self):
return self._name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def name(self):\n return self._sensor.name",
"def get_sensor_name(self):\n return self.data[1]",
"def name(self):\n return self.device.device_data[self.device_id]['name'] + \\\n f' {self._sensor_type}'",
"def name(self):\n return f\"{self._name} {SENSOR_TYPES[self.senso... | [
"0.91893077",
"0.91680735",
"0.89015853",
"0.87704504",
"0.85108286",
"0.8479386",
"0.8444154",
"0.8299531",
"0.81861234",
"0.8105427",
"0.8078726",
"0.80649143",
"0.804929",
"0.770065",
"0.76117194",
"0.7611273",
"0.76001656",
"0.76001656",
"0.76001656",
"0.75384134",
"0.751... | 0.0 | -1 |
Return the state attributes. | def device_state_attributes(self):
while len(self._device.prices) < 4:
self._device.prices.append("None")
attrs = {
"device_name": self._device.name,
"description": self.description,
"unit_of_measurement": self._device.price_currency,
"product_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def state_attributes(self):\n return self._attributes",
"def state_attributes(self):\n return self._attributes",
"def device_state_attributes(self):\r\n return self.attributes",
"def device_state_attributes(self):\n return self._state_attrs",
"def device_state_attributes(self):\... | [
"0.8953404",
"0.8953404",
"0.85239846",
"0.8366765",
"0.8366765",
"0.8363429",
"0.83362615",
"0.8334551",
"0.8310377",
"0.8292682",
"0.8289349",
"0.8289349",
"0.82871646",
"0.82871646",
"0.82871646",
"0.82871646",
"0.82871646",
"0.82871646",
"0.82871646",
"0.82871646",
"0.828... | 0.0 | -1 |
The forward pass of the scaled dot attention mechanism. | def forward(self, queries, keys, values):
batch_size = queries.shape[0]
expanded_queries = queries.view(batch_size, -1, self.hidden_size)
q = self.Q(expanded_queries)
k = self.K(keys)
v = self.V(values)
unnormalized_attention = torch.bmm(k, q.transpose(2,1)) * self.scali... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def forward(self, x: torch.Tensor) -> torch.Tensor:\n out = self.embedding(x) * self.scale\n return out",
"def forward(self, x: torch.Tensor, context: torch.Tensor = None) -> torch.Tensor:\n residual = x\n x = self.norm(x)\n x = self.att(x, context) + residual # residual post-... | [
"0.6429416",
"0.62457675",
"0.6233697",
"0.62092644",
"0.61861",
"0.61455935",
"0.6124017",
"0.6117001",
"0.61004597",
"0.6099254",
"0.6091935",
"0.60832715",
"0.6069192",
"0.6059014",
"0.60309047",
"0.6022254",
"0.6021495",
"0.60203636",
"0.6017598",
"0.601406",
"0.6001378",... | 0.0 | -1 |
Check .csv marker and .mat marker are valid or not. | def marker_validity(table, train, thresh=1.0):
shift = len(table) - len(train)
if shift >= 0:
start_d = train[0] - table.time.values[0]
end_d = train[-1] - table.time.values[len(table)-shift-1]
if np.abs(start_d - end_d) <= thresh:
return shift # valid
else:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_format_of_annotation_in_file(self):\n if not self.is_span_valid():\n sys.exit()",
"def validate_csv_seq(sequence):\n if sequence.find(',') != -1 or sequence.find(';') != -1:\n return True\n else:\n return False",
"def validate_file_contents(cube, metadata):\n ... | [
"0.61996293",
"0.61710596",
"0.60736156",
"0.60378706",
"0.6034101",
"0.6022047",
"0.60121197",
"0.59901893",
"0.5986088",
"0.59612983",
"0.59579706",
"0.59363544",
"0.5909285",
"0.5896918",
"0.5884406",
"0.5873293",
"0.5824759",
"0.5812974",
"0.5797153",
"0.57718825",
"0.576... | 0.0 | -1 |
r""" Used to initializer a layer possibly using information from the node object. | def initialize(self, node: MComputeNode):
raise Exception("Subclass responsibility") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, layer_list_info):\n self.layer_list_info = layer_list_info",
"def __init__(self):\n\n for layer in self._layer_class_map:\n setattr(self, layer, self._layer_class_map[layer]())",
"def __init__(self, parent, layer):\n pass",
"def __init__(self, layer_nest):\n ... | [
"0.712508",
"0.6994062",
"0.69877005",
"0.67738986",
"0.67147434",
"0.66958684",
"0.6674616",
"0.6629193",
"0.6590828",
"0.65465426",
"0.65206885",
"0.63145745",
"0.6182706",
"0.6108525",
"0.6068823",
"0.6050611",
"0.6050023",
"0.60417855",
"0.6012664",
"0.59854835",
"0.59827... | 0.0 | -1 |
r""" Note that since the input dimension is determined at the first invocation of forward, this object does not yet know the input dimension and hecne cannot be initialized. | def __init__(self, input_node, output_dim: int,
initial_w: np.array = None, initial_b: np.array = None,
name: str = None):
MComputeNode.__init__(self, name, is_trainable=True)
self._add_upstream_nodes([input_node])
self.input_node = input_node
self.outpu... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, D_in, H, D_out):\n super(FeedForwardNet, self).__init__()\n self.linear1 = torch.nn.Linear(D_in, H)\n self.linear2 = torch.nn.Linear(H, H)\n self.linear3 = torch.nn.Linear(H, D_out)",
"def forward(self, x):\n h = x\n\n # Get features\n local_fea... | [
"0.6640094",
"0.6438345",
"0.6401085",
"0.6352564",
"0.6332074",
"0.6295988",
"0.62935734",
"0.6279067",
"0.62721807",
"0.62638223",
"0.6263356",
"0.6262734",
"0.62383974",
"0.6237073",
"0.62314993",
"0.62279296",
"0.6218572",
"0.621676",
"0.621676",
"0.619881",
"0.6187453",
... | 0.0 | -1 |
A representation of this object as a dictionary of simple values. | def dict(self):
return {
'key': self.key,
'status': self.status,
'failures': self.failures,
'timeout': self.timeout,
'checkin': self.checkin,
'jitter': self._last_jitter,
'max_failures': self.max_failures
} | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def as_dict(self):\n return {'tag_type': self.tag_type, 'value': self.value}",
"def as_dict(self):\n return dict(self.items())",
"def as_dict(self):\n return dict(self.as_OD())",
"def as_dict(self):\n rv = {\n 'id': self.id,\n 'name': self.name,\n ... | [
"0.7772279",
"0.7603787",
"0.7594658",
"0.7416436",
"0.7410674",
"0.74005604",
"0.738152",
"0.7371231",
"0.72833675",
"0.7280494",
"0.72780704",
"0.7277278",
"0.7273393",
"0.72709405",
"0.72550565",
"0.72502595",
"0.7242584",
"0.7240742",
"0.7236738",
"0.7231142",
"0.7231142"... | 0.0 | -1 |
A representation of this object for use when printing handy for interpreter use. | def __repr__(self):
if self.status == STATUS_CLOSED:
status = "CLOSED"
elif self.status == STATUS_OPEN:
status = "OPEN"
else:
status = "UNKNOWN"
return f"<{self.__class__.__name__} [{self.key}] status={status} failures={self.failures} checkin={self.che... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __repr__(self):\n return str(self.__dict__)",
"def __repr__(self):\n return str(self.__dict__)",
"def __repr__(self):\n return str(self.__dict__)",
"def __repr__(self):\n return str(self.__dict__)",
"def __repr__(self):\n return str(self.__dict__)",
"def __repr__(se... | [
"0.8402925",
"0.8402925",
"0.8402925",
"0.8402925",
"0.8402925",
"0.8365054",
"0.8349366",
"0.8307852",
"0.8244802",
"0.8244802",
"0.8244802",
"0.8237386",
"0.8237386",
"0.8237386",
"0.8237386",
"0.8237386",
"0.8237386",
"0.8237386",
"0.8237386",
"0.8237386",
"0.8237386",
"... | 0.0 | -1 |
Remove duplicates from given list. List may contain mixed data types. | def remove_duplicates(data):
already_used_items = {}
return_data = []
for item in data:
# Yes, I know that I can find used items in the return_data,
# but HW requires this logic.
if not already_used_items.get(item):
return_data.append(item)
already_used_items... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def removeDuplicates(list):\n\treturn Set((item for item in list))",
"def removeDuplicates(list):\n\treturn set((item for item in list))",
"def remove_duplicates(mylist):\n return list(set(mylist))",
"def remove_duplicates(somelist):\n return set(somelist)",
"def remove_duplicates(self,list_):\r\n ... | [
"0.7739",
"0.76429933",
"0.7400024",
"0.73972595",
"0.7129148",
"0.71288717",
"0.7108114",
"0.70933884",
"0.7017403",
"0.7012352",
"0.68856835",
"0.68576276",
"0.6821925",
"0.6818266",
"0.6777846",
"0.6715764",
"0.67126215",
"0.66906726",
"0.6684814",
"0.66834",
"0.66800016",... | 0.0 | -1 |
Compute the recall between samples at each k. This function uses about 8GB of memory. | def recall_at_ks(query_features: torch.Tensor,
query_labels: np.ndarray,
ks: List[int],
gallery_features: Optional[torch.Tensor] = None,
gallery_labels: Optional[torch.Tensor] = None,
cosine: bool = False) -> Dict[int, float]:
offs... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def recall_at_k(self, positions, k, num_samples):\n return 1.0 * sum(i <= k for i in positions) / num_samples",
"def get_recall(self, k=None):\n k = 1 if k is None else k\n recalls = []\n \n for query, answer in tqdm(zip(self.test_queries, self.results)):\n correct_s... | [
"0.73594654",
"0.7261368",
"0.70239085",
"0.6993166",
"0.6789236",
"0.67796314",
"0.6738924",
"0.6696558",
"0.6615064",
"0.6613076",
"0.66051644",
"0.6594125",
"0.6538705",
"0.64816564",
"0.64015085",
"0.63973504",
"0.637287",
"0.63567746",
"0.6341325",
"0.6341325",
"0.634132... | 0.5747007 | 76 |
Compute the entropy of a KBinsDiscretizer split using a certain number of bins. | def __entropy(data: np.array, bins: int) -> float:
discretizer = KBinsDiscretizer(n_bins = bins, encode = "onehot-dense", strategy = ExamDropExtractor.BIN_STRATEGY)
data = discretizer.fit_transform(data)
new_entropy = np.sum(data, axis = 0)
return sc.stats.entropy(new_entropy / np.sum(ne... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_entropy_threshold(self, histogram, num_quantized_bins):\n import copy\n\n from scipy.stats import entropy\n\n hist = histogram[0]\n hist_edges = histogram[1]\n num_bins = hist.size\n zero_bin_index = num_bins // 2\n num_half_quantized_bin = num_quantized_bin... | [
"0.7004662",
"0.6491699",
"0.6240131",
"0.61276454",
"0.6102772",
"0.60943073",
"0.5928152",
"0.5832186",
"0.58265543",
"0.58237094",
"0.57188326",
"0.57068646",
"0.5693535",
"0.5679936",
"0.56507057",
"0.56421196",
"0.5640808",
"0.5581184",
"0.5574977",
"0.5564762",
"0.55574... | 0.73856825 | 0 |
Generate a filename such as mydata20220902_003150613015.csv where "mydata" is the label and "csv" is the extensions. You can also generate the filename without fractional seconds by setting fractional=False which is useful if your code is guaranteed to never generate multiple files per second with crossOS compatible fi... | def generate_datetime_filename(label="data", extension="csv", postfix=None, fractional=True, dt=None):
if dt is None:
dt = datetime.now()
filename = "" if label is None else f"{label}-"
fractional_str = f"-{dt.microsecond:06d}" if fractional is True else ""
filename += f"{dt.year}-{dt.month:02d}... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def outputFilename(name=\"\", ext=\"\", time=True):\n # get the date in the format specifed\n dateTime = datetime.now()\n dateTimeFormat = \"%Y-%m-%d__%H-%M-%S\" if time else \"%Y-%m-%d\"\n fileName = dateTime.strftime(dateTimeFormat)\n\n # construct the filename\n fileName = fileName + \"_\" + name if fileN... | [
"0.73291796",
"0.7164135",
"0.7047534",
"0.7013029",
"0.6870672",
"0.6862087",
"0.6852039",
"0.6851723",
"0.68407625",
"0.68018705",
"0.66923267",
"0.6686387",
"0.6683668",
"0.6671342",
"0.6664652",
"0.66505986",
"0.6643087",
"0.6638087",
"0.6628923",
"0.6590812",
"0.6585323"... | 0.7786054 | 0 |
Returns the number of days in a month, e.g. 31 in January (month=1). Takes into account leap days. | def number_of_days_in_month(year=2019, month=1):
return monthrange(year, month)[1] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def days_in_month(year, month):\n num_days = monthrange(year, month)[1]\n return num_days",
"def days_this_month(year, month):\n ndays = days_per_month(isleap(year))\n return ndays[month - 1]",
"def days_in_month(year, month):\n month_days = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]\n ... | [
"0.864498",
"0.84469765",
"0.8402006",
"0.83021",
"0.82661843",
"0.8202695",
"0.8140011",
"0.81297785",
"0.81121993",
"0.80892736",
"0.7973635",
"0.7939113",
"0.7939113",
"0.7939113",
"0.7853325",
"0.78294545",
"0.78093827",
"0.7798538",
"0.77585644",
"0.7747239",
"0.7716747"... | 0.8450182 | 1 |
Given an 1D array of np.datetime64 timestamps, extract the month of each timestamps and return a numpy array of the same size, containing the month number (january = 1) | def extract_months(timestamps):
return np.asarray([dt.month for dt in timestamps.astype(datetime)]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extract_day_of_month(timestamps):\n return np.asarray([dt.day for dt in timestamps.astype(datetime)])",
"def get_month(time_index):\n return np.array(time_index.month).reshape(-1,1)",
"def arrayofmonths(month1,day1,year1,month2,day2,year2):\n return (arrayofdaysmonthsyears(month1,day1,year1,month2... | [
"0.7802686",
"0.7505786",
"0.70298624",
"0.6730568",
"0.6384789",
"0.61173844",
"0.5985396",
"0.5981096",
"0.59617317",
"0.5877958",
"0.58088666",
"0.5734795",
"0.5730715",
"0.5727068",
"0.56566644",
"0.5637175",
"0.55891556",
"0.5573385",
"0.5563501",
"0.55627954",
"0.552383... | 0.85289097 | 0 |
Given an 1D array of np.datetime64 timestamps, extract the month of each timestamps and return a numpy array of the same size, containing the year number (e.g. 2022) | def extract_years(timestamps):
return np.asarray([dt.year for dt in timestamps.astype(datetime)]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extract_months(timestamps):\n return np.asarray([dt.month for dt in timestamps.astype(datetime)])",
"def get_month(time_index):\n return np.array(time_index.month).reshape(-1,1)",
"def extract_day_of_month(timestamps):\n return np.asarray([dt.day for dt in timestamps.astype(datetime)])",
"def ar... | [
"0.84438866",
"0.72880536",
"0.72729015",
"0.6919165",
"0.6668749",
"0.65592486",
"0.64606506",
"0.642979",
"0.626666",
"0.6245982",
"0.59137785",
"0.5838444",
"0.5704992",
"0.5682093",
"0.56602144",
"0.56594455",
"0.56484044",
"0.5584631",
"0.55821687",
"0.55439156",
"0.5543... | 0.72829646 | 2 |
Given an 1D array of np.datetime64 timestamps, extract the month of each timestamps and return a numpy array of the same size, containing the day of week (Monday=1, Sunday=7) | def extract_day_of_week(timestamps):
return np.asarray([dt.isoweekday() for dt in timestamps.astype(datetime)]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extract_day_of_month(timestamps):\n return np.asarray([dt.day for dt in timestamps.astype(datetime)])",
"def extract_months(timestamps):\n return np.asarray([dt.month for dt in timestamps.astype(datetime)])",
"def get_month(time_index):\n return np.array(time_index.month).reshape(-1,1)",
"def ar... | [
"0.79181767",
"0.73946863",
"0.6675261",
"0.6659338",
"0.6450688",
"0.63708603",
"0.6232171",
"0.60562116",
"0.6026753",
"0.5997162",
"0.59330195",
"0.59325874",
"0.5810649",
"0.5808505",
"0.572389",
"0.563846",
"0.56235904",
"0.5581852",
"0.55749315",
"0.5569089",
"0.5559417... | 0.688596 | 2 |
Generate an 1d array of [ndays] timestamps, starting at the given day, each timestamp being exactly one month from the previous one. The given date will be the first timestamp. Returns a array of np.datetime64[us] >>> generate_months(5, 2022, 1, 1) | def generate_months(nmonths, year=2022, month=1, day=1):
return np.asarray([
f'{year:04d}-{month+i:02d}-{day:02d}T00:00:00.000000'
for i in range(nmonths)
], dtype='datetime64[us]') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def arrayofmonths(month1,day1,year1,month2,day2,year2):\n return (arrayofdaysmonthsyears(month1,day1,year1,month2,day2,year2))[1]",
"def extract_months(timestamps):\n return np.asarray([dt.month for dt in timestamps.astype(datetime)])",
"def gen_month_time_bnds(start_month, num_forecasts):\n bnds = []... | [
"0.59834194",
"0.58531344",
"0.58485293",
"0.5809744",
"0.5782363",
"0.565391",
"0.5648076",
"0.55060804",
"0.5492097",
"0.5488164",
"0.5474868",
"0.5467845",
"0.5445375",
"0.5434418",
"0.5431443",
"0.53702486",
"0.5339301",
"0.5319267",
"0.5288409",
"0.5240782",
"0.5220633",... | 0.7854162 | 0 |
Generate an 1d array of [ndays] timestamps, starting at the given day, each timestamp being exactly one year from the previous one. The given date will be the first timestamp. Returns a array of np.datetime64[us] >>> generate_years(5, 2022, 1, 1) | def generate_years(nyears, year=2022, month=1, day=1):
return np.asarray([
f'{year+i:04d}-{month:02d}-{day:02d}T00:00:00.000000'
for i in range(nyears)
], dtype='datetime64[us]') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def arrayofyears(month1,day1,year1,month2,day2,year2):\n return (arrayofdaysmonthsyears(month1,day1,year1,month2,day2,year2))[2]",
"def extract_years(timestamps):\n return np.asarray([dt.year for dt in timestamps.astype(datetime)])",
"def gen_birthdays(n):\n list = []\n for date in range(n):\n list.... | [
"0.6209125",
"0.6089319",
"0.5925523",
"0.56274366",
"0.5543714",
"0.5536158",
"0.54565984",
"0.54553384",
"0.5419316",
"0.5409759",
"0.5394277",
"0.538889",
"0.5360254",
"0.5359032",
"0.5339896",
"0.5318994",
"0.53105944",
"0.52885956",
"0.52727515",
"0.5210692",
"0.5179869"... | 0.7924828 | 0 |
Return all primes less than N > 0 int | def primes_lt3(N):
# test every number less than N/2
primes = [ i for i in xrange(2,N)
if not any( ( i % p == 0 for p in xrange(2,int(sqrt(i))+1) ) )]
return primes | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def primes(n):\n return [i for i in xrange(1, n + 1) if mr_prime(i)]",
"def primes(n, DEBUG=False):\n\n return [x[0] for x in enumerate(_sieve(n, DEBUG=DEBUG)[0:n+1]) if x[1]]",
"def primes_less(n):\n test_nums = list(range(3, int(floor(sqrt(n))), 2))\n prime_flags = [True] * ((n - 2) // 2)\n fo... | [
"0.82766694",
"0.78592944",
"0.7837244",
"0.7779525",
"0.77792525",
"0.76724344",
"0.76580966",
"0.76055753",
"0.75654954",
"0.7547327",
"0.7540112",
"0.7534009",
"0.7525909",
"0.75065285",
"0.7500622",
"0.7500622",
"0.74907196",
"0.7482908",
"0.74791765",
"0.7462171",
"0.744... | 0.8035543 | 1 |
Prepend a string value to pkg_config_path | def _prepend_pkg_config_path(path: str) -> str:
pkgconf = os.environ.get('PKG_CONFIG_PATH')
if pkgconf:
return f'{path}{os.path.pathsep}{pkgconf}'
return path | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def insert_package_path():\n sys.path.insert(0, ospdn(ospdn(ospdn(ospap(__file__)))))",
"def _replace_module_dir_placeholder(value: str) -> str:\n parts = pathlib.PurePosixPath(value).parts\n if MODULE_DIR_VARIABLE not in parts:\n return value\n if parts[0] != M... | [
"0.6200587",
"0.6018101",
"0.5860132",
"0.58417946",
"0.58154917",
"0.5615715",
"0.5513167",
"0.55082995",
"0.54774755",
"0.5374625",
"0.5359509",
"0.5344476",
"0.5344476",
"0.53373784",
"0.5328586",
"0.5314021",
"0.53047025",
"0.5300246",
"0.52863646",
"0.52265656",
"0.52036... | 0.8486884 | 0 |
Gets the firmware version of the hub. | def firmware_version(self):
return self._get_system_status()["firmware"] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hw_version(self) -> str | None:\n return self.status.get(\"FIRMWARE\")",
"def firmware_version(self):\n return self.data.get('fw_ver')",
"def firmware_version(self):\n return self._read(MX_FIRMWARE_VERSION)",
"def get_firmware_version(self):\n cmd = protocol.GET_FIRMWARE_VERSI... | [
"0.81884253",
"0.80783117",
"0.79095113",
"0.77885336",
"0.77627426",
"0.77625066",
"0.77120686",
"0.7710053",
"0.7708722",
"0.77086866",
"0.76010746",
"0.7528818",
"0.7524536",
"0.75067985",
"0.73977685",
"0.7359628",
"0.73387897",
"0.7235391",
"0.7182128",
"0.7174703",
"0.7... | 0.834214 | 0 |
puts the lasso path coefs in a pandas data frame with adecuate rownames and column names | def path_to_frame(coefs, colnames, rownames):
return pd.DataFrame(coefs, index=rownames, columns=colnames) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_lasso_path(df, resp_var, exp_vars):\n import numpy as np\n import pandas as pd\n import matplotlib.pyplot as plt\n import mpld3\n from mpld3 import plugins\n from sklearn.preprocessing import StandardScaler\n from sklearn.linear_model import lasso_path\n\n # Standardise the feature... | [
"0.6323067",
"0.6065824",
"0.59834975",
"0.5822632",
"0.5747023",
"0.5711625",
"0.5703843",
"0.5686668",
"0.5671264",
"0.56684476",
"0.56452036",
"0.56206936",
"0.5611579",
"0.5604402",
"0.5596479",
"0.55714995",
"0.5563986",
"0.5549773",
"0.5547627",
"0.5532557",
"0.5519693"... | 0.66382724 | 0 |
df index is Multiindex with level_0='stock tickers' and level_1='dates' | def split_time_series_by_time_steps_index(df, n_time_steps=None):
time_steps = df.index.get_level_values(1).unique()
split_time_step = time_steps[-n_time_steps]
train = df[df.index.get_level_values(1) < split_time_step]
test = df[df.index.get_level_values(1) >= split_time_step]
return train, test | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def refresh_index(df):\n if isinstance(df.index, pandas.MultiIndex):\n return df.reset_index().set_index(df.index.names)\n else:\n return df",
"def _idx(name, at_level=None, type=None):\n cls = pd.Index\n kwargs = dict(name=name)\n\n if name == 'CURRENCY':\n data = ['NZD', 'RU... | [
"0.62282205",
"0.6186124",
"0.57680863",
"0.57595867",
"0.57311434",
"0.5697006",
"0.5680217",
"0.56625026",
"0.56069005",
"0.55709296",
"0.5544592",
"0.55259454",
"0.5502904",
"0.54960775",
"0.5491756",
"0.54332286",
"0.5413982",
"0.5394326",
"0.53521115",
"0.53393775",
"0.5... | 0.0 | -1 |
Loads the scaler used when training the model. | def _load_scaler(self, scaler_file):
assert isinstance(scaler_file, str),\
"scaler_file not entered as string."
self.scaler = joblib.load(file_path(scaler_file))
return | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_X_scaler(self, out_tag='lstm_scaler'): \n\n print ('loading X scaler: models/{}_X_scaler.pkl'.format(out_tag))\n self.X_scaler = load(open('models/{}_X_scaler.pkl'.format(out_tag),'rb'))",
"def get_scaler(scaler):\n if scaler == 'standard':\n from sklearn.preprocessing import Sta... | [
"0.7283689",
"0.68523395",
"0.67329955",
"0.63000697",
"0.61723596",
"0.6121807",
"0.6085851",
"0.6052254",
"0.59956545",
"0.588963",
"0.5845883",
"0.57754314",
"0.5760322",
"0.5705721",
"0.56552076",
"0.561918",
"0.5595504",
"0.5560068",
"0.55594486",
"0.553817",
"0.55338717... | 0.7720821 | 0 |
Replaces the numbers with their textual counterpart. | def replace_nums2words(tokens):
e = inflect.engine()
words = []
for word in tokens:
if word.isdigit():
words.append(e.number_to_words(word).replace(',', ''))
else:
words.append(word)
return words | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def replace_digits(text):\n text = re.sub(r\"\\d+\", \"number\", text)\n \n return text",
"def replace_numbers(text, replace_with=\"_NUMBER_\"):\n return RE_NUMBER.sub(replace_with, text)",
"def remove_nums(self, text):\r\n return text.translate(None, digits)",
"def remove_nums... | [
"0.77283555",
"0.7727668",
"0.7414083",
"0.7414083",
"0.7414083",
"0.7334961",
"0.7334961",
"0.72294277",
"0.71680367",
"0.71296597",
"0.70467705",
"0.6959733",
"0.6935073",
"0.6935073",
"0.6935073",
"0.6935073",
"0.6935073",
"0.6935073",
"0.6935073",
"0.69059056",
"0.6877059... | 0.5747057 | 66 |
Apply lemmatisation on a tokenised text. | def lemmatisation(tokens):
pos_tag = nltk.pos_tag(tokens)
lemmatiser = nltk.WordNetLemmatizer()
wornet_tags = {"J": wordnet.ADJ, "N": wordnet.NOUN, "V": wordnet.VERB, "R": wordnet.ADV}
words = []
for word, tag in pos_tag:
proper_tag = wornet_tags.get(tag[0].upper(), wordnet.NOUN)
wor... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def lemmatize_fun(self):\n tokens = str(self.doc).split()\n cleaned_tokens = None\n if self.lemmatize_method == 'wordnet':\n cleaned_tokens = [self.lemmatizer.lemmatize(token) for token in tokens]\n else:\n cleaned_tokens = [self.lemmatizer.stem(token) for token in... | [
"0.8108542",
"0.79308015",
"0.7929428",
"0.7912504",
"0.7824968",
"0.7731516",
"0.7696291",
"0.7679198",
"0.7510334",
"0.7491215",
"0.74824315",
"0.74720657",
"0.74692905",
"0.738473",
"0.73472315",
"0.734722",
"0.7331541",
"0.72897106",
"0.72780186",
"0.7237204",
"0.7183118"... | 0.7141751 | 24 |
Creates a fully connected neuron layer | def __init__(self, activation_function=Function(), input_size=1, output_size=1, noise_size=0,
learning_batch_size=1, param_desc='Parametres de descente', nb_exp=0):
self._input_size = input_size
self._output_size = output_size
self._learning_batch_size = learning_batch_size
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_network(layers):\r\n return NeuronNetwork(layers)",
"def create_base_network(NumberOfFeatures, NumberOfClasses,init_mode='glorot_normal'):\n network = Sequential()\n network.add(Dense(44, activation='sigmoid', kernel_initializer=init_mode,input_dim=NumberOfFeatures))\n# network.add(Dense(2... | [
"0.7232392",
"0.6988886",
"0.6978231",
"0.6932811",
"0.68160754",
"0.67571604",
"0.6724386",
"0.67147577",
"0.66861683",
"0.6664277",
"0.66182035",
"0.6609887",
"0.66086566",
"0.66048396",
"0.65749544",
"0.6574",
"0.64890236",
"0.64885056",
"0.64571166",
"0.6443483",
"0.64401... | 0.0 | -1 |
Calculates the error derivation | def derivate_error(self, in_influence):
deriv_vector = self._activation_function.derivate(self.activation_levels)
return deriv_vector * in_influence | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calc_error_dist(self):\n pass",
"def calculate_error(self):\n \n delta = self.Y - self.T\n error = delta.dot(delta) / self.N\n error = format(error, '.5f')\n \n self.errors.append(error)",
"def rel_error(deriv, orig):\n\treturn abs(orig - deriv) / abs(orig)"... | [
"0.7346064",
"0.7279042",
"0.72260576",
"0.68847746",
"0.68586504",
"0.67252326",
"0.6662258",
"0.66278154",
"0.6613276",
"0.65938735",
"0.65787345",
"0.64907646",
"0.64569044",
"0.64498353",
"0.6427157",
"0.641979",
"0.6412769",
"0.63751006",
"0.6363184",
"0.6335429",
"0.632... | 0.6293126 | 23 |
Can restore a layer from a dictionary created by save_coefs | def restore_coefs(self, coefs):
self._weights = coefs['weights']
self._bias = coefs['bias'] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def forgiving_state_restore(net, loaded_dict):\n net_state_dict = net.state_dict()\n new_loaded_dict = {}\n for k in net_state_dict:\n if k in loaded_dict and net_state_dict[k].size() == loaded_dict[k].size():\n new_loaded_dict[k] = loaded_dict[k]\n else:\n print(\"Skip... | [
"0.60391706",
"0.6022123",
"0.6013992",
"0.59338355",
"0.59098655",
"0.58355135",
"0.5813308",
"0.5787427",
"0.5648885",
"0.5564612",
"0.5516478",
"0.55033505",
"0.5467944",
"0.5465",
"0.5401513",
"0.5399386",
"0.53950965",
"0.5381933",
"0.53740823",
"0.53732324",
"0.5366237"... | 0.6700307 | 0 |
Create a tensor for convolutional layers from a batch of flattened outputs This method should be called during each backprop of the layer. Return a reshaped output with shape (learning_batch_size, output_feature_maps, output_size[0], output_size[1]) | def tensorize_outputs(self, outputs):
ndim = outputs.ndim
# shape = outputs.shape
if ndim == 4:
return outputs
elif ndim == 2:
outputs_reshaped = outputs.ravel('F').reshape((self._learning_batch_size,
self... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def flatten_output(self, output, feature_sequence_lens=None):\n if feature_sequence_lens == None:\n feature_sequence_lens = self.feature_sequence_lens\n num_outs = output.shape[2]\n# num_seq = output.shape[1]\n flat_output = np.zeros((self.batch_size(feature_sequence_lens), n... | [
"0.6715818",
"0.66581565",
"0.6456566",
"0.63592696",
"0.6306411",
"0.6200064",
"0.61971086",
"0.61880356",
"0.6155857",
"0.6136947",
"0.6129803",
"0.6120824",
"0.61087424",
"0.61070156",
"0.61054116",
"0.6049014",
"0.6042388",
"0.6027684",
"0.6000487",
"0.5954876",
"0.594791... | 0.6325037 | 4 |
Loads the weights for each stage. | def load_weights(self):
stage1_weights = (
self.cfg.get("STAGE1", "WEIGHTS")
if self.cfg.getboolean("STAGE1", "LOADPREV")
else None
)
stage2_weights = (
self.cfg.get("STAGE2", "WEIGHTS")
if self.cfg.getboolean("STAGE1", "LOADPREV")
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _load_weights(self):\n self.npz_weights = np.load(self._weight_file)\n self._load_byte_embedding()\n self._load_cnn_weights()\n self._load_highway()\n self._load_projection()",
"def _load_local_weights(self, h5file):\n for name, layer in self._layers_to_save.items():... | [
"0.7257581",
"0.7021141",
"0.70047885",
"0.6771263",
"0.6770265",
"0.66349643",
"0.6590497",
"0.6577159",
"0.65765494",
"0.65542585",
"0.6495277",
"0.6490352",
"0.647935",
"0.64695865",
"0.6451594",
"0.6352799",
"0.63317925",
"0.6330469",
"0.6329745",
"0.6329745",
"0.6328068"... | 0.7200516 | 1 |
The pay type of Cassandra dataCenter1. Valid values are `Subscription`, `PayAsYouGo`,System default to `PayAsYouGo`. | def pay_type(self) -> pulumi.Input[str]:
return pulumi.get(self, "pay_type") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pay_type(self) -> str:\n return pulumi.get(self, \"pay_type\")",
"def pay_type(self) -> str:\n return pulumi.get(self, \"pay_type\")",
"def pay_type(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"pay_type\")",
"def pay_type(self) -> Optional[pulumi.Input[str]]:\n ret... | [
"0.7367641",
"0.7367641",
"0.6978121",
"0.6902121",
"0.63273406",
"0.5886364",
"0.58420783",
"0.58420783",
"0.55192786",
"0.53570175",
"0.5258436",
"0.5258436",
"0.52349025",
"0.52238846",
"0.52183753",
"0.5181009",
"0.5156552",
"0.51224524",
"0.50891304",
"0.5087367",
"0.508... | 0.7037475 | 2 |
The pay type of Cassandra dataCenter1. Valid values are `Subscription`, `PayAsYouGo`,System default to `PayAsYouGo`. | def pay_type(self) -> Optional[pulumi.Input[str]]:
return pulumi.get(self, "pay_type") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pay_type(self) -> str:\n return pulumi.get(self, \"pay_type\")",
"def pay_type(self) -> str:\n return pulumi.get(self, \"pay_type\")",
"def pay_type(self) -> pulumi.Input[str]:\n return pulumi.get(self, \"pay_type\")",
"def pay_type(self) -> pulumi.Output[str]:\n return pulumi... | [
"0.7368209",
"0.7368209",
"0.703807",
"0.6978494",
"0.6328535",
"0.58865356",
"0.584476",
"0.584476",
"0.55207723",
"0.5356215",
"0.52607596",
"0.52607596",
"0.52339244",
"0.52235574",
"0.5218483",
"0.5182255",
"0.5158672",
"0.51241696",
"0.5091491",
"0.5088907",
"0.5084847",... | 0.69026566 | 4 |
Get an existing Cluster resource's state with the given name, id, and optional extra properties used to qualify the lookup. | def get(resource_name: str,
id: pulumi.Input[str],
opts: Optional[pulumi.ResourceOptions] = None,
auto_renew: Optional[pulumi.Input[bool]] = None,
auto_renew_period: Optional[pulumi.Input[int]] = None,
cluster_name: Optional[pulumi.Input[str]] = None,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get(resource_name: str,\n id: pulumi.Input[str],\n opts: Optional[pulumi.ResourceOptions] = None,\n cluster_id: Optional[pulumi.Input[str]] = None,\n identity: Optional[pulumi.Input[pulumi.InputType['ClusterIdentityArgs']]] = None,\n location: Optional[pul... | [
"0.7057115",
"0.6888678",
"0.627001",
"0.61467123",
"0.57516736",
"0.5751398",
"0.5700118",
"0.5689908",
"0.5619388",
"0.5476657",
"0.54439837",
"0.54392594",
"0.54191375",
"0.54170585",
"0.5380507",
"0.5379179",
"0.5321768",
"0.52971476",
"0.5279365",
"0.5273055",
"0.5240308... | 0.6763804 | 2 |
The pay type of Cassandra dataCenter1. Valid values are `Subscription`, `PayAsYouGo`,System default to `PayAsYouGo`. | def pay_type(self) -> pulumi.Output[str]:
return pulumi.get(self, "pay_type") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pay_type(self) -> str:\n return pulumi.get(self, \"pay_type\")",
"def pay_type(self) -> str:\n return pulumi.get(self, \"pay_type\")",
"def pay_type(self) -> pulumi.Input[str]:\n return pulumi.get(self, \"pay_type\")",
"def pay_type(self) -> Optional[pulumi.Input[str]]:\n retu... | [
"0.7370092",
"0.7370092",
"0.7039694",
"0.6904175",
"0.6330069",
"0.58885604",
"0.5845314",
"0.5845314",
"0.55194235",
"0.53571945",
"0.52605695",
"0.52605695",
"0.5235334",
"0.5223406",
"0.5220029",
"0.5181687",
"0.5158966",
"0.5125254",
"0.50920224",
"0.5087104",
"0.5086406... | 0.6980556 | 3 |
Sets the learning rate to the initial LR decayed by 10 every 30 epochs | def adjust_learning_rate(optimizer, epoch, lr_steps):
decay = 0.1 ** (sum(epoch >= np.array(lr_steps)))
lr = args.lr * decay
decay = args.weight_decay
for param_group in optimizer.param_groups:
param_group['lr'] = lr * param_group['lr_mult']
param_group['weight_decay'] = decay * pa... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def adjust_learning_rate(init_lr, optimizer, epoch, n=100):\n init_lr = init_lr * (0.1 ** (epoch // n))\n print('learning rate : ', init_lr)\n for param_group in optimizer.param_groups:\n param_group['lr'] = init_lr",
"def adjust_learning_rate(start_lr, optimizer, epoch, total_epoch_num):\n #l... | [
"0.7913536",
"0.7906521",
"0.7849834",
"0.777524",
"0.77338326",
"0.77306354",
"0.7722718",
"0.77224237",
"0.771982",
"0.77092624",
"0.7693604",
"0.76742035",
"0.7665748",
"0.7665748",
"0.7665748",
"0.7655329",
"0.76419765",
"0.76399755",
"0.7637868",
"0.7626077",
"0.76247585... | 0.0 | -1 |
Computes the precision for the specified values of k | def accuracy(output, target, topk=(1,)):
maxk = max(topk)
batch_size = target.size(0)
_, pred = output.topk(maxk, 1, True, True)
pred = pred.t()
correct = pred.eq(target.view(1, -1).expand_as(pred))
res = []
for k in topk:
correct_k = correct[:k].view(-1).float().sum(0)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def precision(gt, pred, k):\n k = min(len(pred), k)\n den = min(len(gt), k)\n return sum([int(pred[i] in gt) for i in range(k)]) / den",
"def precision_at_k(r, k):\n assert k >= 1\n r = np.asarray(r)[:k] != 0\n if r.size != k:\n raise ValueError('Relevance score length < k')\... | [
"0.7642627",
"0.7417984",
"0.7417116",
"0.72703016",
"0.7245068",
"0.7244174",
"0.72359973",
"0.7221287",
"0.72093123",
"0.70574844",
"0.68535876",
"0.6785699",
"0.6785369",
"0.6770165",
"0.6727407",
"0.67198336",
"0.67198336",
"0.67198336",
"0.67198336",
"0.67198336",
"0.671... | 0.0 | -1 |
Return the exception's message. | def exc_message(exc_info):
exc = exc_info[1]
if exc is None:
# str exception
result = exc_info[0]
else:
try:
result = str(exc)
except UnicodeEncodeError:
try:
result = str(exc)
except UnicodeError:
# Fallback... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def exception_message(self) -> str:\n return pulumi.get(self, \"exception_message\")",
"def exception_message(self):\n # type: () -> string_types\n return self._exception_message",
"def exception_msg(exception):\n if hasattr(exception, 'message'):\n return str(exception.message)\... | [
"0.8948455",
"0.8916867",
"0.84399015",
"0.76953614",
"0.7636854",
"0.75887024",
"0.75721574",
"0.7520313",
"0.7516804",
"0.7516804",
"0.7516804",
"0.74608994",
"0.7456761",
"0.7443336",
"0.7434769",
"0.7402008",
"0.7374875",
"0.7344924",
"0.73113465",
"0.7304915",
"0.7224659... | 0.66821593 | 72 |
Returns true if both objects are equal | def __eq__(self, other):
if not isinstance(other, IQueryUserPartnerCouponsResultV2):
return False
return self.__dict__ == other.__dict__ | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __eq__(self, other):\n return are_equal(self, other)",
"def __eq__(self, other):\n return are_equal(self, other)",
"def __eq__(self,other):\n try: return self.object==other.object and isinstance(self,type(other))\n except: return False",
"def __eq__(self, other):\n if i... | [
"0.8089204",
"0.8089204",
"0.8055265",
"0.7983358",
"0.7967577",
"0.7967577",
"0.7967577",
"0.7967577",
"0.7967577",
"0.7967577",
"0.7967577",
"0.7967577",
"0.7967577",
"0.7967577",
"0.7967577",
"0.7967577",
"0.7967577",
"0.7967577",
"0.7967577",
"0.7967577",
"0.7967577",
"... | 0.0 | -1 |
Returns true if both objects are not equal | def __ne__(self, other):
return not self == other | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __ne__(self, other: object) -> bool:\n if self.__eq__(other):\n return False\n return True",
"def __ne__(self, other: object) -> bool:\n return not self.__eq__(other)",
"def __ne__(self, other) -> bool:\n return not self.__eq__(other)",
"def __eq__(self, other):\n ... | [
"0.845611",
"0.8391477",
"0.8144138",
"0.81410587",
"0.8132492",
"0.8093973",
"0.80920255",
"0.80920255",
"0.80920255",
"0.8085325",
"0.8085325",
"0.8076365",
"0.8076365",
"0.8065748"
] | 0.0 | -1 |
Is the given element above the diagonal? | def above_diagonal(self, i):
if self.diagonal is None:
return False
if i in self.diag:
return False
j, k = self.axis_position(i)
if self.diagonal == 'lower':
if j == k and j > (self.J / 2.):
return Tr... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_diagonal(row, col):\n return 1 if row == col else 0",
"def upper_diagonal_constraint(board: Board, row: int, col: int) -> bool:\n #move to first tile in diagonal\n row -= 1\n col -= 1\n #while still in board, test and move to next position return false if fails\n while row >= 0 and col >... | [
"0.76809126",
"0.7189091",
"0.71369004",
"0.71369004",
"0.7024099",
"0.7020343",
"0.6635364",
"0.6585887",
"0.65840995",
"0.6502569",
"0.64632684",
"0.6425372",
"0.63381606",
"0.63271224",
"0.6272297",
"0.62616473",
"0.6240833",
"0.6196442",
"0.61619264",
"0.6152348",
"0.6145... | 0.7363488 | 1 |
Add axis labels only on left and bottom. Meant for diagonal=True. | def add_labels(self, labels):
for i, axis in enumerate(self.bottom):
self.grid[axis].set_xlabel(labels[i])
for i, axis in enumerate(np.array(self.left)[-1::-1]):
if axis == self.upperleft:
continue
self.grid[axis].set_ylabel(labels[i])
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def AUTO(cls, labels: List[str]):\n # only one: put in the upper center like a title.\n if len(labels) == 1:\n return cls.TOP\n\n # It can be lengthy; Use side layout on the right.\n if len(labels) > 5 or any(len(label) > 20 for label in labels):\n return cls.RIGHT\n\n # compact enough; sh... | [
"0.693203",
"0.6701645",
"0.66453123",
"0.6478102",
"0.6452911",
"0.6443421",
"0.6401797",
"0.6382515",
"0.62302476",
"0.6208959",
"0.61742485",
"0.6162653",
"0.616055",
"0.61135983",
"0.60780126",
"0.6050891",
"0.60324764",
"0.6029909",
"0.6019753",
"0.6018161",
"0.59975046"... | 0.7644905 | 0 |
Estimate the KolmogorovSmirnov distance between all the columns of the experimental samples sample_E and the theorical samples sample_T and return the mean. | def KSDistDF(sample_E, sample_T):
res = [KSDist(sample_E[col], sample_T[col]) for col in sample_E.columns]
return np.mean(res) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def KLDivDF(sample_E, sample_T):\n res = [KLDiv(sample_E[col], sample_T[col]) for col in sample_E.columns]\n res = [v for v in res if not isinf(v)]\n return np.nanmean(res)",
"def KSDist(sample_E, sample_T):\n return ks_2samp(sample_E, sample_T)[0]",
"def KLDiv(sample_E, sample_T):\n x = np.uniq... | [
"0.64961547",
"0.645448",
"0.57628053",
"0.56765246",
"0.5598788",
"0.5491524",
"0.54630136",
"0.54496133",
"0.5443957",
"0.5435232",
"0.5417027",
"0.5410312",
"0.54056954",
"0.5385741",
"0.5373619",
"0.53407043",
"0.5338708",
"0.53284276",
"0.5290291",
"0.52842075",
"0.52827... | 0.72692233 | 0 |
Computes the Matthews Correlation Coefficient (MCC) of the binary classification of label. The XGBoost model is trained on synth_sample and tested on real_sample. | def BinaryClassif(synth_sample, real_sample, label, n_cores=1):
synth_sample = BinaryLabelCheck(synth_sample, label)
real_sample = BinaryLabelCheck(real_sample, label)
train_col = list(set(synth_sample.columns) - set([label]))
X_test = real_sample[train_col]
y_test = real_sample[label]
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def MultiClassif(synth_sample, real_sample, label, n_cores=1):\n synth_sample, real_sample = MultiClassLabelCheck(synth_sample, real_sample, label)\n\n train_col = list(set(synth_sample.columns) - set([label]))\n \n X_test = real_sample[train_col]\n y_test = real_sample[label]\n \n X_train = s... | [
"0.6921573",
"0.645347",
"0.6437997",
"0.622598",
"0.59991336",
"0.5836721",
"0.5788207",
"0.57135224",
"0.5702962",
"0.5690272",
"0.5602915",
"0.5558013",
"0.5542998",
"0.5498048",
"0.5494913",
"0.5494913",
"0.5468136",
"0.5454434",
"0.5446068",
"0.54451466",
"0.53960043",
... | 0.6942308 | 0 |
Returns the command in such a way that it can be copy and pasted into a terminal. >>> command_list_to_str(["ls", "/some path"]) 'ls "/some path"' This is used in some of the log messages. | def command_list_to_str(command):
return " ".join(pipes.quote(i) for i in command) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def commandListToCommandString(cmdlist):\n\n if isinstance(cmdlist, list) and len(cmdlist) > 0:\n cmd = [str(cmdlist[0])]\n\n for arg in cmdlist[1:]:\n argstr = repr(arg)\n\n if isinstance(arg,dict):\n argstr = argstr.replace('{', '[')\n argstr =... | [
"0.69407606",
"0.6441154",
"0.6343818",
"0.6285565",
"0.61214566",
"0.6079114",
"0.6046295",
"0.60174614",
"0.5986366",
"0.597178",
"0.5954181",
"0.59294266",
"0.5911993",
"0.58566976",
"0.5850563",
"0.58092475",
"0.58009374",
"0.5749464",
"0.57288104",
"0.5703034",
"0.568771... | 0.82716095 | 0 |
Validates if presented url is valid | def validateURL(url):
pattern = re.compile("^https*:\/\/\w+(\.\w+){2}[\/A-Za-z\d\?\=]*$")
match = pattern.match(url)
return True if match else False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate_url(self):\n pass",
"def _validate_url(url):\n if not url or url.count('/') != 1 or url[0] != '@':\n return False\n return True",
"def check_url(value):\n\n valid = validators.url(value)\n if valid != True:\n return False",
"def check_url(value):\n\n ... | [
"0.87820935",
"0.8214049",
"0.8180798",
"0.8141959",
"0.8097852",
"0.8087658",
"0.80368716",
"0.8021346",
"0.80030495",
"0.78966635",
"0.78958887",
"0.78505296",
"0.77453023",
"0.7739323",
"0.7728594",
"0.77084345",
"0.7697332",
"0.76661795",
"0.76633567",
"0.76604915",
"0.76... | 0.7732829 | 14 |
Function takes subset from list given indices | def split_data(Xlists, ybinarylists, indices):
tty = str(type(indices))
# or statement in next line is to account for python2 and python3
# difference
if tty == "<class 'slice'>" or tty == "<type 'slice'>":
x_setlist = [X for Xlist in Xlists[indices] for X in Xlist]
y_setlist = [y for yl... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def extract_sub_list(mylist, indices):\n return [mylist[ii] for ii in indices]",
"def slice_by_index(lst, indices):\r\n slicer = itemgetter(*indices)(lst)\r\n if len(indices) == 1:\r\n return [slicer]\r\n return list(slicer)",
"def subset_from_indices(self, indices):\n return self.ext... | [
"0.7489095",
"0.7330362",
"0.71721035",
"0.6905241",
"0.681125",
"0.6771095",
"0.6674392",
"0.6588212",
"0.65346277",
"0.6501113",
"0.6406087",
"0.63054657",
"0.62801874",
"0.6258661",
"0.61933935",
"0.6182325",
"0.61660683",
"0.612865",
"0.6093402",
"0.60804",
"0.605197",
... | 0.57087106 | 42 |
Returns the file name (as a string) associated with the uff object. | def get_file_name(self):
return self._fileName | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_file_name(self):\n return str(self.get_file())",
"def name(self):\n return self._fname",
"def name(self):\n return self._fname",
"def get_name(self):\n return self.file_name",
"def get_name(self):\n return self._file.name",
"def name(self):\n return self.... | [
"0.77690077",
"0.7661073",
"0.7661073",
"0.7419072",
"0.7371913",
"0.73712766",
"0.73677063",
"0.73478",
"0.73432004",
"0.7269109",
"0.72515947",
"0.72416973",
"0.72416973",
"0.72416973",
"0.72416973",
"0.72416973",
"0.72147214",
"0.7177944",
"0.7172954",
"0.7134353",
"0.7094... | 0.71948016 | 17 |
AzureEnvironmentResource a model defined in Swagger | def __init__(self, name=None, display_name=None, authentication_endpoint=None, resource_manager_endpoint=None, graph_endpoint=None, management_endpoint=None, storage_endpoint_suffix=None): # noqa: E501 # noqa: E501
self._name = None
self._display_name = None
self._authentication_endpoint = No... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, endpoint_name, sagemaker_session=None,\n serializer=json_serializer,\n deserializer=json_deserializer,\n content_type=None,\n model_name=None,\n model_version=None):\n super(Predictor, self).__init__(endpoint_... | [
"0.5594596",
"0.54339767",
"0.5406639",
"0.5375493",
"0.5314503",
"0.53112",
"0.5296379",
"0.5292136",
"0.523228",
"0.5211701",
"0.51806813",
"0.51661164",
"0.51369715",
"0.5122908",
"0.5112818",
"0.50852627",
"0.5078125",
"0.5031547",
"0.50281596",
"0.5025517",
"0.5020553",
... | 0.0 | -1 |
Sets the name of this AzureEnvironmentResource. | def name(self, name):
self._name = name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_name(self, name):\n self._name = name",
"def set_name(self, name):\n self.__name = name",
"def set_name(self, name):\n self.__name = name",
"def set_name(self, name: str):\n self._name = name",
"def set_name(self, name):\n self.name = name",
"def set_name(self, ... | [
"0.6502115",
"0.6393454",
"0.6393454",
"0.6382461",
"0.6370519",
"0.6370519",
"0.6370519",
"0.6370519",
"0.6370519",
"0.6361054",
"0.63593614",
"0.6305309",
"0.62983876",
"0.6248513",
"0.6221531",
"0.62170076",
"0.61966234",
"0.616489",
"0.6101837",
"0.6101837",
"0.608628",
... | 0.59398156 | 68 |
Sets the display_name of this AzureEnvironmentResource. | def display_name(self, display_name):
self._display_name = display_name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_display_name(self, display_name):\n self._call('set_display_name', display_name=display_name)",
"def display_name(self, display_name: str):\n\n self._display_name = display_name",
"def display_name(self, display_name):\n self._display_name = display_name",
"def display_name(self,... | [
"0.71251875",
"0.70913684",
"0.6918008",
"0.6918008",
"0.6918008",
"0.6918008",
"0.6918008",
"0.6918008",
"0.63808507",
"0.6134933",
"0.6121486",
"0.6063495",
"0.58136714",
"0.57954973",
"0.57563853",
"0.5688454",
"0.56206805",
"0.5600618",
"0.5600618",
"0.5600618",
"0.560061... | 0.69787323 | 2 |
Sets the graph_endpoint of this AzureEnvironmentResource. | def graph_endpoint(self, graph_endpoint):
self._graph_endpoint = graph_endpoint | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setEndpoint(self, endpoint):\n self.__lockobj.acquire()\n self.__endpoints[endpoint.getEndpoint()] = endpoint\n self.__lockobj.acquire()",
"def resource_manager_endpoint(self, resource_manager_endpoint):\n\n self._resource_manager_endpoint = resource_manager_endpoint",
"def endp... | [
"0.6397361",
"0.5955474",
"0.5711906",
"0.56135863",
"0.5347951",
"0.53392386",
"0.533514",
"0.5282221",
"0.5273625",
"0.51862943",
"0.51736015",
"0.51680773",
"0.5146897",
"0.508749",
"0.5053591",
"0.5010047",
"0.49842572",
"0.49490494",
"0.49405742",
"0.48988315",
"0.488624... | 0.75327146 | 0 |
Sets the management_endpoint of this AzureEnvironmentResource. | def management_endpoint(self, management_endpoint):
self._management_endpoint = management_endpoint | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def resource_manager_endpoint(self, resource_manager_endpoint):\n\n self._resource_manager_endpoint = resource_manager_endpoint",
"def management_password(self, management_password):\n\n self._management_password = management_password",
"def management_password_set(self, management_password_set):... | [
"0.6063906",
"0.57837194",
"0.5768384",
"0.542395",
"0.5134648",
"0.49401835",
"0.4895351",
"0.48799866",
"0.48583812",
"0.48193514",
"0.4786656",
"0.4715544",
"0.4687996",
"0.46870223",
"0.46852607",
"0.46615323",
"0.46615323",
"0.46036828",
"0.4547416",
"0.4539639",
"0.4537... | 0.819022 | 0 |
Sets the storage_endpoint_suffix of this AzureEnvironmentResource. | def storage_endpoint_suffix(self, storage_endpoint_suffix):
self._storage_endpoint_suffix = storage_endpoint_suffix | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def suffix(self, suffix):\n\n self._suffix = suffix",
"def suffix(self, suffix):\n\n self._suffix = suffix",
"def suffix(self, suffix):\n\n self._suffix = suffix",
"def suffix(self, suffix):\n\n self._suffix = suffix",
"def setSuffix(self, value):\n return self._set(suffi... | [
"0.6031992",
"0.6031992",
"0.6031992",
"0.6031992",
"0.5728825",
"0.5548969",
"0.5317373",
"0.52569854",
"0.5233334",
"0.5233334",
"0.51942295",
"0.51911515",
"0.50860834",
"0.5013088",
"0.5008409",
"0.50000554",
"0.49877164",
"0.49843106",
"0.49839348",
"0.48854783",
"0.4884... | 0.8504664 | 0 |
Returns true if both objects are equal | def __eq__(self, other):
if not isinstance(other, AzureEnvironmentResource):
return False
return self.__dict__ == other.__dict__ | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __eq__(self, other):\n return are_equal(self, other)",
"def __eq__(self, other):\n return are_equal(self, other)",
"def __eq__(self,other):\n try: return self.object==other.object and isinstance(self,type(other))\n except: return False",
"def __eq__(self, other):\n if i... | [
"0.8088132",
"0.8088132",
"0.8054589",
"0.7982687",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
"0.79670393",
... | 0.0 | -1 |
Returns true if both objects are not equal | def __ne__(self, other):
return not self == other | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __ne__(self, other: object) -> bool:\n if self.__eq__(other):\n return False\n return True",
"def __ne__(self, other: object) -> bool:\n return not self.__eq__(other)",
"def __ne__(self, other) -> bool:\n return not self.__eq__(other)",
"def __eq__(self, other):\n ... | [
"0.84560555",
"0.83913696",
"0.8143685",
"0.81403786",
"0.8131871",
"0.8093231",
"0.80915105",
"0.80915105",
"0.80915105",
"0.8084564",
"0.8084564",
"0.8075547",
"0.8075547",
"0.8065006"
] | 0.0 | -1 |
self.c = 1; self.tau1 = 1; self.tau2 = 1; tau = [tau1, tau2]; tau = [1 1]; self.tg = 40.62; in units of s for porosity_sp == 0.5 self.Vrtheta = 1; Not actually v, but greek nu (represents Poisson's ratio) self.Err = 1; | def __init__(self, c=1, tau1=1, tau2=1, tg=40.62, Vrtheta=1, Err=1):
# Source: https://stackoverflow.com/questions/12191075/is-there-a-shortcut-for-self-somevariable-somevariable-in-a-python-class-con/12191118
vars(self).update((k, v) for k, v in vars().items() if k != "self")
super().__init__() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self,):\r\n self.g = 9.81\r\n self.l = 0.5\r\n self.m1 = 1.0\r\n self.m2 = 1.0\r\n self.m3 = 1.0\r\n self.r1 = 1.0\r\n self.r2 = 1.0\r\n self.tau = 0.001\r\n self.theta1 = 1.0\r\n self.theta2 = 1.0\r\n self.theta3 = 1.0",
"... | [
"0.80207825",
"0.75504416",
"0.7062767",
"0.69327587",
"0.6891658",
"0.6856872",
"0.68485844",
"0.68429494",
"0.6758704",
"0.67359626",
"0.67142415",
"0.67082226",
"0.6627709",
"0.66226274",
"0.6605862",
"0.6605581",
"0.66032875",
"0.6571434",
"0.6568086",
"0.65680486",
"0.65... | 0.71100575 | 3 |
self.c = 2; self.tau1 = 0.001; self.tau2 = 10; tau = [tau1, tau2]; tau = [1 1]; self.tg = 40.62; in units of s for porosity_sp == 0.5 self.v = 0.3 self.t0_tg = 10 | def __init__(self, c=2, tau1=0.001, tau2=10, tg=40.62, v=0.3, t0_tg=10):
# Source: https://stackoverflow.com/questions/12191075/is-there-a-shortcut-for-self-somevariable-somevariable-in-a-python-class-con/12191118
vars(self).update((k, v) for k, v in vars().items() if k != "self")
super().__init... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self,tau = 1e-3):\n self._tau = tau \n pass",
"def __init__(self,):\r\n self.g = 9.81\r\n self.l = 0.5\r\n self.m1 = 1.0\r\n self.m2 = 1.0\r\n self.m3 = 1.0\r\n self.r1 = 1.0\r\n self.r2 = 1.0\r\n self.tau = 0.001\r\n self.the... | [
"0.79891974",
"0.771",
"0.73785704",
"0.69816023",
"0.69816023",
"0.6871864",
"0.6795907",
"0.67596704",
"0.6733155",
"0.6691811",
"0.66234815",
"0.66088235",
"0.65923774",
"0.65287817",
"0.6510996",
"0.65087396",
"0.64986086",
"0.6435481",
"0.64169884",
"0.64002764",
"0.6399... | 0.7437793 | 2 |
self.c = 1; self.tau1 = 1; self.tau2 = 1; tau = [tau1, tau2]; tau = [1 1]; self.tg = 40.62; in units of s for porosity_sp == 0.5 self.Vrtheta = 1; Not actually v, but greek nu (represents Poisson's ratio) self.Err = 1; | def __init__(self, c=1, tau1=1, tau2=1, tg=40.62, Vrtheta=1, Err=1):
# Source: https://stackoverflow.com/questions/12191075/is-there-a-shortcut-for-self-somevariable-somevariable-in-a-python-class-con/12191118
vars(self).update((k, v) for k, v in vars().items() if k != "self")
super().__init__() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self,):\r\n self.g = 9.81\r\n self.l = 0.5\r\n self.m1 = 1.0\r\n self.m2 = 1.0\r\n self.m3 = 1.0\r\n self.r1 = 1.0\r\n self.r2 = 1.0\r\n self.tau = 0.001\r\n self.theta1 = 1.0\r\n self.theta2 = 1.0\r\n self.theta3 = 1.0",
"... | [
"0.80193514",
"0.75498",
"0.706155",
"0.69317865",
"0.68898535",
"0.6856867",
"0.6847092",
"0.6841986",
"0.67587477",
"0.67350066",
"0.6713122",
"0.6708221",
"0.6626149",
"0.6621614",
"0.6604355",
"0.6604227",
"0.66013265",
"0.6569485",
"0.6567529",
"0.6566655",
"0.65547395",... | 0.710842 | 2 |
Gets one object from the database matching the provided criteria. | def get(self, **search_terms):
instances = self.filter(**search_terms)
if not instances:
raise NotFoundError("Nothing has been found.")
if len(instances) > 1:
raise NotUniqueError("Serveral instance have been found.")
return instances[0] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def find_one(self, criteria):\n return self.connection.find_one(criteria)",
"def get_one(self, object):\n self.lock.acquire()\n result = self.__Session.query(object).first()\n self.lock.release()\n return result",
"def find_first(cls, **kwargs):\n retur... | [
"0.84373474",
"0.7572787",
"0.7346191",
"0.7262237",
"0.7254171",
"0.72390306",
"0.7172697",
"0.71183133",
"0.7102729",
"0.7052207",
"0.6991019",
"0.6971038",
"0.6957347",
"0.6898343",
"0.68883365",
"0.6816034",
"0.6815702",
"0.68093586",
"0.67615014",
"0.67607087",
"0.672264... | 0.0 | -1 |
Adds a category on product_category. | def add_category(self, product, category):
self.db.query("""
INSERT IGNORE INTO product_category(product_id, category_id)
VALUES (:product_id, :category_id)
""", product_id=product.id, category_id=category.id) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_category_to_product(product_pk, category_pk):\n try:\n product = Products.objects.get(pk=product_pk, is_delete=False)\n category = Categories.objects.get(pk=category_pk, is_delete=False)\n except ObjectDoesNotExist:\n return Response({'status': PRODUCT_NOT_FOUND + 'or' + CATEGORY... | [
"0.75121343",
"0.7358083",
"0.7088792",
"0.6777966",
"0.65602285",
"0.6507084",
"0.6472791",
"0.63722146",
"0.6315254",
"0.6274299",
"0.62266326",
"0.62077636",
"0.62001437",
"0.59989184",
"0.5912432",
"0.5904826",
"0.5901935",
"0.5849749",
"0.58080226",
"0.5773969",
"0.57613... | 0.78598714 | 0 |
Get all the favorites. | def get_all_favorite(self):
products = self.db.query(f"""
SELECT original.`name` as "product_as_original", substitute.`name`
as "product_as_substitut", substitute.`url` as "url",
substitute.`nutrition_grade`,
GROUP_CONCAT(DISTINCT store.`name` SEPARATOR ', ')
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def favorites(self):\n path = self._get_path('favorites')\n \n response = self._GET(path)\n self._set_attrs_to_values(response)\n return self._clean_return(response)",
"def get_favorites(self):\n url = \"https://api.imgur.com/3/account/{0}/favorites\".format(self.name)\n... | [
"0.86110663",
"0.796011",
"0.77382666",
"0.7659631",
"0.7522312",
"0.7417046",
"0.71794766",
"0.695396",
"0.69429123",
"0.6856253",
"0.67503685",
"0.6595492",
"0.65568924",
"0.6556464",
"0.6509786",
"0.6458324",
"0.6379483",
"0.63463765",
"0.63425505",
"0.6260186",
"0.6202161... | 0.7040297 | 7 |
Return the nth element of the pingpong sequence. >>> pingpong(7) 7 >>> pingpong(8) 6 >>> pingpong(15) 1 >>> pingpong(21) 1 >>> pingpong(22) 0 >>> pingpong(30) 6 >>> pingpong(68) 2 >>> pingpong(69) 1 >>> pingpong(70) 0 >>> pingpong(71) 1 >>> pingpong(72) 0 >>> pingpong(100) 2 | def pingpong(n):
"*** YOUR CODE HERE ***"
def change(ind):
if ind % 7 == 0 or has_seven(ind):
return True
return False
def pong(up, ind, val):
if ind == n:
return val
if change(ind):
if up == 0:
return pong(1 - up, ind + 1,... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def nth(n, seq):\n try:\n return seq[n]\n except TypeError:\n return next(itertools.islice(seq, n, None))",
"def nth(n, iterable, default = None):\n return next(islice(iterable, n, None), default)",
"def pingpong(n):\n def helper(k, direction, ret):\n if k == n:\n re... | [
"0.66480666",
"0.6234669",
"0.61823606",
"0.6174454",
"0.6174454",
"0.6174454",
"0.6115191",
"0.61041856",
"0.60304207",
"0.60154617",
"0.6012078",
"0.5933489",
"0.5829569",
"0.5798853",
"0.566212",
"0.5646904",
"0.56240547",
"0.56132805",
"0.55990845",
"0.5567045",
"0.556463... | 0.586039 | 12 |
Returns True if at least one of the digits of k is a 7, False otherwise. >>> has_seven(3) False >>> has_seven(7) True >>> has_seven(2734) True >>> has_seven(2634) False >>> has_seven(734) True >>> has_seven(7777) True | def has_seven(k):
if k % 10 == 7:
return True
elif k < 10:
return False
else:
return has_seven(k // 10) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_seven(k):\n\tif k % 10 == 7:\n\t\treturn True\n\telif k < 10:\n\t\treturn False\n\telse:\n\t\treturn has_seven(k // 10)",
"def has_seven(k):\n if k == 0:\n return False\n else:\n if k%10 == 7:\n return True\n return has_seven(k//10)",
"def has_seven(k):\n \n ... | [
"0.89322066",
"0.87168527",
"0.87070906",
"0.6201554",
"0.58183026",
"0.5785289",
"0.57427174",
"0.57331115",
"0.5553506",
"0.55486673",
"0.5535979",
"0.5534775",
"0.54993117",
"0.5435203",
"0.5353972",
"0.5331451",
"0.53296477",
"0.53256255",
"0.5319151",
"0.529955",
"0.5299... | 0.86908776 | 5 |
Set the log level for this logger. | def set_log_level(log_level, quiet, verbose):
log_levels = {
2: 'ERROR',
1: 'WARNING',
0: 'INFO',
-1: 'DEBUG',
}
if log_level is None:
level = quiet - verbose
level = max(level, -1) # No smaller than -1
level = min(level, 2) # No larger than 2
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def level(self, log_level):\n self.logger.setLevel(log_level)",
"def set_log_level(self, level):\n if level == 'info':\n level = logging.INFO\n if level == 'debug':\n level = logging.DEBUG\n if level == 'error':\n level = logging.ERROR\n self._l... | [
"0.7997687",
"0.7911863",
"0.7875731",
"0.7855945",
"0.7657577",
"0.76221687",
"0.76062274",
"0.74678826",
"0.74475974",
"0.74316937",
"0.740048",
"0.733494",
"0.7249082",
"0.72054905",
"0.71819574",
"0.7099424",
"0.70335823",
"0.7016324",
"0.7012648",
"0.6988215",
"0.6971057... | 0.6178165 | 65 |
creating a onehot vector with 1 in the "ind" index. | def turn_to_one_hot(self,length,ind):
one_hot = [0 for _ in range(length)]
if (ind >= len(one_hot)):
one_hot[-1] = 1
else:
one_hot[ind] = 1
return one_hot | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def as_one_hot(ind, n):\n vec = np.zeros(n)\n vec[ind] = 1\n return vec",
"def get_one_hot(size, ind):\n one_hot = np.zeros((size,))\n one_hot[ind] = 1\n return one_hot",
"def one_hot(index):\n\toutput = np.zeros(100)\n\toutput[index] = 1\n\treturn output",
"def one_hot(index, dims, dtype=n... | [
"0.8829551",
"0.8723124",
"0.8635482",
"0.841147",
"0.8256151",
"0.823927",
"0.82021976",
"0.81518936",
"0.81171864",
"0.78469896",
"0.7835709",
"0.778365",
"0.7769134",
"0.77570134",
"0.77238005",
"0.77168167",
"0.7705721",
"0.76892275",
"0.7679577",
"0.7660691",
"0.76390207... | 0.8225875 | 6 |
this method gets a list, and return a dictionary mapping each (word,index) to a count (0 for start) | def list_to_word_count_dict(self,l):
to_return = {}
for i,word in enumerate(l):
to_return[(word,i)] = 0
return to_return | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def word_freq(self, word_list):\n hist = {}\n for word in word_list:\n hist[word] = hist.get(word, 0) + 1\n return hist",
"def frequency(lst):\n\n count = dict()\n for word in lst:\n if word in count:\n count[word] += 1\n else:\n count[wor... | [
"0.75395",
"0.75090414",
"0.74227965",
"0.7338366",
"0.7319109",
"0.7309097",
"0.72782624",
"0.72282577",
"0.7196145",
"0.71903366",
"0.71889",
"0.7155378",
"0.7136484",
"0.71141934",
"0.71105886",
"0.7101909",
"0.7091763",
"0.7069439",
"0.7044735",
"0.7035273",
"0.7026977",
... | 0.80735207 | 0 |
Returns the minimax action using self.depth and self.evaluationFunction | def getAction(self, gameState):
"*** YOUR CODE HERE ***"
result = float("-inf")
action = 1
alfa = float("-inf")
beta = float("inf")
for agentState in gameState.getLegalActions(0):
valorminimax = self.alfaBeta(1, 0, alfa, beta, gameState.generateSuccessor(0, ag... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getAction(self, gameState: GameState):\n _max = float(\"-inf\")\n action = None\n for move in gameState.getLegalActions(0):\n util = minimax(self.evaluationFunction, 1, 0,\n gameState.generateSuccessor(0, move), self.depth)\n if util > _max o... | [
"0.7482665",
"0.7383559",
"0.71806973",
"0.7110041",
"0.70884514",
"0.70694935",
"0.70683014",
"0.7048308",
"0.70055133",
"0.69651455",
"0.69642085",
"0.69604385",
"0.6945924",
"0.68998593",
"0.6895832",
"0.688605",
"0.6826282",
"0.6767276",
"0.6758028",
"0.6751636",
"0.67054... | 0.0 | -1 |
Returns the z for which P(Z >= z) = probability | def normal_lower_bound(probability: float,
mu: float = 0,
sigma: float = 1) -> float:
return inverse_normal_cdf(1 - probability, mu, sigma) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def zprob(z):\r\n Z_MAX = 6.0 # maximum meaningful z-value\r\n if z == 0.0:\r\n x = 0.0\r\n else:\r\n y = 0.5 * math.fabs(z)\r\n if y >= (Z_MAX*0.5):\r\n x = 1.0\r\n elif (y < 1.0):\r\n w = y*y\r\n x = ((((((((0.000124818987 * w\r\n ... | [
"0.7843298",
"0.75316334",
"0.75066924",
"0.73196054",
"0.67896765",
"0.6602989",
"0.64036673",
"0.63276106",
"0.62997496",
"0.62917864",
"0.6258713",
"0.6219829",
"0.6216976",
"0.6144722",
"0.61252874",
"0.6097141",
"0.60743517",
"0.60655755",
"0.6033293",
"0.5998195",
"0.59... | 0.0 | -1 |
How likely are we to see a value at least as extreme as x (in either direction) if our values are from a N(mu, sigma)? | def two_sided_p_value(x: float, mu: float = 0, sigma: float = 1) -> float:
if x >= mu:
# x is greater than the mean, so the tail is everything greater than x
return 2 * normal_probability_above(x, mu, sigma)
else:
# x is less than the mean, so the tail is everything less than x
r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def prob(x: np.ndarray, mu, sigma):\n n = mu.shape[0]\n inv = np.linalg.inv(sigma)\n den = np.sqrt(np.linalg.det(sigma)) * np.power(2 * np.pi, n / 2)\n dif = (x - mu).reshape(1, -1)\n num = -0.5 * dif @ inv @ dif.T\n num = np.exp(num)[0][0]\n return num / den",
"def expected_improvement(f_mi... | [
"0.67590684",
"0.6664639",
"0.65330946",
"0.647128",
"0.6298385",
"0.6276351",
"0.6214233",
"0.6214204",
"0.616229",
"0.6155313",
"0.61543244",
"0.6152204",
"0.6151924",
"0.6141858",
"0.6036254",
"0.60260147",
"0.602503",
"0.6019315",
"0.60075766",
"0.5993864",
"0.59836036",
... | 0.6688918 | 1 |
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
id = dictionary.get('Id')
name = dictionary.get('Name')
last_edited = APIHelper.RFC3339DateTime.from_value(dictionary.get(... | {
"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.83181363",
"0.8168959",
"0.8168959",
"0.81190246",
"0.8089133",
"0.79781497",
"0.792305",
"0.7898849",
"0.7895396",
"0.78879154",
"0.78826",
"0.7881249",
"0.78768563",
"0.7858234",
"0.7840083",
"0.7804028",
"0.7804028",
"0.7804028",
"0.7804028",
"0.7804028",
"0.7804028",
... | 0.79491246 | 6 |
Method to calculate the energies of the PE surfaces at the given point. | def en(self, crd):
en = [0.0, 0.0]
for co in crd.flatten():
en[0] += co**2
en[1] += (co-1)**2
return en | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def energy_surface(self, points=100):\n points = int(points)\n theta = np.linspace(0, np.pi, num=points, dtype=np.float32)\n phi = np.linspace(-np.pi, np.pi, num=points, dtype=np.float32)\n energies = np.zeros((points**2, 3), dtype=np.float32)\n m = np.zeros(3)\n\n for i i... | [
"0.68129474",
"0.639182",
"0.6107873",
"0.6088227",
"0.6053956",
"0.60534704",
"0.60073984",
"0.5990248",
"0.59695727",
"0.59528637",
"0.59215486",
"0.5890589",
"0.58736163",
"0.5864389",
"0.58582336",
"0.5825275",
"0.5803282",
"0.5797568",
"0.57904744",
"0.57886195",
"0.5746... | 0.0 | -1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.