body
stringlengths
26
98.2k
body_hash
int64
-9,222,864,604,528,158,000
9,221,803,474B
docstring
stringlengths
1
16.8k
path
stringlengths
5
230
name
stringlengths
1
96
repository_name
stringlengths
7
89
lang
stringclasses
1 value
body_without_docstring
stringlengths
20
98.2k
def autocontrast(image): 'Implements Autocontrast function from PIL using TF ops.' def scale_channel(channel): 'Scale the 2D image using the autocontrast rule.' lo = tf.cast(tf.reduce_min(channel), tf.float32) hi = tf.cast(tf.reduce_max(channel), tf.float32) def scale_values(im...
-809,971,772,111,610,000
Implements Autocontrast function from PIL using TF ops.
third_party/augment_ops.py
autocontrast
google-research/crest
python
def autocontrast(image): def scale_channel(channel): 'Scale the 2D image using the autocontrast rule.' lo = tf.cast(tf.reduce_min(channel), tf.float32) hi = tf.cast(tf.reduce_max(channel), tf.float32) def scale_values(im): scale = (255.0 / (hi - lo)) of...
def autocontrast_blend(image, factor): 'Implements blend of autocontrast with original image.' return blend(autocontrast(image), image, factor)
837,949,824,050,951,700
Implements blend of autocontrast with original image.
third_party/augment_ops.py
autocontrast_blend
google-research/crest
python
def autocontrast_blend(image, factor): return blend(autocontrast(image), image, factor)
def sharpness(image, factor): 'Implements Sharpness function from PIL using TF ops.' orig_im = image image = tf.cast(image, tf.float32) image = tf.expand_dims(image, 0) kernel = (tf.constant([[1, 1, 1], [1, 5, 1], [1, 1, 1]], dtype=tf.float32, shape=[3, 3, 1, 1]) / 13.0) kernel = tf.tile(kernel,...
-2,921,100,399,587,338,000
Implements Sharpness function from PIL using TF ops.
third_party/augment_ops.py
sharpness
google-research/crest
python
def sharpness(image, factor): orig_im = image image = tf.cast(image, tf.float32) image = tf.expand_dims(image, 0) kernel = (tf.constant([[1, 1, 1], [1, 5, 1], [1, 1, 1]], dtype=tf.float32, shape=[3, 3, 1, 1]) / 13.0) kernel = tf.tile(kernel, [1, 1, 3, 1]) strides = [1, 1, 1, 1] degenera...
def equalize(image): 'Implements Equalize function from PIL using TF ops.' def scale_channel(im, c): 'Scale the data in the channel to implement equalize.' im = tf.cast(im[:, :, c], tf.int32) histo = tf.histogram_fixed_width(im, [0, 255], nbins=256) nonzero = tf.where(tf.not_equ...
-4,360,158,787,895,066,600
Implements Equalize function from PIL using TF ops.
third_party/augment_ops.py
equalize
google-research/crest
python
def equalize(image): def scale_channel(im, c): 'Scale the data in the channel to implement equalize.' im = tf.cast(im[:, :, c], tf.int32) histo = tf.histogram_fixed_width(im, [0, 255], nbins=256) nonzero = tf.where(tf.not_equal(histo, 0)) nonzero_histo = tf.reshape(tf.g...
def equalize_blend(image, factor): 'Implements blend of equalize with original image.' return blend(equalize(image), image, factor)
-6,565,587,435,892,967,000
Implements blend of equalize with original image.
third_party/augment_ops.py
equalize_blend
google-research/crest
python
def equalize_blend(image, factor): return blend(equalize(image), image, factor)
def blur(image, factor): 'Blur with the same kernel as ImageFilter.BLUR.' blur_kernel = (tf.constant([[1.0, 1.0, 1.0, 1.0, 1.0], [1.0, 0.0, 0.0, 0.0, 1.0], [1.0, 0.0, 0.0, 0.0, 1.0], [1.0, 0.0, 0.0, 0.0, 1.0], [1.0, 1.0, 1.0, 1.0, 1.0]], dtype=tf.float32, shape=[5, 5, 1, 1]) / 16.0) blurred_im = _convolve_i...
1,411,185,370,369,190,700
Blur with the same kernel as ImageFilter.BLUR.
third_party/augment_ops.py
blur
google-research/crest
python
def blur(image, factor): blur_kernel = (tf.constant([[1.0, 1.0, 1.0, 1.0, 1.0], [1.0, 0.0, 0.0, 0.0, 1.0], [1.0, 0.0, 0.0, 0.0, 1.0], [1.0, 0.0, 0.0, 0.0, 1.0], [1.0, 1.0, 1.0, 1.0, 1.0]], dtype=tf.float32, shape=[5, 5, 1, 1]) / 16.0) blurred_im = _convolve_image_with_kernel(image, blur_kernel) return ...
def smooth(image, factor): 'Smooth with the same kernel as ImageFilter.SMOOTH.' smooth_kernel = (tf.constant([[1.0, 1.0, 1.0], [1.0, 5.0, 1.0], [1.0, 1.0, 1.0]], dtype=tf.float32, shape=[3, 3, 1, 1]) / 13.0) smoothed_im = _convolve_image_with_kernel(image, smooth_kernel) return blend(image, smoothed_im,...
-3,157,272,762,969,639,400
Smooth with the same kernel as ImageFilter.SMOOTH.
third_party/augment_ops.py
smooth
google-research/crest
python
def smooth(image, factor): smooth_kernel = (tf.constant([[1.0, 1.0, 1.0], [1.0, 5.0, 1.0], [1.0, 1.0, 1.0]], dtype=tf.float32, shape=[3, 3, 1, 1]) / 13.0) smoothed_im = _convolve_image_with_kernel(image, smooth_kernel) return blend(image, smoothed_im, factor)
def rescale(image, level): 'Rescales image and enlarged cornet.' size = image.shape[:2] scale = (level * 0.25) scale_height = tf.cast((scale * size[0]), tf.int32) scale_width = tf.cast((scale * size[1]), tf.int32) cropped_image = tf.image.crop_to_bounding_box(image, offset_height=scale_height, o...
6,311,872,618,237,034,000
Rescales image and enlarged cornet.
third_party/augment_ops.py
rescale
google-research/crest
python
def rescale(image, level): size = image.shape[:2] scale = (level * 0.25) scale_height = tf.cast((scale * size[0]), tf.int32) scale_width = tf.cast((scale * size[1]), tf.int32) cropped_image = tf.image.crop_to_bounding_box(image, offset_height=scale_height, offset_width=scale_width, target_heigh...
def scale_channel(channel): 'Scale the 2D image using the autocontrast rule.' lo = tf.cast(tf.reduce_min(channel), tf.float32) hi = tf.cast(tf.reduce_max(channel), tf.float32) def scale_values(im): scale = (255.0 / (hi - lo)) offset = ((- lo) * scale) im = ((tf.cast(im, tf.float...
899,198,447,933,424,800
Scale the 2D image using the autocontrast rule.
third_party/augment_ops.py
scale_channel
google-research/crest
python
def scale_channel(channel): lo = tf.cast(tf.reduce_min(channel), tf.float32) hi = tf.cast(tf.reduce_max(channel), tf.float32) def scale_values(im): scale = (255.0 / (hi - lo)) offset = ((- lo) * scale) im = ((tf.cast(im, tf.float32) * scale) + offset) return tf.saturate...
def scale_channel(im, c): 'Scale the data in the channel to implement equalize.' im = tf.cast(im[:, :, c], tf.int32) histo = tf.histogram_fixed_width(im, [0, 255], nbins=256) nonzero = tf.where(tf.not_equal(histo, 0)) nonzero_histo = tf.reshape(tf.gather(histo, nonzero), [(- 1)]) step = ((tf.red...
6,353,019,026,156,998,000
Scale the data in the channel to implement equalize.
third_party/augment_ops.py
scale_channel
google-research/crest
python
def scale_channel(im, c): im = tf.cast(im[:, :, c], tf.int32) histo = tf.histogram_fixed_width(im, [0, 255], nbins=256) nonzero = tf.where(tf.not_equal(histo, 0)) nonzero_histo = tf.reshape(tf.gather(histo, nonzero), [(- 1)]) step = ((tf.reduce_sum(nonzero_histo) - nonzero_histo[(- 1)]) // 255)...
def get_author_name(soup): "Get the author's name from its main page.\n\n Args:\n soup (bs4.element.Tag): connection to the author page.\n\n Returns:\n string: name of the author.\n\n Examples::\n >>> from scrapereads import connect\n >>> url = 'https://www.goodreads.com/author/...
-2,567,605,535,743,929,300
Get the author's name from its main page. Args: soup (bs4.element.Tag): connection to the author page. Returns: string: name of the author. Examples:: >>> from scrapereads import connect >>> url = 'https://www.goodreads.com/author/show/1077326' >>> soup = connect(url) >>> get_author_name(soup...
scrapereads/scrape.py
get_author_name
arthurdjn/scrape-goodreads
python
def get_author_name(soup): "Get the author's name from its main page.\n\n Args:\n soup (bs4.element.Tag): connection to the author page.\n\n Returns:\n string: name of the author.\n\n Examples::\n >>> from scrapereads import connect\n >>> url = 'https://www.goodreads.com/author/...
def get_author_desc(soup): "Get the author description / biography.\n\n Args:\n soup (bs4.element.Tag): connection to the author page.\n\n Returns:\n str: long description of the author.\n\n Examples::\n >>> from scrapereads import connect\n >>> url = 'https://www.goodreads.com/...
-7,998,133,341,309,047,000
Get the author description / biography. Args: soup (bs4.element.Tag): connection to the author page. Returns: str: long description of the author. Examples:: >>> from scrapereads import connect >>> url = 'https://www.goodreads.com/author/show/1077326' >>> soup = connect(url) >>> get_author_de...
scrapereads/scrape.py
get_author_desc
arthurdjn/scrape-goodreads
python
def get_author_desc(soup): "Get the author description / biography.\n\n Args:\n soup (bs4.element.Tag): connection to the author page.\n\n Returns:\n str: long description of the author.\n\n Examples::\n >>> from scrapereads import connect\n >>> url = 'https://www.goodreads.com/...
def get_author_info(soup): 'Get all information from an author (genres, influences, website etc.).\n\n Args:\n soup (bs4.element.Tag): author page connection.\n\n Returns:\n dict\n\n ' container = soup.find('div', attrs={'class': 'rightContainer'}) author_info = {} data_div = cont...
-19,904,277,778,161,580
Get all information from an author (genres, influences, website etc.). Args: soup (bs4.element.Tag): author page connection. Returns: dict
scrapereads/scrape.py
get_author_info
arthurdjn/scrape-goodreads
python
def get_author_info(soup): 'Get all information from an author (genres, influences, website etc.).\n\n Args:\n soup (bs4.element.Tag): author page connection.\n\n Returns:\n dict\n\n ' container = soup.find('div', attrs={'class': 'rightContainer'}) author_info = {} data_div = cont...
def scrape_quotes_container(soup): 'Get the quote container from a quote page.\n\n Args:\n soup (bs4.element.Tag): connection to the quote page.\n\n Returns:\n bs4.element.Tag\n\n ' return soup.findAll('div', attrs={'class': 'quotes'})
-2,257,911,790,353,518,800
Get the quote container from a quote page. Args: soup (bs4.element.Tag): connection to the quote page. Returns: bs4.element.Tag
scrapereads/scrape.py
scrape_quotes_container
arthurdjn/scrape-goodreads
python
def scrape_quotes_container(soup): 'Get the quote container from a quote page.\n\n Args:\n soup (bs4.element.Tag): connection to the quote page.\n\n Returns:\n bs4.element.Tag\n\n ' return soup.findAll('div', attrs={'class': 'quotes'})
def scrape_quotes(soup): 'Retrieve all ``<div>`` quote element from a quote page.\n\n Args:\n soup (bs4.element.Tag): connection to the quote page.\n\n Returns:\n yield bs4.element.Tag\n\n ' for container_div in scrape_quotes_container(soup): quote_div = container_div.find('div', ...
3,836,355,887,043,983,400
Retrieve all ``<div>`` quote element from a quote page. Args: soup (bs4.element.Tag): connection to the quote page. Returns: yield bs4.element.Tag
scrapereads/scrape.py
scrape_quotes
arthurdjn/scrape-goodreads
python
def scrape_quotes(soup): 'Retrieve all ``<div>`` quote element from a quote page.\n\n Args:\n soup (bs4.element.Tag): connection to the quote page.\n\n Returns:\n yield bs4.element.Tag\n\n ' for container_div in scrape_quotes_container(soup): quote_div = container_div.find('div', ...
def get_quote_text(quote_div): 'Get the text from a ``<div>`` quote element.\n\n Args:\n quote_div (bs4.element.Tag): ``<div>`` quote element to extract the text.\n\n Returns:\n string\n\n ' quote_text = '' text_iterator = quote_div.find('div', attrs={'class': 'quoteText'}).children ...
1,677,841,520,926,764,300
Get the text from a ``<div>`` quote element. Args: quote_div (bs4.element.Tag): ``<div>`` quote element to extract the text. Returns: string
scrapereads/scrape.py
get_quote_text
arthurdjn/scrape-goodreads
python
def get_quote_text(quote_div): 'Get the text from a ``<div>`` quote element.\n\n Args:\n quote_div (bs4.element.Tag): ``<div>`` quote element to extract the text.\n\n Returns:\n string\n\n ' quote_text = text_iterator = quote_div.find('div', attrs={'class': 'quoteText'}).children ...
def scrape_quote_tags(quote_div): 'Scrape tags from a ``<div>`` quote element.\n\n Args:\n quote_div (bs4.element.Tag): ``<div>`` quote element from a quote page.\n\n Returns:\n yield ``<a>`` tags\n\n ' tags_container = quote_div.find('div', attrs={'class': 'greyText smallText left'}) ...
-8,704,284,436,144,329,000
Scrape tags from a ``<div>`` quote element. Args: quote_div (bs4.element.Tag): ``<div>`` quote element from a quote page. Returns: yield ``<a>`` tags
scrapereads/scrape.py
scrape_quote_tags
arthurdjn/scrape-goodreads
python
def scrape_quote_tags(quote_div): 'Scrape tags from a ``<div>`` quote element.\n\n Args:\n quote_div (bs4.element.Tag): ``<div>`` quote element from a quote page.\n\n Returns:\n yield ``<a>`` tags\n\n ' tags_container = quote_div.find('div', attrs={'class': 'greyText smallText left'}) ...
def get_quote_book(quote_div): 'Get the reference (book) from a ``<div>`` quote element.\n\n Args:\n quote_div (bs4.element.Tag): ``<div>`` quote element from a quote page.\n\n Returns:\n bs4.element.Tag\n\n ' quote_details = quote_div.find('div', attrs={'class': 'quoteText'}) return ...
325,821,846,411,896,200
Get the reference (book) from a ``<div>`` quote element. Args: quote_div (bs4.element.Tag): ``<div>`` quote element from a quote page. Returns: bs4.element.Tag
scrapereads/scrape.py
get_quote_book
arthurdjn/scrape-goodreads
python
def get_quote_book(quote_div): 'Get the reference (book) from a ``<div>`` quote element.\n\n Args:\n quote_div (bs4.element.Tag): ``<div>`` quote element from a quote page.\n\n Returns:\n bs4.element.Tag\n\n ' quote_details = quote_div.find('div', attrs={'class': 'quoteText'}) return ...
def get_quote_author_name(quote_div): "Get the author's name from a ``<div>`` quote element.\n\n Args:\n quote_div (bs4.element.Tag): ``<div>`` quote element from a quote page.\n\n Returns:\n string\n\n " quote_text = quote_div.find('div', attrs={'class': 'quoteText '}) author_name = ...
-7,591,282,057,785,029,000
Get the author's name from a ``<div>`` quote element. Args: quote_div (bs4.element.Tag): ``<div>`` quote element from a quote page. Returns: string
scrapereads/scrape.py
get_quote_author_name
arthurdjn/scrape-goodreads
python
def get_quote_author_name(quote_div): "Get the author's name from a ``<div>`` quote element.\n\n Args:\n quote_div (bs4.element.Tag): ``<div>`` quote element from a quote page.\n\n Returns:\n string\n\n " quote_text = quote_div.find('div', attrs={'class': 'quoteText '}) author_name = ...
def get_quote_likes(quote_div): 'Get the likes ``<a>`` tag from a ``<div>`` quote element.\n\n Args:\n quote_div (bs4.element.Tag): ``<div>`` quote element from a quote page.\n\n Returns:\n bs4.element.Tag: ``<a>`` tag for likes.\n\n ' quote_footer = quote_div.find('div', attrs={'class': ...
6,157,151,784,991,132,000
Get the likes ``<a>`` tag from a ``<div>`` quote element. Args: quote_div (bs4.element.Tag): ``<div>`` quote element from a quote page. Returns: bs4.element.Tag: ``<a>`` tag for likes.
scrapereads/scrape.py
get_quote_likes
arthurdjn/scrape-goodreads
python
def get_quote_likes(quote_div): 'Get the likes ``<a>`` tag from a ``<div>`` quote element.\n\n Args:\n quote_div (bs4.element.Tag): ``<div>`` quote element from a quote page.\n\n Returns:\n bs4.element.Tag: ``<a>`` tag for likes.\n\n ' quote_footer = quote_div.find('div', attrs={'class': ...
def get_quote_name_id(quote_div): 'Get the name and id of a ``<div>`` quote element.\n\n Args:\n quote_div (bs4.element.Tag): ``<div>`` quote element from a quote page.\n\n Returns:\n tuple: id and name.\n\n ' quote_href = get_quote_likes(quote_div).get('href') quote_id = quote_href.s...
-2,960,141,701,786,695,700
Get the name and id of a ``<div>`` quote element. Args: quote_div (bs4.element.Tag): ``<div>`` quote element from a quote page. Returns: tuple: id and name.
scrapereads/scrape.py
get_quote_name_id
arthurdjn/scrape-goodreads
python
def get_quote_name_id(quote_div): 'Get the name and id of a ``<div>`` quote element.\n\n Args:\n quote_div (bs4.element.Tag): ``<div>`` quote element from a quote page.\n\n Returns:\n tuple: id and name.\n\n ' quote_href = get_quote_likes(quote_div).get('href') quote_id = quote_href.s...
def scrape_author_books(soup): "Retrieve books from an author's page.\n\n Args:\n soup (bs4.element.Tag): connection to an author books page.\n\n Returns:\n yield bs4.element.Tag: ``<tr>`` element.\n\n " table_tr = soup.find('tr') while table_tr: if (table_tr.name == 'tr'): ...
-1,126,821,855,199,378,000
Retrieve books from an author's page. Args: soup (bs4.element.Tag): connection to an author books page. Returns: yield bs4.element.Tag: ``<tr>`` element.
scrapereads/scrape.py
scrape_author_books
arthurdjn/scrape-goodreads
python
def scrape_author_books(soup): "Retrieve books from an author's page.\n\n Args:\n soup (bs4.element.Tag): connection to an author books page.\n\n Returns:\n yield bs4.element.Tag: ``<tr>`` element.\n\n " table_tr = soup.find('tr') while table_tr: if (table_tr.name == 'tr'): ...
def get_author_book_title(book_tr): "Get the book title ``<a>`` element from a table ``<tr>`` element from an author page.\n\n Args:\n book_tr (bs4.element.Tag): ``<tr>`` book element.\n\n Returns:\n bs4.element.Tag: book title ``<a>`` element.\n\n Examples::\n >>> for book_tr in scrap...
-1,115,418,599,705,648,800
Get the book title ``<a>`` element from a table ``<tr>`` element from an author page. Args: book_tr (bs4.element.Tag): ``<tr>`` book element. Returns: bs4.element.Tag: book title ``<a>`` element. Examples:: >>> for book_tr in scrape_author_books(soup): ... book_title = get_author_book_title(book_...
scrapereads/scrape.py
get_author_book_title
arthurdjn/scrape-goodreads
python
def get_author_book_title(book_tr): "Get the book title ``<a>`` element from a table ``<tr>`` element from an author page.\n\n Args:\n book_tr (bs4.element.Tag): ``<tr>`` book element.\n\n Returns:\n bs4.element.Tag: book title ``<a>`` element.\n\n Examples::\n >>> for book_tr in scrap...
def get_author_book_author(book_tr): "Get the author ``<a>`` element from a table ``<tr>`` element.\n\n Args:\n book_tr (bs4.element.Tag): ``<tr>`` book element.\n\n Returns:\n bs4.element.Tag: author name ``<a>`` element.\n\n Examples::\n >>> for book_tr in scrape_author_books(soup):\...
4,352,936,690,821,773,300
Get the author ``<a>`` element from a table ``<tr>`` element. Args: book_tr (bs4.element.Tag): ``<tr>`` book element. Returns: bs4.element.Tag: author name ``<a>`` element. Examples:: >>> for book_tr in scrape_author_books(soup): ... book_author = get_author_book_author(book_tr) ... print...
scrapereads/scrape.py
get_author_book_author
arthurdjn/scrape-goodreads
python
def get_author_book_author(book_tr): "Get the author ``<a>`` element from a table ``<tr>`` element.\n\n Args:\n book_tr (bs4.element.Tag): ``<tr>`` book element.\n\n Returns:\n bs4.element.Tag: author name ``<a>`` element.\n\n Examples::\n >>> for book_tr in scrape_author_books(soup):\...
def get_author_book_ratings(book_tr): 'Get the ratings ``<span>`` element from a table ``<tr>`` element from an author page.\n\n Args:\n book_tr (bs4.element.Tag): ``<tr>`` book element.\n\n Returns:\n bs4.element.Tag: ratings ``<span>`` element.\n\n Examples::\n >>> for book_tr in scr...
-3,227,250,309,905,705,500
Get the ratings ``<span>`` element from a table ``<tr>`` element from an author page. Args: book_tr (bs4.element.Tag): ``<tr>`` book element. Returns: bs4.element.Tag: ratings ``<span>`` element. Examples:: >>> for book_tr in scrape_author_books(soup): ... ratings_span = get_author_book_ratings(b...
scrapereads/scrape.py
get_author_book_ratings
arthurdjn/scrape-goodreads
python
def get_author_book_ratings(book_tr): 'Get the ratings ``<span>`` element from a table ``<tr>`` element from an author page.\n\n Args:\n book_tr (bs4.element.Tag): ``<tr>`` book element.\n\n Returns:\n bs4.element.Tag: ratings ``<span>`` element.\n\n Examples::\n >>> for book_tr in scr...
def get_author_book_edition(book_tr): "Get the edition ``<a>`` element from a table ``<tr>`` element from an author page.\n\n Args:\n book_tr (bs4.element.Tag): ``<tr>`` book element.\n\n Returns:\n bs4.element.Tag: book edition ``<a>`` element.\n\n Examples::\n >>> for book_tr in scra...
8,646,870,124,449,000,000
Get the edition ``<a>`` element from a table ``<tr>`` element from an author page. Args: book_tr (bs4.element.Tag): ``<tr>`` book element. Returns: bs4.element.Tag: book edition ``<a>`` element. Examples:: >>> for book_tr in scrape_author_books(soup): ... book_edition = get_author_book_edition(bo...
scrapereads/scrape.py
get_author_book_edition
arthurdjn/scrape-goodreads
python
def get_author_book_edition(book_tr): "Get the edition ``<a>`` element from a table ``<tr>`` element from an author page.\n\n Args:\n book_tr (bs4.element.Tag): ``<tr>`` book element.\n\n Returns:\n bs4.element.Tag: book edition ``<a>`` element.\n\n Examples::\n >>> for book_tr in scra...
def get_author_book_date(book_tr): 'Get the published date from a table ``<tr>`` element from an author page.\n\n Args:\n book_tr (bs4.element.Tag): ``<tr>`` book element.\n\n Returns:\n int: date of publication\n\n Examples::\n >>> for book_tr in scrape_author_books(soup):\n .....
5,196,297,577,235,133,000
Get the published date from a table ``<tr>`` element from an author page. Args: book_tr (bs4.element.Tag): ``<tr>`` book element. Returns: int: date of publication Examples:: >>> for book_tr in scrape_author_books(soup): ... book_date = get_author_book_date(book_tr) ... print(book_date) ...
scrapereads/scrape.py
get_author_book_date
arthurdjn/scrape-goodreads
python
def get_author_book_date(book_tr): 'Get the published date from a table ``<tr>`` element from an author page.\n\n Args:\n book_tr (bs4.element.Tag): ``<tr>`` book element.\n\n Returns:\n int: date of publication\n\n Examples::\n >>> for book_tr in scrape_author_books(soup):\n .....
def get_book_quote_page(soup): 'Find the ``<a>`` element pointing to the quote page of a book.\n\n Args:\n soup (bs4.element.Tag):\n\n Returns:\n\n ' quote_div = soup.findAll('div', attrs={'class': ' clearFloats bigBox'}) if quote_div: return quote_div[(- 1)].find('a') return Non...
-3,858,875,114,353,949,700
Find the ``<a>`` element pointing to the quote page of a book. Args: soup (bs4.element.Tag): Returns:
scrapereads/scrape.py
get_book_quote_page
arthurdjn/scrape-goodreads
python
def get_book_quote_page(soup): 'Find the ``<a>`` element pointing to the quote page of a book.\n\n Args:\n soup (bs4.element.Tag):\n\n Returns:\n\n ' quote_div = soup.findAll('div', attrs={'class': ' clearFloats bigBox'}) if quote_div: return quote_div[(- 1)].find('a') return Non...
def find_divisors(x): '\n This is the "function to find divisors in order to find generators" module.\n This DocTest verifies that the module is correctly calculating all divisors\n of a number x.\n\n >>> find_divisors(10)\n [1, 2, 5, 10]\n\n >>> find_divisors(112)\n [1, 2, 4, 7, 8, 14, 16, 28,...
-782,998,713,240,490,500
This is the "function to find divisors in order to find generators" module. This DocTest verifies that the module is correctly calculating all divisors of a number x. >>> find_divisors(10) [1, 2, 5, 10] >>> find_divisors(112) [1, 2, 4, 7, 8, 14, 16, 28, 56, 112]
libsig/FZZ_unique_ring_signature.py
find_divisors
vs-uulm/libsig_pets
python
def find_divisors(x): '\n This is the "function to find divisors in order to find generators" module.\n This DocTest verifies that the module is correctly calculating all divisors\n of a number x.\n\n >>> find_divisors(10)\n [1, 2, 5, 10]\n\n >>> find_divisors(112)\n [1, 2, 4, 7, 8, 14, 16, 28,...
def find_generator(p): '\n The order of any element in a group can be divided by p-1.\n Step 1: Calculate all Divisors.\n Step 2: Test for a random element e of G wether e to the power of a Divisor is 1.\n if neither is one but e to the power of p-1, a generator is found.\n ' testGen = ra...
3,486,228,835,377,068,500
The order of any element in a group can be divided by p-1. Step 1: Calculate all Divisors. Step 2: Test for a random element e of G wether e to the power of a Divisor is 1. if neither is one but e to the power of p-1, a generator is found.
libsig/FZZ_unique_ring_signature.py
find_generator
vs-uulm/libsig_pets
python
def find_generator(p): '\n The order of any element in a group can be divided by p-1.\n Step 1: Calculate all Divisors.\n Step 2: Test for a random element e of G wether e to the power of a Divisor is 1.\n if neither is one but e to the power of p-1, a generator is found.\n ' testGen = ra...
def list_to_string(input_list): '\n convert a list into a concatenated string of all its elements\n ' result = ''.join(map(str, input_list)) return result
3,923,680,371,048,306,000
convert a list into a concatenated string of all its elements
libsig/FZZ_unique_ring_signature.py
list_to_string
vs-uulm/libsig_pets
python
def list_to_string(input_list): '\n \n ' result = .join(map(str, input_list)) return result
@staticmethod def ringsign(x, pubkey, message, verbose=False): '\n input: x is the privkey from user i, \n | all public keys: pubkeys,\n | the message\n \n output: (R,m, (H(mR)^xi), c1,t1,...,cn,tn),\n | R: all the pubkeys concatenated,\n | c...
-5,456,669,802,386,871,000
input: x is the privkey from user i, | all public keys: pubkeys, | the message output: (R,m, (H(mR)^xi), c1,t1,...,cn,tn), | R: all the pubkeys concatenated, | cj,tj: random number within Zq
libsig/FZZ_unique_ring_signature.py
ringsign
vs-uulm/libsig_pets
python
@staticmethod def ringsign(x, pubkey, message, verbose=False): '\n input: x is the privkey from user i, \n | all public keys: pubkeys,\n | the message\n \n output: (R,m, (H(mR)^xi), c1,t1,...,cn,tn),\n | R: all the pubkeys concatenated,\n | c...
@staticmethod def verify(R, message, signature, verbose=False): '\n Input: the public keys R\n | the message\n | the signature computed with ringsign\n\n Output: whether the message was signed by R or not\n ' g = UniqueRingSignature.g q = UniqueRingSignature.q ...
-5,893,289,199,147,430,000
Input: the public keys R | the message | the signature computed with ringsign Output: whether the message was signed by R or not
libsig/FZZ_unique_ring_signature.py
verify
vs-uulm/libsig_pets
python
@staticmethod def verify(R, message, signature, verbose=False): '\n Input: the public keys R\n | the message\n | the signature computed with ringsign\n\n Output: whether the message was signed by R or not\n ' g = UniqueRingSignature.g q = UniqueRingSignature.q ...
def current_flow_betweenness_centrality_subset(G, sources, targets, normalized=True, weight='weight', dtype=float, solver='lu'): 'Compute current-flow betweenness centrality for subsets of nodes.\n\n Current-flow betweenness centrality uses an electrical current\n model for information spreading in contrast t...
8,374,067,259,139,407,000
Compute current-flow betweenness centrality for subsets of nodes. Current-flow betweenness centrality uses an electrical current model for information spreading in contrast to betweenness centrality which uses shortest paths. Current-flow betweenness centrality is also known as random-walk betweenness centrality [2]_...
networkx/algorithms/centrality/current_flow_betweenness_subset.py
current_flow_betweenness_centrality_subset
AllenDowney/networkx
python
def current_flow_betweenness_centrality_subset(G, sources, targets, normalized=True, weight='weight', dtype=float, solver='lu'): 'Compute current-flow betweenness centrality for subsets of nodes.\n\n Current-flow betweenness centrality uses an electrical current\n model for information spreading in contrast t...
def edge_current_flow_betweenness_centrality_subset(G, sources, targets, normalized=True, weight='weight', dtype=float, solver='lu'): 'Compute current-flow betweenness centrality for edges using subsets \n of nodes.\n\n Current-flow betweenness centrality uses an electrical current\n model for information ...
-270,612,836,393,175,170
Compute current-flow betweenness centrality for edges using subsets of nodes. Current-flow betweenness centrality uses an electrical current model for information spreading in contrast to betweenness centrality which uses shortest paths. Current-flow betweenness centrality is also known as random-walk betweenness ce...
networkx/algorithms/centrality/current_flow_betweenness_subset.py
edge_current_flow_betweenness_centrality_subset
AllenDowney/networkx
python
def edge_current_flow_betweenness_centrality_subset(G, sources, targets, normalized=True, weight='weight', dtype=float, solver='lu'): 'Compute current-flow betweenness centrality for edges using subsets \n of nodes.\n\n Current-flow betweenness centrality uses an electrical current\n model for information ...
def is_inside_offset(inner, outer): 'Checks if the first offset is contained in the second offset\n\n Args:\n inner: inner offset tuple\n outer: outer offset tuple\n\n Returns: bool' return (outer[0] <= inner[0] <= inner[1] <= outer[1])
6,477,983,249,331,503,000
Checks if the first offset is contained in the second offset Args: inner: inner offset tuple outer: outer offset tuple Returns: bool
solcast/nodes.py
is_inside_offset
danhper/py-solc-ast
python
def is_inside_offset(inner, outer): 'Checks if the first offset is contained in the second offset\n\n Args:\n inner: inner offset tuple\n outer: outer offset tuple\n\n Returns: bool' return (outer[0] <= inner[0] <= inner[1] <= outer[1])
def children(self, depth=None, include_self=False, include_parents=True, include_children=True, required_offset=None, offset_limits=None, filters=None, exclude_filter=None): "Get childen nodes of this node.\n\n Arguments:\n depth: Number of levels of children to traverse. 0 returns only this node.\n...
870,645,974,598,897,000
Get childen nodes of this node. Arguments: depth: Number of levels of children to traverse. 0 returns only this node. include_self: Includes this node in the results. include_parents: Includes nodes that match in the results, when they also have child nodes that match. include_children: If True...
solcast/nodes.py
children
danhper/py-solc-ast
python
def children(self, depth=None, include_self=False, include_parents=True, include_children=True, required_offset=None, offset_limits=None, filters=None, exclude_filter=None): "Get childen nodes of this node.\n\n Arguments:\n depth: Number of levels of children to traverse. 0 returns only this node.\n...
def parents(self, depth=(- 1), filters=None): "Get parent nodes of this node.\n\n Arguments:\n depth: Depth limit. If given as a negative value, it will be subtracted\n from this object's depth.\n filters: Dictionary of {attribute: value} that parents must match.\n\n ...
-8,765,994,480,727,989,000
Get parent nodes of this node. Arguments: depth: Depth limit. If given as a negative value, it will be subtracted from this object's depth. filters: Dictionary of {attribute: value} that parents must match. Returns: list of nodes
solcast/nodes.py
parents
danhper/py-solc-ast
python
def parents(self, depth=(- 1), filters=None): "Get parent nodes of this node.\n\n Arguments:\n depth: Depth limit. If given as a negative value, it will be subtracted\n from this object's depth.\n filters: Dictionary of {attribute: value} that parents must match.\n\n ...
def parent(self, depth=(- 1), filters=None): "Get a parent node of this node.\n\n Arguments:\n depth: Depth limit. If given as a negative value, it will be subtracted\n from this object's depth. The parent at this exact depth is returned.\n filters: Dictionary of {attr...
-2,546,208,489,780,907,000
Get a parent node of this node. Arguments: depth: Depth limit. If given as a negative value, it will be subtracted from this object's depth. The parent at this exact depth is returned. filters: Dictionary of {attribute: value} that the parent must match. If a filter value is given, will return the ...
solcast/nodes.py
parent
danhper/py-solc-ast
python
def parent(self, depth=(- 1), filters=None): "Get a parent node of this node.\n\n Arguments:\n depth: Depth limit. If given as a negative value, it will be subtracted\n from this object's depth. The parent at this exact depth is returned.\n filters: Dictionary of {attr...
def is_child_of(self, node): 'Checks if this object is a child of the given node object.' if (node.depth >= self.depth): return False return (self.parent(node.depth) == node)
7,342,769,154,843,425,000
Checks if this object is a child of the given node object.
solcast/nodes.py
is_child_of
danhper/py-solc-ast
python
def is_child_of(self, node): if (node.depth >= self.depth): return False return (self.parent(node.depth) == node)
def is_parent_of(self, node): 'Checks if this object is a parent of the given node object.' if (node.depth <= self.depth): return False return (node.parent(self.depth) == self)
7,078,512,650,039,579,000
Checks if this object is a parent of the given node object.
solcast/nodes.py
is_parent_of
danhper/py-solc-ast
python
def is_parent_of(self, node): if (node.depth <= self.depth): return False return (node.parent(self.depth) == self)
def get(self, key, default=None): '\n Gets an attribute from this node, if that attribute exists.\n\n Arguments:\n key: Field name to return. May contain decimals to return a value\n from a child node.\n default: Default value to return.\n\n Returns: Field ...
1,159,391,490,741,558,500
Gets an attribute from this node, if that attribute exists. Arguments: key: Field name to return. May contain decimals to return a value from a child node. default: Default value to return. Returns: Field value if it exists. Default value if not.
solcast/nodes.py
get
danhper/py-solc-ast
python
def get(self, key, default=None): '\n Gets an attribute from this node, if that attribute exists.\n\n Arguments:\n key: Field name to return. May contain decimals to return a value\n from a child node.\n default: Default value to return.\n\n Returns: Field ...
def pqcost(gencost, ng, on=None): 'Splits the gencost variable into two pieces if costs are given for Qg.\n\n Checks whether C{gencost} has cost information for reactive power\n generation (rows C{ng+1} to C{2*ng}). If so, it returns the first C{ng}\n rows in C{pcost} and the last C{ng} rows in C{qcost}. O...
-4,256,423,973,439,093,000
Splits the gencost variable into two pieces if costs are given for Qg. Checks whether C{gencost} has cost information for reactive power generation (rows C{ng+1} to C{2*ng}). If so, it returns the first C{ng} rows in C{pcost} and the last C{ng} rows in C{qcost}. Otherwise, leaves C{qcost} empty. Also does some error c...
pandapower/pypower/pqcost.py
pqcost
AdrienGougeon/pandapower
python
def pqcost(gencost, ng, on=None): 'Splits the gencost variable into two pieces if costs are given for Qg.\n\n Checks whether C{gencost} has cost information for reactive power\n generation (rows C{ng+1} to C{2*ng}). If so, it returns the first C{ng}\n rows in C{pcost} and the last C{ng} rows in C{qcost}. O...
def update_sarsa_table(sarsa, state, action, reward, next_state, next_action, alpha, gamma): '\n update sarsa state-action pair value, main difference from q learning is that it uses epsilon greedy policy\n return action\n ' next_max = sarsa[(next_state, next_action)] sarsa[(state, action)] = (sars...
5,557,110,078,792,144,000
update sarsa state-action pair value, main difference from q learning is that it uses epsilon greedy policy return action
TD/double_q_learning.py
update_sarsa_table
hadleyhzy34/reinforcement_learning
python
def update_sarsa_table(sarsa, state, action, reward, next_state, next_action, alpha, gamma): '\n update sarsa state-action pair value, main difference from q learning is that it uses epsilon greedy policy\n return action\n ' next_max = sarsa[(next_state, next_action)] sarsa[(state, action)] = (sars...
def epsilon_greedy_policy_sarsa(env, state, sarsa, epsilon): '\n epsilon greedy policy for q learning to generate actions\n ' if (random.uniform(0, 1) < epsilon): return env.action_space.sample() else: return np.argmax(sarsa[state])
-8,075,559,200,367,544,000
epsilon greedy policy for q learning to generate actions
TD/double_q_learning.py
epsilon_greedy_policy_sarsa
hadleyhzy34/reinforcement_learning
python
def epsilon_greedy_policy_sarsa(env, state, sarsa, epsilon): '\n \n ' if (random.uniform(0, 1) < epsilon): return env.action_space.sample() else: return np.argmax(sarsa[state])
def epsilon_greedy_policy(env, state, q, epsilon): '\n epsilon greedy policy for q learning to generate actions\n ' if (random.uniform(0, 1) < epsilon): return env.action_space.sample() else: return np.argmax(q[state])
750,251,734,879,276,300
epsilon greedy policy for q learning to generate actions
TD/double_q_learning.py
epsilon_greedy_policy
hadleyhzy34/reinforcement_learning
python
def epsilon_greedy_policy(env, state, q, epsilon): '\n \n ' if (random.uniform(0, 1) < epsilon): return env.action_space.sample() else: return np.argmax(q[state])
def extendMarkdown(self, md, md_globals): ' Add MetaPreprocessor to Markdown instance. ' md.preprocessors.add('meta', MetaPreprocessor(md), '>normalize_whitespace')
-7,437,616,332,312,968,000
Add MetaPreprocessor to Markdown instance.
venv/lib/python3.6/site-packages/markdown/extensions/meta.py
extendMarkdown
AzDan/Sac-Portal
python
def extendMarkdown(self, md, md_globals): ' ' md.preprocessors.add('meta', MetaPreprocessor(md), '>normalize_whitespace')
def run(self, lines): ' Parse Meta-Data and store in Markdown.Meta. ' meta = {} key = None if (lines and BEGIN_RE.match(lines[0])): lines.pop(0) while lines: line = lines.pop(0) m1 = META_RE.match(line) if ((line.strip() == '') or END_RE.match(line)): brea...
4,990,314,545,543,673,000
Parse Meta-Data and store in Markdown.Meta.
venv/lib/python3.6/site-packages/markdown/extensions/meta.py
run
AzDan/Sac-Portal
python
def run(self, lines): ' ' meta = {} key = None if (lines and BEGIN_RE.match(lines[0])): lines.pop(0) while lines: line = lines.pop(0) m1 = META_RE.match(line) if ((line.strip() == ) or END_RE.match(line)): break if m1: key = m1.group('...
def thumbIncrementCheck(lmList: list[list[int]]) -> int: 'Checks whether your thumb is up or not.\n No matter what hand you use.\n returns 1 if thumb is up else 0' count = 0 t_x = lmList[4][1] p_x = lmList[17][1] if (t_x > p_x): if (lmList[4][1] >= lmList[2][1]): count += 1...
1,383,995,815,912,717,000
Checks whether your thumb is up or not. No matter what hand you use. returns 1 if thumb is up else 0
forOutput.py
thumbIncrementCheck
laughingclouds/dt-mst-project
python
def thumbIncrementCheck(lmList: list[list[int]]) -> int: 'Checks whether your thumb is up or not.\n No matter what hand you use.\n returns 1 if thumb is up else 0' count = 0 t_x = lmList[4][1] p_x = lmList[17][1] if (t_x > p_x): if (lmList[4][1] >= lmList[2][1]): count += 1...
def textOutput(count, cc) -> str: 'Returns an appropriate text output depending on\n `count` and `cc`.' text = 'NOTHING' if ((count, cc) == (2, 2)): text = 'SCISSOR' elif (count == 0): text = 'ROCK' elif (count == 5): text = 'PAPER' else: pass return text
1,949,855,737,496,309,200
Returns an appropriate text output depending on `count` and `cc`.
forOutput.py
textOutput
laughingclouds/dt-mst-project
python
def textOutput(count, cc) -> str: 'Returns an appropriate text output depending on\n `count` and `cc`.' text = 'NOTHING' if ((count, cc) == (2, 2)): text = 'SCISSOR' elif (count == 0): text = 'ROCK' elif (count == 5): text = 'PAPER' else: pass return text
def add(self, block): 'Adds block on top of the stack.' self.register_child(block)
4,228,037,508,592,754,700
Adds block on top of the stack.
python/mxnet/gluon/nn/basic_layers.py
add
IIMarch/mxnet
python
def add(self, block): self.register_child(block)
def add(self, block): 'Adds block on top of the stack.' self.register_child(block)
4,228,037,508,592,754,700
Adds block on top of the stack.
python/mxnet/gluon/nn/basic_layers.py
add
IIMarch/mxnet
python
def add(self, block): self.register_child(block)
def _block_device_mapping_handler(self): '\n Handles requests which are generated by code similar to:\n\n instance.modify_attribute(\'blockDeviceMapping\', {\'/dev/sda1\': True})\n\n The querystring contains information similar to:\n\n BlockDeviceMapping.1.Ebs.DeleteOnTermination...
-8,310,963,183,193,581,000
Handles requests which are generated by code similar to: instance.modify_attribute('blockDeviceMapping', {'/dev/sda1': True}) The querystring contains information similar to: BlockDeviceMapping.1.Ebs.DeleteOnTermination : ['true'] BlockDeviceMapping.1.DeviceName : ['/dev/sda1'] For now we only support t...
moto/ec2/responses/instances.py
_block_device_mapping_handler
adtsys-cloud/moto-aws-mock
python
def _block_device_mapping_handler(self): '\n Handles requests which are generated by code similar to:\n\n instance.modify_attribute(\'blockDeviceMapping\', {\'/dev/sda1\': True})\n\n The querystring contains information similar to:\n\n BlockDeviceMapping.1.Ebs.DeleteOnTermination...
def get_fs(path, opts=None, rtype='instance'): "Helper to infer filesystem correctly.\n\n Gets filesystem options from settings and updates them with given `opts`.\n\n Parameters\n ----------\n path: str\n Path for which we want to infer filesystem.\n opts: dict\n Kwargs that will be pa...
-6,416,019,460,632,777,000
Helper to infer filesystem correctly. Gets filesystem options from settings and updates them with given `opts`. Parameters ---------- path: str Path for which we want to infer filesystem. opts: dict Kwargs that will be passed to inferred filesystem instance. rtype: str Either 'instance' (default) or 'clas...
drfs/filesystems/util.py
get_fs
datarevenue-berlin/drfs
python
def get_fs(path, opts=None, rtype='instance'): "Helper to infer filesystem correctly.\n\n Gets filesystem options from settings and updates them with given `opts`.\n\n Parameters\n ----------\n path: str\n Path for which we want to infer filesystem.\n opts: dict\n Kwargs that will be pa...
def allow_pathlib(func): 'Allow methods to receive pathlib.Path objects.\n\n Parameters\n ----------\n func: callable\n function to decorate must have the following signature\n self, path, *args, **kwargs\n\n Returns\n -------\n wrapper: callable\n ' @wraps(func) def wrap...
8,810,367,554,903,184,000
Allow methods to receive pathlib.Path objects. Parameters ---------- func: callable function to decorate must have the following signature self, path, *args, **kwargs Returns ------- wrapper: callable
drfs/filesystems/util.py
allow_pathlib
datarevenue-berlin/drfs
python
def allow_pathlib(func): 'Allow methods to receive pathlib.Path objects.\n\n Parameters\n ----------\n func: callable\n function to decorate must have the following signature\n self, path, *args, **kwargs\n\n Returns\n -------\n wrapper: callable\n ' @wraps(func) def wrap...
def return_schemes(func): 'Make sure method returns full path with scheme.' @wraps(func) def wrapper(self, path, *args, **kwargs): res = func(self, path, *args, **kwargs) try: res = list(map(partial(prepend_scheme, self.scheme), res)) except TypeError: res = ...
29,942,895,302,851,876
Make sure method returns full path with scheme.
drfs/filesystems/util.py
return_schemes
datarevenue-berlin/drfs
python
def return_schemes(func): @wraps(func) def wrapper(self, path, *args, **kwargs): res = func(self, path, *args, **kwargs) try: res = list(map(partial(prepend_scheme, self.scheme), res)) except TypeError: res = prepend_scheme(self.scheme, res) return r...
def maybe_remove_scheme(func): 'Remove scheme from args and kwargs in case underlying fs does not support it.' @wraps(func) def wrapper(self, path, *args, **kwargs): if (not self.supports_scheme): path = remove_scheme(path, raise_=False) args = [remove_scheme(a, raise_=False...
6,853,007,073,676,262,000
Remove scheme from args and kwargs in case underlying fs does not support it.
drfs/filesystems/util.py
maybe_remove_scheme
datarevenue-berlin/drfs
python
def maybe_remove_scheme(func): @wraps(func) def wrapper(self, path, *args, **kwargs): if (not self.supports_scheme): path = remove_scheme(path, raise_=False) args = [remove_scheme(a, raise_=False) for a in args] kwargs = {k: (remove_scheme(v, raise_=False) if is...
def _default_stim_chs(info): 'Return default stim channels for SQD files.' return pick_types(info, meg=False, ref_meg=False, misc=True, exclude=[])[:8]
-4,594,179,421,141,542,000
Return default stim channels for SQD files.
venv/lib/python3.8/site-packages/mne/io/kit/kit.py
_default_stim_chs
alexisicte/aviate
python
def _default_stim_chs(info): return pick_types(info, meg=False, ref_meg=False, misc=True, exclude=[])[:8]
def _make_stim_channel(trigger_chs, slope, threshold, stim_code, trigger_values): 'Create synthetic stim channel from multiple trigger channels.' if (slope == '+'): trig_chs_bin = (trigger_chs > threshold) elif (slope == '-'): trig_chs_bin = (trigger_chs < threshold) else: raise ...
7,044,268,555,867,526,000
Create synthetic stim channel from multiple trigger channels.
venv/lib/python3.8/site-packages/mne/io/kit/kit.py
_make_stim_channel
alexisicte/aviate
python
def _make_stim_channel(trigger_chs, slope, threshold, stim_code, trigger_values): if (slope == '+'): trig_chs_bin = (trigger_chs > threshold) elif (slope == '-'): trig_chs_bin = (trigger_chs < threshold) else: raise ValueError("slope needs to be '+' or '-'") if (stim_code ==...
@verbose def get_kit_info(rawfile, allow_unknown_format, standardize_names=None, verbose=None): 'Extract all the information from the sqd/con file.\n\n Parameters\n ----------\n rawfile : str\n KIT file to be read.\n allow_unknown_format : bool\n Force reading old data that is not official...
-8,458,605,956,946,132,000
Extract all the information from the sqd/con file. Parameters ---------- rawfile : str KIT file to be read. allow_unknown_format : bool Force reading old data that is not officially supported. Alternatively, read and re-save the data with the KIT MEG Laboratory application. %(standardize_names)s %(verbose)...
venv/lib/python3.8/site-packages/mne/io/kit/kit.py
get_kit_info
alexisicte/aviate
python
@verbose def get_kit_info(rawfile, allow_unknown_format, standardize_names=None, verbose=None): 'Extract all the information from the sqd/con file.\n\n Parameters\n ----------\n rawfile : str\n KIT file to be read.\n allow_unknown_format : bool\n Force reading old data that is not official...
@fill_doc def read_raw_kit(input_fname, mrk=None, elp=None, hsp=None, stim='>', slope='-', stimthresh=1, preload=False, stim_code='binary', allow_unknown_format=False, standardize_names=None, verbose=None): "Reader function for Ricoh/KIT conversion to FIF.\n\n Parameters\n ----------\n input_fname : str\n ...
-419,446,750,408,291,400
Reader function for Ricoh/KIT conversion to FIF. Parameters ---------- input_fname : str Path to the sqd file. mrk : None | str | array_like, shape (5, 3) | list of str or array_like Marker points representing the location of the marker coils with respect to the MEG Sensors, or path to a marker file. I...
venv/lib/python3.8/site-packages/mne/io/kit/kit.py
read_raw_kit
alexisicte/aviate
python
@fill_doc def read_raw_kit(input_fname, mrk=None, elp=None, hsp=None, stim='>', slope='-', stimthresh=1, preload=False, stim_code='binary', allow_unknown_format=False, standardize_names=None, verbose=None): "Reader function for Ricoh/KIT conversion to FIF.\n\n Parameters\n ----------\n input_fname : str\n ...
@fill_doc def read_epochs_kit(input_fname, events, event_id=None, mrk=None, elp=None, hsp=None, allow_unknown_format=False, standardize_names=None, verbose=None): "Reader function for Ricoh/KIT epochs files.\n\n Parameters\n ----------\n input_fname : str\n Path to the sqd file.\n events : array,...
2,132,265,082,483,621,600
Reader function for Ricoh/KIT epochs files. Parameters ---------- input_fname : str Path to the sqd file. events : array, shape (n_events, 3) The events typically returned by the read_events function. If some events don't match the events of interest as specified by event_id, they will be marked as 'IG...
venv/lib/python3.8/site-packages/mne/io/kit/kit.py
read_epochs_kit
alexisicte/aviate
python
@fill_doc def read_epochs_kit(input_fname, events, event_id=None, mrk=None, elp=None, hsp=None, allow_unknown_format=False, standardize_names=None, verbose=None): "Reader function for Ricoh/KIT epochs files.\n\n Parameters\n ----------\n input_fname : str\n Path to the sqd file.\n events : array,...
def read_stim_ch(self, buffer_size=100000.0): 'Read events from data.\n\n Parameter\n ---------\n buffer_size : int\n The size of chunk to by which the data are scanned.\n\n Returns\n -------\n events : array, [samples]\n The event vector (1 x samples)....
-1,490,638,908,371,606,300
Read events from data. Parameter --------- buffer_size : int The size of chunk to by which the data are scanned. Returns ------- events : array, [samples] The event vector (1 x samples).
venv/lib/python3.8/site-packages/mne/io/kit/kit.py
read_stim_ch
alexisicte/aviate
python
def read_stim_ch(self, buffer_size=100000.0): 'Read events from data.\n\n Parameter\n ---------\n buffer_size : int\n The size of chunk to by which the data are scanned.\n\n Returns\n -------\n events : array, [samples]\n The event vector (1 x samples)....
def _set_stimchannels(self, info, stim, stim_code): "Specify how the trigger channel is synthesized from analog channels.\n\n Has to be done before loading data. For a RawKIT instance that has been\n created with preload=True, this method will raise a\n NotImplementedError.\n\n Parameter...
-26,248,256,616,927,200
Specify how the trigger channel is synthesized from analog channels. Has to be done before loading data. For a RawKIT instance that has been created with preload=True, this method will raise a NotImplementedError. Parameters ---------- info : instance of MeasInfo The measurement info. stim : list of int | '<' | '...
venv/lib/python3.8/site-packages/mne/io/kit/kit.py
_set_stimchannels
alexisicte/aviate
python
def _set_stimchannels(self, info, stim, stim_code): "Specify how the trigger channel is synthesized from analog channels.\n\n Has to be done before loading data. For a RawKIT instance that has been\n created with preload=True, this method will raise a\n NotImplementedError.\n\n Parameter...
def _read_segment_file(self, data, idx, fi, start, stop, cals, mult): 'Read a chunk of raw data.' sqd = self._raw_extras[fi] nchan = sqd['nchan'] data_left = ((stop - start) * nchan) conv_factor = sqd['conv_factor'] n_bytes = sqd['dtype'].itemsize assert (n_bytes in (2, 4)) blk_size = mi...
-5,310,060,896,194,029,000
Read a chunk of raw data.
venv/lib/python3.8/site-packages/mne/io/kit/kit.py
_read_segment_file
alexisicte/aviate
python
def _read_segment_file(self, data, idx, fi, start, stop, cals, mult): sqd = self._raw_extras[fi] nchan = sqd['nchan'] data_left = ((stop - start) * nchan) conv_factor = sqd['conv_factor'] n_bytes = sqd['dtype'].itemsize assert (n_bytes in (2, 4)) blk_size = min(data_left, (((100000000 /...
def _read_kit_data(self): 'Read epochs data.\n\n Returns\n -------\n data : array, [channels x samples]\n the data matrix (channels x samples).\n times : array, [samples]\n returns the time values corresponding to the samples.\n ' info = self._raw_extras[0...
6,968,618,934,094,841,000
Read epochs data. Returns ------- data : array, [channels x samples] the data matrix (channels x samples). times : array, [samples] returns the time values corresponding to the samples.
venv/lib/python3.8/site-packages/mne/io/kit/kit.py
_read_kit_data
alexisicte/aviate
python
def _read_kit_data(self): 'Read epochs data.\n\n Returns\n -------\n data : array, [channels x samples]\n the data matrix (channels x samples).\n times : array, [samples]\n returns the time values corresponding to the samples.\n ' info = self._raw_extras[0...
@lru_cache() def get_linux_distribution(): 'Compatibility wrapper for {platform,distro}.linux_distribution().\n ' if hasattr(platform, 'linux_distribution'): with warnings.catch_warnings(): warnings.filterwarnings('ignore', category=DeprecationWarning) result = platform.linux_...
2,094,807,504,367,020,000
Compatibility wrapper for {platform,distro}.linux_distribution().
datalad/utils.py
get_linux_distribution
AKSoo/datalad
python
@lru_cache() def get_linux_distribution(): '\n ' if hasattr(platform, 'linux_distribution'): with warnings.catch_warnings(): warnings.filterwarnings('ignore', category=DeprecationWarning) result = platform.linux_distribution() else: import distro result = d...
def getargspec(func, *, include_kwonlyargs=False): "Compat shim for getargspec deprecated in python 3.\n\n The main difference from inspect.getargspec (and inspect.getfullargspec\n for that matter) is that by using inspect.signature we are providing\n correct args/defaults for functools.wraps'ed functions....
-6,180,160,135,232,466,000
Compat shim for getargspec deprecated in python 3. The main difference from inspect.getargspec (and inspect.getfullargspec for that matter) is that by using inspect.signature we are providing correct args/defaults for functools.wraps'ed functions. `include_kwonlyargs` option was added to centralize getting all args, ...
datalad/utils.py
getargspec
AKSoo/datalad
python
def getargspec(func, *, include_kwonlyargs=False): "Compat shim for getargspec deprecated in python 3.\n\n The main difference from inspect.getargspec (and inspect.getfullargspec\n for that matter) is that by using inspect.signature we are providing\n correct args/defaults for functools.wraps'ed functions....
def any_re_search(regexes, value): 'Return if any of regexes (list or str) searches successfully for value' for regex in ensure_tuple_or_list(regexes): if re.search(regex, value): return True return False
4,265,866,037,996,960,000
Return if any of regexes (list or str) searches successfully for value
datalad/utils.py
any_re_search
AKSoo/datalad
python
def any_re_search(regexes, value): for regex in ensure_tuple_or_list(regexes): if re.search(regex, value): return True return False
def not_supported_on_windows(msg=None): 'A little helper to be invoked to consistently fail whenever functionality is\n not supported (yet) on Windows\n ' if on_windows: raise NotImplementedError(('This functionality is not yet implemented for Windows OS' + ((': %s' % msg) if msg else '')))
-9,206,899,521,312,776,000
A little helper to be invoked to consistently fail whenever functionality is not supported (yet) on Windows
datalad/utils.py
not_supported_on_windows
AKSoo/datalad
python
def not_supported_on_windows(msg=None): 'A little helper to be invoked to consistently fail whenever functionality is\n not supported (yet) on Windows\n ' if on_windows: raise NotImplementedError(('This functionality is not yet implemented for Windows OS' + ((': %s' % msg) if msg else )))
def get_home_envvars(new_home): 'Return dict with env variables to be adjusted for a new HOME\n\n Only variables found in current os.environ are adjusted.\n\n Parameters\n ----------\n new_home: str or Path\n New home path, in native to OS "schema"\n ' new_home = str(new_home) out = {'HO...
4,516,429,125,876,582,400
Return dict with env variables to be adjusted for a new HOME Only variables found in current os.environ are adjusted. Parameters ---------- new_home: str or Path New home path, in native to OS "schema"
datalad/utils.py
get_home_envvars
AKSoo/datalad
python
def get_home_envvars(new_home): 'Return dict with env variables to be adjusted for a new HOME\n\n Only variables found in current os.environ are adjusted.\n\n Parameters\n ----------\n new_home: str or Path\n New home path, in native to OS "schema"\n ' new_home = str(new_home) out = {'HO...
def auto_repr(cls): 'Decorator for a class to assign it an automagic quick and dirty __repr__\n\n It uses public class attributes to prepare repr of a class\n\n Original idea: http://stackoverflow.com/a/27799004/1265472\n ' cls.__repr__ = __auto_repr__ return cls
-7,868,090,968,649,534,000
Decorator for a class to assign it an automagic quick and dirty __repr__ It uses public class attributes to prepare repr of a class Original idea: http://stackoverflow.com/a/27799004/1265472
datalad/utils.py
auto_repr
AKSoo/datalad
python
def auto_repr(cls): 'Decorator for a class to assign it an automagic quick and dirty __repr__\n\n It uses public class attributes to prepare repr of a class\n\n Original idea: http://stackoverflow.com/a/27799004/1265472\n ' cls.__repr__ = __auto_repr__ return cls
def is_interactive(): 'Return True if all in/outs are open and tty.\n\n Note that in a somewhat abnormal case where e.g. stdin is explicitly\n closed, and any operation on it would raise a\n `ValueError("I/O operation on closed file")` exception, this function\n would just return False, since the sessio...
8,509,922,991,414,469,000
Return True if all in/outs are open and tty. Note that in a somewhat abnormal case where e.g. stdin is explicitly closed, and any operation on it would raise a `ValueError("I/O operation on closed file")` exception, this function would just return False, since the session cannot be used interactively.
datalad/utils.py
is_interactive
AKSoo/datalad
python
def is_interactive(): 'Return True if all in/outs are open and tty.\n\n Note that in a somewhat abnormal case where e.g. stdin is explicitly\n closed, and any operation on it would raise a\n `ValueError("I/O operation on closed file")` exception, this function\n would just return False, since the sessio...
def get_ipython_shell(): 'Detect if running within IPython and returns its `ip` (shell) object\n\n Returns None if not under ipython (no `get_ipython` function)\n ' try: return get_ipython() except NameError: return None
7,239,483,232,310,486,000
Detect if running within IPython and returns its `ip` (shell) object Returns None if not under ipython (no `get_ipython` function)
datalad/utils.py
get_ipython_shell
AKSoo/datalad
python
def get_ipython_shell(): 'Detect if running within IPython and returns its `ip` (shell) object\n\n Returns None if not under ipython (no `get_ipython` function)\n ' try: return get_ipython() except NameError: return None
def md5sum(filename): 'Compute an MD5 sum for the given file\n ' from datalad.support.digests import Digester return Digester(digests=['md5'])(filename)['md5']
-6,846,947,516,037,588,000
Compute an MD5 sum for the given file
datalad/utils.py
md5sum
AKSoo/datalad
python
def md5sum(filename): '\n ' from datalad.support.digests import Digester return Digester(digests=['md5'])(filename)['md5']
def sorted_files(path): 'Return a (sorted) list of files under path\n ' return sorted(sum([[op.join(r, f)[(len(path) + 1):] for f in files] for (r, d, files) in os.walk(path) if (not ('.git' in r))], []))
-8,662,916,188,476,686,000
Return a (sorted) list of files under path
datalad/utils.py
sorted_files
AKSoo/datalad
python
def sorted_files(path): '\n ' return sorted(sum([[op.join(r, f)[(len(path) + 1):] for f in files] for (r, d, files) in os.walk(path) if (not ('.git' in r))], []))
def find_files(regex, topdir=curdir, exclude=None, exclude_vcs=True, exclude_datalad=False, dirs=False): 'Generator to find files matching regex\n\n Parameters\n ----------\n regex: basestring\n exclude: basestring, optional\n Matches to exclude\n exclude_vcs:\n If True, excludes commonly k...
-8,840,877,839,042,412,000
Generator to find files matching regex Parameters ---------- regex: basestring exclude: basestring, optional Matches to exclude exclude_vcs: If True, excludes commonly known VCS subdirectories. If string, used as regex to exclude those files (regex: `%r`) exclude_datalad: If True, excludes files known to be d...
datalad/utils.py
find_files
AKSoo/datalad
python
def find_files(regex, topdir=curdir, exclude=None, exclude_vcs=True, exclude_datalad=False, dirs=False): 'Generator to find files matching regex\n\n Parameters\n ----------\n regex: basestring\n exclude: basestring, optional\n Matches to exclude\n exclude_vcs:\n If True, excludes commonly k...
def expandpath(path, force_absolute=True): 'Expand all variables and user handles in a path.\n\n By default return an absolute path\n ' path = expandvars(expanduser(path)) if force_absolute: path = abspath(path) return path
-7,795,529,707,431,371,000
Expand all variables and user handles in a path. By default return an absolute path
datalad/utils.py
expandpath
AKSoo/datalad
python
def expandpath(path, force_absolute=True): 'Expand all variables and user handles in a path.\n\n By default return an absolute path\n ' path = expandvars(expanduser(path)) if force_absolute: path = abspath(path) return path
def posix_relpath(path, start=None): 'Behave like os.path.relpath, but always return POSIX paths...\n\n on any platform.' return posixpath.join(*split(relpath(path, start=(start if (start is not None) else ''))))
4,046,002,054,909,217,300
Behave like os.path.relpath, but always return POSIX paths... on any platform.
datalad/utils.py
posix_relpath
AKSoo/datalad
python
def posix_relpath(path, start=None): 'Behave like os.path.relpath, but always return POSIX paths...\n\n on any platform.' return posixpath.join(*split(relpath(path, start=(start if (start is not None) else ))))
def is_explicit_path(path): "Return whether a path explicitly points to a location\n\n Any absolute path, or relative path starting with either '../' or\n './' is assumed to indicate a location on the filesystem. Any other\n path format is not considered explicit." path = expandpath(path, force_absolut...
1,506,708,320,360,227,800
Return whether a path explicitly points to a location Any absolute path, or relative path starting with either '../' or './' is assumed to indicate a location on the filesystem. Any other path format is not considered explicit.
datalad/utils.py
is_explicit_path
AKSoo/datalad
python
def is_explicit_path(path): "Return whether a path explicitly points to a location\n\n Any absolute path, or relative path starting with either '../' or\n './' is assumed to indicate a location on the filesystem. Any other\n path format is not considered explicit." path = expandpath(path, force_absolut...
def rotree(path, ro=True, chmod_files=True): 'To make tree read-only or writable\n\n Parameters\n ----------\n path : string\n Path to the tree/directory to chmod\n ro : bool, optional\n Whether to make it R/O (default) or RW\n chmod_files : bool, optional\n Whether to operate also on ...
-5,822,748,150,281,047,000
To make tree read-only or writable Parameters ---------- path : string Path to the tree/directory to chmod ro : bool, optional Whether to make it R/O (default) or RW chmod_files : bool, optional Whether to operate also on files (not just directories)
datalad/utils.py
rotree
AKSoo/datalad
python
def rotree(path, ro=True, chmod_files=True): 'To make tree read-only or writable\n\n Parameters\n ----------\n path : string\n Path to the tree/directory to chmod\n ro : bool, optional\n Whether to make it R/O (default) or RW\n chmod_files : bool, optional\n Whether to operate also on ...
def rmtree(path, chmod_files='auto', children_only=False, *args, **kwargs): "To remove git-annex .git it is needed to make all files and directories writable again first\n\n Parameters\n ----------\n path: Path or str\n Path to remove\n chmod_files : string or bool, optional\n Whether to mak...
-4,424,460,177,924,723,000
To remove git-annex .git it is needed to make all files and directories writable again first Parameters ---------- path: Path or str Path to remove chmod_files : string or bool, optional Whether to make files writable also before removal. Usually it is just a matter of directories to have write permissions. ...
datalad/utils.py
rmtree
AKSoo/datalad
python
def rmtree(path, chmod_files='auto', children_only=False, *args, **kwargs): "To remove git-annex .git it is needed to make all files and directories writable again first\n\n Parameters\n ----------\n path: Path or str\n Path to remove\n chmod_files : string or bool, optional\n Whether to mak...
def rmdir(path, *args, **kwargs): 'os.rmdir with our optional checking for open files' assert_no_open_files(path) os.rmdir(path)
-3,323,220,695,162,720,000
os.rmdir with our optional checking for open files
datalad/utils.py
rmdir
AKSoo/datalad
python
def rmdir(path, *args, **kwargs): assert_no_open_files(path) os.rmdir(path)
def get_open_files(path, log_open=False): 'Get open files under a path\n\n Note: This function is very slow on Windows.\n\n Parameters\n ----------\n path : str\n File or directory to check for open files under\n log_open : bool or int\n If set - logger level to use\n\n Returns\n ----...
5,590,518,783,537,523,000
Get open files under a path Note: This function is very slow on Windows. Parameters ---------- path : str File or directory to check for open files under log_open : bool or int If set - logger level to use Returns ------- dict path : pid
datalad/utils.py
get_open_files
AKSoo/datalad
python
def get_open_files(path, log_open=False): 'Get open files under a path\n\n Note: This function is very slow on Windows.\n\n Parameters\n ----------\n path : str\n File or directory to check for open files under\n log_open : bool or int\n If set - logger level to use\n\n Returns\n ----...
def rmtemp(f, *args, **kwargs): 'Wrapper to centralize removing of temp files so we could keep them around\n\n It will not remove the temporary file/directory if DATALAD_TESTS_TEMP_KEEP\n environment variable is defined\n ' if (not os.environ.get('DATALAD_TESTS_TEMP_KEEP')): if (not os.path.lex...
-2,435,413,394,078,092,000
Wrapper to centralize removing of temp files so we could keep them around It will not remove the temporary file/directory if DATALAD_TESTS_TEMP_KEEP environment variable is defined
datalad/utils.py
rmtemp
AKSoo/datalad
python
def rmtemp(f, *args, **kwargs): 'Wrapper to centralize removing of temp files so we could keep them around\n\n It will not remove the temporary file/directory if DATALAD_TESTS_TEMP_KEEP\n environment variable is defined\n ' if (not os.environ.get('DATALAD_TESTS_TEMP_KEEP')): if (not os.path.lex...
def file_basename(name, return_ext=False): '\n Strips up to 2 extensions of length up to 4 characters and starting with alpha\n not a digit, so we could get rid of .tar.gz etc\n ' bname = basename(name) fbname = re.sub('(\\.[a-zA-Z_]\\S{1,4}){0,2}$', '', bname) if return_ext: return (fb...
-4,242,195,939,967,012,400
Strips up to 2 extensions of length up to 4 characters and starting with alpha not a digit, so we could get rid of .tar.gz etc
datalad/utils.py
file_basename
AKSoo/datalad
python
def file_basename(name, return_ext=False): '\n Strips up to 2 extensions of length up to 4 characters and starting with alpha\n not a digit, so we could get rid of .tar.gz etc\n ' bname = basename(name) fbname = re.sub('(\\.[a-zA-Z_]\\S{1,4}){0,2}$', , bname) if return_ext: return (fbna...
def escape_filename(filename): 'Surround filename in "" and escape " in the filename\n ' filename = filename.replace('"', '\\"').replace('`', '\\`') filename = ('"%s"' % filename) return filename
-4,358,157,444,839,086,600
Surround filename in "" and escape " in the filename
datalad/utils.py
escape_filename
AKSoo/datalad
python
def escape_filename(filename): '\n ' filename = filename.replace('"', '\\"').replace('`', '\\`') filename = ('"%s"' % filename) return filename
def encode_filename(filename): 'Encode unicode filename\n ' if isinstance(filename, str): return filename.encode(sys.getfilesystemencoding()) else: return filename
-9,183,947,159,578,037,000
Encode unicode filename
datalad/utils.py
encode_filename
AKSoo/datalad
python
def encode_filename(filename): '\n ' if isinstance(filename, str): return filename.encode(sys.getfilesystemencoding()) else: return filename
def decode_input(s): 'Given input string/bytes, decode according to stdin codepage (or UTF-8)\n if not defined\n\n If fails -- issue warning and decode allowing for errors\n being replaced\n ' if isinstance(s, str): return s else: encoding = (sys.stdin.encoding or 'UTF-8') ...
-4,714,567,132,680,451,000
Given input string/bytes, decode according to stdin codepage (or UTF-8) if not defined If fails -- issue warning and decode allowing for errors being replaced
datalad/utils.py
decode_input
AKSoo/datalad
python
def decode_input(s): 'Given input string/bytes, decode according to stdin codepage (or UTF-8)\n if not defined\n\n If fails -- issue warning and decode allowing for errors\n being replaced\n ' if isinstance(s, str): return s else: encoding = (sys.stdin.encoding or 'UTF-8') ...
def ensure_tuple_or_list(obj): 'Given an object, wrap into a tuple if not list or tuple\n ' if isinstance(obj, (list, tuple)): return obj return (obj,)
-6,620,389,213,814,764,000
Given an object, wrap into a tuple if not list or tuple
datalad/utils.py
ensure_tuple_or_list
AKSoo/datalad
python
def ensure_tuple_or_list(obj): '\n ' if isinstance(obj, (list, tuple)): return obj return (obj,)
def ensure_iter(s, cls, copy=False, iterate=True): 'Given not a list, would place it into a list. If None - empty list is returned\n\n Parameters\n ----------\n s: list or anything\n cls: class\n Which iterable class to ensure\n copy: bool, optional\n If correct iterable is passed, it would...
-8,192,520,584,669,999,000
Given not a list, would place it into a list. If None - empty list is returned Parameters ---------- s: list or anything cls: class Which iterable class to ensure copy: bool, optional If correct iterable is passed, it would generate its shallow copy iterate: bool, optional If it is not a list, but something iter...
datalad/utils.py
ensure_iter
AKSoo/datalad
python
def ensure_iter(s, cls, copy=False, iterate=True): 'Given not a list, would place it into a list. If None - empty list is returned\n\n Parameters\n ----------\n s: list or anything\n cls: class\n Which iterable class to ensure\n copy: bool, optional\n If correct iterable is passed, it would...
def ensure_list(s, copy=False, iterate=True): 'Given not a list, would place it into a list. If None - empty list is returned\n\n Parameters\n ----------\n s: list or anything\n copy: bool, optional\n If list is passed, it would generate a shallow copy of the list\n iterate: bool, optional\n ...
-7,572,995,100,661,384,000
Given not a list, would place it into a list. If None - empty list is returned Parameters ---------- s: list or anything copy: bool, optional If list is passed, it would generate a shallow copy of the list iterate: bool, optional If it is not a list, but something iterable (but not a str) iterate over it.
datalad/utils.py
ensure_list
AKSoo/datalad
python
def ensure_list(s, copy=False, iterate=True): 'Given not a list, would place it into a list. If None - empty list is returned\n\n Parameters\n ----------\n s: list or anything\n copy: bool, optional\n If list is passed, it would generate a shallow copy of the list\n iterate: bool, optional\n ...
def ensure_list_from_str(s, sep='\n'): 'Given a multiline string convert it to a list of return None if empty\n\n Parameters\n ----------\n s: str or list\n ' if (not s): return None if isinstance(s, list): return s return s.split(sep)
-3,554,266,283,958,024,000
Given a multiline string convert it to a list of return None if empty Parameters ---------- s: str or list
datalad/utils.py
ensure_list_from_str
AKSoo/datalad
python
def ensure_list_from_str(s, sep='\n'): 'Given a multiline string convert it to a list of return None if empty\n\n Parameters\n ----------\n s: str or list\n ' if (not s): return None if isinstance(s, list): return s return s.split(sep)
def ensure_dict_from_str(s, **kwargs): 'Given a multiline string with key=value items convert it to a dictionary\n\n Parameters\n ----------\n s: str or dict\n\n Returns None if input s is empty\n ' if (not s): return None if isinstance(s, dict): return s out = {} for ...
3,087,126,313,354,959,400
Given a multiline string with key=value items convert it to a dictionary Parameters ---------- s: str or dict Returns None if input s is empty
datalad/utils.py
ensure_dict_from_str
AKSoo/datalad
python
def ensure_dict_from_str(s, **kwargs): 'Given a multiline string with key=value items convert it to a dictionary\n\n Parameters\n ----------\n s: str or dict\n\n Returns None if input s is empty\n ' if (not s): return None if isinstance(s, dict): return s out = {} for ...
def ensure_bytes(s, encoding='utf-8'): 'Convert/encode unicode string to bytes.\n\n If `s` isn\'t a string, return it as is.\n\n Parameters\n ----------\n encoding: str, optional\n Encoding to use. "utf-8" is the default\n ' if (not isinstance(s, str)): return s return s.encode(...
-7,053,226,920,306,413,000
Convert/encode unicode string to bytes. If `s` isn't a string, return it as is. Parameters ---------- encoding: str, optional Encoding to use. "utf-8" is the default
datalad/utils.py
ensure_bytes
AKSoo/datalad
python
def ensure_bytes(s, encoding='utf-8'): 'Convert/encode unicode string to bytes.\n\n If `s` isn\'t a string, return it as is.\n\n Parameters\n ----------\n encoding: str, optional\n Encoding to use. "utf-8" is the default\n ' if (not isinstance(s, str)): return s return s.encode(...
def ensure_unicode(s, encoding=None, confidence=None): 'Convert/decode bytestring to unicode.\n\n If `s` isn\'t a bytestring, return it as is.\n\n Parameters\n ----------\n encoding: str, optional\n Encoding to use. If None, "utf-8" is tried, and then if not a valid\n UTF-8, encoding will be ...
-1,053,787,349,956,682,400
Convert/decode bytestring to unicode. If `s` isn't a bytestring, return it as is. Parameters ---------- encoding: str, optional Encoding to use. If None, "utf-8" is tried, and then if not a valid UTF-8, encoding will be guessed confidence: float, optional A value between 0 and 1, so if guessing of encoding is ...
datalad/utils.py
ensure_unicode
AKSoo/datalad
python
def ensure_unicode(s, encoding=None, confidence=None): 'Convert/decode bytestring to unicode.\n\n If `s` isn\'t a bytestring, return it as is.\n\n Parameters\n ----------\n encoding: str, optional\n Encoding to use. If None, "utf-8" is tried, and then if not a valid\n UTF-8, encoding will be ...
def ensure_bool(s): 'Convert value into boolean following convention for strings\n\n to recognize on,True,yes as True, off,False,no as False\n ' if isinstance(s, str): if s.isdigit(): return bool(int(s)) sl = s.lower() if (sl in {'y', 'yes', 'true', 'on'}): ...
5,458,731,529,325,434,000
Convert value into boolean following convention for strings to recognize on,True,yes as True, off,False,no as False
datalad/utils.py
ensure_bool
AKSoo/datalad
python
def ensure_bool(s): 'Convert value into boolean following convention for strings\n\n to recognize on,True,yes as True, off,False,no as False\n ' if isinstance(s, str): if s.isdigit(): return bool(int(s)) sl = s.lower() if (sl in {'y', 'yes', 'true', 'on'}): ...
def as_unicode(val, cast_types=object): 'Given an arbitrary value, would try to obtain unicode value of it\n \n For unicode it would return original value, for python2 str or python3\n bytes it would use ensure_unicode, for None - an empty (unicode) string,\n and for any other type (see `cast_types`) - ...
-5,259,481,238,356,841,000
Given an arbitrary value, would try to obtain unicode value of it For unicode it would return original value, for python2 str or python3 bytes it would use ensure_unicode, for None - an empty (unicode) string, and for any other type (see `cast_types`) - would apply the unicode constructor. If value is not an instanc...
datalad/utils.py
as_unicode
AKSoo/datalad
python
def as_unicode(val, cast_types=object): 'Given an arbitrary value, would try to obtain unicode value of it\n \n For unicode it would return original value, for python2 str or python3\n bytes it would use ensure_unicode, for None - an empty (unicode) string,\n and for any other type (see `cast_types`) - ...
def unique(seq, key=None, reverse=False): 'Given a sequence return a list only with unique elements while maintaining order\n\n This is the fastest solution. See\n https://www.peterbe.com/plog/uniqifiers-benchmark\n and\n http://stackoverflow.com/a/480227/1265472\n for more information.\n Enhance...
4,005,972,471,792,257,000
Given a sequence return a list only with unique elements while maintaining order This is the fastest solution. See https://www.peterbe.com/plog/uniqifiers-benchmark and http://stackoverflow.com/a/480227/1265472 for more information. Enhancement -- added ability to compare for uniqueness using a key function Paramete...
datalad/utils.py
unique
AKSoo/datalad
python
def unique(seq, key=None, reverse=False): 'Given a sequence return a list only with unique elements while maintaining order\n\n This is the fastest solution. See\n https://www.peterbe.com/plog/uniqifiers-benchmark\n and\n http://stackoverflow.com/a/480227/1265472\n for more information.\n Enhance...
def all_same(items): 'Quick check if all items are the same.\n\n Identical to a check like len(set(items)) == 1 but\n should be more efficient while working on generators, since would\n return False as soon as any difference detected thus possibly avoiding\n unnecessary evaluations\n ' first = Tr...
3,611,848,074,102,730,000
Quick check if all items are the same. Identical to a check like len(set(items)) == 1 but should be more efficient while working on generators, since would return False as soon as any difference detected thus possibly avoiding unnecessary evaluations
datalad/utils.py
all_same
AKSoo/datalad
python
def all_same(items): 'Quick check if all items are the same.\n\n Identical to a check like len(set(items)) == 1 but\n should be more efficient while working on generators, since would\n return False as soon as any difference detected thus possibly avoiding\n unnecessary evaluations\n ' first = Tr...