id
int32
0
252k
repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
237,600
douban/libmc
misc/runbench.py
benchmark_method
def benchmark_method(f): "decorator to turn f into a factory of benchmarks" @wraps(f) def inner(name, *args, **kwargs): return Benchmark(name, f, args, kwargs) return inner
python
def benchmark_method(f): "decorator to turn f into a factory of benchmarks" @wraps(f) def inner(name, *args, **kwargs): return Benchmark(name, f, args, kwargs) return inner
[ "def", "benchmark_method", "(", "f", ")", ":", "@", "wraps", "(", "f", ")", "def", "inner", "(", "name", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "Benchmark", "(", "name", ",", "f", ",", "args", ",", "kwargs", ")", "return",...
decorator to turn f into a factory of benchmarks
[ "decorator", "to", "turn", "f", "into", "a", "factory", "of", "benchmarks" ]
12e5528e55708d08003671c10267287ed77e4dc4
https://github.com/douban/libmc/blob/12e5528e55708d08003671c10267287ed77e4dc4/misc/runbench.py#L118-L123
237,601
douban/libmc
misc/runbench.py
bench
def bench(participants=participants, benchmarks=benchmarks, bench_time=BENCH_TIME): """Do you even lift?""" mcs = [p.factory() for p in participants] means = [[] for p in participants] stddevs = [[] for p in participants] # Have each lifter do one benchmark each last_fn = None fo...
python
def bench(participants=participants, benchmarks=benchmarks, bench_time=BENCH_TIME): """Do you even lift?""" mcs = [p.factory() for p in participants] means = [[] for p in participants] stddevs = [[] for p in participants] # Have each lifter do one benchmark each last_fn = None fo...
[ "def", "bench", "(", "participants", "=", "participants", ",", "benchmarks", "=", "benchmarks", ",", "bench_time", "=", "BENCH_TIME", ")", ":", "mcs", "=", "[", "p", ".", "factory", "(", ")", "for", "p", "in", "participants", "]", "means", "=", "[", "[...
Do you even lift?
[ "Do", "you", "even", "lift?" ]
12e5528e55708d08003671c10267287ed77e4dc4
https://github.com/douban/libmc/blob/12e5528e55708d08003671c10267287ed77e4dc4/misc/runbench.py#L266-L297
237,602
liampauling/betfair
betfairlightweight/resources/baseresource.py
BaseResource.strip_datetime
def strip_datetime(value): """ Converts value to datetime if string or int. """ if isinstance(value, basestring): try: return parse_datetime(value) except ValueError: return elif isinstance(value, integer_types): ...
python
def strip_datetime(value): """ Converts value to datetime if string or int. """ if isinstance(value, basestring): try: return parse_datetime(value) except ValueError: return elif isinstance(value, integer_types): ...
[ "def", "strip_datetime", "(", "value", ")", ":", "if", "isinstance", "(", "value", ",", "basestring", ")", ":", "try", ":", "return", "parse_datetime", "(", "value", ")", "except", "ValueError", ":", "return", "elif", "isinstance", "(", "value", ",", "inte...
Converts value to datetime if string or int.
[ "Converts", "value", "to", "datetime", "if", "string", "or", "int", "." ]
8479392eb4849c525d78d43497c32c0bb108e977
https://github.com/liampauling/betfair/blob/8479392eb4849c525d78d43497c32c0bb108e977/betfairlightweight/resources/baseresource.py#L26-L39
237,603
liampauling/betfair
betfairlightweight/baseclient.py
BaseClient.set_session_token
def set_session_token(self, session_token): """ Sets session token and new login time. :param str session_token: Session token from request. """ self.session_token = session_token self._login_time = datetime.datetime.now()
python
def set_session_token(self, session_token): """ Sets session token and new login time. :param str session_token: Session token from request. """ self.session_token = session_token self._login_time = datetime.datetime.now()
[ "def", "set_session_token", "(", "self", ",", "session_token", ")", ":", "self", ".", "session_token", "=", "session_token", "self", ".", "_login_time", "=", "datetime", ".", "datetime", ".", "now", "(", ")" ]
Sets session token and new login time. :param str session_token: Session token from request.
[ "Sets", "session", "token", "and", "new", "login", "time", "." ]
8479392eb4849c525d78d43497c32c0bb108e977
https://github.com/liampauling/betfair/blob/8479392eb4849c525d78d43497c32c0bb108e977/betfairlightweight/baseclient.py#L78-L85
237,604
liampauling/betfair
betfairlightweight/baseclient.py
BaseClient.get_password
def get_password(self): """ If password is not provided will look in environment variables for username+'password'. """ if self.password is None: if os.environ.get(self.username+'password'): self.password = os.environ.get(self.username+'password') ...
python
def get_password(self): """ If password is not provided will look in environment variables for username+'password'. """ if self.password is None: if os.environ.get(self.username+'password'): self.password = os.environ.get(self.username+'password') ...
[ "def", "get_password", "(", "self", ")", ":", "if", "self", ".", "password", "is", "None", ":", "if", "os", ".", "environ", ".", "get", "(", "self", ".", "username", "+", "'password'", ")", ":", "self", ".", "password", "=", "os", ".", "environ", "...
If password is not provided will look in environment variables for username+'password'.
[ "If", "password", "is", "not", "provided", "will", "look", "in", "environment", "variables", "for", "username", "+", "password", "." ]
8479392eb4849c525d78d43497c32c0bb108e977
https://github.com/liampauling/betfair/blob/8479392eb4849c525d78d43497c32c0bb108e977/betfairlightweight/baseclient.py#L87-L96
237,605
liampauling/betfair
betfairlightweight/baseclient.py
BaseClient.get_app_key
def get_app_key(self): """ If app_key is not provided will look in environment variables for username. """ if self.app_key is None: if os.environ.get(self.username): self.app_key = os.environ.get(self.username) else: raise A...
python
def get_app_key(self): """ If app_key is not provided will look in environment variables for username. """ if self.app_key is None: if os.environ.get(self.username): self.app_key = os.environ.get(self.username) else: raise A...
[ "def", "get_app_key", "(", "self", ")", ":", "if", "self", ".", "app_key", "is", "None", ":", "if", "os", ".", "environ", ".", "get", "(", "self", ".", "username", ")", ":", "self", ".", "app_key", "=", "os", ".", "environ", ".", "get", "(", "sel...
If app_key is not provided will look in environment variables for username.
[ "If", "app_key", "is", "not", "provided", "will", "look", "in", "environment", "variables", "for", "username", "." ]
8479392eb4849c525d78d43497c32c0bb108e977
https://github.com/liampauling/betfair/blob/8479392eb4849c525d78d43497c32c0bb108e977/betfairlightweight/baseclient.py#L98-L107
237,606
liampauling/betfair
betfairlightweight/baseclient.py
BaseClient.session_expired
def session_expired(self): """ Returns True if login_time not set or seconds since login time is greater than 200 mins. """ if not self._login_time or (datetime.datetime.now()-self._login_time).total_seconds() > 12000: return True
python
def session_expired(self): """ Returns True if login_time not set or seconds since login time is greater than 200 mins. """ if not self._login_time or (datetime.datetime.now()-self._login_time).total_seconds() > 12000: return True
[ "def", "session_expired", "(", "self", ")", ":", "if", "not", "self", ".", "_login_time", "or", "(", "datetime", ".", "datetime", ".", "now", "(", ")", "-", "self", ".", "_login_time", ")", ".", "total_seconds", "(", ")", ">", "12000", ":", "return", ...
Returns True if login_time not set or seconds since login time is greater than 200 mins.
[ "Returns", "True", "if", "login_time", "not", "set", "or", "seconds", "since", "login", "time", "is", "greater", "than", "200", "mins", "." ]
8479392eb4849c525d78d43497c32c0bb108e977
https://github.com/liampauling/betfair/blob/8479392eb4849c525d78d43497c32c0bb108e977/betfairlightweight/baseclient.py#L117-L123
237,607
liampauling/betfair
betfairlightweight/utils.py
check_status_code
def check_status_code(response, codes=None): """ Checks response.status_code is in codes. :param requests.request response: Requests response :param list codes: List of accepted codes or callable :raises: StatusCodeError if code invalid """ codes = codes or [200] if response.status_code...
python
def check_status_code(response, codes=None): """ Checks response.status_code is in codes. :param requests.request response: Requests response :param list codes: List of accepted codes or callable :raises: StatusCodeError if code invalid """ codes = codes or [200] if response.status_code...
[ "def", "check_status_code", "(", "response", ",", "codes", "=", "None", ")", ":", "codes", "=", "codes", "or", "[", "200", "]", "if", "response", ".", "status_code", "not", "in", "codes", ":", "raise", "StatusCodeError", "(", "response", ".", "status_code"...
Checks response.status_code is in codes. :param requests.request response: Requests response :param list codes: List of accepted codes or callable :raises: StatusCodeError if code invalid
[ "Checks", "response", ".", "status_code", "is", "in", "codes", "." ]
8479392eb4849c525d78d43497c32c0bb108e977
https://github.com/liampauling/betfair/blob/8479392eb4849c525d78d43497c32c0bb108e977/betfairlightweight/utils.py#L7-L17
237,608
liampauling/betfair
betfairlightweight/endpoints/betting.py
Betting.list_runner_book
def list_runner_book(self, market_id, selection_id, handicap=None, price_projection=None, order_projection=None, match_projection=None, include_overall_position=None, partition_matched_by_strategy_ref=None, customer_strategy_refs=None, currency_code=None, matched_since=...
python
def list_runner_book(self, market_id, selection_id, handicap=None, price_projection=None, order_projection=None, match_projection=None, include_overall_position=None, partition_matched_by_strategy_ref=None, customer_strategy_refs=None, currency_code=None, matched_since=...
[ "def", "list_runner_book", "(", "self", ",", "market_id", ",", "selection_id", ",", "handicap", "=", "None", ",", "price_projection", "=", "None", ",", "order_projection", "=", "None", ",", "match_projection", "=", "None", ",", "include_overall_position", "=", "...
Returns a list of dynamic data about a market and a specified runner. Dynamic data includes prices, the status of the market, the status of selections, the traded volume, and the status of any orders you have placed in the market :param unicode market_id: The unique id for the market ...
[ "Returns", "a", "list", "of", "dynamic", "data", "about", "a", "market", "and", "a", "specified", "runner", ".", "Dynamic", "data", "includes", "prices", "the", "status", "of", "the", "market", "the", "status", "of", "selections", "the", "traded", "volume", ...
8479392eb4849c525d78d43497c32c0bb108e977
https://github.com/liampauling/betfair/blob/8479392eb4849c525d78d43497c32c0bb108e977/betfairlightweight/endpoints/betting.py#L193-L226
237,609
liampauling/betfair
betfairlightweight/endpoints/betting.py
Betting.list_current_orders
def list_current_orders(self, bet_ids=None, market_ids=None, order_projection=None, customer_order_refs=None, customer_strategy_refs=None, date_range=time_range(), order_by=None, sort_dir=None, from_record=None, record_count=None, session=None, lightweight=None): ...
python
def list_current_orders(self, bet_ids=None, market_ids=None, order_projection=None, customer_order_refs=None, customer_strategy_refs=None, date_range=time_range(), order_by=None, sort_dir=None, from_record=None, record_count=None, session=None, lightweight=None): ...
[ "def", "list_current_orders", "(", "self", ",", "bet_ids", "=", "None", ",", "market_ids", "=", "None", ",", "order_projection", "=", "None", ",", "customer_order_refs", "=", "None", ",", "customer_strategy_refs", "=", "None", ",", "date_range", "=", "time_range...
Returns a list of your current orders. :param list bet_ids: If you ask for orders, restricts the results to orders with the specified bet IDs :param list market_ids: One or more market ids :param str order_projection: Optionally restricts the results to the specified order status :param...
[ "Returns", "a", "list", "of", "your", "current", "orders", "." ]
8479392eb4849c525d78d43497c32c0bb108e977
https://github.com/liampauling/betfair/blob/8479392eb4849c525d78d43497c32c0bb108e977/betfairlightweight/endpoints/betting.py#L228-L255
237,610
liampauling/betfair
betfairlightweight/endpoints/betting.py
Betting.list_cleared_orders
def list_cleared_orders(self, bet_status='SETTLED', event_type_ids=None, event_ids=None, market_ids=None, runner_ids=None, bet_ids=None, customer_order_refs=None, customer_strategy_refs=None, side=None, settled_date_range=time_range(), group_by=None, include_item_...
python
def list_cleared_orders(self, bet_status='SETTLED', event_type_ids=None, event_ids=None, market_ids=None, runner_ids=None, bet_ids=None, customer_order_refs=None, customer_strategy_refs=None, side=None, settled_date_range=time_range(), group_by=None, include_item_...
[ "def", "list_cleared_orders", "(", "self", ",", "bet_status", "=", "'SETTLED'", ",", "event_type_ids", "=", "None", ",", "event_ids", "=", "None", ",", "market_ids", "=", "None", ",", "runner_ids", "=", "None", ",", "bet_ids", "=", "None", ",", "customer_ord...
Returns a list of settled bets based on the bet status, ordered by settled date. :param str bet_status: Restricts the results to the specified status :param list event_type_ids: Optionally restricts the results to the specified Event Type IDs :param list event_ids: Optionally restricts ...
[ "Returns", "a", "list", "of", "settled", "bets", "based", "on", "the", "bet", "status", "ordered", "by", "settled", "date", "." ]
8479392eb4849c525d78d43497c32c0bb108e977
https://github.com/liampauling/betfair/blob/8479392eb4849c525d78d43497c32c0bb108e977/betfairlightweight/endpoints/betting.py#L257-L289
237,611
liampauling/betfair
betfairlightweight/endpoints/betting.py
Betting.list_market_profit_and_loss
def list_market_profit_and_loss(self, market_ids, include_settled_bets=None, include_bsp_bets=None, net_of_commission=None, session=None, lightweight=None): """ Retrieve profit and loss for a given list of OPEN markets. :param list market_ids: List of markets...
python
def list_market_profit_and_loss(self, market_ids, include_settled_bets=None, include_bsp_bets=None, net_of_commission=None, session=None, lightweight=None): """ Retrieve profit and loss for a given list of OPEN markets. :param list market_ids: List of markets...
[ "def", "list_market_profit_and_loss", "(", "self", ",", "market_ids", ",", "include_settled_bets", "=", "None", ",", "include_bsp_bets", "=", "None", ",", "net_of_commission", "=", "None", ",", "session", "=", "None", ",", "lightweight", "=", "None", ")", ":", ...
Retrieve profit and loss for a given list of OPEN markets. :param list market_ids: List of markets to calculate profit and loss :param bool include_settled_bets: Option to include settled bets (partially settled markets only) :param bool include_bsp_bets: Option to include BSP bets :par...
[ "Retrieve", "profit", "and", "loss", "for", "a", "given", "list", "of", "OPEN", "markets", "." ]
8479392eb4849c525d78d43497c32c0bb108e977
https://github.com/liampauling/betfair/blob/8479392eb4849c525d78d43497c32c0bb108e977/betfairlightweight/endpoints/betting.py#L291-L309
237,612
liampauling/betfair
betfairlightweight/endpoints/betting.py
Betting.place_orders
def place_orders(self, market_id, instructions, customer_ref=None, market_version=None, customer_strategy_ref=None, async_=None, session=None, lightweight=None): """ Place new orders into market. :param str market_id: The market id these orders are to be placed on :...
python
def place_orders(self, market_id, instructions, customer_ref=None, market_version=None, customer_strategy_ref=None, async_=None, session=None, lightweight=None): """ Place new orders into market. :param str market_id: The market id these orders are to be placed on :...
[ "def", "place_orders", "(", "self", ",", "market_id", ",", "instructions", ",", "customer_ref", "=", "None", ",", "market_version", "=", "None", ",", "customer_strategy_ref", "=", "None", ",", "async_", "=", "None", ",", "session", "=", "None", ",", "lightwe...
Place new orders into market. :param str market_id: The market id these orders are to be placed on :param list instructions: The number of place instructions :param str customer_ref: Optional parameter allowing the client to pass a unique string (up to 32 chars) that is used to de-dupe ...
[ "Place", "new", "orders", "into", "market", "." ]
8479392eb4849c525d78d43497c32c0bb108e977
https://github.com/liampauling/betfair/blob/8479392eb4849c525d78d43497c32c0bb108e977/betfairlightweight/endpoints/betting.py#L311-L334
237,613
liampauling/betfair
betfairlightweight/streaming/cache.py
MarketBookCache.serialise
def serialise(self): """Creates standard market book json response, will error if EX_MARKET_DEF not incl. """ return { 'marketId': self.market_id, 'totalAvailable': None, 'isMarketDataDelayed': None, 'lastMatchTime': None, 'betD...
python
def serialise(self): """Creates standard market book json response, will error if EX_MARKET_DEF not incl. """ return { 'marketId': self.market_id, 'totalAvailable': None, 'isMarketDataDelayed': None, 'lastMatchTime': None, 'betD...
[ "def", "serialise", "(", "self", ")", ":", "return", "{", "'marketId'", ":", "self", ".", "market_id", ",", "'totalAvailable'", ":", "None", ",", "'isMarketDataDelayed'", ":", "None", ",", "'lastMatchTime'", ":", "None", ",", "'betDelay'", ":", "self", ".", ...
Creates standard market book json response, will error if EX_MARKET_DEF not incl.
[ "Creates", "standard", "market", "book", "json", "response", "will", "error", "if", "EX_MARKET_DEF", "not", "incl", "." ]
8479392eb4849c525d78d43497c32c0bb108e977
https://github.com/liampauling/betfair/blob/8479392eb4849c525d78d43497c32c0bb108e977/betfairlightweight/streaming/cache.py#L223-L253
237,614
liampauling/betfair
betfairlightweight/endpoints/scores.py
Scores.list_race_details
def list_race_details(self, meeting_ids=None, race_ids=None, session=None, lightweight=None): """ Search for races to get their details. :param dict meeting_ids: Optionally restricts the results to the specified meeting IDs. The unique Id for the meeting equivalent to the eventId for th...
python
def list_race_details(self, meeting_ids=None, race_ids=None, session=None, lightweight=None): """ Search for races to get their details. :param dict meeting_ids: Optionally restricts the results to the specified meeting IDs. The unique Id for the meeting equivalent to the eventId for th...
[ "def", "list_race_details", "(", "self", ",", "meeting_ids", "=", "None", ",", "race_ids", "=", "None", ",", "session", "=", "None", ",", "lightweight", "=", "None", ")", ":", "params", "=", "clean_locals", "(", "locals", "(", ")", ")", "method", "=", ...
Search for races to get their details. :param dict meeting_ids: Optionally restricts the results to the specified meeting IDs. The unique Id for the meeting equivalent to the eventId for that specific race as returned by listEvents :param str race_ids: Optionally restricts the results t...
[ "Search", "for", "races", "to", "get", "their", "details", "." ]
8479392eb4849c525d78d43497c32c0bb108e977
https://github.com/liampauling/betfair/blob/8479392eb4849c525d78d43497c32c0bb108e977/betfairlightweight/endpoints/scores.py#L13-L30
237,615
liampauling/betfair
betfairlightweight/endpoints/scores.py
Scores.list_available_events
def list_available_events(self, event_ids=None, event_type_ids=None, event_status=None, session=None, lightweight=None): """ Search for events that have live score data available. :param list event_ids: Optionally restricts the results to the specified event IDs ...
python
def list_available_events(self, event_ids=None, event_type_ids=None, event_status=None, session=None, lightweight=None): """ Search for events that have live score data available. :param list event_ids: Optionally restricts the results to the specified event IDs ...
[ "def", "list_available_events", "(", "self", ",", "event_ids", "=", "None", ",", "event_type_ids", "=", "None", ",", "event_status", "=", "None", ",", "session", "=", "None", ",", "lightweight", "=", "None", ")", ":", "params", "=", "clean_locals", "(", "l...
Search for events that have live score data available. :param list event_ids: Optionally restricts the results to the specified event IDs :param list event_type_ids: Optionally restricts the results to the specified event type IDs :param list event_status: Optionally restricts the results to th...
[ "Search", "for", "events", "that", "have", "live", "score", "data", "available", "." ]
8479392eb4849c525d78d43497c32c0bb108e977
https://github.com/liampauling/betfair/blob/8479392eb4849c525d78d43497c32c0bb108e977/betfairlightweight/endpoints/scores.py#L34-L50
237,616
liampauling/betfair
betfairlightweight/endpoints/scores.py
Scores.list_scores
def list_scores(self, update_keys, session=None, lightweight=None): """ Returns a list of current scores for the given events. :param list update_keys: The filter to select desired markets. All markets that match the criteria in the filter are selected e.g. [{'eventId': '28205674', 'las...
python
def list_scores(self, update_keys, session=None, lightweight=None): """ Returns a list of current scores for the given events. :param list update_keys: The filter to select desired markets. All markets that match the criteria in the filter are selected e.g. [{'eventId': '28205674', 'las...
[ "def", "list_scores", "(", "self", ",", "update_keys", ",", "session", "=", "None", ",", "lightweight", "=", "None", ")", ":", "params", "=", "clean_locals", "(", "locals", "(", ")", ")", "method", "=", "'%s%s'", "%", "(", "self", ".", "URI", ",", "'...
Returns a list of current scores for the given events. :param list update_keys: The filter to select desired markets. All markets that match the criteria in the filter are selected e.g. [{'eventId': '28205674', 'lastUpdateSequenceProcessed': 2}] :param requests.session session: Requests session...
[ "Returns", "a", "list", "of", "current", "scores", "for", "the", "given", "events", "." ]
8479392eb4849c525d78d43497c32c0bb108e977
https://github.com/liampauling/betfair/blob/8479392eb4849c525d78d43497c32c0bb108e977/betfairlightweight/endpoints/scores.py#L52-L66
237,617
liampauling/betfair
betfairlightweight/endpoints/scores.py
Scores.list_incidents
def list_incidents(self, update_keys, session=None, lightweight=None): """ Returns a list of incidents for the given events. :param dict update_keys: The filter to select desired markets. All markets that match the criteria in the filter are selected e.g. [{'eventId': '28205674', 'lastU...
python
def list_incidents(self, update_keys, session=None, lightweight=None): """ Returns a list of incidents for the given events. :param dict update_keys: The filter to select desired markets. All markets that match the criteria in the filter are selected e.g. [{'eventId': '28205674', 'lastU...
[ "def", "list_incidents", "(", "self", ",", "update_keys", ",", "session", "=", "None", ",", "lightweight", "=", "None", ")", ":", "params", "=", "clean_locals", "(", "locals", "(", ")", ")", "method", "=", "'%s%s'", "%", "(", "self", ".", "URI", ",", ...
Returns a list of incidents for the given events. :param dict update_keys: The filter to select desired markets. All markets that match the criteria in the filter are selected e.g. [{'eventId': '28205674', 'lastUpdateSequenceProcessed': 2}] :param requests.session session: Requests session obje...
[ "Returns", "a", "list", "of", "incidents", "for", "the", "given", "events", "." ]
8479392eb4849c525d78d43497c32c0bb108e977
https://github.com/liampauling/betfair/blob/8479392eb4849c525d78d43497c32c0bb108e977/betfairlightweight/endpoints/scores.py#L68-L82
237,618
liampauling/betfair
betfairlightweight/endpoints/inplayservice.py
InPlayService.get_event_timeline
def get_event_timeline(self, event_id, session=None, lightweight=None): """ Returns event timeline for event id provided. :param int event_id: Event id to return :param requests.session session: Requests session object :param bool lightweight: If True will return dict not a reso...
python
def get_event_timeline(self, event_id, session=None, lightweight=None): """ Returns event timeline for event id provided. :param int event_id: Event id to return :param requests.session session: Requests session object :param bool lightweight: If True will return dict not a reso...
[ "def", "get_event_timeline", "(", "self", ",", "event_id", ",", "session", "=", "None", ",", "lightweight", "=", "None", ")", ":", "url", "=", "'%s%s'", "%", "(", "self", ".", "url", ",", "'eventTimeline'", ")", "params", "=", "{", "'eventId'", ":", "e...
Returns event timeline for event id provided. :param int event_id: Event id to return :param requests.session session: Requests session object :param bool lightweight: If True will return dict not a resource :rtype: resources.EventTimeline
[ "Returns", "event", "timeline", "for", "event", "id", "provided", "." ]
8479392eb4849c525d78d43497c32c0bb108e977
https://github.com/liampauling/betfair/blob/8479392eb4849c525d78d43497c32c0bb108e977/betfairlightweight/endpoints/inplayservice.py#L18-L36
237,619
liampauling/betfair
betfairlightweight/endpoints/inplayservice.py
InPlayService.get_event_timelines
def get_event_timelines(self, event_ids, session=None, lightweight=None): """ Returns a list of event timelines based on event id's supplied. :param list event_ids: List of event id's to return :param requests.session session: Requests session object :param bool lightwei...
python
def get_event_timelines(self, event_ids, session=None, lightweight=None): """ Returns a list of event timelines based on event id's supplied. :param list event_ids: List of event id's to return :param requests.session session: Requests session object :param bool lightwei...
[ "def", "get_event_timelines", "(", "self", ",", "event_ids", ",", "session", "=", "None", ",", "lightweight", "=", "None", ")", ":", "url", "=", "'%s%s'", "%", "(", "self", ".", "url", ",", "'eventTimelines'", ")", "params", "=", "{", "'eventIds'", ":", ...
Returns a list of event timelines based on event id's supplied. :param list event_ids: List of event id's to return :param requests.session session: Requests session object :param bool lightweight: If True will return dict not a resource :rtype: list[resources.EventTimeline]
[ "Returns", "a", "list", "of", "event", "timelines", "based", "on", "event", "id", "s", "supplied", "." ]
8479392eb4849c525d78d43497c32c0bb108e977
https://github.com/liampauling/betfair/blob/8479392eb4849c525d78d43497c32c0bb108e977/betfairlightweight/endpoints/inplayservice.py#L38-L57
237,620
liampauling/betfair
betfairlightweight/endpoints/inplayservice.py
InPlayService.get_scores
def get_scores(self, event_ids, session=None, lightweight=None): """ Returns a list of scores based on event id's supplied. :param list event_ids: List of event id's to return :param requests.session session: Requests session object :param bool lightweight: If True will ...
python
def get_scores(self, event_ids, session=None, lightweight=None): """ Returns a list of scores based on event id's supplied. :param list event_ids: List of event id's to return :param requests.session session: Requests session object :param bool lightweight: If True will ...
[ "def", "get_scores", "(", "self", ",", "event_ids", ",", "session", "=", "None", ",", "lightweight", "=", "None", ")", ":", "url", "=", "'%s%s'", "%", "(", "self", ".", "url", ",", "'scores'", ")", "params", "=", "{", "'eventIds'", ":", "','", ".", ...
Returns a list of scores based on event id's supplied. :param list event_ids: List of event id's to return :param requests.session session: Requests session object :param bool lightweight: If True will return dict not a resource :rtype: list[resources.Scores]
[ "Returns", "a", "list", "of", "scores", "based", "on", "event", "id", "s", "supplied", "." ]
8479392eb4849c525d78d43497c32c0bb108e977
https://github.com/liampauling/betfair/blob/8479392eb4849c525d78d43497c32c0bb108e977/betfairlightweight/endpoints/inplayservice.py#L59-L78
237,621
liampauling/betfair
betfairlightweight/endpoints/streaming.py
Streaming.create_stream
def create_stream(self, unique_id=0, listener=None, timeout=11, buffer_size=1024, description='BetfairSocket', host=None): """ Creates BetfairStream. :param dict unique_id: Id used to start unique id's of the stream (+1 before every request) :param resources.Listen...
python
def create_stream(self, unique_id=0, listener=None, timeout=11, buffer_size=1024, description='BetfairSocket', host=None): """ Creates BetfairStream. :param dict unique_id: Id used to start unique id's of the stream (+1 before every request) :param resources.Listen...
[ "def", "create_stream", "(", "self", ",", "unique_id", "=", "0", ",", "listener", "=", "None", ",", "timeout", "=", "11", ",", "buffer_size", "=", "1024", ",", "description", "=", "'BetfairSocket'", ",", "host", "=", "None", ")", ":", "listener", "=", ...
Creates BetfairStream. :param dict unique_id: Id used to start unique id's of the stream (+1 before every request) :param resources.Listener listener: Listener class to use :param float timeout: Socket timeout :param int buffer_size: Socket buffer size :param str description: B...
[ "Creates", "BetfairStream", "." ]
8479392eb4849c525d78d43497c32c0bb108e977
https://github.com/liampauling/betfair/blob/8479392eb4849c525d78d43497c32c0bb108e977/betfairlightweight/endpoints/streaming.py#L19-L43
237,622
liampauling/betfair
betfairlightweight/endpoints/historic.py
Historic.get_my_data
def get_my_data(self, session=None): """ Returns a list of data descriptions for data which has been purchased by the signed in user. :param requests.session session: Requests session object :rtype: dict """ params = clean_locals(locals()) method = 'GetMyData' ...
python
def get_my_data(self, session=None): """ Returns a list of data descriptions for data which has been purchased by the signed in user. :param requests.session session: Requests session object :rtype: dict """ params = clean_locals(locals()) method = 'GetMyData' ...
[ "def", "get_my_data", "(", "self", ",", "session", "=", "None", ")", ":", "params", "=", "clean_locals", "(", "locals", "(", ")", ")", "method", "=", "'GetMyData'", "(", "response", ",", "elapsed_time", ")", "=", "self", ".", "request", "(", "method", ...
Returns a list of data descriptions for data which has been purchased by the signed in user. :param requests.session session: Requests session object :rtype: dict
[ "Returns", "a", "list", "of", "data", "descriptions", "for", "data", "which", "has", "been", "purchased", "by", "the", "signed", "in", "user", "." ]
8479392eb4849c525d78d43497c32c0bb108e977
https://github.com/liampauling/betfair/blob/8479392eb4849c525d78d43497c32c0bb108e977/betfairlightweight/endpoints/historic.py#L22-L33
237,623
liampauling/betfair
betfairlightweight/endpoints/historic.py
Historic.get_data_size
def get_data_size(self, sport, plan, from_day, from_month, from_year, to_day, to_month, to_year, event_id=None, event_name=None, market_types_collection=None, countries_collection=None, file_type_collection=None, session=None): """ Returns a dictionary of file...
python
def get_data_size(self, sport, plan, from_day, from_month, from_year, to_day, to_month, to_year, event_id=None, event_name=None, market_types_collection=None, countries_collection=None, file_type_collection=None, session=None): """ Returns a dictionary of file...
[ "def", "get_data_size", "(", "self", ",", "sport", ",", "plan", ",", "from_day", ",", "from_month", ",", "from_year", ",", "to_day", ",", "to_month", ",", "to_year", ",", "event_id", "=", "None", ",", "event_name", "=", "None", ",", "market_types_collection"...
Returns a dictionary of file count and combines size files. :param sport: sport to filter data for. :param plan: plan type to filter for, Basic Plan, Advanced Plan or Pro Plan. :param from_day: day of month to start data from. :param from_month: month to start data from. :param ...
[ "Returns", "a", "dictionary", "of", "file", "count", "and", "combines", "size", "files", "." ]
8479392eb4849c525d78d43497c32c0bb108e977
https://github.com/liampauling/betfair/blob/8479392eb4849c525d78d43497c32c0bb108e977/betfairlightweight/endpoints/historic.py#L63-L89
237,624
liampauling/betfair
betfairlightweight/endpoints/racecard.py
RaceCard.login
def login(self, session=None): """ Parses app key from betfair exchange site. :param requests.session session: Requests session object """ session = session or self.client.session try: response = session.get(self.login_url) except ConnectionError: ...
python
def login(self, session=None): """ Parses app key from betfair exchange site. :param requests.session session: Requests session object """ session = session or self.client.session try: response = session.get(self.login_url) except ConnectionError: ...
[ "def", "login", "(", "self", ",", "session", "=", "None", ")", ":", "session", "=", "session", "or", "self", ".", "client", ".", "session", "try", ":", "response", "=", "session", ".", "get", "(", "self", ".", "login_url", ")", "except", "ConnectionErr...
Parses app key from betfair exchange site. :param requests.session session: Requests session object
[ "Parses", "app", "key", "from", "betfair", "exchange", "site", "." ]
8479392eb4849c525d78d43497c32c0bb108e977
https://github.com/liampauling/betfair/blob/8479392eb4849c525d78d43497c32c0bb108e977/betfairlightweight/endpoints/racecard.py#L22-L39
237,625
liampauling/betfair
betfairlightweight/endpoints/racecard.py
RaceCard.get_race_card
def get_race_card(self, market_ids, data_entries=None, session=None, lightweight=None): """ Returns a list of race cards based on market ids provided. :param list market_ids: The filter to select desired markets :param str data_entries: Data to be returned :param requests.sessio...
python
def get_race_card(self, market_ids, data_entries=None, session=None, lightweight=None): """ Returns a list of race cards based on market ids provided. :param list market_ids: The filter to select desired markets :param str data_entries: Data to be returned :param requests.sessio...
[ "def", "get_race_card", "(", "self", ",", "market_ids", ",", "data_entries", "=", "None", ",", "session", "=", "None", ",", "lightweight", "=", "None", ")", ":", "if", "not", "self", ".", "app_key", ":", "raise", "RaceCardError", "(", "\"You need to login be...
Returns a list of race cards based on market ids provided. :param list market_ids: The filter to select desired markets :param str data_entries: Data to be returned :param requests.session session: Requests session object :param bool lightweight: If True will return dict not a resource ...
[ "Returns", "a", "list", "of", "race", "cards", "based", "on", "market", "ids", "provided", "." ]
8479392eb4849c525d78d43497c32c0bb108e977
https://github.com/liampauling/betfair/blob/8479392eb4849c525d78d43497c32c0bb108e977/betfairlightweight/endpoints/racecard.py#L41-L57
237,626
liampauling/betfair
betfairlightweight/streaming/listener.py
StreamListener.on_data
def on_data(self, raw_data): """Called when raw data is received from connection. Override this method if you wish to manually handle the stream data :param raw_data: Received raw data :return: Return False to stop stream and close connection """ try: ...
python
def on_data(self, raw_data): """Called when raw data is received from connection. Override this method if you wish to manually handle the stream data :param raw_data: Received raw data :return: Return False to stop stream and close connection """ try: ...
[ "def", "on_data", "(", "self", ",", "raw_data", ")", ":", "try", ":", "data", "=", "json", ".", "loads", "(", "raw_data", ")", "except", "ValueError", ":", "logger", ".", "error", "(", "'value error: %s'", "%", "raw_data", ")", "return", "unique_id", "="...
Called when raw data is received from connection. Override this method if you wish to manually handle the stream data :param raw_data: Received raw data :return: Return False to stop stream and close connection
[ "Called", "when", "raw", "data", "is", "received", "from", "connection", ".", "Override", "this", "method", "if", "you", "wish", "to", "manually", "handle", "the", "stream", "data" ]
8479392eb4849c525d78d43497c32c0bb108e977
https://github.com/liampauling/betfair/blob/8479392eb4849c525d78d43497c32c0bb108e977/betfairlightweight/streaming/listener.py#L85-L115
237,627
liampauling/betfair
betfairlightweight/streaming/listener.py
StreamListener._on_connection
def _on_connection(self, data, unique_id): """Called on collection operation :param data: Received data """ if unique_id is None: unique_id = self.stream_unique_id self.connection_id = data.get('connectionId') logger.info('[Connect: %s]: connection_id: %s' % ...
python
def _on_connection(self, data, unique_id): """Called on collection operation :param data: Received data """ if unique_id is None: unique_id = self.stream_unique_id self.connection_id = data.get('connectionId') logger.info('[Connect: %s]: connection_id: %s' % ...
[ "def", "_on_connection", "(", "self", ",", "data", ",", "unique_id", ")", ":", "if", "unique_id", "is", "None", ":", "unique_id", "=", "self", ".", "stream_unique_id", "self", ".", "connection_id", "=", "data", ".", "get", "(", "'connectionId'", ")", "logg...
Called on collection operation :param data: Received data
[ "Called", "on", "collection", "operation" ]
8479392eb4849c525d78d43497c32c0bb108e977
https://github.com/liampauling/betfair/blob/8479392eb4849c525d78d43497c32c0bb108e977/betfairlightweight/streaming/listener.py#L117-L125
237,628
liampauling/betfair
betfairlightweight/streaming/listener.py
StreamListener._on_status
def _on_status(data, unique_id): """Called on status operation :param data: Received data """ status_code = data.get('statusCode') logger.info('[Subscription: %s]: %s' % (unique_id, status_code))
python
def _on_status(data, unique_id): """Called on status operation :param data: Received data """ status_code = data.get('statusCode') logger.info('[Subscription: %s]: %s' % (unique_id, status_code))
[ "def", "_on_status", "(", "data", ",", "unique_id", ")", ":", "status_code", "=", "data", ".", "get", "(", "'statusCode'", ")", "logger", ".", "info", "(", "'[Subscription: %s]: %s'", "%", "(", "unique_id", ",", "status_code", ")", ")" ]
Called on status operation :param data: Received data
[ "Called", "on", "status", "operation" ]
8479392eb4849c525d78d43497c32c0bb108e977
https://github.com/liampauling/betfair/blob/8479392eb4849c525d78d43497c32c0bb108e977/betfairlightweight/streaming/listener.py#L128-L134
237,629
liampauling/betfair
betfairlightweight/streaming/listener.py
StreamListener._error_handler
def _error_handler(data, unique_id): """Called when data first received :param data: Received data :param unique_id: Unique id :return: True if error present """ if data.get('statusCode') == 'FAILURE': logger.error('[Subscription: %s] %s: %s' % (unique_id, da...
python
def _error_handler(data, unique_id): """Called when data first received :param data: Received data :param unique_id: Unique id :return: True if error present """ if data.get('statusCode') == 'FAILURE': logger.error('[Subscription: %s] %s: %s' % (unique_id, da...
[ "def", "_error_handler", "(", "data", ",", "unique_id", ")", ":", "if", "data", ".", "get", "(", "'statusCode'", ")", "==", "'FAILURE'", ":", "logger", ".", "error", "(", "'[Subscription: %s] %s: %s'", "%", "(", "unique_id", ",", "data", ".", "get", "(", ...
Called when data first received :param data: Received data :param unique_id: Unique id :return: True if error present
[ "Called", "when", "data", "first", "received" ]
8479392eb4849c525d78d43497c32c0bb108e977
https://github.com/liampauling/betfair/blob/8479392eb4849c525d78d43497c32c0bb108e977/betfairlightweight/streaming/listener.py#L157-L171
237,630
liampauling/betfair
betfairlightweight/streaming/betfairstream.py
BetfairStream.stop
def stop(self): """Stops read loop and closes socket if it has been created. """ self._running = False if self._socket is None: return try: self._socket.shutdown(socket.SHUT_RDWR) self._socket.close() except socket.error: p...
python
def stop(self): """Stops read loop and closes socket if it has been created. """ self._running = False if self._socket is None: return try: self._socket.shutdown(socket.SHUT_RDWR) self._socket.close() except socket.error: p...
[ "def", "stop", "(", "self", ")", ":", "self", ".", "_running", "=", "False", "if", "self", ".", "_socket", "is", "None", ":", "return", "try", ":", "self", ".", "_socket", ".", "shutdown", "(", "socket", ".", "SHUT_RDWR", ")", "self", ".", "_socket",...
Stops read loop and closes socket if it has been created.
[ "Stops", "read", "loop", "and", "closes", "socket", "if", "it", "has", "been", "created", "." ]
8479392eb4849c525d78d43497c32c0bb108e977
https://github.com/liampauling/betfair/blob/8479392eb4849c525d78d43497c32c0bb108e977/betfairlightweight/streaming/betfairstream.py#L62-L74
237,631
liampauling/betfair
betfairlightweight/streaming/betfairstream.py
BetfairStream.authenticate
def authenticate(self): """Authentication request. """ unique_id = self.new_unique_id() message = { 'op': 'authentication', 'id': unique_id, 'appKey': self.app_key, 'session': self.session_token, } self._send(message) ...
python
def authenticate(self): """Authentication request. """ unique_id = self.new_unique_id() message = { 'op': 'authentication', 'id': unique_id, 'appKey': self.app_key, 'session': self.session_token, } self._send(message) ...
[ "def", "authenticate", "(", "self", ")", ":", "unique_id", "=", "self", ".", "new_unique_id", "(", ")", "message", "=", "{", "'op'", ":", "'authentication'", ",", "'id'", ":", "unique_id", ",", "'appKey'", ":", "self", ".", "app_key", ",", "'session'", "...
Authentication request.
[ "Authentication", "request", "." ]
8479392eb4849c525d78d43497c32c0bb108e977
https://github.com/liampauling/betfair/blob/8479392eb4849c525d78d43497c32c0bb108e977/betfairlightweight/streaming/betfairstream.py#L76-L87
237,632
liampauling/betfair
betfairlightweight/streaming/betfairstream.py
BetfairStream.heartbeat
def heartbeat(self): """Heartbeat request to keep session alive. """ unique_id = self.new_unique_id() message = { 'op': 'heartbeat', 'id': unique_id, } self._send(message) return unique_id
python
def heartbeat(self): """Heartbeat request to keep session alive. """ unique_id = self.new_unique_id() message = { 'op': 'heartbeat', 'id': unique_id, } self._send(message) return unique_id
[ "def", "heartbeat", "(", "self", ")", ":", "unique_id", "=", "self", ".", "new_unique_id", "(", ")", "message", "=", "{", "'op'", ":", "'heartbeat'", ",", "'id'", ":", "unique_id", ",", "}", "self", ".", "_send", "(", "message", ")", "return", "unique_...
Heartbeat request to keep session alive.
[ "Heartbeat", "request", "to", "keep", "session", "alive", "." ]
8479392eb4849c525d78d43497c32c0bb108e977
https://github.com/liampauling/betfair/blob/8479392eb4849c525d78d43497c32c0bb108e977/betfairlightweight/streaming/betfairstream.py#L89-L98
237,633
liampauling/betfair
betfairlightweight/streaming/betfairstream.py
BetfairStream.subscribe_to_markets
def subscribe_to_markets(self, market_filter, market_data_filter, initial_clk=None, clk=None, conflate_ms=None, heartbeat_ms=None, segmentation_enabled=True): """ Market subscription request. :param dict market_filter: Market filter :param dict market_data_f...
python
def subscribe_to_markets(self, market_filter, market_data_filter, initial_clk=None, clk=None, conflate_ms=None, heartbeat_ms=None, segmentation_enabled=True): """ Market subscription request. :param dict market_filter: Market filter :param dict market_data_f...
[ "def", "subscribe_to_markets", "(", "self", ",", "market_filter", ",", "market_data_filter", ",", "initial_clk", "=", "None", ",", "clk", "=", "None", ",", "conflate_ms", "=", "None", ",", "heartbeat_ms", "=", "None", ",", "segmentation_enabled", "=", "True", ...
Market subscription request. :param dict market_filter: Market filter :param dict market_data_filter: Market data filter :param str initial_clk: Sequence token for reconnect :param str clk: Sequence token for reconnect :param int conflate_ms: conflation rate (bounds are 0 to 120...
[ "Market", "subscription", "request", "." ]
8479392eb4849c525d78d43497c32c0bb108e977
https://github.com/liampauling/betfair/blob/8479392eb4849c525d78d43497c32c0bb108e977/betfairlightweight/streaming/betfairstream.py#L100-L132
237,634
liampauling/betfair
betfairlightweight/streaming/betfairstream.py
BetfairStream.subscribe_to_orders
def subscribe_to_orders(self, order_filter=None, initial_clk=None, clk=None, conflate_ms=None, heartbeat_ms=None, segmentation_enabled=True): """ Order subscription request. :param dict order_filter: Order filter to be applied :param str initial_clk: Sequence...
python
def subscribe_to_orders(self, order_filter=None, initial_clk=None, clk=None, conflate_ms=None, heartbeat_ms=None, segmentation_enabled=True): """ Order subscription request. :param dict order_filter: Order filter to be applied :param str initial_clk: Sequence...
[ "def", "subscribe_to_orders", "(", "self", ",", "order_filter", "=", "None", ",", "initial_clk", "=", "None", ",", "clk", "=", "None", ",", "conflate_ms", "=", "None", ",", "heartbeat_ms", "=", "None", ",", "segmentation_enabled", "=", "True", ")", ":", "u...
Order subscription request. :param dict order_filter: Order filter to be applied :param str initial_clk: Sequence token for reconnect :param str clk: Sequence token for reconnect :param int conflate_ms: conflation rate (bounds are 0 to 120000) :param int heartbeat_ms: heartbeat ...
[ "Order", "subscription", "request", "." ]
8479392eb4849c525d78d43497c32c0bb108e977
https://github.com/liampauling/betfair/blob/8479392eb4849c525d78d43497c32c0bb108e977/betfairlightweight/streaming/betfairstream.py#L134-L164
237,635
liampauling/betfair
betfairlightweight/streaming/betfairstream.py
BetfairStream._create_socket
def _create_socket(self): """Creates ssl socket, connects to stream api and sets timeout. """ s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s = ssl.wrap_socket(s) s.connect((self.host, self.__port)) s.settimeout(self.timeout) return s
python
def _create_socket(self): """Creates ssl socket, connects to stream api and sets timeout. """ s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s = ssl.wrap_socket(s) s.connect((self.host, self.__port)) s.settimeout(self.timeout) return s
[ "def", "_create_socket", "(", "self", ")", ":", "s", "=", "socket", ".", "socket", "(", "socket", ".", "AF_INET", ",", "socket", ".", "SOCK_STREAM", ")", "s", "=", "ssl", ".", "wrap_socket", "(", "s", ")", "s", ".", "connect", "(", "(", "self", "."...
Creates ssl socket, connects to stream api and sets timeout.
[ "Creates", "ssl", "socket", "connects", "to", "stream", "api", "and", "sets", "timeout", "." ]
8479392eb4849c525d78d43497c32c0bb108e977
https://github.com/liampauling/betfair/blob/8479392eb4849c525d78d43497c32c0bb108e977/betfairlightweight/streaming/betfairstream.py#L176-L184
237,636
liampauling/betfair
betfairlightweight/streaming/betfairstream.py
BetfairStream._read_loop
def _read_loop(self): """Read loop, splits by CRLF and pushes received data to _data. """ while self._running: received_data_raw = self._receive_all() if self._running: self.receive_count += 1 self.datetime_last_received = datetime....
python
def _read_loop(self): """Read loop, splits by CRLF and pushes received data to _data. """ while self._running: received_data_raw = self._receive_all() if self._running: self.receive_count += 1 self.datetime_last_received = datetime....
[ "def", "_read_loop", "(", "self", ")", ":", "while", "self", ".", "_running", ":", "received_data_raw", "=", "self", ".", "_receive_all", "(", ")", "if", "self", ".", "_running", ":", "self", ".", "receive_count", "+=", "1", "self", ".", "datetime_last_rec...
Read loop, splits by CRLF and pushes received data to _data.
[ "Read", "loop", "splits", "by", "CRLF", "and", "pushes", "received", "data", "to", "_data", "." ]
8479392eb4849c525d78d43497c32c0bb108e977
https://github.com/liampauling/betfair/blob/8479392eb4849c525d78d43497c32c0bb108e977/betfairlightweight/streaming/betfairstream.py#L186-L198
237,637
liampauling/betfair
betfairlightweight/streaming/betfairstream.py
BetfairStream._receive_all
def _receive_all(self): """Whilst socket is running receives data from socket, till CRLF is detected. """ (data, part) = ('', '') if is_py3: crlf_bytes = bytes(self.__CRLF, encoding=self.__encoding) else: crlf_bytes = self.__CRLF while sel...
python
def _receive_all(self): """Whilst socket is running receives data from socket, till CRLF is detected. """ (data, part) = ('', '') if is_py3: crlf_bytes = bytes(self.__CRLF, encoding=self.__encoding) else: crlf_bytes = self.__CRLF while sel...
[ "def", "_receive_all", "(", "self", ")", ":", "(", "data", ",", "part", ")", "=", "(", "''", ",", "''", ")", "if", "is_py3", ":", "crlf_bytes", "=", "bytes", "(", "self", ".", "__CRLF", ",", "encoding", "=", "self", ".", "__encoding", ")", "else", ...
Whilst socket is running receives data from socket, till CRLF is detected.
[ "Whilst", "socket", "is", "running", "receives", "data", "from", "socket", "till", "CRLF", "is", "detected", "." ]
8479392eb4849c525d78d43497c32c0bb108e977
https://github.com/liampauling/betfair/blob/8479392eb4849c525d78d43497c32c0bb108e977/betfairlightweight/streaming/betfairstream.py#L200-L226
237,638
liampauling/betfair
betfairlightweight/streaming/betfairstream.py
BetfairStream._data
def _data(self, received_data): """Sends data to listener, if False is returned; socket is closed. :param received_data: Decoded data received from socket. """ if self.listener.on_data(received_data) is False: self.stop() raise ListenerError(self.listener...
python
def _data(self, received_data): """Sends data to listener, if False is returned; socket is closed. :param received_data: Decoded data received from socket. """ if self.listener.on_data(received_data) is False: self.stop() raise ListenerError(self.listener...
[ "def", "_data", "(", "self", ",", "received_data", ")", ":", "if", "self", ".", "listener", ".", "on_data", "(", "received_data", ")", "is", "False", ":", "self", ".", "stop", "(", ")", "raise", "ListenerError", "(", "self", ".", "listener", ".", "conn...
Sends data to listener, if False is returned; socket is closed. :param received_data: Decoded data received from socket.
[ "Sends", "data", "to", "listener", "if", "False", "is", "returned", ";", "socket", "is", "closed", "." ]
8479392eb4849c525d78d43497c32c0bb108e977
https://github.com/liampauling/betfair/blob/8479392eb4849c525d78d43497c32c0bb108e977/betfairlightweight/streaming/betfairstream.py#L228-L236
237,639
liampauling/betfair
betfairlightweight/streaming/betfairstream.py
BetfairStream._send
def _send(self, message): """If not running connects socket and authenticates. Adds CRLF and sends message to Betfair. :param message: Data to be sent to Betfair. """ if not self._running: self._connect() self.authenticate() message_dumped...
python
def _send(self, message): """If not running connects socket and authenticates. Adds CRLF and sends message to Betfair. :param message: Data to be sent to Betfair. """ if not self._running: self._connect() self.authenticate() message_dumped...
[ "def", "_send", "(", "self", ",", "message", ")", ":", "if", "not", "self", ".", "_running", ":", "self", ".", "_connect", "(", ")", "self", ".", "authenticate", "(", ")", "message_dumped", "=", "json", ".", "dumps", "(", "message", ")", "+", "self",...
If not running connects socket and authenticates. Adds CRLF and sends message to Betfair. :param message: Data to be sent to Betfair.
[ "If", "not", "running", "connects", "socket", "and", "authenticates", ".", "Adds", "CRLF", "and", "sends", "message", "to", "Betfair", "." ]
8479392eb4849c525d78d43497c32c0bb108e977
https://github.com/liampauling/betfair/blob/8479392eb4849c525d78d43497c32c0bb108e977/betfairlightweight/streaming/betfairstream.py#L238-L253
237,640
dmbee/seglearn
seglearn/pipe.py
Pype.fit_transform
def fit_transform(self, X, y=None, **fit_params): """ Fit the model and transform with the final estimator Fits all the transforms one after the other and transforms the data, then uses fit_transform on transformed data with the final estimator. Parameters ------...
python
def fit_transform(self, X, y=None, **fit_params): """ Fit the model and transform with the final estimator Fits all the transforms one after the other and transforms the data, then uses fit_transform on transformed data with the final estimator. Parameters ------...
[ "def", "fit_transform", "(", "self", ",", "X", ",", "y", "=", "None", ",", "*", "*", "fit_params", ")", ":", "Xt", ",", "yt", ",", "fit_params", "=", "self", ".", "_fit", "(", "X", ",", "y", ",", "*", "*", "fit_params", ")", "if", "isinstance", ...
Fit the model and transform with the final estimator Fits all the transforms one after the other and transforms the data, then uses fit_transform on transformed data with the final estimator. Parameters ---------- X : iterable Training data. Must fulfill inpu...
[ "Fit", "the", "model", "and", "transform", "with", "the", "final", "estimator", "Fits", "all", "the", "transforms", "one", "after", "the", "other", "and", "transforms", "the", "data", "then", "uses", "fit_transform", "on", "transformed", "data", "with", "the",...
d8d7039e92c4c6571a70350c03298aceab8dbeec
https://github.com/dmbee/seglearn/blob/d8d7039e92c4c6571a70350c03298aceab8dbeec/seglearn/pipe.py#L173-L214
237,641
dmbee/seglearn
seglearn/pipe.py
Pype.predict
def predict(self, X): """ Apply transforms to the data, and predict with the final estimator Parameters ---------- X : iterable Data to predict on. Must fulfill input requirements of first step of the pipeline. Returns ------- yp ...
python
def predict(self, X): """ Apply transforms to the data, and predict with the final estimator Parameters ---------- X : iterable Data to predict on. Must fulfill input requirements of first step of the pipeline. Returns ------- yp ...
[ "def", "predict", "(", "self", ",", "X", ")", ":", "Xt", ",", "_", ",", "_", "=", "self", ".", "_transform", "(", "X", ")", "return", "self", ".", "_final_estimator", ".", "predict", "(", "Xt", ")" ]
Apply transforms to the data, and predict with the final estimator Parameters ---------- X : iterable Data to predict on. Must fulfill input requirements of first step of the pipeline. Returns ------- yp : array-like Predicted transfo...
[ "Apply", "transforms", "to", "the", "data", "and", "predict", "with", "the", "final", "estimator" ]
d8d7039e92c4c6571a70350c03298aceab8dbeec
https://github.com/dmbee/seglearn/blob/d8d7039e92c4c6571a70350c03298aceab8dbeec/seglearn/pipe.py#L216-L232
237,642
dmbee/seglearn
seglearn/pipe.py
Pype.transform_predict
def transform_predict(self, X, y): """ Apply transforms to the data, and predict with the final estimator. Unlike predict, this also returns the transformed target Parameters ---------- X : iterable Data to predict on. Must fulfill input requirements of first...
python
def transform_predict(self, X, y): """ Apply transforms to the data, and predict with the final estimator. Unlike predict, this also returns the transformed target Parameters ---------- X : iterable Data to predict on. Must fulfill input requirements of first...
[ "def", "transform_predict", "(", "self", ",", "X", ",", "y", ")", ":", "Xt", ",", "yt", ",", "_", "=", "self", ".", "_transform", "(", "X", ",", "y", ")", "yp", "=", "self", ".", "_final_estimator", ".", "predict", "(", "Xt", ")", "return", "yt",...
Apply transforms to the data, and predict with the final estimator. Unlike predict, this also returns the transformed target Parameters ---------- X : iterable Data to predict on. Must fulfill input requirements of first step of the pipeline. y : array-li...
[ "Apply", "transforms", "to", "the", "data", "and", "predict", "with", "the", "final", "estimator", ".", "Unlike", "predict", "this", "also", "returns", "the", "transformed", "target" ]
d8d7039e92c4c6571a70350c03298aceab8dbeec
https://github.com/dmbee/seglearn/blob/d8d7039e92c4c6571a70350c03298aceab8dbeec/seglearn/pipe.py#L234-L256
237,643
dmbee/seglearn
seglearn/pipe.py
Pype.score
def score(self, X, y=None, sample_weight=None): """ Apply transforms, and score with the final estimator Parameters ---------- X : iterable Data to predict on. Must fulfill input requirements of first step of the pipeline. y : iterable, default=No...
python
def score(self, X, y=None, sample_weight=None): """ Apply transforms, and score with the final estimator Parameters ---------- X : iterable Data to predict on. Must fulfill input requirements of first step of the pipeline. y : iterable, default=No...
[ "def", "score", "(", "self", ",", "X", ",", "y", "=", "None", ",", "sample_weight", "=", "None", ")", ":", "Xt", ",", "yt", ",", "swt", "=", "self", ".", "_transform", "(", "X", ",", "y", ",", "sample_weight", ")", "self", ".", "N_test", "=", "...
Apply transforms, and score with the final estimator Parameters ---------- X : iterable Data to predict on. Must fulfill input requirements of first step of the pipeline. y : iterable, default=None Targets used for scoring. Must fulfill label requirem...
[ "Apply", "transforms", "and", "score", "with", "the", "final", "estimator" ]
d8d7039e92c4c6571a70350c03298aceab8dbeec
https://github.com/dmbee/seglearn/blob/d8d7039e92c4c6571a70350c03298aceab8dbeec/seglearn/pipe.py#L258-L290
237,644
dmbee/seglearn
seglearn/pipe.py
Pype.predict_proba
def predict_proba(self, X): """ Apply transforms, and predict_proba of the final estimator Parameters ---------- X : iterable Data to predict on. Must fulfill input requirements of first step of the pipeline. Returns ------- y_pro...
python
def predict_proba(self, X): """ Apply transforms, and predict_proba of the final estimator Parameters ---------- X : iterable Data to predict on. Must fulfill input requirements of first step of the pipeline. Returns ------- y_pro...
[ "def", "predict_proba", "(", "self", ",", "X", ")", ":", "Xt", ",", "_", ",", "_", "=", "self", ".", "_transform", "(", "X", ")", "return", "self", ".", "_final_estimator", ".", "predict_proba", "(", "Xt", ")" ]
Apply transforms, and predict_proba of the final estimator Parameters ---------- X : iterable Data to predict on. Must fulfill input requirements of first step of the pipeline. Returns ------- y_proba : array-like, shape = [n_samples, n_classes] ...
[ "Apply", "transforms", "and", "predict_proba", "of", "the", "final", "estimator" ]
d8d7039e92c4c6571a70350c03298aceab8dbeec
https://github.com/dmbee/seglearn/blob/d8d7039e92c4c6571a70350c03298aceab8dbeec/seglearn/pipe.py#L292-L308
237,645
dmbee/seglearn
seglearn/pipe.py
Pype.decision_function
def decision_function(self, X): """ Apply transforms, and decision_function of the final estimator Parameters ---------- X : iterable Data to predict on. Must fulfill input requirements of first step of the pipeline. Returns ------- ...
python
def decision_function(self, X): """ Apply transforms, and decision_function of the final estimator Parameters ---------- X : iterable Data to predict on. Must fulfill input requirements of first step of the pipeline. Returns ------- ...
[ "def", "decision_function", "(", "self", ",", "X", ")", ":", "Xt", ",", "_", ",", "_", "=", "self", ".", "_transform", "(", "X", ")", "return", "self", ".", "_final_estimator", ".", "decision_function", "(", "Xt", ")" ]
Apply transforms, and decision_function of the final estimator Parameters ---------- X : iterable Data to predict on. Must fulfill input requirements of first step of the pipeline. Returns ------- y_score : array-like, shape = [n_samples, n_class...
[ "Apply", "transforms", "and", "decision_function", "of", "the", "final", "estimator" ]
d8d7039e92c4c6571a70350c03298aceab8dbeec
https://github.com/dmbee/seglearn/blob/d8d7039e92c4c6571a70350c03298aceab8dbeec/seglearn/pipe.py#L310-L325
237,646
dmbee/seglearn
seglearn/pipe.py
Pype.predict_log_proba
def predict_log_proba(self, X): """ Apply transforms, and predict_log_proba of the final estimator Parameters ---------- X : iterable Data to predict on. Must fulfill input requirements of first step of the pipeline. Returns ------- ...
python
def predict_log_proba(self, X): """ Apply transforms, and predict_log_proba of the final estimator Parameters ---------- X : iterable Data to predict on. Must fulfill input requirements of first step of the pipeline. Returns ------- ...
[ "def", "predict_log_proba", "(", "self", ",", "X", ")", ":", "Xt", ",", "_", ",", "_", "=", "self", ".", "_transform", "(", "X", ")", "return", "self", ".", "_final_estimator", ".", "predict_log_proba", "(", "Xt", ")" ]
Apply transforms, and predict_log_proba of the final estimator Parameters ---------- X : iterable Data to predict on. Must fulfill input requirements of first step of the pipeline. Returns ------- y_score : array-like, shape = [n_samples, n_class...
[ "Apply", "transforms", "and", "predict_log_proba", "of", "the", "final", "estimator" ]
d8d7039e92c4c6571a70350c03298aceab8dbeec
https://github.com/dmbee/seglearn/blob/d8d7039e92c4c6571a70350c03298aceab8dbeec/seglearn/pipe.py#L327-L342
237,647
dmbee/seglearn
seglearn/feature_functions.py
base_features
def base_features(): ''' Returns dictionary of some basic features that can be calculated for segmented time series data ''' features = {'mean': mean, 'median': median, 'abs_energy': abs_energy, 'std': std, 'var': var, 'min': mi...
python
def base_features(): ''' Returns dictionary of some basic features that can be calculated for segmented time series data ''' features = {'mean': mean, 'median': median, 'abs_energy': abs_energy, 'std': std, 'var': var, 'min': mi...
[ "def", "base_features", "(", ")", ":", "features", "=", "{", "'mean'", ":", "mean", ",", "'median'", ":", "median", ",", "'abs_energy'", ":", "abs_energy", ",", "'std'", ":", "std", ",", "'var'", ":", "var", ",", "'min'", ":", "minimum", ",", "'max'", ...
Returns dictionary of some basic features that can be calculated for segmented time series data
[ "Returns", "dictionary", "of", "some", "basic", "features", "that", "can", "be", "calculated", "for", "segmented", "time", "series", "data" ]
d8d7039e92c4c6571a70350c03298aceab8dbeec
https://github.com/dmbee/seglearn/blob/d8d7039e92c4c6571a70350c03298aceab8dbeec/seglearn/feature_functions.py#L37-L51
237,648
dmbee/seglearn
seglearn/feature_functions.py
all_features
def all_features(): ''' Returns dictionary of all features in the module .. note:: Some of the features (hist4, corr) are relatively expensive to compute ''' features = {'mean': mean, 'median': median, 'gmean': gmean, 'hmean': hmean, 'vec_...
python
def all_features(): ''' Returns dictionary of all features in the module .. note:: Some of the features (hist4, corr) are relatively expensive to compute ''' features = {'mean': mean, 'median': median, 'gmean': gmean, 'hmean': hmean, 'vec_...
[ "def", "all_features", "(", ")", ":", "features", "=", "{", "'mean'", ":", "mean", ",", "'median'", ":", "median", ",", "'gmean'", ":", "gmean", ",", "'hmean'", ":", "hmean", ",", "'vec_sum'", ":", "vec_sum", ",", "'abs_sum'", ":", "abs_sum", ",", "'ab...
Returns dictionary of all features in the module .. note:: Some of the features (hist4, corr) are relatively expensive to compute
[ "Returns", "dictionary", "of", "all", "features", "in", "the", "module" ]
d8d7039e92c4c6571a70350c03298aceab8dbeec
https://github.com/dmbee/seglearn/blob/d8d7039e92c4c6571a70350c03298aceab8dbeec/seglearn/feature_functions.py#L54-L86
237,649
dmbee/seglearn
seglearn/feature_functions.py
emg_features
def emg_features(threshold=0): '''Return a dictionary of popular features used for EMG time series classification.''' return { 'mean_abs_value': mean_abs, 'zero_crossings': zero_crossing(threshold), 'slope_sign_changes': slope_sign_changes(threshold), 'waveform_length': waveform_...
python
def emg_features(threshold=0): '''Return a dictionary of popular features used for EMG time series classification.''' return { 'mean_abs_value': mean_abs, 'zero_crossings': zero_crossing(threshold), 'slope_sign_changes': slope_sign_changes(threshold), 'waveform_length': waveform_...
[ "def", "emg_features", "(", "threshold", "=", "0", ")", ":", "return", "{", "'mean_abs_value'", ":", "mean_abs", ",", "'zero_crossings'", ":", "zero_crossing", "(", "threshold", ")", ",", "'slope_sign_changes'", ":", "slope_sign_changes", "(", "threshold", ")", ...
Return a dictionary of popular features used for EMG time series classification.
[ "Return", "a", "dictionary", "of", "popular", "features", "used", "for", "EMG", "time", "series", "classification", "." ]
d8d7039e92c4c6571a70350c03298aceab8dbeec
https://github.com/dmbee/seglearn/blob/d8d7039e92c4c6571a70350c03298aceab8dbeec/seglearn/feature_functions.py#L99-L111
237,650
dmbee/seglearn
seglearn/feature_functions.py
means_abs_diff
def means_abs_diff(X): ''' mean absolute temporal derivative ''' return np.mean(np.abs(np.diff(X, axis=1)), axis=1)
python
def means_abs_diff(X): ''' mean absolute temporal derivative ''' return np.mean(np.abs(np.diff(X, axis=1)), axis=1)
[ "def", "means_abs_diff", "(", "X", ")", ":", "return", "np", ".", "mean", "(", "np", ".", "abs", "(", "np", ".", "diff", "(", "X", ",", "axis", "=", "1", ")", ")", ",", "axis", "=", "1", ")" ]
mean absolute temporal derivative
[ "mean", "absolute", "temporal", "derivative" ]
d8d7039e92c4c6571a70350c03298aceab8dbeec
https://github.com/dmbee/seglearn/blob/d8d7039e92c4c6571a70350c03298aceab8dbeec/seglearn/feature_functions.py#L189-L191
237,651
dmbee/seglearn
seglearn/feature_functions.py
mse
def mse(X): ''' computes mean spectral energy for each variable in a segmented time series ''' return np.mean(np.square(np.abs(np.fft.fft(X, axis=1))), axis=1)
python
def mse(X): ''' computes mean spectral energy for each variable in a segmented time series ''' return np.mean(np.square(np.abs(np.fft.fft(X, axis=1))), axis=1)
[ "def", "mse", "(", "X", ")", ":", "return", "np", ".", "mean", "(", "np", ".", "square", "(", "np", ".", "abs", "(", "np", ".", "fft", ".", "fft", "(", "X", ",", "axis", "=", "1", ")", ")", ")", ",", "axis", "=", "1", ")" ]
computes mean spectral energy for each variable in a segmented time series
[ "computes", "mean", "spectral", "energy", "for", "each", "variable", "in", "a", "segmented", "time", "series" ]
d8d7039e92c4c6571a70350c03298aceab8dbeec
https://github.com/dmbee/seglearn/blob/d8d7039e92c4c6571a70350c03298aceab8dbeec/seglearn/feature_functions.py#L194-L196
237,652
dmbee/seglearn
seglearn/feature_functions.py
mean_crossings
def mean_crossings(X): ''' Computes number of mean crossings for each variable in a segmented time series ''' X = np.atleast_3d(X) N = X.shape[0] D = X.shape[2] mnx = np.zeros((N, D)) for i in range(D): pos = X[:, :, i] > 0 npos = ~pos c = (pos[:, :-1] & npos[:, 1:]) | (n...
python
def mean_crossings(X): ''' Computes number of mean crossings for each variable in a segmented time series ''' X = np.atleast_3d(X) N = X.shape[0] D = X.shape[2] mnx = np.zeros((N, D)) for i in range(D): pos = X[:, :, i] > 0 npos = ~pos c = (pos[:, :-1] & npos[:, 1:]) | (n...
[ "def", "mean_crossings", "(", "X", ")", ":", "X", "=", "np", ".", "atleast_3d", "(", "X", ")", "N", "=", "X", ".", "shape", "[", "0", "]", "D", "=", "X", ".", "shape", "[", "2", "]", "mnx", "=", "np", ".", "zeros", "(", "(", "N", ",", "D"...
Computes number of mean crossings for each variable in a segmented time series
[ "Computes", "number", "of", "mean", "crossings", "for", "each", "variable", "in", "a", "segmented", "time", "series" ]
d8d7039e92c4c6571a70350c03298aceab8dbeec
https://github.com/dmbee/seglearn/blob/d8d7039e92c4c6571a70350c03298aceab8dbeec/seglearn/feature_functions.py#L199-L210
237,653
dmbee/seglearn
seglearn/feature_functions.py
corr2
def corr2(X): ''' computes correlations between all variable pairs in a segmented time series .. note:: this feature is expensive to compute with the current implementation, and cannot be used with univariate time series ''' X = np.atleast_3d(X) N = X.shape[0] D = X.shape[2] if D == 1:...
python
def corr2(X): ''' computes correlations between all variable pairs in a segmented time series .. note:: this feature is expensive to compute with the current implementation, and cannot be used with univariate time series ''' X = np.atleast_3d(X) N = X.shape[0] D = X.shape[2] if D == 1:...
[ "def", "corr2", "(", "X", ")", ":", "X", "=", "np", ".", "atleast_3d", "(", "X", ")", "N", "=", "X", ".", "shape", "[", "0", "]", "D", "=", "X", ".", "shape", "[", "2", "]", "if", "D", "==", "1", ":", "return", "np", ".", "zeros", "(", ...
computes correlations between all variable pairs in a segmented time series .. note:: this feature is expensive to compute with the current implementation, and cannot be used with univariate time series
[ "computes", "correlations", "between", "all", "variable", "pairs", "in", "a", "segmented", "time", "series" ]
d8d7039e92c4c6571a70350c03298aceab8dbeec
https://github.com/dmbee/seglearn/blob/d8d7039e92c4c6571a70350c03298aceab8dbeec/seglearn/feature_functions.py#L241-L260
237,654
dmbee/seglearn
seglearn/feature_functions.py
waveform_length
def waveform_length(X): ''' cumulative length of the waveform over a segment for each variable in the segmented time series ''' return np.sum(np.abs(np.diff(X, axis=1)), axis=1)
python
def waveform_length(X): ''' cumulative length of the waveform over a segment for each variable in the segmented time series ''' return np.sum(np.abs(np.diff(X, axis=1)), axis=1)
[ "def", "waveform_length", "(", "X", ")", ":", "return", "np", ".", "sum", "(", "np", ".", "abs", "(", "np", ".", "diff", "(", "X", ",", "axis", "=", "1", ")", ")", ",", "axis", "=", "1", ")" ]
cumulative length of the waveform over a segment for each variable in the segmented time series
[ "cumulative", "length", "of", "the", "waveform", "over", "a", "segment", "for", "each", "variable", "in", "the", "segmented", "time", "series" ]
d8d7039e92c4c6571a70350c03298aceab8dbeec
https://github.com/dmbee/seglearn/blob/d8d7039e92c4c6571a70350c03298aceab8dbeec/seglearn/feature_functions.py#L299-L302
237,655
dmbee/seglearn
seglearn/feature_functions.py
root_mean_square
def root_mean_square(X): ''' root mean square for each variable in the segmented time series ''' segment_width = X.shape[1] return np.sqrt(np.sum(X * X, axis=1) / segment_width)
python
def root_mean_square(X): ''' root mean square for each variable in the segmented time series ''' segment_width = X.shape[1] return np.sqrt(np.sum(X * X, axis=1) / segment_width)
[ "def", "root_mean_square", "(", "X", ")", ":", "segment_width", "=", "X", ".", "shape", "[", "1", "]", "return", "np", ".", "sqrt", "(", "np", ".", "sum", "(", "X", "*", "X", ",", "axis", "=", "1", ")", "/", "segment_width", ")" ]
root mean square for each variable in the segmented time series
[ "root", "mean", "square", "for", "each", "variable", "in", "the", "segmented", "time", "series" ]
d8d7039e92c4c6571a70350c03298aceab8dbeec
https://github.com/dmbee/seglearn/blob/d8d7039e92c4c6571a70350c03298aceab8dbeec/seglearn/feature_functions.py#L305-L308
237,656
dmbee/seglearn
seglearn/split.py
TemporalKFold.split
def split(self, X, y): ''' Splits time series data and target arrays, and generates splitting indices Parameters ---------- X : array-like, shape [n_series, ...] Time series data and (optionally) contextual data y : array-like shape [n_series, ] ta...
python
def split(self, X, y): ''' Splits time series data and target arrays, and generates splitting indices Parameters ---------- X : array-like, shape [n_series, ...] Time series data and (optionally) contextual data y : array-like shape [n_series, ] ta...
[ "def", "split", "(", "self", ",", "X", ",", "y", ")", ":", "check_ts_data", "(", "X", ",", "y", ")", "Xt", ",", "Xc", "=", "get_ts_data_parts", "(", "X", ")", "Ns", "=", "len", "(", "Xt", ")", "Xt_new", ",", "y_new", "=", "self", ".", "_ts_slic...
Splits time series data and target arrays, and generates splitting indices Parameters ---------- X : array-like, shape [n_series, ...] Time series data and (optionally) contextual data y : array-like shape [n_series, ] target vector Returns ------...
[ "Splits", "time", "series", "data", "and", "target", "arrays", "and", "generates", "splitting", "indices" ]
d8d7039e92c4c6571a70350c03298aceab8dbeec
https://github.com/dmbee/seglearn/blob/d8d7039e92c4c6571a70350c03298aceab8dbeec/seglearn/split.py#L56-L90
237,657
dmbee/seglearn
seglearn/split.py
TemporalKFold._ts_slice
def _ts_slice(self, Xt, y): ''' takes time series data, and splits each series into temporal folds ''' Ns = len(Xt) Xt_new = [] for i in range(self.n_splits): for j in range(Ns): Njs = int(len(Xt[j]) / self.n_splits) Xt_new.append(Xt[j][(Njs * ...
python
def _ts_slice(self, Xt, y): ''' takes time series data, and splits each series into temporal folds ''' Ns = len(Xt) Xt_new = [] for i in range(self.n_splits): for j in range(Ns): Njs = int(len(Xt[j]) / self.n_splits) Xt_new.append(Xt[j][(Njs * ...
[ "def", "_ts_slice", "(", "self", ",", "Xt", ",", "y", ")", ":", "Ns", "=", "len", "(", "Xt", ")", "Xt_new", "=", "[", "]", "for", "i", "in", "range", "(", "self", ".", "n_splits", ")", ":", "for", "j", "in", "range", "(", "Ns", ")", ":", "N...
takes time series data, and splits each series into temporal folds
[ "takes", "time", "series", "data", "and", "splits", "each", "series", "into", "temporal", "folds" ]
d8d7039e92c4c6571a70350c03298aceab8dbeec
https://github.com/dmbee/seglearn/blob/d8d7039e92c4c6571a70350c03298aceab8dbeec/seglearn/split.py#L92-L114
237,658
dmbee/seglearn
seglearn/split.py
TemporalKFold._make_indices
def _make_indices(self, Ns): ''' makes indices for cross validation ''' N_new = int(Ns * self.n_splits) test = [np.full(N_new, False) for i in range(self.n_splits)] for i in range(self.n_splits): test[i][np.arange(Ns * i, Ns * (i + 1))] = True train = [np.logical_not...
python
def _make_indices(self, Ns): ''' makes indices for cross validation ''' N_new = int(Ns * self.n_splits) test = [np.full(N_new, False) for i in range(self.n_splits)] for i in range(self.n_splits): test[i][np.arange(Ns * i, Ns * (i + 1))] = True train = [np.logical_not...
[ "def", "_make_indices", "(", "self", ",", "Ns", ")", ":", "N_new", "=", "int", "(", "Ns", "*", "self", ".", "n_splits", ")", "test", "=", "[", "np", ".", "full", "(", "N_new", ",", "False", ")", "for", "i", "in", "range", "(", "self", ".", "n_s...
makes indices for cross validation
[ "makes", "indices", "for", "cross", "validation" ]
d8d7039e92c4c6571a70350c03298aceab8dbeec
https://github.com/dmbee/seglearn/blob/d8d7039e92c4c6571a70350c03298aceab8dbeec/seglearn/split.py#L116-L129
237,659
dmbee/seglearn
seglearn/preprocessing.py
TargetRunLengthEncoder.transform
def transform(self, X, y, sample_weight=None): ''' Transforms the time series data with run length encoding of the target variable Note this transformation changes the number of samples in the data If sample_weight is provided, it is transformed to align to the new target encoding ...
python
def transform(self, X, y, sample_weight=None): ''' Transforms the time series data with run length encoding of the target variable Note this transformation changes the number of samples in the data If sample_weight is provided, it is transformed to align to the new target encoding ...
[ "def", "transform", "(", "self", ",", "X", ",", "y", ",", "sample_weight", "=", "None", ")", ":", "check_ts_data_with_ts_target", "(", "X", ",", "y", ")", "Xt", ",", "Xc", "=", "get_ts_data_parts", "(", "X", ")", "N", "=", "len", "(", "Xt", ")", "#...
Transforms the time series data with run length encoding of the target variable Note this transformation changes the number of samples in the data If sample_weight is provided, it is transformed to align to the new target encoding Parameters ---------- X : array-like, shape [n_...
[ "Transforms", "the", "time", "series", "data", "with", "run", "length", "encoding", "of", "the", "target", "variable", "Note", "this", "transformation", "changes", "the", "number", "of", "samples", "in", "the", "data", "If", "sample_weight", "is", "provided", ...
d8d7039e92c4c6571a70350c03298aceab8dbeec
https://github.com/dmbee/seglearn/blob/d8d7039e92c4c6571a70350c03298aceab8dbeec/seglearn/preprocessing.py#L66-L115
237,660
dmbee/seglearn
seglearn/preprocessing.py
TargetRunLengthEncoder._rle
def _rle(self, a): ''' rle implementation credit to Thomas Browne from his SOF post Sept 2015 Parameters ---------- a : array, shape[n,] input vector Returns ------- z : array, shape[nt,] run lengths p : array, shape[nt,] ...
python
def _rle(self, a): ''' rle implementation credit to Thomas Browne from his SOF post Sept 2015 Parameters ---------- a : array, shape[n,] input vector Returns ------- z : array, shape[nt,] run lengths p : array, shape[nt,] ...
[ "def", "_rle", "(", "self", ",", "a", ")", ":", "ia", "=", "np", ".", "asarray", "(", "a", ")", "n", "=", "len", "(", "ia", ")", "y", "=", "np", ".", "array", "(", "ia", "[", "1", ":", "]", "!=", "ia", "[", ":", "-", "1", "]", ")", "#...
rle implementation credit to Thomas Browne from his SOF post Sept 2015 Parameters ---------- a : array, shape[n,] input vector Returns ------- z : array, shape[nt,] run lengths p : array, shape[nt,] start positions of each run...
[ "rle", "implementation", "credit", "to", "Thomas", "Browne", "from", "his", "SOF", "post", "Sept", "2015" ]
d8d7039e92c4c6571a70350c03298aceab8dbeec
https://github.com/dmbee/seglearn/blob/d8d7039e92c4c6571a70350c03298aceab8dbeec/seglearn/preprocessing.py#L117-L141
237,661
dmbee/seglearn
seglearn/preprocessing.py
TargetRunLengthEncoder._transform
def _transform(self, X, y): ''' Transforms single series ''' z, p, y_rle = self._rle(y) p = np.append(p, len(y)) big_enough = p[1:] - p[:-1] >= self.min_length Xt = [] for i in range(len(y_rle)): if (big_enough[i]): Xt.append(X...
python
def _transform(self, X, y): ''' Transforms single series ''' z, p, y_rle = self._rle(y) p = np.append(p, len(y)) big_enough = p[1:] - p[:-1] >= self.min_length Xt = [] for i in range(len(y_rle)): if (big_enough[i]): Xt.append(X...
[ "def", "_transform", "(", "self", ",", "X", ",", "y", ")", ":", "z", ",", "p", ",", "y_rle", "=", "self", ".", "_rle", "(", "y", ")", "p", "=", "np", ".", "append", "(", "p", ",", "len", "(", "y", ")", ")", "big_enough", "=", "p", "[", "1...
Transforms single series
[ "Transforms", "single", "series" ]
d8d7039e92c4c6571a70350c03298aceab8dbeec
https://github.com/dmbee/seglearn/blob/d8d7039e92c4c6571a70350c03298aceab8dbeec/seglearn/preprocessing.py#L143-L157
237,662
dmbee/seglearn
seglearn/util.py
get_ts_data_parts
def get_ts_data_parts(X): ''' Separates time series data object into time series variables and contextual variables Parameters ---------- X : array-like, shape [n_series, ...] Time series data and (optionally) contextual data Returns ------- Xt : array-like, shape [n_series, ] ...
python
def get_ts_data_parts(X): ''' Separates time series data object into time series variables and contextual variables Parameters ---------- X : array-like, shape [n_series, ...] Time series data and (optionally) contextual data Returns ------- Xt : array-like, shape [n_series, ] ...
[ "def", "get_ts_data_parts", "(", "X", ")", ":", "if", "not", "isinstance", "(", "X", ",", "TS_Data", ")", ":", "return", "X", ",", "None", "return", "X", ".", "ts_data", ",", "X", ".", "context_data" ]
Separates time series data object into time series variables and contextual variables Parameters ---------- X : array-like, shape [n_series, ...] Time series data and (optionally) contextual data Returns ------- Xt : array-like, shape [n_series, ] Time series data Xs : array...
[ "Separates", "time", "series", "data", "object", "into", "time", "series", "variables", "and", "contextual", "variables" ]
d8d7039e92c4c6571a70350c03298aceab8dbeec
https://github.com/dmbee/seglearn/blob/d8d7039e92c4c6571a70350c03298aceab8dbeec/seglearn/util.py#L13-L32
237,663
dmbee/seglearn
seglearn/util.py
check_ts_data_with_ts_target
def check_ts_data_with_ts_target(X, y=None): ''' Checks time series data with time series target is good. If not raises value error. Parameters ---------- X : array-like, shape [n_series, ...] Time series data and (optionally) contextual data y : array-like, shape [n_series, ...] ...
python
def check_ts_data_with_ts_target(X, y=None): ''' Checks time series data with time series target is good. If not raises value error. Parameters ---------- X : array-like, shape [n_series, ...] Time series data and (optionally) contextual data y : array-like, shape [n_series, ...] ...
[ "def", "check_ts_data_with_ts_target", "(", "X", ",", "y", "=", "None", ")", ":", "if", "y", "is", "not", "None", ":", "Nx", "=", "len", "(", "X", ")", "Ny", "=", "len", "(", "y", ")", "if", "Nx", "!=", "Ny", ":", "raise", "ValueError", "(", "\...
Checks time series data with time series target is good. If not raises value error. Parameters ---------- X : array-like, shape [n_series, ...] Time series data and (optionally) contextual data y : array-like, shape [n_series, ...] target data
[ "Checks", "time", "series", "data", "with", "time", "series", "target", "is", "good", ".", "If", "not", "raises", "value", "error", "." ]
d8d7039e92c4c6571a70350c03298aceab8dbeec
https://github.com/dmbee/seglearn/blob/d8d7039e92c4c6571a70350c03298aceab8dbeec/seglearn/util.py#L67-L96
237,664
dmbee/seglearn
seglearn/util.py
ts_stats
def ts_stats(Xt, y, fs=1.0, class_labels=None): ''' Generates some helpful statistics about the data X Parameters ---------- X : array-like, shape [n_series, ...] Time series data and (optionally) contextual data y : array-like, shape [n_series] target data fs : float ...
python
def ts_stats(Xt, y, fs=1.0, class_labels=None): ''' Generates some helpful statistics about the data X Parameters ---------- X : array-like, shape [n_series, ...] Time series data and (optionally) contextual data y : array-like, shape [n_series] target data fs : float ...
[ "def", "ts_stats", "(", "Xt", ",", "y", ",", "fs", "=", "1.0", ",", "class_labels", "=", "None", ")", ":", "check_ts_data", "(", "Xt", ")", "Xt", ",", "Xs", "=", "get_ts_data_parts", "(", "Xt", ")", "if", "Xs", "is", "not", "None", ":", "S", "=",...
Generates some helpful statistics about the data X Parameters ---------- X : array-like, shape [n_series, ...] Time series data and (optionally) contextual data y : array-like, shape [n_series] target data fs : float sampling frequency class_labels : list of strings, defa...
[ "Generates", "some", "helpful", "statistics", "about", "the", "data", "X" ]
d8d7039e92c4c6571a70350c03298aceab8dbeec
https://github.com/dmbee/seglearn/blob/d8d7039e92c4c6571a70350c03298aceab8dbeec/seglearn/util.py#L99-L163
237,665
dmbee/seglearn
seglearn/datasets.py
load_watch
def load_watch(): ''' Loads some of the 6-axis inertial sensor data from my smartwatch project. The sensor data was recorded as study subjects performed sets of 20 shoulder exercise repetitions while wearing a smartwatch. It is a multivariate time series. The study can be found here: https://arxiv....
python
def load_watch(): ''' Loads some of the 6-axis inertial sensor data from my smartwatch project. The sensor data was recorded as study subjects performed sets of 20 shoulder exercise repetitions while wearing a smartwatch. It is a multivariate time series. The study can be found here: https://arxiv....
[ "def", "load_watch", "(", ")", ":", "module_path", "=", "dirname", "(", "__file__", ")", "data", "=", "np", ".", "load", "(", "module_path", "+", "\"/data/watch_dataset.npy\"", ")", ".", "item", "(", ")", "return", "data" ]
Loads some of the 6-axis inertial sensor data from my smartwatch project. The sensor data was recorded as study subjects performed sets of 20 shoulder exercise repetitions while wearing a smartwatch. It is a multivariate time series. The study can be found here: https://arxiv.org/abs/1802.01489 Return...
[ "Loads", "some", "of", "the", "6", "-", "axis", "inertial", "sensor", "data", "from", "my", "smartwatch", "project", ".", "The", "sensor", "data", "was", "recorded", "as", "study", "subjects", "performed", "sets", "of", "20", "shoulder", "exercise", "repetit...
d8d7039e92c4c6571a70350c03298aceab8dbeec
https://github.com/dmbee/seglearn/blob/d8d7039e92c4c6571a70350c03298aceab8dbeec/seglearn/datasets.py#L13-L46
237,666
dmbee/seglearn
seglearn/transform.py
shuffle_data
def shuffle_data(X, y=None, sample_weight=None): ''' Shuffles indices X, y, and sample_weight together''' if len(X) > 1: ind = np.arange(len(X), dtype=np.int) np.random.shuffle(ind) Xt = X[ind] yt = y swt = sample_weight if yt is not None: yt = yt[ind...
python
def shuffle_data(X, y=None, sample_weight=None): ''' Shuffles indices X, y, and sample_weight together''' if len(X) > 1: ind = np.arange(len(X), dtype=np.int) np.random.shuffle(ind) Xt = X[ind] yt = y swt = sample_weight if yt is not None: yt = yt[ind...
[ "def", "shuffle_data", "(", "X", ",", "y", "=", "None", ",", "sample_weight", "=", "None", ")", ":", "if", "len", "(", "X", ")", ">", "1", ":", "ind", "=", "np", ".", "arange", "(", "len", "(", "X", ")", ",", "dtype", "=", "np", ".", "int", ...
Shuffles indices X, y, and sample_weight together
[ "Shuffles", "indices", "X", "y", "and", "sample_weight", "together" ]
d8d7039e92c4c6571a70350c03298aceab8dbeec
https://github.com/dmbee/seglearn/blob/d8d7039e92c4c6571a70350c03298aceab8dbeec/seglearn/transform.py#L70-L86
237,667
dmbee/seglearn
seglearn/transform.py
expand_variables_to_segments
def expand_variables_to_segments(v, Nt): ''' expands contextual variables v, by repeating each instance as specified in Nt ''' N_v = len(np.atleast_1d(v[0])) return np.concatenate([np.full((Nt[i], N_v), v[i]) for i in np.arange(len(v))])
python
def expand_variables_to_segments(v, Nt): ''' expands contextual variables v, by repeating each instance as specified in Nt ''' N_v = len(np.atleast_1d(v[0])) return np.concatenate([np.full((Nt[i], N_v), v[i]) for i in np.arange(len(v))])
[ "def", "expand_variables_to_segments", "(", "v", ",", "Nt", ")", ":", "N_v", "=", "len", "(", "np", ".", "atleast_1d", "(", "v", "[", "0", "]", ")", ")", "return", "np", ".", "concatenate", "(", "[", "np", ".", "full", "(", "(", "Nt", "[", "i", ...
expands contextual variables v, by repeating each instance as specified in Nt
[ "expands", "contextual", "variables", "v", "by", "repeating", "each", "instance", "as", "specified", "in", "Nt" ]
d8d7039e92c4c6571a70350c03298aceab8dbeec
https://github.com/dmbee/seglearn/blob/d8d7039e92c4c6571a70350c03298aceab8dbeec/seglearn/transform.py#L549-L552
237,668
dmbee/seglearn
seglearn/transform.py
sliding_window
def sliding_window(time_series, width, step, order='F'): ''' Segments univariate time series with sliding window Parameters ---------- time_series : array like shape [n_samples] time series or sequence width : int > 0 segment width in samples step : int > 0 stepsize ...
python
def sliding_window(time_series, width, step, order='F'): ''' Segments univariate time series with sliding window Parameters ---------- time_series : array like shape [n_samples] time series or sequence width : int > 0 segment width in samples step : int > 0 stepsize ...
[ "def", "sliding_window", "(", "time_series", ",", "width", ",", "step", ",", "order", "=", "'F'", ")", ":", "w", "=", "np", ".", "hstack", "(", "[", "time_series", "[", "i", ":", "1", "+", "i", "-", "width", "or", "None", ":", "step", "]", "for",...
Segments univariate time series with sliding window Parameters ---------- time_series : array like shape [n_samples] time series or sequence width : int > 0 segment width in samples step : int > 0 stepsize for sliding in samples Returns ------- w : array like sh...
[ "Segments", "univariate", "time", "series", "with", "sliding", "window" ]
d8d7039e92c4c6571a70350c03298aceab8dbeec
https://github.com/dmbee/seglearn/blob/d8d7039e92c4c6571a70350c03298aceab8dbeec/seglearn/transform.py#L555-L578
237,669
dmbee/seglearn
seglearn/transform.py
sliding_tensor
def sliding_tensor(mv_time_series, width, step, order='F'): ''' segments multivariate time series with sliding window Parameters ---------- mv_time_series : array like shape [n_samples, n_variables] multivariate time series or sequence width : int > 0 segment width in samples ...
python
def sliding_tensor(mv_time_series, width, step, order='F'): ''' segments multivariate time series with sliding window Parameters ---------- mv_time_series : array like shape [n_samples, n_variables] multivariate time series or sequence width : int > 0 segment width in samples ...
[ "def", "sliding_tensor", "(", "mv_time_series", ",", "width", ",", "step", ",", "order", "=", "'F'", ")", ":", "D", "=", "mv_time_series", ".", "shape", "[", "1", "]", "data", "=", "[", "sliding_window", "(", "mv_time_series", "[", ":", ",", "j", "]", ...
segments multivariate time series with sliding window Parameters ---------- mv_time_series : array like shape [n_samples, n_variables] multivariate time series or sequence width : int > 0 segment width in samples step : int > 0 stepsize for sliding in samples Returns ...
[ "segments", "multivariate", "time", "series", "with", "sliding", "window" ]
d8d7039e92c4c6571a70350c03298aceab8dbeec
https://github.com/dmbee/seglearn/blob/d8d7039e92c4c6571a70350c03298aceab8dbeec/seglearn/transform.py#L581-L601
237,670
dmbee/seglearn
seglearn/transform.py
SegmentXY.transform
def transform(self, X, y=None, sample_weight=None): ''' Transforms the time series data into segments Note this transformation changes the number of samples in the data If y is provided, it is segmented and transformed to align to the new samples as per ``y_func`` Current...
python
def transform(self, X, y=None, sample_weight=None): ''' Transforms the time series data into segments Note this transformation changes the number of samples in the data If y is provided, it is segmented and transformed to align to the new samples as per ``y_func`` Current...
[ "def", "transform", "(", "self", ",", "X", ",", "y", "=", "None", ",", "sample_weight", "=", "None", ")", ":", "check_ts_data", "(", "X", ",", "y", ")", "Xt", ",", "Xc", "=", "get_ts_data_parts", "(", "X", ")", "yt", "=", "y", "N", "=", "len", ...
Transforms the time series data into segments Note this transformation changes the number of samples in the data If y is provided, it is segmented and transformed to align to the new samples as per ``y_func`` Currently sample weights always returned as None Parameters --...
[ "Transforms", "the", "time", "series", "data", "into", "segments", "Note", "this", "transformation", "changes", "the", "number", "of", "samples", "in", "the", "data", "If", "y", "is", "provided", "it", "is", "segmented", "and", "transformed", "to", "align", ...
d8d7039e92c4c6571a70350c03298aceab8dbeec
https://github.com/dmbee/seglearn/blob/d8d7039e92c4c6571a70350c03298aceab8dbeec/seglearn/transform.py#L329-L385
237,671
dmbee/seglearn
seglearn/transform.py
PadTrunc.transform
def transform(self, X, y=None, sample_weight=None): ''' Transforms the time series data into fixed length segments using padding and or truncation If y is a time series and passed, it will be transformed as well Parameters ---------- X : array-like, shape [n_series, ...]...
python
def transform(self, X, y=None, sample_weight=None): ''' Transforms the time series data into fixed length segments using padding and or truncation If y is a time series and passed, it will be transformed as well Parameters ---------- X : array-like, shape [n_series, ...]...
[ "def", "transform", "(", "self", ",", "X", ",", "y", "=", "None", ",", "sample_weight", "=", "None", ")", ":", "check_ts_data", "(", "X", ",", "y", ")", "Xt", ",", "Xc", "=", "get_ts_data_parts", "(", "X", ")", "yt", "=", "y", "swt", "=", "sample...
Transforms the time series data into fixed length segments using padding and or truncation If y is a time series and passed, it will be transformed as well Parameters ---------- X : array-like, shape [n_series, ...] Time series data and (optionally) contextual data y ...
[ "Transforms", "the", "time", "series", "data", "into", "fixed", "length", "segments", "using", "padding", "and", "or", "truncation", "If", "y", "is", "a", "time", "series", "and", "passed", "it", "will", "be", "transformed", "as", "well" ]
d8d7039e92c4c6571a70350c03298aceab8dbeec
https://github.com/dmbee/seglearn/blob/d8d7039e92c4c6571a70350c03298aceab8dbeec/seglearn/transform.py#L655-L696
237,672
dmbee/seglearn
seglearn/transform.py
InterpLongToWide._check_data
def _check_data(self, X): ''' Checks that unique identifiers vaf_types are consistent between time series. Parameters ---------- X : array-like, shape [n_series, ...] Time series data and (optionally) contextual data ''' if len(X) > 1: sv...
python
def _check_data(self, X): ''' Checks that unique identifiers vaf_types are consistent between time series. Parameters ---------- X : array-like, shape [n_series, ...] Time series data and (optionally) contextual data ''' if len(X) > 1: sv...
[ "def", "_check_data", "(", "self", ",", "X", ")", ":", "if", "len", "(", "X", ")", ">", "1", ":", "sval", "=", "np", ".", "unique", "(", "X", "[", "0", "]", "[", ":", ",", "1", "]", ")", "if", "np", ".", "all", "(", "[", "np", ".", "all...
Checks that unique identifiers vaf_types are consistent between time series. Parameters ---------- X : array-like, shape [n_series, ...] Time series data and (optionally) contextual data
[ "Checks", "that", "unique", "identifiers", "vaf_types", "are", "consistent", "between", "time", "series", "." ]
d8d7039e92c4c6571a70350c03298aceab8dbeec
https://github.com/dmbee/seglearn/blob/d8d7039e92c4c6571a70350c03298aceab8dbeec/seglearn/transform.py#L900-L915
237,673
dmbee/seglearn
seglearn/transform.py
FeatureRep._check_features
def _check_features(self, features, Xti): ''' tests output of each feature against a segmented time series X Parameters ---------- features : dict feature function dictionary Xti : array-like, shape [n_samples, segment_width, n_variables] segmente...
python
def _check_features(self, features, Xti): ''' tests output of each feature against a segmented time series X Parameters ---------- features : dict feature function dictionary Xti : array-like, shape [n_samples, segment_width, n_variables] segmente...
[ "def", "_check_features", "(", "self", ",", "features", ",", "Xti", ")", ":", "N", "=", "Xti", ".", "shape", "[", "0", "]", "N_fts", "=", "len", "(", "features", ")", "fshapes", "=", "np", ".", "zeros", "(", "(", "N_fts", ",", "2", ")", ",", "d...
tests output of each feature against a segmented time series X Parameters ---------- features : dict feature function dictionary Xti : array-like, shape [n_samples, segment_width, n_variables] segmented time series (instance) Returns ------- ...
[ "tests", "output", "of", "each", "feature", "against", "a", "segmented", "time", "series", "X" ]
d8d7039e92c4c6571a70350c03298aceab8dbeec
https://github.com/dmbee/seglearn/blob/d8d7039e92c4c6571a70350c03298aceab8dbeec/seglearn/transform.py#L1137-L1165
237,674
dmbee/seglearn
seglearn/transform.py
FeatureRep._generate_feature_labels
def _generate_feature_labels(self, X): ''' Generates string feature labels ''' Xt, Xc = get_ts_data_parts(X) ftr_sizes = self._check_features(self.features, Xt[0:3]) f_labels = [] # calculated features for key in ftr_sizes: for i in range(ftr...
python
def _generate_feature_labels(self, X): ''' Generates string feature labels ''' Xt, Xc = get_ts_data_parts(X) ftr_sizes = self._check_features(self.features, Xt[0:3]) f_labels = [] # calculated features for key in ftr_sizes: for i in range(ftr...
[ "def", "_generate_feature_labels", "(", "self", ",", "X", ")", ":", "Xt", ",", "Xc", "=", "get_ts_data_parts", "(", "X", ")", "ftr_sizes", "=", "self", ".", "_check_features", "(", "self", ".", "features", ",", "Xt", "[", "0", ":", "3", "]", ")", "f_...
Generates string feature labels
[ "Generates", "string", "feature", "labels" ]
d8d7039e92c4c6571a70350c03298aceab8dbeec
https://github.com/dmbee/seglearn/blob/d8d7039e92c4c6571a70350c03298aceab8dbeec/seglearn/transform.py#L1167-L1187
237,675
dmbee/seglearn
seglearn/transform.py
FeatureRepMix._retrieve_indices
def _retrieve_indices(cols): ''' Retrieve a list of indices corresponding to the provided column specification. ''' if isinstance(cols, int): return [cols] elif isinstance(cols, slice): start = cols.start if cols.start else 0 stop = cols.stop ...
python
def _retrieve_indices(cols): ''' Retrieve a list of indices corresponding to the provided column specification. ''' if isinstance(cols, int): return [cols] elif isinstance(cols, slice): start = cols.start if cols.start else 0 stop = cols.stop ...
[ "def", "_retrieve_indices", "(", "cols", ")", ":", "if", "isinstance", "(", "cols", ",", "int", ")", ":", "return", "[", "cols", "]", "elif", "isinstance", "(", "cols", ",", "slice", ")", ":", "start", "=", "cols", ".", "start", "if", "cols", ".", ...
Retrieve a list of indices corresponding to the provided column specification.
[ "Retrieve", "a", "list", "of", "indices", "corresponding", "to", "the", "provided", "column", "specification", "." ]
d8d7039e92c4c6571a70350c03298aceab8dbeec
https://github.com/dmbee/seglearn/blob/d8d7039e92c4c6571a70350c03298aceab8dbeec/seglearn/transform.py#L1301-L1319
237,676
dmbee/seglearn
seglearn/transform.py
FeatureRepMix._validate
def _validate(self): ''' Internal function to validate the transformer before applying all internal transformers. ''' if self.f_labels is None: raise NotFittedError('FeatureRepMix') if not self.transformers: return names, transformers, _ = zip(*s...
python
def _validate(self): ''' Internal function to validate the transformer before applying all internal transformers. ''' if self.f_labels is None: raise NotFittedError('FeatureRepMix') if not self.transformers: return names, transformers, _ = zip(*s...
[ "def", "_validate", "(", "self", ")", ":", "if", "self", ".", "f_labels", "is", "None", ":", "raise", "NotFittedError", "(", "'FeatureRepMix'", ")", "if", "not", "self", ".", "transformers", ":", "return", "names", ",", "transformers", ",", "_", "=", "zi...
Internal function to validate the transformer before applying all internal transformers.
[ "Internal", "function", "to", "validate", "the", "transformer", "before", "applying", "all", "internal", "transformers", "." ]
d8d7039e92c4c6571a70350c03298aceab8dbeec
https://github.com/dmbee/seglearn/blob/d8d7039e92c4c6571a70350c03298aceab8dbeec/seglearn/transform.py#L1355-L1374
237,677
dmbee/seglearn
seglearn/transform.py
FunctionTransformer.transform
def transform(self, X): ''' Transforms the time series data based on the provided function. Note this transformation must not change the number of samples in the data. Parameters ---------- X : array-like, shape [n_samples, ...] time series data and (optional...
python
def transform(self, X): ''' Transforms the time series data based on the provided function. Note this transformation must not change the number of samples in the data. Parameters ---------- X : array-like, shape [n_samples, ...] time series data and (optional...
[ "def", "transform", "(", "self", ",", "X", ")", ":", "if", "self", ".", "func", "is", "None", ":", "return", "X", "else", ":", "Xt", ",", "Xc", "=", "get_ts_data_parts", "(", "X", ")", "n_samples", "=", "len", "(", "Xt", ")", "Xt", "=", "self", ...
Transforms the time series data based on the provided function. Note this transformation must not change the number of samples in the data. Parameters ---------- X : array-like, shape [n_samples, ...] time series data and (optionally) contextual data Returns ...
[ "Transforms", "the", "time", "series", "data", "based", "on", "the", "provided", "function", ".", "Note", "this", "transformation", "must", "not", "change", "the", "number", "of", "samples", "in", "the", "data", "." ]
d8d7039e92c4c6571a70350c03298aceab8dbeec
https://github.com/dmbee/seglearn/blob/d8d7039e92c4c6571a70350c03298aceab8dbeec/seglearn/transform.py#L1465-L1491
237,678
SAP/PyHDB
pyhdb/protocol/segments.py
RequestSegment.build_payload
def build_payload(self, payload): """Build payload of all parts and write them into the payload buffer""" remaining_size = self.MAX_SEGMENT_PAYLOAD_SIZE for part in self.parts: part_payload = part.pack(remaining_size) payload.write(part_payload) remaining_siz...
python
def build_payload(self, payload): """Build payload of all parts and write them into the payload buffer""" remaining_size = self.MAX_SEGMENT_PAYLOAD_SIZE for part in self.parts: part_payload = part.pack(remaining_size) payload.write(part_payload) remaining_siz...
[ "def", "build_payload", "(", "self", ",", "payload", ")", ":", "remaining_size", "=", "self", ".", "MAX_SEGMENT_PAYLOAD_SIZE", "for", "part", "in", "self", ".", "parts", ":", "part_payload", "=", "part", ".", "pack", "(", "remaining_size", ")", "payload", "....
Build payload of all parts and write them into the payload buffer
[ "Build", "payload", "of", "all", "parts", "and", "write", "them", "into", "the", "payload", "buffer" ]
826539d06b8bcef74fe755e7489b8a8255628f12
https://github.com/SAP/PyHDB/blob/826539d06b8bcef74fe755e7489b8a8255628f12/pyhdb/protocol/segments.py#L75-L82
237,679
SAP/PyHDB
pyhdb/protocol/types.py
escape
def escape(value): """ Escape a single value. """ if isinstance(value, (tuple, list)): return "(" + ", ".join([escape(arg) for arg in value]) + ")" else: typ = by_python_type.get(value.__class__) if typ is None: raise InterfaceError( "Unsupported ...
python
def escape(value): """ Escape a single value. """ if isinstance(value, (tuple, list)): return "(" + ", ".join([escape(arg) for arg in value]) + ")" else: typ = by_python_type.get(value.__class__) if typ is None: raise InterfaceError( "Unsupported ...
[ "def", "escape", "(", "value", ")", ":", "if", "isinstance", "(", "value", ",", "(", "tuple", ",", "list", ")", ")", ":", "return", "\"(\"", "+", "\", \"", ".", "join", "(", "[", "escape", "(", "arg", ")", "for", "arg", "in", "value", "]", ")", ...
Escape a single value.
[ "Escape", "a", "single", "value", "." ]
826539d06b8bcef74fe755e7489b8a8255628f12
https://github.com/SAP/PyHDB/blob/826539d06b8bcef74fe755e7489b8a8255628f12/pyhdb/protocol/types.py#L555-L569
237,680
SAP/PyHDB
pyhdb/protocol/types.py
escape_values
def escape_values(values): """ Escape multiple values from a list, tuple or dict. """ if isinstance(values, (tuple, list)): return tuple([escape(value) for value in values]) elif isinstance(values, dict): return dict([ (key, escape(value)) for (key, value) in values.items...
python
def escape_values(values): """ Escape multiple values from a list, tuple or dict. """ if isinstance(values, (tuple, list)): return tuple([escape(value) for value in values]) elif isinstance(values, dict): return dict([ (key, escape(value)) for (key, value) in values.items...
[ "def", "escape_values", "(", "values", ")", ":", "if", "isinstance", "(", "values", ",", "(", "tuple", ",", "list", ")", ")", ":", "return", "tuple", "(", "[", "escape", "(", "value", ")", "for", "value", "in", "values", "]", ")", "elif", "isinstance...
Escape multiple values from a list, tuple or dict.
[ "Escape", "multiple", "values", "from", "a", "list", "tuple", "or", "dict", "." ]
826539d06b8bcef74fe755e7489b8a8255628f12
https://github.com/SAP/PyHDB/blob/826539d06b8bcef74fe755e7489b8a8255628f12/pyhdb/protocol/types.py#L572-L583
237,681
SAP/PyHDB
pyhdb/protocol/types.py
Date.prepare
def prepare(cls, value): """Pack datetime value into proper binary format""" pfield = struct.pack('b', cls.type_code) if isinstance(value, string_types): value = datetime.datetime.strptime(value, "%Y-%m-%d") year = value.year | 0x8000 # for some unknown reasons year has to b...
python
def prepare(cls, value): """Pack datetime value into proper binary format""" pfield = struct.pack('b', cls.type_code) if isinstance(value, string_types): value = datetime.datetime.strptime(value, "%Y-%m-%d") year = value.year | 0x8000 # for some unknown reasons year has to b...
[ "def", "prepare", "(", "cls", ",", "value", ")", ":", "pfield", "=", "struct", ".", "pack", "(", "'b'", ",", "cls", ".", "type_code", ")", "if", "isinstance", "(", "value", ",", "string_types", ")", ":", "value", "=", "datetime", ".", "datetime", "."...
Pack datetime value into proper binary format
[ "Pack", "datetime", "value", "into", "proper", "binary", "format" ]
826539d06b8bcef74fe755e7489b8a8255628f12
https://github.com/SAP/PyHDB/blob/826539d06b8bcef74fe755e7489b8a8255628f12/pyhdb/protocol/types.py#L368-L376
237,682
SAP/PyHDB
pyhdb/protocol/types.py
Time.prepare
def prepare(cls, value): """Pack time value into proper binary format""" pfield = struct.pack('b', cls.type_code) if isinstance(value, string_types): if "." in value: value = datetime.datetime.strptime(value, "%H:%M:%S.%f") else: value = da...
python
def prepare(cls, value): """Pack time value into proper binary format""" pfield = struct.pack('b', cls.type_code) if isinstance(value, string_types): if "." in value: value = datetime.datetime.strptime(value, "%H:%M:%S.%f") else: value = da...
[ "def", "prepare", "(", "cls", ",", "value", ")", ":", "pfield", "=", "struct", ".", "pack", "(", "'b'", ",", "cls", ".", "type_code", ")", "if", "isinstance", "(", "value", ",", "string_types", ")", ":", "if", "\".\"", "in", "value", ":", "value", ...
Pack time value into proper binary format
[ "Pack", "time", "value", "into", "proper", "binary", "format" ]
826539d06b8bcef74fe755e7489b8a8255628f12
https://github.com/SAP/PyHDB/blob/826539d06b8bcef74fe755e7489b8a8255628f12/pyhdb/protocol/types.py#L439-L450
237,683
SAP/PyHDB
pyhdb/protocol/types.py
MixinLobType.prepare
def prepare(cls, value, length=0, position=0, is_last_data=True): """Prepare Lob header. Note that the actual lob data is NOT written here but appended after the parameter block for each row! """ hstruct = WriteLobHeader.header_struct lob_option_dataincluded = WriteLobHeader.LOB_...
python
def prepare(cls, value, length=0, position=0, is_last_data=True): """Prepare Lob header. Note that the actual lob data is NOT written here but appended after the parameter block for each row! """ hstruct = WriteLobHeader.header_struct lob_option_dataincluded = WriteLobHeader.LOB_...
[ "def", "prepare", "(", "cls", ",", "value", ",", "length", "=", "0", ",", "position", "=", "0", ",", "is_last_data", "=", "True", ")", ":", "hstruct", "=", "WriteLobHeader", ".", "header_struct", "lob_option_dataincluded", "=", "WriteLobHeader", ".", "LOB_OP...
Prepare Lob header. Note that the actual lob data is NOT written here but appended after the parameter block for each row!
[ "Prepare", "Lob", "header", ".", "Note", "that", "the", "actual", "lob", "data", "is", "NOT", "written", "here", "but", "appended", "after", "the", "parameter", "block", "for", "each", "row!" ]
826539d06b8bcef74fe755e7489b8a8255628f12
https://github.com/SAP/PyHDB/blob/826539d06b8bcef74fe755e7489b8a8255628f12/pyhdb/protocol/types.py#L501-L510
237,684
SAP/PyHDB
pyhdb/protocol/lobs.py
Lob.seek
def seek(self, offset, whence=SEEK_SET): """Seek pointer in lob data buffer to requested position. Might trigger further loading of data from the database if the pointer is beyond currently read data. """ # A nice trick is to (ab)use BytesIO.seek() to go to the desired position for easie...
python
def seek(self, offset, whence=SEEK_SET): """Seek pointer in lob data buffer to requested position. Might trigger further loading of data from the database if the pointer is beyond currently read data. """ # A nice trick is to (ab)use BytesIO.seek() to go to the desired position for easie...
[ "def", "seek", "(", "self", ",", "offset", ",", "whence", "=", "SEEK_SET", ")", ":", "# A nice trick is to (ab)use BytesIO.seek() to go to the desired position for easier calculation.", "# This will not add any data to the buffer however - very convenient!", "self", ".", "data", "....
Seek pointer in lob data buffer to requested position. Might trigger further loading of data from the database if the pointer is beyond currently read data.
[ "Seek", "pointer", "in", "lob", "data", "buffer", "to", "requested", "position", ".", "Might", "trigger", "further", "loading", "of", "data", "from", "the", "database", "if", "the", "pointer", "is", "beyond", "currently", "read", "data", "." ]
826539d06b8bcef74fe755e7489b8a8255628f12
https://github.com/SAP/PyHDB/blob/826539d06b8bcef74fe755e7489b8a8255628f12/pyhdb/protocol/lobs.py#L110-L132
237,685
SAP/PyHDB
pyhdb/protocol/lobs.py
Lob._read_missing_lob_data_from_db
def _read_missing_lob_data_from_db(self, readoffset, readlength): """Read LOB request part from database""" logger.debug('Reading missing lob data from db. Offset: %d, readlength: %d' % (readoffset, readlength)) lob_data = self._make_read_lob_request(readoffset, readlength) # make sure ...
python
def _read_missing_lob_data_from_db(self, readoffset, readlength): """Read LOB request part from database""" logger.debug('Reading missing lob data from db. Offset: %d, readlength: %d' % (readoffset, readlength)) lob_data = self._make_read_lob_request(readoffset, readlength) # make sure ...
[ "def", "_read_missing_lob_data_from_db", "(", "self", ",", "readoffset", ",", "readlength", ")", ":", "logger", ".", "debug", "(", "'Reading missing lob data from db. Offset: %d, readlength: %d'", "%", "(", "readoffset", ",", "readlength", ")", ")", "lob_data", "=", "...
Read LOB request part from database
[ "Read", "LOB", "request", "part", "from", "database" ]
826539d06b8bcef74fe755e7489b8a8255628f12
https://github.com/SAP/PyHDB/blob/826539d06b8bcef74fe755e7489b8a8255628f12/pyhdb/protocol/lobs.py#L152-L165
237,686
SAP/PyHDB
pyhdb/protocol/lobs.py
Clob._init_io_container
def _init_io_container(self, init_value): """Initialize container to hold lob data. Here either a cStringIO or a io.StringIO class is used depending on the Python version. For CLobs ensure that an initial unicode value only contains valid ascii chars. """ if isinstance(init_value...
python
def _init_io_container(self, init_value): """Initialize container to hold lob data. Here either a cStringIO or a io.StringIO class is used depending on the Python version. For CLobs ensure that an initial unicode value only contains valid ascii chars. """ if isinstance(init_value...
[ "def", "_init_io_container", "(", "self", ",", "init_value", ")", ":", "if", "isinstance", "(", "init_value", ",", "CLOB_STRING_IO_CLASSES", ")", ":", "# already a valid StringIO instance, just use it as it is", "v", "=", "init_value", "else", ":", "# works for strings an...
Initialize container to hold lob data. Here either a cStringIO or a io.StringIO class is used depending on the Python version. For CLobs ensure that an initial unicode value only contains valid ascii chars.
[ "Initialize", "container", "to", "hold", "lob", "data", ".", "Here", "either", "a", "cStringIO", "or", "a", "io", ".", "StringIO", "class", "is", "used", "depending", "on", "the", "Python", "version", ".", "For", "CLobs", "ensure", "that", "an", "initial",...
826539d06b8bcef74fe755e7489b8a8255628f12
https://github.com/SAP/PyHDB/blob/826539d06b8bcef74fe755e7489b8a8255628f12/pyhdb/protocol/lobs.py#L238-L254
237,687
SAP/PyHDB
pyhdb/cursor.py
Cursor._handle_upsert
def _handle_upsert(self, parts, unwritten_lobs=()): """Handle reply messages from INSERT or UPDATE statements""" self.description = None self._received_last_resultset_part = True # set to 'True' so that cursor.fetch*() returns just empty list for part in parts: if part.kind...
python
def _handle_upsert(self, parts, unwritten_lobs=()): """Handle reply messages from INSERT or UPDATE statements""" self.description = None self._received_last_resultset_part = True # set to 'True' so that cursor.fetch*() returns just empty list for part in parts: if part.kind...
[ "def", "_handle_upsert", "(", "self", ",", "parts", ",", "unwritten_lobs", "=", "(", ")", ")", ":", "self", ".", "description", "=", "None", "self", ".", "_received_last_resultset_part", "=", "True", "# set to 'True' so that cursor.fetch*() returns just empty list", "...
Handle reply messages from INSERT or UPDATE statements
[ "Handle", "reply", "messages", "from", "INSERT", "or", "UPDATE", "statements" ]
826539d06b8bcef74fe755e7489b8a8255628f12
https://github.com/SAP/PyHDB/blob/826539d06b8bcef74fe755e7489b8a8255628f12/pyhdb/cursor.py#L288-L310
237,688
SAP/PyHDB
pyhdb/cursor.py
Cursor._handle_select
def _handle_select(self, parts, result_metadata=None): """Handle reply messages from SELECT statements""" self.rowcount = -1 if result_metadata is not None: # Select was prepared and we can use the already received metadata self.description, self._column_types = self._han...
python
def _handle_select(self, parts, result_metadata=None): """Handle reply messages from SELECT statements""" self.rowcount = -1 if result_metadata is not None: # Select was prepared and we can use the already received metadata self.description, self._column_types = self._han...
[ "def", "_handle_select", "(", "self", ",", "parts", ",", "result_metadata", "=", "None", ")", ":", "self", ".", "rowcount", "=", "-", "1", "if", "result_metadata", "is", "not", "None", ":", "# Select was prepared and we can use the already received metadata", "self"...
Handle reply messages from SELECT statements
[ "Handle", "reply", "messages", "from", "SELECT", "statements" ]
826539d06b8bcef74fe755e7489b8a8255628f12
https://github.com/SAP/PyHDB/blob/826539d06b8bcef74fe755e7489b8a8255628f12/pyhdb/cursor.py#L328-L347
237,689
SAP/PyHDB
pyhdb/cursor.py
Cursor._handle_dbproc_call
def _handle_dbproc_call(self, parts, parameters_metadata): """Handle reply messages from STORED PROCEDURE statements""" for part in parts: if part.kind == part_kinds.ROWSAFFECTED: self.rowcount = part.values[0] elif part.kind == part_kinds.TRANSACTIONFLAGS: ...
python
def _handle_dbproc_call(self, parts, parameters_metadata): """Handle reply messages from STORED PROCEDURE statements""" for part in parts: if part.kind == part_kinds.ROWSAFFECTED: self.rowcount = part.values[0] elif part.kind == part_kinds.TRANSACTIONFLAGS: ...
[ "def", "_handle_dbproc_call", "(", "self", ",", "parts", ",", "parameters_metadata", ")", ":", "for", "part", "in", "parts", ":", "if", "part", ".", "kind", "==", "part_kinds", ".", "ROWSAFFECTED", ":", "self", ".", "rowcount", "=", "part", ".", "values", ...
Handle reply messages from STORED PROCEDURE statements
[ "Handle", "reply", "messages", "from", "STORED", "PROCEDURE", "statements" ]
826539d06b8bcef74fe755e7489b8a8255628f12
https://github.com/SAP/PyHDB/blob/826539d06b8bcef74fe755e7489b8a8255628f12/pyhdb/cursor.py#L349-L372
237,690
SAP/PyHDB
pyhdb/lib/stringlib.py
allhexlify
def allhexlify(data): """Hexlify given data into a string representation with hex values for all chars Input like 'ab\x04ce' becomes '\x61\x62\x04\x63\x65' """ hx = binascii.hexlify(data) return b''.join([b'\\x' + o for o in re.findall(b'..', hx)])
python
def allhexlify(data): """Hexlify given data into a string representation with hex values for all chars Input like 'ab\x04ce' becomes '\x61\x62\x04\x63\x65' """ hx = binascii.hexlify(data) return b''.join([b'\\x' + o for o in re.findall(b'..', hx)])
[ "def", "allhexlify", "(", "data", ")", ":", "hx", "=", "binascii", ".", "hexlify", "(", "data", ")", "return", "b''", ".", "join", "(", "[", "b'\\\\x'", "+", "o", "for", "o", "in", "re", ".", "findall", "(", "b'..'", ",", "hx", ")", "]", ")" ]
Hexlify given data into a string representation with hex values for all chars Input like 'ab\x04ce' becomes '\x61\x62\x04\x63\x65'
[ "Hexlify", "given", "data", "into", "a", "string", "representation", "with", "hex", "values", "for", "all", "chars", "Input", "like", "ab", "\\", "x04ce", "becomes", "\\", "x61", "\\", "x62", "\\", "x04", "\\", "x63", "\\", "x65" ]
826539d06b8bcef74fe755e7489b8a8255628f12
https://github.com/SAP/PyHDB/blob/826539d06b8bcef74fe755e7489b8a8255628f12/pyhdb/lib/stringlib.py#L19-L27
237,691
SAP/PyHDB
pyhdb/protocol/parts.py
Part.pack
def pack(self, remaining_size): """Pack data of part into binary format""" arguments_count, payload = self.pack_data(remaining_size - self.header_size) payload_length = len(payload) # align payload length to multiple of 8 if payload_length % 8 != 0: payload += b"\x00...
python
def pack(self, remaining_size): """Pack data of part into binary format""" arguments_count, payload = self.pack_data(remaining_size - self.header_size) payload_length = len(payload) # align payload length to multiple of 8 if payload_length % 8 != 0: payload += b"\x00...
[ "def", "pack", "(", "self", ",", "remaining_size", ")", ":", "arguments_count", ",", "payload", "=", "self", ".", "pack_data", "(", "remaining_size", "-", "self", ".", "header_size", ")", "payload_length", "=", "len", "(", "payload", ")", "# align payload leng...
Pack data of part into binary format
[ "Pack", "data", "of", "part", "into", "binary", "format" ]
826539d06b8bcef74fe755e7489b8a8255628f12
https://github.com/SAP/PyHDB/blob/826539d06b8bcef74fe755e7489b8a8255628f12/pyhdb/protocol/parts.py#L101-L116
237,692
SAP/PyHDB
pyhdb/protocol/parts.py
Part.unpack_from
def unpack_from(cls, payload, expected_parts): """Unpack parts from payload""" for num_part in iter_range(expected_parts): hdr = payload.read(cls.header_size) try: part_header = PartHeader(*cls.header_struct.unpack(hdr)) except struct.error: ...
python
def unpack_from(cls, payload, expected_parts): """Unpack parts from payload""" for num_part in iter_range(expected_parts): hdr = payload.read(cls.header_size) try: part_header = PartHeader(*cls.header_struct.unpack(hdr)) except struct.error: ...
[ "def", "unpack_from", "(", "cls", ",", "payload", ",", "expected_parts", ")", ":", "for", "num_part", "in", "iter_range", "(", "expected_parts", ")", ":", "hdr", "=", "payload", ".", "read", "(", "cls", ".", "header_size", ")", "try", ":", "part_header", ...
Unpack parts from payload
[ "Unpack", "parts", "from", "payload" ]
826539d06b8bcef74fe755e7489b8a8255628f12
https://github.com/SAP/PyHDB/blob/826539d06b8bcef74fe755e7489b8a8255628f12/pyhdb/protocol/parts.py#L122-L155
237,693
SAP/PyHDB
pyhdb/protocol/parts.py
ReadLobRequest.pack_data
def pack_data(self, remaining_size): """Pack data. readoffset has to be increased by one, seems like HANA starts from 1, not zero.""" payload = self.part_struct.pack(self.locator_id, self.readoffset + 1, self.readlength, b' ') return 4, payload
python
def pack_data(self, remaining_size): """Pack data. readoffset has to be increased by one, seems like HANA starts from 1, not zero.""" payload = self.part_struct.pack(self.locator_id, self.readoffset + 1, self.readlength, b' ') return 4, payload
[ "def", "pack_data", "(", "self", ",", "remaining_size", ")", ":", "payload", "=", "self", ".", "part_struct", ".", "pack", "(", "self", ".", "locator_id", ",", "self", ".", "readoffset", "+", "1", ",", "self", ".", "readlength", ",", "b' '", ")", "r...
Pack data. readoffset has to be increased by one, seems like HANA starts from 1, not zero.
[ "Pack", "data", ".", "readoffset", "has", "to", "be", "increased", "by", "one", "seems", "like", "HANA", "starts", "from", "1", "not", "zero", "." ]
826539d06b8bcef74fe755e7489b8a8255628f12
https://github.com/SAP/PyHDB/blob/826539d06b8bcef74fe755e7489b8a8255628f12/pyhdb/protocol/parts.py#L338-L341
237,694
SAP/PyHDB
pyhdb/protocol/message.py
RequestMessage.build_payload
def build_payload(self, payload): """ Build payload of message. """ for segment in self.segments: segment.pack(payload, commit=self.autocommit)
python
def build_payload(self, payload): """ Build payload of message. """ for segment in self.segments: segment.pack(payload, commit=self.autocommit)
[ "def", "build_payload", "(", "self", ",", "payload", ")", ":", "for", "segment", "in", "self", ".", "segments", ":", "segment", ".", "pack", "(", "payload", ",", "commit", "=", "self", ".", "autocommit", ")" ]
Build payload of message.
[ "Build", "payload", "of", "message", "." ]
826539d06b8bcef74fe755e7489b8a8255628f12
https://github.com/SAP/PyHDB/blob/826539d06b8bcef74fe755e7489b8a8255628f12/pyhdb/protocol/message.py#L42-L45
237,695
SAP/PyHDB
pyhdb/protocol/message.py
RequestMessage.pack
def pack(self): """ Pack message to binary stream. """ payload = io.BytesIO() # Advance num bytes equal to header size - the header is written later # after the payload of all segments and parts has been written: payload.seek(self.header_size, io.SEEK_CUR) # Write out pa...
python
def pack(self): """ Pack message to binary stream. """ payload = io.BytesIO() # Advance num bytes equal to header size - the header is written later # after the payload of all segments and parts has been written: payload.seek(self.header_size, io.SEEK_CUR) # Write out pa...
[ "def", "pack", "(", "self", ")", ":", "payload", "=", "io", ".", "BytesIO", "(", ")", "# Advance num bytes equal to header size - the header is written later", "# after the payload of all segments and parts has been written:", "payload", ".", "seek", "(", "self", ".", "head...
Pack message to binary stream.
[ "Pack", "message", "to", "binary", "stream", "." ]
826539d06b8bcef74fe755e7489b8a8255628f12
https://github.com/SAP/PyHDB/blob/826539d06b8bcef74fe755e7489b8a8255628f12/pyhdb/protocol/message.py#L47-L69
237,696
serge-sans-paille/pythran
pythran/syntax.py
check_specs
def check_specs(specs, renamings, types): ''' Does nothing but raising PythranSyntaxError if specs are incompatible with the actual code ''' from pythran.types.tog import unify, clone, tr from pythran.types.tog import Function, TypeVariable, InferenceError functions = {renamings.get(k, k): ...
python
def check_specs(specs, renamings, types): ''' Does nothing but raising PythranSyntaxError if specs are incompatible with the actual code ''' from pythran.types.tog import unify, clone, tr from pythran.types.tog import Function, TypeVariable, InferenceError functions = {renamings.get(k, k): ...
[ "def", "check_specs", "(", "specs", ",", "renamings", ",", "types", ")", ":", "from", "pythran", ".", "types", ".", "tog", "import", "unify", ",", "clone", ",", "tr", "from", "pythran", ".", "types", ".", "tog", "import", "Function", ",", "TypeVariable",...
Does nothing but raising PythranSyntaxError if specs are incompatible with the actual code
[ "Does", "nothing", "but", "raising", "PythranSyntaxError", "if", "specs", "are", "incompatible", "with", "the", "actual", "code" ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/syntax.py#L190-L213
237,697
serge-sans-paille/pythran
pythran/syntax.py
check_exports
def check_exports(mod, specs, renamings): ''' Does nothing but raising PythranSyntaxError if specs references an undefined global ''' functions = {renamings.get(k, k): v for k, v in specs.functions.items()} mod_functions = {node.name: node for node in mod.body if isinstance...
python
def check_exports(mod, specs, renamings): ''' Does nothing but raising PythranSyntaxError if specs references an undefined global ''' functions = {renamings.get(k, k): v for k, v in specs.functions.items()} mod_functions = {node.name: node for node in mod.body if isinstance...
[ "def", "check_exports", "(", "mod", ",", "specs", ",", "renamings", ")", ":", "functions", "=", "{", "renamings", ".", "get", "(", "k", ",", "k", ")", ":", "v", "for", "k", ",", "v", "in", "specs", ".", "functions", ".", "items", "(", ")", "}", ...
Does nothing but raising PythranSyntaxError if specs references an undefined global
[ "Does", "nothing", "but", "raising", "PythranSyntaxError", "if", "specs", "references", "an", "undefined", "global" ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/syntax.py#L216-L242
237,698
serge-sans-paille/pythran
pythran/syntax.py
SyntaxChecker.visit_Import
def visit_Import(self, node): """ Check if imported module exists in MODULES. """ for alias in node.names: current_module = MODULES # Recursive check for submodules for path in alias.name.split('.'): if path not in current_module: r...
python
def visit_Import(self, node): """ Check if imported module exists in MODULES. """ for alias in node.names: current_module = MODULES # Recursive check for submodules for path in alias.name.split('.'): if path not in current_module: r...
[ "def", "visit_Import", "(", "self", ",", "node", ")", ":", "for", "alias", "in", "node", ".", "names", ":", "current_module", "=", "MODULES", "# Recursive check for submodules", "for", "path", "in", "alias", ".", "name", ".", "split", "(", "'.'", ")", ":",...
Check if imported module exists in MODULES.
[ "Check", "if", "imported", "module", "exists", "in", "MODULES", "." ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/syntax.py#L129-L140
237,699
serge-sans-paille/pythran
pythran/syntax.py
SyntaxChecker.visit_ImportFrom
def visit_ImportFrom(self, node): """ Check validity of imported functions. Check: - no level specific value are provided. - a module is provided - module/submodule exists in MODULES - imported function exists in the given ...
python
def visit_ImportFrom(self, node): """ Check validity of imported functions. Check: - no level specific value are provided. - a module is provided - module/submodule exists in MODULES - imported function exists in the given ...
[ "def", "visit_ImportFrom", "(", "self", ",", "node", ")", ":", "if", "node", ".", "level", ":", "raise", "PythranSyntaxError", "(", "\"Relative import not supported\"", ",", "node", ")", "if", "not", "node", ".", "module", ":", "raise", "PythranSyntaxError", "...
Check validity of imported functions. Check: - no level specific value are provided. - a module is provided - module/submodule exists in MODULES - imported function exists in the given module/submodule
[ "Check", "validity", "of", "imported", "functions", "." ]
7e1b5af2dddfabc50bd2a977f0178be269b349b5
https://github.com/serge-sans-paille/pythran/blob/7e1b5af2dddfabc50bd2a977f0178be269b349b5/pythran/syntax.py#L142-L176