repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
brechtm/rinohtype
doc/build.py
help
def help(): """List all targets""" print("Please use '{} <target>' where <target> is one of" .format(sys.argv[0])) width = max(len(name) for name in TARGETS) for name, target in TARGETS.items(): print(' {name:{width}} {descr}'.format(name=name, width=width, ...
python
def help(): """List all targets""" print("Please use '{} <target>' where <target> is one of" .format(sys.argv[0])) width = max(len(name) for name in TARGETS) for name, target in TARGETS.items(): print(' {name:{width}} {descr}'.format(name=name, width=width, ...
[ "def", "help", "(", ")", ":", "print", "(", "\"Please use '{} <target>' where <target> is one of\"", ".", "format", "(", "sys", ".", "argv", "[", "0", "]", ")", ")", "width", "=", "max", "(", "len", "(", "name", ")", "for", "name", "in", "TARGETS", ")", ...
List all targets
[ "List", "all", "targets" ]
40a63c4e5ad7550f62b6860f1812cb67cafb9dc7
https://github.com/brechtm/rinohtype/blob/40a63c4e5ad7550f62b6860f1812cb67cafb9dc7/doc/build.py#L253-L260
train
brechtm/rinohtype
src/rinoh/font/__init__.py
Typeface.fonts
def fonts(self): """Generator yielding all fonts of this typeface Yields: Font: the next font in this typeface """ for width in (w for w in FontWidth if w in self): for slant in (s for s in FontSlant if s in self[width]): for weight in (w for w i...
python
def fonts(self): """Generator yielding all fonts of this typeface Yields: Font: the next font in this typeface """ for width in (w for w in FontWidth if w in self): for slant in (s for s in FontSlant if s in self[width]): for weight in (w for w i...
[ "def", "fonts", "(", "self", ")", ":", "for", "width", "in", "(", "w", "for", "w", "in", "FontWidth", "if", "w", "in", "self", ")", ":", "for", "slant", "in", "(", "s", "for", "s", "in", "FontSlant", "if", "s", "in", "self", "[", "width", "]", ...
Generator yielding all fonts of this typeface Yields: Font: the next font in this typeface
[ "Generator", "yielding", "all", "fonts", "of", "this", "typeface" ]
40a63c4e5ad7550f62b6860f1812cb67cafb9dc7
https://github.com/brechtm/rinohtype/blob/40a63c4e5ad7550f62b6860f1812cb67cafb9dc7/src/rinoh/font/__init__.py#L194-L205
train
brechtm/rinohtype
src/rinoh/font/__init__.py
Typeface.get_font
def get_font(self, weight='medium', slant='upright', width='normal'): """Return the font matching or closest to the given style If a font with the given weight, slant and width is available, return it. Otherwise, return the font that is closest in style. Args: weight (FontW...
python
def get_font(self, weight='medium', slant='upright', width='normal'): """Return the font matching or closest to the given style If a font with the given weight, slant and width is available, return it. Otherwise, return the font that is closest in style. Args: weight (FontW...
[ "def", "get_font", "(", "self", ",", "weight", "=", "'medium'", ",", "slant", "=", "'upright'", ",", "width", "=", "'normal'", ")", ":", "def", "find_closest_style", "(", "style", ",", "styles", ",", "alternatives", ")", ":", "try", ":", "return", "style...
Return the font matching or closest to the given style If a font with the given weight, slant and width is available, return it. Otherwise, return the font that is closest in style. Args: weight (FontWeight): weight of the font slant (FontSlant): slant of the font ...
[ "Return", "the", "font", "matching", "or", "closest", "to", "the", "given", "style" ]
40a63c4e5ad7550f62b6860f1812cb67cafb9dc7
https://github.com/brechtm/rinohtype/blob/40a63c4e5ad7550f62b6860f1812cb67cafb9dc7/src/rinoh/font/__init__.py#L207-L253
train
brechtm/rinohtype
src/rinoh/style.py
StyleSheet.get_selector
def get_selector(self, name): """Find a selector mapped to a style in this or a base style sheet. Args: name (str): a style name Returns: :class:`.Selector`: the selector mapped to the style `name` Raises: KeyError: if the style `name` was not found...
python
def get_selector(self, name): """Find a selector mapped to a style in this or a base style sheet. Args: name (str): a style name Returns: :class:`.Selector`: the selector mapped to the style `name` Raises: KeyError: if the style `name` was not found...
[ "def", "get_selector", "(", "self", ",", "name", ")", ":", "try", ":", "return", "self", ".", "matcher", ".", "by_name", "[", "name", "]", "except", "(", "AttributeError", ",", "KeyError", ")", ":", "if", "self", ".", "base", "is", "not", "None", ":"...
Find a selector mapped to a style in this or a base style sheet. Args: name (str): a style name Returns: :class:`.Selector`: the selector mapped to the style `name` Raises: KeyError: if the style `name` was not found in this or a base style ...
[ "Find", "a", "selector", "mapped", "to", "a", "style", "in", "this", "or", "a", "base", "style", "sheet", "." ]
40a63c4e5ad7550f62b6860f1812cb67cafb9dc7
https://github.com/brechtm/rinohtype/blob/40a63c4e5ad7550f62b6860f1812cb67cafb9dc7/src/rinoh/style.py#L761-L782
train
brechtm/rinohtype
src/rinoh/style.py
CharIterator.match
def match(self, chars): """Return all next characters that are listed in `chars` as a string""" start_index = self.next_index for char in self: if char not in chars: self.next_index -= 1 break return self[start_index:self.next_index]
python
def match(self, chars): """Return all next characters that are listed in `chars` as a string""" start_index = self.next_index for char in self: if char not in chars: self.next_index -= 1 break return self[start_index:self.next_index]
[ "def", "match", "(", "self", ",", "chars", ")", ":", "start_index", "=", "self", ".", "next_index", "for", "char", "in", "self", ":", "if", "char", "not", "in", "chars", ":", "self", ".", "next_index", "-=", "1", "break", "return", "self", "[", "star...
Return all next characters that are listed in `chars` as a string
[ "Return", "all", "next", "characters", "that", "are", "listed", "in", "chars", "as", "a", "string" ]
40a63c4e5ad7550f62b6860f1812cb67cafb9dc7
https://github.com/brechtm/rinohtype/blob/40a63c4e5ad7550f62b6860f1812cb67cafb9dc7/src/rinoh/style.py#L983-L990
train
brechtm/rinohtype
src/rinoh/backend/pdf/xobject/purepng.py
_rel_import
def _rel_import(module, tgt): """Using relative import in both Python 2 and Python 3""" try: exec("from ." + module + " import " + tgt, globals(), locals()) except SyntaxError: # On Python < 2.5 relative import cause syntax error exec("from " + module + " import " + tgt, globals(), l...
python
def _rel_import(module, tgt): """Using relative import in both Python 2 and Python 3""" try: exec("from ." + module + " import " + tgt, globals(), locals()) except SyntaxError: # On Python < 2.5 relative import cause syntax error exec("from " + module + " import " + tgt, globals(), l...
[ "def", "_rel_import", "(", "module", ",", "tgt", ")", ":", "try", ":", "exec", "(", "\"from .\"", "+", "module", "+", "\" import \"", "+", "tgt", ",", "globals", "(", ")", ",", "locals", "(", ")", ")", "except", "SyntaxError", ":", "exec", "(", "\"fr...
Using relative import in both Python 2 and Python 3
[ "Using", "relative", "import", "in", "both", "Python", "2", "and", "Python", "3" ]
40a63c4e5ad7550f62b6860f1812cb67cafb9dc7
https://github.com/brechtm/rinohtype/blob/40a63c4e5ad7550f62b6860f1812cb67cafb9dc7/src/rinoh/backend/pdf/xobject/purepng.py#L207-L217
train
brechtm/rinohtype
src/rinoh/backend/pdf/xobject/purepng.py
peekiter
def peekiter(iterable): """Return first row and also iterable with same items as original""" it = iter(iterable) one = next(it) def gen(): """Generator that returns first and proxy other items from source""" yield one while True: yield next(it) return (one, gen()...
python
def peekiter(iterable): """Return first row and also iterable with same items as original""" it = iter(iterable) one = next(it) def gen(): """Generator that returns first and proxy other items from source""" yield one while True: yield next(it) return (one, gen()...
[ "def", "peekiter", "(", "iterable", ")", ":", "it", "=", "iter", "(", "iterable", ")", "one", "=", "next", "(", "it", ")", "def", "gen", "(", ")", ":", "yield", "one", "while", "True", ":", "yield", "next", "(", "it", ")", "return", "(", "one", ...
Return first row and also iterable with same items as original
[ "Return", "first", "row", "and", "also", "iterable", "with", "same", "items", "as", "original" ]
40a63c4e5ad7550f62b6860f1812cb67cafb9dc7
https://github.com/brechtm/rinohtype/blob/40a63c4e5ad7550f62b6860f1812cb67cafb9dc7/src/rinoh/backend/pdf/xobject/purepng.py#L321-L331
train
brechtm/rinohtype
src/rinoh/backend/pdf/xobject/purepng.py
check_sizes
def check_sizes(size, width, height): """ Check that these arguments, in supplied, are consistent. Return a (width, height) pair. """ if not size: return width, height if len(size) != 2: raise ValueError( "size argument should be a pair (width, height)") if width ...
python
def check_sizes(size, width, height): """ Check that these arguments, in supplied, are consistent. Return a (width, height) pair. """ if not size: return width, height if len(size) != 2: raise ValueError( "size argument should be a pair (width, height)") if width ...
[ "def", "check_sizes", "(", "size", ",", "width", ",", "height", ")", ":", "if", "not", "size", ":", "return", "width", ",", "height", "if", "len", "(", "size", ")", "!=", "2", ":", "raise", "ValueError", "(", "\"size argument should be a pair (width, height)...
Check that these arguments, in supplied, are consistent. Return a (width, height) pair.
[ "Check", "that", "these", "arguments", "in", "supplied", "are", "consistent", "." ]
40a63c4e5ad7550f62b6860f1812cb67cafb9dc7
https://github.com/brechtm/rinohtype/blob/40a63c4e5ad7550f62b6860f1812cb67cafb9dc7/src/rinoh/backend/pdf/xobject/purepng.py#L364-L384
train
brechtm/rinohtype
src/rinoh/backend/pdf/xobject/purepng.py
check_color
def check_color(c, greyscale, which): """ Checks that a colour argument is the right form. Returns the colour (which, if it's a bar integer, is "corrected" to a 1-tuple). For transparent or background options. """ if c is None: return c if greyscale: try: len...
python
def check_color(c, greyscale, which): """ Checks that a colour argument is the right form. Returns the colour (which, if it's a bar integer, is "corrected" to a 1-tuple). For transparent or background options. """ if c is None: return c if greyscale: try: len...
[ "def", "check_color", "(", "c", ",", "greyscale", ",", "which", ")", ":", "if", "c", "is", "None", ":", "return", "c", "if", "greyscale", ":", "try", ":", "len", "(", "c", ")", "except", "TypeError", ":", "c", "=", "(", "c", ",", ")", "if", "le...
Checks that a colour argument is the right form. Returns the colour (which, if it's a bar integer, is "corrected" to a 1-tuple). For transparent or background options.
[ "Checks", "that", "a", "colour", "argument", "is", "the", "right", "form", "." ]
40a63c4e5ad7550f62b6860f1812cb67cafb9dc7
https://github.com/brechtm/rinohtype/blob/40a63c4e5ad7550f62b6860f1812cb67cafb9dc7/src/rinoh/backend/pdf/xobject/purepng.py#L387-L415
train
brechtm/rinohtype
src/rinoh/backend/pdf/xobject/purepng.py
check_time
def check_time(value): """Convert time from most popular representations to datetime""" if value is None: return None if isinstance(value, (time.struct_time, tuple)): return value if isinstance(value, datetime.datetime): return value.timetuple() if isinstance(value, datetime....
python
def check_time(value): """Convert time from most popular representations to datetime""" if value is None: return None if isinstance(value, (time.struct_time, tuple)): return value if isinstance(value, datetime.datetime): return value.timetuple() if isinstance(value, datetime....
[ "def", "check_time", "(", "value", ")", ":", "if", "value", "is", "None", ":", "return", "None", "if", "isinstance", "(", "value", ",", "(", "time", ".", "struct_time", ",", "tuple", ")", ")", ":", "return", "value", "if", "isinstance", "(", "value", ...
Convert time from most popular representations to datetime
[ "Convert", "time", "from", "most", "popular", "representations", "to", "datetime" ]
40a63c4e5ad7550f62b6860f1812cb67cafb9dc7
https://github.com/brechtm/rinohtype/blob/40a63c4e5ad7550f62b6860f1812cb67cafb9dc7/src/rinoh/backend/pdf/xobject/purepng.py#L418-L440
train
brechtm/rinohtype
src/rinoh/backend/pdf/xobject/purepng.py
try_greyscale
def try_greyscale(pixels, alpha=False, dirty_alpha=True): """ Check if flatboxed RGB `pixels` could be converted to greyscale If could - return iterator with greyscale pixels, otherwise return `False` constant """ planes = 3 + bool(alpha) res = list() apix = list() for row in pixels...
python
def try_greyscale(pixels, alpha=False, dirty_alpha=True): """ Check if flatboxed RGB `pixels` could be converted to greyscale If could - return iterator with greyscale pixels, otherwise return `False` constant """ planes = 3 + bool(alpha) res = list() apix = list() for row in pixels...
[ "def", "try_greyscale", "(", "pixels", ",", "alpha", "=", "False", ",", "dirty_alpha", "=", "True", ")", ":", "planes", "=", "3", "+", "bool", "(", "alpha", ")", "res", "=", "list", "(", ")", "apix", "=", "list", "(", ")", "for", "row", "in", "pi...
Check if flatboxed RGB `pixels` could be converted to greyscale If could - return iterator with greyscale pixels, otherwise return `False` constant
[ "Check", "if", "flatboxed", "RGB", "pixels", "could", "be", "converted", "to", "greyscale" ]
40a63c4e5ad7550f62b6860f1812cb67cafb9dc7
https://github.com/brechtm/rinohtype/blob/40a63c4e5ad7550f62b6860f1812cb67cafb9dc7/src/rinoh/backend/pdf/xobject/purepng.py#L456-L477
train
brechtm/rinohtype
src/rinoh/backend/pdf/xobject/purepng.py
adapt_sum
def adapt_sum(line, cfg, filter_obj): """Determine best filter by sum of all row values""" lines = filter_obj.filter_all(line) res_s = [sum(it) for it in lines] r = res_s.index(min(res_s)) return lines[r]
python
def adapt_sum(line, cfg, filter_obj): """Determine best filter by sum of all row values""" lines = filter_obj.filter_all(line) res_s = [sum(it) for it in lines] r = res_s.index(min(res_s)) return lines[r]
[ "def", "adapt_sum", "(", "line", ",", "cfg", ",", "filter_obj", ")", ":", "lines", "=", "filter_obj", ".", "filter_all", "(", "line", ")", "res_s", "=", "[", "sum", "(", "it", ")", "for", "it", "in", "lines", "]", "r", "=", "res_s", ".", "index", ...
Determine best filter by sum of all row values
[ "Determine", "best", "filter", "by", "sum", "of", "all", "row", "values" ]
40a63c4e5ad7550f62b6860f1812cb67cafb9dc7
https://github.com/brechtm/rinohtype/blob/40a63c4e5ad7550f62b6860f1812cb67cafb9dc7/src/rinoh/backend/pdf/xobject/purepng.py#L1780-L1785
train
brechtm/rinohtype
src/rinoh/backend/pdf/xobject/purepng.py
adapt_entropy
def adapt_entropy(line, cfg, filter_obj): """Determine best filter by dispersion of row values""" lines = filter_obj.filter_all(line) res_c = [len(set(it)) for it in lines] r = res_c.index(min(res_c)) return lines[r]
python
def adapt_entropy(line, cfg, filter_obj): """Determine best filter by dispersion of row values""" lines = filter_obj.filter_all(line) res_c = [len(set(it)) for it in lines] r = res_c.index(min(res_c)) return lines[r]
[ "def", "adapt_entropy", "(", "line", ",", "cfg", ",", "filter_obj", ")", ":", "lines", "=", "filter_obj", ".", "filter_all", "(", "line", ")", "res_c", "=", "[", "len", "(", "set", "(", "it", ")", ")", "for", "it", "in", "lines", "]", "r", "=", "...
Determine best filter by dispersion of row values
[ "Determine", "best", "filter", "by", "dispersion", "of", "row", "values" ]
40a63c4e5ad7550f62b6860f1812cb67cafb9dc7
https://github.com/brechtm/rinohtype/blob/40a63c4e5ad7550f62b6860f1812cb67cafb9dc7/src/rinoh/backend/pdf/xobject/purepng.py#L1789-L1794
train
brechtm/rinohtype
src/rinoh/backend/pdf/xobject/purepng.py
BaseFilter.__do_filter_sub
def __do_filter_sub(self, scanline, result): """Sub filter.""" ai = 0 for i in range(self.fu, len(result)): x = scanline[i] a = scanline[ai] result[i] = (x - a) & 0xff ai += 1
python
def __do_filter_sub(self, scanline, result): """Sub filter.""" ai = 0 for i in range(self.fu, len(result)): x = scanline[i] a = scanline[ai] result[i] = (x - a) & 0xff ai += 1
[ "def", "__do_filter_sub", "(", "self", ",", "scanline", ",", "result", ")", ":", "ai", "=", "0", "for", "i", "in", "range", "(", "self", ".", "fu", ",", "len", "(", "result", ")", ")", ":", "x", "=", "scanline", "[", "i", "]", "a", "=", "scanli...
Sub filter.
[ "Sub", "filter", "." ]
40a63c4e5ad7550f62b6860f1812cb67cafb9dc7
https://github.com/brechtm/rinohtype/blob/40a63c4e5ad7550f62b6860f1812cb67cafb9dc7/src/rinoh/backend/pdf/xobject/purepng.py#L529-L536
train
brechtm/rinohtype
src/rinoh/backend/pdf/xobject/purepng.py
BaseFilter.__do_filter_up
def __do_filter_up(self, scanline, result): """Up filter.""" previous = self.prev for i in range(len(result)): x = scanline[i] b = previous[i] result[i] = (x - b) & 0xff
python
def __do_filter_up(self, scanline, result): """Up filter.""" previous = self.prev for i in range(len(result)): x = scanline[i] b = previous[i] result[i] = (x - b) & 0xff
[ "def", "__do_filter_up", "(", "self", ",", "scanline", ",", "result", ")", ":", "previous", "=", "self", ".", "prev", "for", "i", "in", "range", "(", "len", "(", "result", ")", ")", ":", "x", "=", "scanline", "[", "i", "]", "b", "=", "previous", ...
Up filter.
[ "Up", "filter", "." ]
40a63c4e5ad7550f62b6860f1812cb67cafb9dc7
https://github.com/brechtm/rinohtype/blob/40a63c4e5ad7550f62b6860f1812cb67cafb9dc7/src/rinoh/backend/pdf/xobject/purepng.py#L546-L552
train
brechtm/rinohtype
src/rinoh/backend/pdf/xobject/purepng.py
BaseFilter.__undo_filter_average
def __undo_filter_average(self, scanline): """Undo average filter.""" ai = -self.fu previous = self.prev for i in range(len(scanline)): x = scanline[i] if ai < 0: a = 0 else: a = scanline[ai] # result b = pr...
python
def __undo_filter_average(self, scanline): """Undo average filter.""" ai = -self.fu previous = self.prev for i in range(len(scanline)): x = scanline[i] if ai < 0: a = 0 else: a = scanline[ai] # result b = pr...
[ "def", "__undo_filter_average", "(", "self", ",", "scanline", ")", ":", "ai", "=", "-", "self", ".", "fu", "previous", "=", "self", ".", "prev", "for", "i", "in", "range", "(", "len", "(", "scanline", ")", ")", ":", "x", "=", "scanline", "[", "i", ...
Undo average filter.
[ "Undo", "average", "filter", "." ]
40a63c4e5ad7550f62b6860f1812cb67cafb9dc7
https://github.com/brechtm/rinohtype/blob/40a63c4e5ad7550f62b6860f1812cb67cafb9dc7/src/rinoh/backend/pdf/xobject/purepng.py#L554-L566
train
brechtm/rinohtype
src/rinoh/backend/pdf/xobject/purepng.py
BaseFilter.undo_filter
def undo_filter(self, filter_type, line): """ Undo the filter for a scanline. `scanline` is a sequence of bytes that does not include the initial filter type byte. The scanline will have the effects of filtering removed. Scanline modified inplace and also returned as re...
python
def undo_filter(self, filter_type, line): """ Undo the filter for a scanline. `scanline` is a sequence of bytes that does not include the initial filter type byte. The scanline will have the effects of filtering removed. Scanline modified inplace and also returned as re...
[ "def", "undo_filter", "(", "self", ",", "filter_type", ",", "line", ")", ":", "assert", "0", "<=", "filter_type", "<=", "4", "if", "self", ".", "prev", "is", "None", ":", "self", ".", "prev", "=", "newBarray", "(", "len", "(", "line", ")", ")", "if...
Undo the filter for a scanline. `scanline` is a sequence of bytes that does not include the initial filter type byte. The scanline will have the effects of filtering removed. Scanline modified inplace and also returned as result.
[ "Undo", "the", "filter", "for", "a", "scanline", "." ]
40a63c4e5ad7550f62b6860f1812cb67cafb9dc7
https://github.com/brechtm/rinohtype/blob/40a63c4e5ad7550f62b6860f1812cb67cafb9dc7/src/rinoh/backend/pdf/xobject/purepng.py#L631-L665
train
brechtm/rinohtype
src/rinoh/backend/pdf/xobject/purepng.py
BaseFilter._filter_scanline
def _filter_scanline(self, filter_type, line, result): """ Apply a scanline filter to a scanline. `filter_type` specifies the filter type (0 to 4) 'line` specifies the current (unfiltered) scanline as a sequence of bytes; """ assert 0 <= filter_type < 5 i...
python
def _filter_scanline(self, filter_type, line, result): """ Apply a scanline filter to a scanline. `filter_type` specifies the filter type (0 to 4) 'line` specifies the current (unfiltered) scanline as a sequence of bytes; """ assert 0 <= filter_type < 5 i...
[ "def", "_filter_scanline", "(", "self", ",", "filter_type", ",", "line", ",", "result", ")", ":", "assert", "0", "<=", "filter_type", "<", "5", "if", "self", ".", "prev", "is", "None", ":", "if", "filter_type", "==", "2", ":", "filter_type", "=", "0", ...
Apply a scanline filter to a scanline. `filter_type` specifies the filter type (0 to 4) 'line` specifies the current (unfiltered) scanline as a sequence of bytes;
[ "Apply", "a", "scanline", "filter", "to", "a", "scanline", "." ]
40a63c4e5ad7550f62b6860f1812cb67cafb9dc7
https://github.com/brechtm/rinohtype/blob/40a63c4e5ad7550f62b6860f1812cb67cafb9dc7/src/rinoh/backend/pdf/xobject/purepng.py#L667-L696
train
brechtm/rinohtype
src/rinoh/backend/pdf/xobject/purepng.py
BaseFilter.convert_la_to_rgba
def convert_la_to_rgba(self, row, result): """Convert a grayscale image with alpha to RGBA.""" for i in range(len(row) // 3): for j in range(3): result[(4 * i) + j] = row[2 * i] result[(4 * i) + 3] = row[(2 * i) + 1]
python
def convert_la_to_rgba(self, row, result): """Convert a grayscale image with alpha to RGBA.""" for i in range(len(row) // 3): for j in range(3): result[(4 * i) + j] = row[2 * i] result[(4 * i) + 3] = row[(2 * i) + 1]
[ "def", "convert_la_to_rgba", "(", "self", ",", "row", ",", "result", ")", ":", "for", "i", "in", "range", "(", "len", "(", "row", ")", "//", "3", ")", ":", "for", "j", "in", "range", "(", "3", ")", ":", "result", "[", "(", "4", "*", "i", ")",...
Convert a grayscale image with alpha to RGBA.
[ "Convert", "a", "grayscale", "image", "with", "alpha", "to", "RGBA", "." ]
40a63c4e5ad7550f62b6860f1812cb67cafb9dc7
https://github.com/brechtm/rinohtype/blob/40a63c4e5ad7550f62b6860f1812cb67cafb9dc7/src/rinoh/backend/pdf/xobject/purepng.py#L700-L705
train
brechtm/rinohtype
src/rinoh/backend/pdf/xobject/purepng.py
BaseFilter.convert_l_to_rgba
def convert_l_to_rgba(self, row, result): """ Convert a grayscale image to RGBA. This method assumes the alpha channel in result is already correctly initialized. """ for i in range(len(row) // 3): for j in range(3): result[(4 * i) + j] = row[...
python
def convert_l_to_rgba(self, row, result): """ Convert a grayscale image to RGBA. This method assumes the alpha channel in result is already correctly initialized. """ for i in range(len(row) // 3): for j in range(3): result[(4 * i) + j] = row[...
[ "def", "convert_l_to_rgba", "(", "self", ",", "row", ",", "result", ")", ":", "for", "i", "in", "range", "(", "len", "(", "row", ")", "//", "3", ")", ":", "for", "j", "in", "range", "(", "3", ")", ":", "result", "[", "(", "4", "*", "i", ")", ...
Convert a grayscale image to RGBA. This method assumes the alpha channel in result is already correctly initialized.
[ "Convert", "a", "grayscale", "image", "to", "RGBA", "." ]
40a63c4e5ad7550f62b6860f1812cb67cafb9dc7
https://github.com/brechtm/rinohtype/blob/40a63c4e5ad7550f62b6860f1812cb67cafb9dc7/src/rinoh/backend/pdf/xobject/purepng.py#L707-L716
train
brechtm/rinohtype
src/rinoh/backend/pdf/xobject/purepng.py
BaseFilter.convert_rgb_to_rgba
def convert_rgb_to_rgba(self, row, result): """ Convert an RGB image to RGBA. This method assumes the alpha channel in result is already correctly initialized. """ for i in range(len(row) // 3): for j in range(3): result[(4 * i) + j] = row[(3 ...
python
def convert_rgb_to_rgba(self, row, result): """ Convert an RGB image to RGBA. This method assumes the alpha channel in result is already correctly initialized. """ for i in range(len(row) // 3): for j in range(3): result[(4 * i) + j] = row[(3 ...
[ "def", "convert_rgb_to_rgba", "(", "self", ",", "row", ",", "result", ")", ":", "for", "i", "in", "range", "(", "len", "(", "row", ")", "//", "3", ")", ":", "for", "j", "in", "range", "(", "3", ")", ":", "result", "[", "(", "4", "*", "i", ")"...
Convert an RGB image to RGBA. This method assumes the alpha channel in result is already correctly initialized.
[ "Convert", "an", "RGB", "image", "to", "RGBA", "." ]
40a63c4e5ad7550f62b6860f1812cb67cafb9dc7
https://github.com/brechtm/rinohtype/blob/40a63c4e5ad7550f62b6860f1812cb67cafb9dc7/src/rinoh/backend/pdf/xobject/purepng.py#L718-L727
train
brechtm/rinohtype
src/rinoh/backend/pdf/xobject/purepng.py
Writer.set_icc_profile
def set_icc_profile(self, profile=None, name='ICC Profile'): """ Add ICC Profile. Prefered way is tuple (`profile_name`, `profile_bytes`), but only bytes with name as separate argument is also supported. """ if isinstance(profile, (basestring, bytes)): icc_pr...
python
def set_icc_profile(self, profile=None, name='ICC Profile'): """ Add ICC Profile. Prefered way is tuple (`profile_name`, `profile_bytes`), but only bytes with name as separate argument is also supported. """ if isinstance(profile, (basestring, bytes)): icc_pr...
[ "def", "set_icc_profile", "(", "self", ",", "profile", "=", "None", ",", "name", "=", "'ICC Profile'", ")", ":", "if", "isinstance", "(", "profile", ",", "(", "basestring", ",", "bytes", ")", ")", ":", "icc_profile", "=", "[", "name", ",", "profile", "...
Add ICC Profile. Prefered way is tuple (`profile_name`, `profile_bytes`), but only bytes with name as separate argument is also supported.
[ "Add", "ICC", "Profile", "." ]
40a63c4e5ad7550f62b6860f1812cb67cafb9dc7
https://github.com/brechtm/rinohtype/blob/40a63c4e5ad7550f62b6860f1812cb67cafb9dc7/src/rinoh/backend/pdf/xobject/purepng.py#L980-L997
train
brechtm/rinohtype
src/rinoh/backend/pdf/xobject/purepng.py
Writer.set_text
def set_text(self, text=None, **kwargs): """ Add textual information passed as dictionary. All pairs in dictionary will be written, but keys should be latin-1; registered keywords could be used as arguments. When called more than once overwrite exist data. """ i...
python
def set_text(self, text=None, **kwargs): """ Add textual information passed as dictionary. All pairs in dictionary will be written, but keys should be latin-1; registered keywords could be used as arguments. When called more than once overwrite exist data. """ i...
[ "def", "set_text", "(", "self", ",", "text", "=", "None", ",", "**", "kwargs", ")", ":", "if", "text", "is", "None", ":", "text", "=", "{", "}", "text", ".", "update", "(", "popdict", "(", "kwargs", ",", "_registered_kw", ")", ")", "if", "'Creation...
Add textual information passed as dictionary. All pairs in dictionary will be written, but keys should be latin-1; registered keywords could be used as arguments. When called more than once overwrite exist data.
[ "Add", "textual", "information", "passed", "as", "dictionary", "." ]
40a63c4e5ad7550f62b6860f1812cb67cafb9dc7
https://github.com/brechtm/rinohtype/blob/40a63c4e5ad7550f62b6860f1812cb67cafb9dc7/src/rinoh/backend/pdf/xobject/purepng.py#L999-L1015
train
brechtm/rinohtype
src/rinoh/backend/pdf/xobject/purepng.py
Writer.set_modification_time
def set_modification_time(self, modification_time=True): """ Add time to be written as last modification time When called after initialisation configure to use time of writing file """ if (isinstance(modification_time, basestring) and modification_time.lo...
python
def set_modification_time(self, modification_time=True): """ Add time to be written as last modification time When called after initialisation configure to use time of writing file """ if (isinstance(modification_time, basestring) and modification_time.lo...
[ "def", "set_modification_time", "(", "self", ",", "modification_time", "=", "True", ")", ":", "if", "(", "isinstance", "(", "modification_time", ",", "basestring", ")", "and", "modification_time", ".", "lower", "(", ")", "==", "'write'", ")", "or", "modificati...
Add time to be written as last modification time When called after initialisation configure to use time of writing file
[ "Add", "time", "to", "be", "written", "as", "last", "modification", "time" ]
40a63c4e5ad7550f62b6860f1812cb67cafb9dc7
https://github.com/brechtm/rinohtype/blob/40a63c4e5ad7550f62b6860f1812cb67cafb9dc7/src/rinoh/backend/pdf/xobject/purepng.py#L1042-L1054
train
brechtm/rinohtype
src/rinoh/backend/pdf/xobject/purepng.py
Writer.set_resolution
def set_resolution(self, resolution=None): """ Add physical pixel dimensions `resolution` supposed two be tuple of two parameterts: pixels per unit and unit type; unit type may be omitted pixels per unit could be simple integer or tuple of (ppu_x, ppu_y) Also possible to...
python
def set_resolution(self, resolution=None): """ Add physical pixel dimensions `resolution` supposed two be tuple of two parameterts: pixels per unit and unit type; unit type may be omitted pixels per unit could be simple integer or tuple of (ppu_x, ppu_y) Also possible to...
[ "def", "set_resolution", "(", "self", ",", "resolution", "=", "None", ")", ":", "if", "resolution", "is", "None", ":", "self", ".", "resolution", "=", "None", "return", "if", "len", "(", "resolution", ")", "==", "3", ":", "resolution", "=", "(", "(", ...
Add physical pixel dimensions `resolution` supposed two be tuple of two parameterts: pixels per unit and unit type; unit type may be omitted pixels per unit could be simple integer or tuple of (ppu_x, ppu_y) Also possible to use all three parameters im row * resolution = ((1, 4...
[ "Add", "physical", "pixel", "dimensions" ]
40a63c4e5ad7550f62b6860f1812cb67cafb9dc7
https://github.com/brechtm/rinohtype/blob/40a63c4e5ad7550f62b6860f1812cb67cafb9dc7/src/rinoh/backend/pdf/xobject/purepng.py#L1056-L1090
train
brechtm/rinohtype
src/rinoh/backend/pdf/xobject/purepng.py
Writer.set_rendering_intent
def set_rendering_intent(self, rendering_intent): """Set rendering intent variant for sRGB chunk""" if rendering_intent not in (None, PERCEPTUAL, RELATIVE_COLORIMETRIC, SATURATION, ...
python
def set_rendering_intent(self, rendering_intent): """Set rendering intent variant for sRGB chunk""" if rendering_intent not in (None, PERCEPTUAL, RELATIVE_COLORIMETRIC, SATURATION, ...
[ "def", "set_rendering_intent", "(", "self", ",", "rendering_intent", ")", ":", "if", "rendering_intent", "not", "in", "(", "None", ",", "PERCEPTUAL", ",", "RELATIVE_COLORIMETRIC", ",", "SATURATION", ",", "ABSOLUTE_COLORIMETRIC", ")", ":", "raise", "FormatError", "...
Set rendering intent variant for sRGB chunk
[ "Set", "rendering", "intent", "variant", "for", "sRGB", "chunk" ]
40a63c4e5ad7550f62b6860f1812cb67cafb9dc7
https://github.com/brechtm/rinohtype/blob/40a63c4e5ad7550f62b6860f1812cb67cafb9dc7/src/rinoh/backend/pdf/xobject/purepng.py#L1092-L1100
train
brechtm/rinohtype
src/rinoh/backend/pdf/xobject/purepng.py
Writer.set_white_point
def set_white_point(self, white_point, point2=None): """Set white point part of cHRM chunk""" if isinstance(white_point, float) and isinstance(point2, float): white_point = (white_point, point2) self.white_point = white_point
python
def set_white_point(self, white_point, point2=None): """Set white point part of cHRM chunk""" if isinstance(white_point, float) and isinstance(point2, float): white_point = (white_point, point2) self.white_point = white_point
[ "def", "set_white_point", "(", "self", ",", "white_point", ",", "point2", "=", "None", ")", ":", "if", "isinstance", "(", "white_point", ",", "float", ")", "and", "isinstance", "(", "point2", ",", "float", ")", ":", "white_point", "=", "(", "white_point", ...
Set white point part of cHRM chunk
[ "Set", "white", "point", "part", "of", "cHRM", "chunk" ]
40a63c4e5ad7550f62b6860f1812cb67cafb9dc7
https://github.com/brechtm/rinohtype/blob/40a63c4e5ad7550f62b6860f1812cb67cafb9dc7/src/rinoh/backend/pdf/xobject/purepng.py#L1102-L1106
train
brechtm/rinohtype
src/rinoh/backend/pdf/xobject/purepng.py
Writer.set_rgb_points
def set_rgb_points(self, rgb_points, *args): """Set rgb points part of cHRM chunk""" if not args: self.rgb_points = rgb_points # separate tuples elif len(args) == 2: self.rgb_points = (rgb_points, args[0], args[1]) # separate numbers elif len(args)...
python
def set_rgb_points(self, rgb_points, *args): """Set rgb points part of cHRM chunk""" if not args: self.rgb_points = rgb_points # separate tuples elif len(args) == 2: self.rgb_points = (rgb_points, args[0], args[1]) # separate numbers elif len(args)...
[ "def", "set_rgb_points", "(", "self", ",", "rgb_points", ",", "*", "args", ")", ":", "if", "not", "args", ":", "self", ".", "rgb_points", "=", "rgb_points", "elif", "len", "(", "args", ")", "==", "2", ":", "self", ".", "rgb_points", "=", "(", "rgb_po...
Set rgb points part of cHRM chunk
[ "Set", "rgb", "points", "part", "of", "cHRM", "chunk" ]
40a63c4e5ad7550f62b6860f1812cb67cafb9dc7
https://github.com/brechtm/rinohtype/blob/40a63c4e5ad7550f62b6860f1812cb67cafb9dc7/src/rinoh/backend/pdf/xobject/purepng.py#L1108-L1119
train
brechtm/rinohtype
src/rinoh/backend/pdf/xobject/purepng.py
Writer.__write_palette
def __write_palette(self, outfile): """ Write``PLTE`` and if necessary a ``tRNS`` chunk to. This method should be called only from ``write_idat`` method or chunk order will be ruined. """ # We must have true bitdepth within palette to use sBIT with palette # if s...
python
def __write_palette(self, outfile): """ Write``PLTE`` and if necessary a ``tRNS`` chunk to. This method should be called only from ``write_idat`` method or chunk order will be ruined. """ # We must have true bitdepth within palette to use sBIT with palette # if s...
[ "def", "__write_palette", "(", "self", ",", "outfile", ")", ":", "p", "=", "bytearray", "(", ")", "t", "=", "bytearray", "(", ")", "for", "x", "in", "self", ".", "palette", ":", "p", ".", "extend", "(", "x", "[", "0", ":", "3", "]", ")", "if", ...
Write``PLTE`` and if necessary a ``tRNS`` chunk to. This method should be called only from ``write_idat`` method or chunk order will be ruined.
[ "Write", "PLTE", "and", "if", "necessary", "a", "tRNS", "chunk", "to", "." ]
40a63c4e5ad7550f62b6860f1812cb67cafb9dc7
https://github.com/brechtm/rinohtype/blob/40a63c4e5ad7550f62b6860f1812cb67cafb9dc7/src/rinoh/backend/pdf/xobject/purepng.py#L1121-L1144
train
brechtm/rinohtype
src/rinoh/backend/pdf/xobject/purepng.py
Writer.__write_text
def __write_text(self, outfile): """ Write text information into file This method should be called only from ``write_idat`` method or chunk order will be ruined. """ for k, v in self.text.items(): if not isinstance(v, bytes): try: ...
python
def __write_text(self, outfile): """ Write text information into file This method should be called only from ``write_idat`` method or chunk order will be ruined. """ for k, v in self.text.items(): if not isinstance(v, bytes): try: ...
[ "def", "__write_text", "(", "self", ",", "outfile", ")", ":", "for", "k", ",", "v", "in", "self", ".", "text", ".", "items", "(", ")", ":", "if", "not", "isinstance", "(", "v", ",", "bytes", ")", ":", "try", ":", "international", "=", "False", "v...
Write text information into file This method should be called only from ``write_idat`` method or chunk order will be ruined.
[ "Write", "text", "information", "into", "file" ]
40a63c4e5ad7550f62b6860f1812cb67cafb9dc7
https://github.com/brechtm/rinohtype/blob/40a63c4e5ad7550f62b6860f1812cb67cafb9dc7/src/rinoh/backend/pdf/xobject/purepng.py#L1191-L1216
train
brechtm/rinohtype
src/rinoh/backend/pdf/xobject/purepng.py
Writer.write_idat
def write_idat(self, outfile, idat_sequence): """ Write png with IDAT to file `idat_sequence` should be iterable that produce IDAT chunks compatible with `Writer` configuration. """ # http://www.w3.org/TR/PNG/#5PNG-file-signature outfile.write(png_signature) ...
python
def write_idat(self, outfile, idat_sequence): """ Write png with IDAT to file `idat_sequence` should be iterable that produce IDAT chunks compatible with `Writer` configuration. """ # http://www.w3.org/TR/PNG/#5PNG-file-signature outfile.write(png_signature) ...
[ "def", "write_idat", "(", "self", ",", "outfile", ",", "idat_sequence", ")", ":", "outfile", ".", "write", "(", "png_signature", ")", "color_type", "=", "4", "*", "self", ".", "alpha", "+", "2", "*", "(", "not", "self", ".", "greyscale", ")", "+", "b...
Write png with IDAT to file `idat_sequence` should be iterable that produce IDAT chunks compatible with `Writer` configuration.
[ "Write", "png", "with", "IDAT", "to", "file" ]
40a63c4e5ad7550f62b6860f1812cb67cafb9dc7
https://github.com/brechtm/rinohtype/blob/40a63c4e5ad7550f62b6860f1812cb67cafb9dc7/src/rinoh/backend/pdf/xobject/purepng.py#L1314-L1384
train
brechtm/rinohtype
src/rinoh/backend/pdf/xobject/purepng.py
Writer.comp_idat
def comp_idat(self, idat): """Generator that produce compressed IDAT chunks from IDAT data""" # http://www.w3.org/TR/PNG/#11IDAT if self.compression is not None: compressor = zlib.compressobj(self.compression) else: compressor = zlib.compressobj() for dat ...
python
def comp_idat(self, idat): """Generator that produce compressed IDAT chunks from IDAT data""" # http://www.w3.org/TR/PNG/#11IDAT if self.compression is not None: compressor = zlib.compressobj(self.compression) else: compressor = zlib.compressobj() for dat ...
[ "def", "comp_idat", "(", "self", ",", "idat", ")", ":", "if", "self", ".", "compression", "is", "not", "None", ":", "compressor", "=", "zlib", ".", "compressobj", "(", "self", ".", "compression", ")", "else", ":", "compressor", "=", "zlib", ".", "compr...
Generator that produce compressed IDAT chunks from IDAT data
[ "Generator", "that", "produce", "compressed", "IDAT", "chunks", "from", "IDAT", "data" ]
40a63c4e5ad7550f62b6860f1812cb67cafb9dc7
https://github.com/brechtm/rinohtype/blob/40a63c4e5ad7550f62b6860f1812cb67cafb9dc7/src/rinoh/backend/pdf/xobject/purepng.py#L1386-L1399
train
brechtm/rinohtype
src/rinoh/backend/pdf/xobject/purepng.py
Writer.idat
def idat(self, rows, packed=False): """Generator that produce uncompressed IDAT data from rows""" # http://www.w3.org/TR/PNG/#11IDAT filt = Filter(self.bitdepth * self.planes, self.interlace, self.height) data = bytearray() def byteextend(rowbytes): ...
python
def idat(self, rows, packed=False): """Generator that produce uncompressed IDAT data from rows""" # http://www.w3.org/TR/PNG/#11IDAT filt = Filter(self.bitdepth * self.planes, self.interlace, self.height) data = bytearray() def byteextend(rowbytes): ...
[ "def", "idat", "(", "self", ",", "rows", ",", "packed", "=", "False", ")", ":", "filt", "=", "Filter", "(", "self", ".", "bitdepth", "*", "self", ".", "planes", ",", "self", ".", "interlace", ",", "self", ".", "height", ")", "data", "=", "bytearray...
Generator that produce uncompressed IDAT data from rows
[ "Generator", "that", "produce", "uncompressed", "IDAT", "data", "from", "rows" ]
40a63c4e5ad7550f62b6860f1812cb67cafb9dc7
https://github.com/brechtm/rinohtype/blob/40a63c4e5ad7550f62b6860f1812cb67cafb9dc7/src/rinoh/backend/pdf/xobject/purepng.py#L1401-L1479
train
brechtm/rinohtype
src/rinoh/backend/pdf/xobject/purepng.py
Writer.write_packed
def write_packed(self, outfile, rows): """ Write PNG file to `outfile`. The pixel data comes from `rows` which should be in boxed row packed format. Each row should be a sequence of packed bytes. Technically, this method does work for interlaced images but it is best a...
python
def write_packed(self, outfile, rows): """ Write PNG file to `outfile`. The pixel data comes from `rows` which should be in boxed row packed format. Each row should be a sequence of packed bytes. Technically, this method does work for interlaced images but it is best a...
[ "def", "write_packed", "(", "self", ",", "outfile", ",", "rows", ")", ":", "return", "self", ".", "write_passes", "(", "outfile", ",", "rows", ",", "packed", "=", "True", ")" ]
Write PNG file to `outfile`. The pixel data comes from `rows` which should be in boxed row packed format. Each row should be a sequence of packed bytes. Technically, this method does work for interlaced images but it is best avoided. For interlaced images, the rows should be ...
[ "Write", "PNG", "file", "to", "outfile", "." ]
40a63c4e5ad7550f62b6860f1812cb67cafb9dc7
https://github.com/brechtm/rinohtype/blob/40a63c4e5ad7550f62b6860f1812cb67cafb9dc7/src/rinoh/backend/pdf/xobject/purepng.py#L1492-L1507
train
brechtm/rinohtype
src/rinoh/backend/pdf/xobject/purepng.py
MergedPlanes.newarray
def newarray(self, length, value=0): """Initialise empty row""" if self.bitdepth > 8: return array('H', [value] * length) else: return bytearray([value] * length)
python
def newarray(self, length, value=0): """Initialise empty row""" if self.bitdepth > 8: return array('H', [value] * length) else: return bytearray([value] * length)
[ "def", "newarray", "(", "self", ",", "length", ",", "value", "=", "0", ")", ":", "if", "self", ".", "bitdepth", ">", "8", ":", "return", "array", "(", "'H'", ",", "[", "value", "]", "*", "length", ")", "else", ":", "return", "bytearray", "(", "["...
Initialise empty row
[ "Initialise", "empty", "row" ]
40a63c4e5ad7550f62b6860f1812cb67cafb9dc7
https://github.com/brechtm/rinohtype/blob/40a63c4e5ad7550f62b6860f1812cb67cafb9dc7/src/rinoh/backend/pdf/xobject/purepng.py#L1604-L1609
train
brechtm/rinohtype
src/rinoh/backend/pdf/xobject/purepng.py
MergedPlanes.rigthgen
def rigthgen(self, value=0): """Generate rows to fill right pixels in int mode""" while True: yield self.newarray(self.nplanes_right * self.width, value)
python
def rigthgen(self, value=0): """Generate rows to fill right pixels in int mode""" while True: yield self.newarray(self.nplanes_right * self.width, value)
[ "def", "rigthgen", "(", "self", ",", "value", "=", "0", ")", ":", "while", "True", ":", "yield", "self", ".", "newarray", "(", "self", ".", "nplanes_right", "*", "self", ".", "width", ",", "value", ")" ]
Generate rows to fill right pixels in int mode
[ "Generate", "rows", "to", "fill", "right", "pixels", "in", "int", "mode" ]
40a63c4e5ad7550f62b6860f1812cb67cafb9dc7
https://github.com/brechtm/rinohtype/blob/40a63c4e5ad7550f62b6860f1812cb67cafb9dc7/src/rinoh/backend/pdf/xobject/purepng.py#L1611-L1614
train
brechtm/rinohtype
src/rinoh/backend/pdf/xobject/purepng.py
MergedPlanes.next
def next(self): """Generate merged row, consuming rows of original iterstors""" left = next(self.seq_left) if self.width is None: self.width = len(left) / self.nplanes_left if self.bitdepth is None: # Detect bitdepth if hasattr(left, 'itemsize'): # ar...
python
def next(self): """Generate merged row, consuming rows of original iterstors""" left = next(self.seq_left) if self.width is None: self.width = len(left) / self.nplanes_left if self.bitdepth is None: # Detect bitdepth if hasattr(left, 'itemsize'): # ar...
[ "def", "next", "(", "self", ")", ":", "left", "=", "next", "(", "self", ".", "seq_left", ")", "if", "self", ".", "width", "is", "None", ":", "self", ".", "width", "=", "len", "(", "left", ")", "/", "self", ".", "nplanes_left", "if", "self", ".", ...
Generate merged row, consuming rows of original iterstors
[ "Generate", "merged", "row", "consuming", "rows", "of", "original", "iterstors" ]
40a63c4e5ad7550f62b6860f1812cb67cafb9dc7
https://github.com/brechtm/rinohtype/blob/40a63c4e5ad7550f62b6860f1812cb67cafb9dc7/src/rinoh/backend/pdf/xobject/purepng.py#L1616-L1649
train
brechtm/rinohtype
src/rinoh/backend/pdf/xobject/purepng.py
Filter.filter_all
def filter_all(self, line): """Doing all filters for specified line return filtered lines as list For using with adaptive filters """ lines = [None] * 5 for filter_type in range(5): # range save more than 'optimised' order res = copyBarray(line) ...
python
def filter_all(self, line): """Doing all filters for specified line return filtered lines as list For using with adaptive filters """ lines = [None] * 5 for filter_type in range(5): # range save more than 'optimised' order res = copyBarray(line) ...
[ "def", "filter_all", "(", "self", ",", "line", ")", ":", "lines", "=", "[", "None", "]", "*", "5", "for", "filter_type", "in", "range", "(", "5", ")", ":", "res", "=", "copyBarray", "(", "line", ")", "self", ".", "_filter_scanline", "(", "filter_type...
Doing all filters for specified line return filtered lines as list For using with adaptive filters
[ "Doing", "all", "filters", "for", "specified", "line" ]
40a63c4e5ad7550f62b6860f1812cb67cafb9dc7
https://github.com/brechtm/rinohtype/blob/40a63c4e5ad7550f62b6860f1812cb67cafb9dc7/src/rinoh/backend/pdf/xobject/purepng.py#L1691-L1703
train
brechtm/rinohtype
src/rinoh/backend/pdf/xobject/purepng.py
Filter.do_filter
def do_filter(self, filter_type, line): """ Applying filter, caring about prev line, interlacing etc. `filter_type` may be integer to apply basic filter or adaptive strategy with dict (`name` is reqired field, others may tune strategy) """ # Recall that filtering...
python
def do_filter(self, filter_type, line): """ Applying filter, caring about prev line, interlacing etc. `filter_type` may be integer to apply basic filter or adaptive strategy with dict (`name` is reqired field, others may tune strategy) """ # Recall that filtering...
[ "def", "do_filter", "(", "self", ",", "filter_type", ",", "line", ")", ":", "line", "=", "bytearray", "(", "line", ")", "if", "isinstance", "(", "filter_type", ",", "int", ")", ":", "res", "=", "bytearray", "(", "line", ")", "self", ".", "_filter_scanl...
Applying filter, caring about prev line, interlacing etc. `filter_type` may be integer to apply basic filter or adaptive strategy with dict (`name` is reqired field, others may tune strategy)
[ "Applying", "filter", "caring", "about", "prev", "line", "interlacing", "etc", "." ]
40a63c4e5ad7550f62b6860f1812cb67cafb9dc7
https://github.com/brechtm/rinohtype/blob/40a63c4e5ad7550f62b6860f1812cb67cafb9dc7/src/rinoh/backend/pdf/xobject/purepng.py#L1734-L1759
train
brechtm/rinohtype
src/rinoh/backend/pdf/xobject/purepng.py
_readable.read
def read(self, n): """Read `n` chars from buffer""" r = self.buf[self.offset:self.offset + n] if isinstance(r, array): r = r.tostring() self.offset += n return r
python
def read(self, n): """Read `n` chars from buffer""" r = self.buf[self.offset:self.offset + n] if isinstance(r, array): r = r.tostring() self.offset += n return r
[ "def", "read", "(", "self", ",", "n", ")", ":", "r", "=", "self", ".", "buf", "[", "self", ".", "offset", ":", "self", ".", "offset", "+", "n", "]", "if", "isinstance", "(", "r", ",", "array", ")", ":", "r", "=", "r", ".", "tostring", "(", ...
Read `n` chars from buffer
[ "Read", "n", "chars", "from", "buffer" ]
40a63c4e5ad7550f62b6860f1812cb67cafb9dc7
https://github.com/brechtm/rinohtype/blob/40a63c4e5ad7550f62b6860f1812cb67cafb9dc7/src/rinoh/backend/pdf/xobject/purepng.py#L2071-L2077
train
brechtm/rinohtype
src/rinoh/backend/pdf/xobject/purepng.py
Reader.chunk
def chunk(self, seek=None, lenient=False): """ Read the next PNG chunk from the input file returns a (*chunk_type*, *data*) tuple. *chunk_type* is the chunk's type as a byte string (all PNG chunk types are 4 bytes long). *data* is the chunk's data content, as a byte string. ...
python
def chunk(self, seek=None, lenient=False): """ Read the next PNG chunk from the input file returns a (*chunk_type*, *data*) tuple. *chunk_type* is the chunk's type as a byte string (all PNG chunk types are 4 bytes long). *data* is the chunk's data content, as a byte string. ...
[ "def", "chunk", "(", "self", ",", "seek", "=", "None", ",", "lenient", "=", "False", ")", ":", "self", ".", "validate_signature", "(", ")", "while", "True", ":", "if", "not", "self", ".", "atchunk", ":", "self", ".", "atchunk", "=", "self", ".", "c...
Read the next PNG chunk from the input file returns a (*chunk_type*, *data*) tuple. *chunk_type* is the chunk's type as a byte string (all PNG chunk types are 4 bytes long). *data* is the chunk's data content, as a byte string. If the optional `seek` argument is specified then ...
[ "Read", "the", "next", "PNG", "chunk", "from", "the", "input", "file" ]
40a63c4e5ad7550f62b6860f1812cb67cafb9dc7
https://github.com/brechtm/rinohtype/blob/40a63c4e5ad7550f62b6860f1812cb67cafb9dc7/src/rinoh/backend/pdf/xobject/purepng.py#L2136-L2188
train
brechtm/rinohtype
src/rinoh/backend/pdf/xobject/purepng.py
Reader.deinterlace
def deinterlace(self, raw): """ Read raw pixel data, undo filters, deinterlace, and flatten. Return in flat row flat pixel format. """ # Values per row (of the target image) vpr = self.width * self.planes # Make a result array, and make it big enough. Interleav...
python
def deinterlace(self, raw): """ Read raw pixel data, undo filters, deinterlace, and flatten. Return in flat row flat pixel format. """ # Values per row (of the target image) vpr = self.width * self.planes # Make a result array, and make it big enough. Interleav...
[ "def", "deinterlace", "(", "self", ",", "raw", ")", ":", "vpr", "=", "self", ".", "width", "*", "self", ".", "planes", "if", "self", ".", "bitdepth", ">", "8", ":", "a", "=", "newHarray", "(", "vpr", "*", "self", ".", "height", ")", "else", ":", ...
Read raw pixel data, undo filters, deinterlace, and flatten. Return in flat row flat pixel format.
[ "Read", "raw", "pixel", "data", "undo", "filters", "deinterlace", "and", "flatten", "." ]
40a63c4e5ad7550f62b6860f1812cb67cafb9dc7
https://github.com/brechtm/rinohtype/blob/40a63c4e5ad7550f62b6860f1812cb67cafb9dc7/src/rinoh/backend/pdf/xobject/purepng.py#L2200-L2250
train
brechtm/rinohtype
src/rinoh/backend/pdf/xobject/purepng.py
Reader.iterboxed
def iterboxed(self, rows): """ Iterator that yields each scanline in boxed row flat pixel format. `rows` should be an iterator that yields the bytes of each row in turn. """ def asvalues(raw): """ Convert a row of raw bytes into a flat row. ...
python
def iterboxed(self, rows): """ Iterator that yields each scanline in boxed row flat pixel format. `rows` should be an iterator that yields the bytes of each row in turn. """ def asvalues(raw): """ Convert a row of raw bytes into a flat row. ...
[ "def", "iterboxed", "(", "self", ",", "rows", ")", ":", "def", "asvalues", "(", "raw", ")", ":", "if", "self", ".", "bitdepth", "==", "8", ":", "return", "raw", "if", "self", ".", "bitdepth", "==", "16", ":", "raw", "=", "bytearray_to_bytes", "(", ...
Iterator that yields each scanline in boxed row flat pixel format. `rows` should be an iterator that yields the bytes of each row in turn.
[ "Iterator", "that", "yields", "each", "scanline", "in", "boxed", "row", "flat", "pixel", "format", "." ]
40a63c4e5ad7550f62b6860f1812cb67cafb9dc7
https://github.com/brechtm/rinohtype/blob/40a63c4e5ad7550f62b6860f1812cb67cafb9dc7/src/rinoh/backend/pdf/xobject/purepng.py#L2252-L2282
train
brechtm/rinohtype
src/rinoh/backend/pdf/xobject/purepng.py
Reader.iterstraight
def iterstraight(self, raw): """ Iterator that undoes the effect of filtering Yields each row in serialised format (as a sequence of bytes). Assumes input is straightlaced. `raw` should be an iterable that yields the raw bytes in chunks of arbitrary size. """ # ...
python
def iterstraight(self, raw): """ Iterator that undoes the effect of filtering Yields each row in serialised format (as a sequence of bytes). Assumes input is straightlaced. `raw` should be an iterable that yields the raw bytes in chunks of arbitrary size. """ # ...
[ "def", "iterstraight", "(", "self", ",", "raw", ")", ":", "rb_1", "=", "self", ".", "row_bytes", "+", "1", "a", "=", "bytearray", "(", ")", "filt", "=", "Filter", "(", "self", ".", "bitdepth", "*", "self", ".", "planes", ")", "for", "some", "in", ...
Iterator that undoes the effect of filtering Yields each row in serialised format (as a sequence of bytes). Assumes input is straightlaced. `raw` should be an iterable that yields the raw bytes in chunks of arbitrary size.
[ "Iterator", "that", "undoes", "the", "effect", "of", "filtering" ]
40a63c4e5ad7550f62b6860f1812cb67cafb9dc7
https://github.com/brechtm/rinohtype/blob/40a63c4e5ad7550f62b6860f1812cb67cafb9dc7/src/rinoh/backend/pdf/xobject/purepng.py#L2309-L2341
train
brechtm/rinohtype
src/rinoh/backend/pdf/xobject/purepng.py
Reader.preamble
def preamble(self, lenient=False): """ Extract the image metadata Extract the image metadata by reading the initial part of the PNG file up to the start of the ``IDAT`` chunk. All the chunks that precede the ``IDAT`` chunk are read and either processed for metadata or d...
python
def preamble(self, lenient=False): """ Extract the image metadata Extract the image metadata by reading the initial part of the PNG file up to the start of the ``IDAT`` chunk. All the chunks that precede the ``IDAT`` chunk are read and either processed for metadata or d...
[ "def", "preamble", "(", "self", ",", "lenient", "=", "False", ")", ":", "self", ".", "validate_signature", "(", ")", "while", "True", ":", "if", "not", "self", ".", "atchunk", ":", "self", ".", "atchunk", "=", "self", ".", "chunklentype", "(", ")", "...
Extract the image metadata Extract the image metadata by reading the initial part of the PNG file up to the start of the ``IDAT`` chunk. All the chunks that precede the ``IDAT`` chunk are read and either processed for metadata or discarded. If the optional `lenient` argument e...
[ "Extract", "the", "image", "metadata" ]
40a63c4e5ad7550f62b6860f1812cb67cafb9dc7
https://github.com/brechtm/rinohtype/blob/40a63c4e5ad7550f62b6860f1812cb67cafb9dc7/src/rinoh/backend/pdf/xobject/purepng.py#L2351-L2372
train
brechtm/rinohtype
src/rinoh/backend/pdf/xobject/purepng.py
Reader.idat
def idat(self, lenient=False): """Iterator that yields all the ``IDAT`` chunks as strings.""" while True: try: chunk_type, data = self.chunk(lenient=lenient) except ValueError: e = sys.exc_info()[1] raise ChunkError(e.args[0]) ...
python
def idat(self, lenient=False): """Iterator that yields all the ``IDAT`` chunks as strings.""" while True: try: chunk_type, data = self.chunk(lenient=lenient) except ValueError: e = sys.exc_info()[1] raise ChunkError(e.args[0]) ...
[ "def", "idat", "(", "self", ",", "lenient", "=", "False", ")", ":", "while", "True", ":", "try", ":", "chunk_type", ",", "data", "=", "self", ".", "chunk", "(", "lenient", "=", "lenient", ")", "except", "ValueError", ":", "e", "=", "sys", ".", "exc...
Iterator that yields all the ``IDAT`` chunks as strings.
[ "Iterator", "that", "yields", "all", "the", "IDAT", "chunks", "as", "strings", "." ]
40a63c4e5ad7550f62b6860f1812cb67cafb9dc7
https://github.com/brechtm/rinohtype/blob/40a63c4e5ad7550f62b6860f1812cb67cafb9dc7/src/rinoh/backend/pdf/xobject/purepng.py#L2592-L2609
train
brechtm/rinohtype
src/rinoh/backend/pdf/xobject/purepng.py
Reader.idatdecomp
def idatdecomp(self, lenient=False, max_length=0): """Iterator that yields decompressed ``IDAT`` strings.""" # Currently, with no max_length paramter to decompress, this # routine will do one yield per IDAT chunk. So not very # incremental. d = zlib.decompressobj() # Eac...
python
def idatdecomp(self, lenient=False, max_length=0): """Iterator that yields decompressed ``IDAT`` strings.""" # Currently, with no max_length paramter to decompress, this # routine will do one yield per IDAT chunk. So not very # incremental. d = zlib.decompressobj() # Eac...
[ "def", "idatdecomp", "(", "self", ",", "lenient", "=", "False", ",", "max_length", "=", "0", ")", ":", "d", "=", "zlib", ".", "decompressobj", "(", ")", "for", "data", "in", "self", ".", "idat", "(", "lenient", ")", ":", "yield", "bytearray", "(", ...
Iterator that yields decompressed ``IDAT`` strings.
[ "Iterator", "that", "yields", "decompressed", "IDAT", "strings", "." ]
40a63c4e5ad7550f62b6860f1812cb67cafb9dc7
https://github.com/brechtm/rinohtype/blob/40a63c4e5ad7550f62b6860f1812cb67cafb9dc7/src/rinoh/backend/pdf/xobject/purepng.py#L2611-L2623
train
brechtm/rinohtype
src/rinoh/backend/pdf/xobject/purepng.py
Reader.read
def read(self, lenient=False): """ Read the PNG file and decode it. Returns (`width`, `height`, `pixels`, `metadata`). May use excessive memory. `pixels` are returned in boxed row flat pixel format. If the optional `lenient` argument evaluates to True, checksu...
python
def read(self, lenient=False): """ Read the PNG file and decode it. Returns (`width`, `height`, `pixels`, `metadata`). May use excessive memory. `pixels` are returned in boxed row flat pixel format. If the optional `lenient` argument evaluates to True, checksu...
[ "def", "read", "(", "self", ",", "lenient", "=", "False", ")", ":", "self", ".", "preamble", "(", "lenient", "=", "lenient", ")", "raw", "=", "self", ".", "idatdecomp", "(", "lenient", ")", "if", "self", ".", "interlace", ":", "raw", "=", "bytearray"...
Read the PNG file and decode it. Returns (`width`, `height`, `pixels`, `metadata`). May use excessive memory. `pixels` are returned in boxed row flat pixel format. If the optional `lenient` argument evaluates to True, checksum failures will raise warnings rather than exceptio...
[ "Read", "the", "PNG", "file", "and", "decode", "it", "." ]
40a63c4e5ad7550f62b6860f1812cb67cafb9dc7
https://github.com/brechtm/rinohtype/blob/40a63c4e5ad7550f62b6860f1812cb67cafb9dc7/src/rinoh/backend/pdf/xobject/purepng.py#L2625-L2662
train
brechtm/rinohtype
src/rinoh/backend/pdf/xobject/purepng.py
Reader.read_flat
def read_flat(self): """ Read a PNG file and decode it into flat row flat pixel format. Returns (*width*, *height*, *pixels*, *metadata*). May use excessive memory. `pixels` are returned in flat row flat pixel format. See also the :meth:`read` method which returns pix...
python
def read_flat(self): """ Read a PNG file and decode it into flat row flat pixel format. Returns (*width*, *height*, *pixels*, *metadata*). May use excessive memory. `pixels` are returned in flat row flat pixel format. See also the :meth:`read` method which returns pix...
[ "def", "read_flat", "(", "self", ")", ":", "x", ",", "y", ",", "pixel", ",", "meta", "=", "self", ".", "read", "(", ")", "arraycode", "=", "'BH'", "[", "meta", "[", "'bitdepth'", "]", ">", "8", "]", "pixel", "=", "array", "(", "arraycode", ",", ...
Read a PNG file and decode it into flat row flat pixel format. Returns (*width*, *height*, *pixels*, *metadata*). May use excessive memory. `pixels` are returned in flat row flat pixel format. See also the :meth:`read` method which returns pixels in the more stream-friendly b...
[ "Read", "a", "PNG", "file", "and", "decode", "it", "into", "flat", "row", "flat", "pixel", "format", "." ]
40a63c4e5ad7550f62b6860f1812cb67cafb9dc7
https://github.com/brechtm/rinohtype/blob/40a63c4e5ad7550f62b6860f1812cb67cafb9dc7/src/rinoh/backend/pdf/xobject/purepng.py#L2664-L2680
train
brechtm/rinohtype
src/rinoh/backend/pdf/xobject/purepng.py
Reader.asRGB
def asRGB(self): """ Return image as RGB pixels. RGB colour images are passed through unchanged; greyscales are expanded into RGB triplets (there is a small speed overhead for doing this). An alpha channel in the source image will raise an exception. The retur...
python
def asRGB(self): """ Return image as RGB pixels. RGB colour images are passed through unchanged; greyscales are expanded into RGB triplets (there is a small speed overhead for doing this). An alpha channel in the source image will raise an exception. The retur...
[ "def", "asRGB", "(", "self", ")", ":", "width", ",", "height", ",", "pixels", ",", "meta", "=", "self", ".", "asDirect", "(", ")", "if", "meta", "[", "'alpha'", "]", ":", "raise", "Error", "(", "\"will not convert image with alpha channel to RGB\"", ")", "...
Return image as RGB pixels. RGB colour images are passed through unchanged; greyscales are expanded into RGB triplets (there is a small speed overhead for doing this). An alpha channel in the source image will raise an exception. The return values are as for the :meth:`read` ...
[ "Return", "image", "as", "RGB", "pixels", "." ]
40a63c4e5ad7550f62b6860f1812cb67cafb9dc7
https://github.com/brechtm/rinohtype/blob/40a63c4e5ad7550f62b6860f1812cb67cafb9dc7/src/rinoh/backend/pdf/xobject/purepng.py#L2893-L2922
train
brechtm/rinohtype
src/rinoh/backend/pdf/xobject/purepng.py
Reader.asRGBA
def asRGBA(self): """ Return image as RGBA pixels. Greyscales are expanded into RGB triplets; an alpha channel is synthesized if necessary. The return values are as for the :meth:`read` method except that the *metadata* reflect the returned pixels, not the source...
python
def asRGBA(self): """ Return image as RGBA pixels. Greyscales are expanded into RGB triplets; an alpha channel is synthesized if necessary. The return values are as for the :meth:`read` method except that the *metadata* reflect the returned pixels, not the source...
[ "def", "asRGBA", "(", "self", ")", ":", "width", ",", "height", ",", "pixels", ",", "meta", "=", "self", ".", "asDirect", "(", ")", "if", "meta", "[", "'alpha'", "]", "and", "not", "meta", "[", "'greyscale'", "]", ":", "return", "width", ",", "heig...
Return image as RGBA pixels. Greyscales are expanded into RGB triplets; an alpha channel is synthesized if necessary. The return values are as for the :meth:`read` method except that the *metadata* reflect the returned pixels, not the source image. In particular, for this metho...
[ "Return", "image", "as", "RGBA", "pixels", "." ]
40a63c4e5ad7550f62b6860f1812cb67cafb9dc7
https://github.com/brechtm/rinohtype/blob/40a63c4e5ad7550f62b6860f1812cb67cafb9dc7/src/rinoh/backend/pdf/xobject/purepng.py#L2924-L2981
train
brechtm/rinohtype
src/rinoh/backend/pdf/xobject/png.py
chromaticity_to_XYZ
def chromaticity_to_XYZ(white, red, green, blue): """From the "CalRGB Color Spaces" section of "PDF Reference", 6th ed.""" xW, yW = white xR, yR = red xG, yG = green xB, yB = blue R = G = B = 1.0 z = yW * ((xG - xB) * yR - (xR - xB) * yG + (xR - xG) * yB) YA = yR / R * ((xG - xB) * yW ...
python
def chromaticity_to_XYZ(white, red, green, blue): """From the "CalRGB Color Spaces" section of "PDF Reference", 6th ed.""" xW, yW = white xR, yR = red xG, yG = green xB, yB = blue R = G = B = 1.0 z = yW * ((xG - xB) * yR - (xR - xB) * yG + (xR - xG) * yB) YA = yR / R * ((xG - xB) * yW ...
[ "def", "chromaticity_to_XYZ", "(", "white", ",", "red", ",", "green", ",", "blue", ")", ":", "xW", ",", "yW", "=", "white", "xR", ",", "yR", "=", "red", "xG", ",", "yG", "=", "green", "xB", ",", "yB", "=", "blue", "R", "=", "G", "=", "B", "="...
From the "CalRGB Color Spaces" section of "PDF Reference", 6th ed.
[ "From", "the", "CalRGB", "Color", "Spaces", "section", "of", "PDF", "Reference", "6th", "ed", "." ]
40a63c4e5ad7550f62b6860f1812cb67cafb9dc7
https://github.com/brechtm/rinohtype/blob/40a63c4e5ad7550f62b6860f1812cb67cafb9dc7/src/rinoh/backend/pdf/xobject/png.py#L200-L222
train
uktrade/directory-client-core
directory_client_core/helpers.py
fallback
def fallback(cache): """ Caches content retrieved by the client, thus allowing the cached content to be used later if the live content cannot be retrieved. """ log_filter = ThrottlingFilter(cache=cache) logger.filters = [] logger.addFilter(log_filter) def get_cache_response(cache_key)...
python
def fallback(cache): """ Caches content retrieved by the client, thus allowing the cached content to be used later if the live content cannot be retrieved. """ log_filter = ThrottlingFilter(cache=cache) logger.filters = [] logger.addFilter(log_filter) def get_cache_response(cache_key)...
[ "def", "fallback", "(", "cache", ")", ":", "log_filter", "=", "ThrottlingFilter", "(", "cache", "=", "cache", ")", "logger", ".", "filters", "=", "[", "]", "logger", ".", "addFilter", "(", "log_filter", ")", "def", "get_cache_response", "(", "cache_key", "...
Caches content retrieved by the client, thus allowing the cached content to be used later if the live content cannot be retrieved.
[ "Caches", "content", "retrieved", "by", "the", "client", "thus", "allowing", "the", "cached", "content", "to", "be", "used", "later", "if", "the", "live", "content", "cannot", "be", "retrieved", "." ]
5196340a73117a27d9efb88d701dbdc7cdc90502
https://github.com/uktrade/directory-client-core/blob/5196340a73117a27d9efb88d701dbdc7cdc90502/directory_client_core/helpers.py#L77-L154
train
uktrade/directory-client-core
directory_client_core/base.py
AbstractAPIClient.build_url
def build_url(base_url, partial_url): """ Makes sure the URL is built properly. >>> urllib.parse.urljoin('https://test.com/1/', '2/3') https://test.com/1/2/3 >>> urllib.parse.urljoin('https://test.com/1/', '/2/3') https://test.com/2/3 >>> urllib.parse.urljoin('ht...
python
def build_url(base_url, partial_url): """ Makes sure the URL is built properly. >>> urllib.parse.urljoin('https://test.com/1/', '2/3') https://test.com/1/2/3 >>> urllib.parse.urljoin('https://test.com/1/', '/2/3') https://test.com/2/3 >>> urllib.parse.urljoin('ht...
[ "def", "build_url", "(", "base_url", ",", "partial_url", ")", ":", "if", "not", "base_url", ".", "endswith", "(", "'/'", ")", ":", "base_url", "+=", "'/'", "if", "partial_url", ".", "startswith", "(", "'/'", ")", ":", "partial_url", "=", "partial_url", "...
Makes sure the URL is built properly. >>> urllib.parse.urljoin('https://test.com/1/', '2/3') https://test.com/1/2/3 >>> urllib.parse.urljoin('https://test.com/1/', '/2/3') https://test.com/2/3 >>> urllib.parse.urljoin('https://test.com/1', '2/3') https://test.com/2/3'
[ "Makes", "sure", "the", "URL", "is", "built", "properly", "." ]
5196340a73117a27d9efb88d701dbdc7cdc90502
https://github.com/uktrade/directory-client-core/blob/5196340a73117a27d9efb88d701dbdc7cdc90502/directory_client_core/base.py#L93-L109
train
sam-cox/pytides
pytides/tide.py
Tide.form_number
def form_number(self): """ Returns the model's form number, a helpful heuristic for classifying tides. """ k1, o1, m2, s2 = ( np.extract(self.model['constituent'] == c, self.model['amplitude']) for c in [constituent._K1, constituent._O1, constituent._M2, constituent._S2] ) return (k1+o1)/(m2+s2)
python
def form_number(self): """ Returns the model's form number, a helpful heuristic for classifying tides. """ k1, o1, m2, s2 = ( np.extract(self.model['constituent'] == c, self.model['amplitude']) for c in [constituent._K1, constituent._O1, constituent._M2, constituent._S2] ) return (k1+o1)/(m2+s2)
[ "def", "form_number", "(", "self", ")", ":", "k1", ",", "o1", ",", "m2", ",", "s2", "=", "(", "np", ".", "extract", "(", "self", ".", "model", "[", "'constituent'", "]", "==", "c", ",", "self", ".", "model", "[", "'amplitude'", "]", ")", "for", ...
Returns the model's form number, a helpful heuristic for classifying tides.
[ "Returns", "the", "model", "s", "form", "number", "a", "helpful", "heuristic", "for", "classifying", "tides", "." ]
63a2507299002f1979ea55a17a82561158d685f7
https://github.com/sam-cox/pytides/blob/63a2507299002f1979ea55a17a82561158d685f7/pytides/tide.py#L136-L144
train
sam-cox/pytides
pytides/tide.py
Tide.normalize
def normalize(self): """ Adapt self.model so that amplitudes are positive and phases are in [0,360) as per convention """ for i, (_, amplitude, phase) in enumerate(self.model): if amplitude < 0: self.model['amplitude'][i] = -amplitude self.model['phase'][i] = phase + 180.0 self.model['phase'][i] =...
python
def normalize(self): """ Adapt self.model so that amplitudes are positive and phases are in [0,360) as per convention """ for i, (_, amplitude, phase) in enumerate(self.model): if amplitude < 0: self.model['amplitude'][i] = -amplitude self.model['phase'][i] = phase + 180.0 self.model['phase'][i] =...
[ "def", "normalize", "(", "self", ")", ":", "for", "i", ",", "(", "_", ",", "amplitude", ",", "phase", ")", "in", "enumerate", "(", "self", ".", "model", ")", ":", "if", "amplitude", "<", "0", ":", "self", ".", "model", "[", "'amplitude'", "]", "[...
Adapt self.model so that amplitudes are positive and phases are in [0,360) as per convention
[ "Adapt", "self", ".", "model", "so", "that", "amplitudes", "are", "positive", "and", "phases", "are", "in", "[", "0", "360", ")", "as", "per", "convention" ]
63a2507299002f1979ea55a17a82561158d685f7
https://github.com/sam-cox/pytides/blob/63a2507299002f1979ea55a17a82561158d685f7/pytides/tide.py#L260-L268
train
pyupio/dparse
dparse/vendor/toml.py
_unescape
def _unescape(v): """Unescape characters in a TOML string.""" i = 0 backslash = False while i < len(v): if backslash: backslash = False if v[i] in _escapes: v = v[:i - 1] + _escape_to_escapedchars[v[i]] + v[i + 1:] elif v[i] == '\\': ...
python
def _unescape(v): """Unescape characters in a TOML string.""" i = 0 backslash = False while i < len(v): if backslash: backslash = False if v[i] in _escapes: v = v[:i - 1] + _escape_to_escapedchars[v[i]] + v[i + 1:] elif v[i] == '\\': ...
[ "def", "_unescape", "(", "v", ")", ":", "i", "=", "0", "backslash", "=", "False", "while", "i", "<", "len", "(", "v", ")", ":", "if", "backslash", ":", "backslash", "=", "False", "if", "v", "[", "i", "]", "in", "_escapes", ":", "v", "=", "v", ...
Unescape characters in a TOML string.
[ "Unescape", "characters", "in", "a", "TOML", "string", "." ]
0cd5aa7eb1f78c39da78b6c63dde6b49a1732cd2
https://github.com/pyupio/dparse/blob/0cd5aa7eb1f78c39da78b6c63dde6b49a1732cd2/dparse/vendor/toml.py#L560-L579
train
pyupio/dparse
dparse/parser.py
RequirementsTXTParser.parse
def parse(self): """ Parses a requirements.txt-like file """ index_server = None for num, line in enumerate(self.iter_lines()): line = line.rstrip() if not line: continue if line.startswith('#'): # comments are l...
python
def parse(self): """ Parses a requirements.txt-like file """ index_server = None for num, line in enumerate(self.iter_lines()): line = line.rstrip() if not line: continue if line.startswith('#'): # comments are l...
[ "def", "parse", "(", "self", ")", ":", "index_server", "=", "None", "for", "num", ",", "line", "in", "enumerate", "(", "self", ".", "iter_lines", "(", ")", ")", ":", "line", "=", "line", ".", "rstrip", "(", ")", "if", "not", "line", ":", "continue"...
Parses a requirements.txt-like file
[ "Parses", "a", "requirements", ".", "txt", "-", "like", "file" ]
0cd5aa7eb1f78c39da78b6c63dde6b49a1732cd2
https://github.com/pyupio/dparse/blob/0cd5aa7eb1f78c39da78b6c63dde6b49a1732cd2/dparse/parser.py#L221-L278
train
hynek/environ_config
src/environ/_environ_config.py
_format_help_dicts
def _format_help_dicts(help_dicts, display_defaults=False): """ Format the output of _generate_help_dicts into a str """ help_strs = [] for help_dict in help_dicts: help_str = "%s (%s" % ( help_dict["var_name"], "Required" if help_dict["required"] else "Optional", ...
python
def _format_help_dicts(help_dicts, display_defaults=False): """ Format the output of _generate_help_dicts into a str """ help_strs = [] for help_dict in help_dicts: help_str = "%s (%s" % ( help_dict["var_name"], "Required" if help_dict["required"] else "Optional", ...
[ "def", "_format_help_dicts", "(", "help_dicts", ",", "display_defaults", "=", "False", ")", ":", "help_strs", "=", "[", "]", "for", "help_dict", "in", "help_dicts", ":", "help_str", "=", "\"%s (%s\"", "%", "(", "help_dict", "[", "\"var_name\"", "]", ",", "\"...
Format the output of _generate_help_dicts into a str
[ "Format", "the", "output", "of", "_generate_help_dicts", "into", "a", "str" ]
d61c0822bf0b6516932534e0496bd3f360a3e5e2
https://github.com/hynek/environ_config/blob/d61c0822bf0b6516932534e0496bd3f360a3e5e2/src/environ/_environ_config.py#L135-L153
train
hynek/environ_config
src/environ/_environ_config.py
_generate_help_dicts
def _generate_help_dicts(config_cls, _prefix=None): """ Generate dictionaries for use in building help strings. Every dictionary includes the keys... var_name: The env var that should be set to populate the value. required: A bool, True if the var is required, False if it's optional. Conditio...
python
def _generate_help_dicts(config_cls, _prefix=None): """ Generate dictionaries for use in building help strings. Every dictionary includes the keys... var_name: The env var that should be set to populate the value. required: A bool, True if the var is required, False if it's optional. Conditio...
[ "def", "_generate_help_dicts", "(", "config_cls", ",", "_prefix", "=", "None", ")", ":", "help_dicts", "=", "[", "]", "if", "_prefix", "is", "None", ":", "_prefix", "=", "config_cls", ".", "_prefix", "for", "a", "in", "attr", ".", "fields", "(", "config_...
Generate dictionaries for use in building help strings. Every dictionary includes the keys... var_name: The env var that should be set to populate the value. required: A bool, True if the var is required, False if it's optional. Conditionally, the following are included... default: Included if a...
[ "Generate", "dictionaries", "for", "use", "in", "building", "help", "strings", "." ]
d61c0822bf0b6516932534e0496bd3f360a3e5e2
https://github.com/hynek/environ_config/blob/d61c0822bf0b6516932534e0496bd3f360a3e5e2/src/environ/_environ_config.py#L156-L198
train
hynek/environ_config
src/environ/_environ_config.py
generate_help
def generate_help(config_cls, **kwargs): """ Autogenerate a help string for a config class. If a callable is provided via the "formatter" kwarg it will be provided with the help dictionaries as an argument and any other kwargs provided to this function. That callable should return the help text...
python
def generate_help(config_cls, **kwargs): """ Autogenerate a help string for a config class. If a callable is provided via the "formatter" kwarg it will be provided with the help dictionaries as an argument and any other kwargs provided to this function. That callable should return the help text...
[ "def", "generate_help", "(", "config_cls", ",", "**", "kwargs", ")", ":", "try", ":", "formatter", "=", "kwargs", ".", "pop", "(", "\"formatter\"", ")", "except", "KeyError", ":", "formatter", "=", "_format_help_dicts", "help_dicts", "=", "_generate_help_dicts",...
Autogenerate a help string for a config class. If a callable is provided via the "formatter" kwarg it will be provided with the help dictionaries as an argument and any other kwargs provided to this function. That callable should return the help text string.
[ "Autogenerate", "a", "help", "string", "for", "a", "config", "class", "." ]
d61c0822bf0b6516932534e0496bd3f360a3e5e2
https://github.com/hynek/environ_config/blob/d61c0822bf0b6516932534e0496bd3f360a3e5e2/src/environ/_environ_config.py#L201-L215
train
yceruto/django-ajax
django_ajax/shortcuts.py
render_to_json
def render_to_json(response, request=None, **kwargs): """ Creates the main structure and returns the JSON response. """ # determine the status code if hasattr(response, 'status_code'): status_code = response.status_code elif issubclass(type(response), Http404): status_code = 404 ...
python
def render_to_json(response, request=None, **kwargs): """ Creates the main structure and returns the JSON response. """ # determine the status code if hasattr(response, 'status_code'): status_code = response.status_code elif issubclass(type(response), Http404): status_code = 404 ...
[ "def", "render_to_json", "(", "response", ",", "request", "=", "None", ",", "**", "kwargs", ")", ":", "if", "hasattr", "(", "response", ",", "'status_code'", ")", ":", "status_code", "=", "response", ".", "status_code", "elif", "issubclass", "(", "type", "...
Creates the main structure and returns the JSON response.
[ "Creates", "the", "main", "structure", "and", "returns", "the", "JSON", "response", "." ]
d5af47c0e65571d4729f48781c0b41886b926221
https://github.com/yceruto/django-ajax/blob/d5af47c0e65571d4729f48781c0b41886b926221/django_ajax/shortcuts.py#L79-L109
train
yceruto/django-ajax
django_ajax/mixin.py
AJAXMixin.dispatch
def dispatch(self, request, *args, **kwargs): """ Using ajax decorator """ ajax_kwargs = {'mandatory': self.ajax_mandatory} if self.json_encoder: ajax_kwargs['cls'] = self.json_encoder return ajax(**ajax_kwargs)(super( AJAXMixin, self).dispatch)(r...
python
def dispatch(self, request, *args, **kwargs): """ Using ajax decorator """ ajax_kwargs = {'mandatory': self.ajax_mandatory} if self.json_encoder: ajax_kwargs['cls'] = self.json_encoder return ajax(**ajax_kwargs)(super( AJAXMixin, self).dispatch)(r...
[ "def", "dispatch", "(", "self", ",", "request", ",", "*", "args", ",", "**", "kwargs", ")", ":", "ajax_kwargs", "=", "{", "'mandatory'", ":", "self", ".", "ajax_mandatory", "}", "if", "self", ".", "json_encoder", ":", "ajax_kwargs", "[", "'cls'", "]", ...
Using ajax decorator
[ "Using", "ajax", "decorator" ]
d5af47c0e65571d4729f48781c0b41886b926221
https://github.com/yceruto/django-ajax/blob/d5af47c0e65571d4729f48781c0b41886b926221/django_ajax/mixin.py#L17-L26
train
ioos/compliance-checker
compliance_checker/protocols/opendap.py
is_opendap
def is_opendap(url): ''' Returns True if the URL is a valid OPeNDAP URL :param str url: URL for a remote OPeNDAP endpoint ''' # If the server replies to a Data Attribute Structure request if url.endswith('#fillmismatch'): das_url = url.replace('#fillmismatch', '.das') else: ...
python
def is_opendap(url): ''' Returns True if the URL is a valid OPeNDAP URL :param str url: URL for a remote OPeNDAP endpoint ''' # If the server replies to a Data Attribute Structure request if url.endswith('#fillmismatch'): das_url = url.replace('#fillmismatch', '.das') else: ...
[ "def", "is_opendap", "(", "url", ")", ":", "if", "url", ".", "endswith", "(", "'#fillmismatch'", ")", ":", "das_url", "=", "url", ".", "replace", "(", "'#fillmismatch'", ",", "'.das'", ")", "else", ":", "das_url", "=", "url", "+", "'.das'", "response", ...
Returns True if the URL is a valid OPeNDAP URL :param str url: URL for a remote OPeNDAP endpoint
[ "Returns", "True", "if", "the", "URL", "is", "a", "valid", "OPeNDAP", "URL" ]
ee89c27b0daade58812489a2da3aa3b6859eafd9
https://github.com/ioos/compliance-checker/blob/ee89c27b0daade58812489a2da3aa3b6859eafd9/compliance_checker/protocols/opendap.py#L10-L29
train
ioos/compliance-checker
compliance_checker/util.py
datetime_is_iso
def datetime_is_iso(date_str): """Attempts to parse a date formatted in ISO 8601 format""" try: if len(date_str) > 10: dt = isodate.parse_datetime(date_str) else: dt = isodate.parse_date(date_str) return True, [] except: # Any error qualifies as not ISO forma...
python
def datetime_is_iso(date_str): """Attempts to parse a date formatted in ISO 8601 format""" try: if len(date_str) > 10: dt = isodate.parse_datetime(date_str) else: dt = isodate.parse_date(date_str) return True, [] except: # Any error qualifies as not ISO forma...
[ "def", "datetime_is_iso", "(", "date_str", ")", ":", "try", ":", "if", "len", "(", "date_str", ")", ">", "10", ":", "dt", "=", "isodate", ".", "parse_datetime", "(", "date_str", ")", "else", ":", "dt", "=", "isodate", ".", "parse_date", "(", "date_str"...
Attempts to parse a date formatted in ISO 8601 format
[ "Attempts", "to", "parse", "a", "date", "formatted", "in", "ISO", "8601", "format" ]
ee89c27b0daade58812489a2da3aa3b6859eafd9
https://github.com/ioos/compliance-checker/blob/ee89c27b0daade58812489a2da3aa3b6859eafd9/compliance_checker/util.py#L16-L25
train
ioos/compliance-checker
compliance_checker/protocols/cdl.py
is_cdl
def is_cdl(filename): ''' Quick check for .cdl ascii file Example: netcdf sample_file { dimensions: name_strlen = 7 ; time = 96 ; variables: float lat ; lat:units = "degrees_north" ; lat:standard_name = "latitude" ;...
python
def is_cdl(filename): ''' Quick check for .cdl ascii file Example: netcdf sample_file { dimensions: name_strlen = 7 ; time = 96 ; variables: float lat ; lat:units = "degrees_north" ; lat:standard_name = "latitude" ;...
[ "def", "is_cdl", "(", "filename", ")", ":", "if", "os", ".", "path", ".", "splitext", "(", "filename", ")", "[", "-", "1", "]", "!=", "'.cdl'", ":", "return", "False", "with", "open", "(", "filename", ",", "'rb'", ")", "as", "f", ":", "data", "="...
Quick check for .cdl ascii file Example: netcdf sample_file { dimensions: name_strlen = 7 ; time = 96 ; variables: float lat ; lat:units = "degrees_north" ; lat:standard_name = "latitude" ; lat:long_name = "...
[ "Quick", "check", "for", ".", "cdl", "ascii", "file" ]
ee89c27b0daade58812489a2da3aa3b6859eafd9
https://github.com/ioos/compliance-checker/blob/ee89c27b0daade58812489a2da3aa3b6859eafd9/compliance_checker/protocols/cdl.py#L8-L34
train
ioos/compliance-checker
compliance_checker/runner.py
ComplianceChecker.run_checker
def run_checker(cls, ds_loc, checker_names, verbose, criteria, skip_checks=None, output_filename='-', output_format=['text']): """ Static check runner. @param ds_loc Dataset location (url or file) @param checker_names List of string n...
python
def run_checker(cls, ds_loc, checker_names, verbose, criteria, skip_checks=None, output_filename='-', output_format=['text']): """ Static check runner. @param ds_loc Dataset location (url or file) @param checker_names List of string n...
[ "def", "run_checker", "(", "cls", ",", "ds_loc", ",", "checker_names", ",", "verbose", ",", "criteria", ",", "skip_checks", "=", "None", ",", "output_filename", "=", "'-'", ",", "output_format", "=", "[", "'text'", "]", ")", ":", "all_groups", "=", "[", ...
Static check runner. @param ds_loc Dataset location (url or file) @param checker_names List of string names to run, should match keys of checkers dict (empty list means run all) @param verbose Verbosity of the output (0, 1, 2) @param criteria Determines fai...
[ "Static", "check", "runner", "." ]
ee89c27b0daade58812489a2da3aa3b6859eafd9
https://github.com/ioos/compliance-checker/blob/ee89c27b0daade58812489a2da3aa3b6859eafd9/compliance_checker/runner.py#L35-L123
train
ioos/compliance-checker
compliance_checker/runner.py
ComplianceChecker.stdout_output
def stdout_output(cls, cs, score_dict, verbose, limit): ''' Calls output routine to display results in terminal, including scoring. Goes to verbose function if called by user. @param cs Compliance Checker Suite @param score_dict Dict with dataset name as key, list of...
python
def stdout_output(cls, cs, score_dict, verbose, limit): ''' Calls output routine to display results in terminal, including scoring. Goes to verbose function if called by user. @param cs Compliance Checker Suite @param score_dict Dict with dataset name as key, list of...
[ "def", "stdout_output", "(", "cls", ",", "cs", ",", "score_dict", ",", "verbose", ",", "limit", ")", ":", "for", "ds", ",", "score_groups", "in", "six", ".", "iteritems", "(", "score_dict", ")", ":", "for", "checker", ",", "rpair", "in", "six", ".", ...
Calls output routine to display results in terminal, including scoring. Goes to verbose function if called by user. @param cs Compliance Checker Suite @param score_dict Dict with dataset name as key, list of results as value @param verbose In...
[ "Calls", "output", "routine", "to", "display", "results", "in", "terminal", "including", "scoring", ".", "Goes", "to", "verbose", "function", "if", "called", "by", "user", "." ]
ee89c27b0daade58812489a2da3aa3b6859eafd9
https://github.com/ioos/compliance-checker/blob/ee89c27b0daade58812489a2da3aa3b6859eafd9/compliance_checker/runner.py#L126-L147
train
ioos/compliance-checker
compliance_checker/ioos.py
IOOSNCCheck.check_time_period
def check_time_period(self, ds): """ Check that time period attributes are both set. """ start = self.std_check(ds, 'time_coverage_start') end = self.std_check(ds, 'time_coverage_end') msgs = [] count = 2 if not start: count -= 1 m...
python
def check_time_period(self, ds): """ Check that time period attributes are both set. """ start = self.std_check(ds, 'time_coverage_start') end = self.std_check(ds, 'time_coverage_end') msgs = [] count = 2 if not start: count -= 1 m...
[ "def", "check_time_period", "(", "self", ",", "ds", ")", ":", "start", "=", "self", ".", "std_check", "(", "ds", ",", "'time_coverage_start'", ")", "end", "=", "self", ".", "std_check", "(", "ds", ",", "'time_coverage_end'", ")", "msgs", "=", "[", "]", ...
Check that time period attributes are both set.
[ "Check", "that", "time", "period", "attributes", "are", "both", "set", "." ]
ee89c27b0daade58812489a2da3aa3b6859eafd9
https://github.com/ioos/compliance-checker/blob/ee89c27b0daade58812489a2da3aa3b6859eafd9/compliance_checker/ioos.py#L57-L73
train
ioos/compliance-checker
compliance_checker/ioos.py
IOOSNCCheck.check_station_location_lat
def check_station_location_lat(self, ds): """ Checks station lat attributes are set """ gmin = self.std_check(ds, 'geospatial_lat_min') gmax = self.std_check(ds, 'geospatial_lat_max') msgs = [] count = 2 if not gmin: count -= 1 msg...
python
def check_station_location_lat(self, ds): """ Checks station lat attributes are set """ gmin = self.std_check(ds, 'geospatial_lat_min') gmax = self.std_check(ds, 'geospatial_lat_max') msgs = [] count = 2 if not gmin: count -= 1 msg...
[ "def", "check_station_location_lat", "(", "self", ",", "ds", ")", ":", "gmin", "=", "self", ".", "std_check", "(", "ds", ",", "'geospatial_lat_min'", ")", "gmax", "=", "self", ".", "std_check", "(", "ds", ",", "'geospatial_lat_max'", ")", "msgs", "=", "[",...
Checks station lat attributes are set
[ "Checks", "station", "lat", "attributes", "are", "set" ]
ee89c27b0daade58812489a2da3aa3b6859eafd9
https://github.com/ioos/compliance-checker/blob/ee89c27b0daade58812489a2da3aa3b6859eafd9/compliance_checker/ioos.py#L75-L91
train
ioos/compliance-checker
compliance_checker/ioos.py
IOOS0_1Check.check_global_attributes
def check_global_attributes(self, ds): """ Check all global NC attributes for existence. :param netCDF4.Dataset ds: An open netCDF dataset """ return [ self._has_attr(ds, 'acknowledgement', 'Platform Sponsor'), self._has_attr(ds, 'publisher_email', 'Stati...
python
def check_global_attributes(self, ds): """ Check all global NC attributes for existence. :param netCDF4.Dataset ds: An open netCDF dataset """ return [ self._has_attr(ds, 'acknowledgement', 'Platform Sponsor'), self._has_attr(ds, 'publisher_email', 'Stati...
[ "def", "check_global_attributes", "(", "self", ",", "ds", ")", ":", "return", "[", "self", ".", "_has_attr", "(", "ds", ",", "'acknowledgement'", ",", "'Platform Sponsor'", ")", ",", "self", ".", "_has_attr", "(", "ds", ",", "'publisher_email'", ",", "'Stati...
Check all global NC attributes for existence. :param netCDF4.Dataset ds: An open netCDF dataset
[ "Check", "all", "global", "NC", "attributes", "for", "existence", "." ]
ee89c27b0daade58812489a2da3aa3b6859eafd9
https://github.com/ioos/compliance-checker/blob/ee89c27b0daade58812489a2da3aa3b6859eafd9/compliance_checker/ioos.py#L117-L131
train
ioos/compliance-checker
compliance_checker/ioos.py
IOOS0_1Check.check_variable_attributes
def check_variable_attributes(self, ds): """ Check IOOS concepts that come from NC variable attributes. :param netCDF4.Dataset ds: An open netCDF dataset """ return [ self._has_var_attr(ds, 'platform', 'long_name', 'Station Long Name'), self._has_var_attr...
python
def check_variable_attributes(self, ds): """ Check IOOS concepts that come from NC variable attributes. :param netCDF4.Dataset ds: An open netCDF dataset """ return [ self._has_var_attr(ds, 'platform', 'long_name', 'Station Long Name'), self._has_var_attr...
[ "def", "check_variable_attributes", "(", "self", ",", "ds", ")", ":", "return", "[", "self", ".", "_has_var_attr", "(", "ds", ",", "'platform'", ",", "'long_name'", ",", "'Station Long Name'", ")", ",", "self", ".", "_has_var_attr", "(", "ds", ",", "'platfor...
Check IOOS concepts that come from NC variable attributes. :param netCDF4.Dataset ds: An open netCDF dataset
[ "Check", "IOOS", "concepts", "that", "come", "from", "NC", "variable", "attributes", "." ]
ee89c27b0daade58812489a2da3aa3b6859eafd9
https://github.com/ioos/compliance-checker/blob/ee89c27b0daade58812489a2da3aa3b6859eafd9/compliance_checker/ioos.py#L133-L146
train
ioos/compliance-checker
compliance_checker/ioos.py
IOOS0_1Check.check_variable_names
def check_variable_names(self, ds): """ Ensures all variables have a standard_name set. """ msgs = [] count = 0 for k, v in ds.variables.items(): if 'standard_name' in v.ncattrs(): count += 1 else: msgs.append("Vari...
python
def check_variable_names(self, ds): """ Ensures all variables have a standard_name set. """ msgs = [] count = 0 for k, v in ds.variables.items(): if 'standard_name' in v.ncattrs(): count += 1 else: msgs.append("Vari...
[ "def", "check_variable_names", "(", "self", ",", "ds", ")", ":", "msgs", "=", "[", "]", "count", "=", "0", "for", "k", ",", "v", "in", "ds", ".", "variables", ".", "items", "(", ")", ":", "if", "'standard_name'", "in", "v", ".", "ncattrs", "(", "...
Ensures all variables have a standard_name set.
[ "Ensures", "all", "variables", "have", "a", "standard_name", "set", "." ]
ee89c27b0daade58812489a2da3aa3b6859eafd9
https://github.com/ioos/compliance-checker/blob/ee89c27b0daade58812489a2da3aa3b6859eafd9/compliance_checker/ioos.py#L148-L161
train
ioos/compliance-checker
compliance_checker/ioos.py
IOOS0_1Check.check_altitude_units
def check_altitude_units(self, ds): """ If there's a variable named z, it must have units. @TODO: this is duplicated with check_variable_units :param netCDF4.Dataset ds: An open netCDF dataset """ if 'z' in ds.variables: msgs = [] val = 'units' in...
python
def check_altitude_units(self, ds): """ If there's a variable named z, it must have units. @TODO: this is duplicated with check_variable_units :param netCDF4.Dataset ds: An open netCDF dataset """ if 'z' in ds.variables: msgs = [] val = 'units' in...
[ "def", "check_altitude_units", "(", "self", ",", "ds", ")", ":", "if", "'z'", "in", "ds", ".", "variables", ":", "msgs", "=", "[", "]", "val", "=", "'units'", "in", "ds", ".", "variables", "[", "'z'", "]", ".", "ncattrs", "(", ")", "if", "not", "...
If there's a variable named z, it must have units. @TODO: this is duplicated with check_variable_units :param netCDF4.Dataset ds: An open netCDF dataset
[ "If", "there", "s", "a", "variable", "named", "z", "it", "must", "have", "units", "." ]
ee89c27b0daade58812489a2da3aa3b6859eafd9
https://github.com/ioos/compliance-checker/blob/ee89c27b0daade58812489a2da3aa3b6859eafd9/compliance_checker/ioos.py#L163-L177
train
ioos/compliance-checker
compliance_checker/ioos.py
IOOS1_1Check.check_platform_variables
def check_platform_variables(self, ds): ''' The value of platform attribute should be set to another variable which contains the details of the platform. There can be multiple platforms involved depending on if all the instances of the featureType in the collection share the same...
python
def check_platform_variables(self, ds): ''' The value of platform attribute should be set to another variable which contains the details of the platform. There can be multiple platforms involved depending on if all the instances of the featureType in the collection share the same...
[ "def", "check_platform_variables", "(", "self", ",", "ds", ")", ":", "platform_names", "=", "getattr", "(", "ds", ",", "'platform'", ",", "''", ")", ".", "split", "(", "' '", ")", "val", "=", "all", "(", "platform_name", "in", "ds", ".", "variables", "...
The value of platform attribute should be set to another variable which contains the details of the platform. There can be multiple platforms involved depending on if all the instances of the featureType in the collection share the same platform or not. If multiple platforms are involved...
[ "The", "value", "of", "platform", "attribute", "should", "be", "set", "to", "another", "variable", "which", "contains", "the", "details", "of", "the", "platform", ".", "There", "can", "be", "multiple", "platforms", "involved", "depending", "on", "if", "all", ...
ee89c27b0daade58812489a2da3aa3b6859eafd9
https://github.com/ioos/compliance-checker/blob/ee89c27b0daade58812489a2da3aa3b6859eafd9/compliance_checker/ioos.py#L267-L286
train
ioos/compliance-checker
compliance_checker/ioos.py
IOOS1_1Check.check_geophysical_vars_fill_value
def check_geophysical_vars_fill_value(self, ds): ''' Check that geophysical variables contain fill values. :param netCDF4.Dataset ds: An open netCDF dataset ''' results = [] for geo_var in get_geophysical_variables(ds): results.append( self._h...
python
def check_geophysical_vars_fill_value(self, ds): ''' Check that geophysical variables contain fill values. :param netCDF4.Dataset ds: An open netCDF dataset ''' results = [] for geo_var in get_geophysical_variables(ds): results.append( self._h...
[ "def", "check_geophysical_vars_fill_value", "(", "self", ",", "ds", ")", ":", "results", "=", "[", "]", "for", "geo_var", "in", "get_geophysical_variables", "(", "ds", ")", ":", "results", ".", "append", "(", "self", ".", "_has_var_attr", "(", "ds", ",", "...
Check that geophysical variables contain fill values. :param netCDF4.Dataset ds: An open netCDF dataset
[ "Check", "that", "geophysical", "variables", "contain", "fill", "values", "." ]
ee89c27b0daade58812489a2da3aa3b6859eafd9
https://github.com/ioos/compliance-checker/blob/ee89c27b0daade58812489a2da3aa3b6859eafd9/compliance_checker/ioos.py#L311-L322
train
ioos/compliance-checker
compliance_checker/ioos.py
IOOS1_1Check.check_geophysical_vars_standard_name
def check_geophysical_vars_standard_name(self, ds): ''' Check that geophysical variables contain standard names. :param netCDF4.Dataset ds: An open netCDF dataset ''' results = [] for geo_var in get_geophysical_variables(ds): results.append( s...
python
def check_geophysical_vars_standard_name(self, ds): ''' Check that geophysical variables contain standard names. :param netCDF4.Dataset ds: An open netCDF dataset ''' results = [] for geo_var in get_geophysical_variables(ds): results.append( s...
[ "def", "check_geophysical_vars_standard_name", "(", "self", ",", "ds", ")", ":", "results", "=", "[", "]", "for", "geo_var", "in", "get_geophysical_variables", "(", "ds", ")", ":", "results", ".", "append", "(", "self", ".", "_has_var_attr", "(", "ds", ",", ...
Check that geophysical variables contain standard names. :param netCDF4.Dataset ds: An open netCDF dataset
[ "Check", "that", "geophysical", "variables", "contain", "standard", "names", "." ]
ee89c27b0daade58812489a2da3aa3b6859eafd9
https://github.com/ioos/compliance-checker/blob/ee89c27b0daade58812489a2da3aa3b6859eafd9/compliance_checker/ioos.py#L324-L335
train
ioos/compliance-checker
compliance_checker/cfutil.py
is_dimensionless_standard_name
def is_dimensionless_standard_name(xml_tree, standard_name): ''' Returns True if the units for the associated standard name are dimensionless. Dimensionless standard names include those that have no units and units that are defined as constant units in the CF standard name table i.e. '1', or '1e-3'...
python
def is_dimensionless_standard_name(xml_tree, standard_name): ''' Returns True if the units for the associated standard name are dimensionless. Dimensionless standard names include those that have no units and units that are defined as constant units in the CF standard name table i.e. '1', or '1e-3'...
[ "def", "is_dimensionless_standard_name", "(", "xml_tree", ",", "standard_name", ")", ":", "if", "not", "isinstance", "(", "standard_name", ",", "basestring", ")", ":", "return", "False", "found_standard_name", "=", "xml_tree", ".", "find", "(", "\".//entry[@id='{}']...
Returns True if the units for the associated standard name are dimensionless. Dimensionless standard names include those that have no units and units that are defined as constant units in the CF standard name table i.e. '1', or '1e-3'.
[ "Returns", "True", "if", "the", "units", "for", "the", "associated", "standard", "name", "are", "dimensionless", ".", "Dimensionless", "standard", "names", "include", "those", "that", "have", "no", "units", "and", "units", "that", "are", "defined", "as", "cons...
ee89c27b0daade58812489a2da3aa3b6859eafd9
https://github.com/ioos/compliance-checker/blob/ee89c27b0daade58812489a2da3aa3b6859eafd9/compliance_checker/cfutil.py#L110-L132
train
ioos/compliance-checker
compliance_checker/cfutil.py
is_unitless
def is_unitless(ds, variable): ''' Returns true if the variable is unitless Note units of '1' are considered whole numbers or parts but still represent physical units and not the absence of units. :param netCDF4.Dataset ds: An open netCDF dataset :param str variable: Name of the variable '...
python
def is_unitless(ds, variable): ''' Returns true if the variable is unitless Note units of '1' are considered whole numbers or parts but still represent physical units and not the absence of units. :param netCDF4.Dataset ds: An open netCDF dataset :param str variable: Name of the variable '...
[ "def", "is_unitless", "(", "ds", ",", "variable", ")", ":", "units", "=", "getattr", "(", "ds", ".", "variables", "[", "variable", "]", ",", "'units'", ",", "None", ")", "return", "units", "is", "None", "or", "units", "==", "''" ]
Returns true if the variable is unitless Note units of '1' are considered whole numbers or parts but still represent physical units and not the absence of units. :param netCDF4.Dataset ds: An open netCDF dataset :param str variable: Name of the variable
[ "Returns", "true", "if", "the", "variable", "is", "unitless" ]
ee89c27b0daade58812489a2da3aa3b6859eafd9
https://github.com/ioos/compliance-checker/blob/ee89c27b0daade58812489a2da3aa3b6859eafd9/compliance_checker/cfutil.py#L152-L163
train
ioos/compliance-checker
compliance_checker/cfutil.py
get_cell_boundary_map
def get_cell_boundary_map(ds): ''' Returns a dictionary mapping a variable to its boundary variable. The returned dictionary maps a string variable name to the name of the boundary variable. :param netCDF4.Dataset nc: netCDF dataset ''' boundary_map = {} for variable in ds.get_variables...
python
def get_cell_boundary_map(ds): ''' Returns a dictionary mapping a variable to its boundary variable. The returned dictionary maps a string variable name to the name of the boundary variable. :param netCDF4.Dataset nc: netCDF dataset ''' boundary_map = {} for variable in ds.get_variables...
[ "def", "get_cell_boundary_map", "(", "ds", ")", ":", "boundary_map", "=", "{", "}", "for", "variable", "in", "ds", ".", "get_variables_by_attributes", "(", "bounds", "=", "lambda", "x", ":", "x", "is", "not", "None", ")", ":", "if", "variable", ".", "bou...
Returns a dictionary mapping a variable to its boundary variable. The returned dictionary maps a string variable name to the name of the boundary variable. :param netCDF4.Dataset nc: netCDF dataset
[ "Returns", "a", "dictionary", "mapping", "a", "variable", "to", "its", "boundary", "variable", ".", "The", "returned", "dictionary", "maps", "a", "string", "variable", "name", "to", "the", "name", "of", "the", "boundary", "variable", "." ]
ee89c27b0daade58812489a2da3aa3b6859eafd9
https://github.com/ioos/compliance-checker/blob/ee89c27b0daade58812489a2da3aa3b6859eafd9/compliance_checker/cfutil.py#L309-L321
train
ioos/compliance-checker
compliance_checker/cfutil.py
get_cell_boundary_variables
def get_cell_boundary_variables(ds): ''' Returns a list of variable names for variables that represent cell boundaries through the `bounds` attribute :param netCDF4.Dataset nc: netCDF dataset ''' boundary_variables = [] has_bounds = ds.get_variables_by_attributes(bounds=lambda x: x is not N...
python
def get_cell_boundary_variables(ds): ''' Returns a list of variable names for variables that represent cell boundaries through the `bounds` attribute :param netCDF4.Dataset nc: netCDF dataset ''' boundary_variables = [] has_bounds = ds.get_variables_by_attributes(bounds=lambda x: x is not N...
[ "def", "get_cell_boundary_variables", "(", "ds", ")", ":", "boundary_variables", "=", "[", "]", "has_bounds", "=", "ds", ".", "get_variables_by_attributes", "(", "bounds", "=", "lambda", "x", ":", "x", "is", "not", "None", ")", "for", "var", "in", "has_bound...
Returns a list of variable names for variables that represent cell boundaries through the `bounds` attribute :param netCDF4.Dataset nc: netCDF dataset
[ "Returns", "a", "list", "of", "variable", "names", "for", "variables", "that", "represent", "cell", "boundaries", "through", "the", "bounds", "attribute" ]
ee89c27b0daade58812489a2da3aa3b6859eafd9
https://github.com/ioos/compliance-checker/blob/ee89c27b0daade58812489a2da3aa3b6859eafd9/compliance_checker/cfutil.py#L324-L336
train
ioos/compliance-checker
compliance_checker/cfutil.py
get_geophysical_variables
def get_geophysical_variables(ds): ''' Returns a list of variable names for the variables detected as geophysical variables. :param netCDF4.Dataset nc: An open netCDF dataset ''' parameters = [] for variable in ds.variables: if is_geophysical(ds, variable): parameters.a...
python
def get_geophysical_variables(ds): ''' Returns a list of variable names for the variables detected as geophysical variables. :param netCDF4.Dataset nc: An open netCDF dataset ''' parameters = [] for variable in ds.variables: if is_geophysical(ds, variable): parameters.a...
[ "def", "get_geophysical_variables", "(", "ds", ")", ":", "parameters", "=", "[", "]", "for", "variable", "in", "ds", ".", "variables", ":", "if", "is_geophysical", "(", "ds", ",", "variable", ")", ":", "parameters", ".", "append", "(", "variable", ")", "...
Returns a list of variable names for the variables detected as geophysical variables. :param netCDF4.Dataset nc: An open netCDF dataset
[ "Returns", "a", "list", "of", "variable", "names", "for", "the", "variables", "detected", "as", "geophysical", "variables", "." ]
ee89c27b0daade58812489a2da3aa3b6859eafd9
https://github.com/ioos/compliance-checker/blob/ee89c27b0daade58812489a2da3aa3b6859eafd9/compliance_checker/cfutil.py#L339-L351
train
ioos/compliance-checker
compliance_checker/cfutil.py
get_z_variables
def get_z_variables(nc): ''' Returns a list of all variables matching definitions for Z :param netcdf4.dataset nc: an open netcdf dataset object ''' z_variables = [] # Vertical coordinates will be identifiable by units of pressure or the # presence of the positive attribute with a value of ...
python
def get_z_variables(nc): ''' Returns a list of all variables matching definitions for Z :param netcdf4.dataset nc: an open netcdf dataset object ''' z_variables = [] # Vertical coordinates will be identifiable by units of pressure or the # presence of the positive attribute with a value of ...
[ "def", "get_z_variables", "(", "nc", ")", ":", "z_variables", "=", "[", "]", "total_coords", "=", "get_coordinate_variables", "(", "nc", ")", "+", "get_auxiliary_coordinate_variables", "(", "nc", ")", "for", "coord_name", "in", "total_coords", ":", "if", "coord_...
Returns a list of all variables matching definitions for Z :param netcdf4.dataset nc: an open netcdf dataset object
[ "Returns", "a", "list", "of", "all", "variables", "matching", "definitions", "for", "Z" ]
ee89c27b0daade58812489a2da3aa3b6859eafd9
https://github.com/ioos/compliance-checker/blob/ee89c27b0daade58812489a2da3aa3b6859eafd9/compliance_checker/cfutil.py#L383-L421
train
ioos/compliance-checker
compliance_checker/cfutil.py
get_latitude_variables
def get_latitude_variables(nc): ''' Returns a list of all variables matching definitions for latitude :param netcdf4.dataset nc: an open netcdf dataset object ''' latitude_variables = [] # standard_name takes precedence for variable in nc.get_variables_by_attributes(standard_name="latitude"...
python
def get_latitude_variables(nc): ''' Returns a list of all variables matching definitions for latitude :param netcdf4.dataset nc: an open netcdf dataset object ''' latitude_variables = [] # standard_name takes precedence for variable in nc.get_variables_by_attributes(standard_name="latitude"...
[ "def", "get_latitude_variables", "(", "nc", ")", ":", "latitude_variables", "=", "[", "]", "for", "variable", "in", "nc", ".", "get_variables_by_attributes", "(", "standard_name", "=", "\"latitude\"", ")", ":", "latitude_variables", ".", "append", "(", "variable",...
Returns a list of all variables matching definitions for latitude :param netcdf4.dataset nc: an open netcdf dataset object
[ "Returns", "a", "list", "of", "all", "variables", "matching", "definitions", "for", "latitude" ]
ee89c27b0daade58812489a2da3aa3b6859eafd9
https://github.com/ioos/compliance-checker/blob/ee89c27b0daade58812489a2da3aa3b6859eafd9/compliance_checker/cfutil.py#L437-L459
train
ioos/compliance-checker
compliance_checker/cfutil.py
get_true_latitude_variables
def get_true_latitude_variables(nc): ''' Returns a list of variables defining true latitude. CF Chapter 4 refers to latitude as a coordinate variable that can also be used in non-standard coordinate systems like rotated pole and other projections. Chapter 5 refers to a concept of true latitude wher...
python
def get_true_latitude_variables(nc): ''' Returns a list of variables defining true latitude. CF Chapter 4 refers to latitude as a coordinate variable that can also be used in non-standard coordinate systems like rotated pole and other projections. Chapter 5 refers to a concept of true latitude wher...
[ "def", "get_true_latitude_variables", "(", "nc", ")", ":", "lats", "=", "get_latitude_variables", "(", "nc", ")", "true_lats", "=", "[", "]", "for", "lat", "in", "lats", ":", "standard_name", "=", "getattr", "(", "nc", ".", "variables", "[", "lat", "]", ...
Returns a list of variables defining true latitude. CF Chapter 4 refers to latitude as a coordinate variable that can also be used in non-standard coordinate systems like rotated pole and other projections. Chapter 5 refers to a concept of true latitude where the variabe defines latitude in a standard ...
[ "Returns", "a", "list", "of", "variables", "defining", "true", "latitude", "." ]
ee89c27b0daade58812489a2da3aa3b6859eafd9
https://github.com/ioos/compliance-checker/blob/ee89c27b0daade58812489a2da3aa3b6859eafd9/compliance_checker/cfutil.py#L462-L485
train
ioos/compliance-checker
compliance_checker/cfutil.py
get_longitude_variables
def get_longitude_variables(nc): ''' Returns a list of all variables matching definitions for longitude :param netcdf4.dataset nc: an open netcdf dataset object ''' longitude_variables = [] # standard_name takes precedence for variable in nc.get_variables_by_attributes(standard_name="longit...
python
def get_longitude_variables(nc): ''' Returns a list of all variables matching definitions for longitude :param netcdf4.dataset nc: an open netcdf dataset object ''' longitude_variables = [] # standard_name takes precedence for variable in nc.get_variables_by_attributes(standard_name="longit...
[ "def", "get_longitude_variables", "(", "nc", ")", ":", "longitude_variables", "=", "[", "]", "for", "variable", "in", "nc", ".", "get_variables_by_attributes", "(", "standard_name", "=", "\"longitude\"", ")", ":", "longitude_variables", ".", "append", "(", "variab...
Returns a list of all variables matching definitions for longitude :param netcdf4.dataset nc: an open netcdf dataset object
[ "Returns", "a", "list", "of", "all", "variables", "matching", "definitions", "for", "longitude" ]
ee89c27b0daade58812489a2da3aa3b6859eafd9
https://github.com/ioos/compliance-checker/blob/ee89c27b0daade58812489a2da3aa3b6859eafd9/compliance_checker/cfutil.py#L501-L523
train
ioos/compliance-checker
compliance_checker/cfutil.py
get_true_longitude_variables
def get_true_longitude_variables(nc): ''' Returns a list of variables defining true longitude. CF Chapter 4 refers to longitude as a coordinate variable that can also be used in non-standard coordinate systems like rotated pole and other projections. Chapter 5 refers to a concept of true longitude ...
python
def get_true_longitude_variables(nc): ''' Returns a list of variables defining true longitude. CF Chapter 4 refers to longitude as a coordinate variable that can also be used in non-standard coordinate systems like rotated pole and other projections. Chapter 5 refers to a concept of true longitude ...
[ "def", "get_true_longitude_variables", "(", "nc", ")", ":", "lons", "=", "get_longitude_variables", "(", "nc", ")", "true_lons", "=", "[", "]", "for", "lon", "in", "lons", ":", "standard_name", "=", "getattr", "(", "nc", ".", "variables", "[", "lon", "]", ...
Returns a list of variables defining true longitude. CF Chapter 4 refers to longitude as a coordinate variable that can also be used in non-standard coordinate systems like rotated pole and other projections. Chapter 5 refers to a concept of true longitude where the variabe defines longitude in a stand...
[ "Returns", "a", "list", "of", "variables", "defining", "true", "longitude", "." ]
ee89c27b0daade58812489a2da3aa3b6859eafd9
https://github.com/ioos/compliance-checker/blob/ee89c27b0daade58812489a2da3aa3b6859eafd9/compliance_checker/cfutil.py#L526-L549
train
ioos/compliance-checker
compliance_checker/cfutil.py
get_platform_variables
def get_platform_variables(ds): ''' Returns a list of platform variable NAMES :param netCDF4.Dataset ds: An open netCDF4 Dataset ''' candidates = [] for variable in ds.variables: platform = getattr(ds.variables[variable], 'platform', '') if platform and platform in ds.variables:...
python
def get_platform_variables(ds): ''' Returns a list of platform variable NAMES :param netCDF4.Dataset ds: An open netCDF4 Dataset ''' candidates = [] for variable in ds.variables: platform = getattr(ds.variables[variable], 'platform', '') if platform and platform in ds.variables:...
[ "def", "get_platform_variables", "(", "ds", ")", ":", "candidates", "=", "[", "]", "for", "variable", "in", "ds", ".", "variables", ":", "platform", "=", "getattr", "(", "ds", ".", "variables", "[", "variable", "]", ",", "'platform'", ",", "''", ")", "...
Returns a list of platform variable NAMES :param netCDF4.Dataset ds: An open netCDF4 Dataset
[ "Returns", "a", "list", "of", "platform", "variable", "NAMES" ]
ee89c27b0daade58812489a2da3aa3b6859eafd9
https://github.com/ioos/compliance-checker/blob/ee89c27b0daade58812489a2da3aa3b6859eafd9/compliance_checker/cfutil.py#L552-L569
train
ioos/compliance-checker
compliance_checker/cfutil.py
get_instrument_variables
def get_instrument_variables(ds): ''' Returns a list of instrument variables :param netCDF4.Dataset ds: An open netCDF4 Dataset ''' candidates = [] for variable in ds.variables: instrument = getattr(ds.variables[variable], 'instrument', '') if instrument and instrument in ds.var...
python
def get_instrument_variables(ds): ''' Returns a list of instrument variables :param netCDF4.Dataset ds: An open netCDF4 Dataset ''' candidates = [] for variable in ds.variables: instrument = getattr(ds.variables[variable], 'instrument', '') if instrument and instrument in ds.var...
[ "def", "get_instrument_variables", "(", "ds", ")", ":", "candidates", "=", "[", "]", "for", "variable", "in", "ds", ".", "variables", ":", "instrument", "=", "getattr", "(", "ds", ".", "variables", "[", "variable", "]", ",", "'instrument'", ",", "''", ")...
Returns a list of instrument variables :param netCDF4.Dataset ds: An open netCDF4 Dataset
[ "Returns", "a", "list", "of", "instrument", "variables" ]
ee89c27b0daade58812489a2da3aa3b6859eafd9
https://github.com/ioos/compliance-checker/blob/ee89c27b0daade58812489a2da3aa3b6859eafd9/compliance_checker/cfutil.py#L572-L589
train
ioos/compliance-checker
compliance_checker/cfutil.py
get_time_variables
def get_time_variables(ds): ''' Returns a list of variables describing the time coordinate :param netCDF4.Dataset ds: An open netCDF4 Dataset ''' time_variables = set() for variable in ds.get_variables_by_attributes(standard_name='time'): time_variables.add(variable.name) for varia...
python
def get_time_variables(ds): ''' Returns a list of variables describing the time coordinate :param netCDF4.Dataset ds: An open netCDF4 Dataset ''' time_variables = set() for variable in ds.get_variables_by_attributes(standard_name='time'): time_variables.add(variable.name) for varia...
[ "def", "get_time_variables", "(", "ds", ")", ":", "time_variables", "=", "set", "(", ")", "for", "variable", "in", "ds", ".", "get_variables_by_attributes", "(", "standard_name", "=", "'time'", ")", ":", "time_variables", ".", "add", "(", "variable", ".", "n...
Returns a list of variables describing the time coordinate :param netCDF4.Dataset ds: An open netCDF4 Dataset
[ "Returns", "a", "list", "of", "variables", "describing", "the", "time", "coordinate" ]
ee89c27b0daade58812489a2da3aa3b6859eafd9
https://github.com/ioos/compliance-checker/blob/ee89c27b0daade58812489a2da3aa3b6859eafd9/compliance_checker/cfutil.py#L623-L642
train
ioos/compliance-checker
compliance_checker/cfutil.py
get_axis_variables
def get_axis_variables(ds): ''' Returns a list of variables that define an axis of the dataset :param netCDF4.Dataset ds: An open netCDF4 Dataset ''' axis_variables = [] for ncvar in ds.get_variables_by_attributes(axis=lambda x: x is not None): axis_variables.append(ncvar.name) retu...
python
def get_axis_variables(ds): ''' Returns a list of variables that define an axis of the dataset :param netCDF4.Dataset ds: An open netCDF4 Dataset ''' axis_variables = [] for ncvar in ds.get_variables_by_attributes(axis=lambda x: x is not None): axis_variables.append(ncvar.name) retu...
[ "def", "get_axis_variables", "(", "ds", ")", ":", "axis_variables", "=", "[", "]", "for", "ncvar", "in", "ds", ".", "get_variables_by_attributes", "(", "axis", "=", "lambda", "x", ":", "x", "is", "not", "None", ")", ":", "axis_variables", ".", "append", ...
Returns a list of variables that define an axis of the dataset :param netCDF4.Dataset ds: An open netCDF4 Dataset
[ "Returns", "a", "list", "of", "variables", "that", "define", "an", "axis", "of", "the", "dataset" ]
ee89c27b0daade58812489a2da3aa3b6859eafd9
https://github.com/ioos/compliance-checker/blob/ee89c27b0daade58812489a2da3aa3b6859eafd9/compliance_checker/cfutil.py#L645-L654
train
ioos/compliance-checker
compliance_checker/cfutil.py
get_climatology_variable
def get_climatology_variable(ds): ''' Returns the variable describing climatology bounds if it exists. Climatology variables are similar to cell boundary variables that describe the climatology bounds. See Example 7.8 in CF 1.6 :param netCDF4.Dataset ds: An open netCDF4 Dataset :rtype: st...
python
def get_climatology_variable(ds): ''' Returns the variable describing climatology bounds if it exists. Climatology variables are similar to cell boundary variables that describe the climatology bounds. See Example 7.8 in CF 1.6 :param netCDF4.Dataset ds: An open netCDF4 Dataset :rtype: st...
[ "def", "get_climatology_variable", "(", "ds", ")", ":", "time", "=", "get_time_variable", "(", "ds", ")", "if", "not", "time", ":", "return", "None", "if", "hasattr", "(", "ds", ".", "variables", "[", "time", "]", ",", "'climatology'", ")", ":", "if", ...
Returns the variable describing climatology bounds if it exists. Climatology variables are similar to cell boundary variables that describe the climatology bounds. See Example 7.8 in CF 1.6 :param netCDF4.Dataset ds: An open netCDF4 Dataset :rtype: str or None
[ "Returns", "the", "variable", "describing", "climatology", "bounds", "if", "it", "exists", "." ]
ee89c27b0daade58812489a2da3aa3b6859eafd9
https://github.com/ioos/compliance-checker/blob/ee89c27b0daade58812489a2da3aa3b6859eafd9/compliance_checker/cfutil.py#L657-L678
train
ioos/compliance-checker
compliance_checker/cfutil.py
get_flag_variables
def get_flag_variables(ds): ''' Returns a list of variables that are defined as flag variables :param netCDF4.Dataset ds: An open netCDF4 Dataset ''' flag_variables = [] for name, ncvar in ds.variables.items(): standard_name = getattr(ncvar, 'standard_name', None) if isinstance(...
python
def get_flag_variables(ds): ''' Returns a list of variables that are defined as flag variables :param netCDF4.Dataset ds: An open netCDF4 Dataset ''' flag_variables = [] for name, ncvar in ds.variables.items(): standard_name = getattr(ncvar, 'standard_name', None) if isinstance(...
[ "def", "get_flag_variables", "(", "ds", ")", ":", "flag_variables", "=", "[", "]", "for", "name", ",", "ncvar", "in", "ds", ".", "variables", ".", "items", "(", ")", ":", "standard_name", "=", "getattr", "(", "ncvar", ",", "'standard_name'", ",", "None",...
Returns a list of variables that are defined as flag variables :param netCDF4.Dataset ds: An open netCDF4 Dataset
[ "Returns", "a", "list", "of", "variables", "that", "are", "defined", "as", "flag", "variables" ]
ee89c27b0daade58812489a2da3aa3b6859eafd9
https://github.com/ioos/compliance-checker/blob/ee89c27b0daade58812489a2da3aa3b6859eafd9/compliance_checker/cfutil.py#L681-L694
train
ioos/compliance-checker
compliance_checker/cfutil.py
get_grid_mapping_variables
def get_grid_mapping_variables(ds): ''' Returns a list of grid mapping variables :param netCDF4.Dataset ds: An open netCDF4 Dataset ''' grid_mapping_variables = [] for ncvar in ds.get_variables_by_attributes(grid_mapping=lambda x: x is not None): if ncvar.grid_mapping in ds.variables: ...
python
def get_grid_mapping_variables(ds): ''' Returns a list of grid mapping variables :param netCDF4.Dataset ds: An open netCDF4 Dataset ''' grid_mapping_variables = [] for ncvar in ds.get_variables_by_attributes(grid_mapping=lambda x: x is not None): if ncvar.grid_mapping in ds.variables: ...
[ "def", "get_grid_mapping_variables", "(", "ds", ")", ":", "grid_mapping_variables", "=", "[", "]", "for", "ncvar", "in", "ds", ".", "get_variables_by_attributes", "(", "grid_mapping", "=", "lambda", "x", ":", "x", "is", "not", "None", ")", ":", "if", "ncvar"...
Returns a list of grid mapping variables :param netCDF4.Dataset ds: An open netCDF4 Dataset
[ "Returns", "a", "list", "of", "grid", "mapping", "variables" ]
ee89c27b0daade58812489a2da3aa3b6859eafd9
https://github.com/ioos/compliance-checker/blob/ee89c27b0daade58812489a2da3aa3b6859eafd9/compliance_checker/cfutil.py#L697-L707
train
ioos/compliance-checker
compliance_checker/cfutil.py
get_axis_map
def get_axis_map(ds, variable): ''' Returns an axis_map dictionary that contains an axis key and the coordinate names as values. For example:: {'X': ['longitude'], 'Y': ['latitude'], 'T': ['time']} The axis C is for compressed coordinates like a reduced grid, and U is for unknown axis...
python
def get_axis_map(ds, variable): ''' Returns an axis_map dictionary that contains an axis key and the coordinate names as values. For example:: {'X': ['longitude'], 'Y': ['latitude'], 'T': ['time']} The axis C is for compressed coordinates like a reduced grid, and U is for unknown axis...
[ "def", "get_axis_map", "(", "ds", ",", "variable", ")", ":", "all_coords", "=", "get_coordinate_variables", "(", "ds", ")", "+", "get_auxiliary_coordinate_variables", "(", "ds", ")", "latitudes", "=", "get_latitude_variables", "(", "ds", ")", "longitudes", "=", ...
Returns an axis_map dictionary that contains an axis key and the coordinate names as values. For example:: {'X': ['longitude'], 'Y': ['latitude'], 'T': ['time']} The axis C is for compressed coordinates like a reduced grid, and U is for unknown axis. This can sometimes be physical quantities ...
[ "Returns", "an", "axis_map", "dictionary", "that", "contains", "an", "axis", "key", "and", "the", "coordinate", "names", "as", "values", "." ]
ee89c27b0daade58812489a2da3aa3b6859eafd9
https://github.com/ioos/compliance-checker/blob/ee89c27b0daade58812489a2da3aa3b6859eafd9/compliance_checker/cfutil.py#L711-L762
train
ioos/compliance-checker
compliance_checker/cfutil.py
is_coordinate_variable
def is_coordinate_variable(ds, variable): ''' Returns True if the variable is a coordinate variable :param netCDF4.Dataset nc: An open netCDF dataset :param str variable: Variable name ''' if variable not in ds.variables: return False return ds.variables[variable].dimensions == (var...
python
def is_coordinate_variable(ds, variable): ''' Returns True if the variable is a coordinate variable :param netCDF4.Dataset nc: An open netCDF dataset :param str variable: Variable name ''' if variable not in ds.variables: return False return ds.variables[variable].dimensions == (var...
[ "def", "is_coordinate_variable", "(", "ds", ",", "variable", ")", ":", "if", "variable", "not", "in", "ds", ".", "variables", ":", "return", "False", "return", "ds", ".", "variables", "[", "variable", "]", ".", "dimensions", "==", "(", "variable", ",", "...
Returns True if the variable is a coordinate variable :param netCDF4.Dataset nc: An open netCDF dataset :param str variable: Variable name
[ "Returns", "True", "if", "the", "variable", "is", "a", "coordinate", "variable" ]
ee89c27b0daade58812489a2da3aa3b6859eafd9
https://github.com/ioos/compliance-checker/blob/ee89c27b0daade58812489a2da3aa3b6859eafd9/compliance_checker/cfutil.py#L765-L774
train
ioos/compliance-checker
compliance_checker/cfutil.py
is_compression_coordinate
def is_compression_coordinate(ds, variable): ''' Returns True if the variable is a coordinate variable that defines a compression scheme. :param netCDF4.Dataset nc: An open netCDF dataset :param str variable: Variable name ''' # Must be a coordinate variable if not is_coordinate_variabl...
python
def is_compression_coordinate(ds, variable): ''' Returns True if the variable is a coordinate variable that defines a compression scheme. :param netCDF4.Dataset nc: An open netCDF dataset :param str variable: Variable name ''' # Must be a coordinate variable if not is_coordinate_variabl...
[ "def", "is_compression_coordinate", "(", "ds", ",", "variable", ")", ":", "if", "not", "is_coordinate_variable", "(", "ds", ",", "variable", ")", ":", "return", "False", "compress", "=", "getattr", "(", "ds", ".", "variables", "[", "variable", "]", ",", "'...
Returns True if the variable is a coordinate variable that defines a compression scheme. :param netCDF4.Dataset nc: An open netCDF dataset :param str variable: Variable name
[ "Returns", "True", "if", "the", "variable", "is", "a", "coordinate", "variable", "that", "defines", "a", "compression", "scheme", "." ]
ee89c27b0daade58812489a2da3aa3b6859eafd9
https://github.com/ioos/compliance-checker/blob/ee89c27b0daade58812489a2da3aa3b6859eafd9/compliance_checker/cfutil.py#L777-L801
train
ioos/compliance-checker
compliance_checker/cfutil.py
coordinate_dimension_matrix
def coordinate_dimension_matrix(nc): ''' Returns a dictionary of coordinates mapped to their dimensions :param netCDF4.Dataset nc: An open netCDF dataset ''' retval = {} x = get_lon_variable(nc) if x: retval['x'] = nc.variables[x].dimensions y = get_lat_variable(nc) if y: ...
python
def coordinate_dimension_matrix(nc): ''' Returns a dictionary of coordinates mapped to their dimensions :param netCDF4.Dataset nc: An open netCDF dataset ''' retval = {} x = get_lon_variable(nc) if x: retval['x'] = nc.variables[x].dimensions y = get_lat_variable(nc) if y: ...
[ "def", "coordinate_dimension_matrix", "(", "nc", ")", ":", "retval", "=", "{", "}", "x", "=", "get_lon_variable", "(", "nc", ")", "if", "x", ":", "retval", "[", "'x'", "]", "=", "nc", ".", "variables", "[", "x", "]", ".", "dimensions", "y", "=", "g...
Returns a dictionary of coordinates mapped to their dimensions :param netCDF4.Dataset nc: An open netCDF dataset
[ "Returns", "a", "dictionary", "of", "coordinates", "mapped", "to", "their", "dimensions" ]
ee89c27b0daade58812489a2da3aa3b6859eafd9
https://github.com/ioos/compliance-checker/blob/ee89c27b0daade58812489a2da3aa3b6859eafd9/compliance_checker/cfutil.py#L804-L825
train
ioos/compliance-checker
compliance_checker/cfutil.py
is_point
def is_point(nc, variable): ''' Returns true if the variable is a point feature type :param netCDF4.Dataset nc: An open netCDF dataset :param str variable: name of the variable to check ''' # x(o), y(o), z(o), t(o) # X(o) dims = nc.variables[variable].dimensions cmatrix = coordina...
python
def is_point(nc, variable): ''' Returns true if the variable is a point feature type :param netCDF4.Dataset nc: An open netCDF dataset :param str variable: name of the variable to check ''' # x(o), y(o), z(o), t(o) # X(o) dims = nc.variables[variable].dimensions cmatrix = coordina...
[ "def", "is_point", "(", "nc", ",", "variable", ")", ":", "dims", "=", "nc", ".", "variables", "[", "variable", "]", ".", "dimensions", "cmatrix", "=", "coordinate_dimension_matrix", "(", "nc", ")", "first_coord", "=", "None", "if", "'t'", "in", "cmatrix", ...
Returns true if the variable is a point feature type :param netCDF4.Dataset nc: An open netCDF dataset :param str variable: name of the variable to check
[ "Returns", "true", "if", "the", "variable", "is", "a", "point", "feature", "type" ]
ee89c27b0daade58812489a2da3aa3b6859eafd9
https://github.com/ioos/compliance-checker/blob/ee89c27b0daade58812489a2da3aa3b6859eafd9/compliance_checker/cfutil.py#L828-L875
train
ioos/compliance-checker
compliance_checker/cfutil.py
is_cf_trajectory
def is_cf_trajectory(nc, variable): ''' Returns true if the variable is a CF trajectory feature type :param netCDF4.Dataset nc: An open netCDF dataset :param str variable: name of the variable to check ''' # x(i, o), y(i, o), z(i, o), t(i, o) # X(i, o) dims = nc.variables[variable].dime...
python
def is_cf_trajectory(nc, variable): ''' Returns true if the variable is a CF trajectory feature type :param netCDF4.Dataset nc: An open netCDF dataset :param str variable: name of the variable to check ''' # x(i, o), y(i, o), z(i, o), t(i, o) # X(i, o) dims = nc.variables[variable].dime...
[ "def", "is_cf_trajectory", "(", "nc", ",", "variable", ")", ":", "dims", "=", "nc", ".", "variables", "[", "variable", "]", ".", "dimensions", "cmatrix", "=", "coordinate_dimension_matrix", "(", "nc", ")", "for", "req", "in", "(", "'x'", ",", "'y'", ",",...
Returns true if the variable is a CF trajectory feature type :param netCDF4.Dataset nc: An open netCDF dataset :param str variable: name of the variable to check
[ "Returns", "true", "if", "the", "variable", "is", "a", "CF", "trajectory", "feature", "type" ]
ee89c27b0daade58812489a2da3aa3b6859eafd9
https://github.com/ioos/compliance-checker/blob/ee89c27b0daade58812489a2da3aa3b6859eafd9/compliance_checker/cfutil.py#L984-L1009
train