query stringlengths 9 9.05k | document stringlengths 10 222k | metadata dict | negatives listlengths 30 30 | negative_scores listlengths 30 30 | document_score stringlengths 4 10 | document_rank stringclasses 2
values |
|---|---|---|---|---|---|---|
Changing retraction distance for a specific source file. User has to define the initial distance and the layer distance, which specifies the number of layers between steps. | def change_retraction_distance(gcode_source=None,
gcode_target=None,
initial_retraction_distance=None,
retraction_distance_step=None,
layer_distance=None):
current_retraction_distance_at ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def change_retraction_speed(gcode_source=None,\r\n gcode_target=None,\r\n initial_retraction_speed=None,\r\n retraction_speed_steps=None,\r\n layer_distance=None):\r\n current_retraction_speed_at = initia... | [
"0.6554519",
"0.5894121",
"0.54211605",
"0.5257834",
"0.52510875",
"0.519945",
"0.5167026",
"0.51603335",
"0.5125909",
"0.5120682",
"0.5090662",
"0.5090662",
"0.5090662",
"0.5077957",
"0.5023852",
"0.5004175",
"0.49800298",
"0.49681148",
"0.49439764",
"0.49373457",
"0.4929862... | 0.7477062 | 0 |
Get list of Networks. | def getNetworksList():
logger.debug('Start.')
code, res = rest_requests.get(networks_url)
if code != requests.codes.ok:
logger.error((code, res))
return None
return res["networks"] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def list_net(self):\n _url = \"http://\" + self.host_ip + \":9696/v2.0/networks\"\n _headers = {'Content-type': 'application/json',\n 'x-auth-token': self.project_info[\"token_project\"]}\n _body = None\n\n response = self.request(\"GET\", _url, _headers, _body)\n ... | [
"0.82582057",
"0.8199183",
"0.78605705",
"0.7499065",
"0.7486813",
"0.7416529",
"0.7398821",
"0.7363961",
"0.7313583",
"0.73133165",
"0.7278503",
"0.72622854",
"0.7212701",
"0.71903056",
"0.71645385",
"0.69654167",
"0.68876684",
"0.6863129",
"0.6854689",
"0.6777646",
"0.67732... | 0.84725606 | 0 |
Extends the provided flask application with the minio extension | def init_app(self, app):
self.client = _Minio(
app.config.get('MINIO_URL'),
access_key=app.config.get('MINIO_ACCESS_KEY'),
secret_key=app.config.get('MINIO_SECRET_KEY'),
session_token=app.config.get('MINIO_SESSION_TOKEN'),
secure=app.config.get('MINIO... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def app(request):\n app = flask.Flask(__name__)\n return app",
"def application():\n\n configure_app(app)\n yield app",
"def main():\r\n run_wsgi_app(app)",
"def init_app(app):\n app.load_extension(__name__)",
"def create_app():\n from server.web import create_app\n # If we do a sta... | [
"0.65421313",
"0.63359344",
"0.6304174",
"0.6301844",
"0.62669164",
"0.6215751",
"0.6214499",
"0.62098366",
"0.6195186",
"0.6118161",
"0.61166584",
"0.611639",
"0.610602",
"0.6103126",
"0.60942835",
"0.607921",
"0.6078686",
"0.60635924",
"0.6055811",
"0.601377",
"0.60137546",... | 0.68851787 | 0 |
Shows who's watching what. | async def watching(self, ctx: commands.Context):
global _ # MyPy was complaining this was a unresolved reference until global was called
watching_data = await self.get_players_per_activity(ctx=ctx, movie=True)
embed_colour = await ctx.embed_colour()
if watching_data:
embed_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def disp_watchlist(caller):\n watchlist = caller.db.watching or []\n if not watchlist:\n caller.msg(\"Not watching anyone.\")\n return\n table = []\n for ob in sorted(watchlist, key=lambda x: x.key):\n name = ob.key.capitalize()\n if ob.player... | [
"0.653655",
"0.6005459",
"0.59488523",
"0.5836988",
"0.58289796",
"0.57998854",
"0.5708749",
"0.5630593",
"0.5536783",
"0.5514452",
"0.5507232",
"0.5500961",
"0.5480793",
"0.5474604",
"0.54352057",
"0.54306835",
"0.54077625",
"0.53979725",
"0.5377859",
"0.52869815",
"0.528430... | 0.66203403 | 0 |
Shows who's listening what. | async def listening(self, ctx: commands.Context):
global _ # MyPy was complaining this was a unresolved reference until global was called
listening_data = await self.get_players_per_activity(ctx=ctx, music=True)
embed_colour = await ctx.embed_colour()
if listening_data:
emb... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def sit(self):\n print(f\"{self.name.title()} is listening to our command and sitting\")",
"def show_greeting(self):\n self.output(' ------------------------ ')\n self.output('You are now playing ' + self.name)\n self.output(self.greeting)\n self.output(' ----------------------... | [
"0.6168793",
"0.60264915",
"0.60048455",
"0.5975427",
"0.5899944",
"0.5896655",
"0.58959395",
"0.5895427",
"0.58945537",
"0.5875578",
"0.5875578",
"0.586331",
"0.5838667",
"0.5824975",
"0.574025",
"0.57317257",
"0.5726735",
"0.5722308",
"0.5651958",
"0.5646903",
"0.5636355",
... | 0.6366619 | 0 |
Shows who's streaming what games. | async def streaming(self, ctx: commands.Context, *, game=None):
global _ # MyPy was complaining this was a unresolved reference until global was called
game_name = _("what")
ending = "."
game_list = []
if game:
game_name = game
game_list = [game]
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def list(self, ctx):\n cyphon = discord.utils.get(ctx.message.server.members, id=\"186835826699665409\")\n\n if self.check_channel(ctx):\n if self.check_permission(ctx) or ctx.message.author == cyphon:\n message = []\n message.append(\"```\\n\")\n ... | [
"0.6299238",
"0.6193129",
"0.61670715",
"0.6062554",
"0.60420376",
"0.6030096",
"0.6024751",
"0.6003919",
"0.5986063",
"0.59717286",
"0.5955881",
"0.5907619",
"0.5881844",
"0.585751",
"0.58329064",
"0.5811922",
"0.5808516",
"0.580039",
"0.5798102",
"0.57709444",
"0.5768401",
... | 0.72848076 | 0 |
initialize the adapter with the app object and the user object | def __init__(self, app, user):
self.app = app
self.user = user | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init():\n create_user(app)\n get_all_user()",
"def initialize(self, *a, **kw):\n\n webapp2.RequestHandler.initialize(self, *a, **kw)\n uid = self.read_secure_cookie('user_id')\n self.user = uid and User.by_id(int(uid))",
"def initialize(self, *a, **kw):\n webapp2.RequestHa... | [
"0.6841957",
"0.62636566",
"0.623731",
"0.6233432",
"0.6223707",
"0.6199464",
"0.6159303",
"0.6133899",
"0.61197054",
"0.6086448",
"0.6050041",
"0.6037377",
"0.6024223",
"0.59973097",
"0.5973324",
"0.5929636",
"0.5925314",
"0.59078264",
"0.5904341",
"0.589733",
"0.5896603",
... | 0.73016673 | 0 |
initialize the adapter with the barcamp and the handler in use | def __init__(self, barcamp, handler):
self.barcamp = barcamp
self.handler = handler
self.app = self.handler.app
self.config = self.handler.app.config
self.user = self.handler.user | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, handler, user, barcamp = None):\n self.handler = handler\n if barcamp is None:\n self.barcamp = handler.barcamp\n else:\n self.barcamp = barcamp\n self.app = handler.app\n self.barcamp_view = BarcampView(self.barcamp, handler)\n sel... | [
"0.70408744",
"0.66367024",
"0.63562727",
"0.6281535",
"0.61023164",
"0.60614496",
"0.6037671",
"0.6036464",
"0.60360694",
"0.6029543",
"0.6024848",
"0.60094357",
"0.59982187",
"0.5996584",
"0.5996584",
"0.5958339",
"0.5958339",
"0.5958339",
"0.5958339",
"0.5958339",
"0.59583... | 0.6997935 | 1 |
return variants of the logo url | def logo_url(self):
asset = self._get_image(self.barcamp.logo)
if asset is None:
return None
uf = self.app.url_for
return dict(
[(vid, uf('asset', asset_id = asset._id)) for vid, asset in asset.variants.items()]
) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def logo_url(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"logo_url\")",
"def logo_url(self) -> pulumi.Output[str]:\n return pulumi.get(self, \"logo_url\")",
"def logo_url(self):\n return self.get_url(\"logo\", \"images/logo.png\")",
"def logo_uri(self) -> str:\n return... | [
"0.6689081",
"0.6689081",
"0.6602399",
"0.6471136",
"0.64212334",
"0.631559",
"0.62997395",
"0.62997395",
"0.6165886",
"0.6165886",
"0.61210525",
"0.6110057",
"0.60907465",
"0.60845435",
"0.60845435",
"0.6083771",
"0.59990895",
"0.598307",
"0.598307",
"0.598307",
"0.598307",
... | 0.7538238 | 0 |
try to get an image by it's asset id or return None | def _get_image(self, asset_id):
try:
return self.app.module_map.uploader.get(asset_id)
except AssetNotFound:
return None
except Exception, e:
return None
return None | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def image(image_id):\n\n found = False\n img = None\n \n try:\n for img in api.get_all_images():\n if img.id == image_id:\n found = True\n break\n except Exception:\n logging.error(\"Cannot make API connection to retrieve image info!\")\n\n if not found:\n return None\n\n return ... | [
"0.7652315",
"0.7507485",
"0.74635994",
"0.73365164",
"0.71952474",
"0.70284665",
"0.70263535",
"0.6995883",
"0.686196",
"0.6843943",
"0.68015677",
"0.67867386",
"0.67748916",
"0.676831",
"0.67658144",
"0.6759978",
"0.67233086",
"0.6720686",
"0.6706931",
"0.6644506",
"0.64170... | 0.8478803 | 0 |
return the logo for the open graph tag | def og_logo(self):
# first try fb logo
uf = self.app.url_for
img = self._get_image(self.barcamp.fb_image)
if img is None:
img = self._get_image(self.barcamp.logo)
if img is None:
return "" # no url
v = img.variants.get('facebook', None) # fb size
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def logo(self) -> str:\n return self._logo",
"def logo(self) -> pulumi.Output[Optional[str]]:\n return pulumi.get(self, \"logo\")",
"def logo(self) -> pulumi.Output[Optional[str]]:\n return pulumi.get(self, \"logo\")",
"def logo(self) -> Optional[pulumi.Input[str]]:\n return pulum... | [
"0.72243494",
"0.70971435",
"0.70971435",
"0.70340204",
"0.70340204",
"0.70340204",
"0.70340204",
"0.6968164",
"0.6944993",
"0.689125",
"0.68231237",
"0.68069965",
"0.67703223",
"0.67703223",
"0.67485213",
"0.6667876",
"0.6667876",
"0.6641108",
"0.6641108",
"0.65623957",
"0.6... | 0.75690675 | 0 |
return whether this barcamp features a gallery | def has_gallery(self):
if self.barcamp.gallery and self.barcamp.gallery == "-1":
return False
try:
gallery = self.config.dbs.galleries.get(bson.ObjectId(self.barcamp.gallery))
except:
return False
return True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def has_media(self):\r\n if self.image:\r\n return True\r\n return False",
"def has_images(self):\n return len(self.images) > 0",
"def hasImages(self):\n return len(self.getImages()) > 0",
"def hasImages(self):\n return len(self.getImages()) > 0",
"def has_pict... | [
"0.64063966",
"0.63213295",
"0.6164534",
"0.6164534",
"0.6093003",
"0.58077437",
"0.5767879",
"0.5756221",
"0.5667037",
"0.563331",
"0.563018",
"0.558962",
"0.5569196",
"0.55634314",
"0.5539645",
"0.5525409",
"0.5525409",
"0.5522532",
"0.5509865",
"0.54701763",
"0.54444665",
... | 0.8243727 | 0 |
properly format the location of the barcamp if given | def short_location(self):
bc = self.barcamp
location = AttributeMapper(bc.location)
if location.name and location.city:
return "%s, %s" %(location.name, location.city)
else:
return self.handler._("location to be announced") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def format_location(location):\n local = location.split()\n if len(local) > 1:\n if len(local) == 2 and len(local[1]) == 2:\n location = f\"{local[0].title()} {local[1].upper()}\"\n elif len(local) == 3 and len(local[2]) == 2:\n location = f\"{local... | [
"0.5791597",
"0.56370795",
"0.5570601",
"0.5560092",
"0.55393064",
"0.54537946",
"0.5428804",
"0.5353446",
"0.53134066",
"0.52877027",
"0.52565855",
"0.5248681",
"0.5224971",
"0.52217567",
"0.5167795",
"0.51587117",
"0.51558244",
"0.51433694",
"0.50987434",
"0.50981337",
"0.5... | 0.6081314 | 0 |
true if the logged in user is a barcamp admin | def is_admin(self):
if self.user is None:
return False
if unicode(self.user._id) in self.barcamp.admins:
return True
if self.user.is_admin:
return True
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_admin(self):\n if self.is_main_admin:\n return True\n if self.user is not None and self.barcamp is not None:\n if unicode(self.user._id) in self.barcamp.admins:\n return True\n return False",
"def is_admin(self):\n if not self.current_user:\... | [
"0.83883846",
"0.79494977",
"0.7751907",
"0.7716503",
"0.7696871",
"0.7695911",
"0.76617527",
"0.7600467",
"0.75899273",
"0.75611526",
"0.75224066",
"0.748795",
"0.7478665",
"0.7475087",
"0.7439486",
"0.743928",
"0.74124193",
"0.7380807",
"0.73783004",
"0.73772204",
"0.730812... | 0.8392431 | 0 |
true if the logged in user is a barcamp subscriber | def is_subscriber(self):
if self.user is None:
return False
if unicode(self.user._id) in self.barcamp.subscribers:
return True
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_subscriber(self) -> bool:\n return self.subscriber",
"def is_subscriber(self):\n try:\n return self.get_subscription().get('@type') != 'free'\n except Exception:\n # If can't retrieve, assume not paired and not a subscriber yet\n return False",
"def ... | [
"0.7343656",
"0.69290966",
"0.6707575",
"0.65904844",
"0.64737",
"0.6328013",
"0.6324193",
"0.6303612",
"0.6245651",
"0.6196794",
"0.61966205",
"0.61519206",
"0.6118781",
"0.608841",
"0.6045109",
"0.6045109",
"0.60163087",
"0.60075057",
"0.6004262",
"0.6004262",
"0.6004262",
... | 0.86000794 | 0 |
true if the logged in user is a barcamp participant | def is_participant(self):
if self.user is None:
return False
if unicode(self.user._id) in self.barcamp.event.participants:
return True
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_participant(self,user):\n if user.is_superuser:\n return True\n\n if user.groups.filter(name=self.participants_group_name).count() > 0:\n return True\n else:\n return False",
"def is_participant(self, user) -> bool:\n return (\n user.... | [
"0.7501542",
"0.7308123",
"0.6689928",
"0.6639729",
"0.655399",
"0.654305",
"0.64862156",
"0.64847696",
"0.62872386",
"0.6278153",
"0.6255397",
"0.6248969",
"0.6224924",
"0.6189183",
"0.61548764",
"0.61516726",
"0.6149584",
"0.6141295",
"0.61229265",
"0.6117724",
"0.61060876"... | 0.8162142 | 0 |
true if the logged in user is on the barcamp waiting list | def is_on_waiting_list(self):
if self.user is None:
return False
if unicode(self.user._id) in self.barcamp.event.waiting_list:
return True
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def user_has_access(self, user):\n if not user: return False\n query = db.Query(TaskListMember)\n query.filter('task_list =', self)\n query.filter('user =', user)\n return query.get()",
"def should_keep_running(self):\n return len(self.party.active_users())",
"def is_waiting_to_be_assigned(se... | [
"0.6522602",
"0.65119416",
"0.6482939",
"0.63675046",
"0.62369585",
"0.62347645",
"0.62110883",
"0.6201915",
"0.6196063",
"0.61820817",
"0.6143147",
"0.613814",
"0.6132546",
"0.61283255",
"0.61191344",
"0.6117263",
"0.61143005",
"0.61114365",
"0.6104621",
"0.60964954",
"0.609... | 0.8920294 | 0 |
this is True if the user is an admin and there are less than 3 pages for the menu slot | def can_add_menu_page(self):
if not self.is_admin:
return False
return self.config.dbs.pages.for_slot("menu", barcamp=self.barcamp).count() < 3 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_admin():\n\tif not current_user.is_admin:\n\t\tabort(403)",
"def allowed(self):\n may = self.request.user.may\n return (not self.__class__.__name__ in self.request.cfg.actions_excluded and\n may.write(self.pagename))",
"def check_admin():\r\n if not current_user.is_adm... | [
"0.63259757",
"0.6275597",
"0.6174168",
"0.61596054",
"0.6156467",
"0.60907745",
"0.6077263",
"0.6077263",
"0.6069751",
"0.60680157",
"0.60671127",
"0.6050176",
"0.60369974",
"0.6024235",
"0.6023522",
"0.59934914",
"0.59766316",
"0.5964952",
"0.5964752",
"0.5963825",
"0.59573... | 0.7944941 | 0 |
return all the pages for a given slot and barcamp | def pages_for(self, slot):
return self.config.dbs.pages.for_slot("menu", barcamp=self.barcamp) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_allpages(self, url:str, paramsdict:Dict[str,str]):\n r1 = self._get_dict_from_url(url, paramsdict)\n r = [r1]\n #display(r)\n if 'total_pages' in r1:\n # print('more than one page')\n for next_page in range(2, r1['total_pages']+1):\n # print... | [
"0.5811271",
"0.57740754",
"0.56722957",
"0.5563043",
"0.5545227",
"0.5459513",
"0.5442293",
"0.54302704",
"0.5358917",
"0.5357131",
"0.5357131",
"0.5342409",
"0.5326347",
"0.5320122",
"0.53073967",
"0.5247933",
"0.5203753",
"0.51923966",
"0.5181428",
"0.5179217",
"0.516802",... | 0.7298861 | 0 |
return variants of background image url | def background_image_url(self):
uf = self.app.url_for
try:
asset = self.app.module_map.uploader.get(self.barcamp.background_image)
except AssetNotFound:
return None
except Exception, e:
return None
return dict(
[(vid, uf('asset'... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _css_background(self, **kwargs) -> str:\n return f'background-image: url(\"{self._get_url(kwargs.get(\"absolute\"))}\");'",
"def get_image(self):\n try:\n image = self.soup.find(class_=\"featured-image-body\").find(\"style\")\n self.image = re.findall(r\".*background-image... | [
"0.66389424",
"0.6199871",
"0.6155285",
"0.61498046",
"0.601717",
"0.5941757",
"0.58175707",
"0.57680833",
"0.5740026",
"0.5618791",
"0.5598718",
"0.55444485",
"0.54629636",
"0.5457275",
"0.54231226",
"0.5367823",
"0.5333095",
"0.5327743",
"0.5276751",
"0.52655023",
"0.526550... | 0.7298335 | 0 |
return variants of facebook image url | def fb_image_url(self):
uf = self.app.url_for
try:
asset = self.app.module_map.uploader.get(self.barcamp.fb_image)
except AssetNotFound:
return None
except Exception, e:
return None
return dict(
[(vid, uf('asset', asset_id = ass... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_image_url():",
"def get_images(self,soup,Images):\n \n img=soup.find_all('a',href=re.compile(\"/photo.php?fbid=\"))\n img1=soup.find_all('a',href=re.compile(\"/photo\"))\n m=' '\n if img !=[]:\n img_href='https://www.facebook.com'+img[0]['href']\n ... | [
"0.7220675",
"0.66345793",
"0.65861577",
"0.6315769",
"0.62766296",
"0.62628675",
"0.6202578",
"0.618805",
"0.61635405",
"0.6121791",
"0.6121791",
"0.6121791",
"0.61173695",
"0.6092205",
"0.6073173",
"0.60113466",
"0.5997369",
"0.59969276",
"0.5989791",
"0.5947178",
"0.592263... | 0.7096372 | 1 |
initialize handler with a logger | def __init__(self, *args, **kwargs):
super(BaseHandler, self).__init__(*args, **kwargs)
self.log = logbook.Logger(self.LOGGER) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, handler, level=logging.INFO):\n self._handler = handler\n self._logging_function = None\n self.level = level",
"def _init():\n global logger\n logger = logging.getLogger(\"Log\")",
"def __init__(self, logname, loglevel, logger):\n\n self.logger = logging.get... | [
"0.75947416",
"0.7419363",
"0.73782873",
"0.72951967",
"0.7286678",
"0.7284319",
"0.7275249",
"0.7265272",
"0.7229264",
"0.7197944",
"0.7182933",
"0.71620834",
"0.71334755",
"0.7096786",
"0.7058198",
"0.7056851",
"0.70374364",
"0.703545",
"0.70354426",
"0.7030917",
"0.6991110... | 0.7976938 | 0 |
true if the logged in user is a main admin | def is_main_admin(self):
if self.user is None:
return False
return self.user.has_permission("admin") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_admin(self):\n if not self.current_user:\n return False\n else:\n return self.current_user in [\"1\"]",
"def is_admin(user):\n return user.is_authenticated and user.id == app.config.get('ADMIN')",
"def is_current_user_admin():\n return (os.environ.get('USER_IS... | [
"0.85164595",
"0.82871264",
"0.8235407",
"0.82319146",
"0.8216897",
"0.8151709",
"0.8142257",
"0.81410295",
"0.81280077",
"0.80545837",
"0.8048427",
"0.8015066",
"0.8005023",
"0.79673415",
"0.7958993",
"0.79073346",
"0.7896765",
"0.7865162",
"0.7865162",
"0.784732",
"0.783932... | 0.8916181 | 0 |
check if the given user is a barcamp admin | def is_admin(self):
if self.is_main_admin:
return True
if self.user is not None and self.barcamp is not None:
if unicode(self.user._id) in self.barcamp.admins:
return True
return False | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_admin(self):\n if self.user is None:\n return False\n if unicode(self.user._id) in self.barcamp.admins:\n return True\n if self.user.is_admin:\n return True\n return False",
"def user_is_admin(user):\n return user in admins",
"def is_admin(... | [
"0.8017001",
"0.78052306",
"0.7767001",
"0.77324444",
"0.7699661",
"0.76618487",
"0.76551867",
"0.756769",
"0.75313574",
"0.7387065",
"0.738372",
"0.7382385",
"0.7361565",
"0.7352563",
"0.7345461",
"0.7327134",
"0.7292621",
"0.7283152",
"0.7274014",
"0.72688115",
"0.72538525"... | 0.7920938 | 1 |
call this if you want to show the user a message that a permission is missing and redirect to the homepage | def forbidden(self):
self.flash(self._("You don't have the correct permissions to access this page."), category="error")
# TODO: maybe check barcamp and permissions for the barcamp homepage and redirect there instead
# TODO: maybe create a remember decorator which remember the last page in the s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def permission_denied(request):\n\treturn render(request, '403.html', None)",
"def _handle_view(self, name, **kwargs):\n if not self.is_accessible():\n if current_user.is_authenticated:\n # permission denied\n abort(403)\n else:\n ... | [
"0.74360025",
"0.6909599",
"0.6909599",
"0.6909599",
"0.68939877",
"0.68591404",
"0.6858368",
"0.6838834",
"0.6838834",
"0.6838834",
"0.6838834",
"0.6838834",
"0.6838834",
"0.6838834",
"0.6838834",
"0.6838834",
"0.6838834",
"0.6838834",
"0.6838834",
"0.6838834",
"0.6770329",
... | 0.749524 | 0 |
generate the line "And(a=.., b=.., out=..)" | def add_statement_and(self, a, b, out=None):
if out is None:
out = self.port_name_generator.generate()
s = 'And(a=%s, b=%s, out=%s)' % (a, b, out)
self.parts_statements.append(s)
return out | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _build_and(self) -> str:\n return dedent(\n \"\"\"\n @SP\n M=M-1\n A=M\n D=M\n @SP\n M=M-1\n A=M\n M=M&D\n @SP\n M=M+1\n \"\"\"\n )",
"def andify(things: list):\n ... | [
"0.73567766",
"0.646734",
"0.5961366",
"0.57551265",
"0.5736782",
"0.5709954",
"0.57009214",
"0.5641163",
"0.56278634",
"0.55792725",
"0.5544076",
"0.55195975",
"0.54172695",
"0.5396942",
"0.538961",
"0.53720766",
"0.5370859",
"0.53564334",
"0.53482896",
"0.5334837",
"0.53086... | 0.7313728 | 1 |
generate the line "Or(a=.., b=.., out=..)" | def add_statement_or(self, a, b, out=None):
if out is None:
out = self.port_name_generator.generate()
s = 'Or(a=%s, b=%s, out=%s)' % (a, b, out)
self.parts_statements.append(s)
return out | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _build_or(self) -> str:\n return dedent(\n \"\"\"\n @SP\n M=M-1\n A=M\n D=M\n @SP\n M=M-1\n A=M\n M=M|D\n @SP\n M=M+1\n \"\"\"\n )",
"def test_singleOr(self):\n\n ... | [
"0.7616597",
"0.6356051",
"0.62720895",
"0.6263102",
"0.6179395",
"0.61275554",
"0.6082262",
"0.59703976",
"0.5927579",
"0.58374393",
"0.5778743",
"0.57054955",
"0.5701007",
"0.5607481",
"0.56010604",
"0.55598",
"0.5552166",
"0.5552166",
"0.5552166",
"0.5552166",
"0.5552166",... | 0.72512823 | 1 |
generate the line "Not(in=.., out=..)" | def add_statement_not(self, a, out=None):
if out is None:
out = self.port_name_generator.generate()
s = 'Not(in=%s, out=%s)' % (a, out)
self.parts_statements.append(s)
return out | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _build_not(self):\n return dedent(\n f\"\"\"\n // SP--\n @SP\n M=M-1\n // D = *SP\n A=M\n D=M\n // *SP = !D\n @SP\n A=M\n M=!D\n @SP\n M=M+1\n \"\"\"\... | [
"0.7077565",
"0.64277554",
"0.6207947",
"0.6107082",
"0.6089727",
"0.6045686",
"0.60098857",
"0.57851785",
"0.57544917",
"0.5735786",
"0.572758",
"0.5723468",
"0.57094",
"0.56758165",
"0.5658078",
"0.5635264",
"0.5594097",
"0.5576536",
"0.5531916",
"0.55158025",
"0.54942054",... | 0.68703365 | 1 |
load CHIP_NAME_expr.txt and then generate the code for .hdl file | def generate_from_file(self, filename):
lines = open(filename, 'r').readlines()
chip_name = lines[0].strip()
input_part = re.sub('\s+', ', ', lines[1].strip())
output_part = re.sub('\s+', ', ', lines[2].strip())
def name_to_names(name):
m = re.match('(.*)\[(\d+)\]', ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def read_uef_details(chunks):\n\n\tpos, chunk = find_next_chunk(chunks, 0, [0x0])\n\n\tif pos == None:\n\n\t\toriginator = 'Unknown'\n\n\telif chunk[1] == '':\n\n\t\toriginator = 'Unknown'\n\telse:\n\t\toriginator = chunk[1]\n\n\tpos, chunk = find_next_chunk(chunks, 0, [0x5])\n\n\tif pos == None:\n\n\t\tmachine, k... | [
"0.5504936",
"0.5386882",
"0.53786993",
"0.5346444",
"0.5326937",
"0.53236806",
"0.5289278",
"0.5233585",
"0.51951134",
"0.51913357",
"0.5181937",
"0.5159957",
"0.5154199",
"0.5143235",
"0.51238763",
"0.5102501",
"0.5099596",
"0.5094918",
"0.50830704",
"0.5079586",
"0.5064224... | 0.59897083 | 0 |
turn expressions into hardware description language each expression corresponds to an output port, which may be implemented by several lines | def generate(self, exprs, input_names, output_names):
self.port_name_generator = PortNameGenerator()
self.parts_statements = []
def part_to_input_name(in_ID_str):
return input_names[int(in_ID_str) - 1]
for expr, output_name in zip(exprs, output_names):
if expr[-... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def hdl_decoder(instruction, arg_select, rs1, rs2, rd, rm, imm12lo, imm12hi, imm12, imm20, shamt, shamtw, opcode,\n funct3, funct7):\n\n @always_comb\n def decoder_output():\n instruction_family = instruction[7:2]\n opcode.next = instruction[7:]\n\n # Branch Instructions\n... | [
"0.5569107",
"0.55601835",
"0.53833455",
"0.53561586",
"0.5354878",
"0.5338756",
"0.5328411",
"0.52621955",
"0.5240469",
"0.5191629",
"0.5153379",
"0.50634533",
"0.5048774",
"0.50378317",
"0.50159687",
"0.5013007",
"0.5004718",
"0.49926028",
"0.49764407",
"0.4968673",
"0.4963... | 0.56132674 | 0 |
Should return the set of deletion requests that may still be pending | def deletion_requests(_):
return set() | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _GetAbortRequests(self):\n new_requests = self._GetRequestsByState(self._ABORTING)\n for request_id in new_requests:\n logging.info('Abort requested for %s', request_id)\n self._ClearRequest(request_id, self._ABORTING)\n return new_requests",
"def _clean_outdated(self):\n now = _now()\n... | [
"0.67508453",
"0.6287652",
"0.6091735",
"0.6091735",
"0.6052274",
"0.60368884",
"0.59504706",
"0.58615834",
"0.58435404",
"0.5836634",
"0.5827744",
"0.5780385",
"0.5739814",
"0.571245",
"0.56598896",
"0.56567377",
"0.56567377",
"0.563498",
"0.5625621",
"0.5625183",
"0.5587740... | 0.8189317 | 0 |
Pack record into buffer | def pack(self,buffer):
buffer.append(self.data) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def into_buffer(self, buf, offset):\n self.payload = containerize(exclude_fields(self))\n self.parser = MsgEd25519SignatureDepB._parser\n self.stream_payload.reset(buf, offset)\n return self.pack_into(buf, offset, self._build_payload)",
"def into_buffer(self, buf, offset):\n self.payload = contain... | [
"0.67037654",
"0.6689548",
"0.66146606",
"0.6578787",
"0.6576699",
"0.65227",
"0.6518708",
"0.6513342",
"0.6506212",
"0.6488553",
"0.6449297",
"0.6312564",
"0.6303461",
"0.6263582",
"0.6258291",
"0.62009865",
"0.6197204",
"0.6158439",
"0.61556584",
"0.61480254",
"0.6136603",
... | 0.7131186 | 0 |
Parse DNS packet data and return DNSRecord instance Recursively parses sections (calling appropriate parse method) | def parse(cls, packet):
buffer = DNSBuffer(packet)
try:
header = DNSHeader.parse(buffer)
questions = []
rr = []
auth = []
ar = []
for i in range(header.q):
questions.append(DNSQuestion.parse(buffer))
for ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _read_dns_(dns, cnt):\r\n \r\n dn_names = None\r\n dn_ids = None\r\n dn_iaps = [None]*10\r\n \r\n for dn in dns.DN:\r\n if dn.ref == 'Name':\r\n dn_names = dn.value\r\n if dn.ref == 'DNId':\r\n dn_ids = dn.value\r\n if dn.ref == 'IAP':\r\n ... | [
"0.58287996",
"0.56316394",
"0.55698323",
"0.5456267",
"0.54482704",
"0.5445094",
"0.54391915",
"0.5387773",
"0.52888453",
"0.5277703",
"0.52391493",
"0.52372813",
"0.52302825",
"0.52105474",
"0.5202308",
"0.5180148",
"0.5162784",
"0.51371616",
"0.51259255",
"0.51015055",
"0.... | 0.7408961 | 0 |
Formatted 'repr'style representation of record (optionally with prefix and/or sorted RRs) | def format(self, prefix="", sort=False):
s = sorted if sort else lambda x: x
sections = [repr(self.header)]
sections.extend(s([repr(q) for q in self.questions]))
sections.extend(s([repr(rr) for rr in self.rr]))
sections.extend(s([repr(rr) for rr in self.auth]))
sections.e... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __repr__(self):\n\n return '%s(%s)' % (self, self._format_entries(),)",
"def __str__(self):\n txt = ''\n if self.PrintHeader:\n txt = \" |\" + \"|\".join(sorted(self.rows[0].keys())).expandtabs() + \"|\"\n txt += \"\\n\"\n txt += \"|-\"\n for r in self.ro... | [
"0.67557865",
"0.6695922",
"0.65245026",
"0.6517333",
"0.6469517",
"0.646618",
"0.64444053",
"0.6387554",
"0.63863015",
"0.6380566",
"0.63708043",
"0.6363295",
"0.6348989",
"0.63442385",
"0.6344004",
"0.6318723",
"0.62986195",
"0.6298393",
"0.62863266",
"0.62753546",
"0.62727... | 0.67554444 | 1 |
get a 1d normalization module from pytorch | def get_norm1d(name: str, num_features: int, affine: bool = True, params: Optional[dict] = None) -> nn.Module:
if name.lower() == 'instance':
norm = nn.InstanceNorm1d(num_features, affine=affine) if params is None else \
nn.InstanceNorm1d(num_features, affine=affine, **params)
elif name.lowe... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def normalize(x, axis=-1):\n x = 1. * x / (torch.norm(x, 2, axis, keepdim=True).expand_as(x) + 1e-12)\n return x",
"def normalize(x, axis=-1):\n x = 1. * x / (torch.norm(x, 2, axis, keepdim=True).expand_as(x) + 1e-12)\n return x",
"def normalize(x, axis=-1):\n x = 1. * x / (torch.norm(x, 2, axis... | [
"0.6590287",
"0.6590287",
"0.6590287",
"0.65241367",
"0.64790493",
"0.6436457",
"0.6283418",
"0.62820417",
"0.6245499",
"0.62178546",
"0.61228526",
"0.6115458",
"0.6079969",
"0.60772556",
"0.607186",
"0.6044192",
"0.60195285",
"0.60140544",
"0.60140544",
"0.6009281",
"0.59788... | 0.67087257 | 0 |
get a 2d normalization module from pytorch | def get_norm2d(name: str, num_features: int, affine: bool = True, params: Optional[dict] = None) -> nn.Module:
if name.lower() == 'instance':
norm = nn.InstanceNorm2d(num_features, affine=affine) if params is None else \
nn.InstanceNorm2d(num_features, affine=affine, **params)
elif name.lowe... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_norm_layer():\n norm_layer = functools.partial(nn.InstanceNorm2d, affine=False, track_running_stats=False)\n return norm_layer",
"def normalization(channels):\n return GroupNorm32(32, channels)",
"def l2_normalization(inputs, scaling=True):\n with tf.variable_scope('L2Normalization'... | [
"0.6500414",
"0.6132579",
"0.6131683",
"0.611844",
"0.6084178",
"0.60422975",
"0.60127944",
"0.6007116",
"0.6006024",
"0.5990931",
"0.5946733",
"0.5923667",
"0.58473796",
"0.5847138",
"0.5847138",
"0.5847138",
"0.58392733",
"0.5806896",
"0.5785803",
"0.5769413",
"0.57618624",... | 0.6242366 | 1 |
get a 3d normalization module from pytorch | def get_norm3d(name: str, num_features: int, affine: bool = True, params: Optional[dict] = None) -> nn.Module:
if name.lower() == 'instance':
norm = nn.InstanceNorm3d(num_features, affine=affine) if params is None else \
nn.InstanceNorm3d(num_features, affine=affine, **params)
elif name.lowe... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_normalize_layer(dataset: str) -> torch.nn.Module:\n if dataset == \"imagenet\":\n return NormalizeLayer(_IMAGENET_MEAN, _IMAGENET_STDDEV)\n elif dataset == \"cifar10\":\n return NormalizeLayer(_CIFAR10_MEAN, _CIFAR10_STDDEV)\n elif dataset == \"imagenet32\":\n return Normalize... | [
"0.6275327",
"0.6196674",
"0.6133436",
"0.59649676",
"0.5904762",
"0.58697927",
"0.580612",
"0.5748991",
"0.57307184",
"0.57173204",
"0.5694001",
"0.5691475",
"0.562516",
"0.55879885",
"0.5578551",
"0.55701315",
"0.5566426",
"0.5566426",
"0.5566426",
"0.55479056",
"0.5540599"... | 0.65019554 | 0 |
get an optimizer by name | def get_optim(name: str):
if name.lower() == 'adam':
optimizer = torch.optim.Adam
elif name.lower() == 'adamw':
optimizer = torch.optim.AdamW
elif name.lower() == 'sgd':
optimizer = torch.optim.SGD
elif name.lower() == 'sgdw':
from ..learn.optim import SGDW
optimi... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_optimizer_cls(name: str):\n return optimizer_registry[name][1]",
"def get_optimizer_by_name(optimizer_name, learning_rate):\n\n if optimizer_name == \"sgd\":\n optimizer = tf.train.GradientDescentOptimizer(learning_rate)\n elif optimizer_name == \"adadelta\":\n optimizer = tf.train.AdadeltaOpt... | [
"0.85157824",
"0.7800172",
"0.7491068",
"0.73751694",
"0.7165509",
"0.7000307",
"0.68168557",
"0.67020977",
"0.6649632",
"0.66452366",
"0.6640799",
"0.6623028",
"0.65635616",
"0.6507324",
"0.65006864",
"0.64704376",
"0.6412128",
"0.6361146",
"0.63466674",
"0.63397473",
"0.631... | 0.79336685 | 1 |
get a loss function by name | def get_loss(name: str):
if name == 'mse' or name is None:
loss = nn.MSELoss()
elif name == 'cp':
loss = CosineProximityLoss()
elif name == 'mae':
loss = nn.L1Loss()
elif name == 'bce':
loss = nn.BCEWithLogitsLoss()
else:
raise ValueError(f'Loss function {name... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_loss_fn(params):\r\n i = importlib.import_module(\"dlex.utils.losses\")\r\n return getattr(i, params.loss)",
"def define_loss(name_loss):\n call_dict = {\n \"pixel_weighted_cross_entropy\": pixel_weighted_cross_entropy,\n \"MeanSquaredLogarithmicError\": tf.keras.losses.MeanSquared... | [
"0.78658175",
"0.769141",
"0.7442373",
"0.74062395",
"0.7330538",
"0.72843874",
"0.72805417",
"0.7065177",
"0.69638765",
"0.6668975",
"0.6627807",
"0.66071135",
"0.660059",
"0.6443715",
"0.6431066",
"0.63850313",
"0.63039154",
"0.629808",
"0.62860835",
"0.6285913",
"0.6185624... | 0.8069126 | 0 |
ICNR init of `x`, with `scale` and `init` function | def icnr(m, scale=2, init=nn.init.kaiming_normal_):
ni, nf, h, w = m.shape
ni2 = int(ni / (scale ** 2))
k = init(torch.zeros([ni2, nf, h, w])).transpose(0, 1)
k = k.contiguous().view(ni2, nf, -1)
k = k.repeat(1, 1, scale ** 2)
k = k.contiguous().view([nf, ni, h, w]).transpose(0, 1)
m.data.co... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def __init__(self, x0, initial_scale=None, update_type=None,\n skip_treshold=None):\n if not initial_scale:\n initial_scale = 1\n BroydenSolver.__init__(self, x0, initial_scale, update_type,\n skip_treshold)",
"def __init__(self, initializer,... | [
"0.6035859",
"0.5874732",
"0.57862383",
"0.5769277",
"0.56695235",
"0.5579722",
"0.55617124",
"0.5555049",
"0.55488336",
"0.55382186",
"0.5528373",
"0.5496373",
"0.5487937",
"0.5464803",
"0.54303855",
"0.5410027",
"0.54030824",
"0.5402177",
"0.5396679",
"0.53947264",
"0.53457... | 0.67800635 | 0 |
Test validation when an IDAA program is not funded | def test_validation_idaa_not_funded(self):
idaa_not_funded_index = 0
upload_program = program.ProgramUpload(idaa_program=self.idaa_json['value'][idaa_not_funded_index]['fields'],
msr_country_codes_list=msr_country_codes_list, msr_gaitid_list=msr_gaitid_list, duplicated_gaitids=self.duplicat... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_validation_idaa_valid_and_does_not_exists(self):\n idaa_index = 1\n expected_discrepancies = 0\n\n upload_program = program.ProgramUpload(idaa_program=self.idaa_json['value'][idaa_index]['fields'],\n msr_country_codes_list=msr_country_codes_list, msr_gaitid_list=msr_gaitid_... | [
"0.7260609",
"0.7018445",
"0.6754538",
"0.6497119",
"0.6483243",
"0.64565367",
"0.6435862",
"0.64116186",
"0.6393785",
"0.6374555",
"0.63660735",
"0.6350394",
"0.6312991",
"0.62806916",
"0.618958",
"0.61891973",
"0.61797667",
"0.61780584",
"0.6148355",
"0.61471885",
"0.613936... | 0.7356701 | 0 |
Test validation when an IDAA program is valid and exists in Tola | def test_validation_idaa_valid_and_exists(self):
expected_discrepancies = 0
upload_program = program.ProgramUpload(idaa_program=self.idaa_json['value'][self.create_idaa_program_index]['fields'],
msr_country_codes_list=msr_country_codes_list, msr_gaitid_list=msr_gaitid_list, duplicated_gaiti... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_validation_idaa_valid_and_does_not_exists(self):\n idaa_index = 1\n expected_discrepancies = 0\n\n upload_program = program.ProgramUpload(idaa_program=self.idaa_json['value'][idaa_index]['fields'],\n msr_country_codes_list=msr_country_codes_list, msr_gaitid_list=msr_gaitid_... | [
"0.7329536",
"0.6868432",
"0.66921926",
"0.65089196",
"0.63125044",
"0.6258971",
"0.61986554",
"0.61622727",
"0.61410594",
"0.61300254",
"0.6053456",
"0.60207057",
"0.59911877",
"0.5968885",
"0.59615105",
"0.595191",
"0.5949033",
"0.59445256",
"0.59384495",
"0.59307194",
"0.5... | 0.7489168 | 0 |
Test validation when an IDAA program is valid and does not exist in Tola | def test_validation_idaa_valid_and_does_not_exists(self):
idaa_index = 1
expected_discrepancies = 0
upload_program = program.ProgramUpload(idaa_program=self.idaa_json['value'][idaa_index]['fields'],
msr_country_codes_list=msr_country_codes_list, msr_gaitid_list=msr_gaitid_list, dupl... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_validation_idaa_valid_and_exists(self):\n expected_discrepancies = 0\n\n upload_program = program.ProgramUpload(idaa_program=self.idaa_json['value'][self.create_idaa_program_index]['fields'],\n msr_country_codes_list=msr_country_codes_list, msr_gaitid_list=msr_gaitid_list, duplica... | [
"0.7491878",
"0.7297784",
"0.6843267",
"0.6823194",
"0.64489067",
"0.6387037",
"0.6236825",
"0.6200977",
"0.6190812",
"0.61764115",
"0.61704665",
"0.6143183",
"0.61343366",
"0.61108536",
"0.6085642",
"0.6078352",
"0.6055132",
"0.6019327",
"0.5996911",
"0.597055",
"0.5953774",... | 0.7663543 | 0 |
Test validation when a Tola program has mismatching countries to the IDAA program | def test_invalid_countries_tola_program(self):
idaa_index = 3
expected_discrepancies = 1
idaa_program = self.idaa_json['value'][idaa_index]['fields']
self._create_tola_program(idaa_program, fields={
"name": idaa_program['ProgramName'],
"funding_status": idaa_pro... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_valid_country():\n assert valid_country(\"Democratic Republic of Lungary\") is True\n assert valid_country(\"Kraznoviklandstan\") is True\n assert valid_country(\"kraznoviklandstan\") is True\n assert valid_country(\"KRAZNOVIKLANDSTAN\") is True\n\n assert valid_country(\"Democratic_Republi... | [
"0.71343833",
"0.6715118",
"0.6700797",
"0.64765984",
"0.64616275",
"0.62915784",
"0.62010276",
"0.61657315",
"0.61532784",
"0.61491483",
"0.6137727",
"0.60993564",
"0.6087429",
"0.60383993",
"0.5982458",
"0.59379905",
"0.59361506",
"0.59280074",
"0.591743",
"0.5897387",
"0.5... | 0.7615408 | 0 |
Test validation when an IDAA program matches to multiple TolaData programs | def test_one_idaa_to_multiple_tola_programs(self):
idaa_index = 7
expected_discrepancies = 1
idaa_program = self.idaa_json['value'][idaa_index]['fields']
for x in range(2):
self._create_tola_program(idaa_program, fields={
"name": f"multiple toladata program ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_validation_idaa_valid_and_exists(self):\n expected_discrepancies = 0\n\n upload_program = program.ProgramUpload(idaa_program=self.idaa_json['value'][self.create_idaa_program_index]['fields'],\n msr_country_codes_list=msr_country_codes_list, msr_gaitid_list=msr_gaitid_list, duplica... | [
"0.7005638",
"0.6797773",
"0.6536046",
"0.6362737",
"0.6350601",
"0.630351",
"0.609529",
"0.59346414",
"0.5914649",
"0.58369225",
"0.5723732",
"0.57134515",
"0.5707373",
"0.57023555",
"0.56809735",
"0.56639534",
"0.5656461",
"0.5650055",
"0.5647799",
"0.5638395",
"0.561956",
... | 0.74057883 | 0 |
Test validation when an IDAA program has invalid GaitIDs | def test_invalid_gaitid_idaa_program(self):
idaa_index = 3
expected_discrepancies = 1
idaa_program = self.idaa_json['value'][idaa_index]['fields']
idaa_program['GaitIDs'][0] = {'LookupValue': '1237a'}
upload_program = program.ProgramUpload(idaa_program=idaa_program,
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_missing_gaitid_idaa_program(self):\n idaa_index = 3\n expected_discrepancies = 1\n\n idaa_program = self.idaa_json['value'][idaa_index]['fields']\n\n idaa_program['GaitIDs'] = []\n\n upload_program = program.ProgramUpload(idaa_program=idaa_program,\n msr_count... | [
"0.7466121",
"0.7208579",
"0.71894306",
"0.7018532",
"0.6954783",
"0.659247",
"0.64552516",
"0.63970274",
"0.63390183",
"0.6298823",
"0.6181597",
"0.6173571",
"0.6147095",
"0.6145762",
"0.612691",
"0.6088068",
"0.60821694",
"0.6060455",
"0.6033052",
"0.6015379",
"0.6009227",
... | 0.78916085 | 0 |
Test validation when an IDAA program does not have a Gait id | def test_missing_gaitid_idaa_program(self):
idaa_index = 3
expected_discrepancies = 1
idaa_program = self.idaa_json['value'][idaa_index]['fields']
idaa_program['GaitIDs'] = []
upload_program = program.ProgramUpload(idaa_program=idaa_program,
msr_country_codes_list=... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_invalid_gaitid_idaa_program(self):\n idaa_index = 3\n expected_discrepancies = 1\n\n idaa_program = self.idaa_json['value'][idaa_index]['fields']\n\n idaa_program['GaitIDs'][0] = {'LookupValue': '1237a'}\n\n upload_program = program.ProgramUpload(idaa_program=idaa_progra... | [
"0.80145824",
"0.7363386",
"0.723916",
"0.7081197",
"0.69514865",
"0.6706156",
"0.6604724",
"0.646115",
"0.6184691",
"0.61745673",
"0.6135782",
"0.6131133",
"0.6044289",
"0.6019073",
"0.60144246",
"0.6011884",
"0.6010463",
"0.5974281",
"0.5965475",
"0.5945397",
"0.59409434",
... | 0.77822286 | 1 |
Test validation when an IDAA program has multiple gait ids | def test_mulitple_idaa_gaitids(self):
idaa_index = 4
expected_discrepancies = 0
upload_program = program.ProgramUpload(idaa_program=self.idaa_json['value'][idaa_index]['fields'],
msr_country_codes_list=msr_country_codes_list, msr_gaitid_list=msr_gaitid_list, duplicated_gaitids=self.... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_invalid_gaitid_idaa_program(self):\n idaa_index = 3\n expected_discrepancies = 1\n\n idaa_program = self.idaa_json['value'][idaa_index]['fields']\n\n idaa_program['GaitIDs'][0] = {'LookupValue': '1237a'}\n\n upload_program = program.ProgramUpload(idaa_program=idaa_progra... | [
"0.7441549",
"0.73125863",
"0.72999895",
"0.6827907",
"0.669894",
"0.6517037",
"0.64605606",
"0.6223405",
"0.61605096",
"0.61182356",
"0.6092908",
"0.59771466",
"0.5857446",
"0.58561075",
"0.5842388",
"0.58350503",
"0.58109146",
"0.5804308",
"0.5801607",
"0.5800483",
"0.57857... | 0.7971479 | 0 |
Test to check if a duplicated gaitid is properly assigned a discrepancy | def test_duplicated_gaitid(self):
idaa_index = 6
upload_program = program.ProgramUpload(idaa_program=self.idaa_json['value'][idaa_index]['fields'],
msr_country_codes_list=msr_country_codes_list, msr_gaitid_list=msr_gaitid_list, duplicated_gaitids=self.duplicated_gaitids
)
s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_duplicate_ids2():\n assert query_row(db_conf, 'osm_buildings', 51001)['type'] == 'way'\n assert query_row(db_conf, 'osm_buildings', -51001) == None\n assert query_row(db_conf, 'osm_buildings', -51011)['type'] == 'mp'\n assert query_row(db_conf, 'osm_buildings', 51011) == None",
"def test_dup... | [
"0.7071438",
"0.70363164",
"0.67744005",
"0.6737411",
"0.66934633",
"0.6681745",
"0.65970165",
"0.653389",
"0.6505358",
"0.6500923",
"0.6489432",
"0.6488283",
"0.64847445",
"0.6478404",
"0.6473124",
"0.6452616",
"0.644455",
"0.6430872",
"0.63565284",
"0.63459796",
"0.6332393"... | 0.7702185 | 0 |
Test that an existing Tola program is updated from IDAA | def test_program_update(self):
gaitid = 10476
tola_program = models.Program.objects.get(gaitid__gaitid=gaitid)
expected_donor = 'World Vision International'
expected_donor_dept = 'Bureau of Humanitarian Assistance (BHA)'
expected_name = '2021 Timor-Leste Cyclone Seroja Flood Resp... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_duo_application_update(self):\n pass",
"def test_update_system(self):\n pass",
"def test_update(self):\n\n\n username,userpass = self.testdata.find_account_for('toolsubmitter')\n\n self.utils.account.login_as(username,userpass)\n\n self.contribtool.update(TOOLNAME,us... | [
"0.69439316",
"0.6641728",
"0.6567187",
"0.63154763",
"0.62872905",
"0.6258699",
"0.6221776",
"0.6171301",
"0.614651",
"0.610955",
"0.60890776",
"0.60855514",
"0.60569376",
"0.60569376",
"0.60569376",
"0.6052934",
"0.60130197",
"0.5972804",
"0.5933892",
"0.5885367",
"0.587286... | 0.72237194 | 0 |
Test that a new country is created if it does not exist in TolaData | def test_new_country_created(self):
idaa_index = 8
upload_program = program.ProgramUpload(
idaa_program=self.idaa_json['value'][idaa_index]['fields'], msr_country_codes_list=msr_country_codes_list,
msr_gaitid_list=msr_gaitid_list, duplicated_gaitids=self.duplicated_gaitids
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def testNormalCreate(self):\n\n canada = self.Country(\n {\"name\": \"Canada\", \"abbreviation\": \"CA\", \"languages\": [\"english\", \"french\"]}\n )\n\n canada.save()\n\n self.assertEqual(\"Canada\", canada.name)\n self.assertEqual(\"CA\", canada.abbreviation)\n ... | [
"0.7098525",
"0.6750823",
"0.6355941",
"0.6332127",
"0.62644494",
"0.62448096",
"0.62199616",
"0.6205874",
"0.61141664",
"0.60871804",
"0.606446",
"0.6051653",
"0.6023745",
"0.6006853",
"0.6005214",
"0.59654975",
"0.5952343",
"0.59480816",
"0.59347963",
"0.5934028",
"0.592658... | 0.72239536 | 0 |
Test that a mismatched gaitid for Tola programs is deleted | def test_program_update_delete_mismatched_gaitid(self):
removed_gaitid = 18021
gaitid = 10476
tola_program = models.Program.objects.get(gaitid__gaitid=gaitid)
new_gaitid = models.GaitID(gaitid=removed_gaitid, program=tola_program)
new_gaitid.save()
upload_program = progr... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_invalid_gaitid_idaa_program(self):\n idaa_index = 3\n expected_discrepancies = 1\n\n idaa_program = self.idaa_json['value'][idaa_index]['fields']\n\n idaa_program['GaitIDs'][0] = {'LookupValue': '1237a'}\n\n upload_program = program.ProgramUpload(idaa_program=idaa_progra... | [
"0.62425905",
"0.6155072",
"0.6149746",
"0.6128432",
"0.61055803",
"0.60785824",
"0.6071837",
"0.6057377",
"0.60572207",
"0.60512847",
"0.60250896",
"0.5982296",
"0.5979931",
"0.5979219",
"0.59723544",
"0.5946857",
"0.59345305",
"0.59263295",
"0.59111226",
"0.59087855",
"0.59... | 0.74938077 | 0 |
Test that a new program is created if it does not exist in Tola. This test includes email notifications. In order for the test to work, the "django.core.mail.backends.smtp.EmailBackend" has to be enabled and SKIP_USER_EMAILS has to be set to FALSE in settings! | def test_program_create(self):
external_program_id = self.idaa_json['value'][self.new_idaa_program_index]['fields']['id']
expected_program_name = self.idaa_json['value'][self.new_idaa_program_index]['fields']['ProgramName']
gaitidvalue = self.idaa_json['value'][self.new_idaa_program_index]['fie... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def test_skip_blank_emails(self):\n appt_date = datetime.date.today() + datetime.timedelta(days=7) # Default for email\n confirmed = self.create_confirmed_notification(self.test_patient, appt_date)\n\n blank_contact = self.create_contact(data={'email': ''})\n self.group.contacts.add(bla... | [
"0.63658994",
"0.6280007",
"0.62030303",
"0.61768866",
"0.6104353",
"0.6099893",
"0.6085732",
"0.60736954",
"0.60383135",
"0.5981701",
"0.59731656",
"0.5964271",
"0.5900917",
"0.5890281",
"0.58891207",
"0.58872426",
"0.5876204",
"0.5876105",
"0.5873545",
"0.58613443",
"0.5860... | 0.6428187 | 0 |
Find all directories paths matching a pattern. | def find_directory(pattern, path):
result = []
for root, dirs, files in os.walk(path):
for name in dirs:
if fnmatch.fnmatch(name, pattern):
result.append(os.path.join(root, name))
return result | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _recursive_file_search(self, path, pattern):\n matches = []\n for root, dirnames, filenames in os.walk(path):\n for filename in fnmatch.filter(filenames, pattern):\n matches.append(os.path.join(root, filename))\n\n return matches",
"def find_directory_in_tree(pa... | [
"0.70146745",
"0.6977053",
"0.69440424",
"0.6841541",
"0.6770175",
"0.67297345",
"0.6727317",
"0.66931665",
"0.6688516",
"0.6683792",
"0.66783786",
"0.6653298",
"0.6639651",
"0.66330737",
"0.66039187",
"0.65898293",
"0.6580216",
"0.6569726",
"0.65655875",
"0.6535989",
"0.6520... | 0.7725334 | 0 |
Check if the benchmark results passes the expected target. | def check_benchmark_result(result, expectation):
for storage_cfg, caches in result['cache_data'].items():
for cache, percent_recorded in caches.items():
if ((percent_recorded['min'] < expectation['min'])
or (percent_recorded['avg'] < expectation['avg'])
or... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def check_expectations(self):\n self.load_results()\n\n for (benchmark, producer), result in self.results.items():\n if not result.reports:\n print('No results found for ' + benchmark + ' ' + producer)\n result.test_passed = False\n else:\n ... | [
"0.7212209",
"0.68514967",
"0.665396",
"0.66333246",
"0.6494828",
"0.6479304",
"0.64030355",
"0.63620555",
"0.63321066",
"0.6294384",
"0.6292632",
"0.6216437",
"0.6215434",
"0.6141543",
"0.61099344",
"0.6086076",
"0.60794073",
"0.6076817",
"0.6050383",
"0.6035072",
"0.6030537... | 0.693431 | 1 |
Return all the benchmark directories in the root folder cases. If multiple directories are found only the most recent one is returned. | def find_benchmark_directories(self):
for (benchmark, producer), result in self.results.items():
pattern = benchmark + '_' + producer + '*'
files = find_directory(pattern, self.root_folder)
if files:
# add just the latest one
sorted_files = sor... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def getImmediateSubdirectories(dir):",
"def get_run_folders():\n return [os.path.join(f, sf) for f in get_date_folders() for sf in os.listdir(f)]",
"def get_all_benchmarks():\n all_benchmarks = []\n for benchmark in os.listdir(BENCHMARKS_DIR):\n benchmark_path = os.path.join(BENCHMARKS_DIR, ben... | [
"0.6650185",
"0.65836525",
"0.63619316",
"0.63374084",
"0.6289886",
"0.62892795",
"0.6215419",
"0.6182507",
"0.61706346",
"0.61677694",
"0.61421084",
"0.61245954",
"0.61191344",
"0.6101239",
"0.60976446",
"0.60525656",
"0.60346913",
"0.602354",
"0.60003644",
"0.5960102",
"0.5... | 0.81804323 | 0 |
Process the benchmark results and generates a report. | def load_results(self):
self.find_benchmark_directories()
for (benchmark, producer), result in self.results.items():
print('Reading results for ' + benchmark + ' ' + producer)
if not result.directory:
print('No results found for ' + benchmark + ' ' + producer)
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run_report(self) -> None:\n t1 = self.t1 or time.time()\n\n dt = t1 - self.t0\n\n if dt and self.max_tasks:\n speed = len(self.statistics) / dt / self.max_tasks\n else:\n speed = 0\n\n LOGGER.info('CRAWLER STATISTICS REPORT')\n\n show = list(self.... | [
"0.71145093",
"0.69347984",
"0.69077617",
"0.6610948",
"0.64731485",
"0.64149916",
"0.63634497",
"0.63466984",
"0.63117945",
"0.6288269",
"0.628414",
"0.6275392",
"0.6265245",
"0.625041",
"0.61753285",
"0.61739695",
"0.6171743",
"0.6164789",
"0.6147563",
"0.6141968",
"0.61394... | 0.6961719 | 1 |
Check the generated report against the expected results and stores the result. | def check_expectations(self):
self.load_results()
for (benchmark, producer), result in self.results.items():
if not result.reports:
print('No results found for ' + benchmark + ' ' + producer)
result.test_passed = False
else:
for re... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reportResult(self):\n return True;",
"def _check_result(self, path, valentin, result_check, result_ok):\n result_list = self._simulate.start_sim(None, 0, 0, '', path,\n valentin, '')\n\n with open(result_check, 'w') as f:\n for elem in result_list:\n ... | [
"0.71465665",
"0.69101596",
"0.63989156",
"0.63736635",
"0.63222337",
"0.6309884",
"0.6282689",
"0.627624",
"0.626249",
"0.62587357",
"0.6158824",
"0.6134077",
"0.609885",
"0.60757405",
"0.60733503",
"0.6039998",
"0.6039882",
"0.60357517",
"0.6032574",
"0.6022591",
"0.6010772... | 0.71762264 | 0 |
DataFrame doesn't store the index value except RangeIndex or specify `store=True` in `parse_index`, So we build a tree structure to avoid too much dependence for getitem node. | def _tree_getitem(cls, op):
out_series = op.outputs[0]
combine_size = options.combine_size
chunks = op.inputs[0].chunks
while len(chunks) > combine_size:
new_chunks = []
for i in range(0, len(chunks), combine_size):
chks = chunks[i : i + combine_si... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def create_index(fname, tree_name):\n froot = uproot3.open(fname)\n jet_id = (\n froot[tree_name].pandas.df(flatten=False, branches=[]).index\n ) # branches=[] reads no branches, branches=None reads all\n multi_index = pd.DataFrame(None, index=jet_id)\n multi_index[\"fpath\"] = fname\n mu... | [
"0.5778598",
"0.56767315",
"0.56412375",
"0.5592823",
"0.55849373",
"0.5571627",
"0.55620545",
"0.55482113",
"0.5541494",
"0.55103046",
"0.53907496",
"0.53312886",
"0.53292507",
"0.53090626",
"0.52764237",
"0.5264978",
"0.52645344",
"0.5248354",
"0.5247067",
"0.5234662",
"0.5... | 0.60486513 | 0 |
Load the LogStatisticsAgent agent configuration and returns and instance of the agent created using that configuration. | def log_statistics(config_path, **kwargs):
config = utils.load_config(config_path)
return LogStatisticsAgent(config, **kwargs) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_agent_config(self) -> AgentConfig:\n agent_loader = ConfigLoader.from_configuration_type(PackageType.AGENT)\n with open(DEFAULT_AEA_CONFIG_FILE, \"r\") as fp:\n agent_config = agent_loader.load(fp)\n return agent_config",
"def load_config(self) -> AgentConfig:\n ag... | [
"0.6125318",
"0.6087537",
"0.6004616",
"0.59834456",
"0.58191025",
"0.56993073",
"0.5554867",
"0.5554867",
"0.54733574",
"0.52667266",
"0.52425694",
"0.5142142",
"0.5135079",
"0.5130938",
"0.50933737",
"0.50669694",
"0.5051954",
"0.50482786",
"0.4991793",
"0.49641585",
"0.492... | 0.73153126 | 0 |
Publishes file's size increment in previous time interval (60 minutes) with timestamp. Also publishes standard deviation of file's hourly size differences every 24 hour. | def publish_analysis(self):
if self._scheduled_event is not None:
self._scheduled_event.cancel()
if self.prev_file_size is None:
self.prev_file_size = self.get_file_size()
_log.debug("init_file_size = {}".format(self.prev_file_size))
else:
# read ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def progress_update(sent, total):\n l.debug(\"%d of %d Mb uploaded to Amazon S3.\", sent / 1000000, total / 1000000)",
"def get_update_function(updateFrequency):\r\n totalTranf = 0\r\n intervalTansf = 0 \r\n intervalStart = time.monotonic()\r\n \r\n def update(transfered):\r\n nonloca... | [
"0.5315727",
"0.5302741",
"0.5221493",
"0.5174541",
"0.51213825",
"0.50695086",
"0.502586",
"0.5009721",
"0.49994358",
"0.49680945",
"0.4962875",
"0.4961736",
"0.49578688",
"0.48692125",
"0.48607737",
"0.48540628",
"0.48461786",
"0.48449996",
"0.4831365",
"0.48263454",
"0.481... | 0.6501824 | 0 |
Check basic properties of random matrix generation | def test_basic_property_of_random_matrix():
for name, random_matrix in all_random_matrix.items():
print(name)
check_input_size_random_matrix(random_matrix)
check_size_generated(random_matrix)
if name != "random_subsample_normalized":
check_zero_mean_and_unit_norm(random_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _make_random_matrix(self, n_components, n_features):",
"def test_rand(self):\n assert len(self._mnist.random()[:5]) == 5\n pass",
"def random_matrix(rows, cols):\n return np.random.randn(rows, cols)",
"def test3(self):\r\n a = T.matrix()\r\n self.assertTrue(None == _as_scal... | [
"0.6636082",
"0.6360721",
"0.6290181",
"0.6281492",
"0.6234151",
"0.62286234",
"0.62032264",
"0.6195325",
"0.61681163",
"0.61486125",
"0.6141923",
"0.6106106",
"0.60447824",
"0.60365814",
"0.60365814",
"0.60129535",
"0.6011785",
"0.5971006",
"0.5963257",
"0.59251195",
"0.5899... | 0.7981367 | 0 |
Get dummy speaker diarization protocol containing only `current_file` | def get_dummy_protocol(current_file: dict) -> SpeakerDiarizationProtocol:
class DummyProtocol(SpeakerDiarizationProtocol):
def trn_iter(self):
yield current_file
def dev_iter(self):
yield current_file
def tst_iter(self):
yield current_file
return ... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_speaker(cls, file_path):\n return Path(file_path).parent.parent.parent.stem",
"def get_sending_target(file_name):\n \"\"\"\n 日本語Windows®上で使用する次のアプリケーションが対象です。Mac OSのアプリケーションには対応していません。\n ・Microsoft® Word 97/98/2000/2002/2003/2007/2010 日本語(拡張子「.doc」「.docx」「.rtf」)\n ・Microsoft® Excel 97/... | [
"0.536381",
"0.49767175",
"0.49154347",
"0.49136817",
"0.488157",
"0.4840874",
"0.48355827",
"0.4818613",
"0.4813588",
"0.48093307",
"0.47909543",
"0.4756315",
"0.47559756",
"0.47468302",
"0.47445056",
"0.47084865",
"0.47027874",
"0.4695509",
"0.46940336",
"0.46934325",
"0.46... | 0.7177217 | 0 |
Intialize one batch generator per file in the protocol | def initialize(self, protocol, subset='train'):
self.batches_ = []
for current_file in getattr(protocol, subset)():
# create a dummy protocol that contains only one file
dummy = get_dummy_protocol(current_file)
# initialize batch generator for current file
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def init_batch(self):\n pass",
"def _generate_and_load_initial_batch(self, working_directory: Path):\n\n template_dir = Path(working_directory) / \"template_1\"\n template_dir.mkdir()\n # changes here should often be reflected in\n # data_generator_opts and data_loader_opts\n\n... | [
"0.6951793",
"0.66523665",
"0.66480076",
"0.6486409",
"0.6449056",
"0.6410844",
"0.63084024",
"0.62821466",
"0.62313265",
"0.62171644",
"0.6214638",
"0.62047136",
"0.6185756",
"0.61471426",
"0.61446726",
"0.6143301",
"0.61341095",
"0.61106086",
"0.60995114",
"0.6085609",
"0.6... | 0.70385647 | 0 |
Generate speech turn fixedlength subsegments | def generator(self):
# generates speech turns long enough to contain at least one segment
speech_turns = super(SpeechTurnSubSegmentGenerator, self).generator()
# number of speech turns per "speech turn batch"
if self.per_fold is not None:
n_speech_turns = self.per_label * s... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def segment(data):",
"def iter_segments_(self, X):\n\n # heuristic that tries to avoid highly-overlapping sub-segments\n # (i.e. with more than 50% overlap on average) for short speech turns\n n_samples = len(X)\n n = (n_samples - self.n_samples_) // (self.n_samples_ // 2) + 1\n ... | [
"0.5535413",
"0.55321836",
"0.5513813",
"0.5512262",
"0.5486237",
"0.5449144",
"0.54481196",
"0.5428312",
"0.53557825",
"0.5342297",
"0.5302634",
"0.52944946",
"0.529139",
"0.5258712",
"0.523742",
"0.52191806",
"0.5215154",
"0.5201453",
"0.5199256",
"0.5196751",
"0.51922387",... | 0.55631065 | 0 |
Returns a new FrozenDict with keys from iterable and values equal to value. | def fromkeys(iterable, value=None):
return FrozenDict(dict.fromkeys(iterable, value)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def freeze(xs: Mapping[Any, Any]) -> FrozenDict[Any, Any]:\n return FrozenDict(xs)",
"def fromkeys(cls, iterable, value=None, callback=(lambda: None)):\r\n new_csvd = cls(callback)\r\n for key in iterable:\r\n new_csvd[key] = value\r\n return new_csvd",
"def dedup(iterable):\n ... | [
"0.6418699",
"0.58564746",
"0.56773466",
"0.5652446",
"0.55607826",
"0.5427696",
"0.5413364",
"0.53514874",
"0.5304149",
"0.52510005",
"0.51757365",
"0.5152398",
"0.5122361",
"0.51208925",
"0.50635445",
"0.50432175",
"0.5033712",
"0.50023425",
"0.49923775",
"0.49399322",
"0.4... | 0.87007105 | 0 |
getquerydict returns a mutable copy of the querydict with exclude values removed. | def exclude_keys(value, *exclude):
if not isinstance(value, QueryDict):
raise RuntimeError("getquerydict should be used with QueryDict instances only (e.g. request.GET)")
value = value.copy()
for key in exclude:
if key in value: del value[key]
return value | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def query_dict(self):\r\n if self._query_dict is None:\r\n def _split(param):\r\n p = param.split('=')\r\n return (unquote_plus(p[0]),\r\n unquote_plus('='.join(p[1:])))\r\n self._query_dict = dict(_split(p) for p in self.query.split... | [
"0.64614964",
"0.6105909",
"0.6084653",
"0.60080016",
"0.5978525",
"0.5949719",
"0.5899048",
"0.582931",
"0.58133054",
"0.57969296",
"0.57734036",
"0.5747309",
"0.57272726",
"0.57094604",
"0.56549114",
"0.5646493",
"0.56302047",
"0.5574521",
"0.556382",
"0.5547581",
"0.548258... | 0.68574476 | 0 |
returns if value starts with s, used for menu highlighting | def startswith(value, s):
if not value: return False
return value.find(s) == 0 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def startswith(self, s):\n return self.peek((0, len(s))).startswith(s)",
"def startswith(self, s):\n return self.peek((0, len(s))).startswith(s)",
"def starts(str_, val_to_check):\n \n return (str_.startswith(val_to_check))",
"def test_starts_letter(x):\n return x[0].isalpha()",
"def... | [
"0.6734909",
"0.6734909",
"0.665961",
"0.6285959",
"0.6276541",
"0.6022511",
"0.6000707",
"0.59770054",
"0.5827545",
"0.57944816",
"0.57935137",
"0.57287425",
"0.56747144",
"0.5672996",
"0.5669597",
"0.56685424",
"0.5632404",
"0.56318706",
"0.56318706",
"0.56318706",
"0.56318... | 0.7256204 | 0 |
Add/Register a datasource factory function and all related `Datasource`, `DataAsset` and `ExecutionEngine` types. Creates mapping table between the `DataSource`/`DataAsset` classes and their declared `type` string. Example An `.add_pandas()` pandas factory method will be added to `context.sources`. | def register_types_and_ds_factory(
cls,
ds_type: Type[Datasource],
factory_fn: SourceFactoryFn,
) -> None:
# TODO: check that the name is a valid python identifier (and maybe that it is snake_case?)
ds_type_name = ds_type.__fields__["type"].default
if not ds_type_nam... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _register_datasource_and_factory_method(\n cls,\n ds_type: Type[Datasource],\n factory_fn: SourceFactoryFn,\n ds_type_name: str,\n datasource_type_lookup: TypeLookup,\n ) -> str:\n method_name = f\"add_{ds_type_name}\"\n LOGGER.info(\n f\"2a. Regis... | [
"0.6715073",
"0.5636041",
"0.56334937",
"0.54436016",
"0.5403923",
"0.5360209",
"0.5254492",
"0.5248973",
"0.5230199",
"0.5199681",
"0.51970965",
"0.5187558",
"0.5115622",
"0.50955814",
"0.50914407",
"0.5043495",
"0.5003381",
"0.49691394",
"0.49054894",
"0.48895955",
"0.48861... | 0.6496101 | 1 |
Register the `Datasource` class and add a factory method for the class on `sources`. The method name is pulled from the `Datasource.type` attribute. | def _register_datasource_and_factory_method(
cls,
ds_type: Type[Datasource],
factory_fn: SourceFactoryFn,
ds_type_name: str,
datasource_type_lookup: TypeLookup,
) -> str:
method_name = f"add_{ds_type_name}"
LOGGER.info(
f"2a. Registering {ds_type._... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def register_source(klass):\n EVENT_SOURCES[klass.__name__] = klass",
"def register_types_and_ds_factory(\n cls,\n ds_type: Type[Datasource],\n factory_fn: SourceFactoryFn,\n ) -> None:\n\n # TODO: check that the name is a valid python identifier (and maybe that it is snake_case... | [
"0.6320931",
"0.6171793",
"0.6078567",
"0.5705505",
"0.56093585",
"0.56023943",
"0.54137015",
"0.5360599",
"0.5227086",
"0.51011264",
"0.508374",
"0.50625104",
"0.5027684",
"0.5019971",
"0.5010033",
"0.50059265",
"0.49942586",
"0.498633",
"0.49783805",
"0.49572867",
"0.494030... | 0.72943217 | 0 |
Generates and returns a unique list of user IDs which have a role assigned. | def get_user_id_list(self):
user_set = set()
for subscription in self['subscriptions'].values():
for role_assignment in subscription['role_assignments'].values():
if role_assignment['principal_type'] == 'User':
user_set.add(role_assignment['principal_id'])... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def get_roles(role):",
"def iter_role_ids(self):\n role_ids = self.role_ids\n if (role_ids is not None):\n yield from role_ids",
"def get_roles(self):\n return [role.role_id for role in self.roles if role]",
"def app_role_ids(self) -> pulumi.Output[Mapping[str, str]]:\n ... | [
"0.67309517",
"0.66829836",
"0.6674705",
"0.6514393",
"0.65128154",
"0.64717126",
"0.6440359",
"0.64233774",
"0.6423213",
"0.6317027",
"0.6313846",
"0.6311536",
"0.62729347",
"0.62628883",
"0.62614244",
"0.62001306",
"0.618918",
"0.6171121",
"0.6154949",
"0.61496717",
"0.6133... | 0.71160877 | 0 |
Compiles ``source`` and returns (result, errors, ast). | def compile_src(source: str) -> Tuple[Any, List[Error]]:
result_tuple = compile_source(source, get_preprocessor(), get_grammar(), get_transformer(),
get_compiler())
return result_tuple[:2] # drop the AST at the end of the result tuple | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def compile_src(source):\n result_tuple = compile_source(source, get_preprocessor(), get_grammar(), get_transformer(),\n get_compiler())\n return result_tuple",
"def compile_src(source):\n result_tuple = compile_source(source, get_preprocessor(), get_grammar(), get_trans... | [
"0.80301553",
"0.80301553",
"0.80301553",
"0.7146783",
"0.68260485",
"0.6706923",
"0.66628903",
"0.6629733",
"0.6602841",
"0.6569773",
"0.6539719",
"0.6538637",
"0.6351463",
"0.63419944",
"0.6261024",
"0.6144432",
"0.6136253",
"0.6100584",
"0.60764694",
"0.60593367",
"0.59880... | 0.84049714 | 0 |
Serialization of result. REWRITE THIS, IF YOUR COMPILATION RESULT IS NOT A TREE OF NODES. | def serialize_result(result: Any) -> Union[str, bytes]:
if isinstance(result, Node):
return result.serialize(how='default' if RESULT_FILE_EXTENSION != '.xml' else 'xml')
else:
return repr(result) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def serialize(self, root):\r\n self.res = []\r\n self.search_serialize(root)\r\n return ' '.join(self.res)",
"def serialize(self, root):\n self.res = []\n self.dfs(root)\n return ' '.join(self.res)",
"def serialize(self, root):",
"def serialize(self, root):\n ... | [
"0.6994656",
"0.68668705",
"0.67351913",
"0.64391494",
"0.62934834",
"0.6279502",
"0.623583",
"0.62147486",
"0.621072",
"0.6207374",
"0.6198766",
"0.61835176",
"0.61826456",
"0.6157616",
"0.6145787",
"0.613086",
"0.60877323",
"0.6055141",
"0.6038221",
"0.60134935",
"0.6008051... | 0.69615585 | 1 |
Compiles the source and writes the serialized results back to disk, unless any fatal errors have occurred. Error and Warning messages are written to a file with the same name as `result_filename` with an appended "_ERRORS.txt" or "_WARNINGS.txt" in place of the name's extension. Returns the name of the errormessages fi... | def process_file(source: str, result_filename: str = '') -> str:
source_filename = source if is_filename(source) else ''
result, errors = compile_src(source)
if not has_errors(errors, FATAL):
if os.path.abspath(source_filename) != os.path.abspath(result_filename):
with open(result_filena... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def process_file(source: str, out_dir: str,\n preprocessor_factory: PreprocessorFactory,\n parser_factory: ParserFactory,\n junctions: Set[Junction],\n targets: Set[str],\n serializations: Dict[str, List[str]]) -> str:\n source_file... | [
"0.5609869",
"0.53882104",
"0.53202623",
"0.52596587",
"0.51766676",
"0.5090102",
"0.5055804",
"0.50231206",
"0.5022438",
"0.5022048",
"0.49947387",
"0.49889153",
"0.49674922",
"0.4922182",
"0.490039",
"0.48633218",
"0.48488358",
"0.48289448",
"0.4825939",
"0.48106307",
"0.47... | 0.7119522 | 0 |
Connection.Connect opens a writer, triggers CLIENT_CONNECT | def test_connect(connection, events, writer, schedule, flush):
schedule(connection.connect())
flush()
assert connection.connected
assert not writer.closed
assert events.triggered("CLIENT_CONNECT") | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def connect(self):\n self.conn.connect()",
"def connect():",
"def _connect(self) -> None:\n if self._connection_waiter:\n return\n\n self._connection_waiter = self._service.whenConnected(failAfterFailures=1)\n\n @self._connection_waiter.addErrback\n def fail(r):\n ... | [
"0.65557486",
"0.6518978",
"0.63452494",
"0.6323653",
"0.62717533",
"0.6270357",
"0.62411857",
"0.620919",
"0.62048924",
"0.6197021",
"0.61938757",
"0.6105541",
"0.6075325",
"0.60641783",
"0.6055794",
"0.6055794",
"0.6055794",
"0.6055794",
"0.6055794",
"0.6055794",
"0.6055794... | 0.69290155 | 0 |
Connection.disconnect closes writer, triggers CLIENT_DISCONNECT | def test_disconnect(writer, patch_connection, events, connection,
schedule, flush):
schedule(connection.connect(), connection.disconnect())
flush()
assert not connection.connected
assert writer.closed
assert connection.writer is None
assert events.triggered("CLIENT_CONNECT")
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def disconnect(self):\n self.log.info(\"Disconnect requested\")\n self.connected = False\n self.writer.close()\n await self.writer.wait_closed()",
"def disconnect(conn):\n conn.close()",
"def disconnect():\n logging.info('Client disconnected')",
"def disconnect(self):\... | [
"0.77368414",
"0.75231403",
"0.7358941",
"0.7176411",
"0.7171201",
"0.710385",
"0.70947856",
"0.7047854",
"0.7045934",
"0.702521",
"0.7015793",
"0.6999884",
"0.6972629",
"0.69582653",
"0.69582653",
"0.6932286",
"0.6909261",
"0.6882554",
"0.6878365",
"0.6836117",
"0.6836117",
... | 0.7671474 | 1 |
Nothing happens when reading before connecting | def test_read_before_connected(connection, reader, loop):
value = loop.run_until_complete(connection.read())
assert not value
assert not reader.used | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def handle_connect(self):\n pass",
"def connect():",
"def handle_read(self):\n if self.established:\n return self._handle_read()\n self._handshake()",
"async def _connect(self):\n if not self._reader:\n self._reader = asyncio.create_task(self._read())",
"de... | [
"0.70835346",
"0.7046764",
"0.7017925",
"0.6873425",
"0.6838027",
"0.6782297",
"0.67739373",
"0.66824675",
"0.6618084",
"0.6544844",
"0.65386903",
"0.6502205",
"0.6495611",
"0.6443093",
"0.64077467",
"0.6397563",
"0.6397563",
"0.6397563",
"0.6397563",
"0.6397563",
"0.6397563"... | 0.7090576 | 0 |
Remove all instances of the given item_to_delete from the list_arg. | def list_delete_item(list_arg: list, item_to_delete: Any) -> list:
from itertools import filterfalse
result = list(filterfalse(lambda x: x == item_to_delete, list_arg))
return result | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def removeItem(*args):",
"def removeItem(*args):",
"def deleteItem(list,item):\n print \"I deleted this item:\", item\n list.remove(item)",
"def remove(*, item : Any, list : Union[List[Any], ConduitVariable]) -> None:\n list.remove(item)",
"def cloudflare_waf_ip_list_item_delete_command(client... | [
"0.70964444",
"0.70964444",
"0.70091504",
"0.6778346",
"0.66589946",
"0.66308564",
"0.65736884",
"0.65371674",
"0.6357414",
"0.63054454",
"0.63054454",
"0.6265344",
"0.61729276",
"0.6156307",
"0.6123787",
"0.61092263",
"0.60733366",
"0.6052361",
"0.6034823",
"0.60257685",
"0.... | 0.8179512 | 0 |
Replace all instances of the old_value with the new_value in the given list_arg. | def list_replace(list_arg: list, old_value, new_value, *, replace_in_place: bool = True) -> list:
old_value_indexes = list_item_indexes(list_arg, old_value)
new_list = list_delete_item(list_arg, old_value)
for index in old_value_indexes:
if replace_in_place:
new_list.insert(index, new_v... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def change(some_list):\n some_list[0] = 'Changed' # will change the original list",
"def substitute_list_value(original_list: Sequence[Any], position: int, new_value: Any) -> Sequence[Any]:\n if not isinstance(original_list, Sequence) or not isinstance(position, int):\n raise TypeError\n indexObj... | [
"0.6344232",
"0.6299414",
"0.61201257",
"0.6109528",
"0.6109498",
"0.60966575",
"0.6063701",
"0.6049112",
"0.60430914",
"0.60294235",
"0.5921863",
"0.5800475",
"0.56845164",
"0.56253046",
"0.5621433",
"0.5589704",
"0.55868757",
"0.55502915",
"0.5512477",
"0.550861",
"0.544164... | 0.74204385 | 0 |
Delete items from the list_arg is the item is an empty strings, empty list, zero, False or None. | def list_delete_empty_items(list_arg: list) -> list:
empty_values = ('', [], 0, False, None)
# TODO: not sure if this is the right way to implement this
return [i for i in list_arg if i not in empty_values] | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def clearList(*args):",
"def clearList(*args):",
"def list_delete_item(list_arg: list, item_to_delete: Any) -> list:\n from itertools import filterfalse\n\n result = list(filterfalse(lambda x: x == item_to_delete, list_arg))\n return result",
"def removeItem(*args):",
"def removeItem(*args):",
"... | [
"0.7484432",
"0.7484432",
"0.74410105",
"0.664139",
"0.664139",
"0.6543606",
"0.64277273",
"0.6395594",
"0.6356726",
"0.62791294",
"0.623651",
"0.6149351",
"0.61075044",
"0.60878307",
"0.60434693",
"0.60081166",
"0.5982874",
"0.5974439",
"0.5914031",
"0.5912869",
"0.58605045"... | 0.8040935 | 0 |
This function creates a colour magnitude diagram (r vs gr) for the lenses and sources of the simulated data. | def colourMagnitudeDiagram(lens_r_list, lens_gr_list, lens_gi_list, source_r_list, source_gr_list,
source_gi_list, positive_path):
int_lens_r_list = []
int_lens_gr_list = []
int_lens_gi_list = []
int_source_r_list = []
int_source_gr_list = []
int_source_gi_list = []
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def plot_colour_mag_diagram(params,mags, colours, local_mags, local_colours,\n target, source, blend, RC, blue_filter, red_filter,\n yaxis_filter, tol, log):\n\n def calc_colour_lightcurve(blue_lc, red_lc, y_lc):\n\n idx1 = np.where( red_lc['mag_err']... | [
"0.6949967",
"0.60977",
"0.60607314",
"0.59762955",
"0.57964194",
"0.5708642",
"0.56588405",
"0.56396",
"0.55768985",
"0.5484139",
"0.54685134",
"0.5456538",
"0.54092693",
"0.5392619",
"0.53742373",
"0.5371201",
"0.5352074",
"0.52988034",
"0.52967405",
"0.52865064",
"0.527994... | 0.75625986 | 0 |
Resaves config file with updated given item to a new value. The "item_pointer" variable must be in form of 'SectionName.PropertyName', | def update_item_in_file(item_pointer, new_value):
# interrupt if config update is locked
if _get_scs_globals().config_update_lock:
return False
# interrupt if settings storage place is set to blend file (except when config storage place itself is being updated)
if _get_scs_globals().config_sto... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def setSection(self, section, item, data):\n if not self.config.has_section(section):\n self.config.add_section(section)\n self.config.set(section, item, data)\n # Write the updated file whenever anything changes\n with open(self.filename, 'w') as configfile:\n sel... | [
"0.65006614",
"0.6447882",
"0.6166506",
"0.5538251",
"0.55345184",
"0.5461876",
"0.5452905",
"0.53958374",
"0.53537035",
"0.53131473",
"0.5309839",
"0.52378386",
"0.52332896",
"0.5189839",
"0.51661515",
"0.51655245",
"0.5135005",
"0.51029074",
"0.5102204",
"0.5087166",
"0.506... | 0.7836323 | 0 |
The function deletes and populates again a list of Shader Preset items in inventory. It also updates corresponding record in config file. | def update_shader_presets_path(shader_presets_filepath):
shader_presets_abs_path = _path_utils.get_abs_path(shader_presets_filepath)
if _shader_presets.is_library_initialized(shader_presets_abs_path):
lprint("I Shader presets library is up-to date, no update will happen!")
return
# CLEAR I... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def reload_presets(self):\n old_active = self._active_index\n old_next = self._next_index\n self._preset_classes = self._loader.reload()\n while len(self._playlist) > 0:\n inst = self._playlist.pop(0)\n inst.clear_parameters()\n del inst\n\n gc.co... | [
"0.57400656",
"0.5485188",
"0.5228926",
"0.52132255",
"0.51227504",
"0.5118033",
"0.50689155",
"0.5020847",
"0.50012475",
"0.4986001",
"0.49771917",
"0.4974179",
"0.49581444",
"0.49462673",
"0.49338964",
"0.49256867",
"0.49223915",
"0.49182445",
"0.49156666",
"0.4898169",
"0.... | 0.617011 | 0 |
The function deletes and populates again a list of Trigger Actions in inventory. It also updates corresponding record in config file. | def update_trigger_actions_rel_path(scs_trigger_actions_inventory, trigger_actions_rel_path, readonly=False):
gathered_library_filepaths = _path_utils.get_abs_paths(trigger_actions_rel_path,
use_infixed_search=_get_scs_globals().trigger_actions_use_infixed... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"async def update_actions(self, payload: discord.RawReactionActionEvent) -> None:\n\n if self.ctx.guild is None:\n return\n\n await execute_query(\n self.bot.database,\n 'UPDATE LOGGING SET BITS=? WHERE GUILD_ID=?',\n (self.bits, self.ctx.guild.id)\n ... | [
"0.54284275",
"0.525637",
"0.5253938",
"0.5252949",
"0.5196892",
"0.5189596",
"0.51540804",
"0.5144626",
"0.5144626",
"0.5132819",
"0.51155436",
"0.50895566",
"0.50693905",
"0.50552595",
"0.50492966",
"0.504177",
"0.504021",
"0.49893007",
"0.4960116",
"0.49391288",
"0.4936645... | 0.58791053 | 0 |
The function deletes and populates again a list of Traffic Rules names in inventory. It also updates corresponding record in config file. | def update_traffic_rules_library_rel_path(scs_traffic_rules_inventory, traffic_rules_library_rel_path, readonly=False):
gathered_library_filepaths = _path_utils.get_abs_paths(traffic_rules_library_rel_path,
use_infixed_search=_get_scs_globals().traffic_rul... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def update_schedule(old_holidays: List[str], new_holidays: dict):\n for holiday in new_holidays:\n trash_service.update({'name': holiday, 'routeDelays': new_holidays[holiday]})\n if holiday in old_holidays:\n old_holidays.remove(holiday)\n delete_holidays(old_holidays)",
"def updat... | [
"0.50836504",
"0.50657815",
"0.50454426",
"0.50288516",
"0.50187206",
"0.49918526",
"0.4931194",
"0.4911704",
"0.48586795",
"0.4801606",
"0.4768395",
"0.4767549",
"0.47556937",
"0.47411525",
"0.4740886",
"0.47227257",
"0.47201374",
"0.47056395",
"0.46969905",
"0.4688929",
"0.... | 0.5478063 | 0 |
The function deletes and populates again a list of Hookup names in inventory. It also updates corresponding record in config file. | def update_hookup_library_rel_path(scs_hookup_inventory, hookup_library_rel_path, readonly=False):
# CLEAR INVENTORY
scs_hookup_inventory.clear()
taken_hoookup_ids = {} # temp dict for identifying unique hookups and preventing creation of duplicates (same type and id)
for abs_path in _path_utils.get_... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def populate_initial_inventory(self):\r\n\r\n weapons_file = open('initial-inventory.json', \"r\")\r\n json_data = json.loads(weapons_file.read())\r\n weapons_file.close()\r\n\r\n weapons = json_data['weapons']\r\n for weapon in weapons:\r\n requests.post(\"http://\" +... | [
"0.5387351",
"0.5320346",
"0.5310604",
"0.529102",
"0.5280156",
"0.5260915",
"0.52547187",
"0.52224386",
"0.5205277",
"0.52045834",
"0.51486945",
"0.51390517",
"0.5111958",
"0.51086336",
"0.50632125",
"0.50632125",
"0.5032007",
"0.5031903",
"0.49989405",
"0.4995356",
"0.49874... | 0.59396255 | 0 |
The function deletes and populates again a list of Material Substance names in inventory. It also updates corresponding record in config file. | def update_matsubs_inventory(scs_matsubs_inventory, matsubs_library_rel_path, readonly=False):
matsubs_library_filepath = _path_utils.get_abs_path(matsubs_library_rel_path)
if matsubs_library_filepath:
matsubs_container = _sii.get_data_from_file(matsubs_library_filepath)
if matsubs_container:
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def load_inventory(file_name, lst_Inventory):\r\n \r\n try:\r\n objFile = open(file_name, 'r')\r\n lst_Inventory.clear()\r\n for line in objFile:\r\n data = line.strip().split(',')\r\n inventory = CD(data[0],data[1],data[2])\r\n ... | [
"0.59965813",
"0.56627977",
"0.5651905",
"0.56051403",
"0.5552282",
"0.549857",
"0.54407156",
"0.54223865",
"0.5353067",
"0.5299522",
"0.5274661",
"0.52420694",
"0.52070445",
"0.51954377",
"0.51893884",
"0.51405096",
"0.512698",
"0.51228446",
"0.5118611",
"0.5104431",
"0.5074... | 0.6003369 | 0 |
Fills up "Header" section. | def fill_header_section():
section = _SectionData("Header")
section.props.append(("FormatVersion", 1))
section.props.append(("Source", get_combined_ver_str()))
section.props.append(("Type", "Configuration"))
section.props.append(("Note", "User settings of SCS Blender Tools"))
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def header(self):\n ...",
"def WriteHeader(self):\n return",
"def update_header(self) -> None:\n self.header.partial_reset()\n self.header.point_format_id = self.points.point_format.id\n self.header.point_data_record_length = self.points.point_size\n\n if len(self.points) ... | [
"0.7128942",
"0.6987209",
"0.6910258",
"0.67842716",
"0.67591256",
"0.6695556",
"0.66135037",
"0.65831286",
"0.6559243",
"0.65579295",
"0.6557858",
"0.65010613",
"0.65010613",
"0.6437753",
"0.64279157",
"0.6423207",
"0.64150655",
"0.63959026",
"0.6374468",
"0.63711065",
"0.63... | 0.85017073 | 0 |
Fills up "Paths" section. | def fill_paths_section():
section = _SectionData("Paths")
section.props.append(("ProjectPath", _property_utils.get_by_type(bpy.types.GlobalSCSProps.scs_project_path)))
section.props.append(("", ""))
section.props.append(("ShaderPresetsFilePath", _property_utils.get_by_type(bpy.types.Glob... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def initialize_paths(self):\n for path in self.config[\"paths\"]:\n self.force_path_to_exist(self.config[\"paths\"][path])",
"def path_entries(self):",
"def set_paths(self, paths):\n self.paths = paths",
"def set_paths(self, paths):\n self._paths = paths\n self._paths_s... | [
"0.7076677",
"0.6774004",
"0.669701",
"0.66188455",
"0.65915775",
"0.6539386",
"0.64254427",
"0.63967776",
"0.62753266",
"0.62628293",
"0.6206696",
"0.6186905",
"0.61089057",
"0.6080841",
"0.60565525",
"0.6017081",
"0.60108155",
"0.6010085",
"0.6004459",
"0.598939",
"0.596201... | 0.8132816 | 0 |
Fills up "Import" section. | def fill_import_section():
section = _SectionData("Import")
section.props.append(("ImportScale", _property_utils.get_by_type(bpy.types.GlobalSCSProps.import_scale)))
section.props.append(("PreservePathForExport", int(_property_utils.get_by_type(bpy.types.GlobalSCSProps.import_preserve_path_for_e... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _import(self, _import):\n\n self.__import = _import",
"def start_import(data_import):\n\tdata_import = frappe.get_doc(\"Data Import Beta\", data_import)\n\ti = Importer(data_import.reference_doctype, data_import=data_import)\n\treturn i.import_data()",
"def file_import(self):\r\n\r\n try:\r\n... | [
"0.6284759",
"0.62417555",
"0.62373024",
"0.6093852",
"0.60715675",
"0.5902594",
"0.58773303",
"0.5828327",
"0.5827192",
"0.57878125",
"0.57859254",
"0.5777508",
"0.5775755",
"0.5741588",
"0.5715434",
"0.56752074",
"0.566254",
"0.5652353",
"0.56283045",
"0.56255245",
"0.56226... | 0.7632777 | 0 |
Fills up "Export" section. | def fill_export_section():
section = _SectionData("Export")
section.props.append(("ExportScale", _property_utils.get_by_type(bpy.types.GlobalSCSProps.export_scale)))
section.props.append(("ApplyModifiers", int(_property_utils.get_by_type(bpy.types.GlobalSCSProps.export_apply_modifiers))))
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def exports():",
"def export(exp_data: ExportData) -> None:\n pass",
"def _after_export(self, *args, **kwargs):\n return",
"def filemenu_Export(self):\n line_dict = {}\n for line in self.lines.values():\n for name, arr in line.to_mat().items():\n line_dic... | [
"0.63981235",
"0.6253329",
"0.62433285",
"0.61767477",
"0.61688995",
"0.61619234",
"0.60300225",
"0.60275",
"0.59965986",
"0.5938908",
"0.59351104",
"0.59121174",
"0.5875772",
"0.58742666",
"0.586958",
"0.5858199",
"0.58324707",
"0.5825648",
"0.5822522",
"0.58003545",
"0.5791... | 0.82059675 | 0 |
Fills up "GlobalDisplay" section. | def fill_global_display_section():
section = _SectionData("GlobalDisplay")
section.props.append(("DisplayLocators", int(_property_utils.get_by_type(bpy.types.GlobalSCSProps.display_locators))))
section.props.append(("LocatorSize", _property_utils.get_by_type(bpy.types.GlobalSCSProps.locator_size... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _init_display(self):\n raise NotImplementedError",
"def start_displayhook(self):\n pass",
"def display_org(self):\n self.__draw(self.__org_state)",
"def initDisplay(self):\n display = self.getDisplay()\n\n os.environ[\"DISPLAY\"] = display\n os.environ[\"XAUTHORI... | [
"0.66409075",
"0.637356",
"0.61869454",
"0.61163443",
"0.6085332",
"0.60756505",
"0.60089076",
"0.6003169",
"0.60018843",
"0.59596795",
"0.594844",
"0.5942837",
"0.59395415",
"0.5934058",
"0.5906203",
"0.58237916",
"0.58032715",
"0.5800552",
"0.5783667",
"0.5772358",
"0.56871... | 0.874626 | 0 |
Fills up "GlobalColors" section. | def fill_global_colors_section():
section = _SectionData("GlobalColors")
section.props.append(("PrefabLocatorsWire", tuple(_property_utils.get_by_type(bpy.types.GlobalSCSProps.locator_prefab_wire_color))))
section.props.append(("ModelLocatorsWire", tuple(_property_utils.get_by_type(bpy.types.Glo... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _init_colors(self):\n self.clr_primary = None\n self.clr_secondary = 'green'\n self.clr_tertiary = 'cyan'\n self.clr_quaternary = 'yellow'\n self.clr_bold = 'cyan'\n self.clr_code = 'cyan'\n self.clr_error = 'red'\n self.clr_header = 'yellow'\n sel... | [
"0.66994256",
"0.6518375",
"0.6233769",
"0.6071562",
"0.59987235",
"0.5904867",
"0.58128333",
"0.5790994",
"0.5767563",
"0.5743275",
"0.5725242",
"0.569594",
"0.56655127",
"0.5630153",
"0.56200606",
"0.55936897",
"0.55935985",
"0.5581525",
"0.55723804",
"0.55438685",
"0.55247... | 0.8461247 | 0 |
Returns a valid filepath to "config.txt" file. If the file doesn't exists it creates empty one. | def get_config_filepath():
scs_installation_dirs = _path_utils.get_addon_installation_paths()
# SEARCH FOR CONFIG...
scs_config_file = ''
for i, location in enumerate(scs_installation_dirs):
test_path = os.path.join(location, 'config.txt')
if os.path.isfile(test_path):
scs_c... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _get_config_filepath(self):\n\t\tif self.configfilepath is None:\n\t\t\treturn os.path.join(self.workdir, \"config.txt\")\n\t\telse:\n\t\t\treturn self.configfilepath",
"def get_configuration_file():\n path = os.path.abspath(os.curdir)\n while path != os.sep:\n config_path = os.path.join(path, C... | [
"0.76491684",
"0.71725255",
"0.7140096",
"0.7110095",
"0.70619977",
"0.6989285",
"0.6955942",
"0.68783677",
"0.68762535",
"0.68332595",
"0.68082064",
"0.6707",
"0.6704025",
"0.66973907",
"0.66801715",
"0.66041505",
"0.6583387",
"0.65353006",
"0.6512789",
"0.6501629",
"0.64704... | 0.7741334 | 0 |
Engages configuration lock to prevent writing to config.txt. Should be always used in pair with release_config_lock. Should be used when applying multiple properties to scs globals at once, as many of those propreties will try to update config file inside their update function. But we don't want another config update a... | def engage_config_lock():
_get_scs_globals().config_update_lock = True | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def _setup_lock(self):\n\n try:\n ml2_config.cfg.CONF.set_override('lock_path', \"lock\")\n except ml2_config.cfg.NoSuchOptError:\n ml2_config.cfg.CONF.set_override(\n 'lock_path', \"lock\", \"oslo_concurrency\")",
"def stage_new_config(self):\n # Ensure ... | [
"0.69062984",
"0.6309621",
"0.62705594",
"0.61587507",
"0.59929645",
"0.5990995",
"0.592037",
"0.5892335",
"0.58856857",
"0.5880902",
"0.586287",
"0.5781591",
"0.5725018",
"0.56719357",
"0.562409",
"0.56073123",
"0.5509034",
"0.54088825",
"0.53652483",
"0.53602654",
"0.535958... | 0.8394109 | 0 |
Decorator to create short tags like , , or any other similar tag \nUse `text` as a `kwargs` argument if you want to add some short text within the tag. If you want to create a tag that takes in no text but closes immediately after the attributes, do not use `text` as an argument \nUse `kwargs` to add tag attributes. Py... | def tag(func):
@functools.wraps(func)
def wrapper(**kwargs):
name = func.__name__
if kwargs:
try:
check_text = kwargs['text']
del kwargs['text']
kwargs = {
k.replace(... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def tag(*args, **kwargs):\n def desc(func):\n assert not hasattr(func, 'tags')\n func.tags = Tags(*args, **kwargs)\n return func\n return desc",
"def descr(text=None, **kwargs):\n\n def decorator(func):\n func.short_description = text or func.__name__\n if \"allow_tags... | [
"0.6948859",
"0.65727085",
"0.6397882",
"0.6168957",
"0.5895058",
"0.5888726",
"0.58568615",
"0.573185",
"0.5712302",
"0.5668395",
"0.56271607",
"0.56142884",
"0.5572015",
"0.5536479",
"0.53770214",
"0.53733623",
"0.536355",
"0.5357055",
"0.53330946",
"0.53041315",
"0.529636"... | 0.710132 | 0 |
Merge the questions in this group with those in the other. | def merge_with(
self, other: 'MultiChoiceQuestionGroup'
) -> 'MultiChoiceQuestionGroup':
if set(self.keys) != set(other.keys):
raise KeyError(
'Keys must be identical to merge MultiChoiceQuestionGroups'
)
return MultiChoiceQuestionGroup({
... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def merge_original_questions(self):\n self.merged_tree = ET.ElementTree()\n self.merged_root = self.root\n ids_encountered = set()\n for org_question in self.merged_root.findall('./OrgQuestion'):\n org_id = org_question.attrib['ORGQ_ID']\n if org_id not in ids_enco... | [
"0.6490926",
"0.5907688",
"0.5730081",
"0.55773187",
"0.5543397",
"0.55087364",
"0.5497852",
"0.5480142",
"0.54190516",
"0.5413813",
"0.54065156",
"0.53788525",
"0.5343708",
"0.53066915",
"0.5289815",
"0.52895784",
"0.52742946",
"0.52618986",
"0.5221287",
"0.51860255",
"0.518... | 0.67889506 | 0 |
Runs training evaluation script for trial ``trial_id``, using the config ``trial(trial_id).config``. This is a blocking call, we wait for the script to finish, then parse all its results and return them. | def _run_job_and_collect_results(
self, trial_id: int, config: Optional[dict] = None
) -> (str, List[dict]):
assert (
trial_id in self._trial_dict
), f"Trial with trial_id = {trial_id} not registered with backend"
if config is None:
config = self._trial_dict[t... | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def run(self, config, **kwargs):\n config_parameters = utils.parse_config_or_kwargs(config, **kwargs)\n experiment_path = self.train(config, **kwargs)\n evaluation_logger = utils.getfile_outlogger(\n Path(experiment_path, 'evaluation.log'))\n for testdata, testlabel in zip(co... | [
"0.613962",
"0.59585625",
"0.5609822",
"0.5583076",
"0.55497175",
"0.551092",
"0.5488453",
"0.53847474",
"0.5373508",
"0.53487325",
"0.53079784",
"0.5301888",
"0.5298633",
"0.5293548",
"0.5250805",
"0.52332485",
"0.5224818",
"0.52151436",
"0.52050304",
"0.51741755",
"0.516324... | 0.7981685 | 0 |
Helper function to construct a range of years from a regex. | def _year_range(m):
return (m.group(1), m.group(2)) | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def string_to_years(s):\n pattern = r'\\d\\d\\d\\d'\n r = re.compile(pattern)\n min_year = 1960\n max_year = datetime.now().year + 1\n return list(filter(lambda y: y >= min_year and y <= max_year, map(int, r.findall(s))))",
"def translate_years(val):\n if val.find(\"-\") > 0:\n tokens = ... | [
"0.74759525",
"0.7462469",
"0.7110036",
"0.7095914",
"0.6986254",
"0.66089237",
"0.6588355",
"0.64874226",
"0.638263",
"0.63712627",
"0.63099253",
"0.6231865",
"0.6100081",
"0.60773075",
"0.60369664",
"0.60107183",
"0.57546455",
"0.57506514",
"0.5747007",
"0.5740334",
"0.5731... | 0.813184 | 0 |
Is the (integer) year in a plausible range of dates? | def is_valid_year(year):
return 1750 <= year <= 2019 | {
"objective": {
"self": [],
"paired": [],
"triplet": [
[
"query",
"document",
"negatives"
]
]
}
} | [
"def is_valid_year(year_range):\n\n if not year_range:\n return False\n\n if len(str(year_range)) != 8:\n return False\n\n year1 = year_range[:4]\n year2 = year_range[4:]\n\n try:\n if int(year2) - int(year1) == 1:\n if int(year1) <= int(get_current_hockey_year_start()... | [
"0.81936455",
"0.793523",
"0.79238385",
"0.7772362",
"0.7557136",
"0.7556754",
"0.7532956",
"0.7422364",
"0.7416792",
"0.74086195",
"0.7400881",
"0.7257958",
"0.71052337",
"0.7092924",
"0.70824087",
"0.7056221",
"0.7024738",
"0.70049447",
"0.6972381",
"0.6970943",
"0.69557303... | 0.8099844 | 1 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.