id int32 0 252k | 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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
5,900 | faucamp/python-gsmmodem | tools/gsmtermlib/terminal.py | GsmTerm._cursorLeft | def _cursorLeft(self):
""" Handles "cursor left" events """
if self.cursorPos > 0:
self.cursorPos -= 1
sys.stdout.write(console.CURSOR_LEFT)
sys.stdout.flush() | python | def _cursorLeft(self):
""" Handles "cursor left" events """
if self.cursorPos > 0:
self.cursorPos -= 1
sys.stdout.write(console.CURSOR_LEFT)
sys.stdout.flush() | [
"def",
"_cursorLeft",
"(",
"self",
")",
":",
"if",
"self",
".",
"cursorPos",
">",
"0",
":",
"self",
".",
"cursorPos",
"-=",
"1",
"sys",
".",
"stdout",
".",
"write",
"(",
"console",
".",
"CURSOR_LEFT",
")",
"sys",
".",
"stdout",
".",
"flush",
"(",
"... | Handles "cursor left" events | [
"Handles",
"cursor",
"left",
"events"
] | 834c68b1387ca2c91e2210faa8f75526b39723b5 | https://github.com/faucamp/python-gsmmodem/blob/834c68b1387ca2c91e2210faa8f75526b39723b5/tools/gsmtermlib/terminal.py#L311-L316 |
5,901 | faucamp/python-gsmmodem | tools/gsmtermlib/terminal.py | GsmTerm._cursorRight | def _cursorRight(self):
""" Handles "cursor right" events """
if self.cursorPos < len(self.inputBuffer):
self.cursorPos += 1
sys.stdout.write(console.CURSOR_RIGHT)
sys.stdout.flush() | python | def _cursorRight(self):
""" Handles "cursor right" events """
if self.cursorPos < len(self.inputBuffer):
self.cursorPos += 1
sys.stdout.write(console.CURSOR_RIGHT)
sys.stdout.flush() | [
"def",
"_cursorRight",
"(",
"self",
")",
":",
"if",
"self",
".",
"cursorPos",
"<",
"len",
"(",
"self",
".",
"inputBuffer",
")",
":",
"self",
".",
"cursorPos",
"+=",
"1",
"sys",
".",
"stdout",
".",
"write",
"(",
"console",
".",
"CURSOR_RIGHT",
")",
"s... | Handles "cursor right" events | [
"Handles",
"cursor",
"right",
"events"
] | 834c68b1387ca2c91e2210faa8f75526b39723b5 | https://github.com/faucamp/python-gsmmodem/blob/834c68b1387ca2c91e2210faa8f75526b39723b5/tools/gsmtermlib/terminal.py#L318-L323 |
5,902 | faucamp/python-gsmmodem | tools/gsmtermlib/terminal.py | GsmTerm._cursorUp | def _cursorUp(self):
""" Handles "cursor up" events """
if self.historyPos > 0:
self.historyPos -= 1
clearLen = len(self.inputBuffer)
self.inputBuffer = list(self.history[self.historyPos])
self.cursorPos = len(self.inputBuffer)
self._refreshInp... | python | def _cursorUp(self):
""" Handles "cursor up" events """
if self.historyPos > 0:
self.historyPos -= 1
clearLen = len(self.inputBuffer)
self.inputBuffer = list(self.history[self.historyPos])
self.cursorPos = len(self.inputBuffer)
self._refreshInp... | [
"def",
"_cursorUp",
"(",
"self",
")",
":",
"if",
"self",
".",
"historyPos",
">",
"0",
":",
"self",
".",
"historyPos",
"-=",
"1",
"clearLen",
"=",
"len",
"(",
"self",
".",
"inputBuffer",
")",
"self",
".",
"inputBuffer",
"=",
"list",
"(",
"self",
".",
... | Handles "cursor up" events | [
"Handles",
"cursor",
"up",
"events"
] | 834c68b1387ca2c91e2210faa8f75526b39723b5 | https://github.com/faucamp/python-gsmmodem/blob/834c68b1387ca2c91e2210faa8f75526b39723b5/tools/gsmtermlib/terminal.py#L325-L332 |
5,903 | faucamp/python-gsmmodem | tools/gsmtermlib/terminal.py | GsmTerm._handleBackspace | def _handleBackspace(self):
""" Handles backspace characters """
if self.cursorPos > 0:
#print( 'cp:',self.cursorPos,'was:', self.inputBuffer)
self.inputBuffer = self.inputBuffer[0:self.cursorPos-1] + self.inputBuffer[self.cursorPos:]
self.cursorPos -= 1
#... | python | def _handleBackspace(self):
""" Handles backspace characters """
if self.cursorPos > 0:
#print( 'cp:',self.cursorPos,'was:', self.inputBuffer)
self.inputBuffer = self.inputBuffer[0:self.cursorPos-1] + self.inputBuffer[self.cursorPos:]
self.cursorPos -= 1
#... | [
"def",
"_handleBackspace",
"(",
"self",
")",
":",
"if",
"self",
".",
"cursorPos",
">",
"0",
":",
"#print( 'cp:',self.cursorPos,'was:', self.inputBuffer)",
"self",
".",
"inputBuffer",
"=",
"self",
".",
"inputBuffer",
"[",
"0",
":",
"self",
".",
"cursorPos",
"-",
... | Handles backspace characters | [
"Handles",
"backspace",
"characters"
] | 834c68b1387ca2c91e2210faa8f75526b39723b5 | https://github.com/faucamp/python-gsmmodem/blob/834c68b1387ca2c91e2210faa8f75526b39723b5/tools/gsmtermlib/terminal.py#L343-L350 |
5,904 | faucamp/python-gsmmodem | tools/gsmtermlib/terminal.py | GsmTerm._handleDelete | def _handleDelete(self):
""" Handles "delete" characters """
if self.cursorPos < len(self.inputBuffer):
self.inputBuffer = self.inputBuffer[0:self.cursorPos] + self.inputBuffer[self.cursorPos+1:]
self._refreshInputPrompt(len(self.inputBuffer)+1) | python | def _handleDelete(self):
""" Handles "delete" characters """
if self.cursorPos < len(self.inputBuffer):
self.inputBuffer = self.inputBuffer[0:self.cursorPos] + self.inputBuffer[self.cursorPos+1:]
self._refreshInputPrompt(len(self.inputBuffer)+1) | [
"def",
"_handleDelete",
"(",
"self",
")",
":",
"if",
"self",
".",
"cursorPos",
"<",
"len",
"(",
"self",
".",
"inputBuffer",
")",
":",
"self",
".",
"inputBuffer",
"=",
"self",
".",
"inputBuffer",
"[",
"0",
":",
"self",
".",
"cursorPos",
"]",
"+",
"sel... | Handles "delete" characters | [
"Handles",
"delete",
"characters"
] | 834c68b1387ca2c91e2210faa8f75526b39723b5 | https://github.com/faucamp/python-gsmmodem/blob/834c68b1387ca2c91e2210faa8f75526b39723b5/tools/gsmtermlib/terminal.py#L352-L356 |
5,905 | faucamp/python-gsmmodem | tools/gsmtermlib/terminal.py | GsmTerm._handleEnd | def _handleEnd(self):
""" Handles "end" character """
self.cursorPos = len(self.inputBuffer)
self._refreshInputPrompt(len(self.inputBuffer)) | python | def _handleEnd(self):
""" Handles "end" character """
self.cursorPos = len(self.inputBuffer)
self._refreshInputPrompt(len(self.inputBuffer)) | [
"def",
"_handleEnd",
"(",
"self",
")",
":",
"self",
".",
"cursorPos",
"=",
"len",
"(",
"self",
".",
"inputBuffer",
")",
"self",
".",
"_refreshInputPrompt",
"(",
"len",
"(",
"self",
".",
"inputBuffer",
")",
")"
] | Handles "end" character | [
"Handles",
"end",
"character"
] | 834c68b1387ca2c91e2210faa8f75526b39723b5 | https://github.com/faucamp/python-gsmmodem/blob/834c68b1387ca2c91e2210faa8f75526b39723b5/tools/gsmtermlib/terminal.py#L363-L366 |
5,906 | faucamp/python-gsmmodem | tools/gsmtermlib/terminal.py | GsmTerm._doCommandCompletion | def _doCommandCompletion(self):
""" Command-completion method """
prefix = ''.join(self.inputBuffer).strip().upper()
matches = self.completion.keys(prefix)
matchLen = len(matches)
if matchLen == 0 and prefix[-1] == '=':
try:
... | python | def _doCommandCompletion(self):
""" Command-completion method """
prefix = ''.join(self.inputBuffer).strip().upper()
matches = self.completion.keys(prefix)
matchLen = len(matches)
if matchLen == 0 and prefix[-1] == '=':
try:
... | [
"def",
"_doCommandCompletion",
"(",
"self",
")",
":",
"prefix",
"=",
"''",
".",
"join",
"(",
"self",
".",
"inputBuffer",
")",
".",
"strip",
"(",
")",
".",
"upper",
"(",
")",
"matches",
"=",
"self",
".",
"completion",
".",
"keys",
"(",
"prefix",
")",
... | Command-completion method | [
"Command",
"-",
"completion",
"method"
] | 834c68b1387ca2c91e2210faa8f75526b39723b5 | https://github.com/faucamp/python-gsmmodem/blob/834c68b1387ca2c91e2210faa8f75526b39723b5/tools/gsmtermlib/terminal.py#L533-L568 |
5,907 | faucamp/python-gsmmodem | gsmmodem/serial_comms.py | SerialComms.connect | def connect(self):
""" Connects to the device and starts the read thread """
self.serial = serial.Serial(port=self.port, baudrate=self.baudrate, timeout=self.timeout)
# Start read thread
self.alive = True
self.rxThread = threading.Thread(target=self._readLoop)
... | python | def connect(self):
""" Connects to the device and starts the read thread """
self.serial = serial.Serial(port=self.port, baudrate=self.baudrate, timeout=self.timeout)
# Start read thread
self.alive = True
self.rxThread = threading.Thread(target=self._readLoop)
... | [
"def",
"connect",
"(",
"self",
")",
":",
"self",
".",
"serial",
"=",
"serial",
".",
"Serial",
"(",
"port",
"=",
"self",
".",
"port",
",",
"baudrate",
"=",
"self",
".",
"baudrate",
",",
"timeout",
"=",
"self",
".",
"timeout",
")",
"# Start read thread",... | Connects to the device and starts the read thread | [
"Connects",
"to",
"the",
"device",
"and",
"starts",
"the",
"read",
"thread"
] | 834c68b1387ca2c91e2210faa8f75526b39723b5 | https://github.com/faucamp/python-gsmmodem/blob/834c68b1387ca2c91e2210faa8f75526b39723b5/gsmmodem/serial_comms.py#L45-L52 |
5,908 | faucamp/python-gsmmodem | gsmmodem/serial_comms.py | SerialComms.close | def close(self):
""" Stops the read thread, waits for it to exit cleanly, then closes the underlying serial port """
self.alive = False
self.rxThread.join()
self.serial.close() | python | def close(self):
""" Stops the read thread, waits for it to exit cleanly, then closes the underlying serial port """
self.alive = False
self.rxThread.join()
self.serial.close() | [
"def",
"close",
"(",
"self",
")",
":",
"self",
".",
"alive",
"=",
"False",
"self",
".",
"rxThread",
".",
"join",
"(",
")",
"self",
".",
"serial",
".",
"close",
"(",
")"
] | Stops the read thread, waits for it to exit cleanly, then closes the underlying serial port | [
"Stops",
"the",
"read",
"thread",
"waits",
"for",
"it",
"to",
"exit",
"cleanly",
"then",
"closes",
"the",
"underlying",
"serial",
"port"
] | 834c68b1387ca2c91e2210faa8f75526b39723b5 | https://github.com/faucamp/python-gsmmodem/blob/834c68b1387ca2c91e2210faa8f75526b39723b5/gsmmodem/serial_comms.py#L54-L58 |
5,909 | faucamp/python-gsmmodem | gsmmodem/serial_comms.py | SerialComms._readLoop | def _readLoop(self):
""" Read thread main loop
Reads lines from the connected device
"""
try:
readTermSeq = list(self.RX_EOL_SEQ)
readTermLen = len(readTermSeq)
rxBuffer = []
while self.alive:
data = self.serial.rea... | python | def _readLoop(self):
""" Read thread main loop
Reads lines from the connected device
"""
try:
readTermSeq = list(self.RX_EOL_SEQ)
readTermLen = len(readTermSeq)
rxBuffer = []
while self.alive:
data = self.serial.rea... | [
"def",
"_readLoop",
"(",
"self",
")",
":",
"try",
":",
"readTermSeq",
"=",
"list",
"(",
"self",
".",
"RX_EOL_SEQ",
")",
"readTermLen",
"=",
"len",
"(",
"readTermSeq",
")",
"rxBuffer",
"=",
"[",
"]",
"while",
"self",
".",
"alive",
":",
"data",
"=",
"s... | Read thread main loop
Reads lines from the connected device | [
"Read",
"thread",
"main",
"loop",
"Reads",
"lines",
"from",
"the",
"connected",
"device"
] | 834c68b1387ca2c91e2210faa8f75526b39723b5 | https://github.com/faucamp/python-gsmmodem/blob/834c68b1387ca2c91e2210faa8f75526b39723b5/gsmmodem/serial_comms.py#L83-L118 |
5,910 | faucamp/python-gsmmodem | gsmmodem/pdu.py | _decodeTimestamp | def _decodeTimestamp(byteIter):
""" Decodes a 7-octet timestamp """
dateStr = decodeSemiOctets(byteIter, 7)
timeZoneStr = dateStr[-2:]
return datetime.strptime(dateStr[:-2], '%y%m%d%H%M%S').replace(tzinfo=SmsPduTzInfo(timeZoneStr)) | python | def _decodeTimestamp(byteIter):
""" Decodes a 7-octet timestamp """
dateStr = decodeSemiOctets(byteIter, 7)
timeZoneStr = dateStr[-2:]
return datetime.strptime(dateStr[:-2], '%y%m%d%H%M%S').replace(tzinfo=SmsPduTzInfo(timeZoneStr)) | [
"def",
"_decodeTimestamp",
"(",
"byteIter",
")",
":",
"dateStr",
"=",
"decodeSemiOctets",
"(",
"byteIter",
",",
"7",
")",
"timeZoneStr",
"=",
"dateStr",
"[",
"-",
"2",
":",
"]",
"return",
"datetime",
".",
"strptime",
"(",
"dateStr",
"[",
":",
"-",
"2",
... | Decodes a 7-octet timestamp | [
"Decodes",
"a",
"7",
"-",
"octet",
"timestamp"
] | 834c68b1387ca2c91e2210faa8f75526b39723b5 | https://github.com/faucamp/python-gsmmodem/blob/834c68b1387ca2c91e2210faa8f75526b39723b5/gsmmodem/pdu.py#L494-L498 |
5,911 | faucamp/python-gsmmodem | gsmmodem/pdu.py | decodeUcs2 | def decodeUcs2(byteIter, numBytes):
""" Decodes UCS2-encoded text from the specified byte iterator, up to a maximum of numBytes """
userData = []
i = 0
try:
while i < numBytes:
userData.append(unichr((next(byteIter) << 8) | next(byteIter)))
i += 2
except StopIteration... | python | def decodeUcs2(byteIter, numBytes):
""" Decodes UCS2-encoded text from the specified byte iterator, up to a maximum of numBytes """
userData = []
i = 0
try:
while i < numBytes:
userData.append(unichr((next(byteIter) << 8) | next(byteIter)))
i += 2
except StopIteration... | [
"def",
"decodeUcs2",
"(",
"byteIter",
",",
"numBytes",
")",
":",
"userData",
"=",
"[",
"]",
"i",
"=",
"0",
"try",
":",
"while",
"i",
"<",
"numBytes",
":",
"userData",
".",
"append",
"(",
"unichr",
"(",
"(",
"next",
"(",
"byteIter",
")",
"<<",
"8",
... | Decodes UCS2-encoded text from the specified byte iterator, up to a maximum of numBytes | [
"Decodes",
"UCS2",
"-",
"encoded",
"text",
"from",
"the",
"specified",
"byte",
"iterator",
"up",
"to",
"a",
"maximum",
"of",
"numBytes"
] | 834c68b1387ca2c91e2210faa8f75526b39723b5 | https://github.com/faucamp/python-gsmmodem/blob/834c68b1387ca2c91e2210faa8f75526b39723b5/gsmmodem/pdu.py#L795-L806 |
5,912 | faucamp/python-gsmmodem | gsmmodem/pdu.py | InformationElement.encode | def encode(self):
""" Encodes this IE and returns the resulting bytes """
result = bytearray()
result.append(self.id)
result.append(self.dataLength)
result.extend(self.data)
return result | python | def encode(self):
""" Encodes this IE and returns the resulting bytes """
result = bytearray()
result.append(self.id)
result.append(self.dataLength)
result.extend(self.data)
return result | [
"def",
"encode",
"(",
"self",
")",
":",
"result",
"=",
"bytearray",
"(",
")",
"result",
".",
"append",
"(",
"self",
".",
"id",
")",
"result",
".",
"append",
"(",
"self",
".",
"dataLength",
")",
"result",
".",
"extend",
"(",
"self",
".",
"data",
")"... | Encodes this IE and returns the resulting bytes | [
"Encodes",
"this",
"IE",
"and",
"returns",
"the",
"resulting",
"bytes"
] | 834c68b1387ca2c91e2210faa8f75526b39723b5 | https://github.com/faucamp/python-gsmmodem/blob/834c68b1387ca2c91e2210faa8f75526b39723b5/gsmmodem/pdu.py#L123-L129 |
5,913 | faucamp/python-gsmmodem | tools/sendsms.py | parseArgsPy26 | def parseArgsPy26():
""" Argument parser for Python 2.6 """
from gsmtermlib.posoptparse import PosOptionParser, Option
parser = PosOptionParser(description='Simple script for sending SMS messages')
parser.add_option('-i', '--port', metavar='PORT', help='port to which the GSM modem is connected; a number... | python | def parseArgsPy26():
""" Argument parser for Python 2.6 """
from gsmtermlib.posoptparse import PosOptionParser, Option
parser = PosOptionParser(description='Simple script for sending SMS messages')
parser.add_option('-i', '--port', metavar='PORT', help='port to which the GSM modem is connected; a number... | [
"def",
"parseArgsPy26",
"(",
")",
":",
"from",
"gsmtermlib",
".",
"posoptparse",
"import",
"PosOptionParser",
",",
"Option",
"parser",
"=",
"PosOptionParser",
"(",
"description",
"=",
"'Simple script for sending SMS messages'",
")",
"parser",
".",
"add_option",
"(",
... | Argument parser for Python 2.6 | [
"Argument",
"parser",
"for",
"Python",
"2",
".",
"6"
] | 834c68b1387ca2c91e2210faa8f75526b39723b5 | https://github.com/faucamp/python-gsmmodem/blob/834c68b1387ca2c91e2210faa8f75526b39723b5/tools/sendsms.py#L26-L40 |
5,914 | faucamp/python-gsmmodem | gsmmodem/util.py | lineMatching | def lineMatching(regexStr, lines):
""" Searches through the specified list of strings and returns the regular expression
match for the first line that matches the specified regex string, or None if no match was found
Note: if you have a pre-compiled regex pattern, use lineMatchingPattern() instead
:t... | python | def lineMatching(regexStr, lines):
""" Searches through the specified list of strings and returns the regular expression
match for the first line that matches the specified regex string, or None if no match was found
Note: if you have a pre-compiled regex pattern, use lineMatchingPattern() instead
:t... | [
"def",
"lineMatching",
"(",
"regexStr",
",",
"lines",
")",
":",
"regex",
"=",
"re",
".",
"compile",
"(",
"regexStr",
")",
"for",
"line",
"in",
"lines",
":",
"m",
"=",
"regex",
".",
"match",
"(",
"line",
")",
"if",
"m",
":",
"return",
"m",
"else",
... | Searches through the specified list of strings and returns the regular expression
match for the first line that matches the specified regex string, or None if no match was found
Note: if you have a pre-compiled regex pattern, use lineMatchingPattern() instead
:type regexStr: Regular expression string to ... | [
"Searches",
"through",
"the",
"specified",
"list",
"of",
"strings",
"and",
"returns",
"the",
"regular",
"expression",
"match",
"for",
"the",
"first",
"line",
"that",
"matches",
"the",
"specified",
"regex",
"string",
"or",
"None",
"if",
"no",
"match",
"was",
... | 834c68b1387ca2c91e2210faa8f75526b39723b5 | https://github.com/faucamp/python-gsmmodem/blob/834c68b1387ca2c91e2210faa8f75526b39723b5/gsmmodem/util.py#L57-L75 |
5,915 | faucamp/python-gsmmodem | gsmmodem/util.py | lineMatchingPattern | def lineMatchingPattern(pattern, lines):
""" Searches through the specified list of strings and returns the regular expression
match for the first line that matches the specified pre-compiled regex pattern, or None if no match was found
Note: if you are using a regex pattern string (i.e. not already compi... | python | def lineMatchingPattern(pattern, lines):
""" Searches through the specified list of strings and returns the regular expression
match for the first line that matches the specified pre-compiled regex pattern, or None if no match was found
Note: if you are using a regex pattern string (i.e. not already compi... | [
"def",
"lineMatchingPattern",
"(",
"pattern",
",",
"lines",
")",
":",
"for",
"line",
"in",
"lines",
":",
"m",
"=",
"pattern",
".",
"match",
"(",
"line",
")",
"if",
"m",
":",
"return",
"m",
"else",
":",
"return",
"None"
] | Searches through the specified list of strings and returns the regular expression
match for the first line that matches the specified pre-compiled regex pattern, or None if no match was found
Note: if you are using a regex pattern string (i.e. not already compiled), use lineMatching() instead
:type patte... | [
"Searches",
"through",
"the",
"specified",
"list",
"of",
"strings",
"and",
"returns",
"the",
"regular",
"expression",
"match",
"for",
"the",
"first",
"line",
"that",
"matches",
"the",
"specified",
"pre",
"-",
"compiled",
"regex",
"pattern",
"or",
"None",
"if",... | 834c68b1387ca2c91e2210faa8f75526b39723b5 | https://github.com/faucamp/python-gsmmodem/blob/834c68b1387ca2c91e2210faa8f75526b39723b5/gsmmodem/util.py#L77-L94 |
5,916 | faucamp/python-gsmmodem | gsmmodem/util.py | allLinesMatchingPattern | def allLinesMatchingPattern(pattern, lines):
""" Like lineMatchingPattern, but returns all lines that match the specified pattern
:type pattern: Compiled regular expression pattern to use
:type lines: List of lines to search
:return: list of re.Match objects for each line matched, or an empty list if ... | python | def allLinesMatchingPattern(pattern, lines):
""" Like lineMatchingPattern, but returns all lines that match the specified pattern
:type pattern: Compiled regular expression pattern to use
:type lines: List of lines to search
:return: list of re.Match objects for each line matched, or an empty list if ... | [
"def",
"allLinesMatchingPattern",
"(",
"pattern",
",",
"lines",
")",
":",
"result",
"=",
"[",
"]",
"for",
"line",
"in",
"lines",
":",
"m",
"=",
"pattern",
".",
"match",
"(",
"line",
")",
"if",
"m",
":",
"result",
".",
"append",
"(",
"m",
")",
"retu... | Like lineMatchingPattern, but returns all lines that match the specified pattern
:type pattern: Compiled regular expression pattern to use
:type lines: List of lines to search
:return: list of re.Match objects for each line matched, or an empty list if none matched
:rtype: list | [
"Like",
"lineMatchingPattern",
"but",
"returns",
"all",
"lines",
"that",
"match",
"the",
"specified",
"pattern"
] | 834c68b1387ca2c91e2210faa8f75526b39723b5 | https://github.com/faucamp/python-gsmmodem/blob/834c68b1387ca2c91e2210faa8f75526b39723b5/gsmmodem/util.py#L96-L110 |
5,917 | n8henrie/pycookiecheat | src/pycookiecheat/pycookiecheat.py | clean | def clean(decrypted: bytes) -> str:
r"""Strip padding from decrypted value.
Remove number indicated by padding
e.g. if last is '\x0e' then ord('\x0e') == 14, so take off 14.
Args:
decrypted: decrypted value
Returns:
Decrypted stripped of junk padding
"""
last = decrypted[-... | python | def clean(decrypted: bytes) -> str:
r"""Strip padding from decrypted value.
Remove number indicated by padding
e.g. if last is '\x0e' then ord('\x0e') == 14, so take off 14.
Args:
decrypted: decrypted value
Returns:
Decrypted stripped of junk padding
"""
last = decrypted[-... | [
"def",
"clean",
"(",
"decrypted",
":",
"bytes",
")",
"->",
"str",
":",
"last",
"=",
"decrypted",
"[",
"-",
"1",
"]",
"if",
"isinstance",
"(",
"last",
",",
"int",
")",
":",
"return",
"decrypted",
"[",
":",
"-",
"last",
"]",
".",
"decode",
"(",
"'u... | r"""Strip padding from decrypted value.
Remove number indicated by padding
e.g. if last is '\x0e' then ord('\x0e') == 14, so take off 14.
Args:
decrypted: decrypted value
Returns:
Decrypted stripped of junk padding | [
"r",
"Strip",
"padding",
"from",
"decrypted",
"value",
"."
] | 1e0ba783da31689f5b37f9706205ff366d72f03d | https://github.com/n8henrie/pycookiecheat/blob/1e0ba783da31689f5b37f9706205ff366d72f03d/src/pycookiecheat/pycookiecheat.py#L26-L41 |
5,918 | pyhys/minimalmodbus | omegacn7500.py | OmegaCN7500.set_pattern_step_setpoint | def set_pattern_step_setpoint(self, patternnumber, stepnumber, setpointvalue):
"""Set the setpoint value for a step.
Args:
* patternnumber (integer): 0-7
* stepnumber (integer): 0-7
* setpointvalue (float): Setpoint value
"""
_checkPatternNumber(patte... | python | def set_pattern_step_setpoint(self, patternnumber, stepnumber, setpointvalue):
"""Set the setpoint value for a step.
Args:
* patternnumber (integer): 0-7
* stepnumber (integer): 0-7
* setpointvalue (float): Setpoint value
"""
_checkPatternNumber(patte... | [
"def",
"set_pattern_step_setpoint",
"(",
"self",
",",
"patternnumber",
",",
"stepnumber",
",",
"setpointvalue",
")",
":",
"_checkPatternNumber",
"(",
"patternnumber",
")",
"_checkStepNumber",
"(",
"stepnumber",
")",
"_checkSetpointValue",
"(",
"setpointvalue",
",",
"s... | Set the setpoint value for a step.
Args:
* patternnumber (integer): 0-7
* stepnumber (integer): 0-7
* setpointvalue (float): Setpoint value | [
"Set",
"the",
"setpoint",
"value",
"for",
"a",
"step",
"."
] | e99f4d74c83258c6039073082955ac9bed3f2155 | https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/omegacn7500.py#L237-L250 |
5,919 | pyhys/minimalmodbus | omegacn7500.py | OmegaCN7500.get_pattern_step_time | def get_pattern_step_time(self, patternnumber, stepnumber):
"""Get the step time.
Args:
* patternnumber (integer): 0-7
* stepnumber (integer): 0-7
Returns:
The step time (int??).
"""
_checkPatternNumber(pa... | python | def get_pattern_step_time(self, patternnumber, stepnumber):
"""Get the step time.
Args:
* patternnumber (integer): 0-7
* stepnumber (integer): 0-7
Returns:
The step time (int??).
"""
_checkPatternNumber(pa... | [
"def",
"get_pattern_step_time",
"(",
"self",
",",
"patternnumber",
",",
"stepnumber",
")",
":",
"_checkPatternNumber",
"(",
"patternnumber",
")",
"_checkStepNumber",
"(",
"stepnumber",
")",
"address",
"=",
"_calculateRegisterAddress",
"(",
"'time'",
",",
"patternnumbe... | Get the step time.
Args:
* patternnumber (integer): 0-7
* stepnumber (integer): 0-7
Returns:
The step time (int??). | [
"Get",
"the",
"step",
"time",
"."
] | e99f4d74c83258c6039073082955ac9bed3f2155 | https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/omegacn7500.py#L253-L268 |
5,920 | pyhys/minimalmodbus | omegacn7500.py | OmegaCN7500.set_pattern_step_time | def set_pattern_step_time(self, patternnumber, stepnumber, timevalue):
"""Set the step time.
Args:
* patternnumber (integer): 0-7
* stepnumber (integer): 0-7
* timevalue (integer??): 0-900
"""
_checkPatternNumber(patternnumber)
_checkStepNumbe... | python | def set_pattern_step_time(self, patternnumber, stepnumber, timevalue):
"""Set the step time.
Args:
* patternnumber (integer): 0-7
* stepnumber (integer): 0-7
* timevalue (integer??): 0-900
"""
_checkPatternNumber(patternnumber)
_checkStepNumbe... | [
"def",
"set_pattern_step_time",
"(",
"self",
",",
"patternnumber",
",",
"stepnumber",
",",
"timevalue",
")",
":",
"_checkPatternNumber",
"(",
"patternnumber",
")",
"_checkStepNumber",
"(",
"stepnumber",
")",
"_checkTimeValue",
"(",
"timevalue",
",",
"self",
".",
"... | Set the step time.
Args:
* patternnumber (integer): 0-7
* stepnumber (integer): 0-7
* timevalue (integer??): 0-900 | [
"Set",
"the",
"step",
"time",
"."
] | e99f4d74c83258c6039073082955ac9bed3f2155 | https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/omegacn7500.py#L271-L284 |
5,921 | pyhys/minimalmodbus | omegacn7500.py | OmegaCN7500.get_pattern_actual_step | def get_pattern_actual_step(self, patternnumber):
"""Get the 'actual step' parameter for a given pattern.
Args:
patternnumber (integer): 0-7
Returns:
The 'actual step' parameter (int).
"""
_checkPatternNumber(patternnumber)
... | python | def get_pattern_actual_step(self, patternnumber):
"""Get the 'actual step' parameter for a given pattern.
Args:
patternnumber (integer): 0-7
Returns:
The 'actual step' parameter (int).
"""
_checkPatternNumber(patternnumber)
... | [
"def",
"get_pattern_actual_step",
"(",
"self",
",",
"patternnumber",
")",
":",
"_checkPatternNumber",
"(",
"patternnumber",
")",
"address",
"=",
"_calculateRegisterAddress",
"(",
"'actualstep'",
",",
"patternnumber",
")",
"return",
"self",
".",
"read_register",
"(",
... | Get the 'actual step' parameter for a given pattern.
Args:
patternnumber (integer): 0-7
Returns:
The 'actual step' parameter (int). | [
"Get",
"the",
"actual",
"step",
"parameter",
"for",
"a",
"given",
"pattern",
"."
] | e99f4d74c83258c6039073082955ac9bed3f2155 | https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/omegacn7500.py#L287-L300 |
5,922 | pyhys/minimalmodbus | omegacn7500.py | OmegaCN7500.set_pattern_actual_step | def set_pattern_actual_step(self, patternnumber, value):
"""Set the 'actual step' parameter for a given pattern.
Args:
* patternnumber (integer): 0-7
* value (integer): 0-7
"""
_checkPatternNumber(patternnumber)
_checkStepNumber(value)
ad... | python | def set_pattern_actual_step(self, patternnumber, value):
"""Set the 'actual step' parameter for a given pattern.
Args:
* patternnumber (integer): 0-7
* value (integer): 0-7
"""
_checkPatternNumber(patternnumber)
_checkStepNumber(value)
ad... | [
"def",
"set_pattern_actual_step",
"(",
"self",
",",
"patternnumber",
",",
"value",
")",
":",
"_checkPatternNumber",
"(",
"patternnumber",
")",
"_checkStepNumber",
"(",
"value",
")",
"address",
"=",
"_calculateRegisterAddress",
"(",
"'actualstep'",
",",
"patternnumber"... | Set the 'actual step' parameter for a given pattern.
Args:
* patternnumber (integer): 0-7
* value (integer): 0-7 | [
"Set",
"the",
"actual",
"step",
"parameter",
"for",
"a",
"given",
"pattern",
"."
] | e99f4d74c83258c6039073082955ac9bed3f2155 | https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/omegacn7500.py#L303-L314 |
5,923 | pyhys/minimalmodbus | omegacn7500.py | OmegaCN7500.get_pattern_additional_cycles | def get_pattern_additional_cycles(self, patternnumber):
"""Get the number of additional cycles for a given pattern.
Args:
patternnumber (integer): 0-7
Returns:
The number of additional cycles (int).
"""
_checkPatternN... | python | def get_pattern_additional_cycles(self, patternnumber):
"""Get the number of additional cycles for a given pattern.
Args:
patternnumber (integer): 0-7
Returns:
The number of additional cycles (int).
"""
_checkPatternN... | [
"def",
"get_pattern_additional_cycles",
"(",
"self",
",",
"patternnumber",
")",
":",
"_checkPatternNumber",
"(",
"patternnumber",
")",
"address",
"=",
"_calculateRegisterAddress",
"(",
"'cycles'",
",",
"patternnumber",
")",
"return",
"self",
".",
"read_register",
"(",... | Get the number of additional cycles for a given pattern.
Args:
patternnumber (integer): 0-7
Returns:
The number of additional cycles (int). | [
"Get",
"the",
"number",
"of",
"additional",
"cycles",
"for",
"a",
"given",
"pattern",
"."
] | e99f4d74c83258c6039073082955ac9bed3f2155 | https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/omegacn7500.py#L317-L330 |
5,924 | pyhys/minimalmodbus | omegacn7500.py | OmegaCN7500.set_pattern_additional_cycles | def set_pattern_additional_cycles(self, patternnumber, value):
"""Set the number of additional cycles for a given pattern.
Args:
* patternnumber (integer): 0-7
* value (integer): 0-99
"""
_checkPatternNumber(patternnumber)
minimalmodbus._checkInt(value, m... | python | def set_pattern_additional_cycles(self, patternnumber, value):
"""Set the number of additional cycles for a given pattern.
Args:
* patternnumber (integer): 0-7
* value (integer): 0-99
"""
_checkPatternNumber(patternnumber)
minimalmodbus._checkInt(value, m... | [
"def",
"set_pattern_additional_cycles",
"(",
"self",
",",
"patternnumber",
",",
"value",
")",
":",
"_checkPatternNumber",
"(",
"patternnumber",
")",
"minimalmodbus",
".",
"_checkInt",
"(",
"value",
",",
"minvalue",
"=",
"0",
",",
"maxvalue",
"=",
"99",
",",
"d... | Set the number of additional cycles for a given pattern.
Args:
* patternnumber (integer): 0-7
* value (integer): 0-99 | [
"Set",
"the",
"number",
"of",
"additional",
"cycles",
"for",
"a",
"given",
"pattern",
"."
] | e99f4d74c83258c6039073082955ac9bed3f2155 | https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/omegacn7500.py#L333-L344 |
5,925 | pyhys/minimalmodbus | omegacn7500.py | OmegaCN7500.get_pattern_link_topattern | def get_pattern_link_topattern(self, patternnumber):
"""Get the 'linked pattern' value for a given pattern.
Args:
patternnumber (integer): From 0-7
Returns:
The 'linked pattern' value (int).
"""
_checkPatternNumber(patternnumber)
add... | python | def get_pattern_link_topattern(self, patternnumber):
"""Get the 'linked pattern' value for a given pattern.
Args:
patternnumber (integer): From 0-7
Returns:
The 'linked pattern' value (int).
"""
_checkPatternNumber(patternnumber)
add... | [
"def",
"get_pattern_link_topattern",
"(",
"self",
",",
"patternnumber",
")",
":",
"_checkPatternNumber",
"(",
"patternnumber",
")",
"address",
"=",
"_calculateRegisterAddress",
"(",
"'linkpattern'",
",",
"patternnumber",
")",
"return",
"self",
".",
"read_register",
"(... | Get the 'linked pattern' value for a given pattern.
Args:
patternnumber (integer): From 0-7
Returns:
The 'linked pattern' value (int). | [
"Get",
"the",
"linked",
"pattern",
"value",
"for",
"a",
"given",
"pattern",
"."
] | e99f4d74c83258c6039073082955ac9bed3f2155 | https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/omegacn7500.py#L347-L359 |
5,926 | pyhys/minimalmodbus | omegacn7500.py | OmegaCN7500.get_all_pattern_variables | def get_all_pattern_variables(self, patternnumber):
"""Get all variables for a given pattern at one time.
Args:
patternnumber (integer): 0-7
Returns:
A descriptive multiline string.
"""
_checkPatternNumber(patternnumber)
... | python | def get_all_pattern_variables(self, patternnumber):
"""Get all variables for a given pattern at one time.
Args:
patternnumber (integer): 0-7
Returns:
A descriptive multiline string.
"""
_checkPatternNumber(patternnumber)
... | [
"def",
"get_all_pattern_variables",
"(",
"self",
",",
"patternnumber",
")",
":",
"_checkPatternNumber",
"(",
"patternnumber",
")",
"outputstring",
"=",
"''",
"for",
"stepnumber",
"in",
"range",
"(",
"8",
")",
":",
"outputstring",
"+=",
"'SP{0}: {1} Time{0}: {2}\\n'... | Get all variables for a given pattern at one time.
Args:
patternnumber (integer): 0-7
Returns:
A descriptive multiline string. | [
"Get",
"all",
"variables",
"for",
"a",
"given",
"pattern",
"at",
"one",
"time",
"."
] | e99f4d74c83258c6039073082955ac9bed3f2155 | https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/omegacn7500.py#L376-L398 |
5,927 | pyhys/minimalmodbus | omegacn7500.py | OmegaCN7500.set_all_pattern_variables | def set_all_pattern_variables(self, patternnumber, \
sp0, ti0, sp1, ti1, sp2, ti2, sp3, ti3, sp4, ti4, sp5, ti5, sp6, ti6, sp7, ti7, \
actual_step, additional_cycles, link_pattern):
"""Set all variables for a given pattern at one time.
Args:
* patternnumber (integer): 0-7
... | python | def set_all_pattern_variables(self, patternnumber, \
sp0, ti0, sp1, ti1, sp2, ti2, sp3, ti3, sp4, ti4, sp5, ti5, sp6, ti6, sp7, ti7, \
actual_step, additional_cycles, link_pattern):
"""Set all variables for a given pattern at one time.
Args:
* patternnumber (integer): 0-7
... | [
"def",
"set_all_pattern_variables",
"(",
"self",
",",
"patternnumber",
",",
"sp0",
",",
"ti0",
",",
"sp1",
",",
"ti1",
",",
"sp2",
",",
"ti2",
",",
"sp3",
",",
"ti3",
",",
"sp4",
",",
"ti4",
",",
"sp5",
",",
"ti5",
",",
"sp6",
",",
"ti6",
",",
"s... | Set all variables for a given pattern at one time.
Args:
* patternnumber (integer): 0-7
* sp[*n*] (float): setpoint value for step *n*
* ti[*n*] (integer??): step time for step *n*, 0-900
* actual_step (int): ?
* additional_cycles(int): ?
... | [
"Set",
"all",
"variables",
"for",
"a",
"given",
"pattern",
"at",
"one",
"time",
"."
] | e99f4d74c83258c6039073082955ac9bed3f2155 | https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/omegacn7500.py#L401-L435 |
5,928 | pyhys/minimalmodbus | dummy_serial.py | Serial.close | def close(self):
"""Close a port on dummy_serial."""
if VERBOSE:
_print_out('\nDummy_serial: Closing port\n')
if not self._isOpen:
raise IOError('Dummy_serial: The port is already closed')
self._isOpen = False
self.port = None | python | def close(self):
"""Close a port on dummy_serial."""
if VERBOSE:
_print_out('\nDummy_serial: Closing port\n')
if not self._isOpen:
raise IOError('Dummy_serial: The port is already closed')
self._isOpen = False
self.port = None | [
"def",
"close",
"(",
"self",
")",
":",
"if",
"VERBOSE",
":",
"_print_out",
"(",
"'\\nDummy_serial: Closing port\\n'",
")",
"if",
"not",
"self",
".",
"_isOpen",
":",
"raise",
"IOError",
"(",
"'Dummy_serial: The port is already closed'",
")",
"self",
".",
"_isOpen",... | Close a port on dummy_serial. | [
"Close",
"a",
"port",
"on",
"dummy_serial",
"."
] | e99f4d74c83258c6039073082955ac9bed3f2155 | https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/dummy_serial.py#L129-L138 |
5,929 | pyhys/minimalmodbus | dummy_serial.py | Serial.write | def write(self, inputdata):
"""Write to a port on dummy_serial.
Args:
inputdata (string/bytes): data for sending to the port on dummy_serial. Will affect the response
for subsequent read operations.
Note that for Python2, the inputdata should be a **string**. For Pytho... | python | def write(self, inputdata):
"""Write to a port on dummy_serial.
Args:
inputdata (string/bytes): data for sending to the port on dummy_serial. Will affect the response
for subsequent read operations.
Note that for Python2, the inputdata should be a **string**. For Pytho... | [
"def",
"write",
"(",
"self",
",",
"inputdata",
")",
":",
"if",
"VERBOSE",
":",
"_print_out",
"(",
"'\\nDummy_serial: Writing to port. Given:'",
"+",
"repr",
"(",
"inputdata",
")",
"+",
"'\\n'",
")",
"if",
"sys",
".",
"version_info",
"[",
"0",
"]",
">",
"2"... | Write to a port on dummy_serial.
Args:
inputdata (string/bytes): data for sending to the port on dummy_serial. Will affect the response
for subsequent read operations.
Note that for Python2, the inputdata should be a **string**. For Python3 it should be of type **bytes**. | [
"Write",
"to",
"a",
"port",
"on",
"dummy_serial",
"."
] | e99f4d74c83258c6039073082955ac9bed3f2155 | https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/dummy_serial.py#L141-L169 |
5,930 | pyhys/minimalmodbus | dummy_serial.py | Serial.read | def read(self, numberOfBytes):
"""Read from a port on dummy_serial.
The response is dependent on what was written last to the port on dummy_serial,
and what is defined in the :data:`RESPONSES` dictionary.
Args:
numberOfBytes (int): For compability with the real function.
... | python | def read(self, numberOfBytes):
"""Read from a port on dummy_serial.
The response is dependent on what was written last to the port on dummy_serial,
and what is defined in the :data:`RESPONSES` dictionary.
Args:
numberOfBytes (int): For compability with the real function.
... | [
"def",
"read",
"(",
"self",
",",
"numberOfBytes",
")",
":",
"if",
"VERBOSE",
":",
"_print_out",
"(",
"'\\nDummy_serial: Reading from port (max length {!r} bytes)'",
".",
"format",
"(",
"numberOfBytes",
")",
")",
"if",
"numberOfBytes",
"<",
"0",
":",
"raise",
"IOEr... | Read from a port on dummy_serial.
The response is dependent on what was written last to the port on dummy_serial,
and what is defined in the :data:`RESPONSES` dictionary.
Args:
numberOfBytes (int): For compability with the real function.
Returns a **string** for Python2 a... | [
"Read",
"from",
"a",
"port",
"on",
"dummy_serial",
"."
] | e99f4d74c83258c6039073082955ac9bed3f2155 | https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/dummy_serial.py#L172-L227 |
5,931 | pyhys/minimalmodbus | minimalmodbus.py | _embedPayload | def _embedPayload(slaveaddress, mode, functioncode, payloaddata):
"""Build a request from the slaveaddress, the function code and the payload data.
Args:
* slaveaddress (int): The address of the slave.
* mode (str): The modbus protcol mode (MODE_RTU or MODE_ASCII)
* functioncode (int): ... | python | def _embedPayload(slaveaddress, mode, functioncode, payloaddata):
"""Build a request from the slaveaddress, the function code and the payload data.
Args:
* slaveaddress (int): The address of the slave.
* mode (str): The modbus protcol mode (MODE_RTU or MODE_ASCII)
* functioncode (int): ... | [
"def",
"_embedPayload",
"(",
"slaveaddress",
",",
"mode",
",",
"functioncode",
",",
"payloaddata",
")",
":",
"_checkSlaveaddress",
"(",
"slaveaddress",
")",
"_checkMode",
"(",
"mode",
")",
"_checkFunctioncode",
"(",
"functioncode",
",",
"None",
")",
"_checkString"... | Build a request from the slaveaddress, the function code and the payload data.
Args:
* slaveaddress (int): The address of the slave.
* mode (str): The modbus protcol mode (MODE_RTU or MODE_ASCII)
* functioncode (int): The function code for the command to be performed. Can for example be 16 ... | [
"Build",
"a",
"request",
"from",
"the",
"slaveaddress",
"the",
"function",
"code",
"and",
"the",
"payload",
"data",
"."
] | e99f4d74c83258c6039073082955ac9bed3f2155 | https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/minimalmodbus.py#L939-L977 |
5,932 | pyhys/minimalmodbus | minimalmodbus.py | _extractPayload | def _extractPayload(response, slaveaddress, mode, functioncode):
"""Extract the payload data part from the slave's response.
Args:
* response (str): The raw response byte string from the slave.
* slaveaddress (int): The adress of the slave. Used here for error checking only.
* mode (str... | python | def _extractPayload(response, slaveaddress, mode, functioncode):
"""Extract the payload data part from the slave's response.
Args:
* response (str): The raw response byte string from the slave.
* slaveaddress (int): The adress of the slave. Used here for error checking only.
* mode (str... | [
"def",
"_extractPayload",
"(",
"response",
",",
"slaveaddress",
",",
"mode",
",",
"functioncode",
")",
":",
"BYTEPOSITION_FOR_ASCII_HEADER",
"=",
"0",
"# Relative to plain response",
"BYTEPOSITION_FOR_SLAVEADDRESS",
"=",
"0",
"# Relative to (stripped) response",
"BYTEPOSITION... | Extract the payload data part from the slave's response.
Args:
* response (str): The raw response byte string from the slave.
* slaveaddress (int): The adress of the slave. Used here for error checking only.
* mode (str): The modbus protcol mode (MODE_RTU or MODE_ASCII)
* functionco... | [
"Extract",
"the",
"payload",
"data",
"part",
"from",
"the",
"slave",
"s",
"response",
"."
] | e99f4d74c83258c6039073082955ac9bed3f2155 | https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/minimalmodbus.py#L980-L1103 |
5,933 | pyhys/minimalmodbus | minimalmodbus.py | _predictResponseSize | def _predictResponseSize(mode, functioncode, payloadToSlave):
"""Calculate the number of bytes that should be received from the slave.
Args:
* mode (str): The modbus protcol mode (MODE_RTU or MODE_ASCII)
* functioncode (int): Modbus function code.
* payloadToSlave (str): The raw request that is ... | python | def _predictResponseSize(mode, functioncode, payloadToSlave):
"""Calculate the number of bytes that should be received from the slave.
Args:
* mode (str): The modbus protcol mode (MODE_RTU or MODE_ASCII)
* functioncode (int): Modbus function code.
* payloadToSlave (str): The raw request that is ... | [
"def",
"_predictResponseSize",
"(",
"mode",
",",
"functioncode",
",",
"payloadToSlave",
")",
":",
"MIN_PAYLOAD_LENGTH",
"=",
"4",
"# For implemented functioncodes here",
"BYTERANGE_FOR_GIVEN_SIZE",
"=",
"slice",
"(",
"2",
",",
"4",
")",
"# Within the payload",
"NUMBER_O... | Calculate the number of bytes that should be received from the slave.
Args:
* mode (str): The modbus protcol mode (MODE_RTU or MODE_ASCII)
* functioncode (int): Modbus function code.
* payloadToSlave (str): The raw request that is to be sent to the slave (not hex encoded string)
Returns:
... | [
"Calculate",
"the",
"number",
"of",
"bytes",
"that",
"should",
"be",
"received",
"from",
"the",
"slave",
"."
] | e99f4d74c83258c6039073082955ac9bed3f2155 | https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/minimalmodbus.py#L1110-L1172 |
5,934 | pyhys/minimalmodbus | minimalmodbus.py | _calculate_minimum_silent_period | def _calculate_minimum_silent_period(baudrate):
"""Calculate the silent period length to comply with the 3.5 character silence between messages.
Args:
baudrate (numerical): The baudrate for the serial port
Returns:
The number of seconds (float) that should pass between each message on the ... | python | def _calculate_minimum_silent_period(baudrate):
"""Calculate the silent period length to comply with the 3.5 character silence between messages.
Args:
baudrate (numerical): The baudrate for the serial port
Returns:
The number of seconds (float) that should pass between each message on the ... | [
"def",
"_calculate_minimum_silent_period",
"(",
"baudrate",
")",
":",
"_checkNumerical",
"(",
"baudrate",
",",
"minvalue",
"=",
"1",
",",
"description",
"=",
"'baudrate'",
")",
"# Avoid division by zero",
"BITTIMES_PER_CHARACTERTIME",
"=",
"11",
"MINIMUM_SILENT_CHARACTERT... | Calculate the silent period length to comply with the 3.5 character silence between messages.
Args:
baudrate (numerical): The baudrate for the serial port
Returns:
The number of seconds (float) that should pass between each message on the bus.
Raises:
ValueError, TypeError. | [
"Calculate",
"the",
"silent",
"period",
"length",
"to",
"comply",
"with",
"the",
"3",
".",
"5",
"character",
"silence",
"between",
"messages",
"."
] | e99f4d74c83258c6039073082955ac9bed3f2155 | https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/minimalmodbus.py#L1175-L1194 |
5,935 | pyhys/minimalmodbus | minimalmodbus.py | _numToTwoByteString | def _numToTwoByteString(value, numberOfDecimals=0, LsbFirst=False, signed=False):
"""Convert a numerical value to a two-byte string, possibly scaling it.
Args:
* value (float or int): The numerical value to be converted.
* numberOfDecimals (int): Number of decimals, 0 or more, for scaling.
... | python | def _numToTwoByteString(value, numberOfDecimals=0, LsbFirst=False, signed=False):
"""Convert a numerical value to a two-byte string, possibly scaling it.
Args:
* value (float or int): The numerical value to be converted.
* numberOfDecimals (int): Number of decimals, 0 or more, for scaling.
... | [
"def",
"_numToTwoByteString",
"(",
"value",
",",
"numberOfDecimals",
"=",
"0",
",",
"LsbFirst",
"=",
"False",
",",
"signed",
"=",
"False",
")",
":",
"_checkNumerical",
"(",
"value",
",",
"description",
"=",
"'inputvalue'",
")",
"_checkInt",
"(",
"numberOfDecim... | Convert a numerical value to a two-byte string, possibly scaling it.
Args:
* value (float or int): The numerical value to be converted.
* numberOfDecimals (int): Number of decimals, 0 or more, for scaling.
* LsbFirst (bol): Whether the least significant byte should be first in the resulting... | [
"Convert",
"a",
"numerical",
"value",
"to",
"a",
"two",
"-",
"byte",
"string",
"possibly",
"scaling",
"it",
"."
] | e99f4d74c83258c6039073082955ac9bed3f2155 | https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/minimalmodbus.py#L1219-L1277 |
5,936 | pyhys/minimalmodbus | minimalmodbus.py | _twoByteStringToNum | def _twoByteStringToNum(bytestring, numberOfDecimals=0, signed=False):
"""Convert a two-byte string to a numerical value, possibly scaling it.
Args:
* bytestring (str): A string of length 2.
* numberOfDecimals (int): The number of decimals. Defaults to 0.
* signed (bol): Whether large p... | python | def _twoByteStringToNum(bytestring, numberOfDecimals=0, signed=False):
"""Convert a two-byte string to a numerical value, possibly scaling it.
Args:
* bytestring (str): A string of length 2.
* numberOfDecimals (int): The number of decimals. Defaults to 0.
* signed (bol): Whether large p... | [
"def",
"_twoByteStringToNum",
"(",
"bytestring",
",",
"numberOfDecimals",
"=",
"0",
",",
"signed",
"=",
"False",
")",
":",
"_checkString",
"(",
"bytestring",
",",
"minlength",
"=",
"2",
",",
"maxlength",
"=",
"2",
",",
"description",
"=",
"'bytestring'",
")"... | Convert a two-byte string to a numerical value, possibly scaling it.
Args:
* bytestring (str): A string of length 2.
* numberOfDecimals (int): The number of decimals. Defaults to 0.
* signed (bol): Whether large positive values should be interpreted as negative values.
Returns:
... | [
"Convert",
"a",
"two",
"-",
"byte",
"string",
"to",
"a",
"numerical",
"value",
"possibly",
"scaling",
"it",
"."
] | e99f4d74c83258c6039073082955ac9bed3f2155 | https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/minimalmodbus.py#L1280-L1323 |
5,937 | pyhys/minimalmodbus | minimalmodbus.py | _pack | def _pack(formatstring, value):
"""Pack a value into a bytestring.
Uses the built-in :mod:`struct` Python module.
Args:
* formatstring (str): String for the packing. See the :mod:`struct` module for details.
* value (depends on formatstring): The value to be packed
Returns:
A ... | python | def _pack(formatstring, value):
"""Pack a value into a bytestring.
Uses the built-in :mod:`struct` Python module.
Args:
* formatstring (str): String for the packing. See the :mod:`struct` module for details.
* value (depends on formatstring): The value to be packed
Returns:
A ... | [
"def",
"_pack",
"(",
"formatstring",
",",
"value",
")",
":",
"_checkString",
"(",
"formatstring",
",",
"description",
"=",
"'formatstring'",
",",
"minlength",
"=",
"1",
")",
"try",
":",
"result",
"=",
"struct",
".",
"pack",
"(",
"formatstring",
",",
"value... | Pack a value into a bytestring.
Uses the built-in :mod:`struct` Python module.
Args:
* formatstring (str): String for the packing. See the :mod:`struct` module for details.
* value (depends on formatstring): The value to be packed
Returns:
A bytestring (str).
Raises:
... | [
"Pack",
"a",
"value",
"into",
"a",
"bytestring",
"."
] | e99f4d74c83258c6039073082955ac9bed3f2155 | https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/minimalmodbus.py#L1597-L1627 |
5,938 | pyhys/minimalmodbus | minimalmodbus.py | _unpack | def _unpack(formatstring, packed):
"""Unpack a bytestring into a value.
Uses the built-in :mod:`struct` Python module.
Args:
* formatstring (str): String for the packing. See the :mod:`struct` module for details.
* packed (str): The bytestring to be unpacked.
Returns:
A value.... | python | def _unpack(formatstring, packed):
"""Unpack a bytestring into a value.
Uses the built-in :mod:`struct` Python module.
Args:
* formatstring (str): String for the packing. See the :mod:`struct` module for details.
* packed (str): The bytestring to be unpacked.
Returns:
A value.... | [
"def",
"_unpack",
"(",
"formatstring",
",",
"packed",
")",
":",
"_checkString",
"(",
"formatstring",
",",
"description",
"=",
"'formatstring'",
",",
"minlength",
"=",
"1",
")",
"_checkString",
"(",
"packed",
",",
"description",
"=",
"'packed string'",
",",
"mi... | Unpack a bytestring into a value.
Uses the built-in :mod:`struct` Python module.
Args:
* formatstring (str): String for the packing. See the :mod:`struct` module for details.
* packed (str): The bytestring to be unpacked.
Returns:
A value. The type depends on the formatstring.
... | [
"Unpack",
"a",
"bytestring",
"into",
"a",
"value",
"."
] | e99f4d74c83258c6039073082955ac9bed3f2155 | https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/minimalmodbus.py#L1630-L1662 |
5,939 | pyhys/minimalmodbus | minimalmodbus.py | _hexencode | def _hexencode(bytestring, insert_spaces = False):
"""Convert a byte string to a hex encoded string.
For example 'J' will return '4A', and ``'\\x04'`` will return '04'.
Args:
bytestring (str): Can be for example ``'A\\x01B\\x45'``.
insert_spaces (bool): Insert space characters between pair... | python | def _hexencode(bytestring, insert_spaces = False):
"""Convert a byte string to a hex encoded string.
For example 'J' will return '4A', and ``'\\x04'`` will return '04'.
Args:
bytestring (str): Can be for example ``'A\\x01B\\x45'``.
insert_spaces (bool): Insert space characters between pair... | [
"def",
"_hexencode",
"(",
"bytestring",
",",
"insert_spaces",
"=",
"False",
")",
":",
"_checkString",
"(",
"bytestring",
",",
"description",
"=",
"'byte string'",
")",
"separator",
"=",
"''",
"if",
"not",
"insert_spaces",
"else",
"' '",
"# Use plain string formatt... | Convert a byte string to a hex encoded string.
For example 'J' will return '4A', and ``'\\x04'`` will return '04'.
Args:
bytestring (str): Can be for example ``'A\\x01B\\x45'``.
insert_spaces (bool): Insert space characters between pair of characters to increase readability.
Returns:
... | [
"Convert",
"a",
"byte",
"string",
"to",
"a",
"hex",
"encoded",
"string",
"."
] | e99f4d74c83258c6039073082955ac9bed3f2155 | https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/minimalmodbus.py#L1665-L1692 |
5,940 | pyhys/minimalmodbus | minimalmodbus.py | _hexdecode | def _hexdecode(hexstring):
"""Convert a hex encoded string to a byte string.
For example '4A' will return 'J', and '04' will return ``'\\x04'`` (which has length 1).
Args:
hexstring (str): Can be for example 'A3' or 'A3B4'. Must be of even length.
Allowed characters are '0' to '9', 'a' to ... | python | def _hexdecode(hexstring):
"""Convert a hex encoded string to a byte string.
For example '4A' will return 'J', and '04' will return ``'\\x04'`` (which has length 1).
Args:
hexstring (str): Can be for example 'A3' or 'A3B4'. Must be of even length.
Allowed characters are '0' to '9', 'a' to ... | [
"def",
"_hexdecode",
"(",
"hexstring",
")",
":",
"# Note: For Python3 the appropriate would be: raise TypeError(new_error_message) from err",
"# but the Python2 interpreter will indicate SyntaxError.",
"# Thus we need to live with this warning in Python3:",
"# 'During handling of the above excepti... | Convert a hex encoded string to a byte string.
For example '4A' will return 'J', and '04' will return ``'\\x04'`` (which has length 1).
Args:
hexstring (str): Can be for example 'A3' or 'A3B4'. Must be of even length.
Allowed characters are '0' to '9', 'a' to 'f' and 'A' to 'F' (not space).
... | [
"Convert",
"a",
"hex",
"encoded",
"string",
"to",
"a",
"byte",
"string",
"."
] | e99f4d74c83258c6039073082955ac9bed3f2155 | https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/minimalmodbus.py#L1695-L1733 |
5,941 | pyhys/minimalmodbus | minimalmodbus.py | _bitResponseToValue | def _bitResponseToValue(bytestring):
"""Convert a response string to a numerical value.
Args:
bytestring (str): A string of length 1. Can be for example ``\\x01``.
Returns:
The converted value (int).
Raises:
TypeError, ValueError
"""
_checkString(bytestring, descripti... | python | def _bitResponseToValue(bytestring):
"""Convert a response string to a numerical value.
Args:
bytestring (str): A string of length 1. Can be for example ``\\x01``.
Returns:
The converted value (int).
Raises:
TypeError, ValueError
"""
_checkString(bytestring, descripti... | [
"def",
"_bitResponseToValue",
"(",
"bytestring",
")",
":",
"_checkString",
"(",
"bytestring",
",",
"description",
"=",
"'bytestring'",
",",
"minlength",
"=",
"1",
",",
"maxlength",
"=",
"1",
")",
"RESPONSE_ON",
"=",
"'\\x01'",
"RESPONSE_OFF",
"=",
"'\\x00'",
"... | Convert a response string to a numerical value.
Args:
bytestring (str): A string of length 1. Can be for example ``\\x01``.
Returns:
The converted value (int).
Raises:
TypeError, ValueError | [
"Convert",
"a",
"response",
"string",
"to",
"a",
"numerical",
"value",
"."
] | e99f4d74c83258c6039073082955ac9bed3f2155 | https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/minimalmodbus.py#L1747-L1770 |
5,942 | pyhys/minimalmodbus | minimalmodbus.py | _createBitpattern | def _createBitpattern(functioncode, value):
"""Create the bit pattern that is used for writing single bits.
This is basically a storage of numerical constants.
Args:
* functioncode (int): can be 5 or 15
* value (int): can be 0 or 1
Returns:
The bit pattern (string).
Raise... | python | def _createBitpattern(functioncode, value):
"""Create the bit pattern that is used for writing single bits.
This is basically a storage of numerical constants.
Args:
* functioncode (int): can be 5 or 15
* value (int): can be 0 or 1
Returns:
The bit pattern (string).
Raise... | [
"def",
"_createBitpattern",
"(",
"functioncode",
",",
"value",
")",
":",
"_checkFunctioncode",
"(",
"functioncode",
",",
"[",
"5",
",",
"15",
"]",
")",
"_checkInt",
"(",
"value",
",",
"minvalue",
"=",
"0",
",",
"maxvalue",
"=",
"1",
",",
"description",
"... | Create the bit pattern that is used for writing single bits.
This is basically a storage of numerical constants.
Args:
* functioncode (int): can be 5 or 15
* value (int): can be 0 or 1
Returns:
The bit pattern (string).
Raises:
TypeError, ValueError | [
"Create",
"the",
"bit",
"pattern",
"that",
"is",
"used",
"for",
"writing",
"single",
"bits",
"."
] | e99f4d74c83258c6039073082955ac9bed3f2155 | https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/minimalmodbus.py#L1773-L1802 |
5,943 | pyhys/minimalmodbus | minimalmodbus.py | _twosComplement | def _twosComplement(x, bits=16):
"""Calculate the two's complement of an integer.
Then also negative values can be represented by an upper range of positive values.
See https://en.wikipedia.org/wiki/Two%27s_complement
Args:
* x (int): input integer.
* bits (int): number of bits, must b... | python | def _twosComplement(x, bits=16):
"""Calculate the two's complement of an integer.
Then also negative values can be represented by an upper range of positive values.
See https://en.wikipedia.org/wiki/Two%27s_complement
Args:
* x (int): input integer.
* bits (int): number of bits, must b... | [
"def",
"_twosComplement",
"(",
"x",
",",
"bits",
"=",
"16",
")",
":",
"_checkInt",
"(",
"bits",
",",
"minvalue",
"=",
"0",
",",
"description",
"=",
"'number of bits'",
")",
"_checkInt",
"(",
"x",
",",
"description",
"=",
"'input'",
")",
"upperlimit",
"="... | Calculate the two's complement of an integer.
Then also negative values can be represented by an upper range of positive values.
See https://en.wikipedia.org/wiki/Two%27s_complement
Args:
* x (int): input integer.
* bits (int): number of bits, must be > 0.
Returns:
An int, tha... | [
"Calculate",
"the",
"two",
"s",
"complement",
"of",
"an",
"integer",
"."
] | e99f4d74c83258c6039073082955ac9bed3f2155 | https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/minimalmodbus.py#L1809-L1847 |
5,944 | pyhys/minimalmodbus | minimalmodbus.py | _setBitOn | def _setBitOn(x, bitNum):
"""Set bit 'bitNum' to True.
Args:
* x (int): The value before.
* bitNum (int): The bit number that should be set to True.
Returns:
The value after setting the bit. This is an integer.
For example:
For x = 4 (dec) = 0100 (bin), setting bit num... | python | def _setBitOn(x, bitNum):
"""Set bit 'bitNum' to True.
Args:
* x (int): The value before.
* bitNum (int): The bit number that should be set to True.
Returns:
The value after setting the bit. This is an integer.
For example:
For x = 4 (dec) = 0100 (bin), setting bit num... | [
"def",
"_setBitOn",
"(",
"x",
",",
"bitNum",
")",
":",
"_checkInt",
"(",
"x",
",",
"minvalue",
"=",
"0",
",",
"description",
"=",
"'input value'",
")",
"_checkInt",
"(",
"bitNum",
",",
"minvalue",
"=",
"0",
",",
"description",
"=",
"'bitnumber'",
")",
... | Set bit 'bitNum' to True.
Args:
* x (int): The value before.
* bitNum (int): The bit number that should be set to True.
Returns:
The value after setting the bit. This is an integer.
For example:
For x = 4 (dec) = 0100 (bin), setting bit number 0 results in 0101 (bin) = 5 (... | [
"Set",
"bit",
"bitNum",
"to",
"True",
"."
] | e99f4d74c83258c6039073082955ac9bed3f2155 | https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/minimalmodbus.py#L1893-L1910 |
5,945 | pyhys/minimalmodbus | minimalmodbus.py | _calculateCrcString | def _calculateCrcString(inputstring):
"""Calculate CRC-16 for Modbus.
Args:
inputstring (str): An arbitrary-length message (without the CRC).
Returns:
A two-byte CRC string, where the least significant byte is first.
"""
_checkString(inputstring, description='input CRC string')
... | python | def _calculateCrcString(inputstring):
"""Calculate CRC-16 for Modbus.
Args:
inputstring (str): An arbitrary-length message (without the CRC).
Returns:
A two-byte CRC string, where the least significant byte is first.
"""
_checkString(inputstring, description='input CRC string')
... | [
"def",
"_calculateCrcString",
"(",
"inputstring",
")",
":",
"_checkString",
"(",
"inputstring",
",",
"description",
"=",
"'input CRC string'",
")",
"# Preload a 16-bit register with ones",
"register",
"=",
"0xFFFF",
"for",
"char",
"in",
"inputstring",
":",
"register",
... | Calculate CRC-16 for Modbus.
Args:
inputstring (str): An arbitrary-length message (without the CRC).
Returns:
A two-byte CRC string, where the least significant byte is first. | [
"Calculate",
"CRC",
"-",
"16",
"for",
"Modbus",
"."
] | e99f4d74c83258c6039073082955ac9bed3f2155 | https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/minimalmodbus.py#L1965-L1983 |
5,946 | pyhys/minimalmodbus | minimalmodbus.py | _calculateLrcString | def _calculateLrcString(inputstring):
"""Calculate LRC for Modbus.
Args:
inputstring (str): An arbitrary-length message (without the beginning
colon and terminating CRLF). It should already be decoded from hex-string.
Returns:
A one-byte LRC bytestring (not encoded to hex-string)
... | python | def _calculateLrcString(inputstring):
"""Calculate LRC for Modbus.
Args:
inputstring (str): An arbitrary-length message (without the beginning
colon and terminating CRLF). It should already be decoded from hex-string.
Returns:
A one-byte LRC bytestring (not encoded to hex-string)
... | [
"def",
"_calculateLrcString",
"(",
"inputstring",
")",
":",
"_checkString",
"(",
"inputstring",
",",
"description",
"=",
"'input LRC string'",
")",
"register",
"=",
"0",
"for",
"character",
"in",
"inputstring",
":",
"register",
"+=",
"ord",
"(",
"character",
")"... | Calculate LRC for Modbus.
Args:
inputstring (str): An arbitrary-length message (without the beginning
colon and terminating CRLF). It should already be decoded from hex-string.
Returns:
A one-byte LRC bytestring (not encoded to hex-string)
Algorithm from the document 'MODBUS over ... | [
"Calculate",
"LRC",
"for",
"Modbus",
"."
] | e99f4d74c83258c6039073082955ac9bed3f2155 | https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/minimalmodbus.py#L1986-L2016 |
5,947 | pyhys/minimalmodbus | minimalmodbus.py | _checkMode | def _checkMode(mode):
"""Check that the Modbus mode is valie.
Args:
mode (string): The Modbus mode (MODE_RTU or MODE_ASCII)
Raises:
TypeError, ValueError
"""
if not isinstance(mode, str):
raise TypeError('The {0} should be a string. Given: {1!r}'.format("mode", mode))
... | python | def _checkMode(mode):
"""Check that the Modbus mode is valie.
Args:
mode (string): The Modbus mode (MODE_RTU or MODE_ASCII)
Raises:
TypeError, ValueError
"""
if not isinstance(mode, str):
raise TypeError('The {0} should be a string. Given: {1!r}'.format("mode", mode))
... | [
"def",
"_checkMode",
"(",
"mode",
")",
":",
"if",
"not",
"isinstance",
"(",
"mode",
",",
"str",
")",
":",
"raise",
"TypeError",
"(",
"'The {0} should be a string. Given: {1!r}'",
".",
"format",
"(",
"\"mode\"",
",",
"mode",
")",
")",
"if",
"mode",
"not",
"... | Check that the Modbus mode is valie.
Args:
mode (string): The Modbus mode (MODE_RTU or MODE_ASCII)
Raises:
TypeError, ValueError | [
"Check",
"that",
"the",
"Modbus",
"mode",
"is",
"valie",
"."
] | e99f4d74c83258c6039073082955ac9bed3f2155 | https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/minimalmodbus.py#L2019-L2034 |
5,948 | pyhys/minimalmodbus | minimalmodbus.py | _checkFunctioncode | def _checkFunctioncode(functioncode, listOfAllowedValues=[]):
"""Check that the given functioncode is in the listOfAllowedValues.
Also verifies that 1 <= function code <= 127.
Args:
* functioncode (int): The function code
* listOfAllowedValues (list of int): Allowed values. Use *None* to b... | python | def _checkFunctioncode(functioncode, listOfAllowedValues=[]):
"""Check that the given functioncode is in the listOfAllowedValues.
Also verifies that 1 <= function code <= 127.
Args:
* functioncode (int): The function code
* listOfAllowedValues (list of int): Allowed values. Use *None* to b... | [
"def",
"_checkFunctioncode",
"(",
"functioncode",
",",
"listOfAllowedValues",
"=",
"[",
"]",
")",
":",
"FUNCTIONCODE_MIN",
"=",
"1",
"FUNCTIONCODE_MAX",
"=",
"127",
"_checkInt",
"(",
"functioncode",
",",
"FUNCTIONCODE_MIN",
",",
"FUNCTIONCODE_MAX",
",",
"description... | Check that the given functioncode is in the listOfAllowedValues.
Also verifies that 1 <= function code <= 127.
Args:
* functioncode (int): The function code
* listOfAllowedValues (list of int): Allowed values. Use *None* to bypass this part of the checking.
Raises:
TypeError, Valu... | [
"Check",
"that",
"the",
"given",
"functioncode",
"is",
"in",
"the",
"listOfAllowedValues",
"."
] | e99f4d74c83258c6039073082955ac9bed3f2155 | https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/minimalmodbus.py#L2037-L2065 |
5,949 | pyhys/minimalmodbus | minimalmodbus.py | _checkResponseByteCount | def _checkResponseByteCount(payload):
"""Check that the number of bytes as given in the response is correct.
The first byte in the payload indicates the length of the payload (first byte not counted).
Args:
payload (string): The payload
Raises:
TypeError, ValueError
"""
POSIT... | python | def _checkResponseByteCount(payload):
"""Check that the number of bytes as given in the response is correct.
The first byte in the payload indicates the length of the payload (first byte not counted).
Args:
payload (string): The payload
Raises:
TypeError, ValueError
"""
POSIT... | [
"def",
"_checkResponseByteCount",
"(",
"payload",
")",
":",
"POSITION_FOR_GIVEN_NUMBER",
"=",
"0",
"NUMBER_OF_BYTES_TO_SKIP",
"=",
"1",
"_checkString",
"(",
"payload",
",",
"minlength",
"=",
"1",
",",
"description",
"=",
"'payload'",
")",
"givenNumberOfDatabytes",
"... | Check that the number of bytes as given in the response is correct.
The first byte in the payload indicates the length of the payload (first byte not counted).
Args:
payload (string): The payload
Raises:
TypeError, ValueError | [
"Check",
"that",
"the",
"number",
"of",
"bytes",
"as",
"given",
"in",
"the",
"response",
"is",
"correct",
"."
] | e99f4d74c83258c6039073082955ac9bed3f2155 | https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/minimalmodbus.py#L2100-L2124 |
5,950 | pyhys/minimalmodbus | minimalmodbus.py | _checkResponseRegisterAddress | def _checkResponseRegisterAddress(payload, registeraddress):
"""Check that the start adress as given in the response is correct.
The first two bytes in the payload holds the address value.
Args:
* payload (string): The payload
* registeraddress (int): The register address (use decimal numb... | python | def _checkResponseRegisterAddress(payload, registeraddress):
"""Check that the start adress as given in the response is correct.
The first two bytes in the payload holds the address value.
Args:
* payload (string): The payload
* registeraddress (int): The register address (use decimal numb... | [
"def",
"_checkResponseRegisterAddress",
"(",
"payload",
",",
"registeraddress",
")",
":",
"_checkString",
"(",
"payload",
",",
"minlength",
"=",
"2",
",",
"description",
"=",
"'payload'",
")",
"_checkRegisteraddress",
"(",
"registeraddress",
")",
"BYTERANGE_FOR_STARTA... | Check that the start adress as given in the response is correct.
The first two bytes in the payload holds the address value.
Args:
* payload (string): The payload
* registeraddress (int): The register address (use decimal numbers, not hex).
Raises:
TypeError, ValueError | [
"Check",
"that",
"the",
"start",
"adress",
"as",
"given",
"in",
"the",
"response",
"is",
"correct",
"."
] | e99f4d74c83258c6039073082955ac9bed3f2155 | https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/minimalmodbus.py#L2127-L2150 |
5,951 | pyhys/minimalmodbus | minimalmodbus.py | _checkResponseNumberOfRegisters | def _checkResponseNumberOfRegisters(payload, numberOfRegisters):
"""Check that the number of written registers as given in the response is correct.
The bytes 2 and 3 (zero based counting) in the payload holds the value.
Args:
* payload (string): The payload
* numberOfRegisters (int): Numbe... | python | def _checkResponseNumberOfRegisters(payload, numberOfRegisters):
"""Check that the number of written registers as given in the response is correct.
The bytes 2 and 3 (zero based counting) in the payload holds the value.
Args:
* payload (string): The payload
* numberOfRegisters (int): Numbe... | [
"def",
"_checkResponseNumberOfRegisters",
"(",
"payload",
",",
"numberOfRegisters",
")",
":",
"_checkString",
"(",
"payload",
",",
"minlength",
"=",
"4",
",",
"description",
"=",
"'payload'",
")",
"_checkInt",
"(",
"numberOfRegisters",
",",
"minvalue",
"=",
"1",
... | Check that the number of written registers as given in the response is correct.
The bytes 2 and 3 (zero based counting) in the payload holds the value.
Args:
* payload (string): The payload
* numberOfRegisters (int): Number of registers that have been written
Raises:
TypeError, Va... | [
"Check",
"that",
"the",
"number",
"of",
"written",
"registers",
"as",
"given",
"in",
"the",
"response",
"is",
"correct",
"."
] | e99f4d74c83258c6039073082955ac9bed3f2155 | https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/minimalmodbus.py#L2153-L2176 |
5,952 | pyhys/minimalmodbus | minimalmodbus.py | _checkResponseWriteData | def _checkResponseWriteData(payload, writedata):
"""Check that the write data as given in the response is correct.
The bytes 2 and 3 (zero based counting) in the payload holds the write data.
Args:
* payload (string): The payload
* writedata (string): The data to write, length should be 2 ... | python | def _checkResponseWriteData(payload, writedata):
"""Check that the write data as given in the response is correct.
The bytes 2 and 3 (zero based counting) in the payload holds the write data.
Args:
* payload (string): The payload
* writedata (string): The data to write, length should be 2 ... | [
"def",
"_checkResponseWriteData",
"(",
"payload",
",",
"writedata",
")",
":",
"_checkString",
"(",
"payload",
",",
"minlength",
"=",
"4",
",",
"description",
"=",
"'payload'",
")",
"_checkString",
"(",
"writedata",
",",
"minlength",
"=",
"2",
",",
"maxlength",... | Check that the write data as given in the response is correct.
The bytes 2 and 3 (zero based counting) in the payload holds the write data.
Args:
* payload (string): The payload
* writedata (string): The data to write, length should be 2 bytes.
Raises:
TypeError, ValueError | [
"Check",
"that",
"the",
"write",
"data",
"as",
"given",
"in",
"the",
"response",
"is",
"correct",
"."
] | e99f4d74c83258c6039073082955ac9bed3f2155 | https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/minimalmodbus.py#L2179-L2201 |
5,953 | pyhys/minimalmodbus | minimalmodbus.py | _checkString | def _checkString(inputstring, description, minlength=0, maxlength=None):
"""Check that the given string is valid.
Args:
* inputstring (string): The string to be checked
* description (string): Used in error messages for the checked inputstring
* minlength (int): Minimum length of the st... | python | def _checkString(inputstring, description, minlength=0, maxlength=None):
"""Check that the given string is valid.
Args:
* inputstring (string): The string to be checked
* description (string): Used in error messages for the checked inputstring
* minlength (int): Minimum length of the st... | [
"def",
"_checkString",
"(",
"inputstring",
",",
"description",
",",
"minlength",
"=",
"0",
",",
"maxlength",
"=",
"None",
")",
":",
"# Type checking",
"if",
"not",
"isinstance",
"(",
"description",
",",
"str",
")",
":",
"raise",
"TypeError",
"(",
"'The descr... | Check that the given string is valid.
Args:
* inputstring (string): The string to be checked
* description (string): Used in error messages for the checked inputstring
* minlength (int): Minimum length of the string
* maxlength (int or None): Maximum length of the string
Raises... | [
"Check",
"that",
"the",
"given",
"string",
"is",
"valid",
"."
] | e99f4d74c83258c6039073082955ac9bed3f2155 | https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/minimalmodbus.py#L2204-L2246 |
5,954 | pyhys/minimalmodbus | minimalmodbus.py | _checkInt | def _checkInt(inputvalue, minvalue=None, maxvalue=None, description='inputvalue'):
"""Check that the given integer is valid.
Args:
* inputvalue (int or long): The integer to be checked
* minvalue (int or long, or None): Minimum value of the integer
* maxvalue (int or long, or None): Max... | python | def _checkInt(inputvalue, minvalue=None, maxvalue=None, description='inputvalue'):
"""Check that the given integer is valid.
Args:
* inputvalue (int or long): The integer to be checked
* minvalue (int or long, or None): Minimum value of the integer
* maxvalue (int or long, or None): Max... | [
"def",
"_checkInt",
"(",
"inputvalue",
",",
"minvalue",
"=",
"None",
",",
"maxvalue",
"=",
"None",
",",
"description",
"=",
"'inputvalue'",
")",
":",
"if",
"not",
"isinstance",
"(",
"description",
",",
"str",
")",
":",
"raise",
"TypeError",
"(",
"'The desc... | Check that the given integer is valid.
Args:
* inputvalue (int or long): The integer to be checked
* minvalue (int or long, or None): Minimum value of the integer
* maxvalue (int or long, or None): Maximum value of the integer
* description (string): Used in error messages for the c... | [
"Check",
"that",
"the",
"given",
"integer",
"is",
"valid",
"."
] | e99f4d74c83258c6039073082955ac9bed3f2155 | https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/minimalmodbus.py#L2249-L2276 |
5,955 | pyhys/minimalmodbus | minimalmodbus.py | _checkNumerical | def _checkNumerical(inputvalue, minvalue=None, maxvalue=None, description='inputvalue'):
"""Check that the given numerical value is valid.
Args:
* inputvalue (numerical): The value to be checked.
* minvalue (numerical): Minimum value Use None to skip this part of the test.
* maxvalue (... | python | def _checkNumerical(inputvalue, minvalue=None, maxvalue=None, description='inputvalue'):
"""Check that the given numerical value is valid.
Args:
* inputvalue (numerical): The value to be checked.
* minvalue (numerical): Minimum value Use None to skip this part of the test.
* maxvalue (... | [
"def",
"_checkNumerical",
"(",
"inputvalue",
",",
"minvalue",
"=",
"None",
",",
"maxvalue",
"=",
"None",
",",
"description",
"=",
"'inputvalue'",
")",
":",
"# Type checking",
"if",
"not",
"isinstance",
"(",
"description",
",",
"str",
")",
":",
"raise",
"Type... | Check that the given numerical value is valid.
Args:
* inputvalue (numerical): The value to be checked.
* minvalue (numerical): Minimum value Use None to skip this part of the test.
* maxvalue (numerical): Maximum value. Use None to skip this part of the test.
* description (string... | [
"Check",
"that",
"the",
"given",
"numerical",
"value",
"is",
"valid",
"."
] | e99f4d74c83258c6039073082955ac9bed3f2155 | https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/minimalmodbus.py#L2279-L2322 |
5,956 | pyhys/minimalmodbus | minimalmodbus.py | _checkBool | def _checkBool(inputvalue, description='inputvalue'):
"""Check that the given inputvalue is a boolean.
Args:
* inputvalue (boolean): The value to be checked.
* description (string): Used in error messages for the checked inputvalue.
Raises:
TypeError, ValueError
"""
_check... | python | def _checkBool(inputvalue, description='inputvalue'):
"""Check that the given inputvalue is a boolean.
Args:
* inputvalue (boolean): The value to be checked.
* description (string): Used in error messages for the checked inputvalue.
Raises:
TypeError, ValueError
"""
_check... | [
"def",
"_checkBool",
"(",
"inputvalue",
",",
"description",
"=",
"'inputvalue'",
")",
":",
"_checkString",
"(",
"description",
",",
"minlength",
"=",
"1",
",",
"description",
"=",
"'description string'",
")",
"if",
"not",
"isinstance",
"(",
"inputvalue",
",",
... | Check that the given inputvalue is a boolean.
Args:
* inputvalue (boolean): The value to be checked.
* description (string): Used in error messages for the checked inputvalue.
Raises:
TypeError, ValueError | [
"Check",
"that",
"the",
"given",
"inputvalue",
"is",
"a",
"boolean",
"."
] | e99f4d74c83258c6039073082955ac9bed3f2155 | https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/minimalmodbus.py#L2325-L2338 |
5,957 | pyhys/minimalmodbus | minimalmodbus.py | _getDiagnosticString | def _getDiagnosticString():
"""Generate a diagnostic string, showing the module version, the platform, current directory etc.
Returns:
A descriptive string.
"""
text = '\n## Diagnostic output from minimalmodbus ## \n\n'
text += 'Minimalmodbus version: ' + __version__ + '\n'
text += 'Mi... | python | def _getDiagnosticString():
"""Generate a diagnostic string, showing the module version, the platform, current directory etc.
Returns:
A descriptive string.
"""
text = '\n## Diagnostic output from minimalmodbus ## \n\n'
text += 'Minimalmodbus version: ' + __version__ + '\n'
text += 'Mi... | [
"def",
"_getDiagnosticString",
"(",
")",
":",
"text",
"=",
"'\\n## Diagnostic output from minimalmodbus ## \\n\\n'",
"text",
"+=",
"'Minimalmodbus version: '",
"+",
"__version__",
"+",
"'\\n'",
"text",
"+=",
"'Minimalmodbus status: '",
"+",
"__status__",
"+",
"'\\n'",
"te... | Generate a diagnostic string, showing the module version, the platform, current directory etc.
Returns:
A descriptive string. | [
"Generate",
"a",
"diagnostic",
"string",
"showing",
"the",
"module",
"version",
"the",
"platform",
"current",
"directory",
"etc",
"."
] | e99f4d74c83258c6039073082955ac9bed3f2155 | https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/minimalmodbus.py#L2513-L2550 |
5,958 | pyhys/minimalmodbus | minimalmodbus.py | Instrument.read_bit | def read_bit(self, registeraddress, functioncode=2):
"""Read one bit from the slave.
Args:
* registeraddress (int): The slave register address (use decimal numbers, not hex).
* functioncode (int): Modbus function code. Can be 1 or 2.
Returns:
The bit value 0... | python | def read_bit(self, registeraddress, functioncode=2):
"""Read one bit from the slave.
Args:
* registeraddress (int): The slave register address (use decimal numbers, not hex).
* functioncode (int): Modbus function code. Can be 1 or 2.
Returns:
The bit value 0... | [
"def",
"read_bit",
"(",
"self",
",",
"registeraddress",
",",
"functioncode",
"=",
"2",
")",
":",
"_checkFunctioncode",
"(",
"functioncode",
",",
"[",
"1",
",",
"2",
"]",
")",
"return",
"self",
".",
"_genericCommand",
"(",
"functioncode",
",",
"registeraddres... | Read one bit from the slave.
Args:
* registeraddress (int): The slave register address (use decimal numbers, not hex).
* functioncode (int): Modbus function code. Can be 1 or 2.
Returns:
The bit value 0 or 1 (int).
Raises:
ValueError, TypeError,... | [
"Read",
"one",
"bit",
"from",
"the",
"slave",
"."
] | e99f4d74c83258c6039073082955ac9bed3f2155 | https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/minimalmodbus.py#L178-L193 |
5,959 | pyhys/minimalmodbus | minimalmodbus.py | Instrument.write_bit | def write_bit(self, registeraddress, value, functioncode=5):
"""Write one bit to the slave.
Args:
* registeraddress (int): The slave register address (use decimal numbers, not hex).
* value (int): 0 or 1
* functioncode (int): Modbus function code. Can be 5 or 15.
... | python | def write_bit(self, registeraddress, value, functioncode=5):
"""Write one bit to the slave.
Args:
* registeraddress (int): The slave register address (use decimal numbers, not hex).
* value (int): 0 or 1
* functioncode (int): Modbus function code. Can be 5 or 15.
... | [
"def",
"write_bit",
"(",
"self",
",",
"registeraddress",
",",
"value",
",",
"functioncode",
"=",
"5",
")",
":",
"_checkFunctioncode",
"(",
"functioncode",
",",
"[",
"5",
",",
"15",
"]",
")",
"_checkInt",
"(",
"value",
",",
"minvalue",
"=",
"0",
",",
"m... | Write one bit to the slave.
Args:
* registeraddress (int): The slave register address (use decimal numbers, not hex).
* value (int): 0 or 1
* functioncode (int): Modbus function code. Can be 5 or 15.
Returns:
None
Raises:
ValueError,... | [
"Write",
"one",
"bit",
"to",
"the",
"slave",
"."
] | e99f4d74c83258c6039073082955ac9bed3f2155 | https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/minimalmodbus.py#L196-L213 |
5,960 | pyhys/minimalmodbus | minimalmodbus.py | Instrument.read_register | def read_register(self, registeraddress, numberOfDecimals=0, functioncode=3, signed=False):
"""Read an integer from one 16-bit register in the slave, possibly scaling it.
The slave register can hold integer values in the range 0 to 65535 ("Unsigned INT16").
Args:
* registeraddress ... | python | def read_register(self, registeraddress, numberOfDecimals=0, functioncode=3, signed=False):
"""Read an integer from one 16-bit register in the slave, possibly scaling it.
The slave register can hold integer values in the range 0 to 65535 ("Unsigned INT16").
Args:
* registeraddress ... | [
"def",
"read_register",
"(",
"self",
",",
"registeraddress",
",",
"numberOfDecimals",
"=",
"0",
",",
"functioncode",
"=",
"3",
",",
"signed",
"=",
"False",
")",
":",
"_checkFunctioncode",
"(",
"functioncode",
",",
"[",
"3",
",",
"4",
"]",
")",
"_checkInt",... | Read an integer from one 16-bit register in the slave, possibly scaling it.
The slave register can hold integer values in the range 0 to 65535 ("Unsigned INT16").
Args:
* registeraddress (int): The slave register address (use decimal numbers, not hex).
* numberOfDecimals (int):... | [
"Read",
"an",
"integer",
"from",
"one",
"16",
"-",
"bit",
"register",
"in",
"the",
"slave",
"possibly",
"scaling",
"it",
"."
] | e99f4d74c83258c6039073082955ac9bed3f2155 | https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/minimalmodbus.py#L216-L258 |
5,961 | pyhys/minimalmodbus | minimalmodbus.py | Instrument.write_register | def write_register(self, registeraddress, value, numberOfDecimals=0, functioncode=16, signed=False):
"""Write an integer to one 16-bit register in the slave, possibly scaling it.
The slave register can hold integer values in the range 0 to 65535 ("Unsigned INT16").
Args:
* register... | python | def write_register(self, registeraddress, value, numberOfDecimals=0, functioncode=16, signed=False):
"""Write an integer to one 16-bit register in the slave, possibly scaling it.
The slave register can hold integer values in the range 0 to 65535 ("Unsigned INT16").
Args:
* register... | [
"def",
"write_register",
"(",
"self",
",",
"registeraddress",
",",
"value",
",",
"numberOfDecimals",
"=",
"0",
",",
"functioncode",
"=",
"16",
",",
"signed",
"=",
"False",
")",
":",
"_checkFunctioncode",
"(",
"functioncode",
",",
"[",
"6",
",",
"16",
"]",
... | Write an integer to one 16-bit register in the slave, possibly scaling it.
The slave register can hold integer values in the range 0 to 65535 ("Unsigned INT16").
Args:
* registeraddress (int): The slave register address (use decimal numbers, not hex).
* value (int or float): T... | [
"Write",
"an",
"integer",
"to",
"one",
"16",
"-",
"bit",
"register",
"in",
"the",
"slave",
"possibly",
"scaling",
"it",
"."
] | e99f4d74c83258c6039073082955ac9bed3f2155 | https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/minimalmodbus.py#L261-L296 |
5,962 | pyhys/minimalmodbus | minimalmodbus.py | Instrument.read_float | def read_float(self, registeraddress, functioncode=3, numberOfRegisters=2):
"""Read a floating point number from the slave.
Floats are stored in two or more consecutive 16-bit registers in the slave. The
encoding is according to the standard IEEE 754.
There are differences in the byte ... | python | def read_float(self, registeraddress, functioncode=3, numberOfRegisters=2):
"""Read a floating point number from the slave.
Floats are stored in two or more consecutive 16-bit registers in the slave. The
encoding is according to the standard IEEE 754.
There are differences in the byte ... | [
"def",
"read_float",
"(",
"self",
",",
"registeraddress",
",",
"functioncode",
"=",
"3",
",",
"numberOfRegisters",
"=",
"2",
")",
":",
"_checkFunctioncode",
"(",
"functioncode",
",",
"[",
"3",
",",
"4",
"]",
")",
"_checkInt",
"(",
"numberOfRegisters",
",",
... | Read a floating point number from the slave.
Floats are stored in two or more consecutive 16-bit registers in the slave. The
encoding is according to the standard IEEE 754.
There are differences in the byte order used by different manufacturers. A floating
point value of 1.0 is encoded... | [
"Read",
"a",
"floating",
"point",
"number",
"from",
"the",
"slave",
"."
] | e99f4d74c83258c6039073082955ac9bed3f2155 | https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/minimalmodbus.py#L358-L392 |
5,963 | pyhys/minimalmodbus | minimalmodbus.py | Instrument.write_float | def write_float(self, registeraddress, value, numberOfRegisters=2):
"""Write a floating point number to the slave.
Floats are stored in two or more consecutive 16-bit registers in the slave.
Uses Modbus function code 16.
For discussion on precision, number of registers and on byte ord... | python | def write_float(self, registeraddress, value, numberOfRegisters=2):
"""Write a floating point number to the slave.
Floats are stored in two or more consecutive 16-bit registers in the slave.
Uses Modbus function code 16.
For discussion on precision, number of registers and on byte ord... | [
"def",
"write_float",
"(",
"self",
",",
"registeraddress",
",",
"value",
",",
"numberOfRegisters",
"=",
"2",
")",
":",
"_checkNumerical",
"(",
"value",
",",
"description",
"=",
"'input value'",
")",
"_checkInt",
"(",
"numberOfRegisters",
",",
"minvalue",
"=",
... | Write a floating point number to the slave.
Floats are stored in two or more consecutive 16-bit registers in the slave.
Uses Modbus function code 16.
For discussion on precision, number of registers and on byte order, see :meth:`.read_float`.
Args:
* registeraddress (int)... | [
"Write",
"a",
"floating",
"point",
"number",
"to",
"the",
"slave",
"."
] | e99f4d74c83258c6039073082955ac9bed3f2155 | https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/minimalmodbus.py#L395-L419 |
5,964 | pyhys/minimalmodbus | minimalmodbus.py | Instrument.read_string | def read_string(self, registeraddress, numberOfRegisters=16, functioncode=3):
"""Read a string from the slave.
Each 16-bit register in the slave are interpreted as two characters (1 byte = 8 bits).
For example 16 consecutive registers can hold 32 characters (32 bytes).
Args:
... | python | def read_string(self, registeraddress, numberOfRegisters=16, functioncode=3):
"""Read a string from the slave.
Each 16-bit register in the slave are interpreted as two characters (1 byte = 8 bits).
For example 16 consecutive registers can hold 32 characters (32 bytes).
Args:
... | [
"def",
"read_string",
"(",
"self",
",",
"registeraddress",
",",
"numberOfRegisters",
"=",
"16",
",",
"functioncode",
"=",
"3",
")",
":",
"_checkFunctioncode",
"(",
"functioncode",
",",
"[",
"3",
",",
"4",
"]",
")",
"_checkInt",
"(",
"numberOfRegisters",
",",... | Read a string from the slave.
Each 16-bit register in the slave are interpreted as two characters (1 byte = 8 bits).
For example 16 consecutive registers can hold 32 characters (32 bytes).
Args:
* registeraddress (int): The slave register start address (use decimal numbers, not hex... | [
"Read",
"a",
"string",
"from",
"the",
"slave",
"."
] | e99f4d74c83258c6039073082955ac9bed3f2155 | https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/minimalmodbus.py#L422-L443 |
5,965 | pyhys/minimalmodbus | minimalmodbus.py | Instrument.write_string | def write_string(self, registeraddress, textstring, numberOfRegisters=16):
"""Write a string to the slave.
Each 16-bit register in the slave are interpreted as two characters (1 byte = 8 bits).
For example 16 consecutive registers can hold 32 characters (32 bytes).
Uses Modbus function... | python | def write_string(self, registeraddress, textstring, numberOfRegisters=16):
"""Write a string to the slave.
Each 16-bit register in the slave are interpreted as two characters (1 byte = 8 bits).
For example 16 consecutive registers can hold 32 characters (32 bytes).
Uses Modbus function... | [
"def",
"write_string",
"(",
"self",
",",
"registeraddress",
",",
"textstring",
",",
"numberOfRegisters",
"=",
"16",
")",
":",
"_checkInt",
"(",
"numberOfRegisters",
",",
"minvalue",
"=",
"1",
",",
"description",
"=",
"'number of registers for write string'",
")",
... | Write a string to the slave.
Each 16-bit register in the slave are interpreted as two characters (1 byte = 8 bits).
For example 16 consecutive registers can hold 32 characters (32 bytes).
Uses Modbus function code 16.
Args:
* registeraddress (int): The slave register start... | [
"Write",
"a",
"string",
"to",
"the",
"slave",
"."
] | e99f4d74c83258c6039073082955ac9bed3f2155 | https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/minimalmodbus.py#L446-L472 |
5,966 | pyhys/minimalmodbus | minimalmodbus.py | Instrument.write_registers | def write_registers(self, registeraddress, values):
"""Write integers to 16-bit registers in the slave.
The slave register can hold integer values in the range 0 to 65535 ("Unsigned INT16").
Uses Modbus function code 16.
The number of registers that will be written is defined by the l... | python | def write_registers(self, registeraddress, values):
"""Write integers to 16-bit registers in the slave.
The slave register can hold integer values in the range 0 to 65535 ("Unsigned INT16").
Uses Modbus function code 16.
The number of registers that will be written is defined by the l... | [
"def",
"write_registers",
"(",
"self",
",",
"registeraddress",
",",
"values",
")",
":",
"if",
"not",
"isinstance",
"(",
"values",
",",
"list",
")",
":",
"raise",
"TypeError",
"(",
"'The \"values parameter\" must be a list. Given: {0!r}'",
".",
"format",
"(",
"valu... | Write integers to 16-bit registers in the slave.
The slave register can hold integer values in the range 0 to 65535 ("Unsigned INT16").
Uses Modbus function code 16.
The number of registers that will be written is defined by the length of the ``values`` list.
Args:
* regi... | [
"Write",
"integers",
"to",
"16",
"-",
"bit",
"registers",
"in",
"the",
"slave",
"."
] | e99f4d74c83258c6039073082955ac9bed3f2155 | https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/minimalmodbus.py#L501-L529 |
5,967 | pyhys/minimalmodbus | minimalmodbus.py | Instrument._communicate | def _communicate(self, request, number_of_bytes_to_read):
"""Talk to the slave via a serial port.
Args:
request (str): The raw request that is to be sent to the slave.
number_of_bytes_to_read (int): number of bytes to read
Returns:
The raw data (string) retu... | python | def _communicate(self, request, number_of_bytes_to_read):
"""Talk to the slave via a serial port.
Args:
request (str): The raw request that is to be sent to the slave.
number_of_bytes_to_read (int): number of bytes to read
Returns:
The raw data (string) retu... | [
"def",
"_communicate",
"(",
"self",
",",
"request",
",",
"number_of_bytes_to_read",
")",
":",
"_checkString",
"(",
"request",
",",
"minlength",
"=",
"1",
",",
"description",
"=",
"'request'",
")",
"_checkInt",
"(",
"number_of_bytes_to_read",
")",
"if",
"self",
... | Talk to the slave via a serial port.
Args:
request (str): The raw request that is to be sent to the slave.
number_of_bytes_to_read (int): number of bytes to read
Returns:
The raw data (string) returned from the slave.
Raises:
TypeError, ValueErr... | [
"Talk",
"to",
"the",
"slave",
"via",
"a",
"serial",
"port",
"."
] | e99f4d74c83258c6039073082955ac9bed3f2155 | https://github.com/pyhys/minimalmodbus/blob/e99f4d74c83258c6039073082955ac9bed3f2155/minimalmodbus.py#L802-L932 |
5,968 | TaylorSMarks/playsound | playsound.py | _playsoundWin | def _playsoundWin(sound, block = True):
'''
Utilizes windll.winmm. Tested and known to work with MP3 and WAVE on
Windows 7 with Python 2.7. Probably works with more file formats.
Probably works on Windows XP thru Windows 10. Probably works with all
versions of Python.
Inspired by (but not copie... | python | def _playsoundWin(sound, block = True):
'''
Utilizes windll.winmm. Tested and known to work with MP3 and WAVE on
Windows 7 with Python 2.7. Probably works with more file formats.
Probably works on Windows XP thru Windows 10. Probably works with all
versions of Python.
Inspired by (but not copie... | [
"def",
"_playsoundWin",
"(",
"sound",
",",
"block",
"=",
"True",
")",
":",
"from",
"ctypes",
"import",
"c_buffer",
",",
"windll",
"from",
"random",
"import",
"random",
"from",
"time",
"import",
"sleep",
"from",
"sys",
"import",
"getfilesystemencoding",
"def",
... | Utilizes windll.winmm. Tested and known to work with MP3 and WAVE on
Windows 7 with Python 2.7. Probably works with more file formats.
Probably works on Windows XP thru Windows 10. Probably works with all
versions of Python.
Inspired by (but not copied from) Michael Gundlach <gundlach@gmail.com>'s mp3p... | [
"Utilizes",
"windll",
".",
"winmm",
".",
"Tested",
"and",
"known",
"to",
"work",
"with",
"MP3",
"and",
"WAVE",
"on",
"Windows",
"7",
"with",
"Python",
"2",
".",
"7",
".",
"Probably",
"works",
"with",
"more",
"file",
"formats",
".",
"Probably",
"works",
... | 907f1fe73375a2156f7e0900c4b42c0a60fa1d00 | https://github.com/TaylorSMarks/playsound/blob/907f1fe73375a2156f7e0900c4b42c0a60fa1d00/playsound.py#L4-L41 |
5,969 | TaylorSMarks/playsound | playsound.py | _playsoundOSX | def _playsoundOSX(sound, block = True):
'''
Utilizes AppKit.NSSound. Tested and known to work with MP3 and WAVE on
OS X 10.11 with Python 2.7. Probably works with anything QuickTime supports.
Probably works on OS X 10.5 and newer. Probably works with all versions of
Python.
Inspired by (but not... | python | def _playsoundOSX(sound, block = True):
'''
Utilizes AppKit.NSSound. Tested and known to work with MP3 and WAVE on
OS X 10.11 with Python 2.7. Probably works with anything QuickTime supports.
Probably works on OS X 10.5 and newer. Probably works with all versions of
Python.
Inspired by (but not... | [
"def",
"_playsoundOSX",
"(",
"sound",
",",
"block",
"=",
"True",
")",
":",
"from",
"AppKit",
"import",
"NSSound",
"from",
"Foundation",
"import",
"NSURL",
"from",
"time",
"import",
"sleep",
"if",
"'://'",
"not",
"in",
"sound",
":",
"if",
"not",
"sound",
... | Utilizes AppKit.NSSound. Tested and known to work with MP3 and WAVE on
OS X 10.11 with Python 2.7. Probably works with anything QuickTime supports.
Probably works on OS X 10.5 and newer. Probably works with all versions of
Python.
Inspired by (but not copied from) Aaron's Stack Overflow answer here:
... | [
"Utilizes",
"AppKit",
".",
"NSSound",
".",
"Tested",
"and",
"known",
"to",
"work",
"with",
"MP3",
"and",
"WAVE",
"on",
"OS",
"X",
"10",
".",
"11",
"with",
"Python",
"2",
".",
"7",
".",
"Probably",
"works",
"with",
"anything",
"QuickTime",
"supports",
"... | 907f1fe73375a2156f7e0900c4b42c0a60fa1d00 | https://github.com/TaylorSMarks/playsound/blob/907f1fe73375a2156f7e0900c4b42c0a60fa1d00/playsound.py#L43-L71 |
5,970 | TaylorSMarks/playsound | playsound.py | _playsoundNix | def _playsoundNix(sound, block=True):
"""Play a sound using GStreamer.
Inspired by this:
https://gstreamer.freedesktop.org/documentation/tutorials/playback/playbin-usage.html
"""
if not block:
raise NotImplementedError(
"block=False cannot be used on this platform yet")
# p... | python | def _playsoundNix(sound, block=True):
"""Play a sound using GStreamer.
Inspired by this:
https://gstreamer.freedesktop.org/documentation/tutorials/playback/playbin-usage.html
"""
if not block:
raise NotImplementedError(
"block=False cannot be used on this platform yet")
# p... | [
"def",
"_playsoundNix",
"(",
"sound",
",",
"block",
"=",
"True",
")",
":",
"if",
"not",
"block",
":",
"raise",
"NotImplementedError",
"(",
"\"block=False cannot be used on this platform yet\"",
")",
"# pathname2url escapes non-URL-safe characters",
"import",
"os",
"try",
... | Play a sound using GStreamer.
Inspired by this:
https://gstreamer.freedesktop.org/documentation/tutorials/playback/playbin-usage.html | [
"Play",
"a",
"sound",
"using",
"GStreamer",
"."
] | 907f1fe73375a2156f7e0900c4b42c0a60fa1d00 | https://github.com/TaylorSMarks/playsound/blob/907f1fe73375a2156f7e0900c4b42c0a60fa1d00/playsound.py#L73-L112 |
5,971 | mfitzp/padua | padua/filters.py | remove_rows_matching | def remove_rows_matching(df, column, match):
"""
Return a ``DataFrame`` with rows where `column` values match `match` are removed.
The selected `column` series of values from the supplied Pandas ``DataFrame`` is compared
to `match`, and those rows that match are removed from the DataFrame.
:param ... | python | def remove_rows_matching(df, column, match):
"""
Return a ``DataFrame`` with rows where `column` values match `match` are removed.
The selected `column` series of values from the supplied Pandas ``DataFrame`` is compared
to `match`, and those rows that match are removed from the DataFrame.
:param ... | [
"def",
"remove_rows_matching",
"(",
"df",
",",
"column",
",",
"match",
")",
":",
"df",
"=",
"df",
".",
"copy",
"(",
")",
"mask",
"=",
"df",
"[",
"column",
"]",
".",
"values",
"!=",
"match",
"return",
"df",
".",
"iloc",
"[",
"mask",
",",
":",
"]"
... | Return a ``DataFrame`` with rows where `column` values match `match` are removed.
The selected `column` series of values from the supplied Pandas ``DataFrame`` is compared
to `match`, and those rows that match are removed from the DataFrame.
:param df: Pandas ``DataFrame``
:param column: Column indexe... | [
"Return",
"a",
"DataFrame",
"with",
"rows",
"where",
"column",
"values",
"match",
"match",
"are",
"removed",
"."
] | 8b14bf4d2f895da6aea5d7885d409315bd303ec6 | https://github.com/mfitzp/padua/blob/8b14bf4d2f895da6aea5d7885d409315bd303ec6/padua/filters.py#L4-L18 |
5,972 | mfitzp/padua | padua/filters.py | remove_rows_containing | def remove_rows_containing(df, column, match):
"""
Return a ``DataFrame`` with rows where `column` values containing `match` are removed.
The selected `column` series of values from the supplied Pandas ``DataFrame`` is compared
to `match`, and those rows that contain it are removed from the DataFrame.
... | python | def remove_rows_containing(df, column, match):
"""
Return a ``DataFrame`` with rows where `column` values containing `match` are removed.
The selected `column` series of values from the supplied Pandas ``DataFrame`` is compared
to `match`, and those rows that contain it are removed from the DataFrame.
... | [
"def",
"remove_rows_containing",
"(",
"df",
",",
"column",
",",
"match",
")",
":",
"df",
"=",
"df",
".",
"copy",
"(",
")",
"mask",
"=",
"[",
"match",
"not",
"in",
"str",
"(",
"v",
")",
"for",
"v",
"in",
"df",
"[",
"column",
"]",
".",
"values",
... | Return a ``DataFrame`` with rows where `column` values containing `match` are removed.
The selected `column` series of values from the supplied Pandas ``DataFrame`` is compared
to `match`, and those rows that contain it are removed from the DataFrame.
:param df: Pandas ``DataFrame``
:param column: Col... | [
"Return",
"a",
"DataFrame",
"with",
"rows",
"where",
"column",
"values",
"containing",
"match",
"are",
"removed",
"."
] | 8b14bf4d2f895da6aea5d7885d409315bd303ec6 | https://github.com/mfitzp/padua/blob/8b14bf4d2f895da6aea5d7885d409315bd303ec6/padua/filters.py#L21-L35 |
5,973 | mfitzp/padua | padua/filters.py | filter_localization_probability | def filter_localization_probability(df, threshold=0.75):
"""
Remove rows with a localization probability below 0.75
Return a ``DataFrame`` where the rows with a value < `threshold` (default 0.75) in column 'Localization prob' are removed.
Filters data to remove poorly localized peptides (non Class-I by... | python | def filter_localization_probability(df, threshold=0.75):
"""
Remove rows with a localization probability below 0.75
Return a ``DataFrame`` where the rows with a value < `threshold` (default 0.75) in column 'Localization prob' are removed.
Filters data to remove poorly localized peptides (non Class-I by... | [
"def",
"filter_localization_probability",
"(",
"df",
",",
"threshold",
"=",
"0.75",
")",
":",
"df",
"=",
"df",
".",
"copy",
"(",
")",
"localization_probability_mask",
"=",
"df",
"[",
"'Localization prob'",
"]",
".",
"values",
">=",
"threshold",
"return",
"df",... | Remove rows with a localization probability below 0.75
Return a ``DataFrame`` where the rows with a value < `threshold` (default 0.75) in column 'Localization prob' are removed.
Filters data to remove poorly localized peptides (non Class-I by default).
:param df: Pandas ``DataFrame``
:param threshold:... | [
"Remove",
"rows",
"with",
"a",
"localization",
"probability",
"below",
"0",
".",
"75"
] | 8b14bf4d2f895da6aea5d7885d409315bd303ec6 | https://github.com/mfitzp/padua/blob/8b14bf4d2f895da6aea5d7885d409315bd303ec6/padua/filters.py#L77-L90 |
5,974 | mfitzp/padua | padua/filters.py | minimum_valid_values_in_any_group | def minimum_valid_values_in_any_group(df, levels=None, n=1, invalid=np.nan):
"""
Filter ``DataFrame`` by at least n valid values in at least one group.
Taking a Pandas ``DataFrame`` with a ``MultiIndex`` column index, filters rows to remove
rows where there are less than `n` valid values per group. Gro... | python | def minimum_valid_values_in_any_group(df, levels=None, n=1, invalid=np.nan):
"""
Filter ``DataFrame`` by at least n valid values in at least one group.
Taking a Pandas ``DataFrame`` with a ``MultiIndex`` column index, filters rows to remove
rows where there are less than `n` valid values per group. Gro... | [
"def",
"minimum_valid_values_in_any_group",
"(",
"df",
",",
"levels",
"=",
"None",
",",
"n",
"=",
"1",
",",
"invalid",
"=",
"np",
".",
"nan",
")",
":",
"df",
"=",
"df",
".",
"copy",
"(",
")",
"if",
"levels",
"is",
"None",
":",
"if",
"'Group'",
"in"... | Filter ``DataFrame`` by at least n valid values in at least one group.
Taking a Pandas ``DataFrame`` with a ``MultiIndex`` column index, filters rows to remove
rows where there are less than `n` valid values per group. Groups are defined by the `levels` parameter indexing
into the column index. For example... | [
"Filter",
"DataFrame",
"by",
"at",
"least",
"n",
"valid",
"values",
"in",
"at",
"least",
"one",
"group",
"."
] | 8b14bf4d2f895da6aea5d7885d409315bd303ec6 | https://github.com/mfitzp/padua/blob/8b14bf4d2f895da6aea5d7885d409315bd303ec6/padua/filters.py#L93-L129 |
5,975 | mfitzp/padua | padua/filters.py | search | def search(df, match, columns=['Proteins','Protein names','Gene names']):
"""
Search for a given string in a set of columns in a processed ``DataFrame``.
Returns a filtered ``DataFrame`` where `match` is contained in one of the `columns`.
:param df: Pandas ``DataFrame``
:param match: ``str`` to se... | python | def search(df, match, columns=['Proteins','Protein names','Gene names']):
"""
Search for a given string in a set of columns in a processed ``DataFrame``.
Returns a filtered ``DataFrame`` where `match` is contained in one of the `columns`.
:param df: Pandas ``DataFrame``
:param match: ``str`` to se... | [
"def",
"search",
"(",
"df",
",",
"match",
",",
"columns",
"=",
"[",
"'Proteins'",
",",
"'Protein names'",
",",
"'Gene names'",
"]",
")",
":",
"df",
"=",
"df",
".",
"copy",
"(",
")",
"dft",
"=",
"df",
".",
"reset_index",
"(",
")",
"mask",
"=",
"np",... | Search for a given string in a set of columns in a processed ``DataFrame``.
Returns a filtered ``DataFrame`` where `match` is contained in one of the `columns`.
:param df: Pandas ``DataFrame``
:param match: ``str`` to search for in columns
:param columns: ``list`` of ``str`` to search for match
:r... | [
"Search",
"for",
"a",
"given",
"string",
"in",
"a",
"set",
"of",
"columns",
"in",
"a",
"processed",
"DataFrame",
"."
] | 8b14bf4d2f895da6aea5d7885d409315bd303ec6 | https://github.com/mfitzp/padua/blob/8b14bf4d2f895da6aea5d7885d409315bd303ec6/padua/filters.py#L132-L152 |
5,976 | mfitzp/padua | padua/filters.py | filter_select_columns_intensity | def filter_select_columns_intensity(df, prefix, columns):
"""
Filter dataframe to include specified columns, retaining any Intensity columns.
"""
# Note: I use %s.+ (not %s.*) so it forces a match with the prefix string, ONLY if it is followed by something.
return df.filter(regex='^(%s.+|%s)$' % (pr... | python | def filter_select_columns_intensity(df, prefix, columns):
"""
Filter dataframe to include specified columns, retaining any Intensity columns.
"""
# Note: I use %s.+ (not %s.*) so it forces a match with the prefix string, ONLY if it is followed by something.
return df.filter(regex='^(%s.+|%s)$' % (pr... | [
"def",
"filter_select_columns_intensity",
"(",
"df",
",",
"prefix",
",",
"columns",
")",
":",
"# Note: I use %s.+ (not %s.*) so it forces a match with the prefix string, ONLY if it is followed by something.",
"return",
"df",
".",
"filter",
"(",
"regex",
"=",
"'^(%s.+|%s)$'",
"%... | Filter dataframe to include specified columns, retaining any Intensity columns. | [
"Filter",
"dataframe",
"to",
"include",
"specified",
"columns",
"retaining",
"any",
"Intensity",
"columns",
"."
] | 8b14bf4d2f895da6aea5d7885d409315bd303ec6 | https://github.com/mfitzp/padua/blob/8b14bf4d2f895da6aea5d7885d409315bd303ec6/padua/filters.py#L163-L168 |
5,977 | mfitzp/padua | padua/filters.py | filter_intensity | def filter_intensity(df, label="", with_multiplicity=False):
"""
Filter to include only the Intensity values with optional specified label, excluding other
Intensity measurements, but retaining all other columns.
"""
label += ".*__\d" if with_multiplicity else ""
dft = df.filter(regex="^(?!Int... | python | def filter_intensity(df, label="", with_multiplicity=False):
"""
Filter to include only the Intensity values with optional specified label, excluding other
Intensity measurements, but retaining all other columns.
"""
label += ".*__\d" if with_multiplicity else ""
dft = df.filter(regex="^(?!Int... | [
"def",
"filter_intensity",
"(",
"df",
",",
"label",
"=",
"\"\"",
",",
"with_multiplicity",
"=",
"False",
")",
":",
"label",
"+=",
"\".*__\\d\"",
"if",
"with_multiplicity",
"else",
"\"\"",
"dft",
"=",
"df",
".",
"filter",
"(",
"regex",
"=",
"\"^(?!Intensity).... | Filter to include only the Intensity values with optional specified label, excluding other
Intensity measurements, but retaining all other columns. | [
"Filter",
"to",
"include",
"only",
"the",
"Intensity",
"values",
"with",
"optional",
"specified",
"label",
"excluding",
"other",
"Intensity",
"measurements",
"but",
"retaining",
"all",
"other",
"columns",
"."
] | 8b14bf4d2f895da6aea5d7885d409315bd303ec6 | https://github.com/mfitzp/padua/blob/8b14bf4d2f895da6aea5d7885d409315bd303ec6/padua/filters.py#L177-L187 |
5,978 | mfitzp/padua | padua/filters.py | filter_ratio | def filter_ratio(df, label="", with_multiplicity=False):
"""
Filter to include only the Ratio values with optional specified label, excluding other
Intensity measurements, but retaining all other columns.
"""
label += ".*__\d" if with_multiplicity else ""
dft = df.filter(regex="^(?!Ratio).*$")
... | python | def filter_ratio(df, label="", with_multiplicity=False):
"""
Filter to include only the Ratio values with optional specified label, excluding other
Intensity measurements, but retaining all other columns.
"""
label += ".*__\d" if with_multiplicity else ""
dft = df.filter(regex="^(?!Ratio).*$")
... | [
"def",
"filter_ratio",
"(",
"df",
",",
"label",
"=",
"\"\"",
",",
"with_multiplicity",
"=",
"False",
")",
":",
"label",
"+=",
"\".*__\\d\"",
"if",
"with_multiplicity",
"else",
"\"\"",
"dft",
"=",
"df",
".",
"filter",
"(",
"regex",
"=",
"\"^(?!Ratio).*$\"",
... | Filter to include only the Ratio values with optional specified label, excluding other
Intensity measurements, but retaining all other columns. | [
"Filter",
"to",
"include",
"only",
"the",
"Ratio",
"values",
"with",
"optional",
"specified",
"label",
"excluding",
"other",
"Intensity",
"measurements",
"but",
"retaining",
"all",
"other",
"columns",
"."
] | 8b14bf4d2f895da6aea5d7885d409315bd303ec6 | https://github.com/mfitzp/padua/blob/8b14bf4d2f895da6aea5d7885d409315bd303ec6/padua/filters.py#L201-L211 |
5,979 | mfitzp/padua | padua/io.py | read_perseus | def read_perseus(f):
"""
Load a Perseus processed data table
:param f: Source file
:return: Pandas dataframe of imported data
"""
df = pd.read_csv(f, delimiter='\t', header=[0,1,2,3], low_memory=False)
df.columns = pd.MultiIndex.from_tuples([(x,) for x in df.columns.get_level_values(0)])
... | python | def read_perseus(f):
"""
Load a Perseus processed data table
:param f: Source file
:return: Pandas dataframe of imported data
"""
df = pd.read_csv(f, delimiter='\t', header=[0,1,2,3], low_memory=False)
df.columns = pd.MultiIndex.from_tuples([(x,) for x in df.columns.get_level_values(0)])
... | [
"def",
"read_perseus",
"(",
"f",
")",
":",
"df",
"=",
"pd",
".",
"read_csv",
"(",
"f",
",",
"delimiter",
"=",
"'\\t'",
",",
"header",
"=",
"[",
"0",
",",
"1",
",",
"2",
",",
"3",
"]",
",",
"low_memory",
"=",
"False",
")",
"df",
".",
"columns",
... | Load a Perseus processed data table
:param f: Source file
:return: Pandas dataframe of imported data | [
"Load",
"a",
"Perseus",
"processed",
"data",
"table"
] | 8b14bf4d2f895da6aea5d7885d409315bd303ec6 | https://github.com/mfitzp/padua/blob/8b14bf4d2f895da6aea5d7885d409315bd303ec6/padua/io.py#L21-L30 |
5,980 | mfitzp/padua | padua/io.py | write_perseus | def write_perseus(f, df):
"""
Export a dataframe to Perseus; recreating the format
:param f:
:param df:
:return:
"""
### Generate the Perseus like type index
FIELD_TYPE_MAP = {
'Amino acid':'C',
'Charge':'C',
'Reverse':'C',
'Potential contaminant':'C',
... | python | def write_perseus(f, df):
"""
Export a dataframe to Perseus; recreating the format
:param f:
:param df:
:return:
"""
### Generate the Perseus like type index
FIELD_TYPE_MAP = {
'Amino acid':'C',
'Charge':'C',
'Reverse':'C',
'Potential contaminant':'C',
... | [
"def",
"write_perseus",
"(",
"f",
",",
"df",
")",
":",
"### Generate the Perseus like type index",
"FIELD_TYPE_MAP",
"=",
"{",
"'Amino acid'",
":",
"'C'",
",",
"'Charge'",
":",
"'C'",
",",
"'Reverse'",
":",
"'C'",
",",
"'Potential contaminant'",
":",
"'C'",
",",... | Export a dataframe to Perseus; recreating the format
:param f:
:param df:
:return: | [
"Export",
"a",
"dataframe",
"to",
"Perseus",
";",
"recreating",
"the",
"format"
] | 8b14bf4d2f895da6aea5d7885d409315bd303ec6 | https://github.com/mfitzp/padua/blob/8b14bf4d2f895da6aea5d7885d409315bd303ec6/padua/io.py#L33-L82 |
5,981 | mfitzp/padua | padua/io.py | write_phosphopath_ratio | def write_phosphopath_ratio(df, f, a, *args, **kwargs):
"""
Write out the data frame ratio between two groups
protein-Rsite-multiplicity-timepoint
ID Ratio
Q13619-S10-1-1 0.5
Q9H3Z4-S10-1-1 0.502
Q6GQQ9-S100-1-1 0.504
Q86YP4-S100-1-1 0.506
Q9H307-S100-1-1 0.508
Q8NEY1-S1000-1-1 0... | python | def write_phosphopath_ratio(df, f, a, *args, **kwargs):
"""
Write out the data frame ratio between two groups
protein-Rsite-multiplicity-timepoint
ID Ratio
Q13619-S10-1-1 0.5
Q9H3Z4-S10-1-1 0.502
Q6GQQ9-S100-1-1 0.504
Q86YP4-S100-1-1 0.506
Q9H307-S100-1-1 0.508
Q8NEY1-S1000-1-1 0... | [
"def",
"write_phosphopath_ratio",
"(",
"df",
",",
"f",
",",
"a",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"timepoint_idx",
"=",
"kwargs",
".",
"get",
"(",
"'timepoint_idx'",
",",
"None",
")",
"proteins",
"=",
"[",
"get_protein_id",
"(",
"k"... | Write out the data frame ratio between two groups
protein-Rsite-multiplicity-timepoint
ID Ratio
Q13619-S10-1-1 0.5
Q9H3Z4-S10-1-1 0.502
Q6GQQ9-S100-1-1 0.504
Q86YP4-S100-1-1 0.506
Q9H307-S100-1-1 0.508
Q8NEY1-S1000-1-1 0.51
Q13541-S101-1-1 0.512
O95785-S1012-2-1 0.514
O95785-... | [
"Write",
"out",
"the",
"data",
"frame",
"ratio",
"between",
"two",
"groups",
"protein",
"-",
"Rsite",
"-",
"multiplicity",
"-",
"timepoint",
"ID",
"Ratio",
"Q13619",
"-",
"S10",
"-",
"1",
"-",
"1",
"0",
".",
"5",
"Q9H3Z4",
"-",
"S10",
"-",
"1",
"-",
... | 8b14bf4d2f895da6aea5d7885d409315bd303ec6 | https://github.com/mfitzp/padua/blob/8b14bf4d2f895da6aea5d7885d409315bd303ec6/padua/io.py#L129-L185 |
5,982 | mfitzp/padua | padua/io.py | write_r | def write_r(df, f, sep=",", index_join="@", columns_join="."):
"""
Export dataframe in a format easily importable to R
Index fields are joined with "@" and column fields by "." by default.
:param df:
:param f:
:param index_join:
:param columns_join:
:return:
"""
df = df.copy()
... | python | def write_r(df, f, sep=",", index_join="@", columns_join="."):
"""
Export dataframe in a format easily importable to R
Index fields are joined with "@" and column fields by "." by default.
:param df:
:param f:
:param index_join:
:param columns_join:
:return:
"""
df = df.copy()
... | [
"def",
"write_r",
"(",
"df",
",",
"f",
",",
"sep",
"=",
"\",\"",
",",
"index_join",
"=",
"\"@\"",
",",
"columns_join",
"=",
"\".\"",
")",
":",
"df",
"=",
"df",
".",
"copy",
"(",
")",
"df",
".",
"index",
"=",
"[",
"\"@\"",
".",
"join",
"(",
"[",... | Export dataframe in a format easily importable to R
Index fields are joined with "@" and column fields by "." by default.
:param df:
:param f:
:param index_join:
:param columns_join:
:return: | [
"Export",
"dataframe",
"in",
"a",
"format",
"easily",
"importable",
"to",
"R"
] | 8b14bf4d2f895da6aea5d7885d409315bd303ec6 | https://github.com/mfitzp/padua/blob/8b14bf4d2f895da6aea5d7885d409315bd303ec6/padua/io.py#L188-L203 |
5,983 | mfitzp/padua | padua/imputation.py | gaussian | def gaussian(df, width=0.3, downshift=-1.8, prefix=None):
"""
Impute missing values by drawing from a normal distribution
:param df:
:param width: Scale factor for the imputed distribution relative to the standard deviation of measured values. Can be a single number or list of one per column.
:para... | python | def gaussian(df, width=0.3, downshift=-1.8, prefix=None):
"""
Impute missing values by drawing from a normal distribution
:param df:
:param width: Scale factor for the imputed distribution relative to the standard deviation of measured values. Can be a single number or list of one per column.
:para... | [
"def",
"gaussian",
"(",
"df",
",",
"width",
"=",
"0.3",
",",
"downshift",
"=",
"-",
"1.8",
",",
"prefix",
"=",
"None",
")",
":",
"df",
"=",
"df",
".",
"copy",
"(",
")",
"imputed",
"=",
"df",
".",
"isnull",
"(",
")",
"# Keep track of what's real",
"... | Impute missing values by drawing from a normal distribution
:param df:
:param width: Scale factor for the imputed distribution relative to the standard deviation of measured values. Can be a single number or list of one per column.
:param downshift: Shift the imputed values down, in units of std. dev. Can ... | [
"Impute",
"missing",
"values",
"by",
"drawing",
"from",
"a",
"normal",
"distribution"
] | 8b14bf4d2f895da6aea5d7885d409315bd303ec6 | https://github.com/mfitzp/padua/blob/8b14bf4d2f895da6aea5d7885d409315bd303ec6/padua/imputation.py#L14-L63 |
5,984 | mfitzp/padua | padua/visualize.py | _pca_scores | def _pca_scores(
scores,
pc1=0,
pc2=1,
fcol=None,
ecol=None,
marker='o',
markersize=30,
label_scores=None,
show_covariance_ellipse=True,
optimize_label_iter=OPTIMIZE_LABEL_ITER_DEFAULT,
**kwargs
):
"""
Plot a scores plot... | python | def _pca_scores(
scores,
pc1=0,
pc2=1,
fcol=None,
ecol=None,
marker='o',
markersize=30,
label_scores=None,
show_covariance_ellipse=True,
optimize_label_iter=OPTIMIZE_LABEL_ITER_DEFAULT,
**kwargs
):
"""
Plot a scores plot... | [
"def",
"_pca_scores",
"(",
"scores",
",",
"pc1",
"=",
"0",
",",
"pc2",
"=",
"1",
",",
"fcol",
"=",
"None",
",",
"ecol",
"=",
"None",
",",
"marker",
"=",
"'o'",
",",
"markersize",
"=",
"30",
",",
"label_scores",
"=",
"None",
",",
"show_covariance_elli... | Plot a scores plot for two principal components as AxB scatter plot.
Returns the plotted axis.
:param scores: DataFrame containing scores
:param pc1: Column indexer into scores for PC1
:param pc2: Column indexer into scores for PC2
:param fcol: Face (fill) color definition
:param ecol: Edge co... | [
"Plot",
"a",
"scores",
"plot",
"for",
"two",
"principal",
"components",
"as",
"AxB",
"scatter",
"plot",
"."
] | 8b14bf4d2f895da6aea5d7885d409315bd303ec6 | https://github.com/mfitzp/padua/blob/8b14bf4d2f895da6aea5d7885d409315bd303ec6/padua/visualize.py#L117-L200 |
5,985 | mfitzp/padua | padua/visualize.py | modifiedaminoacids | def modifiedaminoacids(df, kind='pie'):
"""
Generate a plot of relative numbers of modified amino acids in source DataFrame.
Plot a pie or bar chart showing the number and percentage of modified amino
acids in the supplied data frame. The amino acids displayed will be
determined from the supplied d... | python | def modifiedaminoacids(df, kind='pie'):
"""
Generate a plot of relative numbers of modified amino acids in source DataFrame.
Plot a pie or bar chart showing the number and percentage of modified amino
acids in the supplied data frame. The amino acids displayed will be
determined from the supplied d... | [
"def",
"modifiedaminoacids",
"(",
"df",
",",
"kind",
"=",
"'pie'",
")",
":",
"colors",
"=",
"[",
"'#6baed6'",
",",
"'#c6dbef'",
",",
"'#bdbdbd'",
"]",
"total_aas",
",",
"quants",
"=",
"analysis",
".",
"modifiedaminoacids",
"(",
"df",
")",
"df",
"=",
"pd"... | Generate a plot of relative numbers of modified amino acids in source DataFrame.
Plot a pie or bar chart showing the number and percentage of modified amino
acids in the supplied data frame. The amino acids displayed will be
determined from the supplied data/modification type.
:param df: processed Dat... | [
"Generate",
"a",
"plot",
"of",
"relative",
"numbers",
"of",
"modified",
"amino",
"acids",
"in",
"source",
"DataFrame",
"."
] | 8b14bf4d2f895da6aea5d7885d409315bd303ec6 | https://github.com/mfitzp/padua/blob/8b14bf4d2f895da6aea5d7885d409315bd303ec6/padua/visualize.py#L697-L748 |
5,986 | mfitzp/padua | padua/visualize.py | venn | def venn(df1, df2, df3=None, labels=None, ix1=None, ix2=None, ix3=None, return_intersection=False, fcols=None):
"""
Plot a 2 or 3-part venn diagram showing the overlap between 2 or 3 pandas DataFrames.
Provided with two or three Pandas DataFrames, this will return a venn diagram showing the overlap calcula... | python | def venn(df1, df2, df3=None, labels=None, ix1=None, ix2=None, ix3=None, return_intersection=False, fcols=None):
"""
Plot a 2 or 3-part venn diagram showing the overlap between 2 or 3 pandas DataFrames.
Provided with two or three Pandas DataFrames, this will return a venn diagram showing the overlap calcula... | [
"def",
"venn",
"(",
"df1",
",",
"df2",
",",
"df3",
"=",
"None",
",",
"labels",
"=",
"None",
",",
"ix1",
"=",
"None",
",",
"ix2",
"=",
"None",
",",
"ix3",
"=",
"None",
",",
"return_intersection",
"=",
"False",
",",
"fcols",
"=",
"None",
")",
":",
... | Plot a 2 or 3-part venn diagram showing the overlap between 2 or 3 pandas DataFrames.
Provided with two or three Pandas DataFrames, this will return a venn diagram showing the overlap calculated between
the DataFrame indexes provided as ix1, ix2, ix3. Labels for each DataFrame can be provided as a list in the ... | [
"Plot",
"a",
"2",
"or",
"3",
"-",
"part",
"venn",
"diagram",
"showing",
"the",
"overlap",
"between",
"2",
"or",
"3",
"pandas",
"DataFrames",
"."
] | 8b14bf4d2f895da6aea5d7885d409315bd303ec6 | https://github.com/mfitzp/padua/blob/8b14bf4d2f895da6aea5d7885d409315bd303ec6/padua/visualize.py#L979-L1033 |
5,987 | mfitzp/padua | padua/visualize.py | sitespeptidesproteins | def sitespeptidesproteins(df, labels=None, colors=None, site_localization_probability=0.75):
"""
Plot the number of sites, peptides and proteins in the dataset.
Generates a plot with sites, peptides and proteins displayed hierarchically in chevrons.
The site count is limited to Class I (<=0.75 site loc... | python | def sitespeptidesproteins(df, labels=None, colors=None, site_localization_probability=0.75):
"""
Plot the number of sites, peptides and proteins in the dataset.
Generates a plot with sites, peptides and proteins displayed hierarchically in chevrons.
The site count is limited to Class I (<=0.75 site loc... | [
"def",
"sitespeptidesproteins",
"(",
"df",
",",
"labels",
"=",
"None",
",",
"colors",
"=",
"None",
",",
"site_localization_probability",
"=",
"0.75",
")",
":",
"fig",
"=",
"plt",
".",
"figure",
"(",
"figsize",
"=",
"(",
"4",
",",
"6",
")",
")",
"ax",
... | Plot the number of sites, peptides and proteins in the dataset.
Generates a plot with sites, peptides and proteins displayed hierarchically in chevrons.
The site count is limited to Class I (<=0.75 site localization probability) by default
but may be altered using the `site_localization_probability` parame... | [
"Plot",
"the",
"number",
"of",
"sites",
"peptides",
"and",
"proteins",
"in",
"the",
"dataset",
"."
] | 8b14bf4d2f895da6aea5d7885d409315bd303ec6 | https://github.com/mfitzp/padua/blob/8b14bf4d2f895da6aea5d7885d409315bd303ec6/padua/visualize.py#L1036-L1071 |
5,988 | mfitzp/padua | padua/visualize.py | _areadist | def _areadist(ax, v, xr, c, bins=100, by=None, alpha=1, label=None):
"""
Plot the histogram distribution but as an area plot
"""
y, x = np.histogram(v[~np.isnan(v)], bins)
x = x[:-1]
if by is None:
by = np.zeros((bins,))
ax.fill_between(x, y, by, facecolor=c, alpha=alpha, label=lab... | python | def _areadist(ax, v, xr, c, bins=100, by=None, alpha=1, label=None):
"""
Plot the histogram distribution but as an area plot
"""
y, x = np.histogram(v[~np.isnan(v)], bins)
x = x[:-1]
if by is None:
by = np.zeros((bins,))
ax.fill_between(x, y, by, facecolor=c, alpha=alpha, label=lab... | [
"def",
"_areadist",
"(",
"ax",
",",
"v",
",",
"xr",
",",
"c",
",",
"bins",
"=",
"100",
",",
"by",
"=",
"None",
",",
"alpha",
"=",
"1",
",",
"label",
"=",
"None",
")",
":",
"y",
",",
"x",
"=",
"np",
".",
"histogram",
"(",
"v",
"[",
"~",
"n... | Plot the histogram distribution but as an area plot | [
"Plot",
"the",
"histogram",
"distribution",
"but",
"as",
"an",
"area",
"plot"
] | 8b14bf4d2f895da6aea5d7885d409315bd303ec6 | https://github.com/mfitzp/padua/blob/8b14bf4d2f895da6aea5d7885d409315bd303ec6/padua/visualize.py#L1374-L1385 |
5,989 | mfitzp/padua | padua/visualize.py | hierarchical_timecourse | def hierarchical_timecourse(
df,
cluster_cols=True,
cluster_rows=False,
n_col_clusters=False,
n_row_clusters=False,
fcol=None,
z_score=0,
method='ward',
cmap=cm.PuOr_r,
return_clusters=False,
rdistance_fn=distance.pdist,
cdi... | python | def hierarchical_timecourse(
df,
cluster_cols=True,
cluster_rows=False,
n_col_clusters=False,
n_row_clusters=False,
fcol=None,
z_score=0,
method='ward',
cmap=cm.PuOr_r,
return_clusters=False,
rdistance_fn=distance.pdist,
cdi... | [
"def",
"hierarchical_timecourse",
"(",
"df",
",",
"cluster_cols",
"=",
"True",
",",
"cluster_rows",
"=",
"False",
",",
"n_col_clusters",
"=",
"False",
",",
"n_row_clusters",
"=",
"False",
",",
"fcol",
"=",
"None",
",",
"z_score",
"=",
"0",
",",
"method",
"... | Hierarchical clustering of samples across timecourse experiment.
Peform a hiearchical clustering on a pandas DataFrame and display the resulting clustering as a
timecourse density plot.
Samples are z-scored along the 0-axis (y) by default. To override this use the `z_score` param with the axis to `z_score... | [
"Hierarchical",
"clustering",
"of",
"samples",
"across",
"timecourse",
"experiment",
"."
] | 8b14bf4d2f895da6aea5d7885d409315bd303ec6 | https://github.com/mfitzp/padua/blob/8b14bf4d2f895da6aea5d7885d409315bd303ec6/padua/visualize.py#L1872-L1965 |
5,990 | mfitzp/padua | padua/normalization.py | subtract_column_median | def subtract_column_median(df, prefix='Intensity '):
"""
Apply column-wise normalisation to expression columns.
Default is median transform to expression columns beginning with Intensity
:param df:
:param prefix: The column prefix for expression columns
:return:
"""
df = df.copy()
... | python | def subtract_column_median(df, prefix='Intensity '):
"""
Apply column-wise normalisation to expression columns.
Default is median transform to expression columns beginning with Intensity
:param df:
:param prefix: The column prefix for expression columns
:return:
"""
df = df.copy()
... | [
"def",
"subtract_column_median",
"(",
"df",
",",
"prefix",
"=",
"'Intensity '",
")",
":",
"df",
"=",
"df",
".",
"copy",
"(",
")",
"df",
".",
"replace",
"(",
"[",
"np",
".",
"inf",
",",
"-",
"np",
".",
"inf",
"]",
",",
"np",
".",
"nan",
",",
"in... | Apply column-wise normalisation to expression columns.
Default is median transform to expression columns beginning with Intensity
:param df:
:param prefix: The column prefix for expression columns
:return: | [
"Apply",
"column",
"-",
"wise",
"normalisation",
"to",
"expression",
"columns",
"."
] | 8b14bf4d2f895da6aea5d7885d409315bd303ec6 | https://github.com/mfitzp/padua/blob/8b14bf4d2f895da6aea5d7885d409315bd303ec6/padua/normalization.py#L4-L22 |
5,991 | mfitzp/padua | padua/utils.py | get_protein_id_list | def get_protein_id_list(df, level=0):
"""
Return a complete list of shortform IDs from a DataFrame
Extract all protein IDs from a dataframe from multiple rows containing
protein IDs in MaxQuant output format: e.g. P07830;P63267;Q54A44;P63268
Long names (containing species information) are eliminat... | python | def get_protein_id_list(df, level=0):
"""
Return a complete list of shortform IDs from a DataFrame
Extract all protein IDs from a dataframe from multiple rows containing
protein IDs in MaxQuant output format: e.g. P07830;P63267;Q54A44;P63268
Long names (containing species information) are eliminat... | [
"def",
"get_protein_id_list",
"(",
"df",
",",
"level",
"=",
"0",
")",
":",
"protein_list",
"=",
"[",
"]",
"for",
"s",
"in",
"df",
".",
"index",
".",
"get_level_values",
"(",
"level",
")",
":",
"protein_list",
".",
"extend",
"(",
"get_protein_ids",
"(",
... | Return a complete list of shortform IDs from a DataFrame
Extract all protein IDs from a dataframe from multiple rows containing
protein IDs in MaxQuant output format: e.g. P07830;P63267;Q54A44;P63268
Long names (containing species information) are eliminated (split on ' ') and
isoforms are removed (sp... | [
"Return",
"a",
"complete",
"list",
"of",
"shortform",
"IDs",
"from",
"a",
"DataFrame"
] | 8b14bf4d2f895da6aea5d7885d409315bd303ec6 | https://github.com/mfitzp/padua/blob/8b14bf4d2f895da6aea5d7885d409315bd303ec6/padua/utils.py#L142-L162 |
5,992 | mfitzp/padua | padua/utils.py | hierarchical_match | def hierarchical_match(d, k, default=None):
"""
Match a key against a dict, simplifying element at a time
:param df: DataFrame
:type df: pandas.DataFrame
:param level: Level of DataFrame index to extract IDs from
:type level: int or str
:return: hiearchically matched value or default
"... | python | def hierarchical_match(d, k, default=None):
"""
Match a key against a dict, simplifying element at a time
:param df: DataFrame
:type df: pandas.DataFrame
:param level: Level of DataFrame index to extract IDs from
:type level: int or str
:return: hiearchically matched value or default
"... | [
"def",
"hierarchical_match",
"(",
"d",
",",
"k",
",",
"default",
"=",
"None",
")",
":",
"if",
"d",
"is",
"None",
":",
"return",
"default",
"if",
"type",
"(",
"k",
")",
"!=",
"list",
"and",
"type",
"(",
"k",
")",
"!=",
"tuple",
":",
"k",
"=",
"[... | Match a key against a dict, simplifying element at a time
:param df: DataFrame
:type df: pandas.DataFrame
:param level: Level of DataFrame index to extract IDs from
:type level: int or str
:return: hiearchically matched value or default | [
"Match",
"a",
"key",
"against",
"a",
"dict",
"simplifying",
"element",
"at",
"a",
"time"
] | 8b14bf4d2f895da6aea5d7885d409315bd303ec6 | https://github.com/mfitzp/padua/blob/8b14bf4d2f895da6aea5d7885d409315bd303ec6/padua/utils.py#L228-L256 |
5,993 | mfitzp/padua | padua/utils.py | calculate_s0_curve | def calculate_s0_curve(s0, minpval, maxpval, minratio, maxratio, curve_interval=0.1):
"""
Calculate s0 curve for volcano plot.
Taking an min and max p value, and a min and max ratio, calculate an smooth
curve starting from parameter `s0` in each direction.
The `curve_interval` parameter defines th... | python | def calculate_s0_curve(s0, minpval, maxpval, minratio, maxratio, curve_interval=0.1):
"""
Calculate s0 curve for volcano plot.
Taking an min and max p value, and a min and max ratio, calculate an smooth
curve starting from parameter `s0` in each direction.
The `curve_interval` parameter defines th... | [
"def",
"calculate_s0_curve",
"(",
"s0",
",",
"minpval",
",",
"maxpval",
",",
"minratio",
",",
"maxratio",
",",
"curve_interval",
"=",
"0.1",
")",
":",
"mminpval",
"=",
"-",
"np",
".",
"log10",
"(",
"minpval",
")",
"mmaxpval",
"=",
"-",
"np",
".",
"log1... | Calculate s0 curve for volcano plot.
Taking an min and max p value, and a min and max ratio, calculate an smooth
curve starting from parameter `s0` in each direction.
The `curve_interval` parameter defines the smoothness of the resulting curve.
:param s0: `float` offset of curve from interset
:pa... | [
"Calculate",
"s0",
"curve",
"for",
"volcano",
"plot",
"."
] | 8b14bf4d2f895da6aea5d7885d409315bd303ec6 | https://github.com/mfitzp/padua/blob/8b14bf4d2f895da6aea5d7885d409315bd303ec6/padua/utils.py#L282-L317 |
5,994 | mfitzp/padua | padua/analysis.py | correlation | def correlation(df, rowvar=False):
"""
Calculate column-wise Pearson correlations using ``numpy.ma.corrcoef``
Input data is masked to ignore NaNs when calculating correlations. Data is returned as
a Pandas ``DataFrame`` of column_n x column_n dimensions, with column index copied to
both axes.
... | python | def correlation(df, rowvar=False):
"""
Calculate column-wise Pearson correlations using ``numpy.ma.corrcoef``
Input data is masked to ignore NaNs when calculating correlations. Data is returned as
a Pandas ``DataFrame`` of column_n x column_n dimensions, with column index copied to
both axes.
... | [
"def",
"correlation",
"(",
"df",
",",
"rowvar",
"=",
"False",
")",
":",
"# Create a correlation matrix for all correlations",
"# of the columns (filled with na for all values)",
"df",
"=",
"df",
".",
"copy",
"(",
")",
"maskv",
"=",
"np",
".",
"ma",
".",
"masked_wher... | Calculate column-wise Pearson correlations using ``numpy.ma.corrcoef``
Input data is masked to ignore NaNs when calculating correlations. Data is returned as
a Pandas ``DataFrame`` of column_n x column_n dimensions, with column index copied to
both axes.
:param df: Pandas DataFrame
:return: Pandas... | [
"Calculate",
"column",
"-",
"wise",
"Pearson",
"correlations",
"using",
"numpy",
".",
"ma",
".",
"corrcoef"
] | 8b14bf4d2f895da6aea5d7885d409315bd303ec6 | https://github.com/mfitzp/padua/blob/8b14bf4d2f895da6aea5d7885d409315bd303ec6/padua/analysis.py#L26-L48 |
5,995 | mfitzp/padua | padua/analysis.py | pca | def pca(df, n_components=2, mean_center=False, **kwargs):
"""
Principal Component Analysis, based on `sklearn.decomposition.PCA`
Performs a principal component analysis (PCA) on the supplied dataframe, selecting the first ``n_components`` components
in the resulting model. The model scores and weights ... | python | def pca(df, n_components=2, mean_center=False, **kwargs):
"""
Principal Component Analysis, based on `sklearn.decomposition.PCA`
Performs a principal component analysis (PCA) on the supplied dataframe, selecting the first ``n_components`` components
in the resulting model. The model scores and weights ... | [
"def",
"pca",
"(",
"df",
",",
"n_components",
"=",
"2",
",",
"mean_center",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"sklearn",
":",
"assert",
"(",
"'This library depends on scikit-learn (sklearn) to perform PCA analysis'",
")",
"from",
"skl... | Principal Component Analysis, based on `sklearn.decomposition.PCA`
Performs a principal component analysis (PCA) on the supplied dataframe, selecting the first ``n_components`` components
in the resulting model. The model scores and weights are returned.
For more information on PCA and the algorithm used,... | [
"Principal",
"Component",
"Analysis",
"based",
"on",
"sklearn",
".",
"decomposition",
".",
"PCA"
] | 8b14bf4d2f895da6aea5d7885d409315bd303ec6 | https://github.com/mfitzp/padua/blob/8b14bf4d2f895da6aea5d7885d409315bd303ec6/padua/analysis.py#L51-L93 |
5,996 | mfitzp/padua | padua/analysis.py | plsda | def plsda(df, a, b, n_components=2, mean_center=False, scale=True, **kwargs):
"""
Partial Least Squares Discriminant Analysis, based on `sklearn.cross_decomposition.PLSRegression`
Performs a binary group partial least squares discriminant analysis (PLS-DA) on the supplied
dataframe, selecting the first... | python | def plsda(df, a, b, n_components=2, mean_center=False, scale=True, **kwargs):
"""
Partial Least Squares Discriminant Analysis, based on `sklearn.cross_decomposition.PLSRegression`
Performs a binary group partial least squares discriminant analysis (PLS-DA) on the supplied
dataframe, selecting the first... | [
"def",
"plsda",
"(",
"df",
",",
"a",
",",
"b",
",",
"n_components",
"=",
"2",
",",
"mean_center",
"=",
"False",
",",
"scale",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"sklearn",
":",
"assert",
"(",
"'This library depends on scikit-l... | Partial Least Squares Discriminant Analysis, based on `sklearn.cross_decomposition.PLSRegression`
Performs a binary group partial least squares discriminant analysis (PLS-DA) on the supplied
dataframe, selecting the first ``n_components``.
Sample groups are defined by the selectors ``a`` and ``b`` which a... | [
"Partial",
"Least",
"Squares",
"Discriminant",
"Analysis",
"based",
"on",
"sklearn",
".",
"cross_decomposition",
".",
"PLSRegression"
] | 8b14bf4d2f895da6aea5d7885d409315bd303ec6 | https://github.com/mfitzp/padua/blob/8b14bf4d2f895da6aea5d7885d409315bd303ec6/padua/analysis.py#L96-L161 |
5,997 | mfitzp/padua | padua/analysis.py | enrichment_from_evidence | def enrichment_from_evidence(dfe, modification="Phospho (STY)"):
"""
Calculate relative enrichment of peptide modifications from evidence.txt.
Taking a modifiedsitepeptides ``DataFrame`` returns the relative enrichment of the specified
modification in the table.
The returned data columns are gener... | python | def enrichment_from_evidence(dfe, modification="Phospho (STY)"):
"""
Calculate relative enrichment of peptide modifications from evidence.txt.
Taking a modifiedsitepeptides ``DataFrame`` returns the relative enrichment of the specified
modification in the table.
The returned data columns are gener... | [
"def",
"enrichment_from_evidence",
"(",
"dfe",
",",
"modification",
"=",
"\"Phospho (STY)\"",
")",
":",
"dfe",
"=",
"dfe",
".",
"reset_index",
"(",
")",
".",
"set_index",
"(",
"'Experiment'",
")",
"dfe",
"[",
"'Modifications'",
"]",
"=",
"np",
".",
"array",
... | Calculate relative enrichment of peptide modifications from evidence.txt.
Taking a modifiedsitepeptides ``DataFrame`` returns the relative enrichment of the specified
modification in the table.
The returned data columns are generated from the input data columns.
:param df: Pandas ``DataFrame`` of evi... | [
"Calculate",
"relative",
"enrichment",
"of",
"peptide",
"modifications",
"from",
"evidence",
".",
"txt",
"."
] | 8b14bf4d2f895da6aea5d7885d409315bd303ec6 | https://github.com/mfitzp/padua/blob/8b14bf4d2f895da6aea5d7885d409315bd303ec6/padua/analysis.py#L232-L258 |
5,998 | mfitzp/padua | padua/analysis.py | enrichment_from_msp | def enrichment_from_msp(dfmsp, modification="Phospho (STY)"):
"""
Calculate relative enrichment of peptide modifications from modificationSpecificPeptides.txt.
Taking a modifiedsitepeptides ``DataFrame`` returns the relative enrichment of the specified
modification in the table.
The returned data ... | python | def enrichment_from_msp(dfmsp, modification="Phospho (STY)"):
"""
Calculate relative enrichment of peptide modifications from modificationSpecificPeptides.txt.
Taking a modifiedsitepeptides ``DataFrame`` returns the relative enrichment of the specified
modification in the table.
The returned data ... | [
"def",
"enrichment_from_msp",
"(",
"dfmsp",
",",
"modification",
"=",
"\"Phospho (STY)\"",
")",
":",
"dfmsp",
"[",
"'Modifications'",
"]",
"=",
"np",
".",
"array",
"(",
"[",
"modification",
"in",
"m",
"for",
"m",
"in",
"dfmsp",
"[",
"'Modifications'",
"]",
... | Calculate relative enrichment of peptide modifications from modificationSpecificPeptides.txt.
Taking a modifiedsitepeptides ``DataFrame`` returns the relative enrichment of the specified
modification in the table.
The returned data columns are generated from the input data columns.
:param df: Pandas ... | [
"Calculate",
"relative",
"enrichment",
"of",
"peptide",
"modifications",
"from",
"modificationSpecificPeptides",
".",
"txt",
"."
] | 8b14bf4d2f895da6aea5d7885d409315bd303ec6 | https://github.com/mfitzp/padua/blob/8b14bf4d2f895da6aea5d7885d409315bd303ec6/padua/analysis.py#L263-L287 |
5,999 | mfitzp/padua | padua/analysis.py | sitespeptidesproteins | def sitespeptidesproteins(df, site_localization_probability=0.75):
"""
Generate summary count of modified sites, peptides and proteins in a processed dataset ``DataFrame``.
Returns the number of sites, peptides and proteins as calculated as follows:
- `sites` (>0.75; or specified site localization pro... | python | def sitespeptidesproteins(df, site_localization_probability=0.75):
"""
Generate summary count of modified sites, peptides and proteins in a processed dataset ``DataFrame``.
Returns the number of sites, peptides and proteins as calculated as follows:
- `sites` (>0.75; or specified site localization pro... | [
"def",
"sitespeptidesproteins",
"(",
"df",
",",
"site_localization_probability",
"=",
"0.75",
")",
":",
"sites",
"=",
"filters",
".",
"filter_localization_probability",
"(",
"df",
",",
"site_localization_probability",
")",
"[",
"'Sequence window'",
"]",
"peptides",
"=... | Generate summary count of modified sites, peptides and proteins in a processed dataset ``DataFrame``.
Returns the number of sites, peptides and proteins as calculated as follows:
- `sites` (>0.75; or specified site localization probability) count of all sites > threshold
- `peptides` the set of `Sequence ... | [
"Generate",
"summary",
"count",
"of",
"modified",
"sites",
"peptides",
"and",
"proteins",
"in",
"a",
"processed",
"dataset",
"DataFrame",
"."
] | 8b14bf4d2f895da6aea5d7885d409315bd303ec6 | https://github.com/mfitzp/padua/blob/8b14bf4d2f895da6aea5d7885d409315bd303ec6/padua/analysis.py#L291-L309 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.