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 |
|---|---|---|---|---|---|---|---|---|---|---|---|
26,100 | quantopian/zipline | zipline/algorithm.py | TradingAlgorithm.set_commission | def set_commission(self, us_equities=None, us_futures=None):
"""Sets the commission models for the simulation.
Parameters
----------
us_equities : EquityCommissionModel
The commission model to use for trading US equities.
us_futures : FutureCommissionModel
... | python | def set_commission(self, us_equities=None, us_futures=None):
"""Sets the commission models for the simulation.
Parameters
----------
us_equities : EquityCommissionModel
The commission model to use for trading US equities.
us_futures : FutureCommissionModel
... | [
"def",
"set_commission",
"(",
"self",
",",
"us_equities",
"=",
"None",
",",
"us_futures",
"=",
"None",
")",
":",
"if",
"self",
".",
"initialized",
":",
"raise",
"SetCommissionPostInit",
"(",
")",
"if",
"us_equities",
"is",
"not",
"None",
":",
"if",
"Equity... | Sets the commission models for the simulation.
Parameters
----------
us_equities : EquityCommissionModel
The commission model to use for trading US equities.
us_futures : FutureCommissionModel
The commission model to use for trading US futures.
See Also
... | [
"Sets",
"the",
"commission",
"models",
"for",
"the",
"simulation",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/algorithm.py#L1528-L1563 |
26,101 | quantopian/zipline | zipline/algorithm.py | TradingAlgorithm.set_cancel_policy | def set_cancel_policy(self, cancel_policy):
"""Sets the order cancellation policy for the simulation.
Parameters
----------
cancel_policy : CancelPolicy
The cancellation policy to use.
See Also
--------
:class:`zipline.api.EODCancel`
:class:`... | python | def set_cancel_policy(self, cancel_policy):
"""Sets the order cancellation policy for the simulation.
Parameters
----------
cancel_policy : CancelPolicy
The cancellation policy to use.
See Also
--------
:class:`zipline.api.EODCancel`
:class:`... | [
"def",
"set_cancel_policy",
"(",
"self",
",",
"cancel_policy",
")",
":",
"if",
"not",
"isinstance",
"(",
"cancel_policy",
",",
"CancelPolicy",
")",
":",
"raise",
"UnsupportedCancelPolicy",
"(",
")",
"if",
"self",
".",
"initialized",
":",
"raise",
"SetCancelPolic... | Sets the order cancellation policy for the simulation.
Parameters
----------
cancel_policy : CancelPolicy
The cancellation policy to use.
See Also
--------
:class:`zipline.api.EODCancel`
:class:`zipline.api.NeverCancel` | [
"Sets",
"the",
"order",
"cancellation",
"policy",
"for",
"the",
"simulation",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/algorithm.py#L1566-L1585 |
26,102 | quantopian/zipline | zipline/algorithm.py | TradingAlgorithm.order_percent | def order_percent(self,
asset,
percent,
limit_price=None,
stop_price=None,
style=None):
"""Place an order in the specified asset corresponding to the given
percent of the current portfolio value... | python | def order_percent(self,
asset,
percent,
limit_price=None,
stop_price=None,
style=None):
"""Place an order in the specified asset corresponding to the given
percent of the current portfolio value... | [
"def",
"order_percent",
"(",
"self",
",",
"asset",
",",
"percent",
",",
"limit_price",
"=",
"None",
",",
"stop_price",
"=",
"None",
",",
"style",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"_can_order_asset",
"(",
"asset",
")",
":",
"return",
"No... | Place an order in the specified asset corresponding to the given
percent of the current portfolio value.
Parameters
----------
asset : Asset
The asset that this order is for.
percent : float
The percentage of the portfolio value to allocate to ``asset``.
... | [
"Place",
"an",
"order",
"in",
"the",
"specified",
"asset",
"corresponding",
"to",
"the",
"given",
"percent",
"of",
"the",
"current",
"portfolio",
"value",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/algorithm.py#L1616-L1662 |
26,103 | quantopian/zipline | zipline/algorithm.py | TradingAlgorithm.order_target | def order_target(self,
asset,
target,
limit_price=None,
stop_price=None,
style=None):
"""Place an order to adjust a position to a target number of shares. If
the position doesn't already exist, this ... | python | def order_target(self,
asset,
target,
limit_price=None,
stop_price=None,
style=None):
"""Place an order to adjust a position to a target number of shares. If
the position doesn't already exist, this ... | [
"def",
"order_target",
"(",
"self",
",",
"asset",
",",
"target",
",",
"limit_price",
"=",
"None",
",",
"stop_price",
"=",
"None",
",",
"style",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"_can_order_asset",
"(",
"asset",
")",
":",
"return",
"None... | Place an order to adjust a position to a target number of shares. If
the position doesn't already exist, this is equivalent to placing a new
order. If the position does exist, this is equivalent to placing an
order for the difference between the target number of shares and the
current nu... | [
"Place",
"an",
"order",
"to",
"adjust",
"a",
"position",
"to",
"a",
"target",
"number",
"of",
"shares",
".",
"If",
"the",
"position",
"doesn",
"t",
"already",
"exist",
"this",
"is",
"equivalent",
"to",
"placing",
"a",
"new",
"order",
".",
"If",
"the",
... | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/algorithm.py#L1670-L1732 |
26,104 | quantopian/zipline | zipline/algorithm.py | TradingAlgorithm.order_target_value | def order_target_value(self,
asset,
target,
limit_price=None,
stop_price=None,
style=None):
"""Place an order to adjust a position to a target value. If
the position doe... | python | def order_target_value(self,
asset,
target,
limit_price=None,
stop_price=None,
style=None):
"""Place an order to adjust a position to a target value. If
the position doe... | [
"def",
"order_target_value",
"(",
"self",
",",
"asset",
",",
"target",
",",
"limit_price",
"=",
"None",
",",
"stop_price",
"=",
"None",
",",
"style",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"_can_order_asset",
"(",
"asset",
")",
":",
"return",
... | Place an order to adjust a position to a target value. If
the position doesn't already exist, this is equivalent to placing a new
order. If the position does exist, this is equivalent to placing an
order for the difference between the target value and the
current value.
If the As... | [
"Place",
"an",
"order",
"to",
"adjust",
"a",
"position",
"to",
"a",
"target",
"value",
".",
"If",
"the",
"position",
"doesn",
"t",
"already",
"exist",
"this",
"is",
"equivalent",
"to",
"placing",
"a",
"new",
"order",
".",
"If",
"the",
"position",
"does",... | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/algorithm.py#L1743-L1807 |
26,105 | quantopian/zipline | zipline/algorithm.py | TradingAlgorithm.order_target_percent | def order_target_percent(self, asset, target,
limit_price=None, stop_price=None, style=None):
"""Place an order to adjust a position to a target percent of the
current portfolio value. If the position doesn't already exist, this is
equivalent to placing a new order. ... | python | def order_target_percent(self, asset, target,
limit_price=None, stop_price=None, style=None):
"""Place an order to adjust a position to a target percent of the
current portfolio value. If the position doesn't already exist, this is
equivalent to placing a new order. ... | [
"def",
"order_target_percent",
"(",
"self",
",",
"asset",
",",
"target",
",",
"limit_price",
"=",
"None",
",",
"stop_price",
"=",
"None",
",",
"style",
"=",
"None",
")",
":",
"if",
"not",
"self",
".",
"_can_order_asset",
"(",
"asset",
")",
":",
"return",... | Place an order to adjust a position to a target percent of the
current portfolio value. If the position doesn't already exist, this is
equivalent to placing a new order. If the position does exist, this is
equivalent to placing an order for the difference between the target
percent and t... | [
"Place",
"an",
"order",
"to",
"adjust",
"a",
"position",
"to",
"a",
"target",
"percent",
"of",
"the",
"current",
"portfolio",
"value",
".",
"If",
"the",
"position",
"doesn",
"t",
"already",
"exist",
"this",
"is",
"equivalent",
"to",
"placing",
"a",
"new",
... | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/algorithm.py#L1811-L1870 |
26,106 | quantopian/zipline | zipline/algorithm.py | TradingAlgorithm.batch_market_order | def batch_market_order(self, share_counts):
"""Place a batch market order for multiple assets.
Parameters
----------
share_counts : pd.Series[Asset -> int]
Map from asset to number of shares to order for that asset.
Returns
-------
order_ids : pd.Ind... | python | def batch_market_order(self, share_counts):
"""Place a batch market order for multiple assets.
Parameters
----------
share_counts : pd.Series[Asset -> int]
Map from asset to number of shares to order for that asset.
Returns
-------
order_ids : pd.Ind... | [
"def",
"batch_market_order",
"(",
"self",
",",
"share_counts",
")",
":",
"style",
"=",
"MarketOrder",
"(",
")",
"order_args",
"=",
"[",
"(",
"asset",
",",
"amount",
",",
"style",
")",
"for",
"(",
"asset",
",",
"amount",
")",
"in",
"iteritems",
"(",
"sh... | Place a batch market order for multiple assets.
Parameters
----------
share_counts : pd.Series[Asset -> int]
Map from asset to number of shares to order for that asset.
Returns
-------
order_ids : pd.Index[str]
Index of ids for newly-created orde... | [
"Place",
"a",
"batch",
"market",
"order",
"for",
"multiple",
"assets",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/algorithm.py#L1879-L1898 |
26,107 | quantopian/zipline | zipline/algorithm.py | TradingAlgorithm.get_open_orders | def get_open_orders(self, asset=None):
"""Retrieve all of the current open orders.
Parameters
----------
asset : Asset
If passed and not None, return only the open orders for the given
asset instead of all open orders.
Returns
-------
ope... | python | def get_open_orders(self, asset=None):
"""Retrieve all of the current open orders.
Parameters
----------
asset : Asset
If passed and not None, return only the open orders for the given
asset instead of all open orders.
Returns
-------
ope... | [
"def",
"get_open_orders",
"(",
"self",
",",
"asset",
"=",
"None",
")",
":",
"if",
"asset",
"is",
"None",
":",
"return",
"{",
"key",
":",
"[",
"order",
".",
"to_api_obj",
"(",
")",
"for",
"order",
"in",
"orders",
"]",
"for",
"key",
",",
"orders",
"i... | Retrieve all of the current open orders.
Parameters
----------
asset : Asset
If passed and not None, return only the open orders for the given
asset instead of all open orders.
Returns
-------
open_orders : dict[list[Order]] or list[Order]
... | [
"Retrieve",
"all",
"of",
"the",
"current",
"open",
"orders",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/algorithm.py#L1903-L1929 |
26,108 | quantopian/zipline | zipline/algorithm.py | TradingAlgorithm.get_order | def get_order(self, order_id):
"""Lookup an order based on the order id returned from one of the
order functions.
Parameters
----------
order_id : str
The unique identifier for the order.
Returns
-------
order : Order
The order ob... | python | def get_order(self, order_id):
"""Lookup an order based on the order id returned from one of the
order functions.
Parameters
----------
order_id : str
The unique identifier for the order.
Returns
-------
order : Order
The order ob... | [
"def",
"get_order",
"(",
"self",
",",
"order_id",
")",
":",
"if",
"order_id",
"in",
"self",
".",
"blotter",
".",
"orders",
":",
"return",
"self",
".",
"blotter",
".",
"orders",
"[",
"order_id",
"]",
".",
"to_api_obj",
"(",
")"
] | Lookup an order based on the order id returned from one of the
order functions.
Parameters
----------
order_id : str
The unique identifier for the order.
Returns
-------
order : Order
The order object. | [
"Lookup",
"an",
"order",
"based",
"on",
"the",
"order",
"id",
"returned",
"from",
"one",
"of",
"the",
"order",
"functions",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/algorithm.py#L1932-L1947 |
26,109 | quantopian/zipline | zipline/algorithm.py | TradingAlgorithm.cancel_order | def cancel_order(self, order_param):
"""Cancel an open order.
Parameters
----------
order_param : str or Order
The order_id or order object to cancel.
"""
order_id = order_param
if isinstance(order_param, zipline.protocol.Order):
order_id ... | python | def cancel_order(self, order_param):
"""Cancel an open order.
Parameters
----------
order_param : str or Order
The order_id or order object to cancel.
"""
order_id = order_param
if isinstance(order_param, zipline.protocol.Order):
order_id ... | [
"def",
"cancel_order",
"(",
"self",
",",
"order_param",
")",
":",
"order_id",
"=",
"order_param",
"if",
"isinstance",
"(",
"order_param",
",",
"zipline",
".",
"protocol",
".",
"Order",
")",
":",
"order_id",
"=",
"order_param",
".",
"id",
"self",
".",
"blot... | Cancel an open order.
Parameters
----------
order_param : str or Order
The order_id or order object to cancel. | [
"Cancel",
"an",
"open",
"order",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/algorithm.py#L1950-L1962 |
26,110 | quantopian/zipline | zipline/algorithm.py | TradingAlgorithm.register_account_control | def register_account_control(self, control):
"""
Register a new AccountControl to be checked on each bar.
"""
if self.initialized:
raise RegisterAccountControlPostInit()
self.account_controls.append(control) | python | def register_account_control(self, control):
"""
Register a new AccountControl to be checked on each bar.
"""
if self.initialized:
raise RegisterAccountControlPostInit()
self.account_controls.append(control) | [
"def",
"register_account_control",
"(",
"self",
",",
"control",
")",
":",
"if",
"self",
".",
"initialized",
":",
"raise",
"RegisterAccountControlPostInit",
"(",
")",
"self",
".",
"account_controls",
".",
"append",
"(",
"control",
")"
] | Register a new AccountControl to be checked on each bar. | [
"Register",
"a",
"new",
"AccountControl",
"to",
"be",
"checked",
"on",
"each",
"bar",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/algorithm.py#L2028-L2034 |
26,111 | quantopian/zipline | zipline/algorithm.py | TradingAlgorithm.set_min_leverage | def set_min_leverage(self, min_leverage, grace_period):
"""Set a limit on the minimum leverage of the algorithm.
Parameters
----------
min_leverage : float
The minimum leverage for the algorithm.
grace_period : pd.Timedelta
The offset from the start date ... | python | def set_min_leverage(self, min_leverage, grace_period):
"""Set a limit on the minimum leverage of the algorithm.
Parameters
----------
min_leverage : float
The minimum leverage for the algorithm.
grace_period : pd.Timedelta
The offset from the start date ... | [
"def",
"set_min_leverage",
"(",
"self",
",",
"min_leverage",
",",
"grace_period",
")",
":",
"deadline",
"=",
"self",
".",
"sim_params",
".",
"start_session",
"+",
"grace_period",
"control",
"=",
"MinLeverage",
"(",
"min_leverage",
",",
"deadline",
")",
"self",
... | Set a limit on the minimum leverage of the algorithm.
Parameters
----------
min_leverage : float
The minimum leverage for the algorithm.
grace_period : pd.Timedelta
The offset from the start date used to enforce a minimum leverage. | [
"Set",
"a",
"limit",
"on",
"the",
"minimum",
"leverage",
"of",
"the",
"algorithm",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/algorithm.py#L2057-L2069 |
26,112 | quantopian/zipline | zipline/algorithm.py | TradingAlgorithm.register_trading_control | def register_trading_control(self, control):
"""
Register a new TradingControl to be checked prior to order calls.
"""
if self.initialized:
raise RegisterTradingControlPostInit()
self.trading_controls.append(control) | python | def register_trading_control(self, control):
"""
Register a new TradingControl to be checked prior to order calls.
"""
if self.initialized:
raise RegisterTradingControlPostInit()
self.trading_controls.append(control) | [
"def",
"register_trading_control",
"(",
"self",
",",
"control",
")",
":",
"if",
"self",
".",
"initialized",
":",
"raise",
"RegisterTradingControlPostInit",
"(",
")",
"self",
".",
"trading_controls",
".",
"append",
"(",
"control",
")"
] | Register a new TradingControl to be checked prior to order calls. | [
"Register",
"a",
"new",
"TradingControl",
"to",
"be",
"checked",
"prior",
"to",
"order",
"calls",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/algorithm.py#L2075-L2081 |
26,113 | quantopian/zipline | zipline/algorithm.py | TradingAlgorithm.set_max_order_count | def set_max_order_count(self, max_count, on_error='fail'):
"""Set a limit on the number of orders that can be placed in a single
day.
Parameters
----------
max_count : int
The maximum number of orders that can be placed on any single day.
"""
control ... | python | def set_max_order_count(self, max_count, on_error='fail'):
"""Set a limit on the number of orders that can be placed in a single
day.
Parameters
----------
max_count : int
The maximum number of orders that can be placed on any single day.
"""
control ... | [
"def",
"set_max_order_count",
"(",
"self",
",",
"max_count",
",",
"on_error",
"=",
"'fail'",
")",
":",
"control",
"=",
"MaxOrderCount",
"(",
"on_error",
",",
"max_count",
")",
"self",
".",
"register_trading_control",
"(",
"control",
")"
] | Set a limit on the number of orders that can be placed in a single
day.
Parameters
----------
max_count : int
The maximum number of orders that can be placed on any single day. | [
"Set",
"a",
"limit",
"on",
"the",
"number",
"of",
"orders",
"that",
"can",
"be",
"placed",
"in",
"a",
"single",
"day",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/algorithm.py#L2146-L2156 |
26,114 | quantopian/zipline | zipline/algorithm.py | TradingAlgorithm.attach_pipeline | def attach_pipeline(self, pipeline, name, chunks=None, eager=True):
"""Register a pipeline to be computed at the start of each day.
Parameters
----------
pipeline : Pipeline
The pipeline to have computed.
name : str
The name of the pipeline.
chunk... | python | def attach_pipeline(self, pipeline, name, chunks=None, eager=True):
"""Register a pipeline to be computed at the start of each day.
Parameters
----------
pipeline : Pipeline
The pipeline to have computed.
name : str
The name of the pipeline.
chunk... | [
"def",
"attach_pipeline",
"(",
"self",
",",
"pipeline",
",",
"name",
",",
"chunks",
"=",
"None",
",",
"eager",
"=",
"True",
")",
":",
"if",
"chunks",
"is",
"None",
":",
"# Make the first chunk smaller to get more immediate results:",
"# (one week, then every half year... | Register a pipeline to be computed at the start of each day.
Parameters
----------
pipeline : Pipeline
The pipeline to have computed.
name : str
The name of the pipeline.
chunks : int or iterator, optional
The number of days to compute pipelin... | [
"Register",
"a",
"pipeline",
"to",
"be",
"computed",
"at",
"the",
"start",
"of",
"each",
"day",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/algorithm.py#L2228-L2270 |
26,115 | quantopian/zipline | zipline/algorithm.py | TradingAlgorithm._pipeline_output | def _pipeline_output(self, pipeline, chunks, name):
"""
Internal implementation of `pipeline_output`.
"""
today = normalize_date(self.get_datetime())
try:
data = self._pipeline_cache.get(name, today)
except KeyError:
# Calculate the next block.
... | python | def _pipeline_output(self, pipeline, chunks, name):
"""
Internal implementation of `pipeline_output`.
"""
today = normalize_date(self.get_datetime())
try:
data = self._pipeline_cache.get(name, today)
except KeyError:
# Calculate the next block.
... | [
"def",
"_pipeline_output",
"(",
"self",
",",
"pipeline",
",",
"chunks",
",",
"name",
")",
":",
"today",
"=",
"normalize_date",
"(",
"self",
".",
"get_datetime",
"(",
")",
")",
"try",
":",
"data",
"=",
"self",
".",
"_pipeline_cache",
".",
"get",
"(",
"n... | Internal implementation of `pipeline_output`. | [
"Internal",
"implementation",
"of",
"pipeline_output",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/algorithm.py#L2308-L2328 |
26,116 | quantopian/zipline | zipline/algorithm.py | TradingAlgorithm.run_pipeline | def run_pipeline(self, pipeline, start_session, chunksize):
"""
Compute `pipeline`, providing values for at least `start_date`.
Produces a DataFrame containing data for days between `start_date` and
`end_date`, where `end_date` is defined by:
`end_date = min(start_date + ch... | python | def run_pipeline(self, pipeline, start_session, chunksize):
"""
Compute `pipeline`, providing values for at least `start_date`.
Produces a DataFrame containing data for days between `start_date` and
`end_date`, where `end_date` is defined by:
`end_date = min(start_date + ch... | [
"def",
"run_pipeline",
"(",
"self",
",",
"pipeline",
",",
"start_session",
",",
"chunksize",
")",
":",
"sessions",
"=",
"self",
".",
"trading_calendar",
".",
"all_sessions",
"# Load data starting from the previous trading day...",
"start_date_loc",
"=",
"sessions",
".",... | Compute `pipeline`, providing values for at least `start_date`.
Produces a DataFrame containing data for days between `start_date` and
`end_date`, where `end_date` is defined by:
`end_date = min(start_date + chunksize trading days,
simulation_end)`
Retu... | [
"Compute",
"pipeline",
"providing",
"values",
"for",
"at",
"least",
"start_date",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/algorithm.py#L2330-L2366 |
26,117 | quantopian/zipline | zipline/algorithm.py | TradingAlgorithm.all_api_methods | def all_api_methods(cls):
"""
Return a list of all the TradingAlgorithm API methods.
"""
return [
fn for fn in itervalues(vars(cls))
if getattr(fn, 'is_api_method', False)
] | python | def all_api_methods(cls):
"""
Return a list of all the TradingAlgorithm API methods.
"""
return [
fn for fn in itervalues(vars(cls))
if getattr(fn, 'is_api_method', False)
] | [
"def",
"all_api_methods",
"(",
"cls",
")",
":",
"return",
"[",
"fn",
"for",
"fn",
"in",
"itervalues",
"(",
"vars",
"(",
"cls",
")",
")",
"if",
"getattr",
"(",
"fn",
",",
"'is_api_method'",
",",
"False",
")",
"]"
] | Return a list of all the TradingAlgorithm API methods. | [
"Return",
"a",
"list",
"of",
"all",
"the",
"TradingAlgorithm",
"API",
"methods",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/algorithm.py#L2394-L2401 |
26,118 | quantopian/zipline | zipline/utils/argcheck.py | _expect_extra | def _expect_extra(expected, present, exc_unexpected, exc_missing, exc_args):
"""
Checks for the presence of an extra to the argument list. Raises expections
if this is unexpected or if it is missing and expected.
"""
if present:
if not expected:
raise exc_unexpected(*exc_args)
... | python | def _expect_extra(expected, present, exc_unexpected, exc_missing, exc_args):
"""
Checks for the presence of an extra to the argument list. Raises expections
if this is unexpected or if it is missing and expected.
"""
if present:
if not expected:
raise exc_unexpected(*exc_args)
... | [
"def",
"_expect_extra",
"(",
"expected",
",",
"present",
",",
"exc_unexpected",
",",
"exc_missing",
",",
"exc_args",
")",
":",
"if",
"present",
":",
"if",
"not",
"expected",
":",
"raise",
"exc_unexpected",
"(",
"*",
"exc_args",
")",
"elif",
"expected",
"and"... | Checks for the presence of an extra to the argument list. Raises expections
if this is unexpected or if it is missing and expected. | [
"Checks",
"for",
"the",
"presence",
"of",
"an",
"extra",
"to",
"the",
"argument",
"list",
".",
"Raises",
"expections",
"if",
"this",
"is",
"unexpected",
"or",
"if",
"it",
"is",
"missing",
"and",
"expected",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/utils/argcheck.py#L131-L140 |
26,119 | quantopian/zipline | zipline/finance/asset_restrictions.py | StaticRestrictions.is_restricted | def is_restricted(self, assets, dt):
"""
An asset is restricted for all dts if it is in the static list.
"""
if isinstance(assets, Asset):
return assets in self._restricted_set
return pd.Series(
index=pd.Index(assets),
data=vectorized_is_elemen... | python | def is_restricted(self, assets, dt):
"""
An asset is restricted for all dts if it is in the static list.
"""
if isinstance(assets, Asset):
return assets in self._restricted_set
return pd.Series(
index=pd.Index(assets),
data=vectorized_is_elemen... | [
"def",
"is_restricted",
"(",
"self",
",",
"assets",
",",
"dt",
")",
":",
"if",
"isinstance",
"(",
"assets",
",",
"Asset",
")",
":",
"return",
"assets",
"in",
"self",
".",
"_restricted_set",
"return",
"pd",
".",
"Series",
"(",
"index",
"=",
"pd",
".",
... | An asset is restricted for all dts if it is in the static list. | [
"An",
"asset",
"is",
"restricted",
"for",
"all",
"dts",
"if",
"it",
"is",
"in",
"the",
"static",
"list",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/finance/asset_restrictions.py#L143-L152 |
26,120 | quantopian/zipline | zipline/finance/asset_restrictions.py | HistoricalRestrictions.is_restricted | def is_restricted(self, assets, dt):
"""
Returns whether or not an asset or iterable of assets is restricted
on a dt.
"""
if isinstance(assets, Asset):
return self._is_restricted_for_asset(assets, dt)
is_restricted = partial(self._is_restricted_for_asset, dt=... | python | def is_restricted(self, assets, dt):
"""
Returns whether or not an asset or iterable of assets is restricted
on a dt.
"""
if isinstance(assets, Asset):
return self._is_restricted_for_asset(assets, dt)
is_restricted = partial(self._is_restricted_for_asset, dt=... | [
"def",
"is_restricted",
"(",
"self",
",",
"assets",
",",
"dt",
")",
":",
"if",
"isinstance",
"(",
"assets",
",",
"Asset",
")",
":",
"return",
"self",
".",
"_is_restricted_for_asset",
"(",
"assets",
",",
"dt",
")",
"is_restricted",
"=",
"partial",
"(",
"s... | Returns whether or not an asset or iterable of assets is restricted
on a dt. | [
"Returns",
"whether",
"or",
"not",
"an",
"asset",
"or",
"iterable",
"of",
"assets",
"is",
"restricted",
"on",
"a",
"dt",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/finance/asset_restrictions.py#L177-L189 |
26,121 | quantopian/zipline | zipline/finance/ledger.py | PositionTracker.pay_dividends | def pay_dividends(self, next_trading_day):
"""
Returns a cash payment based on the dividends that should be paid out
according to the accumulated bookkeeping of earned, unpaid, and stock
dividends.
"""
net_cash_payment = 0.0
try:
payments = self._unpa... | python | def pay_dividends(self, next_trading_day):
"""
Returns a cash payment based on the dividends that should be paid out
according to the accumulated bookkeeping of earned, unpaid, and stock
dividends.
"""
net_cash_payment = 0.0
try:
payments = self._unpa... | [
"def",
"pay_dividends",
"(",
"self",
",",
"next_trading_day",
")",
":",
"net_cash_payment",
"=",
"0.0",
"try",
":",
"payments",
"=",
"self",
".",
"_unpaid_dividends",
"[",
"next_trading_day",
"]",
"# Mark these dividends as paid by dropping them from our unpaid",
"del",
... | Returns a cash payment based on the dividends that should be paid out
according to the accumulated bookkeeping of earned, unpaid, and stock
dividends. | [
"Returns",
"a",
"cash",
"payment",
"based",
"on",
"the",
"dividends",
"that",
"should",
"be",
"paid",
"out",
"according",
"to",
"the",
"accumulated",
"bookkeeping",
"of",
"earned",
"unpaid",
"and",
"stock",
"dividends",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/finance/ledger.py#L181-L222 |
26,122 | quantopian/zipline | zipline/finance/ledger.py | PositionTracker.stats | def stats(self):
"""The current status of the positions.
Returns
-------
stats : PositionStats
The current stats position stats.
Notes
-----
This is cached, repeated access will not recompute the stats until
the stats may have changed.
... | python | def stats(self):
"""The current status of the positions.
Returns
-------
stats : PositionStats
The current stats position stats.
Notes
-----
This is cached, repeated access will not recompute the stats until
the stats may have changed.
... | [
"def",
"stats",
"(",
"self",
")",
":",
"if",
"self",
".",
"_dirty_stats",
":",
"calculate_position_tracker_stats",
"(",
"self",
".",
"positions",
",",
"self",
".",
"_stats",
")",
"self",
".",
"_dirty_stats",
"=",
"False",
"return",
"self",
".",
"_stats"
] | The current status of the positions.
Returns
-------
stats : PositionStats
The current stats position stats.
Notes
-----
This is cached, repeated access will not recompute the stats until
the stats may have changed. | [
"The",
"current",
"status",
"of",
"the",
"positions",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/finance/ledger.py#L288-L305 |
26,123 | quantopian/zipline | zipline/finance/ledger.py | Ledger.process_transaction | def process_transaction(self, transaction):
"""Add a transaction to ledger, updating the current state as needed.
Parameters
----------
transaction : zp.Transaction
The transaction to execute.
"""
asset = transaction.asset
if isinstance(asset, Future)... | python | def process_transaction(self, transaction):
"""Add a transaction to ledger, updating the current state as needed.
Parameters
----------
transaction : zp.Transaction
The transaction to execute.
"""
asset = transaction.asset
if isinstance(asset, Future)... | [
"def",
"process_transaction",
"(",
"self",
",",
"transaction",
")",
":",
"asset",
"=",
"transaction",
".",
"asset",
"if",
"isinstance",
"(",
"asset",
",",
"Future",
")",
":",
"try",
":",
"old_price",
"=",
"self",
".",
"_payout_last_sale_prices",
"[",
"asset"... | Add a transaction to ledger, updating the current state as needed.
Parameters
----------
transaction : zp.Transaction
The transaction to execute. | [
"Add",
"a",
"transaction",
"to",
"ledger",
"updating",
"the",
"current",
"state",
"as",
"needed",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/finance/ledger.py#L479-L523 |
26,124 | quantopian/zipline | zipline/finance/ledger.py | Ledger.process_order | def process_order(self, order):
"""Keep track of an order that was placed.
Parameters
----------
order : zp.Order
The order to record.
"""
try:
dt_orders = self._orders_by_modified[order.dt]
except KeyError:
self._orders_by_mod... | python | def process_order(self, order):
"""Keep track of an order that was placed.
Parameters
----------
order : zp.Order
The order to record.
"""
try:
dt_orders = self._orders_by_modified[order.dt]
except KeyError:
self._orders_by_mod... | [
"def",
"process_order",
"(",
"self",
",",
"order",
")",
":",
"try",
":",
"dt_orders",
"=",
"self",
".",
"_orders_by_modified",
"[",
"order",
".",
"dt",
"]",
"except",
"KeyError",
":",
"self",
".",
"_orders_by_modified",
"[",
"order",
".",
"dt",
"]",
"=",... | Keep track of an order that was placed.
Parameters
----------
order : zp.Order
The order to record. | [
"Keep",
"track",
"of",
"an",
"order",
"that",
"was",
"placed",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/finance/ledger.py#L537-L557 |
26,125 | quantopian/zipline | zipline/finance/ledger.py | Ledger.process_commission | def process_commission(self, commission):
"""Process the commission.
Parameters
----------
commission : zp.Event
The commission being paid.
"""
asset = commission['asset']
cost = commission['cost']
self.position_tracker.handle_commission(asse... | python | def process_commission(self, commission):
"""Process the commission.
Parameters
----------
commission : zp.Event
The commission being paid.
"""
asset = commission['asset']
cost = commission['cost']
self.position_tracker.handle_commission(asse... | [
"def",
"process_commission",
"(",
"self",
",",
"commission",
")",
":",
"asset",
"=",
"commission",
"[",
"'asset'",
"]",
"cost",
"=",
"commission",
"[",
"'cost'",
"]",
"self",
".",
"position_tracker",
".",
"handle_commission",
"(",
"asset",
",",
"cost",
")",
... | Process the commission.
Parameters
----------
commission : zp.Event
The commission being paid. | [
"Process",
"the",
"commission",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/finance/ledger.py#L559-L571 |
26,126 | quantopian/zipline | zipline/finance/ledger.py | Ledger.process_dividends | def process_dividends(self, next_session, asset_finder, adjustment_reader):
"""Process dividends for the next session.
This will earn us any dividends whose ex-date is the next session as
well as paying out any dividends whose pay-date is the next session
"""
position_tracker = ... | python | def process_dividends(self, next_session, asset_finder, adjustment_reader):
"""Process dividends for the next session.
This will earn us any dividends whose ex-date is the next session as
well as paying out any dividends whose pay-date is the next session
"""
position_tracker = ... | [
"def",
"process_dividends",
"(",
"self",
",",
"next_session",
",",
"asset_finder",
",",
"adjustment_reader",
")",
":",
"position_tracker",
"=",
"self",
".",
"position_tracker",
"# Earn dividends whose ex_date is the next trading day. We need to",
"# check if we own any of these s... | Process dividends for the next session.
This will earn us any dividends whose ex-date is the next session as
well as paying out any dividends whose pay-date is the next session | [
"Process",
"dividends",
"for",
"the",
"next",
"session",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/finance/ledger.py#L582-L621 |
26,127 | quantopian/zipline | zipline/finance/ledger.py | Ledger.transactions | def transactions(self, dt=None):
"""Retrieve the dict-form of all of the transactions in a given bar or
for the whole simulation.
Parameters
----------
dt : pd.Timestamp or None, optional
The particular datetime to look up transactions for. If not passed,
... | python | def transactions(self, dt=None):
"""Retrieve the dict-form of all of the transactions in a given bar or
for the whole simulation.
Parameters
----------
dt : pd.Timestamp or None, optional
The particular datetime to look up transactions for. If not passed,
... | [
"def",
"transactions",
"(",
"self",
",",
"dt",
"=",
"None",
")",
":",
"if",
"dt",
"is",
"None",
":",
"# flatten the by-day transactions",
"return",
"[",
"txn",
"for",
"by_day",
"in",
"itervalues",
"(",
"self",
".",
"_processed_transactions",
")",
"for",
"txn... | Retrieve the dict-form of all of the transactions in a given bar or
for the whole simulation.
Parameters
----------
dt : pd.Timestamp or None, optional
The particular datetime to look up transactions for. If not passed,
or None is explicitly passed, all of the tr... | [
"Retrieve",
"the",
"dict",
"-",
"form",
"of",
"all",
"of",
"the",
"transactions",
"in",
"a",
"given",
"bar",
"or",
"for",
"the",
"whole",
"simulation",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/finance/ledger.py#L631-L655 |
26,128 | quantopian/zipline | zipline/finance/ledger.py | Ledger.orders | def orders(self, dt=None):
"""Retrieve the dict-form of all of the orders in a given bar or for
the whole simulation.
Parameters
----------
dt : pd.Timestamp or None, optional
The particular datetime to look up order for. If not passed, or
None is explici... | python | def orders(self, dt=None):
"""Retrieve the dict-form of all of the orders in a given bar or for
the whole simulation.
Parameters
----------
dt : pd.Timestamp or None, optional
The particular datetime to look up order for. If not passed, or
None is explici... | [
"def",
"orders",
"(",
"self",
",",
"dt",
"=",
"None",
")",
":",
"if",
"dt",
"is",
"None",
":",
"# orders by id is already flattened",
"return",
"[",
"o",
".",
"to_dict",
"(",
")",
"for",
"o",
"in",
"itervalues",
"(",
"self",
".",
"_orders_by_id",
")",
... | Retrieve the dict-form of all of the orders in a given bar or for
the whole simulation.
Parameters
----------
dt : pd.Timestamp or None, optional
The particular datetime to look up order for. If not passed, or
None is explicitly passed, all of the orders will be ... | [
"Retrieve",
"the",
"dict",
"-",
"form",
"of",
"all",
"of",
"the",
"orders",
"in",
"a",
"given",
"bar",
"or",
"for",
"the",
"whole",
"simulation",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/finance/ledger.py#L657-L679 |
26,129 | quantopian/zipline | zipline/finance/ledger.py | Ledger.update_portfolio | def update_portfolio(self):
"""Force a computation of the current portfolio state.
"""
if not self._dirty_portfolio:
return
portfolio = self._portfolio
pt = self.position_tracker
portfolio.positions = pt.get_positions()
position_stats = pt.stats
... | python | def update_portfolio(self):
"""Force a computation of the current portfolio state.
"""
if not self._dirty_portfolio:
return
portfolio = self._portfolio
pt = self.position_tracker
portfolio.positions = pt.get_positions()
position_stats = pt.stats
... | [
"def",
"update_portfolio",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_dirty_portfolio",
":",
"return",
"portfolio",
"=",
"self",
".",
"_portfolio",
"pt",
"=",
"self",
".",
"position_tracker",
"portfolio",
".",
"positions",
"=",
"pt",
".",
"get_positi... | Force a computation of the current portfolio state. | [
"Force",
"a",
"computation",
"of",
"the",
"current",
"portfolio",
"state",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/finance/ledger.py#L703-L740 |
26,130 | quantopian/zipline | zipline/finance/ledger.py | Ledger.override_account_fields | def override_account_fields(self,
settled_cash=not_overridden,
accrued_interest=not_overridden,
buying_power=not_overridden,
equity_with_loan=not_overridden,
to... | python | def override_account_fields(self,
settled_cash=not_overridden,
accrued_interest=not_overridden,
buying_power=not_overridden,
equity_with_loan=not_overridden,
to... | [
"def",
"override_account_fields",
"(",
"self",
",",
"settled_cash",
"=",
"not_overridden",
",",
"accrued_interest",
"=",
"not_overridden",
",",
"buying_power",
"=",
"not_overridden",
",",
"equity_with_loan",
"=",
"not_overridden",
",",
"total_positions_value",
"=",
"not... | Override fields on ``self.account``. | [
"Override",
"fields",
"on",
"self",
".",
"account",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/finance/ledger.py#L766-L791 |
26,131 | quantopian/zipline | zipline/pipeline/loaders/blaze/core.py | new_dataset | def new_dataset(expr, missing_values, domain):
"""
Creates or returns a dataset from a blaze expression.
Parameters
----------
expr : Expr
The blaze expression representing the values.
missing_values : frozenset((name, value) pairs
Association pairs column name and missing_value... | python | def new_dataset(expr, missing_values, domain):
"""
Creates or returns a dataset from a blaze expression.
Parameters
----------
expr : Expr
The blaze expression representing the values.
missing_values : frozenset((name, value) pairs
Association pairs column name and missing_value... | [
"def",
"new_dataset",
"(",
"expr",
",",
"missing_values",
",",
"domain",
")",
":",
"missing_values",
"=",
"dict",
"(",
"missing_values",
")",
"class_dict",
"=",
"{",
"'ndim'",
":",
"2",
"if",
"SID_FIELD_NAME",
"in",
"expr",
".",
"fields",
"else",
"1",
"}",... | Creates or returns a dataset from a blaze expression.
Parameters
----------
expr : Expr
The blaze expression representing the values.
missing_values : frozenset((name, value) pairs
Association pairs column name and missing_value for that column.
This needs to be a frozenset rat... | [
"Creates",
"or",
"returns",
"a",
"dataset",
"from",
"a",
"blaze",
"expression",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/pipeline/loaders/blaze/core.py#L276-L334 |
26,132 | quantopian/zipline | zipline/pipeline/loaders/blaze/core.py | _check_resources | def _check_resources(name, expr, resources):
"""Validate that the expression and resources passed match up.
Parameters
----------
name : str
The name of the argument we are checking.
expr : Expr
The potentially bound expr.
resources
The explicitly passed resources to com... | python | def _check_resources(name, expr, resources):
"""Validate that the expression and resources passed match up.
Parameters
----------
name : str
The name of the argument we are checking.
expr : Expr
The potentially bound expr.
resources
The explicitly passed resources to com... | [
"def",
"_check_resources",
"(",
"name",
",",
"expr",
",",
"resources",
")",
":",
"if",
"expr",
"is",
"None",
":",
"return",
"bound",
"=",
"expr",
".",
"_resources",
"(",
")",
"if",
"not",
"bound",
"and",
"resources",
"is",
"None",
":",
"raise",
"ValueE... | Validate that the expression and resources passed match up.
Parameters
----------
name : str
The name of the argument we are checking.
expr : Expr
The potentially bound expr.
resources
The explicitly passed resources to compute expr.
Raises
------
ValueError
... | [
"Validate",
"that",
"the",
"expression",
"and",
"resources",
"passed",
"match",
"up",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/pipeline/loaders/blaze/core.py#L337-L362 |
26,133 | quantopian/zipline | zipline/pipeline/loaders/blaze/core.py | _check_datetime_field | def _check_datetime_field(name, measure):
"""Check that a field is a datetime inside some measure.
Parameters
----------
name : str
The name of the field to check.
measure : Record
The record to check the field of.
Raises
------
TypeError
If the field is not a d... | python | def _check_datetime_field(name, measure):
"""Check that a field is a datetime inside some measure.
Parameters
----------
name : str
The name of the field to check.
measure : Record
The record to check the field of.
Raises
------
TypeError
If the field is not a d... | [
"def",
"_check_datetime_field",
"(",
"name",
",",
"measure",
")",
":",
"if",
"not",
"isinstance",
"(",
"measure",
"[",
"name",
"]",
",",
"(",
"Date",
",",
"DateTime",
")",
")",
":",
"raise",
"TypeError",
"(",
"\"'{name}' field must be a '{dt}', not: '{dshape}'\"... | Check that a field is a datetime inside some measure.
Parameters
----------
name : str
The name of the field to check.
measure : Record
The record to check the field of.
Raises
------
TypeError
If the field is not a datetime inside ``measure``. | [
"Check",
"that",
"a",
"field",
"is",
"a",
"datetime",
"inside",
"some",
"measure",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/pipeline/loaders/blaze/core.py#L365-L387 |
26,134 | quantopian/zipline | zipline/pipeline/loaders/blaze/core.py | _get_metadata | def _get_metadata(field, expr, metadata_expr, no_metadata_rule):
"""Find the correct metadata expression for the expression.
Parameters
----------
field : {'deltas', 'checkpoints'}
The kind of metadata expr to lookup.
expr : Expr
The baseline expression.
metadata_expr : Expr, 'a... | python | def _get_metadata(field, expr, metadata_expr, no_metadata_rule):
"""Find the correct metadata expression for the expression.
Parameters
----------
field : {'deltas', 'checkpoints'}
The kind of metadata expr to lookup.
expr : Expr
The baseline expression.
metadata_expr : Expr, 'a... | [
"def",
"_get_metadata",
"(",
"field",
",",
"expr",
",",
"metadata_expr",
",",
"no_metadata_rule",
")",
":",
"if",
"isinstance",
"(",
"metadata_expr",
",",
"bz",
".",
"Expr",
")",
"or",
"metadata_expr",
"is",
"None",
":",
"return",
"metadata_expr",
"try",
":"... | Find the correct metadata expression for the expression.
Parameters
----------
field : {'deltas', 'checkpoints'}
The kind of metadata expr to lookup.
expr : Expr
The baseline expression.
metadata_expr : Expr, 'auto', or None
The metadata argument. If this is 'auto', then the... | [
"Find",
"the",
"correct",
"metadata",
"expression",
"for",
"the",
"expression",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/pipeline/loaders/blaze/core.py#L415-L450 |
26,135 | quantopian/zipline | zipline/pipeline/loaders/blaze/core.py | _ensure_timestamp_field | def _ensure_timestamp_field(dataset_expr, deltas, checkpoints):
"""Verify that the baseline and deltas expressions have a timestamp field.
If there is not a ``TS_FIELD_NAME`` on either of the expressions, it will
be copied from the ``AD_FIELD_NAME``. If one is provided, then we will
verify that it is t... | python | def _ensure_timestamp_field(dataset_expr, deltas, checkpoints):
"""Verify that the baseline and deltas expressions have a timestamp field.
If there is not a ``TS_FIELD_NAME`` on either of the expressions, it will
be copied from the ``AD_FIELD_NAME``. If one is provided, then we will
verify that it is t... | [
"def",
"_ensure_timestamp_field",
"(",
"dataset_expr",
",",
"deltas",
",",
"checkpoints",
")",
":",
"measure",
"=",
"dataset_expr",
".",
"dshape",
".",
"measure",
"if",
"TS_FIELD_NAME",
"not",
"in",
"measure",
".",
"names",
":",
"dataset_expr",
"=",
"bz",
".",... | Verify that the baseline and deltas expressions have a timestamp field.
If there is not a ``TS_FIELD_NAME`` on either of the expressions, it will
be copied from the ``AD_FIELD_NAME``. If one is provided, then we will
verify that it is the correct dshape.
Parameters
----------
dataset_expr : Ex... | [
"Verify",
"that",
"the",
"baseline",
"and",
"deltas",
"expressions",
"have",
"a",
"timestamp",
"field",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/pipeline/loaders/blaze/core.py#L473-L505 |
26,136 | quantopian/zipline | zipline/pipeline/loaders/blaze/core.py | bind_expression_to_resources | def bind_expression_to_resources(expr, resources):
"""
Bind a Blaze expression to resources.
Parameters
----------
expr : bz.Expr
The expression to which we want to bind resources.
resources : dict[bz.Symbol -> any]
Mapping from the loadable terms of ``expr`` to actual data reso... | python | def bind_expression_to_resources(expr, resources):
"""
Bind a Blaze expression to resources.
Parameters
----------
expr : bz.Expr
The expression to which we want to bind resources.
resources : dict[bz.Symbol -> any]
Mapping from the loadable terms of ``expr`` to actual data reso... | [
"def",
"bind_expression_to_resources",
"(",
"expr",
",",
"resources",
")",
":",
"# bind the resources into the expression",
"if",
"resources",
"is",
"None",
":",
"resources",
"=",
"{",
"}",
"# _subs stands for substitute. It's not actually private, blaze just",
"# prefixes sym... | Bind a Blaze expression to resources.
Parameters
----------
expr : bz.Expr
The expression to which we want to bind resources.
resources : dict[bz.Symbol -> any]
Mapping from the loadable terms of ``expr`` to actual data resources.
Returns
-------
bound_expr : bz.Expr
... | [
"Bind",
"a",
"Blaze",
"expression",
"to",
"resources",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/pipeline/loaders/blaze/core.py#L1038-L1063 |
26,137 | quantopian/zipline | zipline/pipeline/loaders/blaze/core.py | get_materialized_checkpoints | def get_materialized_checkpoints(checkpoints, colnames, lower_dt, odo_kwargs):
"""
Computes a lower bound and a DataFrame checkpoints.
Parameters
----------
checkpoints : Expr
Bound blaze expression for a checkpoints table from which to get a
computed lower bound.
colnames : ite... | python | def get_materialized_checkpoints(checkpoints, colnames, lower_dt, odo_kwargs):
"""
Computes a lower bound and a DataFrame checkpoints.
Parameters
----------
checkpoints : Expr
Bound blaze expression for a checkpoints table from which to get a
computed lower bound.
colnames : ite... | [
"def",
"get_materialized_checkpoints",
"(",
"checkpoints",
",",
"colnames",
",",
"lower_dt",
",",
"odo_kwargs",
")",
":",
"if",
"checkpoints",
"is",
"not",
"None",
":",
"ts",
"=",
"checkpoints",
"[",
"TS_FIELD_NAME",
"]",
"checkpoints_ts",
"=",
"odo",
"(",
"ts... | Computes a lower bound and a DataFrame checkpoints.
Parameters
----------
checkpoints : Expr
Bound blaze expression for a checkpoints table from which to get a
computed lower bound.
colnames : iterable of str
The names of the columns for which checkpoints should be computed.
... | [
"Computes",
"a",
"lower",
"bound",
"and",
"a",
"DataFrame",
"checkpoints",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/pipeline/loaders/blaze/core.py#L1066-L1105 |
26,138 | quantopian/zipline | zipline/pipeline/loaders/blaze/core.py | ffill_query_in_range | def ffill_query_in_range(expr,
lower,
upper,
checkpoints=None,
odo_kwargs=None,
ts_field=TS_FIELD_NAME):
"""Query a blaze expression in a given time range properly forward filling
from va... | python | def ffill_query_in_range(expr,
lower,
upper,
checkpoints=None,
odo_kwargs=None,
ts_field=TS_FIELD_NAME):
"""Query a blaze expression in a given time range properly forward filling
from va... | [
"def",
"ffill_query_in_range",
"(",
"expr",
",",
"lower",
",",
"upper",
",",
"checkpoints",
"=",
"None",
",",
"odo_kwargs",
"=",
"None",
",",
"ts_field",
"=",
"TS_FIELD_NAME",
")",
":",
"odo_kwargs",
"=",
"odo_kwargs",
"or",
"{",
"}",
"computed_lower",
",",
... | Query a blaze expression in a given time range properly forward filling
from values that fall before the lower date.
Parameters
----------
expr : Expr
Bound blaze expression.
lower : datetime
The lower date to query for.
upper : datetime
The upper date to query for.
... | [
"Query",
"a",
"blaze",
"expression",
"in",
"a",
"given",
"time",
"range",
"properly",
"forward",
"filling",
"from",
"values",
"that",
"fall",
"before",
"the",
"lower",
"date",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/pipeline/loaders/blaze/core.py#L1108-L1165 |
26,139 | quantopian/zipline | zipline/pipeline/loaders/blaze/core.py | BlazeLoader.register_dataset | def register_dataset(self,
dataset,
expr,
deltas=None,
checkpoints=None,
odo_kwargs=None):
"""Explicitly map a datset to a collection of blaze expressions.
Parameters
---... | python | def register_dataset(self,
dataset,
expr,
deltas=None,
checkpoints=None,
odo_kwargs=None):
"""Explicitly map a datset to a collection of blaze expressions.
Parameters
---... | [
"def",
"register_dataset",
"(",
"self",
",",
"dataset",
",",
"expr",
",",
"deltas",
"=",
"None",
",",
"checkpoints",
"=",
"None",
",",
"odo_kwargs",
"=",
"None",
")",
":",
"expr_data",
"=",
"ExprData",
"(",
"expr",
",",
"deltas",
",",
"checkpoints",
",",... | Explicitly map a datset to a collection of blaze expressions.
Parameters
----------
dataset : DataSet
The pipeline dataset to map to the given expressions.
expr : Expr
The baseline values.
deltas : Expr, optional
The deltas for the data.
... | [
"Explicitly",
"map",
"a",
"datset",
"to",
"a",
"collection",
"of",
"blaze",
"expressions",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/pipeline/loaders/blaze/core.py#L847-L879 |
26,140 | quantopian/zipline | zipline/pipeline/loaders/blaze/core.py | BlazeLoader.register_column | def register_column(self,
column,
expr,
deltas=None,
checkpoints=None,
odo_kwargs=None):
"""Explicitly map a single bound column to a collection of blaze
expressions. The expressions n... | python | def register_column(self,
column,
expr,
deltas=None,
checkpoints=None,
odo_kwargs=None):
"""Explicitly map a single bound column to a collection of blaze
expressions. The expressions n... | [
"def",
"register_column",
"(",
"self",
",",
"column",
",",
"expr",
",",
"deltas",
"=",
"None",
",",
"checkpoints",
"=",
"None",
",",
"odo_kwargs",
"=",
"None",
")",
":",
"self",
".",
"_table_expressions",
"[",
"column",
"]",
"=",
"ExprData",
"(",
"expr",... | Explicitly map a single bound column to a collection of blaze
expressions. The expressions need to have ``timestamp`` and ``as_of``
columns.
Parameters
----------
column : BoundColumn
The pipeline dataset to map to the given expressions.
expr : Expr
... | [
"Explicitly",
"map",
"a",
"single",
"bound",
"column",
"to",
"a",
"collection",
"of",
"blaze",
"expressions",
".",
"The",
"expressions",
"need",
"to",
"have",
"timestamp",
"and",
"as_of",
"columns",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/pipeline/loaders/blaze/core.py#L881-L913 |
26,141 | quantopian/zipline | zipline/assets/assets.py | merge_ownership_periods | def merge_ownership_periods(mappings):
"""
Given a dict of mappings where the values are lists of
OwnershipPeriod objects, returns a dict with the same structure with
new OwnershipPeriod objects adjusted so that the periods have no
gaps.
Orders the periods chronologically, and pushes forward th... | python | def merge_ownership_periods(mappings):
"""
Given a dict of mappings where the values are lists of
OwnershipPeriod objects, returns a dict with the same structure with
new OwnershipPeriod objects adjusted so that the periods have no
gaps.
Orders the periods chronologically, and pushes forward th... | [
"def",
"merge_ownership_periods",
"(",
"mappings",
")",
":",
"return",
"valmap",
"(",
"lambda",
"v",
":",
"tuple",
"(",
"OwnershipPeriod",
"(",
"a",
".",
"start",
",",
"b",
".",
"start",
",",
"a",
".",
"sid",
",",
"a",
".",
"value",
",",
")",
"for",
... | Given a dict of mappings where the values are lists of
OwnershipPeriod objects, returns a dict with the same structure with
new OwnershipPeriod objects adjusted so that the periods have no
gaps.
Orders the periods chronologically, and pushes forward the end date
of each period to match the start da... | [
"Given",
"a",
"dict",
"of",
"mappings",
"where",
"the",
"values",
"are",
"lists",
"of",
"OwnershipPeriod",
"objects",
"returns",
"a",
"dict",
"with",
"the",
"same",
"structure",
"with",
"new",
"OwnershipPeriod",
"objects",
"adjusted",
"so",
"that",
"the",
"per... | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/assets/assets.py#L104-L138 |
26,142 | quantopian/zipline | zipline/assets/assets.py | build_ownership_map | def build_ownership_map(table, key_from_row, value_from_row):
"""
Builds a dict mapping to lists of OwnershipPeriods, from a db table.
"""
return _build_ownership_map_from_rows(
sa.select(table.c).execute().fetchall(),
key_from_row,
value_from_row,
) | python | def build_ownership_map(table, key_from_row, value_from_row):
"""
Builds a dict mapping to lists of OwnershipPeriods, from a db table.
"""
return _build_ownership_map_from_rows(
sa.select(table.c).execute().fetchall(),
key_from_row,
value_from_row,
) | [
"def",
"build_ownership_map",
"(",
"table",
",",
"key_from_row",
",",
"value_from_row",
")",
":",
"return",
"_build_ownership_map_from_rows",
"(",
"sa",
".",
"select",
"(",
"table",
".",
"c",
")",
".",
"execute",
"(",
")",
".",
"fetchall",
"(",
")",
",",
"... | Builds a dict mapping to lists of OwnershipPeriods, from a db table. | [
"Builds",
"a",
"dict",
"mapping",
"to",
"lists",
"of",
"OwnershipPeriods",
"from",
"a",
"db",
"table",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/assets/assets.py#L159-L167 |
26,143 | quantopian/zipline | zipline/assets/assets.py | build_grouped_ownership_map | def build_grouped_ownership_map(table,
key_from_row,
value_from_row,
group_key):
"""
Builds a dict mapping group keys to maps of keys to to lists of
OwnershipPeriods, from a db table.
"""
grouped_rows = g... | python | def build_grouped_ownership_map(table,
key_from_row,
value_from_row,
group_key):
"""
Builds a dict mapping group keys to maps of keys to to lists of
OwnershipPeriods, from a db table.
"""
grouped_rows = g... | [
"def",
"build_grouped_ownership_map",
"(",
"table",
",",
"key_from_row",
",",
"value_from_row",
",",
"group_key",
")",
":",
"grouped_rows",
"=",
"groupby",
"(",
"group_key",
",",
"sa",
".",
"select",
"(",
"table",
".",
"c",
")",
".",
"execute",
"(",
")",
"... | Builds a dict mapping group keys to maps of keys to to lists of
OwnershipPeriods, from a db table. | [
"Builds",
"a",
"dict",
"mapping",
"group",
"keys",
"to",
"maps",
"of",
"keys",
"to",
"to",
"lists",
"of",
"OwnershipPeriods",
"from",
"a",
"db",
"table",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/assets/assets.py#L170-L189 |
26,144 | quantopian/zipline | zipline/assets/assets.py | _filter_kwargs | def _filter_kwargs(names, dict_):
"""Filter out kwargs from a dictionary.
Parameters
----------
names : set[str]
The names to select from ``dict_``.
dict_ : dict[str, any]
The dictionary to select from.
Returns
-------
kwargs : dict[str, any]
``dict_`` where the... | python | def _filter_kwargs(names, dict_):
"""Filter out kwargs from a dictionary.
Parameters
----------
names : set[str]
The names to select from ``dict_``.
dict_ : dict[str, any]
The dictionary to select from.
Returns
-------
kwargs : dict[str, any]
``dict_`` where the... | [
"def",
"_filter_kwargs",
"(",
"names",
",",
"dict_",
")",
":",
"return",
"{",
"k",
":",
"v",
"for",
"k",
",",
"v",
"in",
"dict_",
".",
"items",
"(",
")",
"if",
"k",
"in",
"names",
"and",
"v",
"is",
"not",
"None",
"}"
] | Filter out kwargs from a dictionary.
Parameters
----------
names : set[str]
The names to select from ``dict_``.
dict_ : dict[str, any]
The dictionary to select from.
Returns
-------
kwargs : dict[str, any]
``dict_`` where the keys intersect with ``names`` and the va... | [
"Filter",
"out",
"kwargs",
"from",
"a",
"dictionary",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/assets/assets.py#L193-L209 |
26,145 | quantopian/zipline | zipline/assets/assets.py | _convert_asset_timestamp_fields | def _convert_asset_timestamp_fields(dict_):
"""
Takes in a dict of Asset init args and converts dates to pd.Timestamps
"""
for key in _asset_timestamp_fields & viewkeys(dict_):
value = pd.Timestamp(dict_[key], tz='UTC')
dict_[key] = None if isnull(value) else value
return dict_ | python | def _convert_asset_timestamp_fields(dict_):
"""
Takes in a dict of Asset init args and converts dates to pd.Timestamps
"""
for key in _asset_timestamp_fields & viewkeys(dict_):
value = pd.Timestamp(dict_[key], tz='UTC')
dict_[key] = None if isnull(value) else value
return dict_ | [
"def",
"_convert_asset_timestamp_fields",
"(",
"dict_",
")",
":",
"for",
"key",
"in",
"_asset_timestamp_fields",
"&",
"viewkeys",
"(",
"dict_",
")",
":",
"value",
"=",
"pd",
".",
"Timestamp",
"(",
"dict_",
"[",
"key",
"]",
",",
"tz",
"=",
"'UTC'",
")",
"... | Takes in a dict of Asset init args and converts dates to pd.Timestamps | [
"Takes",
"in",
"a",
"dict",
"of",
"Asset",
"init",
"args",
"and",
"converts",
"dates",
"to",
"pd",
".",
"Timestamps"
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/assets/assets.py#L216-L223 |
26,146 | quantopian/zipline | zipline/assets/assets.py | was_active | def was_active(reference_date_value, asset):
"""
Whether or not `asset` was active at the time corresponding to
`reference_date_value`.
Parameters
----------
reference_date_value : int
Date, represented as nanoseconds since EPOCH, for which we want to know
if `asset` was alive. ... | python | def was_active(reference_date_value, asset):
"""
Whether or not `asset` was active at the time corresponding to
`reference_date_value`.
Parameters
----------
reference_date_value : int
Date, represented as nanoseconds since EPOCH, for which we want to know
if `asset` was alive. ... | [
"def",
"was_active",
"(",
"reference_date_value",
",",
"asset",
")",
":",
"return",
"(",
"asset",
".",
"start_date",
".",
"value",
"<=",
"reference_date_value",
"<=",
"asset",
".",
"end_date",
".",
"value",
")"
] | Whether or not `asset` was active at the time corresponding to
`reference_date_value`.
Parameters
----------
reference_date_value : int
Date, represented as nanoseconds since EPOCH, for which we want to know
if `asset` was alive. This is generally the result of accessing the
`v... | [
"Whether",
"or",
"not",
"asset",
"was",
"active",
"at",
"the",
"time",
"corresponding",
"to",
"reference_date_value",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/assets/assets.py#L1568-L1591 |
26,147 | quantopian/zipline | zipline/assets/assets.py | AssetFinder.lookup_asset_types | def lookup_asset_types(self, sids):
"""
Retrieve asset types for a list of sids.
Parameters
----------
sids : list[int]
Returns
-------
types : dict[sid -> str or None]
Asset types for the provided sids.
"""
found = {}
... | python | def lookup_asset_types(self, sids):
"""
Retrieve asset types for a list of sids.
Parameters
----------
sids : list[int]
Returns
-------
types : dict[sid -> str or None]
Asset types for the provided sids.
"""
found = {}
... | [
"def",
"lookup_asset_types",
"(",
"self",
",",
"sids",
")",
":",
"found",
"=",
"{",
"}",
"missing",
"=",
"set",
"(",
")",
"for",
"sid",
"in",
"sids",
":",
"try",
":",
"found",
"[",
"sid",
"]",
"=",
"self",
".",
"_asset_type_cache",
"[",
"sid",
"]",... | Retrieve asset types for a list of sids.
Parameters
----------
sids : list[int]
Returns
-------
types : dict[sid -> str or None]
Asset types for the provided sids. | [
"Retrieve",
"asset",
"types",
"for",
"a",
"list",
"of",
"sids",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/assets/assets.py#L405-L443 |
26,148 | quantopian/zipline | zipline/assets/assets.py | AssetFinder._select_most_recent_symbols_chunk | def _select_most_recent_symbols_chunk(self, sid_group):
"""Retrieve the most recent symbol for a set of sids.
Parameters
----------
sid_group : iterable[int]
The sids to lookup. The length of this sequence must be less than
or equal to SQLITE_MAX_VARIABLE_NUMBER ... | python | def _select_most_recent_symbols_chunk(self, sid_group):
"""Retrieve the most recent symbol for a set of sids.
Parameters
----------
sid_group : iterable[int]
The sids to lookup. The length of this sequence must be less than
or equal to SQLITE_MAX_VARIABLE_NUMBER ... | [
"def",
"_select_most_recent_symbols_chunk",
"(",
"self",
",",
"sid_group",
")",
":",
"cols",
"=",
"self",
".",
"equity_symbol_mappings",
".",
"c",
"# These are the columns we actually want.",
"data_cols",
"=",
"(",
"cols",
".",
"sid",
",",
")",
"+",
"tuple",
"(",
... | Retrieve the most recent symbol for a set of sids.
Parameters
----------
sid_group : iterable[int]
The sids to lookup. The length of this sequence must be less than
or equal to SQLITE_MAX_VARIABLE_NUMBER because the sids will be
passed in as sql bind params.
... | [
"Retrieve",
"the",
"most",
"recent",
"symbol",
"for",
"a",
"set",
"of",
"sids",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/assets/assets.py#L600-L647 |
26,149 | quantopian/zipline | zipline/assets/assets.py | AssetFinder._retrieve_assets | def _retrieve_assets(self, sids, asset_tbl, asset_type):
"""
Internal function for loading assets from a table.
This should be the only method of `AssetFinder` that writes Assets into
self._asset_cache.
Parameters
---------
sids : iterable of int
Ass... | python | def _retrieve_assets(self, sids, asset_tbl, asset_type):
"""
Internal function for loading assets from a table.
This should be the only method of `AssetFinder` that writes Assets into
self._asset_cache.
Parameters
---------
sids : iterable of int
Ass... | [
"def",
"_retrieve_assets",
"(",
"self",
",",
"sids",
",",
"asset_tbl",
",",
"asset_type",
")",
":",
"# Fastpath for empty request.",
"if",
"not",
"sids",
":",
"return",
"{",
"}",
"cache",
"=",
"self",
".",
"_asset_cache",
"hits",
"=",
"{",
"}",
"querying_equ... | Internal function for loading assets from a table.
This should be the only method of `AssetFinder` that writes Assets into
self._asset_cache.
Parameters
---------
sids : iterable of int
Asset ids to look up.
asset_tbl : sqlalchemy.Table
Table fro... | [
"Internal",
"function",
"for",
"loading",
"assets",
"from",
"a",
"table",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/assets/assets.py#L689-L740 |
26,150 | quantopian/zipline | zipline/assets/assets.py | AssetFinder._lookup_symbol_strict | def _lookup_symbol_strict(self,
ownership_map,
multi_country,
symbol,
as_of_date):
"""
Resolve a symbol to an asset object without fuzzy matching.
Parameters
---------... | python | def _lookup_symbol_strict(self,
ownership_map,
multi_country,
symbol,
as_of_date):
"""
Resolve a symbol to an asset object without fuzzy matching.
Parameters
---------... | [
"def",
"_lookup_symbol_strict",
"(",
"self",
",",
"ownership_map",
",",
"multi_country",
",",
"symbol",
",",
"as_of_date",
")",
":",
"# split the symbol into the components, if there are no",
"# company/share class parts then share_class_symbol will be empty",
"company_symbol",
","... | Resolve a symbol to an asset object without fuzzy matching.
Parameters
----------
ownership_map : dict[(str, str), list[OwnershipPeriod]]
The mapping from split symbols to ownership periods.
multi_country : bool
Does this mapping span multiple countries?
... | [
"Resolve",
"a",
"symbol",
"to",
"an",
"asset",
"object",
"without",
"fuzzy",
"matching",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/assets/assets.py#L742-L865 |
26,151 | quantopian/zipline | zipline/assets/assets.py | AssetFinder.lookup_symbol | def lookup_symbol(self,
symbol,
as_of_date,
fuzzy=False,
country_code=None):
"""Lookup an equity by symbol.
Parameters
----------
symbol : str
The ticker symbol to resolve.
as_of_... | python | def lookup_symbol(self,
symbol,
as_of_date,
fuzzy=False,
country_code=None):
"""Lookup an equity by symbol.
Parameters
----------
symbol : str
The ticker symbol to resolve.
as_of_... | [
"def",
"lookup_symbol",
"(",
"self",
",",
"symbol",
",",
"as_of_date",
",",
"fuzzy",
"=",
"False",
",",
"country_code",
"=",
"None",
")",
":",
"if",
"symbol",
"is",
"None",
":",
"raise",
"TypeError",
"(",
"\"Cannot lookup asset for symbol of None for \"",
"\"as ... | Lookup an equity by symbol.
Parameters
----------
symbol : str
The ticker symbol to resolve.
as_of_date : datetime or None
Look up the last owner of this symbol as of this datetime.
If ``as_of_date`` is None, then this can only resolve the equity
... | [
"Lookup",
"an",
"equity",
"by",
"symbol",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/assets/assets.py#L955-L1016 |
26,152 | quantopian/zipline | zipline/assets/assets.py | AssetFinder.lookup_symbols | def lookup_symbols(self,
symbols,
as_of_date,
fuzzy=False,
country_code=None):
"""
Lookup a list of equities by symbol.
Equivalent to::
[finder.lookup_symbol(s, as_of, fuzzy) for s in symbol... | python | def lookup_symbols(self,
symbols,
as_of_date,
fuzzy=False,
country_code=None):
"""
Lookup a list of equities by symbol.
Equivalent to::
[finder.lookup_symbol(s, as_of, fuzzy) for s in symbol... | [
"def",
"lookup_symbols",
"(",
"self",
",",
"symbols",
",",
"as_of_date",
",",
"fuzzy",
"=",
"False",
",",
"country_code",
"=",
"None",
")",
":",
"if",
"not",
"symbols",
":",
"return",
"[",
"]",
"multi_country",
"=",
"country_code",
"is",
"None",
"if",
"f... | Lookup a list of equities by symbol.
Equivalent to::
[finder.lookup_symbol(s, as_of, fuzzy) for s in symbols]
but potentially faster because repeated lookups are memoized.
Parameters
----------
symbols : sequence[str]
Sequence of ticker symbols to reso... | [
"Lookup",
"a",
"list",
"of",
"equities",
"by",
"symbol",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/assets/assets.py#L1018-L1077 |
26,153 | quantopian/zipline | zipline/assets/assets.py | AssetFinder.lookup_future_symbol | def lookup_future_symbol(self, symbol):
"""Lookup a future contract by symbol.
Parameters
----------
symbol : str
The symbol of the desired contract.
Returns
-------
future : Future
The future contract referenced by ``symbol``.
R... | python | def lookup_future_symbol(self, symbol):
"""Lookup a future contract by symbol.
Parameters
----------
symbol : str
The symbol of the desired contract.
Returns
-------
future : Future
The future contract referenced by ``symbol``.
R... | [
"def",
"lookup_future_symbol",
"(",
"self",
",",
"symbol",
")",
":",
"data",
"=",
"self",
".",
"_select_asset_by_symbol",
"(",
"self",
".",
"futures_contracts",
",",
"symbol",
")",
".",
"execute",
"(",
")",
".",
"fetchone",
"(",
")",
"# If no data found, raise... | Lookup a future contract by symbol.
Parameters
----------
symbol : str
The symbol of the desired contract.
Returns
-------
future : Future
The future contract referenced by ``symbol``.
Raises
------
SymbolNotFound
... | [
"Lookup",
"a",
"future",
"contract",
"by",
"symbol",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/assets/assets.py#L1079-L1105 |
26,154 | quantopian/zipline | zipline/assets/assets.py | AssetFinder.get_supplementary_field | def get_supplementary_field(self, sid, field_name, as_of_date):
"""Get the value of a supplementary field for an asset.
Parameters
----------
sid : int
The sid of the asset to query.
field_name : str
Name of the supplementary field.
as_of_date : p... | python | def get_supplementary_field(self, sid, field_name, as_of_date):
"""Get the value of a supplementary field for an asset.
Parameters
----------
sid : int
The sid of the asset to query.
field_name : str
Name of the supplementary field.
as_of_date : p... | [
"def",
"get_supplementary_field",
"(",
"self",
",",
"sid",
",",
"field_name",
",",
"as_of_date",
")",
":",
"try",
":",
"periods",
"=",
"self",
".",
"equity_supplementary_map_by_sid",
"[",
"field_name",
",",
"sid",
",",
"]",
"assert",
"periods",
",",
"'empty pe... | Get the value of a supplementary field for an asset.
Parameters
----------
sid : int
The sid of the asset to query.
field_name : str
Name of the supplementary field.
as_of_date : pd.Timestamp, None
The last known value on this date is returned... | [
"Get",
"the",
"value",
"of",
"a",
"supplementary",
"field",
"for",
"an",
"asset",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/assets/assets.py#L1142-L1193 |
26,155 | quantopian/zipline | zipline/assets/assets.py | AssetFinder._lookup_generic_scalar | def _lookup_generic_scalar(self,
obj,
as_of_date,
country_code,
matches,
missing):
"""
Convert asset_convertible to an asset.
On success, ap... | python | def _lookup_generic_scalar(self,
obj,
as_of_date,
country_code,
matches,
missing):
"""
Convert asset_convertible to an asset.
On success, ap... | [
"def",
"_lookup_generic_scalar",
"(",
"self",
",",
"obj",
",",
"as_of_date",
",",
"country_code",
",",
"matches",
",",
"missing",
")",
":",
"result",
"=",
"self",
".",
"_lookup_generic_scalar_helper",
"(",
"obj",
",",
"as_of_date",
",",
"country_code",
",",
")... | Convert asset_convertible to an asset.
On success, append to matches.
On failure, append to missing. | [
"Convert",
"asset_convertible",
"to",
"an",
"asset",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/assets/assets.py#L1298-L1316 |
26,156 | quantopian/zipline | zipline/assets/assets.py | AssetFinder.lookup_generic | def lookup_generic(self, obj, as_of_date, country_code):
"""
Convert an object into an Asset or sequence of Assets.
This method exists primarily as a convenience for implementing
user-facing APIs that can handle multiple kinds of input. It should
not be used for internal code w... | python | def lookup_generic(self, obj, as_of_date, country_code):
"""
Convert an object into an Asset or sequence of Assets.
This method exists primarily as a convenience for implementing
user-facing APIs that can handle multiple kinds of input. It should
not be used for internal code w... | [
"def",
"lookup_generic",
"(",
"self",
",",
"obj",
",",
"as_of_date",
",",
"country_code",
")",
":",
"matches",
"=",
"[",
"]",
"missing",
"=",
"[",
"]",
"# Interpret input as scalar.",
"if",
"isinstance",
"(",
"obj",
",",
"(",
"AssetConvertible",
",",
"Contin... | Convert an object into an Asset or sequence of Assets.
This method exists primarily as a convenience for implementing
user-facing APIs that can handle multiple kinds of input. It should
not be used for internal code where we already know the expected types
of our inputs.
Param... | [
"Convert",
"an",
"object",
"into",
"an",
"Asset",
"or",
"sequence",
"of",
"Assets",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/assets/assets.py#L1347-L1414 |
26,157 | quantopian/zipline | zipline/assets/assets.py | AssetFinder._compute_asset_lifetimes | def _compute_asset_lifetimes(self, country_codes):
"""
Compute and cache a recarray of asset lifetimes.
"""
equities_cols = self.equities.c
if country_codes:
buf = np.array(
tuple(
sa.select((
equities_cols.s... | python | def _compute_asset_lifetimes(self, country_codes):
"""
Compute and cache a recarray of asset lifetimes.
"""
equities_cols = self.equities.c
if country_codes:
buf = np.array(
tuple(
sa.select((
equities_cols.s... | [
"def",
"_compute_asset_lifetimes",
"(",
"self",
",",
"country_codes",
")",
":",
"equities_cols",
"=",
"self",
".",
"equities",
".",
"c",
"if",
"country_codes",
":",
"buf",
"=",
"np",
".",
"array",
"(",
"tuple",
"(",
"sa",
".",
"select",
"(",
"(",
"equiti... | Compute and cache a recarray of asset lifetimes. | [
"Compute",
"and",
"cache",
"a",
"recarray",
"of",
"asset",
"lifetimes",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/assets/assets.py#L1416-L1456 |
26,158 | quantopian/zipline | zipline/assets/assets.py | AssetFinder.lifetimes | def lifetimes(self, dates, include_start_date, country_codes):
"""
Compute a DataFrame representing asset lifetimes for the specified date
range.
Parameters
----------
dates : pd.DatetimeIndex
The dates for which to compute lifetimes.
include_start_da... | python | def lifetimes(self, dates, include_start_date, country_codes):
"""
Compute a DataFrame representing asset lifetimes for the specified date
range.
Parameters
----------
dates : pd.DatetimeIndex
The dates for which to compute lifetimes.
include_start_da... | [
"def",
"lifetimes",
"(",
"self",
",",
"dates",
",",
"include_start_date",
",",
"country_codes",
")",
":",
"if",
"isinstance",
"(",
"country_codes",
",",
"string_types",
")",
":",
"raise",
"TypeError",
"(",
"\"Got string {!r} instead of an iterable of strings in \"",
"... | Compute a DataFrame representing asset lifetimes for the specified date
range.
Parameters
----------
dates : pd.DatetimeIndex
The dates for which to compute lifetimes.
include_start_date : bool
Whether or not to count the asset as alive on its start_date.... | [
"Compute",
"a",
"DataFrame",
"representing",
"asset",
"lifetimes",
"for",
"the",
"specified",
"date",
"range",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/assets/assets.py#L1458-L1514 |
26,159 | quantopian/zipline | zipline/assets/assets.py | AssetFinder.equities_sids_for_country_code | def equities_sids_for_country_code(self, country_code):
"""Return all of the sids for a given country.
Parameters
----------
country_code : str
An ISO 3166 alpha-2 country code.
Returns
-------
tuple[int]
The sids whose exchanges are in t... | python | def equities_sids_for_country_code(self, country_code):
"""Return all of the sids for a given country.
Parameters
----------
country_code : str
An ISO 3166 alpha-2 country code.
Returns
-------
tuple[int]
The sids whose exchanges are in t... | [
"def",
"equities_sids_for_country_code",
"(",
"self",
",",
"country_code",
")",
":",
"sids",
"=",
"self",
".",
"_compute_asset_lifetimes",
"(",
"[",
"country_code",
"]",
")",
".",
"sid",
"return",
"tuple",
"(",
"sids",
".",
"tolist",
"(",
")",
")"
] | Return all of the sids for a given country.
Parameters
----------
country_code : str
An ISO 3166 alpha-2 country code.
Returns
-------
tuple[int]
The sids whose exchanges are in this country. | [
"Return",
"all",
"of",
"the",
"sids",
"for",
"a",
"given",
"country",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/assets/assets.py#L1516-L1530 |
26,160 | quantopian/zipline | zipline/data/continuous_future_reader.py | ContinuousFutureSessionBarReader.get_last_traded_dt | def get_last_traded_dt(self, asset, dt):
"""
Get the latest minute on or before ``dt`` in which ``asset`` traded.
If there are no trades on or before ``dt``, returns ``pd.NaT``.
Parameters
----------
asset : zipline.asset.Asset
The asset for which to get the... | python | def get_last_traded_dt(self, asset, dt):
"""
Get the latest minute on or before ``dt`` in which ``asset`` traded.
If there are no trades on or before ``dt``, returns ``pd.NaT``.
Parameters
----------
asset : zipline.asset.Asset
The asset for which to get the... | [
"def",
"get_last_traded_dt",
"(",
"self",
",",
"asset",
",",
"dt",
")",
":",
"rf",
"=",
"self",
".",
"_roll_finders",
"[",
"asset",
".",
"roll_style",
"]",
"sid",
"=",
"(",
"rf",
".",
"get_contract_center",
"(",
"asset",
".",
"root_symbol",
",",
"dt",
... | Get the latest minute on or before ``dt`` in which ``asset`` traded.
If there are no trades on or before ``dt``, returns ``pd.NaT``.
Parameters
----------
asset : zipline.asset.Asset
The asset for which to get the last traded minute.
dt : pd.Timestamp
Th... | [
"Get",
"the",
"latest",
"minute",
"on",
"or",
"before",
"dt",
"in",
"which",
"asset",
"traded",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/data/continuous_future_reader.py#L158-L184 |
26,161 | quantopian/zipline | zipline/protocol.py | Portfolio.current_portfolio_weights | def current_portfolio_weights(self):
"""
Compute each asset's weight in the portfolio by calculating its held
value divided by the total value of all positions.
Each equity's value is its price times the number of shares held. Each
futures contract's value is its unit price time... | python | def current_portfolio_weights(self):
"""
Compute each asset's weight in the portfolio by calculating its held
value divided by the total value of all positions.
Each equity's value is its price times the number of shares held. Each
futures contract's value is its unit price time... | [
"def",
"current_portfolio_weights",
"(",
"self",
")",
":",
"position_values",
"=",
"pd",
".",
"Series",
"(",
"{",
"asset",
":",
"(",
"position",
".",
"last_sale_price",
"*",
"position",
".",
"amount",
"*",
"asset",
".",
"price_multiplier",
")",
"for",
"asset... | Compute each asset's weight in the portfolio by calculating its held
value divided by the total value of all positions.
Each equity's value is its price times the number of shares held. Each
futures contract's value is its unit price times number of shares held
times the multiplier. | [
"Compute",
"each",
"asset",
"s",
"weight",
"in",
"the",
"portfolio",
"by",
"calculating",
"its",
"held",
"value",
"divided",
"by",
"the",
"total",
"value",
"of",
"all",
"positions",
"."
] | 77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe | https://github.com/quantopian/zipline/blob/77ad15e6dc4c1cbcdc133653bac8a63fc704f7fe/zipline/protocol.py#L216-L233 |
26,162 | tensorflow/datasets | tensorflow_datasets/image/sun.py | _decode_image | def _decode_image(fobj, session, filename):
"""Reads and decodes an image from a file object as a Numpy array.
The SUN dataset contains images in several formats (despite the fact that
all of them have .jpg extension). Some of them are:
- BMP (RGB)
- PNG (grayscale, RGBA, RGB interlaced)
- JPEG (RGB)... | python | def _decode_image(fobj, session, filename):
"""Reads and decodes an image from a file object as a Numpy array.
The SUN dataset contains images in several formats (despite the fact that
all of them have .jpg extension). Some of them are:
- BMP (RGB)
- PNG (grayscale, RGBA, RGB interlaced)
- JPEG (RGB)... | [
"def",
"_decode_image",
"(",
"fobj",
",",
"session",
",",
"filename",
")",
":",
"buf",
"=",
"fobj",
".",
"read",
"(",
")",
"image",
"=",
"tfds",
".",
"core",
".",
"lazy_imports",
".",
"cv2",
".",
"imdecode",
"(",
"np",
".",
"fromstring",
"(",
"buf",
... | Reads and decodes an image from a file object as a Numpy array.
The SUN dataset contains images in several formats (despite the fact that
all of them have .jpg extension). Some of them are:
- BMP (RGB)
- PNG (grayscale, RGBA, RGB interlaced)
- JPEG (RGB)
- GIF (1-frame RGB)
Since TFDS assumes tha... | [
"Reads",
"and",
"decodes",
"an",
"image",
"from",
"a",
"file",
"object",
"as",
"a",
"Numpy",
"array",
"."
] | 46ceb0cf7b4690f38ecbbc689e4d659a903d08dc | https://github.com/tensorflow/datasets/blob/46ceb0cf7b4690f38ecbbc689e4d659a903d08dc/tensorflow_datasets/image/sun.py#L65-L102 |
26,163 | tensorflow/datasets | tensorflow_datasets/image/sun.py | _process_image_file | def _process_image_file(fobj, session, filename):
"""Process image files from the dataset."""
# We need to read the image files and convert them to JPEG, since some files
# actually contain GIF, PNG or BMP data (despite having a .jpg extension) and
# some encoding options that will make TF crash in general.
i... | python | def _process_image_file(fobj, session, filename):
"""Process image files from the dataset."""
# We need to read the image files and convert them to JPEG, since some files
# actually contain GIF, PNG or BMP data (despite having a .jpg extension) and
# some encoding options that will make TF crash in general.
i... | [
"def",
"_process_image_file",
"(",
"fobj",
",",
"session",
",",
"filename",
")",
":",
"# We need to read the image files and convert them to JPEG, since some files",
"# actually contain GIF, PNG or BMP data (despite having a .jpg extension) and",
"# some encoding options that will make TF cr... | Process image files from the dataset. | [
"Process",
"image",
"files",
"from",
"the",
"dataset",
"."
] | 46ceb0cf7b4690f38ecbbc689e4d659a903d08dc | https://github.com/tensorflow/datasets/blob/46ceb0cf7b4690f38ecbbc689e4d659a903d08dc/tensorflow_datasets/image/sun.py#L113-L119 |
26,164 | tensorflow/datasets | tensorflow_datasets/translate/wmt.py | _parse_parallel_sentences | def _parse_parallel_sentences(f1, f2):
"""Returns examples from parallel SGML or text files, which may be gzipped."""
def _parse_text(path):
"""Returns the sentences from a single text file, which may be gzipped."""
split_path = path.split(".")
if split_path[-1] == "gz":
lang = split_path[-2]
... | python | def _parse_parallel_sentences(f1, f2):
"""Returns examples from parallel SGML or text files, which may be gzipped."""
def _parse_text(path):
"""Returns the sentences from a single text file, which may be gzipped."""
split_path = path.split(".")
if split_path[-1] == "gz":
lang = split_path[-2]
... | [
"def",
"_parse_parallel_sentences",
"(",
"f1",
",",
"f2",
")",
":",
"def",
"_parse_text",
"(",
"path",
")",
":",
"\"\"\"Returns the sentences from a single text file, which may be gzipped.\"\"\"",
"split_path",
"=",
"path",
".",
"split",
"(",
"\".\"",
")",
"if",
"spli... | Returns examples from parallel SGML or text files, which may be gzipped. | [
"Returns",
"examples",
"from",
"parallel",
"SGML",
"or",
"text",
"files",
"which",
"may",
"be",
"gzipped",
"."
] | 46ceb0cf7b4690f38ecbbc689e4d659a903d08dc | https://github.com/tensorflow/datasets/blob/46ceb0cf7b4690f38ecbbc689e4d659a903d08dc/tensorflow_datasets/translate/wmt.py#L761-L820 |
26,165 | tensorflow/datasets | tensorflow_datasets/translate/wmt.py | _parse_tmx | def _parse_tmx(path):
"""Generates examples from TMX file."""
def _get_tuv_lang(tuv):
for k, v in tuv.items():
if k.endswith("}lang"):
return v
raise AssertionError("Language not found in `tuv` attributes.")
def _get_tuv_seg(tuv):
segs = tuv.findall("seg")
assert len(segs) == 1, "In... | python | def _parse_tmx(path):
"""Generates examples from TMX file."""
def _get_tuv_lang(tuv):
for k, v in tuv.items():
if k.endswith("}lang"):
return v
raise AssertionError("Language not found in `tuv` attributes.")
def _get_tuv_seg(tuv):
segs = tuv.findall("seg")
assert len(segs) == 1, "In... | [
"def",
"_parse_tmx",
"(",
"path",
")",
":",
"def",
"_get_tuv_lang",
"(",
"tuv",
")",
":",
"for",
"k",
",",
"v",
"in",
"tuv",
".",
"items",
"(",
")",
":",
"if",
"k",
".",
"endswith",
"(",
"\"}lang\"",
")",
":",
"return",
"v",
"raise",
"AssertionErro... | Generates examples from TMX file. | [
"Generates",
"examples",
"from",
"TMX",
"file",
"."
] | 46ceb0cf7b4690f38ecbbc689e4d659a903d08dc | https://github.com/tensorflow/datasets/blob/46ceb0cf7b4690f38ecbbc689e4d659a903d08dc/tensorflow_datasets/translate/wmt.py#L838-L858 |
26,166 | tensorflow/datasets | tensorflow_datasets/translate/wmt.py | _parse_tsv | def _parse_tsv(path, language_pair=None):
"""Generates examples from TSV file."""
if language_pair is None:
lang_match = re.match(r".*\.([a-z][a-z])-([a-z][a-z])\.tsv", path)
assert lang_match is not None, "Invalid TSV filename: %s" % path
l1, l2 = lang_match.groups()
else:
l1, l2 = language_pair
... | python | def _parse_tsv(path, language_pair=None):
"""Generates examples from TSV file."""
if language_pair is None:
lang_match = re.match(r".*\.([a-z][a-z])-([a-z][a-z])\.tsv", path)
assert lang_match is not None, "Invalid TSV filename: %s" % path
l1, l2 = lang_match.groups()
else:
l1, l2 = language_pair
... | [
"def",
"_parse_tsv",
"(",
"path",
",",
"language_pair",
"=",
"None",
")",
":",
"if",
"language_pair",
"is",
"None",
":",
"lang_match",
"=",
"re",
".",
"match",
"(",
"r\".*\\.([a-z][a-z])-([a-z][a-z])\\.tsv\"",
",",
"path",
")",
"assert",
"lang_match",
"is",
"n... | Generates examples from TSV file. | [
"Generates",
"examples",
"from",
"TSV",
"file",
"."
] | 46ceb0cf7b4690f38ecbbc689e4d659a903d08dc | https://github.com/tensorflow/datasets/blob/46ceb0cf7b4690f38ecbbc689e4d659a903d08dc/tensorflow_datasets/translate/wmt.py#L861-L881 |
26,167 | tensorflow/datasets | tensorflow_datasets/translate/wmt.py | _parse_wikiheadlines | def _parse_wikiheadlines(path):
"""Generates examples from Wikiheadlines dataset file."""
lang_match = re.match(r".*\.([a-z][a-z])-([a-z][a-z])$", path)
assert lang_match is not None, "Invalid Wikiheadlines filename: %s" % path
l1, l2 = lang_match.groups()
with tf.io.gfile.GFile(path) as f:
for line in f:... | python | def _parse_wikiheadlines(path):
"""Generates examples from Wikiheadlines dataset file."""
lang_match = re.match(r".*\.([a-z][a-z])-([a-z][a-z])$", path)
assert lang_match is not None, "Invalid Wikiheadlines filename: %s" % path
l1, l2 = lang_match.groups()
with tf.io.gfile.GFile(path) as f:
for line in f:... | [
"def",
"_parse_wikiheadlines",
"(",
"path",
")",
":",
"lang_match",
"=",
"re",
".",
"match",
"(",
"r\".*\\.([a-z][a-z])-([a-z][a-z])$\"",
",",
"path",
")",
"assert",
"lang_match",
"is",
"not",
"None",
",",
"\"Invalid Wikiheadlines filename: %s\"",
"%",
"path",
"l1",... | Generates examples from Wikiheadlines dataset file. | [
"Generates",
"examples",
"from",
"Wikiheadlines",
"dataset",
"file",
"."
] | 46ceb0cf7b4690f38ecbbc689e4d659a903d08dc | https://github.com/tensorflow/datasets/blob/46ceb0cf7b4690f38ecbbc689e4d659a903d08dc/tensorflow_datasets/translate/wmt.py#L884-L895 |
26,168 | tensorflow/datasets | tensorflow_datasets/translate/wmt.py | _parse_czeng | def _parse_czeng(*paths, **kwargs):
"""Generates examples from CzEng v1.6, with optional filtering for v1.7."""
filter_path = kwargs.get("filter_path", None)
if filter_path:
re_block = re.compile(r"^[^-]+-b(\d+)-\d\d[tde]")
with tf.io.gfile.GFile(filter_path) as f:
bad_blocks = {
blk for b... | python | def _parse_czeng(*paths, **kwargs):
"""Generates examples from CzEng v1.6, with optional filtering for v1.7."""
filter_path = kwargs.get("filter_path", None)
if filter_path:
re_block = re.compile(r"^[^-]+-b(\d+)-\d\d[tde]")
with tf.io.gfile.GFile(filter_path) as f:
bad_blocks = {
blk for b... | [
"def",
"_parse_czeng",
"(",
"*",
"paths",
",",
"*",
"*",
"kwargs",
")",
":",
"filter_path",
"=",
"kwargs",
".",
"get",
"(",
"\"filter_path\"",
",",
"None",
")",
"if",
"filter_path",
":",
"re_block",
"=",
"re",
".",
"compile",
"(",
"r\"^[^-]+-b(\\d+)-\\d\\d... | Generates examples from CzEng v1.6, with optional filtering for v1.7. | [
"Generates",
"examples",
"from",
"CzEng",
"v1",
".",
"6",
"with",
"optional",
"filtering",
"for",
"v1",
".",
"7",
"."
] | 46ceb0cf7b4690f38ecbbc689e4d659a903d08dc | https://github.com/tensorflow/datasets/blob/46ceb0cf7b4690f38ecbbc689e4d659a903d08dc/tensorflow_datasets/translate/wmt.py#L898-L927 |
26,169 | tensorflow/datasets | tensorflow_datasets/translate/wmt.py | WmtTranslate.subsets | def subsets(self):
"""Subsets that make up each split of the dataset for the language pair."""
source, target = self.builder_config.language_pair
filtered_subsets = {}
for split, ss_names in self._subsets.items():
filtered_subsets[split] = []
for ss_name in ss_names:
ds = DATASET_MAP... | python | def subsets(self):
"""Subsets that make up each split of the dataset for the language pair."""
source, target = self.builder_config.language_pair
filtered_subsets = {}
for split, ss_names in self._subsets.items():
filtered_subsets[split] = []
for ss_name in ss_names:
ds = DATASET_MAP... | [
"def",
"subsets",
"(",
"self",
")",
":",
"source",
",",
"target",
"=",
"self",
".",
"builder_config",
".",
"language_pair",
"filtered_subsets",
"=",
"{",
"}",
"for",
"split",
",",
"ss_names",
"in",
"self",
".",
"_subsets",
".",
"items",
"(",
")",
":",
... | Subsets that make up each split of the dataset for the language pair. | [
"Subsets",
"that",
"make",
"up",
"each",
"split",
"of",
"the",
"dataset",
"for",
"the",
"language",
"pair",
"."
] | 46ceb0cf7b4690f38ecbbc689e4d659a903d08dc | https://github.com/tensorflow/datasets/blob/46ceb0cf7b4690f38ecbbc689e4d659a903d08dc/tensorflow_datasets/translate/wmt.py#L615-L630 |
26,170 | tensorflow/datasets | tensorflow_datasets/core/registered.py | builder | def builder(name, **builder_init_kwargs):
"""Fetches a `tfds.core.DatasetBuilder` by string name.
Args:
name: `str`, the registered name of the `DatasetBuilder` (the snake case
version of the class name). This can be either `"dataset_name"` or
`"dataset_name/config_name"` for datasets with `Builder... | python | def builder(name, **builder_init_kwargs):
"""Fetches a `tfds.core.DatasetBuilder` by string name.
Args:
name: `str`, the registered name of the `DatasetBuilder` (the snake case
version of the class name). This can be either `"dataset_name"` or
`"dataset_name/config_name"` for datasets with `Builder... | [
"def",
"builder",
"(",
"name",
",",
"*",
"*",
"builder_init_kwargs",
")",
":",
"name",
",",
"builder_kwargs",
"=",
"_dataset_name_and_kwargs_from_name_str",
"(",
"name",
")",
"builder_kwargs",
".",
"update",
"(",
"builder_init_kwargs",
")",
"if",
"name",
"in",
"... | Fetches a `tfds.core.DatasetBuilder` by string name.
Args:
name: `str`, the registered name of the `DatasetBuilder` (the snake case
version of the class name). This can be either `"dataset_name"` or
`"dataset_name/config_name"` for datasets with `BuilderConfig`s.
As a convenience, this string m... | [
"Fetches",
"a",
"tfds",
".",
"core",
".",
"DatasetBuilder",
"by",
"string",
"name",
"."
] | 46ceb0cf7b4690f38ecbbc689e4d659a903d08dc | https://github.com/tensorflow/datasets/blob/46ceb0cf7b4690f38ecbbc689e4d659a903d08dc/tensorflow_datasets/core/registered.py#L137-L172 |
26,171 | tensorflow/datasets | tensorflow_datasets/core/registered.py | load | def load(name,
split=None,
data_dir=None,
batch_size=1,
download=True,
as_supervised=False,
with_info=False,
builder_kwargs=None,
download_and_prepare_kwargs=None,
as_dataset_kwargs=None,
try_gcs=False):
"""Loads the named datas... | python | def load(name,
split=None,
data_dir=None,
batch_size=1,
download=True,
as_supervised=False,
with_info=False,
builder_kwargs=None,
download_and_prepare_kwargs=None,
as_dataset_kwargs=None,
try_gcs=False):
"""Loads the named datas... | [
"def",
"load",
"(",
"name",
",",
"split",
"=",
"None",
",",
"data_dir",
"=",
"None",
",",
"batch_size",
"=",
"1",
",",
"download",
"=",
"True",
",",
"as_supervised",
"=",
"False",
",",
"with_info",
"=",
"False",
",",
"builder_kwargs",
"=",
"None",
",",... | Loads the named dataset into a `tf.data.Dataset`.
If `split=None` (the default), returns all splits for the dataset. Otherwise,
returns the specified split.
`load` is a convenience method that fetches the `tfds.core.DatasetBuilder` by
string name, optionally calls `DatasetBuilder.download_and_prepare`
(if `... | [
"Loads",
"the",
"named",
"dataset",
"into",
"a",
"tf",
".",
"data",
".",
"Dataset",
"."
] | 46ceb0cf7b4690f38ecbbc689e4d659a903d08dc | https://github.com/tensorflow/datasets/blob/46ceb0cf7b4690f38ecbbc689e4d659a903d08dc/tensorflow_datasets/core/registered.py#L176-L297 |
26,172 | tensorflow/datasets | tensorflow_datasets/core/registered.py | _dataset_name_and_kwargs_from_name_str | def _dataset_name_and_kwargs_from_name_str(name_str):
"""Extract kwargs from name str."""
res = _NAME_REG.match(name_str)
if not res:
raise ValueError(_NAME_STR_ERR.format(name_str))
name = res.group("dataset_name")
kwargs = _kwargs_str_to_kwargs(res.group("kwargs"))
try:
for attr in ["config", "ver... | python | def _dataset_name_and_kwargs_from_name_str(name_str):
"""Extract kwargs from name str."""
res = _NAME_REG.match(name_str)
if not res:
raise ValueError(_NAME_STR_ERR.format(name_str))
name = res.group("dataset_name")
kwargs = _kwargs_str_to_kwargs(res.group("kwargs"))
try:
for attr in ["config", "ver... | [
"def",
"_dataset_name_and_kwargs_from_name_str",
"(",
"name_str",
")",
":",
"res",
"=",
"_NAME_REG",
".",
"match",
"(",
"name_str",
")",
"if",
"not",
"res",
":",
"raise",
"ValueError",
"(",
"_NAME_STR_ERR",
".",
"format",
"(",
"name_str",
")",
")",
"name",
"... | Extract kwargs from name str. | [
"Extract",
"kwargs",
"from",
"name",
"str",
"."
] | 46ceb0cf7b4690f38ecbbc689e4d659a903d08dc | https://github.com/tensorflow/datasets/blob/46ceb0cf7b4690f38ecbbc689e4d659a903d08dc/tensorflow_datasets/core/registered.py#L311-L329 |
26,173 | tensorflow/datasets | tensorflow_datasets/core/registered.py | _cast_to_pod | def _cast_to_pod(val):
"""Try cast to int, float, bool, str, in that order."""
bools = {"True": True, "False": False}
if val in bools:
return bools[val]
try:
return int(val)
except ValueError:
try:
return float(val)
except ValueError:
return tf.compat.as_text(val) | python | def _cast_to_pod(val):
"""Try cast to int, float, bool, str, in that order."""
bools = {"True": True, "False": False}
if val in bools:
return bools[val]
try:
return int(val)
except ValueError:
try:
return float(val)
except ValueError:
return tf.compat.as_text(val) | [
"def",
"_cast_to_pod",
"(",
"val",
")",
":",
"bools",
"=",
"{",
"\"True\"",
":",
"True",
",",
"\"False\"",
":",
"False",
"}",
"if",
"val",
"in",
"bools",
":",
"return",
"bools",
"[",
"val",
"]",
"try",
":",
"return",
"int",
"(",
"val",
")",
"except... | Try cast to int, float, bool, str, in that order. | [
"Try",
"cast",
"to",
"int",
"float",
"bool",
"str",
"in",
"that",
"order",
"."
] | 46ceb0cf7b4690f38ecbbc689e4d659a903d08dc | https://github.com/tensorflow/datasets/blob/46ceb0cf7b4690f38ecbbc689e4d659a903d08dc/tensorflow_datasets/core/registered.py#L343-L354 |
26,174 | tensorflow/datasets | tensorflow_datasets/core/lazy_imports.py | _try_import | def _try_import(module_name):
"""Try importing a module, with an informative error message on failure."""
try:
mod = importlib.import_module(module_name)
return mod
except ImportError:
err_msg = ("Tried importing %s but failed. See setup.py extras_require. "
"The dataset you are trying ... | python | def _try_import(module_name):
"""Try importing a module, with an informative error message on failure."""
try:
mod = importlib.import_module(module_name)
return mod
except ImportError:
err_msg = ("Tried importing %s but failed. See setup.py extras_require. "
"The dataset you are trying ... | [
"def",
"_try_import",
"(",
"module_name",
")",
":",
"try",
":",
"mod",
"=",
"importlib",
".",
"import_module",
"(",
"module_name",
")",
"return",
"mod",
"except",
"ImportError",
":",
"err_msg",
"=",
"(",
"\"Tried importing %s but failed. See setup.py extras_require. \... | Try importing a module, with an informative error message on failure. | [
"Try",
"importing",
"a",
"module",
"with",
"an",
"informative",
"error",
"message",
"on",
"failure",
"."
] | 46ceb0cf7b4690f38ecbbc689e4d659a903d08dc | https://github.com/tensorflow/datasets/blob/46ceb0cf7b4690f38ecbbc689e4d659a903d08dc/tensorflow_datasets/core/lazy_imports.py#L27-L36 |
26,175 | tensorflow/datasets | tensorflow_datasets/core/features/sequence_feature.py | np_to_list | def np_to_list(elem):
"""Returns list from list, tuple or ndarray."""
if isinstance(elem, list):
return elem
elif isinstance(elem, tuple):
return list(elem)
elif isinstance(elem, np.ndarray):
return list(elem)
else:
raise ValueError(
'Input elements of a sequence should be either a num... | python | def np_to_list(elem):
"""Returns list from list, tuple or ndarray."""
if isinstance(elem, list):
return elem
elif isinstance(elem, tuple):
return list(elem)
elif isinstance(elem, np.ndarray):
return list(elem)
else:
raise ValueError(
'Input elements of a sequence should be either a num... | [
"def",
"np_to_list",
"(",
"elem",
")",
":",
"if",
"isinstance",
"(",
"elem",
",",
"list",
")",
":",
"return",
"elem",
"elif",
"isinstance",
"(",
"elem",
",",
"tuple",
")",
":",
"return",
"list",
"(",
"elem",
")",
"elif",
"isinstance",
"(",
"elem",
",... | Returns list from list, tuple or ndarray. | [
"Returns",
"list",
"from",
"list",
"tuple",
"or",
"ndarray",
"."
] | 46ceb0cf7b4690f38ecbbc689e4d659a903d08dc | https://github.com/tensorflow/datasets/blob/46ceb0cf7b4690f38ecbbc689e4d659a903d08dc/tensorflow_datasets/core/features/sequence_feature.py#L257-L268 |
26,176 | tensorflow/datasets | tensorflow_datasets/image/mnist.py | MNIST._generate_examples | def _generate_examples(self, num_examples, data_path, label_path):
"""Generate MNIST examples as dicts.
Args:
num_examples (int): The number of example.
data_path (str): Path to the data files
label_path (str): Path to the labels
Yields:
Generator yielding the next examples
"""... | python | def _generate_examples(self, num_examples, data_path, label_path):
"""Generate MNIST examples as dicts.
Args:
num_examples (int): The number of example.
data_path (str): Path to the data files
label_path (str): Path to the labels
Yields:
Generator yielding the next examples
"""... | [
"def",
"_generate_examples",
"(",
"self",
",",
"num_examples",
",",
"data_path",
",",
"label_path",
")",
":",
"images",
"=",
"_extract_mnist_images",
"(",
"data_path",
",",
"num_examples",
")",
"labels",
"=",
"_extract_mnist_labels",
"(",
"label_path",
",",
"num_e... | Generate MNIST examples as dicts.
Args:
num_examples (int): The number of example.
data_path (str): Path to the data files
label_path (str): Path to the labels
Yields:
Generator yielding the next examples | [
"Generate",
"MNIST",
"examples",
"as",
"dicts",
"."
] | 46ceb0cf7b4690f38ecbbc689e4d659a903d08dc | https://github.com/tensorflow/datasets/blob/46ceb0cf7b4690f38ecbbc689e4d659a903d08dc/tensorflow_datasets/image/mnist.py#L146-L166 |
26,177 | tensorflow/datasets | tensorflow_datasets/core/dataset_info.py | get_dataset_feature_statistics | def get_dataset_feature_statistics(builder, split):
"""Calculate statistics for the specified split."""
statistics = statistics_pb2.DatasetFeatureStatistics()
# Make this to the best of our abilities.
schema = schema_pb2.Schema()
dataset = builder.as_dataset(split=split)
# Just computing the number of ex... | python | def get_dataset_feature_statistics(builder, split):
"""Calculate statistics for the specified split."""
statistics = statistics_pb2.DatasetFeatureStatistics()
# Make this to the best of our abilities.
schema = schema_pb2.Schema()
dataset = builder.as_dataset(split=split)
# Just computing the number of ex... | [
"def",
"get_dataset_feature_statistics",
"(",
"builder",
",",
"split",
")",
":",
"statistics",
"=",
"statistics_pb2",
".",
"DatasetFeatureStatistics",
"(",
")",
"# Make this to the best of our abilities.",
"schema",
"=",
"schema_pb2",
".",
"Schema",
"(",
")",
"dataset",... | Calculate statistics for the specified split. | [
"Calculate",
"statistics",
"for",
"the",
"specified",
"split",
"."
] | 46ceb0cf7b4690f38ecbbc689e4d659a903d08dc | https://github.com/tensorflow/datasets/blob/46ceb0cf7b4690f38ecbbc689e4d659a903d08dc/tensorflow_datasets/core/dataset_info.py#L443-L556 |
26,178 | tensorflow/datasets | tensorflow_datasets/core/dataset_info.py | read_from_json | def read_from_json(json_filename):
"""Read JSON-formatted proto into DatasetInfo proto."""
with tf.io.gfile.GFile(json_filename) as f:
dataset_info_json_str = f.read()
# Parse it back into a proto.
parsed_proto = json_format.Parse(dataset_info_json_str,
dataset_info_pb2.Da... | python | def read_from_json(json_filename):
"""Read JSON-formatted proto into DatasetInfo proto."""
with tf.io.gfile.GFile(json_filename) as f:
dataset_info_json_str = f.read()
# Parse it back into a proto.
parsed_proto = json_format.Parse(dataset_info_json_str,
dataset_info_pb2.Da... | [
"def",
"read_from_json",
"(",
"json_filename",
")",
":",
"with",
"tf",
".",
"io",
".",
"gfile",
".",
"GFile",
"(",
"json_filename",
")",
"as",
"f",
":",
"dataset_info_json_str",
"=",
"f",
".",
"read",
"(",
")",
"# Parse it back into a proto.",
"parsed_proto",
... | Read JSON-formatted proto into DatasetInfo proto. | [
"Read",
"JSON",
"-",
"formatted",
"proto",
"into",
"DatasetInfo",
"proto",
"."
] | 46ceb0cf7b4690f38ecbbc689e4d659a903d08dc | https://github.com/tensorflow/datasets/blob/46ceb0cf7b4690f38ecbbc689e4d659a903d08dc/tensorflow_datasets/core/dataset_info.py#L559-L566 |
26,179 | tensorflow/datasets | tensorflow_datasets/core/dataset_info.py | DatasetInfo.update_splits_if_different | def update_splits_if_different(self, split_dict):
"""Overwrite the splits if they are different from the current ones.
* If splits aren't already defined or different (ex: different number of
shards), then the new split dict is used. This will trigger stats
computation during download_and_prepare.
... | python | def update_splits_if_different(self, split_dict):
"""Overwrite the splits if they are different from the current ones.
* If splits aren't already defined or different (ex: different number of
shards), then the new split dict is used. This will trigger stats
computation during download_and_prepare.
... | [
"def",
"update_splits_if_different",
"(",
"self",
",",
"split_dict",
")",
":",
"assert",
"isinstance",
"(",
"split_dict",
",",
"splits_lib",
".",
"SplitDict",
")",
"# If splits are already defined and identical, then we do not update",
"if",
"self",
".",
"_splits",
"and",... | Overwrite the splits if they are different from the current ones.
* If splits aren't already defined or different (ex: different number of
shards), then the new split dict is used. This will trigger stats
computation during download_and_prepare.
* If splits are already defined in DatasetInfo and si... | [
"Overwrite",
"the",
"splits",
"if",
"they",
"are",
"different",
"from",
"the",
"current",
"ones",
"."
] | 46ceb0cf7b4690f38ecbbc689e4d659a903d08dc | https://github.com/tensorflow/datasets/blob/46ceb0cf7b4690f38ecbbc689e4d659a903d08dc/tensorflow_datasets/core/dataset_info.py#L197-L217 |
26,180 | tensorflow/datasets | tensorflow_datasets/core/dataset_info.py | DatasetInfo._compute_dynamic_properties | def _compute_dynamic_properties(self, builder):
"""Update from the DatasetBuilder."""
# Fill other things by going over the dataset.
splits = self.splits
for split_info in utils.tqdm(
splits.values(), desc="Computing statistics...", unit=" split"):
try:
split_name = split_info.name... | python | def _compute_dynamic_properties(self, builder):
"""Update from the DatasetBuilder."""
# Fill other things by going over the dataset.
splits = self.splits
for split_info in utils.tqdm(
splits.values(), desc="Computing statistics...", unit=" split"):
try:
split_name = split_info.name... | [
"def",
"_compute_dynamic_properties",
"(",
"self",
",",
"builder",
")",
":",
"# Fill other things by going over the dataset.",
"splits",
"=",
"self",
".",
"splits",
"for",
"split_info",
"in",
"utils",
".",
"tqdm",
"(",
"splits",
".",
"values",
"(",
")",
",",
"de... | Update from the DatasetBuilder. | [
"Update",
"from",
"the",
"DatasetBuilder",
"."
] | 46ceb0cf7b4690f38ecbbc689e4d659a903d08dc | https://github.com/tensorflow/datasets/blob/46ceb0cf7b4690f38ecbbc689e4d659a903d08dc/tensorflow_datasets/core/dataset_info.py#L249-L278 |
26,181 | tensorflow/datasets | tensorflow_datasets/core/dataset_info.py | DatasetInfo.write_to_directory | def write_to_directory(self, dataset_info_dir):
"""Write `DatasetInfo` as JSON to `dataset_info_dir`."""
# Save the metadata from the features (vocabulary, labels,...)
if self.features:
self.features.save_metadata(dataset_info_dir)
if self.redistribution_info.license:
with tf.io.gfile.GFile... | python | def write_to_directory(self, dataset_info_dir):
"""Write `DatasetInfo` as JSON to `dataset_info_dir`."""
# Save the metadata from the features (vocabulary, labels,...)
if self.features:
self.features.save_metadata(dataset_info_dir)
if self.redistribution_info.license:
with tf.io.gfile.GFile... | [
"def",
"write_to_directory",
"(",
"self",
",",
"dataset_info_dir",
")",
":",
"# Save the metadata from the features (vocabulary, labels,...)",
"if",
"self",
".",
"features",
":",
"self",
".",
"features",
".",
"save_metadata",
"(",
"dataset_info_dir",
")",
"if",
"self",
... | Write `DatasetInfo` as JSON to `dataset_info_dir`. | [
"Write",
"DatasetInfo",
"as",
"JSON",
"to",
"dataset_info_dir",
"."
] | 46ceb0cf7b4690f38ecbbc689e4d659a903d08dc | https://github.com/tensorflow/datasets/blob/46ceb0cf7b4690f38ecbbc689e4d659a903d08dc/tensorflow_datasets/core/dataset_info.py#L284-L297 |
26,182 | tensorflow/datasets | tensorflow_datasets/core/dataset_info.py | DatasetInfo.read_from_directory | def read_from_directory(self, dataset_info_dir):
"""Update DatasetInfo from the JSON file in `dataset_info_dir`.
This function updates all the dynamically generated fields (num_examples,
hash, time of creation,...) of the DatasetInfo.
This will overwrite all previous metadata.
Args:
dataset... | python | def read_from_directory(self, dataset_info_dir):
"""Update DatasetInfo from the JSON file in `dataset_info_dir`.
This function updates all the dynamically generated fields (num_examples,
hash, time of creation,...) of the DatasetInfo.
This will overwrite all previous metadata.
Args:
dataset... | [
"def",
"read_from_directory",
"(",
"self",
",",
"dataset_info_dir",
")",
":",
"if",
"not",
"dataset_info_dir",
":",
"raise",
"ValueError",
"(",
"\"Calling read_from_directory with undefined dataset_info_dir.\"",
")",
"json_filename",
"=",
"self",
".",
"_dataset_info_filenam... | Update DatasetInfo from the JSON file in `dataset_info_dir`.
This function updates all the dynamically generated fields (num_examples,
hash, time of creation,...) of the DatasetInfo.
This will overwrite all previous metadata.
Args:
dataset_info_dir: `str` The directory containing the metadata f... | [
"Update",
"DatasetInfo",
"from",
"the",
"JSON",
"file",
"in",
"dataset_info_dir",
"."
] | 46ceb0cf7b4690f38ecbbc689e4d659a903d08dc | https://github.com/tensorflow/datasets/blob/46ceb0cf7b4690f38ecbbc689e4d659a903d08dc/tensorflow_datasets/core/dataset_info.py#L299-L367 |
26,183 | tensorflow/datasets | tensorflow_datasets/core/dataset_info.py | DatasetInfo.initialize_from_bucket | def initialize_from_bucket(self):
"""Initialize DatasetInfo from GCS bucket info files."""
# In order to support Colab, we use the HTTP GCS API to access the metadata
# files. They are copied locally and then loaded.
tmp_dir = tempfile.mkdtemp("tfds")
data_files = gcs_utils.gcs_dataset_info_files(se... | python | def initialize_from_bucket(self):
"""Initialize DatasetInfo from GCS bucket info files."""
# In order to support Colab, we use the HTTP GCS API to access the metadata
# files. They are copied locally and then loaded.
tmp_dir = tempfile.mkdtemp("tfds")
data_files = gcs_utils.gcs_dataset_info_files(se... | [
"def",
"initialize_from_bucket",
"(",
"self",
")",
":",
"# In order to support Colab, we use the HTTP GCS API to access the metadata",
"# files. They are copied locally and then loaded.",
"tmp_dir",
"=",
"tempfile",
".",
"mkdtemp",
"(",
"\"tfds\"",
")",
"data_files",
"=",
"gcs_ut... | Initialize DatasetInfo from GCS bucket info files. | [
"Initialize",
"DatasetInfo",
"from",
"GCS",
"bucket",
"info",
"files",
"."
] | 46ceb0cf7b4690f38ecbbc689e4d659a903d08dc | https://github.com/tensorflow/datasets/blob/46ceb0cf7b4690f38ecbbc689e4d659a903d08dc/tensorflow_datasets/core/dataset_info.py#L369-L381 |
26,184 | tensorflow/datasets | tensorflow_datasets/core/download/download_manager.py | _map_promise | def _map_promise(map_fn, all_inputs):
"""Map the function into each element and resolve the promise."""
all_promises = utils.map_nested(map_fn, all_inputs) # Apply the function
res = utils.map_nested(_wait_on_promise, all_promises)
return res | python | def _map_promise(map_fn, all_inputs):
"""Map the function into each element and resolve the promise."""
all_promises = utils.map_nested(map_fn, all_inputs) # Apply the function
res = utils.map_nested(_wait_on_promise, all_promises)
return res | [
"def",
"_map_promise",
"(",
"map_fn",
",",
"all_inputs",
")",
":",
"all_promises",
"=",
"utils",
".",
"map_nested",
"(",
"map_fn",
",",
"all_inputs",
")",
"# Apply the function",
"res",
"=",
"utils",
".",
"map_nested",
"(",
"_wait_on_promise",
",",
"all_promises... | Map the function into each element and resolve the promise. | [
"Map",
"the",
"function",
"into",
"each",
"element",
"and",
"resolve",
"the",
"promise",
"."
] | 46ceb0cf7b4690f38ecbbc689e4d659a903d08dc | https://github.com/tensorflow/datasets/blob/46ceb0cf7b4690f38ecbbc689e4d659a903d08dc/tensorflow_datasets/core/download/download_manager.py#L392-L396 |
26,185 | tensorflow/datasets | tensorflow_datasets/core/download/download_manager.py | DownloadManager._handle_download_result | def _handle_download_result(self, resource, tmp_dir_path, sha256, dl_size):
"""Store dled file to definitive place, write INFO file, return path."""
fnames = tf.io.gfile.listdir(tmp_dir_path)
if len(fnames) > 1:
raise AssertionError('More than one file in %s.' % tmp_dir_path)
original_fname = fnam... | python | def _handle_download_result(self, resource, tmp_dir_path, sha256, dl_size):
"""Store dled file to definitive place, write INFO file, return path."""
fnames = tf.io.gfile.listdir(tmp_dir_path)
if len(fnames) > 1:
raise AssertionError('More than one file in %s.' % tmp_dir_path)
original_fname = fnam... | [
"def",
"_handle_download_result",
"(",
"self",
",",
"resource",
",",
"tmp_dir_path",
",",
"sha256",
",",
"dl_size",
")",
":",
"fnames",
"=",
"tf",
".",
"io",
".",
"gfile",
".",
"listdir",
"(",
"tmp_dir_path",
")",
"if",
"len",
"(",
"fnames",
")",
">",
... | Store dled file to definitive place, write INFO file, return path. | [
"Store",
"dled",
"file",
"to",
"definitive",
"place",
"write",
"INFO",
"file",
"return",
"path",
"."
] | 46ceb0cf7b4690f38ecbbc689e4d659a903d08dc | https://github.com/tensorflow/datasets/blob/46ceb0cf7b4690f38ecbbc689e4d659a903d08dc/tensorflow_datasets/core/download/download_manager.py#L196-L215 |
26,186 | tensorflow/datasets | tensorflow_datasets/core/download/download_manager.py | DownloadManager._download | def _download(self, resource):
"""Download resource, returns Promise->path to downloaded file."""
if isinstance(resource, six.string_types):
resource = resource_lib.Resource(url=resource)
url = resource.url
if url in self._sizes_checksums:
expected_sha256 = self._sizes_checksums[url][1]
... | python | def _download(self, resource):
"""Download resource, returns Promise->path to downloaded file."""
if isinstance(resource, six.string_types):
resource = resource_lib.Resource(url=resource)
url = resource.url
if url in self._sizes_checksums:
expected_sha256 = self._sizes_checksums[url][1]
... | [
"def",
"_download",
"(",
"self",
",",
"resource",
")",
":",
"if",
"isinstance",
"(",
"resource",
",",
"six",
".",
"string_types",
")",
":",
"resource",
"=",
"resource_lib",
".",
"Resource",
"(",
"url",
"=",
"resource",
")",
"url",
"=",
"resource",
".",
... | Download resource, returns Promise->path to downloaded file. | [
"Download",
"resource",
"returns",
"Promise",
"-",
">",
"path",
"to",
"downloaded",
"file",
"."
] | 46ceb0cf7b4690f38ecbbc689e4d659a903d08dc | https://github.com/tensorflow/datasets/blob/46ceb0cf7b4690f38ecbbc689e4d659a903d08dc/tensorflow_datasets/core/download/download_manager.py#L221-L247 |
26,187 | tensorflow/datasets | tensorflow_datasets/core/download/download_manager.py | DownloadManager._extract | def _extract(self, resource):
"""Extract a single archive, returns Promise->path to extraction result."""
if isinstance(resource, six.string_types):
resource = resource_lib.Resource(path=resource)
path = resource.path
extract_method = resource.extract_method
if extract_method == resource_lib.E... | python | def _extract(self, resource):
"""Extract a single archive, returns Promise->path to extraction result."""
if isinstance(resource, six.string_types):
resource = resource_lib.Resource(path=resource)
path = resource.path
extract_method = resource.extract_method
if extract_method == resource_lib.E... | [
"def",
"_extract",
"(",
"self",
",",
"resource",
")",
":",
"if",
"isinstance",
"(",
"resource",
",",
"six",
".",
"string_types",
")",
":",
"resource",
"=",
"resource_lib",
".",
"Resource",
"(",
"path",
"=",
"resource",
")",
"path",
"=",
"resource",
".",
... | Extract a single archive, returns Promise->path to extraction result. | [
"Extract",
"a",
"single",
"archive",
"returns",
"Promise",
"-",
">",
"path",
"to",
"extraction",
"result",
"."
] | 46ceb0cf7b4690f38ecbbc689e4d659a903d08dc | https://github.com/tensorflow/datasets/blob/46ceb0cf7b4690f38ecbbc689e4d659a903d08dc/tensorflow_datasets/core/download/download_manager.py#L251-L266 |
26,188 | tensorflow/datasets | tensorflow_datasets/core/download/download_manager.py | DownloadManager._download_extract | def _download_extract(self, resource):
"""Download-extract `Resource` or url, returns Promise->path."""
if isinstance(resource, six.string_types):
resource = resource_lib.Resource(url=resource)
def callback(path):
resource.path = path
return self._extract(resource)
return self._downloa... | python | def _download_extract(self, resource):
"""Download-extract `Resource` or url, returns Promise->path."""
if isinstance(resource, six.string_types):
resource = resource_lib.Resource(url=resource)
def callback(path):
resource.path = path
return self._extract(resource)
return self._downloa... | [
"def",
"_download_extract",
"(",
"self",
",",
"resource",
")",
":",
"if",
"isinstance",
"(",
"resource",
",",
"six",
".",
"string_types",
")",
":",
"resource",
"=",
"resource_lib",
".",
"Resource",
"(",
"url",
"=",
"resource",
")",
"def",
"callback",
"(",
... | Download-extract `Resource` or url, returns Promise->path. | [
"Download",
"-",
"extract",
"Resource",
"or",
"url",
"returns",
"Promise",
"-",
">",
"path",
"."
] | 46ceb0cf7b4690f38ecbbc689e4d659a903d08dc | https://github.com/tensorflow/datasets/blob/46ceb0cf7b4690f38ecbbc689e4d659a903d08dc/tensorflow_datasets/core/download/download_manager.py#L270-L277 |
26,189 | tensorflow/datasets | tensorflow_datasets/core/download/download_manager.py | DownloadManager.download_kaggle_data | def download_kaggle_data(self, competition_name):
"""Download data for a given Kaggle competition."""
with self._downloader.tqdm():
kaggle_downloader = self._downloader.kaggle_downloader(competition_name)
urls = kaggle_downloader.competition_urls
files = kaggle_downloader.competition_files
... | python | def download_kaggle_data(self, competition_name):
"""Download data for a given Kaggle competition."""
with self._downloader.tqdm():
kaggle_downloader = self._downloader.kaggle_downloader(competition_name)
urls = kaggle_downloader.competition_urls
files = kaggle_downloader.competition_files
... | [
"def",
"download_kaggle_data",
"(",
"self",
",",
"competition_name",
")",
":",
"with",
"self",
".",
"_downloader",
".",
"tqdm",
"(",
")",
":",
"kaggle_downloader",
"=",
"self",
".",
"_downloader",
".",
"kaggle_downloader",
"(",
"competition_name",
")",
"urls",
... | Download data for a given Kaggle competition. | [
"Download",
"data",
"for",
"a",
"given",
"Kaggle",
"competition",
"."
] | 46ceb0cf7b4690f38ecbbc689e4d659a903d08dc | https://github.com/tensorflow/datasets/blob/46ceb0cf7b4690f38ecbbc689e4d659a903d08dc/tensorflow_datasets/core/download/download_manager.py#L279-L286 |
26,190 | tensorflow/datasets | tensorflow_datasets/core/download/download_manager.py | DownloadManager.iter_archive | def iter_archive(self, resource):
"""Returns iterator over files within archive.
**Important Note**: caller should read files as they are yielded.
Reading out of order is slow.
Args:
resource: path to archive or `tfds.download.Resource`.
Returns:
Generator yielding tuple (path_within_... | python | def iter_archive(self, resource):
"""Returns iterator over files within archive.
**Important Note**: caller should read files as they are yielded.
Reading out of order is slow.
Args:
resource: path to archive or `tfds.download.Resource`.
Returns:
Generator yielding tuple (path_within_... | [
"def",
"iter_archive",
"(",
"self",
",",
"resource",
")",
":",
"if",
"isinstance",
"(",
"resource",
",",
"six",
".",
"string_types",
")",
":",
"resource",
"=",
"resource_lib",
".",
"Resource",
"(",
"path",
"=",
"resource",
")",
"return",
"extractor",
".",
... | Returns iterator over files within archive.
**Important Note**: caller should read files as they are yielded.
Reading out of order is slow.
Args:
resource: path to archive or `tfds.download.Resource`.
Returns:
Generator yielding tuple (path_within_archive, file_obj). | [
"Returns",
"iterator",
"over",
"files",
"within",
"archive",
"."
] | 46ceb0cf7b4690f38ecbbc689e4d659a903d08dc | https://github.com/tensorflow/datasets/blob/46ceb0cf7b4690f38ecbbc689e4d659a903d08dc/tensorflow_datasets/core/download/download_manager.py#L303-L317 |
26,191 | tensorflow/datasets | tensorflow_datasets/core/download/download_manager.py | DownloadManager.download_and_extract | def download_and_extract(self, url_or_urls):
"""Download and extract given url_or_urls.
Is roughly equivalent to:
```
extracted_paths = dl_manager.extract(dl_manager.download(url_or_urls))
```
Args:
url_or_urls: url or `list`/`dict` of urls to download and extract. Each
url can ... | python | def download_and_extract(self, url_or_urls):
"""Download and extract given url_or_urls.
Is roughly equivalent to:
```
extracted_paths = dl_manager.extract(dl_manager.download(url_or_urls))
```
Args:
url_or_urls: url or `list`/`dict` of urls to download and extract. Each
url can ... | [
"def",
"download_and_extract",
"(",
"self",
",",
"url_or_urls",
")",
":",
"# Add progress bar to follow the download state",
"with",
"self",
".",
"_downloader",
".",
"tqdm",
"(",
")",
":",
"with",
"self",
".",
"_extractor",
".",
"tqdm",
"(",
")",
":",
"return",
... | Download and extract given url_or_urls.
Is roughly equivalent to:
```
extracted_paths = dl_manager.extract(dl_manager.download(url_or_urls))
```
Args:
url_or_urls: url or `list`/`dict` of urls to download and extract. Each
url can be a `str` or `tfds.download.Resource`.
If not ... | [
"Download",
"and",
"extract",
"given",
"url_or_urls",
"."
] | 46ceb0cf7b4690f38ecbbc689e4d659a903d08dc | https://github.com/tensorflow/datasets/blob/46ceb0cf7b4690f38ecbbc689e4d659a903d08dc/tensorflow_datasets/core/download/download_manager.py#L337-L359 |
26,192 | tensorflow/datasets | tensorflow_datasets/core/download/download_manager.py | DownloadManager.manual_dir | def manual_dir(self):
"""Returns the directory containing the manually extracted data."""
if not tf.io.gfile.exists(self._manual_dir):
raise AssertionError(
'Manual directory {} does not exist. Create it and download/extract '
'dataset artifacts in there.'.format(self._manual_dir))
... | python | def manual_dir(self):
"""Returns the directory containing the manually extracted data."""
if not tf.io.gfile.exists(self._manual_dir):
raise AssertionError(
'Manual directory {} does not exist. Create it and download/extract '
'dataset artifacts in there.'.format(self._manual_dir))
... | [
"def",
"manual_dir",
"(",
"self",
")",
":",
"if",
"not",
"tf",
".",
"io",
".",
"gfile",
".",
"exists",
"(",
"self",
".",
"_manual_dir",
")",
":",
"raise",
"AssertionError",
"(",
"'Manual directory {} does not exist. Create it and download/extract '",
"'dataset artif... | Returns the directory containing the manually extracted data. | [
"Returns",
"the",
"directory",
"containing",
"the",
"manually",
"extracted",
"data",
"."
] | 46ceb0cf7b4690f38ecbbc689e4d659a903d08dc | https://github.com/tensorflow/datasets/blob/46ceb0cf7b4690f38ecbbc689e4d659a903d08dc/tensorflow_datasets/core/download/download_manager.py#L362-L368 |
26,193 | tensorflow/datasets | tensorflow_datasets/image/cifar10_corrupted.py | Cifar10Corrupted._split_generators | def _split_generators(self, dl_manager):
"""Return the test split of Cifar10.
Args:
dl_manager: download manager object.
Returns:
test split.
"""
path = dl_manager.download_and_extract(_DOWNLOAD_URL)
return [
tfds.core.SplitGenerator(
name=tfds.Split.TEST,
... | python | def _split_generators(self, dl_manager):
"""Return the test split of Cifar10.
Args:
dl_manager: download manager object.
Returns:
test split.
"""
path = dl_manager.download_and_extract(_DOWNLOAD_URL)
return [
tfds.core.SplitGenerator(
name=tfds.Split.TEST,
... | [
"def",
"_split_generators",
"(",
"self",
",",
"dl_manager",
")",
":",
"path",
"=",
"dl_manager",
".",
"download_and_extract",
"(",
"_DOWNLOAD_URL",
")",
"return",
"[",
"tfds",
".",
"core",
".",
"SplitGenerator",
"(",
"name",
"=",
"tfds",
".",
"Split",
".",
... | Return the test split of Cifar10.
Args:
dl_manager: download manager object.
Returns:
test split. | [
"Return",
"the",
"test",
"split",
"of",
"Cifar10",
"."
] | 46ceb0cf7b4690f38ecbbc689e4d659a903d08dc | https://github.com/tensorflow/datasets/blob/46ceb0cf7b4690f38ecbbc689e4d659a903d08dc/tensorflow_datasets/image/cifar10_corrupted.py#L138-L153 |
26,194 | tensorflow/datasets | tensorflow_datasets/image/cifar10_corrupted.py | Cifar10Corrupted._generate_examples | def _generate_examples(self, data_dir):
"""Generate corrupted Cifar10 test data.
Apply corruptions to the raw images according to self.corruption_type.
Args:
data_dir: root directory of downloaded dataset
Yields:
dictionary with image file and label.
"""
corruption = self.builder_... | python | def _generate_examples(self, data_dir):
"""Generate corrupted Cifar10 test data.
Apply corruptions to the raw images according to self.corruption_type.
Args:
data_dir: root directory of downloaded dataset
Yields:
dictionary with image file and label.
"""
corruption = self.builder_... | [
"def",
"_generate_examples",
"(",
"self",
",",
"data_dir",
")",
":",
"corruption",
"=",
"self",
".",
"builder_config",
".",
"corruption",
"severity",
"=",
"self",
".",
"builder_config",
".",
"severity",
"images_file",
"=",
"os",
".",
"path",
".",
"join",
"("... | Generate corrupted Cifar10 test data.
Apply corruptions to the raw images according to self.corruption_type.
Args:
data_dir: root directory of downloaded dataset
Yields:
dictionary with image file and label. | [
"Generate",
"corrupted",
"Cifar10",
"test",
"data",
"."
] | 46ceb0cf7b4690f38ecbbc689e4d659a903d08dc | https://github.com/tensorflow/datasets/blob/46ceb0cf7b4690f38ecbbc689e4d659a903d08dc/tensorflow_datasets/image/cifar10_corrupted.py#L155-L189 |
26,195 | tensorflow/datasets | tensorflow_datasets/scripts/document_datasets.py | document_single_builder | def document_single_builder(builder):
"""Doc string for a single builder, with or without configs."""
mod_name = builder.__class__.__module__
cls_name = builder.__class__.__name__
mod_file = sys.modules[mod_name].__file__
if mod_file.endswith("pyc"):
mod_file = mod_file[:-1]
description_prefix = ""
... | python | def document_single_builder(builder):
"""Doc string for a single builder, with or without configs."""
mod_name = builder.__class__.__module__
cls_name = builder.__class__.__name__
mod_file = sys.modules[mod_name].__file__
if mod_file.endswith("pyc"):
mod_file = mod_file[:-1]
description_prefix = ""
... | [
"def",
"document_single_builder",
"(",
"builder",
")",
":",
"mod_name",
"=",
"builder",
".",
"__class__",
".",
"__module__",
"cls_name",
"=",
"builder",
".",
"__class__",
".",
"__name__",
"mod_file",
"=",
"sys",
".",
"modules",
"[",
"mod_name",
"]",
".",
"__... | Doc string for a single builder, with or without configs. | [
"Doc",
"string",
"for",
"a",
"single",
"builder",
"with",
"or",
"without",
"configs",
"."
] | 46ceb0cf7b4690f38ecbbc689e4d659a903d08dc | https://github.com/tensorflow/datasets/blob/46ceb0cf7b4690f38ecbbc689e4d659a903d08dc/tensorflow_datasets/scripts/document_datasets.py#L196-L265 |
26,196 | tensorflow/datasets | tensorflow_datasets/scripts/document_datasets.py | make_module_to_builder_dict | def make_module_to_builder_dict(datasets=None):
"""Get all builders organized by module in nested dicts."""
# pylint: disable=g-long-lambda
# dict to hold tfds->image->mnist->[builders]
module_to_builder = collections.defaultdict(
lambda: collections.defaultdict(
lambda: collections.defaultdict(... | python | def make_module_to_builder_dict(datasets=None):
"""Get all builders organized by module in nested dicts."""
# pylint: disable=g-long-lambda
# dict to hold tfds->image->mnist->[builders]
module_to_builder = collections.defaultdict(
lambda: collections.defaultdict(
lambda: collections.defaultdict(... | [
"def",
"make_module_to_builder_dict",
"(",
"datasets",
"=",
"None",
")",
":",
"# pylint: disable=g-long-lambda",
"# dict to hold tfds->image->mnist->[builders]",
"module_to_builder",
"=",
"collections",
".",
"defaultdict",
"(",
"lambda",
":",
"collections",
".",
"defaultdict"... | Get all builders organized by module in nested dicts. | [
"Get",
"all",
"builders",
"organized",
"by",
"module",
"in",
"nested",
"dicts",
"."
] | 46ceb0cf7b4690f38ecbbc689e4d659a903d08dc | https://github.com/tensorflow/datasets/blob/46ceb0cf7b4690f38ecbbc689e4d659a903d08dc/tensorflow_datasets/scripts/document_datasets.py#L275-L305 |
26,197 | tensorflow/datasets | tensorflow_datasets/scripts/document_datasets.py | _pprint_features_dict | def _pprint_features_dict(features_dict, indent=0, add_prefix=True):
"""Pretty-print tfds.features.FeaturesDict."""
first_last_indent_str = " " * indent
indent_str = " " * (indent + 4)
first_line = "%s%s({" % (
first_last_indent_str if add_prefix else "",
type(features_dict).__name__,
)
lines = ... | python | def _pprint_features_dict(features_dict, indent=0, add_prefix=True):
"""Pretty-print tfds.features.FeaturesDict."""
first_last_indent_str = " " * indent
indent_str = " " * (indent + 4)
first_line = "%s%s({" % (
first_last_indent_str if add_prefix else "",
type(features_dict).__name__,
)
lines = ... | [
"def",
"_pprint_features_dict",
"(",
"features_dict",
",",
"indent",
"=",
"0",
",",
"add_prefix",
"=",
"True",
")",
":",
"first_last_indent_str",
"=",
"\" \"",
"*",
"indent",
"indent_str",
"=",
"\" \"",
"*",
"(",
"indent",
"+",
"4",
")",
"first_line",
"=",
... | Pretty-print tfds.features.FeaturesDict. | [
"Pretty",
"-",
"print",
"tfds",
".",
"features",
".",
"FeaturesDict",
"."
] | 46ceb0cf7b4690f38ecbbc689e4d659a903d08dc | https://github.com/tensorflow/datasets/blob/46ceb0cf7b4690f38ecbbc689e4d659a903d08dc/tensorflow_datasets/scripts/document_datasets.py#L308-L325 |
26,198 | tensorflow/datasets | tensorflow_datasets/scripts/document_datasets.py | make_statistics_information | def make_statistics_information(info):
"""Make statistics information table."""
if not info.splits.total_num_examples:
# That means that we have yet to calculate the statistics for this.
return "None computed"
stats = [(info.splits.total_num_examples, "ALL")]
for split_name, split_info in info.splits.i... | python | def make_statistics_information(info):
"""Make statistics information table."""
if not info.splits.total_num_examples:
# That means that we have yet to calculate the statistics for this.
return "None computed"
stats = [(info.splits.total_num_examples, "ALL")]
for split_name, split_info in info.splits.i... | [
"def",
"make_statistics_information",
"(",
"info",
")",
":",
"if",
"not",
"info",
".",
"splits",
".",
"total_num_examples",
":",
"# That means that we have yet to calculate the statistics for this.",
"return",
"\"None computed\"",
"stats",
"=",
"[",
"(",
"info",
".",
"s... | Make statistics information table. | [
"Make",
"statistics",
"information",
"table",
"."
] | 46ceb0cf7b4690f38ecbbc689e4d659a903d08dc | https://github.com/tensorflow/datasets/blob/46ceb0cf7b4690f38ecbbc689e4d659a903d08dc/tensorflow_datasets/scripts/document_datasets.py#L337-L351 |
26,199 | tensorflow/datasets | tensorflow_datasets/scripts/document_datasets.py | dataset_docs_str | def dataset_docs_str(datasets=None):
"""Create dataset documentation string for given datasets.
Args:
datasets: list of datasets for which to create documentation.
If None, then all available datasets will be used.
Returns:
string describing the datasets (in the MarkDown format).
"""
m... | python | def dataset_docs_str(datasets=None):
"""Create dataset documentation string for given datasets.
Args:
datasets: list of datasets for which to create documentation.
If None, then all available datasets will be used.
Returns:
string describing the datasets (in the MarkDown format).
"""
m... | [
"def",
"dataset_docs_str",
"(",
"datasets",
"=",
"None",
")",
":",
"module_to_builder",
"=",
"make_module_to_builder_dict",
"(",
"datasets",
")",
"sections",
"=",
"sorted",
"(",
"list",
"(",
"module_to_builder",
".",
"keys",
"(",
")",
")",
")",
"section_tocs",
... | Create dataset documentation string for given datasets.
Args:
datasets: list of datasets for which to create documentation.
If None, then all available datasets will be used.
Returns:
string describing the datasets (in the MarkDown format). | [
"Create",
"dataset",
"documentation",
"string",
"for",
"given",
"datasets",
"."
] | 46ceb0cf7b4690f38ecbbc689e4d659a903d08dc | https://github.com/tensorflow/datasets/blob/46ceb0cf7b4690f38ecbbc689e4d659a903d08dc/tensorflow_datasets/scripts/document_datasets.py#L354-L383 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.