partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
valid | Bulb.rgb_color | Return the color property as list of [R, G, B], each 0-255. | yeelightsunflower/main.py | def rgb_color(self):
"""Return the color property as list of [R, G, B], each 0-255."""
self.update()
return [self._red, self._green, self._blue] | def rgb_color(self):
"""Return the color property as list of [R, G, B], each 0-255."""
self.update()
return [self._red, self._green, self._blue] | [
"Return",
"the",
"color",
"property",
"as",
"list",
"of",
"[",
"R",
"G",
"B",
"]",
"each",
"0",
"-",
"255",
"."
] | lindsaymarkward/python-yeelight-sunflower | python | https://github.com/lindsaymarkward/python-yeelight-sunflower/blob/4ec72d005ce307f832429620ba0bcbf6b236eead/yeelightsunflower/main.py#L193-L196 | [
"def",
"rgb_color",
"(",
"self",
")",
":",
"self",
".",
"update",
"(",
")",
"return",
"[",
"self",
".",
"_red",
",",
"self",
".",
"_green",
",",
"self",
".",
"_blue",
"]"
] | 4ec72d005ce307f832429620ba0bcbf6b236eead |
valid | Bulb.turn_on | Turn bulb on (full brightness). | yeelightsunflower/main.py | def turn_on(self):
"""Turn bulb on (full brightness)."""
command = "C {},,,,100,\r\n".format(self._zid)
response = self._hub.send_command(command)
_LOGGER.debug("Turn on %s: %s", repr(command), response)
return response | def turn_on(self):
"""Turn bulb on (full brightness)."""
command = "C {},,,,100,\r\n".format(self._zid)
response = self._hub.send_command(command)
_LOGGER.debug("Turn on %s: %s", repr(command), response)
return response | [
"Turn",
"bulb",
"on",
"(",
"full",
"brightness",
")",
"."
] | lindsaymarkward/python-yeelight-sunflower | python | https://github.com/lindsaymarkward/python-yeelight-sunflower/blob/4ec72d005ce307f832429620ba0bcbf6b236eead/yeelightsunflower/main.py#L215-L220 | [
"def",
"turn_on",
"(",
"self",
")",
":",
"command",
"=",
"\"C {},,,,100,\\r\\n\"",
".",
"format",
"(",
"self",
".",
"_zid",
")",
"response",
"=",
"self",
".",
"_hub",
".",
"send_command",
"(",
"command",
")",
"_LOGGER",
".",
"debug",
"(",
"\"Turn on %s: %s... | 4ec72d005ce307f832429620ba0bcbf6b236eead |
valid | Bulb.set_brightness | Set brightness of bulb. | yeelightsunflower/main.py | def set_brightness(self, brightness):
"""Set brightness of bulb."""
command = "C {},,,,{},\r\n".format(self._zid, brightness)
response = self._hub.send_command(command)
_LOGGER.debug("Set brightness %s: %s", repr(command), response)
return response | def set_brightness(self, brightness):
"""Set brightness of bulb."""
command = "C {},,,,{},\r\n".format(self._zid, brightness)
response = self._hub.send_command(command)
_LOGGER.debug("Set brightness %s: %s", repr(command), response)
return response | [
"Set",
"brightness",
"of",
"bulb",
"."
] | lindsaymarkward/python-yeelight-sunflower | python | https://github.com/lindsaymarkward/python-yeelight-sunflower/blob/4ec72d005ce307f832429620ba0bcbf6b236eead/yeelightsunflower/main.py#L236-L241 | [
"def",
"set_brightness",
"(",
"self",
",",
"brightness",
")",
":",
"command",
"=",
"\"C {},,,,{},\\r\\n\"",
".",
"format",
"(",
"self",
".",
"_zid",
",",
"brightness",
")",
"response",
"=",
"self",
".",
"_hub",
".",
"send_command",
"(",
"command",
")",
"_L... | 4ec72d005ce307f832429620ba0bcbf6b236eead |
valid | Bulb.set_all | Set color and brightness of bulb. | yeelightsunflower/main.py | def set_all(self, red, green, blue, brightness):
"""Set color and brightness of bulb."""
command = "C {},{},{},{},{},\r\n".format(self._zid, red, green, blue,
brightness)
response = self._hub.send_command(command)
_LOGGER.debug("Set all %s... | def set_all(self, red, green, blue, brightness):
"""Set color and brightness of bulb."""
command = "C {},{},{},{},{},\r\n".format(self._zid, red, green, blue,
brightness)
response = self._hub.send_command(command)
_LOGGER.debug("Set all %s... | [
"Set",
"color",
"and",
"brightness",
"of",
"bulb",
"."
] | lindsaymarkward/python-yeelight-sunflower | python | https://github.com/lindsaymarkward/python-yeelight-sunflower/blob/4ec72d005ce307f832429620ba0bcbf6b236eead/yeelightsunflower/main.py#L243-L249 | [
"def",
"set_all",
"(",
"self",
",",
"red",
",",
"green",
",",
"blue",
",",
"brightness",
")",
":",
"command",
"=",
"\"C {},{},{},{},{},\\r\\n\"",
".",
"format",
"(",
"self",
".",
"_zid",
",",
"red",
",",
"green",
",",
"blue",
",",
"brightness",
")",
"r... | 4ec72d005ce307f832429620ba0bcbf6b236eead |
valid | Bulb.update | Update light objects to their current values. | yeelightsunflower/main.py | def update(self):
"""Update light objects to their current values."""
bulbs = self._hub.get_lights()
if not bulbs:
_LOGGER.debug("%s is offline, send command failed", self._zid)
self._online = False | def update(self):
"""Update light objects to their current values."""
bulbs = self._hub.get_lights()
if not bulbs:
_LOGGER.debug("%s is offline, send command failed", self._zid)
self._online = False | [
"Update",
"light",
"objects",
"to",
"their",
"current",
"values",
"."
] | lindsaymarkward/python-yeelight-sunflower | python | https://github.com/lindsaymarkward/python-yeelight-sunflower/blob/4ec72d005ce307f832429620ba0bcbf6b236eead/yeelightsunflower/main.py#L251-L256 | [
"def",
"update",
"(",
"self",
")",
":",
"bulbs",
"=",
"self",
".",
"_hub",
".",
"get_lights",
"(",
")",
"if",
"not",
"bulbs",
":",
"_LOGGER",
".",
"debug",
"(",
"\"%s is offline, send command failed\"",
",",
"self",
".",
"_zid",
")",
"self",
".",
"_onlin... | 4ec72d005ce307f832429620ba0bcbf6b236eead |
valid | functional | fun(fn) -> function or
fun(fn, args...) -> call of fn(args...)
:param ifunctional: f
:return: decorated function | snipy/basic.py | def functional(ifunctional):
"""
fun(fn) -> function or
fun(fn, args...) -> call of fn(args...)
:param ifunctional: f
:return: decorated function
"""
@wraps(ifunctional)
def wrapper(fn, *args, **kw):
fn = ifunctional(fn)
if args or kw:
return fn(*args, **kw)... | def functional(ifunctional):
"""
fun(fn) -> function or
fun(fn, args...) -> call of fn(args...)
:param ifunctional: f
:return: decorated function
"""
@wraps(ifunctional)
def wrapper(fn, *args, **kw):
fn = ifunctional(fn)
if args or kw:
return fn(*args, **kw)... | [
"fun",
"(",
"fn",
")",
"-",
">",
"function",
"or",
"fun",
"(",
"fn",
"args",
"...",
")",
"-",
">",
"call",
"of",
"fn",
"(",
"args",
"...",
")",
":",
"param",
"ifunctional",
":",
"f",
":",
"return",
":",
"decorated",
"function"
] | dade-ai/snipy | python | https://github.com/dade-ai/snipy/blob/408520867179f99b3158b57520e2619f3fecd69b/snipy/basic.py#L7-L24 | [
"def",
"functional",
"(",
"ifunctional",
")",
":",
"@",
"wraps",
"(",
"ifunctional",
")",
"def",
"wrapper",
"(",
"fn",
",",
"*",
"args",
",",
"*",
"*",
"kw",
")",
":",
"fn",
"=",
"ifunctional",
"(",
"fn",
")",
"if",
"args",
"or",
"kw",
":",
"retu... | 408520867179f99b3158b57520e2619f3fecd69b |
valid | tuple_arg | fun(1,2) -> fun((1,), (2,))๋ก
f(1,2,3) => f((1,), (2,), (3,))
:param fn:
:return: | snipy/basic.py | def tuple_arg(fn):
"""
fun(1,2) -> fun((1,), (2,))๋ก
f(1,2,3) => f((1,), (2,), (3,))
:param fn:
:return:
"""
@wraps(fn)
def wrapped(*args, **kwargs):
args = map(tuplefy, args)
return fn(*args, **kwargs)
return wrapped | def tuple_arg(fn):
"""
fun(1,2) -> fun((1,), (2,))๋ก
f(1,2,3) => f((1,), (2,), (3,))
:param fn:
:return:
"""
@wraps(fn)
def wrapped(*args, **kwargs):
args = map(tuplefy, args)
return fn(*args, **kwargs)
return wrapped | [
"fun",
"(",
"1",
"2",
")",
"-",
">",
"fun",
"((",
"1",
")",
"(",
"2",
"))",
"๋ก",
"f",
"(",
"1",
"2",
"3",
")",
"=",
">",
"f",
"((",
"1",
")",
"(",
"2",
")",
"(",
"3",
"))",
":",
"param",
"fn",
":",
":",
"return",
":"
] | dade-ai/snipy | python | https://github.com/dade-ai/snipy/blob/408520867179f99b3158b57520e2619f3fecd69b/snipy/basic.py#L66-L78 | [
"def",
"tuple_arg",
"(",
"fn",
")",
":",
"@",
"wraps",
"(",
"fn",
")",
"def",
"wrapped",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"args",
"=",
"map",
"(",
"tuplefy",
",",
"args",
")",
"return",
"fn",
"(",
"*",
"args",
",",
"*",
"*... | 408520867179f99b3158b57520e2619f3fecd69b |
valid | tuple_args | args ํ์ฑ ์ ํธ function
fun(p1, p2, ...pn, **kwargs) or fun([p1, p2, ..], **kwargs)
ex) ์ํ::
@tuple_arg
def f(args, **kwargs):
for d in args:
print d
f(1,2,3) => f([1,2,3])
:param function fn:
:return: | snipy/basic.py | def tuple_args(fn):
"""
args ํ์ฑ ์ ํธ function
fun(p1, p2, ...pn, **kwargs) or fun([p1, p2, ..], **kwargs)
ex) ์ํ::
@tuple_arg
def f(args, **kwargs):
for d in args:
print d
f(1,2,3) => f([1,2,3])
:param function fn:
:return:
"""
@wraps(... | def tuple_args(fn):
"""
args ํ์ฑ ์ ํธ function
fun(p1, p2, ...pn, **kwargs) or fun([p1, p2, ..], **kwargs)
ex) ์ํ::
@tuple_arg
def f(args, **kwargs):
for d in args:
print d
f(1,2,3) => f([1,2,3])
:param function fn:
:return:
"""
@wraps(... | [
"args",
"ํ์ฑ",
"์ ํธ",
"function",
"fun",
"(",
"p1",
"p2",
"...",
"pn",
"**",
"kwargs",
")",
"or",
"fun",
"(",
"[",
"p1",
"p2",
"..",
"]",
"**",
"kwargs",
")",
"ex",
")",
"์ํ",
"::"
] | dade-ai/snipy | python | https://github.com/dade-ai/snipy/blob/408520867179f99b3158b57520e2619f3fecd69b/snipy/basic.py#L81-L106 | [
"def",
"tuple_args",
"(",
"fn",
")",
":",
"@",
"wraps",
"(",
"fn",
")",
"def",
"wrapped",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"len",
"(",
"args",
")",
"==",
"1",
":",
"if",
"isinstance",
"(",
"args",
"[",
"0",
"]",
",",... | 408520867179f99b3158b57520e2619f3fecd69b |
valid | unpack_args | args ๊ฐฏ์๊ฐ nth + 1 ๊ฐ ์ผ๋, ๊ทธ๊ฒ ๋ง์ฝ tuple์ด๋ฉด, unpack
:param classfun:
:param nth: nth = 0, ์ผ๋ฐ ํจ์, nth = 1: ํด๋์ค ํจ์ 1์ด self๋๊น.
:return: | snipy/basic.py | def unpack_args(classfun, nth=0):
"""
args ๊ฐฏ์๊ฐ nth + 1 ๊ฐ ์ผ๋, ๊ทธ๊ฒ ๋ง์ฝ tuple์ด๋ฉด, unpack
:param classfun:
:param nth: nth = 0, ์ผ๋ฐ ํจ์, nth = 1: ํด๋์ค ํจ์ 1์ด self๋๊น.
:return:
"""
if classfun:
nth = 1
def deco(fn):
def wrapped(*args, **kwargs):
if len(args) == nth + 1 an... | def unpack_args(classfun, nth=0):
"""
args ๊ฐฏ์๊ฐ nth + 1 ๊ฐ ์ผ๋, ๊ทธ๊ฒ ๋ง์ฝ tuple์ด๋ฉด, unpack
:param classfun:
:param nth: nth = 0, ์ผ๋ฐ ํจ์, nth = 1: ํด๋์ค ํจ์ 1์ด self๋๊น.
:return:
"""
if classfun:
nth = 1
def deco(fn):
def wrapped(*args, **kwargs):
if len(args) == nth + 1 an... | [
"args",
"๊ฐฏ์๊ฐ",
"nth",
"+",
"1",
"๊ฐ",
"์ผ๋",
"๊ทธ๊ฒ",
"๋ง์ฝ",
"tuple์ด๋ฉด",
"unpack",
":",
"param",
"classfun",
":",
":",
"param",
"nth",
":",
"nth",
"=",
"0",
"์ผ๋ฐ",
"ํจ์",
"nth",
"=",
"1",
":",
"ํด๋์ค",
"ํจ์",
"1์ด",
"self๋๊น",
".",
":",
"return",
":"
] | dade-ai/snipy | python | https://github.com/dade-ai/snipy/blob/408520867179f99b3158b57520e2619f3fecd69b/snipy/basic.py#L109-L128 | [
"def",
"unpack_args",
"(",
"classfun",
",",
"nth",
"=",
"0",
")",
":",
"if",
"classfun",
":",
"nth",
"=",
"1",
"def",
"deco",
"(",
"fn",
")",
":",
"def",
"wrapped",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"len",
"(",
"args",
... | 408520867179f99b3158b57520e2619f3fecd69b |
valid | optional_str | string 1๊ฐ๋ง deco ์ธ์๋ก ์ค๊ฑฐ๋ ์๊ฑฐ๋.
:param deco:
:return: | snipy/basic.py | def optional_str(deco):
"""
string 1๊ฐ๋ง deco ์ธ์๋ก ์ค๊ฑฐ๋ ์๊ฑฐ๋.
:param deco:
:return:
"""
@wraps(deco)
def dispatcher(*args, **kwargs):
# when only function arg
if not kwargs and len(args) == 1 and not isinstance(args[0], str) \
and args[0] is not None:
... | def optional_str(deco):
"""
string 1๊ฐ๋ง deco ์ธ์๋ก ์ค๊ฑฐ๋ ์๊ฑฐ๋.
:param deco:
:return:
"""
@wraps(deco)
def dispatcher(*args, **kwargs):
# when only function arg
if not kwargs and len(args) == 1 and not isinstance(args[0], str) \
and args[0] is not None:
... | [
"string",
"1๊ฐ๋ง",
"deco",
"์ธ์๋ก",
"์ค๊ฑฐ๋",
"์๊ฑฐ๋",
".",
":",
"param",
"deco",
":",
":",
"return",
":"
] | dade-ai/snipy | python | https://github.com/dade-ai/snipy/blob/408520867179f99b3158b57520e2619f3fecd69b/snipy/basic.py#L131-L151 | [
"def",
"optional_str",
"(",
"deco",
")",
":",
"@",
"wraps",
"(",
"deco",
")",
"def",
"dispatcher",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"# when only function arg",
"if",
"not",
"kwargs",
"and",
"len",
"(",
"args",
")",
"==",
"1",
"and... | 408520867179f99b3158b57520e2619f3fecd69b |
valid | patchmethod | ํด๋์ค ๋ฉค๋ฒ ํจ์น @patchmethod(Cls1, ..., [name='membername'])
ex)
class A(object):
def __init__(self, data):
self.data = data
@patchmethod(A)
def sample(self):
''' haha docstrings '''
print self.data
@patchmethod(A, name='membermethod)
def sample(self):
'''... | snipy/basic.py | def patchmethod(*cls, **kwargs):
"""
ํด๋์ค ๋ฉค๋ฒ ํจ์น @patchmethod(Cls1, ..., [name='membername'])
ex)
class A(object):
def __init__(self, data):
self.data = data
@patchmethod(A)
def sample(self):
''' haha docstrings '''
print self.data
@patchmethod(A, name='me... | def patchmethod(*cls, **kwargs):
"""
ํด๋์ค ๋ฉค๋ฒ ํจ์น @patchmethod(Cls1, ..., [name='membername'])
ex)
class A(object):
def __init__(self, data):
self.data = data
@patchmethod(A)
def sample(self):
''' haha docstrings '''
print self.data
@patchmethod(A, name='me... | [
"ํด๋์ค",
"๋ฉค๋ฒ",
"ํจ์น",
"@patchmethod",
"(",
"Cls1",
"...",
"[",
"name",
"=",
"membername",
"]",
")",
"ex",
")",
"class",
"A",
"(",
"object",
")",
":",
"def",
"__init__",
"(",
"self",
"data",
")",
":",
"self",
".",
"data",
"=",
"data"
] | dade-ai/snipy | python | https://github.com/dade-ai/snipy/blob/408520867179f99b3158b57520e2619f3fecd69b/snipy/basic.py#L154-L187 | [
"def",
"patchmethod",
"(",
"*",
"cls",
",",
"*",
"*",
"kwargs",
")",
":",
"def",
"_patch",
"(",
"fun",
")",
":",
"m",
"=",
"kwargs",
".",
"pop",
"(",
"'name'",
",",
"None",
")",
"or",
"fun",
".",
"__name__",
"for",
"c",
"in",
"cls",
":",
"setat... | 408520867179f99b3158b57520e2619f3fecd69b |
valid | patchproperty | class getter ํจ์ ํจ์น decorator
EX)
class B(A):
pass
@patchproperty(B)
def prop(self):
return 'hello'
:param cls:
:param kwargs: | snipy/basic.py | def patchproperty(*cls, **kwargs):
"""
class getter ํจ์ ํจ์น decorator
EX)
class B(A):
pass
@patchproperty(B)
def prop(self):
return 'hello'
:param cls:
:param kwargs:
"""
def _patch(fun):
m = kwargs.pop('property', None) or fun.__name__
p = proper... | def patchproperty(*cls, **kwargs):
"""
class getter ํจ์ ํจ์น decorator
EX)
class B(A):
pass
@patchproperty(B)
def prop(self):
return 'hello'
:param cls:
:param kwargs:
"""
def _patch(fun):
m = kwargs.pop('property', None) or fun.__name__
p = proper... | [
"class",
"getter",
"ํจ์",
"ํจ์น",
"decorator",
"EX",
")",
"class",
"B",
"(",
"A",
")",
":",
"pass"
] | dade-ai/snipy | python | https://github.com/dade-ai/snipy/blob/408520867179f99b3158b57520e2619f3fecd69b/snipy/basic.py#L190-L215 | [
"def",
"patchproperty",
"(",
"*",
"cls",
",",
"*",
"*",
"kwargs",
")",
":",
"def",
"_patch",
"(",
"fun",
")",
":",
"m",
"=",
"kwargs",
".",
"pop",
"(",
"'property'",
",",
"None",
")",
"or",
"fun",
".",
"__name__",
"p",
"=",
"property",
"(",
"fun"... | 408520867179f99b3158b57520e2619f3fecd69b |
valid | on_interrupt | context for handling keyboardinterrupt
ex)
with on_interrupt(handler):
critical_work_to_prevent()
from logger import logg
on_interrupt.signal = None
:param function handler:
:param bool reraise:
:return: context | snipy/basic.py | def on_interrupt(handler, reraise=False):
"""
context for handling keyboardinterrupt
ex)
with on_interrupt(handler):
critical_work_to_prevent()
from logger import logg
on_interrupt.signal = None
:param function handler:
:param bool reraise:
:return: context
"""
def... | def on_interrupt(handler, reraise=False):
"""
context for handling keyboardinterrupt
ex)
with on_interrupt(handler):
critical_work_to_prevent()
from logger import logg
on_interrupt.signal = None
:param function handler:
:param bool reraise:
:return: context
"""
def... | [
"context",
"for",
"handling",
"keyboardinterrupt",
"ex",
")",
"with",
"on_interrupt",
"(",
"handler",
")",
":",
"critical_work_to_prevent",
"()"
] | dade-ai/snipy | python | https://github.com/dade-ai/snipy/blob/408520867179f99b3158b57520e2619f3fecd69b/snipy/basic.py#L255-L283 | [
"def",
"on_interrupt",
"(",
"handler",
",",
"reraise",
"=",
"False",
")",
":",
"def",
"_handler",
"(",
"sig",
",",
"frame",
")",
":",
"handler",
".",
"signal",
"=",
"(",
"sig",
",",
"frame",
")",
"handler",
".",
"_reraise",
"=",
"handler",
"(",
")",
... | 408520867179f99b3158b57520e2619f3fecd69b |
valid | interrupt_guard | context for guard keyboardinterrupt
ex)
with interrupt_guard('need long time'):
critical_work_to_prevent()
:param str msg: message to print when interrupted
:param reraise: re-raise or not when exit
:return: context | snipy/basic.py | def interrupt_guard(msg='', reraise=True):
"""
context for guard keyboardinterrupt
ex)
with interrupt_guard('need long time'):
critical_work_to_prevent()
:param str msg: message to print when interrupted
:param reraise: re-raise or not when exit
:return: context
"""
def echo... | def interrupt_guard(msg='', reraise=True):
"""
context for guard keyboardinterrupt
ex)
with interrupt_guard('need long time'):
critical_work_to_prevent()
:param str msg: message to print when interrupted
:param reraise: re-raise or not when exit
:return: context
"""
def echo... | [
"context",
"for",
"guard",
"keyboardinterrupt",
"ex",
")",
"with",
"interrupt_guard",
"(",
"need",
"long",
"time",
")",
":",
"critical_work_to_prevent",
"()"
] | dade-ai/snipy | python | https://github.com/dade-ai/snipy/blob/408520867179f99b3158b57520e2619f3fecd69b/snipy/basic.py#L286-L300 | [
"def",
"interrupt_guard",
"(",
"msg",
"=",
"''",
",",
"reraise",
"=",
"True",
")",
":",
"def",
"echo",
"(",
")",
":",
"print",
"(",
"msg",
")",
"return",
"on_interrupt",
"(",
"echo",
",",
"reraise",
"=",
"reraise",
")"
] | 408520867179f99b3158b57520e2619f3fecd69b |
valid | is_main_alive | is ๋ฉ์ธ ์ฐ๋ ๋ alive?
:rtype: bool | snipy/queues.py | def is_main_alive():
"""
is ๋ฉ์ธ ์ฐ๋ ๋ alive?
:rtype: bool
"""
for t in threading.enumerate():
if t.name == 'MainThread':
return t.is_alive()
print('MainThread not found')
return False | def is_main_alive():
"""
is ๋ฉ์ธ ์ฐ๋ ๋ alive?
:rtype: bool
"""
for t in threading.enumerate():
if t.name == 'MainThread':
return t.is_alive()
print('MainThread not found')
return False | [
"is",
"๋ฉ์ธ",
"์ฐ๋ ๋",
"alive?",
":",
"rtype",
":",
"bool"
] | dade-ai/snipy | python | https://github.com/dade-ai/snipy/blob/408520867179f99b3158b57520e2619f3fecd69b/snipy/queues.py#L84-L94 | [
"def",
"is_main_alive",
"(",
")",
":",
"for",
"t",
"in",
"threading",
".",
"enumerate",
"(",
")",
":",
"if",
"t",
".",
"name",
"==",
"'MainThread'",
":",
"return",
"t",
".",
"is_alive",
"(",
")",
"print",
"(",
"'MainThread not found'",
")",
"return",
"... | 408520867179f99b3158b57520e2619f3fecd69b |
valid | retrieve_document | This function takes a file path beginning with edgar and stores the form in a directory.
The default directory is sec_filings but can be changed through a keyword argument. | edgerdb/helper_functions.py | def retrieve_document(file_path, directory='sec_filings'):
'''
This function takes a file path beginning with edgar and stores the form in a directory.
The default directory is sec_filings but can be changed through a keyword argument.
'''
ftp = FTP('ftp.sec.gov', timeout=None)
ftp.login... | def retrieve_document(file_path, directory='sec_filings'):
'''
This function takes a file path beginning with edgar and stores the form in a directory.
The default directory is sec_filings but can be changed through a keyword argument.
'''
ftp = FTP('ftp.sec.gov', timeout=None)
ftp.login... | [
"This",
"function",
"takes",
"a",
"file",
"path",
"beginning",
"with",
"edgar",
"and",
"stores",
"the",
"form",
"in",
"a",
"directory",
".",
"The",
"default",
"directory",
"is",
"sec_filings",
"but",
"can",
"be",
"changed",
"through",
"a",
"keyword",
"argume... | lancekrogers/edgerdb | python | https://github.com/lancekrogers/edgerdb/blob/ed6f37af40f95588db94ba27a5a27d73da59e485/edgerdb/helper_functions.py#L165-L183 | [
"def",
"retrieve_document",
"(",
"file_path",
",",
"directory",
"=",
"'sec_filings'",
")",
":",
"ftp",
"=",
"FTP",
"(",
"'ftp.sec.gov'",
",",
"timeout",
"=",
"None",
")",
"ftp",
".",
"login",
"(",
")",
"name",
"=",
"file_path",
".",
"replace",
"(",
"'/'"... | ed6f37af40f95588db94ba27a5a27d73da59e485 |
valid | ActiveQ.action | for overriding
:param item:
:return: | snipy/activeq.py | def action(self, item):
"""
for overriding
:param item:
:return:
"""
fun, args, kwargs = item
return fun(*args, **kwargs) | def action(self, item):
"""
for overriding
:param item:
:return:
"""
fun, args, kwargs = item
return fun(*args, **kwargs) | [
"for",
"overriding",
":",
"param",
"item",
":",
":",
"return",
":"
] | dade-ai/snipy | python | https://github.com/dade-ai/snipy/blob/408520867179f99b3158b57520e2619f3fecd69b/snipy/activeq.py#L54-L61 | [
"def",
"action",
"(",
"self",
",",
"item",
")",
":",
"fun",
",",
"args",
",",
"kwargs",
"=",
"item",
"return",
"fun",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")"
] | 408520867179f99b3158b57520e2619f3fecd69b |
valid | ActiveQ.push_job | put job if possible, non-blocking
:param fun:
:param args:
:param kwargs:
:return: | snipy/activeq.py | def push_job(self, fun, *args, **kwargs):
"""
put job if possible, non-blocking
:param fun:
:param args:
:param kwargs:
:return:
"""
assert callable(fun)
return self.put((fun, args, kwargs), block=True) | def push_job(self, fun, *args, **kwargs):
"""
put job if possible, non-blocking
:param fun:
:param args:
:param kwargs:
:return:
"""
assert callable(fun)
return self.put((fun, args, kwargs), block=True) | [
"put",
"job",
"if",
"possible",
"non",
"-",
"blocking",
":",
"param",
"fun",
":",
":",
"param",
"args",
":",
":",
"param",
"kwargs",
":",
":",
"return",
":"
] | dade-ai/snipy | python | https://github.com/dade-ai/snipy/blob/408520867179f99b3158b57520e2619f3fecd69b/snipy/activeq.py#L63-L72 | [
"def",
"push_job",
"(",
"self",
",",
"fun",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"assert",
"callable",
"(",
"fun",
")",
"return",
"self",
".",
"put",
"(",
"(",
"fun",
",",
"args",
",",
"kwargs",
")",
",",
"block",
"=",
"True",
"... | 408520867179f99b3158b57520e2619f3fecd69b |
valid | ActiveQ.put_job | put job if possible, non-blocking
:param fun:
:param args:
:param kwargs:
:return: | snipy/activeq.py | def put_job(self, fun, *args, **kwargs):
"""
put job if possible, non-blocking
:param fun:
:param args:
:param kwargs:
:return:
"""
if not args and not kwargs and isinstance(fun, (tuple, list)):
# ex) q.put_job([fun, args, kwargs])
... | def put_job(self, fun, *args, **kwargs):
"""
put job if possible, non-blocking
:param fun:
:param args:
:param kwargs:
:return:
"""
if not args and not kwargs and isinstance(fun, (tuple, list)):
# ex) q.put_job([fun, args, kwargs])
... | [
"put",
"job",
"if",
"possible",
"non",
"-",
"blocking",
":",
"param",
"fun",
":",
":",
"param",
"args",
":",
":",
"param",
"kwargs",
":",
":",
"return",
":"
] | dade-ai/snipy | python | https://github.com/dade-ai/snipy/blob/408520867179f99b3158b57520e2619f3fecd69b/snipy/activeq.py#L74-L87 | [
"def",
"put_job",
"(",
"self",
",",
"fun",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"args",
"and",
"not",
"kwargs",
"and",
"isinstance",
"(",
"fun",
",",
"(",
"tuple",
",",
"list",
")",
")",
":",
"# ex) q.put_job([fun, args, ... | 408520867179f99b3158b57520e2619f3fecd69b |
valid | add_flag | define a single flag.
add_flag(flagname, default_value, help='', **kwargs)
add_flag([(flagname, default_value, help), ...])
or
define flags without help message
add_flag(flagname, default_value, help='', **kwargs)
add_flag('gpu', 1, help='CUDA_VISIBLE_DEVICES')
:param args:
:param kwarg... | snipy/flags.py | def add_flag(*args, **kwargs):
"""
define a single flag.
add_flag(flagname, default_value, help='', **kwargs)
add_flag([(flagname, default_value, help), ...])
or
define flags without help message
add_flag(flagname, default_value, help='', **kwargs)
add_flag('gpu', 1, help='CUDA_VISIBLE_... | def add_flag(*args, **kwargs):
"""
define a single flag.
add_flag(flagname, default_value, help='', **kwargs)
add_flag([(flagname, default_value, help), ...])
or
define flags without help message
add_flag(flagname, default_value, help='', **kwargs)
add_flag('gpu', 1, help='CUDA_VISIBLE_... | [
"define",
"a",
"single",
"flag",
".",
"add_flag",
"(",
"flagname",
"default_value",
"help",
"=",
"**",
"kwargs",
")",
"add_flag",
"(",
"[",
"(",
"flagname",
"default_value",
"help",
")",
"...",
"]",
")",
"or",
"define",
"flags",
"without",
"help",
"message... | dade-ai/snipy | python | https://github.com/dade-ai/snipy/blob/408520867179f99b3158b57520e2619f3fecd69b/snipy/flags.py#L151-L172 | [
"def",
"add_flag",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"len",
"(",
"args",
")",
"==",
"1",
"and",
"isinstance",
"(",
"args",
"[",
"0",
"]",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"for",
"a",
"in",
"args",
"[",
... | 408520867179f99b3158b57520e2619f3fecd69b |
valid | run | :param main: main or sys.modules['__main__'].main
:param argv: argument list used in argument parse
:param flags: flags to define with defaults
:return: | snipy/flags.py | def run(main=None, argv=None, **flags):
"""
:param main: main or sys.modules['__main__'].main
:param argv: argument list used in argument parse
:param flags: flags to define with defaults
:return:
"""
"""Runs the program with an optional 'main' function and 'argv' list."""
import sys as ... | def run(main=None, argv=None, **flags):
"""
:param main: main or sys.modules['__main__'].main
:param argv: argument list used in argument parse
:param flags: flags to define with defaults
:return:
"""
"""Runs the program with an optional 'main' function and 'argv' list."""
import sys as ... | [
":",
"param",
"main",
":",
"main",
"or",
"sys",
".",
"modules",
"[",
"__main__",
"]",
".",
"main",
":",
"param",
"argv",
":",
"argument",
"list",
"used",
"in",
"argument",
"parse",
":",
"param",
"flags",
":",
"flags",
"to",
"define",
"with",
"defaults"... | dade-ai/snipy | python | https://github.com/dade-ai/snipy/blob/408520867179f99b3158b57520e2619f3fecd69b/snipy/flags.py#L182-L236 | [
"def",
"run",
"(",
"main",
"=",
"None",
",",
"argv",
"=",
"None",
",",
"*",
"*",
"flags",
")",
":",
"\"\"\"Runs the program with an optional 'main' function and 'argv' list.\"\"\"",
"import",
"sys",
"as",
"_sys",
"import",
"inspect",
"main",
"=",
"main",
"or",
"... | 408520867179f99b3158b57520e2619f3fecd69b |
valid | mkdir_if_not | path ๋ถ๋ถ์ด ์์ผ๋ฉด mkdir ์ ํ๋ค.
:param filepath: ํ์ผ ํจ์ฐ
:return: filpath ๊ทธ๋๋ก ๋ฆฌํด | snipy/io/fileutil.py | def mkdir_if_not(filepath, ispath=False):
"""
path ๋ถ๋ถ์ด ์์ผ๋ฉด mkdir ์ ํ๋ค.
:param filepath: ํ์ผ ํจ์ฐ
:return: filpath ๊ทธ๋๋ก ๋ฆฌํด
"""
if not ispath:
p, _ = os.path.split(filepath)
else:
p = filepath
if not p:
return filepath
if not os.path.exists(p):
# M.info('%s... | def mkdir_if_not(filepath, ispath=False):
"""
path ๋ถ๋ถ์ด ์์ผ๋ฉด mkdir ์ ํ๋ค.
:param filepath: ํ์ผ ํจ์ฐ
:return: filpath ๊ทธ๋๋ก ๋ฆฌํด
"""
if not ispath:
p, _ = os.path.split(filepath)
else:
p = filepath
if not p:
return filepath
if not os.path.exists(p):
# M.info('%s... | [
"path",
"๋ถ๋ถ์ด",
"์์ผ๋ฉด",
"mkdir",
"์",
"ํ๋ค",
".",
":",
"param",
"filepath",
":",
"ํ์ผ",
"ํจ์ฐ",
":",
"return",
":",
"filpath",
"๊ทธ๋๋ก",
"๋ฆฌํด"
] | dade-ai/snipy | python | https://github.com/dade-ai/snipy/blob/408520867179f99b3158b57520e2619f3fecd69b/snipy/io/fileutil.py#L9-L29 | [
"def",
"mkdir_if_not",
"(",
"filepath",
",",
"ispath",
"=",
"False",
")",
":",
"if",
"not",
"ispath",
":",
"p",
",",
"_",
"=",
"os",
".",
"path",
".",
"split",
"(",
"filepath",
")",
"else",
":",
"p",
"=",
"filepath",
"if",
"not",
"p",
":",
"retur... | 408520867179f99b3158b57520e2619f3fecd69b |
valid | readlines | read lines from a textfile
:param filepath:
:return: list[line] | snipy/io/fileutil.py | def readlines(filepath):
"""
read lines from a textfile
:param filepath:
:return: list[line]
"""
with open(filepath, 'rt') as f:
lines = f.readlines()
lines = map(str.strip, lines)
lines = [l for l in lines if l]
return lines | def readlines(filepath):
"""
read lines from a textfile
:param filepath:
:return: list[line]
"""
with open(filepath, 'rt') as f:
lines = f.readlines()
lines = map(str.strip, lines)
lines = [l for l in lines if l]
return lines | [
"read",
"lines",
"from",
"a",
"textfile",
":",
"param",
"filepath",
":",
":",
"return",
":",
"list",
"[",
"line",
"]"
] | dade-ai/snipy | python | https://github.com/dade-ai/snipy/blob/408520867179f99b3158b57520e2619f3fecd69b/snipy/io/fileutil.py#L32-L42 | [
"def",
"readlines",
"(",
"filepath",
")",
":",
"with",
"open",
"(",
"filepath",
",",
"'rt'",
")",
"as",
"f",
":",
"lines",
"=",
"f",
".",
"readlines",
"(",
")",
"lines",
"=",
"map",
"(",
"str",
".",
"strip",
",",
"lines",
")",
"lines",
"=",
"[",
... | 408520867179f99b3158b57520e2619f3fecd69b |
valid | readtxt | read file as is | snipy/io/fileutil.py | def readtxt(filepath):
""" read file as is"""
with open(filepath, 'rt') as f:
lines = f.readlines()
return ''.join(lines) | def readtxt(filepath):
""" read file as is"""
with open(filepath, 'rt') as f:
lines = f.readlines()
return ''.join(lines) | [
"read",
"file",
"as",
"is"
] | dade-ai/snipy | python | https://github.com/dade-ai/snipy/blob/408520867179f99b3158b57520e2619f3fecd69b/snipy/io/fileutil.py#L52-L56 | [
"def",
"readtxt",
"(",
"filepath",
")",
":",
"with",
"open",
"(",
"filepath",
",",
"'rt'",
")",
"as",
"f",
":",
"lines",
"=",
"f",
".",
"readlines",
"(",
")",
"return",
"''",
".",
"join",
"(",
"lines",
")"
] | 408520867179f99b3158b57520e2619f3fecd69b |
valid | savefile | ํ์ผ ์์ผ๋ฉด ๋ฎ์ด์
:param obj:
:param str filepath:
:param compress:
:return: | snipy/io/fileutil.py | def savefile(obj, filepath, compress=True):
"""
ํ์ผ ์์ผ๋ฉด ๋ฎ์ด์
:param obj:
:param str filepath:
:param compress:
:return:
"""
try:
import cPickle as pickle
except Exception:
import pickle
import joblib
# ์ผ๋จ ์์ ํ์ผ์ ์ ์ฅ.
tmpfile = filepath + '.tmp'
mkdir_if_... | def savefile(obj, filepath, compress=True):
"""
ํ์ผ ์์ผ๋ฉด ๋ฎ์ด์
:param obj:
:param str filepath:
:param compress:
:return:
"""
try:
import cPickle as pickle
except Exception:
import pickle
import joblib
# ์ผ๋จ ์์ ํ์ผ์ ์ ์ฅ.
tmpfile = filepath + '.tmp'
mkdir_if_... | [
"ํ์ผ",
"์์ผ๋ฉด",
"๋ฎ์ด์",
":",
"param",
"obj",
":",
":",
"param",
"str",
"filepath",
":",
":",
"param",
"compress",
":",
":",
"return",
":"
] | dade-ai/snipy | python | https://github.com/dade-ai/snipy/blob/408520867179f99b3158b57520e2619f3fecd69b/snipy/io/fileutil.py#L65-L89 | [
"def",
"savefile",
"(",
"obj",
",",
"filepath",
",",
"compress",
"=",
"True",
")",
":",
"try",
":",
"import",
"cPickle",
"as",
"pickle",
"except",
"Exception",
":",
"import",
"pickle",
"import",
"joblib",
"# ์ผ๋จ ์์ ํ์ผ์ ์ ์ฅ.",
"tmpfile",
"=",
"filepath",
"+",
... | 408520867179f99b3158b57520e2619f3fecd69b |
valid | loadfile | :param filepath:
:param mmap_mode: {None, โr+โ, โrโ, โw+โ, โcโ} see. joblib.load
:return: | snipy/io/fileutil.py | def loadfile(filepath, mmap_mode=None):
"""
:param filepath:
:param mmap_mode: {None, โr+โ, โrโ, โw+โ, โcโ} see. joblib.load
:return:
"""
import joblib
try:
return joblib.load(filepath, mmap_mode=mmap_mode)
except IOError:
return None | def loadfile(filepath, mmap_mode=None):
"""
:param filepath:
:param mmap_mode: {None, โr+โ, โrโ, โw+โ, โcโ} see. joblib.load
:return:
"""
import joblib
try:
return joblib.load(filepath, mmap_mode=mmap_mode)
except IOError:
return None | [
":",
"param",
"filepath",
":",
":",
"param",
"mmap_mode",
":",
"{",
"None",
"โr",
"+",
"โ",
"โrโ",
"โw",
"+",
"โ",
"โcโ",
"}",
"see",
".",
"joblib",
".",
"load",
":",
"return",
":"
] | dade-ai/snipy | python | https://github.com/dade-ai/snipy/blob/408520867179f99b3158b57520e2619f3fecd69b/snipy/io/fileutil.py#L92-L103 | [
"def",
"loadfile",
"(",
"filepath",
",",
"mmap_mode",
"=",
"None",
")",
":",
"import",
"joblib",
"try",
":",
"return",
"joblib",
".",
"load",
"(",
"filepath",
",",
"mmap_mode",
"=",
"mmap_mode",
")",
"except",
"IOError",
":",
"return",
"None"
] | 408520867179f99b3158b57520e2619f3fecd69b |
valid | load_or_run | ๊ณ์ฐ๋ ๊ฒฐ๊ณผ ํ์ผ์ด ์์ผ๋ฉด ๋ก๋ฉํ๊ณ , ์์ผ๋ฉด ๊ณ์ฐํ ์ ์ฅ
ex)
res = load_or_run('file_loadorsave', funlongtime, ...., force=False)
:param filepath:
:param fun:
:param force:
:return: | snipy/io/fileutil.py | def load_or_run(filepath, fun, *args, **kwargs):
"""
๊ณ์ฐ๋ ๊ฒฐ๊ณผ ํ์ผ์ด ์์ผ๋ฉด ๋ก๋ฉํ๊ณ , ์์ผ๋ฉด ๊ณ์ฐํ ์ ์ฅ
ex)
res = load_or_run('file_loadorsave', funlongtime, ...., force=False)
:param filepath:
:param fun:
:param force:
:return:
"""
force = kwargs.pop('force', False)
compress = kwargs.pop('comp... | def load_or_run(filepath, fun, *args, **kwargs):
"""
๊ณ์ฐ๋ ๊ฒฐ๊ณผ ํ์ผ์ด ์์ผ๋ฉด ๋ก๋ฉํ๊ณ , ์์ผ๋ฉด ๊ณ์ฐํ ์ ์ฅ
ex)
res = load_or_run('file_loadorsave', funlongtime, ...., force=False)
:param filepath:
:param fun:
:param force:
:return:
"""
force = kwargs.pop('force', False)
compress = kwargs.pop('comp... | [
"๊ณ์ฐ๋",
"๊ฒฐ๊ณผ",
"ํ์ผ์ด",
"์์ผ๋ฉด",
"๋ก๋ฉํ๊ณ ",
"์์ผ๋ฉด",
"๊ณ์ฐํ",
"์ ์ฅ",
"ex",
")",
"res",
"=",
"load_or_run",
"(",
"file_loadorsave",
"funlongtime",
"....",
"force",
"=",
"False",
")",
":",
"param",
"filepath",
":",
":",
"param",
"fun",
":",
":",
"param",
"force",
":",... | dade-ai/snipy | python | https://github.com/dade-ai/snipy/blob/408520867179f99b3158b57520e2619f3fecd69b/snipy/io/fileutil.py#L136-L160 | [
"def",
"load_or_run",
"(",
"filepath",
",",
"fun",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"force",
"=",
"kwargs",
".",
"pop",
"(",
"'force'",
",",
"False",
")",
"compress",
"=",
"kwargs",
".",
"pop",
"(",
"'compress'",
",",
"True",
")... | 408520867179f99b3158b57520e2619f3fecd69b |
valid | fnmatches | matches?
:param fname: file name
:type fname: str
:param patterns: list of filename pattern. see fnmatch.fnamtch
:type patterns: [str]
:rtype: generator of bool | snipy/io/fileutil.py | def fnmatches(fname, patterns, matchfun):
""""
matches?
:param fname: file name
:type fname: str
:param patterns: list of filename pattern. see fnmatch.fnamtch
:type patterns: [str]
:rtype: generator of bool
"""
import fnmatch
matchfun = matchfun or fnmatch.fnmatch
for p in p... | def fnmatches(fname, patterns, matchfun):
""""
matches?
:param fname: file name
:type fname: str
:param patterns: list of filename pattern. see fnmatch.fnamtch
:type patterns: [str]
:rtype: generator of bool
"""
import fnmatch
matchfun = matchfun or fnmatch.fnmatch
for p in p... | [
"matches?",
":",
"param",
"fname",
":",
"file",
"name",
":",
"type",
"fname",
":",
"str",
":",
"param",
"patterns",
":",
"list",
"of",
"filename",
"pattern",
".",
"see",
"fnmatch",
".",
"fnamtch",
":",
"type",
"patterns",
":",
"[",
"str",
"]",
":",
"... | dade-ai/snipy | python | https://github.com/dade-ai/snipy/blob/408520867179f99b3158b57520e2619f3fecd69b/snipy/io/fileutil.py#L192-L204 | [
"def",
"fnmatches",
"(",
"fname",
",",
"patterns",
",",
"matchfun",
")",
":",
"import",
"fnmatch",
"matchfun",
"=",
"matchfun",
"or",
"fnmatch",
".",
"fnmatch",
"for",
"p",
"in",
"patterns",
":",
"yield",
"matchfun",
"(",
"fname",
",",
"p",
")"
] | 408520867179f99b3158b57520e2619f3fecd69b |
valid | listdir | list file(or folder) for this path (NOT recursive)
:param p:
:param match:
:param exclude:
:param listtype: ('file' | 'filepath' |'dir' | 'all')
:param matchfun: match fun (default fnmatch.fnmatch) True/False = matchfun(name, pattern)
:rtype: | snipy/io/fileutil.py | def listdir(p, match='*', exclude='', listtype='file', matchfun=None):
"""
list file(or folder) for this path (NOT recursive)
:param p:
:param match:
:param exclude:
:param listtype: ('file' | 'filepath' |'dir' | 'all')
:param matchfun: match fun (default fnmatch.fnmatch) True/False = matchf... | def listdir(p, match='*', exclude='', listtype='file', matchfun=None):
"""
list file(or folder) for this path (NOT recursive)
:param p:
:param match:
:param exclude:
:param listtype: ('file' | 'filepath' |'dir' | 'all')
:param matchfun: match fun (default fnmatch.fnmatch) True/False = matchf... | [
"list",
"file",
"(",
"or",
"folder",
")",
"for",
"this",
"path",
"(",
"NOT",
"recursive",
")",
":",
"param",
"p",
":",
":",
"param",
"match",
":",
":",
"param",
"exclude",
":",
":",
"param",
"listtype",
":",
"(",
"file",
"|",
"filepath",
"|",
"dir"... | dade-ai/snipy | python | https://github.com/dade-ai/snipy/blob/408520867179f99b3158b57520e2619f3fecd69b/snipy/io/fileutil.py#L207-L228 | [
"def",
"listdir",
"(",
"p",
",",
"match",
"=",
"'*'",
",",
"exclude",
"=",
"''",
",",
"listtype",
"=",
"'file'",
",",
"matchfun",
"=",
"None",
")",
":",
"if",
"listtype",
"==",
"'file'",
":",
"gen",
"=",
"listfile",
"(",
"p",
")",
"elif",
"listtype... | 408520867179f99b3158b57520e2619f3fecd69b |
valid | listfile | generator of list files in the path.
filenames only | snipy/io/fileutil.py | def listfile(p):
"""
generator of list files in the path.
filenames only
"""
try:
for entry in scandir.scandir(p):
if entry.is_file():
yield entry.name
except OSError:
return | def listfile(p):
"""
generator of list files in the path.
filenames only
"""
try:
for entry in scandir.scandir(p):
if entry.is_file():
yield entry.name
except OSError:
return | [
"generator",
"of",
"list",
"files",
"in",
"the",
"path",
".",
"filenames",
"only"
] | dade-ai/snipy | python | https://github.com/dade-ai/snipy/blob/408520867179f99b3158b57520e2619f3fecd69b/snipy/io/fileutil.py#L238-L248 | [
"def",
"listfile",
"(",
"p",
")",
":",
"try",
":",
"for",
"entry",
"in",
"scandir",
".",
"scandir",
"(",
"p",
")",
":",
"if",
"entry",
".",
"is_file",
"(",
")",
":",
"yield",
"entry",
".",
"name",
"except",
"OSError",
":",
"return"
] | 408520867179f99b3158b57520e2619f3fecd69b |
valid | listfilepath | generator of list files in the path.
filenames only | snipy/io/fileutil.py | def listfilepath(p):
"""
generator of list files in the path.
filenames only
"""
for entry in scandir.scandir(p):
if entry.is_file():
yield entry.path | def listfilepath(p):
"""
generator of list files in the path.
filenames only
"""
for entry in scandir.scandir(p):
if entry.is_file():
yield entry.path | [
"generator",
"of",
"list",
"files",
"in",
"the",
"path",
".",
"filenames",
"only"
] | dade-ai/snipy | python | https://github.com/dade-ai/snipy/blob/408520867179f99b3158b57520e2619f3fecd69b/snipy/io/fileutil.py#L251-L258 | [
"def",
"listfilepath",
"(",
"p",
")",
":",
"for",
"entry",
"in",
"scandir",
".",
"scandir",
"(",
"p",
")",
":",
"if",
"entry",
".",
"is_file",
"(",
")",
":",
"yield",
"entry",
".",
"path"
] | 408520867179f99b3158b57520e2619f3fecd69b |
valid | listfolder | generator of list folder in the path.
folders only | snipy/io/fileutil.py | def listfolder(p):
"""
generator of list folder in the path.
folders only
"""
for entry in scandir.scandir(p):
if entry.is_dir():
yield entry.name | def listfolder(p):
"""
generator of list folder in the path.
folders only
"""
for entry in scandir.scandir(p):
if entry.is_dir():
yield entry.name | [
"generator",
"of",
"list",
"folder",
"in",
"the",
"path",
".",
"folders",
"only"
] | dade-ai/snipy | python | https://github.com/dade-ai/snipy/blob/408520867179f99b3158b57520e2619f3fecd69b/snipy/io/fileutil.py#L261-L268 | [
"def",
"listfolder",
"(",
"p",
")",
":",
"for",
"entry",
"in",
"scandir",
".",
"scandir",
"(",
"p",
")",
":",
"if",
"entry",
".",
"is_dir",
"(",
")",
":",
"yield",
"entry",
".",
"name"
] | 408520867179f99b3158b57520e2619f3fecd69b |
valid | listfolderpath | generator of list folder in the path.
folders only | snipy/io/fileutil.py | def listfolderpath(p):
"""
generator of list folder in the path.
folders only
"""
for entry in scandir.scandir(p):
if entry.is_dir():
yield entry.path | def listfolderpath(p):
"""
generator of list folder in the path.
folders only
"""
for entry in scandir.scandir(p):
if entry.is_dir():
yield entry.path | [
"generator",
"of",
"list",
"folder",
"in",
"the",
"path",
".",
"folders",
"only"
] | dade-ai/snipy | python | https://github.com/dade-ai/snipy/blob/408520867179f99b3158b57520e2619f3fecd69b/snipy/io/fileutil.py#L271-L278 | [
"def",
"listfolderpath",
"(",
"p",
")",
":",
"for",
"entry",
"in",
"scandir",
".",
"scandir",
"(",
"p",
")",
":",
"if",
"entry",
".",
"is_dir",
"(",
")",
":",
"yield",
"entry",
".",
"path"
] | 408520867179f99b3158b57520e2619f3fecd69b |
valid | _pred_pattern | internal use | snipy/io/fileutil.py | def _pred_pattern(match='*', exclude='', patterntype='fnmatch'):
""" internal use """
m, x = match, exclude
if m == '*':
if not x:
pred = lambda n: True
else:
x = [x] if _is_str(x) else x
matcher = get_match_fun(x, patterntype)
pred = lambda n... | def _pred_pattern(match='*', exclude='', patterntype='fnmatch'):
""" internal use """
m, x = match, exclude
if m == '*':
if not x:
pred = lambda n: True
else:
x = [x] if _is_str(x) else x
matcher = get_match_fun(x, patterntype)
pred = lambda n... | [
"internal",
"use"
] | dade-ai/snipy | python | https://github.com/dade-ai/snipy/blob/408520867179f99b3158b57520e2619f3fecd69b/snipy/io/fileutil.py#L309-L331 | [
"def",
"_pred_pattern",
"(",
"match",
"=",
"'*'",
",",
"exclude",
"=",
"''",
",",
"patterntype",
"=",
"'fnmatch'",
")",
":",
"m",
",",
"x",
"=",
"match",
",",
"exclude",
"if",
"m",
"==",
"'*'",
":",
"if",
"not",
"x",
":",
"pred",
"=",
"lambda",
"... | 408520867179f99b3158b57520e2619f3fecd69b |
valid | findfolder | recursively find folder path from toppath.
patterns to decide to walk folder path or not
:type toppath: str
:type match: str or list(str)
:type exclude: str or list(str)
:rtype: generator for path str | snipy/io/fileutil.py | def findfolder(toppath, match='*', exclude=''):
"""
recursively find folder path from toppath.
patterns to decide to walk folder path or not
:type toppath: str
:type match: str or list(str)
:type exclude: str or list(str)
:rtype: generator for path str
"""
pred = _pred_pattern(match,... | def findfolder(toppath, match='*', exclude=''):
"""
recursively find folder path from toppath.
patterns to decide to walk folder path or not
:type toppath: str
:type match: str or list(str)
:type exclude: str or list(str)
:rtype: generator for path str
"""
pred = _pred_pattern(match,... | [
"recursively",
"find",
"folder",
"path",
"from",
"toppath",
".",
"patterns",
"to",
"decide",
"to",
"walk",
"folder",
"path",
"or",
"not",
":",
"type",
"toppath",
":",
"str",
":",
"type",
"match",
":",
"str",
"or",
"list",
"(",
"str",
")",
":",
"type",
... | dade-ai/snipy | python | https://github.com/dade-ai/snipy/blob/408520867179f99b3158b57520e2619f3fecd69b/snipy/io/fileutil.py#L334-L345 | [
"def",
"findfolder",
"(",
"toppath",
",",
"match",
"=",
"'*'",
",",
"exclude",
"=",
"''",
")",
":",
"pred",
"=",
"_pred_pattern",
"(",
"match",
",",
"exclude",
")",
"return",
"(",
"p",
"for",
"p",
"in",
"walkfolder",
"(",
"toppath",
",",
"pred",
")",... | 408520867179f99b3158b57520e2619f3fecd69b |
valid | walkfolder | walk folder if pred(foldername) is True
:type toppath: str
:type pred: function(str) => bool | snipy/io/fileutil.py | def walkfolder(toppath, pred):
"""
walk folder if pred(foldername) is True
:type toppath: str
:type pred: function(str) => bool
"""
for entry in scandir.scandir(toppath):
if not entry.is_dir() or not pred(entry.name):
continue
yield entry.path
for p in walkfol... | def walkfolder(toppath, pred):
"""
walk folder if pred(foldername) is True
:type toppath: str
:type pred: function(str) => bool
"""
for entry in scandir.scandir(toppath):
if not entry.is_dir() or not pred(entry.name):
continue
yield entry.path
for p in walkfol... | [
"walk",
"folder",
"if",
"pred",
"(",
"foldername",
")",
"is",
"True",
":",
"type",
"toppath",
":",
"str",
":",
"type",
"pred",
":",
"function",
"(",
"str",
")",
"=",
">",
"bool"
] | dade-ai/snipy | python | https://github.com/dade-ai/snipy/blob/408520867179f99b3158b57520e2619f3fecd69b/snipy/io/fileutil.py#L348-L359 | [
"def",
"walkfolder",
"(",
"toppath",
",",
"pred",
")",
":",
"for",
"entry",
"in",
"scandir",
".",
"scandir",
"(",
"toppath",
")",
":",
"if",
"not",
"entry",
".",
"is_dir",
"(",
")",
"or",
"not",
"pred",
"(",
"entry",
".",
"name",
")",
":",
"continu... | 408520867179f99b3158b57520e2619f3fecd69b |
valid | tempfolder | ์์ ํด๋๋ฅผ ๋ง๋ค์ด์ ๋ฆฌํด | snipy/io/fileutil.py | def tempfolder(prefix=''):
"""์์ ํด๋๋ฅผ ๋ง๋ค์ด์ ๋ฆฌํด"""
import uuid
p = prefix + str(uuid.uuid4())
d = tempdir()
tmpd = os.path.join(d, p)
return mkdir_if_not(tmpd, ispath=True) | def tempfolder(prefix=''):
"""์์ ํด๋๋ฅผ ๋ง๋ค์ด์ ๋ฆฌํด"""
import uuid
p = prefix + str(uuid.uuid4())
d = tempdir()
tmpd = os.path.join(d, p)
return mkdir_if_not(tmpd, ispath=True) | [
"์์",
"ํด๋๋ฅผ",
"๋ง๋ค์ด์",
"๋ฆฌํด"
] | dade-ai/snipy | python | https://github.com/dade-ai/snipy/blob/408520867179f99b3158b57520e2619f3fecd69b/snipy/io/fileutil.py#L371-L378 | [
"def",
"tempfolder",
"(",
"prefix",
"=",
"''",
")",
":",
"import",
"uuid",
"p",
"=",
"prefix",
"+",
"str",
"(",
"uuid",
".",
"uuid4",
"(",
")",
")",
"d",
"=",
"tempdir",
"(",
")",
"tmpd",
"=",
"os",
".",
"path",
".",
"join",
"(",
"d",
",",
"p... | 408520867179f99b3158b57520e2619f3fecd69b |
valid | imsize | return image size (height, width)
:param fname:
:return: | snipy/io/fileutil.py | def imsize(fname):
"""
return image size (height, width)
:param fname:
:return:
"""
from PIL import Image
im = Image.open(fname)
return im.size[1], im.size[0] | def imsize(fname):
"""
return image size (height, width)
:param fname:
:return:
"""
from PIL import Image
im = Image.open(fname)
return im.size[1], im.size[0] | [
"return",
"image",
"size",
"(",
"height",
"width",
")",
":",
"param",
"fname",
":",
":",
"return",
":"
] | dade-ai/snipy | python | https://github.com/dade-ai/snipy/blob/408520867179f99b3158b57520e2619f3fecd69b/snipy/io/fileutil.py#L424-L432 | [
"def",
"imsize",
"(",
"fname",
")",
":",
"from",
"PIL",
"import",
"Image",
"im",
"=",
"Image",
".",
"open",
"(",
"fname",
")",
"return",
"im",
".",
"size",
"[",
"1",
"]",
",",
"im",
".",
"size",
"[",
"0",
"]"
] | 408520867179f99b3158b57520e2619f3fecd69b |
valid | DictObj.intersect | self์ other ํค๊ฐ ๋์ผํ ์์ดํ
์ dictobj
:type other: dict
:rtype: dictobj: | snipy/dictobj.py | def intersect(self, other):
"""
self์ other ํค๊ฐ ๋์ผํ ์์ดํ
์ dictobj
:type other: dict
:rtype: dictobj:
"""
return DictObj({k: self[k] for k in self if k in other}) | def intersect(self, other):
"""
self์ other ํค๊ฐ ๋์ผํ ์์ดํ
์ dictobj
:type other: dict
:rtype: dictobj:
"""
return DictObj({k: self[k] for k in self if k in other}) | [
"self์",
"other",
"ํค๊ฐ",
"๋์ผํ",
"์์ดํ
์",
"dictobj",
":",
"type",
"other",
":",
"dict",
":",
"rtype",
":",
"dictobj",
":"
] | dade-ai/snipy | python | https://github.com/dade-ai/snipy/blob/408520867179f99b3158b57520e2619f3fecd69b/snipy/dictobj.py#L51-L57 | [
"def",
"intersect",
"(",
"self",
",",
"other",
")",
":",
"return",
"DictObj",
"(",
"{",
"k",
":",
"self",
"[",
"k",
"]",
"for",
"k",
"in",
"self",
"if",
"k",
"in",
"other",
"}",
")"
] | 408520867179f99b3158b57520e2619f3fecd69b |
valid | DictObj.from_dict | recursive dict to dictobj ์ปจ๋ฒํธ
:param dic:
:return: | snipy/dictobj.py | def from_dict(dic):
"""
recursive dict to dictobj ์ปจ๋ฒํธ
:param dic:
:return:
"""
return DictObj({k: DictObj.convert_ifdic(v) for k, v in dic.items()}) | def from_dict(dic):
"""
recursive dict to dictobj ์ปจ๋ฒํธ
:param dic:
:return:
"""
return DictObj({k: DictObj.convert_ifdic(v) for k, v in dic.items()}) | [
"recursive",
"dict",
"to",
"dictobj",
"์ปจ๋ฒํธ",
":",
"param",
"dic",
":",
":",
"return",
":"
] | dade-ai/snipy | python | https://github.com/dade-ai/snipy/blob/408520867179f99b3158b57520e2619f3fecd69b/snipy/dictobj.py#L67-L73 | [
"def",
"from_dict",
"(",
"dic",
")",
":",
"return",
"DictObj",
"(",
"{",
"k",
":",
"DictObj",
".",
"convert_ifdic",
"(",
"v",
")",
"for",
"k",
",",
"v",
"in",
"dic",
".",
"items",
"(",
")",
"}",
")"
] | 408520867179f99b3158b57520e2619f3fecd69b |
valid | _clean_up | Clean up after ourselves, removing created files.
@param {[String]} A list of file paths specifying the files we've created
during run. Will all be deleted.
@return {None} | snipy/imageme.py | def _clean_up(paths):
"""
Clean up after ourselves, removing created files.
@param {[String]} A list of file paths specifying the files we've created
during run. Will all be deleted.
@return {None}
"""
print('Cleaning up')
# Iterate over the given paths, unlinking them
for path i... | def _clean_up(paths):
"""
Clean up after ourselves, removing created files.
@param {[String]} A list of file paths specifying the files we've created
during run. Will all be deleted.
@return {None}
"""
print('Cleaning up')
# Iterate over the given paths, unlinking them
for path i... | [
"Clean",
"up",
"after",
"ourselves",
"removing",
"created",
"files",
"."
] | dade-ai/snipy | python | https://github.com/dade-ai/snipy/blob/408520867179f99b3158b57520e2619f3fecd69b/snipy/imageme.py#L60-L71 | [
"def",
"_clean_up",
"(",
"paths",
")",
":",
"print",
"(",
"'Cleaning up'",
")",
"# Iterate over the given paths, unlinking them",
"for",
"path",
"in",
"paths",
":",
"print",
"(",
"'Removing %s'",
"%",
"path",
")",
"os",
".",
"unlink",
"(",
"path",
")"
] | 408520867179f99b3158b57520e2619f3fecd69b |
valid | _create_index_file | Create an index file in the given location, supplying known lists of
present image files and subdirectories.
@param {String} root_dir - The root directory of the entire crawl. Used to
ascertain whether the given location is the top level.
@param {String} location - The current directory of the crawl... | snipy/imageme.py | def _create_index_file(
root_dir, location, image_files, dirs, force_no_processing=False):
"""
Create an index file in the given location, supplying known lists of
present image files and subdirectories.
@param {String} root_dir - The root directory of the entire crawl. Used to
ascertain... | def _create_index_file(
root_dir, location, image_files, dirs, force_no_processing=False):
"""
Create an index file in the given location, supplying known lists of
present image files and subdirectories.
@param {String} root_dir - The root directory of the entire crawl. Used to
ascertain... | [
"Create",
"an",
"index",
"file",
"in",
"the",
"given",
"location",
"supplying",
"known",
"lists",
"of",
"present",
"image",
"files",
"and",
"subdirectories",
"."
] | dade-ai/snipy | python | https://github.com/dade-ai/snipy/blob/408520867179f99b3158b57520e2619f3fecd69b/snipy/imageme.py#L74-L172 | [
"def",
"_create_index_file",
"(",
"root_dir",
",",
"location",
",",
"image_files",
",",
"dirs",
",",
"force_no_processing",
"=",
"False",
")",
":",
"# Put together HTML as a list of the lines we'll want to include",
"# Issue #2 exists to do this better than HTML in-code",
"header... | 408520867179f99b3158b57520e2619f3fecd69b |
valid | _create_index_files | Crawl the root directory downwards, generating an index HTML file in each
directory on the way down.
@param {String} root_dir - The top level directory to crawl down from. In
normal usage, this will be '.'.
@param {Boolean=False} force_no_processing - If True, do not attempt to
actually proc... | snipy/imageme.py | def _create_index_files(root_dir, force_no_processing=False):
"""
Crawl the root directory downwards, generating an index HTML file in each
directory on the way down.
@param {String} root_dir - The top level directory to crawl down from. In
normal usage, this will be '.'.
@param {Boolean=Fal... | def _create_index_files(root_dir, force_no_processing=False):
"""
Crawl the root directory downwards, generating an index HTML file in each
directory on the way down.
@param {String} root_dir - The top level directory to crawl down from. In
normal usage, this will be '.'.
@param {Boolean=Fal... | [
"Crawl",
"the",
"root",
"directory",
"downwards",
"generating",
"an",
"index",
"HTML",
"file",
"in",
"each",
"directory",
"on",
"the",
"way",
"down",
"."
] | dade-ai/snipy | python | https://github.com/dade-ai/snipy/blob/408520867179f99b3158b57520e2619f3fecd69b/snipy/imageme.py#L175-L205 | [
"def",
"_create_index_files",
"(",
"root_dir",
",",
"force_no_processing",
"=",
"False",
")",
":",
"# Initialise list of created file paths to build up as we make them",
"created_files",
"=",
"[",
"]",
"# Walk the root dir downwards, creating index files as we go",
"for",
"here",
... | 408520867179f99b3158b57520e2619f3fecd69b |
valid | _get_image_from_file | Get an instance of PIL.Image from the given file.
@param {String} dir_path - The directory containing the image file
@param {String} image_file - The filename of the image file within dir_path
@return {PIL.Image} An instance of the image file as a PIL Image, or None
if the functionality is not avail... | snipy/imageme.py | def _get_image_from_file(dir_path, image_file):
"""
Get an instance of PIL.Image from the given file.
@param {String} dir_path - The directory containing the image file
@param {String} image_file - The filename of the image file within dir_path
@return {PIL.Image} An instance of the image file as a ... | def _get_image_from_file(dir_path, image_file):
"""
Get an instance of PIL.Image from the given file.
@param {String} dir_path - The directory containing the image file
@param {String} image_file - The filename of the image file within dir_path
@return {PIL.Image} An instance of the image file as a ... | [
"Get",
"an",
"instance",
"of",
"PIL",
".",
"Image",
"from",
"the",
"given",
"file",
"."
] | dade-ai/snipy | python | https://github.com/dade-ai/snipy/blob/408520867179f99b3158b57520e2619f3fecd69b/snipy/imageme.py#L208-L229 | [
"def",
"_get_image_from_file",
"(",
"dir_path",
",",
"image_file",
")",
":",
"# Save ourselves the effort if PIL is not present, and return None now",
"if",
"not",
"PIL_ENABLED",
":",
"return",
"None",
"# Put together full path",
"path",
"=",
"os",
".",
"path",
".",
"join... | 408520867179f99b3158b57520e2619f3fecd69b |
valid | _get_image_link_target_from_file | Get the value to be used as the href for links from thumbnail images. For
most image formats this will simply be the image file name itself. However,
some image formats (tif) are not natively displayable by many browsers and
therefore we must link to image data in another format.
@param {String} dir_pat... | snipy/imageme.py | def _get_image_link_target_from_file(dir_path, image_file, force_no_processing=False):
"""
Get the value to be used as the href for links from thumbnail images. For
most image formats this will simply be the image file name itself. However,
some image formats (tif) are not natively displayable by many b... | def _get_image_link_target_from_file(dir_path, image_file, force_no_processing=False):
"""
Get the value to be used as the href for links from thumbnail images. For
most image formats this will simply be the image file name itself. However,
some image formats (tif) are not natively displayable by many b... | [
"Get",
"the",
"value",
"to",
"be",
"used",
"as",
"the",
"href",
"for",
"links",
"from",
"thumbnail",
"images",
".",
"For",
"most",
"image",
"formats",
"this",
"will",
"simply",
"be",
"the",
"image",
"file",
"name",
"itself",
".",
"However",
"some",
"imag... | dade-ai/snipy | python | https://github.com/dade-ai/snipy/blob/408520867179f99b3158b57520e2619f3fecd69b/snipy/imageme.py#L232-L256 | [
"def",
"_get_image_link_target_from_file",
"(",
"dir_path",
",",
"image_file",
",",
"force_no_processing",
"=",
"False",
")",
":",
"# If we've specified to force no processing, just return the image filename",
"if",
"force_no_processing",
":",
"return",
"image_file",
"# First try... | 408520867179f99b3158b57520e2619f3fecd69b |
valid | _get_image_src_from_file | Get base-64 encoded data as a string for the given image file's full image,
for use directly in HTML <img> tags, or a path to the original if image
scaling is not supported.
This is a full-sized version of _get_thumbnail_src_from_file, for use in
image formats which cannot be displayed directly in-brows... | snipy/imageme.py | def _get_image_src_from_file(dir_path, image_file, force_no_processing=False):
"""
Get base-64 encoded data as a string for the given image file's full image,
for use directly in HTML <img> tags, or a path to the original if image
scaling is not supported.
This is a full-sized version of _get_thumbn... | def _get_image_src_from_file(dir_path, image_file, force_no_processing=False):
"""
Get base-64 encoded data as a string for the given image file's full image,
for use directly in HTML <img> tags, or a path to the original if image
scaling is not supported.
This is a full-sized version of _get_thumbn... | [
"Get",
"base",
"-",
"64",
"encoded",
"data",
"as",
"a",
"string",
"for",
"the",
"given",
"image",
"file",
"s",
"full",
"image",
"for",
"use",
"directly",
"in",
"HTML",
"<img",
">",
"tags",
"or",
"a",
"path",
"to",
"the",
"original",
"if",
"image",
"s... | dade-ai/snipy | python | https://github.com/dade-ai/snipy/blob/408520867179f99b3158b57520e2619f3fecd69b/snipy/imageme.py#L259-L282 | [
"def",
"_get_image_src_from_file",
"(",
"dir_path",
",",
"image_file",
",",
"force_no_processing",
"=",
"False",
")",
":",
"# If we've specified to force no processing, just return the image filename",
"if",
"force_no_processing",
":",
"if",
"image_file",
".",
"endswith",
"("... | 408520867179f99b3158b57520e2619f3fecd69b |
valid | _get_src_from_image | Get base-64 encoded data as a string for the given image. Fallback to return
fallback_image_file if cannot get the image data or img is None.
@param {Image} img - The PIL Image to get src data for
@param {String} fallback_image_file - The filename of the image file,
to be used when image data captur... | snipy/imageme.py | def _get_src_from_image(img, fallback_image_file):
"""
Get base-64 encoded data as a string for the given image. Fallback to return
fallback_image_file if cannot get the image data or img is None.
@param {Image} img - The PIL Image to get src data for
@param {String} fallback_image_file - The filena... | def _get_src_from_image(img, fallback_image_file):
"""
Get base-64 encoded data as a string for the given image. Fallback to return
fallback_image_file if cannot get the image data or img is None.
@param {Image} img - The PIL Image to get src data for
@param {String} fallback_image_file - The filena... | [
"Get",
"base",
"-",
"64",
"encoded",
"data",
"as",
"a",
"string",
"for",
"the",
"given",
"image",
".",
"Fallback",
"to",
"return",
"fallback_image_file",
"if",
"cannot",
"get",
"the",
"image",
"data",
"or",
"img",
"is",
"None",
"."
] | dade-ai/snipy | python | https://github.com/dade-ai/snipy/blob/408520867179f99b3158b57520e2619f3fecd69b/snipy/imageme.py#L306-L335 | [
"def",
"_get_src_from_image",
"(",
"img",
",",
"fallback_image_file",
")",
":",
"# If the image is None, then we can't process, so we should return the",
"# path to the file itself",
"if",
"img",
"is",
"None",
":",
"return",
"fallback_image_file",
"# Target format should be the sam... | 408520867179f99b3158b57520e2619f3fecd69b |
valid | _get_thumbnail_image_from_file | Get a PIL.Image from the given image file which has been scaled down to
THUMBNAIL_WIDTH wide.
@param {String} dir_path - The directory containing the image file
@param {String} image_file - The filename of the image file within dir_path
@return {PIL.Image} An instance of the thumbnail as a PIL Image, or... | snipy/imageme.py | def _get_thumbnail_image_from_file(dir_path, image_file):
"""
Get a PIL.Image from the given image file which has been scaled down to
THUMBNAIL_WIDTH wide.
@param {String} dir_path - The directory containing the image file
@param {String} image_file - The filename of the image file within dir_path
... | def _get_thumbnail_image_from_file(dir_path, image_file):
"""
Get a PIL.Image from the given image file which has been scaled down to
THUMBNAIL_WIDTH wide.
@param {String} dir_path - The directory containing the image file
@param {String} image_file - The filename of the image file within dir_path
... | [
"Get",
"a",
"PIL",
".",
"Image",
"from",
"the",
"given",
"image",
"file",
"which",
"has",
"been",
"scaled",
"down",
"to",
"THUMBNAIL_WIDTH",
"wide",
"."
] | dade-ai/snipy | python | https://github.com/dade-ai/snipy/blob/408520867179f99b3158b57520e2619f3fecd69b/snipy/imageme.py#L338-L371 | [
"def",
"_get_thumbnail_image_from_file",
"(",
"dir_path",
",",
"image_file",
")",
":",
"# Get image",
"img",
"=",
"_get_image_from_file",
"(",
"dir_path",
",",
"image_file",
")",
"# If it's not supported, exit now",
"if",
"img",
"is",
"None",
":",
"return",
"None",
... | 408520867179f99b3158b57520e2619f3fecd69b |
valid | _get_thumbnail_src_from_file | Get base-64 encoded data as a string for the given image file's thumbnail,
for use directly in HTML <img> tags, or a path to the original if image
scaling is not supported.
@param {String} dir_path - The directory containing the image file
@param {String} image_file - The filename of the image file with... | snipy/imageme.py | def _get_thumbnail_src_from_file(dir_path, image_file, force_no_processing=False):
"""
Get base-64 encoded data as a string for the given image file's thumbnail,
for use directly in HTML <img> tags, or a path to the original if image
scaling is not supported.
@param {String} dir_path - The directory... | def _get_thumbnail_src_from_file(dir_path, image_file, force_no_processing=False):
"""
Get base-64 encoded data as a string for the given image file's thumbnail,
for use directly in HTML <img> tags, or a path to the original if image
scaling is not supported.
@param {String} dir_path - The directory... | [
"Get",
"base",
"-",
"64",
"encoded",
"data",
"as",
"a",
"string",
"for",
"the",
"given",
"image",
"file",
"s",
"thumbnail",
"for",
"use",
"directly",
"in",
"HTML",
"<img",
">",
"tags",
"or",
"a",
"path",
"to",
"the",
"original",
"if",
"image",
"scaling... | dade-ai/snipy | python | https://github.com/dade-ai/snipy/blob/408520867179f99b3158b57520e2619f3fecd69b/snipy/imageme.py#L374-L394 | [
"def",
"_get_thumbnail_src_from_file",
"(",
"dir_path",
",",
"image_file",
",",
"force_no_processing",
"=",
"False",
")",
":",
"# If we've specified to force no processing, just return the image filename",
"if",
"force_no_processing",
":",
"if",
"image_file",
".",
"endswith",
... | 408520867179f99b3158b57520e2619f3fecd69b |
valid | _run_server | Run the image server. This is blocking. Will handle user KeyboardInterrupt
and other exceptions appropriately and return control once the server is
stopped.
@return {None} | snipy/imageme.py | def _run_server():
"""
Run the image server. This is blocking. Will handle user KeyboardInterrupt
and other exceptions appropriately and return control once the server is
stopped.
@return {None}
"""
# Get the port to run on
port = _get_server_port()
# Configure allow_reuse_address to... | def _run_server():
"""
Run the image server. This is blocking. Will handle user KeyboardInterrupt
and other exceptions appropriately and return control once the server is
stopped.
@return {None}
"""
# Get the port to run on
port = _get_server_port()
# Configure allow_reuse_address to... | [
"Run",
"the",
"image",
"server",
".",
"This",
"is",
"blocking",
".",
"Will",
"handle",
"user",
"KeyboardInterrupt",
"and",
"other",
"exceptions",
"appropriately",
"and",
"return",
"control",
"once",
"the",
"server",
"is",
"stopped",
"."
] | dade-ai/snipy | python | https://github.com/dade-ai/snipy/blob/408520867179f99b3158b57520e2619f3fecd69b/snipy/imageme.py#L397-L433 | [
"def",
"_run_server",
"(",
")",
":",
"# Get the port to run on",
"port",
"=",
"_get_server_port",
"(",
")",
"# Configure allow_reuse_address to make re-runs of the script less painful -",
"# if this is not True then waiting for the address to be freed after the",
"# last run can block a su... | 408520867179f99b3158b57520e2619f3fecd69b |
valid | serve_dir | Generate indexes and run server from the given directory downwards.
@param {String} dir_path - The directory path (absolute, or relative to CWD)
@return {None} | snipy/imageme.py | def serve_dir(dir_path):
"""
Generate indexes and run server from the given directory downwards.
@param {String} dir_path - The directory path (absolute, or relative to CWD)
@return {None}
"""
# Create index files, and store the list of their paths for cleanup later
# This time, force no pro... | def serve_dir(dir_path):
"""
Generate indexes and run server from the given directory downwards.
@param {String} dir_path - The directory path (absolute, or relative to CWD)
@return {None}
"""
# Create index files, and store the list of their paths for cleanup later
# This time, force no pro... | [
"Generate",
"indexes",
"and",
"run",
"server",
"from",
"the",
"given",
"directory",
"downwards",
"."
] | dade-ai/snipy | python | https://github.com/dade-ai/snipy/blob/408520867179f99b3158b57520e2619f3fecd69b/snipy/imageme.py#L436-L459 | [
"def",
"serve_dir",
"(",
"dir_path",
")",
":",
"# Create index files, and store the list of their paths for cleanup later",
"# This time, force no processing - this gives us a fast first-pass in terms",
"# of page generation, but potentially slow serving for large image files",
"print",
"(",
"... | 408520867179f99b3158b57520e2619f3fecd69b |
valid | caller.modulename | get caller's __name__ | snipy/caller.py | def modulename(cls, depth=1):
"""
get caller's __name__
"""
depth += cls.extra_depth
frame = sys._getframe(depth)
return frame.f_globals['__name__'] | def modulename(cls, depth=1):
"""
get caller's __name__
"""
depth += cls.extra_depth
frame = sys._getframe(depth)
return frame.f_globals['__name__'] | [
"get",
"caller",
"s",
"__name__"
] | dade-ai/snipy | python | https://github.com/dade-ai/snipy/blob/408520867179f99b3158b57520e2619f3fecd69b/snipy/caller.py#L45-L51 | [
"def",
"modulename",
"(",
"cls",
",",
"depth",
"=",
"1",
")",
":",
"depth",
"+=",
"cls",
".",
"extra_depth",
"frame",
"=",
"sys",
".",
"_getframe",
"(",
"depth",
")",
"return",
"frame",
".",
"f_globals",
"[",
"'__name__'",
"]"
] | 408520867179f99b3158b57520e2619f3fecd69b |
valid | deco_optional | optional argument ๋ฅผ ํฌํจํ๋ decorator๋ฅผ ๋ง๋๋ decorator | snipy/decotool.py | def deco_optional(decorator):
"""
optional argument ๋ฅผ ํฌํจํ๋ decorator๋ฅผ ๋ง๋๋ decorator
"""
@functools.wraps(decorator)
def dispatcher(*args, **kwargs):
one_arg = len(args) == 1 and not kwargs
if one_arg and inspect.isfunction(args[0]):
decor_obj = decorator()
re... | def deco_optional(decorator):
"""
optional argument ๋ฅผ ํฌํจํ๋ decorator๋ฅผ ๋ง๋๋ decorator
"""
@functools.wraps(decorator)
def dispatcher(*args, **kwargs):
one_arg = len(args) == 1 and not kwargs
if one_arg and inspect.isfunction(args[0]):
decor_obj = decorator()
re... | [
"optional",
"argument",
"๋ฅผ",
"ํฌํจํ๋",
"decorator๋ฅผ",
"๋ง๋๋",
"decorator"
] | dade-ai/snipy | python | https://github.com/dade-ai/snipy/blob/408520867179f99b3158b57520e2619f3fecd69b/snipy/decotool.py#L6-L20 | [
"def",
"deco_optional",
"(",
"decorator",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"decorator",
")",
"def",
"dispatcher",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"one_arg",
"=",
"len",
"(",
"args",
")",
"==",
"1",
"and",
"not",
"... | 408520867179f99b3158b57520e2619f3fecd69b |
valid | optional | decorator option์ kwargs๋ง ํ์ฉ
:param deco:
:return: | snipy/decotool.py | def optional(deco):
"""
decorator option์ kwargs๋ง ํ์ฉ
:param deco:
:return:
"""
@functools.wraps(deco)
def dispatcher(*args, **kwargs):
decorator = deco(**kwargs)
if args:
assert len(args) == 1
return decorator(args[0])
else:
return ... | def optional(deco):
"""
decorator option์ kwargs๋ง ํ์ฉ
:param deco:
:return:
"""
@functools.wraps(deco)
def dispatcher(*args, **kwargs):
decorator = deco(**kwargs)
if args:
assert len(args) == 1
return decorator(args[0])
else:
return ... | [
"decorator",
"option์",
"kwargs๋ง",
"ํ์ฉ",
":",
"param",
"deco",
":",
":",
"return",
":"
] | dade-ai/snipy | python | https://github.com/dade-ai/snipy/blob/408520867179f99b3158b57520e2619f3fecd69b/snipy/decotool.py#L23-L37 | [
"def",
"optional",
"(",
"deco",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"deco",
")",
"def",
"dispatcher",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"decorator",
"=",
"deco",
"(",
"*",
"*",
"kwargs",
")",
"if",
"args",
":",
"asse... | 408520867179f99b3158b57520e2619f3fecd69b |
valid | bindargs | _ = bind.placeholder # unbound placeholder (arg)
f = bind(fun, _, _, arg3, kw=kw1, kw2=kw2), f(arg1, arg2)
:param fun:
:param argsbind:
:param kwbind:
:return: | snipy/decotool.py | def bindargs(fun, *argsbind, **kwbind):
"""
_ = bind.placeholder # unbound placeholder (arg)
f = bind(fun, _, _, arg3, kw=kw1, kw2=kw2), f(arg1, arg2)
:param fun:
:param argsbind:
:param kwbind:
:return:
"""
assert argsbind
argsb = list(argsbind)
iargs = [i for i in range(... | def bindargs(fun, *argsbind, **kwbind):
"""
_ = bind.placeholder # unbound placeholder (arg)
f = bind(fun, _, _, arg3, kw=kw1, kw2=kw2), f(arg1, arg2)
:param fun:
:param argsbind:
:param kwbind:
:return:
"""
assert argsbind
argsb = list(argsbind)
iargs = [i for i in range(... | [
"_",
"=",
"bind",
".",
"placeholder",
"#",
"unbound",
"placeholder",
"(",
"arg",
")",
"f",
"=",
"bind",
"(",
"fun",
"_",
"_",
"arg3",
"kw",
"=",
"kw1",
"kw2",
"=",
"kw2",
")",
"f",
"(",
"arg1",
"arg2",
")",
":",
"param",
"fun",
":",
":",
"param... | dade-ai/snipy | python | https://github.com/dade-ai/snipy/blob/408520867179f99b3158b57520e2619f3fecd69b/snipy/decotool.py#L85-L114 | [
"def",
"bindargs",
"(",
"fun",
",",
"*",
"argsbind",
",",
"*",
"*",
"kwbind",
")",
":",
"assert",
"argsbind",
"argsb",
"=",
"list",
"(",
"argsbind",
")",
"iargs",
"=",
"[",
"i",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"argsbind",
")",
")",
"i... | 408520867179f99b3158b57520e2619f3fecd69b |
valid | bindkw | kwarg ๋ฐ์ธ๋ฉ๋ ํจ์ return.
ex)
def fun(opt1, opt2):
print opt1, opt2
f = bind(fun, opt1=2, opt2=3)
f()
:param function fun:
:param kwbind:
:return: function | snipy/decotool.py | def bindkw(fun, **kwbind):
"""
kwarg ๋ฐ์ธ๋ฉ๋ ํจ์ return.
ex)
def fun(opt1, opt2):
print opt1, opt2
f = bind(fun, opt1=2, opt2=3)
f()
:param function fun:
:param kwbind:
:return: function
"""
@functools.wraps(fun)
def wrapped(*args, **kwargs):
kws = kwbind.co... | def bindkw(fun, **kwbind):
"""
kwarg ๋ฐ์ธ๋ฉ๋ ํจ์ return.
ex)
def fun(opt1, opt2):
print opt1, opt2
f = bind(fun, opt1=2, opt2=3)
f()
:param function fun:
:param kwbind:
:return: function
"""
@functools.wraps(fun)
def wrapped(*args, **kwargs):
kws = kwbind.co... | [
"kwarg",
"๋ฐ์ธ๋ฉ๋",
"ํจ์",
"return",
".",
"ex",
")",
"def",
"fun",
"(",
"opt1",
"opt2",
")",
":",
"print",
"opt1",
"opt2"
] | dade-ai/snipy | python | https://github.com/dade-ai/snipy/blob/408520867179f99b3158b57520e2619f3fecd69b/snipy/decotool.py#L117-L137 | [
"def",
"bindkw",
"(",
"fun",
",",
"*",
"*",
"kwbind",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"fun",
")",
"def",
"wrapped",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"kws",
"=",
"kwbind",
".",
"copy",
"(",
")",
"kws",
".",
"... | 408520867179f99b3158b57520e2619f3fecd69b |
valid | default | change default value for function
ex)
def sample(a, b=1, c=1):
print 'from sample:', a, b, c
return a, b, c
fun = default(sample, b=4,c=5)
print fun.default # get default value dictionary
fun(1) # print 1, 5, 5 and return
:param fun:
:param kwdefault:
:return: | snipy/decotool.py | def default(fun, **kwdefault):
"""
change default value for function
ex)
def sample(a, b=1, c=1):
print 'from sample:', a, b, c
return a, b, c
fun = default(sample, b=4,c=5)
print fun.default # get default value dictionary
fun(1) # print 1, 5, 5 and return
:param fun:
... | def default(fun, **kwdefault):
"""
change default value for function
ex)
def sample(a, b=1, c=1):
print 'from sample:', a, b, c
return a, b, c
fun = default(sample, b=4,c=5)
print fun.default # get default value dictionary
fun(1) # print 1, 5, 5 and return
:param fun:
... | [
"change",
"default",
"value",
"for",
"function",
"ex",
")",
"def",
"sample",
"(",
"a",
"b",
"=",
"1",
"c",
"=",
"1",
")",
":",
"print",
"from",
"sample",
":",
"a",
"b",
"c",
"return",
"a",
"b",
"c",
"fun",
"=",
"default",
"(",
"sample",
"b",
"=... | dade-ai/snipy | python | https://github.com/dade-ai/snipy/blob/408520867179f99b3158b57520e2619f3fecd69b/snipy/decotool.py#L171-L195 | [
"def",
"default",
"(",
"fun",
",",
"*",
"*",
"kwdefault",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"fun",
")",
"def",
"wrapped",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"merge",
"=",
"wrapped",
".",
"default",
".",
"copy",
"(",... | 408520867179f99b3158b57520e2619f3fecd69b |
valid | setup_once | call class instance method for initial setup ::
class B(object):
def init(self, a):
print 'init call:', a
@setup_once(init)
def mycall(self, a):
print 'real call:', a
b = B()
b.mycall(222)
b.mycall(333)
:param f... | snipy/decotool.py | def setup_once(initfn):
"""
call class instance method for initial setup ::
class B(object):
def init(self, a):
print 'init call:', a
@setup_once(init)
def mycall(self, a):
print 'real call:', a
b = B()
b.mycall(222)... | def setup_once(initfn):
"""
call class instance method for initial setup ::
class B(object):
def init(self, a):
print 'init call:', a
@setup_once(init)
def mycall(self, a):
print 'real call:', a
b = B()
b.mycall(222)... | [
"call",
"class",
"instance",
"method",
"for",
"initial",
"setup",
"::"
] | dade-ai/snipy | python | https://github.com/dade-ai/snipy/blob/408520867179f99b3158b57520e2619f3fecd69b/snipy/decotool.py#L198-L238 | [
"def",
"setup_once",
"(",
"initfn",
")",
":",
"def",
"wrap",
"(",
"method",
")",
":",
"finit",
"=",
"initfn",
".",
"__name__",
"fnname",
"=",
"method",
".",
"__name__",
"@",
"functools",
".",
"wraps",
"(",
"method",
")",
"def",
"wrapped",
"(",
"self",
... | 408520867179f99b3158b57520e2619f3fecd69b |
valid | static | USE carefully ^^ | snipy/decotool.py | def static(**kwargs):
""" USE carefully ^^ """
def wrap(fn):
fn.func_globals['static'] = fn
fn.__dict__.update(kwargs)
return fn
return wrap | def static(**kwargs):
""" USE carefully ^^ """
def wrap(fn):
fn.func_globals['static'] = fn
fn.__dict__.update(kwargs)
return fn
return wrap | [
"USE",
"carefully",
"^^"
] | dade-ai/snipy | python | https://github.com/dade-ai/snipy/blob/408520867179f99b3158b57520e2619f3fecd69b/snipy/decotool.py#L259-L265 | [
"def",
"static",
"(",
"*",
"*",
"kwargs",
")",
":",
"def",
"wrap",
"(",
"fn",
")",
":",
"fn",
".",
"func_globals",
"[",
"'static'",
"]",
"=",
"fn",
"fn",
".",
"__dict__",
".",
"update",
"(",
"kwargs",
")",
"return",
"fn",
"return",
"wrap"
] | 408520867179f99b3158b57520e2619f3fecd69b |
valid | rand_crop | random crop
# assume imagez has same size (H, W)
# assume sz is less or equal than size of image
:param sz: cropped image sz
:param imagez: imagez
:return: rand cropped image pairs or function bound to sz | snipy/img/imageutil.py | def rand_crop(sz, *imagez):
"""
random crop
# assume imagez has same size (H, W)
# assume sz is less or equal than size of image
:param sz: cropped image sz
:param imagez: imagez
:return: rand cropped image pairs or function bound to sz
"""
def _rand_crop(*imgz):
imsz = imgz... | def rand_crop(sz, *imagez):
"""
random crop
# assume imagez has same size (H, W)
# assume sz is less or equal than size of image
:param sz: cropped image sz
:param imagez: imagez
:return: rand cropped image pairs or function bound to sz
"""
def _rand_crop(*imgz):
imsz = imgz... | [
"random",
"crop",
"#",
"assume",
"imagez",
"has",
"same",
"size",
"(",
"H",
"W",
")",
"#",
"assume",
"sz",
"is",
"less",
"or",
"equal",
"than",
"size",
"of",
"image",
":",
"param",
"sz",
":",
"cropped",
"image",
"sz",
":",
"param",
"imagez",
":",
"... | dade-ai/snipy | python | https://github.com/dade-ai/snipy/blob/408520867179f99b3158b57520e2619f3fecd69b/snipy/img/imageutil.py#L68-L92 | [
"def",
"rand_crop",
"(",
"sz",
",",
"*",
"imagez",
")",
":",
"def",
"_rand_crop",
"(",
"*",
"imgz",
")",
":",
"imsz",
"=",
"imgz",
"[",
"0",
"]",
".",
"shape",
"[",
":",
"2",
"]",
"assert",
"imsz",
"[",
"0",
"]",
">=",
"sz",
"[",
"0",
"]",
... | 408520867179f99b3158b57520e2619f3fecd69b |
valid | rand_rotate | :param anglerange:
:param imagez:
:return: | snipy/img/imageutil.py | def rand_rotate(anglerange, *imagez):
"""
:param anglerange:
:param imagez:
:return:
"""
r = float(anglerange[1] - anglerange[0])
s = anglerange[0]
def _rand_rotate(*imgz):
angle = np.random.random(1)[0] * r + s
out = tuple(rotate(img, angle) for img in imgz)
ret... | def rand_rotate(anglerange, *imagez):
"""
:param anglerange:
:param imagez:
:return:
"""
r = float(anglerange[1] - anglerange[0])
s = anglerange[0]
def _rand_rotate(*imgz):
angle = np.random.random(1)[0] * r + s
out = tuple(rotate(img, angle) for img in imgz)
ret... | [
":",
"param",
"anglerange",
":",
":",
"param",
"imagez",
":",
":",
"return",
":"
] | dade-ai/snipy | python | https://github.com/dade-ai/snipy/blob/408520867179f99b3158b57520e2619f3fecd69b/snipy/img/imageutil.py#L99-L113 | [
"def",
"rand_rotate",
"(",
"anglerange",
",",
"*",
"imagez",
")",
":",
"r",
"=",
"float",
"(",
"anglerange",
"[",
"1",
"]",
"-",
"anglerange",
"[",
"0",
"]",
")",
"s",
"=",
"anglerange",
"[",
"0",
"]",
"def",
"_rand_rotate",
"(",
"*",
"imgz",
")",
... | 408520867179f99b3158b57520e2619f3fecd69b |
valid | blend_discrete | depthmask : shape of [batch, h, w] | snipy/img/imageutil.py | def blend_discrete(images, depthmask, depth=None):
"""
depthmask : shape of [batch, h, w]
"""
imshape = images.shape
depth = depth or images.shape[3]
blend = np.empty(shape=(imshape[0], imshape[1], imshape[2]))
for d in range(depth):
imask = (depthmask == d)
channel = images[... | def blend_discrete(images, depthmask, depth=None):
"""
depthmask : shape of [batch, h, w]
"""
imshape = images.shape
depth = depth or images.shape[3]
blend = np.empty(shape=(imshape[0], imshape[1], imshape[2]))
for d in range(depth):
imask = (depthmask == d)
channel = images[... | [
"depthmask",
":",
"shape",
"of",
"[",
"batch",
"h",
"w",
"]"
] | dade-ai/snipy | python | https://github.com/dade-ai/snipy/blob/408520867179f99b3158b57520e2619f3fecd69b/snipy/img/imageutil.py#L128-L139 | [
"def",
"blend_discrete",
"(",
"images",
",",
"depthmask",
",",
"depth",
"=",
"None",
")",
":",
"imshape",
"=",
"images",
".",
"shape",
"depth",
"=",
"depth",
"or",
"images",
".",
"shape",
"[",
"3",
"]",
"blend",
"=",
"np",
".",
"empty",
"(",
"shape",... | 408520867179f99b3158b57520e2619f3fecd69b |
valid | rand_blend_mask | random blending masks | snipy/img/imageutil.py | def rand_blend_mask(shape, rand=rand.uniform(-10, 10), **kwargs):
""" random blending masks """
# batch, channel = shape[0], shape[3]
z = rand(shape[0]) # seed
noise = snoise2dz((shape[1], shape[2]), z, **kwargs)
return noise | def rand_blend_mask(shape, rand=rand.uniform(-10, 10), **kwargs):
""" random blending masks """
# batch, channel = shape[0], shape[3]
z = rand(shape[0]) # seed
noise = snoise2dz((shape[1], shape[2]), z, **kwargs)
return noise | [
"random",
"blending",
"masks"
] | dade-ai/snipy | python | https://github.com/dade-ai/snipy/blob/408520867179f99b3158b57520e2619f3fecd69b/snipy/img/imageutil.py#L142-L148 | [
"def",
"rand_blend_mask",
"(",
"shape",
",",
"rand",
"=",
"rand",
".",
"uniform",
"(",
"-",
"10",
",",
"10",
")",
",",
"*",
"*",
"kwargs",
")",
":",
"# batch, channel = shape[0], shape[3]",
"z",
"=",
"rand",
"(",
"shape",
"[",
"0",
"]",
")",
"# seed",
... | 408520867179f99b3158b57520e2619f3fecd69b |
valid | snoise2dvec | vector parameters
:param size:
:param vz:
:param vscale:
:param voctave:
:param vpersistence:
:param vlacunarity:
:return: | snipy/img/imageutil.py | def snoise2dvec(size, *params, **kwargs): #, vlacunarity):
"""
vector parameters
:param size:
:param vz:
:param vscale:
:param voctave:
:param vpersistence:
:param vlacunarity:
:return:
"""
data = (snoise2d(size, *p, **kwargs) for p in zip(*params)) # , vlacunarity))
re... | def snoise2dvec(size, *params, **kwargs): #, vlacunarity):
"""
vector parameters
:param size:
:param vz:
:param vscale:
:param voctave:
:param vpersistence:
:param vlacunarity:
:return:
"""
data = (snoise2d(size, *p, **kwargs) for p in zip(*params)) # , vlacunarity))
re... | [
"vector",
"parameters",
":",
"param",
"size",
":",
":",
"param",
"vz",
":",
":",
"param",
"vscale",
":",
":",
"param",
"voctave",
":",
":",
"param",
"vpersistence",
":",
":",
"param",
"vlacunarity",
":",
":",
"return",
":"
] | dade-ai/snipy | python | https://github.com/dade-ai/snipy/blob/408520867179f99b3158b57520e2619f3fecd69b/snipy/img/imageutil.py#L151-L163 | [
"def",
"snoise2dvec",
"(",
"size",
",",
"*",
"params",
",",
"*",
"*",
"kwargs",
")",
":",
"#, vlacunarity):",
"data",
"=",
"(",
"snoise2d",
"(",
"size",
",",
"*",
"p",
",",
"*",
"*",
"kwargs",
")",
"for",
"p",
"in",
"zip",
"(",
"*",
"params",
")"... | 408520867179f99b3158b57520e2619f3fecd69b |
valid | snoise2d | z value as like a seed | snipy/img/imageutil.py | def snoise2d(size, z=0.0, scale=0.05, octaves=1, persistence=0.25, lacunarity=2.0):
"""
z value as like a seed
"""
import noise
data = np.empty(size, dtype='float32')
for y in range(size[0]):
for x in range(size[1]):
v = noise.snoise3(x * scale, y * scale, z,
... | def snoise2d(size, z=0.0, scale=0.05, octaves=1, persistence=0.25, lacunarity=2.0):
"""
z value as like a seed
"""
import noise
data = np.empty(size, dtype='float32')
for y in range(size[0]):
for x in range(size[1]):
v = noise.snoise3(x * scale, y * scale, z,
... | [
"z",
"value",
"as",
"like",
"a",
"seed"
] | dade-ai/snipy | python | https://github.com/dade-ai/snipy/blob/408520867179f99b3158b57520e2619f3fecd69b/snipy/img/imageutil.py#L166-L180 | [
"def",
"snoise2d",
"(",
"size",
",",
"z",
"=",
"0.0",
",",
"scale",
"=",
"0.05",
",",
"octaves",
"=",
"1",
",",
"persistence",
"=",
"0.25",
",",
"lacunarity",
"=",
"2.0",
")",
":",
"import",
"noise",
"data",
"=",
"np",
".",
"empty",
"(",
"size",
... | 408520867179f99b3158b57520e2619f3fecd69b |
valid | snoise2dz | z as seeds
scale์ด ์์ ์๋ก ํจํด์ด ์ปค์ง๋ ํจ๊ณผ | snipy/img/imageutil.py | def snoise2dz(size, z, scale=0.05, octaves=1, persistence=0.25, lacunarity=2.0):
"""
z as seeds
scale์ด ์์ ์๋ก ํจํด์ด ์ปค์ง๋ ํจ๊ณผ
"""
import noise
z_l = len(z)
data = np.empty((z_l, size[0], size[1]), dtype='float32')
for iz in range(z_l):
zvalue = z[iz]
for y in range(size[0]):
... | def snoise2dz(size, z, scale=0.05, octaves=1, persistence=0.25, lacunarity=2.0):
"""
z as seeds
scale์ด ์์ ์๋ก ํจํด์ด ์ปค์ง๋ ํจ๊ณผ
"""
import noise
z_l = len(z)
data = np.empty((z_l, size[0], size[1]), dtype='float32')
for iz in range(z_l):
zvalue = z[iz]
for y in range(size[0]):
... | [
"z",
"as",
"seeds",
"scale์ด",
"์์",
"์๋ก",
"ํจํด์ด",
"์ปค์ง๋",
"ํจ๊ณผ"
] | dade-ai/snipy | python | https://github.com/dade-ai/snipy/blob/408520867179f99b3158b57520e2619f3fecd69b/snipy/img/imageutil.py#L183-L202 | [
"def",
"snoise2dz",
"(",
"size",
",",
"z",
",",
"scale",
"=",
"0.05",
",",
"octaves",
"=",
"1",
",",
"persistence",
"=",
"0.25",
",",
"lacunarity",
"=",
"2.0",
")",
":",
"import",
"noise",
"z_l",
"=",
"len",
"(",
"z",
")",
"data",
"=",
"np",
".",... | 408520867179f99b3158b57520e2619f3fecd69b |
valid | rand_brightness | :param images:
:param scale: scale for random value
:param randfun: any randfun binding except shape
:param clamp: clamping range
:return: | snipy/img/imageutil.py | def rand_brightness(imagez, scale=1.0, randfun=rand.normal(0., .1), clamp=(0., 1.)):
"""
:param images:
:param scale: scale for random value
:param randfun: any randfun binding except shape
:param clamp: clamping range
:return:
"""
l, h = clamp
r = randfun((imagez[0].shape[0], 1, 1, ... | def rand_brightness(imagez, scale=1.0, randfun=rand.normal(0., .1), clamp=(0., 1.)):
"""
:param images:
:param scale: scale for random value
:param randfun: any randfun binding except shape
:param clamp: clamping range
:return:
"""
l, h = clamp
r = randfun((imagez[0].shape[0], 1, 1, ... | [
":",
"param",
"images",
":",
":",
"param",
"scale",
":",
"scale",
"for",
"random",
"value",
":",
"param",
"randfun",
":",
"any",
"randfun",
"binding",
"except",
"shape",
":",
"param",
"clamp",
":",
"clamping",
"range",
":",
"return",
":"
] | dade-ai/snipy | python | https://github.com/dade-ai/snipy/blob/408520867179f99b3158b57520e2619f3fecd69b/snipy/img/imageutil.py#L206-L223 | [
"def",
"rand_brightness",
"(",
"imagez",
",",
"scale",
"=",
"1.0",
",",
"randfun",
"=",
"rand",
".",
"normal",
"(",
"0.",
",",
".1",
")",
",",
"clamp",
"=",
"(",
"0.",
",",
"1.",
")",
")",
":",
"l",
",",
"h",
"=",
"clamp",
"r",
"=",
"randfun",
... | 408520867179f99b3158b57520e2619f3fecd69b |
valid | elastic_transform | Based on https://gist.github.com/erniejunior/601cdf56d2b424757de5
elastic deformation of images as described in [Simard2003] | snipy/img/imageutil.py | def elastic_transform(im, alpha=0.5, sigma=0.2, affine_sigma=1.):
"""
Based on https://gist.github.com/erniejunior/601cdf56d2b424757de5
elastic deformation of images as described in [Simard2003]
"""
# fixme : not implemented for multi channel !
import cv2
islist = isinstance(im, (tuple, lis... | def elastic_transform(im, alpha=0.5, sigma=0.2, affine_sigma=1.):
"""
Based on https://gist.github.com/erniejunior/601cdf56d2b424757de5
elastic deformation of images as described in [Simard2003]
"""
# fixme : not implemented for multi channel !
import cv2
islist = isinstance(im, (tuple, lis... | [
"Based",
"on",
"https",
":",
"//",
"gist",
".",
"github",
".",
"com",
"/",
"erniejunior",
"/",
"601cdf56d2b424757de5",
"elastic",
"deformation",
"of",
"images",
"as",
"described",
"in",
"[",
"Simard2003",
"]"
] | dade-ai/snipy | python | https://github.com/dade-ai/snipy/blob/408520867179f99b3158b57520e2619f3fecd69b/snipy/img/imageutil.py#L259-L310 | [
"def",
"elastic_transform",
"(",
"im",
",",
"alpha",
"=",
"0.5",
",",
"sigma",
"=",
"0.2",
",",
"affine_sigma",
"=",
"1.",
")",
":",
"# fixme : not implemented for multi channel !",
"import",
"cv2",
"islist",
"=",
"isinstance",
"(",
"im",
",",
"(",
"tuple",
... | 408520867179f99b3158b57520e2619f3fecd69b |
valid | rotate_crop | rotate and crop
if no img, then return crop function
:param centerij:
:param sz:
:param angle:
:param img: [h,w,d]
:param mode: padding option
:return: cropped image or function | snipy/img/imageutil.py | def rotate_crop(centerij, sz, angle, img=None, mode='constant', **kwargs):
"""
rotate and crop
if no img, then return crop function
:param centerij:
:param sz:
:param angle:
:param img: [h,w,d]
:param mode: padding option
:return: cropped image or function
"""
# crop enough s... | def rotate_crop(centerij, sz, angle, img=None, mode='constant', **kwargs):
"""
rotate and crop
if no img, then return crop function
:param centerij:
:param sz:
:param angle:
:param img: [h,w,d]
:param mode: padding option
:return: cropped image or function
"""
# crop enough s... | [
"rotate",
"and",
"crop",
"if",
"no",
"img",
"then",
"return",
"crop",
"function",
":",
"param",
"centerij",
":",
":",
"param",
"sz",
":",
":",
"param",
"angle",
":",
":",
"param",
"img",
":",
"[",
"h",
"w",
"d",
"]",
":",
"param",
"mode",
":",
"p... | dade-ai/snipy | python | https://github.com/dade-ai/snipy/blob/408520867179f99b3158b57520e2619f3fecd69b/snipy/img/imageutil.py#L315-L355 | [
"def",
"rotate_crop",
"(",
"centerij",
",",
"sz",
",",
"angle",
",",
"img",
"=",
"None",
",",
"mode",
"=",
"'constant'",
",",
"*",
"*",
"kwargs",
")",
":",
"# crop enough size ( 2 * sqrt(sum(sz^2) )",
"# rotate",
"from",
"skimage",
"import",
"transform",
"sz",... | 408520867179f99b3158b57520e2619f3fecd69b |
valid | crop | crop sz from ij as center
:param img:
:param center: ij
:param sz:
:param mode:
:return: | snipy/img/imageutil.py | def crop(img, center, sz, mode='constant'):
"""
crop sz from ij as center
:param img:
:param center: ij
:param sz:
:param mode:
:return:
"""
center = np.array(center)
sz = np.array(sz)
istart = (center - sz / 2.).astype('int32')
iend = istart + sz
imsz = img.shape[:2]... | def crop(img, center, sz, mode='constant'):
"""
crop sz from ij as center
:param img:
:param center: ij
:param sz:
:param mode:
:return:
"""
center = np.array(center)
sz = np.array(sz)
istart = (center - sz / 2.).astype('int32')
iend = istart + sz
imsz = img.shape[:2]... | [
"crop",
"sz",
"from",
"ij",
"as",
"center",
":",
"param",
"img",
":",
":",
"param",
"center",
":",
"ij",
":",
"param",
"sz",
":",
":",
"param",
"mode",
":",
":",
"return",
":"
] | dade-ai/snipy | python | https://github.com/dade-ai/snipy/blob/408520867179f99b3158b57520e2619f3fecd69b/snipy/img/imageutil.py#L363-L387 | [
"def",
"crop",
"(",
"img",
",",
"center",
",",
"sz",
",",
"mode",
"=",
"'constant'",
")",
":",
"center",
"=",
"np",
".",
"array",
"(",
"center",
")",
"sz",
"=",
"np",
".",
"array",
"(",
"sz",
")",
"istart",
"=",
"(",
"center",
"-",
"sz",
"/",
... | 408520867179f99b3158b57520e2619f3fecd69b |
valid | cropcenter | if no img, then return crop function
:param sz:
:param img:
:return: | snipy/img/imageutil.py | def cropcenter(sz, img=None):
"""
if no img, then return crop function
:param sz:
:param img:
:return:
"""
l = len(sz)
sz = np.array(sz)
def wrapped(im):
imsz = np.array(im.shape)
s = (imsz[:l] - sz) / 2 # start index
to = s + sz # end index
# img[... | def cropcenter(sz, img=None):
"""
if no img, then return crop function
:param sz:
:param img:
:return:
"""
l = len(sz)
sz = np.array(sz)
def wrapped(im):
imsz = np.array(im.shape)
s = (imsz[:l] - sz) / 2 # start index
to = s + sz # end index
# img[... | [
"if",
"no",
"img",
"then",
"return",
"crop",
"function",
":",
"param",
"sz",
":",
":",
"param",
"img",
":",
":",
"return",
":"
] | dade-ai/snipy | python | https://github.com/dade-ai/snipy/blob/408520867179f99b3158b57520e2619f3fecd69b/snipy/img/imageutil.py#L390-L413 | [
"def",
"cropcenter",
"(",
"sz",
",",
"img",
"=",
"None",
")",
":",
"l",
"=",
"len",
"(",
"sz",
")",
"sz",
"=",
"np",
".",
"array",
"(",
"sz",
")",
"def",
"wrapped",
"(",
"im",
")",
":",
"imsz",
"=",
"np",
".",
"array",
"(",
"im",
".",
"shap... | 408520867179f99b3158b57520e2619f3fecd69b |
valid | pad_if_need | pad img if need to guarantee minumum size
:param sz_atleast: [H,W] at least
:param img: image np.array [H,W, ...]
:param mode: str, padding mode
:return: padded image or asis if enought size | snipy/img/imageutil.py | def pad_if_need(sz_atleast, img, mode='constant'):
# fixme : function or ....
"""
pad img if need to guarantee minumum size
:param sz_atleast: [H,W] at least
:param img: image np.array [H,W, ...]
:param mode: str, padding mode
:return: padded image or asis if enought size
"""
# sz_at... | def pad_if_need(sz_atleast, img, mode='constant'):
# fixme : function or ....
"""
pad img if need to guarantee minumum size
:param sz_atleast: [H,W] at least
:param img: image np.array [H,W, ...]
:param mode: str, padding mode
:return: padded image or asis if enought size
"""
# sz_at... | [
"pad",
"img",
"if",
"need",
"to",
"guarantee",
"minumum",
"size",
":",
"param",
"sz_atleast",
":",
"[",
"H",
"W",
"]",
"at",
"least",
":",
"param",
"img",
":",
"image",
"np",
".",
"array",
"[",
"H",
"W",
"...",
"]",
":",
"param",
"mode",
":",
"st... | dade-ai/snipy | python | https://github.com/dade-ai/snipy/blob/408520867179f99b3158b57520e2619f3fecd69b/snipy/img/imageutil.py#L438-L458 | [
"def",
"pad_if_need",
"(",
"sz_atleast",
",",
"img",
",",
"mode",
"=",
"'constant'",
")",
":",
"# fixme : function or ....",
"# sz_atleast = np.asarray(sz_atleast)",
"imsz",
"=",
"img",
".",
"shape",
"[",
":",
"2",
"]",
"# assume img [H,W, ...]",
"padneed",
"=",
"... | 408520867179f99b3158b57520e2619f3fecd69b |
valid | canny | canny edge | snipy/img/imageutil.py | def canny(img, threshold1=255/3, threshold2=255, **kwargs):
""" canny edge """
import cv2
# edges=None, apertureSize=None, L2gradient=None
if img.ndim <= 3:
edge = cv2.Canny(img, threshold1, threshold2, **kwargs)
if edge.ndim == 2:
edge = np.expand_dims(edge, 2)
elif img.... | def canny(img, threshold1=255/3, threshold2=255, **kwargs):
""" canny edge """
import cv2
# edges=None, apertureSize=None, L2gradient=None
if img.ndim <= 3:
edge = cv2.Canny(img, threshold1, threshold2, **kwargs)
if edge.ndim == 2:
edge = np.expand_dims(edge, 2)
elif img.... | [
"canny",
"edge"
] | dade-ai/snipy | python | https://github.com/dade-ai/snipy/blob/408520867179f99b3158b57520e2619f3fecd69b/snipy/img/imageutil.py#L461-L476 | [
"def",
"canny",
"(",
"img",
",",
"threshold1",
"=",
"255",
"/",
"3",
",",
"threshold2",
"=",
"255",
",",
"*",
"*",
"kwargs",
")",
":",
"import",
"cv2",
"# edges=None, apertureSize=None, L2gradient=None",
"if",
"img",
".",
"ndim",
"<=",
"3",
":",
"edge",
... | 408520867179f99b3158b57520e2619f3fecd69b |
valid | guess_package_path | package path. return None if failed to guess | snipy/packageutil.py | def guess_package_path(searchfrom):
"""
package path. return None if failed to guess
"""
from snipy.io import fileutil
current = searchfrom + '/'
init_found = False
pack_found = False
while not init_found and current != '/':
current = os.path.dirname(current)
initfile = ... | def guess_package_path(searchfrom):
"""
package path. return None if failed to guess
"""
from snipy.io import fileutil
current = searchfrom + '/'
init_found = False
pack_found = False
while not init_found and current != '/':
current = os.path.dirname(current)
initfile = ... | [
"package",
"path",
".",
"return",
"None",
"if",
"failed",
"to",
"guess"
] | dade-ai/snipy | python | https://github.com/dade-ai/snipy/blob/408520867179f99b3158b57520e2619f3fecd69b/snipy/packageutil.py#L13-L44 | [
"def",
"guess_package_path",
"(",
"searchfrom",
")",
":",
"from",
"snipy",
".",
"io",
"import",
"fileutil",
"current",
"=",
"searchfrom",
"+",
"'/'",
"init_found",
"=",
"False",
"pack_found",
"=",
"False",
"while",
"not",
"init_found",
"and",
"current",
"!=",
... | 408520867179f99b3158b57520e2619f3fecd69b |
valid | find_package_path | package path. return None if failed to guess | snipy/packageutil.py | def find_package_path(searchfrom):
"""
package path. return None if failed to guess
"""
current = searchfrom + '/'
init_found = False
pack_found = False
while not init_found and current != '/':
current = os.path.dirname(current)
initfile = os.path.join(current, '__init__.py'... | def find_package_path(searchfrom):
"""
package path. return None if failed to guess
"""
current = searchfrom + '/'
init_found = False
pack_found = False
while not init_found and current != '/':
current = os.path.dirname(current)
initfile = os.path.join(current, '__init__.py'... | [
"package",
"path",
".",
"return",
"None",
"if",
"failed",
"to",
"guess"
] | dade-ai/snipy | python | https://github.com/dade-ai/snipy/blob/408520867179f99b3158b57520e2619f3fecd69b/snipy/packageutil.py#L47-L66 | [
"def",
"find_package_path",
"(",
"searchfrom",
")",
":",
"current",
"=",
"searchfrom",
"+",
"'/'",
"init_found",
"=",
"False",
"pack_found",
"=",
"False",
"while",
"not",
"init_found",
"and",
"current",
"!=",
"'/'",
":",
"current",
"=",
"os",
".",
"path",
... | 408520867179f99b3158b57520e2619f3fecd69b |
valid | append_this_package_path | this_package.py ์์ ์ฌ์ฉ
import snipy.this_package | snipy/packageutil.py | def append_this_package_path(depth=1):
"""
this_package.py ์์ ์ฌ์ฉ
import snipy.this_package
"""
from .caller import caller
logg.debug('caller module %s', caller.modulename(depth + 1))
c = caller.abspath(depth + 1)
logg.debug('caller path %s', c)
p = guess_package_path(dirname(c))
... | def append_this_package_path(depth=1):
"""
this_package.py ์์ ์ฌ์ฉ
import snipy.this_package
"""
from .caller import caller
logg.debug('caller module %s', caller.modulename(depth + 1))
c = caller.abspath(depth + 1)
logg.debug('caller path %s', c)
p = guess_package_path(dirname(c))
... | [
"this_package",
".",
"py",
"์์",
"์ฌ์ฉ",
"import",
"snipy",
".",
"this_package"
] | dade-ai/snipy | python | https://github.com/dade-ai/snipy/blob/408520867179f99b3158b57520e2619f3fecd69b/snipy/packageutil.py#L77-L94 | [
"def",
"append_this_package_path",
"(",
"depth",
"=",
"1",
")",
":",
"from",
".",
"caller",
"import",
"caller",
"logg",
".",
"debug",
"(",
"'caller module %s'",
",",
"caller",
".",
"modulename",
"(",
"depth",
"+",
"1",
")",
")",
"c",
"=",
"caller",
".",
... | 408520867179f99b3158b57520e2619f3fecd69b |
valid | flows | todo : add some example
:param args:
:return: | snipy/iterflow.py | def flows(args):
"""
todo : add some example
:param args:
:return:
"""
def flow_if_not(fun):
# t = type(fun)
if isinstance(fun, iterator):
return fun
elif isinstance(fun, type) and 'itertools' in str(fun.__class__):
return fun
else:
... | def flows(args):
"""
todo : add some example
:param args:
:return:
"""
def flow_if_not(fun):
# t = type(fun)
if isinstance(fun, iterator):
return fun
elif isinstance(fun, type) and 'itertools' in str(fun.__class__):
return fun
else:
... | [
"todo",
":",
"add",
"some",
"example",
":",
"param",
"args",
":",
":",
"return",
":"
] | dade-ai/snipy | python | https://github.com/dade-ai/snipy/blob/408520867179f99b3158b57520e2619f3fecd69b/snipy/iterflow.py#L164-L184 | [
"def",
"flows",
"(",
"args",
")",
":",
"def",
"flow_if_not",
"(",
"fun",
")",
":",
"# t = type(fun)",
"if",
"isinstance",
"(",
"fun",
",",
"iterator",
")",
":",
"return",
"fun",
"elif",
"isinstance",
"(",
"fun",
",",
"type",
")",
"and",
"'itertools'",
... | 408520867179f99b3158b57520e2619f3fecd69b |
valid | forever | forever
todo : add example | snipy/iterflow.py | def forever(it):
""" forever
todo : add example
"""
while True:
# generator ๋๋ฒ์จฐ iteration ๋ฌดํ ๋ฃจํ ๋ฐฉ์ง
i = iter(it)
try:
yield i.next()
except StopIteration:
raise StopIteration
while True:
try:
yield i.next()
... | def forever(it):
""" forever
todo : add example
"""
while True:
# generator ๋๋ฒ์จฐ iteration ๋ฌดํ ๋ฃจํ ๋ฐฉ์ง
i = iter(it)
try:
yield i.next()
except StopIteration:
raise StopIteration
while True:
try:
yield i.next()
... | [
"forever",
"todo",
":",
"add",
"example"
] | dade-ai/snipy | python | https://github.com/dade-ai/snipy/blob/408520867179f99b3158b57520e2619f3fecd69b/snipy/iterflow.py#L230-L245 | [
"def",
"forever",
"(",
"it",
")",
":",
"while",
"True",
":",
"# generator ๋๋ฒ์จฐ iteration ๋ฌดํ ๋ฃจํ ๋ฐฉ์ง",
"i",
"=",
"iter",
"(",
"it",
")",
"try",
":",
"yield",
"i",
".",
"next",
"(",
")",
"except",
"StopIteration",
":",
"raise",
"StopIteration",
"while",
"True",... | 408520867179f99b3158b57520e2619f3fecd69b |
valid | ibatch | add example
:param size:
:param iterable:
:param rest:
:return: | snipy/iterflow.py | def ibatch(size, iterable=None, rest=False):
"""
add example
:param size:
:param iterable:
:param rest:
:return:
"""
@iterflow
def exact_size(it):
it = iter(it)
while True:
yield [it.next() for _ in xrange(size)]
@iterflow
def at_most(it):
... | def ibatch(size, iterable=None, rest=False):
"""
add example
:param size:
:param iterable:
:param rest:
:return:
"""
@iterflow
def exact_size(it):
it = iter(it)
while True:
yield [it.next() for _ in xrange(size)]
@iterflow
def at_most(it):
... | [
"add",
"example",
":",
"param",
"size",
":",
":",
"param",
"iterable",
":",
":",
"param",
"rest",
":",
":",
"return",
":"
] | dade-ai/snipy | python | https://github.com/dade-ai/snipy/blob/408520867179f99b3158b57520e2619f3fecd69b/snipy/iterflow.py#L293-L324 | [
"def",
"ibatch",
"(",
"size",
",",
"iterable",
"=",
"None",
",",
"rest",
"=",
"False",
")",
":",
"@",
"iterflow",
"def",
"exact_size",
"(",
"it",
")",
":",
"it",
"=",
"iter",
"(",
"it",
")",
"while",
"True",
":",
"yield",
"[",
"it",
".",
"next",
... | 408520867179f99b3158b57520e2619f3fecd69b |
valid | batchzip | todo : add example
:param size:
:param iterable:
:param rest:
:return: | snipy/iterflow.py | def batchzip(size, iterable=None, rest=False):
"""
todo : add example
:param size:
:param iterable:
:param rest:
:return:
"""
fn = ibatch(size, rest=rest) >> zipflow
return fn if iterable is None else fn(iterable) | def batchzip(size, iterable=None, rest=False):
"""
todo : add example
:param size:
:param iterable:
:param rest:
:return:
"""
fn = ibatch(size, rest=rest) >> zipflow
return fn if iterable is None else fn(iterable) | [
"todo",
":",
"add",
"example",
":",
"param",
"size",
":",
":",
"param",
"iterable",
":",
":",
"param",
"rest",
":",
":",
"return",
":"
] | dade-ai/snipy | python | https://github.com/dade-ai/snipy/blob/408520867179f99b3158b57520e2619f3fecd69b/snipy/iterflow.py#L327-L337 | [
"def",
"batchzip",
"(",
"size",
",",
"iterable",
"=",
"None",
",",
"rest",
"=",
"False",
")",
":",
"fn",
"=",
"ibatch",
"(",
"size",
",",
"rest",
"=",
"rest",
")",
">>",
"zipflow",
"return",
"fn",
"if",
"iterable",
"is",
"None",
"else",
"fn",
"(",
... | 408520867179f99b3158b57520e2619f3fecd69b |
valid | batchstack | todo : add example
:param size:
:param iterable:
:param rest:
:return: | snipy/iterflow.py | def batchstack(size, iterable=None, rest=False):
"""
todo : add example
:param size:
:param iterable:
:param rest:
:return:
"""
def stack(data):
import numpy as np
return map(np.vstack, data)
fn = batchzip(size, rest=rest) >> flow(stack)
return fn if iterable i... | def batchstack(size, iterable=None, rest=False):
"""
todo : add example
:param size:
:param iterable:
:param rest:
:return:
"""
def stack(data):
import numpy as np
return map(np.vstack, data)
fn = batchzip(size, rest=rest) >> flow(stack)
return fn if iterable i... | [
"todo",
":",
"add",
"example",
":",
"param",
"size",
":",
":",
"param",
"iterable",
":",
":",
"param",
"rest",
":",
":",
"return",
":"
] | dade-ai/snipy | python | https://github.com/dade-ai/snipy/blob/408520867179f99b3158b57520e2619f3fecd69b/snipy/iterflow.py#L341-L356 | [
"def",
"batchstack",
"(",
"size",
",",
"iterable",
"=",
"None",
",",
"rest",
"=",
"False",
")",
":",
"def",
"stack",
"(",
"data",
")",
":",
"import",
"numpy",
"as",
"np",
"return",
"map",
"(",
"np",
".",
"vstack",
",",
"data",
")",
"fn",
"=",
"ba... | 408520867179f99b3158b57520e2619f3fecd69b |
valid | shuffle | add example
:param qsize:
:param iterable:
:return: | snipy/iterflow.py | def shuffle(qsize=1024, iterable=None):
"""
add example
:param qsize:
:param iterable:
:return:
"""
@iterflow
def shuffleit(it):
from random import randrange
q = []
for i, d in enumerate(it):
q.insert(randrange(0, len(q) + 1), d)
if i < q... | def shuffle(qsize=1024, iterable=None):
"""
add example
:param qsize:
:param iterable:
:return:
"""
@iterflow
def shuffleit(it):
from random import randrange
q = []
for i, d in enumerate(it):
q.insert(randrange(0, len(q) + 1), d)
if i < q... | [
"add",
"example",
":",
"param",
"qsize",
":",
":",
"param",
"iterable",
":",
":",
"return",
":"
] | dade-ai/snipy | python | https://github.com/dade-ai/snipy/blob/408520867179f99b3158b57520e2619f3fecd69b/snipy/iterflow.py#L359-L381 | [
"def",
"shuffle",
"(",
"qsize",
"=",
"1024",
",",
"iterable",
"=",
"None",
")",
":",
"@",
"iterflow",
"def",
"shuffleit",
"(",
"it",
")",
":",
"from",
"random",
"import",
"randrange",
"q",
"=",
"[",
"]",
"for",
"i",
",",
"d",
"in",
"enumerate",
"("... | 408520867179f99b3158b57520e2619f3fecd69b |
valid | to_permutation_matrix | Converts a permutation into a permutation matrix.
`matches` is a dictionary whose keys are vertices and whose values are
partners. For each vertex ``u`` and ``v``, entry (``u``, ``v``) in the
returned matrix will be a ``1`` if and only if ``matches[u] == v``.
Pre-condition: `matches` must be a permuta... | birkhoff.py | def to_permutation_matrix(matches):
"""Converts a permutation into a permutation matrix.
`matches` is a dictionary whose keys are vertices and whose values are
partners. For each vertex ``u`` and ``v``, entry (``u``, ``v``) in the
returned matrix will be a ``1`` if and only if ``matches[u] == v``.
... | def to_permutation_matrix(matches):
"""Converts a permutation into a permutation matrix.
`matches` is a dictionary whose keys are vertices and whose values are
partners. For each vertex ``u`` and ``v``, entry (``u``, ``v``) in the
returned matrix will be a ``1`` if and only if ``matches[u] == v``.
... | [
"Converts",
"a",
"permutation",
"into",
"a",
"permutation",
"matrix",
"."
] | jfinkels/birkhoff | python | https://github.com/jfinkels/birkhoff/blob/86fff692c9cfb7217e51e25868230f4e0b53caa0/birkhoff.py#L40-L61 | [
"def",
"to_permutation_matrix",
"(",
"matches",
")",
":",
"n",
"=",
"len",
"(",
"matches",
")",
"P",
"=",
"np",
".",
"zeros",
"(",
"(",
"n",
",",
"n",
")",
")",
"# This is a cleverer way of doing",
"#",
"# for (u, v) in matches.items():",
"# P[u, v] ... | 86fff692c9cfb7217e51e25868230f4e0b53caa0 |
valid | four_blocks | Convenience function that creates a block matrix with the specified
blocks.
Each argument must be a NumPy matrix. The two top matrices must have the
same number of rows, as must the two bottom matrices. The two left matrices
must have the same number of columns, as must the two right matrices. | birkhoff.py | def four_blocks(topleft, topright, bottomleft, bottomright):
"""Convenience function that creates a block matrix with the specified
blocks.
Each argument must be a NumPy matrix. The two top matrices must have the
same number of rows, as must the two bottom matrices. The two left matrices
must have ... | def four_blocks(topleft, topright, bottomleft, bottomright):
"""Convenience function that creates a block matrix with the specified
blocks.
Each argument must be a NumPy matrix. The two top matrices must have the
same number of rows, as must the two bottom matrices. The two left matrices
must have ... | [
"Convenience",
"function",
"that",
"creates",
"a",
"block",
"matrix",
"with",
"the",
"specified",
"blocks",
"."
] | jfinkels/birkhoff | python | https://github.com/jfinkels/birkhoff/blob/86fff692c9cfb7217e51e25868230f4e0b53caa0/birkhoff.py#L79-L89 | [
"def",
"four_blocks",
"(",
"topleft",
",",
"topright",
",",
"bottomleft",
",",
"bottomright",
")",
":",
"return",
"vstack",
"(",
"hstack",
"(",
"topleft",
",",
"topright",
")",
",",
"hstack",
"(",
"bottomleft",
",",
"bottomright",
")",
")"
] | 86fff692c9cfb7217e51e25868230f4e0b53caa0 |
valid | to_bipartite_matrix | Returns the adjacency matrix of a bipartite graph whose biadjacency
matrix is `A`.
`A` must be a NumPy array.
If `A` has **m** rows and **n** columns, then the returned matrix has **m +
n** rows and columns. | birkhoff.py | def to_bipartite_matrix(A):
"""Returns the adjacency matrix of a bipartite graph whose biadjacency
matrix is `A`.
`A` must be a NumPy array.
If `A` has **m** rows and **n** columns, then the returned matrix has **m +
n** rows and columns.
"""
m, n = A.shape
return four_blocks(zeros(m,... | def to_bipartite_matrix(A):
"""Returns the adjacency matrix of a bipartite graph whose biadjacency
matrix is `A`.
`A` must be a NumPy array.
If `A` has **m** rows and **n** columns, then the returned matrix has **m +
n** rows and columns.
"""
m, n = A.shape
return four_blocks(zeros(m,... | [
"Returns",
"the",
"adjacency",
"matrix",
"of",
"a",
"bipartite",
"graph",
"whose",
"biadjacency",
"matrix",
"is",
"A",
"."
] | jfinkels/birkhoff | python | https://github.com/jfinkels/birkhoff/blob/86fff692c9cfb7217e51e25868230f4e0b53caa0/birkhoff.py#L92-L103 | [
"def",
"to_bipartite_matrix",
"(",
"A",
")",
":",
"m",
",",
"n",
"=",
"A",
".",
"shape",
"return",
"four_blocks",
"(",
"zeros",
"(",
"m",
",",
"m",
")",
",",
"A",
",",
"A",
".",
"T",
",",
"zeros",
"(",
"n",
",",
"n",
")",
")"
] | 86fff692c9cfb7217e51e25868230f4e0b53caa0 |
valid | to_pattern_matrix | Returns the Boolean matrix in the same shape as `D` with ones exactly
where there are nonzero entries in `D`.
`D` must be a NumPy array. | birkhoff.py | def to_pattern_matrix(D):
"""Returns the Boolean matrix in the same shape as `D` with ones exactly
where there are nonzero entries in `D`.
`D` must be a NumPy array.
"""
result = np.zeros_like(D)
# This is a cleverer way of doing
#
# for (u, v) in zip(*(D.nonzero())):
# ... | def to_pattern_matrix(D):
"""Returns the Boolean matrix in the same shape as `D` with ones exactly
where there are nonzero entries in `D`.
`D` must be a NumPy array.
"""
result = np.zeros_like(D)
# This is a cleverer way of doing
#
# for (u, v) in zip(*(D.nonzero())):
# ... | [
"Returns",
"the",
"Boolean",
"matrix",
"in",
"the",
"same",
"shape",
"as",
"D",
"with",
"ones",
"exactly",
"where",
"there",
"are",
"nonzero",
"entries",
"in",
"D",
"."
] | jfinkels/birkhoff | python | https://github.com/jfinkels/birkhoff/blob/86fff692c9cfb7217e51e25868230f4e0b53caa0/birkhoff.py#L106-L120 | [
"def",
"to_pattern_matrix",
"(",
"D",
")",
":",
"result",
"=",
"np",
".",
"zeros_like",
"(",
"D",
")",
"# This is a cleverer way of doing",
"#",
"# for (u, v) in zip(*(D.nonzero())):",
"# result[u, v] = 1",
"#",
"result",
"[",
"D",
".",
"nonzero",
"(",
"... | 86fff692c9cfb7217e51e25868230f4e0b53caa0 |
valid | birkhoff_von_neumann_decomposition | Returns the Birkhoff--von Neumann decomposition of the doubly
stochastic matrix `D`.
The input `D` must be a square NumPy array representing a doubly
stochastic matrix (that is, a matrix whose entries are nonnegative
reals and whose row sums and column sums are all 1). Each doubly
stochastic matrix... | birkhoff.py | def birkhoff_von_neumann_decomposition(D):
"""Returns the Birkhoff--von Neumann decomposition of the doubly
stochastic matrix `D`.
The input `D` must be a square NumPy array representing a doubly
stochastic matrix (that is, a matrix whose entries are nonnegative
reals and whose row sums and column ... | def birkhoff_von_neumann_decomposition(D):
"""Returns the Birkhoff--von Neumann decomposition of the doubly
stochastic matrix `D`.
The input `D` must be a square NumPy array representing a doubly
stochastic matrix (that is, a matrix whose entries are nonnegative
reals and whose row sums and column ... | [
"Returns",
"the",
"Birkhoff",
"--",
"von",
"Neumann",
"decomposition",
"of",
"the",
"doubly",
"stochastic",
"matrix",
"D",
"."
] | jfinkels/birkhoff | python | https://github.com/jfinkels/birkhoff/blob/86fff692c9cfb7217e51e25868230f4e0b53caa0/birkhoff.py#L123-L237 | [
"def",
"birkhoff_von_neumann_decomposition",
"(",
"D",
")",
":",
"m",
",",
"n",
"=",
"D",
".",
"shape",
"if",
"m",
"!=",
"n",
":",
"raise",
"ValueError",
"(",
"'Input matrix must be square ({} x {})'",
".",
"format",
"(",
"m",
",",
"n",
")",
")",
"indices"... | 86fff692c9cfb7217e51e25868230f4e0b53caa0 |
valid | bump_version | Returns the result of incrementing `version`.
If `which` is not specified, the "patch" part of the version number will be
incremented. If `which` is specified, it must be ``'major'``, ``'minor'``,
or ``'patch'``. If it is one of these three strings, the corresponding part
of the version number will be... | make-release.py | def bump_version(version, which=None):
"""Returns the result of incrementing `version`.
If `which` is not specified, the "patch" part of the version number will be
incremented. If `which` is specified, it must be ``'major'``, ``'minor'``,
or ``'patch'``. If it is one of these three strings, the corres... | def bump_version(version, which=None):
"""Returns the result of incrementing `version`.
If `which` is not specified, the "patch" part of the version number will be
incremented. If `which` is specified, it must be ``'major'``, ``'minor'``,
or ``'patch'``. If it is one of these three strings, the corres... | [
"Returns",
"the",
"result",
"of",
"incrementing",
"version",
"."
] | jfinkels/birkhoff | python | https://github.com/jfinkels/birkhoff/blob/86fff692c9cfb7217e51e25868230f4e0b53caa0/make-release.py#L73-L106 | [
"def",
"bump_version",
"(",
"version",
",",
"which",
"=",
"None",
")",
":",
"try",
":",
"parts",
"=",
"[",
"int",
"(",
"n",
")",
"for",
"n",
"in",
"version",
".",
"split",
"(",
"'.'",
")",
"]",
"except",
"ValueError",
":",
"fail",
"(",
"'Current ve... | 86fff692c9cfb7217e51e25868230f4e0b53caa0 |
valid | get_version | Gets the current version from the specified file.
This function assumes the file includes a string of the form::
<pattern> = <version> | make-release.py | def get_version(filename, pattern):
"""Gets the current version from the specified file.
This function assumes the file includes a string of the form::
<pattern> = <version>
"""
with open(filename) as f:
match = re.search(r"^(\s*%s\s*=\s*')(.+?)(')(?sm)" % pattern, f.read())
if ma... | def get_version(filename, pattern):
"""Gets the current version from the specified file.
This function assumes the file includes a string of the form::
<pattern> = <version>
"""
with open(filename) as f:
match = re.search(r"^(\s*%s\s*=\s*')(.+?)(')(?sm)" % pattern, f.read())
if ma... | [
"Gets",
"the",
"current",
"version",
"from",
"the",
"specified",
"file",
"."
] | jfinkels/birkhoff | python | https://github.com/jfinkels/birkhoff/blob/86fff692c9cfb7217e51e25868230f4e0b53caa0/make-release.py#L125-L138 | [
"def",
"get_version",
"(",
"filename",
",",
"pattern",
")",
":",
"with",
"open",
"(",
"filename",
")",
"as",
"f",
":",
"match",
"=",
"re",
".",
"search",
"(",
"r\"^(\\s*%s\\s*=\\s*')(.+?)(')(?sm)\"",
"%",
"pattern",
",",
"f",
".",
"read",
"(",
")",
")",
... | 86fff692c9cfb7217e51e25868230f4e0b53caa0 |
valid | fail | Prints the specified message and exits the program with the specified
exit status. | make-release.py | def fail(message=None, exit_status=None):
"""Prints the specified message and exits the program with the specified
exit status.
"""
print('Error:', message, file=sys.stderr)
sys.exit(exit_status or 1) | def fail(message=None, exit_status=None):
"""Prints the specified message and exits the program with the specified
exit status.
"""
print('Error:', message, file=sys.stderr)
sys.exit(exit_status or 1) | [
"Prints",
"the",
"specified",
"message",
"and",
"exits",
"the",
"program",
"with",
"the",
"specified",
"exit",
"status",
"."
] | jfinkels/birkhoff | python | https://github.com/jfinkels/birkhoff/blob/86fff692c9cfb7217e51e25868230f4e0b53caa0/make-release.py#L151-L157 | [
"def",
"fail",
"(",
"message",
"=",
"None",
",",
"exit_status",
"=",
"None",
")",
":",
"print",
"(",
"'Error:'",
",",
"message",
",",
"file",
"=",
"sys",
".",
"stderr",
")",
"sys",
".",
"exit",
"(",
"exit_status",
"or",
"1",
")"
] | 86fff692c9cfb7217e51e25868230f4e0b53caa0 |
valid | git_tag | Tags the current version. | make-release.py | def git_tag(tag):
"""Tags the current version."""
print('Tagging "{}"'.format(tag))
msg = '"Released version {}"'.format(tag)
Popen(['git', 'tag', '-s', '-m', msg, tag]).wait() | def git_tag(tag):
"""Tags the current version."""
print('Tagging "{}"'.format(tag))
msg = '"Released version {}"'.format(tag)
Popen(['git', 'tag', '-s', '-m', msg, tag]).wait() | [
"Tags",
"the",
"current",
"version",
"."
] | jfinkels/birkhoff | python | https://github.com/jfinkels/birkhoff/blob/86fff692c9cfb7217e51e25868230f4e0b53caa0/make-release.py#L176-L180 | [
"def",
"git_tag",
"(",
"tag",
")",
":",
"print",
"(",
"'Tagging \"{}\"'",
".",
"format",
"(",
"tag",
")",
")",
"msg",
"=",
"'\"Released version {}\"'",
".",
"format",
"(",
"tag",
")",
"Popen",
"(",
"[",
"'git'",
",",
"'tag'",
",",
"'-s'",
",",
"'-m'",
... | 86fff692c9cfb7217e51e25868230f4e0b53caa0 |
valid | Renderer.initialize | initialize with templates' path
parameters
templates_path str the position of templates directory
global_data dict globa data can be got in any templates | rux/renderer.py | def initialize(self, templates_path, global_data):
"""initialize with templates' path
parameters
templates_path str the position of templates directory
global_data dict globa data can be got in any templates"""
self.env = Environment(loader=FileSystemLoader(temp... | def initialize(self, templates_path, global_data):
"""initialize with templates' path
parameters
templates_path str the position of templates directory
global_data dict globa data can be got in any templates"""
self.env = Environment(loader=FileSystemLoader(temp... | [
"initialize",
"with",
"templates",
"path",
"parameters",
"templates_path",
"str",
"the",
"position",
"of",
"templates",
"directory",
"global_data",
"dict",
"globa",
"data",
"can",
"be",
"got",
"in",
"any",
"templates"
] | hit9/rux | python | https://github.com/hit9/rux/blob/d7f60722658a3b83ac6d7bb3ca2790ac9c926b59/rux/renderer.py#L19-L26 | [
"def",
"initialize",
"(",
"self",
",",
"templates_path",
",",
"global_data",
")",
":",
"self",
".",
"env",
"=",
"Environment",
"(",
"loader",
"=",
"FileSystemLoader",
"(",
"templates_path",
")",
")",
"self",
".",
"env",
".",
"trim_blocks",
"=",
"True",
"se... | d7f60722658a3b83ac6d7bb3ca2790ac9c926b59 |
valid | Renderer.render | Render data with template, return html unicodes.
parameters
template str the template's filename
data dict the data to render | rux/renderer.py | def render(self, template, **data):
"""Render data with template, return html unicodes.
parameters
template str the template's filename
data dict the data to render
"""
# make a copy and update the copy
dct = self.global_data.copy()
dct.update... | def render(self, template, **data):
"""Render data with template, return html unicodes.
parameters
template str the template's filename
data dict the data to render
"""
# make a copy and update the copy
dct = self.global_data.copy()
dct.update... | [
"Render",
"data",
"with",
"template",
"return",
"html",
"unicodes",
".",
"parameters",
"template",
"str",
"the",
"template",
"s",
"filename",
"data",
"dict",
"the",
"data",
"to",
"render"
] | hit9/rux | python | https://github.com/hit9/rux/blob/d7f60722658a3b83ac6d7bb3ca2790ac9c926b59/rux/renderer.py#L28-L42 | [
"def",
"render",
"(",
"self",
",",
"template",
",",
"*",
"*",
"data",
")",
":",
"# make a copy and update the copy",
"dct",
"=",
"self",
".",
"global_data",
".",
"copy",
"(",
")",
"dct",
".",
"update",
"(",
"data",
")",
"try",
":",
"html",
"=",
"self",... | d7f60722658a3b83ac6d7bb3ca2790ac9c926b59 |
valid | Renderer.render_to | Render data with template and then write to path | rux/renderer.py | def render_to(self, path, template, **data):
"""Render data with template and then write to path"""
html = self.render(template, **data)
with open(path, 'w') as f:
f.write(html.encode(charset)) | def render_to(self, path, template, **data):
"""Render data with template and then write to path"""
html = self.render(template, **data)
with open(path, 'w') as f:
f.write(html.encode(charset)) | [
"Render",
"data",
"with",
"template",
"and",
"then",
"write",
"to",
"path"
] | hit9/rux | python | https://github.com/hit9/rux/blob/d7f60722658a3b83ac6d7bb3ca2790ac9c926b59/rux/renderer.py#L44-L48 | [
"def",
"render_to",
"(",
"self",
",",
"path",
",",
"template",
",",
"*",
"*",
"data",
")",
":",
"html",
"=",
"self",
".",
"render",
"(",
"template",
",",
"*",
"*",
"data",
")",
"with",
"open",
"(",
"path",
",",
"'w'",
")",
"as",
"f",
":",
"f",
... | d7f60722658a3b83ac6d7bb3ca2790ac9c926b59 |
valid | render | shortcut to render data with `template`. Just add exception
catch to `renderer.render` | rux/pdf.py | def render(template, **data):
"""shortcut to render data with `template`. Just add exception
catch to `renderer.render`"""
try:
return renderer.render(template, **data)
except JinjaTemplateNotFound as e:
logger.error(e.__doc__ + ', Template: %r' % template)
sys.exit(e.exit_code) | def render(template, **data):
"""shortcut to render data with `template`. Just add exception
catch to `renderer.render`"""
try:
return renderer.render(template, **data)
except JinjaTemplateNotFound as e:
logger.error(e.__doc__ + ', Template: %r' % template)
sys.exit(e.exit_code) | [
"shortcut",
"to",
"render",
"data",
"with",
"template",
".",
"Just",
"add",
"exception",
"catch",
"to",
"renderer",
".",
"render"
] | hit9/rux | python | https://github.com/hit9/rux/blob/d7f60722658a3b83ac6d7bb3ca2790ac9c926b59/rux/pdf.py#L27-L34 | [
"def",
"render",
"(",
"template",
",",
"*",
"*",
"data",
")",
":",
"try",
":",
"return",
"renderer",
".",
"render",
"(",
"template",
",",
"*",
"*",
"data",
")",
"except",
"JinjaTemplateNotFound",
"as",
"e",
":",
"logger",
".",
"error",
"(",
"e",
".",... | d7f60722658a3b83ac6d7bb3ca2790ac9c926b59 |
valid | PDFGenerator.replace_relative_url_to_absolute | Replace '../' leaded url with absolute uri. | rux/pdf.py | def replace_relative_url_to_absolute(self, content):
"""Replace '../' leaded url with absolute uri.
"""
p = os.path.join(os.getcwd(), './src', '../')
return content.replace('../', p) | def replace_relative_url_to_absolute(self, content):
"""Replace '../' leaded url with absolute uri.
"""
p = os.path.join(os.getcwd(), './src', '../')
return content.replace('../', p) | [
"Replace",
"..",
"/",
"leaded",
"url",
"with",
"absolute",
"uri",
"."
] | hit9/rux | python | https://github.com/hit9/rux/blob/d7f60722658a3b83ac6d7bb3ca2790ac9c926b59/rux/pdf.py#L93-L97 | [
"def",
"replace_relative_url_to_absolute",
"(",
"self",
",",
"content",
")",
":",
"p",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"getcwd",
"(",
")",
",",
"'./src'",
",",
"'../'",
")",
"return",
"content",
".",
"replace",
"(",
"'../'",
",",
... | d7f60722658a3b83ac6d7bb3ca2790ac9c926b59 |
valid | GenericDataFrameAPIView.get_dataframe | Get the DataFrame for this view.
Defaults to using `self.dataframe`.
This method should always be used rather than accessing `self.dataframe`
directly, as `self.dataframe` gets evaluated only once, and those results
are cached for all subsequent requests.
You may want to overri... | pandas_drf_tools/generics.py | def get_dataframe(self):
"""
Get the DataFrame for this view.
Defaults to using `self.dataframe`.
This method should always be used rather than accessing `self.dataframe`
directly, as `self.dataframe` gets evaluated only once, and those results
are cached for all subsequ... | def get_dataframe(self):
"""
Get the DataFrame for this view.
Defaults to using `self.dataframe`.
This method should always be used rather than accessing `self.dataframe`
directly, as `self.dataframe` gets evaluated only once, and those results
are cached for all subsequ... | [
"Get",
"the",
"DataFrame",
"for",
"this",
"view",
".",
"Defaults",
"to",
"using",
"self",
".",
"dataframe",
"."
] | abarto/pandas-drf-tools | python | https://github.com/abarto/pandas-drf-tools/blob/ec754ac75327e6ee5a1efd256a572a9a531e4d28/pandas_drf_tools/generics.py#L26-L45 | [
"def",
"get_dataframe",
"(",
"self",
")",
":",
"assert",
"self",
".",
"dataframe",
"is",
"not",
"None",
",",
"(",
"\"'%s' should either include a `dataframe` attribute, \"",
"\"or override the `get_dataframe()` method.\"",
"%",
"self",
".",
"__class__",
".",
"__name__",
... | ec754ac75327e6ee5a1efd256a572a9a531e4d28 |
valid | GenericDataFrameAPIView.index_row | Indexes the row based on the request parameters. | pandas_drf_tools/generics.py | def index_row(self, dataframe):
"""
Indexes the row based on the request parameters.
"""
return dataframe.loc[self.kwargs[self.lookup_url_kwarg]].to_frame().T | def index_row(self, dataframe):
"""
Indexes the row based on the request parameters.
"""
return dataframe.loc[self.kwargs[self.lookup_url_kwarg]].to_frame().T | [
"Indexes",
"the",
"row",
"based",
"on",
"the",
"request",
"parameters",
"."
] | abarto/pandas-drf-tools | python | https://github.com/abarto/pandas-drf-tools/blob/ec754ac75327e6ee5a1efd256a572a9a531e4d28/pandas_drf_tools/generics.py#L55-L59 | [
"def",
"index_row",
"(",
"self",
",",
"dataframe",
")",
":",
"return",
"dataframe",
".",
"loc",
"[",
"self",
".",
"kwargs",
"[",
"self",
".",
"lookup_url_kwarg",
"]",
"]",
".",
"to_frame",
"(",
")",
".",
"T"
] | ec754ac75327e6ee5a1efd256a572a9a531e4d28 |
valid | GenericDataFrameAPIView.get_object | Returns the row the view is displaying.
You may want to override this if you need to provide non-standard
queryset lookups. Eg if objects are referenced using multiple
keyword arguments in the url conf. | pandas_drf_tools/generics.py | def get_object(self):
"""
Returns the row the view is displaying.
You may want to override this if you need to provide non-standard
queryset lookups. Eg if objects are referenced using multiple
keyword arguments in the url conf.
"""
dataframe = self.filter_dataf... | def get_object(self):
"""
Returns the row the view is displaying.
You may want to override this if you need to provide non-standard
queryset lookups. Eg if objects are referenced using multiple
keyword arguments in the url conf.
"""
dataframe = self.filter_dataf... | [
"Returns",
"the",
"row",
"the",
"view",
"is",
"displaying",
"."
] | abarto/pandas-drf-tools | python | https://github.com/abarto/pandas-drf-tools/blob/ec754ac75327e6ee5a1efd256a572a9a531e4d28/pandas_drf_tools/generics.py#L61-L86 | [
"def",
"get_object",
"(",
"self",
")",
":",
"dataframe",
"=",
"self",
".",
"filter_dataframe",
"(",
"self",
".",
"get_dataframe",
"(",
")",
")",
"assert",
"self",
".",
"lookup_url_kwarg",
"in",
"self",
".",
"kwargs",
",",
"(",
"'Expected view %s to be called w... | ec754ac75327e6ee5a1efd256a572a9a531e4d28 |
valid | GenericDataFrameAPIView.paginator | The paginator instance associated with the view, or `None`. | pandas_drf_tools/generics.py | def paginator(self):
"""
The paginator instance associated with the view, or `None`.
"""
if not hasattr(self, '_paginator'):
if self.pagination_class is None:
self._paginator = None
else:
self._paginator = self.pagination_class()
... | def paginator(self):
"""
The paginator instance associated with the view, or `None`.
"""
if not hasattr(self, '_paginator'):
if self.pagination_class is None:
self._paginator = None
else:
self._paginator = self.pagination_class()
... | [
"The",
"paginator",
"instance",
"associated",
"with",
"the",
"view",
"or",
"None",
"."
] | abarto/pandas-drf-tools | python | https://github.com/abarto/pandas-drf-tools/blob/ec754ac75327e6ee5a1efd256a572a9a531e4d28/pandas_drf_tools/generics.py#L132-L141 | [
"def",
"paginator",
"(",
"self",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"'_paginator'",
")",
":",
"if",
"self",
".",
"pagination_class",
"is",
"None",
":",
"self",
".",
"_paginator",
"=",
"None",
"else",
":",
"self",
".",
"_paginator",
"="... | ec754ac75327e6ee5a1efd256a572a9a531e4d28 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.