How to use list_roles method in localstack

Best Python code snippet using localstack_python

similarity_by_role.py

Source: similarity_by_role.py Github

copy

Full Screen

1from datetime import datetime2import pandas as pd3from itertools import combinations4from helpers import extract_players_with_role, transpose_features5from helpers_similarity import compute_max_distance, compute_relative_similarity6# load data7players = pd.read_csv("data/​players_post_corr.csv")8scl_ftrs = pd.read_csv("data/​scaled_features_post_corr.csv")9list_roles = players['Pos'].unique()10# keep only 1 roles (for now)11list_roles = [role for role in list_roles if not ("-" in role)]12# overall complementarity13df_overall = pd.read_csv("output_data/​ovrl_distances.csv")14# transpose features15t_scl_ftrs = transpose_features(scl_ftrs)16# computation last about 5 seconds17list_players = [extract_players_with_role(players, elem) for elem in list_roles]18# use a dictionary to recognize list of which roles19dict_players_roles = dict(zip(list_roles, list_players))20# compute max distances per role21dict_max_distance = dict(zip(list_roles, [compute_max_distance(t_scl_ftrs, elem) for elem in dict_players_roles.values()]))22# compute combination for every role23comb_roles_players_values = [list(combinations(elem, 2)) for elem in dict_players_roles.values()]24# create dataframe of combinations per every role25dict_comb_roles_players = dict(zip(list_roles, [pd.DataFrame(elem, columns=['Player1', 'Player2']) for elem in comb_roles_players_values]))26# for every role, com27for role in dict_comb_roles_players.keys():28 dict_comb_roles_players[role]['similarity'] = list(29 map(lambda x, y: compute_relative_similarity(30 t_scl_ftrs,31 x,32 y,33 dict_max_distance[role]),34 dict_comb_roles_players[role]['Player1'],35 dict_comb_roles_players[role]['Player2']))36 dict_comb_roles_players[role]['complementarity'] = 1 - dict_comb_roles_players[role]['similarity']37# add role to every dataframe and concatenate38for role in dict_comb_roles_players.keys():39 dict_comb_roles_players[role].insert(0, 'Pos', [role]*len(dict_comb_roles_players[role]))40df_by_roles = pd.concat(dict_comb_roles_players.values())41# add_overall complementarity ###42# change column name of overall_df43df_overall.rename(columns={'similarity': 'similarity_ov', 'complementarity': 'complementarity_ov'}, inplace=True)44# merge by role and overall45df_by_roles_overall = df_by_roles.merge(df_overall, how='left', on=['Player1', 'Player2'])46# add column of delta between two method47df_by_roles_overall['delta_sim'] = df_by_roles_overall['similarity_ov'] - df_by_roles_overall['similarity']48df_by_roles_overall['delta_com'] = df_by_roles_overall['complementarity'] - df_by_roles_overall['complementarity_ov']49# save output to csv...

Full Screen

Full Screen

rolemanager.py

Source: rolemanager.py Github

copy

Full Screen

1# coding: utf-82import argparse3import os4from discord.ext import commands5from base import BaseCog, Parser6# Discord roles allowed to be granted to users7DISCORD_ROLES = os.environ.get('DISCORD_ROLES')8class RoleManager(BaseCog):9 """10 Role manager bot11 """12 @commands.command(name='roles')13 @commands.guild_only()14 async def _roles(self, ctx, *args):15 """16 Permet de s'attribuer un ou plusieurs rôles.17 Usage : `!roles <role> [<role> ...]`18 """19 if ctx.channel and hasattr(ctx.channel, 'name'):20 await ctx.message.delete()21 user = await self.get_user(ctx.author)22 # Get roles23 list_roles = [r.split("=") for r in DISCORD_ROLES.split(",")] if DISCORD_ROLES else []24 help_roles = ",\n".join(f"- {rolename} ({shortcut})" for (shortcut, rolename) in list_roles)25 # Argument parser26 parser = Parser(27 prog=f'{ctx.prefix}{ctx.command.name}',28 description="Permet de s'attribuer un ou plusieurs rôles.",29 epilog=f"Rôles disponibles :\n{help_roles}",30 formatter_class=argparse.RawTextHelpFormatter)31 parser.add_argument('roles', metavar='role', type=str, nargs='*', help="Rôle")32 args = parser.parse_args(args)33 if parser.message:34 await ctx.author.send(f"```{parser.message}```")35 return36 # Collect all allowed roles37 roles = {}38 for role in ctx.guild.roles:39 for shortcut, rolename in list_roles:40 if role.name.lower() == rolename.lower():41 roles[shortcut] = role42 # Collect selected roles43 new_roles = []44 selected_roles = map(str.lower, args.roles)45 for shortcut, role in roles.items():46 if shortcut.lower() in selected_roles:47 new_roles.append(role)48 elif role.name.lower() in selected_roles:49 new_roles.append(role)50 if not new_roles:51 help_roles = ", ".join(f"**{rolename}** ({shortcut})" for (shortcut, rolename) in list_roles)52 await ctx.author.send(f":warning: Vous devez sélectionner un ou plusieurs rôles parmi : {help_roles}")53 return54 # Clear roles55 old_roles = list(roles.values())56 await ctx.author.remove_roles(*old_roles)57 # Add roles58 await ctx.author.add_roles(*new_roles)59 role_names = ', '.join(role.name for role in new_roles)...

Full Screen

Full Screen

test_user.py

Source: test_user.py Github

copy

Full Screen

...33 user.set_password('')34 assert not user.check_password('')35def test_user_role():36 user = User('paper')37 assert user.list_roles() == []38 user.add_role('ADMIN')39 assert user.list_roles() == ['ADMIN']40 user.del_role('ADMIN')41 assert user.list_roles() == []42 # add twice to confirm set-ness43 user.add_role('ADMIN')44 user.add_role('ADMIN')...

Full Screen

Full Screen

Blogs

Check out the latest blogs from LambdaTest on this topic:

13 Best Java Testing Frameworks For 2023

The fact is not alien to us anymore that cross browser testing is imperative to enhance your application’s user experience. Enhanced knowledge of popular and highly acclaimed testing frameworks goes a long way in developing a new app. It holds more significance if you are a full-stack developer or expert programmer.

QA Innovation &#8211; Using the senseshaping concept to discover customer needs

QA Innovation - Using the senseshaping concept to discover customer needsQA testers have a unique role and responsibility to serve the customer. Serving the customer in software testing means protecting customers from application defects, failures, and perceived failures from missing or misunderstood requirements. Testing for known requirements based on documentation or discussion is the core of the testing profession. One unique way QA testers can both differentiate themselves and be innovative occurs when senseshaping is used to improve the application user experience.

Best 23 Web Design Trends To Follow In 2023

Having a good web design can empower business and make your brand stand out. According to a survey by Top Design Firms, 50% of users believe that website design is crucial to an organization’s overall brand. Therefore, businesses should prioritize website design to meet customer expectations and build their brand identity. Your website is the face of your business, so it’s important that it’s updated regularly as per the current web design trends.

Acquiring Employee Support for Change Management Implementation

Enterprise resource planning (ERP) is a form of business process management software—typically a suite of integrated applications—that assists a company in managing its operations, interpreting data, and automating various back-office processes. The introduction of a new ERP system is analogous to the introduction of a new product into the market. If the product is not handled appropriately, it will fail, resulting in significant losses for the business. Most significantly, the employees’ time, effort, and morale would suffer as a result of the procedure.

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run localstack automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful