query
stringlengths
9
3.4k
document
stringlengths
9
87.4k
metadata
dict
negatives
listlengths
4
101
negative_scores
listlengths
4
101
document_score
stringlengths
3
10
document_rank
stringclasses
102 values
Method which calculate Offensive Ratio of a player. The total points scored in 100 possessions
def set_offensive_ratio(self): bx = self.get_standard_stats() team = self.get_team_stats() opp_team = self.get_opp_team_stats() if bx["minutes"] > 0 and (bx["t2p_int"] + bx["t3p_int"]) > 0: fgm = bx["t2p_conv"] + bx["t3p_conv"] fga = bx["t2p_int"] + bx["t3p_int"] ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "async def player_ratio(self, ctx):\r\n player = ctx.message.content.split(' ')[1]\r\n if os.environ.get(\"WoW_Token\") is None:\r\n return\r\n else:\r\n async with aiohttp.ClientSession().get('https://us.api.battle.net/wow/character/zul\\'jin/' + player + '?fields=pvp&loc...
[ "0.6951562", "0.6515817", "0.644771", "0.6344681", "0.62165296", "0.62093073", "0.61908257", "0.6157803", "0.6073757", "0.60568166", "0.6025391", "0.60042846", "0.5987803", "0.5981942", "0.5976337", "0.5951976", "0.5948813", "0.5936161", "0.593527", "0.593107", "0.5930244", ...
0.6635203
1
Linear interpolation for converting between physics and engineering units.
def __init__(self, coef, f1=unit_function, f2=unit_function): super(self.__class__, self).__init__(f1, f2) self.p = np.poly1d(coef)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def interpolate_linear(self, transect):\n\n u = np.copy(self.u_mps)\n v = np.copy(self.v_mps)\n\n valid = np.isnan(u) == False\n\n # Check for valid data\n if sum(valid) > 1 and sum(self.valid_data[0, :]) > 1:\n\n # Compute ens_time\n ens_time = np.nancumsum...
[ "0.63465023", "0.62840116", "0.6036108", "0.59930384", "0.59634036", "0.59620404", "0.5953784", "0.59198254", "0.5882442", "0.5880557", "0.5876995", "0.5843551", "0.5801997", "0.57321805", "0.5688701", "0.5683657", "0.5601913", "0.55995375", "0.55786633", "0.5578463", "0.5534...
0.0
-1
Convert between engineering and physics units.
def _raw_eng_to_phys(self, eng_value): return self.p(eng_value)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def convert_units(self):\n for prod in (\"ier\", \"ier_inc_rain\"):\n self.data[prod].data[:] /= 1e6", "def original_units(self):\n self.physical_units(distance=self.infer_original_units('km'),\n velocity=self.infer_original_units('km s^-1'),\n ...
[ "0.6702368", "0.661202", "0.6604063", "0.6344034", "0.61844754", "0.6114347", "0.60904294", "0.6029163", "0.6023127", "0.59929097", "0.5970022", "0.59694815", "0.5943942", "0.5935189", "0.59149885", "0.59114206", "0.5895953", "0.5884657", "0.58838505", "0.5863761", "0.5856587...
0.57462955
29
Convert between physics and engineering units.
def _raw_phys_to_eng(self, physics_value): roots = (self.p - physics_value).roots if len(roots) == 1: x = roots[0] return x else: raise ValueError("There doesn't exist a corresponding engineering value or " "they are not unique:", ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def convert_units(self):\n for prod in (\"ier\", \"ier_inc_rain\"):\n self.data[prod].data[:] /= 1e6", "def original_units(self):\n self.physical_units(distance=self.infer_original_units('km'),\n velocity=self.infer_original_units('km s^-1'),\n ...
[ "0.67884886", "0.65156615", "0.6370421", "0.62429684", "0.60196847", "0.59708744", "0.59549516", "0.59494585", "0.59487826", "0.59480655", "0.591996", "0.5908836", "0.590394", "0.5892939", "0.58907676", "0.58825135", "0.58816415", "0.5879758", "0.5878579", "0.5834652", "0.580...
0.60435265
4
PChip interpolation for converting between physics and engineering units.
def __init__(self, x, y, f1=unit_function, f2=unit_function): super(self.__class__, self).__init__(f1, f2) self.x = x self.y = y self.pp = PchipInterpolator(x, y) diff = np.diff(y) if not ((np.all(diff > 0)) or (np.all((diff < 0)))): raise ValueError("Given c...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _raw_phys_to_eng(self, physics_value):\n y = [val - physics_value for val in self.y]\n new_pp = PchipInterpolator(self.x, y)\n roots = new_pp.roots()\n if len(roots) == 1:\n x = roots[0]\n return x\n else:\n raise UniqueSolutionException(\"The...
[ "0.6409062", "0.6191294", "0.6163329", "0.60624963", "0.59122026", "0.591134", "0.5853295", "0.57724625", "0.5744279", "0.57384187", "0.5700157", "0.5695096", "0.56918746", "0.56765395", "0.56729674", "0.56695503", "0.56321025", "0.5626728", "0.56115127", "0.5593795", "0.5577...
0.0
-1
Convert between engineering and physics units.
def _raw_eng_to_phys(self, eng_value): return self.pp(eng_value)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def convert_units(self):\n for prod in (\"ier\", \"ier_inc_rain\"):\n self.data[prod].data[:] /= 1e6", "def original_units(self):\n self.physical_units(distance=self.infer_original_units('km'),\n velocity=self.infer_original_units('km s^-1'),\n ...
[ "0.6702368", "0.661202", "0.6604063", "0.6344034", "0.61844754", "0.6114347", "0.60904294", "0.6029163", "0.6023127", "0.59929097", "0.5970022", "0.59694815", "0.5943942", "0.5935189", "0.59149885", "0.59114206", "0.5895953", "0.5884657", "0.58838505", "0.5863761", "0.5856587...
0.5688327
32
Convert between physics and engineering units.
def _raw_phys_to_eng(self, physics_value): y = [val - physics_value for val in self.y] new_pp = PchipInterpolator(self.x, y) roots = new_pp.roots() if len(roots) == 1: x = roots[0] return x else: raise UniqueSolutionException("The function does...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def convert_units(self):\n for prod in (\"ier\", \"ier_inc_rain\"):\n self.data[prod].data[:] /= 1e6", "def original_units(self):\n self.physical_units(distance=self.infer_original_units('km'),\n velocity=self.infer_original_units('km s^-1'),\n ...
[ "0.67884886", "0.65156615", "0.6370421", "0.62429684", "0.60435265", "0.60196847", "0.59708744", "0.59549516", "0.59494585", "0.59487826", "0.59480655", "0.591996", "0.5908836", "0.590394", "0.5892939", "0.58907676", "0.58825135", "0.58816415", "0.5879758", "0.5878579", "0.58...
0.0
-1
This function is used to make the final dataset to be used, computes and adds the new WsRF and service classification
def make_dataset(interim_file_path, processed_file_path, weights, version): qws_wsrf, qws_complete_numpy_array = src.dataset.compute_wsrf.compute_wsrf(interim_file_path, weights) # qws_complete_numpy_array_temp = np.append(qws_complete_numpy_array, qws_wsrf[:, np.newaxis], axis=1) qws_wsrf_level = np.array(...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __train__(self):\n if (self.type_camf == 'CAMF_CI'):\n #users, items, context, ratings\n ci = camf_ci.CI_class(self.__users_array__, self.__items_array__, self.__context_array__, self.__ratings__, self.fold, self.lr, self.factors)\n predictions, losses = ci.fit()\n ...
[ "0.66069067", "0.66063356", "0.6386136", "0.63641405", "0.6359857", "0.6340846", "0.63389325", "0.63323617", "0.6254566", "0.62452006", "0.6183691", "0.61397463", "0.61367977", "0.6132934", "0.61155736", "0.6114331", "0.6066086", "0.6050593", "0.60490036", "0.6045469", "0.603...
0.6155825
11
Return the serializer instance that should be used for validating and deserializing input, and for serializing output.
def get_serializer_in(self, *args, **kwargs): serializer_class = self.get_serializer_class_in() kwargs['context'] = self.get_serializer_context() return serializer_class(*args, **kwargs)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getSerializer():", "def get_serializer(self, *args, **kwargs):\n serializer_class = self.get_serializer_class()\n kwargs['context'] = self.get_serializer_context()\n return serializer_class(*args, **kwargs)", "def serializer_for(self, obj):\n # 1-NULL serializer\n if obj ...
[ "0.72009987", "0.7115752", "0.69366866", "0.6924428", "0.68449354", "0.6820688", "0.67195165", "0.6692233", "0.6686074", "0.65120816", "0.6473344", "0.6473284", "0.6444412", "0.6443525", "0.6418904", "0.63524395", "0.6348317", "0.63381505", "0.6311651", "0.63109744", "0.62789...
0.67095476
7
Do login action here. For example in case of session authentication store the session in cookies.
def do_login(self, backend, user):
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def login(self):\n\n self.__login_if_required()", "def login(self):\n if self._cookie_cached(self.login_email):\n self.cookie_login(self.login_email)\n else:\n self.new_login(self.login_email, self.login_pass)", "def login_perform():\n try:\n user_name = req...
[ "0.7799108", "0.7728997", "0.7510619", "0.7478229", "0.7478229", "0.7477876", "0.74192667", "0.7330238", "0.7261792", "0.72554547", "0.72398543", "0.7227756", "0.7222385", "0.7211491", "0.7187431", "0.71860313", "0.7163313", "0.7160891", "0.7127272", "0.7124372", "0.71183175"...
0.7133062
18
auth_data will be used used as request_data in strategy
def set_input_data(self, request, auth_data): request.auth_data = auth_data
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_oauth_data():", "def __init__(self, my_data, my_auth):\n self.user = my_auth.user\n self.password = my_auth.password\n self.my_data = my_data", "def authenticate(self, request):\n auth_data = super().authenticate(request)\n if not auth_data:\n return auth_d...
[ "0.6669421", "0.6569925", "0.63427466", "0.61100876", "0.6065976", "0.6054941", "0.6029151", "0.60213995", "0.6012752", "0.5897798", "0.5737002", "0.5730088", "0.56567615", "0.5615505", "0.56064767", "0.55513734", "0.5519616", "0.5500598", "0.5468376", "0.5468376", "0.5440677...
0.71807003
0
Tests that only 'admin' can add a product
def test_only_admin_can_create_product(self): resp = self.admin_create_user() reply = self.attendant_login() token = reply['token'] product = dict( prod_name='NY_denims', category='denims', stock=20, price=150 ) resp = self....
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_non_admin_cannot_delete_product(self):\n resp = self.admin_register()\n reply = self.admin_login()\n token = reply['token']\n product = dict(\n prod_name='NY_denims',\n category='denims',\n stock=20,\n price=150\n )\n re...
[ "0.7732614", "0.766534", "0.746467", "0.73577404", "0.7302724", "0.7297793", "0.7198699", "0.7088031", "0.706756", "0.69749635", "0.6925475", "0.6893543", "0.6830343", "0.68255603", "0.6805827", "0.68006784", "0.677526", "0.67369896", "0.6678268", "0.66471297", "0.6601341", ...
0.8407797
0
Tests that 'admin' can add a product
def test_admin_create_product(self): resp = self.admin_register() reply = self.admin_login() token = reply['token'] product = dict( prod_name='NY_denims', category='denims', stock=20, price=150 ) resp = self.client.post( ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_only_admin_can_create_product(self):\n resp = self.admin_create_user()\n reply = self.attendant_login()\n token = reply['token']\n product = dict(\n prod_name='NY_denims',\n category='denims',\n stock=20,\n price=150\n )\n ...
[ "0.8125268", "0.78284925", "0.7689276", "0.74345493", "0.7312975", "0.72979146", "0.71163535", "0.709621", "0.70959914", "0.7021732", "0.6964215", "0.6953487", "0.6913336", "0.6887993", "0.6846328", "0.6843517", "0.6843496", "0.68297696", "0.67998624", "0.6782752", "0.6768684...
0.79675835
1
Test admin cannot create a product with a blacklisted token
def test_cannot_create_product_with_blacklisted_token(self): resp = self.admin_register() reply = self.admin_login() token = reply['token'] resp = self.client.delete( '/api/v1/logout', headers={'Authorization': 'Bearer {}'.format(token)} ) reply =...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_cannot_view_a_product_with_blacklisted_token(self):\n resp = self.admin_register()\n reply = self.admin_login()\n token = reply['token']\n product = dict(\n prod_name='NY_denims',\n category='denims',\n stock=20,\n price=150\n ...
[ "0.82479733", "0.7897591", "0.7884179", "0.78223985", "0.7625364", "0.7585557", "0.7400365", "0.7375994", "0.72420007", "0.7152579", "0.7103639", "0.70389014", "0.6944365", "0.6929796", "0.68858266", "0.68301815", "0.67753994", "0.6750073", "0.6746582", "0.66715974", "0.66688...
0.8788049
0
Tests that 'admin' cannot add a product with empty fields
def test_admin_cannot_create_product_with_empty_fields(self): resp = self.admin_register() reply = self.admin_login() token = reply['token'] product = dict( prod_name='', category='', stock=20, price=150 ) resp = self.client...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_cannot_make_sale_with_missing_fields(self):\n reply = self.admin_add_product()\n\n resp = self.admin_create_user()\n reply = self.attendant_login()\n token = reply['token']\n sale = dict(products = [\n {\n \"prod_name\":\"\", \n \...
[ "0.7727357", "0.71426547", "0.71228373", "0.6888725", "0.6875848", "0.68659735", "0.68113697", "0.6800745", "0.6779112", "0.67721987", "0.6709652", "0.66885155", "0.6665036", "0.6651361", "0.6607132", "0.66057837", "0.66039413", "0.65725106", "0.6552758", "0.6544897", "0.6522...
0.8373025
0
Tests that product_name field cannot contain a number
def test_Product_name_cannot_contain_a_number(self): resp = self.admin_register() reply = self.admin_login() token = reply['token'] product = dict( prod_name='NY_3', category='denims', stock=20, price=150 ) resp = self.clien...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_category_cannot_contain_a_number(self):\n resp = self.admin_register()\n reply = self.admin_login()\n token = reply['token']\n product = dict(\n prod_name='NY_denims',\n category='4dens',\n stock=20,\n price=150\n )\n re...
[ "0.6742002", "0.6642998", "0.6555487", "0.6555487", "0.6454647", "0.62910545", "0.62258327", "0.6198766", "0.6166252", "0.61075205", "0.5994341", "0.5968352", "0.5964386", "0.595047", "0.5949145", "0.5943742", "0.59381294", "0.591026", "0.5901904", "0.5901547", "0.58894527", ...
0.76176125
0
Tests that category field cannot contain a number
def test_category_cannot_contain_a_number(self): resp = self.admin_register() reply = self.admin_login() token = reply['token'] product = dict( prod_name='NY_denims', category='4dens', stock=20, price=150 ) resp = self.clien...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_isNumericCategory(self):\r\n obs = self.overview_map.isNumericCategory('Treatment')\r\n self.assertEqual(obs, False)\r\n\r\n obs = self.overview_map.isNumericCategory('DOB')\r\n self.assertEqual(obs, True)", "def test_isNumericCategory(self):\n obs = self.overview_map....
[ "0.69292754", "0.6892475", "0.68267983", "0.68267983", "0.6329393", "0.60511804", "0.6026339", "0.60021937", "0.5988064", "0.5981536", "0.5980512", "0.5917058", "0.59100056", "0.59020984", "0.5897836", "0.5872285", "0.58462423", "0.58406997", "0.58369875", "0.58208215", "0.58...
0.70390165
0
Tests that stock and price fields must be numbers
def test_stock_and_price_must_be_numbers(self): resp = self.admin_register() reply = self.admin_login() token = reply['token'] product = dict( prod_name='NY_denims', category='denims', stock='stock', price='money' ) resp = s...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_add_sale_with_price_not_digit_format(self):\n self.register_admin_test_account()\n token = self.login_admin_test()\n\n response = self.app_test_client.post('{}/saleorder'.format(\n self.base_url), json={'name': \"Hand Bag\", 'price': \"1500\", 'quantity': 3, 'totalamt': \"\...
[ "0.73344076", "0.72246283", "0.72246283", "0.68624747", "0.66491514", "0.6644348", "0.66039526", "0.65944123", "0.6510274", "0.64985764", "0.6415647", "0.6365934", "0.6306292", "0.6289345", "0.6277049", "0.6271073", "0.62253267", "0.6222383", "0.6221313", "0.616871", "0.61683...
0.7861267
0
Tests that product already exists in the Inventory
def test_product_exists_in_inventory(self): resp = self.admin_register() reply = self.admin_login() token = reply['token'] product = dict( prod_name='NY_denims', category='denims', stock=20, price=150 ) resp = self.client.po...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_view_product_that_doesnot_exist_in_inventory(self):\n resp = self.admin_register()\n reply = self.admin_login()\n token = reply['token']\n product = dict(\n prod_name='NY_denims',\n category='denims',\n stock=20,\n price=150\n ...
[ "0.7496905", "0.7326862", "0.71235555", "0.68696725", "0.6750119", "0.6638737", "0.65924627", "0.6544556", "0.65392476", "0.6516768", "0.6488533", "0.6471995", "0.64518577", "0.6451675", "0.64378035", "0.63537824", "0.6353224", "0.63370115", "0.6325946", "0.6315863", "0.63116...
0.81727195
0
Tests that a user can view a product in the Inventory
def test_view_a_product(self): resp = self.admin_register() reply = self.admin_login() token = reply['token'] product = dict( prod_name='NY_denims', category='denims', stock=20, price=150 ) resp = self.client.post( ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_is_product_show(self):\n\n self.selenium.get(\"http://localhost:8000/\")\n response = self.selenium.find_element(By.ID, \"id_product_name\")\n response.send_keys(\"frosties\")\n response.send_keys(Keys.ENTER)\n self.assertTemplateUsed('selected_product.html')", "def te...
[ "0.6914857", "0.68370014", "0.68132645", "0.67801803", "0.6777728", "0.6743917", "0.67292273", "0.6651706", "0.663699", "0.6590794", "0.6579514", "0.654358", "0.6536533", "0.64720875", "0.64325994", "0.6371396", "0.63542134", "0.63323015", "0.6293569", "0.6277347", "0.6251508...
0.74070454
0
Tests that a user cannot view a product in the Inventory with blacklisted token
def test_cannot_view_a_product_with_blacklisted_token(self): resp = self.admin_register() reply = self.admin_login() token = reply['token'] product = dict( prod_name='NY_denims', category='denims', stock=20, price=150 ) resp...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_cannot_view_all_products_with_blacklisted_token(self):\n resp = self.admin_register()\n reply = self.admin_login()\n token = reply['token']\n product = dict(\n prod_name='NY_denims',\n category='denims',\n stock=20,\n price=150\n ...
[ "0.77314836", "0.7319002", "0.68258417", "0.6709656", "0.66352224", "0.6600747", "0.65926576", "0.65914124", "0.6580106", "0.6573959", "0.6558386", "0.65569514", "0.6534714", "0.6512719", "0.6504638", "0.64704", "0.6448948", "0.6437487", "0.6420581", "0.6419264", "0.63966596"...
0.79721093
0
Tests that a user can view all products in the Inventory
def test_view_all_products(self): resp = self.admin_register() reply = self.admin_login() token = reply['token'] product = dict( prod_name='NY_denims', category='denims', stock=20, price=150 ) resp = self.client.post( ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_list_products_logged_in(self):\n\n # Log in seller\n self.client.login(username=\"test_seller\", password=\"secret\")\n\n # Issue a GET request\n response = self.client.get(reverse('website:products'))\n\n # Check that the response is 200\n self.assertEqual(respon...
[ "0.72330284", "0.71533865", "0.70860183", "0.6867175", "0.6790764", "0.67349434", "0.6666839", "0.6636514", "0.66316766", "0.6597527", "0.65619427", "0.6444273", "0.6425292", "0.642249", "0.6402104", "0.64012486", "0.6383176", "0.6383148", "0.6321953", "0.6320072", "0.6299333...
0.7486654
0
Tests that a user cannot view all products in the Inventory with blacklisted token
def test_cannot_view_all_products_with_blacklisted_token(self): resp = self.admin_register() reply = self.admin_login() token = reply['token'] product = dict( prod_name='NY_denims', category='denims', stock=20, price=150 ) r...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_cannot_view_a_product_with_blacklisted_token(self):\n resp = self.admin_register()\n reply = self.admin_login()\n token = reply['token']\n product = dict(\n prod_name='NY_denims',\n category='denims',\n stock=20,\n price=150\n ...
[ "0.77733105", "0.7087671", "0.67957276", "0.6761181", "0.675135", "0.67509085", "0.66980356", "0.6541592", "0.65259844", "0.6448291", "0.64465666", "0.6436873", "0.64326245", "0.64205766", "0.6409761", "0.6387554", "0.6384848", "0.6369056", "0.63571316", "0.63104194", "0.6281...
0.8038467
0
Tests that a user cannot view a product that doesnot exist in the Inventory
def test_view_product_that_doesnot_exist_in_inventory(self): resp = self.admin_register() reply = self.admin_login() token = reply['token'] product = dict( prod_name='NY_denims', category='denims', stock=20, price=150 ) resp...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_cannot_sale_nonexistant_product(self):\n reply = self.admin_add_product()\n\n resp = self.admin_create_user()\n reply = self.attendant_login()\n token = reply['token']\n sale = dict(products = [\n {\n \"prod_name\":\"Paris_heels\", \n ...
[ "0.72640157", "0.6747577", "0.6742351", "0.6686189", "0.66764927", "0.6665994", "0.6556591", "0.6439238", "0.6401339", "0.6370489", "0.6360187", "0.6351575", "0.6346178", "0.63409466", "0.63361067", "0.6330177", "0.6312651", "0.62697184", "0.6259748", "0.62596893", "0.6218498...
0.73303914
0
Tests that a user cannot view products from empty Inventory
def test_view_products_from_empty_inventory(self): resp = self.admin_register() reply = self.admin_login() token = reply['token'] resp = self.client.get( '/api/v1/products', headers={'Authorization': 'Bearer {}'.format(token)} ) reply = json.loads...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_admin_cannot_delete_product_from_empty_Inventory(self):\n resp = self.admin_register()\n reply = self.admin_login()\n token = reply['token']\n \n resp = self.client.delete(\n '/api/v1/products/1',\n content_type='application/json',\n head...
[ "0.74154675", "0.72096145", "0.7158583", "0.693217", "0.6781853", "0.6733253", "0.66969836", "0.65152705", "0.64797616", "0.64615333", "0.6445138", "0.6428424", "0.63962966", "0.6393635", "0.63872916", "0.63662773", "0.633816", "0.6332057", "0.63152456", "0.6308194", "0.63058...
0.78474796
0
Tests that a user cannot view a product with invalid id
def test_view_product_with_invalid_id(self): resp = self.admin_register() reply = self.admin_login() token = reply['token'] product = dict( prod_name='NY_denims', category='denims', stock=20, price=150 ) resp = self.client.p...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_detail_odd_product_id_permission(self):\n self.assertEqual(self.product_2.id, 2)\n\n token = Token.objects.create(user=self.user_1)\n headers = {\n 'HTTP_AUTHORIZATION': 'Token ' + str(token)\n }\n response = self.client.get(\n '/api/products/{}/'.f...
[ "0.7096591", "0.6907471", "0.6797254", "0.6654126", "0.665064", "0.6630695", "0.6613442", "0.6613442", "0.6613442", "0.66119534", "0.65806687", "0.6550584", "0.6499338", "0.64979565", "0.64979565", "0.64979565", "0.6494183", "0.64578736", "0.64060956", "0.63708884", "0.634357...
0.75562716
0
Test that product can be updated successfully
def test_update_product(self): resp = self.admin_register() reply = self.admin_login() token = reply['token'] product = dict( prod_name='NY_denims', category='denims', stock=20, price=150 ) resp = self.client.post( ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_full_update_product(self):\n view = ProductUpdateView.as_view({'patch': 'update'})\n uri = reverse('products:update-product', kwargs={'pk': self.product_id})\n data = {\n \"id\": self.product_id,\n \"name\": \"Headphone updated\",\n \"description\": \"...
[ "0.8304104", "0.8161559", "0.8123623", "0.8105165", "0.809037", "0.79182774", "0.790087", "0.78989977", "0.7809965", "0.7688704", "0.7684496", "0.7684496", "0.7684496", "0.76524705", "0.7631343", "0.76261145", "0.7580674", "0.7554157", "0.75375104", "0.7501177", "0.7474084", ...
0.81104404
3
Test that product cannot be updated successfully with blacklisted token
def test_cannot_update_product_with_blacklisted_token(self): resp = self.admin_register() reply = self.admin_login() token = reply['token'] product = dict( prod_name='NY_denims', category='denims', stock=20, price=150 ) resp...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_cannot_create_product_with_blacklisted_token(self):\n resp = self.admin_register()\n reply = self.admin_login()\n token = reply['token']\n\n resp = self.client.delete(\n '/api/v1/logout',\n headers={'Authorization': 'Bearer {}'.format(token)}\n )\n ...
[ "0.7377064", "0.7333218", "0.7190565", "0.7068335", "0.70310974", "0.69859517", "0.67677313", "0.6604328", "0.65338165", "0.65273803", "0.6446804", "0.6441972", "0.64315784", "0.64071953", "0.6401291", "0.6390641", "0.6355562", "0.6326239", "0.6304661", "0.62910193", "0.62794...
0.80966264
0
Test that you cant updated a nonexistant product
def test_update_nonexistant_product(self): resp = self.admin_register() reply = self.admin_login() token = reply['token'] product_update = dict( prod_name='NY_jeans', category='denims', stock=50, price=180 ) resp = self.clie...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_update_nonexist(self):\n promotion = PromotionFactory()\n promotion.id = '1cak41-nonexist'\n try:\n promotion.update()\n except KeyError:\n self.assertRaises(KeyError)", "def test_update_not_my_product(self):\n post_data = {\n \"categor...
[ "0.74883664", "0.74142987", "0.7132973", "0.7130076", "0.6898503", "0.6843232", "0.676572", "0.6739922", "0.67206293", "0.67113554", "0.66875863", "0.6684773", "0.668369", "0.66656035", "0.6630668", "0.6606419", "0.65949506", "0.6585263", "0.65486664", "0.65191656", "0.651270...
0.7994515
0
Test that product cannot be updated with unauthorised user
def test_unauthorized_product_update(self): resp = self.admin_create_user() reply = self.attendant_login() token = reply['token'] product_update = dict( prod_name='NY_jeans', category='denims', stock=50, price=180 ) resp = s...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_update_not_my_product(self):\n post_data = {\n \"category\": {\n \"name\": \"general\",\n \"index\": 0\n },\n \"name\": \"Producto 2 modified\",\n \"description\": \"Descripcion de producto 2 modified\",\n \"sellin...
[ "0.7472202", "0.74601954", "0.730332", "0.72697306", "0.71795666", "0.71784", "0.7131658", "0.70938385", "0.7079321", "0.6975282", "0.695774", "0.6886112", "0.68209416", "0.68174875", "0.6791423", "0.6772019", "0.6765322", "0.6752393", "0.67434675", "0.66997343", "0.6691479",...
0.80988926
0
Test that product cannot be updated with empty fields
def test_update_product_with_empty_fields(self): resp = self.admin_register() reply = self.admin_login() token = reply['token'] product = dict( prod_name='NY_denims', category='denims', stock=20, price=150 ) resp = self.clie...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_update_product_required_fields(self):\n data = {\n 'pk': 1,\n 'name': None,\n 'description': '''\n Yogurt also spelled yoghurt, yogourt or yoghourt,\n is a food produced by bacterial fermentation of milk.\n '''\n }\n ...
[ "0.802753", "0.7568224", "0.7292608", "0.7203753", "0.7033387", "0.69645137", "0.6949159", "0.6943705", "0.69149756", "0.691329", "0.690093", "0.6899394", "0.6895893", "0.68875086", "0.6824652", "0.6816774", "0.68002254", "0.6785967", "0.6772013", "0.67623484", "0.6751942", ...
0.8045699
0
Test that product cannot be updated with numbers for strings
def test_update_product_with_numbers_for_strings(self): resp = self.admin_register() reply = self.admin_login() token = reply['token'] product = dict( prod_name='NY_denims', category='denims', stock=20, price=150 ) resp = se...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_non_numberic_validation(self):", "def test_non_numberic_validation(self):", "def test_update_product_with_characters_for_numbers(self):\n resp = self.admin_register()\n reply = self.admin_login()\n token = reply['token']\n product = dict(\n prod_name='NY_denims',...
[ "0.6655952", "0.6655952", "0.62706953", "0.62572986", "0.6155536", "0.60939926", "0.6081916", "0.60734576", "0.6025201", "0.5992067", "0.5951248", "0.5883255", "0.58490777", "0.5848731", "0.58472234", "0.5843898", "0.5835155", "0.5830356", "0.57858956", "0.57778364", "0.57684...
0.6393195
2
Test that product cannot be updated with strings for numbers
def test_update_product_with_characters_for_numbers(self): resp = self.admin_register() reply = self.admin_login() token = reply['token'] product = dict( prod_name='NY_denims', category='denims', stock=20, price=150 ) resp =...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_non_numberic_validation(self):", "def test_non_numberic_validation(self):", "def test_product(self):\n self.assertEqual(functions.product(2, 2), 4)\n self.assertEqual(functions.product(2, -2), -4)", "def test_update_product_with_numbers_for_strings(self):\n resp = self.admin_reg...
[ "0.6562785", "0.6562785", "0.6329283", "0.6300493", "0.62892044", "0.62012047", "0.6175202", "0.61220795", "0.60739857", "0.6057926", "0.6026264", "0.6014248", "0.60098", "0.5888831", "0.5833497", "0.5802217", "0.5802217", "0.57738906", "0.57637155", "0.57532704", "0.5741166"...
0.62037754
5
Test that admin can delete a product
def test_admin_delete_product(self): resp = self.admin_register() reply = self.admin_login() token = reply['token'] product = dict( prod_name='NY_denims', category='denims', stock=20, price=150 ) resp = self.client.post( ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_non_admin_cannot_delete_product(self):\n resp = self.admin_register()\n reply = self.admin_login()\n token = reply['token']\n product = dict(\n prod_name='NY_denims',\n category='denims',\n stock=20,\n price=150\n )\n re...
[ "0.83574384", "0.83247185", "0.8285091", "0.82623804", "0.8177644", "0.8141131", "0.80846477", "0.80198777", "0.8002211", "0.7932145", "0.7909494", "0.7733621", "0.7691911", "0.7655855", "0.756794", "0.7516048", "0.75010175", "0.7476865", "0.74705225", "0.7435304", "0.7377097...
0.8554349
0
Test that admin can delete a product
def test_admin_cannot_delete_product_with_blacklisted_token(self): resp = self.admin_register() reply = self.admin_login() token = reply['token'] product = dict( prod_name='NY_denims', category='denims', stock=20, price=150 ) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_admin_delete_product(self):\n resp = self.admin_register()\n reply = self.admin_login()\n token = reply['token']\n product = dict(\n prod_name='NY_denims',\n category='denims',\n stock=20,\n price=150\n )\n resp = self.c...
[ "0.8554349", "0.83574384", "0.83247185", "0.8285091", "0.82623804", "0.8177644", "0.8141131", "0.80846477", "0.80198777", "0.8002211", "0.7932145", "0.7909494", "0.7691911", "0.7655855", "0.756794", "0.7516048", "0.75010175", "0.7476865", "0.74705225", "0.7435304", "0.7377097...
0.7733621
12
Test that a non admin cannot delete a product
def test_non_admin_cannot_delete_product(self): resp = self.admin_register() reply = self.admin_login() token = reply['token'] product = dict( prod_name='NY_denims', category='denims', stock=20, price=150 ) resp = self.clien...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_delete_not_my_product(self):\n self._require_login(self.user1)\n response = self.client.delete('/api/1.0/products/2/')\n self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)", "def test_admin_cannot_delete_nonexistant_product(self):\n resp = self.admin_register()...
[ "0.8456681", "0.82070416", "0.8153313", "0.772525", "0.750598", "0.75052166", "0.7497598", "0.74397874", "0.73591393", "0.7334757", "0.7330903", "0.72217363", "0.72114277", "0.71953607", "0.7125004", "0.70727336", "0.70629984", "0.6935391", "0.69298255", "0.6893835", "0.68860...
0.834971
1
Test that admin cannnot delete a product from empty Inventory
def test_admin_cannot_delete_product_from_empty_Inventory(self): resp = self.admin_register() reply = self.admin_login() token = reply['token'] resp = self.client.delete( '/api/v1/products/1', content_type='application/json', headers={'Authori...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_admin_cannot_delete_nonexistant_product(self):\n resp = self.admin_register()\n reply = self.admin_login()\n token = reply['token']\n product = dict(\n prod_name='NY_denims',\n category='denims',\n stock=20,\n price=150\n )\n ...
[ "0.79532677", "0.7735564", "0.7528131", "0.7521453", "0.7518936", "0.746801", "0.7354772", "0.72263944", "0.71801", "0.71784055", "0.7171436", "0.7112214", "0.7106493", "0.70771635", "0.6879483", "0.68655676", "0.68639493", "0.68453324", "0.6812393", "0.6777014", "0.67697865"...
0.8764794
0
Test that admin cannnot delete a nonexistant product
def test_admin_cannot_delete_nonexistant_product(self): resp = self.admin_register() reply = self.admin_login() token = reply['token'] product = dict( prod_name='NY_denims', category='denims', stock=20, price=150 ) resp = se...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_delete_not_my_product(self):\n self._require_login(self.user1)\n response = self.client.delete('/api/1.0/products/2/')\n self.assertEqual(response.status_code, status.HTTP_403_FORBIDDEN)", "def test_non_admin_cannot_delete_product(self):\n resp = self.admin_register()\n ...
[ "0.8434453", "0.81416374", "0.8129146", "0.79895574", "0.7884565", "0.7712441", "0.7642063", "0.75856626", "0.7577927", "0.757099", "0.7507489", "0.75073075", "0.75018024", "0.7473333", "0.7418871", "0.7409584", "0.72817427", "0.7275699", "0.72678584", "0.7262097", "0.7227959...
0.8506851
0
Test that admin cannnot delete a product with nointeger prod_id
def test_admin_cannot_delete_product_with_non_integer_prod_id(self): resp = self.admin_register() reply = self.admin_login() token = reply['token'] product = dict( prod_name='NY_denims', category='denims', stock=20, price=150 ) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_03_product_delete(self):\n product = self.create_product()\n products = self.product_obj.search([])\n self.assertIn(product, products)\n product.unlink()\n self.assertNotIn(product.exists(), products)", "def test_delete_not_my_product(self):\n self._require_logi...
[ "0.8163337", "0.811003", "0.80877143", "0.80876744", "0.8045905", "0.79786986", "0.7882516", "0.7854732", "0.7846621", "0.7829516", "0.77844703", "0.77800816", "0.7772745", "0.77263916", "0.7600396", "0.7597553", "0.75532126", "0.7346543", "0.72736114", "0.7209453", "0.708175...
0.8068848
4
Test ComBat feature harmonization.
def test_combat(): # Check if example data directory exists example_data_dir = th.find_exampledatadir() # Check if example data required exists features = glob.glob(os.path.join(example_data_dir, 'examplefeatures_Patient*.hdf5')) if len(features) < 7: message = 'Too few example features for...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_feature(feature, value, good_features):\r\n\tbase_write(good_features,\"bin/stanford-ner-2015-04-20/base.prop\")\r\n\tbase_prop = open(\"bin/stanford-ner-2015-04-20/base.prop\", \"a\")\r\n\tbase_prop.write(feature.strip() + \"=\" + str(value) + \"\\n\")\r\n\tbase_prop.close()\r\n\r\n\t#Test read base.prop...
[ "0.652699", "0.64427763", "0.6373243", "0.6333925", "0.6331873", "0.6215436", "0.6211196", "0.59231627", "0.59107846", "0.5880464", "0.5870288", "0.58623254", "0.58284056", "0.58262885", "0.58067703", "0.5803254", "0.57745475", "0.5774168", "0.57514584", "0.5704505", "0.57006...
0.6563471
0
Test ComBat feature harmonization.
def test_combat_fastr(): # Check if example data directory exists example_data_dir = th.find_exampledatadir() # Check if example data required exists features = glob.glob(os.path.join(example_data_dir, 'examplefeatures_Patient*.hdf5')) if len(features) < 6: message = 'Too few example featur...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_combat():\n # Check if example data directory exists\n example_data_dir = th.find_exampledatadir()\n\n # Check if example data required exists\n features = glob.glob(os.path.join(example_data_dir, 'examplefeatures_Patient*.hdf5'))\n if len(features) < 7:\n message = 'Too few example ...
[ "0.6563471", "0.652699", "0.64427763", "0.6373243", "0.6333925", "0.6331873", "0.6215436", "0.6211196", "0.59107846", "0.5880464", "0.5870288", "0.58623254", "0.58284056", "0.58262885", "0.58067703", "0.5803254", "0.57745475", "0.5774168", "0.57514584", "0.5704505", "0.570060...
0.59231627
8
Returns true for all hostclasses which aren't tagged as nonZDD hostclasses
def is_deployable(self, hostclass): return ((hostclass in self._hostclasses and is_truthy(self._hostclasses[hostclass].get("deployable"))) or hostclass not in self._hostclasses)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def IsNoHost(self):\n if self.no_host:\n return True\n return any([node.no_host for node in self.GetAncestorGroups()])", "def is_opaque(self, classobj):\n try:\n return self.instance_vars[classobj] == []\n except KeyError:\n return False", "def has_ghosts(self):\n...
[ "0.6732368", "0.61149806", "0.60162634", "0.598662", "0.5910872", "0.57612085", "0.5761027", "0.5724565", "0.57139426", "0.56720996", "0.56686395", "0.5650766", "0.5641392", "0.56388974", "0.5596937", "0.55439645", "0.55356926", "0.5530277", "0.55288005", "0.5514988", "0.5490...
0.66115427
1
Returns the integration test for this hostclass, or None if none exists
def get_integration_test(self, hostclass): return (hostclass in self._hostclasses and self._hostclasses[hostclass].get("integration_test")) or None
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_test(self,test_id):\n for test in self.suite.get_tests():\n if test.id == test_id:\n return test\n return None", "def GetHWTestSuite(self):\n hw_tests = self._run.config['hw_tests']\n if not hw_tests:\n # TODO(milleral): Add HWTests back to lumpy-chrome-...
[ "0.6346583", "0.6162359", "0.5884836", "0.5876703", "0.55224764", "0.5468428", "0.5372038", "0.529812", "0.52784747", "0.52683514", "0.5250328", "0.52476835", "0.5240323", "0.5180137", "0.51473355", "0.51330215", "0.51204187", "0.5118088", "0.5116481", "0.50992554", "0.508809...
0.8695572
0
Promote AMI to specified stage. And, conditionally, make executable by production account if ami is staged as tested.
def _promote_ami(self, ami, stage): prod_baker = self._disco_bake.option("prod_baker") promote_conditions = [ stage == "tested", prod_baker, ami.tags.get("baker") == prod_baker, ] try: self._disco_bake.promote_ami(ami, stage) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def stage(self, stage: osbuild.Stage):", "def deploy():\n stage(branch='live', role='live')", "def setup(self, stage: Optional[str] = None) -> None:", "def deploy():\n test()\n if not env.is_staging:\n backup()\n prepare()\n restart_api()", "def Stage(self, descriptor, app_dir, runtim...
[ "0.600044", "0.58983445", "0.5597183", "0.55506766", "0.55401236", "0.5401714", "0.5389094", "0.53601116", "0.5331389", "0.52924347", "0.526997", "0.52426094", "0.5238283", "0.5174726", "0.5095269", "0.5092394", "0.50896496", "0.5085712", "0.5071455", "0.50698596", "0.5068133...
0.7794168
0
Define data used in test.
def setUp(self): pwd = self.get_script_path() self.test_drug_info_file = pwd+'/../insight_testsuite/tests/my_test/input/test_input_file.txt' self.test_raw_tuple= [('jordanmichael', 'A', 23.00), ('jameslebron', 'C', 23.10), ('bryantkobe', 'B', 8), ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def setUpTestData(cls):\n data_gen.run()", "def setUpTestData(cls):\n data_gen.run()", "def setUpTestData(cls):\n data_gen.run()", "def setUpTestData(cls):\n data_gen.run()", "def setUp(self):\n\n self.data_list = [\n \"hello\", \"world\", \"funilrys\", \"funce...
[ "0.7128387", "0.7128387", "0.7128387", "0.7128387", "0.6960889", "0.6884261", "0.68240964", "0.68195206", "0.6783465", "0.6741896", "0.6734708", "0.6721453", "0.6721293", "0.67041653", "0.6678538", "0.66765255", "0.6659576", "0.6627872", "0.66132146", "0.66129124", "0.6599503...
0.0
-1
Line is correctlt split and missing/corrupetd fields are checked.
def test_read_line(self): expected_data = ['\"lu, jr\"','ming-yuan','\"DRUG,1\"',135.999,True,3] input_string = '001,\"LU, JR\",MING-YUAN,\"DRUG,1\",135.999\n' data = read_line(input_string) self.assertEqual(expected_data[0],data[0]) self.assertEqual(expected_data[1],data[1]) ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_Lines(self):\n\n pass", "def check_record(idline,nclline,sepline,qualiline):\n return check_idline(idline) and check_sepline(sepline)", "def is_line(self): \n return False", "def check_line(self):\n if not self.hosts and not self.line:\n self.msg(\"There is...
[ "0.68945944", "0.65980923", "0.64360386", "0.64280456", "0.640811", "0.6315471", "0.62812597", "0.6233146", "0.61786985", "0.617687", "0.6170383", "0.61697614", "0.6118626", "0.6044029", "0.6039419", "0.6007905", "0.60070646", "0.6002585", "0.5974007", "0.5965619", "0.5962297...
0.6924609
0
Inpue file is correctly read and tuple constructed.
def test_read_input_file(self): test_max_digit = 2 tuple1 = self.test_raw_tuple tuple2, max_digit = read_input_file(self.test_drug_info_file) self.assertEqual(tuple1, tuple2) self.assertAlmostEqual(max_digit,test_max_digit)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse(self, infile):\r\n raise NotImplementedError()", "def _read_input_file(self):\n pass", "def _parse(self, infile):\n raise NotImplementedError()", "def _read(self, in_file):\n #\n # I know this function is long, but the FRD block is long as well...\n # Splitting...
[ "0.62718296", "0.6199125", "0.6139345", "0.61193955", "0.60940003", "0.59377885", "0.59339136", "0.5890041", "0.5879968", "0.5824287", "0.5814559", "0.5812669", "0.57651573", "0.5727909", "0.5723036", "0.57121086", "0.570808", "0.57077694", "0.5688802", "0.5678212", "0.567730...
0.6141999
2
Unique drug list dict is correctly returned.
def test_get_unique_drug_list(self): dict1 = self.test_dict dict2 = get_unique_drug_list(self.test_sorted_tuple) self.assertEqual(dict1, dict2)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def unique_drugs(self):\n if self.results is not None:\n return tuple(self.results['drug'].unique())", "def _get_unique_genres(connection):\n print('---Getting unique genres---')\n genreDict = {}\n cursor = connection.cursor()\n cursor.execute(\"SELECT * FROM shared_genres;\")\n ...
[ "0.6729187", "0.5912013", "0.57591486", "0.5738331", "0.5666848", "0.5649718", "0.5634769", "0.562001", "0.56132656", "0.5601305", "0.55995375", "0.55618244", "0.55507255", "0.5541687", "0.5520323", "0.5516712", "0.5491589", "0.54879695", "0.54779065", "0.54644716", "0.545142...
0.68579596
0
Number of unique names for each drug is correcy.
def test_get_num_unique_name(self): list1 = self.test_num_unique_name list2 = get_num_unique_name(self.test_sorted_tuple, self.test_dict) self.assertEqual(list1, list2)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def count(self):\n return len(self.names)", "def __len__(self):\n return self.data.index.get_level_values(0).to_series().nunique()", "def number_of_variables(dataset, name_of_variable):\r\n first_row = dataset[0].keys()\r\n num = 0\r\n for variable in first_row:\r\n if name_of_var...
[ "0.62920433", "0.60662675", "0.5955769", "0.59471035", "0.5925419", "0.5915438", "0.5910354", "0.58735096", "0.586835", "0.58442324", "0.58086777", "0.57781553", "0.5766293", "0.5765629", "0.5764152", "0.57473814", "0.5723728", "0.5690694", "0.56676644", "0.56587267", "0.5648...
0.0
-1
Total cost of each drug is correct.
def test_get_total_cost_each_drug(self): list1 = self.test_total_cost_each_drug list2 = get_total_cost_each_drug(self.test_sorted_tuple, self.test_dict) self.assertEqual(list1, list2)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cost(self) -> float:", "def tablecost(self):\n subtotal_getter = operator.attrgetter(\"subtotal\")\n\n cost = 0.0\n\n cost += sum(map(subtotal_getter, self.materials))\n cost += sum(map(subtotal_getter, self.processes))\n cost += sum(map(subtotal_getter, self.fasteners))\n ...
[ "0.7039642", "0.68268335", "0.6784941", "0.67635846", "0.6760325", "0.66375047", "0.66135275", "0.65899247", "0.65713847", "0.6541224", "0.6456955", "0.6456513", "0.6444531", "0.6374481", "0.6351378", "0.63261276", "0.6230316", "0.6212625", "0.6205208", "0.6195797", "0.618874...
0.68602717
1
The output file is as expected.
def test_print_drug_info(self): pwd = self.get_script_path() fout1 = self.test_output_file fout2 = pwd+'/../insight_testsuite/tests/my_test/output/test_output_file_2.txt' print_drug_info(self.test_sorted_tuple, self.test_dict, self.test_num_unique_name, self.test_total_cost_each_drug, f...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def write_output(self):", "def write_actual_output(self, output):\n actual_output_file = path.splitext(self.source_name)[0] + \".actual\"\n with open(actual_output_file, \"w\") as f:\n f.write(output)", "def _toFile(self):\n pass", "def test_outfile():\n\n out_file = random...
[ "0.68608725", "0.68279564", "0.67969465", "0.67020315", "0.65961033", "0.6551729", "0.65434563", "0.65230155", "0.6469242", "0.6408502", "0.63981223", "0.63253784", "0.6316267", "0.6316267", "0.63015395", "0.6297902", "0.6295766", "0.62910724", "0.62809604", "0.6252292", "0.6...
0.0
-1
check if a user exist in the db
def __check_user_exist(self): login_form = self.login_form() user = User.query.filter_by(username=login_form.username.data).first() if user is None or not user.get_password(login_form.password.data): flash('Invalid username or password') # TODO: flash in Template hinzufuegen ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def userExists(self, username):\n data = db.session.query(User.id).filter_by(username = username).first()\n if data is None:\n return False\n else:\n return True", "def exists_in_db(self) -> bool:\n query = \"\"\"SELECT * \n FROM Users \n ...
[ "0.8210985", "0.8123747", "0.8072711", "0.8056698", "0.80316305", "0.7948778", "0.79255694", "0.78522176", "0.7824358", "0.7791029", "0.7768088", "0.7739863", "0.7722479", "0.77069974", "0.77069974", "0.7654071", "0.76501435", "0.7623449", "0.76128906", "0.76000804", "0.75982...
0.7002597
79
Checks if a string is a permutation of a palindrome by populating a map and counting the occurrences of letters. O(N)
def is_palindrome_permutation(string): letter_to_count = dict() for letter in string: letter_to_count[letter] = letter_to_count.get(letter, 0) + 1 residual = 0 for count in letter_to_count.values(): residual += count % 2 # there are can be a single letter with an odd character co...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def palindrom_permutation(string: str):\n string = re.sub(r'\\W+', '', string.lower())\n\n chars = dict()\n for c in string:\n chars[c] = chars[c] + 1 if c in chars else 1\n\n almost_not_okey = False\n for val in chars.values():\n if val % 2 == 1:\n if not almost_not_okey:\n...
[ "0.79791397", "0.7845905", "0.7619931", "0.7566796", "0.72823507", "0.7219113", "0.72079515", "0.71518576", "0.7108441", "0.6992611", "0.69697845", "0.6915593", "0.6882766", "0.6821809", "0.6709572", "0.6699704", "0.65028495", "0.6462751", "0.645578", "0.64369947", "0.6321017...
0.81786555
0
Add ops for dataset loaders to graph
def generate_dataset(self): if self.training: dataset = UnpairedDataset(self.opt, self.training) datasetA, datasetB = dataset.generate(cacheA='./dataA.tfcache', cacheB='./dataB.tfcache') dataA_iter = datasetA.make_initializable_iterator() dataB_iter = datasetB.mak...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def import_ops(self):\n if self.is_training:\n self.lr = tf.get_collection_ref(\"lr\")[0]\n self.new_lr = tf.get_collection_ref(\"new_lr\")[0]\n self.lr_update = tf.get_collection_ref(\"lr_update\")[0]\n\n self.cost = tf.get_collection_ref(util.with_prefix(self.name, \"cost\...
[ "0.65246606", "0.6266942", "0.59693766", "0.59283423", "0.5864471", "0.57984567", "0.57888275", "0.57675457", "0.5730815", "0.56816316", "0.56744856", "0.5652499", "0.5620212", "0.55867034", "0.5557611", "0.55549645", "0.54842335", "0.5481167", "0.5478355", "0.54730076", "0.5...
0.0
-1
Build TensorFlow graph for MaskShadowGAN model.
def build(self): # add ops for generator (A->B) to graph self.G = Generator(channels=self.opt.channels, ngf=self.opt.ngf, norm_type=self.opt.layer_norm_type, init_type=self.opt.weight_init_type, init_gain=self.opt.weight_init_gain, training=self.trai...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def build_graph(self, inputs, masks):\n with vs.variable_scope(\"SimpleSoftmaxLayer\"):\n\n # Linear downprojection layer\n logits = tf.contrib.layers.fully_connected(inputs, num_outputs=1, activation_fn=None) # shape (batch_size, seq_len, 1)\n logits = tf.squeeze(logits, ax...
[ "0.69234383", "0.69234383", "0.6907245", "0.6791445", "0.6789565", "0.6765206", "0.6709734", "0.66579914", "0.6548826", "0.65472156", "0.6503266", "0.6484194", "0.6441474", "0.6392635", "0.6377581", "0.6376619", "0.6360305", "0.63222873", "0.6321313", "0.63196373", "0.6286161...
0.6129226
37
Compute the losses for the generators and discriminators.
def __loss(self, fakeA, fakeB, reconstructedA, reconstructedB, identA, identB): # compute the generators loss G_loss = self.__G_loss(self.D_B, fakeB) F_loss = self.__G_loss(self.D_A, fakeA) cc_loss = self.__cycle_consistency_loss(reconstructedA, reconstructedB) ident_loss = self....
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def compute_losses(self):\n cycle_consistency_loss_a = \\\n self._lambda_a * losses.cycle_consistency_loss(\n real_images=self.input_a, generated_images=self.cycle_images_a,\n )\n cycle_consistency_loss_b = \\\n self._lambda_b * losses.cycle_consistency...
[ "0.7707404", "0.7442763", "0.69570446", "0.69570446", "0.6913104", "0.6866929", "0.6692329", "0.6500259", "0.64484847", "0.6443854", "0.6421832", "0.64056575", "0.63885695", "0.6378459", "0.6364855", "0.6319561", "0.62842685", "0.6246546", "0.624369", "0.6235395", "0.62323135...
0.6739313
6
Compute the discriminator loss.
def __D_loss(self, D, real, fake): loss = 0.5 * (tf.reduce_mean(tf.squared_difference(D(real), 1.0)) + \ tf.reduce_mean(tf.square(D(fake)))) return loss
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _define_discriminator_loss(self):\n real_d_loss = tf.reduce_mean(self._real_discriminator_out)\n real_d_loss = tf.negative(real_d_loss, name='real_discriminator_loss')\n gen_d_loss = tf.reduce_mean(self._gen_discriminator_out,\n name='gen_discriminator_loss')\n return...
[ "0.8110355", "0.78501636", "0.7769317", "0.7654356", "0.7549625", "0.7488209", "0.73963207", "0.7360349", "0.7320101", "0.7283635", "0.72751373", "0.7269417", "0.7124739", "0.7010574", "0.699223", "0.69803566", "0.69646436", "0.69372475", "0.6897706", "0.6882033", "0.684818",...
0.65725476
36
Compute the generator loss.
def __G_loss(self, D, fake): loss = tf.reduce_mean(tf.squared_difference(D(fake), 1.0)) return loss
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generator_loss(self, disc_generated_output, gen_output, target):\n # Compute the loss function\n loss_function = self.loss_func()\n\n # Generated GAN loss\n gan_loss = loss_function(tf.ones_like(disc_generated_output), disc_generated_output)\n\n # L1 loss\n l1_loss = t...
[ "0.77820057", "0.7764371", "0.75634307", "0.75527585", "0.74715674", "0.73343015", "0.73278564", "0.7294605", "0.7289977", "0.72849333", "0.7278991", "0.7254628", "0.72545844", "0.72445464", "0.7168463", "0.71656865", "0.71556157", "0.71551716", "0.7152865", "0.71504474", "0....
0.67413956
52
Compute the cycle consistenty loss. L_cyc = lamA [Expectation of L1_norm(F(G(A)) A)] + lamb [Expectation of L1_norm(G(F(B)) B)]
def __cycle_consistency_loss(self, reconstructedA, reconstructedB): loss = self.opt.lamA * tf.reduce_mean(tf.abs(reconstructedA - self.realA)) + \ self.opt.lamB * tf.reduce_mean(tf.abs(reconstructedB - self.realB)) return loss
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cycle_consistency_loss(self, ra, rb, fa, fb):\n with tf.device(\"/gpu:0\"):\n backward_loss = tf.reduce_mean(tf.abs(self.Ga2b(fa) - rb))\n with tf.device(\"/gpu:1\"):\n forward_loss = tf.reduce_mean(tf.abs(self.Gb2a(fb) - ra))\n loss = self.lambda1 * forward_loss ...
[ "0.661372", "0.61719704", "0.60370505", "0.5863777", "0.569097", "0.5663334", "0.56262916", "0.5592393", "0.54651314", "0.5444343", "0.53959835", "0.5394466", "0.53734285", "0.53725505", "0.5371813", "0.5362057", "0.5342894", "0.53264534", "0.5277725", "0.5275031", "0.5255691...
0.6959504
0
Compute the identity loss. L_idt = lamda_idt [lamA [Expectation of L1_norm(F(A) A)] + lamB [Expectation of L1_norm(G(B) B)]]
def __identity_loss(self, identA, identB): loss = self.opt.lambda_ident * (self.opt.lamA * tf.reduce_mean(tf.abs(identB - self.realA)) + \ self.opt.lamB * tf.reduce_mean(tf.abs(identA - self.realB))) return loss
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def l1_loss(inputs, reduction='mean', **kwargs):\n args = ArgHelper.parse(locals())\n args['reduction'] = reduction.upper()\n op_lib = loss_ops_lib.L1Loss\n if context.executing_eagerly():\n return op_lib \\\n .instantiate(reduction=args['reduction']) \\\n .apply(inputs)\n ...
[ "0.5652646", "0.5454709", "0.5431929", "0.5346413", "0.52700704", "0.5245193", "0.5241548", "0.5189512", "0.51814455", "0.51782507", "0.51747054", "0.5168681", "0.5149222", "0.51125103", "0.510106", "0.50966114", "0.5086483", "0.50756854", "0.50619715", "0.5041158", "0.502635...
0.69998527
0
Modified optimizer taken from vanhuyz TensorFlow implementation of CycleGAN
def __optimizers(self, Gen_loss, D_A_loss, D_B_loss): def make_optimizer(loss, variables, name='Adam'): """ Adam optimizer with learning rate 0.0002 for the first 100k steps (~100 epochs) and a linearly decaying rate that goes to zero over the next 100k steps """ ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __init__(self, sess, max_iter=50001, optim='adagrad', learning_rate=1e-2,\n d_per_iter=1, g_per_iter=2, d_update=True, g_update=True,\n real_n=1000, real_dim=2, fake_n=1000, z_dim=3, g_out_dim=2,\n g_layers_depth=5, g_layers_width=None, g_activations=None,\n d_out_di...
[ "0.6959912", "0.6959529", "0.6903491", "0.68603384", "0.6580812", "0.6557089", "0.65515715", "0.6538013", "0.64774996", "0.64496166", "0.6435693", "0.6410382", "0.63923454", "0.6380889", "0.63773113", "0.6373982", "0.6361317", "0.63536835", "0.6332485", "0.631817", "0.6312744...
0.626492
22
Adam optimizer with learning rate 0.0002 for the first 100k steps (~100 epochs) and a linearly decaying rate that goes to zero over the next 100k steps
def make_optimizer(loss, variables, name='Adam'): global_step = tf.Variable(0, trainable=False, name='global_step') starter_learning_rate = self.opt.lr end_learning_rate = 0.0 start_decay_step = self.opt.niter decay_steps = self.opt.niter_decay bet...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def adam_optimizer(loss, initial_lr, decay_step, decay_rate):\n global_step = tf.train.get_or_create_global_step()\n lr = tf.train.exponential_decay(initial_lr, global_step, decay_step,\n decay_rate, staircase=True)\n\n optim = tf.train.AdamOptimizer(learning_rate=lr)\n ...
[ "0.7543031", "0.73133004", "0.724946", "0.7170338", "0.7165979", "0.7088052", "0.7046958", "0.6981401", "0.6972685", "0.69598085", "0.6947667", "0.69352144", "0.69040656", "0.6877185", "0.68620074", "0.6840973", "0.68289465", "0.6801931", "0.67928517", "0.6781422", "0.6772846...
0.68411076
15
Insert object into the Property Sheet to display it. Object must implements the GetPropList interface. This interface returns the dictionary with keys as the groups labels and values as dictionary with keys as property labels and values as property value objects
def SetPropObject(self, obj): if self.propObj is not None: # deregister notification if hasattr(self.propObj, "DropPropsNotify") : self.propObj.DropPropsNotify() if hasattr(obj, "GetPropList") : self.propObj = obj self.UpdateGrid() else : wx.MessageBox(_("Can't display properties for %s, becaus...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def define_group_properties(self):\n\n # PropertyGroup\n self.propertygroup['debug']['x86'] = get_propertygroup(\n 'debug', 'x86', ' and @Label=\"Configuration\"'\n )\n self.propertygroup['debug']['x64'] = get_propertygroup(\n 'debug', 'x64', ' and @Label=\"Configu...
[ "0.5784708", "0.5752772", "0.5563086", "0.55042255", "0.54970247", "0.54590595", "0.5275027", "0.52564776", "0.51849294", "0.51720124", "0.50716716", "0.5064659", "0.5059839", "0.5025119", "0.50181776", "0.4982828", "0.49804395", "0.4961031", "0.49296808", "0.49119613", "0.49...
0.50260586
13
Parses a tensorflow.SequenceExample into an image and caption.
def parse_sequence_example(serialized, image_id, image_feature, caption_feature): context, sequence = tf.parse_single_sequence_example( serialized, context_features={ image_id : tf.FixedLenFeature([], dtype=tf.int64), image_feature: tf.FixedLenFeature([], dtype=tf.string) }...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def parse_sequence_example(serialized, image_feature, caption_feature):\n\tcontext, sequence = tf.parse_single_sequence_example(\n\t\t\tserialized,\n\t\t\tcontext_features={\n\t\t\t\t\timage_feature: tf.FixedLenFeature([], dtype=tf.string)\n\t\t\t},\n\t\t\tsequence_features={\n\t\t\t\t\tcaption_feature: tf.FixedLe...
[ "0.7773432", "0.70653176", "0.6706283", "0.66781205", "0.66210777", "0.6502138", "0.63294804", "0.63211375", "0.62616134", "0.62233996", "0.6201436", "0.6195922", "0.6186161", "0.6184599", "0.6164636", "0.6148699", "0.6147658", "0.614749", "0.6147216", "0.61331445", "0.609978...
0.7657589
1
Decodes and processes an image string.
def process_image(encoded_image, config, thread_id=0): return image_processing.process_image(encoded_image, is_training=False, height=config.image_height, width=config.image_width, ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def process_image_string(self, image_string):\n image = image_util.load_image_from_string(image_string)\n return self.process_image(image)", "def convert_str_to_image(image_string):\n image = image_string.partition('base64,')[2]\n img_data = base64.b64decode(image)\n return img_data", "d...
[ "0.76571083", "0.70518196", "0.67220795", "0.6707585", "0.66721165", "0.6323393", "0.6302396", "0.6182582", "0.61463886", "0.6065278", "0.6065278", "0.603599", "0.6005533", "0.5996547", "0.59715015", "0.5929471", "0.5828417", "0.58076036", "0.5807062", "0.57541275", "0.573893...
0.52232766
74
Estimate ND similarity transformation with or without scaling.
def umeyama(src, dst, estimate_scale): num = src.size(0) dim = src.size(1) # Compute mean of src and dst. src_mean = src.mean(dim=0) # [N] dst_mean = dst.mean(dim=0) # [N] # Subtract mean from src and dst. src_demean = src - src_mean # [M, N] dst_demean = dst - dst_mean # [M, N] ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _calculate_trilinear_similarity(self, context, query, context_max_len, query_max_len,\n w4mlu, bias):\n\n subres0 = nd.tile(self.w4c(context), [1, 1, query_max_len])\n subres1 = nd.tile(nd.transpose(\n self.w4q(query), axes=(0, 2, 1)), [1, context...
[ "0.5920537", "0.5897834", "0.5621034", "0.55399406", "0.5531732", "0.54380125", "0.54253316", "0.539818", "0.5361793", "0.53471076", "0.53471076", "0.5319093", "0.5299263", "0.529202", "0.52626157", "0.52620703", "0.52577376", "0.52334017", "0.5212186", "0.52016556", "0.51950...
0.5116158
31
Run demo, testing whether input words are beer related.
def run_demo(): while True: embeddings = beer_emb.embed_doc(input("Test if words are beer-related: "), word_filter=False) for word_vec in embeddings: print(is_beer_related(word_vec))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_run():\r\n print(count_words(\"cat bat mat cat bat cat\", 3))\r\n print(count_words(\"betty bought a bit of butter but the butter was bitter\", 3))", "def test_run():\n print count_words(\"cat bat mat cat bat cat\", 3)\n print count_words(\"betty bought a bit of butter but the butter was bit...
[ "0.64361274", "0.63639456", "0.63639456", "0.61933094", "0.5985079", "0.59168476", "0.58774954", "0.58620715", "0.58588994", "0.5743201", "0.57326597", "0.57213676", "0.5714051", "0.57126486", "0.5685293", "0.56775856", "0.56722903", "0.56616175", "0.56303006", "0.5619225", "...
0.7582199
0
Creates and saves a new user
def create_user(self, phone, password=None, **extra_fields): print(extra_fields) if not phone: raise ValueError('Users must have an phone number') if not password: raise ValueError('Users must have a password') try: extra_fields['role'] except ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_user():\n record = request.get_json()\n if record is None:\n return {\"Error\": \"No data Supplied.\"}, 400\n\n schema = user_schema.load(record)\n\n if UserModel.objects(email=schema['email']):\n return {\"Error\": \"User Data already exists.\"}, 400\n user = UserModel(**s...
[ "0.81209964", "0.7988362", "0.7942134", "0.794042", "0.7909767", "0.79059476", "0.7895585", "0.78710216", "0.7859143", "0.7820724", "0.78207135", "0.7810844", "0.77932024", "0.77833587", "0.77703035", "0.77604187", "0.7755999", "0.77458596", "0.7740836", "0.773325", "0.771976...
0.0
-1
Creates and saves a new super user
def create_superuser(self, phone, password): user = self.model(phone=phone) user.set_password(password) user.save(using=self._db) user.is_staff = True user.is_superuser = True user.save(using=self._db) return user
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_superuser(self, username, email, password):\n print(\"creating super user....\")\n user = self.create_user(\n\n username=username,\n password=password,\n email = email,\n commit=False,\n )\n user.is_staff = True\n user.is_sup...
[ "0.770437", "0.76964134", "0.76661605", "0.76653856", "0.7655734", "0.75484675", "0.7541768", "0.75341594", "0.75114566", "0.7500617", "0.74416953", "0.74323356", "0.7431842", "0.74239194", "0.7409911", "0.73949206", "0.73942757", "0.73923373", "0.7387035", "0.7382646", "0.73...
0.0
-1
return least common multiple of two integers
def lcm(x: int, y: int) -> int: assert isinstance(x, int) and isinstance(y, int) and x > 0 and y > 0 return int(x * y / gcd(x, y))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def least_common_multiple(number1, number2):\n return number1 * number2 // math.gcd(number1, number2)", "def lowest_common_multiple(a, b):\n # 两个数字相乘后除以最大公约数 = 两个数字的最小公倍数\n return a * b // gcd(a, b)", "def least_common_multiple2(number1, number2, number3, number4):\n return least_common_multiple((n...
[ "0.8421955", "0.8331325", "0.7644219", "0.76081353", "0.75759864", "0.75759864", "0.75638235", "0.7436232", "0.73484886", "0.7300214", "0.7295642", "0.72913396", "0.72913396", "0.72913396", "0.72913396", "0.72913396", "0.72913396", "0.72913396", "0.72913396", "0.72913396", "0...
0.71541774
27
return the greatest common divisor of two integers
def gcd(x: int, y: int) -> int: assert isinstance(x, int) and isinstance(y, int) and x > 0 and y > 0 while y != 0: x, y = y, x % y return x
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def greatest_common_divisor(x: int, y: int) -> int:\n while y != 0:\n (x, y) = (y, x % y)\n return x", "def greatest_common_divisor(a: int, b: int) -> int:\n#[SOLUTION]\n while b:\n a, b = b, a % b\n return a", "def gcd_algo(a,b):\n i = max(a,b)\n j = min(a,b)\n\n if j == 0:\...
[ "0.85697377", "0.8548809", "0.80010635", "0.7985648", "0.7972896", "0.7921842", "0.78888613", "0.7888709", "0.78645015", "0.78455526", "0.7827044", "0.7827044", "0.7821854", "0.7792171", "0.7777419", "0.7754992", "0.775436", "0.775147", "0.77433187", "0.77408284", "0.77301985...
0.75848126
49
return least common multiple of a range of integers
def lcms(argg: range) -> int: l = 1 for arg in argg: l = lcm(l, arg) return l
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def smallest_multiple(n):\n return reduce(lowest_common_multiple, range(1, n+1))", "def least_common_multiple(number1, number2):\n return number1 * number2 // math.gcd(number1, number2)", "def lowest_common_multiple(a, b):\n # 两个数字相乘后除以最大公约数 = 两个数字的最小公倍数\n return a * b // gcd(a, b)", "def find_sm...
[ "0.7665987", "0.75820744", "0.7434193", "0.725471", "0.71709675", "0.6794163", "0.6781177", "0.6689504", "0.6673474", "0.66556793", "0.66154504", "0.6614286", "0.66003877", "0.65978855", "0.65978855", "0.65896875", "0.6571934", "0.65678567", "0.6525186", "0.65232986", "0.6469...
0.6465514
21
Creates a UNet model with pretrained optiopn.
def unet(num_classes=21, is_deconv=False, feature_scale=1, is_batchnorm=True, pretrained=False): if pretrained: model_path = pretrained_models['pascal'] model = UNet(n_classes=num_classes, feature_scale=feature_scale, is_batchnorm=is_batchnorm, is_deconv=is_deconv) checkpoint = torch.load(mo...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_unet_model(self):\n # create optimizer instance\n config = {\n 'class_name': self.optimizer,\n 'config': self.optimizer_params}\n optimizer = get_optimizer(config)\n\n self.model = unet(optimizer=optimizer,\n loss=self.loss,\n ...
[ "0.68969065", "0.665536", "0.62934476", "0.61874026", "0.6184248", "0.6179625", "0.6171186", "0.6165023", "0.61580503", "0.6156004", "0.61520237", "0.6149518", "0.6119684", "0.61149585", "0.60775506", "0.6073373", "0.60634506", "0.605574", "0.60486454", "0.6038523", "0.601402...
0.6460649
2
Download text from the given url to fname.
def download_target_url(target, fname): r = requests.get(target) if r.ok: with open(fname, 'w') as f: f.write(r.text) print(f"Wrote {len(r.text)} chars to {fname}.")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def download_file(url, fname):\n urllib.request.urlretrieve(url, fname)", "def download (url):\n path, url = url\n r = requests.get (url, stream = True)\n content = r.text\n #print (content)\n with open (path + '.txt', 'w') as f:\n f.write (content)", "def download_link(url,save_dir):\...
[ "0.7638134", "0.755848", "0.73113656", "0.72749597", "0.7246588", "0.7025229", "0.70069635", "0.6974052", "0.6928931", "0.6926085", "0.69255304", "0.6919365", "0.6906989", "0.6897153", "0.68755436", "0.68460965", "0.683638", "0.68292296", "0.6827624", "0.6824476", "0.6773361"...
0.705656
5
Load parsed beautifulsoup object holding the full html
def load_parsed(self): with open(self.fname) as f: self.parsed = BeautifulSoup(f.read(), features="html.parser")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_website(self):\n# r = urllib.request.urlopen(self.url).read()\n r = requests.get(self.url).content \n self.soup = bs(r, \"lxml\")", "def load_page(self) -> bs4.BeautifulSoup:\n\n res = requests.get(self.url)\n\n res.raise_for_status()\n return bs4.Beautif...
[ "0.7414255", "0.7408412", "0.7246797", "0.7061659", "0.6892907", "0.68442833", "0.6834316", "0.6795834", "0.6783969", "0.67211264", "0.67171395", "0.6716718", "0.66845864", "0.6660223", "0.660617", "0.65939754", "0.6587271", "0.6559653", "0.65470797", "0.6519594", "0.65095526...
0.7917264
0
Iterator over maintext paragraph elements; this includes footnotes.
def _paragraphs_raw(self): for par in self.parsed.find_all("p")[self.PAR_START:]: yield par
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def linked_text_paragraphs(self):\n for par in self._main_paragraphs_raw():\n par_links = par.find_all('a')\n if len(par_links) == 0:\n self.main_count += len(par.text)\n yield par.text\n else:\n for el in par.contents:\n ...
[ "0.70568925", "0.6538393", "0.630119", "0.6105424", "0.59029144", "0.5857844", "0.56422466", "0.561061", "0.5597017", "0.5584193", "0.55805284", "0.55002755", "0.5490439", "0.5486235", "0.5449823", "0.5444187", "0.5435644", "0.5427534", "0.5414275", "0.54038227", "0.5385818",...
0.6565161
1
Checks whether an element contains footnote text.
def is_footnote_text(self, par): return (par is not None) and ("foot" in par.attrs.get("class", []))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_footnote(self, par):\n if par.find_next_sibling('p') is None:\n return False\n return self.is_footnote_text(par) or self.is_footnote_link(par)", "def is_footnote_link(self, par):\n return self.is_footnote_text(par.find_next_sibling('p'))", "def is_footnote(self):\n ...
[ "0.72341335", "0.688278", "0.6498541", "0.6382326", "0.61090255", "0.6085547", "0.59022486", "0.5810465", "0.5732255", "0.5724639", "0.56633186", "0.55054045", "0.54965115", "0.5481354", "0.54613525", "0.5442589", "0.5437752", "0.54305816", "0.53904307", "0.5370518", "0.53681...
0.80490977
0
Checks whether an element is a link adjacent to footnote text.
def is_footnote_link(self, par): return self.is_footnote_text(par.find_next_sibling('p'))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_footnote(self, par):\n if par.find_next_sibling('p') is None:\n return False\n return self.is_footnote_text(par) or self.is_footnote_link(par)", "def is_link(s):\n return (len(s) == 2 and is_link(s[1])) or s == empty", "def check_link(self, link, links_para):\n href =...
[ "0.69997984", "0.6757967", "0.6695195", "0.66264176", "0.66264176", "0.66264176", "0.63451207", "0.6296661", "0.6101461", "0.60751194", "0.604954", "0.6045755", "0.60173523", "0.5861832", "0.5820362", "0.5799617", "0.5760772", "0.57050264", "0.5704481", "0.5701879", "0.569843...
0.8036169
0
Checks whether a paragraph element is part of a footnote.
def is_footnote(self, par): if par.find_next_sibling('p') is None: return False return self.is_footnote_text(par) or self.is_footnote_link(par)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_footnote_text(self, par):\n return (par is not None) and (\"foot\" in par.attrs.get(\"class\", []))", "def is_footnote_link(self, par):\n return self.is_footnote_text(par.find_next_sibling('p'))", "def is_footnote(self):\n return self.style['float'] == 'footnote'", "def check_mark...
[ "0.8045934", "0.7436927", "0.6865161", "0.60696536", "0.60482085", "0.6026402", "0.6006918", "0.57114613", "0.56973517", "0.56481415", "0.5624542", "0.55489916", "0.5463017", "0.53871185", "0.52857167", "0.5267883", "0.5256443", "0.5246128", "0.5203835", "0.5170078", "0.51535...
0.79070187
1
Checks whether a paragraph is part of a table of contents.
def is_toc(self, par): return "toc" in par.attrs.get("class", [])
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def isTable(line):\n # Make the string easier to parse.\n line_stripped = lineNormalise(line)\n\n # Return value.\n ret = False\n\n # If the line starts with the word table, we have a table definition!\n if line_stripped.startswith('table'):\n ret = True\n\n # Tell the horrible truth th...
[ "0.64335525", "0.6316292", "0.5921447", "0.5887786", "0.5816467", "0.58017445", "0.5749812", "0.5692028", "0.56918216", "0.56839854", "0.56645924", "0.5649797", "0.5557572", "0.5544824", "0.5544294", "0.553953", "0.5523673", "0.5453183", "0.54286253", "0.5415694", "0.53847057...
0.6113981
2
Returns paragraph element corresponding to the given id.
def _get_footnote_par(self, id): start = self._current_body_par if start is None: start = self.parsed link = start.find_next(id=id) if link is None: raise NoFootnoteError(f"Could not find id {id}") foot_par = link.parent.find_next_sibling('p') if n...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __getitem__(self, pID: int) -> Tuple[int, str, str]:\n\n try:\n return next(self._cursor.execute(\n f\"SELECT id, raw_document_title, raw_paragraph_context FROM paragraphs WHERE id = ?\", (pID,)\n ))\n except StopIteration:\n raise KeyError(...
[ "0.62857157", "0.6051216", "0.6041252", "0.5996266", "0.5886566", "0.58803475", "0.581452", "0.57547826", "0.5694344", "0.56772363", "0.5660466", "0.5647002", "0.5594322", "0.55925494", "0.55812985", "0.5573686", "0.5553297", "0.5532051", "0.5492356", "0.54790217", "0.5463343...
0.5871431
6
Walk over pararaphs in the main text. If a footnote link is found, jump to that paragraph, then back to the main text.
def linked_text_paragraphs(self): for par in self._main_paragraphs_raw(): par_links = par.find_all('a') if len(par_links) == 0: self.main_count += len(par.text) yield par.text else: for el in par.contents: if...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def segment_paragraphs(root_el, cites=[]):\n from capdb.models import Citation\n\n last_el_ends_mid_sentence = False\n join_with_last_el = False\n html_to_prepend_to_next_el = ''\n\n # build a lookup like {\"935 F.3d\": 1, \"123 Mass.\": 2}\n reporter_indexes = {}\n for i, cite in enumerate(Ci...
[ "0.5886465", "0.58725065", "0.58705807", "0.57472676", "0.56360775", "0.55975014", "0.5573705", "0.5540514", "0.54371405", "0.54029816", "0.53338504", "0.53178537", "0.5315798", "0.5282773", "0.52491987", "0.52362645", "0.5195637", "0.5168886", "0.513893", "0.51377296", "0.51...
0.6464983
0
Tokenize on linebyline basis.
def tokenize_generic(self, tokenizer, N=None, drop_punctuation=True): ct, done = 0, False with open(self.textfile) as f: for ln in f.readlines(): if done: break ln = ln.replace("(return)", "") for token in tokenizer(ln.strip...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tokenize_words(line):\n return", "def tokenize(\n self, text_row: Optional[List[str]], token_row: Optional[List[List[str]]]\n ):\n raise NotImplementedError", "def tokenize_line(line, max_line_length=None, number_token=None, name_token=None, gpe_token=None):\n new_line = word_tokeniz...
[ "0.69884706", "0.66323274", "0.6459621", "0.64471626", "0.6395952", "0.6366297", "0.63627106", "0.6332375", "0.62884957", "0.62397844", "0.620047", "0.61909837", "0.6182466", "0.61787194", "0.6176044", "0.61732286", "0.6165838", "0.6162342", "0.6160397", "0.6157418", "0.61514...
0.0
-1
tokenize using the nltk default (ptb + a 'punkt' sentence tokenizer)
def tokenize(self, N=None, drop_punctuation=True, lower=True): for tok in self.tokenize_generic(word_tokenize, N=N, drop_punctuation=drop_punctuation): if lower: tok = tok.lower() yield tok
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def gpt2_tokenize(self, text: str):\n return self.bpe_tokenize(text)", "def preprocess(text):\n\tX = []\n\tsent_detector = nltk.data.load('tokenizers/punkt/english.pickle')\n\tfor t in text:\n\t\tsents = sent_detector.tokenize(t)\n\t\tresult = ''\n\t\tfor s in sents:\n\t\t\ttokens = word_tokenize(s)\n\t\t...
[ "0.7247982", "0.7229188", "0.7094783", "0.70895004", "0.70805717", "0.69946355", "0.6974862", "0.6922694", "0.6919841", "0.68694", "0.6835729", "0.6791642", "0.67796576", "0.6747571", "0.6684571", "0.66801494", "0.6662924", "0.6644727", "0.66325396", "0.6598598", "0.6588903",...
0.0
-1
boolean of if changes have been made to present sha
def dirty(cls): output = subprocess.check_output(DIRTY_INCANTATION) return len(output.strip()) == 0
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def has_changes(self):\n if self.repo_is_empty:\n return True\n\n tree = self.repo.get(self.index.write_tree(self.repo))\n diff = tree.diff_to_tree(self.repo.get(self.repo.head.target).tree)\n return bool(diff)", "def index_is_dirty():\n result, output = popen('git diff ...
[ "0.69775397", "0.6945446", "0.6825735", "0.68252903", "0.6719734", "0.6671272", "0.6610195", "0.6565223", "0.6532837", "0.6526835", "0.6508548", "0.6499044", "0.6385325", "0.63748574", "0.6319224", "0.6314689", "0.63038826", "0.6292349", "0.6275215", "0.6274554", "0.6246274",...
0.66552734
6
Read input from a text file
def read_input(): orbitDict = {} with open('day06_input.txt') as f: for line in f: planet, satellite = line.split(')') satellite = satellite.rstrip('\n') if satellite in orbitDict: orbitDict[satellite].append(planet) else: ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def read_input():\n return Path(__file__).with_name('input.txt').read_text().splitlines()", "def read_txt(cls, input_file):\n return open(input_file, \"r\", encoding=\"utf-8\").readlines()", "def read_txt(cls, input_file):\n return open(input_file, \"r\", encoding=\"utf-8\").readlines()", "d...
[ "0.80333656", "0.73937935", "0.73937935", "0.7325028", "0.7260986", "0.72499967", "0.72369945", "0.712606", "0.7094524", "0.70686525", "0.69390434", "0.6938965", "0.6922924", "0.68762004", "0.68759114", "0.68530405", "0.68422097", "0.67936075", "0.67765266", "0.6772103", "0.6...
0.0
-1
Counts the number of orbitating planets
def num_of_orbits(orbitDict): total_orbits = len(orbitDict.keys()) total_orbits += independent_orbits(orbitDict) return total_orbits
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def orbit_count(self) -> int:\n if self.orbit:\n return 1 + self.orbit.orbit_count()\n return 0", "def orbit_count(objects: Dict[str, ObjectMass]) -> int:\n total = 0\n\n for mass in objects.values():\n total += mass.orbit_count()\n\n return total", "def count():", "d...
[ "0.7507539", "0.72100306", "0.617972", "0.6152469", "0.61030316", "0.603404", "0.6009309", "0.5947875", "0.59461266", "0.5906092", "0.5883676", "0.5869086", "0.58329415", "0.5806103", "0.5806103", "0.5806103", "0.5806103", "0.577206", "0.574075", "0.57232994", "0.57174265", ...
0.6075204
5
This function identify on which orbits it is possible to meet santa with the least number of jumps
def meet_santa(orbitDict): santa_count, santa_path = does_orbit('SAN', orbitDict) your_count, your_path = does_orbit('YOU', orbitDict) santa_planets = set(santa_path) your_planets = set(your_path) common = len(santa_planets.intersection(your_planets)) dist = santa_count + your_count - 2*common ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def spotlessroomba_first_heuristic(state : SpotlessRoombaState) -> float:\n # TODO a nontrivial admissible heuristic\n return len(state.dirty_locations)", "def challenge1(self):\n self.parse_input()\n\n # Find strongest nanobot\n strongest = max(self.nanobots, key=lambda n: n.r)\n\n ...
[ "0.6110882", "0.60308844", "0.5878015", "0.5863746", "0.5748723", "0.5709508", "0.56566536", "0.56528664", "0.5624614", "0.5575636", "0.5567551", "0.55536634", "0.5527198", "0.55191416", "0.5517331", "0.5514932", "0.5513137", "0.5498134", "0.5493011", "0.54866076", "0.5477608...
0.5761488
4
Returns a Pythonnormalized String object from unicode.
def normalize_unicode_data(data): normalized_data = unicodedata.normalize('NFKD', data).encode('ascii', 'ignore') return normalized_data
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load(self, string):\r\n if isinstance(string, unicode):\r\n u = string\r\n else:\r\n u = unicode(string, self.encoding)\r\n return u", "def as_unicode(string):\n return same_string_type_as(\"\", string)", "def _as_unicode(s):\n if isinstance(s, str):\n ...
[ "0.7233125", "0.71349865", "0.7019128", "0.70103765", "0.6991322", "0.6916738", "0.6904967", "0.68421304", "0.6790128", "0.67792904", "0.671786", "0.6711641", "0.67108285", "0.66316116", "0.6597703", "0.6570314", "0.6567923", "0.65449303", "0.6489974", "0.645341", "0.64313215...
0.0
-1
Material saver. Saves material and their properties the JSON file for type building elements. If the Project parent is set, it automatically saves it to the file given in Project.data. Alternatively you can specify a path to a file with Materials. If this file does not exist, a new file is created.
def save_material(material, data_class): data_class.material_bind["version"] = "0.7" add_to_json = True warning_text = ("Material with same name and same properties already " "exists in JSON, consider this material or revising your " "properties") for id, check ...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def save_material(filename, mat):\n out = np.array([mat.wav, mat.eps.real, mat.eps.imag,\n mat.mu.real, mat.mu.imag]).T\n header = \"Wavelength\\teps_real\\teps_imag\\tmu_real\\tmu_imag\"\n miepy.array_io.save(filename, out, header=header)", "def WriteStructuralMaterialsjson(save_path...
[ "0.57051945", "0.55286336", "0.54615587", "0.53826904", "0.5350502", "0.53496337", "0.5319556", "0.52859074", "0.5285472", "0.52815086", "0.5229431", "0.5202984", "0.5185666", "0.5141686", "0.5140259", "0.513041", "0.51060146", "0.5105606", "0.50921017", "0.5083165", "0.50725...
0.65841603
0
Create a new Settings, reading from a default location for the given domain (~/Library/Preferences/%s.plist).
def __init__(self, domain='com.markfickett.gors'): settingsDir = os.path.expanduser(self.__SETTINGS_DIR) if not os.path.isdir(settingsDir): os.makedirs(settingsDir) self.__settingsFileName = os.path.join(settingsDir, domain + '.plist') if os.path.isfile(self.__settingsFileName): self.__settings = plist...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def settings_create(ctx):\n # Choose where and whether to save the configuration file.\n path = ctx.obj['load_path']\n if path:\n click.confirm(\n 'A settings file already exists. Continuing will override it. '\n 'Do you want to continue?',\n abort=True,\n )\...
[ "0.5657144", "0.548896", "0.5319334", "0.5285291", "0.52768016", "0.5255273", "0.5222265", "0.5218223", "0.5189833", "0.5173989", "0.5170184", "0.51397663", "0.513596", "0.5086622", "0.50810987", "0.50810987", "0.50761354", "0.5024908", "0.5006228", "0.5000491", "0.5000396", ...
0.7057614
0
Create and return a GroupGuard for this Settings object, which prepends a group name to all settings names referenced while it is active.
def groupGuard(self, groupNameRaw): groupName = str(groupNameRaw) if self.__DELIMITER in groupName: raise ValueError(("Illegal group name '%s' contains" + " delimiter '%s'.") % (groupName, self.__DELIMITER)) return self._GroupGuard(self, groupName)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def make_grp(self, name='grp'):\n self.base[name] = self.get_group_array()", "def createGroup(self):\n return _libsbml.GroupsModelPlugin_createGroup(self)", "def save_group_and_return_instance(self, groupname=\"\"):\n if groupname == \"\":\n raise ValueError(\"group needs its na...
[ "0.6209012", "0.5984325", "0.5788384", "0.568222", "0.56628835", "0.563917", "0.5622585", "0.56192756", "0.56191015", "0.55996215", "0.5569049", "0.5563115", "0.5557951", "0.55311483", "0.550896", "0.54411197", "0.54324687", "0.5423106", "0.5397997", "0.53885156", "0.53813946...
0.5727455
3
Return a list of all groups under the current group. (This is potentially slow, as it recomputes every time.)
def getChildGroups(self): groupPrefix = self.__DELIMITER.join(self.__currentGroupNames) if groupPrefix: groupPrefix += self.__DELIMITER skipLen = len(groupPrefix) childGroups = set() for keyName in self.__settings.keys(): if keyName.startswith(groupPrefix): childKey = keyName[skipLen:] groupKey,...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getGroups(self):\n return [g[0] for g in grp.getgrall()]", "def list_groups():\n return _list_tindyb_unique_values(\"group\", dbpath=__dbpath__)", "def get_all_groups(self):\n return self.groups + ['all']", "def getGroups():\r\n return Group.getGroups()", "def get_pingroups(self...
[ "0.80298066", "0.7753639", "0.7704329", "0.76670724", "0.7662189", "0.7483736", "0.74683553", "0.7443777", "0.7393224", "0.7341", "0.7341", "0.7341", "0.73013186", "0.7216928", "0.7213653", "0.7186486", "0.7179003", "0.7083968", "0.7080749", "0.70386165", "0.7009138", "0.69...
0.67759746
32
Get the full name of the given keyName under the current group. If extant is True, only return extant keys; otherwise return None.
def __getKey(self, keyNameRaw, extant=True): fullKeyName = self.__DELIMITER.join( self.__currentGroupNames + [str(keyNameRaw)]) if extant and (fullKeyName not in self.__settings): return None return fullKeyName
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def key_name(self) -> Optional[str]:\n return pulumi.get(self, \"key_name\")", "def get_name(self):\n return self.key().name().split(':', 1)[1]", "def extract_key_name(self):\n # quick and dirty regex parsing..\n # consider using gnupg.\n _, out, _ = self.as_user('/usr/bin/gp...
[ "0.61867285", "0.6151179", "0.59994215", "0.59087443", "0.59087443", "0.58050305", "0.57887447", "0.57743907", "0.57119745", "0.5711618", "0.56672543", "0.5649241", "0.5592001", "0.55778885", "0.55366206", "0.55205065", "0.55190045", "0.55060714", "0.55060714", "0.55060714", ...
0.77827585
0
This function gets the total occurrences of words and syllables in the original Unicode Garshana corpus. To do this, it opens a .csv file with utf16 encoding, and splits on commans, expecting the line of sumerian text to be in the 8th column. Filters annotations from each line, and tracks the occurrence of each word an...
def get_counts(data): word_count = {} syll_count = {} infile = data.corpus try: open_file = codecs.open(infile, 'r', encoding='utf-16') for line in open_file: line = line.lower() # Remove tablet indexing info and line numbers. Grab only text data li...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_word_counts(filename):\n raw_rows = csv_rows(filename)\n word_counts = defaultdict(lambda: 0)\n\n for line_number, raw_row in enumerate(raw_rows, 2):\n count = int(raw_row[\"count\"])\n ipa = raw_row[\"IPA\"]\n if '*' in ipa:\n continue\n\n # Fixes random badness.. hopefully doesn't hi...
[ "0.6335053", "0.57268775", "0.57179636", "0.5714977", "0.57052946", "0.5632471", "0.56277466", "0.56243765", "0.5612738", "0.5593558", "0.55885386", "0.5571546", "0.5560268", "0.55578226", "0.55549335", "0.55408674", "0.55253506", "0.5510573", "0.55039716", "0.5502862", "0.55...
0.65279776
0
Update the total occurrence counts of each unigram, bigram, and trigram
def update_syllable_count(word, syll_count): syllables = word.split('-') for i in range(1, 4): for j in range(len(syllables) - i + 1): gram = '-'.join(syllables[j: j + i]) count = syll_count.setdefault(gram, 0) syll_count[gram] = count + 1
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _count(self):\n words = [word.lower() for word in self.corpus.words()]\n bigrams_words = bigrams(words)\n for bigram in bigrams_words:\n self._bigrams[bigram] += 1", "def count_ngrams(self, corpus):\n \n self.unigramcounts = {} # might want to use defaultdict or Count...
[ "0.7613877", "0.754076", "0.7213328", "0.7121193", "0.7052331", "0.6792219", "0.6738704", "0.6667053", "0.6502214", "0.6489286", "0.647944", "0.64368546", "0.6427307", "0.641034", "0.6370047", "0.6328885", "0.6313854", "0.62974036", "0.62933725", "0.6273226", "0.62302506", ...
0.0
-1
Clean a line of data, removing all annotations from the line.
def clean_line(line, normNum=True, normProf=True): # Remove square brackets, ceiling characters, question marks, other # questionable characters, and line breaks line = re.sub(r'(\[|\])', '', line) line = re.sub(r'(⌈|⌉)', '', line) line = re.sub(r'( / )', ' ', line) line = re.sub(r'/', '', line...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def cleaning (data):", "def clean_line(self, line):\n\n if \"#\" in line:\n temp = line.split(\"#\")\n if len(temp) < 2:\n return \"\"\n else:\n temp = temp[0] + \"\\n\"\n\n # make sure the \"#\" isn't in quotes\n if temp...
[ "0.65842664", "0.6322053", "0.61243117", "0.6106798", "0.6106798", "0.6087376", "0.60553944", "0.5906017", "0.5889315", "0.5888119", "0.58622", "0.58618647", "0.58282447", "0.58261687", "0.5818282", "0.58130705", "0.57777137", "0.5760969", "0.57328576", "0.57266486", "0.57165...
0.6030962
7
Returns the accounting period that is currently valid. Valid is an accounting_period when the current date lies between begin and end of the accounting_period
def get_current_valid_accounting_period(): current_valid_accounting_period = None for accounting_period in AccountingPeriod.objects.all(): if accounting_period.begin < date.today() and accounting_period.end > date.today(): return accounting_period if not current_valid...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getCurrentValidAccountingPeriod():\n currentValidAccountingPeriod = None\n for accountingPeriod in AccountingPeriod.objects.all():\n if accountingPeriod.begin < date.today() and accountingPeriod.end > date.today():\n return accountingPeriod\n if currentValidAccoun...
[ "0.82862264", "0.6872075", "0.65232825", "0.6370569", "0.6290718", "0.60823673", "0.6040515", "0.6040515", "0.6040515", "0.6040515", "0.6040515", "0.6040515", "0.6040515", "0.6040515", "0.6018042", "0.6012301", "0.5940794", "0.59097856", "0.5859212", "0.5821298", "0.5755713",...
0.8423247
0
Returns the accounting period that is currently valid. Valid is an accountingPeriod when the current date lies between begin and end of the accountingPeriod
def get_all_prior_accounting_periods(target_accounting_period): accounting_periods = [] for accounting_period in AccountingPeriod.objects.all(): if accounting_period.end < target_accounting_period.begin: accounting_periods.append(accounting_period) if accounting_perio...
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_current_valid_accounting_period():\n current_valid_accounting_period = None\n for accounting_period in AccountingPeriod.objects.all():\n if accounting_period.begin < date.today() and accounting_period.end > date.today():\n return accounting_period\n if not cur...
[ "0.84471315", "0.8381506", "0.68428826", "0.6510184", "0.6339413", "0.60962486", "0.60355204", "0.6016154", "0.6016154", "0.6016154", "0.6016154", "0.6016154", "0.6016154", "0.6016154", "0.6016154", "0.6013164", "0.5948316", "0.58576053", "0.58273315", "0.58267355", "0.572815...
0.63429344
4
Transform mp3 file into wav format calling bash and using mpg123 or ffmpeg.
def mp3_to_wav(mp3_file, wav_file, encoder='mpg123'): if encoder == 'mpg123': bash_command = ['mpg123', '-w', wav_file, '--mono', mp3_file] else: bash_command = ['ffmpeg', '-i', mp3_file, wav_file] subprocess.run(bash_command)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def mp3_to_wav(show_progress=True):\n\n # Define a devnull var to supress subprocess output\n devnull = open(os.devnull, 'w')\n\n # Get a list of the filepath for each of the mp3 files in each subdirectory of data/fma_small\n file_list = glob.glob('./../data/fma_small/*/*.mp3')\n\n # Get the number ...
[ "0.73525465", "0.7225452", "0.7119044", "0.70570403", "0.67239785", "0.6696764", "0.6579686", "0.6547333", "0.6539131", "0.6505683", "0.6481485", "0.64209044", "0.6362076", "0.6354701", "0.632691", "0.6275299", "0.62359387", "0.6216278", "0.6215746", "0.61728823", "0.6155799"...
0.8660163
0