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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
test | SMBus.write_byte_data | Write a byte of data to the specified cmd register of the device. | Adafruit_PureIO/smbus.py | def write_byte_data(self, addr, cmd, val):
"""Write a byte of data to the specified cmd register of the device.
"""
assert self._device is not None, 'Bus must be opened before operations are made against it!'
# Construct a string of data to send with the command register and byte value.
... | def write_byte_data(self, addr, cmd, val):
"""Write a byte of data to the specified cmd register of the device.
"""
assert self._device is not None, 'Bus must be opened before operations are made against it!'
# Construct a string of data to send with the command register and byte value.
... | [
"Write",
"a",
"byte",
"of",
"data",
"to",
"the",
"specified",
"cmd",
"register",
"of",
"the",
"device",
"."
] | adafruit/Adafruit_Python_PureIO | python | https://github.com/adafruit/Adafruit_Python_PureIO/blob/6f4976d91c52d70b67b28bba75a429b5328a52c1/Adafruit_PureIO/smbus.py#L246-L256 | [
"def",
"write_byte_data",
"(",
"self",
",",
"addr",
",",
"cmd",
",",
"val",
")",
":",
"assert",
"self",
".",
"_device",
"is",
"not",
"None",
",",
"'Bus must be opened before operations are made against it!'",
"# Construct a string of data to send with the command register a... | 6f4976d91c52d70b67b28bba75a429b5328a52c1 |
test | SMBus.write_word_data | Write a word (2 bytes) of data to the specified cmd register of the
device. Note that this will write the data in the endianness of the
processor running Python (typically little endian)! | Adafruit_PureIO/smbus.py | def write_word_data(self, addr, cmd, val):
"""Write a word (2 bytes) of data to the specified cmd register of the
device. Note that this will write the data in the endianness of the
processor running Python (typically little endian)!
"""
assert self._device is not None, 'Bus mus... | def write_word_data(self, addr, cmd, val):
"""Write a word (2 bytes) of data to the specified cmd register of the
device. Note that this will write the data in the endianness of the
processor running Python (typically little endian)!
"""
assert self._device is not None, 'Bus mus... | [
"Write",
"a",
"word",
"(",
"2",
"bytes",
")",
"of",
"data",
"to",
"the",
"specified",
"cmd",
"register",
"of",
"the",
"device",
".",
"Note",
"that",
"this",
"will",
"write",
"the",
"data",
"in",
"the",
"endianness",
"of",
"the",
"processor",
"running",
... | adafruit/Adafruit_Python_PureIO | python | https://github.com/adafruit/Adafruit_Python_PureIO/blob/6f4976d91c52d70b67b28bba75a429b5328a52c1/Adafruit_PureIO/smbus.py#L258-L268 | [
"def",
"write_word_data",
"(",
"self",
",",
"addr",
",",
"cmd",
",",
"val",
")",
":",
"assert",
"self",
".",
"_device",
"is",
"not",
"None",
",",
"'Bus must be opened before operations are made against it!'",
"# Construct a string of data to send with the command register a... | 6f4976d91c52d70b67b28bba75a429b5328a52c1 |
test | SMBus.write_block_data | Write a block of data to the specified cmd register of the device.
The amount of data to write should be the first byte inside the vals
string/bytearray and that count of bytes of data to write should follow
it. | Adafruit_PureIO/smbus.py | def write_block_data(self, addr, cmd, vals):
"""Write a block of data to the specified cmd register of the device.
The amount of data to write should be the first byte inside the vals
string/bytearray and that count of bytes of data to write should follow
it.
"""
# Just u... | def write_block_data(self, addr, cmd, vals):
"""Write a block of data to the specified cmd register of the device.
The amount of data to write should be the first byte inside the vals
string/bytearray and that count of bytes of data to write should follow
it.
"""
# Just u... | [
"Write",
"a",
"block",
"of",
"data",
"to",
"the",
"specified",
"cmd",
"register",
"of",
"the",
"device",
".",
"The",
"amount",
"of",
"data",
"to",
"write",
"should",
"be",
"the",
"first",
"byte",
"inside",
"the",
"vals",
"string",
"/",
"bytearray",
"and"... | adafruit/Adafruit_Python_PureIO | python | https://github.com/adafruit/Adafruit_Python_PureIO/blob/6f4976d91c52d70b67b28bba75a429b5328a52c1/Adafruit_PureIO/smbus.py#L270-L281 | [
"def",
"write_block_data",
"(",
"self",
",",
"addr",
",",
"cmd",
",",
"vals",
")",
":",
"# Just use the I2C block data write to write the provided values and",
"# their length as the first byte.",
"data",
"=",
"bytearray",
"(",
"len",
"(",
"vals",
")",
"+",
"1",
")",
... | 6f4976d91c52d70b67b28bba75a429b5328a52c1 |
test | SMBus.write_i2c_block_data | Write a buffer of data to the specified cmd register of the device. | Adafruit_PureIO/smbus.py | def write_i2c_block_data(self, addr, cmd, vals):
"""Write a buffer of data to the specified cmd register of the device.
"""
assert self._device is not None, 'Bus must be opened before operations are made against it!'
# Construct a string of data to send, including room for the command re... | def write_i2c_block_data(self, addr, cmd, vals):
"""Write a buffer of data to the specified cmd register of the device.
"""
assert self._device is not None, 'Bus must be opened before operations are made against it!'
# Construct a string of data to send, including room for the command re... | [
"Write",
"a",
"buffer",
"of",
"data",
"to",
"the",
"specified",
"cmd",
"register",
"of",
"the",
"device",
"."
] | adafruit/Adafruit_Python_PureIO | python | https://github.com/adafruit/Adafruit_Python_PureIO/blob/6f4976d91c52d70b67b28bba75a429b5328a52c1/Adafruit_PureIO/smbus.py#L283-L294 | [
"def",
"write_i2c_block_data",
"(",
"self",
",",
"addr",
",",
"cmd",
",",
"vals",
")",
":",
"assert",
"self",
".",
"_device",
"is",
"not",
"None",
",",
"'Bus must be opened before operations are made against it!'",
"# Construct a string of data to send, including room for t... | 6f4976d91c52d70b67b28bba75a429b5328a52c1 |
test | SMBus.process_call | Perform a smbus process call by writing a word (2 byte) value to
the specified register of the device, and then reading a word of response
data (which is returned). | Adafruit_PureIO/smbus.py | def process_call(self, addr, cmd, val):
"""Perform a smbus process call by writing a word (2 byte) value to
the specified register of the device, and then reading a word of response
data (which is returned).
"""
assert self._device is not None, 'Bus must be opened before operatio... | def process_call(self, addr, cmd, val):
"""Perform a smbus process call by writing a word (2 byte) value to
the specified register of the device, and then reading a word of response
data (which is returned).
"""
assert self._device is not None, 'Bus must be opened before operatio... | [
"Perform",
"a",
"smbus",
"process",
"call",
"by",
"writing",
"a",
"word",
"(",
"2",
"byte",
")",
"value",
"to",
"the",
"specified",
"register",
"of",
"the",
"device",
"and",
"then",
"reading",
"a",
"word",
"of",
"response",
"data",
"(",
"which",
"is",
... | adafruit/Adafruit_Python_PureIO | python | https://github.com/adafruit/Adafruit_Python_PureIO/blob/6f4976d91c52d70b67b28bba75a429b5328a52c1/Adafruit_PureIO/smbus.py#L296-L314 | [
"def",
"process_call",
"(",
"self",
",",
"addr",
",",
"cmd",
",",
"val",
")",
":",
"assert",
"self",
".",
"_device",
"is",
"not",
"None",
",",
"'Bus must be opened before operations are made against it!'",
"# Build ctypes values to marshall between ioctl and Python.",
"da... | 6f4976d91c52d70b67b28bba75a429b5328a52c1 |
test | File.cdn_url | Returns file's CDN url.
Usage example::
>>> file_ = File('a771f854-c2cb-408a-8c36-71af77811f3b')
>>> file_.cdn_url
https://ucarecdn.com/a771f854-c2cb-408a-8c36-71af77811f3b/
You can set default effects::
>>> file_.default_effects = 'effect/flip/-/effec... | pyuploadcare/api_resources.py | def cdn_url(self):
"""Returns file's CDN url.
Usage example::
>>> file_ = File('a771f854-c2cb-408a-8c36-71af77811f3b')
>>> file_.cdn_url
https://ucarecdn.com/a771f854-c2cb-408a-8c36-71af77811f3b/
You can set default effects::
>>> file_.default_... | def cdn_url(self):
"""Returns file's CDN url.
Usage example::
>>> file_ = File('a771f854-c2cb-408a-8c36-71af77811f3b')
>>> file_.cdn_url
https://ucarecdn.com/a771f854-c2cb-408a-8c36-71af77811f3b/
You can set default effects::
>>> file_.default_... | [
"Returns",
"file",
"s",
"CDN",
"url",
"."
] | uploadcare/pyuploadcare | python | https://github.com/uploadcare/pyuploadcare/blob/cefddc0306133a71e37b18e8700df5948ef49b37/pyuploadcare/api_resources.py#L106-L123 | [
"def",
"cdn_url",
"(",
"self",
")",
":",
"return",
"'{cdn_base}{path}'",
".",
"format",
"(",
"cdn_base",
"=",
"conf",
".",
"cdn_base",
",",
"path",
"=",
"self",
".",
"cdn_path",
"(",
"self",
".",
"default_effects",
")",
")"
] | cefddc0306133a71e37b18e8700df5948ef49b37 |
test | File.datetime_stored | Returns file's store aware *datetime* in UTC format.
It might do API request once because it depends on ``info()``. | pyuploadcare/api_resources.py | def datetime_stored(self):
"""Returns file's store aware *datetime* in UTC format.
It might do API request once because it depends on ``info()``.
"""
if self.info().get('datetime_stored'):
return dateutil.parser.parse(self.info()['datetime_stored']) | def datetime_stored(self):
"""Returns file's store aware *datetime* in UTC format.
It might do API request once because it depends on ``info()``.
"""
if self.info().get('datetime_stored'):
return dateutil.parser.parse(self.info()['datetime_stored']) | [
"Returns",
"file",
"s",
"store",
"aware",
"*",
"datetime",
"*",
"in",
"UTC",
"format",
"."
] | uploadcare/pyuploadcare | python | https://github.com/uploadcare/pyuploadcare/blob/cefddc0306133a71e37b18e8700df5948ef49b37/pyuploadcare/api_resources.py#L150-L157 | [
"def",
"datetime_stored",
"(",
"self",
")",
":",
"if",
"self",
".",
"info",
"(",
")",
".",
"get",
"(",
"'datetime_stored'",
")",
":",
"return",
"dateutil",
".",
"parser",
".",
"parse",
"(",
"self",
".",
"info",
"(",
")",
"[",
"'datetime_stored'",
"]",
... | cefddc0306133a71e37b18e8700df5948ef49b37 |
test | File.datetime_removed | Returns file's remove aware *datetime* in UTC format.
It might do API request once because it depends on ``info()``. | pyuploadcare/api_resources.py | def datetime_removed(self):
"""Returns file's remove aware *datetime* in UTC format.
It might do API request once because it depends on ``info()``.
"""
if self.info().get('datetime_removed'):
return dateutil.parser.parse(self.info()['datetime_removed']) | def datetime_removed(self):
"""Returns file's remove aware *datetime* in UTC format.
It might do API request once because it depends on ``info()``.
"""
if self.info().get('datetime_removed'):
return dateutil.parser.parse(self.info()['datetime_removed']) | [
"Returns",
"file",
"s",
"remove",
"aware",
"*",
"datetime",
"*",
"in",
"UTC",
"format",
"."
] | uploadcare/pyuploadcare | python | https://github.com/uploadcare/pyuploadcare/blob/cefddc0306133a71e37b18e8700df5948ef49b37/pyuploadcare/api_resources.py#L159-L166 | [
"def",
"datetime_removed",
"(",
"self",
")",
":",
"if",
"self",
".",
"info",
"(",
")",
".",
"get",
"(",
"'datetime_removed'",
")",
":",
"return",
"dateutil",
".",
"parser",
".",
"parse",
"(",
"self",
".",
"info",
"(",
")",
"[",
"'datetime_removed'",
"]... | cefddc0306133a71e37b18e8700df5948ef49b37 |
test | File.datetime_uploaded | Returns file's upload aware *datetime* in UTC format.
It might do API request once because it depends on ``info()``. | pyuploadcare/api_resources.py | def datetime_uploaded(self):
"""Returns file's upload aware *datetime* in UTC format.
It might do API request once because it depends on ``info()``.
"""
if self.info().get('datetime_uploaded'):
return dateutil.parser.parse(self.info()['datetime_uploaded']) | def datetime_uploaded(self):
"""Returns file's upload aware *datetime* in UTC format.
It might do API request once because it depends on ``info()``.
"""
if self.info().get('datetime_uploaded'):
return dateutil.parser.parse(self.info()['datetime_uploaded']) | [
"Returns",
"file",
"s",
"upload",
"aware",
"*",
"datetime",
"*",
"in",
"UTC",
"format",
"."
] | uploadcare/pyuploadcare | python | https://github.com/uploadcare/pyuploadcare/blob/cefddc0306133a71e37b18e8700df5948ef49b37/pyuploadcare/api_resources.py#L168-L175 | [
"def",
"datetime_uploaded",
"(",
"self",
")",
":",
"if",
"self",
".",
"info",
"(",
")",
".",
"get",
"(",
"'datetime_uploaded'",
")",
":",
"return",
"dateutil",
".",
"parser",
".",
"parse",
"(",
"self",
".",
"info",
"(",
")",
"[",
"'datetime_uploaded'",
... | cefddc0306133a71e37b18e8700df5948ef49b37 |
test | File.copy | Creates a File Copy on Uploadcare or Custom Storage.
File.copy method is deprecated and will be removed in 4.0.0.
Please use `create_local_copy` and `create_remote_copy` instead.
Args:
- effects:
Adds CDN image effects. If ``self.default_effects`` property
... | pyuploadcare/api_resources.py | def copy(self, effects=None, target=None):
"""Creates a File Copy on Uploadcare or Custom Storage.
File.copy method is deprecated and will be removed in 4.0.0.
Please use `create_local_copy` and `create_remote_copy` instead.
Args:
- effects:
Adds CDN... | def copy(self, effects=None, target=None):
"""Creates a File Copy on Uploadcare or Custom Storage.
File.copy method is deprecated and will be removed in 4.0.0.
Please use `create_local_copy` and `create_remote_copy` instead.
Args:
- effects:
Adds CDN... | [
"Creates",
"a",
"File",
"Copy",
"on",
"Uploadcare",
"or",
"Custom",
"Storage",
".",
"File",
".",
"copy",
"method",
"is",
"deprecated",
"and",
"will",
"be",
"removed",
"in",
"4",
".",
"0",
".",
"0",
".",
"Please",
"use",
"create_local_copy",
"and",
"creat... | uploadcare/pyuploadcare | python | https://github.com/uploadcare/pyuploadcare/blob/cefddc0306133a71e37b18e8700df5948ef49b37/pyuploadcare/api_resources.py#L240-L265 | [
"def",
"copy",
"(",
"self",
",",
"effects",
"=",
"None",
",",
"target",
"=",
"None",
")",
":",
"warning",
"=",
"\"\"\"File.copy method is deprecated and will be\n removed in 4.0.0.\n Please use `create_local_copy`\n and `create_remote_copy` instead.\n... | cefddc0306133a71e37b18e8700df5948ef49b37 |
test | File.create_local_copy | Creates a Local File Copy on Uploadcare Storage.
Args:
- effects:
Adds CDN image effects. If ``self.default_effects`` property
is set effects will be combined with default effects.
- store:
If ``store`` option is set to False the copy of y... | pyuploadcare/api_resources.py | def create_local_copy(self, effects=None, store=None):
"""Creates a Local File Copy on Uploadcare Storage.
Args:
- effects:
Adds CDN image effects. If ``self.default_effects`` property
is set effects will be combined with default effects.
- store:... | def create_local_copy(self, effects=None, store=None):
"""Creates a Local File Copy on Uploadcare Storage.
Args:
- effects:
Adds CDN image effects. If ``self.default_effects`` property
is set effects will be combined with default effects.
- store:... | [
"Creates",
"a",
"Local",
"File",
"Copy",
"on",
"Uploadcare",
"Storage",
"."
] | uploadcare/pyuploadcare | python | https://github.com/uploadcare/pyuploadcare/blob/cefddc0306133a71e37b18e8700df5948ef49b37/pyuploadcare/api_resources.py#L267-L287 | [
"def",
"create_local_copy",
"(",
"self",
",",
"effects",
"=",
"None",
",",
"store",
"=",
"None",
")",
":",
"effects",
"=",
"self",
".",
"_build_effects",
"(",
"effects",
")",
"store",
"=",
"store",
"or",
"''",
"data",
"=",
"{",
"'source'",
":",
"self",... | cefddc0306133a71e37b18e8700df5948ef49b37 |
test | File.create_remote_copy | Creates file copy in remote storage.
Args:
- target:
Name of a custom storage connected to the project.
- effects:
Adds CDN image effects to ``self.default_effects`` if any.
- make_public:
To forbid public from accessing your f... | pyuploadcare/api_resources.py | def create_remote_copy(self, target, effects=None, make_public=None,
pattern=None):
"""Creates file copy in remote storage.
Args:
- target:
Name of a custom storage connected to the project.
- effects:
Adds CDN image eff... | def create_remote_copy(self, target, effects=None, make_public=None,
pattern=None):
"""Creates file copy in remote storage.
Args:
- target:
Name of a custom storage connected to the project.
- effects:
Adds CDN image eff... | [
"Creates",
"file",
"copy",
"in",
"remote",
"storage",
"."
] | uploadcare/pyuploadcare | python | https://github.com/uploadcare/pyuploadcare/blob/cefddc0306133a71e37b18e8700df5948ef49b37/pyuploadcare/api_resources.py#L289-L333 | [
"def",
"create_remote_copy",
"(",
"self",
",",
"target",
",",
"effects",
"=",
"None",
",",
"make_public",
"=",
"None",
",",
"pattern",
"=",
"None",
")",
":",
"effects",
"=",
"self",
".",
"_build_effects",
"(",
"effects",
")",
"data",
"=",
"{",
"'source'"... | cefddc0306133a71e37b18e8700df5948ef49b37 |
test | File.construct_from | Constructs ``File`` instance from file information.
For example you have result of
``/files/1921953c-5d94-4e47-ba36-c2e1dd165e1a/`` API request::
>>> file_info = {
# ...
'uuid': '1921953c-5d94-4e47-ba36-c2e1dd165e1a',
# ...
... | pyuploadcare/api_resources.py | def construct_from(cls, file_info):
"""Constructs ``File`` instance from file information.
For example you have result of
``/files/1921953c-5d94-4e47-ba36-c2e1dd165e1a/`` API request::
>>> file_info = {
# ...
'uuid': '1921953c-5d94-4e47-ba36-... | def construct_from(cls, file_info):
"""Constructs ``File`` instance from file information.
For example you have result of
``/files/1921953c-5d94-4e47-ba36-c2e1dd165e1a/`` API request::
>>> file_info = {
# ...
'uuid': '1921953c-5d94-4e47-ba36-... | [
"Constructs",
"File",
"instance",
"from",
"file",
"information",
"."
] | uploadcare/pyuploadcare | python | https://github.com/uploadcare/pyuploadcare/blob/cefddc0306133a71e37b18e8700df5948ef49b37/pyuploadcare/api_resources.py#L340-L358 | [
"def",
"construct_from",
"(",
"cls",
",",
"file_info",
")",
":",
"file_",
"=",
"cls",
"(",
"file_info",
"[",
"'uuid'",
"]",
")",
"file_",
".",
"default_effects",
"=",
"file_info",
".",
"get",
"(",
"'default_effects'",
")",
"file_",
".",
"_info_cache",
"=",... | cefddc0306133a71e37b18e8700df5948ef49b37 |
test | File.upload | Uploads a file and returns ``File`` instance.
Args:
- file_obj: file object to upload to
- store (Optional[bool]): Should the file be automatically stored
upon upload. Defaults to None.
- False - do not store file
- True - store file (can ... | pyuploadcare/api_resources.py | def upload(cls, file_obj, store=None):
"""Uploads a file and returns ``File`` instance.
Args:
- file_obj: file object to upload to
- store (Optional[bool]): Should the file be automatically stored
upon upload. Defaults to None.
- False - do not st... | def upload(cls, file_obj, store=None):
"""Uploads a file and returns ``File`` instance.
Args:
- file_obj: file object to upload to
- store (Optional[bool]): Should the file be automatically stored
upon upload. Defaults to None.
- False - do not st... | [
"Uploads",
"a",
"file",
"and",
"returns",
"File",
"instance",
"."
] | uploadcare/pyuploadcare | python | https://github.com/uploadcare/pyuploadcare/blob/cefddc0306133a71e37b18e8700df5948ef49b37/pyuploadcare/api_resources.py#L361-L391 | [
"def",
"upload",
"(",
"cls",
",",
"file_obj",
",",
"store",
"=",
"None",
")",
":",
"if",
"store",
"is",
"None",
":",
"store",
"=",
"'auto'",
"elif",
"store",
":",
"store",
"=",
"'1'",
"else",
":",
"store",
"=",
"'0'",
"data",
"=",
"{",
"'UPLOADCARE... | cefddc0306133a71e37b18e8700df5948ef49b37 |
test | File.upload_from_url | Uploads file from given url and returns ``FileFromUrl`` instance.
Args:
- url (str): URL of file to upload to
- store (Optional[bool]): Should the file be automatically stored
upon upload. Defaults to None.
- False - do not store file
- Tr... | pyuploadcare/api_resources.py | def upload_from_url(cls, url, store=None, filename=None):
"""Uploads file from given url and returns ``FileFromUrl`` instance.
Args:
- url (str): URL of file to upload to
- store (Optional[bool]): Should the file be automatically stored
upon upload. Defaults to N... | def upload_from_url(cls, url, store=None, filename=None):
"""Uploads file from given url and returns ``FileFromUrl`` instance.
Args:
- url (str): URL of file to upload to
- store (Optional[bool]): Should the file be automatically stored
upon upload. Defaults to N... | [
"Uploads",
"file",
"from",
"given",
"url",
"and",
"returns",
"FileFromUrl",
"instance",
"."
] | uploadcare/pyuploadcare | python | https://github.com/uploadcare/pyuploadcare/blob/cefddc0306133a71e37b18e8700df5948ef49b37/pyuploadcare/api_resources.py#L394-L434 | [
"def",
"upload_from_url",
"(",
"cls",
",",
"url",
",",
"store",
"=",
"None",
",",
"filename",
"=",
"None",
")",
":",
"if",
"store",
"is",
"None",
":",
"store",
"=",
"'auto'",
"elif",
"store",
":",
"store",
"=",
"'1'",
"else",
":",
"store",
"=",
"'0... | cefddc0306133a71e37b18e8700df5948ef49b37 |
test | File.upload_from_url_sync | Uploads file from given url and returns ``File`` instance.
Args:
- url (str): URL of file to upload to
- store (Optional[bool]): Should the file be automatically stored
upon upload. Defaults to None.
- False - do not store file
- True - st... | pyuploadcare/api_resources.py | def upload_from_url_sync(cls, url, timeout=30, interval=0.3,
until_ready=False, store=None, filename=None):
"""Uploads file from given url and returns ``File`` instance.
Args:
- url (str): URL of file to upload to
- store (Optional[bool]): Should the... | def upload_from_url_sync(cls, url, timeout=30, interval=0.3,
until_ready=False, store=None, filename=None):
"""Uploads file from given url and returns ``File`` instance.
Args:
- url (str): URL of file to upload to
- store (Optional[bool]): Should the... | [
"Uploads",
"file",
"from",
"given",
"url",
"and",
"returns",
"File",
"instance",
"."
] | uploadcare/pyuploadcare | python | https://github.com/uploadcare/pyuploadcare/blob/cefddc0306133a71e37b18e8700df5948ef49b37/pyuploadcare/api_resources.py#L437-L468 | [
"def",
"upload_from_url_sync",
"(",
"cls",
",",
"url",
",",
"timeout",
"=",
"30",
",",
"interval",
"=",
"0.3",
",",
"until_ready",
"=",
"False",
",",
"store",
"=",
"None",
",",
"filename",
"=",
"None",
")",
":",
"ffu",
"=",
"cls",
".",
"upload_from_url... | cefddc0306133a71e37b18e8700df5948ef49b37 |
test | FileGroup.file_cdn_urls | Returns CDN urls of all files from group without API requesting.
Usage example::
>>> file_group = FileGroup('0513dda0-582f-447d-846f-096e5df9e2bb~2')
>>> file_group.file_cdn_urls[0]
'https://ucarecdn.com/0513dda0-582f-447d-846f-096e5df9e2bb~2/nth/0/' | pyuploadcare/api_resources.py | def file_cdn_urls(self):
"""Returns CDN urls of all files from group without API requesting.
Usage example::
>>> file_group = FileGroup('0513dda0-582f-447d-846f-096e5df9e2bb~2')
>>> file_group.file_cdn_urls[0]
'https://ucarecdn.com/0513dda0-582f-447d-846f-096e5df9e2... | def file_cdn_urls(self):
"""Returns CDN urls of all files from group without API requesting.
Usage example::
>>> file_group = FileGroup('0513dda0-582f-447d-846f-096e5df9e2bb~2')
>>> file_group.file_cdn_urls[0]
'https://ucarecdn.com/0513dda0-582f-447d-846f-096e5df9e2... | [
"Returns",
"CDN",
"urls",
"of",
"all",
"files",
"from",
"group",
"without",
"API",
"requesting",
"."
] | uploadcare/pyuploadcare | python | https://github.com/uploadcare/pyuploadcare/blob/cefddc0306133a71e37b18e8700df5948ef49b37/pyuploadcare/api_resources.py#L659-L676 | [
"def",
"file_cdn_urls",
"(",
"self",
")",
":",
"file_cdn_urls",
"=",
"[",
"]",
"for",
"file_index",
"in",
"six",
".",
"moves",
".",
"xrange",
"(",
"len",
"(",
"self",
")",
")",
":",
"file_cdn_url",
"=",
"'{group_cdn_url}nth/{file_index}/'",
".",
"format",
... | cefddc0306133a71e37b18e8700df5948ef49b37 |
test | FileGroup.datetime_created | Returns file group's create aware *datetime* in UTC format. | pyuploadcare/api_resources.py | def datetime_created(self):
"""Returns file group's create aware *datetime* in UTC format."""
if self.info().get('datetime_created'):
return dateutil.parser.parse(self.info()['datetime_created']) | def datetime_created(self):
"""Returns file group's create aware *datetime* in UTC format."""
if self.info().get('datetime_created'):
return dateutil.parser.parse(self.info()['datetime_created']) | [
"Returns",
"file",
"group",
"s",
"create",
"aware",
"*",
"datetime",
"*",
"in",
"UTC",
"format",
"."
] | uploadcare/pyuploadcare | python | https://github.com/uploadcare/pyuploadcare/blob/cefddc0306133a71e37b18e8700df5948ef49b37/pyuploadcare/api_resources.py#L700-L703 | [
"def",
"datetime_created",
"(",
"self",
")",
":",
"if",
"self",
".",
"info",
"(",
")",
".",
"get",
"(",
"'datetime_created'",
")",
":",
"return",
"dateutil",
".",
"parser",
".",
"parse",
"(",
"self",
".",
"info",
"(",
")",
"[",
"'datetime_created'",
"]... | cefddc0306133a71e37b18e8700df5948ef49b37 |
test | FileGroup.construct_from | Constructs ``FileGroup`` instance from group information. | pyuploadcare/api_resources.py | def construct_from(cls, group_info):
"""Constructs ``FileGroup`` instance from group information."""
group = cls(group_info['id'])
group._info_cache = group_info
return group | def construct_from(cls, group_info):
"""Constructs ``FileGroup`` instance from group information."""
group = cls(group_info['id'])
group._info_cache = group_info
return group | [
"Constructs",
"FileGroup",
"instance",
"from",
"group",
"information",
"."
] | uploadcare/pyuploadcare | python | https://github.com/uploadcare/pyuploadcare/blob/cefddc0306133a71e37b18e8700df5948ef49b37/pyuploadcare/api_resources.py#L725-L729 | [
"def",
"construct_from",
"(",
"cls",
",",
"group_info",
")",
":",
"group",
"=",
"cls",
"(",
"group_info",
"[",
"'id'",
"]",
")",
"group",
".",
"_info_cache",
"=",
"group_info",
"return",
"group"
] | cefddc0306133a71e37b18e8700df5948ef49b37 |
test | FileGroup.create | Creates file group and returns ``FileGroup`` instance.
It expects iterable object that contains ``File`` instances, e.g.::
>>> file_1 = File('6c5e9526-b0fe-4739-8975-72e8d5ee6342')
>>> file_2 = File('a771f854-c2cb-408a-8c36-71af77811f3b')
>>> FileGroup.create((file_1, file_... | pyuploadcare/api_resources.py | def create(cls, files):
"""Creates file group and returns ``FileGroup`` instance.
It expects iterable object that contains ``File`` instances, e.g.::
>>> file_1 = File('6c5e9526-b0fe-4739-8975-72e8d5ee6342')
>>> file_2 = File('a771f854-c2cb-408a-8c36-71af77811f3b')
... | def create(cls, files):
"""Creates file group and returns ``FileGroup`` instance.
It expects iterable object that contains ``File`` instances, e.g.::
>>> file_1 = File('6c5e9526-b0fe-4739-8975-72e8d5ee6342')
>>> file_2 = File('a771f854-c2cb-408a-8c36-71af77811f3b')
... | [
"Creates",
"file",
"group",
"and",
"returns",
"FileGroup",
"instance",
"."
] | uploadcare/pyuploadcare | python | https://github.com/uploadcare/pyuploadcare/blob/cefddc0306133a71e37b18e8700df5948ef49b37/pyuploadcare/api_resources.py#L732-L758 | [
"def",
"create",
"(",
"cls",
",",
"files",
")",
":",
"data",
"=",
"{",
"}",
"for",
"index",
",",
"file_",
"in",
"enumerate",
"(",
"files",
")",
":",
"if",
"isinstance",
"(",
"file_",
",",
"File",
")",
":",
"file_index",
"=",
"'files[{index}]'",
".",
... | cefddc0306133a71e37b18e8700df5948ef49b37 |
test | FilesStorage._base_opration | Base method for storage operations. | pyuploadcare/api_resources.py | def _base_opration(self, method):
""" Base method for storage operations.
"""
uuids = self.uuids()
while True:
chunk = list(islice(uuids, 0, self.chunk_size))
if not chunk:
return
rest_request(method, self.storage_url, chunk) | def _base_opration(self, method):
""" Base method for storage operations.
"""
uuids = self.uuids()
while True:
chunk = list(islice(uuids, 0, self.chunk_size))
if not chunk:
return
rest_request(method, self.storage_url, chunk) | [
"Base",
"method",
"for",
"storage",
"operations",
"."
] | uploadcare/pyuploadcare | python | https://github.com/uploadcare/pyuploadcare/blob/cefddc0306133a71e37b18e8700df5948ef49b37/pyuploadcare/api_resources.py#L916-L927 | [
"def",
"_base_opration",
"(",
"self",
",",
"method",
")",
":",
"uuids",
"=",
"self",
".",
"uuids",
"(",
")",
"while",
"True",
":",
"chunk",
"=",
"list",
"(",
"islice",
"(",
"uuids",
",",
"0",
",",
"self",
".",
"chunk_size",
")",
")",
"if",
"not",
... | cefddc0306133a71e37b18e8700df5948ef49b37 |
test | FilesStorage.uuids | Extract uuid from each item of specified ``seq``. | pyuploadcare/api_resources.py | def uuids(self):
""" Extract uuid from each item of specified ``seq``.
"""
for f in self._seq:
if isinstance(f, File):
yield f.uuid
elif isinstance(f, six.string_types):
yield f
else:
raise ValueError(
... | def uuids(self):
""" Extract uuid from each item of specified ``seq``.
"""
for f in self._seq:
if isinstance(f, File):
yield f.uuid
elif isinstance(f, six.string_types):
yield f
else:
raise ValueError(
... | [
"Extract",
"uuid",
"from",
"each",
"item",
"of",
"specified",
"seq",
"."
] | uploadcare/pyuploadcare | python | https://github.com/uploadcare/pyuploadcare/blob/cefddc0306133a71e37b18e8700df5948ef49b37/pyuploadcare/api_resources.py#L929-L939 | [
"def",
"uuids",
"(",
"self",
")",
":",
"for",
"f",
"in",
"self",
".",
"_seq",
":",
"if",
"isinstance",
"(",
"f",
",",
"File",
")",
":",
"yield",
"f",
".",
"uuid",
"elif",
"isinstance",
"(",
"f",
",",
"six",
".",
"string_types",
")",
":",
"yield",... | cefddc0306133a71e37b18e8700df5948ef49b37 |
test | _list | A common function for building methods of the "list showing". | pyuploadcare/ucare_cli/__init__.py | def _list(api_list_class, arg_namespace, **extra):
""" A common function for building methods of the "list showing".
"""
if arg_namespace.starting_point:
ordering_field = (arg_namespace.ordering or '').lstrip('-')
if ordering_field in ('', 'datetime_uploaded', 'datetime_created'):
... | def _list(api_list_class, arg_namespace, **extra):
""" A common function for building methods of the "list showing".
"""
if arg_namespace.starting_point:
ordering_field = (arg_namespace.ordering or '').lstrip('-')
if ordering_field in ('', 'datetime_uploaded', 'datetime_created'):
... | [
"A",
"common",
"function",
"for",
"building",
"methods",
"of",
"the",
"list",
"showing",
"."
] | uploadcare/pyuploadcare | python | https://github.com/uploadcare/pyuploadcare/blob/cefddc0306133a71e37b18e8700df5948ef49b37/pyuploadcare/ucare_cli/__init__.py#L38-L59 | [
"def",
"_list",
"(",
"api_list_class",
",",
"arg_namespace",
",",
"*",
"*",
"extra",
")",
":",
"if",
"arg_namespace",
".",
"starting_point",
":",
"ordering_field",
"=",
"(",
"arg_namespace",
".",
"ordering",
"or",
"''",
")",
".",
"lstrip",
"(",
"'-'",
")",... | cefddc0306133a71e37b18e8700df5948ef49b37 |
test | bar | Iterates over the "iter_content" and draws a progress bar to stdout. | pyuploadcare/ucare_cli/utils.py | def bar(iter_content, parts, title=''):
""" Iterates over the "iter_content" and draws a progress bar to stdout.
"""
parts = max(float(parts), 1.0)
cells = 10
progress = 0
step = cells / parts
draw = lambda progress: sys.stdout.write(
'\r[{0:10}] {1:.2f}% {2}'.format(
'#... | def bar(iter_content, parts, title=''):
""" Iterates over the "iter_content" and draws a progress bar to stdout.
"""
parts = max(float(parts), 1.0)
cells = 10
progress = 0
step = cells / parts
draw = lambda progress: sys.stdout.write(
'\r[{0:10}] {1:.2f}% {2}'.format(
'#... | [
"Iterates",
"over",
"the",
"iter_content",
"and",
"draws",
"a",
"progress",
"bar",
"to",
"stdout",
"."
] | uploadcare/pyuploadcare | python | https://github.com/uploadcare/pyuploadcare/blob/cefddc0306133a71e37b18e8700df5948ef49b37/pyuploadcare/ucare_cli/utils.py#L26-L46 | [
"def",
"bar",
"(",
"iter_content",
",",
"parts",
",",
"title",
"=",
"''",
")",
":",
"parts",
"=",
"max",
"(",
"float",
"(",
"parts",
")",
",",
"1.0",
")",
"cells",
"=",
"10",
"progress",
"=",
"0",
"step",
"=",
"cells",
"/",
"parts",
"draw",
"=",
... | cefddc0306133a71e37b18e8700df5948ef49b37 |
test | rest_request | Makes REST API request and returns response as ``dict``.
It provides auth headers as well and takes settings from ``conf`` module.
Make sure that given ``path`` does not contain leading slash.
Usage example::
>>> rest_request('GET', 'files/?limit=10')
{
'next': 'https://api.u... | pyuploadcare/api.py | def rest_request(verb, path, data=None, timeout=conf.DEFAULT,
retry_throttled=conf.DEFAULT):
"""Makes REST API request and returns response as ``dict``.
It provides auth headers as well and takes settings from ``conf`` module.
Make sure that given ``path`` does not contain leading slash.
... | def rest_request(verb, path, data=None, timeout=conf.DEFAULT,
retry_throttled=conf.DEFAULT):
"""Makes REST API request and returns response as ``dict``.
It provides auth headers as well and takes settings from ``conf`` module.
Make sure that given ``path`` does not contain leading slash.
... | [
"Makes",
"REST",
"API",
"request",
"and",
"returns",
"response",
"as",
"dict",
"."
] | uploadcare/pyuploadcare | python | https://github.com/uploadcare/pyuploadcare/blob/cefddc0306133a71e37b18e8700df5948ef49b37/pyuploadcare/api.py#L68-L204 | [
"def",
"rest_request",
"(",
"verb",
",",
"path",
",",
"data",
"=",
"None",
",",
"timeout",
"=",
"conf",
".",
"DEFAULT",
",",
"retry_throttled",
"=",
"conf",
".",
"DEFAULT",
")",
":",
"if",
"retry_throttled",
"is",
"conf",
".",
"DEFAULT",
":",
"retry_thro... | cefddc0306133a71e37b18e8700df5948ef49b37 |
test | uploading_request | Makes Uploading API request and returns response as ``dict``.
It takes settings from ``conf`` module.
Make sure that given ``path`` does not contain leading slash.
Usage example::
>>> file_obj = open('photo.jpg', 'rb')
>>> uploading_request('POST', 'base/', files={'file': file_obj})
... | pyuploadcare/api.py | def uploading_request(verb, path, data=None, files=None, timeout=conf.DEFAULT):
"""Makes Uploading API request and returns response as ``dict``.
It takes settings from ``conf`` module.
Make sure that given ``path`` does not contain leading slash.
Usage example::
>>> file_obj = open('photo.jp... | def uploading_request(verb, path, data=None, files=None, timeout=conf.DEFAULT):
"""Makes Uploading API request and returns response as ``dict``.
It takes settings from ``conf`` module.
Make sure that given ``path`` does not contain leading slash.
Usage example::
>>> file_obj = open('photo.jp... | [
"Makes",
"Uploading",
"API",
"request",
"and",
"returns",
"response",
"as",
"dict",
"."
] | uploadcare/pyuploadcare | python | https://github.com/uploadcare/pyuploadcare/blob/cefddc0306133a71e37b18e8700df5948ef49b37/pyuploadcare/api.py#L207-L260 | [
"def",
"uploading_request",
"(",
"verb",
",",
"path",
",",
"data",
"=",
"None",
",",
"files",
"=",
"None",
",",
"timeout",
"=",
"conf",
".",
"DEFAULT",
")",
":",
"path",
"=",
"path",
".",
"lstrip",
"(",
"'/'",
")",
"url",
"=",
"urljoin",
"(",
"conf... | cefddc0306133a71e37b18e8700df5948ef49b37 |
test | Api.home_mode_set_state | Set the state of Home Mode | synology/api.py | def home_mode_set_state(self, state, **kwargs):
"""Set the state of Home Mode"""
# It appears that surveillance station needs lowercase text
# true/false for the on switch
if state not in (HOME_MODE_ON, HOME_MODE_OFF):
raise ValueError('Invalid home mode state')
api... | def home_mode_set_state(self, state, **kwargs):
"""Set the state of Home Mode"""
# It appears that surveillance station needs lowercase text
# true/false for the on switch
if state not in (HOME_MODE_ON, HOME_MODE_OFF):
raise ValueError('Invalid home mode state')
api... | [
"Set",
"the",
"state",
"of",
"Home",
"Mode"
] | snjoetw/py-synology | python | https://github.com/snjoetw/py-synology/blob/4f7eb0a3a9f86c24ad65993802e6fb11fbaa1f7f/synology/api.py#L99-L120 | [
"def",
"home_mode_set_state",
"(",
"self",
",",
"state",
",",
"*",
"*",
"kwargs",
")",
":",
"# It appears that surveillance station needs lowercase text",
"# true/false for the on switch",
"if",
"state",
"not",
"in",
"(",
"HOME_MODE_ON",
",",
"HOME_MODE_OFF",
")",
":",
... | 4f7eb0a3a9f86c24ad65993802e6fb11fbaa1f7f |
test | Api.home_mode_status | Returns the status of Home Mode | synology/api.py | def home_mode_status(self, **kwargs):
"""Returns the status of Home Mode"""
api = self._api_info['home_mode']
payload = dict({
'api': api['name'],
'method': 'GetInfo',
'version': api['version'],
'_sid': self._sid
}, **kwargs)
respon... | def home_mode_status(self, **kwargs):
"""Returns the status of Home Mode"""
api = self._api_info['home_mode']
payload = dict({
'api': api['name'],
'method': 'GetInfo',
'version': api['version'],
'_sid': self._sid
}, **kwargs)
respon... | [
"Returns",
"the",
"status",
"of",
"Home",
"Mode"
] | snjoetw/py-synology | python | https://github.com/snjoetw/py-synology/blob/4f7eb0a3a9f86c24ad65993802e6fb11fbaa1f7f/synology/api.py#L122-L133 | [
"def",
"home_mode_status",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"api",
"=",
"self",
".",
"_api_info",
"[",
"'home_mode'",
"]",
"payload",
"=",
"dict",
"(",
"{",
"'api'",
":",
"api",
"[",
"'name'",
"]",
",",
"'method'",
":",
"'GetInfo'",
",... | 4f7eb0a3a9f86c24ad65993802e6fb11fbaa1f7f |
test | Api.camera_list | Return a list of cameras. | synology/api.py | def camera_list(self, **kwargs):
"""Return a list of cameras."""
api = self._api_info['camera']
payload = dict({
'_sid': self._sid,
'api': api['name'],
'method': 'List',
'version': api['version'],
}, **kwargs)
response = self._get_j... | def camera_list(self, **kwargs):
"""Return a list of cameras."""
api = self._api_info['camera']
payload = dict({
'_sid': self._sid,
'api': api['name'],
'method': 'List',
'version': api['version'],
}, **kwargs)
response = self._get_j... | [
"Return",
"a",
"list",
"of",
"cameras",
"."
] | snjoetw/py-synology | python | https://github.com/snjoetw/py-synology/blob/4f7eb0a3a9f86c24ad65993802e6fb11fbaa1f7f/synology/api.py#L135-L151 | [
"def",
"camera_list",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"api",
"=",
"self",
".",
"_api_info",
"[",
"'camera'",
"]",
"payload",
"=",
"dict",
"(",
"{",
"'_sid'",
":",
"self",
".",
"_sid",
",",
"'api'",
":",
"api",
"[",
"'name'",
"]",
... | 4f7eb0a3a9f86c24ad65993802e6fb11fbaa1f7f |
test | Api.camera_info | Return a list of cameras matching camera_ids. | synology/api.py | def camera_info(self, camera_ids, **kwargs):
"""Return a list of cameras matching camera_ids."""
api = self._api_info['camera']
payload = dict({
'_sid': self._sid,
'api': api['name'],
'method': 'GetInfo',
'version': api['version'],
'cam... | def camera_info(self, camera_ids, **kwargs):
"""Return a list of cameras matching camera_ids."""
api = self._api_info['camera']
payload = dict({
'_sid': self._sid,
'api': api['name'],
'method': 'GetInfo',
'version': api['version'],
'cam... | [
"Return",
"a",
"list",
"of",
"cameras",
"matching",
"camera_ids",
"."
] | snjoetw/py-synology | python | https://github.com/snjoetw/py-synology/blob/4f7eb0a3a9f86c24ad65993802e6fb11fbaa1f7f/synology/api.py#L153-L170 | [
"def",
"camera_info",
"(",
"self",
",",
"camera_ids",
",",
"*",
"*",
"kwargs",
")",
":",
"api",
"=",
"self",
".",
"_api_info",
"[",
"'camera'",
"]",
"payload",
"=",
"dict",
"(",
"{",
"'_sid'",
":",
"self",
".",
"_sid",
",",
"'api'",
":",
"api",
"["... | 4f7eb0a3a9f86c24ad65993802e6fb11fbaa1f7f |
test | Api.camera_snapshot | Return bytes of camera image. | synology/api.py | def camera_snapshot(self, camera_id, **kwargs):
"""Return bytes of camera image."""
api = self._api_info['camera']
payload = dict({
'_sid': self._sid,
'api': api['name'],
'method': 'GetSnapshot',
'version': api['version'],
'cameraId': c... | def camera_snapshot(self, camera_id, **kwargs):
"""Return bytes of camera image."""
api = self._api_info['camera']
payload = dict({
'_sid': self._sid,
'api': api['name'],
'method': 'GetSnapshot',
'version': api['version'],
'cameraId': c... | [
"Return",
"bytes",
"of",
"camera",
"image",
"."
] | snjoetw/py-synology | python | https://github.com/snjoetw/py-synology/blob/4f7eb0a3a9f86c24ad65993802e6fb11fbaa1f7f/synology/api.py#L172-L184 | [
"def",
"camera_snapshot",
"(",
"self",
",",
"camera_id",
",",
"*",
"*",
"kwargs",
")",
":",
"api",
"=",
"self",
".",
"_api_info",
"[",
"'camera'",
"]",
"payload",
"=",
"dict",
"(",
"{",
"'_sid'",
":",
"self",
".",
"_sid",
",",
"'api'",
":",
"api",
... | 4f7eb0a3a9f86c24ad65993802e6fb11fbaa1f7f |
test | Api.camera_disable | Disable camera. | synology/api.py | def camera_disable(self, camera_id, **kwargs):
"""Disable camera."""
api = self._api_info['camera']
payload = dict({
'_sid': self._sid,
'api': api['name'],
'method': 'Disable',
'version': 9,
'idList': camera_id,
}, **kwargs)
... | def camera_disable(self, camera_id, **kwargs):
"""Disable camera."""
api = self._api_info['camera']
payload = dict({
'_sid': self._sid,
'api': api['name'],
'method': 'Disable',
'version': 9,
'idList': camera_id,
}, **kwargs)
... | [
"Disable",
"camera",
"."
] | snjoetw/py-synology | python | https://github.com/snjoetw/py-synology/blob/4f7eb0a3a9f86c24ad65993802e6fb11fbaa1f7f/synology/api.py#L186-L200 | [
"def",
"camera_disable",
"(",
"self",
",",
"camera_id",
",",
"*",
"*",
"kwargs",
")",
":",
"api",
"=",
"self",
".",
"_api_info",
"[",
"'camera'",
"]",
"payload",
"=",
"dict",
"(",
"{",
"'_sid'",
":",
"self",
".",
"_sid",
",",
"'api'",
":",
"api",
"... | 4f7eb0a3a9f86c24ad65993802e6fb11fbaa1f7f |
test | Api.camera_event_motion_enum | Return motion settings matching camera_id. | synology/api.py | def camera_event_motion_enum(self, camera_id, **kwargs):
"""Return motion settings matching camera_id."""
api = self._api_info['camera_event']
payload = dict({
'_sid': self._sid,
'api': api['name'],
'method': 'MotionEnum',
'version': api['version']... | def camera_event_motion_enum(self, camera_id, **kwargs):
"""Return motion settings matching camera_id."""
api = self._api_info['camera_event']
payload = dict({
'_sid': self._sid,
'api': api['name'],
'method': 'MotionEnum',
'version': api['version']... | [
"Return",
"motion",
"settings",
"matching",
"camera_id",
"."
] | snjoetw/py-synology | python | https://github.com/snjoetw/py-synology/blob/4f7eb0a3a9f86c24ad65993802e6fb11fbaa1f7f/synology/api.py#L216-L228 | [
"def",
"camera_event_motion_enum",
"(",
"self",
",",
"camera_id",
",",
"*",
"*",
"kwargs",
")",
":",
"api",
"=",
"self",
".",
"_api_info",
"[",
"'camera_event'",
"]",
"payload",
"=",
"dict",
"(",
"{",
"'_sid'",
":",
"self",
".",
"_sid",
",",
"'api'",
"... | 4f7eb0a3a9f86c24ad65993802e6fb11fbaa1f7f |
test | Api.camera_event_md_param_save | Update motion settings matching camera_id with keyword args. | synology/api.py | def camera_event_md_param_save(self, camera_id, **kwargs):
"""Update motion settings matching camera_id with keyword args."""
api = self._api_info['camera_event']
payload = dict({
'_sid': self._sid,
'api': api['name'],
'method': 'MDParamSave',
'ver... | def camera_event_md_param_save(self, camera_id, **kwargs):
"""Update motion settings matching camera_id with keyword args."""
api = self._api_info['camera_event']
payload = dict({
'_sid': self._sid,
'api': api['name'],
'method': 'MDParamSave',
'ver... | [
"Update",
"motion",
"settings",
"matching",
"camera_id",
"with",
"keyword",
"args",
"."
] | snjoetw/py-synology | python | https://github.com/snjoetw/py-synology/blob/4f7eb0a3a9f86c24ad65993802e6fb11fbaa1f7f/synology/api.py#L230-L242 | [
"def",
"camera_event_md_param_save",
"(",
"self",
",",
"camera_id",
",",
"*",
"*",
"kwargs",
")",
":",
"api",
"=",
"self",
".",
"_api_info",
"[",
"'camera_event'",
"]",
"payload",
"=",
"dict",
"(",
"{",
"'_sid'",
":",
"self",
".",
"_sid",
",",
"'api'",
... | 4f7eb0a3a9f86c24ad65993802e6fb11fbaa1f7f |
test | SurveillanceStation.update | Update cameras and motion settings with latest from API. | synology/surveillance_station.py | def update(self):
"""Update cameras and motion settings with latest from API."""
cameras = self._api.camera_list()
self._cameras_by_id = {v.camera_id: v for i, v in enumerate(cameras)}
motion_settings = []
for camera_id in self._cameras_by_id.keys():
motion_setting =... | def update(self):
"""Update cameras and motion settings with latest from API."""
cameras = self._api.camera_list()
self._cameras_by_id = {v.camera_id: v for i, v in enumerate(cameras)}
motion_settings = []
for camera_id in self._cameras_by_id.keys():
motion_setting =... | [
"Update",
"cameras",
"and",
"motion",
"settings",
"with",
"latest",
"from",
"API",
"."
] | snjoetw/py-synology | python | https://github.com/snjoetw/py-synology/blob/4f7eb0a3a9f86c24ad65993802e6fb11fbaa1f7f/synology/surveillance_station.py#L19-L30 | [
"def",
"update",
"(",
"self",
")",
":",
"cameras",
"=",
"self",
".",
"_api",
".",
"camera_list",
"(",
")",
"self",
".",
"_cameras_by_id",
"=",
"{",
"v",
".",
"camera_id",
":",
"v",
"for",
"i",
",",
"v",
"in",
"enumerate",
"(",
"cameras",
")",
"}",
... | 4f7eb0a3a9f86c24ad65993802e6fb11fbaa1f7f |
test | SurveillanceStation.set_home_mode | Set the state of Home Mode | synology/surveillance_station.py | def set_home_mode(self, state):
"""Set the state of Home Mode"""
state_parameter = HOME_MODE_OFF
if state:
state_parameter = HOME_MODE_ON
return self._api.home_mode_set_state(state_parameter) | def set_home_mode(self, state):
"""Set the state of Home Mode"""
state_parameter = HOME_MODE_OFF
if state:
state_parameter = HOME_MODE_ON
return self._api.home_mode_set_state(state_parameter) | [
"Set",
"the",
"state",
"of",
"Home",
"Mode"
] | snjoetw/py-synology | python | https://github.com/snjoetw/py-synology/blob/4f7eb0a3a9f86c24ad65993802e6fb11fbaa1f7f/synology/surveillance_station.py#L68-L73 | [
"def",
"set_home_mode",
"(",
"self",
",",
"state",
")",
":",
"state_parameter",
"=",
"HOME_MODE_OFF",
"if",
"state",
":",
"state_parameter",
"=",
"HOME_MODE_ON",
"return",
"self",
".",
"_api",
".",
"home_mode_set_state",
"(",
"state_parameter",
")"
] | 4f7eb0a3a9f86c24ad65993802e6fb11fbaa1f7f |
test | replace_ext | >>> replace_ext('one/two/three.four.doc', '.html')
'one/two/three.four.html'
>>> replace_ext('one/two/three.four.DOC', '.html')
'one/two/three.four.html'
>>> replace_ext('one/two/three.four.DOC', 'html')
'one/two/three.four.html' | docx2html/core.py | def replace_ext(file_path, new_ext):
"""
>>> replace_ext('one/two/three.four.doc', '.html')
'one/two/three.four.html'
>>> replace_ext('one/two/three.four.DOC', '.html')
'one/two/three.four.html'
>>> replace_ext('one/two/three.four.DOC', 'html')
'one/two/three.four.html'
"""
if not ne... | def replace_ext(file_path, new_ext):
"""
>>> replace_ext('one/two/three.four.doc', '.html')
'one/two/three.four.html'
>>> replace_ext('one/two/three.four.DOC', '.html')
'one/two/three.four.html'
>>> replace_ext('one/two/three.four.DOC', 'html')
'one/two/three.four.html'
"""
if not ne... | [
">>>",
"replace_ext",
"(",
"one",
"/",
"two",
"/",
"three",
".",
"four",
".",
"doc",
".",
"html",
")",
"one",
"/",
"two",
"/",
"three",
".",
"four",
".",
"html",
">>>",
"replace_ext",
"(",
"one",
"/",
"two",
"/",
"three",
".",
"four",
".",
"DOC",... | PolicyStat/docx2html | python | https://github.com/PolicyStat/docx2html/blob/2dc4afd1e3a3f2f0b357d0bff903eb58bcc94429/docx2html/core.py#L34-L46 | [
"def",
"replace_ext",
"(",
"file_path",
",",
"new_ext",
")",
":",
"if",
"not",
"new_ext",
".",
"startswith",
"(",
"os",
".",
"extsep",
")",
":",
"new_ext",
"=",
"os",
".",
"extsep",
"+",
"new_ext",
"index",
"=",
"file_path",
".",
"rfind",
"(",
"os",
... | 2dc4afd1e3a3f2f0b357d0bff903eb58bcc94429 |
test | is_last_li | Determine if ``li`` is the last list item for a given list | docx2html/core.py | def is_last_li(li, meta_data, current_numId):
"""
Determine if ``li`` is the last list item for a given list
"""
if not is_li(li, meta_data):
return False
w_namespace = get_namespace(li, 'w')
next_el = li
while True:
# If we run out of element this must be the last list item
... | def is_last_li(li, meta_data, current_numId):
"""
Determine if ``li`` is the last list item for a given list
"""
if not is_li(li, meta_data):
return False
w_namespace = get_namespace(li, 'w')
next_el = li
while True:
# If we run out of element this must be the last list item
... | [
"Determine",
"if",
"li",
"is",
"the",
"last",
"list",
"item",
"for",
"a",
"given",
"list"
] | PolicyStat/docx2html | python | https://github.com/PolicyStat/docx2html/blob/2dc4afd1e3a3f2f0b357d0bff903eb58bcc94429/docx2html/core.py#L266-L289 | [
"def",
"is_last_li",
"(",
"li",
",",
"meta_data",
",",
"current_numId",
")",
":",
"if",
"not",
"is_li",
"(",
"li",
",",
"meta_data",
")",
":",
"return",
"False",
"w_namespace",
"=",
"get_namespace",
"(",
"li",
",",
"'w'",
")",
"next_el",
"=",
"li",
"wh... | 2dc4afd1e3a3f2f0b357d0bff903eb58bcc94429 |
test | get_single_list_nodes_data | Find consecutive li tags that have content that have the same list id. | docx2html/core.py | def get_single_list_nodes_data(li, meta_data):
"""
Find consecutive li tags that have content that have the same list id.
"""
yield li
w_namespace = get_namespace(li, 'w')
current_numId = get_numId(li, w_namespace)
starting_ilvl = get_ilvl(li, w_namespace)
el = li
while True:
... | def get_single_list_nodes_data(li, meta_data):
"""
Find consecutive li tags that have content that have the same list id.
"""
yield li
w_namespace = get_namespace(li, 'w')
current_numId = get_numId(li, w_namespace)
starting_ilvl = get_ilvl(li, w_namespace)
el = li
while True:
... | [
"Find",
"consecutive",
"li",
"tags",
"that",
"have",
"content",
"that",
"have",
"the",
"same",
"list",
"id",
"."
] | PolicyStat/docx2html | python | https://github.com/PolicyStat/docx2html/blob/2dc4afd1e3a3f2f0b357d0bff903eb58bcc94429/docx2html/core.py#L293-L333 | [
"def",
"get_single_list_nodes_data",
"(",
"li",
",",
"meta_data",
")",
":",
"yield",
"li",
"w_namespace",
"=",
"get_namespace",
"(",
"li",
",",
"'w'",
")",
"current_numId",
"=",
"get_numId",
"(",
"li",
",",
"w_namespace",
")",
"starting_ilvl",
"=",
"get_ilvl",... | 2dc4afd1e3a3f2f0b357d0bff903eb58bcc94429 |
test | get_ilvl | The ilvl on an li tag tells the li tag at what level of indentation this
tag is at. This is used to determine if the li tag needs to be nested or
not. | docx2html/core.py | def get_ilvl(li, w_namespace):
"""
The ilvl on an li tag tells the li tag at what level of indentation this
tag is at. This is used to determine if the li tag needs to be nested or
not.
"""
ilvls = li.xpath('.//w:ilvl', namespaces=li.nsmap)
if len(ilvls) == 0:
return -1
return in... | def get_ilvl(li, w_namespace):
"""
The ilvl on an li tag tells the li tag at what level of indentation this
tag is at. This is used to determine if the li tag needs to be nested or
not.
"""
ilvls = li.xpath('.//w:ilvl', namespaces=li.nsmap)
if len(ilvls) == 0:
return -1
return in... | [
"The",
"ilvl",
"on",
"an",
"li",
"tag",
"tells",
"the",
"li",
"tag",
"at",
"what",
"level",
"of",
"indentation",
"this",
"tag",
"is",
"at",
".",
"This",
"is",
"used",
"to",
"determine",
"if",
"the",
"li",
"tag",
"needs",
"to",
"be",
"nested",
"or",
... | PolicyStat/docx2html | python | https://github.com/PolicyStat/docx2html/blob/2dc4afd1e3a3f2f0b357d0bff903eb58bcc94429/docx2html/core.py#L337-L346 | [
"def",
"get_ilvl",
"(",
"li",
",",
"w_namespace",
")",
":",
"ilvls",
"=",
"li",
".",
"xpath",
"(",
"'.//w:ilvl'",
",",
"namespaces",
"=",
"li",
".",
"nsmap",
")",
"if",
"len",
"(",
"ilvls",
")",
"==",
"0",
":",
"return",
"-",
"1",
"return",
"int",
... | 2dc4afd1e3a3f2f0b357d0bff903eb58bcc94429 |
test | get_numId | The numId on an li tag maps to the numbering dictionary along side the ilvl
to determine what the list should look like (unordered, digits, lower
alpha, etc) | docx2html/core.py | def get_numId(li, w_namespace):
"""
The numId on an li tag maps to the numbering dictionary along side the ilvl
to determine what the list should look like (unordered, digits, lower
alpha, etc)
"""
numIds = li.xpath('.//w:numId', namespaces=li.nsmap)
if len(numIds) == 0:
return -1
... | def get_numId(li, w_namespace):
"""
The numId on an li tag maps to the numbering dictionary along side the ilvl
to determine what the list should look like (unordered, digits, lower
alpha, etc)
"""
numIds = li.xpath('.//w:numId', namespaces=li.nsmap)
if len(numIds) == 0:
return -1
... | [
"The",
"numId",
"on",
"an",
"li",
"tag",
"maps",
"to",
"the",
"numbering",
"dictionary",
"along",
"side",
"the",
"ilvl",
"to",
"determine",
"what",
"the",
"list",
"should",
"look",
"like",
"(",
"unordered",
"digits",
"lower",
"alpha",
"etc",
")"
] | PolicyStat/docx2html | python | https://github.com/PolicyStat/docx2html/blob/2dc4afd1e3a3f2f0b357d0bff903eb58bcc94429/docx2html/core.py#L350-L359 | [
"def",
"get_numId",
"(",
"li",
",",
"w_namespace",
")",
":",
"numIds",
"=",
"li",
".",
"xpath",
"(",
"'.//w:numId'",
",",
"namespaces",
"=",
"li",
".",
"nsmap",
")",
"if",
"len",
"(",
"numIds",
")",
"==",
"0",
":",
"return",
"-",
"1",
"return",
"nu... | 2dc4afd1e3a3f2f0b357d0bff903eb58bcc94429 |
test | create_list | Based on the passed in list_type create a list objects (ol/ul). In the
future this function will also deal with what the numbering of an ordered
list should look like. | docx2html/core.py | def create_list(list_type):
"""
Based on the passed in list_type create a list objects (ol/ul). In the
future this function will also deal with what the numbering of an ordered
list should look like.
"""
list_types = {
'bullet': 'ul',
}
el = etree.Element(list_types.get(list_type... | def create_list(list_type):
"""
Based on the passed in list_type create a list objects (ol/ul). In the
future this function will also deal with what the numbering of an ordered
list should look like.
"""
list_types = {
'bullet': 'ul',
}
el = etree.Element(list_types.get(list_type... | [
"Based",
"on",
"the",
"passed",
"in",
"list_type",
"create",
"a",
"list",
"objects",
"(",
"ol",
"/",
"ul",
")",
".",
"In",
"the",
"future",
"this",
"function",
"will",
"also",
"deal",
"with",
"what",
"the",
"numbering",
"of",
"an",
"ordered",
"list",
"... | PolicyStat/docx2html | python | https://github.com/PolicyStat/docx2html/blob/2dc4afd1e3a3f2f0b357d0bff903eb58bcc94429/docx2html/core.py#L362-L389 | [
"def",
"create_list",
"(",
"list_type",
")",
":",
"list_types",
"=",
"{",
"'bullet'",
":",
"'ul'",
",",
"}",
"el",
"=",
"etree",
".",
"Element",
"(",
"list_types",
".",
"get",
"(",
"list_type",
",",
"'ol'",
")",
")",
"# These are the supported list style typ... | 2dc4afd1e3a3f2f0b357d0bff903eb58bcc94429 |
test | get_v_merge | vMerge is what docx uses to denote that a table cell is part of a rowspan.
The first cell to have a vMerge is the start of the rowspan, and the vMerge
will be denoted with 'restart'. If it is anything other than restart then
it is a continuation of another rowspan. | docx2html/core.py | def get_v_merge(tc):
"""
vMerge is what docx uses to denote that a table cell is part of a rowspan.
The first cell to have a vMerge is the start of the rowspan, and the vMerge
will be denoted with 'restart'. If it is anything other than restart then
it is a continuation of another rowspan.
"""
... | def get_v_merge(tc):
"""
vMerge is what docx uses to denote that a table cell is part of a rowspan.
The first cell to have a vMerge is the start of the rowspan, and the vMerge
will be denoted with 'restart'. If it is anything other than restart then
it is a continuation of another rowspan.
"""
... | [
"vMerge",
"is",
"what",
"docx",
"uses",
"to",
"denote",
"that",
"a",
"table",
"cell",
"is",
"part",
"of",
"a",
"rowspan",
".",
"The",
"first",
"cell",
"to",
"have",
"a",
"vMerge",
"is",
"the",
"start",
"of",
"the",
"rowspan",
"and",
"the",
"vMerge",
... | PolicyStat/docx2html | python | https://github.com/PolicyStat/docx2html/blob/2dc4afd1e3a3f2f0b357d0bff903eb58bcc94429/docx2html/core.py#L393-L406 | [
"def",
"get_v_merge",
"(",
"tc",
")",
":",
"if",
"tc",
"is",
"None",
":",
"return",
"None",
"v_merges",
"=",
"tc",
".",
"xpath",
"(",
"'.//w:vMerge'",
",",
"namespaces",
"=",
"tc",
".",
"nsmap",
")",
"if",
"len",
"(",
"v_merges",
")",
"!=",
"1",
":... | 2dc4afd1e3a3f2f0b357d0bff903eb58bcc94429 |
test | get_grid_span | gridSpan is what docx uses to denote that a table cell has a colspan. This
is much more simple than rowspans in that there is a one-to-one mapping
from gridSpan to colspan. | docx2html/core.py | def get_grid_span(tc):
"""
gridSpan is what docx uses to denote that a table cell has a colspan. This
is much more simple than rowspans in that there is a one-to-one mapping
from gridSpan to colspan.
"""
w_namespace = get_namespace(tc, 'w')
grid_spans = tc.xpath('.//w:gridSpan', namespaces=t... | def get_grid_span(tc):
"""
gridSpan is what docx uses to denote that a table cell has a colspan. This
is much more simple than rowspans in that there is a one-to-one mapping
from gridSpan to colspan.
"""
w_namespace = get_namespace(tc, 'w')
grid_spans = tc.xpath('.//w:gridSpan', namespaces=t... | [
"gridSpan",
"is",
"what",
"docx",
"uses",
"to",
"denote",
"that",
"a",
"table",
"cell",
"has",
"a",
"colspan",
".",
"This",
"is",
"much",
"more",
"simple",
"than",
"rowspans",
"in",
"that",
"there",
"is",
"a",
"one",
"-",
"to",
"-",
"one",
"mapping",
... | PolicyStat/docx2html | python | https://github.com/PolicyStat/docx2html/blob/2dc4afd1e3a3f2f0b357d0bff903eb58bcc94429/docx2html/core.py#L410-L421 | [
"def",
"get_grid_span",
"(",
"tc",
")",
":",
"w_namespace",
"=",
"get_namespace",
"(",
"tc",
",",
"'w'",
")",
"grid_spans",
"=",
"tc",
".",
"xpath",
"(",
"'.//w:gridSpan'",
",",
"namespaces",
"=",
"tc",
".",
"nsmap",
")",
"if",
"len",
"(",
"grid_spans",
... | 2dc4afd1e3a3f2f0b357d0bff903eb58bcc94429 |
test | get_td_at_index | When calculating the rowspan for a given cell it is required to find all
table cells 'below' the initial cell with a v_merge. This function will
return the td element at the passed in index, taking into account colspans. | docx2html/core.py | def get_td_at_index(tr, index):
"""
When calculating the rowspan for a given cell it is required to find all
table cells 'below' the initial cell with a v_merge. This function will
return the td element at the passed in index, taking into account colspans.
"""
current = 0
for td in tr.xpath(... | def get_td_at_index(tr, index):
"""
When calculating the rowspan for a given cell it is required to find all
table cells 'below' the initial cell with a v_merge. This function will
return the td element at the passed in index, taking into account colspans.
"""
current = 0
for td in tr.xpath(... | [
"When",
"calculating",
"the",
"rowspan",
"for",
"a",
"given",
"cell",
"it",
"is",
"required",
"to",
"find",
"all",
"table",
"cells",
"below",
"the",
"initial",
"cell",
"with",
"a",
"v_merge",
".",
"This",
"function",
"will",
"return",
"the",
"td",
"element... | PolicyStat/docx2html | python | https://github.com/PolicyStat/docx2html/blob/2dc4afd1e3a3f2f0b357d0bff903eb58bcc94429/docx2html/core.py#L425-L435 | [
"def",
"get_td_at_index",
"(",
"tr",
",",
"index",
")",
":",
"current",
"=",
"0",
"for",
"td",
"in",
"tr",
".",
"xpath",
"(",
"'.//w:tc'",
",",
"namespaces",
"=",
"tr",
".",
"nsmap",
")",
":",
"if",
"index",
"==",
"current",
":",
"return",
"td",
"c... | 2dc4afd1e3a3f2f0b357d0bff903eb58bcc94429 |
test | style_is_false | For bold, italics and underline. Simply checking to see if the various tags
are present will not suffice. If the tag is present and set to False then
the style should not be present. | docx2html/core.py | def style_is_false(style):
"""
For bold, italics and underline. Simply checking to see if the various tags
are present will not suffice. If the tag is present and set to False then
the style should not be present.
"""
if style is None:
return False
w_namespace = get_namespace(style, ... | def style_is_false(style):
"""
For bold, italics and underline. Simply checking to see if the various tags
are present will not suffice. If the tag is present and set to False then
the style should not be present.
"""
if style is None:
return False
w_namespace = get_namespace(style, ... | [
"For",
"bold",
"italics",
"and",
"underline",
".",
"Simply",
"checking",
"to",
"see",
"if",
"the",
"various",
"tags",
"are",
"present",
"will",
"not",
"suffice",
".",
"If",
"the",
"tag",
"is",
"present",
"and",
"set",
"to",
"False",
"then",
"the",
"style... | PolicyStat/docx2html | python | https://github.com/PolicyStat/docx2html/blob/2dc4afd1e3a3f2f0b357d0bff903eb58bcc94429/docx2html/core.py#L494-L503 | [
"def",
"style_is_false",
"(",
"style",
")",
":",
"if",
"style",
"is",
"None",
":",
"return",
"False",
"w_namespace",
"=",
"get_namespace",
"(",
"style",
",",
"'w'",
")",
"return",
"style",
".",
"get",
"(",
"'%sval'",
"%",
"w_namespace",
")",
"!=",
"'fals... | 2dc4afd1e3a3f2f0b357d0bff903eb58bcc94429 |
test | is_bold | The function will return True if the r tag passed in is considered bold. | docx2html/core.py | def is_bold(r):
"""
The function will return True if the r tag passed in is considered bold.
"""
w_namespace = get_namespace(r, 'w')
rpr = r.find('%srPr' % w_namespace)
if rpr is None:
return False
bold = rpr.find('%sb' % w_namespace)
return style_is_false(bold) | def is_bold(r):
"""
The function will return True if the r tag passed in is considered bold.
"""
w_namespace = get_namespace(r, 'w')
rpr = r.find('%srPr' % w_namespace)
if rpr is None:
return False
bold = rpr.find('%sb' % w_namespace)
return style_is_false(bold) | [
"The",
"function",
"will",
"return",
"True",
"if",
"the",
"r",
"tag",
"passed",
"in",
"is",
"considered",
"bold",
"."
] | PolicyStat/docx2html | python | https://github.com/PolicyStat/docx2html/blob/2dc4afd1e3a3f2f0b357d0bff903eb58bcc94429/docx2html/core.py#L507-L516 | [
"def",
"is_bold",
"(",
"r",
")",
":",
"w_namespace",
"=",
"get_namespace",
"(",
"r",
",",
"'w'",
")",
"rpr",
"=",
"r",
".",
"find",
"(",
"'%srPr'",
"%",
"w_namespace",
")",
"if",
"rpr",
"is",
"None",
":",
"return",
"False",
"bold",
"=",
"rpr",
".",... | 2dc4afd1e3a3f2f0b357d0bff903eb58bcc94429 |
test | is_italics | The function will return True if the r tag passed in is considered
italicized. | docx2html/core.py | def is_italics(r):
"""
The function will return True if the r tag passed in is considered
italicized.
"""
w_namespace = get_namespace(r, 'w')
rpr = r.find('%srPr' % w_namespace)
if rpr is None:
return False
italics = rpr.find('%si' % w_namespace)
return style_is_false(italics... | def is_italics(r):
"""
The function will return True if the r tag passed in is considered
italicized.
"""
w_namespace = get_namespace(r, 'w')
rpr = r.find('%srPr' % w_namespace)
if rpr is None:
return False
italics = rpr.find('%si' % w_namespace)
return style_is_false(italics... | [
"The",
"function",
"will",
"return",
"True",
"if",
"the",
"r",
"tag",
"passed",
"in",
"is",
"considered",
"italicized",
"."
] | PolicyStat/docx2html | python | https://github.com/PolicyStat/docx2html/blob/2dc4afd1e3a3f2f0b357d0bff903eb58bcc94429/docx2html/core.py#L520-L530 | [
"def",
"is_italics",
"(",
"r",
")",
":",
"w_namespace",
"=",
"get_namespace",
"(",
"r",
",",
"'w'",
")",
"rpr",
"=",
"r",
".",
"find",
"(",
"'%srPr'",
"%",
"w_namespace",
")",
"if",
"rpr",
"is",
"None",
":",
"return",
"False",
"italics",
"=",
"rpr",
... | 2dc4afd1e3a3f2f0b357d0bff903eb58bcc94429 |
test | is_underlined | The function will return True if the r tag passed in is considered
underlined. | docx2html/core.py | def is_underlined(r):
"""
The function will return True if the r tag passed in is considered
underlined.
"""
w_namespace = get_namespace(r, 'w')
rpr = r.find('%srPr' % w_namespace)
if rpr is None:
return False
underline = rpr.find('%su' % w_namespace)
return style_is_false(un... | def is_underlined(r):
"""
The function will return True if the r tag passed in is considered
underlined.
"""
w_namespace = get_namespace(r, 'w')
rpr = r.find('%srPr' % w_namespace)
if rpr is None:
return False
underline = rpr.find('%su' % w_namespace)
return style_is_false(un... | [
"The",
"function",
"will",
"return",
"True",
"if",
"the",
"r",
"tag",
"passed",
"in",
"is",
"considered",
"underlined",
"."
] | PolicyStat/docx2html | python | https://github.com/PolicyStat/docx2html/blob/2dc4afd1e3a3f2f0b357d0bff903eb58bcc94429/docx2html/core.py#L534-L544 | [
"def",
"is_underlined",
"(",
"r",
")",
":",
"w_namespace",
"=",
"get_namespace",
"(",
"r",
",",
"'w'",
")",
"rpr",
"=",
"r",
".",
"find",
"(",
"'%srPr'",
"%",
"w_namespace",
")",
"if",
"rpr",
"is",
"None",
":",
"return",
"False",
"underline",
"=",
"r... | 2dc4afd1e3a3f2f0b357d0bff903eb58bcc94429 |
test | is_title | Certain p tags are denoted as ``Title`` tags. This function will return
True if the passed in p tag is considered a title. | docx2html/core.py | def is_title(p):
"""
Certain p tags are denoted as ``Title`` tags. This function will return
True if the passed in p tag is considered a title.
"""
w_namespace = get_namespace(p, 'w')
styles = p.xpath('.//w:pStyle', namespaces=p.nsmap)
if len(styles) == 0:
return False
style = st... | def is_title(p):
"""
Certain p tags are denoted as ``Title`` tags. This function will return
True if the passed in p tag is considered a title.
"""
w_namespace = get_namespace(p, 'w')
styles = p.xpath('.//w:pStyle', namespaces=p.nsmap)
if len(styles) == 0:
return False
style = st... | [
"Certain",
"p",
"tags",
"are",
"denoted",
"as",
"Title",
"tags",
".",
"This",
"function",
"will",
"return",
"True",
"if",
"the",
"passed",
"in",
"p",
"tag",
"is",
"considered",
"a",
"title",
"."
] | PolicyStat/docx2html | python | https://github.com/PolicyStat/docx2html/blob/2dc4afd1e3a3f2f0b357d0bff903eb58bcc94429/docx2html/core.py#L548-L558 | [
"def",
"is_title",
"(",
"p",
")",
":",
"w_namespace",
"=",
"get_namespace",
"(",
"p",
",",
"'w'",
")",
"styles",
"=",
"p",
".",
"xpath",
"(",
"'.//w:pStyle'",
",",
"namespaces",
"=",
"p",
".",
"nsmap",
")",
"if",
"len",
"(",
"styles",
")",
"==",
"0... | 2dc4afd1e3a3f2f0b357d0bff903eb58bcc94429 |
test | get_text_run_content_data | It turns out that r tags can contain both t tags and drawing tags. Since we
need both, this function will return them in the order in which they are
found. | docx2html/core.py | def get_text_run_content_data(r):
"""
It turns out that r tags can contain both t tags and drawing tags. Since we
need both, this function will return them in the order in which they are
found.
"""
w_namespace = get_namespace(r, 'w')
valid_elements = (
'%st' % w_namespace,
'%... | def get_text_run_content_data(r):
"""
It turns out that r tags can contain both t tags and drawing tags. Since we
need both, this function will return them in the order in which they are
found.
"""
w_namespace = get_namespace(r, 'w')
valid_elements = (
'%st' % w_namespace,
'%... | [
"It",
"turns",
"out",
"that",
"r",
"tags",
"can",
"contain",
"both",
"t",
"tags",
"and",
"drawing",
"tags",
".",
"Since",
"we",
"need",
"both",
"this",
"function",
"will",
"return",
"them",
"in",
"the",
"order",
"in",
"which",
"they",
"are",
"found",
"... | PolicyStat/docx2html | python | https://github.com/PolicyStat/docx2html/blob/2dc4afd1e3a3f2f0b357d0bff903eb58bcc94429/docx2html/core.py#L562-L577 | [
"def",
"get_text_run_content_data",
"(",
"r",
")",
":",
"w_namespace",
"=",
"get_namespace",
"(",
"r",
",",
"'w'",
")",
"valid_elements",
"=",
"(",
"'%st'",
"%",
"w_namespace",
",",
"'%sdrawing'",
"%",
"w_namespace",
",",
"'%spict'",
"%",
"w_namespace",
",",
... | 2dc4afd1e3a3f2f0b357d0bff903eb58bcc94429 |
test | whole_line_styled | Checks to see if the whole p tag will end up being bold or italics. Returns
a tuple (boolean, boolean). The first boolean will be True if the whole
line is bold, False otherwise. The second boolean will be True if the whole
line is italics, False otherwise. | docx2html/core.py | def whole_line_styled(p):
"""
Checks to see if the whole p tag will end up being bold or italics. Returns
a tuple (boolean, boolean). The first boolean will be True if the whole
line is bold, False otherwise. The second boolean will be True if the whole
line is italics, False otherwise.
"""
... | def whole_line_styled(p):
"""
Checks to see if the whole p tag will end up being bold or italics. Returns
a tuple (boolean, boolean). The first boolean will be True if the whole
line is bold, False otherwise. The second boolean will be True if the whole
line is italics, False otherwise.
"""
... | [
"Checks",
"to",
"see",
"if",
"the",
"whole",
"p",
"tag",
"will",
"end",
"up",
"being",
"bold",
"or",
"italics",
".",
"Returns",
"a",
"tuple",
"(",
"boolean",
"boolean",
")",
".",
"The",
"first",
"boolean",
"will",
"be",
"True",
"if",
"the",
"whole",
... | PolicyStat/docx2html | python | https://github.com/PolicyStat/docx2html/blob/2dc4afd1e3a3f2f0b357d0bff903eb58bcc94429/docx2html/core.py#L599-L613 | [
"def",
"whole_line_styled",
"(",
"p",
")",
":",
"r_tags",
"=",
"p",
".",
"xpath",
"(",
"'.//w:r'",
",",
"namespaces",
"=",
"p",
".",
"nsmap",
")",
"tags_are_bold",
"=",
"[",
"is_bold",
"(",
"r",
")",
"or",
"is_underlined",
"(",
"r",
")",
"for",
"r",
... | 2dc4afd1e3a3f2f0b357d0bff903eb58bcc94429 |
test | get_numbering_info | There is a separate file called numbering.xml that stores how lists should
look (unordered, digits, lower case letters, etc.). Parse that file and
return a dictionary of what each combination should be based on list Id and
level of indentation. | docx2html/core.py | def get_numbering_info(tree):
"""
There is a separate file called numbering.xml that stores how lists should
look (unordered, digits, lower case letters, etc.). Parse that file and
return a dictionary of what each combination should be based on list Id and
level of indentation.
"""
if tree i... | def get_numbering_info(tree):
"""
There is a separate file called numbering.xml that stores how lists should
look (unordered, digits, lower case letters, etc.). Parse that file and
return a dictionary of what each combination should be based on list Id and
level of indentation.
"""
if tree i... | [
"There",
"is",
"a",
"separate",
"file",
"called",
"numbering",
".",
"xml",
"that",
"stores",
"how",
"lists",
"should",
"look",
"(",
"unordered",
"digits",
"lower",
"case",
"letters",
"etc",
".",
")",
".",
"Parse",
"that",
"file",
"and",
"return",
"a",
"d... | PolicyStat/docx2html | python | https://github.com/PolicyStat/docx2html/blob/2dc4afd1e3a3f2f0b357d0bff903eb58bcc94429/docx2html/core.py#L634-L671 | [
"def",
"get_numbering_info",
"(",
"tree",
")",
":",
"if",
"tree",
"is",
"None",
":",
"return",
"{",
"}",
"w_namespace",
"=",
"get_namespace",
"(",
"tree",
",",
"'w'",
")",
"num_ids",
"=",
"{",
"}",
"result",
"=",
"defaultdict",
"(",
"dict",
")",
"# Fir... | 2dc4afd1e3a3f2f0b357d0bff903eb58bcc94429 |
test | get_style_dict | Some things that are considered lists are actually supposed to be H tags
(h1, h2, etc.) These can be denoted by their styleId | docx2html/core.py | def get_style_dict(tree):
"""
Some things that are considered lists are actually supposed to be H tags
(h1, h2, etc.) These can be denoted by their styleId
"""
# This is a partial document and actual h1 is the document title, which
# will be displayed elsewhere.
headers = {
'heading ... | def get_style_dict(tree):
"""
Some things that are considered lists are actually supposed to be H tags
(h1, h2, etc.) These can be denoted by their styleId
"""
# This is a partial document and actual h1 is the document title, which
# will be displayed elsewhere.
headers = {
'heading ... | [
"Some",
"things",
"that",
"are",
"considered",
"lists",
"are",
"actually",
"supposed",
"to",
"be",
"H",
"tags",
"(",
"h1",
"h2",
"etc",
".",
")",
"These",
"can",
"be",
"denoted",
"by",
"their",
"styleId"
] | PolicyStat/docx2html | python | https://github.com/PolicyStat/docx2html/blob/2dc4afd1e3a3f2f0b357d0bff903eb58bcc94429/docx2html/core.py#L674-L729 | [
"def",
"get_style_dict",
"(",
"tree",
")",
":",
"# This is a partial document and actual h1 is the document title, which",
"# will be displayed elsewhere.",
"headers",
"=",
"{",
"'heading 1'",
":",
"'h2'",
",",
"'heading 2'",
":",
"'h3'",
",",
"'heading 3'",
":",
"'h4'",
... | 2dc4afd1e3a3f2f0b357d0bff903eb58bcc94429 |
test | get_relationship_info | There is a separate file holds the targets to links as well as the targets
for images. Return a dictionary based on the relationship id and the
target. | docx2html/core.py | def get_relationship_info(tree, media, image_sizes):
"""
There is a separate file holds the targets to links as well as the targets
for images. Return a dictionary based on the relationship id and the
target.
"""
if tree is None:
return {}
result = {}
# Loop through each relation... | def get_relationship_info(tree, media, image_sizes):
"""
There is a separate file holds the targets to links as well as the targets
for images. Return a dictionary based on the relationship id and the
target.
"""
if tree is None:
return {}
result = {}
# Loop through each relation... | [
"There",
"is",
"a",
"separate",
"file",
"holds",
"the",
"targets",
"to",
"links",
"as",
"well",
"as",
"the",
"targets",
"for",
"images",
".",
"Return",
"a",
"dictionary",
"based",
"on",
"the",
"relationship",
"id",
"and",
"the",
"target",
"."
] | PolicyStat/docx2html | python | https://github.com/PolicyStat/docx2html/blob/2dc4afd1e3a3f2f0b357d0bff903eb58bcc94429/docx2html/core.py#L752-L778 | [
"def",
"get_relationship_info",
"(",
"tree",
",",
"media",
",",
"image_sizes",
")",
":",
"if",
"tree",
"is",
"None",
":",
"return",
"{",
"}",
"result",
"=",
"{",
"}",
"# Loop through each relationship.",
"for",
"el",
"in",
"tree",
".",
"iter",
"(",
")",
... | 2dc4afd1e3a3f2f0b357d0bff903eb58bcc94429 |
test | _get_document_data | ``f`` is a ``ZipFile`` that is open
Extract out the document data, numbering data and the relationship data. | docx2html/core.py | def _get_document_data(f, image_handler=None):
'''
``f`` is a ``ZipFile`` that is open
Extract out the document data, numbering data and the relationship data.
'''
if image_handler is None:
def image_handler(image_id, relationship_dict):
return relationship_dict.get(image_id)
... | def _get_document_data(f, image_handler=None):
'''
``f`` is a ``ZipFile`` that is open
Extract out the document data, numbering data and the relationship data.
'''
if image_handler is None:
def image_handler(image_id, relationship_dict):
return relationship_dict.get(image_id)
... | [
"f",
"is",
"a",
"ZipFile",
"that",
"is",
"open",
"Extract",
"out",
"the",
"document",
"data",
"numbering",
"data",
"and",
"the",
"relationship",
"data",
"."
] | PolicyStat/docx2html | python | https://github.com/PolicyStat/docx2html/blob/2dc4afd1e3a3f2f0b357d0bff903eb58bcc94429/docx2html/core.py#L816-L882 | [
"def",
"_get_document_data",
"(",
"f",
",",
"image_handler",
"=",
"None",
")",
":",
"if",
"image_handler",
"is",
"None",
":",
"def",
"image_handler",
"(",
"image_id",
",",
"relationship_dict",
")",
":",
"return",
"relationship_dict",
".",
"get",
"(",
"image_id... | 2dc4afd1e3a3f2f0b357d0bff903eb58bcc94429 |
test | get_ordered_list_type | Return the list type. If numId or ilvl not in the numbering dict then
default to returning decimal.
This function only cares about ordered lists, unordered lists get dealt
with elsewhere. | docx2html/core.py | def get_ordered_list_type(meta_data, numId, ilvl):
"""
Return the list type. If numId or ilvl not in the numbering dict then
default to returning decimal.
This function only cares about ordered lists, unordered lists get dealt
with elsewhere.
"""
# Early return if numId or ilvl are not val... | def get_ordered_list_type(meta_data, numId, ilvl):
"""
Return the list type. If numId or ilvl not in the numbering dict then
default to returning decimal.
This function only cares about ordered lists, unordered lists get dealt
with elsewhere.
"""
# Early return if numId or ilvl are not val... | [
"Return",
"the",
"list",
"type",
".",
"If",
"numId",
"or",
"ilvl",
"not",
"in",
"the",
"numbering",
"dict",
"then",
"default",
"to",
"returning",
"decimal",
"."
] | PolicyStat/docx2html | python | https://github.com/PolicyStat/docx2html/blob/2dc4afd1e3a3f2f0b357d0bff903eb58bcc94429/docx2html/core.py#L890-L905 | [
"def",
"get_ordered_list_type",
"(",
"meta_data",
",",
"numId",
",",
"ilvl",
")",
":",
"# Early return if numId or ilvl are not valid",
"numbering_dict",
"=",
"meta_data",
".",
"numbering_dict",
"if",
"numId",
"not",
"in",
"numbering_dict",
":",
"return",
"DEFAULT_LIST_... | 2dc4afd1e3a3f2f0b357d0bff903eb58bcc94429 |
test | build_list | Build the list structure and return the root list | docx2html/core.py | def build_list(li_nodes, meta_data):
"""
Build the list structure and return the root list
"""
# Need to keep track of all incomplete nested lists.
ol_dict = {}
# Need to keep track of the current indentation level.
current_ilvl = -1
# Need to keep track of the current list id.
cur... | def build_list(li_nodes, meta_data):
"""
Build the list structure and return the root list
"""
# Need to keep track of all incomplete nested lists.
ol_dict = {}
# Need to keep track of the current indentation level.
current_ilvl = -1
# Need to keep track of the current list id.
cur... | [
"Build",
"the",
"list",
"structure",
"and",
"return",
"the",
"root",
"list"
] | PolicyStat/docx2html | python | https://github.com/PolicyStat/docx2html/blob/2dc4afd1e3a3f2f0b357d0bff903eb58bcc94429/docx2html/core.py#L908-L1048 | [
"def",
"build_list",
"(",
"li_nodes",
",",
"meta_data",
")",
":",
"# Need to keep track of all incomplete nested lists.",
"ol_dict",
"=",
"{",
"}",
"# Need to keep track of the current indentation level.",
"current_ilvl",
"=",
"-",
"1",
"# Need to keep track of the current list i... | 2dc4afd1e3a3f2f0b357d0bff903eb58bcc94429 |
test | build_tr | This will return a single tr element, with all tds already populated. | docx2html/core.py | def build_tr(tr, meta_data, row_spans):
"""
This will return a single tr element, with all tds already populated.
"""
# Create a blank tr element.
tr_el = etree.Element('tr')
w_namespace = get_namespace(tr, 'w')
visited_nodes = []
for el in tr:
if el in visited_nodes:
... | def build_tr(tr, meta_data, row_spans):
"""
This will return a single tr element, with all tds already populated.
"""
# Create a blank tr element.
tr_el = etree.Element('tr')
w_namespace = get_namespace(tr, 'w')
visited_nodes = []
for el in tr:
if el in visited_nodes:
... | [
"This",
"will",
"return",
"a",
"single",
"tr",
"element",
"with",
"all",
"tds",
"already",
"populated",
"."
] | PolicyStat/docx2html | python | https://github.com/PolicyStat/docx2html/blob/2dc4afd1e3a3f2f0b357d0bff903eb58bcc94429/docx2html/core.py#L1052-L1133 | [
"def",
"build_tr",
"(",
"tr",
",",
"meta_data",
",",
"row_spans",
")",
":",
"# Create a blank tr element.",
"tr_el",
"=",
"etree",
".",
"Element",
"(",
"'tr'",
")",
"w_namespace",
"=",
"get_namespace",
"(",
"tr",
",",
"'w'",
")",
"visited_nodes",
"=",
"[",
... | 2dc4afd1e3a3f2f0b357d0bff903eb58bcc94429 |
test | build_table | This returns a table object with all rows and cells correctly populated. | docx2html/core.py | def build_table(table, meta_data):
"""
This returns a table object with all rows and cells correctly populated.
"""
# Create a blank table element.
table_el = etree.Element('table')
w_namespace = get_namespace(table, 'w')
# Get the rowspan values for cells that have a rowspan.
row_span... | def build_table(table, meta_data):
"""
This returns a table object with all rows and cells correctly populated.
"""
# Create a blank table element.
table_el = etree.Element('table')
w_namespace = get_namespace(table, 'w')
# Get the rowspan values for cells that have a rowspan.
row_span... | [
"This",
"returns",
"a",
"table",
"object",
"with",
"all",
"rows",
"and",
"cells",
"correctly",
"populated",
"."
] | PolicyStat/docx2html | python | https://github.com/PolicyStat/docx2html/blob/2dc4afd1e3a3f2f0b357d0bff903eb58bcc94429/docx2html/core.py#L1137-L1160 | [
"def",
"build_table",
"(",
"table",
",",
"meta_data",
")",
":",
"# Create a blank table element.",
"table_el",
"=",
"etree",
".",
"Element",
"(",
"'table'",
")",
"w_namespace",
"=",
"get_namespace",
"(",
"table",
",",
"'w'",
")",
"# Get the rowspan values for cells ... | 2dc4afd1e3a3f2f0b357d0bff903eb58bcc94429 |
test | get_t_tag_content | Generate the string data that for this particular t tag. | docx2html/core.py | def get_t_tag_content(
t, parent, remove_bold, remove_italics, meta_data):
"""
Generate the string data that for this particular t tag.
"""
if t is None or t.text is None:
return ''
# Need to escape the text so that we do not accidentally put in text
# that is not valid XML.
... | def get_t_tag_content(
t, parent, remove_bold, remove_italics, meta_data):
"""
Generate the string data that for this particular t tag.
"""
if t is None or t.text is None:
return ''
# Need to escape the text so that we do not accidentally put in text
# that is not valid XML.
... | [
"Generate",
"the",
"string",
"data",
"that",
"for",
"this",
"particular",
"t",
"tag",
"."
] | PolicyStat/docx2html | python | https://github.com/PolicyStat/docx2html/blob/2dc4afd1e3a3f2f0b357d0bff903eb58bcc94429/docx2html/core.py#L1164-L1188 | [
"def",
"get_t_tag_content",
"(",
"t",
",",
"parent",
",",
"remove_bold",
",",
"remove_italics",
",",
"meta_data",
")",
":",
"if",
"t",
"is",
"None",
"or",
"t",
".",
"text",
"is",
"None",
":",
"return",
"''",
"# Need to escape the text so that we do not accidenta... | 2dc4afd1e3a3f2f0b357d0bff903eb58bcc94429 |
test | get_element_content | P tags are made up of several runs (r tags) of text. This function takes a
p tag and constructs the text that should be part of the p tag.
image_handler should be a callable that returns the desired ``src``
attribute for a given image. | docx2html/core.py | def get_element_content(
p,
meta_data,
is_td=False,
remove_italics=False,
remove_bold=False,
):
"""
P tags are made up of several runs (r tags) of text. This function takes a
p tag and constructs the text that should be part of the p tag.
image_handler should be ... | def get_element_content(
p,
meta_data,
is_td=False,
remove_italics=False,
remove_bold=False,
):
"""
P tags are made up of several runs (r tags) of text. This function takes a
p tag and constructs the text that should be part of the p tag.
image_handler should be ... | [
"P",
"tags",
"are",
"made",
"up",
"of",
"several",
"runs",
"(",
"r",
"tags",
")",
"of",
"text",
".",
"This",
"function",
"takes",
"a",
"p",
"tag",
"and",
"constructs",
"the",
"text",
"that",
"should",
"be",
"part",
"of",
"the",
"p",
"tag",
"."
] | PolicyStat/docx2html | python | https://github.com/PolicyStat/docx2html/blob/2dc4afd1e3a3f2f0b357d0bff903eb58bcc94429/docx2html/core.py#L1272-L1341 | [
"def",
"get_element_content",
"(",
"p",
",",
"meta_data",
",",
"is_td",
"=",
"False",
",",
"remove_italics",
"=",
"False",
",",
"remove_bold",
"=",
"False",
",",
")",
":",
"# Only remove bold or italics if this tag is an h tag.",
"# Td elements have the same look and feel... | 2dc4afd1e3a3f2f0b357d0bff903eb58bcc94429 |
test | _strip_tag | Remove all tags that have the tag name ``tag`` | docx2html/core.py | def _strip_tag(tree, tag):
"""
Remove all tags that have the tag name ``tag``
"""
for el in tree.iter():
if el.tag == tag:
el.getparent().remove(el) | def _strip_tag(tree, tag):
"""
Remove all tags that have the tag name ``tag``
"""
for el in tree.iter():
if el.tag == tag:
el.getparent().remove(el) | [
"Remove",
"all",
"tags",
"that",
"have",
"the",
"tag",
"name",
"tag"
] | PolicyStat/docx2html | python | https://github.com/PolicyStat/docx2html/blob/2dc4afd1e3a3f2f0b357d0bff903eb58bcc94429/docx2html/core.py#L1344-L1350 | [
"def",
"_strip_tag",
"(",
"tree",
",",
"tag",
")",
":",
"for",
"el",
"in",
"tree",
".",
"iter",
"(",
")",
":",
"if",
"el",
".",
"tag",
"==",
"tag",
":",
"el",
".",
"getparent",
"(",
")",
".",
"remove",
"(",
"el",
")"
] | 2dc4afd1e3a3f2f0b357d0bff903eb58bcc94429 |
test | convert | ``file_path`` is a path to the file on the file system that you want to be
converted to html.
``image_handler`` is a function that takes an image_id and a
relationship_dict to generate the src attribute for images. (see readme
for more details)
``fall_back`` is a function that takes a ``... | docx2html/core.py | def convert(file_path, image_handler=None, fall_back=None, converter=None):
"""
``file_path`` is a path to the file on the file system that you want to be
converted to html.
``image_handler`` is a function that takes an image_id and a
relationship_dict to generate the src attribute for image... | def convert(file_path, image_handler=None, fall_back=None, converter=None):
"""
``file_path`` is a path to the file on the file system that you want to be
converted to html.
``image_handler`` is a function that takes an image_id and a
relationship_dict to generate the src attribute for image... | [
"file_path",
"is",
"a",
"path",
"to",
"the",
"file",
"on",
"the",
"file",
"system",
"that",
"you",
"want",
"to",
"be",
"converted",
"to",
"html",
".",
"image_handler",
"is",
"a",
"function",
"that",
"takes",
"an",
"image_id",
"and",
"a",
"relationship_dict... | PolicyStat/docx2html | python | https://github.com/PolicyStat/docx2html/blob/2dc4afd1e3a3f2f0b357d0bff903eb58bcc94429/docx2html/core.py#L1363-L1406 | [
"def",
"convert",
"(",
"file_path",
",",
"image_handler",
"=",
"None",
",",
"fall_back",
"=",
"None",
",",
"converter",
"=",
"None",
")",
":",
"file_base",
",",
"extension",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"os",
".",
"path",
".",
"basenam... | 2dc4afd1e3a3f2f0b357d0bff903eb58bcc94429 |
test | find | Find the location of a dataset on disk, downloading if needed. | examples/utils.py | def find(dataset, url):
'''Find the location of a dataset on disk, downloading if needed.'''
fn = os.path.join(DATASETS, dataset)
dn = os.path.dirname(fn)
if not os.path.exists(dn):
print('creating dataset directory: %s', dn)
os.makedirs(dn)
if not os.path.exists(fn):
if sys.... | def find(dataset, url):
'''Find the location of a dataset on disk, downloading if needed.'''
fn = os.path.join(DATASETS, dataset)
dn = os.path.dirname(fn)
if not os.path.exists(dn):
print('creating dataset directory: %s', dn)
os.makedirs(dn)
if not os.path.exists(fn):
if sys.... | [
"Find",
"the",
"location",
"of",
"a",
"dataset",
"on",
"disk",
"downloading",
"if",
"needed",
"."
] | lmjohns3/theanets | python | https://github.com/lmjohns3/theanets/blob/79db9f878ef2071f2f576a1cf5d43a752a55894a/examples/utils.py#L18-L30 | [
"def",
"find",
"(",
"dataset",
",",
"url",
")",
":",
"fn",
"=",
"os",
".",
"path",
".",
"join",
"(",
"DATASETS",
",",
"dataset",
")",
"dn",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"fn",
")",
"if",
"not",
"os",
".",
"path",
".",
"exists",
... | 79db9f878ef2071f2f576a1cf5d43a752a55894a |
test | load_mnist | Load the MNIST digits dataset. | examples/utils.py | def load_mnist(flatten=True, labels=False):
'''Load the MNIST digits dataset.'''
fn = find('mnist.pkl.gz', 'http://deeplearning.net/data/mnist/mnist.pkl.gz')
h = gzip.open(fn, 'rb')
if sys.version_info < (3, ):
(timg, tlab), (vimg, vlab), (simg, slab) = pickle.load(h)
else:
(timg, tl... | def load_mnist(flatten=True, labels=False):
'''Load the MNIST digits dataset.'''
fn = find('mnist.pkl.gz', 'http://deeplearning.net/data/mnist/mnist.pkl.gz')
h = gzip.open(fn, 'rb')
if sys.version_info < (3, ):
(timg, tlab), (vimg, vlab), (simg, slab) = pickle.load(h)
else:
(timg, tl... | [
"Load",
"the",
"MNIST",
"digits",
"dataset",
"."
] | lmjohns3/theanets | python | https://github.com/lmjohns3/theanets/blob/79db9f878ef2071f2f576a1cf5d43a752a55894a/examples/utils.py#L33-L50 | [
"def",
"load_mnist",
"(",
"flatten",
"=",
"True",
",",
"labels",
"=",
"False",
")",
":",
"fn",
"=",
"find",
"(",
"'mnist.pkl.gz'",
",",
"'http://deeplearning.net/data/mnist/mnist.pkl.gz'",
")",
"h",
"=",
"gzip",
".",
"open",
"(",
"fn",
",",
"'rb'",
")",
"i... | 79db9f878ef2071f2f576a1cf5d43a752a55894a |
test | load_cifar | Load the CIFAR10 image dataset. | examples/utils.py | def load_cifar(flatten=True, labels=False):
'''Load the CIFAR10 image dataset.'''
def extract(name):
print('extracting data from {}'.format(name))
h = tar.extractfile(name)
if sys.version_info < (3, ):
d = pickle.load(h)
else:
d = pickle.load(h, encoding='... | def load_cifar(flatten=True, labels=False):
'''Load the CIFAR10 image dataset.'''
def extract(name):
print('extracting data from {}'.format(name))
h = tar.extractfile(name)
if sys.version_info < (3, ):
d = pickle.load(h)
else:
d = pickle.load(h, encoding='... | [
"Load",
"the",
"CIFAR10",
"image",
"dataset",
"."
] | lmjohns3/theanets | python | https://github.com/lmjohns3/theanets/blob/79db9f878ef2071f2f576a1cf5d43a752a55894a/examples/utils.py#L53-L94 | [
"def",
"load_cifar",
"(",
"flatten",
"=",
"True",
",",
"labels",
"=",
"False",
")",
":",
"def",
"extract",
"(",
"name",
")",
":",
"print",
"(",
"'extracting data from {}'",
".",
"format",
"(",
"name",
")",
")",
"h",
"=",
"tar",
".",
"extractfile",
"(",... | 79db9f878ef2071f2f576a1cf5d43a752a55894a |
test | plot_images | Plot an array of images.
We assume that we are given a matrix of data whose shape is (n*n, s*s*c) --
that is, there are n^2 images along the first axis of the array, and each
image is c squares measuring s pixels on a side. Each row of the input will
be plotted as a sub-region within a single image arr... | examples/utils.py | def plot_images(imgs, loc, title=None, channels=1):
'''Plot an array of images.
We assume that we are given a matrix of data whose shape is (n*n, s*s*c) --
that is, there are n^2 images along the first axis of the array, and each
image is c squares measuring s pixels on a side. Each row of the input wi... | def plot_images(imgs, loc, title=None, channels=1):
'''Plot an array of images.
We assume that we are given a matrix of data whose shape is (n*n, s*s*c) --
that is, there are n^2 images along the first axis of the array, and each
image is c squares measuring s pixels on a side. Each row of the input wi... | [
"Plot",
"an",
"array",
"of",
"images",
"."
] | lmjohns3/theanets | python | https://github.com/lmjohns3/theanets/blob/79db9f878ef2071f2f576a1cf5d43a752a55894a/examples/utils.py#L97-L126 | [
"def",
"plot_images",
"(",
"imgs",
",",
"loc",
",",
"title",
"=",
"None",
",",
"channels",
"=",
"1",
")",
":",
"n",
"=",
"int",
"(",
"np",
".",
"sqrt",
"(",
"len",
"(",
"imgs",
")",
")",
")",
"assert",
"n",
"*",
"n",
"==",
"len",
"(",
"imgs",... | 79db9f878ef2071f2f576a1cf5d43a752a55894a |
test | plot_layers | Create a plot of weights, visualized as "bottom-level" pixel arrays. | examples/utils.py | def plot_layers(weights, tied_weights=False, channels=1):
'''Create a plot of weights, visualized as "bottom-level" pixel arrays.'''
if hasattr(weights[0], 'get_value'):
weights = [w.get_value() for w in weights]
k = min(len(weights), 9)
imgs = np.eye(weights[0].shape[0])
for i, weight in en... | def plot_layers(weights, tied_weights=False, channels=1):
'''Create a plot of weights, visualized as "bottom-level" pixel arrays.'''
if hasattr(weights[0], 'get_value'):
weights = [w.get_value() for w in weights]
k = min(len(weights), 9)
imgs = np.eye(weights[0].shape[0])
for i, weight in en... | [
"Create",
"a",
"plot",
"of",
"weights",
"visualized",
"as",
"bottom",
"-",
"level",
"pixel",
"arrays",
"."
] | lmjohns3/theanets | python | https://github.com/lmjohns3/theanets/blob/79db9f878ef2071f2f576a1cf5d43a752a55894a/examples/utils.py#L129-L155 | [
"def",
"plot_layers",
"(",
"weights",
",",
"tied_weights",
"=",
"False",
",",
"channels",
"=",
"1",
")",
":",
"if",
"hasattr",
"(",
"weights",
"[",
"0",
"]",
",",
"'get_value'",
")",
":",
"weights",
"=",
"[",
"w",
".",
"get_value",
"(",
")",
"for",
... | 79db9f878ef2071f2f576a1cf5d43a752a55894a |
test | plot_filters | Create a plot of conv filters, visualized as pixel arrays. | examples/utils.py | def plot_filters(filters):
'''Create a plot of conv filters, visualized as pixel arrays.'''
imgs = filters.get_value()
N, channels, x, y = imgs.shape
n = int(np.sqrt(N))
assert n * n == N, 'filters must contain a square number of rows!'
assert channels == 1 or channels == 3, 'can only plot gray... | def plot_filters(filters):
'''Create a plot of conv filters, visualized as pixel arrays.'''
imgs = filters.get_value()
N, channels, x, y = imgs.shape
n = int(np.sqrt(N))
assert n * n == N, 'filters must contain a square number of rows!'
assert channels == 1 or channels == 3, 'can only plot gray... | [
"Create",
"a",
"plot",
"of",
"conv",
"filters",
"visualized",
"as",
"pixel",
"arrays",
"."
] | lmjohns3/theanets | python | https://github.com/lmjohns3/theanets/blob/79db9f878ef2071f2f576a1cf5d43a752a55894a/examples/utils.py#L158-L180 | [
"def",
"plot_filters",
"(",
"filters",
")",
":",
"imgs",
"=",
"filters",
".",
"get_value",
"(",
")",
"N",
",",
"channels",
",",
"x",
",",
"y",
"=",
"imgs",
".",
"shape",
"n",
"=",
"int",
"(",
"np",
".",
"sqrt",
"(",
"N",
")",
")",
"assert",
"n"... | 79db9f878ef2071f2f576a1cf5d43a752a55894a |
test | batches | Create a callable that generates samples from a dataset.
Parameters
----------
arrays : list of ndarray (time-steps, data-dimensions)
Arrays of data. Rows in these arrays are assumed to correspond to time
steps, and columns to variables. Multiple arrays can be given; in such
a case,... | theanets/recurrent.py | def batches(arrays, steps=100, batch_size=64, rng=None):
'''Create a callable that generates samples from a dataset.
Parameters
----------
arrays : list of ndarray (time-steps, data-dimensions)
Arrays of data. Rows in these arrays are assumed to correspond to time
steps, and columns to ... | def batches(arrays, steps=100, batch_size=64, rng=None):
'''Create a callable that generates samples from a dataset.
Parameters
----------
arrays : list of ndarray (time-steps, data-dimensions)
Arrays of data. Rows in these arrays are assumed to correspond to time
steps, and columns to ... | [
"Create",
"a",
"callable",
"that",
"generates",
"samples",
"from",
"a",
"dataset",
"."
] | lmjohns3/theanets | python | https://github.com/lmjohns3/theanets/blob/79db9f878ef2071f2f576a1cf5d43a752a55894a/theanets/recurrent.py#L12-L54 | [
"def",
"batches",
"(",
"arrays",
",",
"steps",
"=",
"100",
",",
"batch_size",
"=",
"64",
",",
"rng",
"=",
"None",
")",
":",
"assert",
"batch_size",
">=",
"2",
",",
"'batch_size must be at least 2!'",
"assert",
"isinstance",
"(",
"arrays",
",",
"(",
"tuple"... | 79db9f878ef2071f2f576a1cf5d43a752a55894a |
test | Text.encode | Encode a text string by replacing characters with alphabet index.
Parameters
----------
txt : str
A string to encode.
Returns
-------
classes : list of int
A sequence of alphabet index values corresponding to the given text. | theanets/recurrent.py | def encode(self, txt):
'''Encode a text string by replacing characters with alphabet index.
Parameters
----------
txt : str
A string to encode.
Returns
-------
classes : list of int
A sequence of alphabet index values corresponding to the... | def encode(self, txt):
'''Encode a text string by replacing characters with alphabet index.
Parameters
----------
txt : str
A string to encode.
Returns
-------
classes : list of int
A sequence of alphabet index values corresponding to the... | [
"Encode",
"a",
"text",
"string",
"by",
"replacing",
"characters",
"with",
"alphabet",
"index",
"."
] | lmjohns3/theanets | python | https://github.com/lmjohns3/theanets/blob/79db9f878ef2071f2f576a1cf5d43a752a55894a/theanets/recurrent.py#L97-L110 | [
"def",
"encode",
"(",
"self",
",",
"txt",
")",
":",
"return",
"list",
"(",
"self",
".",
"_fwd_index",
".",
"get",
"(",
"c",
",",
"0",
")",
"for",
"c",
"in",
"txt",
")"
] | 79db9f878ef2071f2f576a1cf5d43a752a55894a |
test | Text.classifier_batches | Create a callable that returns a batch of training data.
Parameters
----------
steps : int
Number of time steps in each batch.
batch_size : int
Number of training examples per batch.
rng : :class:`numpy.random.RandomState` or int, optional
A r... | theanets/recurrent.py | def classifier_batches(self, steps, batch_size, rng=None):
'''Create a callable that returns a batch of training data.
Parameters
----------
steps : int
Number of time steps in each batch.
batch_size : int
Number of training examples per batch.
rn... | def classifier_batches(self, steps, batch_size, rng=None):
'''Create a callable that returns a batch of training data.
Parameters
----------
steps : int
Number of time steps in each batch.
batch_size : int
Number of training examples per batch.
rn... | [
"Create",
"a",
"callable",
"that",
"returns",
"a",
"batch",
"of",
"training",
"data",
"."
] | lmjohns3/theanets | python | https://github.com/lmjohns3/theanets/blob/79db9f878ef2071f2f576a1cf5d43a752a55894a/theanets/recurrent.py#L127-L164 | [
"def",
"classifier_batches",
"(",
"self",
",",
"steps",
",",
"batch_size",
",",
"rng",
"=",
"None",
")",
":",
"assert",
"batch_size",
">=",
"2",
",",
"'batch_size must be at least 2!'",
"if",
"rng",
"is",
"None",
"or",
"isinstance",
"(",
"rng",
",",
"int",
... | 79db9f878ef2071f2f576a1cf5d43a752a55894a |
test | Classifier.predict_sequence | Draw a sequential sample of class labels from this network.
Parameters
----------
labels : list of int
A list of integer class labels to get the classifier started.
steps : int
The number of time steps to sample.
streams : int, optional
Number... | theanets/recurrent.py | def predict_sequence(self, labels, steps, streams=1, rng=None):
'''Draw a sequential sample of class labels from this network.
Parameters
----------
labels : list of int
A list of integer class labels to get the classifier started.
steps : int
The number ... | def predict_sequence(self, labels, steps, streams=1, rng=None):
'''Draw a sequential sample of class labels from this network.
Parameters
----------
labels : list of int
A list of integer class labels to get the classifier started.
steps : int
The number ... | [
"Draw",
"a",
"sequential",
"sample",
"of",
"class",
"labels",
"from",
"this",
"network",
"."
] | lmjohns3/theanets | python | https://github.com/lmjohns3/theanets/blob/79db9f878ef2071f2f576a1cf5d43a752a55894a/theanets/recurrent.py#L392-L433 | [
"def",
"predict_sequence",
"(",
"self",
",",
"labels",
",",
"steps",
",",
"streams",
"=",
"1",
",",
"rng",
"=",
"None",
")",
":",
"if",
"rng",
"is",
"None",
"or",
"isinstance",
"(",
"rng",
",",
"int",
")",
":",
"rng",
"=",
"np",
".",
"random",
".... | 79db9f878ef2071f2f576a1cf5d43a752a55894a |
test | Convolution.add_conv_weights | Add a convolutional weight array to this layer's parameters.
Parameters
----------
name : str
Name of the parameter to add.
mean : float, optional
Mean value for randomly-initialized weights. Defaults to 0.
std : float, optional
Standard devia... | theanets/layers/convolution.py | def add_conv_weights(self, name, mean=0, std=None, sparsity=0):
'''Add a convolutional weight array to this layer's parameters.
Parameters
----------
name : str
Name of the parameter to add.
mean : float, optional
Mean value for randomly-initialized weigh... | def add_conv_weights(self, name, mean=0, std=None, sparsity=0):
'''Add a convolutional weight array to this layer's parameters.
Parameters
----------
name : str
Name of the parameter to add.
mean : float, optional
Mean value for randomly-initialized weigh... | [
"Add",
"a",
"convolutional",
"weight",
"array",
"to",
"this",
"layer",
"s",
"parameters",
"."
] | lmjohns3/theanets | python | https://github.com/lmjohns3/theanets/blob/79db9f878ef2071f2f576a1cf5d43a752a55894a/theanets/layers/convolution.py#L53-L84 | [
"def",
"add_conv_weights",
"(",
"self",
",",
"name",
",",
"mean",
"=",
"0",
",",
"std",
"=",
"None",
",",
"sparsity",
"=",
"0",
")",
":",
"nin",
"=",
"self",
".",
"input_size",
"nout",
"=",
"self",
".",
"output_size",
"mean",
"=",
"self",
".",
"kwa... | 79db9f878ef2071f2f576a1cf5d43a752a55894a |
test | Autoencoder.encode | Encode a dataset using the hidden layer activations of our network.
Parameters
----------
x : ndarray
A dataset to encode. Rows of this dataset capture individual data
points, while columns represent the variables in each data point.
layer : str, optional
... | theanets/feedforward.py | def encode(self, x, layer=None, sample=False, **kwargs):
'''Encode a dataset using the hidden layer activations of our network.
Parameters
----------
x : ndarray
A dataset to encode. Rows of this dataset capture individual data
points, while columns represent the... | def encode(self, x, layer=None, sample=False, **kwargs):
'''Encode a dataset using the hidden layer activations of our network.
Parameters
----------
x : ndarray
A dataset to encode. Rows of this dataset capture individual data
points, while columns represent the... | [
"Encode",
"a",
"dataset",
"using",
"the",
"hidden",
"layer",
"activations",
"of",
"our",
"network",
"."
] | lmjohns3/theanets | python | https://github.com/lmjohns3/theanets/blob/79db9f878ef2071f2f576a1cf5d43a752a55894a/theanets/feedforward.py#L125-L153 | [
"def",
"encode",
"(",
"self",
",",
"x",
",",
"layer",
"=",
"None",
",",
"sample",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"enc",
"=",
"self",
".",
"feed_forward",
"(",
"x",
",",
"*",
"*",
"kwargs",
")",
"[",
"self",
".",
"_find_output",
... | 79db9f878ef2071f2f576a1cf5d43a752a55894a |
test | Autoencoder.decode | Decode an encoded dataset by computing the output layer activation.
Parameters
----------
z : ndarray
A matrix containing encoded data from this autoencoder.
layer : int or str or :class:`Layer <layers.Layer>`, optional
The index or name of the hidden layer that ... | theanets/feedforward.py | def decode(self, z, layer=None, **kwargs):
'''Decode an encoded dataset by computing the output layer activation.
Parameters
----------
z : ndarray
A matrix containing encoded data from this autoencoder.
layer : int or str or :class:`Layer <layers.Layer>`, optional
... | def decode(self, z, layer=None, **kwargs):
'''Decode an encoded dataset by computing the output layer activation.
Parameters
----------
z : ndarray
A matrix containing encoded data from this autoencoder.
layer : int or str or :class:`Layer <layers.Layer>`, optional
... | [
"Decode",
"an",
"encoded",
"dataset",
"by",
"computing",
"the",
"output",
"layer",
"activation",
"."
] | lmjohns3/theanets | python | https://github.com/lmjohns3/theanets/blob/79db9f878ef2071f2f576a1cf5d43a752a55894a/theanets/feedforward.py#L155-L178 | [
"def",
"decode",
"(",
"self",
",",
"z",
",",
"layer",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"key",
"=",
"self",
".",
"_find_output",
"(",
"layer",
")",
"if",
"key",
"not",
"in",
"self",
".",
"_functions",
":",
"regs",
"=",
"regularizers",... | 79db9f878ef2071f2f576a1cf5d43a752a55894a |
test | Autoencoder._find_output | Find a layer output name for the given layer specifier.
Parameters
----------
layer : None, int, str, or :class:`theanets.layers.Layer`
A layer specification. If this is None, the "middle" layer in the
network will be used (i.e., the layer at the middle index in the
... | theanets/feedforward.py | def _find_output(self, layer):
'''Find a layer output name for the given layer specifier.
Parameters
----------
layer : None, int, str, or :class:`theanets.layers.Layer`
A layer specification. If this is None, the "middle" layer in the
network will be used (i.e.,... | def _find_output(self, layer):
'''Find a layer output name for the given layer specifier.
Parameters
----------
layer : None, int, str, or :class:`theanets.layers.Layer`
A layer specification. If this is None, the "middle" layer in the
network will be used (i.e.,... | [
"Find",
"a",
"layer",
"output",
"name",
"for",
"the",
"given",
"layer",
"specifier",
"."
] | lmjohns3/theanets | python | https://github.com/lmjohns3/theanets/blob/79db9f878ef2071f2f576a1cf5d43a752a55894a/theanets/feedforward.py#L180-L208 | [
"def",
"_find_output",
"(",
"self",
",",
"layer",
")",
":",
"if",
"layer",
"is",
"None",
":",
"layer",
"=",
"len",
"(",
"self",
".",
"layers",
")",
"//",
"2",
"if",
"isinstance",
"(",
"layer",
",",
"int",
")",
":",
"layer",
"=",
"self",
".",
"lay... | 79db9f878ef2071f2f576a1cf5d43a752a55894a |
test | Autoencoder.score | Compute R^2 coefficient of determination for a given input.
Parameters
----------
x : ndarray (num-examples, num-inputs)
An array containing data to be fed into the network. Multiple
examples are arranged as rows in this array, with columns containing
the var... | theanets/feedforward.py | def score(self, x, w=None, **kwargs):
'''Compute R^2 coefficient of determination for a given input.
Parameters
----------
x : ndarray (num-examples, num-inputs)
An array containing data to be fed into the network. Multiple
examples are arranged as rows in this a... | def score(self, x, w=None, **kwargs):
'''Compute R^2 coefficient of determination for a given input.
Parameters
----------
x : ndarray (num-examples, num-inputs)
An array containing data to be fed into the network. Multiple
examples are arranged as rows in this a... | [
"Compute",
"R^2",
"coefficient",
"of",
"determination",
"for",
"a",
"given",
"input",
"."
] | lmjohns3/theanets | python | https://github.com/lmjohns3/theanets/blob/79db9f878ef2071f2f576a1cf5d43a752a55894a/theanets/feedforward.py#L210-L227 | [
"def",
"score",
"(",
"self",
",",
"x",
",",
"w",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"super",
"(",
"Autoencoder",
",",
"self",
")",
".",
"score",
"(",
"x",
",",
"x",
",",
"w",
"=",
"w",
",",
"*",
"*",
"kwargs",
")"
] | 79db9f878ef2071f2f576a1cf5d43a752a55894a |
test | Classifier.monitors | Return expressions that should be computed to monitor training.
Returns
-------
monitors : list of (name, expression) pairs
A list of named monitor expressions to compute for this network. | theanets/feedforward.py | def monitors(self, **kwargs):
'''Return expressions that should be computed to monitor training.
Returns
-------
monitors : list of (name, expression) pairs
A list of named monitor expressions to compute for this network.
'''
monitors = super(Classifier, self... | def monitors(self, **kwargs):
'''Return expressions that should be computed to monitor training.
Returns
-------
monitors : list of (name, expression) pairs
A list of named monitor expressions to compute for this network.
'''
monitors = super(Classifier, self... | [
"Return",
"expressions",
"that",
"should",
"be",
"computed",
"to",
"monitor",
"training",
"."
] | lmjohns3/theanets | python | https://github.com/lmjohns3/theanets/blob/79db9f878ef2071f2f576a1cf5d43a752a55894a/theanets/feedforward.py#L363-L374 | [
"def",
"monitors",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"monitors",
"=",
"super",
"(",
"Classifier",
",",
"self",
")",
".",
"monitors",
"(",
"*",
"*",
"kwargs",
")",
"regs",
"=",
"regularizers",
".",
"from_kwargs",
"(",
"self",
",",
"*",
... | 79db9f878ef2071f2f576a1cf5d43a752a55894a |
test | Classifier.predict | Compute a greedy classification for the given set of data.
Parameters
----------
x : ndarray (num-examples, num-variables)
An array containing examples to classify. Examples are given as the
rows in this array.
Returns
-------
k : ndarray (num-ex... | theanets/feedforward.py | def predict(self, x, **kwargs):
'''Compute a greedy classification for the given set of data.
Parameters
----------
x : ndarray (num-examples, num-variables)
An array containing examples to classify. Examples are given as the
rows in this array.
Returns
... | def predict(self, x, **kwargs):
'''Compute a greedy classification for the given set of data.
Parameters
----------
x : ndarray (num-examples, num-variables)
An array containing examples to classify. Examples are given as the
rows in this array.
Returns
... | [
"Compute",
"a",
"greedy",
"classification",
"for",
"the",
"given",
"set",
"of",
"data",
"."
] | lmjohns3/theanets | python | https://github.com/lmjohns3/theanets/blob/79db9f878ef2071f2f576a1cf5d43a752a55894a/theanets/feedforward.py#L376-L391 | [
"def",
"predict",
"(",
"self",
",",
"x",
",",
"*",
"*",
"kwargs",
")",
":",
"outputs",
"=",
"self",
".",
"feed_forward",
"(",
"x",
",",
"*",
"*",
"kwargs",
")",
"return",
"outputs",
"[",
"self",
".",
"layers",
"[",
"-",
"1",
"]",
".",
"output_nam... | 79db9f878ef2071f2f576a1cf5d43a752a55894a |
test | Classifier.predict_proba | Compute class posterior probabilities for the given set of data.
Parameters
----------
x : ndarray (num-examples, num-variables)
An array containing examples to predict. Examples are given as the
rows in this array.
Returns
-------
p : ndarray (n... | theanets/feedforward.py | def predict_proba(self, x, **kwargs):
'''Compute class posterior probabilities for the given set of data.
Parameters
----------
x : ndarray (num-examples, num-variables)
An array containing examples to predict. Examples are given as the
rows in this array.
... | def predict_proba(self, x, **kwargs):
'''Compute class posterior probabilities for the given set of data.
Parameters
----------
x : ndarray (num-examples, num-variables)
An array containing examples to predict. Examples are given as the
rows in this array.
... | [
"Compute",
"class",
"posterior",
"probabilities",
"for",
"the",
"given",
"set",
"of",
"data",
"."
] | lmjohns3/theanets | python | https://github.com/lmjohns3/theanets/blob/79db9f878ef2071f2f576a1cf5d43a752a55894a/theanets/feedforward.py#L398-L413 | [
"def",
"predict_proba",
"(",
"self",
",",
"x",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"feed_forward",
"(",
"x",
",",
"*",
"*",
"kwargs",
")",
"[",
"self",
".",
"layers",
"[",
"-",
"1",
"]",
".",
"output_name",
"]"
] | 79db9f878ef2071f2f576a1cf5d43a752a55894a |
test | Classifier.predict_logit | Compute the logit values that underlie the softmax output.
Parameters
----------
x : ndarray (num-examples, num-variables)
An array containing examples to classify. Examples are given as the
rows in this array.
Returns
-------
l : ndarray (num-ex... | theanets/feedforward.py | def predict_logit(self, x, **kwargs):
'''Compute the logit values that underlie the softmax output.
Parameters
----------
x : ndarray (num-examples, num-variables)
An array containing examples to classify. Examples are given as the
rows in this array.
Re... | def predict_logit(self, x, **kwargs):
'''Compute the logit values that underlie the softmax output.
Parameters
----------
x : ndarray (num-examples, num-variables)
An array containing examples to classify. Examples are given as the
rows in this array.
Re... | [
"Compute",
"the",
"logit",
"values",
"that",
"underlie",
"the",
"softmax",
"output",
"."
] | lmjohns3/theanets | python | https://github.com/lmjohns3/theanets/blob/79db9f878ef2071f2f576a1cf5d43a752a55894a/theanets/feedforward.py#L415-L430 | [
"def",
"predict_logit",
"(",
"self",
",",
"x",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"feed_forward",
"(",
"x",
",",
"*",
"*",
"kwargs",
")",
"[",
"self",
".",
"layers",
"[",
"-",
"1",
"]",
".",
"full_name",
"(",
"'pre'",
")",
... | 79db9f878ef2071f2f576a1cf5d43a752a55894a |
test | Classifier.score | Compute the mean accuracy on a set of labeled data.
Parameters
----------
x : ndarray (num-examples, num-variables)
An array containing examples to classify. Examples are given as the
rows in this array.
y : ndarray (num-examples, )
A vector of intege... | theanets/feedforward.py | def score(self, x, y, w=None, **kwargs):
'''Compute the mean accuracy on a set of labeled data.
Parameters
----------
x : ndarray (num-examples, num-variables)
An array containing examples to classify. Examples are given as the
rows in this array.
y : nda... | def score(self, x, y, w=None, **kwargs):
'''Compute the mean accuracy on a set of labeled data.
Parameters
----------
x : ndarray (num-examples, num-variables)
An array containing examples to classify. Examples are given as the
rows in this array.
y : nda... | [
"Compute",
"the",
"mean",
"accuracy",
"on",
"a",
"set",
"of",
"labeled",
"data",
"."
] | lmjohns3/theanets | python | https://github.com/lmjohns3/theanets/blob/79db9f878ef2071f2f576a1cf5d43a752a55894a/theanets/feedforward.py#L432-L453 | [
"def",
"score",
"(",
"self",
",",
"x",
",",
"y",
",",
"w",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"eq",
"=",
"y",
"==",
"self",
".",
"predict",
"(",
"x",
",",
"*",
"*",
"kwargs",
")",
"if",
"w",
"is",
"not",
"None",
":",
"return",
... | 79db9f878ef2071f2f576a1cf5d43a752a55894a |
test | batch_at | Extract a single batch of data to pass to the model being trained.
Parameters
----------
features, labels : ndarray
Arrays of the input features and target labels.
seq_begins : ndarray
Array of the start offsets of the speech segments to include.
seq_lengths : ndarray
Array ... | examples/lstm-chime.py | def batch_at(features, labels, seq_begins, seq_lengths):
'''Extract a single batch of data to pass to the model being trained.
Parameters
----------
features, labels : ndarray
Arrays of the input features and target labels.
seq_begins : ndarray
Array of the start offsets of the spee... | def batch_at(features, labels, seq_begins, seq_lengths):
'''Extract a single batch of data to pass to the model being trained.
Parameters
----------
features, labels : ndarray
Arrays of the input features and target labels.
seq_begins : ndarray
Array of the start offsets of the spee... | [
"Extract",
"a",
"single",
"batch",
"of",
"data",
"to",
"pass",
"to",
"the",
"model",
"being",
"trained",
"."
] | lmjohns3/theanets | python | https://github.com/lmjohns3/theanets/blob/79db9f878ef2071f2f576a1cf5d43a752a55894a/examples/lstm-chime.py#L40-L68 | [
"def",
"batch_at",
"(",
"features",
",",
"labels",
",",
"seq_begins",
",",
"seq_lengths",
")",
":",
"length",
"=",
"seq_lengths",
".",
"max",
"(",
")",
"feat",
"=",
"np",
".",
"zeros",
"(",
"(",
"BATCH_SIZE",
",",
"length",
",",
"features",
".",
"shape... | 79db9f878ef2071f2f576a1cf5d43a752a55894a |
test | batches | Returns a callable that chooses sequences from netcdf data. | examples/lstm-chime.py | def batches(dataset):
'''Returns a callable that chooses sequences from netcdf data.'''
seq_lengths = dataset.variables['seqLengths'].data
seq_begins = np.concatenate(([0], np.cumsum(seq_lengths)[:-1]))
def sample():
chosen = np.random.choice(
list(range(len(seq_lengths))), BATCH_SI... | def batches(dataset):
'''Returns a callable that chooses sequences from netcdf data.'''
seq_lengths = dataset.variables['seqLengths'].data
seq_begins = np.concatenate(([0], np.cumsum(seq_lengths)[:-1]))
def sample():
chosen = np.random.choice(
list(range(len(seq_lengths))), BATCH_SI... | [
"Returns",
"a",
"callable",
"that",
"chooses",
"sequences",
"from",
"netcdf",
"data",
"."
] | lmjohns3/theanets | python | https://github.com/lmjohns3/theanets/blob/79db9f878ef2071f2f576a1cf5d43a752a55894a/examples/lstm-chime.py#L71-L84 | [
"def",
"batches",
"(",
"dataset",
")",
":",
"seq_lengths",
"=",
"dataset",
".",
"variables",
"[",
"'seqLengths'",
"]",
".",
"data",
"seq_begins",
"=",
"np",
".",
"concatenate",
"(",
"(",
"[",
"0",
"]",
",",
"np",
".",
"cumsum",
"(",
"seq_lengths",
")",... | 79db9f878ef2071f2f576a1cf5d43a752a55894a |
test | Experiment.load | Load a saved network from a pickle file on disk.
This method sets the ``network`` attribute of the experiment to the
loaded network model.
Parameters
----------
filename : str
Load the keyword arguments and parameters of a network from a pickle
file at t... | theanets/main.py | def load(self, path):
'''Load a saved network from a pickle file on disk.
This method sets the ``network`` attribute of the experiment to the
loaded network model.
Parameters
----------
filename : str
Load the keyword arguments and parameters of a network fr... | def load(self, path):
'''Load a saved network from a pickle file on disk.
This method sets the ``network`` attribute of the experiment to the
loaded network model.
Parameters
----------
filename : str
Load the keyword arguments and parameters of a network fr... | [
"Load",
"a",
"saved",
"network",
"from",
"a",
"pickle",
"file",
"on",
"disk",
"."
] | lmjohns3/theanets | python | https://github.com/lmjohns3/theanets/blob/79db9f878ef2071f2f576a1cf5d43a752a55894a/theanets/main.py#L86-L107 | [
"def",
"load",
"(",
"self",
",",
"path",
")",
":",
"self",
".",
"network",
"=",
"graph",
".",
"Network",
".",
"load",
"(",
"path",
")",
"return",
"self",
".",
"network"
] | 79db9f878ef2071f2f576a1cf5d43a752a55894a |
test | random_matrix | Create a matrix of randomly-initialized weights.
Parameters
----------
rows : int
Number of rows of the weight matrix -- equivalently, the number of
"input" units that the weight matrix connects.
cols : int
Number of columns of the weight matrix -- equivalently, the number
... | theanets/util.py | def random_matrix(rows, cols, mean=0, std=1, sparsity=0, radius=0, diagonal=0, rng=None):
'''Create a matrix of randomly-initialized weights.
Parameters
----------
rows : int
Number of rows of the weight matrix -- equivalently, the number of
"input" units that the weight matrix connects... | def random_matrix(rows, cols, mean=0, std=1, sparsity=0, radius=0, diagonal=0, rng=None):
'''Create a matrix of randomly-initialized weights.
Parameters
----------
rows : int
Number of rows of the weight matrix -- equivalently, the number of
"input" units that the weight matrix connects... | [
"Create",
"a",
"matrix",
"of",
"randomly",
"-",
"initialized",
"weights",
"."
] | lmjohns3/theanets | python | https://github.com/lmjohns3/theanets/blob/79db9f878ef2071f2f576a1cf5d43a752a55894a/theanets/util.py#L55-L107 | [
"def",
"random_matrix",
"(",
"rows",
",",
"cols",
",",
"mean",
"=",
"0",
",",
"std",
"=",
"1",
",",
"sparsity",
"=",
"0",
",",
"radius",
"=",
"0",
",",
"diagonal",
"=",
"0",
",",
"rng",
"=",
"None",
")",
":",
"if",
"rng",
"is",
"None",
"or",
... | 79db9f878ef2071f2f576a1cf5d43a752a55894a |
test | random_vector | Create a vector of randomly-initialized values.
Parameters
----------
size : int
Length of vecctor to create.
mean : float, optional
Mean value for initial vector values. Defaults to 0.
std : float, optional
Standard deviation for initial vector values. Defaults to 1.
rn... | theanets/util.py | def random_vector(size, mean=0, std=1, rng=None):
'''Create a vector of randomly-initialized values.
Parameters
----------
size : int
Length of vecctor to create.
mean : float, optional
Mean value for initial vector values. Defaults to 0.
std : float, optional
Standard d... | def random_vector(size, mean=0, std=1, rng=None):
'''Create a vector of randomly-initialized values.
Parameters
----------
size : int
Length of vecctor to create.
mean : float, optional
Mean value for initial vector values. Defaults to 0.
std : float, optional
Standard d... | [
"Create",
"a",
"vector",
"of",
"randomly",
"-",
"initialized",
"values",
"."
] | lmjohns3/theanets | python | https://github.com/lmjohns3/theanets/blob/79db9f878ef2071f2f576a1cf5d43a752a55894a/theanets/util.py#L110-L134 | [
"def",
"random_vector",
"(",
"size",
",",
"mean",
"=",
"0",
",",
"std",
"=",
"1",
",",
"rng",
"=",
"None",
")",
":",
"if",
"rng",
"is",
"None",
"or",
"isinstance",
"(",
"rng",
",",
"int",
")",
":",
"rng",
"=",
"np",
".",
"random",
".",
"RandomS... | 79db9f878ef2071f2f576a1cf5d43a752a55894a |
test | outputs_matching | Get the outputs from a network that match a pattern.
Parameters
----------
outputs : dict or sequence of (str, theano expression)
Output expressions to filter for matches. If this is a dictionary, its
``items()`` will be processed for matches.
patterns : sequence of str
A sequen... | theanets/util.py | def outputs_matching(outputs, patterns):
'''Get the outputs from a network that match a pattern.
Parameters
----------
outputs : dict or sequence of (str, theano expression)
Output expressions to filter for matches. If this is a dictionary, its
``items()`` will be processed for matches.... | def outputs_matching(outputs, patterns):
'''Get the outputs from a network that match a pattern.
Parameters
----------
outputs : dict or sequence of (str, theano expression)
Output expressions to filter for matches. If this is a dictionary, its
``items()`` will be processed for matches.... | [
"Get",
"the",
"outputs",
"from",
"a",
"network",
"that",
"match",
"a",
"pattern",
"."
] | lmjohns3/theanets | python | https://github.com/lmjohns3/theanets/blob/79db9f878ef2071f2f576a1cf5d43a752a55894a/theanets/util.py#L137-L164 | [
"def",
"outputs_matching",
"(",
"outputs",
",",
"patterns",
")",
":",
"if",
"isinstance",
"(",
"patterns",
",",
"basestring",
")",
":",
"patterns",
"=",
"(",
"patterns",
",",
")",
"if",
"isinstance",
"(",
"outputs",
",",
"dict",
")",
":",
"outputs",
"=",... | 79db9f878ef2071f2f576a1cf5d43a752a55894a |
test | params_matching | Get the parameters from a network that match a pattern.
Parameters
----------
layers : list of :class:`theanets.layers.Layer`
A list of network layers to retrieve parameters from.
patterns : sequence of str
A sequence of glob-style patterns to match against. Any parameter
matchi... | theanets/util.py | def params_matching(layers, patterns):
'''Get the parameters from a network that match a pattern.
Parameters
----------
layers : list of :class:`theanets.layers.Layer`
A list of network layers to retrieve parameters from.
patterns : sequence of str
A sequence of glob-style patterns ... | def params_matching(layers, patterns):
'''Get the parameters from a network that match a pattern.
Parameters
----------
layers : list of :class:`theanets.layers.Layer`
A list of network layers to retrieve parameters from.
patterns : sequence of str
A sequence of glob-style patterns ... | [
"Get",
"the",
"parameters",
"from",
"a",
"network",
"that",
"match",
"a",
"pattern",
"."
] | lmjohns3/theanets | python | https://github.com/lmjohns3/theanets/blob/79db9f878ef2071f2f576a1cf5d43a752a55894a/theanets/util.py#L167-L193 | [
"def",
"params_matching",
"(",
"layers",
",",
"patterns",
")",
":",
"if",
"isinstance",
"(",
"patterns",
",",
"basestring",
")",
":",
"patterns",
"=",
"(",
"patterns",
",",
")",
"for",
"layer",
"in",
"layers",
":",
"for",
"param",
"in",
"layer",
".",
"... | 79db9f878ef2071f2f576a1cf5d43a752a55894a |
test | from_kwargs | Construct common regularizers from a set of keyword arguments.
Keyword arguments not listed below will be passed to
:func:`Regularizer.build` if they specify the name of a registered
:class:`Regularizer`.
Parameters
----------
graph : :class:`theanets.graph.Network`
A network graph to ... | theanets/regularizers.py | def from_kwargs(graph, **kwargs):
'''Construct common regularizers from a set of keyword arguments.
Keyword arguments not listed below will be passed to
:func:`Regularizer.build` if they specify the name of a registered
:class:`Regularizer`.
Parameters
----------
graph : :class:`theanets.g... | def from_kwargs(graph, **kwargs):
'''Construct common regularizers from a set of keyword arguments.
Keyword arguments not listed below will be passed to
:func:`Regularizer.build` if they specify the name of a registered
:class:`Regularizer`.
Parameters
----------
graph : :class:`theanets.g... | [
"Construct",
"common",
"regularizers",
"from",
"a",
"set",
"of",
"keyword",
"arguments",
"."
] | lmjohns3/theanets | python | https://github.com/lmjohns3/theanets/blob/79db9f878ef2071f2f576a1cf5d43a752a55894a/theanets/regularizers.py#L23-L121 | [
"def",
"from_kwargs",
"(",
"graph",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"'regularizers'",
"in",
"kwargs",
":",
"regs",
"=",
"kwargs",
"[",
"'regularizers'",
"]",
"if",
"isinstance",
"(",
"regs",
",",
"(",
"tuple",
",",
"list",
")",
")",
":",
"re... | 79db9f878ef2071f2f576a1cf5d43a752a55894a |
test | Loss.variables | A list of Theano variables used in this loss. | theanets/losses.py | def variables(self):
'''A list of Theano variables used in this loss.'''
result = [self._target]
if self._weights is not None:
result.append(self._weights)
return result | def variables(self):
'''A list of Theano variables used in this loss.'''
result = [self._target]
if self._weights is not None:
result.append(self._weights)
return result | [
"A",
"list",
"of",
"Theano",
"variables",
"used",
"in",
"this",
"loss",
"."
] | lmjohns3/theanets | python | https://github.com/lmjohns3/theanets/blob/79db9f878ef2071f2f576a1cf5d43a752a55894a/theanets/losses.py#L54-L59 | [
"def",
"variables",
"(",
"self",
")",
":",
"result",
"=",
"[",
"self",
".",
"_target",
"]",
"if",
"self",
".",
"_weights",
"is",
"not",
"None",
":",
"result",
".",
"append",
"(",
"self",
".",
"_weights",
")",
"return",
"result"
] | 79db9f878ef2071f2f576a1cf5d43a752a55894a |
test | CrossEntropy.accuracy | Build a Theano expression for computing the accuracy of graph output.
Parameters
----------
outputs : dict of Theano expressions
A dictionary mapping network output names to Theano expressions
representing the outputs of a computation graph.
Returns
----... | theanets/losses.py | def accuracy(self, outputs):
'''Build a Theano expression for computing the accuracy of graph output.
Parameters
----------
outputs : dict of Theano expressions
A dictionary mapping network output names to Theano expressions
representing the outputs of a computat... | def accuracy(self, outputs):
'''Build a Theano expression for computing the accuracy of graph output.
Parameters
----------
outputs : dict of Theano expressions
A dictionary mapping network output names to Theano expressions
representing the outputs of a computat... | [
"Build",
"a",
"Theano",
"expression",
"for",
"computing",
"the",
"accuracy",
"of",
"graph",
"output",
"."
] | lmjohns3/theanets | python | https://github.com/lmjohns3/theanets/blob/79db9f878ef2071f2f576a1cf5d43a752a55894a/theanets/losses.py#L517-L538 | [
"def",
"accuracy",
"(",
"self",
",",
"outputs",
")",
":",
"output",
"=",
"outputs",
"[",
"self",
".",
"output_name",
"]",
"predict",
"=",
"TT",
".",
"argmax",
"(",
"output",
",",
"axis",
"=",
"-",
"1",
")",
"correct",
"=",
"TT",
".",
"eq",
"(",
"... | 79db9f878ef2071f2f576a1cf5d43a752a55894a |
test | Recurrent.add_weights | Helper method to create a new weight matrix.
Parameters
----------
name : str
Name of parameter to define.
nin : int, optional
Size of "input" for this weight matrix. Defaults to self.nin.
nout : int, optional
Size of "output" for this weight ... | theanets/layers/recurrent.py | def add_weights(self, name, nin, nout, mean=0, std=0, sparsity=0, radius=0,
diagonal=0):
'''Helper method to create a new weight matrix.
Parameters
----------
name : str
Name of parameter to define.
nin : int, optional
Size of "input" ... | def add_weights(self, name, nin, nout, mean=0, std=0, sparsity=0, radius=0,
diagonal=0):
'''Helper method to create a new weight matrix.
Parameters
----------
name : str
Name of parameter to define.
nin : int, optional
Size of "input" ... | [
"Helper",
"method",
"to",
"create",
"a",
"new",
"weight",
"matrix",
"."
] | lmjohns3/theanets | python | https://github.com/lmjohns3/theanets/blob/79db9f878ef2071f2f576a1cf5d43a752a55894a/theanets/layers/recurrent.py#L78-L119 | [
"def",
"add_weights",
"(",
"self",
",",
"name",
",",
"nin",
",",
"nout",
",",
"mean",
"=",
"0",
",",
"std",
"=",
"0",
",",
"sparsity",
"=",
"0",
",",
"radius",
"=",
"0",
",",
"diagonal",
"=",
"0",
")",
":",
"glorot",
"=",
"1",
"/",
"np",
".",... | 79db9f878ef2071f2f576a1cf5d43a752a55894a |
test | Recurrent._scan | Helper method for defining a basic loop in theano.
Parameters
----------
inputs : sequence of theano expressions
Inputs to the scan operation.
outputs : sequence of output specifiers
Specifiers for the outputs of the scan operation. This should be a
s... | theanets/layers/recurrent.py | def _scan(self, inputs, outputs, name='scan', step=None, constants=None):
'''Helper method for defining a basic loop in theano.
Parameters
----------
inputs : sequence of theano expressions
Inputs to the scan operation.
outputs : sequence of output specifiers
... | def _scan(self, inputs, outputs, name='scan', step=None, constants=None):
'''Helper method for defining a basic loop in theano.
Parameters
----------
inputs : sequence of theano expressions
Inputs to the scan operation.
outputs : sequence of output specifiers
... | [
"Helper",
"method",
"for",
"defining",
"a",
"basic",
"loop",
"in",
"theano",
"."
] | lmjohns3/theanets | python | https://github.com/lmjohns3/theanets/blob/79db9f878ef2071f2f576a1cf5d43a752a55894a/theanets/layers/recurrent.py#L121-L173 | [
"def",
"_scan",
"(",
"self",
",",
"inputs",
",",
"outputs",
",",
"name",
"=",
"'scan'",
",",
"step",
"=",
"None",
",",
"constants",
"=",
"None",
")",
":",
"init",
"=",
"[",
"]",
"for",
"i",
",",
"x",
"in",
"enumerate",
"(",
"outputs",
")",
":",
... | 79db9f878ef2071f2f576a1cf5d43a752a55894a |
test | Recurrent._create_rates | Create a rate parameter (usually for a recurrent network layer).
Parameters
----------
dist : {'uniform', 'log'}, optional
Distribution of rate values. Defaults to ``'uniform'``.
size : int, optional
Number of rates to create. Defaults to ``self.output_size``.
... | theanets/layers/recurrent.py | def _create_rates(self, dist='uniform', size=None, eps=1e-4):
'''Create a rate parameter (usually for a recurrent network layer).
Parameters
----------
dist : {'uniform', 'log'}, optional
Distribution of rate values. Defaults to ``'uniform'``.
size : int, optional
... | def _create_rates(self, dist='uniform', size=None, eps=1e-4):
'''Create a rate parameter (usually for a recurrent network layer).
Parameters
----------
dist : {'uniform', 'log'}, optional
Distribution of rate values. Defaults to ``'uniform'``.
size : int, optional
... | [
"Create",
"a",
"rate",
"parameter",
"(",
"usually",
"for",
"a",
"recurrent",
"network",
"layer",
")",
"."
] | lmjohns3/theanets | python | https://github.com/lmjohns3/theanets/blob/79db9f878ef2071f2f576a1cf5d43a752a55894a/theanets/layers/recurrent.py#L175-L201 | [
"def",
"_create_rates",
"(",
"self",
",",
"dist",
"=",
"'uniform'",
",",
"size",
"=",
"None",
",",
"eps",
"=",
"1e-4",
")",
":",
"if",
"size",
"is",
"None",
":",
"size",
"=",
"self",
".",
"output_size",
"if",
"dist",
"==",
"'uniform'",
":",
"z",
"=... | 79db9f878ef2071f2f576a1cf5d43a752a55894a |
test | build | Construct an activation function by name.
Parameters
----------
name : str or :class:`Activation`
The name of the type of activation function to build, or an
already-created instance of an activation function.
layer : :class:`theanets.layers.Layer`
The layer to which this activa... | theanets/activations.py | def build(name, layer, **kwargs):
'''Construct an activation function by name.
Parameters
----------
name : str or :class:`Activation`
The name of the type of activation function to build, or an
already-created instance of an activation function.
layer : :class:`theanets.layers.Laye... | def build(name, layer, **kwargs):
'''Construct an activation function by name.
Parameters
----------
name : str or :class:`Activation`
The name of the type of activation function to build, or an
already-created instance of an activation function.
layer : :class:`theanets.layers.Laye... | [
"Construct",
"an",
"activation",
"function",
"by",
"name",
"."
] | lmjohns3/theanets | python | https://github.com/lmjohns3/theanets/blob/79db9f878ef2071f2f576a1cf5d43a752a55894a/theanets/activations.py#L89-L125 | [
"def",
"build",
"(",
"name",
",",
"layer",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"isinstance",
"(",
"name",
",",
"Activation",
")",
":",
"return",
"name",
"if",
"'+'",
"in",
"name",
":",
"return",
"functools",
".",
"reduce",
"(",
"Compose",
",",
... | 79db9f878ef2071f2f576a1cf5d43a752a55894a |
test | DownhillTrainer.itertrain | Train a model using a training and validation set.
This method yields a series of monitor values to the caller. After every
iteration, a pair of monitor dictionaries is generated: one evaluated on
the training dataset, and another evaluated on the validation dataset.
The validation moni... | theanets/trainer.py | def itertrain(self, train, valid=None, **kwargs):
'''Train a model using a training and validation set.
This method yields a series of monitor values to the caller. After every
iteration, a pair of monitor dictionaries is generated: one evaluated on
the training dataset, and another eva... | def itertrain(self, train, valid=None, **kwargs):
'''Train a model using a training and validation set.
This method yields a series of monitor values to the caller. After every
iteration, a pair of monitor dictionaries is generated: one evaluated on
the training dataset, and another eva... | [
"Train",
"a",
"model",
"using",
"a",
"training",
"and",
"validation",
"set",
"."
] | lmjohns3/theanets | python | https://github.com/lmjohns3/theanets/blob/79db9f878ef2071f2f576a1cf5d43a752a55894a/theanets/trainer.py#L28-L64 | [
"def",
"itertrain",
"(",
"self",
",",
"train",
",",
"valid",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"for",
"monitors",
"in",
"downhill",
".",
"build",
"(",
"algo",
"=",
"self",
".",
"algo",
",",
"loss",
"=",
"self",
".",
"network",
".",
... | 79db9f878ef2071f2f576a1cf5d43a752a55894a |
test | SampleTrainer.reservoir | Select a random sample of n items from xs. | theanets/trainer.py | def reservoir(xs, n, rng):
'''Select a random sample of n items from xs.'''
pool = []
for i, x in enumerate(xs):
if len(pool) < n:
pool.append(x / np.linalg.norm(x))
continue
j = rng.randint(i + 1)
if j < n:
pool... | def reservoir(xs, n, rng):
'''Select a random sample of n items from xs.'''
pool = []
for i, x in enumerate(xs):
if len(pool) < n:
pool.append(x / np.linalg.norm(x))
continue
j = rng.randint(i + 1)
if j < n:
pool... | [
"Select",
"a",
"random",
"sample",
"of",
"n",
"items",
"from",
"xs",
"."
] | lmjohns3/theanets | python | https://github.com/lmjohns3/theanets/blob/79db9f878ef2071f2f576a1cf5d43a752a55894a/theanets/trainer.py#L71-L88 | [
"def",
"reservoir",
"(",
"xs",
",",
"n",
",",
"rng",
")",
":",
"pool",
"=",
"[",
"]",
"for",
"i",
",",
"x",
"in",
"enumerate",
"(",
"xs",
")",
":",
"if",
"len",
"(",
"pool",
")",
"<",
"n",
":",
"pool",
".",
"append",
"(",
"x",
"/",
"np",
... | 79db9f878ef2071f2f576a1cf5d43a752a55894a |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.