query stringlengths 9 9.05k | document stringlengths 10 222k | metadata dict | negatives listlengths 30 30 | negative_scores listlengths 30 30 | document_score stringlengths 4 10 | document_rank stringclasses 2
values |
|---|---|---|---|---|---|---|
Sample n unique transitions from this replay buffer. | def sample(self, n):
raise NotImplementedError | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def forward_sample(self, n):\n return self.flow.sample(n)",
"def make_transition_probs(self):\n n = len(self.speakers) # TODO why this line ???\n transitions = np.random.randint(5, size=(n, n)) + 1\n transitions += transitions.transpose()\n for i in range(0, math.floor(n / 2))... | [
"0.68146557",
"0.6224251",
"0.6222788",
"0.62133044",
"0.62121004",
"0.6095127",
"0.60457236",
"0.6044495",
"0.6036218",
"0.6034767",
"0.5981826",
"0.59806126",
"0.5973659",
"0.59557086",
"0.5937926",
"0.59049225",
"0.5866684",
"0.5856035",
"0.58527726",
"0.58494985",
"0.5827... | 0.6358313 | 1 |
Sample n unique (sub)episodes from this replay buffer. | def sample_episodes(self, n_episodes, max_len=None):
raise NotImplementedError | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sample_episodes(self, n_episodes, max_len=None):\n assert len(self.episodic_memory) >= n_episodes\n episodes, probabilities = self.episodic_memory.sample(\n n_episodes, uniform_ratio=self.uniform_ratio)\n if max_len is not None:\n episodes = [random_subseq(ep, max_len... | [
"0.6816557",
"0.6772563",
"0.6766175",
"0.66474956",
"0.6633737",
"0.6541992",
"0.65018564",
"0.650122",
"0.6493712",
"0.6410177",
"0.6291393",
"0.62809753",
"0.6238704",
"0.620394",
"0.6201665",
"0.6201665",
"0.6185153",
"0.6118868",
"0.6079757",
"0.60614866",
"0.60578036",
... | 0.7432015 | 0 |
Returns the number of episodes in the buffer. | def n_episodes(self):
raise NotImplementedError | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_num_episodes(self) -> int:\n return len(self.episodes)",
"def __len__(self) -> int:\n return len(self.episodes)",
"def get_tv_episodes(self) -> int:\n return len(glob.glob(os.path.join(\n os.path.dirname(self.file),\n f\"*{os.path.splitext(self.file)[-1]}\"\n ... | [
"0.7731033",
"0.6756215",
"0.6697167",
"0.66335285",
"0.6520303",
"0.6492043",
"0.6488236",
"0.6454305",
"0.63702416",
"0.6308576",
"0.6201339",
"0.6192891",
"0.618868",
"0.6162246",
"0.6147996",
"0.60496384",
"0.604726",
"0.600012",
"0.5996808",
"0.59935427",
"0.5982767",
... | 0.70023835 | 1 |
Tests task timeout exceeded. | def test_timeout(self, mocker, mock_timedelta):
tid = 289466
site = "mysite"
exception_response = self.generate_task_dictionary(
tid, state="started", completed=None
)
responses = [{"json": exception_response}]
url = (
"https://cloudapi.acquia.c... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def assert_timeout(self) -> None:",
"def raise_timeout(self, *args, **kwargs):\n\n self.log.error(\"Task timeout encountered.\")\n raise TimeoutError",
"def timeout(order):\n return ResultProxy(TaskResult(TaskTimedout('A task has timedout'), order))",
"def test_get_timeouts_with_maximum(self... | [
"0.7699012",
"0.7480195",
"0.7368372",
"0.7333086",
"0.7270023",
"0.7233615",
"0.7205132",
"0.70961386",
"0.70661306",
"0.70456356",
"0.7003196",
"0.6990812",
"0.6983837",
"0.6959921",
"0.6955381",
"0.69085103",
"0.6899538",
"0.68383205",
"0.68176025",
"0.675982",
"0.67549634... | 0.76899767 | 1 |
call fn n times with args in n is an int; if n is float, repeat up to n seconds; return min, avg, and max times | def timedcalls(n, fn, *args):
if isinstance(n, int):
times = [timedcall(fn, *args)[0] for _ in xrange(n)]
elif isinstance(n, float):
timer, times = 0.0, []
while timer < n:
times.append(timedcall(fn, *args)[0])
timer += times[-1]
return min(times), average(t... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def timer(*args, **kwargs):\r\n\r\n accepted_args = ['n']\r\n\r\n for argument in kwargs.keys():\r\n if argument not in accepted_args:\r\n raise AttributeError(\r\n '{} not accepted argument: please see documentation for allowed arguments'.format(argument))\r\n\r\n def mak... | [
"0.7270432",
"0.681288",
"0.6719622",
"0.65781075",
"0.6565701",
"0.65172404",
"0.64856404",
"0.64584816",
"0.6301394",
"0.62860733",
"0.6191388",
"0.61890405",
"0.6142164",
"0.6140048",
"0.6104853",
"0.6041679",
"0.6026724",
"0.60056436",
"0.60029274",
"0.59953314",
"0.59874... | 0.82888895 | 0 |
Tests the initialization of Commands plugin. | def test_commands_initialization(bot):
plugin = Commands(bot)
assert isinstance(plugin, Commands)
assert plugin.bot == bot | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_arg_parser_init(self):\n args = self.parser.parse_args(['init'])\n self.assertEqual(args.command, 'init')",
"def test_plugin_initialize(self):\n p = PluginCustom()\n self.assertEqual('youpie', p.toto)",
"def test_01_Init(self):\n pass",
"def test_plugin_command(nod... | [
"0.7322691",
"0.69727504",
"0.6834208",
"0.6811413",
"0.6743495",
"0.6726742",
"0.66476715",
"0.66441023",
"0.6640725",
"0.65635633",
"0.65407413",
"0.65406895",
"0.6537672",
"0.6500868",
"0.64592093",
"0.6451078",
"0.6431344",
"0.64273673",
"0.64224267",
"0.6421834",
"0.6414... | 0.85673785 | 0 |
Tests the horoscope command. | def test_horoscope(mock_session_get, sign, expected, bot):
data = {'horoscope': expected}
request = asynctest.Mock(json=asynctest.CoroutineMock(side_effect=[data]))
mock_session_get.return_value.__aenter__.return_value = request
mask = IrcString('nickname!@192.168.0.100')
channel = IrcString('#melec... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_cli_exists():\n\n assert \"main\" in vars(dork.cli), \"Dork.cli should define a main method\"\n assert isinstance(dork.cli.main, FunctionType)",
"def test_cli_fix():\n assert Cli is Cl",
"async def horoscope(self, mask, target, args):\n wished = args['<zodiac>']\n\n # list of zo... | [
"0.5647759",
"0.56472015",
"0.560856",
"0.5552268",
"0.55183226",
"0.54527044",
"0.5444253",
"0.54387784",
"0.54324186",
"0.5415717",
"0.5388596",
"0.53846055",
"0.5365956",
"0.5356168",
"0.5349364",
"0.5343237",
"0.5337284",
"0.53130776",
"0.53128475",
"0.5271401",
"0.526793... | 0.66078097 | 0 |
Tests the greeting command. | def test_greeting(bot):
mask = IrcString('nickname!@192.168.0.100')
channel = IrcString('#meleca')
args = {
'<nick>': 'nickname',
'<message>': 'Hello there.'
}
data = {
'channel': channel.replace('#', ''),
'nick': args.get('<nick>'),
'options': '\n'.join(['Hey... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_greeting(self):\r\n self.assertEqual(greet_by_name('Dani'), 'Hello, Mark!')",
"def greeting():\n print('\\n',\n '=' * 45,\n \"\\n Welcome to this Module-Creation-Test-Program!!!\",\n '\\n',\n '=' * 45)",
"async def greeting(self, ctx):\n await self.... | [
"0.75602263",
"0.73418033",
"0.6975271",
"0.69664526",
"0.6752271",
"0.67297",
"0.66938585",
"0.66837734",
"0.66831857",
"0.66415226",
"0.663575",
"0.6620999",
"0.65337926",
"0.6501583",
"0.6501583",
"0.6501583",
"0.6428034",
"0.6417725",
"0.6416484",
"0.6416484",
"0.6351988"... | 0.76283956 | 0 |
Tests the greeting command when error occur. | def test_greeting_raising_exception(bot):
bot.dataset['greetings'].upsert.side_effect = ValueError()
mask = IrcString('nickname!@192.168.0.100')
channel = IrcString('#meleca')
args = {
'<nick>': 'nickname',
'<message>': 'Hello there.'
}
plugin = Commands(bot)
async def test(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_greeting(bot):\n mask = IrcString('nickname!@192.168.0.100')\n channel = IrcString('#meleca')\n args = {\n '<nick>': 'nickname',\n '<message>': 'Hello there.'\n }\n data = {\n 'channel': channel.replace('#', ''),\n 'nick': args.get('<nick>'),\n 'options': ... | [
"0.66667175",
"0.63299525",
"0.6273337",
"0.61859703",
"0.6163701",
"0.61435163",
"0.61362547",
"0.6118038",
"0.6092297",
"0.60595864",
"0.60546046",
"0.6017189",
"0.60101837",
"0.600944",
"0.6006676",
"0.5990766",
"0.59791356",
"0.5973189",
"0.5959298",
"0.5951244",
"0.59473... | 0.79444855 | 0 |
Tests the joke command. | def test_joke(mock_session_get, subject, joke, expected, bot):
request = asynctest.Mock(json=asynctest.CoroutineMock(side_effect=[joke]))
mock_session_get.return_value.__aenter__.return_value = request
mask = IrcString('nickname!@192.168.0.100')
channel = IrcString('#meleca')
args = {'<subject>': su... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def joke(message):\n return random.choice(jokes)",
"def main():\n joke_util = JokeUtility()\n for i in xrange(7):\n print \"{}. \".format(i + 1) + joke_util.get_joke()",
"async def tell_joke(intent: NluIntent):\n _LOGGER.info(\"TellJoke\")\n \n return EndSession(random.choice(jok... | [
"0.64295465",
"0.632113",
"0.6320038",
"0.625344",
"0.6012959",
"0.59555566",
"0.59026814",
"0.5856913",
"0.573086",
"0.57065004",
"0.56679606",
"0.5631582",
"0.56119335",
"0.5609192",
"0.5545284",
"0.54654557",
"0.54609776",
"0.5439848",
"0.5403573",
"0.53812855",
"0.5353147... | 0.7267169 | 0 |
Tests the cebolate command. | def test_cebolate(bot):
mask = IrcString('nickname!@192.168.0.100')
channel = IrcString('#meleca')
args = {'<message>': ['CORRECT', 'answer']}
plugin = Commands(bot)
async def test():
response = await plugin.cebolate(mask, channel, args)
assert response == 'COLLECT answel'
async... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def testCasCommand(self):\n self.assertEqual(None, self.msTest.getCASCommand(\"abc123\"),\n \"\\\"abc123\\\" was not a valid computer algebra system in the list, but\\\nour machine settings instance returned it as one.\")\n self.assertEqual(\"magma\", self.msTest.getCASCommand(\"Ma... | [
"0.6186664",
"0.61535156",
"0.6087915",
"0.6053571",
"0.6042913",
"0.5946228",
"0.5932634",
"0.5869777",
"0.58158827",
"0.58158004",
"0.5815441",
"0.5779321",
"0.5771726",
"0.5769046",
"0.57646203",
"0.5725273",
"0.56969696",
"0.5688723",
"0.5672813",
"0.5669628",
"0.56478757... | 0.6847303 | 0 |
Added a file logger to the root | def add_file_handler_to_root(file_name):
formatter = logging.Formatter('%(asctime)-15s:' + logging.BASIC_FORMAT)
file_handler = logging.FileHandler(file_name)
file_handler.setFormatter(formatter)
root_logger = logging.getLogger()
root_logger.addHandler(file_handler) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_add_file_handler():\n change_cwd()\n logger = logging.getLogger(__name__)\n file_handler = logging.FileHandler('logging.log')\n file_handler.setLevel(logging.DEBUG)\n logger.addHandler(file_handler)\n log_all_levels(logger)\n log_all_levels_decorated(logger)\n log_all_levels_loop(l... | [
"0.74221367",
"0.7318558",
"0.72203755",
"0.7216344",
"0.7157909",
"0.7038564",
"0.69997287",
"0.6942662",
"0.6902283",
"0.6843575",
"0.68174726",
"0.68048483",
"0.67970276",
"0.6787445",
"0.67730004",
"0.6715203",
"0.66246045",
"0.6597348",
"0.65791374",
"0.65753305",
"0.656... | 0.7924246 | 0 |
Test instantiation of base metadata object | def test_base_metadata(self):
base_meta = BaseMetadata(api_client=self.IDS_SYS_CLIENT)
self.assertIsNotNone(base_meta)
self.assertEqual(base_meta._api_client, self.IDS_SYS_CLIENT) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_meta_data_is_not_inherited(self):",
"def test_all_attributes_in_base_metadata(self):\n\n name = 'idsvc.basemeta'\n uuid = 'ABC'\n value = { 'color': 'blue' }\n owner = 'bob'\n schemaId = None\n internalUsername = None\n associationIds = ['CDE', 'EFG']\n ... | [
"0.72128224",
"0.72077847",
"0.71640617",
"0.6948457",
"0.686556",
"0.66628927",
"0.6646507",
"0.6618003",
"0.66168135",
"0.658924",
"0.65528834",
"0.65279025",
"0.64800894",
"0.6454468",
"0.64089274",
"0.63812315",
"0.6378082",
"0.63752025",
"0.6340802",
"0.63331854",
"0.633... | 0.7681497 | 0 |
Test value parameter to base metadata constructor | def test_value_base_metadata_param(self):
value = { 'color': 'blue' }
base_meta = BaseMetadata(api_client=self.IDS_SYS_CLIENT, value=value)
self.assertEqual(base_meta.value, value) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, value=None):",
"def __init__(self, value=None):",
"def __init__(self,\n value: Optional[Union[str, float, int]] = None,\n metadata_file: Optional[str] = None,\n field_name: Optional[str] = None):\n if not (value is not None and not (metadata_file or field_name) or (\n ... | [
"0.66596955",
"0.66596955",
"0.65618765",
"0.6533144",
"0.6519998",
"0.6411573",
"0.63997006",
"0.63804954",
"0.63804954",
"0.63804954",
"0.63804954",
"0.63804954",
"0.63804954",
"0.6361811",
"0.6346104",
"0.6346104",
"0.63296425",
"0.63152283",
"0.6261587",
"0.62377363",
"0.... | 0.74877274 | 0 |
Test meta parameter to base metadata constructor | def test_meta_base_metadata_param(self):
name = 'idsvc.basemeta'
meta = { 'name': name }
base_meta = BaseMetadata(api_client=self.IDS_SYS_CLIENT, meta=meta)
# base_meta.meta will return null values that we did not specifiy
# so we need to test if meta is a subset of base_meta.met... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_value_base_metadata_param(self):\n value = { 'color': 'blue' }\n base_meta = BaseMetadata(api_client=self.IDS_SYS_CLIENT, value=value)\n self.assertEqual(base_meta.value, value)",
"def test_meta_data_is_not_inherited(self):",
"def __init__(self):\n super().__init__(interfac... | [
"0.6549488",
"0.64956385",
"0.6303458",
"0.62716156",
"0.62638754",
"0.62207234",
"0.6170832",
"0.6167809",
"0.6123403",
"0.61136276",
"0.6099809",
"0.6058466",
"0.6057352",
"0.6049857",
"0.6049857",
"0.6023122",
"0.5989329",
"0.59722364",
"0.59373343",
"0.5929125",
"0.592070... | 0.67646563 | 0 |
Test name attribute in base metadata object | def test_name_attribute_in_base_metadata(self):
name = 'idsvc.basemeta'
meta = { 'name': name }
base_meta = BaseMetadata(api_client=self.IDS_SYS_CLIENT, meta=meta)
self.assertEqual(base_meta.name, meta['name']) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_name(self):\n self.assertTrue(type(x.name) == str)",
"def test_name(self):\n inst = Amenity()\n self.assertTrue(hasattr(inst, \"name\"))\n self.assertEqual(inst.name, \"\")",
"def test_name(self):\n insta = Amenity()\n self.assertTrue(hasattr(insta, \"name\"))... | [
"0.7202838",
"0.71910316",
"0.7186613",
"0.70835626",
"0.69561404",
"0.6942329",
"0.679943",
"0.67916936",
"0.67906064",
"0.67756766",
"0.6773035",
"0.6744572",
"0.67302454",
"0.6668658",
"0.6660452",
"0.6624203",
"0.66221493",
"0.6598095",
"0.6590471",
"0.65831363",
"0.65818... | 0.8473764 | 0 |
Reusable method for saving a base metadata object | def save_base_metadata(self):
value = { 'color': 'blue' }
meta = { 'value': value }
base_meta = BaseMetadata(api_client=self.IDS_SYS_CLIENT, meta=meta)
base_meta.save()
self.assertIsNotNone(base_meta.uuid)
self.assertTrue(all([item in base_meta.meta.items() for item in me... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_save_base_metadata(self):\n\n self.save_base_metadata()\n\n # cleanup\n\n self.delete_base_metadata()",
"def save(self, metadata):\n pass",
"def save_info(base):\r\n _info = open(base.info_name,'wb')\r\n fields = []\r\n for k in base.field_names:\r\n if isin... | [
"0.7243453",
"0.71924603",
"0.70609534",
"0.6648852",
"0.65792817",
"0.6564216",
"0.6487601",
"0.64820987",
"0.6461785",
"0.64593667",
"0.6449653",
"0.64074403",
"0.6393467",
"0.6393467",
"0.6393467",
"0.6366843",
"0.63604736",
"0.6354679",
"0.635351",
"0.633432",
"0.6328498"... | 0.76338327 | 0 |
Test saving a base metadata object | def test_save_base_metadata(self):
self.save_base_metadata()
# cleanup
self.delete_base_metadata() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_edit_base_metadata(self):\n\n # start out by creating some metadata\n\n base_meta_object_a = self.save_base_metadata()\n\n # load the same metadata object again from agave\n\n base_meta_object_b = BaseMetadata(api_client=self.IDS_SYS_CLIENT, uuid=base_meta_object_a.uuid)\n ... | [
"0.78543615",
"0.7616469",
"0.7609624",
"0.73526305",
"0.7122581",
"0.7122581",
"0.70944816",
"0.7065448",
"0.68938506",
"0.68533725",
"0.68063986",
"0.67536354",
"0.67241395",
"0.66987973",
"0.6693329",
"0.66302127",
"0.6625193",
"0.66245514",
"0.6577093",
"0.6557982",
"0.65... | 0.81676334 | 0 |
Test saving with value but without 'meta' | def test_save_with_value_no_meta(self):
value = { 'color': 'blue' }
base_meta = BaseMetadata(api_client=self.IDS_SYS_CLIENT, value=value)
base_meta.save()
self.assertIsNotNone(base_meta.uuid)
self.assertTrue(all(item in base_meta.value.items() for item in value.items()))
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_model_keeps_value( self ):\r\n\t\tself.assertEqual( self.m_test_model.custom_field, custom_data )",
"def test_save_with_no_meta(self):\n\n base_meta = BaseMetadata(api_client=self.IDS_SYS_CLIENT)\n\n base_meta.save()\n self.assertIsNotNone(base_meta.uuid)\n\n # cleanup\n\n ... | [
"0.7051546",
"0.66853964",
"0.64824414",
"0.6398936",
"0.6274527",
"0.6220943",
"0.6220943",
"0.6131616",
"0.60958767",
"0.6071231",
"0.60439295",
"0.6008178",
"0.5979268",
"0.5953959",
"0.5919423",
"0.5896215",
"0.5889991",
"0.58881336",
"0.58852464",
"0.588067",
"0.58757675... | 0.7676591 | 0 |
Test editing a base metadata object | def test_edit_base_metadata(self):
# start out by creating some metadata
base_meta_object_a = self.save_base_metadata()
# load the same metadata object again from agave
base_meta_object_b = BaseMetadata(api_client=self.IDS_SYS_CLIENT, uuid=base_meta_object_a.uuid)
base_meta_o... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_update_metadata(self):\n pass",
"def test_update_metadata1(self):\n pass",
"def test_update_metadata_by_attribute(self):\n pass",
"def test_metadata(self):\n self.assertEquals(self.testObject.metadata, {})",
"def test_partial_update_metadata(self):\n pass",
"de... | [
"0.7476434",
"0.727935",
"0.7029074",
"0.68390214",
"0.6807431",
"0.6756963",
"0.66941255",
"0.66874236",
"0.6676477",
"0.6640251",
"0.6638407",
"0.65415853",
"0.65285915",
"0.6526825",
"0.6501212",
"0.6446845",
"0.6417073",
"0.64023674",
"0.6385858",
"0.6383965",
"0.6369355"... | 0.8445895 | 0 |
Delete all metadata with name = 'idsvc.basemeta' | def delete_base_metadata(self):
# get a list of basemetadata objects
response = BaseMetadata.list(self.IDS_SYS_CLIENT)
# we will delete any and all metadata with name = 'idsvc.basemeta'
for mo in response:
mo.delete()
# check delete, list metadata with name = 'id... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_delete_base_metadata(self):\n\n # start out by creating some metadata\n\n self.save_base_metadata()\n\n # delete all metadata with name = 'idsvc.basemeta'\n\n self.delete_base_metadata()",
"def delete_server_metadata(self, name):\n raise NotImplementedError",
"def cl... | [
"0.84430635",
"0.64150095",
"0.62892693",
"0.6152004",
"0.61284477",
"0.61047477",
"0.6098977",
"0.60908705",
"0.60583866",
"0.60540974",
"0.60007805",
"0.5944395",
"0.5921063",
"0.5835727",
"0.5834407",
"0.582344",
"0.5756708",
"0.57534325",
"0.5712043",
"0.56959385",
"0.563... | 0.8524633 | 0 |
Test deleting a base metadata object | def test_delete_base_metadata(self):
# start out by creating some metadata
self.save_base_metadata()
# delete all metadata with name = 'idsvc.basemeta'
self.delete_base_metadata() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_data_object_del(self):\n pass",
"def delete_base_metadata(self):\n\n # get a list of basemetadata objects\n\n response = BaseMetadata.list(self.IDS_SYS_CLIENT)\n\n # we will delete any and all metadata with name = 'idsvc.basemeta'\n\n for mo in response:\n m... | [
"0.76360863",
"0.75796247",
"0.7424912",
"0.7392482",
"0.73275954",
"0.7265674",
"0.72626764",
"0.7231402",
"0.7199362",
"0.71669066",
"0.7125277",
"0.70837337",
"0.70734006",
"0.70433253",
"0.6997248",
"0.6987438",
"0.69809085",
"0.6940797",
"0.693287",
"0.6854025",
"0.68499... | 0.8555884 | 0 |
Create a few metadata objects with associations, and test to see that model returns appropriate associations between objects | def test_associations(self):
oj = {}
if self.DEBUG:
print "Create A"
# create a
a = self.save_base_metadata()
oj[a.uuid] = 'A'
if self.DEBUG:
print "Create B, point B to A"
# create b, point b to a
b = self.save_base_metadata(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_instance(self):\n self.assertEqual(True, type(self.Test.defined_associations['things']) is pyperry.association.HasMany)",
"def test_defined_associations(self):\n self.assertEqual(True, len(self.Test.defined_associations) > 0)",
"def test_defined_associations(self):\n self.assertEq... | [
"0.6860871",
"0.67655295",
"0.67655295",
"0.67655295",
"0.67218894",
"0.65718967",
"0.6386253",
"0.6373686",
"0.63736224",
"0.62489605",
"0.6214252",
"0.6139644",
"0.604479",
"0.60318655",
"0.60233927",
"0.59938467",
"0.5951699",
"0.59041905",
"0.58758587",
"0.58755773",
"0.5... | 0.74057245 | 0 |
Main entry point. Waits until the protocol should start and then runs the Hydrand protocol. returns True if the protocol was succesfully executed for NUM_ROUNDS | def run(self):
self.logger.info(f"THIS IS NODE: {self.ID}")
self.logger.info("starting node")
self.startup()
self.logger.info("startup completed")
while not self.shutdown_requested and self.round < NUM_ROUNDS:
self._run_round()
self.shutdown()
self.l... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def main():\n print(\"Welcome to the Cryptography Suite!\")\n run_suite()\n while should_continue():\n run_suite()\n print(\"Goodbye!\")",
"def main():\r\n # Initialize words from specific file\r\n words_list = hangman_helper.load_words()\r\n # Run single game with given word list to ... | [
"0.56066555",
"0.5558875",
"0.5554896",
"0.5537083",
"0.55305225",
"0.5479147",
"0.5455473",
"0.54533494",
"0.5423325",
"0.53984165",
"0.538176",
"0.53176254",
"0.53092045",
"0.53022957",
"0.52891845",
"0.5284703",
"0.5283291",
"0.5262857",
"0.5255488",
"0.5246759",
"0.524605... | 0.60520685 | 0 |
Wrapper for _run_round, used for single stepping execution in tests only. | def run_round(self):
self._running = True
self._run_round()
self._running = False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def simulate(self):\n self.round += 1",
"def _run_round(self):\n self.advance_round() # increment round number and update timeouts\n self.compute_leader()\n\n if self.is_leader:\n self.propose()\n\n while not self.shutdown_requested:\n\n if self.update_ph... | [
"0.6459184",
"0.5923093",
"0.5778624",
"0.5775442",
"0.5770883",
"0.574531",
"0.56716996",
"0.5626923",
"0.5620087",
"0.56040144",
"0.5580789",
"0.5545288",
"0.552805",
"0.5520642",
"0.5518841",
"0.55148053",
"0.5511724",
"0.5507922",
"0.5486841",
"0.54748136",
"0.5466471",
... | 0.7190493 | 0 |
helper function rn(Dx) to recursively compute the set of recovered nodes from the view of a dataset | def _recovered_nodes(self, x: int):
if x == 0:
return set()
Dx = self.datasets[x]
assert Dx is not None
xprev = Dx.prev_round_idx
if xprev == x - 1:
# no recovery certificates
return self._recovered_nodes(xprev)
return self._recovered_n... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def idfs(start_node, goal_state, improved_descendants = False):\t\n\tnumber_nodes_expanded = 0\n\tt0 = time.time()\n\n\tfor lim in range(21): #from depth 0 to 20\n\t\tsolution, number_nodes_expanded_iter = dfs(start_node, goal_state, lim, iterative= True, improved_descendants= improved_descendants)\n\t\tnumber_no... | [
"0.5757122",
"0.56601816",
"0.5618215",
"0.5558861",
"0.54924595",
"0.53879654",
"0.5385801",
"0.53537655",
"0.53510165",
"0.53428787",
"0.53374165",
"0.5325327",
"0.53223133",
"0.5308494",
"0.5294493",
"0.5279992",
"0.5276192",
"0.52739906",
"0.52637124",
"0.5239348",
"0.520... | 0.6716138 | 0 |
Trys to process the next message from the message queue. All past message at the beginning of the queue are skipped. If the next message is for some future round and phase, it is not processed and this call returns False. Otherwise, the next message is removed from the queue and processed, True is returned. | def process_message(self):
while True:
if not self.next_message:
return False
# check if next message is in the past, and drop it
if (self.next_message.round, self.next_message.phase) < (self.round, self.phase):
(self.logger.debug if self.is_l... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_next(self):\n return not self.finished_function(self.peek)",
"def Next(self):\n next_task = fleetspeak_test_lib.PopMessage(self.client_id)\n if next_task is None:\n return False\n\n try:\n responses = self.client_mock.HandleMessage(next_task)\n except Exception as e: # pylin... | [
"0.66106015",
"0.6346463",
"0.62877834",
"0.6275698",
"0.6060755",
"0.6039437",
"0.5979104",
"0.5978973",
"0.59707963",
"0.5935703",
"0.5935703",
"0.59026",
"0.5820143",
"0.58180416",
"0.5810485",
"0.579302",
"0.57863045",
"0.5774863",
"0.5749116",
"0.5748575",
"0.57075465",
... | 0.7979613 | 0 |
Processes a receive propose message from some node. The outer message signature has already been verified, but the other signatures and all messageinternal checks are performed in this function. This includes the check if the sender is actually leader of the current round. | def process_propose(self, msg: ProposeMessage):
dataset = msg.dataset
if self.verify_revealed_secret(dataset.revealed_secret):
self.revealed_secrets[self.round] = dataset.revealed_secret
self.compute_beacon(msg.dataset.revealed_secret)
else:
self.flag_adversa... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process_message(self):\n while True:\n if not self.next_message:\n return False\n\n # check if next message is in the past, and drop it\n if (self.next_message.round, self.next_message.phase) < (self.round, self.phase):\n (self.logger.debug ... | [
"0.66365314",
"0.6116566",
"0.5569347",
"0.5476225",
"0.54232764",
"0.53519475",
"0.5339798",
"0.53252363",
"0.5323907",
"0.532339",
"0.5273541",
"0.526867",
"0.5243941",
"0.5214057",
"0.51772726",
"0.5156063",
"0.51349",
"0.5122346",
"0.511073",
"0.51088786",
"0.5108569",
... | 0.6630038 | 1 |
Checks the validity of an incomming message prior to deserialization. Raises a ValueError if any of the checks fail. | def verify_raw_message(self, msg: bytes):
if not (MIN_MESSAGE_SIZE < len(msg) < MAX_MESSAGE_SIZE):
raise ValueError("Invalid message size!")
msg_type = get_message_type(msg) # yields a ValueError on invalid type
msg_sender = get_message_sender(msg) # yields a ValueError if sender ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def recvcheck(self):\n\n data = self.recv()\n if self.serializer == 'json' and data and isinstance(data, dict):\n if '@error' in data:\n exception = getattr(builtins, data['@error'])\n if (isinstance(exception, type) and\n issubclass(exc... | [
"0.61960053",
"0.61874247",
"0.613771",
"0.6075688",
"0.59505975",
"0.5941427",
"0.5927932",
"0.58881575",
"0.5753204",
"0.57190883",
"0.57021964",
"0.56871074",
"0.568275",
"0.5681627",
"0.5675577",
"0.565072",
"0.5648861",
"0.564648",
"0.55970114",
"0.5591246",
"0.55893433"... | 0.6513264 | 0 |
Checks if the given revealed secret can successfully be verified against the value the leader previously committed itself to. The check also fails if the leader previously did not send the ProposeMessage to this node. | def verify_revealed_secret(self, revealed_secret: Scalar):
r = self.prev_round_with_same_leader
if r:
dataset = self.datasets[r]
if dataset:
proof = dataset.proof
else:
proof = NODE_INFOS[self.leader].initial_proof
return proof is not ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def verify_secret(secret: str, known_hash: bytes, known_salt: bytes) -> bool:\n unknown_bytes = secret.encode(SECRET_ENCODING)\n unknown_hash = hash_secret_raw(unknown_bytes, known_salt, **CRYPTO_PARAMS)\n\n return unknown_hash == known_hash",
"def is_right_secret(self, secret):\n dct = []\n ... | [
"0.63848233",
"0.63117766",
"0.63070196",
"0.62667006",
"0.6163316",
"0.6157268",
"0.5983814",
"0.5667858",
"0.5612532",
"0.55915385",
"0.5587102",
"0.5521405",
"0.5490282",
"0.5435051",
"0.54261136",
"0.5425868",
"0.5363421",
"0.5352231",
"0.53487307",
"0.53454804",
"0.53385... | 0.84828514 | 0 |
Returns the current virtual time as continously increasing float. Before protocol start this value is negative. At the start of the 1st round this value is 1.0. At the middle of round 5 this value is ~5.5. At the end of round 5 this value is 5.99. | def virtual_time(self):
return (_time.time() - PROTOCOL_START_TIME) / ROUND_DURATION | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def virtual_round(self):\n return math.ceil(self.virtual_time())",
"def current_time(cls) -> float:",
"def time(self) -> float:\n return self.state.game_loop / 22.4 # / (1/1.4) * (1/16)",
"def get_time(self):\n return self.get_timed() / 10.0",
"def get_measured_current(self):\n ... | [
"0.7634846",
"0.65942997",
"0.64568603",
"0.6331034",
"0.6321079",
"0.62146425",
"0.6186211",
"0.6112976",
"0.6091038",
"0.6062856",
"0.6051767",
"0.60485196",
"0.6035505",
"0.60246044",
"0.6020776",
"0.6016315",
"0.60044426",
"0.6003315",
"0.59993505",
"0.59926534",
"0.59885... | 0.7629296 | 1 |
Return the most recent round number in which the current leader was previously leader. | def prev_round_with_same_leader(self):
for r in range(self.round - 1, 0, -1):
if self.leaders[r] == self.leader:
return r
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def latest_score(self):\r\n if not self.child_history:\r\n return None\r\n return self.score_for_attempt(-1)",
"def latest_score(self):\r\n if not self.child_history:\r\n return None\r\n return self.child_history[-1].get('score')",
"def get_current_turn(self):\... | [
"0.6638657",
"0.6398866",
"0.6312401",
"0.630607",
"0.62277234",
"0.61071503",
"0.61071503",
"0.6046409",
"0.60040575",
"0.59547776",
"0.59475803",
"0.5873872",
"0.58482575",
"0.58208615",
"0.5816444",
"0.58012736",
"0.5780201",
"0.5770921",
"0.57672983",
"0.57581395",
"0.575... | 0.7695777 | 0 |
Increments the internal round number and phase. Must be called at to start a new round, including the protocol start itself (round 0 > round 1). Also updates the internal times for round starts and ends to compute timeouts correctly. Extends rounds based lists by one None element. | def advance_round(self):
self._round += 1
self._phase = Phase.Propose
self._t_round_start += ROUND_DURATION
self._t_round_end = self._t_round_start + ROUND_DURATION
self._t_ack_phase_start = self._t_round_start + PROPOSE_PHASE_DURATION
self._t_vote_phase_start = self._t_a... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _increment_round_number():\n store.round += 1",
"def start_round(self, round_counter):\n cxnlib.CXNNetStartRound(self.handle, round_counter)",
"def _run_round(self):\n self.advance_round() # increment round number and update timeouts\n self.compute_leader()\n\n if self.is_le... | [
"0.63059986",
"0.6066291",
"0.58937764",
"0.5797738",
"0.5793691",
"0.57747275",
"0.5702283",
"0.56661105",
"0.55340683",
"0.5492743",
"0.54827094",
"0.54185575",
"0.5400686",
"0.53044605",
"0.52600724",
"0.5201231",
"0.5192579",
"0.5171257",
"0.5171201",
"0.51650596",
"0.515... | 0.706966 | 0 |
If a new phase is specified, the current phase is updated to match the given phase. Otherwise, the phase is updated to the next phase if the current timeout was exceeded. Return True if the phase was changed and False otherwise. | def update_phase(self, new_phase: Optional[Phase] = None):
if new_phase is None:
if self._phase != Phase.Vote and self.next_timeout() == 0:
self._phase = Phase(self._phase + 1)
self.logger.info(f"PHASE CHANGED, now in: round=%d, phase=%s", self.round, self.phase)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def advance_phase(self):\n self.game.resolve(self.phase)\n last_phase = self.phase\n self.phase = self.phase.next_phase()\n self.phase_end = self.get_phase_end(start=self.get_time())\n\n if not self.game.is_game_over():\n body = render_message(\n \"end_of_phase.html\",\n ... | [
"0.59533304",
"0.5585961",
"0.5572388",
"0.55578935",
"0.5491071",
"0.5429019",
"0.5380205",
"0.5364545",
"0.53519267",
"0.53190094",
"0.52565444",
"0.5220581",
"0.5201888",
"0.5193213",
"0.5187893",
"0.5159875",
"0.51500165",
"0.5144977",
"0.5130022",
"0.51095176",
"0.510223... | 0.794282 | 0 |
Return the round number the node is operating in according to the current virtual time. As long as the syncroncy assumption is fulfilled, virtual_round <= round is ensured. | def virtual_round(self):
return math.ceil(self.virtual_time()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_round() -> int:\n return store.round",
"def get_time_in_round() -> int:\n # FIXME - returning negative value for projectiles\n return store.round_time",
"def round_based_alien_limitation(self):\n if self.num_round < 5:\n return 1\n elif self.num_round < 10:\n ... | [
"0.63612664",
"0.61435306",
"0.59480464",
"0.5917682",
"0.5754174",
"0.5604368",
"0.55464804",
"0.5526831",
"0.5467947",
"0.544659",
"0.5443614",
"0.5379377",
"0.53379166",
"0.5329982",
"0.5305252",
"0.52633387",
"0.524337",
"0.5218792",
"0.51519173",
"0.51369035",
"0.5131849... | 0.7767477 | 0 |
Return the number of (fractional) seconds to wait until a change to the next protocol phase should happen. Typically used in the main message receive loop, to ensure progress when no messages are received. Returns at most config.MAX_TIMEOUT to allow for proper termination (keep alive tick). | def next_timeout(self):
if self.phase == Phase.Propose:
timeout = max(self._t_ack_phase_start - self.actual_time(), 0)
elif self.phase == Phase.Acknowledge:
timeout = max(self._t_vote_phase_start - self.actual_time(), 0)
else:
timeout = max(self._t_round_end -... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _probe_wait_time(self):\n r = self.probe_cycle_time / float(len(self.servers)) #self.probe_cycle_time=5\n r = max(.25, r) # Cap it at four per second\n return r",
"def get_timeout(self) -> int:",
"def ReceiveTimeout(self) -> int:",
"def ReceiveTimeout(self) -> int:",
"def... | [
"0.69436854",
"0.6625911",
"0.6053797",
"0.6053797",
"0.6023106",
"0.6016484",
"0.5993953",
"0.598985",
"0.59471756",
"0.5921672",
"0.58781904",
"0.58689594",
"0.5840007",
"0.58343875",
"0.58277625",
"0.58181554",
"0.58181554",
"0.579703",
"0.579703",
"0.579703",
"0.579703",
... | 0.7117425 | 0 |
Initialize publisher socket to broadcast messages to all other nodes. | def connect(self):
assert self.listening
assert not self.connected
ctx = zmq.Context.instance()
port = NODE_INFOS[self.ID].port
self._send_socket = ctx.socket(zmq.PUB)
self._send_socket.bind(f"tcp://*:{port}")
self.connected = True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def connect(self):\n self.socket.connect(f'tcp://{self.ip}:{self.port}')\n self.socket.send_string('PUB_PORT')\n self.pub_port = self.socket.recv_string()\n self.pub_socket = zmq.Socket(self.ctx, zmq.PUB)\n self.pub_socket.connect(f\"tcp://{self.ip}:{self.pub_port}\")",
"def _s... | [
"0.6296751",
"0.611952",
"0.6114131",
"0.60732424",
"0.5969431",
"0.5913646",
"0.58385533",
"0.57690626",
"0.5768459",
"0.57379735",
"0.56977034",
"0.5660937",
"0.5646916",
"0.5634144",
"0.5609033",
"0.5600255",
"0.5595455",
"0.5559843",
"0.553895",
"0.5534269",
"0.5522451",
... | 0.68648255 | 0 |
Returns the next message from the message queue without removing it. | def next_message(self) -> Optional[MessageQueueItem]:
if self._message_queue:
return self._message_queue[0]
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pop_next_message(self):\n messages = self._msq_queue.receive_messages(\n AttributeNames=['All'],\n MessageAttributeNames=['All'],\n MaxNumberOfMessages=1,\n VisibilityTimeout=self._vis_timeout,\n WaitTimeSeconds=self._wait_time,\n )\n ... | [
"0.79111135",
"0.7808662",
"0.76835024",
"0.7362662",
"0.73599327",
"0.7308949",
"0.7258198",
"0.7168249",
"0.71140194",
"0.7090979",
"0.70531934",
"0.70370066",
"0.69149953",
"0.69149953",
"0.6863086",
"0.68589836",
"0.6842349",
"0.6840149",
"0.68179965",
"0.6813469",
"0.677... | 0.87598956 | 0 |
Returns the next message from the message queue and removes it from the queue. | def dequeue_message(self) -> MessageQueueItem:
return heapq.heappop(self._message_queue) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def pop_message(self, tag):\n if self.new_messages_number(tag):\n return heapq.heappop(self._message_queue[tag])[-1]\n raise threadprop.NoMessageThreadError(\"no messages with tag '{}'\".format(tag))",
"def pop_next_message(self):\n messages = self._msq_queue.receive_messages(\n ... | [
"0.77722317",
"0.77062035",
"0.7474739",
"0.7438533",
"0.7427273",
"0.7333179",
"0.7270015",
"0.7189474",
"0.70708114",
"0.703778",
"0.70278907",
"0.69851446",
"0.6978719",
"0.6967639",
"0.69274807",
"0.69156086",
"0.6910222",
"0.69095707",
"0.68793523",
"0.6839691",
"0.68349... | 0.78775036 | 0 |
Removes the next message from the message queue. | def drop_message(self):
heapq.heappop(self._message_queue) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_message(self, msg):\n with self.message_lock:\n if msg not in self.messages:\n raise ValueError(f'{msg.msg_type} was not found in '\n 'the list of messages.')\n # Update processed message count if a read message was removed\n ... | [
"0.72836775",
"0.7197904",
"0.71951973",
"0.71194994",
"0.71052474",
"0.6965616",
"0.68810344",
"0.68048775",
"0.67426777",
"0.67140895",
"0.66316277",
"0.66257346",
"0.662173",
"0.6519371",
"0.6509101",
"0.6499589",
"0.64639556",
"0.645388",
"0.6434746",
"0.64345",
"0.643244... | 0.7618811 | 0 |
Wait for a new incomming message or a timeout, whichever comes first. If a message is received, preprocessing checks (i.e. msg size, type, ...) are performed. If a message is considered valid it is added to the message queue and True is returned. If a timeout occurres False is returned. If any of the message preprocess... | def receive_message(self, timeout: Optional[float] = None) -> bool:
self.logger.debug("waiting for incomming message (timeout=%f seconds)", timeout)
message_bytes = self.receive_bytes(timeout)
if not message_bytes:
self.logger.debug("message receive timeout")
return False... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _wait_for_message(self, expectedmessage, timeout):\r\n \r\n # Parse the first part (the message) from the expected reply. We need\r\n # to do this, because parts of some replies will contain parameters\r\n # that differ between replies.\r\n if '_' in expectedmessage:\r\n ... | [
"0.7456093",
"0.7194318",
"0.70266265",
"0.69645053",
"0.68434817",
"0.6316553",
"0.62526435",
"0.61950636",
"0.61666554",
"0.6161958",
"0.6146891",
"0.60891217",
"0.6062484",
"0.6056713",
"0.6056713",
"0.60501516",
"0.60343146",
"0.6014367",
"0.59845597",
"0.59507775",
"0.59... | 0.7233411 | 1 |
Plot GAIM climate and assim VTEC versus JASON using at least two 'gc' files. First file is usually climate file, and rest are assim files. | def plotVtecAndJasonTracks(gtcFiles, outFile=None, names=None, makeFigure=True, show=False, **options):
ensureItems(options, {'title': 'GAIM vs. JASON for '+gtcFiles[0], \
'xlabel': 'Geographic Latitude (deg)', 'ylabel': 'VTEC (TECU)'})
if 'show' in options:
show = True
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def app(ngr=100,c2a=1.6235):\n import matplotlib.pyplot as plt\n\n ## small donuts\n # plt.gcf().clf()\n grs = main(mu=0,ngrains=ngr,tilt_1=30.,sigma=15)\n plt.gcf().savefig('small_doughnut.pdf',bbox_inches='tight')\n plt.gcf().clf()\n f = gen_file(lab='sm_doughnut',ngr=ngr)\n write_gr(f,gr... | [
"0.59613496",
"0.5928554",
"0.584825",
"0.58290136",
"0.58263165",
"0.58152646",
"0.5796668",
"0.5795537",
"0.57904345",
"0.5739129",
"0.57288754",
"0.5657795",
"0.56574386",
"0.5634456",
"0.5631649",
"0.5621442",
"0.5612407",
"0.56111044",
"0.55997586",
"0.5593438",
"0.55730... | 0.6449078 | 0 |
CASSANDRA9748 CASSANDRA8084 Test that it's possible to connect over the broadcast_address when listen_on_broadcast_address=true and that GossipingPropertyFileSnitch reconnect via listen_address when prefer_local=true | def test_prefer_local_reconnect_on_listen_address(self):
NODE1_LISTEN_ADDRESS = '127.0.0.1'
NODE1_BROADCAST_ADDRESS = '127.0.0.3'
NODE2_LISTEN_ADDRESS = '127.0.0.2'
NODE2_BROADCAST_ADDRESS = '127.0.0.4'
STORAGE_PORT = 7000
cluster = self.cluster
cluster.popula... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_broadcast(self):\n if _debug: TestSimple._debug(\"test_broadcast\")\n\n # create a network\n tnet = TNetwork()\n\n # make a PDU from node 1 to node 2\n pdu_data = xtob('dead.beef')\n pdu = PDU(pdu_data, source=tnet.td.address, destination=LocalBroadcast())\n ... | [
"0.65779686",
"0.64892584",
"0.63216996",
"0.6206259",
"0.6157802",
"0.6157802",
"0.5982558",
"0.5940301",
"0.59292006",
"0.58701515",
"0.58506644",
"0.5844771",
"0.5790418",
"0.5749246",
"0.5738339",
"0.57269305",
"0.57269305",
"0.57084113",
"0.5681832",
"0.56433904",
"0.559... | 0.74002033 | 0 |
This function returns the residual amount on a receivable or payable account.move.line. By default, it returns an amount in the currency of this journal entry (maybe different of the company currency), but if you pass 'residual_in_company_currency' = True in the context then the returned amount will be in company curre... | def _amount_residual(self, cr, uid, ids, field_names, args, context=None):
res = {}
if context is None:
context = {}
cur_obj = self.pool.get('res.currency')
for move_line in self.browse(cr, uid, ids, context=context):
res[move_line.id] = {
'amount_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def recompute_billing_lines(self, cr, uid, ids, partner_id, journal_id, price, currency_id, date, context=None):\n def _remove_noise_in_o2m():\n \"\"\"if the line is partially reconciled, then we must pay attention to display it only once and\n in the good o2m.\n Thi... | [
"0.529292",
"0.5219197",
"0.52055126",
"0.51994324",
"0.5130958",
"0.5117739",
"0.5095714",
"0.50658065",
"0.50062007",
"0.4983113",
"0.49648607",
"0.49217787",
"0.4897736",
"0.48674244",
"0.48599845",
"0.48526254",
"0.48462662",
"0.48205847",
"0.48049423",
"0.47749168",
"0.4... | 0.7165496 | 0 |
Prepare the values given at the create() of account.analytic.line upon the validation of a journal item having an analytic account. This method is intended to be extended in other modules. | def _prepare_analytic_line(self, cr, uid, obj_line, context=None):
return {'name': obj_line.name,
'date': obj_line.date,
'account_id': obj_line.analytic_account_id.id,
'unit_amount': obj_line.quantity,
'product_id': obj_line.product_id and obj_line... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _prepare_invoice(self):\n self.ensure_one()\n journal_id = self.env['account.invoice'].default_get(['journal_id'])['journal_id']\n if not journal_id:\n raise UserError(_('Please define an accounting sales journal for this company.'))\n invoice_vals = {\n 'name'... | [
"0.6333295",
"0.61296386",
"0.60856193",
"0.59841675",
"0.5954299",
"0.5894288",
"0.58654183",
"0.5691361",
"0.56707895",
"0.565811",
"0.56062704",
"0.55693346",
"0.5564056",
"0.55583304",
"0.5537369",
"0.5501138",
"0.5485389",
"0.54587525",
"0.5409213",
"0.53910714",
"0.5322... | 0.68250525 | 0 |
Return journal based on the journal type | def _get_journal(self, cr, uid, context=None):
context = context or {}
if context.get('journal_id', False):
return context['journal_id']
journal_id = False
journal_pool = self.pool.get('account.journal')
if context.get('journal_type', False):
jids = journ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_journal(self):\n context = dict(self._context or {})\n type_inv = context.get('type', 'in_invoice')\n type2journal = {'out_invoice': 'src_sale',\n 'in_invoice': 'src_purchase'}\n journal_obj = self.env['account.journal']\n user = self.env['res.user... | [
"0.7473577",
"0.72819084",
"0.6733848",
"0.60112536",
"0.58675444",
"0.5785311",
"0.5770023",
"0.5768502",
"0.5768502",
"0.5696875",
"0.5619576",
"0.55207074",
"0.5518111",
"0.5447846",
"0.5432462",
"0.53505915",
"0.52632326",
"0.52632326",
"0.5225179",
"0.5146338",
"0.512722... | 0.73491955 | 1 |
modified brick mising model sigma_1 is the resistivity of the host material sigma_2 is the resistivity of the filling material percent_2 is the percentage of the filling material | def modified_brick(sigma_1, sigma_2, percent_2):
s1 = sigma_1
s2 = sigma_2
p1 = percent_2
n = 2.0 / 3
sigma_eff = s2 * (s2 * (p1 ** n - 1) - s1 * p1 ** n) / s1 * (p1 - p1 ** n) - s2 * (
p1 ** n - p1 - 1
)
sigma_eff = np.nan_to_num(sigma_eff)
return sigma_eff | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def modified_archies(sigma_1, sigma_2, percent_2, m=1.05):\n s1 = sigma_1\n s2 = sigma_2\n p2 = 1 - percent_2\n\n p = np.log(1 - p2 ** m) / np.log(1 - p2)\n\n sigma_eff = s1 * (1 - p2) ** p + s2 * p2 ** m\n\n return sigma_eff",
"def reg2():\n data2 = np.load(\"./data/measure4_1.npy\")[2:]\n\... | [
"0.59674364",
"0.5803159",
"0.5756769",
"0.5736154",
"0.5710244",
"0.5641309",
"0.56100285",
"0.55756146",
"0.5534095",
"0.55074966",
"0.54341006",
"0.5433233",
"0.5425668",
"0.5366121",
"0.53618926",
"0.5360086",
"0.5358348",
"0.5343291",
"0.53429514",
"0.5339476",
"0.532465... | 0.70891565 | 0 |
modified archies law sigma_1 is the resistivity of the host material sigma_2 is the resistivity of the filling material percent_2 is the percentage of the filling material | def modified_archies(sigma_1, sigma_2, percent_2, m=1.05):
s1 = sigma_1
s2 = sigma_2
p2 = 1 - percent_2
p = np.log(1 - p2 ** m) / np.log(1 - p2)
sigma_eff = s1 * (1 - p2) ** p + s2 * p2 ** m
return sigma_eff | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def modified_brick(sigma_1, sigma_2, percent_2):\n\n s1 = sigma_1\n s2 = sigma_2\n p1 = percent_2\n n = 2.0 / 3\n\n sigma_eff = s2 * (s2 * (p1 ** n - 1) - s1 * p1 ** n) / s1 * (p1 - p1 ** n) - s2 * (\n p1 ** n - p1 - 1\n )\n\n sigma_eff = np.nan_to_num(sigma_eff)\n\n return sigma_eff... | [
"0.6717472",
"0.5891842",
"0.58682793",
"0.58556384",
"0.57447743",
"0.57390624",
"0.56752676",
"0.56685185",
"0.5585946",
"0.55496764",
"0.5518233",
"0.54987943",
"0.54471964",
"0.5416098",
"0.5405844",
"0.53328085",
"0.5329378",
"0.5307954",
"0.52773523",
"0.5272315",
"0.52... | 0.69864863 | 0 |
hashinshtrickman lowe r bound sigma_1 is the resistivity of the host material sigma_2 is the resistivity of the filling material percent_2 is the percentage of the filling material | def hs_lower(sigma_1, sigma_2, percent_2):
s1 = sigma_1
s2 = sigma_2
p2 = 1 - percent_2
sigma_eff = s1 * (1 + (3 * p2 * (s2 - s1)) / (3 * s1 + (1 - p2) * (s2 - s1)))
return sigma_eff | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def modified_brick(sigma_1, sigma_2, percent_2):\n\n s1 = sigma_1\n s2 = sigma_2\n p1 = percent_2\n n = 2.0 / 3\n\n sigma_eff = s2 * (s2 * (p1 ** n - 1) - s1 * p1 ** n) / s1 * (p1 - p1 ** n) - s2 * (\n p1 ** n - p1 - 1\n )\n\n sigma_eff = np.nan_to_num(sigma_eff)\n\n return sigma_eff... | [
"0.6488292",
"0.61165637",
"0.59237045",
"0.586412",
"0.5857164",
"0.576152",
"0.5724699",
"0.5653779",
"0.56292176",
"0.5624477",
"0.5611664",
"0.5554874",
"0.5545601",
"0.55388236",
"0.55329514",
"0.55204356",
"0.55142736",
"0.5489799",
"0.5467704",
"0.5466371",
"0.54607433... | 0.64571023 | 1 |
Step through the motor sequence for nsteps at the specified speeds by talking to the I2C 8bit output device at the specified address. | def run(address, nsteps, speed1=6, speed2=6):
m1i = 0
m2i = 0
for i in range(nsteps):
m1i = _speed_action(i, speed1, m1i)
m2i = _speed_action(i, speed2, m2i)
byte_to_send = MOTORS[m1i][m2i]
try:
i2c.write(address, byte_to_send)
except:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, address: int = PCA9685_ADDRESS, i2c = None, \n frequency: int = 26500000, resolution: int = 4096,\n servo_frequency: int = 50, **kwargs):\n i2c = ensureI2C(i2c)\n self._servos = {}\n self._servo_frequency = servo_frequency\n self._frequ... | [
"0.5287434",
"0.5256194",
"0.5177722",
"0.5124063",
"0.5124063",
"0.51041585",
"0.5097198",
"0.5031252",
"0.50176036",
"0.5009186",
"0.49859858",
"0.49387726",
"0.4934197",
"0.48866022",
"0.48788404",
"0.48544276",
"0.48544276",
"0.48530456",
"0.4852825",
"0.4783781",
"0.4783... | 0.75915796 | 0 |
Return a name, value pair extracted from the data packet sent by Makecode Radio. | def interpret_packet_value_pair(data):
if data is None:
return None, None
packet_type = int.from_bytes(data[3:4], 'little')
name = value = None
if packet_type == 1:
name = str(data[17:], 'utf8')
value = float(ustruct.unpack('<i', data[12:16])[0])
elif packet_type == 5:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def parse_from_dref(self, packet):\n\t\tname = packet[9:].strip(b'\\x00').decode('utf-8')\n\t\traw_value = packet[5:9]\n\t\tvalue = struct.unpack('f', raw_value)[0]\n\t\treturn name, value",
"def getData(self):\n return struct.unpack(\"!Q\",self.data)[0]",
"def getData(self):\n return struct.unpa... | [
"0.65353966",
"0.6099811",
"0.6099811",
"0.5969333",
"0.5969333",
"0.5839855",
"0.58112675",
"0.5806836",
"0.5802945",
"0.57996464",
"0.5779412",
"0.57647896",
"0.57647896",
"0.57647896",
"0.5718457",
"0.5649855",
"0.56436163",
"0.5622148",
"0.5619399",
"0.561031",
"0.5562257... | 0.71622455 | 0 |
Process one nucleotide TCR sequence (any chain). | def processNT(organism, chain, nuc, quals):
ch = chain.lower()
quals = np.array(quals.split('.')).astype(int)
res = parse_unpaired_dna_sequence_blastn(organism, chain, nuc, info='',
nocleanup=False, hide_nucseq=False,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def convert_tcr(split_line, tcr_id):\n\n # Compile the necessary fields for output\n out_vals = {'sequence_id': tcr_id,\n 'sequence': split_line[params['sequence_index']], 'rev_comp': 'F',\n 'duplicate_count': split_line[params['abundance_index']]}\n\n # If the option has bee... | [
"0.6031489",
"0.5584631",
"0.53004116",
"0.52297455",
"0.51646274",
"0.5124967",
"0.5097716",
"0.50925404",
"0.50785017",
"0.50465524",
"0.5042807",
"0.49943596",
"0.49804884",
"0.49492407",
"0.49291",
"0.49264944",
"0.49025747",
"0.49019822",
"0.4899996",
"0.4895618",
"0.487... | 0.56105846 | 1 |
Finds unique clones among a paired sequence dataset. | def identifyClones(psDf, min_quality_for_singletons=20, average_clone_scores=[], none_score_for_averaging=9.6):
clonesDf = findClones(psDf,
min_quality_for_singletons=min_quality_for_singletons,
average_clone_scores=average_clone_scores,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def duplicates(self, tuples):\n b, k, l, r = tuples.size()\n\n primes = self.primes[:r]\n primes = primes[None, None, None, :].expand(b, k, l, r)\n unique = ((tuples+1) ** primes).prod(dim=3) # unique identifier for each tuple\n\n sorted, sort_idx = torch.sort(unique, dim=2)\n ... | [
"0.60576683",
"0.59921503",
"0.59548444",
"0.59344554",
"0.5900003",
"0.58835095",
"0.5868912",
"0.58574486",
"0.5827164",
"0.57431567",
"0.57222706",
"0.56882215",
"0.5662213",
"0.5647122",
"0.5627986",
"0.5599876",
"0.5553651",
"0.55454904",
"0.55207324",
"0.55196273",
"0.5... | 0.61568564 | 0 |
Create a dataset from a range of integers [0..n). | def range(n: int, *, parallelism: int = -1) -> Dataset[int]:
return read_datasource(
RangeDatasource(), parallelism=parallelism, n=n, block_format="list"
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def generate_dataset_uniform(n, a, b):\n return [(np.random.randint(a, b), 1) for _ in range(n)]",
"def generate_dataset():\n num_list = 10\n return [generate_list() for _ in range(num_list)]",
"def range_table(n: int, *, parallelism: int = -1) -> Dataset[ArrowRow]:\n return read_datasource(\n ... | [
"0.69052786",
"0.67425954",
"0.66565806",
"0.65352327",
"0.64392483",
"0.6378765",
"0.6371677",
"0.6314869",
"0.62608945",
"0.6258317",
"0.62324286",
"0.61703104",
"0.6136698",
"0.6132705",
"0.61193246",
"0.6104596",
"0.60916454",
"0.60897154",
"0.6072704",
"0.60214275",
"0.5... | 0.78668165 | 0 |
Create a tabular dataset from a range of integers [0..n). | def range_table(n: int, *, parallelism: int = -1) -> Dataset[ArrowRow]:
return read_datasource(
RangeDatasource(), parallelism=parallelism, n=n, block_format="arrow"
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_table(m, n):\n return np.array([[0] * n for _ in range(m)], dtype=float)",
"def make_table(m, n):\n return [[0] * n for _ in range(m)]",
"def range(n: int, *, parallelism: int = -1) -> Dataset[int]:\n return read_datasource(\n RangeDatasource(), parallelism=parallelism, n=n, block_form... | [
"0.7118987",
"0.7055491",
"0.6627258",
"0.6301194",
"0.62718916",
"0.6196273",
"0.6059686",
"0.605769",
"0.59853125",
"0.5955439",
"0.59521717",
"0.59082735",
"0.5888157",
"0.58156496",
"0.58119833",
"0.580484",
"0.5750245",
"0.5685949",
"0.56696886",
"0.5657227",
"0.56356335... | 0.72626185 | 0 |
Create a Tensor dataset from a range of integers [0..n). | def range_tensor(
n: int, *, shape: Tuple = (1,), parallelism: int = -1
) -> Dataset[ArrowRow]:
return read_datasource(
RangeDatasource(),
parallelism=parallelism,
n=n,
block_format="tensor",
tensor_shape=tuple(shape),
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def range(n: int, *, parallelism: int = -1) -> Dataset[int]:\n return read_datasource(\n RangeDatasource(), parallelism=parallelism, n=n, block_format=\"list\"\n )",
"def generate_dataset_uniform(n, a, b):\n return [(np.random.randint(a, b), 1) for _ in range(n)]",
"def generate_dataset():\n n... | [
"0.7215684",
"0.684556",
"0.67031056",
"0.6239486",
"0.62267065",
"0.61698556",
"0.6158186",
"0.6122921",
"0.61187315",
"0.6093927",
"0.60922456",
"0.6084687",
"0.6070186",
"0.6059963",
"0.6026061",
"0.60131866",
"0.5978774",
"0.59686565",
"0.5966816",
"0.59492105",
"0.593724... | 0.7142443 | 1 |
Read a dataset from a custom data source. | def read_datasource(
datasource: Datasource[T],
*,
parallelism: int = -1,
ray_remote_args: Dict[str, Any] = None,
**read_args,
) -> Dataset[T]:
ctx = DatasetContext.get_current()
if ray_remote_args is None:
ray_remote_args = {}
local_uri = False
paths = read_args.get("paths... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_dataset(dataset_name):\n url = METADATA[dataset_name][\"url\"]\n f = urlopen(url)\n data = _read_rows(f)\n f.close()\n return data",
"def DataReader(name, data_source=None, start=None, end=None,\n retry_count=3, pause=0.001, session=None, access_key=None):\n if data_sourc... | [
"0.6465696",
"0.63246596",
"0.63223606",
"0.6222079",
"0.61951244",
"0.6180791",
"0.6180791",
"0.6180791",
"0.6165846",
"0.6140465",
"0.6131076",
"0.61154026",
"0.60848093",
"0.6043491",
"0.600465",
"0.60002077",
"0.5996348",
"0.5958436",
"0.5943675",
"0.5933759",
"0.59263337... | 0.7017197 | 0 |
Create an Arrow dataset from MongoDB. The data to read from is specified via the ``uri``, ``database`` and ``collection`` of the MongoDB. The dataset is created from the results of executing ``pipeline`` against the ``collection``. If ``pipeline`` is None, the entire ``collection`` will be read. | def read_mongo(
uri: str,
database: str,
collection: str,
*,
pipeline: Optional[List[Dict]] = None,
schema: Optional["pymongoarrow.api.Schema"] = None,
parallelism: int = -1,
ray_remote_args: Dict[str, Any] = None,
**mongo_args,
) -> Dataset[ArrowRow]:
return read_datasource(
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getAggregateData(self, pipeline: t.Mapping[t.Text, t.Any],\n filter: t.Mapping[t.Text, t.Any] = {},\n ) -> DatasetData:\n session = self.session_maker()\n\n mongoquery = self._mongo_query(session).query(\n filter=filter,\n aggregate=pipeline,\n ).end()\n\n ... | [
"0.6034132",
"0.5559788",
"0.55280215",
"0.5342421",
"0.5231967",
"0.52295494",
"0.5168609",
"0.5137753",
"0.51302",
"0.511581",
"0.51003087",
"0.5092251",
"0.50884324",
"0.50646925",
"0.50045764",
"0.500052",
"0.49770147",
"0.4940992",
"0.49350905",
"0.4905728",
"0.48938805"... | 0.78244567 | 0 |
Create a dataset from a Dask DataFrame. | def from_dask(df: "dask.DataFrame") -> Dataset[ArrowRow]:
import dask
from ray.util.dask import ray_dask_get
partitions = df.to_delayed()
persisted_partitions = dask.persist(*partitions, scheduler=ray_dask_get)
import pandas
def to_ref(df):
if isinstance(df, pandas.DataFrame):
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_dataset(self, df, **kwargs):\n\t\treturn df",
"def to_dataset(df, batch_size=5):\n df = df.copy()\n labels = df.pop('Relevant')\n ds = tf.data.Dataset.from_tensor_slices((dict(df), labels))\n ds = ds.batch(batch_size)\n return ds",
"def from_dask(cls, dask_schema):\n return cls.from_pandas... | [
"0.7358074",
"0.71884704",
"0.7148657",
"0.7032926",
"0.67411435",
"0.6609532",
"0.6466937",
"0.6466937",
"0.6390665",
"0.63478494",
"0.6343732",
"0.6320492",
"0.6295609",
"0.6224059",
"0.62093985",
"0.61777514",
"0.6176935",
"0.61739504",
"0.61604214",
"0.615397",
"0.6104097... | 0.738469 | 0 |
Create a dataset from a MARS dataframe. | def from_mars(df: "mars.DataFrame") -> Dataset[ArrowRow]:
import mars.dataframe as md
return md.to_ray_dataset(df) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_dataset(self, df, **kwargs):\n\t\treturn df",
"def from_dataframe(cls, dataframe):\n return cls(dataframe)",
"def from_pandas(cls, df, data_cls):\n pass",
"def from_dataframe(cls, df, data_cls):\n pass",
"def from_pandas(cls, pandasFrame,timeSeriesCol,mainCategoryCol):\n ... | [
"0.6979988",
"0.69335115",
"0.66152024",
"0.643734",
"0.6371",
"0.61443305",
"0.6060658",
"0.596201",
"0.5952343",
"0.5886135",
"0.58827454",
"0.586776",
"0.5864657",
"0.5846291",
"0.5837472",
"0.58290774",
"0.58259636",
"0.5802777",
"0.5780569",
"0.5776847",
"0.57553375",
... | 0.733102 | 0 |
Create a dataset from a Modin dataframe. | def from_modin(df: "modin.DataFrame") -> Dataset[ArrowRow]:
from modin.distributed.dataframe.pandas.partitions import unwrap_partitions
parts = unwrap_partitions(df, axis=0)
return from_pandas_refs(parts) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_dataset(self, df, **kwargs):\n\t\treturn df",
"def from_dataframe(cls, dataframe):\n return cls(dataframe)",
"def from_pandas(cls, df, data_cls):\n pass",
"def create_dataframe():\r\n\r\n df = pd.read_csv('data/data.csv', header=0)\r\n return df",
"def from_dataframe(cls, df, d... | [
"0.7449036",
"0.6398872",
"0.63498116",
"0.61783284",
"0.61599034",
"0.61461693",
"0.61223394",
"0.6112605",
"0.6106977",
"0.6069312",
"0.5991231",
"0.59896815",
"0.59289813",
"0.59230125",
"0.58626014",
"0.5860832",
"0.58503693",
"0.58376694",
"0.58260405",
"0.5805859",
"0.5... | 0.7272815 | 1 |
Create a dataset from a list of Pandas dataframes. | def from_pandas(
dfs: Union["pandas.DataFrame", List["pandas.DataFrame"]]
) -> Dataset[ArrowRow]:
import pandas as pd
if isinstance(dfs, pd.DataFrame):
dfs = [dfs]
return from_pandas_refs([ray.put(df) for df in dfs]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def to_dataframe(dslist):\n from pytraj.utils import _import_pandas\n has_pandas, pd = _import_pandas()\n \n if not has_pandas:\n require(\"pandas\")\n\n if isinstance(dslist, (list, tuple, DataSetList)):\n my_dict = dict((d0.legend, list(d0.to_ndarray())) for d0 in dslist)\n else:\... | [
"0.7083464",
"0.68006945",
"0.6474429",
"0.64584476",
"0.6450354",
"0.6328892",
"0.61668",
"0.61495",
"0.6132779",
"0.61170745",
"0.6115301",
"0.61134356",
"0.60554993",
"0.60491776",
"0.60198253",
"0.60058683",
"0.593231",
"0.5930992",
"0.5908679",
"0.5893621",
"0.58868414",... | 0.70932466 | 0 |
Create a dataset from a list of Ray object references to Pandas dataframes. | def from_pandas_refs(
dfs: Union[ObjectRef["pandas.DataFrame"], List[ObjectRef["pandas.DataFrame"]]]
) -> Dataset[ArrowRow]:
if isinstance(dfs, ray.ObjectRef):
dfs = [dfs]
elif isinstance(dfs, list):
for df in dfs:
if not isinstance(df, ray.ObjectRef):
raise Value... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def from_pandas(\n dfs: Union[\"pandas.DataFrame\", List[\"pandas.DataFrame\"]]\n) -> Dataset[ArrowRow]:\n import pandas as pd\n\n if isinstance(dfs, pd.DataFrame):\n dfs = [dfs]\n return from_pandas_refs([ray.put(df) for df in dfs])",
"def from_numpy_refs(\n ndarrays: Union[ObjectRef[np.nd... | [
"0.718746",
"0.6614455",
"0.6192964",
"0.6108832",
"0.5993874",
"0.591883",
"0.58683336",
"0.5808829",
"0.57721496",
"0.5748721",
"0.5735934",
"0.57252276",
"0.5692856",
"0.56347847",
"0.56210566",
"0.56096196",
"0.5600356",
"0.557569",
"0.55643505",
"0.55369276",
"0.5530647"... | 0.7169262 | 1 |
Create a dataset from a list of NumPy ndarrays. | def from_numpy(ndarrays: Union[np.ndarray, List[np.ndarray]]) -> Dataset[ArrowRow]:
if isinstance(ndarrays, np.ndarray):
ndarrays = [ndarrays]
return from_numpy_refs([ray.put(ndarray) for ndarray in ndarrays]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def CreateDataset(all_arrays):\n dataset = Dataset()\n\n dataset._addData(all_arrays[0])\n dataset._addData(all_arrays[1])\n dataset._addData(all_arrays[3])\n dataset._addData(all_arrays[5])\n dataset._addData(all_arrays[6])\n dataset._addData(all_arrays[9])\n dataset._addData(all_arrays[8]... | [
"0.73530215",
"0.6588379",
"0.6378847",
"0.6375847",
"0.6340084",
"0.63386816",
"0.63354266",
"0.6312542",
"0.62362945",
"0.6206093",
"0.6190065",
"0.61899257",
"0.61268455",
"0.61268455",
"0.60350126",
"0.59286946",
"0.5926574",
"0.58916944",
"0.5879859",
"0.5868182",
"0.586... | 0.7541424 | 0 |
Create a dataset from a list of Arrow tables. | def from_arrow(
tables: Union["pyarrow.Table", bytes, List[Union["pyarrow.Table", bytes]]]
) -> Dataset[ArrowRow]:
import pyarrow as pa
if isinstance(tables, (pa.Table, bytes)):
tables = [tables]
return from_arrow_refs([ray.put(t) for t in tables]) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def from_arrow_refs(\n tables: Union[\n ObjectRef[Union[\"pyarrow.Table\", bytes]],\n List[ObjectRef[Union[\"pyarrow.Table\", bytes]]],\n ]\n) -> Dataset[ArrowRow]:\n if isinstance(tables, ray.ObjectRef):\n tables = [tables]\n\n get_metadata = cached_remote_fn(_get_metadata)\n m... | [
"0.72011745",
"0.6344774",
"0.62772125",
"0.59344965",
"0.5684852",
"0.56701493",
"0.5668168",
"0.5643385",
"0.55909485",
"0.557843",
"0.5575552",
"0.5565219",
"0.5548783",
"0.5548537",
"0.553044",
"0.5519854",
"0.5507606",
"0.54916775",
"0.5490204",
"0.5473039",
"0.5470697",... | 0.76491827 | 0 |
Create a dataset from a set of Arrow tables. | def from_arrow_refs(
tables: Union[
ObjectRef[Union["pyarrow.Table", bytes]],
List[ObjectRef[Union["pyarrow.Table", bytes]]],
]
) -> Dataset[ArrowRow]:
if isinstance(tables, ray.ObjectRef):
tables = [tables]
get_metadata = cached_remote_fn(_get_metadata)
metadata = ray.get([... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def from_arrow(\n tables: Union[\"pyarrow.Table\", bytes, List[Union[\"pyarrow.Table\", bytes]]]\n) -> Dataset[ArrowRow]:\n import pyarrow as pa\n\n if isinstance(tables, (pa.Table, bytes)):\n tables = [tables]\n return from_arrow_refs([ray.put(t) for t in tables])",
"def CreateDataset(all_arr... | [
"0.76289916",
"0.65527433",
"0.61841595",
"0.6051117",
"0.60478765",
"0.5917792",
"0.5859672",
"0.5843175",
"0.58364785",
"0.5778761",
"0.5750244",
"0.5688019",
"0.5680298",
"0.56751215",
"0.56386256",
"0.56350017",
"0.56252235",
"0.5625124",
"0.5615937",
"0.56129897",
"0.561... | 0.72027206 | 1 |
Create a dataset from a Spark dataframe. | def from_spark(
df: "pyspark.sql.DataFrame", *, parallelism: Optional[int] = None
) -> Dataset[ArrowRow]:
import raydp
return raydp.spark.spark_dataframe_to_ray_dataset(df, parallelism) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def from_pyspark(cls, df: 'pyspark.sql.DataFrame') -> 'PlainFrame':\n\n converter = ConverterFromPySpark(df)\n\n return converter(cls)",
"def make_dataset(self, df, **kwargs):\n\t\treturn df",
"def creat_data_frame(spark, file_path):\n df = spark.read \\\n .format(\"csv\") \\\n .... | [
"0.7055911",
"0.69652724",
"0.6917585",
"0.66052735",
"0.6590582",
"0.6451625",
"0.6405847",
"0.6296315",
"0.62781864",
"0.6275498",
"0.62342614",
"0.61837584",
"0.6171788",
"0.61299926",
"0.61091655",
"0.60425824",
"0.600258",
"0.59971154",
"0.5965709",
"0.59264064",
"0.5905... | 0.7773276 | 0 |
Create a dataset from a Hugging Face Datasets Dataset. This function is not parallelized, and is intended to be used with Hugging Face Datasets that are loaded into memory (as opposed to memorymapped). | def from_huggingface(
dataset: Union["datasets.Dataset", "datasets.DatasetDict"],
) -> Union[Dataset[ArrowRow], Dict[str, Dataset[ArrowRow]]]:
import datasets
def convert(ds: "datasets.Dataset") -> Dataset[ArrowRow]:
return from_arrow(ds.data.table)
if isinstance(dataset, datasets.DatasetDict)... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def from_hff(cls, hff_data, name=None, args=None):\n assert isinstance(hff_data, h5py.Dataset)\n obj = cls()\n [obj.append(_decode(_, u'utf-8')) for _ in hff_data]\n return obj",
"def from_hff(cls, hff_data, name=None, args=None):\n assert isinstance(hff_data, h5py.Dataset)\n ... | [
"0.60441357",
"0.60441357",
"0.60296017",
"0.60139734",
"0.5984552",
"0.59628016",
"0.5959609",
"0.5957469",
"0.5929263",
"0.59155",
"0.5904758",
"0.589037",
"0.5848701",
"0.58384186",
"0.582297",
"0.5816806",
"0.5760641",
"0.5759153",
"0.5756531",
"0.5735877",
"0.5719885",
... | 0.6471192 | 0 |
Create a dataset from a TensorFlow dataset. This function is inefficient. Use it to read small datasets or prototype. | def from_tf(
dataset: "tf.data.Dataset",
) -> Dataset: # noqa: E501
# FIXME: `as_numpy_iterator` errors if `dataset` contains ragged tensors.
return from_items(list(dataset.as_numpy_iterator())) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _create_dataset(batch_size):\n ds = collections.OrderedDict([('x', [[-1.0, -1.0], [1.0, 1.0], [1.0, 1.0]]),\n ('y', [[1.0], [1.0], [1.0]])])\n # Note: batching is needed here as it creates the required batch dimension.\n # The batch size can be re-set (by `unbatch()` first) in... | [
"0.7282069",
"0.7274765",
"0.7099198",
"0.7082656",
"0.70408505",
"0.70286113",
"0.7024231",
"0.6944935",
"0.69420475",
"0.69063264",
"0.6890119",
"0.68817264",
"0.6857036",
"0.68509847",
"0.68509847",
"0.68497187",
"0.683696",
"0.68225837",
"0.6791475",
"0.67904323",
"0.6787... | 0.7504643 | 0 |
Create a dataset from a Torch dataset. This function is inefficient. Use it to read small datasets or prototype. | def from_torch(
dataset: "torch.utils.data.Dataset",
) -> Dataset:
return from_items(list(dataset)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_dataset(opt):\n data_loader = CustomDatasetDataLoader(opt)\n dataset = data_loader.load_data()\n return dataset",
"def create_dataset(dataset_type, soruce, opts): \n\n p = PreProcessor(dataset_type, opts)\n\n # If we are NOT running \"implementation.py\", we read the data from file\n ... | [
"0.6940325",
"0.69113123",
"0.69102263",
"0.6868152",
"0.6646911",
"0.6627573",
"0.65698886",
"0.6531242",
"0.65226",
"0.6471262",
"0.6454252",
"0.6422976",
"0.6400077",
"0.63881147",
"0.6383834",
"0.63747567",
"0.6370634",
"0.63566804",
"0.63518524",
"0.6341975",
"0.6337354"... | 0.77745163 | 0 |
Round number of repeats based on depth multiplier. | def round_repeats(repeats):
return int(math.ceil(depth_coefficient * repeats)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _round_repeats(self, repeats):\n return int(math.ceil(self.depth_coefficient * repeats))",
"def _round_repeats(self, repeats, depth_coefficient):\n\n if not depth_coefficient:\n return repeats\n\n return int(math.ceil(depth_coefficient * repeats))",
"def round_repeats(repeats, depth_coeff... | [
"0.8876546",
"0.86348873",
"0.8589512",
"0.85847086",
"0.8439529",
"0.83897537",
"0.83897537",
"0.83897537",
"0.8308418",
"0.77939695",
"0.6887175",
"0.6887175",
"0.6861657",
"0.6199542",
"0.6199542",
"0.6029677",
"0.5980465",
"0.59490407",
"0.59474444",
"0.5848384",
"0.58335... | 0.87485105 | 1 |
use infomation from excel to calculate transmission rate of each parameter | def tran_rate_cal():
avg_result = {
"default": [0, 0, 0, 0],
"node_amount": [0, 0, 0, 0],
"tran_range": [0, 0, 0, 0],
"ttl": [0, 0, 0, 0]
}
inventory_path = ["result/TranRate_default.xls", "result/TranRate_node.xls", "result/TranRate_tranrange.xls",\
"result/TranRate_tt... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def calculateDataRate(self):\n pass",
"def x_rate(self):\n values = self._interpolate_table(\"x\", derivative_order=1)\n # values += self._corrections(('ortho_eop', iers.ortho_eop, 0, 1e-6),\n # ('pmsdnut2', iers.pmsdnut2, 0, 1e-6))\n return values",
... | [
"0.63834226",
"0.57567555",
"0.56934655",
"0.5659466",
"0.5659466",
"0.56232417",
"0.5579109",
"0.55477005",
"0.5540278",
"0.55178225",
"0.5508646",
"0.5508117",
"0.5507188",
"0.54946375",
"0.54725456",
"0.5470746",
"0.54564255",
"0.5449148",
"0.54449",
"0.54405284",
"0.53936... | 0.6187337 | 1 |
Extract page images and region descriptions (type and coordinates) from the workspace. Open and deserialize PAGE input files and their respective images, then iterate over the element hierarchy down to the region level. Get all regions with their types (region element class), subtypes () and coordinates relative to the... | def process(self):
LOG = getLogger('processor.ExtractPages')
assert_file_grp_cardinality(self.input_file_grp, 1)
file_groups = self.output_file_grp.split(',')
if len(file_groups) > 3:
raise Exception("at most 3 output file grps allowed (raw, [binarized, [mask]] image)")
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process(self):\n level = self.parameter['level-of-operation']\n assert_file_grp_cardinality(self.input_file_grp, 1)\n assert_file_grp_cardinality(self.output_file_grp, 1)\n\n for (n, input_file) in enumerate(self.input_files):\n self.logger.info(\"INPUT FILE %i / %s\", n,... | [
"0.6240344",
"0.5477238",
"0.5443689",
"0.5365213",
"0.53253525",
"0.5262132",
"0.5212361",
"0.5199541",
"0.5190341",
"0.518026",
"0.51269823",
"0.51269823",
"0.5120302",
"0.5038665",
"0.5038035",
"0.50176233",
"0.49897826",
"0.4987465",
"0.49827957",
"0.49776888",
"0.4977385... | 0.6773539 | 0 |
List all supported countries incl. their abbreviation. | def list_supported_countries():
return [name for name, obj in
inspect.getmembers(holidays.countries, inspect.isclass)] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_countries():\n print('-c, -C [country]\\\n \\n [country]=\\\n \\n AR\\t: Argentina\\\n \\n AT\\t: Austria\\\n \\n BR\\t: Brazil\\\n \\n BY\\t: Belarus\\\n \\n CA\\t: Canda\\\n \\n DE\\t: Germany\\\n \\n FR\\t: Franc... | [
"0.7511494",
"0.72535145",
"0.7052958",
"0.6978256",
"0.6691851",
"0.66047174",
"0.6590827",
"0.65553176",
"0.652452",
"0.65244263",
"0.65244263",
"0.6329242",
"0.6327819",
"0.63269407",
"0.63204235",
"0.63095444",
"0.6202448",
"0.61192524",
"0.6110544",
"0.60948986",
"0.6088... | 0.7560731 | 0 |
returns the gregian date of of a of the given gregorian calendar yyyy year with Hijari Month & Day works only if hijriconverter library is installed, otherwise a warning is raised that this holiday is missing. hijriconverter requires Python >= 3.6 | def get_gre_date(year, Hmonth, Hday):
try:
from hijri_converter import convert
except ImportError:
import warnings
def warning_on_one_line(message, category, filename, lineno,
file=None, line=None):
return filename + ': ' + str(message) + '\n'... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def diwali(gregorian_year):\n return hindu_lunar_holiday(8, 1, gregorian_year)",
"def gregorian_date(year, julian_day):\n result = datetime.date(year, 1, 1)\n result += datetime.timedelta(days=julian_day - 1)\n return result",
"def AstroGDate2JDate(year, month, day):\n \n if month > 2:\n ... | [
"0.6640387",
"0.663638",
"0.6570559",
"0.6400787",
"0.627295",
"0.61860746",
"0.6030212",
"0.59143287",
"0.59135425",
"0.5871908",
"0.5868574",
"0.58485085",
"0.58340734",
"0.57977015",
"0.5784534",
"0.5699011",
"0.56817824",
"0.5644804",
"0.56405455",
"0.56310695",
"0.561729... | 0.7589246 | 0 |
IFieldWidget factory for DateTimeWidget. | def DateTimeFieldWidget(field, request):
return z3c.form.widget.FieldWidget(field, DateTimeWidget(request)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def TimeFieldWidget(field, request):\n return FieldWidget(field, TimeWidget(request))",
"def create_widget(self, parent, tree):\n return QTimeEdit(parent)",
"def __init__(self, label=None, auto_now=False, default_now=False, **kw):\r\n super(DateTime, self).__init__(label=label, **kw)\r\n ... | [
"0.6756735",
"0.6401246",
"0.59684926",
"0.5850191",
"0.5801212",
"0.5639257",
"0.5417162",
"0.53845227",
"0.53807914",
"0.53639007",
"0.5361664",
"0.5350406",
"0.5320731",
"0.5316257",
"0.52530336",
"0.52522534",
"0.5116196",
"0.51137656",
"0.5099057",
"0.50864375",
"0.50864... | 0.81256235 | 0 |
Convert edge features in shape (num_edges, 6) to vertex features in shape (num_vertices, 3). | def get_vertex_features(mesh: Mesh, features: tf.Tensor):
assert features_valid(mesh, features)
assert features.shape[1] == 6
# Reshape features into the following shape:
# (num_edges, num_vertices_per_edge = 2, dimensions_per_vertex = 3)
edge_features = tf.reshape(features, (-1, 2, 3))
# Now,... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def naive_get_vertex_features(mesh: Mesh, features: tf.Tensor):\n assert features_valid(mesh, features)\n assert features.shape[1] == 6\n\n # Create a list of features for each vertex.\n vertex_features = [[] for _ in range(mesh.vertices.shape[0])]\n for edge_key in range(features.shape[0]):\n ... | [
"0.60077816",
"0.5883677",
"0.5637103",
"0.55797905",
"0.55570096",
"0.55314726",
"0.5512168",
"0.55112827",
"0.54677236",
"0.5248659",
"0.5239427",
"0.52219266",
"0.5213783",
"0.5209585",
"0.519664",
"0.519664",
"0.51912075",
"0.5191109",
"0.51885426",
"0.51885426",
"0.51622... | 0.65134853 | 0 |
This is a naive version of get_vertex_features used for testing. | def naive_get_vertex_features(mesh: Mesh, features: tf.Tensor):
assert features_valid(mesh, features)
assert features.shape[1] == 6
# Create a list of features for each vertex.
vertex_features = [[] for _ in range(mesh.vertices.shape[0])]
for edge_key in range(features.shape[0]):
left_verte... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_vertex_features(mesh: Mesh, features: tf.Tensor):\n assert features_valid(mesh, features)\n assert features.shape[1] == 6\n\n # Reshape features into the following shape:\n # (num_edges, num_vertices_per_edge = 2, dimensions_per_vertex = 3)\n edge_features = tf.reshape(features, (-1, 2, 3))\... | [
"0.69760925",
"0.61674917",
"0.6073074",
"0.6017452",
"0.60167944",
"0.59950835",
"0.5928972",
"0.5911403",
"0.5841912",
"0.5814852",
"0.5804287",
"0.5778445",
"0.57368195",
"0.57343954",
"0.5722504",
"0.5712735",
"0.56789404",
"0.56608117",
"0.5656523",
"0.5642769",
"0.56304... | 0.7164583 | 0 |
Changes the username of a DjangoDev. | def change_username(self, name):
self.username = name | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_username(self, value):\n self.username = value",
"def setName(self, newName):\n self.__username = newName",
"def update_username(self, old_username, new_username):\n raise NotImplementedError()",
"def set_username(old_name, new_name):\n if not validate_username(new_name):\n ... | [
"0.70550954",
"0.69109625",
"0.67627853",
"0.6732764",
"0.6687207",
"0.66782",
"0.6615209",
"0.64098835",
"0.6344115",
"0.6300827",
"0.62013185",
"0.6157272",
"0.6107142",
"0.6097507",
"0.6082731",
"0.60745627",
"0.60423666",
"0.6019578",
"0.6009145",
"0.5981343",
"0.5972355"... | 0.7677855 | 0 |
Returns a list of all blog posts made | def get_posts(self):
return self.blog_posts.all() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_all_posts(self):\n cur = self.conn.cursor()\n\n query = 'SELECT blog.blog_id as id, blog.title as title, ' \\\n 'blog.subtitle as subtitle, ' \\\n 'blog.content as content, blog.date as date, ' \\\n 'author.name as author ' \\\n 'FR... | [
"0.7986396",
"0.7916092",
"0.7622036",
"0.7458175",
"0.7382099",
"0.73804796",
"0.7358619",
"0.7352812",
"0.72435147",
"0.7171367",
"0.7117209",
"0.7114211",
"0.704716",
"0.70316935",
"0.70120746",
"0.7006345",
"0.698528",
"0.6972948",
"0.69642323",
"0.6945211",
"0.692806",
... | 0.8164236 | 0 |
Custom Hueristic 2 Avaliable Move Ratio This hueristic prefer state that diffrence between avaliable moves of 2 players is greatest. The end game state of choice is that opponent's move (opp_moves) is 0 ratio of own_moves to opp_moves is inf. On the other hand, ratio will be 0 aka. we lose. | def custom_score_2(game, player):
# get avaliable moves for each player
own_moves = len(game.get_legal_moves(player))
opp_moves = len(game.get_legal_moves(game.get_opponent(player)))
# shortcut to definite state:
# 1. my agent win -> return very high score
if opp_moves == 0:
re... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def custom_score_2(game, player):\n if game.is_loser(player):\n return float(\"-inf\")\n if game.is_winner(player):\n return float(\"inf\")\n\n # Aim to maximise your own available moves vs the opponent (Factor 2)\n\n opponent = game.get_opponent(player)\n return float(len(game.get_leg... | [
"0.6969146",
"0.64040613",
"0.6337338",
"0.6311604",
"0.6286668",
"0.62673473",
"0.6242176",
"0.62160647",
"0.61978966",
"0.6148411",
"0.61277914",
"0.6061867",
"0.6051929",
"0.60510355",
"0.6050401",
"0.5991467",
"0.5981397",
"0.59808594",
"0.59598213",
"0.5958712",
"0.59515... | 0.6957185 | 1 |
Implements an iterable article PID list cotaining docs already sent to wos. sent_wos = True | def sent_to_wos(self, code_title=None):
fltr = {'sent_wos': 'True'}
if code_title:
fltr.update({'code_title': code_title})
documents = []
total = 0
for document in self._articles_coll.find(fltr, {'code': 1}):
total += 1
documents.append([doc... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fetch_docs(udocIDs):\n docs = {}\n for udocID in udocIDs:\n docs[udocID] = map(lambda x:x['sent'], db['sents'].find({'udocID': udocID}))\n for i, (udocID, sentlst) in enumerate(sorted(docs.items(), key=lambda x:x[0])):\n with open('post-'+str(i)+'.txt', 'w') as fw:\n fw.write(... | [
"0.5759032",
"0.5757237",
"0.5635691",
"0.56166947",
"0.5549683",
"0.5537424",
"0.55034274",
"0.5486859",
"0.54360557",
"0.5426847",
"0.54192376",
"0.5295758",
"0.5240209",
"0.5236919",
"0.5217502",
"0.520669",
"0.5204777",
"0.5171954",
"0.5125901",
"0.5118083",
"0.5112463",
... | 0.62330204 | 0 |
Method to get compute service. | def _get_compute_service(self):
service_account_credentials = self._get_credentials(
self.auth['json_file'],
self.compute_scopes)
# Authenticate using service account.
if service_account_credentials is None:
Console.error('Credentials are required.')
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute_api(self):\n path = self.compute.path = '/'\n res = self.compute.call('', 'GET', data='', \n token=self.manager.identity.token)\n self.logger.debug('Get openstack compute services: %s' % truncate(res))\n self.compute.path = path\n return... | [
"0.7883765",
"0.6941773",
"0.6774908",
"0.6767354",
"0.67189574",
"0.65214187",
"0.65168047",
"0.62702537",
"0.62702537",
"0.6194902",
"0.61309576",
"0.6110916",
"0.60997164",
"0.60317063",
"0.6022719",
"0.60045475",
"0.5996135",
"0.59774256",
"0.5961565",
"0.5953596",
"0.594... | 0.81270444 | 0 |
suspends the node with the given name | def suspend(self, name=None):
raise NotImplementedError | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def suspend(self, name=None):\n # UNTESTED\n server = self.cloudman.get_server(name)['id']\n r = self.cloudman.compute.suspend_server(server)\n\n return r\n\n \"\"\"\n raise NotImplementedError\n\n #\n # BUG THIS CODE DOES NOT WORK\n #\n nodes =... | [
"0.6972618",
"0.5939623",
"0.57357794",
"0.5690328",
"0.5601709",
"0.5572462",
"0.5508997",
"0.5485503",
"0.5382925",
"0.5315153",
"0.531125",
"0.5305027",
"0.5303234",
"0.52831846",
"0.5260677",
"0.525503",
"0.5166036",
"0.5147776",
"0.5077395",
"0.5065606",
"0.5056241",
"... | 0.7316579 | 0 |
resume the named node | def resume(self, name=None):
raise NotImplementedError | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def resume(self):\n\t\tpass",
"def resume(self):\n pass",
"def resume(self):\n pass",
"def resume(self):\n pass",
"def resume(self, name=None):\n server = self.cloudman.get_server(name)['id']\n r = self.cloudman.compute.resume_server(server)\n\n return r",
"def e... | [
"0.6669292",
"0.6599097",
"0.6599097",
"0.6599097",
"0.6325046",
"0.6315988",
"0.6307187",
"0.62824976",
"0.62824976",
"0.62357867",
"0.607537",
"0.60554075",
"0.60115844",
"0.5882792",
"0.5853385",
"0.57943976",
"0.5770834",
"0.57563317",
"0.5712445",
"0.5696074",
"0.5679642... | 0.7433429 | 0 |
sets the metadata for the server | def set_server_metadata(self, name, **metadata):
raise NotImplementedError | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setUp(self):\n super(ServerMetadataTest, self).setUp()\n self.meta = {'meta_key_1': 'meta_value_1',\n 'meta_key_2': 'meta_value_2'}\n self.servers_client.set_server_metadata(self.server.id, self.meta)",
"def set_server_metadata(self, name, **metadata):\n # VERB... | [
"0.8001114",
"0.7996493",
"0.7629841",
"0.74588615",
"0.7242395",
"0.7206426",
"0.7206426",
"0.71188545",
"0.71188545",
"0.7095241",
"0.70713186",
"0.70713186",
"0.70713186",
"0.70713186",
"0.70713186",
"0.70713186",
"0.70713186",
"0.704847",
"0.6731147",
"0.6657243",
"0.6603... | 0.81189495 | 0 |
gets the metadata for the server | def get_server_metadata(self, name):
raise NotImplementedError | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def metadata(self, server_id):\n\n server = self.compute.servers.get(server_id)\n\n if server.tenant_id not in Scope.projects():\n pecan.abort(403, 'unauthorized access a resource outside of your domain')\n\n # Required by Fog, but oddly not in novaclient.v2.servers\n return ... | [
"0.77513814",
"0.7428368",
"0.73522073",
"0.73225397",
"0.71864694",
"0.70514494",
"0.7049469",
"0.7036733",
"0.69580853",
"0.69121975",
"0.68675256",
"0.6847166",
"0.68437904",
"0.68289846",
"0.6828778",
"0.682185",
"0.6817243",
"0.6800407",
"0.67967075",
"0.6775665",
"0.676... | 0.8075407 | 0 |
deletes the key with the given name | def key_delete(self, name=None):
raise NotImplementedError | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove(self, key_name: str):\n pass",
"def delete(self, key):",
"def key_delete(self, name=None):\n\n cloud = self.cloud\n Console.msg(f\"delete the key: {name} -> {cloud}\")\n r = self.cloudman.delete_keypair(name)\n\n return r",
"def delete(self, key):\n pass",... | [
"0.7936263",
"0.7883737",
"0.7550867",
"0.74700725",
"0.74700725",
"0.7366061",
"0.7348318",
"0.7316608",
"0.72970927",
"0.72145027",
"0.7207017",
"0.72053176",
"0.7194768",
"0.7178714",
"0.7160523",
"0.714863",
"0.71445876",
"0.7090821",
"0.70595086",
"0.7034436",
"0.7031271... | 0.8348747 | 0 |
adds a public ip to the named vm | def attach_public_ip(self, name=None, ip=None):
raise NotImplementedError | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_virtualip(self, vip):\n return self.manager.add_virtualip(self, vip)",
"def _set_static_ip(name, session, vm_):\n ipv4_cidr = \"\"\n ipv4_gw = \"\"\n if \"ipv4_gw\" in vm_.keys():\n log.debug(\"ipv4_gw is found in keys\")\n ipv4_gw = vm_[\"ipv4_gw\"]\n if \"ipv4_cidr\" in... | [
"0.72822183",
"0.71772736",
"0.6942156",
"0.67908",
"0.6691078",
"0.6653082",
"0.6541217",
"0.6515282",
"0.62146676",
"0.61995417",
"0.6178747",
"0.6171909",
"0.6152558",
"0.6138848",
"0.60932493",
"0.6092606",
"0.6091926",
"0.606167",
"0.6059371",
"0.60232085",
"0.60013014",... | 0.73824364 | 0 |
Deletes the ip address | def delete_public_ip(self, ip=None):
raise NotImplementedError | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def delete(self, ip): # pylint: disable=invalid-name\n return self.request(\"DELETE\", ip)",
"def delete_virtualip(self, vip):\n return vip.delete()",
"def delete_ip(ip):\n sql = sqlite3.connect('data.db')\n cursor = sql.cursor()\n\n # Deleting single record now\n sql_delete_query = ... | [
"0.80220795",
"0.7433687",
"0.736022",
"0.7224909",
"0.7221889",
"0.7190891",
"0.7143261",
"0.7139014",
"0.6977782",
"0.68272954",
"0.67321694",
"0.6725609",
"0.6713316",
"0.66727453",
"0.66567415",
"0.66511804",
"0.66409653",
"0.6637119",
"0.66339606",
"0.658773",
"0.6562882... | 0.7828117 | 1 |
Lists the public ip addresses. | def list_public_ips(self, available=False):
raise NotImplementedError | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def public_ip_addresses(self) -> pulumi.Output[Sequence[str]]:\n return pulumi.get(self, \"public_ip_addresses\")",
"def public_ip_addresses(self) -> Optional[pulumi.Input[Sequence[pulumi.Input[str]]]]:\n return pulumi.get(self, \"public_ip_addresses\")",
"def get_ips(self, instances):\n p... | [
"0.8043028",
"0.7694534",
"0.74953663",
"0.72698253",
"0.7171025",
"0.69528675",
"0.67700285",
"0.6631726",
"0.65569127",
"0.6542633",
"0.65263474",
"0.65187705",
"0.64694786",
"0.64559686",
"0.6404039",
"0.6391972",
"0.6389926",
"0.63838625",
"0.6370865",
"0.6299024",
"0.628... | 0.80117214 | 1 |
Creates a new public IP address to use | def create_public_ip(self):
raise NotImplementedError | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def new_ip(address):\n return IPy.IP(address)",
"def new_ip(address):\n return ipaddress.IPv4Address(address)",
"def get_new_address(self):\n key = generate_key(generate_random())\n address = pubtoaddr(key[\"public\"])\n self.keyring.append(key)\n write_keys(self.path,... | [
"0.71581805",
"0.7059292",
"0.66827583",
"0.6659382",
"0.643292",
"0.6378128",
"0.63720804",
"0.635525",
"0.634524",
"0.6336229",
"0.63313055",
"0.6324348",
"0.63112247",
"0.6299061",
"0.6279214",
"0.6265997",
"0.6207343",
"0.6194526",
"0.6188847",
"0.6121375",
"0.61018807",
... | 0.852303 | 0 |
List the named security group | def list_secgroups(self, name=None): | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_secgroups(self, name=None):\n groups = self.cloudman.network.security_groups()\n\n # print (\"TTTTT\")\n # for g in groups:\n # pprint(g)\n\n if name is not None:\n for entry in groups:\n\n if entry['name'] == name:\n grou... | [
"0.8219804",
"0.7228481",
"0.71501523",
"0.71501523",
"0.7068843",
"0.70688295",
"0.69058067",
"0.6899201",
"0.6831084",
"0.68143445",
"0.6773217",
"0.6773217",
"0.6773217",
"0.6773217",
"0.6773217",
"0.6752336",
"0.67276174",
"0.66714066",
"0.66400886",
"0.66281724",
"0.6599... | 0.85960776 | 0 |
wait till the given VM can be logged into | def wait(self,
vm=None,
interval=None,
timeout=None):
raise NotImplementedError
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def wait_vm_operation(self, params: dict) -> Tuple[\"Status\", dict]:",
"def wait_for_reachable(self, userid, timeout=CONF.guest.reachable_timeout):\n def _check_reachable():\n if not self.is_reachable(userid):\n raise exception.SDKRetryException()\n zvmutils.looping_call(... | [
"0.6183586",
"0.5995159",
"0.5913249",
"0.58899987",
"0.5885938",
"0.58617157",
"0.5805502",
"0.5803961",
"0.57789487",
"0.5772219",
"0.5768958",
"0.5755898",
"0.57291335",
"0.5724518",
"0.57129514",
"0.56149065",
"0.55982107",
"0.55978006",
"0.558356",
"0.5569643",
"0.556113... | 0.62261075 | 0 |
Given a json file downloaded from google, copies the content into the cloudmesh yaml file, while overwriting or creating a new compute provider | def json_to_yaml(cls, name, filename="~/.cloudmesh/security/google.json"):
path = path_expand(filename)
# Open and load the JSON file.
with open(path, "r") as file:
d = json.load(file)
# Get the project id and client email.
project_id = d["project_id"]
clien... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _StageMetadata(json_metadata, storage_service, staged_file: str):\n # Write computed metadata to object storage.\n temp_run_dir = temp_dir.GetRunDirPath()\n local_file = os.path.join(temp_run_dir, os.path.basename(staged_file))\n with open(local_file, 'w') as f:\n json.dump(json_metadata, f)\n storage_... | [
"0.55638355",
"0.53303784",
"0.5243267",
"0.52389425",
"0.5216308",
"0.5209414",
"0.5167432",
"0.5089143",
"0.50759137",
"0.5071788",
"0.50646424",
"0.5050458",
"0.50458425",
"0.5034967",
"0.50346255",
"0.5031685",
"0.49979848",
"0.49920565",
"0.49904394",
"0.49648455",
"0.49... | 0.7002891 | 0 |
Handler function. Returns a 200 OK Response, with no additional headers or response body. | def simple_handler(request):
logger.debug('')
return Response(200, 'OK', {}, '') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def root():\n return Response(\"It's alive!\", status=200)",
"def _return_200(response_body):\n return {\n \"statusCode\": 200,\n \"body\": response_body\n }",
"def ping_response():\n\n return Response(\"ok\", status=200)",
"def echo_handler(request):\n logger.debug('')\n ... | [
"0.69751835",
"0.6943527",
"0.68465",
"0.6775545",
"0.6652168",
"0.66183394",
"0.66183394",
"0.6607427",
"0.654512",
"0.6512772",
"0.6497046",
"0.64908737",
"0.6484081",
"0.6430808",
"0.64087015",
"0.64087015",
"0.63962305",
"0.63962305",
"0.6386626",
"0.6354971",
"0.63491315... | 0.7763849 | 0 |
Handler function. Returns a 200 OK Response, with the same headers and body as the request. | def echo_handler(request):
logger.debug('')
return Response(200, 'OK', request.headers, request.body) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def simple_handler(request):\n logger.debug('')\n return Response(200, 'OK', {}, '')",
"def respond(self):\n req = self.req\n req_uri = bton(req.uri)\n if req_uri == '/':\n req.status = b'200 OK'\n req.ensure_headers_sent()\n req.write(b'Hello world!')\... | [
"0.74266696",
"0.6732569",
"0.6692408",
"0.66385794",
"0.657537",
"0.6538705",
"0.65188336",
"0.65132636",
"0.6480159",
"0.64719045",
"0.6466069",
"0.64507717",
"0.6389785",
"0.6374382",
"0.6343593",
"0.6343282",
"0.6287823",
"0.6287823",
"0.62692755",
"0.6251329",
"0.6247499... | 0.7142119 | 1 |
Factory function. Returns a handler that delays the request for the specified number of seconds, forwards it to the next handler function, and returns that handler function's Response. | def delay(timeout, next_handler=simple_handler):
def delayer(request):
logger.debug('delaying for %i seconds' % timeout)
time.sleep(timeout)
return next_handler(request)
delayer.__doc__ = ('Delay for %s seconds, then forward the Request to the '
'next handler' % s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sleep(self, *args, seconds):\n return deferLater(reactor, seconds, lambda: None)",
"def sleep(self, *args, seconds):\n return deferLater(reactor, seconds, lambda: None)",
"def repeater(seconds):\n return lambda function: TwistedRepeater(function, seconds)",
"def throttle(f):\n def wrapper... | [
"0.64438695",
"0.64438695",
"0.63550466",
"0.62731755",
"0.6106973",
"0.6098928",
"0.6054269",
"0.5985643",
"0.58477014",
"0.58406466",
"0.58406466",
"0.58406466",
"0.57366884",
"0.57180077",
"0.5657726",
"0.56576216",
"0.56409246",
"0.5586975",
"0.55125177",
"0.5495542",
"0.... | 0.76904124 | 0 |
Add a DeproxyEndpoint object to this Deproxy object's list of endpoints, giving it the specified server address, and then return the endpoint. | def add_endpoint(self, port, name=None, hostname=None,
default_handler=None, ssl_enable=False,
ssl_certs=None):
logger.debug('')
endpoint = None
with self._endpoint_lock:
if name is None:
name = 'Endpoint-%i' % len(self._endp... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_endpoint(self, endpoint):\n self._endpoints.append(endpoint)",
"def add_endpoint(self, endpoint):\n exists = self.get_endpoint(endpoint)\n if not exists:\n self.endpoints.append((endpoint, now()))",
"def add_endpoint(self, endpoint, **kwargs):\n endpoint.arguments... | [
"0.69222105",
"0.66806054",
"0.651612",
"0.65105253",
"0.60707116",
"0.5865334",
"0.5854492",
"0.56875104",
"0.5570992",
"0.557044",
"0.5478335",
"0.5405185",
"0.536587",
"0.5338989",
"0.5309399",
"0.5180917",
"0.5134349",
"0.5079733",
"0.5077364",
"0.50701183",
"0.50597095",... | 0.7130575 | 0 |
Remove a DeproxyEndpoint from the list of endpoints. Returns True if the endpoint was removed, or False if the endpoint was not in the list. This method should normally not be called by user code. Instead, call the endpoint's shutdown method. | def _remove_endpoint(self, endpoint):
logger.debug('')
with self._endpoint_lock:
count = len(self._endpoints)
self._endpoints = [e for e in self._endpoints if e != endpoint]
return (count != len(self._endpoints)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def removeEndpoint(self, endpoint):\n # If endpoint not recognized, returns False, else True\n self.__lockobj.acquire()\n retval = False\n if endpoint in self.__endpoints.keys():\n del self.__endpoints[endpoint]\n retval = True\n self.__lockobj.acquire()\n ... | [
"0.7861624",
"0.673121",
"0.61311984",
"0.6026717",
"0.60209435",
"0.59862417",
"0.59574944",
"0.5927816",
"0.5895637",
"0.5808006",
"0.5769851",
"0.575731",
"0.56803304",
"0.5642779",
"0.5585065",
"0.55566144",
"0.55546165",
"0.5542212",
"0.5529159",
"0.5454134",
"0.54436666... | 0.75198144 | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.