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 |
|---|---|---|---|---|---|---|
Show supplied command line parameters | def show_parameters(args):
logging.basicConfig(format='%(message)s', level=args.logging)
logging.info('\n#{0}'.format('-'*60))
logging.info('BUILD CONFIG : {0}'.format(args.config))
logging.info('BUNDLE FILE : {0}'.format(args.bfile)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print_args():\r\n args = \", \".join(sys.argv)\r\n print(\"pfArgs: \" + args)",
"def main():\n\tparser = setup_argument_parser()\n\targuments = parser.parse_args()\n\tto_print = arguments.to_print\n\techo(to_print)",
"def print_usage():\n print 'USAGE: %s [options]' % os.path.abspath(__file__)\... | [
"0.72994787",
"0.70214033",
"0.6917337",
"0.6849881",
"0.6849881",
"0.6849881",
"0.6849881",
"0.6642024",
"0.66258633",
"0.6605503",
"0.6598556",
"0.65788394",
"0.65658325",
"0.6563445",
"0.65632486",
"0.65605456",
"0.65329534",
"0.6525422",
"0.65092707",
"0.6507383",
"0.6496... | 0.77256334 | 0 |
Show the bundle definitions that have been read from the JSON file. | def show_bundle_definitions(bundleDefinitions):
logging.info("\n#{0}\nBundle defintions read from JSON file".format('-'*60))
for bundle in sorted(bundleDefinitions):
logging.info(" BUNDLE : {0}".format(bundle))
for item in bundleDefinitions[bundle]['not_supported_configs']:
logg... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_bundle_definitions(bundleFile):\n\n try:\n with open(bundleFile) as fh_json:\n bundleDefinitions = json.load(fh_json, object_pairs_hook=check_for_duplicate_key)\n\n except IOError as err:\n logging.error(\"Failed to access JSON file: '{0}'\".format(bundleFile))\n sys.e... | [
"0.6989743",
"0.60708797",
"0.5993263",
"0.5617851",
"0.56166613",
"0.5570709",
"0.5503199",
"0.5469521",
"0.538671",
"0.52929497",
"0.5265156",
"0.52113706",
"0.5182566",
"0.51816195",
"0.51578945",
"0.5110362",
"0.5108369",
"0.5098516",
"0.5092119",
"0.50598633",
"0.5047749... | 0.8043274 | 0 |
Show the list of the bundles needed for the specified build configuration. The bundles should be generated in the order shown. | def show_bundles_for_config(buildConfig, bundlesForConfig):
logging.info("\n#{0}\nOrdered list of bundles to be generated for {1}".format('-'*60, buildConfig))
logging.info(' {0}\n'.format( '\n '.join(str(x) for x in bundlesForConfig))) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_bundles():\n response = houston.get(\"/zipline/bundles\")\n\n houston.raise_for_status_with_json(response)\n return response.json()",
"def determine_bundles_for_config(buildConfig, bundleDefinitions):\n\n logging.info(\"\\n#{0}\\nDetermining bundle order for {1}\".format('-'*60, buildConfig)... | [
"0.6998439",
"0.6123112",
"0.6039796",
"0.598613",
"0.59619206",
"0.5935597",
"0.5926793",
"0.5903993",
"0.58582425",
"0.58277285",
"0.5818082",
"0.57594585",
"0.55930454",
"0.5567453",
"0.55650634",
"0.5500252",
"0.54493994",
"0.5446825",
"0.54432946",
"0.54328114",
"0.54263... | 0.83626467 | 0 |
Validate word against the Oxford | def validate_word(word: str) -> bool:
if word:
url = f'{OXFORD_DICT_BASE_URL}{OXFORD_DICT_ENTRY_URL}/en-us/{word.lower()}'
headers = {
'app_id': settings.OXFORD_APP_ID,
'app_key': settings.OXFORD_API_KEY,
}
logger.info(f'validating {word} against oxford dicti... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def validate(self, word):\n\n return self.valid_word(word)",
"def validate(self, word):\n\n return self.valid_word(word)",
"def checkWord(self, word):\n\t\treturn self.root.checkString(u' ' + word);",
"def _validate_word(self, word):\n return type(word) == type('a') and set(self._letters... | [
"0.7154809",
"0.7154809",
"0.70644045",
"0.7039645",
"0.6993988",
"0.69451195",
"0.69159997",
"0.6735668",
"0.6720593",
"0.6714118",
"0.66661435",
"0.66358995",
"0.65806365",
"0.6578512",
"0.6574474",
"0.6533447",
"0.6501707",
"0.6491227",
"0.645163",
"0.6435742",
"0.64315283... | 0.7239461 | 0 |
Initialize the board with a 2D list of random characters Return 2D list and game id | def init_board(user_name:str) -> Tuple[List[List[str]], str]:
game = Game.objects.create(user_name=user_name)
board = []
for _ in range(GAME_BOARD_SIZE):
row = []
for _ in range(GAME_BOARD_SIZE):
random_letter = random.choice(string.ascii_uppercase)
row.append(rando... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_board():\n board = ['#', 1, 2, 3, 4, 5, 6, 7, 8, 9]\n return board",
"def init():\n for i in range(COLS):\n for j in range(ROWS):\n BOARD[i][j] = int(random(2))",
"def __makeRandomLetterGrid(self):\n for x in range(self.numRows):\n row = []\n for y in range(self... | [
"0.7314985",
"0.7192099",
"0.6878203",
"0.6796816",
"0.67921454",
"0.6748575",
"0.67141336",
"0.6695857",
"0.66832465",
"0.665502",
"0.66280633",
"0.662005",
"0.660073",
"0.65887046",
"0.6581255",
"0.6545052",
"0.65072316",
"0.6490323",
"0.6474044",
"0.64622366",
"0.64331925"... | 0.73489505 | 0 |
Creates a dataframe with the location and the category + subcategory information | def counter(data, location):
df = pd.DataFrame(data)
df.columns = ['Path']
df['Category'] = df['Sub-Category'] = ''
# Split in categories and sub-categories
for i in range(len(df)):
tmp_categories = df['Path'][i].split(location)[1].split("\\")[1:3]
df['Category'].iat[i] = tmp_categ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self):\n self.file_name = 'data.csv'\n # Column of interest\n self._col = ['product_name', 'url', 'quantity', 'packaging']\n self._col += ['brands', 'origins', 'countries_fr', 'allergens']\n self._col += ['traces_fr', 'additives_n', 'additives_fr']\n self._col... | [
"0.59107196",
"0.5841233",
"0.581339",
"0.57519704",
"0.5745347",
"0.57205385",
"0.56050104",
"0.55876654",
"0.55352265",
"0.5487894",
"0.5419102",
"0.5407245",
"0.5394587",
"0.5353546",
"0.53176284",
"0.5277364",
"0.5231057",
"0.5224481",
"0.5205005",
"0.5196254",
"0.5184209... | 0.670813 | 0 |
Compute shapes based on pyramid levels. | def compute_shape(image_shape, pyramid_levels):
image_shape = np.array(image_shape[:2])
image_shapes = [(image_shape + 2 ** x - 1) // (2 ** x) for x in pyramid_levels]
return image_shapes | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def render_pyramid(pyr, levels):\n positionLst = []\n finalLst = []\n if levels > len(pyr):\n print(\"error. number of levels to display is more than max_levels\")\n width = 0\n\n for i in range(levels):\n # streching each layer\n pyr[i] = strech_helper(pyr[i])\n width +=... | [
"0.6240694",
"0.6118037",
"0.5876699",
"0.5858496",
"0.58484614",
"0.57944995",
"0.57806325",
"0.575052",
"0.5684079",
"0.5684079",
"0.559415",
"0.54742503",
"0.5452048",
"0.5427259",
"0.5427259",
"0.5412499",
"0.5389447",
"0.5383719",
"0.5383669",
"0.5335233",
"0.5319706",
... | 0.7420897 | 0 |
Split mass_mailing and mass_mailing_sms activities in systray by removing the single mailing.mailing activity represented and doing a new query to split them by mailing_type. | def systray_get_activities(self):
activities = super(Users, self).systray_get_activities()
for activity in activities:
if activity.get('model') == 'mailing.mailing':
activities.remove(activity)
query = """SELECT m.mailing_type, count(*), act.res_model as model... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def split_sms(self) -> GetResponseType:\n return self._connection.get('sms/split-sms')",
"def split_to_cycles(self, msg_type_filter = None, separation = 0.5):\n\n ids = {msg_type.get_message_id() for msg_type in msg_type_filter}\n\n if not len(ids):\n class _Everything:\n ... | [
"0.46555245",
"0.4531723",
"0.4504555",
"0.43491852",
"0.4308207",
"0.4266434",
"0.42539883",
"0.42331496",
"0.42087987",
"0.41847062",
"0.416127",
"0.41584274",
"0.41557625",
"0.41434288",
"0.4132268",
"0.4116761",
"0.4114674",
"0.41036007",
"0.4100826",
"0.4099363",
"0.4081... | 0.604209 | 0 |
load a batch of test images for inference | def load_test_batch(self, image_sequence_names):
def _parse_test_img(img_path):
with tf.device('/cpu:0'):
img_buffer = tf.read_file(img_path)
image_decoded = tf.image.decode_jpeg(img_buffer)
return image_decoded
image_dataset = tf.data.Dataset.fro... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_images(input_dir, batch_shape):\n images = np.zeros(batch_shape)\n filenames = []\n idx = 0\n batch_size = batch_shape[0]\n # all_files = tf.gfile.Glob(os.path.join(input_dir, '*.png'))\n # test_files = [all_files[idx] for x in np.random.choice(len(all_files), 200, replace=False)]\n # for filepath ... | [
"0.7638802",
"0.7516106",
"0.7403828",
"0.73432887",
"0.72056586",
"0.70791805",
"0.7076064",
"0.7050845",
"0.7048674",
"0.70428956",
"0.70274216",
"0.7000175",
"0.6981634",
"0.6973878",
"0.6957183",
"0.6935096",
"0.6931672",
"0.6926189",
"0.69239885",
"0.69223124",
"0.690414... | 0.7716155 | 0 |
Compile the url for Historical Data from Yahoo Finance for Jan 1, 2020 to March 31, 2021. Frequency set to Daily. | def get_url(ticker: str, period: int) -> str:
periods = {
1: 'period1=1577836800&period2=1585699200', # First Quarter 2020
2: 'period1=1585699200&period2=1593561600', # Second Quarter 2020
3: 'period1=1593561600&period2=1601510400', # Third Quarter 2020
4: 'period1=1601510400&pe... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stock_url(stock_symbol, day=None, month=None, year=None):\r\n\r\n page = \"http://ichart.finance.yahoo.com/table.csv?\"\r\n page = ''.join([page, 's=', stock_symbol])\r\n now = datetime.datetime.now()\r\n if day == None:\r\n day = now.day\r\n if month == None:\r\n month = now.month... | [
"0.6633096",
"0.65309125",
"0.6507803",
"0.6503107",
"0.64991486",
"0.6361005",
"0.6279037",
"0.6273346",
"0.62572783",
"0.6208939",
"0.6183131",
"0.6144482",
"0.61408323",
"0.610295",
"0.6049862",
"0.601408",
"0.59232163",
"0.58711356",
"0.5855296",
"0.5816339",
"0.57807374"... | 0.6903547 | 0 |
When passed raw HTML from Yahoo Finance, will convert the table of Historical Stock data into a list of dictionary objects for each day of data. | def convert_html_to_list(html: str) -> List[dict]:
soup = BeautifulSoup(html, 'html.parser')
if not (tbodies := soup.find_all('tbody')): # Find the Table
raise ValueError('No tables found in the HTML passed!')
index_column_map = {
1: 'date',
2: 'open',
3: 'high',
4:... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def scrape_data():\n soup = get_page_source_code(\"https://www.tradingview.com/markets/stocks-usa/market-movers-active/\")\n stock_table = soup.select(\".tv-data-table__tbody tr\")\n \n stock_data = []\n\n for data in stock_table:\n stock_name = data.find(\"a\").get_text(strip=True)\n ... | [
"0.6858391",
"0.68429345",
"0.6632754",
"0.63661",
"0.634068",
"0.61382437",
"0.613481",
"0.61267716",
"0.61046755",
"0.60685205",
"0.60589904",
"0.6056857",
"0.60510856",
"0.60114765",
"0.5996936",
"0.59883475",
"0.5977929",
"0.59638447",
"0.5952866",
"0.593743",
"0.5917761"... | 0.7321175 | 0 |
Will paginate through all 5 quarters of interest for the provided ticker, combining all of the records into a single list and saving that list as a JSON file saved at the provided path. | def create_json_for_ticker(ticker: str, path: str) -> bool:
stock_data = [] # Will have to paginate over the data, one financial quarter at a time
for period in range(1, 6): # 5 financial quarter period
response = requests.get(get_url(ticker, period))
stock_data += convert_html_to_list(str(res... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_json(ticker_symbol):\n s_data = Stock.objects.filter(ticker=ticker_symbol).order_by('-date')\n json_file = []\n for data in s_data:\n json_obj = StockSerializer(data).data\n json_file.append(json_obj)\n return json_file",
"def download_all_stocks():\n ... | [
"0.57403725",
"0.53482336",
"0.5338412",
"0.53366387",
"0.53185207",
"0.52370477",
"0.5045187",
"0.49885362",
"0.49838585",
"0.49380884",
"0.4935918",
"0.48569182",
"0.4816543",
"0.48016262",
"0.47973043",
"0.4794625",
"0.47821856",
"0.47803226",
"0.47605705",
"0.47324476",
"... | 0.70600617 | 0 |
Get the connected signs | def signs(self) -> Dict[str, HanoverSign]:
return self._signs | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _connectivity(self):\n if not self.is_connected():\n raise gfapy.ArgumentError(\n \"Cannot compute the connectivity of {}\\n\".format(self)+\n \"Segment is not connected to a GFA instance\")\n return self._connectivity_symbols(len(self.dovetails_L),\n ... | [
"0.5988669",
"0.59284824",
"0.57749724",
"0.56526196",
"0.56343955",
"0.56310093",
"0.55913466",
"0.55886096",
"0.55867475",
"0.55490667",
"0.55300474",
"0.55252635",
"0.5496374",
"0.5487526",
"0.5479785",
"0.54754657",
"0.5448505",
"0.5398998",
"0.5371763",
"0.5349526",
"0.5... | 0.60209274 | 0 |
Broadcasts the test signs start command All signs connected to the serial port will loop the test sequence. | def start_test_signs(self):
self._write(TestSignsStartPacket()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_start_test(self):\n self.protocol.startTest(self.test)\n self.assertEqual(self.io.getvalue(), compat._b(\n \"test: %s\\n\" % self.test.id()))",
"def SendStartScanSignal(self):\n pass",
"def begin_sending_packets():\n monitoru = main_monitoring.MainMonitoring()\n m... | [
"0.6231464",
"0.61730486",
"0.5988609",
"0.5960701",
"0.59175575",
"0.58512706",
"0.58059675",
"0.57590073",
"0.575668",
"0.5731106",
"0.5710256",
"0.56982476",
"0.56892633",
"0.5673425",
"0.5649762",
"0.5647067",
"0.5632346",
"0.56058913",
"0.5593129",
"0.5585903",
"0.557240... | 0.6874082 | 0 |
Broadcasts the test signs stop command All signs connected to the serial port will stop the test sequence. | def stop_test_signs(self):
self._write(TestSignsStopPacket()) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def stop(self):\n\n command = [0x00, 0x00, 0x00, 0x00]\n self.send_command(command)",
"def stop(self):\r\n self.inst.write(':STOP')",
"def stop():\n message = \"STOP:0\" + '\\n'\n sock.sendall(message)\n return",
"def stop(self):\n\n print(\"Status sent: stop\")\n\n ... | [
"0.7133479",
"0.6787533",
"0.6761563",
"0.6628596",
"0.65733594",
"0.6556142",
"0.63732076",
"0.63683236",
"0.63430876",
"0.62860405",
"0.6267058",
"0.6251952",
"0.62277514",
"0.6218978",
"0.61927193",
"0.6174102",
"0.61632395",
"0.61619365",
"0.61550176",
"0.61550176",
"0.61... | 0.7698604 | 0 |
Sends an image to a sign to be displayed | def draw_image(self, image_data: np.array, sign_name: str = None):
if sign_name is None:
if len(self.signs) == 1:
# Get the only sign
sign = next(iter(self.signs.values()))
else:
raise ValueError(
"Cannot determine which... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def send_img(msg, user_name):\n msg['Text'](msg['FileName'])\n itchat.send_image(msg['FileName'], user_name)",
"def send_image(image: PIL.Image.Image):\n import base64\n import io\n\n image = image.convert(\"RGB\")\n buffer = io.BytesIO()\n image.save(buffer, format=\"PNG\")\n image_b64 =... | [
"0.68497753",
"0.64805",
"0.63634735",
"0.62521076",
"0.62521076",
"0.6189917",
"0.6179018",
"0.6167498",
"0.6127294",
"0.6105862",
"0.6097711",
"0.6064862",
"0.6022038",
"0.59483916",
"0.5934693",
"0.5810689",
"0.58097464",
"0.5804869",
"0.5804201",
"0.57872885",
"0.5747261"... | 0.69355583 | 0 |
Make a call to the API | def _call(self, method, url, params):
if not url.startswith('http'):
url = self.root + url
headers = self._auth_headers()
headers['Content-Type'] = 'application/json'
r = self._session.request(method, url,
headers=headers,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def api_call():\n\tresponse = requests.get(URL_API)\n\treturn response",
"def _do_call(cls, method, url, params={}):\n headers = {\n 'User-Agent': 'py-retain/' + __version__,\n 'content-type': 'application/json'\n }\n try:\n r = cls.request_map[method.lower()... | [
"0.7561549",
"0.7262479",
"0.7217644",
"0.71784467",
"0.71442205",
"0.7074366",
"0.70250636",
"0.70250636",
"0.692503",
"0.6904695",
"0.68952674",
"0.68806225",
"0.68405724",
"0.6833163",
"0.681605",
"0.67899567",
"0.6780549",
"0.67628896",
"0.67379415",
"0.6725369",
"0.67138... | 0.74701285 | 1 |
Print the distribution of labels in a data frame | def show_label_distribution(data):
stats = [0, 0, 0, 0]
for index, row in data.iterrows():
if int(row['label']) == 0:
stats[0] = stats[0] + 1
elif int(row['label']) == 1:
stats[1] = stats[1] + 1
elif int(row['label']) == 2:
stats[2] = stats[2] + 1
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def print_info(df):\n\n # Data statistics\n # Number of total samples\n print('There are {n_samples} samples in total.'.format(n_samples=len(list(df.index.get_level_values(0).unique()))))\n\n # Count the different types of labels\n unique = df['label'].unique()\n count = []\n\n for label in un... | [
"0.6952506",
"0.6819506",
"0.64931095",
"0.64425844",
"0.6305837",
"0.62718546",
"0.6270794",
"0.61792946",
"0.6159525",
"0.61379826",
"0.61144364",
"0.6106488",
"0.6027057",
"0.59839725",
"0.59660524",
"0.59130096",
"0.5909932",
"0.5856374",
"0.5759965",
"0.57563275",
"0.575... | 0.76450306 | 0 |
Read Cartesian grid HDF5 file. | def read_grid(filename_grid, dim=2, slc=None):
## get shape and slice
fid = h5py.File(filename_grid, 'r')
if dim==2:
varnames = ['x', 'y', 'ep']
if slc is None: slc = np.s_[0,:,:]
if dim==3:
varnames = ['x', 'y', 'z', 'ep']
if slc is None: slc = np.s_[:,:,:]
dset = f... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _readHDF5(self):\n\n h5 = h5py.File(self.pointInputFile, 'r')\n self.coords = h5['geometry/vertices'][:]\n self.stations = h5['stations'][:]\n self.dispRaw = h5['vertex_fields/displacement'][self.timeStep,:,:]\n h5.close()\n\n self.numStations = self.coords.shape[0]\n\n return",
"def rea... | [
"0.7039812",
"0.68652445",
"0.63912624",
"0.6375906",
"0.63526535",
"0.63147867",
"0.6265056",
"0.61917305",
"0.61373085",
"0.61373085",
"0.6124641",
"0.60619587",
"0.6030196",
"0.59503937",
"0.5920003",
"0.59158546",
"0.5909038",
"0.5875686",
"0.5875686",
"0.58699346",
"0.58... | 0.69720143 | 1 |
Configures logging. Commandline arguments ``v`` and ``q`` set both the code log file and what streams to stdout. The ``v`` flag turns on debug level, and ``q`` sets it to info level. The math logger will always be set to debug level. | def logging_config(args):
# Any handlers from a basicConfig, which we will reconfigure.
for handler in logging.root.handlers:
logging.root.removeHandler(handler)
level = logging.INFO - 10 * args.verbose + 10 * args.quiet
# The command-line logging level specifies what goes to stderr.
root_h... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setup_logging(level_name='INFO', debug_queries=None, stream=sys.stdout,\n format='%(asctime)s %(levelname)s %(message)s',\n loggers=['mqe', 'mqeweb', 'mqeapi', 'mqetables']):\n if debug_queries is not None:\n from mqe import mqeconfig\n mqeconfig.DEBUG_QUERIES... | [
"0.6579105",
"0.65698",
"0.6522916",
"0.6516832",
"0.6437229",
"0.6395055",
"0.62888694",
"0.6284832",
"0.6279969",
"0.6275125",
"0.6262051",
"0.62609464",
"0.62458163",
"0.62311167",
"0.62102",
"0.62023115",
"0.61890405",
"0.61836797",
"0.6182649",
"0.6177687",
"0.6166397",
... | 0.670149 | 0 |
Test the vacuum state is correct. | def test_vacuum_state(self, hbar, tol):
modes = 3
means, cov = symplectic.vacuum_state(modes, hbar=hbar)
assert np.allclose(means, np.zeros([2 * modes]), atol=tol, rtol=0)
assert np.allclose(cov, np.identity(2 * modes) * hbar / 2, atol=tol, rtol=0) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_vacuum(self, tol=0.0, **kwargs):\n return self.circuit.is_vacuum(tol)",
"def is_vacuum(self, tol=0.0, **kwargs):\n return self.circuit.is_vacuum(tol)",
"def test_vacuum(self):\n # This will upgrade Dummy2 in-place; Dummy had its own upgrade.\n upgradeExplicitOid(self.store)\n... | [
"0.70713776",
"0.70713776",
"0.6724152",
"0.65383327",
"0.6275313",
"0.6262108",
"0.61836994",
"0.6052069",
"0.59776473",
"0.5968448",
"0.59251255",
"0.59051126",
"0.5897805",
"0.5884018",
"0.58561885",
"0.5839658",
"0.583105",
"0.5811577",
"0.58029264",
"0.57977176",
"0.5774... | 0.73807794 | 0 |
Test that the squeeze operator is symplectic | def test_symplectic(self, tol):
r = 0.543
phi = 0.123
S = symplectic.squeezing(r, phi)
# the symplectic matrix
O = np.array([[0, 1], [-1, 0]])
assert np.allclose(S @ O @ S.T, O, atol=tol, rtol=0) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_singularization(self):\n self.failUnless(singularize(\"axes\") == \"axis\")\n self.failUnless(singularize(\":\") == \":\")",
"def test_is_symplectic():\n theta = np.pi / 6\n r = np.arcsinh(1.0)\n phi = np.pi / 8\n S = symplectic.rotation(theta)\n assert symplectic.is_symplec... | [
"0.64427245",
"0.6233597",
"0.60628706",
"0.5975643",
"0.59538513",
"0.5937224",
"0.57462484",
"0.57060236",
"0.5700574",
"0.56484276",
"0.5571448",
"0.5444138",
"0.5443832",
"0.5424793",
"0.5419034",
"0.53868157",
"0.5342502",
"0.52900535",
"0.5286869",
"0.5266703",
"0.51946... | 0.6306285 | 1 |
Test the squeezing symplectic transform. | def test_squeezing(self, tol):
r = 0.543
phi = 0.123
S = symplectic.squeezing(r, phi)
out = S @ S.T
# apply to an identity covariance matrix
rotation = np.array(
[[np.cos(phi / 2), -np.sin(phi / 2)], [np.sin(phi / 2), np.cos(phi / 2)]]
)
expec... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_symplectic(self, tol):\n r = 0.543\n phi = 0.123\n S = symplectic.squeezing(r, phi)\n\n # the symplectic matrix\n O = np.array([[0, 1], [-1, 0]])\n\n assert np.allclose(S @ O @ S.T, O, atol=tol, rtol=0)",
"def test_squeezing_no_phi_array(self, tol):\n r =... | [
"0.732495",
"0.7014014",
"0.66260445",
"0.65929484",
"0.62812924",
"0.6050254",
"0.597708",
"0.56100684",
"0.56086886",
"0.55395865",
"0.54980934",
"0.5486338",
"0.5479237",
"0.5468921",
"0.5436581",
"0.5407536",
"0.5389658",
"0.5380142",
"0.5379945",
"0.5350596",
"0.53356093... | 0.71258855 | 1 |
Test the squeezing symplectic transform without specifying phi | def test_squeezing_no_phi(self, tol):
r = 0.543
phi = 0.0
S = symplectic.squeezing(r)
out = S @ S.T
# apply to an identity covariance matrix
rotation = np.array(
[[np.cos(phi / 2), -np.sin(phi / 2)], [np.sin(phi / 2), np.cos(phi / 2)]]
)
expec... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_squeezing_no_phi_array(self, tol):\n r = np.random.randn(6)\n phi = np.zeros_like(r)\n\n S = symplectic.squeezing(r)\n S_phi = symplectic.squeezing(r, phi)\n\n assert np.allclose(S, S_phi, atol=tol, rtol=0)",
"def test_symplectic(self, tol):\n r = 0.543\n ... | [
"0.79999155",
"0.789621",
"0.76069957",
"0.7025861",
"0.69747615",
"0.65962255",
"0.58864063",
"0.5794227",
"0.57742554",
"0.57558644",
"0.57503843",
"0.5727884",
"0.5605262",
"0.55961466",
"0.55768186",
"0.5461069",
"0.5450417",
"0.54491484",
"0.5447036",
"0.54448444",
"0.54... | 0.7928133 | 1 |
Test multimode version gives symplectic matrix | def test_symplectic_multimode(self, tol):
r = [0.543] * 4
phi = [0.123] * 4
S = symplectic.squeezing(r, phi)
# the symplectic matrix
O = symplectic.sympmat(4)
assert np.allclose(S @ O @ S.T, O, atol=tol, rtol=0) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_extend_single_mode_symplectic(self, N, matrix_type, tol):\n\n modes = np.random.choice(N, N - 1, replace=False)\n S = random_symplectic(1)\n S = matrix_type(S, dtype=S.dtype)\n\n res = symplectic.expand(S, modes=modes, N=N)\n\n if issparse(S):\n S = S.toarray(... | [
"0.6315886",
"0.6281806",
"0.61313885",
"0.6100252",
"0.6021782",
"0.5976386",
"0.59364206",
"0.5888411",
"0.58746153",
"0.5765146",
"0.57079464",
"0.5697238",
"0.56629276",
"0.5608793",
"0.5603698",
"0.5599183",
"0.55825824",
"0.55742615",
"0.55482703",
"0.5534011",
"0.55332... | 0.76871413 | 0 |
Test the two mode squeezing symplectic transform decomposes correctly. | def test_decompose(self, tol):
r = 0.543
phi = 0.123
S = symplectic.two_mode_squeezing(r, phi)
# test that S = B^\dagger(pi/4, 0) [S(z) x S(-z)] B(pi/4)
# fmt:off
B = np.array([[1, -1, 0, 0], [1, 1, 0, 0], [0, 0, 1, -1], [0, 0, 1, 1]])/np.sqrt(2)
Sq1 = np.array(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_exact_two_qubit_cnot_decompose_paulis(self):\n unitary = Operator.from_label(\"XZ\")\n self.check_exact_decomposition(unitary.data, two_qubit_cnot_decompose)",
"def test_is_symplectic():\n theta = np.pi / 6\n r = np.arcsinh(1.0)\n phi = np.pi / 8\n S = symplectic.rotation(theta... | [
"0.6298844",
"0.58669525",
"0.57883143",
"0.5735739",
"0.5707996",
"0.5701629",
"0.56696594",
"0.56217694",
"0.558217",
"0.55421317",
"0.55347294",
"0.5524282",
"0.55137944",
"0.54886293",
"0.54759514",
"0.54726905",
"0.5321991",
"0.53013265",
"0.52965504",
"0.527561",
"0.525... | 0.6660276 | 0 |
Test that an interferometer returns correct symplectic | def test_interferometer(self, tol):
# fmt:off
U = np.array([[0.83645892-0.40533293j, -0.20215326+0.30850569j],
[-0.23889780-0.28101519j, -0.88031770-0.29832709j]])
# fmt:on
S = symplectic.interferometer(U)
expected = np.block([[U.real, -U.imag], [U.imag, U.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_pint_to_simtk():\n q = 5.0 / unit.nanometer\n assert pint_to_simtk(q) == 0.5 / omm_unit.angstrom",
"def test_symplectic(self, tol):\n # random interferometer\n # fmt:off\n U = np.array([[-0.06658906-0.36413058j, 0.07229868+0.65935896j, 0.59094625-0.17369183j, -0.18254686-0.101... | [
"0.63631886",
"0.6307245",
"0.61842406",
"0.6044003",
"0.60306865",
"0.59221554",
"0.58728933",
"0.58567166",
"0.58367074",
"0.58329916",
"0.5817299",
"0.5817299",
"0.5817299",
"0.5817299",
"0.5817299",
"0.5817299",
"0.5817299",
"0.5817299",
"0.5817299",
"0.5817299",
"0.58172... | 0.71499187 | 0 |
Test that the interferometer is symplectic | def test_symplectic(self, tol):
# random interferometer
# fmt:off
U = np.array([[-0.06658906-0.36413058j, 0.07229868+0.65935896j, 0.59094625-0.17369183j, -0.18254686-0.10140904j],
[0.53854866+0.36529723j, 0.61152793+0.15022026j, 0.05073631+0.32624882j, -0.17482023-0.2010377... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_interferometer(self, tol):\n # fmt:off\n U = np.array([[0.83645892-0.40533293j, -0.20215326+0.30850569j],\n [-0.23889780-0.28101519j, -0.88031770-0.29832709j]])\n # fmt:on\n\n S = symplectic.interferometer(U)\n expected = np.block([[U.real, -U.imag],... | [
"0.69182575",
"0.6312107",
"0.61173964",
"0.5967121",
"0.5886627",
"0.58122754",
"0.58122754",
"0.58122754",
"0.58122754",
"0.58122754",
"0.58122754",
"0.58122754",
"0.58122754",
"0.58122754",
"0.58122754",
"0.58122754",
"0.58122754",
"0.58122754",
"0.58122754",
"0.58122754",
... | 0.63223344 | 1 |
Test that an interferometer returns correct symplectic for a 5050 beamsplitter | def test_50_50_beamsplitter(self, tol):
U = np.array([[1, -1], [1, 1]]) / np.sqrt(2)
S = symplectic.interferometer(U)
B = np.array([[1, -1, 0, 0], [1, 1, 0, 0], [0, 0, 1, -1], [0, 0, 1, 1]]) / np.sqrt(2)
assert np.allclose(S, B, atol=tol, rtol=0) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_beamsplitter(self, tol):\n theta = 0.98\n phi = 0.41\n U = symplectic.beam_splitter(theta, phi)\n S = symplectic.interferometer(U)\n expected = np.block([[U.real, -U.imag], [U.imag, U.real]])\n np.allclose(S, expected, atol=tol, rtol=0)",
"def test_imsim():\n ... | [
"0.72447073",
"0.6217212",
"0.606898",
"0.60097283",
"0.5978577",
"0.5902334",
"0.5839211",
"0.5818933",
"0.57633305",
"0.57533425",
"0.5707598",
"0.56564283",
"0.563227",
"0.5618321",
"0.560233",
"0.5560391",
"0.5559955",
"0.55543053",
"0.5540196",
"0.552216",
"0.5521984",
... | 0.7322756 | 0 |
Test that an interferometer returns correct symplectic for an arbitrary beamsplitter | def test_beamsplitter(self, tol):
theta = 0.98
phi = 0.41
U = symplectic.beam_splitter(theta, phi)
S = symplectic.interferometer(U)
expected = np.block([[U.real, -U.imag], [U.imag, U.real]])
np.allclose(S, expected, atol=tol, rtol=0) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_50_50_beamsplitter(self, tol):\n U = np.array([[1, -1], [1, 1]]) / np.sqrt(2)\n\n S = symplectic.interferometer(U)\n B = np.array([[1, -1, 0, 0], [1, 1, 0, 0], [0, 0, 1, -1], [0, 0, 1, 1]]) / np.sqrt(2)\n\n assert np.allclose(S, B, atol=tol, rtol=0)",
"def test_get_integral_b... | [
"0.74121416",
"0.6051322",
"0.59612495",
"0.5830647",
"0.5718893",
"0.57145494",
"0.56256294",
"0.5621167",
"0.5613371",
"0.5515395",
"0.5475906",
"0.54747194",
"0.5469573",
"0.5445608",
"0.54225075",
"0.5417419",
"0.5397021",
"0.53339547",
"0.53277606",
"0.532112",
"0.531597... | 0.76223993 | 0 |
Test that a rotation returns the correct symplectic for an abritrary angle | def test_rotation(self, tol):
theta = 0.98
S = symplectic.rotation(theta)
expected = np.block([[np.cos(theta), -np.sin(theta)], [np.sin(theta), np.cos(theta)]])
np.allclose(S, expected, atol=tol, rtol=0) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_rotation_angle(self):\n\n self.test_shape.azimuth_placement_angle = [45, 135, 225, 315]\n test_volume = self.test_shape.volume()\n self.test_shape.rotation_angle = 180\n assert self.test_shape.volume() == pytest.approx(test_volume * 0.5)",
"def test_calc_rotation(self):\n ... | [
"0.7787546",
"0.7584751",
"0.73108375",
"0.72521657",
"0.71550333",
"0.7142728",
"0.6906487",
"0.67970854",
"0.6786937",
"0.6767595",
"0.6731719",
"0.67219853",
"0.67171705",
"0.66996586",
"0.66752625",
"0.6657087",
"0.66561294",
"0.66394335",
"0.65897477",
"0.65578544",
"0.6... | 0.77721405 | 1 |
Test that the loss channel on a TMS state corresponds to a beamsplitter acting on the mode with loss and an ancilla vacuum state | def test_TMS_against_interferometer(self, hbar, tol):
r = 0.543
phi = 0.432
T = 0.812
S = symplectic.two_mode_squeezing(r, phi)
cov = S @ S.T * (hbar / 2)
# perform loss
_, cov_res = symplectic.loss(np.zeros([4]), cov, T, mode=0, hbar=hbar)
# create a t... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_mlag_status(device, actual, testcase):\n has_state = actual['state']\n exp_state = testcase['expected']['state']\n\n is_up = (exp_state == 'up' and has_state == 'active')\n has_neg_st = actual['negStatus']\n is_neg = has_neg_st == \"connected\"\n\n if is_up and is_neg:\n return Tr... | [
"0.610027",
"0.54928505",
"0.54843247",
"0.538472",
"0.5376206",
"0.53329206",
"0.5292487",
"0.5259885",
"0.5259591",
"0.52537143",
"0.523257",
"0.5230858",
"0.52053463",
"0.51892555",
"0.51812863",
"0.51804304",
"0.5178098",
"0.5177065",
"0.51733464",
"0.5165498",
"0.5161356... | 0.5754807 | 1 |
Test that the loss channel on a displaced state corresponds to a beamsplitter acting on the mode with loss and an ancilla vacuum state | def test_displaced_loss_against_interferometer(self, hbar, tol):
T = 0.812
alpha = np.random.random(size=[2]) + np.random.random(size=[2]) * 1j
mu = np.concatenate([alpha.real, alpha.imag])
# perform loss
mu_res, _ = symplectic.loss(mu, np.identity(4), T, mode=0, hbar=hbar)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_errors_state_SDP():\n with pytest.raises(ValueError, match=\"Provided input state is not a density matrix.\"):\n fidelity_of_separability(bad_rho, [2, 2])\n with pytest.raises(AssertionError, match=\"For State SDP: require bipartite state dims.\"):\n fidelity_of_separability(sep_rho, [... | [
"0.5674453",
"0.5671132",
"0.566915",
"0.5659622",
"0.54717535",
"0.54095054",
"0.53825945",
"0.5352345",
"0.53438014",
"0.5314535",
"0.53032106",
"0.5297342",
"0.5271369",
"0.5251538",
"0.5243904",
"0.52406925",
"0.5239406",
"0.52317727",
"0.52252525",
"0.5202244",
"0.519385... | 0.6036796 | 0 |
Test loss on part of a thermal state | def test_loss_thermal_state(self, hbar, tol):
nbar = np.array([0.4532, 0.123, 0.432])
T = 0.54
mu = np.zeros([2 * len(nbar)])
cov = np.diag(2 * np.tile(nbar, 2) + 1) * (hbar / 2)
res = symplectic.loss(mu, cov, T, mode=1, hbar=hbar)
# the loss reduces the fractional mea... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compute_loss(self):",
"def test_non_zero_loss(self):\n # Reset models.\n self.model.load_state_dict(self.initial_model_dict)\n self.actor_model.load_state_dict(self.initial_actor_model_dict)\n\n polybeast.learn(*self.learn_args)\n\n self.assertNotEqual(self.stats[\"total_lo... | [
"0.6557733",
"0.649664",
"0.64508307",
"0.6409148",
"0.6393856",
"0.6364646",
"0.63612276",
"0.6321213",
"0.62905174",
"0.6281446",
"0.6276483",
"0.6269184",
"0.62561256",
"0.6250694",
"0.6215095",
"0.61977535",
"0.61700064",
"0.6159824",
"0.6146588",
"0.6076377",
"0.6070988"... | 0.68701863 | 0 |
test that error is raised when length of modes array is incorrect | def test_modes_length(self):
with pytest.raises(ValueError, match="length of modes must match the shape of T"):
symplectic.expand_passive(np.ones((3, 3)), [0, 1, 2, 3, 4], 8) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_tooManyModeParameters(self):\n self._sendModeChange(\"+s\", \"wrong\")\n self._checkModeChange([])\n errors = self.flushLoggedErrors(irc.IRCBadModes)\n self.assertEqual(len(errors), 1)\n self.assertSubstring(\"Too many parameters\", errors[0].getErrorMessage())",
"def ... | [
"0.68717605",
"0.6719313",
"0.6469907",
"0.63585526",
"0.6327024",
"0.62718683",
"0.6178851",
"0.61168265",
"0.61156166",
"0.6062404",
"0.60577786",
"0.6035269",
"0.60257506",
"0.58907795",
"0.5887417",
"0.5872176",
"0.5840044",
"0.583284",
"0.5798619",
"0.5779981",
"0.575119... | 0.73936355 | 0 |
Test that applying squeezing and interferometers to a four mode circuit, followed by applying the inverse operations, return the state to the vacuum | def test_inverse_ops_cancel(self, hbar, tol):
# the symplectic matrix
O = np.block([[np.zeros([4, 4]), np.identity(4)], [-np.identity(4), np.zeros([4, 4])]])
# begin in the vacuum state
mu_init, cov_init = symplectic.vacuum_state(4, hbar=hbar)
# add displacement
alpha ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_circuit_decompose(self):\n dec = TwoQubitDecomposeUpToDiagonal()\n u4 = scipy.stats.unitary_group.rvs(4, random_state=47)\n dmat, circ2cx = dec(u4)\n\n qc1 = QuantumCircuit(2)\n qc1.append(UnitaryGate(u4), range(2))\n\n qc2 = QuantumCircuit(2)\n qc2.compose... | [
"0.6064617",
"0.58418345",
"0.58331007",
"0.5784152",
"0.56935436",
"0.56916195",
"0.56741935",
"0.5616282",
"0.56120634",
"0.5598436",
"0.5595036",
"0.55797696",
"0.54715794",
"0.5467197",
"0.544422",
"0.543307",
"0.5420268",
"0.5419678",
"0.54039377",
"0.5402418",
"0.538833... | 0.6018929 | 1 |
Tests that the matrices generated in the symplectic module are indeed symplectic | def test_is_symplectic():
theta = np.pi / 6
r = np.arcsinh(1.0)
phi = np.pi / 8
S = symplectic.rotation(theta)
assert symplectic.is_symplectic(S)
S = symplectic.squeezing(r, theta)
assert symplectic.is_symplectic(S)
S = symplectic.beam_splitter(theta, phi)
assert symplectic.is_symple... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_symplectic_multimode(self, tol):\n r = [0.543] * 4\n phi = [0.123] * 4\n S = symplectic.squeezing(r, phi)\n\n # the symplectic matrix\n O = symplectic.sympmat(4)\n\n assert np.allclose(S @ O @ S.T, O, atol=tol, rtol=0)",
"def test_symplectic(self, tol):\n ... | [
"0.7264588",
"0.7137548",
"0.7099854",
"0.7004554",
"0.6783439",
"0.62454903",
"0.61881614",
"0.6172591",
"0.61723524",
"0.6104744",
"0.6077903",
"0.6067226",
"0.60514003",
"0.6049556",
"0.59936893",
"0.59757316",
"0.59664327",
"0.59643245",
"0.59631926",
"0.59485084",
"0.594... | 0.73571527 | 0 |
Checks the correctness of the Autonne decomposition function | def test_autonne(n, datatype, svd_order):
if datatype is np.complex128:
A = np.random.rand(n, n) + 1j * np.random.rand(n, n)
if datatype is np.float64:
A = np.random.rand(n, n)
A += A.T
r, U = symplectic.autonne(A, svd_order=svd_order)
assert np.allclose(A, U @ np.diag(r) @ U.T)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_csendes(self):\n fun = get_problem('csendes', self.dimension, -1.0, 1.0)\n self.assertEqual(fun(self.array), 0.0)",
"def _check_determinancy(self, values, errors, combo):\n val, err = self.used_vars(values, errors, combo)\n n, m = len(val), len(self.get_equations(combo))\n\n ... | [
"0.61847746",
"0.6085928",
"0.60464895",
"0.6037118",
"0.60084844",
"0.6002486",
"0.5991143",
"0.5898128",
"0.584331",
"0.5765758",
"0.57627267",
"0.576049",
"0.57357657",
"0.57017523",
"0.5700457",
"0.5660507",
"0.5657597",
"0.5657597",
"0.5657597",
"0.5657597",
"0.563528",
... | 0.6294067 | 0 |
Test the change of basis function applied to vectors. This function converts from xp to symmetric ordering, and vice versa. | def test_means_changebasis(self):
means_xp = np.array([1, 2, 3, 4, 5, 6])
means_symmetric = np.array([1, 4, 2, 5, 3, 6])
assert np.all(symplectic.xxpp_to_xpxp(means_xp) == means_symmetric)
assert np.all(symplectic.xpxp_to_xxpp(means_symmetric) == means_xp) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_cov_changebasis(self):\n cov_xp = np.array([[0, 1, 2, 3], [4, 5, 6, 7], [8, 9, 10, 11], [12, 13, 14, 15]])\n\n cov_symmetric = np.array([[0, 2, 1, 3], [8, 10, 9, 11], [4, 6, 5, 7], [12, 14, 13, 15]])\n\n assert np.all(symplectic.xxpp_to_xpxp(cov_xp) == cov_symmetric)\n assert n... | [
"0.68661994",
"0.6683089",
"0.64289373",
"0.61462635",
"0.60818833",
"0.6007215",
"0.59997624",
"0.5993004",
"0.5986447",
"0.58355707",
"0.5661903",
"0.56606877",
"0.5653268",
"0.5648356",
"0.5647753",
"0.5639548",
"0.56343216",
"0.5626287",
"0.56128305",
"0.5595368",
"0.5584... | 0.688866 | 0 |
Test correct error is raised when a nonsquare matrix is passed | def test_change_basis_raises_not_square(self, fun):
A = np.random.rand(4, 6)
with pytest.raises(ValueError, match="The input matrix is not square"):
fun(A) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_square(self):\n if self.rows != self.cols:\n raise IndexError(\"Matrix is not square\")",
"def test_exception():\n mat2D = MatrixDouble([[0.0, 0.0], [1.0, 1.0], [2.0, 2.0], [3.0, 3.0]])\n mat3D = MatrixDouble([[0.0, 0.0, 0.0], [1.0, 1.0, 1.0], [2.0, 2.0, 2.0], [3.0, 3.0, 3.0]])\... | [
"0.75665575",
"0.7414959",
"0.74014336",
"0.739059",
"0.710802",
"0.70430565",
"0.704296",
"0.7036605",
"0.6953137",
"0.6953137",
"0.69052404",
"0.6805007",
"0.67927366",
"0.6752481",
"0.6748283",
"0.6736855",
"0.66916555",
"0.6681887",
"0.6676933",
"0.66670984",
"0.6657981",... | 0.78269637 | 0 |
Check that xxpp_to_xpxp is the inverse of xpxp_to_xxpp and viceversa | def test_functional_inverse(self, dim):
M = np.random.rand(dim, dim)
assert np.all(M == symplectic.xxpp_to_xpxp(symplectic.xpxp_to_xxpp(M)))
assert np.all(M == symplectic.xpxp_to_xxpp(symplectic.xxpp_to_xpxp(M)))
v = np.random.rand(dim)
assert np.all(v == symplectic.xxpp_to_xpxp... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_pk2x(self):\n self.assertFloatEqual(pkolmogorov2x(0.7199, 50), (1-6.661e-16))\n self.assertFloatEqual(pkolmogorov2x(0.08, 30), 0.01754027)\n self.assertFloatEqual(pkolmogorov2x(0.03, 300), 0.05753413)",
"def test_ps2x(self):\n self.assertFloatEqual(psmirnov2x(0.48, 20, 50), 0... | [
"0.5890805",
"0.5870609",
"0.57905334",
"0.572639",
"0.57105285",
"0.56434244",
"0.5631743",
"0.55476296",
"0.5531059",
"0.55111104",
"0.55026233",
"0.54769284",
"0.54205465",
"0.5372108",
"0.53619933",
"0.5348244",
"0.53308654",
"0.5318651",
"0.5284802",
"0.5270421",
"0.5242... | 0.5954942 | 0 |
When a message arrives on the servicebus, send a trigger to IoT Hub to start the fan for that device. | def main(msg: func.ServiceBusMessage):
# Extract the method into a dictionary
msg_dict = json.loads(msg.get_body().decode("utf-8"))
logging.info(f"Python ServiceBus queue trigger processed message: {msg_dict}")
# Enable a connection with the IoT Hub. The connectionstring for the IoT Hub
#... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cbMqtt_dev_fan(client, userdata, message):\n if not mqtt_message_log(message):\n return\n command = iot.get_command_index(message.payload.decode('utf-8'))\n try:\n value = float(message.payload)\n except ValueError:\n value = None\n if message.topic == mqtt.topic_name('mqtt_... | [
"0.62256354",
"0.6204612",
"0.5938217",
"0.5851733",
"0.5787778",
"0.5740057",
"0.5671162",
"0.56475306",
"0.5595448",
"0.55503374",
"0.55425894",
"0.551952",
"0.55153245",
"0.5507054",
"0.5502583",
"0.54830575",
"0.54751164",
"0.5473902",
"0.5469198",
"0.5460177",
"0.5432455... | 0.7289142 | 0 |
Construct a Git commandline, setting its working tree to `workTree`, and git directory to `gitDir`, and then appends `subcommand`. | def prepareGitCommand(self, workTree, subcommand, gitDir):
absWorkTree = self.__chroot.getDirectory() + workTree
absGitDir = self.__chroot.getDirectory() + gitDir
command = "git --git-dir=%s --work-tree=%s " % (absGitDir, absWorkTree)
command += subcommand
return command | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __git(self, command, args=None, logCommand=False, **kwargs):\n parts = [\"git\"]\n if \"stdout\" not in kwargs and \"stderr\" not in kwargs and CraftCore.settings.getboolean(\"General\", \"AllowAnsiColor\", True):\n parts += [\"-c\", \"color.ui=always\"]\n if command in (\"clone... | [
"0.64051634",
"0.608088",
"0.5972793",
"0.5900138",
"0.5787076",
"0.5784107",
"0.5717767",
"0.57163435",
"0.56660086",
"0.5629974",
"0.5602561",
"0.55977106",
"0.55699235",
"0.5552696",
"0.5537944",
"0.5464937",
"0.5462093",
"0.5454389",
"0.54503447",
"0.5437023",
"0.541048",... | 0.8268942 | 0 |
Construct a Git 'archive' subcommand with autodetected format. If outputFilePath is None, format will be tar, and output will be stdout. | def makeArchiveGitSubcommand(self, prefix, revision=u"HEAD", outputFilePath=None):
command = "archive --prefix=%s/ %s "
command = command % (prefix, revision)
if outputFilePath is not None:
command += " -o %s" % outputFilePath
return command | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def make_archive(base_name, format, root_dir=None, base_dir=None, verbose=0,\n dry_run=0, owner=None, group=None):\n save_cwd = os.getcwd()\n if root_dir is not None:\n log.debug(\"changing into '%s'\", root_dir)\n base_name = os.path.abspath(base_name)\n if not dry_run:\... | [
"0.6310503",
"0.6213252",
"0.5903841",
"0.56020045",
"0.5471116",
"0.54561937",
"0.5420927",
"0.5351721",
"0.5305187",
"0.530036",
"0.52904725",
"0.5287436",
"0.5281172",
"0.5258818",
"0.52575177",
"0.52182823",
"0.5201736",
"0.5175484",
"0.5155601",
"0.5134311",
"0.51288",
... | 0.70219696 | 0 |
Git complains if you don't set 'user.name' and 'user.email' config parameters. This method checks if they are set, and in case they aren't, set them. | def checkGitUserConfig(self, workTree, gitDir):
confParams = {"user.email": "obslight@example.com", "user.name": "OBS Light"}
for param, value in confParams.iteritems():
cmd = self.prepareGitCommand(workTree, "config " + param, gitDir)
res = self.__subprocess(cmd, stdout=True, no... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __gitEditUserConfig(self):\n self.vcs.gitEditUserConfig()",
"def git_config_setup():\n\n local('git config user.email $GIT_EMAIL')\n local('git config user.name $GIT_NAME')\n\n local(\n 'git remote set-url --push origin '\n 'https://$GH_TOKEN@github.com/$TRAVIS_REPO_SLUG.git'\n ... | [
"0.6524679",
"0.6293602",
"0.61563706",
"0.60802794",
"0.59775037",
"0.5826218",
"0.56713724",
"0.56607777",
"0.56431246",
"0.5572216",
"0.5566696",
"0.5539429",
"0.55392605",
"0.55193794",
"0.5486381",
"0.5480235",
"0.54342926",
"0.54149544",
"0.5414949",
"0.54110503",
"0.53... | 0.6988445 | 0 |
Returns state table dynamodb table resource | def state_table(self):
if self._state_table is None:
dynamodb = boto3.resource("dynamodb")
self._state_table = dynamodb.Table(self._table_name)
add_retry_methods_to_resource(self._state_table, ["get_item", "put_item"], context=self._context)
return self._state_table | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def createStateTable(self):\r\n tableName = self._names['state']\r\n con = None\r\n try:\r\n con = sql.connect(self._filename, timeout=10, \r\n isolation_level=\"IMMEDIATE\")\r\n with con:\r\n c = con.cursor()\r\n ... | [
"0.68151045",
"0.66190535",
"0.6576156",
"0.65184677",
"0.6493206",
"0.6330615",
"0.63109934",
"0.62821645",
"0.6272649",
"0.62651694",
"0.6262398",
"0.6253667",
"0.6253667",
"0.62382483",
"0.62252474",
"0.6199148",
"0.6159229",
"0.6121347",
"0.61199003",
"0.6063084",
"0.6018... | 0.8200871 | 0 |
Loads the desired state for the specified account and service | def load(self, account, region):
self._dirty = False
self._state_info = {}
self._current_account_region = "{}:{}".format(account, region)
# get single row from dynamoDB
try:
resp = self.state_table.get_item_with_retries(Key={
InstanceStates.INSTANCE_T... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_get_account_from_state(self):\n state = State('test-state')\n account = Account('test-account')\n state.add_account(account)\n self.assertEqual(state.get_account('test-account'), account)",
"def get_state(self, service, key, auth, context=None):\n return self._client.c... | [
"0.5983211",
"0.58598644",
"0.5476416",
"0.53023756",
"0.5208085",
"0.5198449",
"0.5160197",
"0.5155446",
"0.5145707",
"0.51331735",
"0.5087769",
"0.50609773",
"0.5046408",
"0.5028825",
"0.5027528",
"0.5020877",
"0.4996154",
"0.49956942",
"0.49860314",
"0.49641198",
"0.495631... | 0.591315 | 1 |
Removes the state of an instance | def delete_instance_state(self, instance_id):
if instance_id in self._state_info:
del self._state_info[instance_id]
if instance_id in self._instances_to_purge:
self._instances_to_purge.remove(instance_id)
self._dirty = True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def remove_state(self, state):\n self._validate_state(state)\n self._state.remove(state)",
"def remove_instance_state_on_destroy(self) -> pulumi.Output[Optional[bool]]:\n return pulumi.get(self, \"remove_instance_state_on_destroy\")",
"def __delete__(self, instance):\r\n self._set_i... | [
"0.73004764",
"0.70006686",
"0.6930774",
"0.68310314",
"0.6823668",
"0.6812733",
"0.6812733",
"0.6796559",
"0.66261524",
"0.65926176",
"0.659163",
"0.6577975",
"0.6577103",
"0.6555158",
"0.65036756",
"0.64839613",
"0.64355385",
"0.6424211",
"0.64160055",
"0.63753873",
"0.6337... | 0.707869 | 1 |
Stores the instance state information to the dynamodb table if it has changed | def save(self):
if self._dirty:
# key and timestamp
data = {
InstanceStates.INSTANCE_TABLE_NAME: self._service,
InstanceStates.INSTANCE_TABLE_ACCOUNT_REGION: self._current_account_region,
InstanceStates.INSTANCE_TABLE_TIMESTAMP: Decimal(tim... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _update_state(context, node, instance, state):\n values = {'task_state': state}\n if not instance:\n values['instance_uuid'] = None\n values['instance_name'] = None\n db.bm_node_update(context, node['id'], values)",
"def _write_to_db(self, instance: DBModelInstance) -> None:\n s... | [
"0.64052135",
"0.63261276",
"0.605285",
"0.6039104",
"0.5931852",
"0.58845836",
"0.58681184",
"0.579252",
"0.5780897",
"0.5764212",
"0.5677982",
"0.5651571",
"0.5622943",
"0.56212825",
"0.5613502",
"0.5608942",
"0.559356",
"0.5577013",
"0.55660856",
"0.55487597",
"0.55449885"... | 0.8172984 | 0 |
Removes instance id's from the table that have been terminated or not being processed by the scheduler. This code contains workaround for instances not being returned by describe_instances when changing state When an instance is not listed it is marked for removal at next cleanup if it is not found again | def cleanup(self, instances):
# cleanup only if the last cleanup was more than a the configured interval ago
if (Decimal(time.time()) - Decimal(self._timestamp)) > InstanceStates.cleanup_interval:
self._logger.info(INF_CLEANING)
self._timestamp = time.time()
self._dir... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _cleanup_running_deleted_instances(self, context):\n action = CONF.running_deleted_instance_action\n\n if action == \"noop\":\n return\n\n # NOTE(sirp): admin contexts don't ordinarily return deleted records\n with utils.temporary_mutation(context, read_deleted=\"yes\"):\... | [
"0.72665536",
"0.6622512",
"0.6608846",
"0.638443",
"0.6297026",
"0.6213036",
"0.6179447",
"0.613314",
"0.6083176",
"0.6067407",
"0.59540826",
"0.59376824",
"0.5858502",
"0.57749027",
"0.5751054",
"0.5700498",
"0.5672394",
"0.5664225",
"0.56500286",
"0.564892",
"0.5645379",
... | 0.69833094 | 1 |
Look up a FQN in a mapper, logging all nonImportError exceptions and converting them to ImportErrors. | def lookupWithMapper(mapper, fqn):
try:
return mapper.lookup(fqn)
except ImportError, e:
raise e
except:
print "Error raised by Exocet mapper while loading %r" % (fqn)
traceback.print_exc()
raise ImportError(fqn) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _maybe_show_missing_import_error(self, node):\n if not self._is_checking():\n return\n if node.id not in self.config.NAMES_TO_IMPORTS:\n return\n if node.id in self.imports_added:\n return\n self.imports_added.add(node.id)\n target = self.conf... | [
"0.546759",
"0.5457706",
"0.54406106",
"0.5417069",
"0.53574413",
"0.5259838",
"0.52041495",
"0.5190706",
"0.5168303",
"0.5109185",
"0.51066345",
"0.5105973",
"0.50043106",
"0.49576783",
"0.48983428",
"0.48885408",
"0.4848351",
"0.48429307",
"0.48311594",
"0.48237872",
"0.482... | 0.6757015 | 0 |
Create a proxy for a module object, overriding some of its attributes with replacement objects. | def proxyModule(original, **replacements):
class _ModuleProxy(object):
def __getattribute__(self, name):
if name in replacements:
return replacements[name]
else:
return getattr(original, name)
def __repr__(self):
return "<Proxy for %r: %s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _createModuleObj(self):\n ModuleTimeWeakening.__init__(self)\n return",
"def make_module_instance(self, *args, **kwargs):\r\n\r\n # Function to go through member lists and dictionaries recursively,\r\n # to look for submodules on which make_module_instance needs to be called\r\n de... | [
"0.64491117",
"0.6339931",
"0.62900716",
"0.6232776",
"0.6232776",
"0.6215524",
"0.6075675",
"0.58981276",
"0.58981276",
"0.5870938",
"0.58484423",
"0.57430935",
"0.5732268",
"0.5725669",
"0.57047176",
"0.5662384",
"0.5653784",
"0.5641301",
"0.5604349",
"0.55789244",
"0.55359... | 0.82936937 | 0 |
Constructs a generator based on a ResNet18 model. | def genresnet18(**kwargs):
return Generator(resnetblocks.EresNetBasicBlock, resnetblocks.DresNetBasicBlock, [2, 2, 2, 2], **kwargs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def resnext18( **kwargs):\n model = ResNeXt(BasicBlock, [2, 2, 2, 2], **kwargs)\n return model",
"def resnet18(pretrained=False):\n model = ResNet(BasicBlock, [2, 2, 2, 2])\n if pretrained:\n model.load_state_dict(model_zoo.load_url(model_urls['resnet18']))\n return model",
"def resnet18(... | [
"0.670444",
"0.6201081",
"0.61616635",
"0.6147389",
"0.61351657",
"0.6127375",
"0.6127375",
"0.6127375",
"0.6127375",
"0.6127375",
"0.6066816",
"0.6053501",
"0.60121393",
"0.59246445",
"0.5903505",
"0.58481234",
"0.5784622",
"0.57822853",
"0.5779865",
"0.5757513",
"0.5705468"... | 0.6700043 | 1 |
Constructs a discriminator based on a ResNet101 model decoder. | def disresnet101(**kwargs):
return Discriminator(resnetblocks.DresNetBottleneck, [3, 4, 23, 3], **kwargs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def build_discriminator(self):\n # label input\n in_label = Input(shape=(1,))\n # embedding for categorical input\n li = Embedding(self.n_classes, 50)(in_label)\n # scale up to image dimensions with linear activation\n n_nodes = self.in_shape[0] * self.in_shape[1]\n ... | [
"0.6821208",
"0.6758763",
"0.6571235",
"0.6552628",
"0.64924765",
"0.6436699",
"0.6419941",
"0.64112055",
"0.6362126",
"0.6359593",
"0.62890416",
"0.6245676",
"0.6175603",
"0.6118328",
"0.61152256",
"0.6088889",
"0.60616994",
"0.60593534",
"0.604333",
"0.60331523",
"0.6030297... | 0.69752914 | 0 |
Constructs a discriminator based on a ResNet152 model decoder. | def disresnet152(**kwargs):
return Discriminator(resnetblocks.DresNetBottleneck, [3, 8, 36, 3], **kwargs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def disresnet101(**kwargs):\n return Discriminator(resnetblocks.DresNetBottleneck, [3, 4, 23, 3], **kwargs)",
"def build_discriminator(self):\n img_shape = (self.img_size[0], self.img_size[1], self.channels)\n\n model = Sequential()\n ###############\n # Conv Stack 1:\n ####... | [
"0.65576226",
"0.6459214",
"0.64486456",
"0.6308615",
"0.6252068",
"0.62429833",
"0.6164812",
"0.61193645",
"0.61136514",
"0.6112274",
"0.6104113",
"0.605819",
"0.6034276",
"0.6007072",
"0.59882915",
"0.59749997",
"0.59533167",
"0.5951373",
"0.594227",
"0.594227",
"0.594227",... | 0.7111796 | 0 |
Test the model using the parameters (and their ranges) specified in the param_dict input. Features and classes are used to fit the model for testing the accuracy score. Cross validation is used for splitting the data throughout the grid search. | def test_k_models(param_dict, features, classes, cross_val=4):
assert type(param_dict) == dict
model = GridSearchCV(KNeighborsClassifier(), param_dict, cv=cross_val)
model.fit(features, classes)
return list(model.best_params_.values())[0] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def fit(train_data, train_target):\r\n for name in models.keys():\r\n est = models[name]\r\n est_params = params2[name]\r\n gscv = GridSearchCV(estimator=est, param_grid=est_params, cv=5)\r\n gscv.fit(train_data, train_target)\r\n print(\"best parameter... | [
"0.6459051",
"0.6420987",
"0.6273333",
"0.6229936",
"0.6172753",
"0.61413914",
"0.6132222",
"0.6114078",
"0.6111218",
"0.61003935",
"0.60821277",
"0.6059227",
"0.6059227",
"0.6037962",
"0.6034692",
"0.60259694",
"0.60191506",
"0.6003235",
"0.600246",
"0.5958543",
"0.5950811",... | 0.6845213 | 0 |
Find module and determine __all__. Return None if the module is a C module. Return (module_path, __all__) if Python module. Raise an exception or exit if failed. | def find_module_path_and_all(module: str, pyversion: Tuple[int, int],
no_import: bool,
search_path: List[str],
interpreter: str) -> Optional[Tuple[str,
Optional[List[st... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _find_module(name, path=None):\n\n parts = name.split('.')\n\n for part in parts:\n if path is not None:\n path = [path]\n\n fh, path, descr = imp.find_module(part, path)\n\n return fh, path, descr",
"def load_python_module_info(module: str, interpreter: str) -> Tuple[str, O... | [
"0.6034657",
"0.587554",
"0.5767841",
"0.5718104",
"0.5703696",
"0.56973255",
"0.5685329",
"0.5660578",
"0.563566",
"0.56269044",
"0.56059307",
"0.559648",
"0.55879086",
"0.5580596",
"0.55803764",
"0.5574204",
"0.5559112",
"0.5535757",
"0.55123293",
"0.5506985",
"0.5489032",
... | 0.68999195 | 0 |
The list of required import lines (as strings with python code) | def import_lines(self) -> List[str]:
result = []
# To summarize multiple names imported from a same module, we collect those
# in the `module_map` dictionary, mapping a module path to the list of names that should
# be imported from it. the names can also be alias in the form 'original ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_imports(self) -> str:\n\n imports = [\n \"_ = require('lodash');\",\n \"stream = require('stream');\",\n f\"const hookRegister = require('./{settings.ARTILLERY_HOOK_FILE}').hookRegister;\",\n f\"hook = require('./{settings.ARTILLERY_LIB_FOLDER}/hooks').hoo... | [
"0.7392999",
"0.7008633",
"0.7006744",
"0.6577546",
"0.65343875",
"0.6469632",
"0.63858473",
"0.6340286",
"0.6318618",
"0.62747866",
"0.62601453",
"0.6256329",
"0.624323",
"0.6182229",
"0.61704916",
"0.6132508",
"0.61241585",
"0.6098096",
"0.60951346",
"0.6083969",
"0.6073907... | 0.74202406 | 0 |
Return True for things that look like type expressions Used to know if assignments look like typealiases | def is_type_expression(self, expr: Expression, top_level: bool=True) -> bool:
# Assignment of TypeVar(...) are passed through
if (isinstance(expr, CallExpr) and
isinstance(expr.callee, NameExpr) and
expr.callee.name == 'TypeVar'):
return True
elif isin... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _assigns_typealias(node: nodes.NodeNG | None) -> bool:\n inferred = utils.safe_infer(node)\n if isinstance(inferred, nodes.ClassDef):\n if inferred.qname() == \".Union\":\n # Union is a special case because it can be used as a type alias\n # or as a type a... | [
"0.75892544",
"0.64642125",
"0.6263441",
"0.6158379",
"0.6114874",
"0.6100098",
"0.60984015",
"0.6002122",
"0.59788626",
"0.5920719",
"0.59187007",
"0.5858805",
"0.58472574",
"0.5825362",
"0.5792614",
"0.5763648",
"0.57438254",
"0.5742774",
"0.57378244",
"0.57350683",
"0.5734... | 0.6617053 | 1 |
Add a name to be imported from typing, unless it's imported already. The import will be internal to the stub. | def add_typing_import(self, name: str) -> None:
self.import_tracker.require_name(name) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def genImportWithAsName(self, name, asname):\n name = self._moreImportObject.getAbsName(name, '.'.join(self._module.getNames()))\n pass",
"def addModule(self, name):\n if name in self.needed_modules: return\n self.needed_modules[name] = True #avoid circular references\n\n module = self.moduleResol... | [
"0.6452142",
"0.642181",
"0.6324198",
"0.58398294",
"0.58065367",
"0.5746489",
"0.5704582",
"0.5649799",
"0.5627245",
"0.55776817",
"0.55756474",
"0.55648285",
"0.55641186",
"0.55243814",
"0.5483515",
"0.544545",
"0.54032904",
"0.5386403",
"0.5368005",
"0.53631985",
"0.532851... | 0.7900337 | 0 |
Add a line of text to the import section, unless it's already there. | def add_import_line(self, line: str) -> None:
if line not in self._import_lines:
self._import_lines.append(line) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def add_line(self, lineno, text, important=True):\n self.append((lineno, important, text))",
"def add(self, line):\n self.body.append(line)",
"def addContent(text):",
"def insert_needed_import(note, exer_name):\n txt_import = ''\n if exer_name in ('lp_duality', 'lp_interactive', 'lp_two_p... | [
"0.64810336",
"0.6229938",
"0.6147012",
"0.6069085",
"0.59199584",
"0.5896735",
"0.58797914",
"0.58497953",
"0.57973146",
"0.5779183",
"0.5776102",
"0.5725393",
"0.5712124",
"0.5712124",
"0.57075715",
"0.5690898",
"0.5673124",
"0.56676525",
"0.5603078",
"0.5593564",
"0.559354... | 0.7749153 | 0 |
Are we processing the top level of a file? | def is_top_level(self) -> bool:
return self._indent == '' | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_input_file(self):\r\n return self.depth == 0",
"def parsed_in_current(self, filep: Optional[str]) -> bool:\n if not filep:\n return False # pragma: no cover\n return self._parsed_by_parser_paths(filep, self.parser_paths)",
"def has_subfile(self) -> bool:\n\t\tself._updat... | [
"0.6975095",
"0.61733156",
"0.5956356",
"0.5948463",
"0.5918394",
"0.5907852",
"0.58611095",
"0.58003384",
"0.5763818",
"0.57152635",
"0.56970733",
"0.5652683",
"0.5651375",
"0.56352603",
"0.56304574",
"0.5619415",
"0.56081414",
"0.5589545",
"0.5579615",
"0.5570493",
"0.55684... | 0.6477744 | 1 |
Has this name been recorded previously? | def is_recorded_name(self, name: str) -> bool:
return self.is_top_level() and name in self._toplevel_names | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hasname(self):\n\t\treturn self.name is not None",
"def has_name(self):\n return self.unpack_word(0x2) != 0",
"def has_name(self):\n return self.name is not None",
"def is_named(self):\n return self._name != \"\"",
"def is_retired(self):\n if str.__str__(self) in UID_diction... | [
"0.6974096",
"0.6936471",
"0.69021505",
"0.6819593",
"0.67862594",
"0.6753564",
"0.6437195",
"0.6406641",
"0.6403",
"0.6318099",
"0.6314018",
"0.62805325",
"0.6253563",
"0.624307",
"0.621462",
"0.62131774",
"0.6196239",
"0.61853796",
"0.61845356",
"0.61830586",
"0.6179036",
... | 0.7265591 | 0 |
Find checkpoint files based on its max steps. is_outdir indicates whether find from outdir or modeldir. note that outdir generated from train and eval copy them to modeldir. | def _find_train_ckptfiles(path, is_delete):
# if not exists(path):
# return None, -1
steps = [int(f[len(ckpt_prefix):-5]) for f in os.listdir(path)
if f[:len(ckpt_prefix)] == ckpt_prefix and f[-5:] == '.meta']
if len(steps) == 0:
if is_delete:
raise FileNotFoundError... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def output_dir(self):\n return os.path.join(self.checkpoint_dir, self.model_dir)",
"def find_last(self):\n # Get directory names. Each directory corresponds to a model\n dir_names = next(os.walk(self.model_dir))[1]\n key = self.config.NAME.lower()\n dir_names = filter(lambda f:... | [
"0.6018463",
"0.5785135",
"0.5748152",
"0.57382095",
"0.5651902",
"0.55859107",
"0.5512155",
"0.5418045",
"0.5396361",
"0.5361415",
"0.5323277",
"0.53144616",
"0.53109574",
"0.5308277",
"0.5305889",
"0.52755123",
"0.52709544",
"0.51943886",
"0.5179579",
"0.5176981",
"0.512353... | 0.61166877 | 0 |
Get model files based on steps | def _get_model_files(steps, path):
if not isinstance(steps, list):
steps = [steps]
model_files = []
for step in steps:
model_pref = ckpt_prefix + str(step)
model_files.extend([f for f in os.listdir(path)
if os.path.isfile(os.path.join(path, f)) and f[:len(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def model_files(cmd_args):\n if cmd_args.learning_file_list:\n learning_files_list = files_constructor(cmd_args, file_type='learning')\n else:\n learning_files_list = None\n\n if cmd_args.prediction_file:\n prediction_file = files_constructor(cmd_args, file_type='prediction')\n els... | [
"0.676276",
"0.6610174",
"0.6426755",
"0.62805164",
"0.6206885",
"0.612019",
"0.6063496",
"0.6039039",
"0.6038808",
"0.6018534",
"0.5972065",
"0.5970282",
"0.59624505",
"0.5941705",
"0.5923377",
"0.5885832",
"0.58630353",
"0.5795052",
"0.57913876",
"0.5777931",
"0.5757521",
... | 0.7436546 | 0 |
Copy checkpoints from logdir to modeldir | def _copy_ckpt_to_modeldir(modeldir, logdir):
files, max_step = _find_train_ckptfiles(logdir, False)
_, cur_max_step = _find_train_ckptfiles(modeldir, False)
if cur_max_step == max_step:
raise FileNotFoundError('No new ckpt. cur_max_step: %s, max_step: %s.'
% (cur_max... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def save(self, checkpoint_dir, step):\n model_name = \"CNN.model\"\n model_dir = \"%s\" % (\"cnn\")\n checkpoint_dir = os.path.join(checkpoint_dir, model_dir)\n \n if not os.path.exists(checkpoint_dir):\n os.makedirs(checkpoint_dir)\n \n self.saver.save(self.sess,\n ... | [
"0.6527062",
"0.64596003",
"0.6340646",
"0.63143325",
"0.6298034",
"0.6278887",
"0.6275947",
"0.62065506",
"0.6204184",
"0.6097115",
"0.60966355",
"0.60625505",
"0.6009166",
"0.59816647",
"0.59810704",
"0.59746873",
"0.5959901",
"0.5951992",
"0.59505",
"0.59296125",
"0.591445... | 0.71924883 | 0 |
Test all expected versioned base URLs responds with 200 This depends on the routers for each kind of server. | def test_versioned_base_urls(client, index_client, server: str):
try:
import simplejson as json
except ImportError:
import json
from optimade.server.routers.utils import BASE_URL_PREFIXES
clients = {
"regular": client,
"index": index_client,
}
valid_endpoints =... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_all_http_stats(self):\n client = Client()\n response = client.get(reverse('home'))\n self.assertEqual(200, response.status_code)\n response = client.get(reverse('browse_produce'))\n self.assertEqual(200, response.status_code)\n response = client.get(reverse('brows... | [
"0.6897015",
"0.68129045",
"0.677679",
"0.6763513",
"0.6698699",
"0.6693176",
"0.65127456",
"0.6466742",
"0.6453278",
"0.6448831",
"0.6442751",
"0.63902104",
"0.63858867",
"0.63354486",
"0.6322557",
"0.6315488",
"0.63115126",
"0.63115126",
"0.63044256",
"0.6285797",
"0.627788... | 0.74736565 | 0 |
Lowercase and remove quotes from a TensorFlow string. | def normalize_text(text):
text = tf.strings.lower(text)
text = tf.strings.regex_replace(text, "'(.*)'", r"\1")
return text | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def normalize_text(text):\n text = tf.strings.lower(text)\n #text = tf.strings.regex_replace(text, br\"\\\\n\", b\"\\n\")\n #text = tf.strings.regex_replace(text, br\"\\\\t\", b\"\\t\")\n text = tf.strings.regex_replace(text, r\"\\\\n\", \"\\n\")\n text = tf.strings.regex_replace(text, r\"\\\\t\", \... | [
"0.6890607",
"0.6509728",
"0.6238172",
"0.6043498",
"0.58790535",
"0.5853888",
"0.5839589",
"0.58263975",
"0.58069015",
"0.5798169",
"0.5798169",
"0.5798169",
"0.57550186",
"0.5749079",
"0.5741239",
"0.573856",
"0.57360864",
"0.57360864",
"0.57360864",
"0.5729773",
"0.5724807... | 0.7568055 | 0 |
return a flavorid not in the DB | def _generate_flavorid(self):
nonexistent_flavor = 2700
flavor_ids = [value["id"] for key, value in
instance_types.get_all_types().iteritems()]
while nonexistent_flavor in flavor_ids:
nonexistent_flavor += 1
else:
return nonexistent_flavor | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def flavor_id(self):\n return self._flavor_id",
"def flavor_id(self):\n return self._flavor_id",
"def test_get_non_existent_flavor(self):\n try:\n self.flavors_client.get_flavor_details(999)\n self.fail('No exception thrown for a non-existent flavor id')\n exce... | [
"0.6119678",
"0.6119678",
"0.6045949",
"0.6031333",
"0.60261506",
"0.591185",
"0.5858374",
"0.5790065",
"0.5565923",
"0.55642855",
"0.5541844",
"0.5517942",
"0.5476757",
"0.5457186",
"0.54222244",
"0.5376874",
"0.5346884",
"0.5267501",
"0.5234335",
"0.52042115",
"0.5176118",
... | 0.68062633 | 0 |
Ensure instance types raises InvalidInput for invalid characters | def test_instance_type_create_with_special_characters(self):
name = "foo.bar!@#$%^-test_name"
flavorid = "flavor1"
self.assertRaises(exception.InvalidInput, instance_types.create,
name, 256, 1, 120, 100, flavorid) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __check_validation(input_string):\n if not input_string:\n raise NullInputException(\"Input string should be not empty\")\n if type(input_string) != str:\n raise NonStringInputException(\"Input value should be a string\")\n if len(input_string) >= 200:\n raise TooLongInputExceptio... | [
"0.68736625",
"0.6711566",
"0.65574163",
"0.6545155",
"0.64907664",
"0.64633787",
"0.6405154",
"0.6372343",
"0.6348574",
"0.6326689",
"0.6300262",
"0.6284233",
"0.6284176",
"0.6283676",
"0.62422216",
"0.6236837",
"0.62334555",
"0.6208564",
"0.61779624",
"0.6172249",
"0.616987... | 0.72997975 | 0 |
Ensures that all instance types can be retrieved | def test_get_all_instance_types(self):
session = sql_session.get_session()
total_instance_types = session.query(models.InstanceTypes).count()
inst_types = instance_types.get_all_types()
self.assertEqual(total_instance_types, len(inst_types)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_instance_classes():\n return Base_Instance.get_instance_classes()",
"def needs_unique_instance(type_):\n return type_ in unique_instance_types",
"def objects(self, cls):\n for name, info in direct_fields(self.__class__).items():\n if issubclass(cls, info.sub_fields[0].type_):\n ... | [
"0.6301667",
"0.62187815",
"0.62132394",
"0.61179364",
"0.60337543",
"0.60130465",
"0.5849791",
"0.5824665",
"0.5816945",
"0.57794785",
"0.5754539",
"0.5730565",
"0.5728285",
"0.5676546",
"0.5619532",
"0.5573343",
"0.5571297",
"0.5551837",
"0.5550403",
"0.5541071",
"0.5534637... | 0.70329773 | 0 |
Ensures that instance type creation fails with invalid args | def test_invalid_create_args_should_fail(self):
invalid_sigs = [
(('Zero memory', 0, 1, 10, 20, 'flavor1'), {}),
(('Negative memory', -256, 1, 10, 20, 'flavor1'), {}),
(('Non-integer memory', 'asdf', 1, 10, 20, 'flavor1'), {}),
(('Zero vcpus', 256, 0, 10, 20, 'fl... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_constructor_invalid():\n with pytest.raises(TypeError, match='missing 1 required positional argument'):\n PseudoPotentialData() # pylint: disable=no-value-for-parameter",
"def test_invalid_instantiation(invalid_instance):\n with pytest.raises(ValueError):\n invalid_instance()",
"d... | [
"0.69298536",
"0.6837397",
"0.67571485",
"0.674843",
"0.66988367",
"0.66542804",
"0.665428",
"0.6615131",
"0.6568029",
"0.6447652",
"0.6442925",
"0.64396554",
"0.64238024",
"0.6405531",
"0.6372361",
"0.6337279",
"0.6330088",
"0.62957954",
"0.62931526",
"0.62897813",
"0.628855... | 0.7482758 | 0 |
Ensures that name duplicates raise InstanceTypeCreateFailed | def test_duplicate_names_fail(self):
name = 'some_name'
instance_types.create(name, 256, 1, 120, 200, 'flavor1')
self.assertRaises(exception.InstanceTypeExists,
instance_types.create,
name, 256, 1, 120, 200, 'flavor2') | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_duplicate_flavorids_fail(self):\n flavorid = 'flavor1'\n instance_types.create('name one', 256, 1, 120, 200, flavorid)\n self.assertRaises(exception.InstanceTypeIdExists,\n instance_types.create,\n 'name two', 256, 1, 120, 200, flavori... | [
"0.7247416",
"0.707179",
"0.6810338",
"0.6650736",
"0.65036047",
"0.61791724",
"0.61254096",
"0.6117903",
"0.5956379",
"0.5944358",
"0.58177644",
"0.581491",
"0.57984436",
"0.57979167",
"0.5750061",
"0.57135063",
"0.5701931",
"0.5688782",
"0.5659694",
"0.56580305",
"0.5642164... | 0.82253397 | 0 |
Ensures that flavorid duplicates raise InstanceTypeCreateFailed | def test_duplicate_flavorids_fail(self):
flavorid = 'flavor1'
instance_types.create('name one', 256, 1, 120, 200, flavorid)
self.assertRaises(exception.InstanceTypeIdExists,
instance_types.create,
'name two', 256, 1, 120, 200, flavorid) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_duplicate_names_fail(self):\n name = 'some_name'\n instance_types.create(name, 256, 1, 120, 200, 'flavor1')\n self.assertRaises(exception.InstanceTypeExists,\n instance_types.create,\n name, 256, 1, 120, 200, 'flavor2')",
"def test_c... | [
"0.6808342",
"0.67799765",
"0.6590003",
"0.6453586",
"0.64351535",
"0.6365518",
"0.6303799",
"0.62312794",
"0.60959566",
"0.5960529",
"0.58526385",
"0.5842749",
"0.57575655",
"0.57458967",
"0.5740525",
"0.57401335",
"0.5717716",
"0.5713491",
"0.56291854",
"0.5617452",
"0.5548... | 0.8336245 | 0 |
ensures error raised on bad default instance type | def test_will_not_get_bad_default_instance_type(self):
self.flags(default_instance_type='unknown_flavor')
self.assertRaises(exception.InstanceTypeNotFound,
instance_types.get_default_instance_type) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def testDefaultFields_InvalidSingle(self):\n def action(field_class):\n self.assertRaises(messages.InvalidDefaultError,\n field_class,\n 1,\n default=object())\n self.ActionOnAllFieldClasses(action)",
... | [
"0.66334176",
"0.6629237",
"0.6416697",
"0.615752",
"0.6151391",
"0.60536635",
"0.6035054",
"0.59681475",
"0.59593534",
"0.5952388",
"0.594881",
"0.5944644",
"0.58902866",
"0.587271",
"0.587271",
"0.58682835",
"0.5863922",
"0.585604",
"0.58467704",
"0.5840831",
"0.58360696",
... | 0.7285694 | 0 |
Ensure deleted instance types can be read when querying flavor_id | def test_can_read_deleted_types_using_flavor_id(self):
inst_type_name = "test"
inst_type_flavor_id = "test1"
inst_type = instance_types.create(inst_type_name, 256, 1, 120, 100,
inst_type_flavor_id)
self.assertEqual(inst_type_name, inst_type["name"])
# NOTE(jk0):... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_read_deleted_false_converting_flavorid(self):\n instance_types.create(\"instance_type1\", 256, 1, 120, 100, \"test1\")\n instance_types.destroy(\"instance_type1\")\n instance_types.create(\"instance_type1_redo\", 256, 1, 120, 100, \"test1\")\n\n instance_type = instance_types.g... | [
"0.73981106",
"0.6608148",
"0.65988344",
"0.61150736",
"0.60661936",
"0.59694356",
"0.5921002",
"0.58384556",
"0.58055365",
"0.58031",
"0.5714919",
"0.5699564",
"0.56664246",
"0.5567468",
"0.5565964",
"0.54951143",
"0.54946256",
"0.5469968",
"0.5467863",
"0.54455763",
"0.5409... | 0.7891962 | 0 |
Ensure deleted instance types with active instances can be read | def test_will_list_deleted_type_for_active_instance(self):
ctxt = context.get_admin_context()
inst_type = instance_types.create("test", 256, 1, 120, 100, "test1")
instance_params = {"instance_type_id": inst_type["id"]}
instance = db.instance_create(ctxt, instance_params)
# NOTE... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _cleanup_running_deleted_instances(self, context):\n action = CONF.running_deleted_instance_action\n\n if action == \"noop\":\n return\n\n # NOTE(sirp): admin contexts don't ordinarily return deleted records\n with utils.temporary_mutation(context, read_deleted=\"yes\"):\... | [
"0.68650156",
"0.66688466",
"0.6471648",
"0.6098841",
"0.60762185",
"0.6068695",
"0.605311",
"0.60285616",
"0.59748095",
"0.5932986",
"0.59095365",
"0.5904155",
"0.58781976",
"0.58707935",
"0.57883406",
"0.5759327",
"0.57526535",
"0.5746796",
"0.567993",
"0.56586134",
"0.5654... | 0.7560171 | 0 |
Exclude tiny instance which is 512 MB | def test_min_memory_mb_filter(self):
filters = dict(min_memory_mb=513)
expected = [
'cg1.2xlarge',
'cg1.4xlarge',
'cg1.large',
'cg1.medium',
'cg1.small',
'cg1.xlarge',
'm1.large',
'm1.medium',
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def testExcessiveRamUsage(self):\n c = Simulation()\n c.set_simulation_parameters(\n seed=1,\n task=36,\n output_directory=\"output\",\n min_speciation_rate=0.5,\n sigma=2,\n tau=2,\n deme=100000000000,\n sample_s... | [
"0.5843196",
"0.58360285",
"0.57478285",
"0.5644754",
"0.5644754",
"0.5527895",
"0.54908496",
"0.54593486",
"0.5417644",
"0.53783613",
"0.53406674",
"0.5313809",
"0.52780926",
"0.52685916",
"0.5256068",
"0.5256045",
"0.5231614",
"0.5222889",
"0.52152693",
"0.5197948",
"0.5195... | 0.5887295 | 0 |
Exclude everything but large and xlarge which have >= 80 GB | def test_min_memory_mb_AND_root_gb_filter(self):
filters = dict(min_memory_mb=16384, min_root_gb=80)
expected = [
'cg1.2xlarge',
'cg1.4xlarge',
'cg1.xlarge',
'm1.xlarge',
'sh1.16xlarge',
'sh1.2xlarge',
'sh1.32xlar... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_min_memory_mb_filter(self):\n filters = dict(min_memory_mb=513)\n expected = [\n 'cg1.2xlarge',\n 'cg1.4xlarge',\n 'cg1.large',\n 'cg1.medium',\n 'cg1.small',\n 'cg1.xlarge',\n 'm1.large',\n 'm1.m... | [
"0.65132266",
"0.6262705",
"0.6109946",
"0.6001285",
"0.59283924",
"0.58663434",
"0.58393484",
"0.5810322",
"0.57387215",
"0.57092696",
"0.5683109",
"0.56573683",
"0.5645567",
"0.5604963",
"0.55473864",
"0.553308",
"0.55324054",
"0.5506308",
"0.55062497",
"0.54348725",
"0.541... | 0.6497188 | 1 |
Create the main executor classes and establish their relationships. Then start the execution thread to launch the procedure execution | def prepareExecution(self):
try:
LOG("Setting up procedure controller for " + repr(self.procId))
if self.thread is not None:
del self.thread
self.thread = None
if self.mailbox is not None:
del self.mailbox
if... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self):\n super(Executor, self).__init__()\n self.__scheduler = _scheduler.Scheduler()\n self.__procedures_lock = threading.RLock()\n self.__procedures = WeakValueDictionary()\n self.__threads_lock = threading.RLock()\n self.__executors = []\n self.__num... | [
"0.6443108",
"0.63219255",
"0.61173695",
"0.60939586",
"0.60236686",
"0.5936038",
"0.59045786",
"0.58546585",
"0.5850279",
"0.57877666",
"0.5786908",
"0.57670355",
"0.5758811",
"0.57492566",
"0.5727076",
"0.5723943",
"0.57225335",
"0.5695811",
"0.56871283",
"0.5662627",
"0.56... | 0.68501204 | 0 |
Setup procedure manager before the procedure execution | def setupProcedures(self):
try:
LOG("Setting up procedure manager")
ProcedureManager.instance().setup(ctxName)
except SpellException,ex:
traceback.print_exc( file = sys.stderr )
LOG("Could not setup procedure manager: " + repr(ex), LOG_ERROR)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def start_procedure(self):\n pass",
"def setup_manager(self) -> None:\n\n #Clean out the process list.\n self.process_list.clear()\n for _ in range(self.num_processes):\n p = Process(target=self.multiprocessing_job,\n args=(self.process_job,))\n ... | [
"0.679288",
"0.6760889",
"0.6388826",
"0.61486053",
"0.60546744",
"0.5966077",
"0.5869143",
"0.5832843",
"0.5731313",
"0.5706904",
"0.5699991",
"0.56837374",
"0.5656353",
"0.5656119",
"0.56130314",
"0.56015164",
"0.56015164",
"0.56015164",
"0.5595485",
"0.5575912",
"0.5558897... | 0.7013467 | 0 |
Perform the cleanup. If executionOnly is True, only the execution thread is stopped. This implies that the execution context is reset, and this is used tipically for reloading. If executionOnly is False, an entire cleanup is performed, including the SPELL driver. | def cleanup(self, executionOnly = False ):
LOG("Stopping execution")
if not executionOnly:
LOG("Stopping client interface")
ClientIF.cleanup()
self.thread.stop()
self.thread.join()
self.cleanResources(not executionOnly)
if not executionOnly... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clean_up_executors(self):\n pass",
"def cleanup(self):\n logger.debug('Beginning cleanup ...')\n self.stop()\n\n #Clear subscriptions\n for sub, dev in self.subs.items():\n dev.clear_sub(sub)\n\n #Clear databases\n self.subs.clear()\n self.cmds.c... | [
"0.60352564",
"0.5982608",
"0.57991225",
"0.5793357",
"0.5750608",
"0.5737773",
"0.5721506",
"0.57066435",
"0.5706069",
"0.5702562",
"0.569888",
"0.5698602",
"0.5697382",
"0.5674511",
"0.56625444",
"0.5627837",
"0.56259656",
"0.562358",
"0.5611727",
"0.55947363",
"0.5589872",... | 0.7674899 | 0 |
Obtain the absolute path to the AsRun file. | def getAsRunFile(self):
return ClientIF.getAsRun() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_R_script_path(self):\r\n return join(self._get_R_script_dir(), self._R_script)",
"def _get_R_script_path(self):\r\n return join(self._get_R_script_dir(), self._r_script)",
"def _get_R_script_path(self):\r\n return join(self._get_R_script_dir(), self._r_script)",
"def exepath(fil... | [
"0.6982224",
"0.6978412",
"0.6978412",
"0.69593924",
"0.69361335",
"0.68926036",
"0.6841561",
"0.67743593",
"0.67432815",
"0.6642484",
"0.6639229",
"0.6638133",
"0.6629451",
"0.6616786",
"0.6586052",
"0.6574156",
"0.6574156",
"0.65583396",
"0.6546417",
"0.65249336",
"0.649549... | 0.6983227 | 0 |
Start a wait condition processing in the executor. If no callback is given, the executor simply goes to WAITING status. If a callback is provided, it is called periodically to check wether the condition (whatever it is) is fulfilled or not (this is indicated by returning True or False in the callback, respectively). On... | def startWait(self, checkCallback = None, period = 0.5 ):
self.scheduler.startWait(checkCallback,period) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def ensure_condition(callback, *args,\n sleep_step=0.001, max_wait_time=30, **kwargs):\n event = Event()\n condition = ConditionWaiter(event, callback, *args,\n sleep_step=sleep_step, **kwargs)\n condition.start()\n result = event.wait(max_wait_time)\n... | [
"0.70611024",
"0.5899853",
"0.5827729",
"0.57954097",
"0.5749593",
"0.57395905",
"0.57161385",
"0.5680078",
"0.56610894",
"0.5616939",
"0.56027",
"0.5593041",
"0.556902",
"0.55154413",
"0.55154413",
"0.5512612",
"0.54915106",
"0.5483529",
"0.54652953",
"0.5456005",
"0.5432583... | 0.6476449 | 1 |
Abort the execution of the procedure. Tipically used by SPELL language wrappers. | def abort(self):
LOG("Aborting execution")
self.controller.abort() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _doAbort(self):\n self._cmdAbort()",
"def Abort(self):\n handler = self.get_command_object(\"Abort\")\n handler()",
"def abort(self):\n print(\"abort\")",
"def ctxAbort(*args, **kwargs)->None:\n pass",
"def abort(self):\n raise NotImplementedError",
"def abort() ... | [
"0.7795741",
"0.7681984",
"0.7611163",
"0.75484663",
"0.74770874",
"0.7359959",
"0.72669864",
"0.7252203",
"0.7106759",
"0.7094899",
"0.7078785",
"0.70316947",
"0.6961344",
"0.6961344",
"0.69130546",
"0.68980694",
"0.6870538",
"0.6856597",
"0.6790143",
"0.6785233",
"0.675265"... | 0.78669137 | 0 |
Process an incomming message from the clients. | def processMessage(self, msg):
LOG("Received message: " + msg.getId())
# Process messages incoming from child executor, if any
procId = msg[FIELD_PROC_ID]
if procId != self.procId:
if self.childManager.hasChild():
self.childManager.processChild... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _process_messages(self):\r\n \r\n self._print(\"%s: Starting _process messages, looking out for special messages:\" \\\r\n % (self._clientnr))\r\n \r\n # Set some expected messages.\r\n expected = {}\r\n expected['clientconfirm'] = cb.CLIENTCONFIRM[:cb.CLIEN... | [
"0.7099424",
"0.69237363",
"0.692279",
"0.68362087",
"0.6694693",
"0.6604166",
"0.66036946",
"0.6588213",
"0.6558896",
"0.64540213",
"0.64526254",
"0.6445058",
"0.64315796",
"0.64261127",
"0.6419149",
"0.63898546",
"0.63777936",
"0.6377558",
"0.6338513",
"0.63202727",
"0.6307... | 0.70465255 | 1 |
Obtain the current stack position. | def getStackPosition(self):
return self.callstack.getStack() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def position(self):\n return self.stack.position()",
"def peek(self) -> int:\n return self.stack[len(self.stack)-1]",
"def top(self) -> int:\n return self.stack[-1]",
"def top(self) -> int:\n return self.stack[-1]",
"def read_stack_pointer(self):\n return self.STACK_POINTER",... | [
"0.8640317",
"0.74863195",
"0.74775666",
"0.74775666",
"0.7423859",
"0.73601425",
"0.73447627",
"0.7341382",
"0.726584",
"0.7190162",
"0.7152273",
"0.7098277",
"0.70845926",
"0.7058605",
"0.7058605",
"0.7058605",
"0.70164347",
"0.69690615",
"0.6949782",
"0.6937096",
"0.690912... | 0.8502217 | 1 |
Used by the language to change the runinto flag | def setRunInto(self, enabled):
if enabled == True:
LOG("Enabled RunInto")
self.controller.enableRunInto()
elif enabled == False:
LOG("Disabled RunInto")
self.controller.disableRunInto()
#TODO: send notification EXECUTOR CONFIGURED
| {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run_cmd(self):\r\n self.run = True",
"def flag():\n pass",
"def take_action_on_flags(self, *args, **kwargs):\r\n pass",
"def RUN(self):",
"def set_flag(self, new):\n self.flag = new",
"def flag_change(self, flag):\n\n if flag == 0:\n self.setText(\"全部暂停\")\n ... | [
"0.62337434",
"0.614811",
"0.607644",
"0.57373494",
"0.5693293",
"0.5666935",
"0.5614315",
"0.56027615",
"0.55291516",
"0.55280423",
"0.5514334",
"0.54845285",
"0.5481132",
"0.5475954",
"0.54742694",
"0.54494107",
"0.5439435",
"0.5434992",
"0.5423222",
"0.5420009",
"0.5408224... | 0.6149809 | 1 |
Used by the language to change the browsablelib flag | def setBrowsableLib(self, enabled):
if enabled == True:
LOG("Enabled browsable lib")
self.thread.setBrowsableLib(True)
elif enabled == False:
LOG("Disabled browsable lib")
self.thread.setBrowsableLib(False)
#TODO: send notification EXECUTOR ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def set_flag(self, new):\n self.flag = new",
"def setFlag(self, flag, value) -> None:\n ...",
"def test_setFlags(self):\n self._flagsTest('setFlags', b'FLAGS')",
"def OMBool(self, b):\n if b:\n return self.OMSymbol(\"Python\", \"true\")\n else:\n retur... | [
"0.5999886",
"0.5862498",
"0.58051765",
"0.5767794",
"0.5619172",
"0.5529246",
"0.5510968",
"0.54556364",
"0.5427888",
"0.5407133",
"0.5404582",
"0.53616965",
"0.53187567",
"0.5304399",
"0.5264561",
"0.52620834",
"0.52540123",
"0.5248532",
"0.523425",
"0.5226875",
"0.52035123... | 0.59958357 | 1 |
Trains the agent for episode_per_ticker, on each of num_tickers, looping over the approved list of tickers. This is a convenience function. | def train(self, num_tickers=4, episodes_per_ticker=5, **kwargs):
num_tickers = min(num_tickers, len(self.filtered_tickers))
for i in range(num_tickers):
ticker = self.filtered_tickers[i % num_tickers]
env = self.ENV_CONSTRUCTOR(ticker=ticker, **kwargs)
for j in tqdm(r... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def train_multiple_eps(self, env, no_episodes=200, horizon=1000, lr=0.1):\n\n\t\tr_vec = []\n\t\tep_len_vec = []\n\t\tfor i in range(no_episodes):\n\n\t\t\t# Run the agent for one episode and get a vector of rewards and a scalar for episode length\n\t\t\tr_ep, ep_len = self.train_one_eps(env, horizon=horizon, lr=l... | [
"0.6178398",
"0.6169245",
"0.60627633",
"0.6004256",
"0.5952633",
"0.59228915",
"0.5920008",
"0.58501834",
"0.5811061",
"0.5760288",
"0.57591045",
"0.5697758",
"0.56761396",
"0.567613",
"0.56650954",
"0.56085414",
"0.5605246",
"0.55622375",
"0.5519902",
"0.5485799",
"0.544439... | 0.7333398 | 0 |
adds padding to the side of images, create a mask, and moves the results to the imag and mask folders | def run_padding(self):
image_padded, mask, self.pad_to_right, self.pad_to_bottom = gen_padded_image_and_mask (os.path.join('utils_dfn/temp', self.file_name_with_ext),
self.new_height, self.new_width)
cv2.imwrite(os.path.join('utils... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def mask_images(self, folder_name, mask_image_name):\n\n photo_list = self.get_photo_list(folder_name)\n masked_folder_name = folder_name + '_background'\n\n try:\n print(\"Making dir \" + str(masked_folder_name) + \" for masking\")\n os.mkdir(masked_folder_name)\n ... | [
"0.69298804",
"0.67375904",
"0.673584",
"0.6623443",
"0.65959984",
"0.658947",
"0.6578154",
"0.6525031",
"0.6488499",
"0.64011204",
"0.6395551",
"0.6377289",
"0.63664716",
"0.62546206",
"0.6229988",
"0.62280905",
"0.6211939",
"0.6206255",
"0.61793363",
"0.6176746",
"0.6149905... | 0.6907533 | 1 |
rescale an images to the new_width and new_height using the model provided and adds file_description to the result image | def rescale_image(self, img_file, new_width, new_height, model_path, file_description):
cwd = os.getcwd()
self.new_width = new_width
self.new_height = new_height
self.extract_file_name(img_file)
shutil.copy(img_file, os.path.join('utils_dfn/temp', self.file_name_with_ext))
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def restore_to_correct_size(self, file_description):\n file_name = os.listdir('utils_dfn/output/result')[0]\n file_name_with_ext, file_name = extract_file_name(file_name)\n new_file = os.path.join('static/rescaled_images', self.file_name + file_description + '.png')\n img = cv2.imread(o... | [
"0.6986328",
"0.6633199",
"0.6617432",
"0.6300467",
"0.6101597",
"0.6018169",
"0.59406203",
"0.5932833",
"0.59259355",
"0.58973444",
"0.58908314",
"0.58661085",
"0.58657044",
"0.5855355",
"0.583179",
"0.5764614",
"0.5758361",
"0.5737768",
"0.5731653",
"0.5730573",
"0.57147723... | 0.8180639 | 0 |
removes any files and subfolders that temporary created in the rescaling process | def clean():
folders = ['utils_dfn/temp', 'utils_dfn/img', 'utils_dfn/mask', 'utils_dfn/output']
for folder in folders:
for item in os.listdir(folder):
item_path = os.path.join(folder, item)
if os.path.isdir(item_path):
shutil.rmtree(item_path)
elif os... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def cleanUpTemporaryFiles(options):\n os.system(\"rm \"+options.output_directory_per_run+\"/*.abundance\")\n os.system(\"rm \"+options.output_directory_per_run+\"/*.phasing_score\")\n os.system(\"rm \"+options.output_directory_per_run+\"/*regionsOfInterest*\")\n os.system(\"mv \"+options.output_directo... | [
"0.74612176",
"0.7361185",
"0.7213539",
"0.713342",
"0.71236914",
"0.70721453",
"0.7030905",
"0.7019349",
"0.6994895",
"0.6969091",
"0.6945633",
"0.6941198",
"0.6920303",
"0.6905462",
"0.6897785",
"0.68775487",
"0.6850482",
"0.68474907",
"0.68297064",
"0.6825779",
"0.6807118"... | 0.75486666 | 0 |
Takes an index and returns the matching Address index index to search on Address address matched to index | def getAddressAtIndex(self, index: int) -> ghidra.program.model.address.Address:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def filter_ipaddr_index(base_address, index):\n try:\n base_address_str = unicode(base_address)\n except NameError as ex:\n base_address_str = str(base_address)\n return IPv4Address(base_address_str) + int(index)",
"def select_search(search_result: list, index: int):\n return search_res... | [
"0.6476046",
"0.6268623",
"0.6065724",
"0.6051883",
"0.5961066",
"0.5914628",
"0.58707434",
"0.5808841",
"0.57986736",
"0.56956106",
"0.5596284",
"0.55899864",
"0.55754566",
"0.55578613",
"0.5537989",
"0.5520875",
"0.5517261",
"0.54930437",
"0.54735434",
"0.5472506",
"0.54696... | 0.7229227 | 0 |
Eliminates incompatible values from var's neighbors' domains, modifying the original csp. Returns an alphabetically sorted list of the neighboring variables whose domains were reduced, with each variable appearing at most once. If no domains were reduced, returns empty list. If a domain is reduced to size 0, quits imme... | def eliminate_from_neighbors(csp, var) :
eliminated_vars=[]
val1s=csp.get_domain(var)
neighbors=csp.get_neighbors(var)
for neighbor in neighbors:
eliminated=False
constraints=csp.constraints_between(var,neighbor)
tem=csp.copy()
neighbor_domain=tem.get_domain(neighbor)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def eliminate_from_neighbors(csp, var) :\n reduced = []\n val = csp.get_assigned_value(var)\n replacement = []\n for constraint in csp.constraints_between(var,None):\n var2 = constraint.var2\n domainCopy = csp.domains[var2][:]\n numLeft = len(domainCopy)\n if (val!=None):\n ... | [
"0.78952694",
"0.71214586",
"0.7096222",
"0.68540066",
"0.6828208",
"0.68044823",
"0.678496",
"0.6536461",
"0.6151661",
"0.60821366",
"0.5942006",
"0.5861008",
"0.5838741",
"0.5812621",
"0.5799095",
"0.56493247",
"0.5620978",
"0.56105685",
"0.55851865",
"0.55830467",
"0.55132... | 0.7493027 | 1 |
Uses constraints to reduce domains, modifying the original csp. If queue is None, initializes propagation queue by adding all variables in their default order. Returns a list of all variables that were dequeued, in the order they were removed from the queue. Variables may appear in the list multiple times. If a domain ... | def domain_reduction(csp, queue=None) :
if queue==None:
queue=csp.get_all_variables()
dequeued=[]
while len(queue)!=0:
current_var=queue.pop(0)
dequeued.append(current_var)
eliminated=eliminate_from_neighbors(csp,current_var)
if(eliminated==None):
return N... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def domain_reduction(csp, queue=None) :\n if (queue==None):\n queue = csp.get_all_variables()\n dequeued = []\n while len(queue)!=0:\n removedVar = queue[0]\n dequeued.append(removedVar)\n queue = queue[1:]\n for constraint in csp.constraints_between(removedVar,None)[:]:... | [
"0.81130826",
"0.73415357",
"0.719081",
"0.7137959",
"0.6930692",
"0.68671155",
"0.6227046",
"0.6071545",
"0.5690307",
"0.560006",
"0.5529515",
"0.5403914",
"0.53377",
"0.5325278",
"0.5288351",
"0.52441835",
"0.52135086",
"0.51562387",
"0.51547736",
"0.5154067",
"0.51160634",... | 0.82298666 | 0 |
Solves the problem using depthfirst search with forward checking and propagation through singleton domains. Same return type as solve_constraint_dfs. | def solve_constraint_propagate_singleton_domains(problem) :
agenda=[problem]
extension=0
current_prob=agenda.pop(0)
extension+=1
#check failure
if has_empty_domains(current_prob) or (not check_all_constraints(current_prob)):
return (None, extension)
#check success
all_assigned=... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def solve_constraint_propagate_singleton_domains(problem) :\n q = [problem]\n extCount = 0\n while len(q)!=0:\n removed = q[0]\n q = q[1:]\n extCount+=1\n if has_empty_domains(removed) or check_all_constraints(removed)==False:\n continue\n if len(removed.unass... | [
"0.62974983",
"0.6084218",
"0.60134697",
"0.60103655",
"0.6005473",
"0.600404",
"0.5947959",
"0.5908106",
"0.58490694",
"0.58153534",
"0.58153534",
"0.58153534",
"0.57803607",
"0.5777507",
"0.57477474",
"0.5727428",
"0.57169443",
"0.56951916",
"0.5681387",
"0.5675661",
"0.567... | 0.628712 | 1 |
Returns True if var should be enqueued under the allreduceddomains condition, otherwise False | def condition_domain_reduction(csp, var) :
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def condition_singleton(csp, var) :\n if len(csp.get_domain(var))==1:\n return True\n return False",
"def condition_singleton(csp, var) :\n return len(csp.get_domain(var))==1",
"def any_holds(self, domains, const, env, other_vars, ind=0, assigned_vars=[]):\r\n # All the variables in the ... | [
"0.6265647",
"0.6243808",
"0.5521765",
"0.5475188",
"0.54499143",
"0.5381839",
"0.5379803",
"0.5367007",
"0.53247434",
"0.5320797",
"0.53065324",
"0.53065324",
"0.5259333",
"0.52381426",
"0.5214658",
"0.5190644",
"0.5171438",
"0.5169606",
"0.5158193",
"0.5148482",
"0.51421607... | 0.6505326 | 1 |
Returns True if var should be enqueued under the singletondomains condition, otherwise False | def condition_singleton(csp, var) :
if len(csp.get_domain(var))==1:
return True
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def condition_singleton(csp, var) :\n return len(csp.get_domain(var))==1",
"def is_shared_with_domain(self):\n return self.has_label(SHAREDWITHDOMAIN_LABEL)",
"def condition_domain_reduction(csp, var) :\n return True",
"def condition_domain_reduction(csp, var) :\n return True",
"def allow_bare_... | [
"0.7515692",
"0.6359609",
"0.6248687",
"0.6248687",
"0.6022763",
"0.6022763",
"0.6010284",
"0.58347994",
"0.5811564",
"0.5811564",
"0.5689526",
"0.55664146",
"0.55624366",
"0.5551198",
"0.55263907",
"0.55263907",
"0.5476592",
"0.5419524",
"0.54008955",
"0.5396627",
"0.5390506... | 0.7757652 | 0 |
Returns True if var should be enqueued under the forwardchecking condition, otherwise False | def condition_forward_checking(csp, var) :
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def forward_checking(csp, var, value, assignment, removals):\r\n csp.support_pruning()\r\n check=0\r\n for B in csp.neighbors[var]:\r\n if B not in assignment:\r\n for b in csp.curr_domains[B][:]:\r\n check+=1\r\n if not csp.constraints(var, value, B, b):\r\... | [
"0.6296808",
"0.5990182",
"0.5972382",
"0.5852342",
"0.58257467",
"0.5817982",
"0.5796664",
"0.57221603",
"0.569893",
"0.5688268",
"0.56624824",
"0.56278247",
"0.5602736",
"0.5596941",
"0.55571604",
"0.5531923",
"0.5524298",
"0.55127466",
"0.5474215",
"0.5456701",
"0.54431474... | 0.75584596 | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.