query
stringlengths
9
3.4k
document
stringlengths
9
87.4k
metadata
dict
negatives
listlengths
4
101
negative_scores
listlengths
4
101
document_score
stringlengths
3
10
document_rank
stringclasses
102 values
Calculate the number of columns and rows required to divide an image into ``n`` parts. Return a tuple of integers in the format (num_columns, num_rows)
def calc_columns_rows(n): num_columns = int(ceil(sqrt(n))) num_rows = int(ceil(n / float(num_columns))) return (num_columns, num_rows)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def compute_rows_columns(num_wells):\n a = math.sqrt(num_wells / 6)\n n_rows = int(round(2 * a))\n n_columns = int(round(3 * a))\n return n_rows, n_columns", "def compute_nrows_ncolumns(nplots):\n n_rows = int(np.sqrt(nplots)) + (np.sqrt(nplots) != int(np.sqrt(nplots))) * 1\n n_columns = int(np...
[ "0.73097175", "0.7159921", "0.6962047", "0.69273585", "0.6925103", "0.6749133", "0.66736543", "0.6470178", "0.64632785", "0.63872576", "0.6368298", "0.62814194", "0.6258692", "0.6197939", "0.61734897", "0.6155329", "0.6155302", "0.61514986", "0.61438143", "0.6133328", "0.6131...
0.79326427
0
Calculate combined size of tiles.
def get_combined_size(tiles): # TODO: Refactor calculating layout to avoid repetition. columns, rows = calc_columns_rows(len(tiles)) tile_size = tiles[0].image.size return (tile_size[0] * columns, tile_size[1] * rows)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def tile_size_2d(self):\n return 32.0, 32.0", "def get_num_tiles(rows, cols, row_tile_size, col_tile_size):\n num_row_tiles = math.ceil(rows / row_tile_size)\n num_col_tiles = math.ceil(cols / col_tile_size)\n return num_row_tiles, num_col_tiles", "def get_tilesize(self, sampling):\n xsize = {...
[ "0.6917832", "0.6854386", "0.66924536", "0.66773844", "0.6626963", "0.6563682", "0.6505493", "0.6481431", "0.64496267", "0.641139", "0.63941205", "0.631634", "0.6312036", "0.627973", "0.62632513", "0.625943", "0.6246556", "0.621888", "0.6217926", "0.62107056", "0.61723995", ...
0.8319171
0
``tiles`` Tuple of ``Image`` instances. ``width`` Optional, width of combined image. ``height`` Optional, height of combined image. ``Image`` instance.
def join(tiles, width=0, height=0): # Don't calculate size if width and height are provided # this allows an application that knows what the # combined size should be to construct an image when # pieces are missing. if width > 0 and height > 0: im = Image.new("RGBA", (width, height), None) else: im = Image.new("RGBA", get_combined_size(tiles), None) columns, rows = calc_columns_rows(len(tiles)) for tile in tiles: try: im.paste(tile.image, tile.coords) except IOError: # do nothing, blank out the image continue return im
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _tile_images(imgs, tile_shape, concatenated_image, margin_color=None):\n x_num, y_num = tile_shape\n one_width = imgs[0].shape[1]\n one_height = imgs[0].shape[0]\n if concatenated_image is None:\n concatenated_image = np.zeros((one_height * y_num, one_width * x_num, 3),\n ...
[ "0.6996957", "0.6695184", "0.63886476", "0.62590015", "0.6253077", "0.6211737", "0.62029433", "0.60706353", "0.6000102", "0.596734", "0.5926167", "0.5918759", "0.5894937", "0.5867754", "0.5861465", "0.5857397", "0.5848029", "0.5744577", "0.5702461", "0.5656095", "0.56503665",...
0.7703681
0
Basic sanity checks prior to performing a split.
def validate_image(image, number_tiles): TILE_LIMIT = 99 * 99 try: number_tiles = int(number_tiles) except BaseException: raise ValueError("number_tiles could not be cast to integer.") if number_tiles > TILE_LIMIT or number_tiles < 2: raise ValueError( "Number of tiles must be between 2 and {} (you \ asked for {}).".format( TILE_LIMIT, number_tiles ) )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_splitSanity(self):\n # Whiteboxing\n self.assertRaises(ValueError, irc.split, \"foo\", -1)\n self.assertRaises(ValueError, irc.split, \"foo\", 0)\n self.assertEqual([], irc.split(\"\", 1))\n self.assertEqual([], irc.split(\"\"))", "def test_splitValidatesLength(self):\...
[ "0.7558807", "0.69345814", "0.6754861", "0.6698345", "0.6582555", "0.6470959", "0.644443", "0.6433854", "0.6428578", "0.63183737", "0.63103896", "0.6191666", "0.61298126", "0.60792583", "0.6011742", "0.5989836", "0.5981029", "0.5925554", "0.589626", "0.58922535", "0.58776075"...
0.0
-1
Basic checks for columns and rows values
def validate_image_col_row(image, col, row): SPLIT_LIMIT = 99 try: col = int(col) row = int(row) except BaseException: raise ValueError("columns and rows values could not be cast to integer.") if col < 1 or row < 1 or col > SPLIT_LIMIT or row > SPLIT_LIMIT: raise ValueError( f"Number of columns and rows must be between 1 and" f"{SPLIT_LIMIT} (you asked for rows: {row} and col: {col})." ) if col == 1 and row == 1: raise ValueError("There is nothing to divide. You asked for the entire image.")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def getValidRowsCols(self) :\n colns = number_of_good_cols(self.r_sheet)\n rowns = number_of_good_rows(self.r_sheet)\n \n # Check whether the number of good columns and rows are correct\n while self.isEmptyRow(rowns-1, colns) :\n rowns = rowns - 1 \n while self....
[ "0.6793047", "0.6788679", "0.6685578", "0.66567594", "0.65624297", "0.6553434", "0.6511974", "0.6502489", "0.6456458", "0.6430093", "0.6386662", "0.63792455", "0.63757235", "0.63635373", "0.63515013", "0.6350334", "0.6341316", "0.6338641", "0.63122106", "0.6300438", "0.629813...
0.0
-1
Split an image into a specified number of tiles.
def slice( filename, number_tiles=None, col=None, row=None, save=True, DecompressionBombWarning=True, ): if DecompressionBombWarning is False: Image.MAX_IMAGE_PIXELS = None im = Image.open(filename) im_w, im_h = im.size columns = 0 rows = 0 if number_tiles: validate_image(im, number_tiles) columns, rows = calc_columns_rows(number_tiles) else: validate_image_col_row(im, col, row) columns = col rows = row tile_w, tile_h = int(floor(im_w / columns)), int(floor(im_h / rows)) tiles = [] number = 1 for pos_y in range(0, im_h - rows, tile_h): # -rows for rounding error. for pos_x in range(0, im_w - columns, tile_w): # as above. area = (pos_x, pos_y, pos_x + tile_w, pos_y + tile_h) image = im.crop(area) position = (int(floor(pos_x / tile_w)) + 1, int(floor(pos_y / tile_h)) + 1) coords = (pos_x, pos_y) tile = Tile(image, number, position, coords) tiles.append(tile) number += 1 if save: save_tiles( tiles, prefix=get_basename(filename), directory=os.path.dirname(filename) ) return tuple(tiles)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _split_image_into_tiles(\n self, image: np.ndarray\n ) -> t.Sequence[t.Tuple[t.Tuple[t.Any, ...], np.ndarray]]:\n h, w, c = image.shape\n tile_height = (\n math.ceil(h / (self._n_tiles // 2 - 1))\n if self._n_tiles > 4\n else math.ceil(h / (self._n_tiles...
[ "0.7739236", "0.76190794", "0.70275676", "0.67776227", "0.6704536", "0.66682243", "0.6638104", "0.6595239", "0.65494275", "0.6480226", "0.646695", "0.6428937", "0.6403003", "0.6392269", "0.6336873", "0.62955356", "0.6278064", "0.6265527", "0.6264345", "0.624642", "0.614579", ...
0.64391273
11
Write image files to disk. Create specified folder(s) if they
def save_tiles(tiles, prefix="", directory=os.getcwd(), format="png"): for tile in tiles: tile.save( filename=tile.generate_filename( prefix=prefix, directory=directory, format=format ), format=format, ) return tuple(tiles)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def write(img, path):\n create_directories_for_file_name(path)\n writer = sitk.ImageFileWriter()\n writer.Execute(img, path, True)", "def create_directories(train_path, test_path):\n train_path.joinpath(\"images\").mkdir(parents=True)\n test_path.joinpath(\"images\").mkdir(parents=True)", "def c...
[ "0.71206725", "0.70679843", "0.70667833", "0.69145185", "0.68923235", "0.6808798", "0.680336", "0.67864877", "0.6739885", "0.66490185", "0.65963286", "0.65840054", "0.656958", "0.65321773", "0.6529073", "0.6489769", "0.647365", "0.6456709", "0.642183", "0.641787", "0.64059615...
0.0
-1
Determine column and row position for filename.
def get_image_column_row(filename): row, column = os.path.splitext(filename)[0][-5:].split("_") return (int(column) - 1, int(row) - 1)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_position(self): # maybe encoded in filepath at some point\n result = (self.iter * self.row_step)% self.row_size, self.iter // (self.row_size * self.row_step)* self.col_step\n self.iter += 1\n return result", "def ind(self, pos):\n row = int(pos[1:]) - 1\n column = self...
[ "0.6791335", "0.66289556", "0.66289556", "0.66289556", "0.6522248", "0.6411789", "0.63911855", "0.63667697", "0.6281292", "0.62766576", "0.6266177", "0.6249092", "0.6142638", "0.61390686", "0.6129921", "0.60795605", "0.60582995", "0.60221326", "0.6021388", "0.60078406", "0.59...
0.75118536
0
Open all images in a directory. Return tuple of Tile instances.
def open_images_in(directory): files = [ filename for filename in os.listdir(directory) if "_" in filename and not filename.startswith("joined") ] tiles = [] if len(files) > 0: i = 0 for file in files: pos = get_image_column_row(file) im = Image.open(os.path.join(directory, file)) position_xy = [0, 0] count = 0 for a, b in zip(pos, im.size): position_xy[count] = a * b count = count + 1 tiles.append( Tile( image=im, position=pos, number=i + 1, coords=position_xy, filename=file, ) ) i = i + 1 return tiles
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_pic_in_directory(directory):\n return [Image.open(os.path.join(directory, img)) for img in os.listdir(directory)]", "def get_images(directory=None): #import from mask.py\n \n if directory == None:\n directory = os.getcwd() # Use working directory if unspecified\n \n image_list ...
[ "0.67336595", "0.6599813", "0.6416653", "0.63725936", "0.61642754", "0.6014441", "0.5978408", "0.59570676", "0.5940081", "0.5896447", "0.58877945", "0.5837525", "0.5792128", "0.5787893", "0.5751572", "0.57426775", "0.5739392", "0.57090163", "0.57005966", "0.56994253", "0.5688...
0.81790555
0
If a resource has no title, it's ID should be returned.
def test_str_no_title(media_resource_factory): resource = media_resource_factory() assert str(resource) == str(resource.id)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def resourceid(self):", "def resource_id(self) -> Optional[str]:\n return pulumi.get(self, \"resource_id\")", "def resource_id(self) -> Optional[pulumi.Input[str]]:\n return pulumi.get(self, \"resource_id\")", "def resource_id(self) -> Optional[pulumi.Input[str]]:\n return pulumi.get(sel...
[ "0.7058361", "0.68127316", "0.6649041", "0.6649041", "0.6649041", "0.6649041", "0.6649041", "0.6649041", "0.6649041", "0.6649041", "0.6649041", "0.66319466", "0.662835", "0.65403503", "0.6520874", "0.6478558", "0.643827", "0.6429088", "0.6386452", "0.6386452", "0.6386452", ...
0.5996474
44
If a resource has a title, it should be included in the string representation.
def test_str_with_title(media_resource_factory): resource = media_resource_factory(title="Test Resource") assert str(resource) == f"{resource.id} ({resource.title})"
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def resource_link_title(self):\n return self.request.POST.get(\"resource_link_title\", self.resource_link_id)", "def get_resource_details (self):\n return (f\"[Title:\\\"{self.get_title()}\\\"] [Author:{self.get_author()}] [Publisher:{self.get_publisher()}] [Year:{self.get_year()}]\")", "def res_...
[ "0.68804574", "0.6865952", "0.6629121", "0.6599802", "0.6590698", "0.6551943", "0.6400065", "0.6386993", "0.6346398", "0.632626", "0.63220584", "0.63117653", "0.6293808", "0.62767816", "0.6276447", "0.62574726", "0.6230404", "0.61885935", "0.6185459", "0.61847913", "0.6184791...
0.7142992
0
Media resources should be ordered by creation time, ascending.
def test_ordering(media_resource_factory): m1 = media_resource_factory() m2 = media_resource_factory() assert list(models.MediaResource.objects.all()) == [m1, m2]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_sorted_img_list():\n dirPath=settings.BASE_DIR\n imgdir=\"/pttWeb/static/topicmodel\"\n fileID=glob.glob(dirPath+imgdir+\"/*.png\")\n fileID=[i.replace('/home/stream/Documents/minimum_django/pttWeb/static/','') for i in fileID]\n fileID=[Week_Image(i) for i in fileID]\n fileID.sort(key=la...
[ "0.61875653", "0.60358816", "0.59814835", "0.5946629", "0.5863695", "0.57058465", "0.5681557", "0.5633815", "0.55823237", "0.5550474", "0.5542779", "0.5542779", "0.5542779", "0.5542779", "0.5485966", "0.54624945", "0.544271", "0.5394488", "0.5365429", "0.5348334", "0.5256054"...
0.65957546
0
If a media resource has both an image and YouTube video ID specified then cleaning it should throw an error.
def test_clean_both_image_and_youtube_id(image): resource = models.MediaResource(image=image, youtube_id="dQw4w9WgXcQ") with pytest.raises(ValidationError): resource.clean()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_clean_no_image_or_youtube_id():\n resource = models.MediaResource()\n\n with pytest.raises(ValidationError):\n resource.clean()", "def test_clean_only_youtube_id():\n resource = models.MediaResource(youtube_id=\"dQw4w9WgXcQ\")\n\n resource.clean()", "def test_clean_only_image(image)...
[ "0.7774484", "0.7352817", "0.6742315", "0.6415747", "0.59018755", "0.5872863", "0.58247", "0.57007104", "0.55338883", "0.5439113", "0.54177034", "0.53636616", "0.5305156", "0.53002834", "0.52959025", "0.51120865", "0.51028275", "0.50996584", "0.5081952", "0.5054293", "0.50387...
0.78584284
0
If a media resource does not encapsulate any media, cleaning it should throw an error.
def test_clean_no_image_or_youtube_id(): resource = models.MediaResource() with pytest.raises(ValidationError): resource.clean()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _handle_removed_media(self):\r\n if self.has_media():\r\n try:\r\n image = str(self.image)\r\n os.remove(image)\r\n except OSError:\r\n raise('Failure trying to remove image from filesystem.')\r\n return True", "def test_clean_o...
[ "0.69884086", "0.6832411", "0.6076411", "0.5952054", "0.5877735", "0.586007", "0.574167", "0.5715479", "0.56592447", "0.56336623", "0.5573302", "0.55011815", "0.5439052", "0.54167026", "0.5395553", "0.5383151", "0.53797346", "0.532659", "0.52952904", "0.5293007", "0.5271096",...
0.70109206
0
Cleaning a media resource that only has an image should do nothing.
def test_clean_only_image(image): resource = models.MediaResource(image=image) resource.clean()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _handle_removed_media(self):\r\n if self.has_media():\r\n try:\r\n image = str(self.image)\r\n os.remove(image)\r\n except OSError:\r\n raise('Failure trying to remove image from filesystem.')\r\n return True", "def clean_before...
[ "0.698834", "0.67045337", "0.6504589", "0.6436783", "0.6413871", "0.637336", "0.6318583", "0.61001015", "0.60031515", "0.59312874", "0.59246147", "0.5909386", "0.58954066", "0.5854419", "0.58376265", "0.58252335", "0.5816791", "0.5799392", "0.5791953", "0.5740084", "0.5719948...
0.7978231
0
Cleaning a media resource that only has a YouTube video ID should do nothing.
def test_clean_only_youtube_id(): resource = models.MediaResource(youtube_id="dQw4w9WgXcQ") resource.clean()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_clean_no_image_or_youtube_id():\n resource = models.MediaResource()\n\n with pytest.raises(ValidationError):\n resource.clean()", "def test_clean_both_image_and_youtube_id(image):\n resource = models.MediaResource(image=image, youtube_id=\"dQw4w9WgXcQ\")\n\n with pytest.raises(Validat...
[ "0.7022397", "0.66042817", "0.61575353", "0.5879848", "0.56859034", "0.56468034", "0.5629039", "0.5511188", "0.5497184", "0.54881966", "0.54724157", "0.5448994", "0.5418817", "0.541001", "0.54045886", "0.53989905", "0.5339894", "0.5189437", "0.51847184", "0.51762545", "0.5173...
0.8092883
0
If a media resource has an image, its type property should indicate it's an image.
def test_type_image(image): resource = models.MediaResource(image=image) assert resource.type == models.MediaResource.TYPE_IMAGE
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def is_image(content_type):\n return content_type == \"image/jpeg\" or content_type == \"image/png\"", "def is_image(self):\r\n # we can only get this if we have headers\r\n LOG.debug('content type')\r\n LOG.debug(self.content_type)\r\n if (self.content_type is not None and\r\n ...
[ "0.71367157", "0.6835922", "0.6663885", "0.6654667", "0.6619548", "0.648332", "0.6373138", "0.6143732", "0.6071515", "0.59954345", "0.5967518", "0.596137", "0.59485954", "0.5918796", "0.5918796", "0.5918796", "0.5918796", "0.5918796", "0.5918796", "0.5918796", "0.5918796", ...
0.7742908
0
If a media resource has a YouTube video ID, its type property should indicate it's a YouTube video.
def test_type_youtube(): resource = models.MediaResource(youtube_id="dQw4w9WgXcQ") assert resource.type == models.MediaResource.TYPE_YOUTUBE
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def play_youtube(self, media_id):\n pass", "def isYouTube(self):\n if 'youtube' in self.link.split('.'):\n return True\n return None", "def play_youtube(self, media_id):\n raise NotImplementedError()", "def on_play(self, event, type=\"yt\", content=None):\n urls ...
[ "0.6823963", "0.6766844", "0.6746436", "0.6112856", "0.60233295", "0.59815586", "0.5897715", "0.58677566", "0.5842102", "0.58315057", "0.580741", "0.580741", "0.580741", "0.580741", "0.58059746", "0.579559", "0.579133", "0.5763148", "0.57312804", "0.57054985", "0.56609565", ...
0.78130394
0
A facet dict should produce correct choice labels
def test_choices_from_facets(self): fake_facets = { "doctype": {"foo": 1, "bar": 2, "baz": 3}, "has_transcription": {"true": 3, "false": 3}, } form = DocumentSearchForm() # call the method to configure choices based on facets form.set_choices_from_facets(fake_facets) # test doctype facets (FacetChoiceField) for choice in form.fields["doctype"].widget.choices: # choice is index id, label choice_label = choice[1] assert isinstance(choice_label, str) assert "<span>" in choice_label # test has_transcription facet (BooleanFacetField) bool_label = form.fields["has_transcription"].label assert isinstance(bool_label, str) assert "3</span>" in bool_label
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def populate_from_facets(self, facet_dict):\n # generate the list of choice from the facets\n\n self.choices = (\n (\n val,\n mark_safe(f'<span>{label}</span><span class=\"count\">{count:,}</span>'),\n )\n for val, (label, count) in facet...
[ "0.72828305", "0.6952813", "0.6830777", "0.6303037", "0.6230736", "0.60396737", "0.58811235", "0.56370056", "0.56334686", "0.5489322", "0.54117686", "0.53088254", "0.5206354", "0.5197836", "0.5150402", "0.5128234", "0.51101923", "0.50881493", "0.5084556", "0.50771785", "0.506...
0.69385916
2
Should add an error if query is empty and sort is relevance
def test_clean(self): form = DocumentSearchForm() form.cleaned_data = {"q": "", "sort": "relevance"} form.clean() assert len(form.errors) == 1 # Otherwise should not raise an error form = DocumentSearchForm() form.cleaned_data = {"q": "test", "sort": "relevance"} form.clean() assert len(form.errors) == 0 form = DocumentSearchForm() form.cleaned_data = {"q": "", "sort": "scholarship_desc"} form.clean() assert len(form.errors) == 0
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_sortby_invalid(self):\n qs = {'a': 1, 'w': 4, 'format': 'json', 'sortby': ''}\n response = self.client.get(reverse('search.advanced'), qs)\n eq_(200, response.status_code)", "def test_scroll_query_sort_safe(self):\n self._validate_scroll_search_params({\"sort\": \"_id\"}, {\"...
[ "0.68004227", "0.668683", "0.649039", "0.6110041", "0.60085225", "0.5954969", "0.5795239", "0.5701212", "0.5672946", "0.5664839", "0.5664839", "0.56449044", "0.5619792", "0.5586709", "0.5570209", "0.55674064", "0.5558715", "0.55321485", "0.5520282", "0.55074567", "0.5495927",...
0.0
-1
Should add an error if rationale is 'other' and rationale notes are empty
def test_clean(self): doc = Document.objects.create() form = DocumentMergeForm() form.cleaned_data = { "primary_document": doc.id, "rationale": "other", "rationale_notes": "", } form.clean() assert len(form.errors) == 1 # should not produce an error if rationale notes provided form = DocumentSearchForm() form.cleaned_data = { "primary_document": doc.id, "rationale": "other", "rationale_notes": "test", } form.clean() assert len(form.errors) == 0 # should not produce an error if rational is "duplicate" or "join" form = DocumentSearchForm() form.cleaned_data = { "primary_document": doc.id, "rationale": "duplicate", "rationale_notes": "", } form.clean() assert len(form.errors) == 0
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_contentious_prescription_no_rationale(self):\n url = reverse('admin:prescription_prescription_add')\n data = {\n 'name': 'Test',\n 'planned_season': 1,\n 'planned_year': 2013,\n 'region': 1,\n 'district': 1,\n 'location': 'Tes...
[ "0.6536794", "0.6193883", "0.59964615", "0.59149736", "0.5794971", "0.57020473", "0.568294", "0.5651748", "0.56196064", "0.55880433", "0.556072", "0.55405277", "0.5500709", "0.54977834", "0.5488182", "0.5431535", "0.5406004", "0.5385384", "0.5364079", "0.53436726", "0.5336585...
0.5011413
64
Can this crawler process this URL?
def offer(self, url): parts = urlparse(url) return bool(self.KT_RE.match(parts.netloc))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def can_handle(self, url):\n return self.url_re.match(url)", "def match_url(self, url):\n pass", "def can_fetch(self, useragent, url):\n target_url = url\n if self.root_path:\n target_url = re.sub(self.root_path, \"\", target_url)\n return super(Robot, self).can_fe...
[ "0.73433197", "0.6720704", "0.66891474", "0.6490422", "0.647403", "0.6457199", "0.6456133", "0.6403348", "0.6397142", "0.636222", "0.6355213", "0.6349857", "0.6321741", "0.630184", "0.62799656", "0.6256721", "0.62470055", "0.6201895", "0.61920714", "0.61752903", "0.6173302", ...
0.619864
18
Fetch and return the raw HTML for this url. The return content is a unicode string.
def fetch(self, url): self.log.info("Fetching URL: " + url) r = requests.get(url, verify=False) # raise an HTTPError on badness r.raise_for_status() # this decodes r.content using a guessed encoding return r.text
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _get_raw_html(self):\n buffer = BytesIO()\n c = pycurl.Curl()\n c.setopt(c.URL, self.url)\n c.setopt(c.WRITEDATA, buffer)\n c.perform()\n c.close()\n return buffer.getvalue()", "def getHtml(self, url):\n r = requests.get(url)\n html = r.content\n...
[ "0.8074977", "0.7284636", "0.7092009", "0.7025183", "0.69793874", "0.69557333", "0.6916234", "0.68908453", "0.68863857", "0.6852996", "0.68447953", "0.68049586", "0.6689668", "0.6678838", "0.6672157", "0.66424465", "0.6611915", "0.6605699", "0.6543702", "0.65425205", "0.65123...
0.69644094
5
Extract text and other things from the raw_html for this document.
def extract(self, doc, raw_html): super(KenyaTodayCrawler, self).extract(doc, raw_html) soup = BeautifulSoup(raw_html) # gather title doc.title = soup.find(attrs={"property":"og:title"})['content'] #gather publish date date = self.extract_plaintext(soup.select("main.content .entry-meta .entry-time")) doc.published_at = self.parse_timestamp(date) nodes = soup.select(".content .entry-content p") self.log.info(nodes) if len(nodes) > 1: doc.summary = self.extract_plaintext(nodes[0:1]) doc.text = "\n\n".join(p.text.strip() for p in nodes[2:]) doc.author = Author.unknown()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def extract_all_text(self, url, html_doc):\n self.title_text = self.get_title_words(html_doc)\n self.meta_text = self.get_meta_words(html_doc)\n self.url_text = self.get_url_words(url)\n self.heading_text = self.get_heading_words(html_doc)\n self.body_text = self.get_body_words(h...
[ "0.6755422", "0.6671859", "0.6553396", "0.64243054", "0.6272383", "0.623531", "0.623531", "0.6228035", "0.61742455", "0.61664754", "0.61556983", "0.6104006", "0.6092044", "0.60168433", "0.59852856", "0.59402233", "0.5923603", "0.59181535", "0.59116304", "0.58720744", "0.58008...
0.73629075
0
We override the normal solve() so that we do not have to enter all 343,000 state_targets for this class.
def solve(self, print_steps=False) -> bool: (state, _cost_to_goal) = self.ida_heuristic() steps = self.steps(state) if steps: for step in steps: self.parent.rotate(step) if print_steps: logger.info(f"{self}: step {step}") return True else: return False
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def solve(self, state, times):", "def solve(self, current_state: dict) -> dict:", "def solution(self) -> State:", "def solve(self):\n pass", "def solve(self):\n pass", "def solve(self):\n ...", "def solve(self):", "def solve(self):\n \n raise NotImplementedError(\"n...
[ "0.7180512", "0.6942709", "0.6700484", "0.662909", "0.662909", "0.6619703", "0.6546795", "0.63575697", "0.6320139", "0.6305795", "0.6301925", "0.6139513", "0.6138511", "0.608324", "0.6081203", "0.6034735", "0.6010343", "0.5882625", "0.5849981", "0.57675886", "0.57673275", "...
0.0
-1
Our goal is to get the edges split into high/low groups but we do not care what the final orienation is of the edges. Each edge can either be in its final orientation or not so there are (2^12)/2 or 2048 possible permutations. The /2 is because there cannot be an odd number of edges not in their final orientation.
def eo_edges(self): logger.info("eo_edges called") permutations = [] original_state = self.state[:] original_solution = self.solution[:] tmp_solution_len = len(self.solution) # Build a list of the wing strings at each midge wing_strs = [] for _, square_index, partner_index in midges_recolor_tuples_555: square_value = self.state[square_index] partner_value = self.state[partner_index] wing_str = square_value + partner_value wing_str = wing_str_map[square_value + partner_value] wing_strs.append(wing_str) # build a list of all possible EO permutations...an even number of edges must be high for num in range(4096): num = str(bin(num)).lstrip("0b").zfill(12) if num.count("1") % 2 == 0: permutations.append(list(map(int, num))) # Put all 2048 starting states in a file and point ida-via-graph # at the file so it can solve all of them and apply the one that is the shortest. lr_center_stage_states = [] eo_outer_orbit_states = [] eo_inner_orbit_states = [] for permutation in permutations: must_be_uppercase = [] must_be_lowercase = [] self.state = original_state[:] for wing_str, uppercase in zip(wing_strs, permutation): if uppercase: must_be_uppercase.append(wing_str) else: must_be_lowercase.append(wing_str) # logger.info("%s: %s permutation %s" % (self, index, "".join(map(str, permutation)))) self.edges_flip_orientation(must_be_uppercase, must_be_lowercase) # build lists of the states that we need to find state_indexes for lr_center_stage_states.append(self.lt_phase3_lr_center_stage.state()) eo_outer_orbit_states.append(self.lt_phase3_eo_outer_orbit.state()) eo_inner_orbit_states.append(self.lt_phase3_eo_inner_orbit.state()) # now we have a huge list of states to lookup, do a binary search on multiple states at once (this is drastically faster # than binary searching for them individually). state_index_multiple() will return a dict where the state is the key # and the state_index is the value. lr_center_stage_eo_inner_orbit_state_indexes = self.lt_phase3_lr_center_stage.state_index_multiple( lr_center_stage_states ) eo_outer_orbit_state_indexes = self.lt_phase3_eo_outer_orbit.state_index_multiple(eo_outer_orbit_states) eo_inner_orbit_state_indexes = self.lt_phase3_eo_inner_orbit.state_index_multiple(eo_inner_orbit_states) # build a list of tuples of the state indexes pt_state_indexes = [] for lr_center_stage_eo_inner_orbit_state, eo_outer_orbit_state, eo_inner_orbit_state in zip( lr_center_stage_states, eo_outer_orbit_states, eo_inner_orbit_states ): pt_state_indexes.append( ( lr_center_stage_eo_inner_orbit_state_indexes[lr_center_stage_eo_inner_orbit_state], eo_outer_orbit_state_indexes[eo_outer_orbit_state], eo_inner_orbit_state_indexes[eo_inner_orbit_state], ) ) self.state = original_state[:] self.solution = original_solution[:] # When solve_via_c is passed pt_state_indexes (2048 lines of states in this case), it will try all 2048 of them # to find the state that has the shortest solution. self.lt_phase3.solve_via_c(pt_states=pt_state_indexes) self.print_cube_add_comment("edges EOed into high/low groups", tmp_solution_len) self.post_eo_state = self.state[:] self.post_eo_solution = self.solution[:] # re-color the cube so that the edges are oriented correctly so we can # pair 4-edges then 8-edges. After all edge pairing is done we will uncolor # the cube and re-apply the solution. self.edges_flip_orientation(wing_strs, []) self.highlow_edges_print()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def subdivide_ngons(faces: Iterable[Sequence[Union[Vector, Vec2]]]) -> Iterable[\n List[Vector]]:\n for face in faces:\n if len(face) < 5:\n yield face\n else:\n mid_pos = sum(face) / len(face)\n for index, vertex in enumerate(face):\n yield face[...
[ "0.5971374", "0.58695173", "0.5826751", "0.5813039", "0.57311904", "0.57143676", "0.5701675", "0.5663653", "0.5646929", "0.56423926", "0.5626546", "0.560861", "0.55968225", "0.55719924", "0.55631095", "0.5513152", "0.5477863", "0.5472609", "0.5460661", "0.5448054", "0.5435083...
0.5720235
5
phase5 requires a 4edge combo where none of the edges are in the zplane. phase4 will put a 4edge combo into that state. There are 12!/(4!8!) or 495 different 4edge combinations. Try them all and see which one has the lowest phase4 cost.
def find_first_four_edges_to_pair(self): original_state = self.state[:] original_solution = self.solution[:] original_solution_len = len(self.solution) results = [] for wing_str_index, wing_str_combo in enumerate(itertools.combinations(wing_strs_all, 4)): wing_str_combo = sorted(wing_str_combo) self.state = original_state[:] self.solution = original_solution[:] self.lt_phase4.wing_strs = wing_str_combo if self.lt_phase4.solve(): phase4_solution = self.solution[original_solution_len:] phase4_solution_len = len(phase4_solution) results.append((phase4_solution_len, wing_str_combo)) logger.debug( f"{wing_str_index+1}/495 {wing_str_combo} phase-4 solution length is {phase4_solution_len}" ) else: logger.debug(f"{wing_str_index+1}/495 {wing_str_combo} phase-4 solution length is >= 4 ") self.lt_phase4.fh_txt_cache = {} self.state = original_state[:] self.solution = original_solution[:] results.sort() return results
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def phase_5(self):\n test_board_1 = board(5, 5, [1, 1], [0, 0])\n render = Render_engine('terminal', test_board_1)\n\n render.render_terminal(test_board_1)", "def cost_function_SO4(params: list):\n cost = 0\n SO4 = SO4_circuit(params[0], params[1], params[2], params[3], params[4], para...
[ "0.56203735", "0.5353156", "0.5339077", "0.53312033", "0.52918285", "0.52905166", "0.5248838", "0.52097756", "0.5169619", "0.51692957", "0.51207316", "0.50766826", "0.5064046", "0.5053413", "0.50450885", "0.50349313", "0.503351", "0.49939486", "0.49711737", "0.49670827", "0.4...
0.58114266
0
phase1 stages the centers on sides L and R phase2 stages the centers on sides F and B and put the LR centers in one of 495 states that can be solved without L L' R R'...this is prep work for phase 3 TODO this needs more work BLBFRUFRDDFBUULBRLBRRLDLDLFURFLUBUDRRRDDFDFBBLUFRUFFBBFBLLLDBDFBDBLFDUUFRFBLDUDDURFDRBBDFUUFUBFBDLULDLRRUDFDFULLLUUBUDRLURLBBDURFRBULBRFRBRDRRULDFLFLR results in "5x5x5 edge swaps are odd, cannot pair edges"
def group_centers_phase1_and_2(self) -> None: self.rotate_U_to_U() self.rotate_F_to_F() if self.centers_staged(): return original_state = self.state[:] original_solution = self.solution[:] tmp_solution_len = len(self.solution) # find multiple phase1 solutions phase1_solutions = self.lt_LR_centers_stage.solutions_via_c(solution_count=100) pt_state_indexes = [] pt_state_indexes_LR_centers_special = [] phase2_pt_state_indexes_to_phase1_solution = {} logger.info(f"found {len(phase1_solutions)} phase1 solutions") # find the phase2 solution for each phase1 solution for phase1_solution, (pt0_state, pt1_state, pt2_state, pt3_state, pt4_state) in phase1_solutions: self.state = original_state[:] self.solution = original_solution[:] for step in phase1_solution: self.rotate(step) # stage the LR centers phase2_pt_state_indexes = tuple([pt.state_index() for pt in self.lt_FB_centers_stage.prune_tables]) pt_state_indexes.append(phase2_pt_state_indexes) phase2_pt_state_indexes_to_phase1_solution[phase2_pt_state_indexes] = phase1_solution # stage the LR centers and put them into one of 495 states solveable with L L' R R' phase2_pt_state_indexes = tuple( [pt.state_index() for pt in self.lt_FB_centers_stage_LR_centers_special.prune_tables] ) pt_state_indexes_LR_centers_special.append(phase2_pt_state_indexes) phase2_pt_state_indexes_to_phase1_solution[phase2_pt_state_indexes] = phase1_solution self.state = original_state[:] self.solution = original_solution[:] # stage the FB centers phase2_solutions = self.lt_FB_centers_stage.solutions_via_c(pt_states=pt_state_indexes, solution_count=1) phase2_solution = phase2_solutions[0][0] # stage the FB centers and put LR centers into one of 495 states solveable with L L' R R' phase2_solutions_lr_centers_special = self.lt_FB_centers_stage_LR_centers_special.solutions_via_c( pt_states=pt_state_indexes_LR_centers_special, solution_count=1 ) phase2_solution_lr_centers_special = phase2_solutions_lr_centers_special[0][0] # if we can put the LR centers into one of 495 states without adding to the move count, make it so if len(phase2_solution_lr_centers_special) <= len(phase2_solution): min_phase2_solution, ( pt0_state, pt1_state, pt2_state, pt3_state, pt4_state, ) = phase2_solutions_lr_centers_special[0] min_phase1_solution = phase2_pt_state_indexes_to_phase1_solution[pt0_state, pt1_state, pt2_state] else: min_phase2_solution, (pt0_state, pt1_state, pt2_state, pt3_state, pt4_state) = phase2_solutions[0] min_phase1_solution = phase2_pt_state_indexes_to_phase1_solution[pt0_state, pt1_state] logger.info( f"phase2 solution length {len(phase2_solution)}, phase2_lr_centers_special solution length {len(phase2_solution_lr_centers_special)}" ) for step in min_phase1_solution: self.rotate(step) self.print_cube_add_comment("LR centers staged", tmp_solution_len) tmp_solution_len = len(self.solution) for step in min_phase2_solution: self.rotate(step) self.print_cube_add_comment("UD FB centers staged", tmp_solution_len)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def chain_corrections():\n \n #read the files\n sample_4m=read_sample(map_files('sample_4m'))\n empty_cell_4m=read_sample(map_files('empty_cell_4m'))\n empty_4m=read_sample(map_files('empty_4m'))\n transmission_sample_cell_4m=read_sample(map_files('trans_sample_4m'))\n transmission_empty_cell_...
[ "0.5802384", "0.5704981", "0.553651", "0.55297977", "0.55000675", "0.5490818", "0.53914285", "0.5377671", "0.5346241", "0.53404874", "0.5332665", "0.52918446", "0.52571434", "0.52550757", "0.52523685", "0.5244776", "0.5243008", "0.5238628", "0.5237757", "0.52282685", "0.51770...
0.7835292
0
Returns value of card. Always returns 11 for Ace.
def get_value(self): if self.rank == 'A': return 11 elif self.rank in ['J', 'Q', 'K']: return 10 else: return int(self.rank)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_card_value(self, card):\n if card >= 10:\n return 10\n if card == 1:\n return 11\n return card", "def value(self, card):\n return self.valores[self.deck.index(card)]", "def card_value (card):\r\n value = card[0]\r\n if value in ['Jack','Queen','Ki...
[ "0.8789612", "0.8161618", "0.7929443", "0.7905337", "0.76787597", "0.75404507", "0.7418031", "0.7387034", "0.7376184", "0.7270906", "0.72434753", "0.713611", "0.708218", "0.7063227", "0.6924992", "0.69160146", "0.68489075", "0.6820446", "0.6620286", "0.657642", "0.65416074", ...
0.61869216
35
Convert a column number into a column letter (3 > 'C') Right shift the column col_idx by 26 to find column letters in reverse order. These numbers are 1based, and can be converted to ASCII ordinals by adding 64.
def _get_column_letter(col_idx): # these indicies corrospond to A -> ZZZ and include all allowed # columns if not 1 <= col_idx <= 18278: raise ValueError("Invalid column index {0}".format(col_idx)) letters = [] while col_idx > 0: col_idx, remainder = divmod(col_idx, 26) # check for exact division and borrow if needed if remainder == 0: remainder = 26 col_idx -= 1 letters.append(chr(remainder+64)) return ''.join(reversed(letters))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _index_to_column(i, column=''):\n\n # A dictionary of numbers to letters starting at 0, e.g.\n # {0: 'A', 1: 'B' ...}\n num_to_alpha = {k:v for k, v in enumerate(string.ascii_uppercase, 0)}\n # If our index is divisble by 26, we need to get recursive and add\n # additional letters.\n div = i ...
[ "0.7620537", "0.74437094", "0.7439917", "0.7273949", "0.68757963", "0.6614841", "0.65894353", "0.6583816", "0.6494394", "0.64713115", "0.64713115", "0.6470613", "0.6470613", "0.6470613", "0.64606607", "0.6388831", "0.6317523", "0.6244326", "0.61555386", "0.60580075", "0.59901...
0.7847133
0
Given a head of LinkedList, delete from that linkedList index j and skip index i iterative
def skip_i_delete_j(head, i, j): if i == 0: return None if head is None or j < 0 or i < 0: return head current = head previous = None while current: # skip (i - 1) nodes for _ in range(i - 1): if current is None: return head current = current.next previous = current current = current.next # delete next j nodes for _ in range(j): if current is None: break next_node = current.next current = next_node previous.next = current return head
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def delete(self, index):\n if index == 0 and self.head is not None:\n self.head = self.head.next\n return\n\n current_index = 0\n current = self.head\n previous = None\n\n while current:\n if current_index == index:\n previous.next = current.next\n\n previous = current\n ...
[ "0.7670848", "0.7561153", "0.73862875", "0.7377517", "0.73646194", "0.73238605", "0.7250336", "0.72010875", "0.71746737", "0.71504664", "0.713762", "0.71322805", "0.7128258", "0.7071973", "0.70681566", "0.7032534", "0.69234806", "0.6903745", "0.6830704", "0.6819169", "0.68181...
0.81535465
0
Perform a context visibility test. Creates a (fake) image with the specified owner and is_public attributes, then creates a context with the given keyword arguments and expects exp_res as the result of an is_image_visible() call on the context.
def do_visible(self, exp_res, img_owner, img_public, **kwargs): img = FakeImage(img_owner, img_public) ctx = context.RequestContext(**kwargs) self.assertEqual(ctx.is_image_visible(img), exp_res)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def do_sharable(self, exp_res, img_owner, membership=None, **kwargs):\n\n img = FakeImage(img_owner, True)\n ctx = context.RequestContext(**kwargs)\n\n sharable_args = {}\n if membership is not None:\n sharable_args['membership'] = membership\n\n self.assertEqual(ctx.i...
[ "0.55633384", "0.54331094", "0.5389461", "0.5342315", "0.5338732", "0.53361624", "0.5331995", "0.53111786", "0.5263905", "0.519634", "0.5192311", "0.5132145", "0.51142937", "0.5112023", "0.50558454", "0.49886537", "0.49874082", "0.49178144", "0.47592", "0.4705346", "0.4691575...
0.7743895
0
Perform a context sharability test. Creates a (fake) image with the specified owner and is_public attributes, then creates a context with the given keyword arguments and expects exp_res as the result of an is_image_sharable() call on the context. If membership is not None, its value will be passed in as the 'membership' keyword argument of is_image_sharable().
def do_sharable(self, exp_res, img_owner, membership=None, **kwargs): img = FakeImage(img_owner, True) ctx = context.RequestContext(**kwargs) sharable_args = {} if membership is not None: sharable_args['membership'] = membership self.assertEqual(ctx.is_image_sharable(img, **sharable_args), exp_res)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_auth_sharable_can_share(self):\n self.do_sharable(True, 'pattieblack', FakeMembership(True),\n tenant='froggy')", "def do_visible(self, exp_res, img_owner, img_public, **kwargs):\n\n img = FakeImage(img_owner, img_public)\n ctx = context.RequestContext(**kwar...
[ "0.54896724", "0.54389876", "0.52578163", "0.5243541", "0.5127175", "0.50320935", "0.49899673", "0.49097702", "0.4775629", "0.47158346", "0.47047496", "0.4655331", "0.4621686", "0.46000612", "0.45601118", "0.45558378", "0.45160365", "0.4514471", "0.45083925", "0.45038795", "0...
0.8215476
0
Tests that an empty context (with is_admin set to True) can access an image with is_public set to True.
def test_empty_public(self): self.do_visible(True, None, True, is_admin=True)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def do_visible(self, exp_res, img_owner, img_public, **kwargs):\n\n img = FakeImage(img_owner, img_public)\n ctx = context.RequestContext(**kwargs)\n\n self.assertEqual(ctx.is_image_visible(img), exp_res)", "def test_aws_service_api_private_images_get(self):\n pass", "def test_aws_s...
[ "0.6889831", "0.67943805", "0.67671615", "0.6649116", "0.66382194", "0.6531554", "0.64865774", "0.6406382", "0.6406382", "0.62943596", "0.6245481", "0.62123114", "0.6179777", "0.61140406", "0.6112191", "0.6104334", "0.61026704", "0.6068213", "0.605546", "0.6054745", "0.599086...
0.65038705
6
Tests that an empty context (with is_admin set to True) can access an owned image with is_public set to True.
def test_empty_public_owned(self): self.do_visible(True, 'pattieblack', True, is_admin=True)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_empty_private_owned(self):\n self.do_visible(True, 'pattieblack', False, is_admin=True)", "def test_auth_public_unowned(self):\n self.do_visible(True, 'pattieblack', True, tenant='froggy')", "def test_should_render_for_owner_unpublished(self) -> None:\n self.assertTrue(self.action...
[ "0.68287414", "0.68124455", "0.6661694", "0.65978193", "0.6575297", "0.6509962", "0.6473352", "0.64539516", "0.6439792", "0.63888246", "0.63792306", "0.6371669", "0.6366299", "0.6361131", "0.63585526", "0.62366015", "0.6124907", "0.6047954", "0.6000606", "0.5996451", "0.59751...
0.7047812
0
Tests that an empty context (with is_admin set to True) can access an image with is_public set to False.
def test_empty_private(self): self.do_visible(True, None, False, is_admin=True)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def do_visible(self, exp_res, img_owner, img_public, **kwargs):\n\n img = FakeImage(img_owner, img_public)\n ctx = context.RequestContext(**kwargs)\n\n self.assertEqual(ctx.is_image_visible(img), exp_res)", "def test_aws_service_api_private_images_get(self):\n pass", "def test_aws_s...
[ "0.6836172", "0.6736128", "0.67086965", "0.6513356", "0.65056294", "0.6466665", "0.64133674", "0.6399818", "0.6399818", "0.63390875", "0.6302523", "0.6226055", "0.61997557", "0.6121848", "0.6118551", "0.6102106", "0.6089454", "0.6087831", "0.6057525", "0.6023837", "0.5988064"...
0.6399744
9
Tests that an empty context (with is_admin set to True) can access an owned image with is_public set to False.
def test_empty_private_owned(self): self.do_visible(True, 'pattieblack', False, is_admin=True)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_empty_public_owned(self):\n self.do_visible(True, 'pattieblack', True, is_admin=True)", "def test_auth_public_unowned(self):\n self.do_visible(True, 'pattieblack', True, tenant='froggy')", "def test_should_render_for_owner_unpublished(self) -> None:\n self.assertTrue(self.action.s...
[ "0.70528495", "0.6893526", "0.67592186", "0.6630321", "0.65318274", "0.65298545", "0.6517861", "0.65116936", "0.6454932", "0.6407351", "0.63348746", "0.63260263", "0.63152415", "0.6308235", "0.62680256", "0.62383586", "0.6053724", "0.59971654", "0.5979315", "0.59685737", "0.5...
0.6911272
1
Tests that an empty context (with is_admin set to True) can not share an image, with or without membership.
def test_empty_shared(self): self.do_sharable(False, 'pattieblack', None, is_admin=True) self.do_sharable(False, 'pattieblack', FakeMembership(True), is_admin=True)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_un_logged_in_user_can_not_upload_picture(self):\n tmp_file = generate_image_for_testing()\n response = self.client.post(self.user_passport_url,\n data={'passport': tmp_file})\n\n self.assertEqual(403, response.status_code)", "def test_auth_sharable...
[ "0.6628714", "0.65942466", "0.6389793", "0.63213843", "0.6221423", "0.6164767", "0.6150678", "0.6041313", "0.6000155", "0.5972449", "0.597103", "0.5943589", "0.59278715", "0.59188557", "0.59188557", "0.5916836", "0.59154505", "0.5850877", "0.58333635", "0.5827698", "0.5801319...
0.60693204
7
Tests that an anonymous context (with is_admin set to False) can access an image with is_public set to True.
def test_anon_public(self): self.do_visible(True, None, True)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def do_visible(self, exp_res, img_owner, img_public, **kwargs):\n\n img = FakeImage(img_owner, img_public)\n ctx = context.RequestContext(**kwargs)\n\n self.assertEqual(ctx.is_image_visible(img), exp_res)", "def test_home_as_anonymous(self):\n response = self.client.get(\"/images/cont...
[ "0.7238873", "0.6944182", "0.6944182", "0.6802116", "0.6793539", "0.6687952", "0.6679281", "0.667282", "0.65554184", "0.65371454", "0.6498809", "0.6494417", "0.6419172", "0.6416152", "0.62828475", "0.6213219", "0.61874706", "0.61568916", "0.6070943", "0.6064813", "0.6054403",...
0.60884994
18
Tests that an anonymous context (with is_admin set to False) can access an owned image with is_public set to True.
def test_anon_public_owned(self): self.do_visible(True, 'pattieblack', True)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_auth_public_owned(self):\n self.do_visible(True, 'pattieblack', True, tenant='pattieblack')", "def do_visible(self, exp_res, img_owner, img_public, **kwargs):\n\n img = FakeImage(img_owner, img_public)\n ctx = context.RequestContext(**kwargs)\n\n self.assertEqual(ctx.is_image...
[ "0.7065106", "0.6996031", "0.69618833", "0.6797919", "0.6793525", "0.67584467", "0.6624481", "0.65740824", "0.65740824", "0.6573112", "0.65594554", "0.65575325", "0.6551023", "0.6535924", "0.6526421", "0.64701694", "0.6450757", "0.6430041", "0.63988215", "0.6285752", "0.62624...
0.69320416
3
Tests that an anonymous context (with is_admin set to False) can access an unowned image with is_public set to False.
def test_anon_private(self): self.do_visible(True, None, False)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_auth_public_unowned(self):\n self.do_visible(True, 'pattieblack', True, tenant='froggy')", "def test_auth_private_unowned(self):\n self.do_visible(False, 'pattieblack', False, tenant='froggy')", "def test_home_as_anonymous(self):\n response = self.client.get(\"/images/contents/\")...
[ "0.74188906", "0.7377053", "0.7144698", "0.7144698", "0.6877964", "0.67840487", "0.676745", "0.67583287", "0.6704905", "0.6680704", "0.66680026", "0.66457", "0.663838", "0.6636891", "0.6628976", "0.6577022", "0.65723354", "0.6503181", "0.6480543", "0.6474261", "0.64629656", ...
0.6370962
24
Tests that an anonymous context (with is_admin set to False) cannot access an owned image with is_public set to False.
def test_anon_private_owned(self): self.do_visible(False, 'pattieblack', False)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_auth_public_unowned(self):\n self.do_visible(True, 'pattieblack', True, tenant='froggy')", "def test_auth_private_unowned(self):\n self.do_visible(False, 'pattieblack', False, tenant='froggy')", "def test_get_user_template_as_anonymous_with_access_right_raises_access_control_error(\n ...
[ "0.7152943", "0.7109335", "0.70072263", "0.69585896", "0.69585896", "0.68980104", "0.6817293", "0.6704428", "0.66895926", "0.64946806", "0.64736044", "0.64594865", "0.645942", "0.644374", "0.64420414", "0.6405941", "0.6374608", "0.6368752", "0.6364217", "0.6354941", "0.634457...
0.6603411
9
Tests that an empty context (with is_admin set to True) can not share an image, with or without membership.
def test_anon_shared(self): self.do_sharable(False, 'pattieblack', None) self.do_sharable(False, 'pattieblack', FakeMembership(True))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_un_logged_in_user_can_not_upload_picture(self):\n tmp_file = generate_image_for_testing()\n response = self.client.post(self.user_passport_url,\n data={'passport': tmp_file})\n\n self.assertEqual(403, response.status_code)", "def test_auth_sharable...
[ "0.6629645", "0.6598161", "0.6393106", "0.6323076", "0.62207663", "0.61628443", "0.61534476", "0.6073732", "0.6038234", "0.6002864", "0.5974506", "0.5970309", "0.5945625", "0.5925215", "0.5923474", "0.5923474", "0.59200865", "0.59187025", "0.5852431", "0.58361256", "0.5830204...
0.54502434
86
Tests that an authenticated context (with is_admin set to False) can access an image with is_public set to True.
def test_auth_public(self): self.do_visible(True, None, True, tenant='froggy')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def do_visible(self, exp_res, img_owner, img_public, **kwargs):\n\n img = FakeImage(img_owner, img_public)\n ctx = context.RequestContext(**kwargs)\n\n self.assertEqual(ctx.is_image_visible(img), exp_res)", "def test_admin_public(self):\n with self.login(self.user_admin):\n ...
[ "0.7359513", "0.6947033", "0.6891199", "0.6887777", "0.67541796", "0.66183466", "0.65862226", "0.6581423", "0.64067996", "0.6383469", "0.6383469", "0.63796556", "0.6267833", "0.6206277", "0.61293125", "0.612802", "0.6117827", "0.61051565", "0.6098563", "0.6088459", "0.6074225...
0.6749067
5
Tests that an authenticated context (with is_admin set to False) can access an image (which it does not own) with is_public set to True.
def test_auth_public_unowned(self): self.do_visible(True, 'pattieblack', True, tenant='froggy')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def do_visible(self, exp_res, img_owner, img_public, **kwargs):\n\n img = FakeImage(img_owner, img_public)\n ctx = context.RequestContext(**kwargs)\n\n self.assertEqual(ctx.is_image_visible(img), exp_res)", "def test_aws_service_api_private_images_get(self):\n pass", "def test_aws_s...
[ "0.7225246", "0.7020056", "0.7001125", "0.6687295", "0.6627152", "0.6603058", "0.6603058", "0.6587212", "0.6518558", "0.6515378", "0.64673233", "0.63507557", "0.63226664", "0.63195735", "0.6267392", "0.6243786", "0.6220447", "0.62151307", "0.6181711", "0.61252385", "0.6124277...
0.6331947
12
Tests that an authenticated context (with is_admin set to False) can access an image (which it does own) with is_public set to True.
def test_auth_public_owned(self): self.do_visible(True, 'pattieblack', True, tenant='pattieblack')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def do_visible(self, exp_res, img_owner, img_public, **kwargs):\n\n img = FakeImage(img_owner, img_public)\n ctx = context.RequestContext(**kwargs)\n\n self.assertEqual(ctx.is_image_visible(img), exp_res)", "def test_aws_service_api_private_image_get(self):\n pass", "def test_aws_se...
[ "0.73359025", "0.69640315", "0.6943459", "0.6736147", "0.6731248", "0.65971106", "0.65788954", "0.6512353", "0.6501864", "0.6422808", "0.63721627", "0.63721627", "0.6363177", "0.6315687", "0.6243033", "0.6159482", "0.6147465", "0.6144617", "0.6143973", "0.6141446", "0.6107203...
0.64223385
10
Tests that an authenticated context (with is_admin set to False) can access an image with is_public set to False.
def test_auth_private(self): self.do_visible(True, None, False, tenant='froggy')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def do_visible(self, exp_res, img_owner, img_public, **kwargs):\n\n img = FakeImage(img_owner, img_public)\n ctx = context.RequestContext(**kwargs)\n\n self.assertEqual(ctx.is_image_visible(img), exp_res)", "def test_aws_service_api_private_image_get(self):\n pass", "def test_aws_se...
[ "0.7295332", "0.69605845", "0.69604754", "0.67785037", "0.66477525", "0.6625932", "0.65665686", "0.6512257", "0.65008277", "0.65008277", "0.6442916", "0.62628233", "0.62376827", "0.6148696", "0.6145751", "0.6145588", "0.61448425", "0.61161464", "0.6112119", "0.60931945", "0.6...
0.66329974
5
Tests that an authenticated context (with is_admin set to False) cannot access an image (which it does not own) with is_public set to False.
def test_auth_private_unowned(self): self.do_visible(False, 'pattieblack', False, tenant='froggy')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_no_images_unauthorized(self):\n res = self.client.get(IMAGE_URL)\n self.assertEqual(res.status_code, status.HTTP_401_UNAUTHORIZED)", "def test_unauthenticated_resource_allowed(self):\n raise NotImplementedError # FIXME", "def test_un_logged_in_user_can_not_upload_picture(self):\n...
[ "0.72276163", "0.69970745", "0.6978492", "0.68080735", "0.6803085", "0.6803085", "0.67497104", "0.6643472", "0.6630605", "0.6568257", "0.65023047", "0.64936197", "0.6412895", "0.6403637", "0.6389285", "0.6367777", "0.6367777", "0.6348167", "0.6298395", "0.6289524", "0.6269371...
0.6672808
7
Tests that an authenticated context (with is_admin set to False) can access an image (which it does own) with is_public set to False.
def test_auth_private_owned(self): self.do_visible(True, 'pattieblack', False, tenant='pattieblack')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def do_visible(self, exp_res, img_owner, img_public, **kwargs):\n\n img = FakeImage(img_owner, img_public)\n ctx = context.RequestContext(**kwargs)\n\n self.assertEqual(ctx.is_image_visible(img), exp_res)", "def test_aws_service_api_private_image_get(self):\n pass", "def test_aws_se...
[ "0.72539985", "0.70253825", "0.7010216", "0.66228914", "0.65394044", "0.652322", "0.649416", "0.649245", "0.649245", "0.6490199", "0.6474233", "0.64500856", "0.64078796", "0.6296748", "0.6282635", "0.6253098", "0.6213612", "0.61675084", "0.61526585", "0.60946745", "0.6082156"...
0.61762923
17
Tests that an authenticated context (with is_admin set to False) cannot share an image it neither owns nor is shared with it.
def test_auth_sharable(self): self.do_sharable(False, 'pattieblack', None, tenant='froggy')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_auth_sharable_cannot_share(self):\n self.do_sharable(False, 'pattieblack', FakeMembership(False),\n tenant='froggy')", "def cant_share_photo(request, ttl=None,*args, **kwargs):\n\tif ttl:\n\t\ttry:\n\t\t\tttl = int(ttl)\n\t\texcept ValueError:\n\t\t\tttl = None\n\tphoto_id...
[ "0.73269576", "0.66646326", "0.662856", "0.6424367", "0.6423024", "0.63863295", "0.62619466", "0.6225412", "0.62130284", "0.62111557", "0.62085885", "0.61964643", "0.61871755", "0.60659873", "0.6040665", "0.59974575", "0.59781015", "0.59628546", "0.5954561", "0.59475374", "0....
0.5450656
81
Tests that an authenticated context (with is_admin set to True) can share an image it neither owns nor is shared with it.
def test_auth_sharable_admin(self): self.do_sharable(True, 'pattieblack', None, tenant='froggy', is_admin=True)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_auth_sharable_cannot_share(self):\n self.do_sharable(False, 'pattieblack', FakeMembership(False),\n tenant='froggy')", "def ensure_share(self, context, share, share_server=None):\n pass", "def ensure_share(self, context, share, share_server=None):\r\n LOG.d...
[ "0.7128801", "0.6828019", "0.67746824", "0.67188835", "0.6670886", "0.64948475", "0.63549715", "0.63543147", "0.61875457", "0.6095076", "0.6056876", "0.60101897", "0.600731", "0.59870404", "0.59508693", "0.5939599", "0.5927158", "0.58969176", "0.58855337", "0.5838346", "0.581...
0.55289805
44
Tests that an authenticated context (with is_admin set to False) can share an image it owns, even if it is not shared with it.
def test_auth_sharable_owned(self): self.do_sharable(True, 'pattieblack', None, tenant='pattieblack')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def canShare(self):\n return False", "def test_auth_sharable_can_share(self):\n self.do_sharable(True, 'pattieblack', FakeMembership(True),\n tenant='froggy')", "def do_sharable(self, exp_res, img_owner, membership=None, **kwargs):\n\n img = FakeImage(img_owner, Tru...
[ "0.6706358", "0.6633116", "0.6622457", "0.66168797", "0.6576476", "0.6559533", "0.62385696", "0.6178727", "0.6154038", "0.60761106", "0.60420334", "0.59743327", "0.5963598", "0.58454823", "0.5845463", "0.5824839", "0.57912004", "0.5788092", "0.57464755", "0.5700856", "0.56992...
0.6179839
7
Tests that an authenticated context (with is_admin set to False) cannot share an image it does not own even if it is shared with it, but with can_share = False.
def test_auth_sharable_cannot_share(self): self.do_sharable(False, 'pattieblack', FakeMembership(False), tenant='froggy')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ensure_share(self, context, share, share_server=None):\n pass", "def ensure_share(self, context, share, share_server=None):\r\n LOG.debug(\"Ensure share.\")", "def cant_share_photo(request, ttl=None,*args, **kwargs):\n\tif ttl:\n\t\ttry:\n\t\t\tttl = int(ttl)\n\t\texcept ValueError:\n\t\t\ttt...
[ "0.6938848", "0.6857029", "0.68210304", "0.67752564", "0.6616296", "0.63722545", "0.6287799", "0.6185038", "0.61454177", "0.6070145", "0.6063103", "0.6063056", "0.59651726", "0.5954177", "0.5950448", "0.58537835", "0.5789933", "0.57651097", "0.5743968", "0.57354796", "0.57342...
0.74366206
0
Tests that an authenticated context (with is_admin set to False) can share an image it does not own if it is shared with it with can_share = True.
def test_auth_sharable_can_share(self): self.do_sharable(True, 'pattieblack', FakeMembership(True), tenant='froggy')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def ensure_share(self, context, share, share_server=None):\n pass", "def canShare(self):\n return False", "def ensure_share(self, context, share, share_server=None):\r\n LOG.debug(\"Ensure share.\")", "def test_auth_sharable_cannot_share(self):\n self.do_sharable(False, 'pattiebla...
[ "0.7160142", "0.71592975", "0.70918334", "0.70580095", "0.65058416", "0.635865", "0.6244558", "0.62139976", "0.6194017", "0.6169052", "0.61176854", "0.6066014", "0.605547", "0.59966147", "0.59790087", "0.59150696", "0.58924675", "0.5879898", "0.5861287", "0.57947785", "0.5792...
0.6919593
4
Init args with argparse
def init_args(): parser = argparse.ArgumentParser(description='Create xls for Tom') parser.add_argument('start', metavar='N', type=int, help='starting ' 'number') parser.add_argument('total_x', metavar='N', type=int, help='total number of x rows') parser.add_argument('total_y', metavar='N', type=int, help='total number of y columns') parser.add_argument('filename', metavar='NAME', default='test.csv', type=str, help='file name to write to, should end in ' 'csv') return parser.parse_args()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def init_args():\n parser = argparse.ArgumentParser(\n description=\"DeltaSherlock Client software.\")\n parser.add_argument('-v', '--version', action='version', version=VERSION)\n parser.add_argument('-c', '--config', action='store', dest='config_file',\n default='./config.i...
[ "0.79507685", "0.7793449", "0.77239007", "0.77109313", "0.76677924", "0.7543103", "0.7493199", "0.7482822", "0.7471515", "0.74647325", "0.74401", "0.73976904", "0.7346049", "0.732926", "0.7325903", "0.73169327", "0.7307563", "0.7270258", "0.72573745", "0.7214987", "0.7203224"...
0.76917267
4
loads file FILTER, returns filter matrix
def load_filter(): if not os.path.isfile(FILTER): print('no filter found, creating square grid') return [] with open(FILTER, 'r') as ff: reader = csv.reader(ff) l = list(reader) ar = numpy.asarray(l) # ar = numpy.transpose(ar, (0, 1)) # ar = numpy.flip(ar, 1) # ar = numpy.rot90(ar, k=3, axes=(0, 1)) # ar = numpy.swapaxes(ar, 0, 1) f = list(map(list, ar)) return f
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def load_filter_file(self, file_path): \n self._pop_all_self()\n self.filter_list = []\n self.file_path = file_path \n \n with codecs.open(self.file_path, 'r', encoding='cp1252') as fid: \n for k, line in enumerate(fid):\n line = line.lstrip('\\n\\r ')\n...
[ "0.66520554", "0.657589", "0.65067047", "0.64896256", "0.63868827", "0.6371127", "0.626495", "0.5997112", "0.59562635", "0.5929189", "0.59240067", "0.5835717", "0.58037555", "0.5700353", "0.56678426", "0.5623952", "0.5620478", "0.55956954", "0.5576885", "0.55100983", "0.55041...
0.7438268
0
returns boolean, whether xy is occupied in filter matrix
def filtered(filter, xy): try: x, y = xy return bool(filter[x][y]) except IndexError: return False
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def xy_occupied(xy, board):\n return True if board[xy[0]][xy[1]] else False", "def occupiedNeighbor(self, xi, yi):\n\n xmax = self.mapData.og.info.width\n ymax = self.mapData.og.info.height\n\n if self.mapData.sampled:\n # Fails on an occupied cell\n assert self.mapD...
[ "0.6924757", "0.6860181", "0.6504782", "0.6499604", "0.6476733", "0.6406629", "0.6393374", "0.63787687", "0.6288766", "0.6284607", "0.6230571", "0.62087417", "0.6196269", "0.61808234", "0.6141441", "0.612595", "0.61152285", "0.61060596", "0.60959953", "0.60850585", "0.6084111...
0.71220756
0
Do all the grunt work of the snaking values, ordering the filtered blanks, and basically all the heavy lifting
def create_matrix(totals, filter, start=0, odd=False): i = start blank = '' x, y = 0, 0 total_x, total_y = totals # matrix is represented as # # row are down # t-> 1 7 # 2 9 # 3 10 # 4 11 # 5 12 # 6 13 # Transposed with zip later matrix = [] while y < total_y: row = [] blank_pos = [] while x < total_x: # TODO: Blank all points before starting coords if bool(i % 2) != odd: # xor operator for two boolean variables blank_pos.append(x) elif filtered(filter, (x, y)): blank_pos.append(x) x += 1 continue else: row.append(i) x += 1 i += 1 if y % 2: # if odd row.reverse() for pos in blank_pos: row.insert(pos, blank) matrix.append(row) y += 1 x = 0 final = list(map(list, zip_longest(*matrix))) print('final matrix') for f in final: print(f) return final
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def order_filter(self,elements):", "def sorted_data():\n stock_data = scrape_data()\n filtered_data = list(filter(sort_func, stock_data))\n return filtered_data", "def sort_by_default(self):\n self.data.sort()", "def sorting_by_criteria(self, result):\r\n\t\tresult = sorted(result, key=lambda...
[ "0.58309174", "0.5732334", "0.55798095", "0.55124855", "0.55037796", "0.548661", "0.5477536", "0.5469715", "0.5449085", "0.5353315", "0.5303698", "0.5301049", "0.5292167", "0.5289656", "0.52799255", "0.5173217", "0.51695305", "0.5167786", "0.5151389", "0.51467687", "0.5128702...
0.0
-1
Write the matrix to a csv table
def write_out(matrix, filename): with open(filename, 'w') as csvfile: writer = csv.writer(csvfile) for r in matrix: writer.writerow(r) print(filename + ' writen!')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def generate_csv(table, header):\n with open(\"%s.csv\" % header, \"w\") as csvfile:\n for i in range(len(table)):\n for j in range(len(table[i])):\n if j != len(table[i])-1:\n tmp = table[i][j] + \",\"\n else:\n tmp = table[i...
[ "0.75623345", "0.7330622", "0.71900606", "0.71231455", "0.71107894", "0.7031687", "0.7024952", "0.70113516", "0.697658", "0.69399834", "0.6934993", "0.69087684", "0.69058", "0.6873836", "0.6852782", "0.6852024", "0.6777883", "0.676096", "0.6755106", "0.67167455", "0.6708375",...
0.76784086
0
Name a city and the country it resides in seperated by a comma.
def city_country(city, country): print(f'"{city.title()}, {country.title()}"\n')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def city_names(city, country):\n place = f\"{city}, {country}\"\n return place.title()", "def city_country(city, country):\n city_and_country = city + ', ' + country\n return city_and_country.title()", "def city_country(city_name, country_name):\n city_country_combo = city_name + ', ' + country_...
[ "0.8305632", "0.8101193", "0.80840385", "0.80514556", "0.8050137", "0.7992045", "0.79826546", "0.7955863", "0.79475707", "0.7865331", "0.7797506", "0.77545387", "0.7729826", "0.7729826", "0.7728276", "0.75599986", "0.75591683", "0.72416097", "0.7220424", "0.71964306", "0.7175...
0.760025
15
Construct a DCEL from the output of matplotlib.delaunay.delaunay.
def from_delaunay_triangulation(cls, xl, yl, triangles, circumcentres): def add_containing_face_to_dcel(): containing_face_edges = [edge for edge in dcel.edges if not edge.nxt] edge = containing_face_edges.pop() face = Face(outer_component=None, inner_components=[edge]) dcel.faces.append(face) first_edge = edge previous_edge = [ e for e in containing_face_edges if e.get_destination() == edge.origin ] edge.prev = previous_edge[0] while len(containing_face_edges) > 1: edge.incident_face = face next_edge = [ e for e in containing_face_edges if e.origin == edge.get_destination() ] edge.nxt = next_edge[0] next_edge[0].prev = edge edge = next_edge[0] containing_face_edges.remove(next_edge[0]) edge_2 = containing_face_edges.pop() edge.incident_face = face edge_2.incident_face = face edge_2.prev = edge edge_2.nxt = first_edge edge.nxt = edge_2 def add_triangle_edges(circumcentre): triangles_edges = [] for vertex_idx, origin in enumerate(triangle_vertices): # Destination of the edge in this triangle that has vertex as origin destination = triangle_vertices[(vertex_idx + 1) % 3] edge_1 = HalfEdge(origin) edge_2 = HalfEdge(destination, twin=edge_1) edge_1.twin = edge_2 edge_1 = dcel.add_edge(edge_1) edge_2.twin = edge_1 edge_2 = dcel.add_edge(edge_2) edge_1.twin = edge_2 triangles_edges.append(edge_1) triangle_face = Face(triangles_edges[0], circumcentre=list(circumcentre)) dcel.faces.append(triangle_face) # Set previous and next of the edges for edge_idx, edge in enumerate(triangles_edges): edge.nxt = triangles_edges[(edge_idx + 1) % 3] edge.prev = triangles_edges[(edge_idx + 3 - 1) % 3] edge.incident_face = triangle_face triangle_vertices[edge_idx].incident_edge = edge dcel = cls() for t_idx, t in enumerate(triangles): triangle_vertices = [ dcel.add_vertex(Vertex(x)) for x in du.get_triangle_vertices(xl, yl, t) ] add_triangle_edges(circumcentres[t_idx]) add_containing_face_to_dcel() return dcel
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _mesh(self):\n from scipy.spatial import Delaunay\n points = self.cluster.get_positions()\n delaunay = Delaunay(points)\n simplices = self._filter_max_dist_in_element(delaunay.simplices)\n delaunay.simplices = simplices\n return delaunay", "def __plot_delaunay(self, ...
[ "0.553893", "0.5346823", "0.52831537", "0.50846463", "0.49604708", "0.48745608", "0.48555076", "0.485055", "0.4848358", "0.4832407", "0.47853115", "0.47777563", "0.47689658", "0.47675616", "0.47572455", "0.474961", "0.4736425", "0.47201127", "0.4714435", "0.47010985", "0.4685...
0.5686502
0
Add an edge to DCEL if it doesn't already exists, otherwise return the existing edge.
def add_edge(self, edge): try: edge_idx = self.edges.index(edge) return self.edges[edge_idx] except Exception: self.edges.append(edge) return edge
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_edge(self, edge):\n\n add_egde = True\n for edge_this in self.edges:\n if edge_this == edge:\n add_egde = False\n\n if add_egde:\n self.edges.append(edge)\n\n return self", "def add_edge(self, edge):\n edge = set(edge)\n (vert...
[ "0.7570172", "0.7543887", "0.7385329", "0.731582", "0.7228451", "0.72140056", "0.7205442", "0.7191608", "0.7144214", "0.712575", "0.7108078", "0.7094593", "0.7083264", "0.6992474", "0.6966737", "0.6870384", "0.6825222", "0.6818147", "0.67740756", "0.67177004", "0.6700951", ...
0.81017184
0
Add vertex to DCEL if it doesn't already exists, otherwise return the existing vertex.
def add_vertex(self, vertex): try: vertex_idx = self.vertices.index(vertex) # print "{} already in {}".format(vertex, self.vertices) return self.vertices[vertex_idx] except Exception: self.vertices.append(vertex) # print "adding {} to {}".format(vertex, self.vertices) return vertex
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_vertex(self, vertex):\n if vertex.id not in self.vertices.keys():\n self.vertices[vertex.id] = vertex", "def _add_vertex(self, x, y):\n v = Vertex2(x, y)\n i = bisect(self.vertices, v)\n \n # if vertex at these coordinates exists just return it\n if le...
[ "0.7698422", "0.75747514", "0.7562474", "0.75239784", "0.7504211", "0.7403369", "0.7356343", "0.7279313", "0.71772546", "0.7124853", "0.70904213", "0.7066278", "0.7066278", "0.7043618", "0.70346177", "0.7016917", "0.69948727", "0.6946342", "0.6899464", "0.6882716", "0.6859618...
0.8166046
0
Construct a DCEL object.
def __init__(self, vertices=None, edges=None, faces=None): super(DCEL, self).__init__() self.vertices = vertices or [] self.edges = edges or [] self.faces = faces or []
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def build(*args, **kwargs):\n\n\treturn Excel(*args, **kwargs)", "def __init__(self, name=None, compile_paths=combined_path):\n Hay2011Cell.__init__(self, name=name, compile_paths=compile_paths)", "def new( self, d, x, y, dx, n='temp.grd', nd=-999.0):\n self.data = d\n self.name = n\n ...
[ "0.5953067", "0.5625412", "0.5618868", "0.5610069", "0.5567573", "0.553519", "0.5409826", "0.5340056", "0.5289628", "0.52513236", "0.52174574", "0.52136445", "0.5164729", "0.5140498", "0.5093613", "0.50666684", "0.5061276", "0.50513726", "0.5045033", "0.5029647", "0.50290495"...
0.5404663
7
Return all faces where the circumcentre is not infinity.
def get_bounded_faces(self): return [face for face in self.faces if face.is_bounded()]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def faces_only(self):\n return self._faces_only", "def get_filtered_faces(self, faces):\n filtered_faces = []\n for face in faces:\n i, j, k = face\n thresh = 100.0\n if self.get_distance_between_points(i, j) > thresh:\n continue\n e...
[ "0.6049252", "0.6032412", "0.5654293", "0.5523289", "0.55073357", "0.5405898", "0.5375053", "0.53417516", "0.52805036", "0.52619165", "0.52610266", "0.5258601", "0.5257462", "0.5247194", "0.5216561", "0.52134645", "0.5212665", "0.5200357", "0.5186478", "0.51604086", "0.515638...
0.5622148
3
Add a face to DCEL if it doesn't already exists, otherwise return the existing face.
def add_face(self, face): try: face_idx = self.faces.index(face) return self.faces[face_idx] except Exception: self.faces.append(face) return face
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def add_face(self, face):\n\n if face.uuid is None:\n face.uuid = self._generate_uuid()\n\n if face.uuid in self._faces:\n error_str = \"Trying to add an already existing face with uuid: \"\\\n + str(face.uuid)\n raise KeyError(error_str)\n\n sel...
[ "0.7516604", "0.62119764", "0.61790365", "0.5979341", "0.5872748", "0.5751965", "0.5587595", "0.539488", "0.5394591", "0.5375931", "0.53083056", "0.5234154", "0.52226603", "0.5124483", "0.5124483", "0.5102945", "0.50553864", "0.5042418", "0.5035193", "0.502191", "0.5008115", ...
0.8184843
0
Return a list of vertices that form the outer boundary of finite faces of the DCEL.
def get_outer_boundary_of_voronoi(self): edge = [edge for edge in self.edges if not edge.nxt][0] # next(obj for obj in objs if obj.val==5) first_vertex = edge.origin outer_boundary = [] while (not edge.get_destination() == first_vertex): if(edge.get_destination().is_infinity()): edge = edge.twin.nxt else: outer_boundary.append(edge) edge = edge.nxt outer_boundary.append(edge) return outer_boundary
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def GetInteriorEdgesQuad(self):\n\n if not isinstance(self.all_edges,np.ndarray):\n self.GetEdgesQuad()\n if not isinstance(self.edges,np.ndarray):\n self.GetBoundaryEdgesQuad()\n\n sorted_all_edges = np.sort(self.all_edges,axis=1)\n sorted_boundary_edges = np.sort...
[ "0.6706478", "0.6694034", "0.6630309", "0.6623699", "0.66021216", "0.65841985", "0.6554914", "0.64516014", "0.6362444", "0.63408965", "0.6277447", "0.62755173", "0.61893046", "0.6162313", "0.6147987", "0.6136316", "0.612656", "0.611977", "0.61181563", "0.610831", "0.60700697"...
0.73313373
0
Return the dual of the current DCEL.
def dual(self): def set_twins(): for edge_idx in range(0, len(dual_dcel.edges), 2): dual_dcel.edges[edge_idx].twin = dual_dcel.edges[edge_idx + 1] dual_dcel.edges[edge_idx + 1].twin = dual_dcel.edges[edge_idx] def set_next_and_previous(): for face in dual_dcel.faces: face_edges = [edge for edge in dual_dcel.edges if edge.incident_face == face] for edge in face_edges: if(not edge.get_destination().is_infinity()): edge.nxt = [e for e in face_edges if e.origin == edge.get_destination()][0] if(not edge.origin.is_infinity()): edge.prev = [e for e in face_edges if edge.origin == e.get_destination()][0] dual_dcel = DCEL() for edge in self.edges: incident_face = dual_dcel.add_face(Face(circumcentre=edge.twin.origin.as_points())) origin = dual_dcel.add_vertex(Vertex(coordinates=edge.incident_face.circumcentre)) dual_edge = HalfEdge( origin=origin, incident_face=incident_face ) incident_face.outer_component = dual_edge origin.incident_edge = dual_edge dual_dcel.edges.append(dual_edge) set_twins() set_next_and_previous() return dual_dcel
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def dual(self):\n return dual_array(self)", "def getdualobj(self,whichsol_):\n dualobj_ = ctypes.c_double()\n res = __library__.MSK_XX_getdualobj(self.__nativep,whichsol_,ctypes.byref(dualobj_))\n if res != 0:\n _,msg = self.__getlasterror(res)\n raise Error(rescode(res),msg)\n dualo...
[ "0.68338317", "0.6423258", "0.5941094", "0.5921593", "0.57853687", "0.57633495", "0.5762203", "0.57469624", "0.5682356", "0.5682002", "0.5639214", "0.5613858", "0.55889916", "0.55681217", "0.5535743", "0.5530557", "0.55077", "0.54985017", "0.5457592", "0.54481125", "0.5441906...
0.6778644
1
Printfriendly representation of the DCEL object.
def __repr__(self): return ( '<DCEL (' 'vertices:\n {obj.vertices},\n' 'edges:\n {obj.edges},\n' 'faces:\n {obj.faces}>'.format(obj=self) )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __repr__(self):\n cls = self.__class__.__name__\n return '%s(%s)' % (cls, repr(self.d))", "def __str__(self):\n result=\"curv %f d0 %f z0 %f ctheta %f phi %f barcode %d\"%(self.curv,self.d0,self.z0,self.ctheta,self.phi,self.barcode)\n return result", "def printObj(self):\n ...
[ "0.71572053", "0.70599174", "0.70522857", "0.69488704", "0.69239604", "0.6836956", "0.6819858", "0.6812137", "0.6802802", "0.6789431", "0.6776764", "0.6766797", "0.6753627", "0.6751448", "0.6745186", "0.67189395", "0.6699513", "0.6692117", "0.6681709", "0.6676318", "0.6663971...
0.74030674
0
Read the VQE convergence data for the mini BMN model from disk
def read_data( optimizer: str, p: dict, ): filename = f"{p['f']}_l{p['l']}_convergence_{optimizer}_{p['v']}_depth{p['d']}_reps{p['n']}_max{p['m']}.{p['s']}" if not os.path.isfile(filename): print(f"{filename} does not exist.") sys.exit() if p['s'] == 'h5': df = pd.read_hdf(filename, "vqe") if p['s'] == 'gz': df = pd.read_pickle(filename) return df[df.counts<=p['m']]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def read_models():\n model_files_cvd = np.sort(glob.glob(\"./grad_results/cvd*N1024_f0003.npy\"))\n model_files_mnist = np.sort(glob.glob(\"./grad_results/mnist*N25000_f02.npy\"))\n\n model_files_cvd = np.array([model_files_cvd[2], model_files_cvd[1], model_files_cvd[0]])\n\n results_cvd = []\n resu...
[ "0.590859", "0.5844918", "0.5836278", "0.57506764", "0.5689922", "0.565109", "0.5614794", "0.55639184", "0.55183434", "0.5517771", "0.5503399", "0.5463083", "0.5459767", "0.54251224", "0.5416442", "0.5392664", "0.5355077", "0.53432804", "0.5338355", "0.53167695", "0.53060263"...
0.0
-1
Read the VQE convergence data for the mini BMN model from disk
def collect_data( optimizers: list, p: dict, ): # concatenate the results from all files frames = [read_data(o, p) for o in optimizers] return pd.concat(frames, keys=optimizers, names=["Optimizer"])
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def read_models():\n model_files_cvd = np.sort(glob.glob(\"./grad_results/cvd*N1024_f0003.npy\"))\n model_files_mnist = np.sort(glob.glob(\"./grad_results/mnist*N25000_f02.npy\"))\n\n model_files_cvd = np.array([model_files_cvd[2], model_files_cvd[1], model_files_cvd[0]])\n\n results_cvd = []\n resu...
[ "0.5908623", "0.58457416", "0.583959", "0.5752228", "0.56917495", "0.5652151", "0.56139976", "0.55662304", "0.5519502", "0.5518119", "0.550503", "0.54647243", "0.54624826", "0.54254407", "0.5418097", "0.53947306", "0.5358178", "0.53448343", "0.53399765", "0.53206843", "0.5307...
0.0
-1
Read the VQE convergence data for the mini BMN model from disk
def plot_convergence( optimizers: list = ["COBYLA", "SLSQP", "L-BFGS-B", "NELDER-MEAD"], g2N: float = 0.2, maxit: int = 10000, varform: list = ["ry"], depth: int = 3, nrep: int = 10, dataprefix: str = "data/miniBMN", datasuffix: str = "h5", figprefix: str = "figures/miniBMN", ht: float = 0.0, up: int = 1000, ): # setup parameters params = dict() params["l"] = str(g2N).replace(".", "") params["d"] = depth params["v"] = "-".join(varform) params["m"] = maxit params["n"] = nrep params["f"] = dataprefix params["s"] = datasuffix assert type(optimizers).__name__ == "list" # collect data result = collect_data(optimizers, params) # get best runs gs = dict() for r in optimizers: gs[r] = result.loc[r].groupby("rep").apply(min).energy gsdf = pd.DataFrame.from_dict(gs, dtype=float) print(gsdf.describe().T[["min", "max", "mean", "std"]]) # Plot # select the best runs for each optimizer fig, ax = plt.subplots() for o in optimizers: result.loc[o, gsdf[o].idxmin()].plot( x="counts", y="energy", xlim=[0, up], label=o, ax=ax ) ax.axhline(ht, c="k", ls="--", lw="2", label="HT") ax.set_xlabel("iterations") ax.set_ylabel("VQE energy") ax.legend(loc="upper right") filename = f"{figprefix}_l{params['l']}_convergence_{params['v']}_depth{params['d']}_nr{params['n']}_max{params['m']}_xlim{up}" plt.savefig(f"{filename}.pdf") plt.savefig(f"{filename}.png") plt.savefig(f"{filename}.svg") plt.close()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def read_models():\n model_files_cvd = np.sort(glob.glob(\"./grad_results/cvd*N1024_f0003.npy\"))\n model_files_mnist = np.sort(glob.glob(\"./grad_results/mnist*N25000_f02.npy\"))\n\n model_files_cvd = np.array([model_files_cvd[2], model_files_cvd[1], model_files_cvd[0]])\n\n results_cvd = []\n resu...
[ "0.590859", "0.5844918", "0.5836278", "0.57506764", "0.5689922", "0.565109", "0.5614794", "0.55639184", "0.55183434", "0.5517771", "0.5503399", "0.5463083", "0.5459767", "0.54251224", "0.5416442", "0.5392664", "0.5355077", "0.53432804", "0.5338355", "0.53167695", "0.53060263"...
0.0
-1
Store the camera intrinsics. We need this for the calibration matrices from the Tango
def new_camera_intrinsics_callback(self, new_camera_info): self.camera_intrinsics = new_camera_info self.k_mat = np.matrix( np.array(self.camera_intrinsics.K).reshape((3, 3)) ) self.k_inv = self.k_mat.I
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def save_intrinsics(self, save_dir):\n if not osp.isfile(\n osp.join(save_dir, 'intrinsics', 'intrinsics.npy')):\n np.save(osp.join(\n save_dir, 'intrinsics', 'intrinsics'), self.camera_model.K)", "def load_extrinsics(self):\n return self.um.read_json(\"extr...
[ "0.6322945", "0.597689", "0.58319306", "0.5828599", "0.57685983", "0.5751193", "0.57245207", "0.5624981", "0.55312103", "0.550769", "0.55075365", "0.5502988", "0.54702735", "0.54578793", "0.53877527", "0.5327595", "0.53023946", "0.5278144", "0.5220536", "0.5179092", "0.516386...
0.6199243
1
Take keypoint motion data from other node and process it
def new_motion_callback(self, new_motion_msg): # we can't do anything until we have the camera calibration if self.camera_intrinsics is None: # TOmaybeDO: use a wait_for_message instead of missing a frame? return previous_kp = np.stack( (new_motion_msg.prev_x, new_motion_msg.prev_y), axis=1 ) current_kp = np.stack( (new_motion_msg.cur_x, new_motion_msg.cur_y), axis=1 ) f_mat = self.calculate_fundamental_matrix(previous_kp, current_kp) camera_matrix, R_mat, t_mat = self.manually_calculate_pose(f_mat) error_amount, triangulated = self.triangulation( previous_kp, current_kp, self.base_transformation_mat, camera_matrix ) # print np.linalg.norm(np.array(error_amount)) for p in triangulated: print p self.pub_point_cloud.publish( header=Header( stamp=rospy.Time.now(), # TODO: use camera image time frame_id='map' ), points=[Point32(p[0], p[1], p[2]) for p in triangulated] ) # get quaternion from rotation matrix tf_rot = np.identity(4) tf_rot[0:3, 0:3] = R_mat quat = tf.transformations.quaternion_from_matrix(tf_rot) old_quat = self.accumulated_pose.orientation new_quat = tf.transformations.quaternion_multiply( [old_quat.x, old_quat.y, old_quat.z, old_quat.w], quat ) normalized_new_quat = tf.transformations.quaternion_from_euler( *tf.transformations.euler_from_quaternion(new_quat) ) print normalized_new_quat self.accumulated_pose.orientation = Quaternion( *normalized_new_quat ) self.pub_pose.publish( header=Header( stamp=rospy.Time.now(), # TODO: use camera image time frame_id='map' ), pose=Pose( Point( 0, 0, 0 ), self.accumulated_pose.orientation ) )
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def PTS(self):", "def dnd_motion(self, source, event):", "def motion_model(particle_poses, speed_command, odom_pose, odom_pose_prev, dt):\n \n M = particle_poses.shape[0]\n \n # TODO. For each particle calculate its predicted pose plus some\n # additive error to represent the process noise. Wi...
[ "0.5876557", "0.5821907", "0.5732931", "0.56815475", "0.56735855", "0.56616944", "0.5590481", "0.5567074", "0.54753345", "0.5468342", "0.54676706", "0.53700924", "0.5357709", "0.5344554", "0.53419507", "0.53375906", "0.5330831", "0.53234816", "0.5321119", "0.5305486", "0.5304...
0.5297739
21
Returns a point cloud
def triangulation(self, kp_a, kp_b, cam_a, cam_b): reproj_error = [] point_cloud = [] for i in range(len(kp_a)): # convert to normalized homogeneous coordinates kp = kp_a[i] u = np.array([kp[0], kp[1], 1.0]) mat_um = self.k_inv * np.matrix(u).T u = np.array(mat_um[:, 0]) kp_ = kp_b[i] u_ = np.array([kp_[0], kp_[1], 1.0]) mat_um_ = self.k_inv * np.matrix(u_).T u_ = np.array(mat_um_[:, 0]) # now we triangulate! x = self.linear_ls_triangulation( u, cam_a, u_, cam_b ) point_cloud.append(x.flatten()) # calculate reprojection error # reproject to other img x_for_camera = np.matrix( np.append(x, [[1.0]], axis=0) ) x_pt_img = np.array(self.k_mat * cam_b * x_for_camera).flatten() x_pt_img_ = np.array([ x_pt_img[0] / x_pt_img[2], x_pt_img[1] / x_pt_img[2] ]) # check error in matched keypoint reproj_error.append( np.linalg.norm(x_pt_img_ - kp_) ) return reproj_error, point_cloud
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def point_cloud(self):\n\t\tgen = self.loop(point_cloud=True)\n\t\tpoint_cloud = next(gen)\n\t\treturn point_cloud", "def convertcloud(points):\n pcd = open3d.geometry.PointCloud()\n pcd.points = open3d.utility.Vector3dVector(points)\n return pcd", "def as_point_cloud(self):\n far = 1000.0 # m...
[ "0.8203496", "0.77815324", "0.7489397", "0.743419", "0.7415985", "0.7225747", "0.708484", "0.7042392", "0.6747202", "0.6592699", "0.6537746", "0.65085596", "0.6495195", "0.6450036", "0.64452165", "0.64442986", "0.64307445", "0.6306346", "0.62692606", "0.6268943", "0.6201976",...
0.0
-1
Python version of Mastering Opencv With Practical Computer Vision Projects' LST implementation on page 144
def linear_ls_triangulation(self, point_a, cam_a, point_b, cam_b): # build A matrix # import pdb; pdb.set_trace() point_a = point_a.flatten() point_b = point_b.flatten() mat_a = np.matrix([ [point_a[0]*cam_a[2, 0]-cam_a[0, 0], point_a[0]*cam_a[2, 1]-cam_a[0, 1], point_a[0]*cam_a[2, 2]-cam_a[0, 2]], [point_a[1]*cam_a[2, 0]-cam_a[1, 0], point_a[1]*cam_a[2, 1]-cam_a[1, 1], point_a[1]*cam_a[2, 2]-cam_a[1, 2]], [point_b[0]*cam_b[2, 0]-cam_b[0, 0], point_b[0]*cam_b[2, 1]-cam_b[0, 1], point_b[0]*cam_b[2, 2]-cam_b[0, 2]], [point_b[1]*cam_b[2, 0]-cam_b[1, 0], point_b[1]*cam_b[2, 1]-cam_b[1, 1], point_b[1]*cam_b[2, 2]-cam_b[1, 2]] ]) # build B vector mat_b = np.matrix([ [-(point_a[0]*cam_a[2, 3]-cam_a[0, 3])], [-(point_a[1]*cam_a[2, 3]-cam_a[1, 3])], [-(point_b[0]*cam_b[2, 3]-cam_b[0, 3])], [-(point_b[1]*cam_b[2, 3]-cam_b[1, 3])] ]) # solve for X _, x = cv2.solve(mat_a, mat_b, None, cv2.DECOMP_SVD) return x
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def test_lk():\n\n # get current directory to work relative to current file path\n curdir = os.path.dirname(__file__)\n\n # Load configuration for system\n yaml_file = os.path.join(curdir, 'config.yaml')\n with open(yaml_file, \"r\") as f:\n config = yaml.load(f)\n\n # extract list of vide...
[ "0.6522741", "0.6153111", "0.6147058", "0.61378473", "0.61305165", "0.6099224", "0.60517925", "0.60009754", "0.5988831", "0.5987549", "0.59458303", "0.5937482", "0.59371877", "0.59214646", "0.5915029", "0.5895097", "0.5894147", "0.5874924", "0.584025", "0.58343947", "0.582210...
0.0
-1
The main run loop
def run(self): r = rospy.Rate(100) while not rospy.is_shutdown(): r.sleep()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def loop(self):\n pass", "def _run(self):\n while(self._loop):\n pass", "async def _main(self):\n while True:\n time.sleep(1)", "def run(self):\n self.cmdloop()", "def main_loop(self):\n # main loop...don't ever exit\n while True:\n # collect dat...
[ "0.8346334", "0.8201697", "0.80821764", "0.7956556", "0.7799716", "0.7637182", "0.75982195", "0.75860673", "0.75406194", "0.7487311", "0.7481487", "0.7428722", "0.73967844", "0.7389132", "0.73753315", "0.7373896", "0.7358908", "0.73579377", "0.73549044", "0.73549044", "0.7353...
0.0
-1
Add padding for unet of given depth
def _pad(x, depth=4): divisor = np.power(2, depth) remainder = x.shape[0] % divisor # no padding because already of even shape if remainder == 0: return x # add zero rows after 1D feature elif len(x.shape) == 2: return np.pad(x, [(0, divisor - remainder), (0, 0)], "constant") # add zero columns and rows after 2D feature elif len(x.shape) == 3: return np.pad(x, [(0, divisor - remainder), (0, divisor - remainder), (0, 0)], "constant")
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def space_to_depth_fixed_padding(inputs, kernel_size,\n data_format='channels_last', block_size=2):\n pad_total = kernel_size - 1\n pad_beg = (pad_total // 2 + 1) // block_size\n pad_end = (pad_total // 2) // block_size\n return _padding(inputs, (pad_beg, pad_end), data_format)"...
[ "0.66942734", "0.6406283", "0.61821586", "0.6131536", "0.5901226", "0.5837195", "0.57383364", "0.56973714", "0.56866306", "0.56743133", "0.56252444", "0.551921", "0.55042475", "0.5423706", "0.5403531", "0.54034203", "0.5395218", "0.53895396", "0.538164", "0.5379684", "0.53743...
0.69494796
0
returns a normalized url to path relative from root
def relative_url(path, root): try: url = os.path.relpath(path, root) except: error('Unable to make a relative url:', url, root) url = url.replace('\\', '/') if os.sep == '\\' else url return urllib.parse.quote(url)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def full_url(self, path):\n if path[0] == '/':\n path = path[1:]\n return urljoin(self.absolute_root, path)", "def getRootURL():", "def relative_base(base):\n return as_base(base).lstrip('/')", "def _graceful_relative_url(base_url, url):\n if url == base_url:\n return ''...
[ "0.75811696", "0.7120959", "0.7007499", "0.6957676", "0.6937742", "0.6913981", "0.6850913", "0.67784756", "0.6737724", "0.67350227", "0.67350227", "0.6698321", "0.6689216", "0.6677582", "0.6671769", "0.6658958", "0.66039646", "0.6588936", "0.65848976", "0.65747464", "0.656249...
0.7165835
1
Generate Post objects from markdown. Date must be present in each post and posts must be ordrered by date.
def parse_markdown(filename): if not os.path.exists(filename): error('File not found', filename) posts = list() with open(filename, encoding='utf-8') as f: line = next(f) if line.startswith('# '): title = line[2:].strip() record = [] next(f) else: title = None record = [line] for line in f: if not line.startswith('___'): record.append(line) else: posts.append(Post.from_markdown(record)) record = [] # set rank of posts in date daterank = defaultdict(int) for post in posts: daterank[post.date] += 1 post.daterank = daterank[post.date] # check post order for post1, post2 in zip(posts[:-1], posts[1:]): if post1.date > post2.date: error('Posts are not ordered', f'{post1.date} > {post2.date}') return title, posts
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def markdown_post(post):\n post['entry'] = markdown(post['entry'].replace(\"\\n\",\" \\n\"), output=\"html5\")\n return post", "def parse_post_text(formatted_content):\n post = {}\n # Parse Mod comments and remove them from the text.\n potential_comments = re.finditer(\"\\[.+?\\]\", formatted_con...
[ "0.6771389", "0.62583774", "0.59715056", "0.59394884", "0.59075785", "0.58579963", "0.5806396", "0.58032244", "0.57632285", "0.5762416", "0.575449", "0.5736609", "0.5716471", "0.5630635", "0.56303996", "0.55910885", "0.5574774", "0.55405563", "0.5535492", "0.55039394", "0.549...
0.7360025
0
Purge root dir from irrelevant html files
def purge_htmlfiles(args, posts): htmlist = list_of_htmlfiles(args, posts) html_to_remove = list() for fullname in glob.glob(os.path.join(args.root, '*.htm*')): if fullname not in htmlist: html_to_remove.append(fullname) if len(html_to_remove) > args.thumbnails.threshold_htmlfiles: inpt = 'x' while inpt not in 'yn': inpt = input(f'{len(html_to_remove)} html files to remove. Continue [y|n]? ').lower() if inpt == 'n': return for name in html_to_remove: print('Removing html files', name) os.remove(name)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def clean(ctx):\n ctx.run(\"rm -rf build/html\")", "def cleanup():\n download_dir = settings.DOWNLOAD_BASE_DIR\n\n for base, dirs, files in os.walk(download_dir):\n for dir in dirs:\n shutil.rmtree(download_dir + dir)", "def _cleanup_files(self):\n\n for root, dirs, files in os.walk(self.bu...
[ "0.7720015", "0.6934762", "0.68778396", "0.6763646", "0.66906065", "0.6680769", "0.668029", "0.66643465", "0.66492623", "0.6645479", "0.6635241", "0.6626942", "0.6605654", "0.65854466", "0.654416", "0.6536765", "0.6526797", "0.64898103", "0.64494216", "0.6443703", "0.6431596"...
0.72082686
1
Purge thumbnail dir from irrelevant thumbnails
def purge_thumbnails(args, thumbdir, posts, diary=False): thumblist = list_of_thumbnails(posts, diary) thumbs_to_remove = list() for fullname in glob.glob(os.path.join(thumbdir, '*.jpg')): if os.path.basename(fullname) not in thumblist: thumbs_to_remove.append(fullname) if len(thumbs_to_remove) > args.thumbnails.threshold_thumbs: inpt = 'x' while inpt not in 'yn': inpt = input(f'{len(thumbs_to_remove)} thumbnails to remove. Continue [y|n]? ').lower() if inpt == 'n': return for name in thumbs_to_remove: print('Removing thumbnail', name) os.remove(name) info_fullname = os.path.splitext(name)[0] + '.info' if os.path.exists(info_fullname): os.remove(info_fullname)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def clear_thumbnails(self):", "def delete_thumbnail(self, thumbnail_name):", "def tearDown(self):\n for fn in self.tempImages:\n os.remove(os.path.join(self.root, fn))\n os.rmdir(self.root)", "def clear_tmp_folder(self):\r\n for file in os.listdir(self.temp_dir):\r\n ...
[ "0.7496226", "0.70975465", "0.6904142", "0.6789052", "0.65433615", "0.64652795", "0.64232606", "0.6410066", "0.635366", "0.6340497", "0.63255644", "0.63222384", "0.6308864", "0.630171", "0.6284883", "0.6272671", "0.6269268", "0.62621397", "0.62551665", "0.6248571", "0.6245241...
0.7741738
0
Return the list of full paths for files in source directory
def list_of_files(sourcedir, recursive): result = list() if recursive is False: listdir = sorted_listdir(os.listdir(sourcedir)) if '.nomedia' not in listdir: for basename in listdir: result.append(os.path.join(sourcedir, basename)) else: for root, dirs, files in os.walk(sourcedir): if '.nomedia' not in files: for basename in sorted_listdir(files): result.append(os.path.join(root, basename)) return result
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_source_files(self):\n return [\n path.as_posix()\n for path in _Path(self.src_dir).rglob(\"*\")\n if not path.is_dir()\n ] + [\n (path / \"CMakeLists.txt\").as_posix()\n for path in _PurePath(self.src_dir).parents\n ]", "def coll...
[ "0.8271542", "0.77901995", "0.75900644", "0.73890495", "0.7383353", "0.7309688", "0.7303101", "0.7151451", "0.7086724", "0.70593715", "0.7048522", "0.704018", "0.6996113", "0.69825387", "0.69230485", "0.68788785", "0.6873243", "0.6849214", "0.6813808", "0.68076485", "0.678657...
0.6541307
39
Return the list of full paths for pictures and movies in source directory
def list_of_medias(args, sourcedir, recursive): files = list_of_files(sourcedir, recursive) return [_ for _ in files if is_media_within_dates(_, args.dates)]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __return_movie_file_list(self, movie_path):\n movie_dir = movie_path.rsplit(\"/\",1)[0]\n movie_file_list =[]\n movie_extentionds = self.__movie_file_extensions(self.__file_extentions)\n for x in os.listdir(movie_dir):\n if x.rsplit(\".\",1)[-1]in movie_extentionds:\n ...
[ "0.6780654", "0.664078", "0.66328037", "0.6586579", "0.6527416", "0.6516118", "0.6454078", "0.6445807", "0.6427995", "0.64033985", "0.6284854", "0.6242137", "0.62136245", "0.62066734", "0.61857104", "0.61600107", "0.61456895", "0.6120278", "0.61164725", "0.6079566", "0.607903...
0.0
-1
Return the list of full paths for pictures and movies in source directory plus subdirectories containing media
def list_of_medias_ext(args, sourcedir): result = list() listdir = sorted_listdir(os.listdir(sourcedir)) if '.nomedia' not in listdir: for basename in listdir: fullname = os.path.join(sourcedir, basename) if os.path.isdir(fullname) and basename != '$RECYCLE.BIN' and contains_media(args, fullname): result.append(fullname) else: if is_media_within_dates(fullname, args.dates): result.append(fullname) return result
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def list_of_files(sourcedir, recursive):\n result = list()\n if recursive is False:\n listdir = sorted_listdir(os.listdir(sourcedir))\n if '.nomedia' not in listdir:\n for basename in listdir:\n result.append(os.path.join(sourcedir, basename))\n else:\n for r...
[ "0.6816371", "0.6584394", "0.65694135", "0.6454687", "0.64294946", "0.63914907", "0.63858587", "0.6369066", "0.6280144", "0.62456554", "0.6161519", "0.6160253", "0.61361057", "0.61112374", "0.60726917", "0.60657465", "0.6015738", "0.60046023", "0.59833866", "0.5970308", "0.59...
0.6835324
0
/Gilles/Dev/journal/tests/subdir/deeper2/deepest/OCT_20000112_000004.jpg > deeper2_deepest_OCT_20000112_000004.jpg /Gilles/Dev/journal/tests/subdir/deeper2/deepest > deeper2_deepest
def relative_name(media_fullname, sourcedir): x = os.path.relpath(media_fullname, sourcedir) x = x.replace('\\', '_').replace('/', '_').replace('#', '_') return x
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def create_train(train_img_path):\n\n f = open(\"train.txt\", \"w+\")\n for subdirs, dirs, files in os.walk(train_img_path):\n for filename in files:\n if filename.endswith(\".jpg\"):\n train_image_path = os.path.join(train_img_path, filename)\n print(train_ima...
[ "0.6020291", "0.58817405", "0.5803224", "0.57723814", "0.57670635", "0.57295036", "0.5712866", "0.56850314", "0.56731784", "0.5619671", "0.55809706", "0.5572275", "0.5563066", "0.55071867", "0.55031073", "0.538915", "0.5343728", "0.5336606", "0.5318499", "0.53176695", "0.5316...
0.0
-1
return True if images read on file are identical, False otherwise
def compare_image_buffers(imgbuf1, imgbuf2): with io.BytesIO(imgbuf1) as imgio1, io.BytesIO(imgbuf2) as imgio2: img1 = Image.open(imgio1) img2 = Image.open(imgio2) diff = ImageChops.difference(img1, img2) return not diff.getbbox()
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __compareImage(self, file1, file2):\n # arg=self.__validateString(str_arg)\n # file1, file2=arg.split(' ', 1)\n try:\n img1 = Image.open(file1)\n img2 = Image.open(file2)\n if img1.size != img2.size:\n return False\n by1 = img1.tob...
[ "0.73973125", "0.6985823", "0.68735695", "0.6753808", "0.6718825", "0.67187357", "0.67060715", "0.66544104", "0.64797544", "0.6415226", "0.6404903", "0.6333785", "0.629946", "0.62671864", "0.6233922", "0.6232194", "0.61956316", "0.6156336", "0.60619223", "0.6051723", "0.60221...
0.57149756
64
Compose html with blogger image urls
def compose_blogger_html(args, title, posts, imgdata, online_videos): for post in posts: for media in post.medias: if type(media) is PostImage: if media.uri not in imgdata: print('Image missing: ', media.uri) else: img_url, resized_url = imgdata[media.uri] media.uri = img_url media.resized_url = resized_url elif type(media) is PostVideo: if not online_videos: print('Video missing: ', media.uri) else: media.iframe = online_videos[0] del online_videos[0] else: assert False return print_html(args, posts, title, '', target='blogger')
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def replfunc(self, match):\n url = match.group(1)\n imgformat = url.split('.')[-1]\n if url.startswith('http'):\n data = urlopen(url).read()\n elif url.startswith('data'):\n img = '<img src=\"' + url + '\" ' + match.group(2) + ' />'\n return img\n ...
[ "0.65580297", "0.6551254", "0.65510756", "0.6550227", "0.6437125", "0.6404325", "0.6345454", "0.63356936", "0.6310244", "0.6258961", "0.6221798", "0.6157185", "0.6137797", "0.60765594", "0.606654", "0.6046435", "0.60122216", "0.6008134", "0.60027015", "0.60017127", "0.5978731...
0.74483454
0
Export blogger html to clipboard. If full, export complete html, otherwise export html extract ready to paste into blogger edit mode.
def prepare_for_blogger(args): title, posts = parse_markdown(os.path.join(args.root, 'index.md')) online_images, online_videos = online_images_url(args) if args.check_images and check_images(args, posts, online_images) is False: pass html = compose_blogger_html(args, title, posts, online_images, online_videos) if args.full is False: html = re.search('<body>(.*)?</body>', html, flags=re.DOTALL).group(1) html = re.sub('<script>.*?</script>', '', html, flags=re.DOTALL) html = STYLE.replace('%%', '%') + html if args.dest: with open(args.dest, 'wt', encoding='utf-8') as f: f.write(html) else: clipboard.copy(html)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def make_backup(filename, html):\n\n with open(filename, 'wb') as f:\n f.write(html)", "def write_to_paste_buffer(txt):\n pyperclip.copy(txt)", "def clipboard(self, text = None):\n if text == None:\n response = self._fetch_json('/api/clipboard')\n return response['cont...
[ "0.5765858", "0.56113607", "0.55505186", "0.55185163", "0.54795206", "0.5450024", "0.5427715", "0.54080874", "0.5321129", "0.5313652", "0.52682567", "0.52502394", "0.52400166", "0.5201354", "0.5193638", "0.51862955", "0.51706195", "0.51384276", "0.5110709", "0.51039314", "0.5...
0.6119939
0
For testing identity between a diary file and the fle obtained after reading and printing it. See testing.
def idempotence(args): title, posts = parse_markdown(os.path.join(args.root, 'index.md')) print_markdown(posts, title, os.path.join(args.dest, 'index.md'))
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def _test_example_eda_adf():\n main([\"pnictogen/repo/split.ADF.in\", \"data/water-dimer.xyz\"])\n assert_equals(\n open(\"data/water-dimer_eda.in\").read(),\n \"\"\"TITLE data/water-dimer.xyz eda\n\nCHARGE 0 0\n\nNumber of atoms\n 6\n\nATOMS Cartesian\nO 0.12908 -0.26336 ...
[ "0.59925705", "0.59771883", "0.59220266", "0.5896933", "0.58921814", "0.58638084", "0.57837987", "0.5661089", "0.56471264", "0.56424177", "0.5633926", "0.56308526", "0.5623441", "0.5612273", "0.56118274", "0.56060433", "0.5597619", "0.55867624", "0.557899", "0.5573398", "0.55...
0.0
-1
Made before reading config file (config file located in args.root). Check and normalize root path.
def setup_part1(args): args.rootarg = args.root rootext = os.path.splitext(args.rootarg)[1] if rootext == '': pass else: args.root = os.path.dirname(args.root) if args.root: args.root = os.path.abspath(args.root) if not os.path.isdir(args.root): if args.gallery: os.mkdir(args.root) else: error('Directory not found', args.root)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_config_file(self):\n\n conf_file = self.args.file\n if conf_file is not None:\n if os.path.isfile(conf_file):\n config_file = open(conf_file, \"r\")\n self.main_file = yaml.load(config_file, Loader=yaml.FullLoader)\n elif os.path.isfile(\n ...
[ "0.6453089", "0.63893116", "0.62628293", "0.6203292", "0.61769146", "0.6169113", "0.6103033", "0.6092019", "0.60891813", "0.6075031", "0.6063229", "0.60553133", "0.60498255", "0.6032961", "0.60153127", "0.5980272", "0.59365386", "0.59269124", "0.5921976", "0.5921835", "0.5918...
0.0
-1
Made after reading config file. Check for ffmpeg in path. Create .thumbnails dir if necessary and create .nomedia in it. Copy photobox file to destination dir. Handle priority between command line and config file.
def setup_part2(args): if args.update: args.sourcedir = args.source.sourcedir args.bydir = args.source.bydir args.bydate = args.source.bydate args.diary = args.source.diary args.recursive = args.source.recursive args.dates = args.source.dates args.github_pages = args.source.github_pages elif args.gallery: args.source.sourcedir = args.sourcedir args.source.bydir = args.bydir args.source.bydate = args.bydate args.source.diary = args.diary args.source.recursive = args.recursive args.source.dates = args.dates args.source.github_pages = args.github_pages update_config(args) if args.github_pages: args.html_suffix = '.html' else: args.html_suffix = '.htm' rootext = os.path.splitext(args.rootarg)[1] if rootext: args.rootname = os.path.basename(args.rootarg) else: args.rootname = 'index' + args.html_suffix if args.sourcedir: args.sourcedir = os.path.abspath(args.sourcedir) if os.path.splitdrive(args.sourcedir)[0]: drive, rest = os.path.splitdrive(args.sourcedir) args.sourcedir = drive.upper() + rest if not os.path.isdir(args.sourcedir): error('Directory not found', args.sourcedir) else: if args.gallery and args.diary is False and args.update is None: error('Directory not found', 'Use --sourcedir') if args.dest: args.dest = os.path.abspath(args.dest) if args.dest is None: args.dest = args.root if args.blogger and args.urlblogger is None: error('No blogger url (--url)') if args.gallery or args.update: # check for ffmpeg and ffprobe in path for exe in ('ffmpeg', 'ffprobe'): try: check_output([exe, '-version']) except FileNotFoundError: error('File not found', exe) if args.github_pages: args.thumbrep = 'thumbnails' else: args.thumbrep = '.thumbnails' args.thumbdir = os.path.join(args.dest, args.thumbrep) if not os.path.exists(args.thumbdir): os.mkdir(args.thumbdir) open(os.path.join(args.thumbdir, '.nomedia'), 'a').close() favicondst = os.path.join(args.dest, 'favicon.ico') if not os.path.isfile(favicondst): faviconsrc = os.path.join(os.path.dirname(__file__), 'favicon.ico') shutil.copyfile(faviconsrc, favicondst) photoboxdir = os.path.join(args.dest, 'photobox') if not os.path.exists(photoboxdir): photoboxsrc = os.path.join(os.path.dirname(__file__), 'photobox') shutil.copytree(photoboxsrc, photoboxdir) if args.dates: if not(args.gallery or args.create): # silently ignored for the moment, otherwise all other commands will # launch a wanrning or an error on the default --dates value pass if args.dates == 'source': pass elif args.dates == 'diary': if args.create: error('Incorrect date format', args.dates) elif re.match(r'\d+-\d+', args.dates): date1, date2 = args.dates.split('-') if validate_date(date1) and validate_date(date2): args.dates = date1, date2 else: error('Incorrect date format', args.dates) else: error('Incorrect date format', args.dates)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def take_one_shot(path_to_images, name_image, video_source=\"/dev/video0\"):\n subprocess_cmd(\"ffmpeg -f video4linux2 -s 1280x720 -i {} -frames 1 ./{}/{} -loglevel error -nostats\".format(video_source, path_to_images, name_image))", "def makeVideo():\n os.system(\"cd video && ffmpeg -r 10 -i img%05d.jpg -...
[ "0.5893241", "0.57616824", "0.5529838", "0.55258685", "0.55187756", "0.55067265", "0.5499056", "0.54705536", "0.5458571", "0.5449385", "0.54415053", "0.53093326", "0.5306078", "0.53042513", "0.5287746", "0.5274733", "0.5265946", "0.5246467", "0.52405924", "0.5228054", "0.5227...
0.57895535
1
Read command line argument runtype Throws error if the choice is not correct
def parseArg(): try: parser = argparse.ArgumentParser( description='This is the Scheduler export utility') parser.add_argument('--weekofmonth', action='store', dest='weekofmonth', required=True, help='select the week of month[1-5]', type = int, choices=[1,2,3,4,5]) parser.add_argument('--dayofweek', action='store', dest='dayofweek', help='select day of week [1-7]', type=int, choices=[1,2,3,4,5,6,7]) args = parser.parse_args() global WEEK global DAY WEEK = args.weekofmonth DAY = args.dayofweek log.info("1;EME;RUNNING;000;Scheduler.py;;;;;STARTING " + os.path.basename(__file__)) schedule(WEEK, DAY) except Exception as e: log.exception("1;EME;FAILURE;700;STARTUP ERROR " + str(e), exc_info=False) sys.exit(0)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def readArgs():\n args = sys.argv\n if len(args) != 3:\n print(\"ERROR - Wrong number of arguments! \\n\")\n print(\"Usage: plotGantt.py TYPE path/to/result/file.gantt \\n where TYPE is : MTS / SCH\")\n exit(5)\n if args[1] != \"MTS\" and args[1] != \"SCH\":\n print(\"ERROR - W...
[ "0.7166374", "0.67722404", "0.6072575", "0.60625833", "0.60188425", "0.5963004", "0.593148", "0.5922895", "0.59138274", "0.5889174", "0.5888878", "0.58836305", "0.5879857", "0.58746564", "0.5859843", "0.5856361", "0.5829581", "0.58261716", "0.58230263", "0.5807125", "0.580537...
0.0
-1
Returns the week of the month for the specified date.
def week_of_month(dt): try: first_day = dt.replace(day=1) dom = dt.day if first_day.weekday() == 6: adjusted_dom = dom + day_of_week(dt) - 1 else: adjusted_dom = dom + day_of_week(dt) return int(ceil(adjusted_dom/7.0)) except Exception as e: log.exception("1;EME;FAILURE;700; FUNCTION ERROR " + str(e), exc_info=False) sys.exit(0)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def get_week_from_date(date) -> int:\n month, year = date.month, date.year\n if month < 4:\n year -= 1\n ld = _labor_day(year)\n wk1_wed = ld + timedelta(days=2)\n days_since = (date - wk1_wed).days\n weeks_since = days_since / 7.\n week = math.floor(weeks_since) + 1\n return int(wee...
[ "0.7487706", "0.7056256", "0.70537466", "0.70099276", "0.70012397", "0.6820069", "0.6787127", "0.66652584", "0.6636667", "0.651747", "0.6508568", "0.644575", "0.6422966", "0.64131665", "0.6229527", "0.6217697", "0.62044543", "0.61213183", "0.60555804", "0.6036671", "0.6029071...
0.65848774
9
Returns customized day of week as first day Default first day of week is Monday mday used to set firstweek of day
def day_of_week(dt): cday = dt mday = 2 uday = cday.isocalendar()[2] + mday try: if uday > 7: CURRDAY = uday - 7 log.debug("1;EME;RUNNING;000;Scheduler.py;Setting customized day of week>7 : ", CURRDAY) else: CURRDAY = uday log.debug("1;EME;RUNNING;000;Scheduler.py;Setting customized day of week : ", CURRDAY) return CURRDAY except Exception as e: log.exception("1;EME;FAILURE;700;SCHEDULE ERROR " + str(e), exc_info=False) sys.exit(0)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def first_day_of_week(self):\n return self.__first_day_of_week", "def locale_first_weekday():\n\tfirst_weekday = 6 #by default settle on monday\n\n\ttry:\n\t\tprocess = os.popen(\"locale first_weekday week-1stday\")\n\t\tweek_offset, week_start = process.read().split('\\n')[:2]\n\t\tprocess.close()\n\t\tw...
[ "0.7771828", "0.7742936", "0.7577031", "0.75041586", "0.74610543", "0.74022716", "0.74017537", "0.7226098", "0.715162", "0.71447414", "0.7032424", "0.69580626", "0.68952614", "0.6892024", "0.6892024", "0.6819581", "0.6817187", "0.6786361", "0.67820686", "0.67820686", "0.67739...
0.6687542
30
Returns the q'th percentile of the distribution given in the argument 'data'. Uses the 'precision' parameter to control the noise level.
def Quantile(data, q, precision=1.0): N, bins = np.histogram(data, bins=precision*np.sqrt(len(data))) norm_cumul = 1.0*N.cumsum() / len(data) for i in range(0, len(norm_cumul)): if norm_cumul[i] > q: return bins[i]
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def Quartiles(data):\n q = np.percentile(data, [25, 50, 75])\n\n return q[0], q[1], q[2]", "def test__quantile(self):\r\n # regular cases\r\n sample_data = array(range(25, 42))\r\n assert_almost_equal(_quantile(sample_data, 0.5), median(sample_data))\r\n\r\n # sorted data is ass...
[ "0.72270185", "0.7012418", "0.6803648", "0.67029893", "0.67029893", "0.669614", "0.6685391", "0.65556973", "0.65500534", "0.65500534", "0.65500534", "0.64803755", "0.64564687", "0.64286137", "0.64046985", "0.6381233", "0.6363074", "0.636056", "0.6354891", "0.63055617", "0.626...
0.7864236
0
Downloads a YouTube video by its unique id.
def youtube_download_by_id(id, title=None, output_dir='.', merge=True, info_only=False): raw_video_info = get_content('http://www.youtube.com/get_video_info?video_id=%s' % id) video_info = parse.parse_qs(raw_video_info) if video_info['status'] == ['ok'] and ('use_cipher_signature' not in video_info or video_info['use_cipher_signature'] == ['False']): title = parse.unquote_plus(video_info['title'][0]) stream_list = parse.parse_qs(raw_video_info)['url_encoded_fmt_stream_map'][0].split(',') else: # Parse video page when video_info is not usable. video_page = get_content('http://www.youtube.com/watch?v=%s' % id) ytplayer_config = json.loads(match1(video_page, r'ytplayer.config\s*=\s*([^\n]+);')) title = ytplayer_config['args']['title'] stream_list = ytplayer_config['args']['url_encoded_fmt_stream_map'].split(',') streams = { parse.parse_qs(stream)['itag'][0] : parse.parse_qs(stream) for stream in stream_list } for codec in yt_codecs: itag = str(codec['itag']) if itag in streams: download_stream = streams[itag] break url = download_stream['url'][0] if 'sig' in download_stream: sig = download_stream['sig'][0] else: sig = decrypt_signature(download_stream['s'][0]) url = '%s&signature=%s' % (url, sig) type, ext, size = url_info(url) print_info(site_info, title, type, size) if not info_only: download_urls([url], title, ext, size, output_dir, merge = merge)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def download(idd, path):\n print(f'[{script}]: Downloading YT video \"{idd}\"...') if verbosity >= 1 else None\n\n try:\n yt = pytube.YouTube(\"https://www.youtube.com/watch?v=\" + idd)\n stream = yt.streams.filter(progressive=True).first()\n stream.download(path, filename=idd)\n exce...
[ "0.7745084", "0.7303579", "0.7203833", "0.71133363", "0.70373094", "0.7022766", "0.69767386", "0.6973098", "0.69691336", "0.69578743", "0.69145817", "0.6872059", "0.68037355", "0.6796082", "0.6795651", "0.67516667", "0.6571322", "0.6560047", "0.65302217", "0.65141547", "0.651...
0.7562303
1
Downloads YouTube videos by URL.
def youtube_download(url, output_dir='.', merge=True, info_only=False): id = match1(url, r'youtu.be/([^/]+)') or parse_query_param(url, 'v') assert id youtube_download_by_id(id, title=None, output_dir=output_dir, merge=merge, info_only=info_only)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def download_video(self, url):\n yt = YouTube(url)\n yt_filtered = yt.streams.filter(progressive=True, file_extension=\"mp4\")\n yt_resolutions = yt_filtered.order_by(\"resolution\")\n\n # Downloads the first video that fits the description\n video = yt_resolutions.desc().first()...
[ "0.7559332", "0.7511336", "0.7269561", "0.7109881", "0.69188035", "0.6849369", "0.6837979", "0.67307305", "0.67147034", "0.6699649", "0.6661852", "0.6603577", "0.6570227", "0.6545135", "0.65282965", "0.6528034", "0.6490521", "0.64205855", "0.63792336", "0.63700604", "0.634333...
0.7409529
2
Check that user_data is a dict and that key is in there
def has_user_data(self, key): return isinstance(self._user_data, dict) and key in self._user_data
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def check_for_dict(check):", "def is_valid(data):\n return isinstance(data, dict) \\\n and \"u_id\" in data \\\n and \"token\" in data \\\n and isinstance(data[\"u_id\"], int) \\\n and isinstance(data[\"token\"], str)", "def can_insert(data):\n return isinstanc...
[ "0.719985", "0.7077056", "0.6867152", "0.6618034", "0.6470574", "0.63971496", "0.63777405", "0.63742024", "0.63429755", "0.63425326", "0.62384546", "0.6238243", "0.61970216", "0.6187313", "0.6175904", "0.61512995", "0.6139445", "0.6129756", "0.610137", "0.6098412", "0.6043313...
0.75419945
0
Return key from user_data if it's a dict
def get_user_data(self, key, default=None): if not isinstance(self._user_data, dict): return default return self._user_data.get(key)
{ "objective": { "self": [], "paired": [], "triplet": [ [ "query", "document", "negatives" ] ] } }
[ "def __getitem__(self, key):\n return self._user_data.get(key)", "def _get_user_data(self):\n return {\"key\": self._key}", "def get(self, key):\n return self._user_data.get(key)", "def _get_key(self, object_type, user_key = None):\n\t\tif not user_key and not self.object_type_keys.has_ke...
[ "0.6847286", "0.65308297", "0.6454429", "0.63964266", "0.6262093", "0.618459", "0.61062187", "0.60399806", "0.59043604", "0.5890058", "0.5878438", "0.5858267", "0.5846593", "0.58453906", "0.5799683", "0.57730305", "0.57642144", "0.57528245", "0.5742863", "0.5742863", "0.57288...
0.6621438
1