partition
stringclasses
3 values
func_name
stringlengths
1
134
docstring
stringlengths
1
46.9k
path
stringlengths
4
223
original_string
stringlengths
75
104k
code
stringlengths
75
104k
docstring_tokens
listlengths
1
1.97k
repo
stringlengths
7
55
language
stringclasses
1 value
url
stringlengths
87
315
code_tokens
listlengths
19
28.4k
sha
stringlengths
40
40
train
FlexReport.df
Same as extract but return the result as a pandas DataFrame.
ib_insync/flexreport.py
def df(self, topic: str, parseNumbers=True): """ Same as extract but return the result as a pandas DataFrame. """ return util.df(self.extract(topic, parseNumbers))
def df(self, topic: str, parseNumbers=True): """ Same as extract but return the result as a pandas DataFrame. """ return util.df(self.extract(topic, parseNumbers))
[ "Same", "as", "extract", "but", "return", "the", "result", "as", "a", "pandas", "DataFrame", "." ]
erdewit/ib_insync
python
https://github.com/erdewit/ib_insync/blob/d0646a482590f5cb7bfddbd1f0870f8c4bc1df80/ib_insync/flexreport.py#L73-L77
[ "def", "df", "(", "self", ",", "topic", ":", "str", ",", "parseNumbers", "=", "True", ")", ":", "return", "util", ".", "df", "(", "self", ".", "extract", "(", "topic", ",", "parseNumbers", ")", ")" ]
d0646a482590f5cb7bfddbd1f0870f8c4bc1df80
train
FlexReport.download
Download report for the given ``token`` and ``queryId``.
ib_insync/flexreport.py
def download(self, token, queryId): """ Download report for the given ``token`` and ``queryId``. """ url = ( 'https://gdcdyn.interactivebrokers.com' f'/Universal/servlet/FlexStatementService.SendRequest?' f't={token}&q={queryId}&v=3') ...
def download(self, token, queryId): """ Download report for the given ``token`` and ``queryId``. """ url = ( 'https://gdcdyn.interactivebrokers.com' f'/Universal/servlet/FlexStatementService.SendRequest?' f't={token}&q={queryId}&v=3') ...
[ "Download", "report", "for", "the", "given", "token", "and", "queryId", "." ]
erdewit/ib_insync
python
https://github.com/erdewit/ib_insync/blob/d0646a482590f5cb7bfddbd1f0870f8c4bc1df80/ib_insync/flexreport.py#L79-L114
[ "def", "download", "(", "self", ",", "token", ",", "queryId", ")", ":", "url", "=", "(", "'https://gdcdyn.interactivebrokers.com'", "f'/Universal/servlet/FlexStatementService.SendRequest?'", "f't={token}&q={queryId}&v=3'", ")", "resp", "=", "urlopen", "(", "url", ")", "...
d0646a482590f5cb7bfddbd1f0870f8c4bc1df80
train
FlexReport.load
Load report from XML file.
ib_insync/flexreport.py
def load(self, path): """ Load report from XML file. """ with open(path, 'rb') as f: self.data = f.read() self.root = et.fromstring(self.data)
def load(self, path): """ Load report from XML file. """ with open(path, 'rb') as f: self.data = f.read() self.root = et.fromstring(self.data)
[ "Load", "report", "from", "XML", "file", "." ]
erdewit/ib_insync
python
https://github.com/erdewit/ib_insync/blob/d0646a482590f5cb7bfddbd1f0870f8c4bc1df80/ib_insync/flexreport.py#L116-L122
[ "def", "load", "(", "self", ",", "path", ")", ":", "with", "open", "(", "path", ",", "'rb'", ")", "as", "f", ":", "self", ".", "data", "=", "f", ".", "read", "(", ")", "self", ".", "root", "=", "et", ".", "fromstring", "(", "self", ".", "data...
d0646a482590f5cb7bfddbd1f0870f8c4bc1df80
train
FlexReport.save
Save report to XML file.
ib_insync/flexreport.py
def save(self, path): """ Save report to XML file. """ with open(path, 'wb') as f: f.write(self.data)
def save(self, path): """ Save report to XML file. """ with open(path, 'wb') as f: f.write(self.data)
[ "Save", "report", "to", "XML", "file", "." ]
erdewit/ib_insync
python
https://github.com/erdewit/ib_insync/blob/d0646a482590f5cb7bfddbd1f0870f8c4bc1df80/ib_insync/flexreport.py#L124-L129
[ "def", "save", "(", "self", ",", "path", ")", ":", "with", "open", "(", "path", ",", "'wb'", ")", "as", "f", ":", "f", ".", "write", "(", "self", ".", "data", ")" ]
d0646a482590f5cb7bfddbd1f0870f8c4bc1df80
train
Contract.create
Create and a return a specialized contract based on the given secType, or a general Contract if secType is not given.
ib_insync/contract.py
def create(**kwargs): """ Create and a return a specialized contract based on the given secType, or a general Contract if secType is not given. """ secType = kwargs.get('secType', '') cls = { '': Contract, 'STK': Stock, 'OPT': Option, ...
def create(**kwargs): """ Create and a return a specialized contract based on the given secType, or a general Contract if secType is not given. """ secType = kwargs.get('secType', '') cls = { '': Contract, 'STK': Stock, 'OPT': Option, ...
[ "Create", "and", "a", "return", "a", "specialized", "contract", "based", "on", "the", "given", "secType", "or", "a", "general", "Contract", "if", "secType", "is", "not", "given", "." ]
erdewit/ib_insync
python
https://github.com/erdewit/ib_insync/blob/d0646a482590f5cb7bfddbd1f0870f8c4bc1df80/ib_insync/contract.py#L102-L128
[ "def", "create", "(", "*", "*", "kwargs", ")", ":", "secType", "=", "kwargs", ".", "get", "(", "'secType'", ",", "''", ")", "cls", "=", "{", "''", ":", "Contract", ",", "'STK'", ":", "Stock", ",", "'OPT'", ":", "Option", ",", "'FUT'", ":", "Futur...
d0646a482590f5cb7bfddbd1f0870f8c4bc1df80
train
Ticker.hasBidAsk
See if this ticker has a valid bid and ask.
ib_insync/ticker.py
def hasBidAsk(self) -> bool: """ See if this ticker has a valid bid and ask. """ return ( self.bid != -1 and not isNan(self.bid) and self.bidSize > 0 and self.ask != -1 and not isNan(self.ask) and self.askSize > 0)
def hasBidAsk(self) -> bool: """ See if this ticker has a valid bid and ask. """ return ( self.bid != -1 and not isNan(self.bid) and self.bidSize > 0 and self.ask != -1 and not isNan(self.ask) and self.askSize > 0)
[ "See", "if", "this", "ticker", "has", "a", "valid", "bid", "and", "ask", "." ]
erdewit/ib_insync
python
https://github.com/erdewit/ib_insync/blob/d0646a482590f5cb7bfddbd1f0870f8c4bc1df80/ib_insync/ticker.py#L107-L113
[ "def", "hasBidAsk", "(", "self", ")", "->", "bool", ":", "return", "(", "self", ".", "bid", "!=", "-", "1", "and", "not", "isNan", "(", "self", ".", "bid", ")", "and", "self", ".", "bidSize", ">", "0", "and", "self", ".", "ask", "!=", "-", "1",...
d0646a482590f5cb7bfddbd1f0870f8c4bc1df80
train
Ticker.midpoint
Return average of bid and ask, or NaN if no valid bid and ask are available.
ib_insync/ticker.py
def midpoint(self) -> float: """ Return average of bid and ask, or NaN if no valid bid and ask are available. """ return (self.bid + self.ask) / 2 if self.hasBidAsk() else nan
def midpoint(self) -> float: """ Return average of bid and ask, or NaN if no valid bid and ask are available. """ return (self.bid + self.ask) / 2 if self.hasBidAsk() else nan
[ "Return", "average", "of", "bid", "and", "ask", "or", "NaN", "if", "no", "valid", "bid", "and", "ask", "are", "available", "." ]
erdewit/ib_insync
python
https://github.com/erdewit/ib_insync/blob/d0646a482590f5cb7bfddbd1f0870f8c4bc1df80/ib_insync/ticker.py#L115-L120
[ "def", "midpoint", "(", "self", ")", "->", "float", ":", "return", "(", "self", ".", "bid", "+", "self", ".", "ask", ")", "/", "2", "if", "self", ".", "hasBidAsk", "(", ")", "else", "nan" ]
d0646a482590f5cb7bfddbd1f0870f8c4bc1df80
train
Ticker.marketPrice
Return the first available one of * last price if within current bid/ask; * average of bid and ask (midpoint); * close price.
ib_insync/ticker.py
def marketPrice(self) -> float: """ Return the first available one of * last price if within current bid/ask; * average of bid and ask (midpoint); * close price. """ price = self.last if ( self.hasBidAsk() and self.bid <= self.last <= self.ask) else \...
def marketPrice(self) -> float: """ Return the first available one of * last price if within current bid/ask; * average of bid and ask (midpoint); * close price. """ price = self.last if ( self.hasBidAsk() and self.bid <= self.last <= self.ask) else \...
[ "Return", "the", "first", "available", "one", "of" ]
erdewit/ib_insync
python
https://github.com/erdewit/ib_insync/blob/d0646a482590f5cb7bfddbd1f0870f8c4bc1df80/ib_insync/ticker.py#L122-L135
[ "def", "marketPrice", "(", "self", ")", "->", "float", ":", "price", "=", "self", ".", "last", "if", "(", "self", ".", "hasBidAsk", "(", ")", "and", "self", ".", "bid", "<=", "self", ".", "last", "<=", "self", ".", "ask", ")", "else", "self", "."...
d0646a482590f5cb7bfddbd1f0870f8c4bc1df80
train
KeywordProcessor.add_keyword_from_file
To add keywords from a file Args: keyword_file : path to keywords file encoding : specify the encoding of the file Examples: keywords file format can be like: >>> # Option 1: keywords.txt content >>> # java_2e=>java >>> # java pr...
flashtext/keyword.py
def add_keyword_from_file(self, keyword_file, encoding="utf-8"): """To add keywords from a file Args: keyword_file : path to keywords file encoding : specify the encoding of the file Examples: keywords file format can be like: >>> # Option 1: ke...
def add_keyword_from_file(self, keyword_file, encoding="utf-8"): """To add keywords from a file Args: keyword_file : path to keywords file encoding : specify the encoding of the file Examples: keywords file format can be like: >>> # Option 1: ke...
[ "To", "add", "keywords", "from", "a", "file" ]
vi3k6i5/flashtext
python
https://github.com/vi3k6i5/flashtext/blob/50c45f1f4a394572381249681046f57e2bf5a591/flashtext/keyword.py#L291-L327
[ "def", "add_keyword_from_file", "(", "self", ",", "keyword_file", ",", "encoding", "=", "\"utf-8\"", ")", ":", "if", "not", "os", ".", "path", ".", "isfile", "(", "keyword_file", ")", ":", "raise", "IOError", "(", "\"Invalid file path {}\"", ".", "format", "...
50c45f1f4a394572381249681046f57e2bf5a591
train
KeywordProcessor.add_keywords_from_dict
To add keywords from a dictionary Args: keyword_dict (dict): A dictionary with `str` key and (list `str`) as value Examples: >>> keyword_dict = { "java": ["java_2e", "java programing"], "product management": ["PM", "product manager"] ...
flashtext/keyword.py
def add_keywords_from_dict(self, keyword_dict): """To add keywords from a dictionary Args: keyword_dict (dict): A dictionary with `str` key and (list `str`) as value Examples: >>> keyword_dict = { "java": ["java_2e", "java programing"], ...
def add_keywords_from_dict(self, keyword_dict): """To add keywords from a dictionary Args: keyword_dict (dict): A dictionary with `str` key and (list `str`) as value Examples: >>> keyword_dict = { "java": ["java_2e", "java programing"], ...
[ "To", "add", "keywords", "from", "a", "dictionary" ]
vi3k6i5/flashtext
python
https://github.com/vi3k6i5/flashtext/blob/50c45f1f4a394572381249681046f57e2bf5a591/flashtext/keyword.py#L329-L351
[ "def", "add_keywords_from_dict", "(", "self", ",", "keyword_dict", ")", ":", "for", "clean_name", ",", "keywords", "in", "keyword_dict", ".", "items", "(", ")", ":", "if", "not", "isinstance", "(", "keywords", ",", "list", ")", ":", "raise", "AttributeError"...
50c45f1f4a394572381249681046f57e2bf5a591
train
KeywordProcessor.remove_keywords_from_dict
To remove keywords from a dictionary Args: keyword_dict (dict): A dictionary with `str` key and (list `str`) as value Examples: >>> keyword_dict = { "java": ["java_2e", "java programing"], "product management": ["PM", "product manager"] ...
flashtext/keyword.py
def remove_keywords_from_dict(self, keyword_dict): """To remove keywords from a dictionary Args: keyword_dict (dict): A dictionary with `str` key and (list `str`) as value Examples: >>> keyword_dict = { "java": ["java_2e", "java programing"], ...
def remove_keywords_from_dict(self, keyword_dict): """To remove keywords from a dictionary Args: keyword_dict (dict): A dictionary with `str` key and (list `str`) as value Examples: >>> keyword_dict = { "java": ["java_2e", "java programing"], ...
[ "To", "remove", "keywords", "from", "a", "dictionary" ]
vi3k6i5/flashtext
python
https://github.com/vi3k6i5/flashtext/blob/50c45f1f4a394572381249681046f57e2bf5a591/flashtext/keyword.py#L353-L375
[ "def", "remove_keywords_from_dict", "(", "self", ",", "keyword_dict", ")", ":", "for", "clean_name", ",", "keywords", "in", "keyword_dict", ".", "items", "(", ")", ":", "if", "not", "isinstance", "(", "keywords", ",", "list", ")", ":", "raise", "AttributeErr...
50c45f1f4a394572381249681046f57e2bf5a591
train
KeywordProcessor.add_keywords_from_list
To add keywords from a list Args: keyword_list (list(str)): List of keywords to add Examples: >>> keyword_processor.add_keywords_from_list(["java", "python"]}) Raises: AttributeError: If `keyword_list` is not a list.
flashtext/keyword.py
def add_keywords_from_list(self, keyword_list): """To add keywords from a list Args: keyword_list (list(str)): List of keywords to add Examples: >>> keyword_processor.add_keywords_from_list(["java", "python"]}) Raises: AttributeError: If `keyword_lis...
def add_keywords_from_list(self, keyword_list): """To add keywords from a list Args: keyword_list (list(str)): List of keywords to add Examples: >>> keyword_processor.add_keywords_from_list(["java", "python"]}) Raises: AttributeError: If `keyword_lis...
[ "To", "add", "keywords", "from", "a", "list" ]
vi3k6i5/flashtext
python
https://github.com/vi3k6i5/flashtext/blob/50c45f1f4a394572381249681046f57e2bf5a591/flashtext/keyword.py#L377-L393
[ "def", "add_keywords_from_list", "(", "self", ",", "keyword_list", ")", ":", "if", "not", "isinstance", "(", "keyword_list", ",", "list", ")", ":", "raise", "AttributeError", "(", "\"keyword_list should be a list\"", ")", "for", "keyword", "in", "keyword_list", ":...
50c45f1f4a394572381249681046f57e2bf5a591
train
KeywordProcessor.remove_keywords_from_list
To remove keywords present in list Args: keyword_list (list(str)): List of keywords to remove Examples: >>> keyword_processor.remove_keywords_from_list(["java", "python"]}) Raises: AttributeError: If `keyword_list` is not a list.
flashtext/keyword.py
def remove_keywords_from_list(self, keyword_list): """To remove keywords present in list Args: keyword_list (list(str)): List of keywords to remove Examples: >>> keyword_processor.remove_keywords_from_list(["java", "python"]}) Raises: AttributeError:...
def remove_keywords_from_list(self, keyword_list): """To remove keywords present in list Args: keyword_list (list(str)): List of keywords to remove Examples: >>> keyword_processor.remove_keywords_from_list(["java", "python"]}) Raises: AttributeError:...
[ "To", "remove", "keywords", "present", "in", "list" ]
vi3k6i5/flashtext
python
https://github.com/vi3k6i5/flashtext/blob/50c45f1f4a394572381249681046f57e2bf5a591/flashtext/keyword.py#L395-L411
[ "def", "remove_keywords_from_list", "(", "self", ",", "keyword_list", ")", ":", "if", "not", "isinstance", "(", "keyword_list", ",", "list", ")", ":", "raise", "AttributeError", "(", "\"keyword_list should be a list\"", ")", "for", "keyword", "in", "keyword_list", ...
50c45f1f4a394572381249681046f57e2bf5a591
train
KeywordProcessor.get_all_keywords
Recursively builds a dictionary of keywords present in the dictionary And the clean name mapped to those keywords. Args: term_so_far : string term built so far by adding all previous characters current_dict : dict current recursive position in dic...
flashtext/keyword.py
def get_all_keywords(self, term_so_far='', current_dict=None): """Recursively builds a dictionary of keywords present in the dictionary And the clean name mapped to those keywords. Args: term_so_far : string term built so far by adding all previous characters ...
def get_all_keywords(self, term_so_far='', current_dict=None): """Recursively builds a dictionary of keywords present in the dictionary And the clean name mapped to those keywords. Args: term_so_far : string term built so far by adding all previous characters ...
[ "Recursively", "builds", "a", "dictionary", "of", "keywords", "present", "in", "the", "dictionary", "And", "the", "clean", "name", "mapped", "to", "those", "keywords", "." ]
vi3k6i5/flashtext
python
https://github.com/vi3k6i5/flashtext/blob/50c45f1f4a394572381249681046f57e2bf5a591/flashtext/keyword.py#L413-L448
[ "def", "get_all_keywords", "(", "self", ",", "term_so_far", "=", "''", ",", "current_dict", "=", "None", ")", ":", "terms_present", "=", "{", "}", "if", "not", "term_so_far", ":", "term_so_far", "=", "''", "if", "current_dict", "is", "None", ":", "current_...
50c45f1f4a394572381249681046f57e2bf5a591
train
KeywordProcessor.extract_keywords
Searches in the string for all keywords present in corpus. Keywords present are added to a list `keywords_extracted` and returned. Args: sentence (str): Line of text where we will search for keywords Returns: keywords_extracted (list(str)): List of terms/keywords found ...
flashtext/keyword.py
def extract_keywords(self, sentence, span_info=False): """Searches in the string for all keywords present in corpus. Keywords present are added to a list `keywords_extracted` and returned. Args: sentence (str): Line of text where we will search for keywords Returns: ...
def extract_keywords(self, sentence, span_info=False): """Searches in the string for all keywords present in corpus. Keywords present are added to a list `keywords_extracted` and returned. Args: sentence (str): Line of text where we will search for keywords Returns: ...
[ "Searches", "in", "the", "string", "for", "all", "keywords", "present", "in", "corpus", ".", "Keywords", "present", "are", "added", "to", "a", "list", "keywords_extracted", "and", "returned", "." ]
vi3k6i5/flashtext
python
https://github.com/vi3k6i5/flashtext/blob/50c45f1f4a394572381249681046f57e2bf5a591/flashtext/keyword.py#L450-L558
[ "def", "extract_keywords", "(", "self", ",", "sentence", ",", "span_info", "=", "False", ")", ":", "keywords_extracted", "=", "[", "]", "if", "not", "sentence", ":", "# if sentence is empty or none just return empty list", "return", "keywords_extracted", "if", "not", ...
50c45f1f4a394572381249681046f57e2bf5a591
train
KeywordProcessor.replace_keywords
Searches in the string for all keywords present in corpus. Keywords present are replaced by the clean name and a new string is returned. Args: sentence (str): Line of text where we will replace keywords Returns: new_sentence (str): Line of text with replaced keywords ...
flashtext/keyword.py
def replace_keywords(self, sentence): """Searches in the string for all keywords present in corpus. Keywords present are replaced by the clean name and a new string is returned. Args: sentence (str): Line of text where we will replace keywords Returns: new_sente...
def replace_keywords(self, sentence): """Searches in the string for all keywords present in corpus. Keywords present are replaced by the clean name and a new string is returned. Args: sentence (str): Line of text where we will replace keywords Returns: new_sente...
[ "Searches", "in", "the", "string", "for", "all", "keywords", "present", "in", "corpus", ".", "Keywords", "present", "are", "replaced", "by", "the", "clean", "name", "and", "a", "new", "string", "is", "returned", "." ]
vi3k6i5/flashtext
python
https://github.com/vi3k6i5/flashtext/blob/50c45f1f4a394572381249681046f57e2bf5a591/flashtext/keyword.py#L560-L681
[ "def", "replace_keywords", "(", "self", ",", "sentence", ")", ":", "if", "not", "sentence", ":", "# if sentence is empty or none just return the same.", "return", "sentence", "new_sentence", "=", "[", "]", "orig_sentence", "=", "sentence", "if", "not", "self", ".", ...
50c45f1f4a394572381249681046f57e2bf5a591
train
factor_information_coefficient
Computes the Spearman Rank Correlation based Information Coefficient (IC) between factor values and N period forward returns for each period in the factor index. Parameters ---------- factor_data : pd.DataFrame - MultiIndex A MultiIndex DataFrame indexed by date (level 0) and asset (level 1...
alphalens/performance.py
def factor_information_coefficient(factor_data, group_adjust=False, by_group=False): """ Computes the Spearman Rank Correlation based Information Coefficient (IC) between factor values and N period forward returns for each period in t...
def factor_information_coefficient(factor_data, group_adjust=False, by_group=False): """ Computes the Spearman Rank Correlation based Information Coefficient (IC) between factor values and N period forward returns for each period in t...
[ "Computes", "the", "Spearman", "Rank", "Correlation", "based", "Information", "Coefficient", "(", "IC", ")", "between", "factor", "values", "and", "N", "period", "forward", "returns", "for", "each", "period", "in", "the", "factor", "index", "." ]
quantopian/alphalens
python
https://github.com/quantopian/alphalens/blob/d43eac871bb061e956df936794d3dd514da99e44/alphalens/performance.py#L27-L73
[ "def", "factor_information_coefficient", "(", "factor_data", ",", "group_adjust", "=", "False", ",", "by_group", "=", "False", ")", ":", "def", "src_ic", "(", "group", ")", ":", "f", "=", "group", "[", "'factor'", "]", "_ic", "=", "group", "[", "utils", ...
d43eac871bb061e956df936794d3dd514da99e44
train
mean_information_coefficient
Get the mean information coefficient of specified groups. Answers questions like: What is the mean IC for each month? What is the mean IC for each group for our whole timerange? What is the mean IC for for each group, each week? Parameters ---------- factor_data : pd.DataFrame - MultiIndex ...
alphalens/performance.py
def mean_information_coefficient(factor_data, group_adjust=False, by_group=False, by_time=None): """ Get the mean information coefficient of specified groups. Answers questions like: What is the mean IC fo...
def mean_information_coefficient(factor_data, group_adjust=False, by_group=False, by_time=None): """ Get the mean information coefficient of specified groups. Answers questions like: What is the mean IC fo...
[ "Get", "the", "mean", "information", "coefficient", "of", "specified", "groups", ".", "Answers", "questions", "like", ":", "What", "is", "the", "mean", "IC", "for", "each", "month?", "What", "is", "the", "mean", "IC", "for", "each", "group", "for", "our", ...
quantopian/alphalens
python
https://github.com/quantopian/alphalens/blob/d43eac871bb061e956df936794d3dd514da99e44/alphalens/performance.py#L76-L125
[ "def", "mean_information_coefficient", "(", "factor_data", ",", "group_adjust", "=", "False", ",", "by_group", "=", "False", ",", "by_time", "=", "None", ")", ":", "ic", "=", "factor_information_coefficient", "(", "factor_data", ",", "group_adjust", ",", "by_group...
d43eac871bb061e956df936794d3dd514da99e44
train
factor_weights
Computes asset weights by factor values and dividing by the sum of their absolute value (achieving gross leverage of 1). Positive factor values will results in positive weights and negative values in negative weights. Parameters ---------- factor_data : pd.DataFrame - MultiIndex A MultiInde...
alphalens/performance.py
def factor_weights(factor_data, demeaned=True, group_adjust=False, equal_weight=False): """ Computes asset weights by factor values and dividing by the sum of their absolute value (achieving gross leverage of 1). Positive factor values will result...
def factor_weights(factor_data, demeaned=True, group_adjust=False, equal_weight=False): """ Computes asset weights by factor values and dividing by the sum of their absolute value (achieving gross leverage of 1). Positive factor values will result...
[ "Computes", "asset", "weights", "by", "factor", "values", "and", "dividing", "by", "the", "sum", "of", "their", "absolute", "value", "(", "achieving", "gross", "leverage", "of", "1", ")", ".", "Positive", "factor", "values", "will", "results", "in", "positiv...
quantopian/alphalens
python
https://github.com/quantopian/alphalens/blob/d43eac871bb061e956df936794d3dd514da99e44/alphalens/performance.py#L128-L204
[ "def", "factor_weights", "(", "factor_data", ",", "demeaned", "=", "True", ",", "group_adjust", "=", "False", ",", "equal_weight", "=", "False", ")", ":", "def", "to_weights", "(", "group", ",", "_demeaned", ",", "_equal_weight", ")", ":", "if", "_equal_weig...
d43eac871bb061e956df936794d3dd514da99e44
train
factor_returns
Computes period wise returns for portfolio weighted by factor values. Parameters ---------- factor_data : pd.DataFrame - MultiIndex A MultiIndex DataFrame indexed by date (level 0) and asset (level 1), containing the values for a single alpha factor, forward returns for each per...
alphalens/performance.py
def factor_returns(factor_data, demeaned=True, group_adjust=False, equal_weight=False, by_asset=False): """ Computes period wise returns for portfolio weighted by factor values. Parameters ---------- factor_data : pd.Da...
def factor_returns(factor_data, demeaned=True, group_adjust=False, equal_weight=False, by_asset=False): """ Computes period wise returns for portfolio weighted by factor values. Parameters ---------- factor_data : pd.Da...
[ "Computes", "period", "wise", "returns", "for", "portfolio", "weighted", "by", "factor", "values", "." ]
quantopian/alphalens
python
https://github.com/quantopian/alphalens/blob/d43eac871bb061e956df936794d3dd514da99e44/alphalens/performance.py#L207-L254
[ "def", "factor_returns", "(", "factor_data", ",", "demeaned", "=", "True", ",", "group_adjust", "=", "False", ",", "equal_weight", "=", "False", ",", "by_asset", "=", "False", ")", ":", "weights", "=", "factor_weights", "(", "factor_data", ",", "demeaned", "...
d43eac871bb061e956df936794d3dd514da99e44
train
factor_alpha_beta
Compute the alpha (excess returns), alpha t-stat (alpha significance), and beta (market exposure) of a factor. A regression is run with the period wise factor universe mean return as the independent variable and mean period wise return from a portfolio weighted by factor values as the dependent variable...
alphalens/performance.py
def factor_alpha_beta(factor_data, returns=None, demeaned=True, group_adjust=False, equal_weight=False): """ Compute the alpha (excess returns), alpha t-stat (alpha significance), and beta (market exposure) of a factor. ...
def factor_alpha_beta(factor_data, returns=None, demeaned=True, group_adjust=False, equal_weight=False): """ Compute the alpha (excess returns), alpha t-stat (alpha significance), and beta (market exposure) of a factor. ...
[ "Compute", "the", "alpha", "(", "excess", "returns", ")", "alpha", "t", "-", "stat", "(", "alpha", "significance", ")", "and", "beta", "(", "market", "exposure", ")", "of", "a", "factor", ".", "A", "regression", "is", "run", "with", "the", "period", "w...
quantopian/alphalens
python
https://github.com/quantopian/alphalens/blob/d43eac871bb061e956df936794d3dd514da99e44/alphalens/performance.py#L257-L329
[ "def", "factor_alpha_beta", "(", "factor_data", ",", "returns", "=", "None", ",", "demeaned", "=", "True", ",", "group_adjust", "=", "False", ",", "equal_weight", "=", "False", ")", ":", "if", "returns", "is", "None", ":", "returns", "=", "factor_returns", ...
d43eac871bb061e956df936794d3dd514da99e44
train
cumulative_returns
Builds cumulative returns from 'period' returns. This function simulates the cumulative effect that a series of gains or losses (the 'returns') have on an original amount of capital over a period of time. if F is the frequency at which returns are computed (e.g. 1 day if 'returns' contains daily values...
alphalens/performance.py
def cumulative_returns(returns, period, freq=None): """ Builds cumulative returns from 'period' returns. This function simulates the cumulative effect that a series of gains or losses (the 'returns') have on an original amount of capital over a period of time. if F is the frequency at which returns...
def cumulative_returns(returns, period, freq=None): """ Builds cumulative returns from 'period' returns. This function simulates the cumulative effect that a series of gains or losses (the 'returns') have on an original amount of capital over a period of time. if F is the frequency at which returns...
[ "Builds", "cumulative", "returns", "from", "period", "returns", ".", "This", "function", "simulates", "the", "cumulative", "effect", "that", "a", "series", "of", "gains", "or", "losses", "(", "the", "returns", ")", "have", "on", "an", "original", "amount", "...
quantopian/alphalens
python
https://github.com/quantopian/alphalens/blob/d43eac871bb061e956df936794d3dd514da99e44/alphalens/performance.py#L332-L494
[ "def", "cumulative_returns", "(", "returns", ",", "period", ",", "freq", "=", "None", ")", ":", "if", "not", "isinstance", "(", "period", ",", "pd", ".", "Timedelta", ")", ":", "period", "=", "pd", ".", "Timedelta", "(", "period", ")", "if", "freq", ...
d43eac871bb061e956df936794d3dd514da99e44
train
positions
Builds net position values time series, the portfolio percentage invested in each position. Parameters ---------- weights: pd.Series pd.Series containing factor weights, the index contains timestamps at which the trades are computed and the values correspond to assets weights ...
alphalens/performance.py
def positions(weights, period, freq=None): """ Builds net position values time series, the portfolio percentage invested in each position. Parameters ---------- weights: pd.Series pd.Series containing factor weights, the index contains timestamps at which the trades are computed...
def positions(weights, period, freq=None): """ Builds net position values time series, the portfolio percentage invested in each position. Parameters ---------- weights: pd.Series pd.Series containing factor weights, the index contains timestamps at which the trades are computed...
[ "Builds", "net", "position", "values", "time", "series", "the", "portfolio", "percentage", "invested", "in", "each", "position", "." ]
quantopian/alphalens
python
https://github.com/quantopian/alphalens/blob/d43eac871bb061e956df936794d3dd514da99e44/alphalens/performance.py#L497-L592
[ "def", "positions", "(", "weights", ",", "period", ",", "freq", "=", "None", ")", ":", "weights", "=", "weights", ".", "unstack", "(", ")", "if", "not", "isinstance", "(", "period", ",", "pd", ".", "Timedelta", ")", ":", "period", "=", "pd", ".", "...
d43eac871bb061e956df936794d3dd514da99e44
train
mean_return_by_quantile
Computes mean returns for factor quantiles across provided forward returns columns. Parameters ---------- factor_data : pd.DataFrame - MultiIndex A MultiIndex DataFrame indexed by date (level 0) and asset (level 1), containing the values for a single alpha factor, forward returns for ...
alphalens/performance.py
def mean_return_by_quantile(factor_data, by_date=False, by_group=False, demeaned=True, group_adjust=False): """ Computes mean returns for factor quantiles across provided forward returns columns. ...
def mean_return_by_quantile(factor_data, by_date=False, by_group=False, demeaned=True, group_adjust=False): """ Computes mean returns for factor quantiles across provided forward returns columns. ...
[ "Computes", "mean", "returns", "for", "factor", "quantiles", "across", "provided", "forward", "returns", "columns", "." ]
quantopian/alphalens
python
https://github.com/quantopian/alphalens/blob/d43eac871bb061e956df936794d3dd514da99e44/alphalens/performance.py#L595-L659
[ "def", "mean_return_by_quantile", "(", "factor_data", ",", "by_date", "=", "False", ",", "by_group", "=", "False", ",", "demeaned", "=", "True", ",", "group_adjust", "=", "False", ")", ":", "if", "group_adjust", ":", "grouper", "=", "[", "factor_data", ".", ...
d43eac871bb061e956df936794d3dd514da99e44
train
compute_mean_returns_spread
Computes the difference between the mean returns of two quantiles. Optionally, computes the standard error of this difference. Parameters ---------- mean_returns : pd.DataFrame DataFrame of mean period wise returns by quantile. MultiIndex containing date and quantile. See me...
alphalens/performance.py
def compute_mean_returns_spread(mean_returns, upper_quant, lower_quant, std_err=None): """ Computes the difference between the mean returns of two quantiles. Optionally, computes the standard error of this di...
def compute_mean_returns_spread(mean_returns, upper_quant, lower_quant, std_err=None): """ Computes the difference between the mean returns of two quantiles. Optionally, computes the standard error of this di...
[ "Computes", "the", "difference", "between", "the", "mean", "returns", "of", "two", "quantiles", ".", "Optionally", "computes", "the", "standard", "error", "of", "this", "difference", "." ]
quantopian/alphalens
python
https://github.com/quantopian/alphalens/blob/d43eac871bb061e956df936794d3dd514da99e44/alphalens/performance.py#L662-L707
[ "def", "compute_mean_returns_spread", "(", "mean_returns", ",", "upper_quant", ",", "lower_quant", ",", "std_err", "=", "None", ")", ":", "mean_return_difference", "=", "mean_returns", ".", "xs", "(", "upper_quant", ",", "level", "=", "'factor_quantile'", ")", "-"...
d43eac871bb061e956df936794d3dd514da99e44
train
quantile_turnover
Computes the proportion of names in a factor quantile that were not in that quantile in the previous period. Parameters ---------- quantile_factor : pd.Series DataFrame with date, asset and factor quantile. quantile : int Quantile on which to perform turnover analysis. period: s...
alphalens/performance.py
def quantile_turnover(quantile_factor, quantile, period=1): """ Computes the proportion of names in a factor quantile that were not in that quantile in the previous period. Parameters ---------- quantile_factor : pd.Series DataFrame with date, asset and factor quantile. quantile : i...
def quantile_turnover(quantile_factor, quantile, period=1): """ Computes the proportion of names in a factor quantile that were not in that quantile in the previous period. Parameters ---------- quantile_factor : pd.Series DataFrame with date, asset and factor quantile. quantile : i...
[ "Computes", "the", "proportion", "of", "names", "in", "a", "factor", "quantile", "that", "were", "not", "in", "that", "quantile", "in", "the", "previous", "period", "." ]
quantopian/alphalens
python
https://github.com/quantopian/alphalens/blob/d43eac871bb061e956df936794d3dd514da99e44/alphalens/performance.py#L710-L748
[ "def", "quantile_turnover", "(", "quantile_factor", ",", "quantile", ",", "period", "=", "1", ")", ":", "quant_names", "=", "quantile_factor", "[", "quantile_factor", "==", "quantile", "]", "quant_name_sets", "=", "quant_names", ".", "groupby", "(", "level", "="...
d43eac871bb061e956df936794d3dd514da99e44
train
factor_rank_autocorrelation
Computes autocorrelation of mean factor ranks in specified time spans. We must compare period to period factor ranks rather than factor values to account for systematic shifts in the factor values of all names or names within a group. This metric is useful for measuring the turnover of a factor. If the ...
alphalens/performance.py
def factor_rank_autocorrelation(factor_data, period=1): """ Computes autocorrelation of mean factor ranks in specified time spans. We must compare period to period factor ranks rather than factor values to account for systematic shifts in the factor values of all names or names within a group. This ...
def factor_rank_autocorrelation(factor_data, period=1): """ Computes autocorrelation of mean factor ranks in specified time spans. We must compare period to period factor ranks rather than factor values to account for systematic shifts in the factor values of all names or names within a group. This ...
[ "Computes", "autocorrelation", "of", "mean", "factor", "ranks", "in", "specified", "time", "spans", ".", "We", "must", "compare", "period", "to", "period", "factor", "ranks", "rather", "than", "factor", "values", "to", "account", "for", "systematic", "shifts", ...
quantopian/alphalens
python
https://github.com/quantopian/alphalens/blob/d43eac871bb061e956df936794d3dd514da99e44/alphalens/performance.py#L751-L799
[ "def", "factor_rank_autocorrelation", "(", "factor_data", ",", "period", "=", "1", ")", ":", "grouper", "=", "[", "factor_data", ".", "index", ".", "get_level_values", "(", "'date'", ")", "]", "ranks", "=", "factor_data", ".", "groupby", "(", "grouper", ")",...
d43eac871bb061e956df936794d3dd514da99e44
train
common_start_returns
A date and equity pair is extracted from each index row in the factor dataframe and for each of these pairs a return series is built starting from 'before' the date and ending 'after' the date specified in the pair. All those returns series are then aligned to a common index (-before to after) and retur...
alphalens/performance.py
def common_start_returns(factor, prices, before, after, cumulative=False, mean_by_date=False, demean_by=None): """ A date and equity pair is extracted from each i...
def common_start_returns(factor, prices, before, after, cumulative=False, mean_by_date=False, demean_by=None): """ A date and equity pair is extracted from each i...
[ "A", "date", "and", "equity", "pair", "is", "extracted", "from", "each", "index", "row", "in", "the", "factor", "dataframe", "and", "for", "each", "of", "these", "pairs", "a", "return", "series", "is", "built", "starting", "from", "before", "the", "date", ...
quantopian/alphalens
python
https://github.com/quantopian/alphalens/blob/d43eac871bb061e956df936794d3dd514da99e44/alphalens/performance.py#L802-L892
[ "def", "common_start_returns", "(", "factor", ",", "prices", ",", "before", ",", "after", ",", "cumulative", "=", "False", ",", "mean_by_date", "=", "False", ",", "demean_by", "=", "None", ")", ":", "if", "cumulative", ":", "returns", "=", "prices", "else"...
d43eac871bb061e956df936794d3dd514da99e44
train
average_cumulative_return_by_quantile
Plots average cumulative returns by factor quantiles in the period range defined by -periods_before to periods_after Parameters ---------- factor_data : pd.DataFrame - MultiIndex A MultiIndex DataFrame indexed by date (level 0) and asset (level 1), containing the values for a single alp...
alphalens/performance.py
def average_cumulative_return_by_quantile(factor_data, prices, periods_before=10, periods_after=15, demeaned=True, ...
def average_cumulative_return_by_quantile(factor_data, prices, periods_before=10, periods_after=15, demeaned=True, ...
[ "Plots", "average", "cumulative", "returns", "by", "factor", "quantiles", "in", "the", "period", "range", "defined", "by", "-", "periods_before", "to", "periods_after" ]
quantopian/alphalens
python
https://github.com/quantopian/alphalens/blob/d43eac871bb061e956df936794d3dd514da99e44/alphalens/performance.py#L895-L1018
[ "def", "average_cumulative_return_by_quantile", "(", "factor_data", ",", "prices", ",", "periods_before", "=", "10", ",", "periods_after", "=", "15", ",", "demeaned", "=", "True", ",", "group_adjust", "=", "False", ",", "by_group", "=", "False", ")", ":", "def...
d43eac871bb061e956df936794d3dd514da99e44
train
factor_cumulative_returns
Simulate a portfolio using the factor in input and returns the cumulative returns of the simulated portfolio Parameters ---------- factor_data : pd.DataFrame - MultiIndex A MultiIndex DataFrame indexed by date (level 0) and asset (level 1), containing the values for a single alpha facto...
alphalens/performance.py
def factor_cumulative_returns(factor_data, period, long_short=True, group_neutral=False, equal_weight=False, quantiles=None, groups=None): ...
def factor_cumulative_returns(factor_data, period, long_short=True, group_neutral=False, equal_weight=False, quantiles=None, groups=None): ...
[ "Simulate", "a", "portfolio", "using", "the", "factor", "in", "input", "and", "returns", "the", "cumulative", "returns", "of", "the", "simulated", "portfolio" ]
quantopian/alphalens
python
https://github.com/quantopian/alphalens/blob/d43eac871bb061e956df936794d3dd514da99e44/alphalens/performance.py#L1021-L1088
[ "def", "factor_cumulative_returns", "(", "factor_data", ",", "period", ",", "long_short", "=", "True", ",", "group_neutral", "=", "False", ",", "equal_weight", "=", "False", ",", "quantiles", "=", "None", ",", "groups", "=", "None", ")", ":", "fwd_ret_cols", ...
d43eac871bb061e956df936794d3dd514da99e44
train
factor_positions
Simulate a portfolio using the factor in input and returns the assets positions as percentage of the total portfolio. Parameters ---------- factor_data : pd.DataFrame - MultiIndex A MultiIndex DataFrame indexed by date (level 0) and asset (level 1), containing the values for a single al...
alphalens/performance.py
def factor_positions(factor_data, period, long_short=True, group_neutral=False, equal_weight=False, quantiles=None, groups=None): """ Simulate a portfolio using the factor in input and r...
def factor_positions(factor_data, period, long_short=True, group_neutral=False, equal_weight=False, quantiles=None, groups=None): """ Simulate a portfolio using the factor in input and r...
[ "Simulate", "a", "portfolio", "using", "the", "factor", "in", "input", "and", "returns", "the", "assets", "positions", "as", "percentage", "of", "the", "total", "portfolio", "." ]
quantopian/alphalens
python
https://github.com/quantopian/alphalens/blob/d43eac871bb061e956df936794d3dd514da99e44/alphalens/performance.py#L1091-L1160
[ "def", "factor_positions", "(", "factor_data", ",", "period", ",", "long_short", "=", "True", ",", "group_neutral", "=", "False", ",", "equal_weight", "=", "False", ",", "quantiles", "=", "None", ",", "groups", "=", "None", ")", ":", "fwd_ret_cols", "=", "...
d43eac871bb061e956df936794d3dd514da99e44
train
create_pyfolio_input
Simulate a portfolio using the input factor and returns the portfolio performance data properly formatted for Pyfolio analysis. For more details on how this portfolio is built see: - performance.cumulative_returns (how the portfolio returns are computed) - performance.factor_weights (how assets weights...
alphalens/performance.py
def create_pyfolio_input(factor_data, period, capital=None, long_short=True, group_neutral=False, equal_weight=False, quantiles=None, groups=None...
def create_pyfolio_input(factor_data, period, capital=None, long_short=True, group_neutral=False, equal_weight=False, quantiles=None, groups=None...
[ "Simulate", "a", "portfolio", "using", "the", "input", "factor", "and", "returns", "the", "portfolio", "performance", "data", "properly", "formatted", "for", "Pyfolio", "analysis", "." ]
quantopian/alphalens
python
https://github.com/quantopian/alphalens/blob/d43eac871bb061e956df936794d3dd514da99e44/alphalens/performance.py#L1163-L1320
[ "def", "create_pyfolio_input", "(", "factor_data", ",", "period", ",", "capital", "=", "None", ",", "long_short", "=", "True", ",", "group_neutral", "=", "False", ",", "equal_weight", "=", "False", ",", "quantiles", "=", "None", ",", "groups", "=", "None", ...
d43eac871bb061e956df936794d3dd514da99e44
train
create_summary_tear_sheet
Creates a small summary tear sheet with returns, information, and turnover analysis. Parameters ---------- factor_data : pd.DataFrame - MultiIndex A MultiIndex DataFrame indexed by date (level 0) and asset (level 1), containing the values for a single alpha factor, forward returns for ...
alphalens/tears.py
def create_summary_tear_sheet(factor_data, long_short=True, group_neutral=False): """ Creates a small summary tear sheet with returns, information, and turnover analysis. Parameters ---------- factor_data : pd.DataFrame - MultiIndex ...
def create_summary_tear_sheet(factor_data, long_short=True, group_neutral=False): """ Creates a small summary tear sheet with returns, information, and turnover analysis. Parameters ---------- factor_data : pd.DataFrame - MultiIndex ...
[ "Creates", "a", "small", "summary", "tear", "sheet", "with", "returns", "information", "and", "turnover", "analysis", "." ]
quantopian/alphalens
python
https://github.com/quantopian/alphalens/blob/d43eac871bb061e956df936794d3dd514da99e44/alphalens/tears.py#L63-L162
[ "def", "create_summary_tear_sheet", "(", "factor_data", ",", "long_short", "=", "True", ",", "group_neutral", "=", "False", ")", ":", "# Returns Analysis", "mean_quant_ret", ",", "std_quantile", "=", "perf", ".", "mean_return_by_quantile", "(", "factor_data", ",", "...
d43eac871bb061e956df936794d3dd514da99e44
train
create_returns_tear_sheet
Creates a tear sheet for returns analysis of a factor. Parameters ---------- factor_data : pd.DataFrame - MultiIndex A MultiIndex DataFrame indexed by date (level 0) and asset (level 1), containing the values for a single alpha factor, forward returns for each period, the factor qua...
alphalens/tears.py
def create_returns_tear_sheet(factor_data, long_short=True, group_neutral=False, by_group=False): """ Creates a tear sheet for returns analysis of a factor. Parameters ---------- factor_data : pd.DataFrame - M...
def create_returns_tear_sheet(factor_data, long_short=True, group_neutral=False, by_group=False): """ Creates a tear sheet for returns analysis of a factor. Parameters ---------- factor_data : pd.DataFrame - M...
[ "Creates", "a", "tear", "sheet", "for", "returns", "analysis", "of", "a", "factor", "." ]
quantopian/alphalens
python
https://github.com/quantopian/alphalens/blob/d43eac871bb061e956df936794d3dd514da99e44/alphalens/tears.py#L166-L321
[ "def", "create_returns_tear_sheet", "(", "factor_data", ",", "long_short", "=", "True", ",", "group_neutral", "=", "False", ",", "by_group", "=", "False", ")", ":", "factor_returns", "=", "perf", ".", "factor_returns", "(", "factor_data", ",", "long_short", ",",...
d43eac871bb061e956df936794d3dd514da99e44
train
create_information_tear_sheet
Creates a tear sheet for information analysis of a factor. Parameters ---------- factor_data : pd.DataFrame - MultiIndex A MultiIndex DataFrame indexed by date (level 0) and asset (level 1), containing the values for a single alpha factor, forward returns for each period, the factor...
alphalens/tears.py
def create_information_tear_sheet(factor_data, group_neutral=False, by_group=False): """ Creates a tear sheet for information analysis of a factor. Parameters ---------- factor_data : pd.DataFrame - MultiIndex A MultiIndex ...
def create_information_tear_sheet(factor_data, group_neutral=False, by_group=False): """ Creates a tear sheet for information analysis of a factor. Parameters ---------- factor_data : pd.DataFrame - MultiIndex A MultiIndex ...
[ "Creates", "a", "tear", "sheet", "for", "information", "analysis", "of", "a", "factor", "." ]
quantopian/alphalens
python
https://github.com/quantopian/alphalens/blob/d43eac871bb061e956df936794d3dd514da99e44/alphalens/tears.py#L325-L382
[ "def", "create_information_tear_sheet", "(", "factor_data", ",", "group_neutral", "=", "False", ",", "by_group", "=", "False", ")", ":", "ic", "=", "perf", ".", "factor_information_coefficient", "(", "factor_data", ",", "group_neutral", ")", "plotting", ".", "plot...
d43eac871bb061e956df936794d3dd514da99e44
train
create_turnover_tear_sheet
Creates a tear sheet for analyzing the turnover properties of a factor. Parameters ---------- factor_data : pd.DataFrame - MultiIndex A MultiIndex DataFrame indexed by date (level 0) and asset (level 1), containing the values for a single alpha factor, forward returns for each perio...
alphalens/tears.py
def create_turnover_tear_sheet(factor_data, turnover_periods=None): """ Creates a tear sheet for analyzing the turnover properties of a factor. Parameters ---------- factor_data : pd.DataFrame - MultiIndex A MultiIndex DataFrame indexed by date (level 0) and asset (level 1), contain...
def create_turnover_tear_sheet(factor_data, turnover_periods=None): """ Creates a tear sheet for analyzing the turnover properties of a factor. Parameters ---------- factor_data : pd.DataFrame - MultiIndex A MultiIndex DataFrame indexed by date (level 0) and asset (level 1), contain...
[ "Creates", "a", "tear", "sheet", "for", "analyzing", "the", "turnover", "properties", "of", "a", "factor", "." ]
quantopian/alphalens
python
https://github.com/quantopian/alphalens/blob/d43eac871bb061e956df936794d3dd514da99e44/alphalens/tears.py#L386-L446
[ "def", "create_turnover_tear_sheet", "(", "factor_data", ",", "turnover_periods", "=", "None", ")", ":", "if", "turnover_periods", "is", "None", ":", "turnover_periods", "=", "utils", ".", "get_forward_returns_columns", "(", "factor_data", ".", "columns", ")", "quan...
d43eac871bb061e956df936794d3dd514da99e44
train
create_full_tear_sheet
Creates a full tear sheet for analysis and evaluating single return predicting (alpha) factor. Parameters ---------- factor_data : pd.DataFrame - MultiIndex A MultiIndex DataFrame indexed by date (level 0) and asset (level 1), containing the values for a single alpha factor, forward ret...
alphalens/tears.py
def create_full_tear_sheet(factor_data, long_short=True, group_neutral=False, by_group=False): """ Creates a full tear sheet for analysis and evaluating single return predicting (alpha) factor. Parameters ---------- ...
def create_full_tear_sheet(factor_data, long_short=True, group_neutral=False, by_group=False): """ Creates a full tear sheet for analysis and evaluating single return predicting (alpha) factor. Parameters ---------- ...
[ "Creates", "a", "full", "tear", "sheet", "for", "analysis", "and", "evaluating", "single", "return", "predicting", "(", "alpha", ")", "factor", "." ]
quantopian/alphalens
python
https://github.com/quantopian/alphalens/blob/d43eac871bb061e956df936794d3dd514da99e44/alphalens/tears.py#L450-L490
[ "def", "create_full_tear_sheet", "(", "factor_data", ",", "long_short", "=", "True", ",", "group_neutral", "=", "False", ",", "by_group", "=", "False", ")", ":", "plotting", ".", "plot_quantile_statistics_table", "(", "factor_data", ")", "create_returns_tear_sheet", ...
d43eac871bb061e956df936794d3dd514da99e44
train
create_event_returns_tear_sheet
Creates a tear sheet to view the average cumulative returns for a factor within a window (pre and post event). Parameters ---------- factor_data : pd.DataFrame - MultiIndex A MultiIndex Series indexed by date (level 0) and asset (level 1), containing the values for a single alpha factor...
alphalens/tears.py
def create_event_returns_tear_sheet(factor_data, prices, avgretplot=(5, 15), long_short=True, group_neutral=False, std_bar=True, ...
def create_event_returns_tear_sheet(factor_data, prices, avgretplot=(5, 15), long_short=True, group_neutral=False, std_bar=True, ...
[ "Creates", "a", "tear", "sheet", "to", "view", "the", "average", "cumulative", "returns", "for", "a", "factor", "within", "a", "window", "(", "pre", "and", "post", "event", ")", "." ]
quantopian/alphalens
python
https://github.com/quantopian/alphalens/blob/d43eac871bb061e956df936794d3dd514da99e44/alphalens/tears.py#L494-L591
[ "def", "create_event_returns_tear_sheet", "(", "factor_data", ",", "prices", ",", "avgretplot", "=", "(", "5", ",", "15", ")", ",", "long_short", "=", "True", ",", "group_neutral", "=", "False", ",", "std_bar", "=", "True", ",", "by_group", "=", "False", "...
d43eac871bb061e956df936794d3dd514da99e44
train
create_event_study_tear_sheet
Creates an event study tear sheet for analysis of a specific event. Parameters ---------- factor_data : pd.DataFrame - MultiIndex A MultiIndex DataFrame indexed by date (level 0) and asset (level 1), containing the values for a single event, forward returns for each period, the fact...
alphalens/tears.py
def create_event_study_tear_sheet(factor_data, prices=None, avgretplot=(5, 15), rate_of_ret=True, n_bars=50): """ Creates an event study tear sheet for analysis of a specific e...
def create_event_study_tear_sheet(factor_data, prices=None, avgretplot=(5, 15), rate_of_ret=True, n_bars=50): """ Creates an event study tear sheet for analysis of a specific e...
[ "Creates", "an", "event", "study", "tear", "sheet", "for", "analysis", "of", "a", "specific", "event", "." ]
quantopian/alphalens
python
https://github.com/quantopian/alphalens/blob/d43eac871bb061e956df936794d3dd514da99e44/alphalens/tears.py#L595-L701
[ "def", "create_event_study_tear_sheet", "(", "factor_data", ",", "prices", "=", "None", ",", "avgretplot", "=", "(", "5", ",", "15", ")", ",", "rate_of_ret", "=", "True", ",", "n_bars", "=", "50", ")", ":", "long_short", "=", "False", "plotting", ".", "p...
d43eac871bb061e956df936794d3dd514da99e44
train
rethrow
Re-raise the last exception that was active in the current scope without losing the stacktrace but adding an additional message. This is hacky because it has to be compatible with both python 2/3
alphalens/utils.py
def rethrow(exception, additional_message): """ Re-raise the last exception that was active in the current scope without losing the stacktrace but adding an additional message. This is hacky because it has to be compatible with both python 2/3 """ e = exception m = additional_message if ...
def rethrow(exception, additional_message): """ Re-raise the last exception that was active in the current scope without losing the stacktrace but adding an additional message. This is hacky because it has to be compatible with both python 2/3 """ e = exception m = additional_message if ...
[ "Re", "-", "raise", "the", "last", "exception", "that", "was", "active", "in", "the", "current", "scope", "without", "losing", "the", "stacktrace", "but", "adding", "an", "additional", "message", ".", "This", "is", "hacky", "because", "it", "has", "to", "b...
quantopian/alphalens
python
https://github.com/quantopian/alphalens/blob/d43eac871bb061e956df936794d3dd514da99e44/alphalens/utils.py#L33-L45
[ "def", "rethrow", "(", "exception", ",", "additional_message", ")", ":", "e", "=", "exception", "m", "=", "additional_message", "if", "not", "e", ".", "args", ":", "e", ".", "args", "=", "(", "m", ",", ")", "else", ":", "e", ".", "args", "=", "(", ...
d43eac871bb061e956df936794d3dd514da99e44
train
non_unique_bin_edges_error
Give user a more informative error in case it is not possible to properly calculate quantiles on the input dataframe (factor)
alphalens/utils.py
def non_unique_bin_edges_error(func): """ Give user a more informative error in case it is not possible to properly calculate quantiles on the input dataframe (factor) """ message = """ An error occurred while computing bins/quantiles on the input provided. This usually happens when the inp...
def non_unique_bin_edges_error(func): """ Give user a more informative error in case it is not possible to properly calculate quantiles on the input dataframe (factor) """ message = """ An error occurred while computing bins/quantiles on the input provided. This usually happens when the inp...
[ "Give", "user", "a", "more", "informative", "error", "in", "case", "it", "is", "not", "possible", "to", "properly", "calculate", "quantiles", "on", "the", "input", "dataframe", "(", "factor", ")" ]
quantopian/alphalens
python
https://github.com/quantopian/alphalens/blob/d43eac871bb061e956df936794d3dd514da99e44/alphalens/utils.py#L48-L80
[ "def", "non_unique_bin_edges_error", "(", "func", ")", ":", "message", "=", "\"\"\"\n\n An error occurred while computing bins/quantiles on the input provided.\n This usually happens when the input contains too many identical\n values and they span more than one quantile. The quantiles are ...
d43eac871bb061e956df936794d3dd514da99e44
train
quantize_factor
Computes period wise factor quantiles. Parameters ---------- factor_data : pd.DataFrame - MultiIndex A MultiIndex DataFrame indexed by date (level 0) and asset (level 1), containing the values for a single alpha factor, forward returns for each period, the factor quantile/bin that f...
alphalens/utils.py
def quantize_factor(factor_data, quantiles=5, bins=None, by_group=False, no_raise=False, zero_aware=False): """ Computes period wise factor quantiles. Parameters ---------- factor_data : pd.DataFrame...
def quantize_factor(factor_data, quantiles=5, bins=None, by_group=False, no_raise=False, zero_aware=False): """ Computes period wise factor quantiles. Parameters ---------- factor_data : pd.DataFrame...
[ "Computes", "period", "wise", "factor", "quantiles", "." ]
quantopian/alphalens
python
https://github.com/quantopian/alphalens/blob/d43eac871bb061e956df936794d3dd514da99e44/alphalens/utils.py#L84-L169
[ "def", "quantize_factor", "(", "factor_data", ",", "quantiles", "=", "5", ",", "bins", "=", "None", ",", "by_group", "=", "False", ",", "no_raise", "=", "False", ",", "zero_aware", "=", "False", ")", ":", "if", "not", "(", "(", "quantiles", "is", "not"...
d43eac871bb061e956df936794d3dd514da99e44
train
infer_trading_calendar
Infer the trading calendar from factor and price information. Parameters ---------- factor_idx : pd.DatetimeIndex The factor datetimes for which we are computing the forward returns prices_idx : pd.DatetimeIndex The prices datetimes associated withthe factor data Returns ------...
alphalens/utils.py
def infer_trading_calendar(factor_idx, prices_idx): """ Infer the trading calendar from factor and price information. Parameters ---------- factor_idx : pd.DatetimeIndex The factor datetimes for which we are computing the forward returns prices_idx : pd.DatetimeIndex The prices ...
def infer_trading_calendar(factor_idx, prices_idx): """ Infer the trading calendar from factor and price information. Parameters ---------- factor_idx : pd.DatetimeIndex The factor datetimes for which we are computing the forward returns prices_idx : pd.DatetimeIndex The prices ...
[ "Infer", "the", "trading", "calendar", "from", "factor", "and", "price", "information", "." ]
quantopian/alphalens
python
https://github.com/quantopian/alphalens/blob/d43eac871bb061e956df936794d3dd514da99e44/alphalens/utils.py#L172-L212
[ "def", "infer_trading_calendar", "(", "factor_idx", ",", "prices_idx", ")", ":", "full_idx", "=", "factor_idx", ".", "union", "(", "prices_idx", ")", "traded_weekdays", "=", "[", "]", "holidays", "=", "[", "]", "days_of_the_week", "=", "[", "'Mon'", ",", "'T...
d43eac871bb061e956df936794d3dd514da99e44
train
compute_forward_returns
Finds the N period forward returns (as percent change) for each asset provided. Parameters ---------- factor : pd.Series - MultiIndex A MultiIndex Series indexed by timestamp (level 0) and asset (level 1), containing the values for a single alpha factor. - See full explanation ...
alphalens/utils.py
def compute_forward_returns(factor, prices, periods=(1, 5, 10), filter_zscore=None, cumulative_returns=True): """ Finds the N period forward returns (as percent change) for each asset provided. ...
def compute_forward_returns(factor, prices, periods=(1, 5, 10), filter_zscore=None, cumulative_returns=True): """ Finds the N period forward returns (as percent change) for each asset provided. ...
[ "Finds", "the", "N", "period", "forward", "returns", "(", "as", "percent", "change", ")", "for", "each", "asset", "provided", "." ]
quantopian/alphalens
python
https://github.com/quantopian/alphalens/blob/d43eac871bb061e956df936794d3dd514da99e44/alphalens/utils.py#L215-L343
[ "def", "compute_forward_returns", "(", "factor", ",", "prices", ",", "periods", "=", "(", "1", ",", "5", ",", "10", ")", ",", "filter_zscore", "=", "None", ",", "cumulative_returns", "=", "True", ")", ":", "factor_dateindex", "=", "factor", ".", "index", ...
d43eac871bb061e956df936794d3dd514da99e44
train
demean_forward_returns
Convert forward returns to returns relative to mean period wise all-universe or group returns. group-wise normalization incorporates the assumption of a group neutral portfolio constraint and thus allows allows the factor to be evaluated across groups. For example, if AAPL 5 period return is 0.1% a...
alphalens/utils.py
def demean_forward_returns(factor_data, grouper=None): """ Convert forward returns to returns relative to mean period wise all-universe or group returns. group-wise normalization incorporates the assumption of a group neutral portfolio constraint and thus allows allows the factor to be evaluated...
def demean_forward_returns(factor_data, grouper=None): """ Convert forward returns to returns relative to mean period wise all-universe or group returns. group-wise normalization incorporates the assumption of a group neutral portfolio constraint and thus allows allows the factor to be evaluated...
[ "Convert", "forward", "returns", "to", "returns", "relative", "to", "mean", "period", "wise", "all", "-", "universe", "or", "group", "returns", ".", "group", "-", "wise", "normalization", "incorporates", "the", "assumption", "of", "a", "group", "neutral", "por...
quantopian/alphalens
python
https://github.com/quantopian/alphalens/blob/d43eac871bb061e956df936794d3dd514da99e44/alphalens/utils.py#L346-L383
[ "def", "demean_forward_returns", "(", "factor_data", ",", "grouper", "=", "None", ")", ":", "factor_data", "=", "factor_data", ".", "copy", "(", ")", "if", "not", "grouper", ":", "grouper", "=", "factor_data", ".", "index", ".", "get_level_values", "(", "'da...
d43eac871bb061e956df936794d3dd514da99e44
train
print_table
Pretty print a pandas DataFrame. Uses HTML output if running inside Jupyter Notebook, otherwise formatted text output. Parameters ---------- table : pd.Series or pd.DataFrame Table to pretty-print. name : str, optional Table name to display in upper left corner. fmt : str, ...
alphalens/utils.py
def print_table(table, name=None, fmt=None): """ Pretty print a pandas DataFrame. Uses HTML output if running inside Jupyter Notebook, otherwise formatted text output. Parameters ---------- table : pd.Series or pd.DataFrame Table to pretty-print. name : str, optional Ta...
def print_table(table, name=None, fmt=None): """ Pretty print a pandas DataFrame. Uses HTML output if running inside Jupyter Notebook, otherwise formatted text output. Parameters ---------- table : pd.Series or pd.DataFrame Table to pretty-print. name : str, optional Ta...
[ "Pretty", "print", "a", "pandas", "DataFrame", "." ]
quantopian/alphalens
python
https://github.com/quantopian/alphalens/blob/d43eac871bb061e956df936794d3dd514da99e44/alphalens/utils.py#L386-L417
[ "def", "print_table", "(", "table", ",", "name", "=", "None", ",", "fmt", "=", "None", ")", ":", "if", "isinstance", "(", "table", ",", "pd", ".", "Series", ")", ":", "table", "=", "pd", ".", "DataFrame", "(", "table", ")", "if", "isinstance", "(",...
d43eac871bb061e956df936794d3dd514da99e44
train
get_clean_factor
Formats the factor data, forward return data, and group mappings into a DataFrame that contains aligned MultiIndex indices of timestamp and asset. The returned data will be formatted to be suitable for Alphalens functions. It is safe to skip a call to this function and still make use of Alphalens funct...
alphalens/utils.py
def get_clean_factor(factor, forward_returns, groupby=None, binning_by_group=False, quantiles=5, bins=None, groupby_labels=None, max_loss=0.35, zero_awa...
def get_clean_factor(factor, forward_returns, groupby=None, binning_by_group=False, quantiles=5, bins=None, groupby_labels=None, max_loss=0.35, zero_awa...
[ "Formats", "the", "factor", "data", "forward", "return", "data", "and", "group", "mappings", "into", "a", "DataFrame", "that", "contains", "aligned", "MultiIndex", "indices", "of", "timestamp", "and", "asset", ".", "The", "returned", "data", "will", "be", "for...
quantopian/alphalens
python
https://github.com/quantopian/alphalens/blob/d43eac871bb061e956df936794d3dd514da99e44/alphalens/utils.py#L420-L629
[ "def", "get_clean_factor", "(", "factor", ",", "forward_returns", ",", "groupby", "=", "None", ",", "binning_by_group", "=", "False", ",", "quantiles", "=", "5", ",", "bins", "=", "None", ",", "groupby_labels", "=", "None", ",", "max_loss", "=", "0.35", ",...
d43eac871bb061e956df936794d3dd514da99e44
train
get_clean_factor_and_forward_returns
Formats the factor data, pricing data, and group mappings into a DataFrame that contains aligned MultiIndex indices of timestamp and asset. The returned data will be formatted to be suitable for Alphalens functions. It is safe to skip a call to this function and still make use of Alphalens functionalit...
alphalens/utils.py
def get_clean_factor_and_forward_returns(factor, prices, groupby=None, binning_by_group=False, quantiles=5, bins=No...
def get_clean_factor_and_forward_returns(factor, prices, groupby=None, binning_by_group=False, quantiles=5, bins=No...
[ "Formats", "the", "factor", "data", "pricing", "data", "and", "group", "mappings", "into", "a", "DataFrame", "that", "contains", "aligned", "MultiIndex", "indices", "of", "timestamp", "and", "asset", ".", "The", "returned", "data", "will", "be", "formatted", "...
quantopian/alphalens
python
https://github.com/quantopian/alphalens/blob/d43eac871bb061e956df936794d3dd514da99e44/alphalens/utils.py#L632-L799
[ "def", "get_clean_factor_and_forward_returns", "(", "factor", ",", "prices", ",", "groupby", "=", "None", ",", "binning_by_group", "=", "False", ",", "quantiles", "=", "5", ",", "bins", "=", "None", ",", "periods", "=", "(", "1", ",", "5", ",", "10", ")"...
d43eac871bb061e956df936794d3dd514da99e44
train
rate_of_return
Convert returns to 'one_period_len' rate of returns: that is the value the returns would have every 'one_period_len' if they had grown at a steady rate Parameters ---------- period_ret: pd.DataFrame DataFrame containing returns values with column headings representing the return per...
alphalens/utils.py
def rate_of_return(period_ret, base_period): """ Convert returns to 'one_period_len' rate of returns: that is the value the returns would have every 'one_period_len' if they had grown at a steady rate Parameters ---------- period_ret: pd.DataFrame DataFrame containing returns values...
def rate_of_return(period_ret, base_period): """ Convert returns to 'one_period_len' rate of returns: that is the value the returns would have every 'one_period_len' if they had grown at a steady rate Parameters ---------- period_ret: pd.DataFrame DataFrame containing returns values...
[ "Convert", "returns", "to", "one_period_len", "rate", "of", "returns", ":", "that", "is", "the", "value", "the", "returns", "would", "have", "every", "one_period_len", "if", "they", "had", "grown", "at", "a", "steady", "rate" ]
quantopian/alphalens
python
https://github.com/quantopian/alphalens/blob/d43eac871bb061e956df936794d3dd514da99e44/alphalens/utils.py#L802-L827
[ "def", "rate_of_return", "(", "period_ret", ",", "base_period", ")", ":", "period_len", "=", "period_ret", ".", "name", "conversion_factor", "=", "(", "pd", ".", "Timedelta", "(", "base_period", ")", "/", "pd", ".", "Timedelta", "(", "period_len", ")", ")", ...
d43eac871bb061e956df936794d3dd514da99e44
train
std_conversion
one_period_len standard deviation (or standard error) approximation Parameters ---------- period_std: pd.DataFrame DataFrame containing standard deviation or standard error values with column headings representing the return period. base_period: string The base period length use...
alphalens/utils.py
def std_conversion(period_std, base_period): """ one_period_len standard deviation (or standard error) approximation Parameters ---------- period_std: pd.DataFrame DataFrame containing standard deviation or standard error values with column headings representing the return period. ...
def std_conversion(period_std, base_period): """ one_period_len standard deviation (or standard error) approximation Parameters ---------- period_std: pd.DataFrame DataFrame containing standard deviation or standard error values with column headings representing the return period. ...
[ "one_period_len", "standard", "deviation", "(", "or", "standard", "error", ")", "approximation" ]
quantopian/alphalens
python
https://github.com/quantopian/alphalens/blob/d43eac871bb061e956df936794d3dd514da99e44/alphalens/utils.py#L830-L853
[ "def", "std_conversion", "(", "period_std", ",", "base_period", ")", ":", "period_len", "=", "period_std", ".", "name", "conversion_factor", "=", "(", "pd", ".", "Timedelta", "(", "period_len", ")", "/", "pd", ".", "Timedelta", "(", "base_period", ")", ")", ...
d43eac871bb061e956df936794d3dd514da99e44
train
get_forward_returns_columns
Utility that detects and returns the columns that are forward returns
alphalens/utils.py
def get_forward_returns_columns(columns): """ Utility that detects and returns the columns that are forward returns """ pattern = re.compile(r"^(\d+([Dhms]|ms|us|ns))+$", re.IGNORECASE) valid_columns = [(pattern.match(col) is not None) for col in columns] return columns[valid_columns]
def get_forward_returns_columns(columns): """ Utility that detects and returns the columns that are forward returns """ pattern = re.compile(r"^(\d+([Dhms]|ms|us|ns))+$", re.IGNORECASE) valid_columns = [(pattern.match(col) is not None) for col in columns] return columns[valid_columns]
[ "Utility", "that", "detects", "and", "returns", "the", "columns", "that", "are", "forward", "returns" ]
quantopian/alphalens
python
https://github.com/quantopian/alphalens/blob/d43eac871bb061e956df936794d3dd514da99e44/alphalens/utils.py#L856-L862
[ "def", "get_forward_returns_columns", "(", "columns", ")", ":", "pattern", "=", "re", ".", "compile", "(", "r\"^(\\d+([Dhms]|ms|us|ns))+$\"", ",", "re", ".", "IGNORECASE", ")", "valid_columns", "=", "[", "(", "pattern", ".", "match", "(", "col", ")", "is", "...
d43eac871bb061e956df936794d3dd514da99e44
train
timedelta_to_string
Utility that converts a pandas.Timedelta to a string representation compatible with pandas.Timedelta constructor format Parameters ---------- timedelta: pd.Timedelta Returns ------- string string representation of 'timedelta'
alphalens/utils.py
def timedelta_to_string(timedelta): """ Utility that converts a pandas.Timedelta to a string representation compatible with pandas.Timedelta constructor format Parameters ---------- timedelta: pd.Timedelta Returns ------- string string representation of 'timedelta' """ ...
def timedelta_to_string(timedelta): """ Utility that converts a pandas.Timedelta to a string representation compatible with pandas.Timedelta constructor format Parameters ---------- timedelta: pd.Timedelta Returns ------- string string representation of 'timedelta' """ ...
[ "Utility", "that", "converts", "a", "pandas", ".", "Timedelta", "to", "a", "string", "representation", "compatible", "with", "pandas", ".", "Timedelta", "constructor", "format" ]
quantopian/alphalens
python
https://github.com/quantopian/alphalens/blob/d43eac871bb061e956df936794d3dd514da99e44/alphalens/utils.py#L865-L895
[ "def", "timedelta_to_string", "(", "timedelta", ")", ":", "c", "=", "timedelta", ".", "components", "format", "=", "''", "if", "c", ".", "days", "!=", "0", ":", "format", "+=", "'%dD'", "%", "c", ".", "days", "if", "c", ".", "hours", ">", "0", ":",...
d43eac871bb061e956df936794d3dd514da99e44
train
add_custom_calendar_timedelta
Add timedelta to 'input' taking into consideration custom frequency, which is used to deal with custom calendars, such as a trading calendar Parameters ---------- input : pd.DatetimeIndex or pd.Timestamp timedelta : pd.Timedelta freq : pd.DataOffset (CustomBusinessDay, Day or BusinessDay) ...
alphalens/utils.py
def add_custom_calendar_timedelta(input, timedelta, freq): """ Add timedelta to 'input' taking into consideration custom frequency, which is used to deal with custom calendars, such as a trading calendar Parameters ---------- input : pd.DatetimeIndex or pd.Timestamp timedelta : pd.Timedelta...
def add_custom_calendar_timedelta(input, timedelta, freq): """ Add timedelta to 'input' taking into consideration custom frequency, which is used to deal with custom calendars, such as a trading calendar Parameters ---------- input : pd.DatetimeIndex or pd.Timestamp timedelta : pd.Timedelta...
[ "Add", "timedelta", "to", "input", "taking", "into", "consideration", "custom", "frequency", "which", "is", "used", "to", "deal", "with", "custom", "calendars", "such", "as", "a", "trading", "calendar" ]
quantopian/alphalens
python
https://github.com/quantopian/alphalens/blob/d43eac871bb061e956df936794d3dd514da99e44/alphalens/utils.py#L898-L918
[ "def", "add_custom_calendar_timedelta", "(", "input", ",", "timedelta", ",", "freq", ")", ":", "if", "not", "isinstance", "(", "freq", ",", "(", "Day", ",", "BusinessDay", ",", "CustomBusinessDay", ")", ")", ":", "raise", "ValueError", "(", "\"freq must be Day...
d43eac871bb061e956df936794d3dd514da99e44
train
diff_custom_calendar_timedeltas
Compute the difference between two pd.Timedelta taking into consideration custom frequency, which is used to deal with custom calendars, such as a trading calendar Parameters ---------- start : pd.Timestamp end : pd.Timestamp freq : CustomBusinessDay (see infer_trading_calendar) freq : ...
alphalens/utils.py
def diff_custom_calendar_timedeltas(start, end, freq): """ Compute the difference between two pd.Timedelta taking into consideration custom frequency, which is used to deal with custom calendars, such as a trading calendar Parameters ---------- start : pd.Timestamp end : pd.Timestamp ...
def diff_custom_calendar_timedeltas(start, end, freq): """ Compute the difference between two pd.Timedelta taking into consideration custom frequency, which is used to deal with custom calendars, such as a trading calendar Parameters ---------- start : pd.Timestamp end : pd.Timestamp ...
[ "Compute", "the", "difference", "between", "two", "pd", ".", "Timedelta", "taking", "into", "consideration", "custom", "frequency", "which", "is", "used", "to", "deal", "with", "custom", "calendars", "such", "as", "a", "trading", "calendar" ]
quantopian/alphalens
python
https://github.com/quantopian/alphalens/blob/d43eac871bb061e956df936794d3dd514da99e44/alphalens/utils.py#L921-L966
[ "def", "diff_custom_calendar_timedeltas", "(", "start", ",", "end", ",", "freq", ")", ":", "if", "not", "isinstance", "(", "freq", ",", "(", "Day", ",", "BusinessDay", ",", "CustomBusinessDay", ")", ")", ":", "raise", "ValueError", "(", "\"freq must be Day, Bu...
d43eac871bb061e956df936794d3dd514da99e44
train
customize
Decorator to set plotting context and axes style during function call.
alphalens/plotting.py
def customize(func): """ Decorator to set plotting context and axes style during function call. """ @wraps(func) def call_w_context(*args, **kwargs): set_context = kwargs.pop('set_context', True) if set_context: color_palette = sns.color_palette('colorblind') ...
def customize(func): """ Decorator to set plotting context and axes style during function call. """ @wraps(func) def call_w_context(*args, **kwargs): set_context = kwargs.pop('set_context', True) if set_context: color_palette = sns.color_palette('colorblind') ...
[ "Decorator", "to", "set", "plotting", "context", "and", "axes", "style", "during", "function", "call", "." ]
quantopian/alphalens
python
https://github.com/quantopian/alphalens/blob/d43eac871bb061e956df936794d3dd514da99e44/alphalens/plotting.py#L34-L48
[ "def", "customize", "(", "func", ")", ":", "@", "wraps", "(", "func", ")", "def", "call_w_context", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "set_context", "=", "kwargs", ".", "pop", "(", "'set_context'", ",", "True", ")", "if", "set_cont...
d43eac871bb061e956df936794d3dd514da99e44
train
plot_ic_ts
Plots Spearman Rank Information Coefficient and IC moving average for a given factor. Parameters ---------- ic : pd.DataFrame DataFrame indexed by date, with IC for each forward return. ax : matplotlib.Axes, optional Axes upon which to plot. Returns ------- ax : matplot...
alphalens/plotting.py
def plot_ic_ts(ic, ax=None): """ Plots Spearman Rank Information Coefficient and IC moving average for a given factor. Parameters ---------- ic : pd.DataFrame DataFrame indexed by date, with IC for each forward return. ax : matplotlib.Axes, optional Axes upon which to plot. ...
def plot_ic_ts(ic, ax=None): """ Plots Spearman Rank Information Coefficient and IC moving average for a given factor. Parameters ---------- ic : pd.DataFrame DataFrame indexed by date, with IC for each forward return. ax : matplotlib.Axes, optional Axes upon which to plot. ...
[ "Plots", "Spearman", "Rank", "Information", "Coefficient", "and", "IC", "moving", "average", "for", "a", "given", "factor", "." ]
quantopian/alphalens
python
https://github.com/quantopian/alphalens/blob/d43eac871bb061e956df936794d3dd514da99e44/alphalens/plotting.py#L192-L245
[ "def", "plot_ic_ts", "(", "ic", ",", "ax", "=", "None", ")", ":", "ic", "=", "ic", ".", "copy", "(", ")", "num_plots", "=", "len", "(", "ic", ".", "columns", ")", "if", "ax", "is", "None", ":", "f", ",", "ax", "=", "plt", ".", "subplots", "("...
d43eac871bb061e956df936794d3dd514da99e44
train
plot_ic_hist
Plots Spearman Rank Information Coefficient histogram for a given factor. Parameters ---------- ic : pd.DataFrame DataFrame indexed by date, with IC for each forward return. ax : matplotlib.Axes, optional Axes upon which to plot. Returns ------- ax : matplotlib.Axes ...
alphalens/plotting.py
def plot_ic_hist(ic, ax=None): """ Plots Spearman Rank Information Coefficient histogram for a given factor. Parameters ---------- ic : pd.DataFrame DataFrame indexed by date, with IC for each forward return. ax : matplotlib.Axes, optional Axes upon which to plot. Returns ...
def plot_ic_hist(ic, ax=None): """ Plots Spearman Rank Information Coefficient histogram for a given factor. Parameters ---------- ic : pd.DataFrame DataFrame indexed by date, with IC for each forward return. ax : matplotlib.Axes, optional Axes upon which to plot. Returns ...
[ "Plots", "Spearman", "Rank", "Information", "Coefficient", "histogram", "for", "a", "given", "factor", "." ]
quantopian/alphalens
python
https://github.com/quantopian/alphalens/blob/d43eac871bb061e956df936794d3dd514da99e44/alphalens/plotting.py#L248-L289
[ "def", "plot_ic_hist", "(", "ic", ",", "ax", "=", "None", ")", ":", "ic", "=", "ic", ".", "copy", "(", ")", "num_plots", "=", "len", "(", "ic", ".", "columns", ")", "v_spaces", "=", "(", "(", "num_plots", "-", "1", ")", "//", "3", ")", "+", "...
d43eac871bb061e956df936794d3dd514da99e44
train
plot_ic_qq
Plots Spearman Rank Information Coefficient "Q-Q" plot relative to a theoretical distribution. Parameters ---------- ic : pd.DataFrame DataFrame indexed by date, with IC for each forward return. theoretical_dist : scipy.stats._continuous_distns Continuous distribution generator. sci...
alphalens/plotting.py
def plot_ic_qq(ic, theoretical_dist=stats.norm, ax=None): """ Plots Spearman Rank Information Coefficient "Q-Q" plot relative to a theoretical distribution. Parameters ---------- ic : pd.DataFrame DataFrame indexed by date, with IC for each forward return. theoretical_dist : scipy.s...
def plot_ic_qq(ic, theoretical_dist=stats.norm, ax=None): """ Plots Spearman Rank Information Coefficient "Q-Q" plot relative to a theoretical distribution. Parameters ---------- ic : pd.DataFrame DataFrame indexed by date, with IC for each forward return. theoretical_dist : scipy.s...
[ "Plots", "Spearman", "Rank", "Information", "Coefficient", "Q", "-", "Q", "plot", "relative", "to", "a", "theoretical", "distribution", "." ]
quantopian/alphalens
python
https://github.com/quantopian/alphalens/blob/d43eac871bb061e956df936794d3dd514da99e44/alphalens/plotting.py#L292-L338
[ "def", "plot_ic_qq", "(", "ic", ",", "theoretical_dist", "=", "stats", ".", "norm", ",", "ax", "=", "None", ")", ":", "ic", "=", "ic", ".", "copy", "(", ")", "num_plots", "=", "len", "(", "ic", ".", "columns", ")", "v_spaces", "=", "(", "(", "num...
d43eac871bb061e956df936794d3dd514da99e44
train
plot_quantile_returns_bar
Plots mean period wise returns for factor quantiles. Parameters ---------- mean_ret_by_q : pd.DataFrame DataFrame with quantile, (group) and mean period wise return values. by_group : bool Disaggregated figures by group. ylim_percentiles : tuple of integers Percentiles of ob...
alphalens/plotting.py
def plot_quantile_returns_bar(mean_ret_by_q, by_group=False, ylim_percentiles=None, ax=None): """ Plots mean period wise returns for factor quantiles. Parameters ---------- mean_ret_by_q : pd.DataFrame ...
def plot_quantile_returns_bar(mean_ret_by_q, by_group=False, ylim_percentiles=None, ax=None): """ Plots mean period wise returns for factor quantiles. Parameters ---------- mean_ret_by_q : pd.DataFrame ...
[ "Plots", "mean", "period", "wise", "returns", "for", "factor", "quantiles", "." ]
quantopian/alphalens
python
https://github.com/quantopian/alphalens/blob/d43eac871bb061e956df936794d3dd514da99e44/alphalens/plotting.py#L341-L409
[ "def", "plot_quantile_returns_bar", "(", "mean_ret_by_q", ",", "by_group", "=", "False", ",", "ylim_percentiles", "=", "None", ",", "ax", "=", "None", ")", ":", "mean_ret_by_q", "=", "mean_ret_by_q", ".", "copy", "(", ")", "if", "ylim_percentiles", "is", "not"...
d43eac871bb061e956df936794d3dd514da99e44
train
plot_quantile_returns_violin
Plots a violin box plot of period wise returns for factor quantiles. Parameters ---------- return_by_q : pd.DataFrame - MultiIndex DataFrame with date and quantile as rows MultiIndex, forward return windows as columns, returns as values. ylim_percentiles : tuple of integers Perc...
alphalens/plotting.py
def plot_quantile_returns_violin(return_by_q, ylim_percentiles=None, ax=None): """ Plots a violin box plot of period wise returns for factor quantiles. Parameters ---------- return_by_q : pd.DataFrame - MultiIndex DataFrame w...
def plot_quantile_returns_violin(return_by_q, ylim_percentiles=None, ax=None): """ Plots a violin box plot of period wise returns for factor quantiles. Parameters ---------- return_by_q : pd.DataFrame - MultiIndex DataFrame w...
[ "Plots", "a", "violin", "box", "plot", "of", "period", "wise", "returns", "for", "factor", "quantiles", "." ]
quantopian/alphalens
python
https://github.com/quantopian/alphalens/blob/d43eac871bb061e956df936794d3dd514da99e44/alphalens/plotting.py#L412-L469
[ "def", "plot_quantile_returns_violin", "(", "return_by_q", ",", "ylim_percentiles", "=", "None", ",", "ax", "=", "None", ")", ":", "return_by_q", "=", "return_by_q", ".", "copy", "(", ")", "if", "ylim_percentiles", "is", "not", "None", ":", "ymin", "=", "(",...
d43eac871bb061e956df936794d3dd514da99e44
train
plot_mean_quantile_returns_spread_time_series
Plots mean period wise returns for factor quantiles. Parameters ---------- mean_returns_spread : pd.Series Series with difference between quantile mean returns by period. std_err : pd.Series Series with standard error of difference between quantile mean returns each period. ...
alphalens/plotting.py
def plot_mean_quantile_returns_spread_time_series(mean_returns_spread, std_err=None, bandwidth=1, ax=None): """ Plots mean period wise returns for factor quantile...
def plot_mean_quantile_returns_spread_time_series(mean_returns_spread, std_err=None, bandwidth=1, ax=None): """ Plots mean period wise returns for factor quantile...
[ "Plots", "mean", "period", "wise", "returns", "for", "factor", "quantiles", "." ]
quantopian/alphalens
python
https://github.com/quantopian/alphalens/blob/d43eac871bb061e956df936794d3dd514da99e44/alphalens/plotting.py#L472-L555
[ "def", "plot_mean_quantile_returns_spread_time_series", "(", "mean_returns_spread", ",", "std_err", "=", "None", ",", "bandwidth", "=", "1", ",", "ax", "=", "None", ")", ":", "if", "isinstance", "(", "mean_returns_spread", ",", "pd", ".", "DataFrame", ")", ":", ...
d43eac871bb061e956df936794d3dd514da99e44
train
plot_ic_by_group
Plots Spearman Rank Information Coefficient for a given factor over provided forward returns. Separates by group. Parameters ---------- ic_group : pd.DataFrame group-wise mean period wise returns. ax : matplotlib.Axes, optional Axes upon which to plot. Returns ------- a...
alphalens/plotting.py
def plot_ic_by_group(ic_group, ax=None): """ Plots Spearman Rank Information Coefficient for a given factor over provided forward returns. Separates by group. Parameters ---------- ic_group : pd.DataFrame group-wise mean period wise returns. ax : matplotlib.Axes, optional Ax...
def plot_ic_by_group(ic_group, ax=None): """ Plots Spearman Rank Information Coefficient for a given factor over provided forward returns. Separates by group. Parameters ---------- ic_group : pd.DataFrame group-wise mean period wise returns. ax : matplotlib.Axes, optional Ax...
[ "Plots", "Spearman", "Rank", "Information", "Coefficient", "for", "a", "given", "factor", "over", "provided", "forward", "returns", ".", "Separates", "by", "group", "." ]
quantopian/alphalens
python
https://github.com/quantopian/alphalens/blob/d43eac871bb061e956df936794d3dd514da99e44/alphalens/plotting.py#L558-L582
[ "def", "plot_ic_by_group", "(", "ic_group", ",", "ax", "=", "None", ")", ":", "if", "ax", "is", "None", ":", "f", ",", "ax", "=", "plt", ".", "subplots", "(", "1", ",", "1", ",", "figsize", "=", "(", "18", ",", "6", ")", ")", "ic_group", ".", ...
d43eac871bb061e956df936794d3dd514da99e44
train
plot_factor_rank_auto_correlation
Plots factor rank autocorrelation over time. See factor_rank_autocorrelation for more details. Parameters ---------- factor_autocorrelation : pd.Series Rolling 1 period (defined by time_rule) autocorrelation of factor values. period: int, optional Period over which the autoc...
alphalens/plotting.py
def plot_factor_rank_auto_correlation(factor_autocorrelation, period=1, ax=None): """ Plots factor rank autocorrelation over time. See factor_rank_autocorrelation for more details. Parameters ---------- factor_autocorre...
def plot_factor_rank_auto_correlation(factor_autocorrelation, period=1, ax=None): """ Plots factor rank autocorrelation over time. See factor_rank_autocorrelation for more details. Parameters ---------- factor_autocorre...
[ "Plots", "factor", "rank", "autocorrelation", "over", "time", ".", "See", "factor_rank_autocorrelation", "for", "more", "details", "." ]
quantopian/alphalens
python
https://github.com/quantopian/alphalens/blob/d43eac871bb061e956df936794d3dd514da99e44/alphalens/plotting.py#L585-L620
[ "def", "plot_factor_rank_auto_correlation", "(", "factor_autocorrelation", ",", "period", "=", "1", ",", "ax", "=", "None", ")", ":", "if", "ax", "is", "None", ":", "f", ",", "ax", "=", "plt", ".", "subplots", "(", "1", ",", "1", ",", "figsize", "=", ...
d43eac871bb061e956df936794d3dd514da99e44
train
plot_top_bottom_quantile_turnover
Plots period wise top and bottom quantile factor turnover. Parameters ---------- quantile_turnover: pd.Dataframe Quantile turnover (each DataFrame column a quantile). period: int, optional Period over which to calculate the turnover ax : matplotlib.Axes, optional Axes upon w...
alphalens/plotting.py
def plot_top_bottom_quantile_turnover(quantile_turnover, period=1, ax=None): """ Plots period wise top and bottom quantile factor turnover. Parameters ---------- quantile_turnover: pd.Dataframe Quantile turnover (each DataFrame column a quantile). period: int, optional Period ov...
def plot_top_bottom_quantile_turnover(quantile_turnover, period=1, ax=None): """ Plots period wise top and bottom quantile factor turnover. Parameters ---------- quantile_turnover: pd.Dataframe Quantile turnover (each DataFrame column a quantile). period: int, optional Period ov...
[ "Plots", "period", "wise", "top", "and", "bottom", "quantile", "factor", "turnover", "." ]
quantopian/alphalens
python
https://github.com/quantopian/alphalens/blob/d43eac871bb061e956df936794d3dd514da99e44/alphalens/plotting.py#L623-L653
[ "def", "plot_top_bottom_quantile_turnover", "(", "quantile_turnover", ",", "period", "=", "1", ",", "ax", "=", "None", ")", ":", "if", "ax", "is", "None", ":", "f", ",", "ax", "=", "plt", ".", "subplots", "(", "1", ",", "1", ",", "figsize", "=", "(",...
d43eac871bb061e956df936794d3dd514da99e44
train
plot_monthly_ic_heatmap
Plots a heatmap of the information coefficient or returns by month. Parameters ---------- mean_monthly_ic : pd.DataFrame The mean monthly IC for N periods forward. Returns ------- ax : matplotlib.Axes The axes that were plotted on.
alphalens/plotting.py
def plot_monthly_ic_heatmap(mean_monthly_ic, ax=None): """ Plots a heatmap of the information coefficient or returns by month. Parameters ---------- mean_monthly_ic : pd.DataFrame The mean monthly IC for N periods forward. Returns ------- ax : matplotlib.Axes The axes t...
def plot_monthly_ic_heatmap(mean_monthly_ic, ax=None): """ Plots a heatmap of the information coefficient or returns by month. Parameters ---------- mean_monthly_ic : pd.DataFrame The mean monthly IC for N periods forward. Returns ------- ax : matplotlib.Axes The axes t...
[ "Plots", "a", "heatmap", "of", "the", "information", "coefficient", "or", "returns", "by", "month", "." ]
quantopian/alphalens
python
https://github.com/quantopian/alphalens/blob/d43eac871bb061e956df936794d3dd514da99e44/alphalens/plotting.py#L656-L711
[ "def", "plot_monthly_ic_heatmap", "(", "mean_monthly_ic", ",", "ax", "=", "None", ")", ":", "mean_monthly_ic", "=", "mean_monthly_ic", ".", "copy", "(", ")", "num_plots", "=", "len", "(", "mean_monthly_ic", ".", "columns", ")", "v_spaces", "=", "(", "(", "nu...
d43eac871bb061e956df936794d3dd514da99e44
train
plot_cumulative_returns
Plots the cumulative returns of the returns series passed in. Parameters ---------- factor_returns : pd.Series Period wise returns of dollar neutral portfolio weighted by factor value. period: pandas.Timedelta or string Length of period for which the returns are computed (e.g. 1...
alphalens/plotting.py
def plot_cumulative_returns(factor_returns, period, freq, title=None, ax=None): """ Plots the cumulative returns of the returns series passed in. Parameters ---------- factor_returns : pd.Series Period wise returns of dollar neutral portfolio weighted by factor value. period: pa...
def plot_cumulative_returns(factor_returns, period, freq, title=None, ax=None): """ Plots the cumulative returns of the returns series passed in. Parameters ---------- factor_returns : pd.Series Period wise returns of dollar neutral portfolio weighted by factor value. period: pa...
[ "Plots", "the", "cumulative", "returns", "of", "the", "returns", "series", "passed", "in", "." ]
quantopian/alphalens
python
https://github.com/quantopian/alphalens/blob/d43eac871bb061e956df936794d3dd514da99e44/alphalens/plotting.py#L714-L754
[ "def", "plot_cumulative_returns", "(", "factor_returns", ",", "period", ",", "freq", ",", "title", "=", "None", ",", "ax", "=", "None", ")", ":", "if", "ax", "is", "None", ":", "f", ",", "ax", "=", "plt", ".", "subplots", "(", "1", ",", "1", ",", ...
d43eac871bb061e956df936794d3dd514da99e44
train
plot_cumulative_returns_by_quantile
Plots the cumulative returns of various factor quantiles. Parameters ---------- quantile_returns : pd.DataFrame Returns by factor quantile period: pandas.Timedelta or string Length of period for which the returns are computed (e.g. 1 day) if 'period' is a string it must follow p...
alphalens/plotting.py
def plot_cumulative_returns_by_quantile(quantile_returns, period, freq, ax=None): """ Plots the cumulative returns of various factor quantiles. Parameters ---------- quantile_retu...
def plot_cumulative_returns_by_quantile(quantile_returns, period, freq, ax=None): """ Plots the cumulative returns of various factor quantiles. Parameters ---------- quantile_retu...
[ "Plots", "the", "cumulative", "returns", "of", "various", "factor", "quantiles", "." ]
quantopian/alphalens
python
https://github.com/quantopian/alphalens/blob/d43eac871bb061e956df936794d3dd514da99e44/alphalens/plotting.py#L757-L807
[ "def", "plot_cumulative_returns_by_quantile", "(", "quantile_returns", ",", "period", ",", "freq", ",", "ax", "=", "None", ")", ":", "if", "ax", "is", "None", ":", "f", ",", "ax", "=", "plt", ".", "subplots", "(", "1", ",", "1", ",", "figsize", "=", ...
d43eac871bb061e956df936794d3dd514da99e44
train
plot_quantile_average_cumulative_return
Plots sector-wise mean daily returns for factor quantiles across provided forward price movement columns. Parameters ---------- avg_cumulative_returns: pd.Dataframe The format is the one returned by performance.average_cumulative_return_by_quantile by_quantile : boolean, optional ...
alphalens/plotting.py
def plot_quantile_average_cumulative_return(avg_cumulative_returns, by_quantile=False, std_bar=False, title=None, ax=None): """ Plots se...
def plot_quantile_average_cumulative_return(avg_cumulative_returns, by_quantile=False, std_bar=False, title=None, ax=None): """ Plots se...
[ "Plots", "sector", "-", "wise", "mean", "daily", "returns", "for", "factor", "quantiles", "across", "provided", "forward", "price", "movement", "columns", "." ]
quantopian/alphalens
python
https://github.com/quantopian/alphalens/blob/d43eac871bb061e956df936794d3dd514da99e44/alphalens/plotting.py#L810-L895
[ "def", "plot_quantile_average_cumulative_return", "(", "avg_cumulative_returns", ",", "by_quantile", "=", "False", ",", "std_bar", "=", "False", ",", "title", "=", "None", ",", "ax", "=", "None", ")", ":", "avg_cumulative_returns", "=", "avg_cumulative_returns", "."...
d43eac871bb061e956df936794d3dd514da99e44
train
plot_events_distribution
Plots the distribution of events in time. Parameters ---------- events : pd.Series A pd.Series whose index contains at least 'date' level. num_bars : integer, optional Number of bars to plot ax : matplotlib.Axes, optional Axes upon which to plot. Returns ------- ...
alphalens/plotting.py
def plot_events_distribution(events, num_bars=50, ax=None): """ Plots the distribution of events in time. Parameters ---------- events : pd.Series A pd.Series whose index contains at least 'date' level. num_bars : integer, optional Number of bars to plot ax : matplotlib.Axes...
def plot_events_distribution(events, num_bars=50, ax=None): """ Plots the distribution of events in time. Parameters ---------- events : pd.Series A pd.Series whose index contains at least 'date' level. num_bars : integer, optional Number of bars to plot ax : matplotlib.Axes...
[ "Plots", "the", "distribution", "of", "events", "in", "time", "." ]
quantopian/alphalens
python
https://github.com/quantopian/alphalens/blob/d43eac871bb061e956df936794d3dd514da99e44/alphalens/plotting.py#L898-L928
[ "def", "plot_events_distribution", "(", "events", ",", "num_bars", "=", "50", ",", "ax", "=", "None", ")", ":", "if", "ax", "is", "None", ":", "f", ",", "ax", "=", "plt", ".", "subplots", "(", "1", ",", "1", ",", "figsize", "=", "(", "18", ",", ...
d43eac871bb061e956df936794d3dd514da99e44
train
Cursor.close
Closing a cursor just exhausts all remaining data.
pymysql/cursors.py
def close(self): """ Closing a cursor just exhausts all remaining data. """ conn = self.connection if conn is None: return try: while self.nextset(): pass finally: self.connection = None
def close(self): """ Closing a cursor just exhausts all remaining data. """ conn = self.connection if conn is None: return try: while self.nextset(): pass finally: self.connection = None
[ "Closing", "a", "cursor", "just", "exhausts", "all", "remaining", "data", "." ]
PyMySQL/PyMySQL
python
https://github.com/PyMySQL/PyMySQL/blob/3674bc6fd064bf88524e839c07690e8c35223709/pymysql/cursors.py#L47-L58
[ "def", "close", "(", "self", ")", ":", "conn", "=", "self", ".", "connection", "if", "conn", "is", "None", ":", "return", "try", ":", "while", "self", ".", "nextset", "(", ")", ":", "pass", "finally", ":", "self", ".", "connection", "=", "None" ]
3674bc6fd064bf88524e839c07690e8c35223709
train
Cursor._nextset
Get the next query set
pymysql/cursors.py
def _nextset(self, unbuffered=False): """Get the next query set""" conn = self._get_db() current_result = self._result if current_result is None or current_result is not conn._result: return None if not current_result.has_next: return None self._re...
def _nextset(self, unbuffered=False): """Get the next query set""" conn = self._get_db() current_result = self._result if current_result is None or current_result is not conn._result: return None if not current_result.has_next: return None self._re...
[ "Get", "the", "next", "query", "set" ]
PyMySQL/PyMySQL
python
https://github.com/PyMySQL/PyMySQL/blob/3674bc6fd064bf88524e839c07690e8c35223709/pymysql/cursors.py#L85-L97
[ "def", "_nextset", "(", "self", ",", "unbuffered", "=", "False", ")", ":", "conn", "=", "self", ".", "_get_db", "(", ")", "current_result", "=", "self", ".", "_result", "if", "current_result", "is", "None", "or", "current_result", "is", "not", "conn", "....
3674bc6fd064bf88524e839c07690e8c35223709
train
Cursor.mogrify
Returns the exact string that is sent to the database by calling the execute() method. This method follows the extension to the DB API 2.0 followed by Psycopg.
pymysql/cursors.py
def mogrify(self, query, args=None): """ Returns the exact string that is sent to the database by calling the execute() method. This method follows the extension to the DB API 2.0 followed by Psycopg. """ conn = self._get_db() if PY2: # Use bytes on Python 2 alw...
def mogrify(self, query, args=None): """ Returns the exact string that is sent to the database by calling the execute() method. This method follows the extension to the DB API 2.0 followed by Psycopg. """ conn = self._get_db() if PY2: # Use bytes on Python 2 alw...
[ "Returns", "the", "exact", "string", "that", "is", "sent", "to", "the", "database", "by", "calling", "the", "execute", "()", "method", "." ]
PyMySQL/PyMySQL
python
https://github.com/PyMySQL/PyMySQL/blob/3674bc6fd064bf88524e839c07690e8c35223709/pymysql/cursors.py#L128-L142
[ "def", "mogrify", "(", "self", ",", "query", ",", "args", "=", "None", ")", ":", "conn", "=", "self", ".", "_get_db", "(", ")", "if", "PY2", ":", "# Use bytes on Python 2 always", "query", "=", "self", ".", "_ensure_bytes", "(", "query", ",", "encoding",...
3674bc6fd064bf88524e839c07690e8c35223709
train
Cursor.execute
Execute a query :param str query: Query to execute. :param args: parameters used with query. (optional) :type args: tuple, list or dict :return: Number of affected rows :rtype: int If args is a list or tuple, %s can be used as a placeholder in the query. If ar...
pymysql/cursors.py
def execute(self, query, args=None): """Execute a query :param str query: Query to execute. :param args: parameters used with query. (optional) :type args: tuple, list or dict :return: Number of affected rows :rtype: int If args is a list or tuple, %s can be u...
def execute(self, query, args=None): """Execute a query :param str query: Query to execute. :param args: parameters used with query. (optional) :type args: tuple, list or dict :return: Number of affected rows :rtype: int If args is a list or tuple, %s can be u...
[ "Execute", "a", "query" ]
PyMySQL/PyMySQL
python
https://github.com/PyMySQL/PyMySQL/blob/3674bc6fd064bf88524e839c07690e8c35223709/pymysql/cursors.py#L144-L165
[ "def", "execute", "(", "self", ",", "query", ",", "args", "=", "None", ")", ":", "while", "self", ".", "nextset", "(", ")", ":", "pass", "query", "=", "self", ".", "mogrify", "(", "query", ",", "args", ")", "result", "=", "self", ".", "_query", "...
3674bc6fd064bf88524e839c07690e8c35223709
train
Cursor.callproc
Execute stored procedure procname with args procname -- string, name of procedure to execute on server args -- Sequence of parameters to use with procedure Returns the original args. Compatibility warning: PEP-249 specifies that any modified parameters must be returned. This ...
pymysql/cursors.py
def callproc(self, procname, args=()): """Execute stored procedure procname with args procname -- string, name of procedure to execute on server args -- Sequence of parameters to use with procedure Returns the original args. Compatibility warning: PEP-249 specifies that any m...
def callproc(self, procname, args=()): """Execute stored procedure procname with args procname -- string, name of procedure to execute on server args -- Sequence of parameters to use with procedure Returns the original args. Compatibility warning: PEP-249 specifies that any m...
[ "Execute", "stored", "procedure", "procname", "with", "args" ]
PyMySQL/PyMySQL
python
https://github.com/PyMySQL/PyMySQL/blob/3674bc6fd064bf88524e839c07690e8c35223709/pymysql/cursors.py#L231-L271
[ "def", "callproc", "(", "self", ",", "procname", ",", "args", "=", "(", ")", ")", ":", "conn", "=", "self", ".", "_get_db", "(", ")", "if", "args", ":", "fmt", "=", "'@_{0}_%d=%s'", ".", "format", "(", "procname", ")", "self", ".", "_query", "(", ...
3674bc6fd064bf88524e839c07690e8c35223709
train
Cursor.fetchone
Fetch the next row
pymysql/cursors.py
def fetchone(self): """Fetch the next row""" self._check_executed() if self._rows is None or self.rownumber >= len(self._rows): return None result = self._rows[self.rownumber] self.rownumber += 1 return result
def fetchone(self): """Fetch the next row""" self._check_executed() if self._rows is None or self.rownumber >= len(self._rows): return None result = self._rows[self.rownumber] self.rownumber += 1 return result
[ "Fetch", "the", "next", "row" ]
PyMySQL/PyMySQL
python
https://github.com/PyMySQL/PyMySQL/blob/3674bc6fd064bf88524e839c07690e8c35223709/pymysql/cursors.py#L273-L280
[ "def", "fetchone", "(", "self", ")", ":", "self", ".", "_check_executed", "(", ")", "if", "self", ".", "_rows", "is", "None", "or", "self", ".", "rownumber", ">=", "len", "(", "self", ".", "_rows", ")", ":", "return", "None", "result", "=", "self", ...
3674bc6fd064bf88524e839c07690e8c35223709
train
Cursor.fetchmany
Fetch several rows
pymysql/cursors.py
def fetchmany(self, size=None): """Fetch several rows""" self._check_executed() if self._rows is None: return () end = self.rownumber + (size or self.arraysize) result = self._rows[self.rownumber:end] self.rownumber = min(end, len(self._rows)) return r...
def fetchmany(self, size=None): """Fetch several rows""" self._check_executed() if self._rows is None: return () end = self.rownumber + (size or self.arraysize) result = self._rows[self.rownumber:end] self.rownumber = min(end, len(self._rows)) return r...
[ "Fetch", "several", "rows" ]
PyMySQL/PyMySQL
python
https://github.com/PyMySQL/PyMySQL/blob/3674bc6fd064bf88524e839c07690e8c35223709/pymysql/cursors.py#L282-L290
[ "def", "fetchmany", "(", "self", ",", "size", "=", "None", ")", ":", "self", ".", "_check_executed", "(", ")", "if", "self", ".", "_rows", "is", "None", ":", "return", "(", ")", "end", "=", "self", ".", "rownumber", "+", "(", "size", "or", "self", ...
3674bc6fd064bf88524e839c07690e8c35223709
train
Cursor.fetchall
Fetch all the rows
pymysql/cursors.py
def fetchall(self): """Fetch all the rows""" self._check_executed() if self._rows is None: return () if self.rownumber: result = self._rows[self.rownumber:] else: result = self._rows self.rownumber = len(self._rows) return resul...
def fetchall(self): """Fetch all the rows""" self._check_executed() if self._rows is None: return () if self.rownumber: result = self._rows[self.rownumber:] else: result = self._rows self.rownumber = len(self._rows) return resul...
[ "Fetch", "all", "the", "rows" ]
PyMySQL/PyMySQL
python
https://github.com/PyMySQL/PyMySQL/blob/3674bc6fd064bf88524e839c07690e8c35223709/pymysql/cursors.py#L292-L302
[ "def", "fetchall", "(", "self", ")", ":", "self", ".", "_check_executed", "(", ")", "if", "self", ".", "_rows", "is", "None", ":", "return", "(", ")", "if", "self", ".", "rownumber", ":", "result", "=", "self", ".", "_rows", "[", "self", ".", "rown...
3674bc6fd064bf88524e839c07690e8c35223709
train
SSCursor.fetchone
Fetch next row
pymysql/cursors.py
def fetchone(self): """Fetch next row""" self._check_executed() row = self.read_next() if row is None: return None self.rownumber += 1 return row
def fetchone(self): """Fetch next row""" self._check_executed() row = self.read_next() if row is None: return None self.rownumber += 1 return row
[ "Fetch", "next", "row" ]
PyMySQL/PyMySQL
python
https://github.com/PyMySQL/PyMySQL/blob/3674bc6fd064bf88524e839c07690e8c35223709/pymysql/cursors.py#L437-L444
[ "def", "fetchone", "(", "self", ")", ":", "self", ".", "_check_executed", "(", ")", "row", "=", "self", ".", "read_next", "(", ")", "if", "row", "is", "None", ":", "return", "None", "self", ".", "rownumber", "+=", "1", "return", "row" ]
3674bc6fd064bf88524e839c07690e8c35223709
train
SSCursor.fetchmany
Fetch many
pymysql/cursors.py
def fetchmany(self, size=None): """Fetch many""" self._check_executed() if size is None: size = self.arraysize rows = [] for i in range_type(size): row = self.read_next() if row is None: break rows.append(row) ...
def fetchmany(self, size=None): """Fetch many""" self._check_executed() if size is None: size = self.arraysize rows = [] for i in range_type(size): row = self.read_next() if row is None: break rows.append(row) ...
[ "Fetch", "many" ]
PyMySQL/PyMySQL
python
https://github.com/PyMySQL/PyMySQL/blob/3674bc6fd064bf88524e839c07690e8c35223709/pymysql/cursors.py#L465-L478
[ "def", "fetchmany", "(", "self", ",", "size", "=", "None", ")", ":", "self", ".", "_check_executed", "(", ")", "if", "size", "is", "None", ":", "size", "=", "self", ".", "arraysize", "rows", "=", "[", "]", "for", "i", "in", "range_type", "(", "size...
3674bc6fd064bf88524e839c07690e8c35223709
train
convert_datetime
Returns a DATETIME or TIMESTAMP column value as a datetime object: >>> datetime_or_None('2007-02-25 23:06:20') datetime.datetime(2007, 2, 25, 23, 6, 20) >>> datetime_or_None('2007-02-25T23:06:20') datetime.datetime(2007, 2, 25, 23, 6, 20) Illegal values are returned as None: >>> dat...
pymysql/converters.py
def convert_datetime(obj): """Returns a DATETIME or TIMESTAMP column value as a datetime object: >>> datetime_or_None('2007-02-25 23:06:20') datetime.datetime(2007, 2, 25, 23, 6, 20) >>> datetime_or_None('2007-02-25T23:06:20') datetime.datetime(2007, 2, 25, 23, 6, 20) Illegal values ar...
def convert_datetime(obj): """Returns a DATETIME or TIMESTAMP column value as a datetime object: >>> datetime_or_None('2007-02-25 23:06:20') datetime.datetime(2007, 2, 25, 23, 6, 20) >>> datetime_or_None('2007-02-25T23:06:20') datetime.datetime(2007, 2, 25, 23, 6, 20) Illegal values ar...
[ "Returns", "a", "DATETIME", "or", "TIMESTAMP", "column", "value", "as", "a", "datetime", "object", ":" ]
PyMySQL/PyMySQL
python
https://github.com/PyMySQL/PyMySQL/blob/3674bc6fd064bf88524e839c07690e8c35223709/pymysql/converters.py#L167-L195
[ "def", "convert_datetime", "(", "obj", ")", ":", "if", "not", "PY2", "and", "isinstance", "(", "obj", ",", "(", "bytes", ",", "bytearray", ")", ")", ":", "obj", "=", "obj", ".", "decode", "(", "'ascii'", ")", "m", "=", "DATETIME_RE", ".", "match", ...
3674bc6fd064bf88524e839c07690e8c35223709
train
convert_timedelta
Returns a TIME column as a timedelta object: >>> timedelta_or_None('25:06:17') datetime.timedelta(1, 3977) >>> timedelta_or_None('-25:06:17') datetime.timedelta(-2, 83177) Illegal values are returned as None: >>> timedelta_or_None('random crap') is None True Note that MyS...
pymysql/converters.py
def convert_timedelta(obj): """Returns a TIME column as a timedelta object: >>> timedelta_or_None('25:06:17') datetime.timedelta(1, 3977) >>> timedelta_or_None('-25:06:17') datetime.timedelta(-2, 83177) Illegal values are returned as None: >>> timedelta_or_None('random crap') is...
def convert_timedelta(obj): """Returns a TIME column as a timedelta object: >>> timedelta_or_None('25:06:17') datetime.timedelta(1, 3977) >>> timedelta_or_None('-25:06:17') datetime.timedelta(-2, 83177) Illegal values are returned as None: >>> timedelta_or_None('random crap') is...
[ "Returns", "a", "TIME", "column", "as", "a", "timedelta", "object", ":" ]
PyMySQL/PyMySQL
python
https://github.com/PyMySQL/PyMySQL/blob/3674bc6fd064bf88524e839c07690e8c35223709/pymysql/converters.py#L200-L238
[ "def", "convert_timedelta", "(", "obj", ")", ":", "if", "not", "PY2", "and", "isinstance", "(", "obj", ",", "(", "bytes", ",", "bytearray", ")", ")", ":", "obj", "=", "obj", ".", "decode", "(", "'ascii'", ")", "m", "=", "TIMEDELTA_RE", ".", "match", ...
3674bc6fd064bf88524e839c07690e8c35223709
train
convert_time
Returns a TIME column as a time object: >>> time_or_None('15:06:17') datetime.time(15, 6, 17) Illegal values are returned as None: >>> time_or_None('-25:06:17') is None True >>> time_or_None('random crap') is None True Note that MySQL always returns TIME columns as (+|-)H...
pymysql/converters.py
def convert_time(obj): """Returns a TIME column as a time object: >>> time_or_None('15:06:17') datetime.time(15, 6, 17) Illegal values are returned as None: >>> time_or_None('-25:06:17') is None True >>> time_or_None('random crap') is None True Note that MySQL always ...
def convert_time(obj): """Returns a TIME column as a time object: >>> time_or_None('15:06:17') datetime.time(15, 6, 17) Illegal values are returned as None: >>> time_or_None('-25:06:17') is None True >>> time_or_None('random crap') is None True Note that MySQL always ...
[ "Returns", "a", "TIME", "column", "as", "a", "time", "object", ":" ]
PyMySQL/PyMySQL
python
https://github.com/PyMySQL/PyMySQL/blob/3674bc6fd064bf88524e839c07690e8c35223709/pymysql/converters.py#L243-L279
[ "def", "convert_time", "(", "obj", ")", ":", "if", "not", "PY2", "and", "isinstance", "(", "obj", ",", "(", "bytes", ",", "bytearray", ")", ")", ":", "obj", "=", "obj", ".", "decode", "(", "'ascii'", ")", "m", "=", "TIME_RE", ".", "match", "(", "...
3674bc6fd064bf88524e839c07690e8c35223709
train
convert_date
Returns a DATE column as a date object: >>> date_or_None('2007-02-26') datetime.date(2007, 2, 26) Illegal values are returned as None: >>> date_or_None('2007-02-31') is None True >>> date_or_None('0000-00-00') is None True
pymysql/converters.py
def convert_date(obj): """Returns a DATE column as a date object: >>> date_or_None('2007-02-26') datetime.date(2007, 2, 26) Illegal values are returned as None: >>> date_or_None('2007-02-31') is None True >>> date_or_None('0000-00-00') is None True """ if not PY2 ...
def convert_date(obj): """Returns a DATE column as a date object: >>> date_or_None('2007-02-26') datetime.date(2007, 2, 26) Illegal values are returned as None: >>> date_or_None('2007-02-31') is None True >>> date_or_None('0000-00-00') is None True """ if not PY2 ...
[ "Returns", "a", "DATE", "column", "as", "a", "date", "object", ":" ]
PyMySQL/PyMySQL
python
https://github.com/PyMySQL/PyMySQL/blob/3674bc6fd064bf88524e839c07690e8c35223709/pymysql/converters.py#L282-L301
[ "def", "convert_date", "(", "obj", ")", ":", "if", "not", "PY2", "and", "isinstance", "(", "obj", ",", "(", "bytes", ",", "bytearray", ")", ")", ":", "obj", "=", "obj", ".", "decode", "(", "'ascii'", ")", "try", ":", "return", "datetime", ".", "dat...
3674bc6fd064bf88524e839c07690e8c35223709
train
SocketIO.write
Write the given bytes or bytearray object *b* to the socket and return the number of bytes written. This can be less than len(b) if not all data could be written. If the socket is non-blocking and no bytes could be written None is returned.
pymysql/_socketio.py
def write(self, b): """Write the given bytes or bytearray object *b* to the socket and return the number of bytes written. This can be less than len(b) if not all data could be written. If the socket is non-blocking and no bytes could be written None is returned. """ se...
def write(self, b): """Write the given bytes or bytearray object *b* to the socket and return the number of bytes written. This can be less than len(b) if not all data could be written. If the socket is non-blocking and no bytes could be written None is returned. """ se...
[ "Write", "the", "given", "bytes", "or", "bytearray", "object", "*", "b", "*", "to", "the", "socket", "and", "return", "the", "number", "of", "bytes", "written", ".", "This", "can", "be", "less", "than", "len", "(", "b", ")", "if", "not", "all", "data...
PyMySQL/PyMySQL
python
https://github.com/PyMySQL/PyMySQL/blob/3674bc6fd064bf88524e839c07690e8c35223709/pymysql/_socketio.py#L71-L85
[ "def", "write", "(", "self", ",", "b", ")", ":", "self", ".", "_checkClosed", "(", ")", "self", ".", "_checkWritable", "(", ")", "try", ":", "return", "self", ".", "_sock", ".", "send", "(", "b", ")", "except", "error", "as", "e", ":", "# XXX what ...
3674bc6fd064bf88524e839c07690e8c35223709
train
SocketIO.close
Close the SocketIO object. This doesn't close the underlying socket, except if all references to it have disappeared.
pymysql/_socketio.py
def close(self): """Close the SocketIO object. This doesn't close the underlying socket, except if all references to it have disappeared. """ if self.closed: return io.RawIOBase.close(self) self._sock._decref_socketios() self._sock = None
def close(self): """Close the SocketIO object. This doesn't close the underlying socket, except if all references to it have disappeared. """ if self.closed: return io.RawIOBase.close(self) self._sock._decref_socketios() self._sock = None
[ "Close", "the", "SocketIO", "object", ".", "This", "doesn", "t", "close", "the", "underlying", "socket", "except", "if", "all", "references", "to", "it", "have", "disappeared", "." ]
PyMySQL/PyMySQL
python
https://github.com/PyMySQL/PyMySQL/blob/3674bc6fd064bf88524e839c07690e8c35223709/pymysql/_socketio.py#L125-L133
[ "def", "close", "(", "self", ")", ":", "if", "self", ".", "closed", ":", "return", "io", ".", "RawIOBase", ".", "close", "(", "self", ")", "self", ".", "_sock", ".", "_decref_socketios", "(", ")", "self", ".", "_sock", "=", "None" ]
3674bc6fd064bf88524e839c07690e8c35223709
train
MysqlPacket.read
Read the first 'size' bytes in packet and advance cursor past them.
pymysql/protocol.py
def read(self, size): """Read the first 'size' bytes in packet and advance cursor past them.""" result = self._data[self._position:(self._position+size)] if len(result) != size: error = ('Result length not requested length:\n' 'Expected=%s. Actual=%s. Position:...
def read(self, size): """Read the first 'size' bytes in packet and advance cursor past them.""" result = self._data[self._position:(self._position+size)] if len(result) != size: error = ('Result length not requested length:\n' 'Expected=%s. Actual=%s. Position:...
[ "Read", "the", "first", "size", "bytes", "in", "packet", "and", "advance", "cursor", "past", "them", "." ]
PyMySQL/PyMySQL
python
https://github.com/PyMySQL/PyMySQL/blob/3674bc6fd064bf88524e839c07690e8c35223709/pymysql/protocol.py#L63-L75
[ "def", "read", "(", "self", ",", "size", ")", ":", "result", "=", "self", ".", "_data", "[", "self", ".", "_position", ":", "(", "self", ".", "_position", "+", "size", ")", "]", "if", "len", "(", "result", ")", "!=", "size", ":", "error", "=", ...
3674bc6fd064bf88524e839c07690e8c35223709
train
MysqlPacket.read_all
Read all remaining data in the packet. (Subsequent read() will return errors.)
pymysql/protocol.py
def read_all(self): """Read all remaining data in the packet. (Subsequent read() will return errors.) """ result = self._data[self._position:] self._position = None # ensure no subsequent read() return result
def read_all(self): """Read all remaining data in the packet. (Subsequent read() will return errors.) """ result = self._data[self._position:] self._position = None # ensure no subsequent read() return result
[ "Read", "all", "remaining", "data", "in", "the", "packet", "." ]
PyMySQL/PyMySQL
python
https://github.com/PyMySQL/PyMySQL/blob/3674bc6fd064bf88524e839c07690e8c35223709/pymysql/protocol.py#L77-L84
[ "def", "read_all", "(", "self", ")", ":", "result", "=", "self", ".", "_data", "[", "self", ".", "_position", ":", "]", "self", ".", "_position", "=", "None", "# ensure no subsequent read()", "return", "result" ]
3674bc6fd064bf88524e839c07690e8c35223709
train
MysqlPacket.advance
Advance the cursor in data buffer 'length' bytes.
pymysql/protocol.py
def advance(self, length): """Advance the cursor in data buffer 'length' bytes.""" new_position = self._position + length if new_position < 0 or new_position > len(self._data): raise Exception('Invalid advance amount (%s) for cursor. ' 'Position=%s' % (le...
def advance(self, length): """Advance the cursor in data buffer 'length' bytes.""" new_position = self._position + length if new_position < 0 or new_position > len(self._data): raise Exception('Invalid advance amount (%s) for cursor. ' 'Position=%s' % (le...
[ "Advance", "the", "cursor", "in", "data", "buffer", "length", "bytes", "." ]
PyMySQL/PyMySQL
python
https://github.com/PyMySQL/PyMySQL/blob/3674bc6fd064bf88524e839c07690e8c35223709/pymysql/protocol.py#L86-L92
[ "def", "advance", "(", "self", ",", "length", ")", ":", "new_position", "=", "self", ".", "_position", "+", "length", "if", "new_position", "<", "0", "or", "new_position", ">", "len", "(", "self", ".", "_data", ")", ":", "raise", "Exception", "(", "'In...
3674bc6fd064bf88524e839c07690e8c35223709
train
MysqlPacket.rewind
Set the position of the data buffer cursor to 'position'.
pymysql/protocol.py
def rewind(self, position=0): """Set the position of the data buffer cursor to 'position'.""" if position < 0 or position > len(self._data): raise Exception("Invalid position to rewind cursor to: %s." % position) self._position = position
def rewind(self, position=0): """Set the position of the data buffer cursor to 'position'.""" if position < 0 or position > len(self._data): raise Exception("Invalid position to rewind cursor to: %s." % position) self._position = position
[ "Set", "the", "position", "of", "the", "data", "buffer", "cursor", "to", "position", "." ]
PyMySQL/PyMySQL
python
https://github.com/PyMySQL/PyMySQL/blob/3674bc6fd064bf88524e839c07690e8c35223709/pymysql/protocol.py#L94-L98
[ "def", "rewind", "(", "self", ",", "position", "=", "0", ")", ":", "if", "position", "<", "0", "or", "position", ">", "len", "(", "self", ".", "_data", ")", ":", "raise", "Exception", "(", "\"Invalid position to rewind cursor to: %s.\"", "%", "position", "...
3674bc6fd064bf88524e839c07690e8c35223709
train
MysqlPacket.read_length_encoded_integer
Read a 'Length Coded Binary' number from the data buffer. Length coded numbers can be anywhere from 1 to 9 bytes depending on the value of the first byte.
pymysql/protocol.py
def read_length_encoded_integer(self): """Read a 'Length Coded Binary' number from the data buffer. Length coded numbers can be anywhere from 1 to 9 bytes depending on the value of the first byte. """ c = self.read_uint8() if c == NULL_COLUMN: return None ...
def read_length_encoded_integer(self): """Read a 'Length Coded Binary' number from the data buffer. Length coded numbers can be anywhere from 1 to 9 bytes depending on the value of the first byte. """ c = self.read_uint8() if c == NULL_COLUMN: return None ...
[ "Read", "a", "Length", "Coded", "Binary", "number", "from", "the", "data", "buffer", "." ]
PyMySQL/PyMySQL
python
https://github.com/PyMySQL/PyMySQL/blob/3674bc6fd064bf88524e839c07690e8c35223709/pymysql/protocol.py#L150-L166
[ "def", "read_length_encoded_integer", "(", "self", ")", ":", "c", "=", "self", ".", "read_uint8", "(", ")", "if", "c", "==", "NULL_COLUMN", ":", "return", "None", "if", "c", "<", "UNSIGNED_CHAR_COLUMN", ":", "return", "c", "elif", "c", "==", "UNSIGNED_SHOR...
3674bc6fd064bf88524e839c07690e8c35223709
train
FieldDescriptorPacket._parse_field_descriptor
Parse the 'Field Descriptor' (Metadata) packet. This is compatible with MySQL 4.1+ (not compatible with MySQL 4.0).
pymysql/protocol.py
def _parse_field_descriptor(self, encoding): """Parse the 'Field Descriptor' (Metadata) packet. This is compatible with MySQL 4.1+ (not compatible with MySQL 4.0). """ self.catalog = self.read_length_coded_string() self.db = self.read_length_coded_string() self.table_nam...
def _parse_field_descriptor(self, encoding): """Parse the 'Field Descriptor' (Metadata) packet. This is compatible with MySQL 4.1+ (not compatible with MySQL 4.0). """ self.catalog = self.read_length_coded_string() self.db = self.read_length_coded_string() self.table_nam...
[ "Parse", "the", "Field", "Descriptor", "(", "Metadata", ")", "packet", "." ]
PyMySQL/PyMySQL
python
https://github.com/PyMySQL/PyMySQL/blob/3674bc6fd064bf88524e839c07690e8c35223709/pymysql/protocol.py#L237-L249
[ "def", "_parse_field_descriptor", "(", "self", ",", "encoding", ")", ":", "self", ".", "catalog", "=", "self", ".", "read_length_coded_string", "(", ")", "self", ".", "db", "=", "self", ".", "read_length_coded_string", "(", ")", "self", ".", "table_name", "=...
3674bc6fd064bf88524e839c07690e8c35223709
train
FieldDescriptorPacket.description
Provides a 7-item tuple compatible with the Python PEP249 DB Spec.
pymysql/protocol.py
def description(self): """Provides a 7-item tuple compatible with the Python PEP249 DB Spec.""" return ( self.name, self.type_code, None, # TODO: display_length; should this be self.length? self.get_column_length(), # 'internal_size' self.get...
def description(self): """Provides a 7-item tuple compatible with the Python PEP249 DB Spec.""" return ( self.name, self.type_code, None, # TODO: display_length; should this be self.length? self.get_column_length(), # 'internal_size' self.get...
[ "Provides", "a", "7", "-", "item", "tuple", "compatible", "with", "the", "Python", "PEP249", "DB", "Spec", "." ]
PyMySQL/PyMySQL
python
https://github.com/PyMySQL/PyMySQL/blob/3674bc6fd064bf88524e839c07690e8c35223709/pymysql/protocol.py#L253-L262
[ "def", "description", "(", "self", ")", ":", "return", "(", "self", ".", "name", ",", "self", ".", "type_code", ",", "None", ",", "# TODO: display_length; should this be self.length?", "self", ".", "get_column_length", "(", ")", ",", "# 'internal_size'", "self", ...
3674bc6fd064bf88524e839c07690e8c35223709
train
Connection.close
Send the quit message and close the socket. See `Connection.close() <https://www.python.org/dev/peps/pep-0249/#Connection.close>`_ in the specification. :raise Error: If the connection is already closed.
pymysql/connections.py
def close(self): """ Send the quit message and close the socket. See `Connection.close() <https://www.python.org/dev/peps/pep-0249/#Connection.close>`_ in the specification. :raise Error: If the connection is already closed. """ if self._closed: rais...
def close(self): """ Send the quit message and close the socket. See `Connection.close() <https://www.python.org/dev/peps/pep-0249/#Connection.close>`_ in the specification. :raise Error: If the connection is already closed. """ if self._closed: rais...
[ "Send", "the", "quit", "message", "and", "close", "the", "socket", "." ]
PyMySQL/PyMySQL
python
https://github.com/PyMySQL/PyMySQL/blob/3674bc6fd064bf88524e839c07690e8c35223709/pymysql/connections.py#L344-L364
[ "def", "close", "(", "self", ")", ":", "if", "self", ".", "_closed", ":", "raise", "err", ".", "Error", "(", "\"Already closed\"", ")", "self", ".", "_closed", "=", "True", "if", "self", ".", "_sock", "is", "None", ":", "return", "send_data", "=", "s...
3674bc6fd064bf88524e839c07690e8c35223709
train
Connection._force_close
Close connection without QUIT message
pymysql/connections.py
def _force_close(self): """Close connection without QUIT message""" if self._sock: try: self._sock.close() except: # noqa pass self._sock = None self._rfile = None
def _force_close(self): """Close connection without QUIT message""" if self._sock: try: self._sock.close() except: # noqa pass self._sock = None self._rfile = None
[ "Close", "connection", "without", "QUIT", "message" ]
PyMySQL/PyMySQL
python
https://github.com/PyMySQL/PyMySQL/blob/3674bc6fd064bf88524e839c07690e8c35223709/pymysql/connections.py#L371-L379
[ "def", "_force_close", "(", "self", ")", ":", "if", "self", ".", "_sock", ":", "try", ":", "self", ".", "_sock", ".", "close", "(", ")", "except", ":", "# noqa", "pass", "self", ".", "_sock", "=", "None", "self", ".", "_rfile", "=", "None" ]
3674bc6fd064bf88524e839c07690e8c35223709
train
Connection._send_autocommit_mode
Set whether or not to commit after every execute()
pymysql/connections.py
def _send_autocommit_mode(self): """Set whether or not to commit after every execute()""" self._execute_command(COMMAND.COM_QUERY, "SET AUTOCOMMIT = %s" % self.escape(self.autocommit_mode)) self._read_ok_packet()
def _send_autocommit_mode(self): """Set whether or not to commit after every execute()""" self._execute_command(COMMAND.COM_QUERY, "SET AUTOCOMMIT = %s" % self.escape(self.autocommit_mode)) self._read_ok_packet()
[ "Set", "whether", "or", "not", "to", "commit", "after", "every", "execute", "()" ]
PyMySQL/PyMySQL
python
https://github.com/PyMySQL/PyMySQL/blob/3674bc6fd064bf88524e839c07690e8c35223709/pymysql/connections.py#L401-L405
[ "def", "_send_autocommit_mode", "(", "self", ")", ":", "self", ".", "_execute_command", "(", "COMMAND", ".", "COM_QUERY", ",", "\"SET AUTOCOMMIT = %s\"", "%", "self", ".", "escape", "(", "self", ".", "autocommit_mode", ")", ")", "self", ".", "_read_ok_packet", ...
3674bc6fd064bf88524e839c07690e8c35223709
train
Connection.escape
Escape whatever value you pass to it. Non-standard, for internal use; do not use this in your applications.
pymysql/connections.py
def escape(self, obj, mapping=None): """Escape whatever value you pass to it. Non-standard, for internal use; do not use this in your applications. """ if isinstance(obj, str_type): return "'" + self.escape_string(obj) + "'" if isinstance(obj, (bytes, bytearray)): ...
def escape(self, obj, mapping=None): """Escape whatever value you pass to it. Non-standard, for internal use; do not use this in your applications. """ if isinstance(obj, str_type): return "'" + self.escape_string(obj) + "'" if isinstance(obj, (bytes, bytearray)): ...
[ "Escape", "whatever", "value", "you", "pass", "to", "it", "." ]
PyMySQL/PyMySQL
python
https://github.com/PyMySQL/PyMySQL/blob/3674bc6fd064bf88524e839c07690e8c35223709/pymysql/connections.py#L448-L460
[ "def", "escape", "(", "self", ",", "obj", ",", "mapping", "=", "None", ")", ":", "if", "isinstance", "(", "obj", ",", "str_type", ")", ":", "return", "\"'\"", "+", "self", ".", "escape_string", "(", "obj", ")", "+", "\"'\"", "if", "isinstance", "(", ...
3674bc6fd064bf88524e839c07690e8c35223709
train
Connection.ping
Check if the server is alive. :param reconnect: If the connection is closed, reconnect. :raise Error: If the connection is closed and reconnect=False.
pymysql/connections.py
def ping(self, reconnect=True): """ Check if the server is alive. :param reconnect: If the connection is closed, reconnect. :raise Error: If the connection is closed and reconnect=False. """ if self._sock is None: if reconnect: self.connect() ...
def ping(self, reconnect=True): """ Check if the server is alive. :param reconnect: If the connection is closed, reconnect. :raise Error: If the connection is closed and reconnect=False. """ if self._sock is None: if reconnect: self.connect() ...
[ "Check", "if", "the", "server", "is", "alive", "." ]
PyMySQL/PyMySQL
python
https://github.com/PyMySQL/PyMySQL/blob/3674bc6fd064bf88524e839c07690e8c35223709/pymysql/connections.py#L518-L539
[ "def", "ping", "(", "self", ",", "reconnect", "=", "True", ")", ":", "if", "self", ".", "_sock", "is", "None", ":", "if", "reconnect", ":", "self", ".", "connect", "(", ")", "reconnect", "=", "False", "else", ":", "raise", "err", ".", "Error", "(",...
3674bc6fd064bf88524e839c07690e8c35223709
train
Connection._read_packet
Read an entire "mysql packet" in its entirety from the network and return a MysqlPacket type that represents the results. :raise OperationalError: If the connection to the MySQL server is lost. :raise InternalError: If the packet sequence number is wrong.
pymysql/connections.py
def _read_packet(self, packet_type=MysqlPacket): """Read an entire "mysql packet" in its entirety from the network and return a MysqlPacket type that represents the results. :raise OperationalError: If the connection to the MySQL server is lost. :raise InternalError: If the packet seque...
def _read_packet(self, packet_type=MysqlPacket): """Read an entire "mysql packet" in its entirety from the network and return a MysqlPacket type that represents the results. :raise OperationalError: If the connection to the MySQL server is lost. :raise InternalError: If the packet seque...
[ "Read", "an", "entire", "mysql", "packet", "in", "its", "entirety", "from", "the", "network", "and", "return", "a", "MysqlPacket", "type", "that", "represents", "the", "results", "." ]
PyMySQL/PyMySQL
python
https://github.com/PyMySQL/PyMySQL/blob/3674bc6fd064bf88524e839c07690e8c35223709/pymysql/connections.py#L635-L672
[ "def", "_read_packet", "(", "self", ",", "packet_type", "=", "MysqlPacket", ")", ":", "buff", "=", "bytearray", "(", ")", "while", "True", ":", "packet_header", "=", "self", ".", "_read_bytes", "(", "4", ")", "#if DEBUG: dump_packet(packet_header)", "btrl", ",...
3674bc6fd064bf88524e839c07690e8c35223709
train
Connection._execute_command
:raise InterfaceError: If the connection is closed. :raise ValueError: If no username was specified.
pymysql/connections.py
def _execute_command(self, command, sql): """ :raise InterfaceError: If the connection is closed. :raise ValueError: If no username was specified. """ if not self._sock: raise err.InterfaceError("(0, '')") # If the last query was unbuffered, make sure it fini...
def _execute_command(self, command, sql): """ :raise InterfaceError: If the connection is closed. :raise ValueError: If no username was specified. """ if not self._sock: raise err.InterfaceError("(0, '')") # If the last query was unbuffered, make sure it fini...
[ ":", "raise", "InterfaceError", ":", "If", "the", "connection", "is", "closed", ".", ":", "raise", "ValueError", ":", "If", "no", "username", "was", "specified", "." ]
PyMySQL/PyMySQL
python
https://github.com/PyMySQL/PyMySQL/blob/3674bc6fd064bf88524e839c07690e8c35223709/pymysql/connections.py#L731-L771
[ "def", "_execute_command", "(", "self", ",", "command", ",", "sql", ")", ":", "if", "not", "self", ".", "_sock", ":", "raise", "err", ".", "InterfaceError", "(", "\"(0, '')\"", ")", "# If the last query was unbuffered, make sure it finishes before", "# sending new com...
3674bc6fd064bf88524e839c07690e8c35223709
train
LoadLocalFile.send_data
Send data packets from the local file to the server
pymysql/connections.py
def send_data(self): """Send data packets from the local file to the server""" if not self.connection._sock: raise err.InterfaceError("(0, '')") conn = self.connection try: with open(self.filename, 'rb') as open_file: packet_size = min(conn.max_al...
def send_data(self): """Send data packets from the local file to the server""" if not self.connection._sock: raise err.InterfaceError("(0, '')") conn = self.connection try: with open(self.filename, 'rb') as open_file: packet_size = min(conn.max_al...
[ "Send", "data", "packets", "from", "the", "local", "file", "to", "the", "server" ]
PyMySQL/PyMySQL
python
https://github.com/PyMySQL/PyMySQL/blob/3674bc6fd064bf88524e839c07690e8c35223709/pymysql/connections.py#L1248-L1266
[ "def", "send_data", "(", "self", ")", ":", "if", "not", "self", ".", "connection", ".", "_sock", ":", "raise", "err", ".", "InterfaceError", "(", "\"(0, '')\"", ")", "conn", "=", "self", ".", "connection", "try", ":", "with", "open", "(", "self", ".", ...
3674bc6fd064bf88524e839c07690e8c35223709