repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
cmbruns/pyopenvr
src/openvr/__init__.py
IVRInput.getSkeletalSummaryData
def getSkeletalSummaryData(self, action): """Reads summary information about the current pose of the skeleton associated with the given action.""" fn = self.function_table.getSkeletalSummaryData pSkeletalSummaryData = VRSkeletalSummaryData_t() result = fn(action, byref(pSkeletalSummaryD...
python
def getSkeletalSummaryData(self, action): """Reads summary information about the current pose of the skeleton associated with the given action.""" fn = self.function_table.getSkeletalSummaryData pSkeletalSummaryData = VRSkeletalSummaryData_t() result = fn(action, byref(pSkeletalSummaryD...
[ "def", "getSkeletalSummaryData", "(", "self", ",", "action", ")", ":", "fn", "=", "self", ".", "function_table", ".", "getSkeletalSummaryData", "pSkeletalSummaryData", "=", "VRSkeletalSummaryData_t", "(", ")", "result", "=", "fn", "(", "action", ",", "byref", "(...
Reads summary information about the current pose of the skeleton associated with the given action.
[ "Reads", "summary", "information", "about", "the", "current", "pose", "of", "the", "skeleton", "associated", "with", "the", "given", "action", "." ]
68395d26bb3df6ab1f0f059c38d441f962938be6
https://github.com/cmbruns/pyopenvr/blob/68395d26bb3df6ab1f0f059c38d441f962938be6/src/openvr/__init__.py#L6075-L6081
train
cmbruns/pyopenvr
src/openvr/__init__.py
IVRInput.decompressSkeletalBoneData
def decompressSkeletalBoneData(self, pvCompressedBuffer, unCompressedBufferSize, eTransformSpace, unTransformArrayCount): """Turns a compressed buffer from GetSkeletalBoneDataCompressed and turns it back into a bone transform array.""" fn = self.function_table.decompressSkeletalBoneData pTransf...
python
def decompressSkeletalBoneData(self, pvCompressedBuffer, unCompressedBufferSize, eTransformSpace, unTransformArrayCount): """Turns a compressed buffer from GetSkeletalBoneDataCompressed and turns it back into a bone transform array.""" fn = self.function_table.decompressSkeletalBoneData pTransf...
[ "def", "decompressSkeletalBoneData", "(", "self", ",", "pvCompressedBuffer", ",", "unCompressedBufferSize", ",", "eTransformSpace", ",", "unTransformArrayCount", ")", ":", "fn", "=", "self", ".", "function_table", ".", "decompressSkeletalBoneData", "pTransformArray", "=",...
Turns a compressed buffer from GetSkeletalBoneDataCompressed and turns it back into a bone transform array.
[ "Turns", "a", "compressed", "buffer", "from", "GetSkeletalBoneDataCompressed", "and", "turns", "it", "back", "into", "a", "bone", "transform", "array", "." ]
68395d26bb3df6ab1f0f059c38d441f962938be6
https://github.com/cmbruns/pyopenvr/blob/68395d26bb3df6ab1f0f059c38d441f962938be6/src/openvr/__init__.py#L6095-L6101
train
cmbruns/pyopenvr
src/openvr/__init__.py
IVRInput.triggerHapticVibrationAction
def triggerHapticVibrationAction(self, action, fStartSecondsFromNow, fDurationSeconds, fFrequency, fAmplitude, ulRestrictToDevice): """Triggers a haptic event as described by the specified action""" fn = self.function_table.triggerHapticVibrationAction result = fn(action, fStartSecondsFromNow, ...
python
def triggerHapticVibrationAction(self, action, fStartSecondsFromNow, fDurationSeconds, fFrequency, fAmplitude, ulRestrictToDevice): """Triggers a haptic event as described by the specified action""" fn = self.function_table.triggerHapticVibrationAction result = fn(action, fStartSecondsFromNow, ...
[ "def", "triggerHapticVibrationAction", "(", "self", ",", "action", ",", "fStartSecondsFromNow", ",", "fDurationSeconds", ",", "fFrequency", ",", "fAmplitude", ",", "ulRestrictToDevice", ")", ":", "fn", "=", "self", ".", "function_table", ".", "triggerHapticVibrationAc...
Triggers a haptic event as described by the specified action
[ "Triggers", "a", "haptic", "event", "as", "described", "by", "the", "specified", "action" ]
68395d26bb3df6ab1f0f059c38d441f962938be6
https://github.com/cmbruns/pyopenvr/blob/68395d26bb3df6ab1f0f059c38d441f962938be6/src/openvr/__init__.py#L6103-L6108
train
cmbruns/pyopenvr
src/openvr/__init__.py
IVRInput.getActionOrigins
def getActionOrigins(self, actionSetHandle, digitalActionHandle, originOutCount): """Retrieve origin handles for an action""" fn = self.function_table.getActionOrigins originsOut = VRInputValueHandle_t() result = fn(actionSetHandle, digitalActionHandle, byref(originsOut), originOutCount...
python
def getActionOrigins(self, actionSetHandle, digitalActionHandle, originOutCount): """Retrieve origin handles for an action""" fn = self.function_table.getActionOrigins originsOut = VRInputValueHandle_t() result = fn(actionSetHandle, digitalActionHandle, byref(originsOut), originOutCount...
[ "def", "getActionOrigins", "(", "self", ",", "actionSetHandle", ",", "digitalActionHandle", ",", "originOutCount", ")", ":", "fn", "=", "self", ".", "function_table", ".", "getActionOrigins", "originsOut", "=", "VRInputValueHandle_t", "(", ")", "result", "=", "fn"...
Retrieve origin handles for an action
[ "Retrieve", "origin", "handles", "for", "an", "action" ]
68395d26bb3df6ab1f0f059c38d441f962938be6
https://github.com/cmbruns/pyopenvr/blob/68395d26bb3df6ab1f0f059c38d441f962938be6/src/openvr/__init__.py#L6110-L6116
train
cmbruns/pyopenvr
src/openvr/__init__.py
IVRInput.getOriginLocalizedName
def getOriginLocalizedName(self, origin, pchNameArray, unNameArraySize, unStringSectionsToInclude): """ Retrieves the name of the origin in the current language. unStringSectionsToInclude is a bitfield of values in EVRInputStringBits that allows the application to specify which parts of the ori...
python
def getOriginLocalizedName(self, origin, pchNameArray, unNameArraySize, unStringSectionsToInclude): """ Retrieves the name of the origin in the current language. unStringSectionsToInclude is a bitfield of values in EVRInputStringBits that allows the application to specify which parts of the ori...
[ "def", "getOriginLocalizedName", "(", "self", ",", "origin", ",", "pchNameArray", ",", "unNameArraySize", ",", "unStringSectionsToInclude", ")", ":", "fn", "=", "self", ".", "function_table", ".", "getOriginLocalizedName", "result", "=", "fn", "(", "origin", ",", ...
Retrieves the name of the origin in the current language. unStringSectionsToInclude is a bitfield of values in EVRInputStringBits that allows the application to specify which parts of the origin's information it wants a string for.
[ "Retrieves", "the", "name", "of", "the", "origin", "in", "the", "current", "language", ".", "unStringSectionsToInclude", "is", "a", "bitfield", "of", "values", "in", "EVRInputStringBits", "that", "allows", "the", "application", "to", "specify", "which", "parts", ...
68395d26bb3df6ab1f0f059c38d441f962938be6
https://github.com/cmbruns/pyopenvr/blob/68395d26bb3df6ab1f0f059c38d441f962938be6/src/openvr/__init__.py#L6118-L6126
train
cmbruns/pyopenvr
src/openvr/__init__.py
IVRInput.getOriginTrackedDeviceInfo
def getOriginTrackedDeviceInfo(self, origin, unOriginInfoSize): """Retrieves useful information for the origin of this action""" fn = self.function_table.getOriginTrackedDeviceInfo pOriginInfo = InputOriginInfo_t() result = fn(origin, byref(pOriginInfo), unOriginInfoSize) return...
python
def getOriginTrackedDeviceInfo(self, origin, unOriginInfoSize): """Retrieves useful information for the origin of this action""" fn = self.function_table.getOriginTrackedDeviceInfo pOriginInfo = InputOriginInfo_t() result = fn(origin, byref(pOriginInfo), unOriginInfoSize) return...
[ "def", "getOriginTrackedDeviceInfo", "(", "self", ",", "origin", ",", "unOriginInfoSize", ")", ":", "fn", "=", "self", ".", "function_table", ".", "getOriginTrackedDeviceInfo", "pOriginInfo", "=", "InputOriginInfo_t", "(", ")", "result", "=", "fn", "(", "origin", ...
Retrieves useful information for the origin of this action
[ "Retrieves", "useful", "information", "for", "the", "origin", "of", "this", "action" ]
68395d26bb3df6ab1f0f059c38d441f962938be6
https://github.com/cmbruns/pyopenvr/blob/68395d26bb3df6ab1f0f059c38d441f962938be6/src/openvr/__init__.py#L6128-L6134
train
cmbruns/pyopenvr
src/openvr/__init__.py
IVRInput.showActionOrigins
def showActionOrigins(self, actionSetHandle, ulActionHandle): """Shows the current binding for the action in-headset""" fn = self.function_table.showActionOrigins result = fn(actionSetHandle, ulActionHandle) return result
python
def showActionOrigins(self, actionSetHandle, ulActionHandle): """Shows the current binding for the action in-headset""" fn = self.function_table.showActionOrigins result = fn(actionSetHandle, ulActionHandle) return result
[ "def", "showActionOrigins", "(", "self", ",", "actionSetHandle", ",", "ulActionHandle", ")", ":", "fn", "=", "self", ".", "function_table", ".", "showActionOrigins", "result", "=", "fn", "(", "actionSetHandle", ",", "ulActionHandle", ")", "return", "result" ]
Shows the current binding for the action in-headset
[ "Shows", "the", "current", "binding", "for", "the", "action", "in", "-", "headset" ]
68395d26bb3df6ab1f0f059c38d441f962938be6
https://github.com/cmbruns/pyopenvr/blob/68395d26bb3df6ab1f0f059c38d441f962938be6/src/openvr/__init__.py#L6136-L6141
train
cmbruns/pyopenvr
src/openvr/__init__.py
IVRInput.showBindingsForActionSet
def showBindingsForActionSet(self, unSizeOfVRSelectedActionSet_t, unSetCount, originToHighlight): """Shows the current binding all the actions in the specified action sets""" fn = self.function_table.showBindingsForActionSet pSets = VRActiveActionSet_t() result = fn(byref(pSets), unSize...
python
def showBindingsForActionSet(self, unSizeOfVRSelectedActionSet_t, unSetCount, originToHighlight): """Shows the current binding all the actions in the specified action sets""" fn = self.function_table.showBindingsForActionSet pSets = VRActiveActionSet_t() result = fn(byref(pSets), unSize...
[ "def", "showBindingsForActionSet", "(", "self", ",", "unSizeOfVRSelectedActionSet_t", ",", "unSetCount", ",", "originToHighlight", ")", ":", "fn", "=", "self", ".", "function_table", ".", "showBindingsForActionSet", "pSets", "=", "VRActiveActionSet_t", "(", ")", "resu...
Shows the current binding all the actions in the specified action sets
[ "Shows", "the", "current", "binding", "all", "the", "actions", "in", "the", "specified", "action", "sets" ]
68395d26bb3df6ab1f0f059c38d441f962938be6
https://github.com/cmbruns/pyopenvr/blob/68395d26bb3df6ab1f0f059c38d441f962938be6/src/openvr/__init__.py#L6143-L6149
train
cmbruns/pyopenvr
src/openvr/__init__.py
IVRIOBuffer.open
def open(self, pchPath, mode, unElementSize, unElements): """opens an existing or creates a new IOBuffer of unSize bytes""" fn = self.function_table.open pulBuffer = IOBufferHandle_t() result = fn(pchPath, mode, unElementSize, unElements, byref(pulBuffer)) return result, pulBuff...
python
def open(self, pchPath, mode, unElementSize, unElements): """opens an existing or creates a new IOBuffer of unSize bytes""" fn = self.function_table.open pulBuffer = IOBufferHandle_t() result = fn(pchPath, mode, unElementSize, unElements, byref(pulBuffer)) return result, pulBuff...
[ "def", "open", "(", "self", ",", "pchPath", ",", "mode", ",", "unElementSize", ",", "unElements", ")", ":", "fn", "=", "self", ".", "function_table", ".", "open", "pulBuffer", "=", "IOBufferHandle_t", "(", ")", "result", "=", "fn", "(", "pchPath", ",", ...
opens an existing or creates a new IOBuffer of unSize bytes
[ "opens", "an", "existing", "or", "creates", "a", "new", "IOBuffer", "of", "unSize", "bytes" ]
68395d26bb3df6ab1f0f059c38d441f962938be6
https://github.com/cmbruns/pyopenvr/blob/68395d26bb3df6ab1f0f059c38d441f962938be6/src/openvr/__init__.py#L6190-L6196
train
cmbruns/pyopenvr
src/openvr/__init__.py
IVRIOBuffer.close
def close(self, ulBuffer): """closes a previously opened or created buffer""" fn = self.function_table.close result = fn(ulBuffer) return result
python
def close(self, ulBuffer): """closes a previously opened or created buffer""" fn = self.function_table.close result = fn(ulBuffer) return result
[ "def", "close", "(", "self", ",", "ulBuffer", ")", ":", "fn", "=", "self", ".", "function_table", ".", "close", "result", "=", "fn", "(", "ulBuffer", ")", "return", "result" ]
closes a previously opened or created buffer
[ "closes", "a", "previously", "opened", "or", "created", "buffer" ]
68395d26bb3df6ab1f0f059c38d441f962938be6
https://github.com/cmbruns/pyopenvr/blob/68395d26bb3df6ab1f0f059c38d441f962938be6/src/openvr/__init__.py#L6198-L6203
train
cmbruns/pyopenvr
src/openvr/__init__.py
IVRIOBuffer.propertyContainer
def propertyContainer(self, ulBuffer): """retrieves the property container of an buffer.""" fn = self.function_table.propertyContainer result = fn(ulBuffer) return result
python
def propertyContainer(self, ulBuffer): """retrieves the property container of an buffer.""" fn = self.function_table.propertyContainer result = fn(ulBuffer) return result
[ "def", "propertyContainer", "(", "self", ",", "ulBuffer", ")", ":", "fn", "=", "self", ".", "function_table", ".", "propertyContainer", "result", "=", "fn", "(", "ulBuffer", ")", "return", "result" ]
retrieves the property container of an buffer.
[ "retrieves", "the", "property", "container", "of", "an", "buffer", "." ]
68395d26bb3df6ab1f0f059c38d441f962938be6
https://github.com/cmbruns/pyopenvr/blob/68395d26bb3df6ab1f0f059c38d441f962938be6/src/openvr/__init__.py#L6220-L6225
train
cmbruns/pyopenvr
src/openvr/__init__.py
IVRIOBuffer.hasReaders
def hasReaders(self, ulBuffer): """inexpensively checks for readers to allow writers to fast-fail potentially expensive copies and writes.""" fn = self.function_table.hasReaders result = fn(ulBuffer) return result
python
def hasReaders(self, ulBuffer): """inexpensively checks for readers to allow writers to fast-fail potentially expensive copies and writes.""" fn = self.function_table.hasReaders result = fn(ulBuffer) return result
[ "def", "hasReaders", "(", "self", ",", "ulBuffer", ")", ":", "fn", "=", "self", ".", "function_table", ".", "hasReaders", "result", "=", "fn", "(", "ulBuffer", ")", "return", "result" ]
inexpensively checks for readers to allow writers to fast-fail potentially expensive copies and writes.
[ "inexpensively", "checks", "for", "readers", "to", "allow", "writers", "to", "fast", "-", "fail", "potentially", "expensive", "copies", "and", "writes", "." ]
68395d26bb3df6ab1f0f059c38d441f962938be6
https://github.com/cmbruns/pyopenvr/blob/68395d26bb3df6ab1f0f059c38d441f962938be6/src/openvr/__init__.py#L6227-L6232
train
aio-libs/aioodbc
aioodbc/cursor.py
Cursor.execute
async def execute(self, sql, *params): """Executes the given operation substituting any markers with the given parameters. :param sql: the SQL statement to execute with optional ? parameter markers. Note that pyodbc never modifies the SQL statement. :param params: optional p...
python
async def execute(self, sql, *params): """Executes the given operation substituting any markers with the given parameters. :param sql: the SQL statement to execute with optional ? parameter markers. Note that pyodbc never modifies the SQL statement. :param params: optional p...
[ "async", "def", "execute", "(", "self", ",", "sql", ",", "*", "params", ")", ":", "if", "self", ".", "_echo", ":", "logger", ".", "info", "(", "sql", ")", "logger", ".", "info", "(", "\"%r\"", ",", "sql", ")", "await", "self", ".", "_run_operation"...
Executes the given operation substituting any markers with the given parameters. :param sql: the SQL statement to execute with optional ? parameter markers. Note that pyodbc never modifies the SQL statement. :param params: optional parameters for the markers in the SQL. They ...
[ "Executes", "the", "given", "operation", "substituting", "any", "markers", "with", "the", "given", "parameters", "." ]
01245560828d4adce0d7d16930fa566102322a0a
https://github.com/aio-libs/aioodbc/blob/01245560828d4adce0d7d16930fa566102322a0a/aioodbc/cursor.py#L108-L122
train
aio-libs/aioodbc
aioodbc/cursor.py
Cursor.executemany
def executemany(self, sql, *params): """Prepare a database query or command and then execute it against all parameter sequences found in the sequence seq_of_params. :param sql: the SQL statement to execute with optional ? parameters :param params: sequence parameters for the markers in...
python
def executemany(self, sql, *params): """Prepare a database query or command and then execute it against all parameter sequences found in the sequence seq_of_params. :param sql: the SQL statement to execute with optional ? parameters :param params: sequence parameters for the markers in...
[ "def", "executemany", "(", "self", ",", "sql", ",", "*", "params", ")", ":", "fut", "=", "self", ".", "_run_operation", "(", "self", ".", "_impl", ".", "executemany", ",", "sql", ",", "*", "params", ")", "return", "fut" ]
Prepare a database query or command and then execute it against all parameter sequences found in the sequence seq_of_params. :param sql: the SQL statement to execute with optional ? parameters :param params: sequence parameters for the markers in the SQL.
[ "Prepare", "a", "database", "query", "or", "command", "and", "then", "execute", "it", "against", "all", "parameter", "sequences", "found", "in", "the", "sequence", "seq_of_params", "." ]
01245560828d4adce0d7d16930fa566102322a0a
https://github.com/aio-libs/aioodbc/blob/01245560828d4adce0d7d16930fa566102322a0a/aioodbc/cursor.py#L124-L132
train
aio-libs/aioodbc
aioodbc/cursor.py
Cursor.fetchmany
def fetchmany(self, size): """Returns a list of remaining rows, containing no more than size rows, used to process results in chunks. The list will be empty when there are no more rows. The default for cursor.arraysize is 1 which is no different than calling fetchone(). ...
python
def fetchmany(self, size): """Returns a list of remaining rows, containing no more than size rows, used to process results in chunks. The list will be empty when there are no more rows. The default for cursor.arraysize is 1 which is no different than calling fetchone(). ...
[ "def", "fetchmany", "(", "self", ",", "size", ")", ":", "fut", "=", "self", ".", "_run_operation", "(", "self", ".", "_impl", ".", "fetchmany", ",", "size", ")", "return", "fut" ]
Returns a list of remaining rows, containing no more than size rows, used to process results in chunks. The list will be empty when there are no more rows. The default for cursor.arraysize is 1 which is no different than calling fetchone(). A ProgrammingError exception is raise...
[ "Returns", "a", "list", "of", "remaining", "rows", "containing", "no", "more", "than", "size", "rows", "used", "to", "process", "results", "in", "chunks", ".", "The", "list", "will", "be", "empty", "when", "there", "are", "no", "more", "rows", "." ]
01245560828d4adce0d7d16930fa566102322a0a
https://github.com/aio-libs/aioodbc/blob/01245560828d4adce0d7d16930fa566102322a0a/aioodbc/cursor.py#L169-L184
train
aio-libs/aioodbc
aioodbc/cursor.py
Cursor.tables
def tables(self, **kw): """Creates a result set of tables in the database that match the given criteria. :param table: the table tname :param catalog: the catalog name :param schema: the schmea name :param tableType: one of TABLE, VIEW, SYSTEM TABLE ... """ ...
python
def tables(self, **kw): """Creates a result set of tables in the database that match the given criteria. :param table: the table tname :param catalog: the catalog name :param schema: the schmea name :param tableType: one of TABLE, VIEW, SYSTEM TABLE ... """ ...
[ "def", "tables", "(", "self", ",", "*", "*", "kw", ")", ":", "fut", "=", "self", ".", "_run_operation", "(", "self", ".", "_impl", ".", "tables", ",", "*", "*", "kw", ")", "return", "fut" ]
Creates a result set of tables in the database that match the given criteria. :param table: the table tname :param catalog: the catalog name :param schema: the schmea name :param tableType: one of TABLE, VIEW, SYSTEM TABLE ...
[ "Creates", "a", "result", "set", "of", "tables", "in", "the", "database", "that", "match", "the", "given", "criteria", "." ]
01245560828d4adce0d7d16930fa566102322a0a
https://github.com/aio-libs/aioodbc/blob/01245560828d4adce0d7d16930fa566102322a0a/aioodbc/cursor.py#L200-L210
train
aio-libs/aioodbc
aioodbc/cursor.py
Cursor.columns
def columns(self, **kw): """Creates a results set of column names in specified tables by executing the ODBC SQLColumns function. Each row fetched has the following columns. :param table: the table tname :param catalog: the catalog name :param schema: the schmea name ...
python
def columns(self, **kw): """Creates a results set of column names in specified tables by executing the ODBC SQLColumns function. Each row fetched has the following columns. :param table: the table tname :param catalog: the catalog name :param schema: the schmea name ...
[ "def", "columns", "(", "self", ",", "*", "*", "kw", ")", ":", "fut", "=", "self", ".", "_run_operation", "(", "self", ".", "_impl", ".", "columns", ",", "*", "*", "kw", ")", "return", "fut" ]
Creates a results set of column names in specified tables by executing the ODBC SQLColumns function. Each row fetched has the following columns. :param table: the table tname :param catalog: the catalog name :param schema: the schmea name :param column: string search pat...
[ "Creates", "a", "results", "set", "of", "column", "names", "in", "specified", "tables", "by", "executing", "the", "ODBC", "SQLColumns", "function", ".", "Each", "row", "fetched", "has", "the", "following", "columns", "." ]
01245560828d4adce0d7d16930fa566102322a0a
https://github.com/aio-libs/aioodbc/blob/01245560828d4adce0d7d16930fa566102322a0a/aioodbc/cursor.py#L212-L223
train
aio-libs/aioodbc
aioodbc/cursor.py
Cursor.statistics
def statistics(self, catalog=None, schema=None, unique=False, quick=True): """Creates a results set of statistics about a single table and the indexes associated with the table by executing SQLStatistics. :param catalog: the catalog name :param schema: the schmea name :param uni...
python
def statistics(self, catalog=None, schema=None, unique=False, quick=True): """Creates a results set of statistics about a single table and the indexes associated with the table by executing SQLStatistics. :param catalog: the catalog name :param schema: the schmea name :param uni...
[ "def", "statistics", "(", "self", ",", "catalog", "=", "None", ",", "schema", "=", "None", ",", "unique", "=", "False", ",", "quick", "=", "True", ")", ":", "fut", "=", "self", ".", "_run_operation", "(", "self", ".", "_impl", ".", "statistics", ",",...
Creates a results set of statistics about a single table and the indexes associated with the table by executing SQLStatistics. :param catalog: the catalog name :param schema: the schmea name :param unique: if True, only unique indexes are retured. Otherwise all indexes are r...
[ "Creates", "a", "results", "set", "of", "statistics", "about", "a", "single", "table", "and", "the", "indexes", "associated", "with", "the", "table", "by", "executing", "SQLStatistics", "." ]
01245560828d4adce0d7d16930fa566102322a0a
https://github.com/aio-libs/aioodbc/blob/01245560828d4adce0d7d16930fa566102322a0a/aioodbc/cursor.py#L225-L238
train
aio-libs/aioodbc
aioodbc/cursor.py
Cursor.rowIdColumns
def rowIdColumns(self, table, catalog=None, schema=None, # nopep8 nullable=True): """Executes SQLSpecialColumns with SQL_BEST_ROWID which creates a result set of columns that uniquely identify a row """ fut = self._run_operation(self._impl.rowIdColumns, table, ...
python
def rowIdColumns(self, table, catalog=None, schema=None, # nopep8 nullable=True): """Executes SQLSpecialColumns with SQL_BEST_ROWID which creates a result set of columns that uniquely identify a row """ fut = self._run_operation(self._impl.rowIdColumns, table, ...
[ "def", "rowIdColumns", "(", "self", ",", "table", ",", "catalog", "=", "None", ",", "schema", "=", "None", ",", "# nopep8", "nullable", "=", "True", ")", ":", "fut", "=", "self", ".", "_run_operation", "(", "self", ".", "_impl", ".", "rowIdColumns", ",...
Executes SQLSpecialColumns with SQL_BEST_ROWID which creates a result set of columns that uniquely identify a row
[ "Executes", "SQLSpecialColumns", "with", "SQL_BEST_ROWID", "which", "creates", "a", "result", "set", "of", "columns", "that", "uniquely", "identify", "a", "row" ]
01245560828d4adce0d7d16930fa566102322a0a
https://github.com/aio-libs/aioodbc/blob/01245560828d4adce0d7d16930fa566102322a0a/aioodbc/cursor.py#L240-L248
train
aio-libs/aioodbc
aioodbc/cursor.py
Cursor.primaryKeys
def primaryKeys(self, table, catalog=None, schema=None): # nopep8 """Creates a result set of column names that make up the primary key for a table by executing the SQLPrimaryKeys function.""" fut = self._run_operation(self._impl.primaryKeys, table, catalog=cata...
python
def primaryKeys(self, table, catalog=None, schema=None): # nopep8 """Creates a result set of column names that make up the primary key for a table by executing the SQLPrimaryKeys function.""" fut = self._run_operation(self._impl.primaryKeys, table, catalog=cata...
[ "def", "primaryKeys", "(", "self", ",", "table", ",", "catalog", "=", "None", ",", "schema", "=", "None", ")", ":", "# nopep8", "fut", "=", "self", ".", "_run_operation", "(", "self", ".", "_impl", ".", "primaryKeys", ",", "table", ",", "catalog", "=",...
Creates a result set of column names that make up the primary key for a table by executing the SQLPrimaryKeys function.
[ "Creates", "a", "result", "set", "of", "column", "names", "that", "make", "up", "the", "primary", "key", "for", "a", "table", "by", "executing", "the", "SQLPrimaryKeys", "function", "." ]
01245560828d4adce0d7d16930fa566102322a0a
https://github.com/aio-libs/aioodbc/blob/01245560828d4adce0d7d16930fa566102322a0a/aioodbc/cursor.py#L261-L266
train
aio-libs/aioodbc
aioodbc/cursor.py
Cursor.getTypeInfo
def getTypeInfo(self, sql_type): # nopep8 """Executes SQLGetTypeInfo a creates a result set with information about the specified data type or all data types supported by the ODBC driver if not specified. """ fut = self._run_operation(self._impl.getTypeInfo, sql_type) ret...
python
def getTypeInfo(self, sql_type): # nopep8 """Executes SQLGetTypeInfo a creates a result set with information about the specified data type or all data types supported by the ODBC driver if not specified. """ fut = self._run_operation(self._impl.getTypeInfo, sql_type) ret...
[ "def", "getTypeInfo", "(", "self", ",", "sql_type", ")", ":", "# nopep8", "fut", "=", "self", ".", "_run_operation", "(", "self", ".", "_impl", ".", "getTypeInfo", ",", "sql_type", ")", "return", "fut" ]
Executes SQLGetTypeInfo a creates a result set with information about the specified data type or all data types supported by the ODBC driver if not specified.
[ "Executes", "SQLGetTypeInfo", "a", "creates", "a", "result", "set", "with", "information", "about", "the", "specified", "data", "type", "or", "all", "data", "types", "supported", "by", "the", "ODBC", "driver", "if", "not", "specified", "." ]
01245560828d4adce0d7d16930fa566102322a0a
https://github.com/aio-libs/aioodbc/blob/01245560828d4adce0d7d16930fa566102322a0a/aioodbc/cursor.py#L278-L284
train
aio-libs/aioodbc
aioodbc/cursor.py
Cursor.procedures
def procedures(self, *a, **kw): """Executes SQLProcedures and creates a result set of information about the procedures in the data source. """ fut = self._run_operation(self._impl.procedures, *a, **kw) return fut
python
def procedures(self, *a, **kw): """Executes SQLProcedures and creates a result set of information about the procedures in the data source. """ fut = self._run_operation(self._impl.procedures, *a, **kw) return fut
[ "def", "procedures", "(", "self", ",", "*", "a", ",", "*", "*", "kw", ")", ":", "fut", "=", "self", ".", "_run_operation", "(", "self", ".", "_impl", ".", "procedures", ",", "*", "a", ",", "*", "*", "kw", ")", "return", "fut" ]
Executes SQLProcedures and creates a result set of information about the procedures in the data source.
[ "Executes", "SQLProcedures", "and", "creates", "a", "result", "set", "of", "information", "about", "the", "procedures", "in", "the", "data", "source", "." ]
01245560828d4adce0d7d16930fa566102322a0a
https://github.com/aio-libs/aioodbc/blob/01245560828d4adce0d7d16930fa566102322a0a/aioodbc/cursor.py#L286-L291
train
aio-libs/aioodbc
aioodbc/__init__.py
dataSources
async def dataSources(loop=None, executor=None): """Returns a dictionary mapping available DSNs to their descriptions. :param loop: asyncio compatible event loop :param executor: instance of custom ThreadPoolExecutor, if not supplied default executor will be used :return dict: mapping of dsn to...
python
async def dataSources(loop=None, executor=None): """Returns a dictionary mapping available DSNs to their descriptions. :param loop: asyncio compatible event loop :param executor: instance of custom ThreadPoolExecutor, if not supplied default executor will be used :return dict: mapping of dsn to...
[ "async", "def", "dataSources", "(", "loop", "=", "None", ",", "executor", "=", "None", ")", ":", "loop", "=", "loop", "or", "asyncio", ".", "get_event_loop", "(", ")", "sources", "=", "await", "loop", ".", "run_in_executor", "(", "executor", ",", "_dataS...
Returns a dictionary mapping available DSNs to their descriptions. :param loop: asyncio compatible event loop :param executor: instance of custom ThreadPoolExecutor, if not supplied default executor will be used :return dict: mapping of dsn to driver description
[ "Returns", "a", "dictionary", "mapping", "available", "DSNs", "to", "their", "descriptions", "." ]
01245560828d4adce0d7d16930fa566102322a0a
https://github.com/aio-libs/aioodbc/blob/01245560828d4adce0d7d16930fa566102322a0a/aioodbc/__init__.py#L14-L24
train
aio-libs/aioodbc
aioodbc/connection.py
connect
def connect(*, dsn, autocommit=False, ansi=False, timeout=0, loop=None, executor=None, echo=False, after_created=None, **kwargs): """Accepts an ODBC connection string and returns a new Connection object. The connection string can be passed as the string `str`, as a list of keywords,or a combina...
python
def connect(*, dsn, autocommit=False, ansi=False, timeout=0, loop=None, executor=None, echo=False, after_created=None, **kwargs): """Accepts an ODBC connection string and returns a new Connection object. The connection string can be passed as the string `str`, as a list of keywords,or a combina...
[ "def", "connect", "(", "*", ",", "dsn", ",", "autocommit", "=", "False", ",", "ansi", "=", "False", ",", "timeout", "=", "0", ",", "loop", "=", "None", ",", "executor", "=", "None", ",", "echo", "=", "False", ",", "after_created", "=", "None", ",",...
Accepts an ODBC connection string and returns a new Connection object. The connection string can be passed as the string `str`, as a list of keywords,or a combination of the two. Any keywords except autocommit, ansi, and timeout are simply added to the connection string. :param autocommit bool: False...
[ "Accepts", "an", "ODBC", "connection", "string", "and", "returns", "a", "new", "Connection", "object", "." ]
01245560828d4adce0d7d16930fa566102322a0a
https://github.com/aio-libs/aioodbc/blob/01245560828d4adce0d7d16930fa566102322a0a/aioodbc/connection.py#L15-L40
train
aio-libs/aioodbc
aioodbc/connection.py
Connection.close
async def close(self): """Close pyodbc connection""" if not self._conn: return c = await self._execute(self._conn.close) self._conn = None return c
python
async def close(self): """Close pyodbc connection""" if not self._conn: return c = await self._execute(self._conn.close) self._conn = None return c
[ "async", "def", "close", "(", "self", ")", ":", "if", "not", "self", ".", "_conn", ":", "return", "c", "=", "await", "self", ".", "_execute", "(", "self", ".", "_conn", ".", "close", ")", "self", ".", "_conn", "=", "None", "return", "c" ]
Close pyodbc connection
[ "Close", "pyodbc", "connection" ]
01245560828d4adce0d7d16930fa566102322a0a
https://github.com/aio-libs/aioodbc/blob/01245560828d4adce0d7d16930fa566102322a0a/aioodbc/connection.py#L133-L139
train
aio-libs/aioodbc
aioodbc/connection.py
Connection.execute
async def execute(self, sql, *args): """Create a new Cursor object, call its execute method, and return it. See Cursor.execute for more details.This is a convenience method that is not part of the DB API. Since a new Cursor is allocated by each call, this should not be used if more tha...
python
async def execute(self, sql, *args): """Create a new Cursor object, call its execute method, and return it. See Cursor.execute for more details.This is a convenience method that is not part of the DB API. Since a new Cursor is allocated by each call, this should not be used if more tha...
[ "async", "def", "execute", "(", "self", ",", "sql", ",", "*", "args", ")", ":", "_cursor", "=", "await", "self", ".", "_execute", "(", "self", ".", "_conn", ".", "execute", ",", "sql", ",", "*", "args", ")", "connection", "=", "self", "cursor", "="...
Create a new Cursor object, call its execute method, and return it. See Cursor.execute for more details.This is a convenience method that is not part of the DB API. Since a new Cursor is allocated by each call, this should not be used if more than one SQL statement needs to be executed...
[ "Create", "a", "new", "Cursor", "object", "call", "its", "execute", "method", "and", "return", "it", "." ]
01245560828d4adce0d7d16930fa566102322a0a
https://github.com/aio-libs/aioodbc/blob/01245560828d4adce0d7d16930fa566102322a0a/aioodbc/connection.py#L153-L167
train
aio-libs/aioodbc
aioodbc/connection.py
Connection.getinfo
def getinfo(self, type_): """Returns general information about the driver and data source associated with a connection by calling SQLGetInfo and returning its results. See Microsoft's SQLGetInfo documentation for the types of information available. :param type_: int, pyodbc.SQL_...
python
def getinfo(self, type_): """Returns general information about the driver and data source associated with a connection by calling SQLGetInfo and returning its results. See Microsoft's SQLGetInfo documentation for the types of information available. :param type_: int, pyodbc.SQL_...
[ "def", "getinfo", "(", "self", ",", "type_", ")", ":", "fut", "=", "self", ".", "_execute", "(", "self", ".", "_conn", ".", "getinfo", ",", "type_", ")", "return", "fut" ]
Returns general information about the driver and data source associated with a connection by calling SQLGetInfo and returning its results. See Microsoft's SQLGetInfo documentation for the types of information available. :param type_: int, pyodbc.SQL_* constant
[ "Returns", "general", "information", "about", "the", "driver", "and", "data", "source", "associated", "with", "a", "connection", "by", "calling", "SQLGetInfo", "and", "returning", "its", "results", ".", "See", "Microsoft", "s", "SQLGetInfo", "documentation", "for"...
01245560828d4adce0d7d16930fa566102322a0a
https://github.com/aio-libs/aioodbc/blob/01245560828d4adce0d7d16930fa566102322a0a/aioodbc/connection.py#L169-L178
train
aio-libs/aioodbc
aioodbc/connection.py
Connection.add_output_converter
def add_output_converter(self, sqltype, func): """Register an output converter function that will be called whenever a value with the given SQL type is read from the database. :param sqltype: the integer SQL type value to convert, which can be one of the defined standard constants (...
python
def add_output_converter(self, sqltype, func): """Register an output converter function that will be called whenever a value with the given SQL type is read from the database. :param sqltype: the integer SQL type value to convert, which can be one of the defined standard constants (...
[ "def", "add_output_converter", "(", "self", ",", "sqltype", ",", "func", ")", ":", "fut", "=", "self", ".", "_execute", "(", "self", ".", "_conn", ".", "add_output_converter", ",", "sqltype", ",", "func", ")", "return", "fut" ]
Register an output converter function that will be called whenever a value with the given SQL type is read from the database. :param sqltype: the integer SQL type value to convert, which can be one of the defined standard constants (pyodbc.SQL_VARCHAR) or a database-specific val...
[ "Register", "an", "output", "converter", "function", "that", "will", "be", "called", "whenever", "a", "value", "with", "the", "given", "SQL", "type", "is", "read", "from", "the", "database", "." ]
01245560828d4adce0d7d16930fa566102322a0a
https://github.com/aio-libs/aioodbc/blob/01245560828d4adce0d7d16930fa566102322a0a/aioodbc/connection.py#L180-L194
train
aio-libs/aioodbc
aioodbc/connection.py
Connection.set_attr
def set_attr(self, attr_id, value): """Calls SQLSetConnectAttr with the given values. :param attr_id: the attribute ID (integer) to set. These are ODBC or driver constants. :parm value: the connection attribute value to set. At this time only integer values are supported...
python
def set_attr(self, attr_id, value): """Calls SQLSetConnectAttr with the given values. :param attr_id: the attribute ID (integer) to set. These are ODBC or driver constants. :parm value: the connection attribute value to set. At this time only integer values are supported...
[ "def", "set_attr", "(", "self", ",", "attr_id", ",", "value", ")", ":", "fut", "=", "self", ".", "_execute", "(", "self", ".", "_conn", ".", "set_attr", ",", "attr_id", ",", "value", ")", "return", "fut" ]
Calls SQLSetConnectAttr with the given values. :param attr_id: the attribute ID (integer) to set. These are ODBC or driver constants. :parm value: the connection attribute value to set. At this time only integer values are supported.
[ "Calls", "SQLSetConnectAttr", "with", "the", "given", "values", "." ]
01245560828d4adce0d7d16930fa566102322a0a
https://github.com/aio-libs/aioodbc/blob/01245560828d4adce0d7d16930fa566102322a0a/aioodbc/connection.py#L203-L212
train
tsifrer/python-twitch-client
twitch/api/base.py
TwitchAPI._request_get
def _request_get(self, path, params=None, json=True, url=BASE_URL): """Perform a HTTP GET request.""" url = urljoin(url, path) headers = self._get_request_headers() response = requests.get(url, params=params, headers=headers) if response.status_code >= 500: backoff ...
python
def _request_get(self, path, params=None, json=True, url=BASE_URL): """Perform a HTTP GET request.""" url = urljoin(url, path) headers = self._get_request_headers() response = requests.get(url, params=params, headers=headers) if response.status_code >= 500: backoff ...
[ "def", "_request_get", "(", "self", ",", "path", ",", "params", "=", "None", ",", "json", "=", "True", ",", "url", "=", "BASE_URL", ")", ":", "url", "=", "urljoin", "(", "url", ",", "path", ")", "headers", "=", "self", ".", "_get_request_headers", "(...
Perform a HTTP GET request.
[ "Perform", "a", "HTTP", "GET", "request", "." ]
d8eda09acddabe1a9fd9eb76b3f454fa827b5074
https://github.com/tsifrer/python-twitch-client/blob/d8eda09acddabe1a9fd9eb76b3f454fa827b5074/twitch/api/base.py#L34-L57
train
tsifrer/python-twitch-client
twitch/api/base.py
TwitchAPI._request_post
def _request_post(self, path, data=None, params=None, url=BASE_URL): """Perform a HTTP POST request..""" url = urljoin(url, path) headers = self._get_request_headers() response = requests.post( url, json=data, params=params, headers=headers, timeout=DEFAULT_TIME...
python
def _request_post(self, path, data=None, params=None, url=BASE_URL): """Perform a HTTP POST request..""" url = urljoin(url, path) headers = self._get_request_headers() response = requests.post( url, json=data, params=params, headers=headers, timeout=DEFAULT_TIME...
[ "def", "_request_post", "(", "self", ",", "path", ",", "data", "=", "None", ",", "params", "=", "None", ",", "url", "=", "BASE_URL", ")", ":", "url", "=", "urljoin", "(", "url", ",", "path", ")", "headers", "=", "self", ".", "_get_request_headers", "...
Perform a HTTP POST request..
[ "Perform", "a", "HTTP", "POST", "request", ".." ]
d8eda09acddabe1a9fd9eb76b3f454fa827b5074
https://github.com/tsifrer/python-twitch-client/blob/d8eda09acddabe1a9fd9eb76b3f454fa827b5074/twitch/api/base.py#L59-L70
train
tsifrer/python-twitch-client
twitch/api/base.py
TwitchAPI._request_delete
def _request_delete(self, path, params=None, url=BASE_URL): """Perform a HTTP DELETE request.""" url = urljoin(url, path) headers = self._get_request_headers() response = requests.delete( url, params=params, headers=headers, timeout=DEFAULT_TIMEOUT) response.raise_f...
python
def _request_delete(self, path, params=None, url=BASE_URL): """Perform a HTTP DELETE request.""" url = urljoin(url, path) headers = self._get_request_headers() response = requests.delete( url, params=params, headers=headers, timeout=DEFAULT_TIMEOUT) response.raise_f...
[ "def", "_request_delete", "(", "self", ",", "path", ",", "params", "=", "None", ",", "url", "=", "BASE_URL", ")", ":", "url", "=", "urljoin", "(", "url", ",", "path", ")", "headers", "=", "self", ".", "_get_request_headers", "(", ")", "response", "=", ...
Perform a HTTP DELETE request.
[ "Perform", "a", "HTTP", "DELETE", "request", "." ]
d8eda09acddabe1a9fd9eb76b3f454fa827b5074
https://github.com/tsifrer/python-twitch-client/blob/d8eda09acddabe1a9fd9eb76b3f454fa827b5074/twitch/api/base.py#L84-L94
train
jgorset/facepy
facepy/signed_request.py
SignedRequest.parse
def parse(cls, signed_request, application_secret_key): """Parse a signed request, returning a dictionary describing its payload.""" def decode(encoded): padding = '=' * (len(encoded) % 4) return base64.urlsafe_b64decode(encoded + padding) try: encoded_signat...
python
def parse(cls, signed_request, application_secret_key): """Parse a signed request, returning a dictionary describing its payload.""" def decode(encoded): padding = '=' * (len(encoded) % 4) return base64.urlsafe_b64decode(encoded + padding) try: encoded_signat...
[ "def", "parse", "(", "cls", ",", "signed_request", ",", "application_secret_key", ")", ":", "def", "decode", "(", "encoded", ")", ":", "padding", "=", "'='", "*", "(", "len", "(", "encoded", ")", "%", "4", ")", "return", "base64", ".", "urlsafe_b64decode...
Parse a signed request, returning a dictionary describing its payload.
[ "Parse", "a", "signed", "request", "returning", "a", "dictionary", "describing", "its", "payload", "." ]
1be3ee21389fb2db543927a2f4ffa949faec4242
https://github.com/jgorset/facepy/blob/1be3ee21389fb2db543927a2f4ffa949faec4242/facepy/signed_request.py#L92-L113
train
jgorset/facepy
facepy/signed_request.py
SignedRequest.generate
def generate(self): """Generate a signed request from this instance.""" payload = { 'algorithm': 'HMAC-SHA256' } if self.data: payload['app_data'] = self.data if self.page: payload['page'] = {} if self.page.id: pa...
python
def generate(self): """Generate a signed request from this instance.""" payload = { 'algorithm': 'HMAC-SHA256' } if self.data: payload['app_data'] = self.data if self.page: payload['page'] = {} if self.page.id: pa...
[ "def", "generate", "(", "self", ")", ":", "payload", "=", "{", "'algorithm'", ":", "'HMAC-SHA256'", "}", "if", "self", ".", "data", ":", "payload", "[", "'app_data'", "]", "=", "self", ".", "data", "if", "self", ".", "page", ":", "payload", "[", "'pa...
Generate a signed request from this instance.
[ "Generate", "a", "signed", "request", "from", "this", "instance", "." ]
1be3ee21389fb2db543927a2f4ffa949faec4242
https://github.com/jgorset/facepy/blob/1be3ee21389fb2db543927a2f4ffa949faec4242/facepy/signed_request.py#L117-L182
train
jgorset/facepy
facepy/graph_api.py
GraphAPI.for_application
def for_application(self, id, secret_key, api_version=None): """ Initialize GraphAPI with an OAuth access token for an application. :param id: An integer describing a Facebook application. :param secret_key: A String describing the Facebook application's secret key. """ ...
python
def for_application(self, id, secret_key, api_version=None): """ Initialize GraphAPI with an OAuth access token for an application. :param id: An integer describing a Facebook application. :param secret_key: A String describing the Facebook application's secret key. """ ...
[ "def", "for_application", "(", "self", ",", "id", ",", "secret_key", ",", "api_version", "=", "None", ")", ":", "from", "facepy", ".", "utils", "import", "get_application_access_token", "access_token", "=", "get_application_access_token", "(", "id", ",", "secret_k...
Initialize GraphAPI with an OAuth access token for an application. :param id: An integer describing a Facebook application. :param secret_key: A String describing the Facebook application's secret key.
[ "Initialize", "GraphAPI", "with", "an", "OAuth", "access", "token", "for", "an", "application", "." ]
1be3ee21389fb2db543927a2f4ffa949faec4242
https://github.com/jgorset/facepy/blob/1be3ee21389fb2db543927a2f4ffa949faec4242/facepy/graph_api.py#L43-L53
train
jgorset/facepy
facepy/graph_api.py
GraphAPI.get
def get(self, path='', page=False, retry=3, **options): """ Get an item from the Graph API. :param path: A string describing the path to the item. :param page: A boolean describing whether to return a generator that iterates over each page of results. :param...
python
def get(self, path='', page=False, retry=3, **options): """ Get an item from the Graph API. :param path: A string describing the path to the item. :param page: A boolean describing whether to return a generator that iterates over each page of results. :param...
[ "def", "get", "(", "self", ",", "path", "=", "''", ",", "page", "=", "False", ",", "retry", "=", "3", ",", "*", "*", "options", ")", ":", "response", "=", "self", ".", "_query", "(", "method", "=", "'GET'", ",", "path", "=", "path", ",", "data"...
Get an item from the Graph API. :param path: A string describing the path to the item. :param page: A boolean describing whether to return a generator that iterates over each page of results. :param retry: An integer describing how many times the request may be retried. ...
[ "Get", "an", "item", "from", "the", "Graph", "API", "." ]
1be3ee21389fb2db543927a2f4ffa949faec4242
https://github.com/jgorset/facepy/blob/1be3ee21389fb2db543927a2f4ffa949faec4242/facepy/graph_api.py#L55-L82
train
jgorset/facepy
facepy/graph_api.py
GraphAPI.post
def post(self, path='', retry=0, **data): """ Post an item to the Graph API. :param path: A string describing the path to the item. :param retry: An integer describing how many times the request may be retried. :param data: Graph API parameters such as 'message' or 'source'. ...
python
def post(self, path='', retry=0, **data): """ Post an item to the Graph API. :param path: A string describing the path to the item. :param retry: An integer describing how many times the request may be retried. :param data: Graph API parameters such as 'message' or 'source'. ...
[ "def", "post", "(", "self", ",", "path", "=", "''", ",", "retry", "=", "0", ",", "*", "*", "data", ")", ":", "response", "=", "self", ".", "_query", "(", "method", "=", "'POST'", ",", "path", "=", "path", ",", "data", "=", "data", ",", "retry",...
Post an item to the Graph API. :param path: A string describing the path to the item. :param retry: An integer describing how many times the request may be retried. :param data: Graph API parameters such as 'message' or 'source'. See `Facebook's Graph API documentation <http://develope...
[ "Post", "an", "item", "to", "the", "Graph", "API", "." ]
1be3ee21389fb2db543927a2f4ffa949faec4242
https://github.com/jgorset/facepy/blob/1be3ee21389fb2db543927a2f4ffa949faec4242/facepy/graph_api.py#L84-L105
train
jgorset/facepy
facepy/graph_api.py
GraphAPI.search
def search(self, term, type='place', page=False, retry=3, **options): """ Search for an item in the Graph API. :param term: A string describing the search term. :param type: A string describing the type of items to search for. :param page: A boolean describing whether to return ...
python
def search(self, term, type='place', page=False, retry=3, **options): """ Search for an item in the Graph API. :param term: A string describing the search term. :param type: A string describing the type of items to search for. :param page: A boolean describing whether to return ...
[ "def", "search", "(", "self", ",", "term", ",", "type", "=", "'place'", ",", "page", "=", "False", ",", "retry", "=", "3", ",", "*", "*", "options", ")", ":", "if", "type", "!=", "'place'", ":", "raise", "ValueError", "(", "'Unsupported type \"%s\". Th...
Search for an item in the Graph API. :param term: A string describing the search term. :param type: A string describing the type of items to search for. :param page: A boolean describing whether to return a generator that iterates over each page of results. :param r...
[ "Search", "for", "an", "item", "in", "the", "Graph", "API", "." ]
1be3ee21389fb2db543927a2f4ffa949faec4242
https://github.com/jgorset/facepy/blob/1be3ee21389fb2db543927a2f4ffa949faec4242/facepy/graph_api.py#L130-L157
train
jgorset/facepy
facepy/graph_api.py
GraphAPI.batch
def batch(self, requests): """ Make a batch request. :param requests: A list of dictionaries with keys 'method', 'relative_url' and optionally 'body'. Yields a list of responses and/or exceptions. """ for request in requests: if 'body' in request: ...
python
def batch(self, requests): """ Make a batch request. :param requests: A list of dictionaries with keys 'method', 'relative_url' and optionally 'body'. Yields a list of responses and/or exceptions. """ for request in requests: if 'body' in request: ...
[ "def", "batch", "(", "self", ",", "requests", ")", ":", "for", "request", "in", "requests", ":", "if", "'body'", "in", "request", ":", "request", "[", "'body'", "]", "=", "urlencode", "(", "request", "[", "'body'", "]", ")", "def", "_grouper", "(", "...
Make a batch request. :param requests: A list of dictionaries with keys 'method', 'relative_url' and optionally 'body'. Yields a list of responses and/or exceptions.
[ "Make", "a", "batch", "request", "." ]
1be3ee21389fb2db543927a2f4ffa949faec4242
https://github.com/jgorset/facepy/blob/1be3ee21389fb2db543927a2f4ffa949faec4242/facepy/graph_api.py#L159-L207
train
jgorset/facepy
facepy/graph_api.py
GraphAPI._parse
def _parse(self, data): """ Parse the response from Facebook's Graph API. :param data: A string describing the Graph API's response. """ if type(data) == type(bytes()): try: data = data.decode('utf-8') except UnicodeDecodeError: ...
python
def _parse(self, data): """ Parse the response from Facebook's Graph API. :param data: A string describing the Graph API's response. """ if type(data) == type(bytes()): try: data = data.decode('utf-8') except UnicodeDecodeError: ...
[ "def", "_parse", "(", "self", ",", "data", ")", ":", "if", "type", "(", "data", ")", "==", "type", "(", "bytes", "(", ")", ")", ":", "try", ":", "data", "=", "data", ".", "decode", "(", "'utf-8'", ")", "except", "UnicodeDecodeError", ":", "return",...
Parse the response from Facebook's Graph API. :param data: A string describing the Graph API's response.
[ "Parse", "the", "response", "from", "Facebook", "s", "Graph", "API", "." ]
1be3ee21389fb2db543927a2f4ffa949faec4242
https://github.com/jgorset/facepy/blob/1be3ee21389fb2db543927a2f4ffa949faec4242/facepy/graph_api.py#L372-L417
train
jgorset/facepy
facepy/utils.py
get_extended_access_token
def get_extended_access_token(access_token, application_id, application_secret_key, api_version=None): """ Get an extended OAuth access token. :param access_token: A string describing an OAuth access token. :param application_id: An integer describing the Facebook application's ID. :param applicati...
python
def get_extended_access_token(access_token, application_id, application_secret_key, api_version=None): """ Get an extended OAuth access token. :param access_token: A string describing an OAuth access token. :param application_id: An integer describing the Facebook application's ID. :param applicati...
[ "def", "get_extended_access_token", "(", "access_token", ",", "application_id", ",", "application_secret_key", ",", "api_version", "=", "None", ")", ":", "graph", "=", "GraphAPI", "(", "version", "=", "api_version", ")", "response", "=", "graph", ".", "get", "("...
Get an extended OAuth access token. :param access_token: A string describing an OAuth access token. :param application_id: An integer describing the Facebook application's ID. :param application_secret_key: A string describing the Facebook application's secret key. Returns a tuple with a string descri...
[ "Get", "an", "extended", "OAuth", "access", "token", "." ]
1be3ee21389fb2db543927a2f4ffa949faec4242
https://github.com/jgorset/facepy/blob/1be3ee21389fb2db543927a2f4ffa949faec4242/facepy/utils.py#L11-L44
train
jgorset/facepy
facepy/utils.py
get_application_access_token
def get_application_access_token(application_id, application_secret_key, api_version=None): """ Get an OAuth access token for the given application. :param application_id: An integer describing a Facebook application's ID. :param application_secret_key: A string describing a Facebook application's secr...
python
def get_application_access_token(application_id, application_secret_key, api_version=None): """ Get an OAuth access token for the given application. :param application_id: An integer describing a Facebook application's ID. :param application_secret_key: A string describing a Facebook application's secr...
[ "def", "get_application_access_token", "(", "application_id", ",", "application_secret_key", ",", "api_version", "=", "None", ")", ":", "graph", "=", "GraphAPI", "(", "version", "=", "api_version", ")", "response", "=", "graph", ".", "get", "(", "path", "=", "...
Get an OAuth access token for the given application. :param application_id: An integer describing a Facebook application's ID. :param application_secret_key: A string describing a Facebook application's secret key.
[ "Get", "an", "OAuth", "access", "token", "for", "the", "given", "application", "." ]
1be3ee21389fb2db543927a2f4ffa949faec4242
https://github.com/jgorset/facepy/blob/1be3ee21389fb2db543927a2f4ffa949faec4242/facepy/utils.py#L47-L71
train
ionelmc/python-redis-lock
src/redis_lock/django_cache.py
RedisCache.locked_get_or_set
def locked_get_or_set(self, key, value_creator, version=None, expire=None, id=None, lock_key=None, timeout=DEFAULT_TIMEOUT): """ Fetch a given key from the cache. If the key does not exist, the key is added and set to the value returned when ca...
python
def locked_get_or_set(self, key, value_creator, version=None, expire=None, id=None, lock_key=None, timeout=DEFAULT_TIMEOUT): """ Fetch a given key from the cache. If the key does not exist, the key is added and set to the value returned when ca...
[ "def", "locked_get_or_set", "(", "self", ",", "key", ",", "value_creator", ",", "version", "=", "None", ",", "expire", "=", "None", ",", "id", "=", "None", ",", "lock_key", "=", "None", ",", "timeout", "=", "DEFAULT_TIMEOUT", ")", ":", "if", "lock_key", ...
Fetch a given key from the cache. If the key does not exist, the key is added and set to the value returned when calling `value_creator`. The creator function is invoked inside of a lock.
[ "Fetch", "a", "given", "key", "from", "the", "cache", ".", "If", "the", "key", "does", "not", "exist", "the", "key", "is", "added", "and", "set", "to", "the", "value", "returned", "when", "calling", "value_creator", ".", "The", "creator", "function", "is...
5481cd88b64d86d318e389c79b0575a73464b1f5
https://github.com/ionelmc/python-redis-lock/blob/5481cd88b64d86d318e389c79b0575a73464b1f5/src/redis_lock/django_cache.py#L23-L51
train
ionelmc/python-redis-lock
src/redis_lock/__init__.py
_eval_script
def _eval_script(redis, script_id, *keys, **kwargs): """Tries to call ``EVALSHA`` with the `hash` and then, if it fails, calls regular ``EVAL`` with the `script`. """ args = kwargs.pop('args', ()) if kwargs: raise TypeError("Unexpected keyword arguments %s" % kwargs.keys()) try: ...
python
def _eval_script(redis, script_id, *keys, **kwargs): """Tries to call ``EVALSHA`` with the `hash` and then, if it fails, calls regular ``EVAL`` with the `script`. """ args = kwargs.pop('args', ()) if kwargs: raise TypeError("Unexpected keyword arguments %s" % kwargs.keys()) try: ...
[ "def", "_eval_script", "(", "redis", ",", "script_id", ",", "*", "keys", ",", "*", "*", "kwargs", ")", ":", "args", "=", "kwargs", ".", "pop", "(", "'args'", ",", "(", ")", ")", "if", "kwargs", ":", "raise", "TypeError", "(", "\"Unexpected keyword argu...
Tries to call ``EVALSHA`` with the `hash` and then, if it fails, calls regular ``EVAL`` with the `script`.
[ "Tries", "to", "call", "EVALSHA", "with", "the", "hash", "and", "then", "if", "it", "fails", "calls", "regular", "EVAL", "with", "the", "script", "." ]
5481cd88b64d86d318e389c79b0575a73464b1f5
https://github.com/ionelmc/python-redis-lock/blob/5481cd88b64d86d318e389c79b0575a73464b1f5/src/redis_lock/__init__.py#L129-L140
train
ionelmc/python-redis-lock
src/redis_lock/__init__.py
Lock.reset
def reset(self): """ Forcibly deletes the lock. Use this with care. """ _eval_script(self._client, RESET, self._name, self._signal) self._delete_signal()
python
def reset(self): """ Forcibly deletes the lock. Use this with care. """ _eval_script(self._client, RESET, self._name, self._signal) self._delete_signal()
[ "def", "reset", "(", "self", ")", ":", "_eval_script", "(", "self", ".", "_client", ",", "RESET", ",", "self", ".", "_name", ",", "self", ".", "_signal", ")", "self", ".", "_delete_signal", "(", ")" ]
Forcibly deletes the lock. Use this with care.
[ "Forcibly", "deletes", "the", "lock", ".", "Use", "this", "with", "care", "." ]
5481cd88b64d86d318e389c79b0575a73464b1f5
https://github.com/ionelmc/python-redis-lock/blob/5481cd88b64d86d318e389c79b0575a73464b1f5/src/redis_lock/__init__.py#L205-L210
train
ionelmc/python-redis-lock
src/redis_lock/__init__.py
Lock.extend
def extend(self, expire=None): """Extends expiration time of the lock. :param expire: New expiration time. If ``None`` - `expire` provided during lock initialization will be taken. """ if expire is None: if self._expire is not None: ex...
python
def extend(self, expire=None): """Extends expiration time of the lock. :param expire: New expiration time. If ``None`` - `expire` provided during lock initialization will be taken. """ if expire is None: if self._expire is not None: ex...
[ "def", "extend", "(", "self", ",", "expire", "=", "None", ")", ":", "if", "expire", "is", "None", ":", "if", "self", ".", "_expire", "is", "not", "None", ":", "expire", "=", "self", ".", "_expire", "else", ":", "raise", "TypeError", "(", "\"To extend...
Extends expiration time of the lock. :param expire: New expiration time. If ``None`` - `expire` provided during lock initialization will be taken.
[ "Extends", "expiration", "time", "of", "the", "lock", "." ]
5481cd88b64d86d318e389c79b0575a73464b1f5
https://github.com/ionelmc/python-redis-lock/blob/5481cd88b64d86d318e389c79b0575a73464b1f5/src/redis_lock/__init__.py#L263-L285
train
ionelmc/python-redis-lock
src/redis_lock/__init__.py
Lock._lock_renewer
def _lock_renewer(lockref, interval, stop): """ Renew the lock key in redis every `interval` seconds for as long as `self._lock_renewal_thread.should_exit` is False. """ log = getLogger("%s.lock_refresher" % __name__) while not stop.wait(timeout=interval): log...
python
def _lock_renewer(lockref, interval, stop): """ Renew the lock key in redis every `interval` seconds for as long as `self._lock_renewal_thread.should_exit` is False. """ log = getLogger("%s.lock_refresher" % __name__) while not stop.wait(timeout=interval): log...
[ "def", "_lock_renewer", "(", "lockref", ",", "interval", ",", "stop", ")", ":", "log", "=", "getLogger", "(", "\"%s.lock_refresher\"", "%", "__name__", ")", "while", "not", "stop", ".", "wait", "(", "timeout", "=", "interval", ")", ":", "log", ".", "debu...
Renew the lock key in redis every `interval` seconds for as long as `self._lock_renewal_thread.should_exit` is False.
[ "Renew", "the", "lock", "key", "in", "redis", "every", "interval", "seconds", "for", "as", "long", "as", "self", ".", "_lock_renewal_thread", ".", "should_exit", "is", "False", "." ]
5481cd88b64d86d318e389c79b0575a73464b1f5
https://github.com/ionelmc/python-redis-lock/blob/5481cd88b64d86d318e389c79b0575a73464b1f5/src/redis_lock/__init__.py#L288-L303
train
ionelmc/python-redis-lock
src/redis_lock/__init__.py
Lock._start_lock_renewer
def _start_lock_renewer(self): """ Starts the lock refresher thread. """ if self._lock_renewal_thread is not None: raise AlreadyStarted("Lock refresh thread already started") logger.debug( "Starting thread to refresh lock every %s seconds", se...
python
def _start_lock_renewer(self): """ Starts the lock refresher thread. """ if self._lock_renewal_thread is not None: raise AlreadyStarted("Lock refresh thread already started") logger.debug( "Starting thread to refresh lock every %s seconds", se...
[ "def", "_start_lock_renewer", "(", "self", ")", ":", "if", "self", ".", "_lock_renewal_thread", "is", "not", "None", ":", "raise", "AlreadyStarted", "(", "\"Lock refresh thread already started\"", ")", "logger", ".", "debug", "(", "\"Starting thread to refresh lock ever...
Starts the lock refresher thread.
[ "Starts", "the", "lock", "refresher", "thread", "." ]
5481cd88b64d86d318e389c79b0575a73464b1f5
https://github.com/ionelmc/python-redis-lock/blob/5481cd88b64d86d318e389c79b0575a73464b1f5/src/redis_lock/__init__.py#L305-L325
train
ionelmc/python-redis-lock
src/redis_lock/__init__.py
Lock._stop_lock_renewer
def _stop_lock_renewer(self): """ Stop the lock renewer. This signals the renewal thread and waits for its exit. """ if self._lock_renewal_thread is None or not self._lock_renewal_thread.is_alive(): return logger.debug("Signalling the lock refresher to stop")...
python
def _stop_lock_renewer(self): """ Stop the lock renewer. This signals the renewal thread and waits for its exit. """ if self._lock_renewal_thread is None or not self._lock_renewal_thread.is_alive(): return logger.debug("Signalling the lock refresher to stop")...
[ "def", "_stop_lock_renewer", "(", "self", ")", ":", "if", "self", ".", "_lock_renewal_thread", "is", "None", "or", "not", "self", ".", "_lock_renewal_thread", ".", "is_alive", "(", ")", ":", "return", "logger", ".", "debug", "(", "\"Signalling the lock refresher...
Stop the lock renewer. This signals the renewal thread and waits for its exit.
[ "Stop", "the", "lock", "renewer", "." ]
5481cd88b64d86d318e389c79b0575a73464b1f5
https://github.com/ionelmc/python-redis-lock/blob/5481cd88b64d86d318e389c79b0575a73464b1f5/src/redis_lock/__init__.py#L327-L339
train
ionelmc/python-redis-lock
src/redis_lock/__init__.py
Lock.release
def release(self): """Releases the lock, that was acquired with the same object. .. note:: If you want to release a lock that you acquired in a different place you have two choices: * Use ``Lock("name", id=id_from_other_place).release()`` * Use ``Lock("name").reset...
python
def release(self): """Releases the lock, that was acquired with the same object. .. note:: If you want to release a lock that you acquired in a different place you have two choices: * Use ``Lock("name", id=id_from_other_place).release()`` * Use ``Lock("name").reset...
[ "def", "release", "(", "self", ")", ":", "if", "self", ".", "_lock_renewal_thread", "is", "not", "None", ":", "self", ".", "_stop_lock_renewer", "(", ")", "logger", ".", "debug", "(", "\"Releasing %r.\"", ",", "self", ".", "_name", ")", "error", "=", "_e...
Releases the lock, that was acquired with the same object. .. note:: If you want to release a lock that you acquired in a different place you have two choices: * Use ``Lock("name", id=id_from_other_place).release()`` * Use ``Lock("name").reset()``
[ "Releases", "the", "lock", "that", "was", "acquired", "with", "the", "same", "object", "." ]
5481cd88b64d86d318e389c79b0575a73464b1f5
https://github.com/ionelmc/python-redis-lock/blob/5481cd88b64d86d318e389c79b0575a73464b1f5/src/redis_lock/__init__.py#L349-L368
train
mitodl/edx-api-client
edx_api/course_detail/__init__.py
CourseDetails.get_detail
def get_detail(self, course_id): """ Fetches course details. Args: course_id (str): An edx course id. Returns: CourseDetail """ # the request is done in behalf of the current logged in user resp = self._requester.get( urljoin(...
python
def get_detail(self, course_id): """ Fetches course details. Args: course_id (str): An edx course id. Returns: CourseDetail """ # the request is done in behalf of the current logged in user resp = self._requester.get( urljoin(...
[ "def", "get_detail", "(", "self", ",", "course_id", ")", ":", "# the request is done in behalf of the current logged in user", "resp", "=", "self", ".", "_requester", ".", "get", "(", "urljoin", "(", "self", ".", "_base_url", ",", "'/api/courses/v1/courses/{course_key}/...
Fetches course details. Args: course_id (str): An edx course id. Returns: CourseDetail
[ "Fetches", "course", "details", "." ]
083fd23a48b3ef0d39602fc3e7e53ef02f4ad6d6
https://github.com/mitodl/edx-api-client/blob/083fd23a48b3ef0d39602fc3e7e53ef02f4ad6d6/edx_api/course_detail/__init__.py#L16-L36
train
mitodl/edx-api-client
edx_api/user_info/__init__.py
UserInfo.get_user_info
def get_user_info(self): """ Returns a UserInfo object for the logged in user. Returns: UserInfo: object representing the student current grades """ # the request is done in behalf of the current logged in user resp = self.requester.get( urljoin( ...
python
def get_user_info(self): """ Returns a UserInfo object for the logged in user. Returns: UserInfo: object representing the student current grades """ # the request is done in behalf of the current logged in user resp = self.requester.get( urljoin( ...
[ "def", "get_user_info", "(", "self", ")", ":", "# the request is done in behalf of the current logged in user", "resp", "=", "self", ".", "requester", ".", "get", "(", "urljoin", "(", "self", ".", "base_url", ",", "'/api/mobile/v0.5/my_user_info'", ")", ")", "resp", ...
Returns a UserInfo object for the logged in user. Returns: UserInfo: object representing the student current grades
[ "Returns", "a", "UserInfo", "object", "for", "the", "logged", "in", "user", "." ]
083fd23a48b3ef0d39602fc3e7e53ef02f4ad6d6
https://github.com/mitodl/edx-api-client/blob/083fd23a48b3ef0d39602fc3e7e53ef02f4ad6d6/edx_api/user_info/__init__.py#L21-L38
train
mitodl/edx-api-client
edx_api/course_structure/__init__.py
CourseStructure.course_blocks
def course_blocks(self, course_id, username): """ Fetches course blocks. Args: course_id (str): An edx course id. username (str): username of the user to query for (can reveal hidden modules) Returns: Structure """...
python
def course_blocks(self, course_id, username): """ Fetches course blocks. Args: course_id (str): An edx course id. username (str): username of the user to query for (can reveal hidden modules) Returns: Structure """...
[ "def", "course_blocks", "(", "self", ",", "course_id", ",", "username", ")", ":", "resp", "=", "self", ".", "requester", ".", "get", "(", "urljoin", "(", "self", ".", "base_url", ",", "'/api/courses/v1/blocks/'", ")", ",", "params", "=", "{", "\"depth\"", ...
Fetches course blocks. Args: course_id (str): An edx course id. username (str): username of the user to query for (can reveal hidden modules) Returns: Structure
[ "Fetches", "course", "blocks", "." ]
083fd23a48b3ef0d39602fc3e7e53ef02f4ad6d6
https://github.com/mitodl/edx-api-client/blob/083fd23a48b3ef0d39602fc3e7e53ef02f4ad6d6/edx_api/course_structure/__init__.py#L15-L38
train
mitodl/edx-api-client
edx_api/grades/__init__.py
UserCurrentGrades.get_student_current_grade
def get_student_current_grade(self, username, course_id): """ Returns an CurrentGrade object for the user in a course Args: username (str): an edx user's username course_id (str): an edX course id. Returns: CurrentGrade: object representing the stude...
python
def get_student_current_grade(self, username, course_id): """ Returns an CurrentGrade object for the user in a course Args: username (str): an edx user's username course_id (str): an edX course id. Returns: CurrentGrade: object representing the stude...
[ "def", "get_student_current_grade", "(", "self", ",", "username", ",", "course_id", ")", ":", "# the request is done in behalf of the current logged in user", "resp", "=", "self", ".", "requester", ".", "get", "(", "urljoin", "(", "self", ".", "base_url", ",", "'/ap...
Returns an CurrentGrade object for the user in a course Args: username (str): an edx user's username course_id (str): an edX course id. Returns: CurrentGrade: object representing the student current grade for a course
[ "Returns", "an", "CurrentGrade", "object", "for", "the", "user", "in", "a", "course" ]
083fd23a48b3ef0d39602fc3e7e53ef02f4ad6d6
https://github.com/mitodl/edx-api-client/blob/083fd23a48b3ef0d39602fc3e7e53ef02f4ad6d6/edx_api/grades/__init__.py#L25-L49
train
mitodl/edx-api-client
edx_api/grades/__init__.py
UserCurrentGrades.get_student_current_grades
def get_student_current_grades(self, username, course_ids=None): """ Returns a CurrentGradesByUser object with the user current grades. Args: username (str): an edx user's username course_ids (list): a list of edX course ids. Returns: CurrentGradesBy...
python
def get_student_current_grades(self, username, course_ids=None): """ Returns a CurrentGradesByUser object with the user current grades. Args: username (str): an edx user's username course_ids (list): a list of edX course ids. Returns: CurrentGradesBy...
[ "def", "get_student_current_grades", "(", "self", ",", "username", ",", "course_ids", "=", "None", ")", ":", "# if no course ids are provided, let's get the user enrollments", "if", "course_ids", "is", "None", ":", "enrollments_client", "=", "CourseEnrollments", "(", "sel...
Returns a CurrentGradesByUser object with the user current grades. Args: username (str): an edx user's username course_ids (list): a list of edX course ids. Returns: CurrentGradesByUser: object representing the student current grades
[ "Returns", "a", "CurrentGradesByUser", "object", "with", "the", "user", "current", "grades", "." ]
083fd23a48b3ef0d39602fc3e7e53ef02f4ad6d6
https://github.com/mitodl/edx-api-client/blob/083fd23a48b3ef0d39602fc3e7e53ef02f4ad6d6/edx_api/grades/__init__.py#L51-L76
train
mitodl/edx-api-client
edx_api/grades/__init__.py
UserCurrentGrades.get_course_current_grades
def get_course_current_grades(self, course_id): """ Returns a CurrentGradesByCourse object for all users in the specified course. Args: course_id (str): an edX course ids. Returns: CurrentGradesByCourse: object representing the student current grades Au...
python
def get_course_current_grades(self, course_id): """ Returns a CurrentGradesByCourse object for all users in the specified course. Args: course_id (str): an edX course ids. Returns: CurrentGradesByCourse: object representing the student current grades Au...
[ "def", "get_course_current_grades", "(", "self", ",", "course_id", ")", ":", "resp", "=", "self", ".", "requester", ".", "get", "(", "urljoin", "(", "self", ".", "base_url", ",", "'/api/grades/v1/courses/{course_key}/'", ".", "format", "(", "course_key", "=", ...
Returns a CurrentGradesByCourse object for all users in the specified course. Args: course_id (str): an edX course ids. Returns: CurrentGradesByCourse: object representing the student current grades Authorization: The authenticated user must have staff perm...
[ "Returns", "a", "CurrentGradesByCourse", "object", "for", "all", "users", "in", "the", "specified", "course", "." ]
083fd23a48b3ef0d39602fc3e7e53ef02f4ad6d6
https://github.com/mitodl/edx-api-client/blob/083fd23a48b3ef0d39602fc3e7e53ef02f4ad6d6/edx_api/grades/__init__.py#L78-L110
train
mitodl/edx-api-client
edx_api/client.py
EdxApi.get_requester
def get_requester(self): """ Returns an object to make authenticated requests. See python `requests` for the API. """ # TODO(abrahms): Perhaps pull this out into a factory function for # generating an EdxApi instance with the proper requester & credentials. session = requ...
python
def get_requester(self): """ Returns an object to make authenticated requests. See python `requests` for the API. """ # TODO(abrahms): Perhaps pull this out into a factory function for # generating an EdxApi instance with the proper requester & credentials. session = requ...
[ "def", "get_requester", "(", "self", ")", ":", "# TODO(abrahms): Perhaps pull this out into a factory function for", "# generating an EdxApi instance with the proper requester & credentials.", "session", "=", "requests", ".", "session", "(", ")", "session", ".", "headers", ".", ...
Returns an object to make authenticated requests. See python `requests` for the API.
[ "Returns", "an", "object", "to", "make", "authenticated", "requests", ".", "See", "python", "requests", "for", "the", "API", "." ]
083fd23a48b3ef0d39602fc3e7e53ef02f4ad6d6
https://github.com/mitodl/edx-api-client/blob/083fd23a48b3ef0d39602fc3e7e53ef02f4ad6d6/edx_api/client.py#L30-L50
train
mitodl/edx-api-client
edx_api/ccx.py
CCX.create
def create(self, master_course_id, coach_email, max_students_allowed, title, modules=None): """ Creates a CCX Args: master_course_id (str): edx course id of the master course coach_email (str): email of the user to make a coach. This user must exist on edx. m...
python
def create(self, master_course_id, coach_email, max_students_allowed, title, modules=None): """ Creates a CCX Args: master_course_id (str): edx course id of the master course coach_email (str): email of the user to make a coach. This user must exist on edx. m...
[ "def", "create", "(", "self", ",", "master_course_id", ",", "coach_email", ",", "max_students_allowed", ",", "title", ",", "modules", "=", "None", ")", ":", "payload", "=", "{", "'master_course_id'", ":", "master_course_id", ",", "'coach_email'", ":", "coach_ema...
Creates a CCX Args: master_course_id (str): edx course id of the master course coach_email (str): email of the user to make a coach. This user must exist on edx. max_students_allowed (int): Maximum number of students to allow in this ccx. title (str): Title of th...
[ "Creates", "a", "CCX" ]
083fd23a48b3ef0d39602fc3e7e53ef02f4ad6d6
https://github.com/mitodl/edx-api-client/blob/083fd23a48b3ef0d39602fc3e7e53ef02f4ad6d6/edx_api/ccx.py#L20-L55
train
mitodl/edx-api-client
edx_api/enrollments/__init__.py
CourseEnrollments._get_enrollments_list_page
def _get_enrollments_list_page(self, params=None): """ Submit request to retrieve enrollments list. Args: params (dict): Query parameters to use in the request. Valid parameters are: * course_id: Filters the result to course enrollments for the course ...
python
def _get_enrollments_list_page(self, params=None): """ Submit request to retrieve enrollments list. Args: params (dict): Query parameters to use in the request. Valid parameters are: * course_id: Filters the result to course enrollments for the course ...
[ "def", "_get_enrollments_list_page", "(", "self", ",", "params", "=", "None", ")", ":", "req_url", "=", "urljoin", "(", "self", ".", "base_url", ",", "self", ".", "enrollment_list_url", ")", "resp", "=", "self", ".", "requester", ".", "get", "(", "req_url"...
Submit request to retrieve enrollments list. Args: params (dict): Query parameters to use in the request. Valid parameters are: * course_id: Filters the result to course enrollments for the course corresponding to the given course ID. The value must be URL encode...
[ "Submit", "request", "to", "retrieve", "enrollments", "list", "." ]
083fd23a48b3ef0d39602fc3e7e53ef02f4ad6d6
https://github.com/mitodl/edx-api-client/blob/083fd23a48b3ef0d39602fc3e7e53ef02f4ad6d6/edx_api/enrollments/__init__.py#L31-L59
train
mitodl/edx-api-client
edx_api/enrollments/__init__.py
CourseEnrollments.get_enrollments
def get_enrollments(self, course_id=None, usernames=None): """ List all course enrollments. Args: course_id (str, optional): If used enrollments will be filtered to the specified course id. usernames (list, optional): List of usernames to filter enrollmen...
python
def get_enrollments(self, course_id=None, usernames=None): """ List all course enrollments. Args: course_id (str, optional): If used enrollments will be filtered to the specified course id. usernames (list, optional): List of usernames to filter enrollmen...
[ "def", "get_enrollments", "(", "self", ",", "course_id", "=", "None", ",", "usernames", "=", "None", ")", ":", "params", "=", "{", "}", "if", "course_id", "is", "not", "None", ":", "params", "[", "'course_id'", "]", "=", "course_id", "if", "usernames", ...
List all course enrollments. Args: course_id (str, optional): If used enrollments will be filtered to the specified course id. usernames (list, optional): List of usernames to filter enrollments. Notes: - This method returns an iterator to avoid goin...
[ "List", "all", "course", "enrollments", "." ]
083fd23a48b3ef0d39602fc3e7e53ef02f4ad6d6
https://github.com/mitodl/edx-api-client/blob/083fd23a48b3ef0d39602fc3e7e53ef02f4ad6d6/edx_api/enrollments/__init__.py#L61-L106
train
mitodl/edx-api-client
edx_api/enrollments/__init__.py
CourseEnrollments.get_student_enrollments
def get_student_enrollments(self): """ Returns an Enrollments object with the user enrollments Returns: Enrollments: object representing the student enrollments """ # the request is done in behalf of the current logged in user resp = self.requester.get( ...
python
def get_student_enrollments(self): """ Returns an Enrollments object with the user enrollments Returns: Enrollments: object representing the student enrollments """ # the request is done in behalf of the current logged in user resp = self.requester.get( ...
[ "def", "get_student_enrollments", "(", "self", ")", ":", "# the request is done in behalf of the current logged in user", "resp", "=", "self", ".", "requester", ".", "get", "(", "urljoin", "(", "self", ".", "base_url", ",", "self", ".", "enrollment_url", ")", ")", ...
Returns an Enrollments object with the user enrollments Returns: Enrollments: object representing the student enrollments
[ "Returns", "an", "Enrollments", "object", "with", "the", "user", "enrollments" ]
083fd23a48b3ef0d39602fc3e7e53ef02f4ad6d6
https://github.com/mitodl/edx-api-client/blob/083fd23a48b3ef0d39602fc3e7e53ef02f4ad6d6/edx_api/enrollments/__init__.py#L108-L119
train
mitodl/edx-api-client
edx_api/enrollments/__init__.py
CourseEnrollments.create_audit_student_enrollment
def create_audit_student_enrollment(self, course_id): """ Creates an audit enrollment for the user in a given course Args: course_id (str): an edX course id Returns: Enrollment: object representing the student enrollment in the provided course """ ...
python
def create_audit_student_enrollment(self, course_id): """ Creates an audit enrollment for the user in a given course Args: course_id (str): an edX course id Returns: Enrollment: object representing the student enrollment in the provided course """ ...
[ "def", "create_audit_student_enrollment", "(", "self", ",", "course_id", ")", ":", "audit_enrollment", "=", "{", "\"mode\"", ":", "\"audit\"", ",", "\"course_details\"", ":", "{", "\"course_id\"", ":", "course_id", "}", "}", "# the request is done in behalf of the curre...
Creates an audit enrollment for the user in a given course Args: course_id (str): an edX course id Returns: Enrollment: object representing the student enrollment in the provided course
[ "Creates", "an", "audit", "enrollment", "for", "the", "user", "in", "a", "given", "course" ]
083fd23a48b3ef0d39602fc3e7e53ef02f4ad6d6
https://github.com/mitodl/edx-api-client/blob/083fd23a48b3ef0d39602fc3e7e53ef02f4ad6d6/edx_api/enrollments/__init__.py#L121-L141
train
mitodl/edx-api-client
edx_api/certificates/__init__.py
UserCertificates.get_student_certificate
def get_student_certificate(self, username, course_id): """ Returns an Certificate object with the user certificates Args: username (str): an edx user's username course_id (str): an edX course id. Returns: Certificate: object representing the student...
python
def get_student_certificate(self, username, course_id): """ Returns an Certificate object with the user certificates Args: username (str): an edx user's username course_id (str): an edX course id. Returns: Certificate: object representing the student...
[ "def", "get_student_certificate", "(", "self", ",", "username", ",", "course_id", ")", ":", "# the request is done in behalf of the current logged in user", "resp", "=", "self", ".", "requester", ".", "get", "(", "urljoin", "(", "self", ".", "base_url", ",", "'/api/...
Returns an Certificate object with the user certificates Args: username (str): an edx user's username course_id (str): an edX course id. Returns: Certificate: object representing the student certificate for a course
[ "Returns", "an", "Certificate", "object", "with", "the", "user", "certificates" ]
083fd23a48b3ef0d39602fc3e7e53ef02f4ad6d6
https://github.com/mitodl/edx-api-client/blob/083fd23a48b3ef0d39602fc3e7e53ef02f4ad6d6/edx_api/certificates/__init__.py#L25-L49
train
mitodl/edx-api-client
edx_api/certificates/__init__.py
UserCertificates.get_student_certificates
def get_student_certificates(self, username, course_ids=None): """ Returns an Certificates object with the user certificates Args: username (str): an edx user's username course_ids (list): a list of edX course ids. Returns: Certificates: object repre...
python
def get_student_certificates(self, username, course_ids=None): """ Returns an Certificates object with the user certificates Args: username (str): an edx user's username course_ids (list): a list of edX course ids. Returns: Certificates: object repre...
[ "def", "get_student_certificates", "(", "self", ",", "username", ",", "course_ids", "=", "None", ")", ":", "# if no course ids are provided, let's get the user enrollments", "if", "course_ids", "is", "None", ":", "enrollments_client", "=", "CourseEnrollments", "(", "self"...
Returns an Certificates object with the user certificates Args: username (str): an edx user's username course_ids (list): a list of edX course ids. Returns: Certificates: object representing the student certificates for a course
[ "Returns", "an", "Certificates", "object", "with", "the", "user", "certificates" ]
083fd23a48b3ef0d39602fc3e7e53ef02f4ad6d6
https://github.com/mitodl/edx-api-client/blob/083fd23a48b3ef0d39602fc3e7e53ef02f4ad6d6/edx_api/certificates/__init__.py#L51-L76
train
metakirby5/colorz
colorz.py
get_colors
def get_colors(img): """ Returns a list of all the image's colors. """ w, h = img.size return [color[:3] for count, color in img.convert('RGB').getcolors(w * h)]
python
def get_colors(img): """ Returns a list of all the image's colors. """ w, h = img.size return [color[:3] for count, color in img.convert('RGB').getcolors(w * h)]
[ "def", "get_colors", "(", "img", ")", ":", "w", ",", "h", "=", "img", ".", "size", "return", "[", "color", "[", ":", "3", "]", "for", "count", ",", "color", "in", "img", ".", "convert", "(", "'RGB'", ")", ".", "getcolors", "(", "w", "*", "h", ...
Returns a list of all the image's colors.
[ "Returns", "a", "list", "of", "all", "the", "image", "s", "colors", "." ]
11fd47a28d7a4af5b91d29978524335c8fef8cc9
https://github.com/metakirby5/colorz/blob/11fd47a28d7a4af5b91d29978524335c8fef8cc9/colorz.py#L56-L61
train
metakirby5/colorz
colorz.py
clamp
def clamp(color, min_v, max_v): """ Clamps a color such that the value is between min_v and max_v. """ h, s, v = rgb_to_hsv(*map(down_scale, color)) min_v, max_v = map(down_scale, (min_v, max_v)) v = min(max(min_v, v), max_v) return tuple(map(up_scale, hsv_to_rgb(h, s, v)))
python
def clamp(color, min_v, max_v): """ Clamps a color such that the value is between min_v and max_v. """ h, s, v = rgb_to_hsv(*map(down_scale, color)) min_v, max_v = map(down_scale, (min_v, max_v)) v = min(max(min_v, v), max_v) return tuple(map(up_scale, hsv_to_rgb(h, s, v)))
[ "def", "clamp", "(", "color", ",", "min_v", ",", "max_v", ")", ":", "h", ",", "s", ",", "v", "=", "rgb_to_hsv", "(", "*", "map", "(", "down_scale", ",", "color", ")", ")", "min_v", ",", "max_v", "=", "map", "(", "down_scale", ",", "(", "min_v", ...
Clamps a color such that the value is between min_v and max_v.
[ "Clamps", "a", "color", "such", "that", "the", "value", "is", "between", "min_v", "and", "max_v", "." ]
11fd47a28d7a4af5b91d29978524335c8fef8cc9
https://github.com/metakirby5/colorz/blob/11fd47a28d7a4af5b91d29978524335c8fef8cc9/colorz.py#L64-L71
train
metakirby5/colorz
colorz.py
order_by_hue
def order_by_hue(colors): """ Orders colors by hue. """ hsvs = [rgb_to_hsv(*map(down_scale, color)) for color in colors] hsvs.sort(key=lambda t: t[0]) return [tuple(map(up_scale, hsv_to_rgb(*hsv))) for hsv in hsvs]
python
def order_by_hue(colors): """ Orders colors by hue. """ hsvs = [rgb_to_hsv(*map(down_scale, color)) for color in colors] hsvs.sort(key=lambda t: t[0]) return [tuple(map(up_scale, hsv_to_rgb(*hsv))) for hsv in hsvs]
[ "def", "order_by_hue", "(", "colors", ")", ":", "hsvs", "=", "[", "rgb_to_hsv", "(", "*", "map", "(", "down_scale", ",", "color", ")", ")", "for", "color", "in", "colors", "]", "hsvs", ".", "sort", "(", "key", "=", "lambda", "t", ":", "t", "[", "...
Orders colors by hue.
[ "Orders", "colors", "by", "hue", "." ]
11fd47a28d7a4af5b91d29978524335c8fef8cc9
https://github.com/metakirby5/colorz/blob/11fd47a28d7a4af5b91d29978524335c8fef8cc9/colorz.py#L74-L80
train
metakirby5/colorz
colorz.py
brighten
def brighten(color, brightness): """ Adds or subtracts value to a color. """ h, s, v = rgb_to_hsv(*map(down_scale, color)) return tuple(map(up_scale, hsv_to_rgb(h, s, v + down_scale(brightness))))
python
def brighten(color, brightness): """ Adds or subtracts value to a color. """ h, s, v = rgb_to_hsv(*map(down_scale, color)) return tuple(map(up_scale, hsv_to_rgb(h, s, v + down_scale(brightness))))
[ "def", "brighten", "(", "color", ",", "brightness", ")", ":", "h", ",", "s", ",", "v", "=", "rgb_to_hsv", "(", "*", "map", "(", "down_scale", ",", "color", ")", ")", "return", "tuple", "(", "map", "(", "up_scale", ",", "hsv_to_rgb", "(", "h", ",", ...
Adds or subtracts value to a color.
[ "Adds", "or", "subtracts", "value", "to", "a", "color", "." ]
11fd47a28d7a4af5b91d29978524335c8fef8cc9
https://github.com/metakirby5/colorz/blob/11fd47a28d7a4af5b91d29978524335c8fef8cc9/colorz.py#L83-L88
train
metakirby5/colorz
colorz.py
colorz
def colorz(fd, n=DEFAULT_NUM_COLORS, min_v=DEFAULT_MINV, max_v=DEFAULT_MAXV, bold_add=DEFAULT_BOLD_ADD, order_colors=True): """ Get the n most dominant colors of an image. Clamps value to between min_v and max_v. Creates bold colors using bold_add. Total number of colors returned is 2*n,...
python
def colorz(fd, n=DEFAULT_NUM_COLORS, min_v=DEFAULT_MINV, max_v=DEFAULT_MAXV, bold_add=DEFAULT_BOLD_ADD, order_colors=True): """ Get the n most dominant colors of an image. Clamps value to between min_v and max_v. Creates bold colors using bold_add. Total number of colors returned is 2*n,...
[ "def", "colorz", "(", "fd", ",", "n", "=", "DEFAULT_NUM_COLORS", ",", "min_v", "=", "DEFAULT_MINV", ",", "max_v", "=", "DEFAULT_MAXV", ",", "bold_add", "=", "DEFAULT_BOLD_ADD", ",", "order_colors", "=", "True", ")", ":", "img", "=", "Image", ".", "open", ...
Get the n most dominant colors of an image. Clamps value to between min_v and max_v. Creates bold colors using bold_add. Total number of colors returned is 2*n, optionally ordered by hue. Returns as a list of pairs of RGB triples. For terminal colors, the hue order is: red, yellow, green, cyan...
[ "Get", "the", "n", "most", "dominant", "colors", "of", "an", "image", ".", "Clamps", "value", "to", "between", "min_v", "and", "max_v", "." ]
11fd47a28d7a4af5b91d29978524335c8fef8cc9
https://github.com/metakirby5/colorz/blob/11fd47a28d7a4af5b91d29978524335c8fef8cc9/colorz.py#L91-L111
train
ansible/pytest-ansible
setup.py
long_description
def long_description(*paths): '''Returns a RST formated string. ''' result = '' # attempt to import pandoc try: import pypandoc except (ImportError, OSError) as e: print("Unable to import pypandoc - %s" % e) return result # attempt md -> rst conversion try: ...
python
def long_description(*paths): '''Returns a RST formated string. ''' result = '' # attempt to import pandoc try: import pypandoc except (ImportError, OSError) as e: print("Unable to import pypandoc - %s" % e) return result # attempt md -> rst conversion try: ...
[ "def", "long_description", "(", "*", "paths", ")", ":", "result", "=", "''", "# attempt to import pandoc", "try", ":", "import", "pypandoc", "except", "(", "ImportError", ",", "OSError", ")", "as", "e", ":", "print", "(", "\"Unable to import pypandoc - %s\"", "%...
Returns a RST formated string.
[ "Returns", "a", "RST", "formated", "string", "." ]
0f7eea80887715fb290a425b8ea4a1c1cfad1ecf
https://github.com/ansible/pytest-ansible/blob/0f7eea80887715fb290a425b8ea4a1c1cfad1ecf/setup.py#L78-L100
train
wmayner/pyphi
pyphi/cache.py
memory_full
def memory_full(): """Check if the memory is too full for further caching.""" current_process = psutil.Process(os.getpid()) return (current_process.memory_percent() > config.MAXIMUM_CACHE_MEMORY_PERCENTAGE)
python
def memory_full(): """Check if the memory is too full for further caching.""" current_process = psutil.Process(os.getpid()) return (current_process.memory_percent() > config.MAXIMUM_CACHE_MEMORY_PERCENTAGE)
[ "def", "memory_full", "(", ")", ":", "current_process", "=", "psutil", ".", "Process", "(", "os", ".", "getpid", "(", ")", ")", "return", "(", "current_process", ".", "memory_percent", "(", ")", ">", "config", ".", "MAXIMUM_CACHE_MEMORY_PERCENTAGE", ")" ]
Check if the memory is too full for further caching.
[ "Check", "if", "the", "memory", "is", "too", "full", "for", "further", "caching", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/cache.py#L26-L30
train
wmayner/pyphi
pyphi/cache.py
cache
def cache(cache={}, maxmem=config.MAXIMUM_CACHE_MEMORY_PERCENTAGE, typed=False): """Memory-limited cache decorator. ``maxmem`` is a float between 0 and 100, inclusive, specifying the maximum percentage of physical memory that the cache can use. If ``typed`` is ``True``, arguments of differen...
python
def cache(cache={}, maxmem=config.MAXIMUM_CACHE_MEMORY_PERCENTAGE, typed=False): """Memory-limited cache decorator. ``maxmem`` is a float between 0 and 100, inclusive, specifying the maximum percentage of physical memory that the cache can use. If ``typed`` is ``True``, arguments of differen...
[ "def", "cache", "(", "cache", "=", "{", "}", ",", "maxmem", "=", "config", ".", "MAXIMUM_CACHE_MEMORY_PERCENTAGE", ",", "typed", "=", "False", ")", ":", "# Constants shared by all lru cache instances:", "# Unique object used to signal cache misses.", "sentinel", "=", "o...
Memory-limited cache decorator. ``maxmem`` is a float between 0 and 100, inclusive, specifying the maximum percentage of physical memory that the cache can use. If ``typed`` is ``True``, arguments of different types will be cached separately. For example, f(3.0) and f(3) will be treated as distinct ca...
[ "Memory", "-", "limited", "cache", "decorator", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/cache.py#L78-L156
train
wmayner/pyphi
pyphi/cache.py
MICECache
def MICECache(subsystem, parent_cache=None): """Construct a |MICE| cache. Uses either a Redis-backed cache or a local dict cache on the object. Args: subsystem (Subsystem): The subsystem that this is a cache for. Kwargs: parent_cache (MICECache): The cache generated by the uncut ...
python
def MICECache(subsystem, parent_cache=None): """Construct a |MICE| cache. Uses either a Redis-backed cache or a local dict cache on the object. Args: subsystem (Subsystem): The subsystem that this is a cache for. Kwargs: parent_cache (MICECache): The cache generated by the uncut ...
[ "def", "MICECache", "(", "subsystem", ",", "parent_cache", "=", "None", ")", ":", "if", "config", ".", "REDIS_CACHE", ":", "cls", "=", "RedisMICECache", "else", ":", "cls", "=", "DictMICECache", "return", "cls", "(", "subsystem", ",", "parent_cache", "=", ...
Construct a |MICE| cache. Uses either a Redis-backed cache or a local dict cache on the object. Args: subsystem (Subsystem): The subsystem that this is a cache for. Kwargs: parent_cache (MICECache): The cache generated by the uncut version of ``subsystem``. Any cached |MICE| w...
[ "Construct", "a", "|MICE|", "cache", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/cache.py#L396-L414
train
wmayner/pyphi
pyphi/cache.py
method
def method(cache_name, key_prefix=None): """Caching decorator for object-level method caches. Cache key generation is delegated to the cache. Args: cache_name (str): The name of the (already-instantiated) cache on the decorated object which should be used to store results o...
python
def method(cache_name, key_prefix=None): """Caching decorator for object-level method caches. Cache key generation is delegated to the cache. Args: cache_name (str): The name of the (already-instantiated) cache on the decorated object which should be used to store results o...
[ "def", "method", "(", "cache_name", ",", "key_prefix", "=", "None", ")", ":", "def", "decorator", "(", "func", ")", ":", "if", "(", "func", ".", "__name__", "in", "[", "'cause_repertoire'", ",", "'effect_repertoire'", "]", "and", "not", "config", ".", "C...
Caching decorator for object-level method caches. Cache key generation is delegated to the cache. Args: cache_name (str): The name of the (already-instantiated) cache on the decorated object which should be used to store results of this method. *key_prefix: A constant t...
[ "Caching", "decorator", "for", "object", "-", "level", "method", "caches", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/cache.py#L426-L458
train
wmayner/pyphi
pyphi/cache.py
DictCache.get
def get(self, key): """Get a value out of the cache. Returns None if the key is not in the cache. Updates cache statistics. """ if key in self.cache: self.hits += 1 return self.cache[key] self.misses += 1 return None
python
def get(self, key): """Get a value out of the cache. Returns None if the key is not in the cache. Updates cache statistics. """ if key in self.cache: self.hits += 1 return self.cache[key] self.misses += 1 return None
[ "def", "get", "(", "self", ",", "key", ")", ":", "if", "key", "in", "self", ".", "cache", ":", "self", ".", "hits", "+=", "1", "return", "self", ".", "cache", "[", "key", "]", "self", ".", "misses", "+=", "1", "return", "None" ]
Get a value out of the cache. Returns None if the key is not in the cache. Updates cache statistics.
[ "Get", "a", "value", "out", "of", "the", "cache", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/cache.py#L183-L193
train
wmayner/pyphi
pyphi/cache.py
DictCache.key
def key(self, *args, _prefix=None, **kwargs): """Get the cache key for the given function args. Kwargs: prefix: A constant to prefix to the key. """ if kwargs: raise NotImplementedError( 'kwarg cache keys not implemented') return (_prefix,)...
python
def key(self, *args, _prefix=None, **kwargs): """Get the cache key for the given function args. Kwargs: prefix: A constant to prefix to the key. """ if kwargs: raise NotImplementedError( 'kwarg cache keys not implemented') return (_prefix,)...
[ "def", "key", "(", "self", ",", "*", "args", ",", "_prefix", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "kwargs", ":", "raise", "NotImplementedError", "(", "'kwarg cache keys not implemented'", ")", "return", "(", "_prefix", ",", ")", "+", "tu...
Get the cache key for the given function args. Kwargs: prefix: A constant to prefix to the key.
[ "Get", "the", "cache", "key", "for", "the", "given", "function", "args", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/cache.py#L201-L210
train
wmayner/pyphi
pyphi/cache.py
RedisCache.info
def info(self): """Return cache information. .. note:: This is not the cache info for the entire Redis key space. """ info = redis_conn.info() return _CacheInfo(info['keyspace_hits'], info['keyspace_misses'], self.size())
python
def info(self): """Return cache information. .. note:: This is not the cache info for the entire Redis key space. """ info = redis_conn.info() return _CacheInfo(info['keyspace_hits'], info['keyspace_misses'], self.size())
[ "def", "info", "(", "self", ")", ":", "info", "=", "redis_conn", ".", "info", "(", ")", "return", "_CacheInfo", "(", "info", "[", "'keyspace_hits'", "]", ",", "info", "[", "'keyspace_misses'", "]", ",", "self", ".", "size", "(", ")", ")" ]
Return cache information. .. note:: This is not the cache info for the entire Redis key space.
[ "Return", "cache", "information", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/cache.py#L251-L259
train
wmayner/pyphi
pyphi/cache.py
RedisMICECache.set
def set(self, key, value): """Only need to set if the subsystem is uncut. Caches are only inherited from uncut subsystems. """ if not self.subsystem.is_cut: super().set(key, value)
python
def set(self, key, value): """Only need to set if the subsystem is uncut. Caches are only inherited from uncut subsystems. """ if not self.subsystem.is_cut: super().set(key, value)
[ "def", "set", "(", "self", ",", "key", ",", "value", ")", ":", "if", "not", "self", ".", "subsystem", ".", "is_cut", ":", "super", "(", ")", ".", "set", "(", "key", ",", "value", ")" ]
Only need to set if the subsystem is uncut. Caches are only inherited from uncut subsystems.
[ "Only", "need", "to", "set", "if", "the", "subsystem", "is", "uncut", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/cache.py#L334-L340
train
wmayner/pyphi
pyphi/cache.py
DictMICECache._build
def _build(self, parent_cache): """Build the initial cache from the parent. Only include the |MICE| which are unaffected by the subsystem cut. A |MICE| is affected if either the cut splits the mechanism or splits the connections between the purview and mechanism """ for ...
python
def _build(self, parent_cache): """Build the initial cache from the parent. Only include the |MICE| which are unaffected by the subsystem cut. A |MICE| is affected if either the cut splits the mechanism or splits the connections between the purview and mechanism """ for ...
[ "def", "_build", "(", "self", ",", "parent_cache", ")", ":", "for", "key", ",", "mice", "in", "parent_cache", ".", "cache", ".", "items", "(", ")", ":", "if", "not", "mice", ".", "damaged_by_cut", "(", "self", ".", "subsystem", ")", ":", "self", ".",...
Build the initial cache from the parent. Only include the |MICE| which are unaffected by the subsystem cut. A |MICE| is affected if either the cut splits the mechanism or splits the connections between the purview and mechanism
[ "Build", "the", "initial", "cache", "from", "the", "parent", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/cache.py#L362-L371
train
wmayner/pyphi
pyphi/cache.py
PurviewCache.set
def set(self, key, value): """Only set if purview caching is enabled""" if config.CACHE_POTENTIAL_PURVIEWS: self.cache[key] = value
python
def set(self, key, value): """Only set if purview caching is enabled""" if config.CACHE_POTENTIAL_PURVIEWS: self.cache[key] = value
[ "def", "set", "(", "self", ",", "key", ",", "value", ")", ":", "if", "config", ".", "CACHE_POTENTIAL_PURVIEWS", ":", "self", ".", "cache", "[", "key", "]", "=", "value" ]
Only set if purview caching is enabled
[ "Only", "set", "if", "purview", "caching", "is", "enabled" ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/cache.py#L420-L423
train
wmayner/pyphi
pyphi/connectivity.py
apply_boundary_conditions_to_cm
def apply_boundary_conditions_to_cm(external_indices, cm): """Remove connections to or from external nodes.""" cm = cm.copy() cm[external_indices, :] = 0 # Zero-out row cm[:, external_indices] = 0 # Zero-out columnt return cm
python
def apply_boundary_conditions_to_cm(external_indices, cm): """Remove connections to or from external nodes.""" cm = cm.copy() cm[external_indices, :] = 0 # Zero-out row cm[:, external_indices] = 0 # Zero-out columnt return cm
[ "def", "apply_boundary_conditions_to_cm", "(", "external_indices", ",", "cm", ")", ":", "cm", "=", "cm", ".", "copy", "(", ")", "cm", "[", "external_indices", ",", ":", "]", "=", "0", "# Zero-out row", "cm", "[", ":", ",", "external_indices", "]", "=", "...
Remove connections to or from external nodes.
[ "Remove", "connections", "to", "or", "from", "external", "nodes", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/connectivity.py#L13-L18
train
wmayner/pyphi
pyphi/connectivity.py
get_inputs_from_cm
def get_inputs_from_cm(index, cm): """Return indices of inputs to the node with the given index.""" return tuple(i for i in range(cm.shape[0]) if cm[i][index])
python
def get_inputs_from_cm(index, cm): """Return indices of inputs to the node with the given index.""" return tuple(i for i in range(cm.shape[0]) if cm[i][index])
[ "def", "get_inputs_from_cm", "(", "index", ",", "cm", ")", ":", "return", "tuple", "(", "i", "for", "i", "in", "range", "(", "cm", ".", "shape", "[", "0", "]", ")", "if", "cm", "[", "i", "]", "[", "index", "]", ")" ]
Return indices of inputs to the node with the given index.
[ "Return", "indices", "of", "inputs", "to", "the", "node", "with", "the", "given", "index", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/connectivity.py#L21-L23
train
wmayner/pyphi
pyphi/connectivity.py
get_outputs_from_cm
def get_outputs_from_cm(index, cm): """Return indices of the outputs of node with the given index.""" return tuple(i for i in range(cm.shape[0]) if cm[index][i])
python
def get_outputs_from_cm(index, cm): """Return indices of the outputs of node with the given index.""" return tuple(i for i in range(cm.shape[0]) if cm[index][i])
[ "def", "get_outputs_from_cm", "(", "index", ",", "cm", ")", ":", "return", "tuple", "(", "i", "for", "i", "in", "range", "(", "cm", ".", "shape", "[", "0", "]", ")", "if", "cm", "[", "index", "]", "[", "i", "]", ")" ]
Return indices of the outputs of node with the given index.
[ "Return", "indices", "of", "the", "outputs", "of", "node", "with", "the", "given", "index", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/connectivity.py#L26-L28
train
wmayner/pyphi
pyphi/connectivity.py
causally_significant_nodes
def causally_significant_nodes(cm): """Return indices of nodes that have both inputs and outputs.""" inputs = cm.sum(0) outputs = cm.sum(1) nodes_with_inputs_and_outputs = np.logical_and(inputs > 0, outputs > 0) return tuple(np.where(nodes_with_inputs_and_outputs)[0])
python
def causally_significant_nodes(cm): """Return indices of nodes that have both inputs and outputs.""" inputs = cm.sum(0) outputs = cm.sum(1) nodes_with_inputs_and_outputs = np.logical_and(inputs > 0, outputs > 0) return tuple(np.where(nodes_with_inputs_and_outputs)[0])
[ "def", "causally_significant_nodes", "(", "cm", ")", ":", "inputs", "=", "cm", ".", "sum", "(", "0", ")", "outputs", "=", "cm", ".", "sum", "(", "1", ")", "nodes_with_inputs_and_outputs", "=", "np", ".", "logical_and", "(", "inputs", ">", "0", ",", "ou...
Return indices of nodes that have both inputs and outputs.
[ "Return", "indices", "of", "nodes", "that", "have", "both", "inputs", "and", "outputs", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/connectivity.py#L31-L36
train
wmayner/pyphi
pyphi/connectivity.py
relevant_connections
def relevant_connections(n, _from, to): """Construct a connectivity matrix. Args: n (int): The dimensions of the matrix _from (tuple[int]): Nodes with outgoing connections to ``to`` to (tuple[int]): Nodes with incoming connections from ``_from`` Returns: np.ndarray: An |n x...
python
def relevant_connections(n, _from, to): """Construct a connectivity matrix. Args: n (int): The dimensions of the matrix _from (tuple[int]): Nodes with outgoing connections to ``to`` to (tuple[int]): Nodes with incoming connections from ``_from`` Returns: np.ndarray: An |n x...
[ "def", "relevant_connections", "(", "n", ",", "_from", ",", "to", ")", ":", "cm", "=", "np", ".", "zeros", "(", "(", "n", ",", "n", ")", ")", "# Don't try and index with empty arrays. Older versions of NumPy", "# (at least up to 1.9.3) break with empty array indices.", ...
Construct a connectivity matrix. Args: n (int): The dimensions of the matrix _from (tuple[int]): Nodes with outgoing connections to ``to`` to (tuple[int]): Nodes with incoming connections from ``_from`` Returns: np.ndarray: An |n x n| connectivity matrix with the |i,jth| entry ...
[ "Construct", "a", "connectivity", "matrix", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/connectivity.py#L40-L60
train
wmayner/pyphi
pyphi/connectivity.py
block_cm
def block_cm(cm): """Return whether ``cm`` can be arranged as a block connectivity matrix. If so, the corresponding mechanism/purview is trivially reducible. Technically, only square matrices are "block diagonal", but the notion of connectivity carries over. We test for block connectivity by tryin...
python
def block_cm(cm): """Return whether ``cm`` can be arranged as a block connectivity matrix. If so, the corresponding mechanism/purview is trivially reducible. Technically, only square matrices are "block diagonal", but the notion of connectivity carries over. We test for block connectivity by tryin...
[ "def", "block_cm", "(", "cm", ")", ":", "if", "np", ".", "any", "(", "cm", ".", "sum", "(", "1", ")", "==", "0", ")", ":", "return", "True", "if", "np", ".", "all", "(", "cm", ".", "sum", "(", "1", ")", "==", "1", ")", ":", "return", "Tru...
Return whether ``cm`` can be arranged as a block connectivity matrix. If so, the corresponding mechanism/purview is trivially reducible. Technically, only square matrices are "block diagonal", but the notion of connectivity carries over. We test for block connectivity by trying to grow a block of node...
[ "Return", "whether", "cm", "can", "be", "arranged", "as", "a", "block", "connectivity", "matrix", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/connectivity.py#L63-L130
train
wmayner/pyphi
pyphi/connectivity.py
block_reducible
def block_reducible(cm, nodes1, nodes2): """Return whether connections from ``nodes1`` to ``nodes2`` are reducible. Args: cm (np.ndarray): The network's connectivity matrix. nodes1 (tuple[int]): Source nodes nodes2 (tuple[int]): Sink nodes """ # Trivial case if not nodes1 or...
python
def block_reducible(cm, nodes1, nodes2): """Return whether connections from ``nodes1`` to ``nodes2`` are reducible. Args: cm (np.ndarray): The network's connectivity matrix. nodes1 (tuple[int]): Source nodes nodes2 (tuple[int]): Sink nodes """ # Trivial case if not nodes1 or...
[ "def", "block_reducible", "(", "cm", ",", "nodes1", ",", "nodes2", ")", ":", "# Trivial case", "if", "not", "nodes1", "or", "not", "nodes2", ":", "return", "True", "cm", "=", "cm", "[", "np", ".", "ix_", "(", "nodes1", ",", "nodes2", ")", "]", "# Val...
Return whether connections from ``nodes1`` to ``nodes2`` are reducible. Args: cm (np.ndarray): The network's connectivity matrix. nodes1 (tuple[int]): Source nodes nodes2 (tuple[int]): Sink nodes
[ "Return", "whether", "connections", "from", "nodes1", "to", "nodes2", "are", "reducible", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/connectivity.py#L135-L154
train
wmayner/pyphi
pyphi/connectivity.py
_connected
def _connected(cm, nodes, connection): """Test connectivity for the connectivity matrix.""" if nodes is not None: cm = cm[np.ix_(nodes, nodes)] num_components, _ = connected_components(cm, connection=connection) return num_components < 2
python
def _connected(cm, nodes, connection): """Test connectivity for the connectivity matrix.""" if nodes is not None: cm = cm[np.ix_(nodes, nodes)] num_components, _ = connected_components(cm, connection=connection) return num_components < 2
[ "def", "_connected", "(", "cm", ",", "nodes", ",", "connection", ")", ":", "if", "nodes", "is", "not", "None", ":", "cm", "=", "cm", "[", "np", ".", "ix_", "(", "nodes", ",", "nodes", ")", "]", "num_components", ",", "_", "=", "connected_components",...
Test connectivity for the connectivity matrix.
[ "Test", "connectivity", "for", "the", "connectivity", "matrix", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/connectivity.py#L157-L163
train
wmayner/pyphi
pyphi/connectivity.py
is_full
def is_full(cm, nodes1, nodes2): """Test connectivity of one set of nodes to another. Args: cm (``np.ndarrray``): The connectivity matrix nodes1 (tuple[int]): The nodes whose outputs to ``nodes2`` will be tested. nodes2 (tuple[int]): The nodes whose inputs from ``nodes1`` wi...
python
def is_full(cm, nodes1, nodes2): """Test connectivity of one set of nodes to another. Args: cm (``np.ndarrray``): The connectivity matrix nodes1 (tuple[int]): The nodes whose outputs to ``nodes2`` will be tested. nodes2 (tuple[int]): The nodes whose inputs from ``nodes1`` wi...
[ "def", "is_full", "(", "cm", ",", "nodes1", ",", "nodes2", ")", ":", "if", "not", "nodes1", "or", "not", "nodes2", ":", "return", "True", "cm", "=", "cm", "[", "np", ".", "ix_", "(", "nodes1", ",", "nodes2", ")", "]", "# Do all nodes have at least one ...
Test connectivity of one set of nodes to another. Args: cm (``np.ndarrray``): The connectivity matrix nodes1 (tuple[int]): The nodes whose outputs to ``nodes2`` will be tested. nodes2 (tuple[int]): The nodes whose inputs from ``nodes1`` will be tested. Returns: ...
[ "Test", "connectivity", "of", "one", "set", "of", "nodes", "to", "another", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/connectivity.py#L192-L214
train
wmayner/pyphi
pyphi/models/cuts.py
_CutBase.apply_cut
def apply_cut(self, cm): """Return a modified connectivity matrix with all connections that are severed by this cut removed. Args: cm (np.ndarray): A connectivity matrix. """ # Invert the cut matrix, creating a matrix of preserved connections inverse = np.log...
python
def apply_cut(self, cm): """Return a modified connectivity matrix with all connections that are severed by this cut removed. Args: cm (np.ndarray): A connectivity matrix. """ # Invert the cut matrix, creating a matrix of preserved connections inverse = np.log...
[ "def", "apply_cut", "(", "self", ",", "cm", ")", ":", "# Invert the cut matrix, creating a matrix of preserved connections", "inverse", "=", "np", ".", "logical_not", "(", "self", ".", "cut_matrix", "(", "cm", ".", "shape", "[", "0", "]", ")", ")", ".", "astyp...
Return a modified connectivity matrix with all connections that are severed by this cut removed. Args: cm (np.ndarray): A connectivity matrix.
[ "Return", "a", "modified", "connectivity", "matrix", "with", "all", "connections", "that", "are", "severed", "by", "this", "cut", "removed", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/models/cuts.py#L48-L57
train
wmayner/pyphi
pyphi/models/cuts.py
_CutBase.cuts_connections
def cuts_connections(self, a, b): """Check if this cut severs any connections from ``a`` to ``b``. Args: a (tuple[int]): A set of nodes. b (tuple[int]): A set of nodes. """ n = max(self.indices) + 1 return self.cut_matrix(n)[np.ix_(a, b)].any()
python
def cuts_connections(self, a, b): """Check if this cut severs any connections from ``a`` to ``b``. Args: a (tuple[int]): A set of nodes. b (tuple[int]): A set of nodes. """ n = max(self.indices) + 1 return self.cut_matrix(n)[np.ix_(a, b)].any()
[ "def", "cuts_connections", "(", "self", ",", "a", ",", "b", ")", ":", "n", "=", "max", "(", "self", ".", "indices", ")", "+", "1", "return", "self", ".", "cut_matrix", "(", "n", ")", "[", "np", ".", "ix_", "(", "a", ",", "b", ")", "]", ".", ...
Check if this cut severs any connections from ``a`` to ``b``. Args: a (tuple[int]): A set of nodes. b (tuple[int]): A set of nodes.
[ "Check", "if", "this", "cut", "severs", "any", "connections", "from", "a", "to", "b", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/models/cuts.py#L59-L67
train
wmayner/pyphi
pyphi/models/cuts.py
_CutBase.all_cut_mechanisms
def all_cut_mechanisms(self): """Return all mechanisms with elements on both sides of this cut. Yields: tuple[int]: The next cut mechanism. """ for mechanism in utils.powerset(self.indices, nonempty=True): if self.splits_mechanism(mechanism): yiel...
python
def all_cut_mechanisms(self): """Return all mechanisms with elements on both sides of this cut. Yields: tuple[int]: The next cut mechanism. """ for mechanism in utils.powerset(self.indices, nonempty=True): if self.splits_mechanism(mechanism): yiel...
[ "def", "all_cut_mechanisms", "(", "self", ")", ":", "for", "mechanism", "in", "utils", ".", "powerset", "(", "self", ".", "indices", ",", "nonempty", "=", "True", ")", ":", "if", "self", ".", "splits_mechanism", "(", "mechanism", ")", ":", "yield", "mech...
Return all mechanisms with elements on both sides of this cut. Yields: tuple[int]: The next cut mechanism.
[ "Return", "all", "mechanisms", "with", "elements", "on", "both", "sides", "of", "this", "cut", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/models/cuts.py#L81-L89
train
wmayner/pyphi
pyphi/models/cuts.py
Cut.cut_matrix
def cut_matrix(self, n): """Compute the cut matrix for this cut. The cut matrix is a square matrix which represents connections severed by the cut. Args: n (int): The size of the network. Example: >>> cut = Cut((1,), (2,)) >>> cut.cut_matrix(...
python
def cut_matrix(self, n): """Compute the cut matrix for this cut. The cut matrix is a square matrix which represents connections severed by the cut. Args: n (int): The size of the network. Example: >>> cut = Cut((1,), (2,)) >>> cut.cut_matrix(...
[ "def", "cut_matrix", "(", "self", ",", "n", ")", ":", "return", "connectivity", ".", "relevant_connections", "(", "n", ",", "self", ".", "from_nodes", ",", "self", ".", "to_nodes", ")" ]
Compute the cut matrix for this cut. The cut matrix is a square matrix which represents connections severed by the cut. Args: n (int): The size of the network. Example: >>> cut = Cut((1,), (2,)) >>> cut.cut_matrix(3) array([[0., 0., 0.], ...
[ "Compute", "the", "cut", "matrix", "for", "this", "cut", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/models/cuts.py#L153-L170
train
wmayner/pyphi
pyphi/models/cuts.py
KCut.cut_matrix
def cut_matrix(self, n): """The matrix of connections that are severed by this cut.""" cm = np.zeros((n, n)) for part in self.partition: from_, to = self.direction.order(part.mechanism, part.purview) # All indices external to this part external = tuple(set(se...
python
def cut_matrix(self, n): """The matrix of connections that are severed by this cut.""" cm = np.zeros((n, n)) for part in self.partition: from_, to = self.direction.order(part.mechanism, part.purview) # All indices external to this part external = tuple(set(se...
[ "def", "cut_matrix", "(", "self", ",", "n", ")", ":", "cm", "=", "np", ".", "zeros", "(", "(", "n", ",", "n", ")", ")", "for", "part", "in", "self", ".", "partition", ":", "from_", ",", "to", "=", "self", ".", "direction", ".", "order", "(", ...
The matrix of connections that are severed by this cut.
[ "The", "matrix", "of", "connections", "that", "are", "severed", "by", "this", "cut", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/models/cuts.py#L204-L214
train
wmayner/pyphi
pyphi/compute/distance.py
concept_distance
def concept_distance(c1, c2): """Return the distance between two concepts in concept space. Args: c1 (Concept): The first concept. c2 (Concept): The second concept. Returns: float: The distance between the two concepts in concept space. """ # Calculate the sum of the cause ...
python
def concept_distance(c1, c2): """Return the distance between two concepts in concept space. Args: c1 (Concept): The first concept. c2 (Concept): The second concept. Returns: float: The distance between the two concepts in concept space. """ # Calculate the sum of the cause ...
[ "def", "concept_distance", "(", "c1", ",", "c2", ")", ":", "# Calculate the sum of the cause and effect EMDs, expanding the repertoires", "# to the combined purview of the two concepts, so that the EMD signatures", "# are the same size.", "cause_purview", "=", "tuple", "(", "set", "(...
Return the distance between two concepts in concept space. Args: c1 (Concept): The first concept. c2 (Concept): The second concept. Returns: float: The distance between the two concepts in concept space.
[ "Return", "the", "distance", "between", "two", "concepts", "in", "concept", "space", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/compute/distance.py#L16-L35
train
wmayner/pyphi
pyphi/compute/distance.py
small_phi_ces_distance
def small_phi_ces_distance(C1, C2): """Return the difference in |small_phi| between |CauseEffectStructure|.""" return sum(c.phi for c in C1) - sum(c.phi for c in C2)
python
def small_phi_ces_distance(C1, C2): """Return the difference in |small_phi| between |CauseEffectStructure|.""" return sum(c.phi for c in C1) - sum(c.phi for c in C2)
[ "def", "small_phi_ces_distance", "(", "C1", ",", "C2", ")", ":", "return", "sum", "(", "c", ".", "phi", "for", "c", "in", "C1", ")", "-", "sum", "(", "c", ".", "phi", "for", "c", "in", "C2", ")" ]
Return the difference in |small_phi| between |CauseEffectStructure|.
[ "Return", "the", "difference", "in", "|small_phi|", "between", "|CauseEffectStructure|", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/compute/distance.py#L149-L151
train
wmayner/pyphi
pyphi/node.py
generate_nodes
def generate_nodes(tpm, cm, network_state, indices, node_labels=None): """Generate |Node| objects for a subsystem. Args: tpm (np.ndarray): The system's TPM cm (np.ndarray): The corresponding CM. network_state (tuple): The state of the network. indices (tuple[int]): Indices to ge...
python
def generate_nodes(tpm, cm, network_state, indices, node_labels=None): """Generate |Node| objects for a subsystem. Args: tpm (np.ndarray): The system's TPM cm (np.ndarray): The corresponding CM. network_state (tuple): The state of the network. indices (tuple[int]): Indices to ge...
[ "def", "generate_nodes", "(", "tpm", ",", "cm", ",", "network_state", ",", "indices", ",", "node_labels", "=", "None", ")", ":", "if", "node_labels", "is", "None", ":", "node_labels", "=", "NodeLabels", "(", "None", ",", "indices", ")", "node_state", "=", ...
Generate |Node| objects for a subsystem. Args: tpm (np.ndarray): The system's TPM cm (np.ndarray): The corresponding CM. network_state (tuple): The state of the network. indices (tuple[int]): Indices to generate nodes for. Keyword Args: node_labels (|NodeLabels|): Textu...
[ "Generate", "|Node|", "objects", "for", "a", "subsystem", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/node.py#L156-L177
train
wmayner/pyphi
pyphi/node.py
expand_node_tpm
def expand_node_tpm(tpm): """Broadcast a node TPM over the full network. This is different from broadcasting the TPM of a full system since the last dimension (containing the state of the node) contains only the probability of *this* node being on, rather than the probabilities for each node. """ ...
python
def expand_node_tpm(tpm): """Broadcast a node TPM over the full network. This is different from broadcasting the TPM of a full system since the last dimension (containing the state of the node) contains only the probability of *this* node being on, rather than the probabilities for each node. """ ...
[ "def", "expand_node_tpm", "(", "tpm", ")", ":", "uc", "=", "np", ".", "ones", "(", "[", "2", "for", "node", "in", "tpm", ".", "shape", "]", ")", "return", "uc", "*", "tpm" ]
Broadcast a node TPM over the full network. This is different from broadcasting the TPM of a full system since the last dimension (containing the state of the node) contains only the probability of *this* node being on, rather than the probabilities for each node.
[ "Broadcast", "a", "node", "TPM", "over", "the", "full", "network", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/node.py#L180-L188
train
wmayner/pyphi
pyphi/tpm.py
condition_tpm
def condition_tpm(tpm, fixed_nodes, state): """Return a TPM conditioned on the given fixed node indices, whose states are fixed according to the given state-tuple. The dimensions of the new TPM that correspond to the fixed nodes are collapsed onto their state, making those dimensions singletons suitabl...
python
def condition_tpm(tpm, fixed_nodes, state): """Return a TPM conditioned on the given fixed node indices, whose states are fixed according to the given state-tuple. The dimensions of the new TPM that correspond to the fixed nodes are collapsed onto their state, making those dimensions singletons suitabl...
[ "def", "condition_tpm", "(", "tpm", ",", "fixed_nodes", ",", "state", ")", ":", "conditioning_indices", "=", "[", "[", "slice", "(", "None", ")", "]", "]", "*", "len", "(", "state", ")", "for", "i", "in", "fixed_nodes", ":", "# Preserve singleton dimension...
Return a TPM conditioned on the given fixed node indices, whose states are fixed according to the given state-tuple. The dimensions of the new TPM that correspond to the fixed nodes are collapsed onto their state, making those dimensions singletons suitable for broadcasting. The number of dimensions of...
[ "Return", "a", "TPM", "conditioned", "on", "the", "given", "fixed", "node", "indices", "whose", "states", "are", "fixed", "according", "to", "the", "given", "state", "-", "tuple", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/tpm.py#L29-L46
train
wmayner/pyphi
pyphi/tpm.py
expand_tpm
def expand_tpm(tpm): """Broadcast a state-by-node TPM so that singleton dimensions are expanded over the full network. """ unconstrained = np.ones([2] * (tpm.ndim - 1) + [tpm.shape[-1]]) return tpm * unconstrained
python
def expand_tpm(tpm): """Broadcast a state-by-node TPM so that singleton dimensions are expanded over the full network. """ unconstrained = np.ones([2] * (tpm.ndim - 1) + [tpm.shape[-1]]) return tpm * unconstrained
[ "def", "expand_tpm", "(", "tpm", ")", ":", "unconstrained", "=", "np", ".", "ones", "(", "[", "2", "]", "*", "(", "tpm", ".", "ndim", "-", "1", ")", "+", "[", "tpm", ".", "shape", "[", "-", "1", "]", "]", ")", "return", "tpm", "*", "unconstra...
Broadcast a state-by-node TPM so that singleton dimensions are expanded over the full network.
[ "Broadcast", "a", "state", "-", "by", "-", "node", "TPM", "so", "that", "singleton", "dimensions", "are", "expanded", "over", "the", "full", "network", "." ]
deeca69a084d782a6fde7bf26f59e93b593c5d77
https://github.com/wmayner/pyphi/blob/deeca69a084d782a6fde7bf26f59e93b593c5d77/pyphi/tpm.py#L49-L54
train