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
listlengths
20
707
docstring
stringlengths
3
17.3k
docstring_tokens
listlengths
3
222
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
idx
int64
0
252k
spyder-ide/conda-manager
conda_manager/api/client_api.py
_ClientAPI.packages
def packages(self, login=None, platform=None, package_type=None, type_=None, access=None): """Return all the available packages for a given user. Parameters ---------- type_: Optional[str] Only find packages that have this conda `type`, (i.e. 'app'). ...
python
def packages(self, login=None, platform=None, package_type=None, type_=None, access=None): """Return all the available packages for a given user. Parameters ---------- type_: Optional[str] Only find packages that have this conda `type`, (i.e. 'app'). ...
[ "def", "packages", "(", "self", ",", "login", "=", "None", ",", "platform", "=", "None", ",", "package_type", "=", "None", ",", "type_", "=", "None", ",", "access", "=", "None", ")", ":", "logger", ".", "debug", "(", "''", ")", "method", "=", "self...
Return all the available packages for a given user. Parameters ---------- type_: Optional[str] Only find packages that have this conda `type`, (i.e. 'app'). access : Optional[str] Only find packages that have this access level (e.g. 'private', 'authen...
[ "Return", "all", "the", "available", "packages", "for", "a", "given", "user", "." ]
89a2126cbecefc92185cf979347ccac1c5ee5d9d
https://github.com/spyder-ide/conda-manager/blob/89a2126cbecefc92185cf979347ccac1c5ee5d9d/conda_manager/api/client_api.py#L386-L402
train
62,100
yaph/geonamescache
geonamescache/mappers.py
country
def country(from_key='name', to_key='iso'): """Creates and returns a mapper function to access country data. The mapper function that is returned must be called with one argument. In the default case you call it with a name and it returns a 3-letter ISO_3166-1 code, e. g. called with ``Spain`` it would...
python
def country(from_key='name', to_key='iso'): """Creates and returns a mapper function to access country data. The mapper function that is returned must be called with one argument. In the default case you call it with a name and it returns a 3-letter ISO_3166-1 code, e. g. called with ``Spain`` it would...
[ "def", "country", "(", "from_key", "=", "'name'", ",", "to_key", "=", "'iso'", ")", ":", "gc", "=", "GeonamesCache", "(", ")", "dataset", "=", "gc", ".", "get_dataset_by_key", "(", "gc", ".", "get_countries", "(", ")", ",", "from_key", ")", "def", "map...
Creates and returns a mapper function to access country data. The mapper function that is returned must be called with one argument. In the default case you call it with a name and it returns a 3-letter ISO_3166-1 code, e. g. called with ``Spain`` it would return ``ESP``. :param from_key: (optional) t...
[ "Creates", "and", "returns", "a", "mapper", "function", "to", "access", "country", "data", "." ]
5a3835d6c32664ffa5ab9e6e5887f0b7dd39962b
https://github.com/yaph/geonamescache/blob/5a3835d6c32664ffa5ab9e6e5887f0b7dd39962b/geonamescache/mappers.py#L6-L33
train
62,101
yaph/geonamescache
geonamescache/__init__.py
GeonamesCache.get_cities
def get_cities(self): """Get a dictionary of cities keyed by geonameid.""" if self.cities is None: self.cities = self._load_data(self.cities, 'cities.json') return self.cities
python
def get_cities(self): """Get a dictionary of cities keyed by geonameid.""" if self.cities is None: self.cities = self._load_data(self.cities, 'cities.json') return self.cities
[ "def", "get_cities", "(", "self", ")", ":", "if", "self", ".", "cities", "is", "None", ":", "self", ".", "cities", "=", "self", ".", "_load_data", "(", "self", ".", "cities", ",", "'cities.json'", ")", "return", "self", ".", "cities" ]
Get a dictionary of cities keyed by geonameid.
[ "Get", "a", "dictionary", "of", "cities", "keyed", "by", "geonameid", "." ]
5a3835d6c32664ffa5ab9e6e5887f0b7dd39962b
https://github.com/yaph/geonamescache/blob/5a3835d6c32664ffa5ab9e6e5887f0b7dd39962b/geonamescache/__init__.py#L56-L61
train
62,102
yaph/geonamescache
geonamescache/__init__.py
GeonamesCache.get_cities_by_name
def get_cities_by_name(self, name): """Get a list of city dictionaries with the given name. City names cannot be used as keys, as they are not unique. """ if name not in self.cities_by_names: if self.cities_items is None: self.cities_items = list(self.get_ci...
python
def get_cities_by_name(self, name): """Get a list of city dictionaries with the given name. City names cannot be used as keys, as they are not unique. """ if name not in self.cities_by_names: if self.cities_items is None: self.cities_items = list(self.get_ci...
[ "def", "get_cities_by_name", "(", "self", ",", "name", ")", ":", "if", "name", "not", "in", "self", ".", "cities_by_names", ":", "if", "self", ".", "cities_items", "is", "None", ":", "self", ".", "cities_items", "=", "list", "(", "self", ".", "get_cities...
Get a list of city dictionaries with the given name. City names cannot be used as keys, as they are not unique.
[ "Get", "a", "list", "of", "city", "dictionaries", "with", "the", "given", "name", "." ]
5a3835d6c32664ffa5ab9e6e5887f0b7dd39962b
https://github.com/yaph/geonamescache/blob/5a3835d6c32664ffa5ab9e6e5887f0b7dd39962b/geonamescache/__init__.py#L63-L74
train
62,103
spyder-ide/conda-manager
conda_manager/api/manager_api.py
_ManagerAPI._set_repo_urls_from_channels
def _set_repo_urls_from_channels(self, channels): """ Convert a channel into a normalized repo name including. Channels are assumed in normalized url form. """ repos = [] sys_platform = self._conda_api.get_platform() for channel in channels: url = '{...
python
def _set_repo_urls_from_channels(self, channels): """ Convert a channel into a normalized repo name including. Channels are assumed in normalized url form. """ repos = [] sys_platform = self._conda_api.get_platform() for channel in channels: url = '{...
[ "def", "_set_repo_urls_from_channels", "(", "self", ",", "channels", ")", ":", "repos", "=", "[", "]", "sys_platform", "=", "self", ".", "_conda_api", ".", "get_platform", "(", ")", "for", "channel", "in", "channels", ":", "url", "=", "'{0}/{1}/repodata.json.b...
Convert a channel into a normalized repo name including. Channels are assumed in normalized url form.
[ "Convert", "a", "channel", "into", "a", "normalized", "repo", "name", "including", "." ]
89a2126cbecefc92185cf979347ccac1c5ee5d9d
https://github.com/spyder-ide/conda-manager/blob/89a2126cbecefc92185cf979347ccac1c5ee5d9d/conda_manager/api/manager_api.py#L106-L119
train
62,104
spyder-ide/conda-manager
conda_manager/api/manager_api.py
_ManagerAPI._check_repos
def _check_repos(self, repos): """Check if repodata urls are valid.""" self._checking_repos = [] self._valid_repos = [] for repo in repos: worker = self.download_is_valid_url(repo) worker.sig_finished.connect(self._repos_checked) worker.repo = repo ...
python
def _check_repos(self, repos): """Check if repodata urls are valid.""" self._checking_repos = [] self._valid_repos = [] for repo in repos: worker = self.download_is_valid_url(repo) worker.sig_finished.connect(self._repos_checked) worker.repo = repo ...
[ "def", "_check_repos", "(", "self", ",", "repos", ")", ":", "self", ".", "_checking_repos", "=", "[", "]", "self", ".", "_valid_repos", "=", "[", "]", "for", "repo", "in", "repos", ":", "worker", "=", "self", ".", "download_is_valid_url", "(", "repo", ...
Check if repodata urls are valid.
[ "Check", "if", "repodata", "urls", "are", "valid", "." ]
89a2126cbecefc92185cf979347ccac1c5ee5d9d
https://github.com/spyder-ide/conda-manager/blob/89a2126cbecefc92185cf979347ccac1c5ee5d9d/conda_manager/api/manager_api.py#L121-L130
train
62,105
spyder-ide/conda-manager
conda_manager/api/manager_api.py
_ManagerAPI._repos_checked
def _repos_checked(self, worker, output, error): """Callback for _check_repos.""" if worker.repo in self._checking_repos: self._checking_repos.remove(worker.repo) if output: self._valid_repos.append(worker.repo) if len(self._checking_repos) == 0: sel...
python
def _repos_checked(self, worker, output, error): """Callback for _check_repos.""" if worker.repo in self._checking_repos: self._checking_repos.remove(worker.repo) if output: self._valid_repos.append(worker.repo) if len(self._checking_repos) == 0: sel...
[ "def", "_repos_checked", "(", "self", ",", "worker", ",", "output", ",", "error", ")", ":", "if", "worker", ".", "repo", "in", "self", ".", "_checking_repos", ":", "self", ".", "_checking_repos", ".", "remove", "(", "worker", ".", "repo", ")", "if", "o...
Callback for _check_repos.
[ "Callback", "for", "_check_repos", "." ]
89a2126cbecefc92185cf979347ccac1c5ee5d9d
https://github.com/spyder-ide/conda-manager/blob/89a2126cbecefc92185cf979347ccac1c5ee5d9d/conda_manager/api/manager_api.py#L132-L141
train
62,106
spyder-ide/conda-manager
conda_manager/api/manager_api.py
_ManagerAPI._repo_url_to_path
def _repo_url_to_path(self, repo): """Convert a `repo` url to a file path for local storage.""" repo = repo.replace('http://', '') repo = repo.replace('https://', '') repo = repo.replace('/', '_') return os.sep.join([self._data_directory, repo])
python
def _repo_url_to_path(self, repo): """Convert a `repo` url to a file path for local storage.""" repo = repo.replace('http://', '') repo = repo.replace('https://', '') repo = repo.replace('/', '_') return os.sep.join([self._data_directory, repo])
[ "def", "_repo_url_to_path", "(", "self", ",", "repo", ")", ":", "repo", "=", "repo", ".", "replace", "(", "'http://'", ",", "''", ")", "repo", "=", "repo", ".", "replace", "(", "'https://'", ",", "''", ")", "repo", "=", "repo", ".", "replace", "(", ...
Convert a `repo` url to a file path for local storage.
[ "Convert", "a", "repo", "url", "to", "a", "file", "path", "for", "local", "storage", "." ]
89a2126cbecefc92185cf979347ccac1c5ee5d9d
https://github.com/spyder-ide/conda-manager/blob/89a2126cbecefc92185cf979347ccac1c5ee5d9d/conda_manager/api/manager_api.py#L143-L149
train
62,107
spyder-ide/conda-manager
conda_manager/api/manager_api.py
_ManagerAPI._download_repodata
def _download_repodata(self, checked_repos): """Dowload repodata.""" self._files_downloaded = [] self._repodata_files = [] self.__counter = -1 if checked_repos: for repo in checked_repos: path = self._repo_url_to_path(repo) self._files...
python
def _download_repodata(self, checked_repos): """Dowload repodata.""" self._files_downloaded = [] self._repodata_files = [] self.__counter = -1 if checked_repos: for repo in checked_repos: path = self._repo_url_to_path(repo) self._files...
[ "def", "_download_repodata", "(", "self", ",", "checked_repos", ")", ":", "self", ".", "_files_downloaded", "=", "[", "]", "self", ".", "_repodata_files", "=", "[", "]", "self", ".", "__counter", "=", "-", "1", "if", "checked_repos", ":", "for", "repo", ...
Dowload repodata.
[ "Dowload", "repodata", "." ]
89a2126cbecefc92185cf979347ccac1c5ee5d9d
https://github.com/spyder-ide/conda-manager/blob/89a2126cbecefc92185cf979347ccac1c5ee5d9d/conda_manager/api/manager_api.py#L151-L171
train
62,108
spyder-ide/conda-manager
conda_manager/api/manager_api.py
_ManagerAPI._get_repodata_from_meta
def _get_repodata_from_meta(self): """Generate repodata from local meta files.""" path = os.sep.join([self.ROOT_PREFIX, 'conda-meta']) packages = os.listdir(path) meta_repodata = {} for pkg in packages: if pkg.endswith('.json'): filepath = os.sep.join(...
python
def _get_repodata_from_meta(self): """Generate repodata from local meta files.""" path = os.sep.join([self.ROOT_PREFIX, 'conda-meta']) packages = os.listdir(path) meta_repodata = {} for pkg in packages: if pkg.endswith('.json'): filepath = os.sep.join(...
[ "def", "_get_repodata_from_meta", "(", "self", ")", ":", "path", "=", "os", ".", "sep", ".", "join", "(", "[", "self", ".", "ROOT_PREFIX", ",", "'conda-meta'", "]", ")", "packages", "=", "os", ".", "listdir", "(", "path", ")", "meta_repodata", "=", "{"...
Generate repodata from local meta files.
[ "Generate", "repodata", "from", "local", "meta", "files", "." ]
89a2126cbecefc92185cf979347ccac1c5ee5d9d
https://github.com/spyder-ide/conda-manager/blob/89a2126cbecefc92185cf979347ccac1c5ee5d9d/conda_manager/api/manager_api.py#L173-L201
train
62,109
spyder-ide/conda-manager
conda_manager/api/manager_api.py
_ManagerAPI._repodata_downloaded
def _repodata_downloaded(self, worker=None, output=None, error=None): """Callback for _download_repodata.""" if worker: self._files_downloaded.remove(worker.path) if worker.path in self._files_downloaded: self._files_downloaded.remove(worker.path) if len...
python
def _repodata_downloaded(self, worker=None, output=None, error=None): """Callback for _download_repodata.""" if worker: self._files_downloaded.remove(worker.path) if worker.path in self._files_downloaded: self._files_downloaded.remove(worker.path) if len...
[ "def", "_repodata_downloaded", "(", "self", ",", "worker", "=", "None", ",", "output", "=", "None", ",", "error", "=", "None", ")", ":", "if", "worker", ":", "self", ".", "_files_downloaded", ".", "remove", "(", "worker", ".", "path", ")", "if", "worke...
Callback for _download_repodata.
[ "Callback", "for", "_download_repodata", "." ]
89a2126cbecefc92185cf979347ccac1c5ee5d9d
https://github.com/spyder-ide/conda-manager/blob/89a2126cbecefc92185cf979347ccac1c5ee5d9d/conda_manager/api/manager_api.py#L203-L212
train
62,110
spyder-ide/conda-manager
conda_manager/api/manager_api.py
_ManagerAPI.repodata_files
def repodata_files(self, channels=None): """ Return the repodata paths based on `channels` and the `data_directory`. There is no check for validity here. """ if channels is None: channels = self.conda_get_condarc_channels() repodata_urls = self._set_repo_url...
python
def repodata_files(self, channels=None): """ Return the repodata paths based on `channels` and the `data_directory`. There is no check for validity here. """ if channels is None: channels = self.conda_get_condarc_channels() repodata_urls = self._set_repo_url...
[ "def", "repodata_files", "(", "self", ",", "channels", "=", "None", ")", ":", "if", "channels", "is", "None", ":", "channels", "=", "self", ".", "conda_get_condarc_channels", "(", ")", "repodata_urls", "=", "self", ".", "_set_repo_urls_from_channels", "(", "ch...
Return the repodata paths based on `channels` and the `data_directory`. There is no check for validity here.
[ "Return", "the", "repodata", "paths", "based", "on", "channels", "and", "the", "data_directory", "." ]
89a2126cbecefc92185cf979347ccac1c5ee5d9d
https://github.com/spyder-ide/conda-manager/blob/89a2126cbecefc92185cf979347ccac1c5ee5d9d/conda_manager/api/manager_api.py#L216-L233
train
62,111
spyder-ide/conda-manager
conda_manager/api/manager_api.py
_ManagerAPI.update_repodata
def update_repodata(self, channels=None): """Update repodata from channels or use condarc channels if None.""" norm_channels = self.conda_get_condarc_channels(channels=channels, normalize=True) repodata_urls = self._set_repo_urls_from_chann...
python
def update_repodata(self, channels=None): """Update repodata from channels or use condarc channels if None.""" norm_channels = self.conda_get_condarc_channels(channels=channels, normalize=True) repodata_urls = self._set_repo_urls_from_chann...
[ "def", "update_repodata", "(", "self", ",", "channels", "=", "None", ")", ":", "norm_channels", "=", "self", ".", "conda_get_condarc_channels", "(", "channels", "=", "channels", ",", "normalize", "=", "True", ")", "repodata_urls", "=", "self", ".", "_set_repo_...
Update repodata from channels or use condarc channels if None.
[ "Update", "repodata", "from", "channels", "or", "use", "condarc", "channels", "if", "None", "." ]
89a2126cbecefc92185cf979347ccac1c5ee5d9d
https://github.com/spyder-ide/conda-manager/blob/89a2126cbecefc92185cf979347ccac1c5ee5d9d/conda_manager/api/manager_api.py#L239-L244
train
62,112
spyder-ide/conda-manager
conda_manager/api/manager_api.py
_ManagerAPI.update_metadata
def update_metadata(self): """ Update the metadata available for packages in repo.continuum.io. Returns a download worker. """ if self._data_directory is None: raise Exception('Need to call `api.set_data_directory` first.') metadata_url = 'https://repo.conti...
python
def update_metadata(self): """ Update the metadata available for packages in repo.continuum.io. Returns a download worker. """ if self._data_directory is None: raise Exception('Need to call `api.set_data_directory` first.') metadata_url = 'https://repo.conti...
[ "def", "update_metadata", "(", "self", ")", ":", "if", "self", ".", "_data_directory", "is", "None", ":", "raise", "Exception", "(", "'Need to call `api.set_data_directory` first.'", ")", "metadata_url", "=", "'https://repo.continuum.io/pkgs/metadata.json'", "filepath", "...
Update the metadata available for packages in repo.continuum.io. Returns a download worker.
[ "Update", "the", "metadata", "available", "for", "packages", "in", "repo", ".", "continuum", ".", "io", "." ]
89a2126cbecefc92185cf979347ccac1c5ee5d9d
https://github.com/spyder-ide/conda-manager/blob/89a2126cbecefc92185cf979347ccac1c5ee5d9d/conda_manager/api/manager_api.py#L246-L258
train
62,113
spyder-ide/conda-manager
conda_manager/api/manager_api.py
_ManagerAPI.check_valid_channel
def check_valid_channel(self, channel, conda_url='https://conda.anaconda.org'): """Check if channel is valid.""" if channel.startswith('https://') or channel.startswith('http://'): url = channel else: url = "{0}/{1}"...
python
def check_valid_channel(self, channel, conda_url='https://conda.anaconda.org'): """Check if channel is valid.""" if channel.startswith('https://') or channel.startswith('http://'): url = channel else: url = "{0}/{1}"...
[ "def", "check_valid_channel", "(", "self", ",", "channel", ",", "conda_url", "=", "'https://conda.anaconda.org'", ")", ":", "if", "channel", ".", "startswith", "(", "'https://'", ")", "or", "channel", ".", "startswith", "(", "'http://'", ")", ":", "url", "=", ...
Check if channel is valid.
[ "Check", "if", "channel", "is", "valid", "." ]
89a2126cbecefc92185cf979347ccac1c5ee5d9d
https://github.com/spyder-ide/conda-manager/blob/89a2126cbecefc92185cf979347ccac1c5ee5d9d/conda_manager/api/manager_api.py#L260-L275
train
62,114
google/python-cloud-utils
cloud_utils/list_instances.py
_aws_get_instance_by_tag
def _aws_get_instance_by_tag(region, name, tag, raw): """Get all instances matching a tag.""" client = boto3.session.Session().client('ec2', region) matching_reservations = client.describe_instances(Filters=[{'Name': tag, 'Values': [name]}]).get('Reservations', []) instances = [] [[instances.append(...
python
def _aws_get_instance_by_tag(region, name, tag, raw): """Get all instances matching a tag.""" client = boto3.session.Session().client('ec2', region) matching_reservations = client.describe_instances(Filters=[{'Name': tag, 'Values': [name]}]).get('Reservations', []) instances = [] [[instances.append(...
[ "def", "_aws_get_instance_by_tag", "(", "region", ",", "name", ",", "tag", ",", "raw", ")", ":", "client", "=", "boto3", ".", "session", ".", "Session", "(", ")", ".", "client", "(", "'ec2'", ",", "region", ")", "matching_reservations", "=", "client", "....
Get all instances matching a tag.
[ "Get", "all", "instances", "matching", "a", "tag", "." ]
1ad892da078b0fd6ba5cace78602c616b9262b2b
https://github.com/google/python-cloud-utils/blob/1ad892da078b0fd6ba5cace78602c616b9262b2b/cloud_utils/list_instances.py#L101-L108
train
62,115
google/python-cloud-utils
cloud_utils/list_instances.py
aws_get_instances_by_id
def aws_get_instances_by_id(region, instance_id, raw=True): """Returns instances mathing an id.""" client = boto3.session.Session().client('ec2', region) try: matching_reservations = client.describe_instances(InstanceIds=[instance_id]).get('Reservations', []) except ClientError as exc: i...
python
def aws_get_instances_by_id(region, instance_id, raw=True): """Returns instances mathing an id.""" client = boto3.session.Session().client('ec2', region) try: matching_reservations = client.describe_instances(InstanceIds=[instance_id]).get('Reservations', []) except ClientError as exc: i...
[ "def", "aws_get_instances_by_id", "(", "region", ",", "instance_id", ",", "raw", "=", "True", ")", ":", "client", "=", "boto3", ".", "session", ".", "Session", "(", ")", ".", "client", "(", "'ec2'", ",", "region", ")", "try", ":", "matching_reservations", ...
Returns instances mathing an id.
[ "Returns", "instances", "mathing", "an", "id", "." ]
1ad892da078b0fd6ba5cace78602c616b9262b2b
https://github.com/google/python-cloud-utils/blob/1ad892da078b0fd6ba5cace78602c616b9262b2b/cloud_utils/list_instances.py#L231-L243
train
62,116
google/python-cloud-utils
cloud_utils/list_instances.py
get_instances_by_name
def get_instances_by_name(name, sort_by_order=('cloud', 'name'), projects=None, raw=True, regions=None, gcp_credentials=None, clouds=SUPPORTED_CLOUDS): """Get intsances from GCP and AWS by name.""" matching_instances = all_clouds_get_instances_by_name( name, projects, raw, credentials=gcp_credentials, c...
python
def get_instances_by_name(name, sort_by_order=('cloud', 'name'), projects=None, raw=True, regions=None, gcp_credentials=None, clouds=SUPPORTED_CLOUDS): """Get intsances from GCP and AWS by name.""" matching_instances = all_clouds_get_instances_by_name( name, projects, raw, credentials=gcp_credentials, c...
[ "def", "get_instances_by_name", "(", "name", ",", "sort_by_order", "=", "(", "'cloud'", ",", "'name'", ")", ",", "projects", "=", "None", ",", "raw", "=", "True", ",", "regions", "=", "None", ",", "gcp_credentials", "=", "None", ",", "clouds", "=", "SUPP...
Get intsances from GCP and AWS by name.
[ "Get", "intsances", "from", "GCP", "and", "AWS", "by", "name", "." ]
1ad892da078b0fd6ba5cace78602c616b9262b2b
https://github.com/google/python-cloud-utils/blob/1ad892da078b0fd6ba5cace78602c616b9262b2b/cloud_utils/list_instances.py#L297-L304
train
62,117
google/python-cloud-utils
cloud_utils/list_instances.py
get_os_version
def get_os_version(instance): """Get OS Version for instances.""" if instance.cloud == 'aws': client = boto3.client('ec2', instance.region) image_id = client.describe_instances(InstanceIds=[instance.id])['Reservations'][0]['Instances'][0]['ImageId'] return '16.04' if '16.04' in client.de...
python
def get_os_version(instance): """Get OS Version for instances.""" if instance.cloud == 'aws': client = boto3.client('ec2', instance.region) image_id = client.describe_instances(InstanceIds=[instance.id])['Reservations'][0]['Instances'][0]['ImageId'] return '16.04' if '16.04' in client.de...
[ "def", "get_os_version", "(", "instance", ")", ":", "if", "instance", ".", "cloud", "==", "'aws'", ":", "client", "=", "boto3", ".", "client", "(", "'ec2'", ",", "instance", ".", "region", ")", "image_id", "=", "client", ".", "describe_instances", "(", "...
Get OS Version for instances.
[ "Get", "OS", "Version", "for", "instances", "." ]
1ad892da078b0fd6ba5cace78602c616b9262b2b
https://github.com/google/python-cloud-utils/blob/1ad892da078b0fd6ba5cace78602c616b9262b2b/cloud_utils/list_instances.py#L367-L387
train
62,118
google/python-cloud-utils
cloud_utils/list_instances.py
get_volumes
def get_volumes(instance): """Returns all the volumes of an instance.""" if instance.cloud == 'aws': client = boto3.client('ec2', instance.region) devices = client.describe_instance_attribute( InstanceId=instance.id, Attribute='blockDeviceMapping').get('BlockDeviceMappings', []) ...
python
def get_volumes(instance): """Returns all the volumes of an instance.""" if instance.cloud == 'aws': client = boto3.client('ec2', instance.region) devices = client.describe_instance_attribute( InstanceId=instance.id, Attribute='blockDeviceMapping').get('BlockDeviceMappings', []) ...
[ "def", "get_volumes", "(", "instance", ")", ":", "if", "instance", ".", "cloud", "==", "'aws'", ":", "client", "=", "boto3", ".", "client", "(", "'ec2'", ",", "instance", ".", "region", ")", "devices", "=", "client", ".", "describe_instance_attribute", "("...
Returns all the volumes of an instance.
[ "Returns", "all", "the", "volumes", "of", "an", "instance", "." ]
1ad892da078b0fd6ba5cace78602c616b9262b2b
https://github.com/google/python-cloud-utils/blob/1ad892da078b0fd6ba5cace78602c616b9262b2b/cloud_utils/list_instances.py#L390-L425
train
62,119
google/python-cloud-utils
cloud_utils/list_instances.py
get_persistent_address
def get_persistent_address(instance): """Returns the public ip address of an instance.""" if instance.cloud == 'aws': client = boto3.client('ec2', instance.region) try: client.describe_addresses(PublicIps=[instance.ip_address]) return instance.ip_address except bo...
python
def get_persistent_address(instance): """Returns the public ip address of an instance.""" if instance.cloud == 'aws': client = boto3.client('ec2', instance.region) try: client.describe_addresses(PublicIps=[instance.ip_address]) return instance.ip_address except bo...
[ "def", "get_persistent_address", "(", "instance", ")", ":", "if", "instance", ".", "cloud", "==", "'aws'", ":", "client", "=", "boto3", ".", "client", "(", "'ec2'", ",", "instance", ".", "region", ")", "try", ":", "client", ".", "describe_addresses", "(", ...
Returns the public ip address of an instance.
[ "Returns", "the", "public", "ip", "address", "of", "an", "instance", "." ]
1ad892da078b0fd6ba5cace78602c616b9262b2b
https://github.com/google/python-cloud-utils/blob/1ad892da078b0fd6ba5cace78602c616b9262b2b/cloud_utils/list_instances.py#L428-L449
train
62,120
spyder-ide/conda-manager
conda_manager/utils/findpip.py
main
def main(): """Use pip to find pip installed packages in a given prefix.""" pip_packages = {} for package in pip.get_installed_distributions(): name = package.project_name version = package.version full_name = "{0}-{1}-pip".format(name.lower(), version) pip_packages[full_name...
python
def main(): """Use pip to find pip installed packages in a given prefix.""" pip_packages = {} for package in pip.get_installed_distributions(): name = package.project_name version = package.version full_name = "{0}-{1}-pip".format(name.lower(), version) pip_packages[full_name...
[ "def", "main", "(", ")", ":", "pip_packages", "=", "{", "}", "for", "package", "in", "pip", ".", "get_installed_distributions", "(", ")", ":", "name", "=", "package", ".", "project_name", "version", "=", "package", ".", "version", "full_name", "=", "\"{0}-...
Use pip to find pip installed packages in a given prefix.
[ "Use", "pip", "to", "find", "pip", "installed", "packages", "in", "a", "given", "prefix", "." ]
89a2126cbecefc92185cf979347ccac1c5ee5d9d
https://github.com/spyder-ide/conda-manager/blob/89a2126cbecefc92185cf979347ccac1c5ee5d9d/conda_manager/utils/findpip.py#L21-L30
train
62,121
xgvargas/js-css-min-django
jscssmin.py
_save
def _save(file, data, mode='w+'): """ Write all data to created file. Also overwrite previous file. """ with open(file, mode) as fh: fh.write(data)
python
def _save(file, data, mode='w+'): """ Write all data to created file. Also overwrite previous file. """ with open(file, mode) as fh: fh.write(data)
[ "def", "_save", "(", "file", ",", "data", ",", "mode", "=", "'w+'", ")", ":", "with", "open", "(", "file", ",", "mode", ")", "as", "fh", ":", "fh", ".", "write", "(", "data", ")" ]
Write all data to created file. Also overwrite previous file.
[ "Write", "all", "data", "to", "created", "file", ".", "Also", "overwrite", "previous", "file", "." ]
29300bef0d72b523c41deb72ef19bb1d24a619bb
https://github.com/xgvargas/js-css-min-django/blob/29300bef0d72b523c41deb72ef19bb1d24a619bb/jscssmin.py#L32-L37
train
62,122
xgvargas/js-css-min-django
jscssmin.py
merge
def merge(obj): """ Merge contents. It does a simply merge of all files defined under 'static' key. If you have JS or CSS file with embeded django tags like {% url ... %} or {% static ... %} you should declare them under 'template' key. This function will render them and append to the merged o...
python
def merge(obj): """ Merge contents. It does a simply merge of all files defined under 'static' key. If you have JS or CSS file with embeded django tags like {% url ... %} or {% static ... %} you should declare them under 'template' key. This function will render them and append to the merged o...
[ "def", "merge", "(", "obj", ")", ":", "merge", "=", "''", "for", "f", "in", "obj", ".", "get", "(", "'static'", ",", "[", "]", ")", ":", "print", "'Merging: {}'", ".", "format", "(", "f", ")", "merge", "+=", "_read", "(", "f", ")", "def", "dole...
Merge contents. It does a simply merge of all files defined under 'static' key. If you have JS or CSS file with embeded django tags like {% url ... %} or {% static ... %} you should declare them under 'template' key. This function will render them and append to the merged output. To use the rende...
[ "Merge", "contents", "." ]
29300bef0d72b523c41deb72ef19bb1d24a619bb
https://github.com/xgvargas/js-css-min-django/blob/29300bef0d72b523c41deb72ef19bb1d24a619bb/jscssmin.py#L40-L102
train
62,123
xgvargas/js-css-min-django
jscssmin.py
jsMin
def jsMin(data, file): """ Minify JS data and saves to file. Data should be a string will whole JS content, and file will be overwrited if exists. """ print 'Minifying JS... ', url = 'http://javascript-minifier.com/raw' #POST req = urllib2.Request(url, urllib.urlencode({'input': data}))...
python
def jsMin(data, file): """ Minify JS data and saves to file. Data should be a string will whole JS content, and file will be overwrited if exists. """ print 'Minifying JS... ', url = 'http://javascript-minifier.com/raw' #POST req = urllib2.Request(url, urllib.urlencode({'input': data}))...
[ "def", "jsMin", "(", "data", ",", "file", ")", ":", "print", "'Minifying JS... '", ",", "url", "=", "'http://javascript-minifier.com/raw'", "#POST", "req", "=", "urllib2", ".", "Request", "(", "url", ",", "urllib", ".", "urlencode", "(", "{", "'input'", ":",...
Minify JS data and saves to file. Data should be a string will whole JS content, and file will be overwrited if exists.
[ "Minify", "JS", "data", "and", "saves", "to", "file", "." ]
29300bef0d72b523c41deb72ef19bb1d24a619bb
https://github.com/xgvargas/js-css-min-django/blob/29300bef0d72b523c41deb72ef19bb1d24a619bb/jscssmin.py#L105-L125
train
62,124
xgvargas/js-css-min-django
jscssmin.py
jpgMin
def jpgMin(file, force=False): """ Try to optimise a JPG file. The original will be saved at the same place with '.original' appended to its name. Once a .original exists the function will ignore this file unless force is True. """ if not os.path.isfile(file+'.original') or force: data...
python
def jpgMin(file, force=False): """ Try to optimise a JPG file. The original will be saved at the same place with '.original' appended to its name. Once a .original exists the function will ignore this file unless force is True. """ if not os.path.isfile(file+'.original') or force: data...
[ "def", "jpgMin", "(", "file", ",", "force", "=", "False", ")", ":", "if", "not", "os", ".", "path", ".", "isfile", "(", "file", "+", "'.original'", ")", "or", "force", ":", "data", "=", "_read", "(", "file", ",", "'rb'", ")", "_save", "(", "file"...
Try to optimise a JPG file. The original will be saved at the same place with '.original' appended to its name. Once a .original exists the function will ignore this file unless force is True.
[ "Try", "to", "optimise", "a", "JPG", "file", "." ]
29300bef0d72b523c41deb72ef19bb1d24a619bb
https://github.com/xgvargas/js-css-min-django/blob/29300bef0d72b523c41deb72ef19bb1d24a619bb/jscssmin.py#L151-L177
train
62,125
xgvargas/js-css-min-django
jscssmin.py
process
def process(obj): """ Process each block of the merger object. """ #merge all static and templates and less files merged = merge(obj) #save the full file if name defined if obj.get('full'): print 'Saving: {} ({:.2f}kB)'.format(obj['full'], len(merged)/1024.0) _save(obj['full...
python
def process(obj): """ Process each block of the merger object. """ #merge all static and templates and less files merged = merge(obj) #save the full file if name defined if obj.get('full'): print 'Saving: {} ({:.2f}kB)'.format(obj['full'], len(merged)/1024.0) _save(obj['full...
[ "def", "process", "(", "obj", ")", ":", "#merge all static and templates and less files", "merged", "=", "merge", "(", "obj", ")", "#save the full file if name defined", "if", "obj", ".", "get", "(", "'full'", ")", ":", "print", "'Saving: {} ({:.2f}kB)'", ".", "form...
Process each block of the merger object.
[ "Process", "each", "block", "of", "the", "merger", "object", "." ]
29300bef0d72b523c41deb72ef19bb1d24a619bb
https://github.com/xgvargas/js-css-min-django/blob/29300bef0d72b523c41deb72ef19bb1d24a619bb/jscssmin.py#L284-L304
train
62,126
aisthesis/pynance
pynance/pf.py
optimize
def optimize(exp_rets, covs): """ Return parameters for portfolio optimization. Parameters ---------- exp_rets : ndarray Vector of expected returns for each investment.. covs : ndarray Covariance matrix for the given investments. Returns --------- a : ndarray ...
python
def optimize(exp_rets, covs): """ Return parameters for portfolio optimization. Parameters ---------- exp_rets : ndarray Vector of expected returns for each investment.. covs : ndarray Covariance matrix for the given investments. Returns --------- a : ndarray ...
[ "def", "optimize", "(", "exp_rets", ",", "covs", ")", ":", "_cov_inv", "=", "np", ".", "linalg", ".", "inv", "(", "covs", ")", "# unit vector", "_u", "=", "np", ".", "ones", "(", "(", "len", "(", "exp_rets", ")", ")", ")", "# compute some dot products ...
Return parameters for portfolio optimization. Parameters ---------- exp_rets : ndarray Vector of expected returns for each investment.. covs : ndarray Covariance matrix for the given investments. Returns --------- a : ndarray The first vector (to be combined with ta...
[ "Return", "parameters", "for", "portfolio", "optimization", "." ]
9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41
https://github.com/aisthesis/pynance/blob/9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41/pynance/pf.py#L13-L69
train
62,127
aisthesis/pynance
pynance/interest.py
growthfromrange
def growthfromrange(rangegrowth, startdate, enddate): """ Annual growth given growth from start date to end date. """ _yrs = (pd.Timestamp(enddate) - pd.Timestamp(startdate)).total_seconds() /\ dt.timedelta(365.25).total_seconds() return yrlygrowth(rangegrowth, _yrs)
python
def growthfromrange(rangegrowth, startdate, enddate): """ Annual growth given growth from start date to end date. """ _yrs = (pd.Timestamp(enddate) - pd.Timestamp(startdate)).total_seconds() /\ dt.timedelta(365.25).total_seconds() return yrlygrowth(rangegrowth, _yrs)
[ "def", "growthfromrange", "(", "rangegrowth", ",", "startdate", ",", "enddate", ")", ":", "_yrs", "=", "(", "pd", ".", "Timestamp", "(", "enddate", ")", "-", "pd", ".", "Timestamp", "(", "startdate", ")", ")", ".", "total_seconds", "(", ")", "/", "dt",...
Annual growth given growth from start date to end date.
[ "Annual", "growth", "given", "growth", "from", "start", "date", "to", "end", "date", "." ]
9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41
https://github.com/aisthesis/pynance/blob/9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41/pynance/interest.py#L30-L36
train
62,128
aisthesis/pynance
pynance/data/retrieve.py
equities
def equities(country='US'): """ Return a DataFrame of current US equities. .. versionadded:: 0.4.0 .. versionchanged:: 0.5.0 Return a DataFrame Parameters ---------- country : str, optional Country code for equities to return, defaults to 'US'. Returns ------- ...
python
def equities(country='US'): """ Return a DataFrame of current US equities. .. versionadded:: 0.4.0 .. versionchanged:: 0.5.0 Return a DataFrame Parameters ---------- country : str, optional Country code for equities to return, defaults to 'US'. Returns ------- ...
[ "def", "equities", "(", "country", "=", "'US'", ")", ":", "nasdaqblob", ",", "otherblob", "=", "_getrawdata", "(", ")", "eq_triples", "=", "[", "]", "eq_triples", ".", "extend", "(", "_get_nas_triples", "(", "nasdaqblob", ")", ")", "eq_triples", ".", "exte...
Return a DataFrame of current US equities. .. versionadded:: 0.4.0 .. versionchanged:: 0.5.0 Return a DataFrame Parameters ---------- country : str, optional Country code for equities to return, defaults to 'US'. Returns ------- eqs : :class:`pandas.DataFrame` ...
[ "Return", "a", "DataFrame", "of", "current", "US", "equities", "." ]
9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41
https://github.com/aisthesis/pynance/blob/9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41/pynance/data/retrieve.py#L36-L72
train
62,129
aisthesis/pynance
pynance/opt/spread/vert.py
Vert.straddle
def straddle(self, strike, expiry): """ Metrics for evaluating a straddle. Parameters ------------ strike : numeric Strike price. expiry : date or date str (e.g. '2015-01-01') Expiration date. Returns ------------ metrics ...
python
def straddle(self, strike, expiry): """ Metrics for evaluating a straddle. Parameters ------------ strike : numeric Strike price. expiry : date or date str (e.g. '2015-01-01') Expiration date. Returns ------------ metrics ...
[ "def", "straddle", "(", "self", ",", "strike", ",", "expiry", ")", ":", "_rows", "=", "{", "}", "_prices", "=", "{", "}", "for", "_opttype", "in", "_constants", ".", "OPTTYPES", ":", "_rows", "[", "_opttype", "]", "=", "_relevant_rows", "(", "self", ...
Metrics for evaluating a straddle. Parameters ------------ strike : numeric Strike price. expiry : date or date str (e.g. '2015-01-01') Expiration date. Returns ------------ metrics : DataFrame Metrics for evaluating straddle.
[ "Metrics", "for", "evaluating", "a", "straddle", "." ]
9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41
https://github.com/aisthesis/pynance/blob/9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41/pynance/opt/spread/vert.py#L166-L192
train
62,130
aisthesis/pynance
pynance/opt/retrieve.py
get
def get(equity): """ Retrieve all current options chains for given equity. .. versionchanged:: 0.5.0 Eliminate special exception handling. Parameters ------------- equity : str Equity for which to retrieve options data. Returns ------------- optdata : :class:`~pynan...
python
def get(equity): """ Retrieve all current options chains for given equity. .. versionchanged:: 0.5.0 Eliminate special exception handling. Parameters ------------- equity : str Equity for which to retrieve options data. Returns ------------- optdata : :class:`~pynan...
[ "def", "get", "(", "equity", ")", ":", "_optmeta", "=", "pdr", ".", "data", ".", "Options", "(", "equity", ",", "'yahoo'", ")", "_optdata", "=", "_optmeta", ".", "get_all_data", "(", ")", "return", "Options", "(", "_optdata", ")" ]
Retrieve all current options chains for given equity. .. versionchanged:: 0.5.0 Eliminate special exception handling. Parameters ------------- equity : str Equity for which to retrieve options data. Returns ------------- optdata : :class:`~pynance.opt.core.Options` ...
[ "Retrieve", "all", "current", "options", "chains", "for", "given", "equity", "." ]
9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41
https://github.com/aisthesis/pynance/blob/9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41/pynance/opt/retrieve.py#L17-L53
train
62,131
aisthesis/pynance
pynance/data/prep.py
transform
def transform(data_frame, **kwargs): """ Return a transformed DataFrame. Transform data_frame along the given axis. By default, each row will be normalized (axis=0). Parameters ----------- data_frame : DataFrame Data to be normalized. axis : int, optional 0 (default) to nor...
python
def transform(data_frame, **kwargs): """ Return a transformed DataFrame. Transform data_frame along the given axis. By default, each row will be normalized (axis=0). Parameters ----------- data_frame : DataFrame Data to be normalized. axis : int, optional 0 (default) to nor...
[ "def", "transform", "(", "data_frame", ",", "*", "*", "kwargs", ")", ":", "norm", "=", "kwargs", ".", "get", "(", "'norm'", ",", "1.0", ")", "axis", "=", "kwargs", ".", "get", "(", "'axis'", ",", "0", ")", "if", "axis", "==", "0", ":", "norm_vect...
Return a transformed DataFrame. Transform data_frame along the given axis. By default, each row will be normalized (axis=0). Parameters ----------- data_frame : DataFrame Data to be normalized. axis : int, optional 0 (default) to normalize each row, 1 to normalize each column. ...
[ "Return", "a", "transformed", "DataFrame", "." ]
9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41
https://github.com/aisthesis/pynance/blob/9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41/pynance/data/prep.py#L119-L181
train
62,132
aisthesis/pynance
pynance/data/prep.py
_get_norms_of_rows
def _get_norms_of_rows(data_frame, method): """ return a column vector containing the norm of each row """ if method == 'vector': norm_vector = np.linalg.norm(data_frame.values, axis=1) elif method == 'last': norm_vector = data_frame.iloc[:, -1].values elif method == 'mean': norm...
python
def _get_norms_of_rows(data_frame, method): """ return a column vector containing the norm of each row """ if method == 'vector': norm_vector = np.linalg.norm(data_frame.values, axis=1) elif method == 'last': norm_vector = data_frame.iloc[:, -1].values elif method == 'mean': norm...
[ "def", "_get_norms_of_rows", "(", "data_frame", ",", "method", ")", ":", "if", "method", "==", "'vector'", ":", "norm_vector", "=", "np", ".", "linalg", ".", "norm", "(", "data_frame", ".", "values", ",", "axis", "=", "1", ")", "elif", "method", "==", ...
return a column vector containing the norm of each row
[ "return", "a", "column", "vector", "containing", "the", "norm", "of", "each", "row" ]
9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41
https://github.com/aisthesis/pynance/blob/9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41/pynance/data/prep.py#L183-L195
train
62,133
aisthesis/pynance
pynance/opt/price.py
Price.get
def get(self, opttype, strike, expiry): """ Price as midpoint between bid and ask. Parameters ---------- opttype : str 'call' or 'put'. strike : numeric Strike price. expiry : date-like Expiration date. Can be a :class:`datetim...
python
def get(self, opttype, strike, expiry): """ Price as midpoint between bid and ask. Parameters ---------- opttype : str 'call' or 'put'. strike : numeric Strike price. expiry : date-like Expiration date. Can be a :class:`datetim...
[ "def", "get", "(", "self", ",", "opttype", ",", "strike", ",", "expiry", ")", ":", "_optrow", "=", "_relevant_rows", "(", "self", ".", "data", ",", "(", "strike", ",", "expiry", ",", "opttype", ",", ")", ",", "\"No key for {} strike {} {}\"", ".", "forma...
Price as midpoint between bid and ask. Parameters ---------- opttype : str 'call' or 'put'. strike : numeric Strike price. expiry : date-like Expiration date. Can be a :class:`datetime.datetime` or a string that :mod:`pandas` can i...
[ "Price", "as", "midpoint", "between", "bid", "and", "ask", "." ]
9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41
https://github.com/aisthesis/pynance/blob/9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41/pynance/opt/price.py#L52-L79
train
62,134
aisthesis/pynance
pynance/opt/price.py
Price.metrics
def metrics(self, opttype, strike, expiry): """ Basic metrics for a specific option. Parameters ---------- opttype : str ('call' or 'put') strike : numeric Strike price. expiry : date-like Expiration date. Can be a :class:`datetime.datetim...
python
def metrics(self, opttype, strike, expiry): """ Basic metrics for a specific option. Parameters ---------- opttype : str ('call' or 'put') strike : numeric Strike price. expiry : date-like Expiration date. Can be a :class:`datetime.datetim...
[ "def", "metrics", "(", "self", ",", "opttype", ",", "strike", ",", "expiry", ")", ":", "_optrow", "=", "_relevant_rows", "(", "self", ".", "data", ",", "(", "strike", ",", "expiry", ",", "opttype", ",", ")", ",", "\"No key for {} strike {} {}\"", ".", "f...
Basic metrics for a specific option. Parameters ---------- opttype : str ('call' or 'put') strike : numeric Strike price. expiry : date-like Expiration date. Can be a :class:`datetime.datetime` or a string that :mod:`pandas` can interpret as s...
[ "Basic", "metrics", "for", "a", "specific", "option", "." ]
9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41
https://github.com/aisthesis/pynance/blob/9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41/pynance/opt/price.py#L81-L111
train
62,135
aisthesis/pynance
pynance/opt/price.py
Price.strikes
def strikes(self, opttype, expiry): """ Retrieve option prices for all strikes of a given type with a given expiration. Parameters ---------- opttype : str ('call' or 'put') expiry : date-like Expiration date. Can be a :class:`datetime.datetime` or ...
python
def strikes(self, opttype, expiry): """ Retrieve option prices for all strikes of a given type with a given expiration. Parameters ---------- opttype : str ('call' or 'put') expiry : date-like Expiration date. Can be a :class:`datetime.datetime` or ...
[ "def", "strikes", "(", "self", ",", "opttype", ",", "expiry", ")", ":", "_relevant", "=", "_relevant_rows", "(", "self", ".", "data", ",", "(", "slice", "(", "None", ")", ",", "expiry", ",", "opttype", ",", ")", ",", "\"No key for {} {}\"", ".", "forma...
Retrieve option prices for all strikes of a given type with a given expiration. Parameters ---------- opttype : str ('call' or 'put') expiry : date-like Expiration date. Can be a :class:`datetime.datetime` or a string that :mod:`pandas` can interpret as such, e.g...
[ "Retrieve", "option", "prices", "for", "all", "strikes", "of", "a", "given", "type", "with", "a", "given", "expiration", "." ]
9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41
https://github.com/aisthesis/pynance/blob/9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41/pynance/opt/price.py#L113-L148
train
62,136
aisthesis/pynance
pynance/opt/price.py
Price.exps
def exps(self, opttype, strike): """ Prices for given strike on all available dates. Parameters ---------- opttype : str ('call' or 'put') strike : numeric Returns ---------- df : :class:`pandas.DataFrame` eq : float Price of ...
python
def exps(self, opttype, strike): """ Prices for given strike on all available dates. Parameters ---------- opttype : str ('call' or 'put') strike : numeric Returns ---------- df : :class:`pandas.DataFrame` eq : float Price of ...
[ "def", "exps", "(", "self", ",", "opttype", ",", "strike", ")", ":", "_relevant", "=", "_relevant_rows", "(", "self", ".", "data", ",", "(", "strike", ",", "slice", "(", "None", ")", ",", "opttype", ",", ")", ",", "\"No key for {} {}\"", ".", "format",...
Prices for given strike on all available dates. Parameters ---------- opttype : str ('call' or 'put') strike : numeric Returns ---------- df : :class:`pandas.DataFrame` eq : float Price of underlying. qt : :class:`datetime.datetime` ...
[ "Prices", "for", "given", "strike", "on", "all", "available", "dates", "." ]
9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41
https://github.com/aisthesis/pynance/blob/9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41/pynance/opt/price.py#L150-L182
train
62,137
aisthesis/pynance
pynance/data/combine.py
labeledfeatures
def labeledfeatures(eqdata, featurefunc, labelfunc): """ Return features and labels for the given equity data. Each row of the features returned contains `2 * n_sessions + 1` columns (or 1 less if the constant feature is excluded). After the constant feature, if present, there will be `n_sessions` ...
python
def labeledfeatures(eqdata, featurefunc, labelfunc): """ Return features and labels for the given equity data. Each row of the features returned contains `2 * n_sessions + 1` columns (or 1 less if the constant feature is excluded). After the constant feature, if present, there will be `n_sessions` ...
[ "def", "labeledfeatures", "(", "eqdata", ",", "featurefunc", ",", "labelfunc", ")", ":", "_size", "=", "len", "(", "eqdata", ".", "index", ")", "_labels", ",", "_skipatend", "=", "labelfunc", "(", "eqdata", ")", "_features", ",", "_skipatstart", "=", "feat...
Return features and labels for the given equity data. Each row of the features returned contains `2 * n_sessions + 1` columns (or 1 less if the constant feature is excluded). After the constant feature, if present, there will be `n_sessions` columns derived from daily growth of the given price column, ...
[ "Return", "features", "and", "labels", "for", "the", "given", "equity", "data", "." ]
9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41
https://github.com/aisthesis/pynance/blob/9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41/pynance/data/combine.py#L15-L76
train
62,138
aisthesis/pynance
pynance/data/lab.py
growth
def growth(interval, pricecol, eqdata): """ Retrieve growth labels. Parameters -------------- interval : int Number of sessions over which growth is measured. For example, if the value of 32 is passed for `interval`, the data returned will show the growth 32 sessions ahead ...
python
def growth(interval, pricecol, eqdata): """ Retrieve growth labels. Parameters -------------- interval : int Number of sessions over which growth is measured. For example, if the value of 32 is passed for `interval`, the data returned will show the growth 32 sessions ahead ...
[ "def", "growth", "(", "interval", ",", "pricecol", ",", "eqdata", ")", ":", "size", "=", "len", "(", "eqdata", ".", "index", ")", "labeldata", "=", "eqdata", ".", "loc", "[", ":", ",", "pricecol", "]", ".", "values", "[", "interval", ":", "]", "/",...
Retrieve growth labels. Parameters -------------- interval : int Number of sessions over which growth is measured. For example, if the value of 32 is passed for `interval`, the data returned will show the growth 32 sessions ahead for each data point. eqdata : DataFrame ...
[ "Retrieve", "growth", "labels", "." ]
9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41
https://github.com/aisthesis/pynance/blob/9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41/pynance/data/lab.py#L22-L56
train
62,139
aisthesis/pynance
pynance/tech/movave.py
sma
def sma(eqdata, **kwargs): """ simple moving average Parameters ---------- eqdata : DataFrame window : int, optional Lookback period for sma. Defaults to 20. outputcol : str, optional Column to use for output. Defaults to 'SMA'. selection : str, optional Column...
python
def sma(eqdata, **kwargs): """ simple moving average Parameters ---------- eqdata : DataFrame window : int, optional Lookback period for sma. Defaults to 20. outputcol : str, optional Column to use for output. Defaults to 'SMA'. selection : str, optional Column...
[ "def", "sma", "(", "eqdata", ",", "*", "*", "kwargs", ")", ":", "if", "len", "(", "eqdata", ".", "shape", ")", ">", "1", "and", "eqdata", ".", "shape", "[", "1", "]", "!=", "1", ":", "_selection", "=", "kwargs", ".", "get", "(", "'selection'", ...
simple moving average Parameters ---------- eqdata : DataFrame window : int, optional Lookback period for sma. Defaults to 20. outputcol : str, optional Column to use for output. Defaults to 'SMA'. selection : str, optional Column of eqdata on which to calculate sma. If...
[ "simple", "moving", "average" ]
9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41
https://github.com/aisthesis/pynance/blob/9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41/pynance/tech/movave.py#L18-L44
train
62,140
aisthesis/pynance
pynance/tech/movave.py
ema
def ema(eqdata, **kwargs): """ Exponential moving average with the given span. Parameters ---------- eqdata : DataFrame Must have exactly 1 column on which to calculate EMA span : int, optional Span for exponential moving average. Cf. `pandas.stats.moments.ewma <http://...
python
def ema(eqdata, **kwargs): """ Exponential moving average with the given span. Parameters ---------- eqdata : DataFrame Must have exactly 1 column on which to calculate EMA span : int, optional Span for exponential moving average. Cf. `pandas.stats.moments.ewma <http://...
[ "def", "ema", "(", "eqdata", ",", "*", "*", "kwargs", ")", ":", "if", "len", "(", "eqdata", ".", "shape", ")", ">", "1", "and", "eqdata", ".", "shape", "[", "1", "]", "!=", "1", ":", "_selection", "=", "kwargs", ".", "get", "(", "'selection'", ...
Exponential moving average with the given span. Parameters ---------- eqdata : DataFrame Must have exactly 1 column on which to calculate EMA span : int, optional Span for exponential moving average. Cf. `pandas.stats.moments.ewma <http://pandas.pydata.org/pandas-docs/stable/ge...
[ "Exponential", "moving", "average", "with", "the", "given", "span", "." ]
9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41
https://github.com/aisthesis/pynance/blob/9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41/pynance/tech/movave.py#L46-L81
train
62,141
aisthesis/pynance
pynance/tech/movave.py
ema_growth
def ema_growth(eqdata, **kwargs): """ Growth of exponential moving average. Parameters ---------- eqdata : DataFrame span : int, optional Span for exponential moving average. Defaults to 20. outputcol : str, optional. Column to use for output. Defaults to 'EMA Growth'. s...
python
def ema_growth(eqdata, **kwargs): """ Growth of exponential moving average. Parameters ---------- eqdata : DataFrame span : int, optional Span for exponential moving average. Defaults to 20. outputcol : str, optional. Column to use for output. Defaults to 'EMA Growth'. s...
[ "def", "ema_growth", "(", "eqdata", ",", "*", "*", "kwargs", ")", ":", "_growth_outputcol", "=", "kwargs", ".", "get", "(", "'outputcol'", ",", "'EMA Growth'", ")", "_ema_outputcol", "=", "'EMA'", "kwargs", "[", "'outputcol'", "]", "=", "_ema_outputcol", "_e...
Growth of exponential moving average. Parameters ---------- eqdata : DataFrame span : int, optional Span for exponential moving average. Defaults to 20. outputcol : str, optional. Column to use for output. Defaults to 'EMA Growth'. selection : str, optional Column of eqd...
[ "Growth", "of", "exponential", "moving", "average", "." ]
9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41
https://github.com/aisthesis/pynance/blob/9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41/pynance/tech/movave.py#L83-L109
train
62,142
aisthesis/pynance
pynance/tech/movave.py
growth_volatility
def growth_volatility(eqdata, **kwargs): """ Return the volatility of growth. Note that, like :func:`pynance.tech.simple.growth` but in contrast to :func:`volatility`, :func:`growth_volatility` applies directly to a dataframe like that returned by :func:`pynance.data.retrieve.get`, not necess...
python
def growth_volatility(eqdata, **kwargs): """ Return the volatility of growth. Note that, like :func:`pynance.tech.simple.growth` but in contrast to :func:`volatility`, :func:`growth_volatility` applies directly to a dataframe like that returned by :func:`pynance.data.retrieve.get`, not necess...
[ "def", "growth_volatility", "(", "eqdata", ",", "*", "*", "kwargs", ")", ":", "_window", "=", "kwargs", ".", "get", "(", "'window'", ",", "20", ")", "_selection", "=", "kwargs", ".", "get", "(", "'selection'", ",", "'Adj Close'", ")", "_outputcol", "=", ...
Return the volatility of growth. Note that, like :func:`pynance.tech.simple.growth` but in contrast to :func:`volatility`, :func:`growth_volatility` applies directly to a dataframe like that returned by :func:`pynance.data.retrieve.get`, not necessarily to a single-column dataframe. Parameters ...
[ "Return", "the", "volatility", "of", "growth", "." ]
9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41
https://github.com/aisthesis/pynance/blob/9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41/pynance/tech/movave.py#L144-L176
train
62,143
aisthesis/pynance
pynance/tech/movave.py
ratio_to_ave
def ratio_to_ave(window, eqdata, **kwargs): """ Return values expressed as ratios to the average over some number of prior sessions. Parameters ---------- eqdata : DataFrame Must contain a column with name matching `selection`, or, if `selection` is not specified, a column named...
python
def ratio_to_ave(window, eqdata, **kwargs): """ Return values expressed as ratios to the average over some number of prior sessions. Parameters ---------- eqdata : DataFrame Must contain a column with name matching `selection`, or, if `selection` is not specified, a column named...
[ "def", "ratio_to_ave", "(", "window", ",", "eqdata", ",", "*", "*", "kwargs", ")", ":", "_selection", "=", "kwargs", ".", "get", "(", "'selection'", ",", "'Volume'", ")", "_skipstartrows", "=", "kwargs", ".", "get", "(", "'skipstartrows'", ",", "0", ")",...
Return values expressed as ratios to the average over some number of prior sessions. Parameters ---------- eqdata : DataFrame Must contain a column with name matching `selection`, or, if `selection` is not specified, a column named 'Volume' window : int Interval over which t...
[ "Return", "values", "expressed", "as", "ratios", "to", "the", "average", "over", "some", "number", "of", "prior", "sessions", "." ]
9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41
https://github.com/aisthesis/pynance/blob/9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41/pynance/tech/movave.py#L222-L259
train
62,144
aisthesis/pynance
pynance/learn/linreg.py
run
def run(features, labels, regularization=0., constfeat=True): """ Run linear regression on the given data. .. versionadded:: 0.5.0 If a regularization parameter is provided, this function is a simplification and specialization of ridge regression, as implemented in `scikit-learn <http://sc...
python
def run(features, labels, regularization=0., constfeat=True): """ Run linear regression on the given data. .. versionadded:: 0.5.0 If a regularization parameter is provided, this function is a simplification and specialization of ridge regression, as implemented in `scikit-learn <http://sc...
[ "def", "run", "(", "features", ",", "labels", ",", "regularization", "=", "0.", ",", "constfeat", "=", "True", ")", ":", "n_col", "=", "(", "features", ".", "shape", "[", "1", "]", "if", "len", "(", "features", ".", "shape", ")", ">", "1", "else", ...
Run linear regression on the given data. .. versionadded:: 0.5.0 If a regularization parameter is provided, this function is a simplification and specialization of ridge regression, as implemented in `scikit-learn <http://scikit-learn.org/stable/modules/generated/sklearn.linear_model.Ridge.html#sk...
[ "Run", "linear", "regression", "on", "the", "given", "data", "." ]
9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41
https://github.com/aisthesis/pynance/blob/9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41/pynance/learn/linreg.py#L13-L53
train
62,145
aisthesis/pynance
pynance/opt/spread/core.py
Spread.cal
def cal(self, opttype, strike, exp1, exp2): """ Metrics for evaluating a calendar spread. Parameters ------------ opttype : str ('call' or 'put') Type of option on which to collect data. strike : numeric Strike price. exp1 : date or date s...
python
def cal(self, opttype, strike, exp1, exp2): """ Metrics for evaluating a calendar spread. Parameters ------------ opttype : str ('call' or 'put') Type of option on which to collect data. strike : numeric Strike price. exp1 : date or date s...
[ "def", "cal", "(", "self", ",", "opttype", ",", "strike", ",", "exp1", ",", "exp2", ")", ":", "assert", "pd", ".", "Timestamp", "(", "exp1", ")", "<", "pd", ".", "Timestamp", "(", "exp2", ")", "_row1", "=", "_relevant_rows", "(", "self", ".", "data...
Metrics for evaluating a calendar spread. Parameters ------------ opttype : str ('call' or 'put') Type of option on which to collect data. strike : numeric Strike price. exp1 : date or date str (e.g. '2015-01-01') Earlier expiration date. ...
[ "Metrics", "for", "evaluating", "a", "calendar", "spread", "." ]
9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41
https://github.com/aisthesis/pynance/blob/9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41/pynance/opt/spread/core.py#L53-L84
train
62,146
aisthesis/pynance
pynance/common.py
expand
def expand(fn, col, inputtype=pd.DataFrame): """ Wrap a function applying to a single column to make a function applying to a multi-dimensional dataframe or ndarray Parameters ---------- fn : function Function that applies to a series or vector. col : str or int Index of co...
python
def expand(fn, col, inputtype=pd.DataFrame): """ Wrap a function applying to a single column to make a function applying to a multi-dimensional dataframe or ndarray Parameters ---------- fn : function Function that applies to a series or vector. col : str or int Index of co...
[ "def", "expand", "(", "fn", ",", "col", ",", "inputtype", "=", "pd", ".", "DataFrame", ")", ":", "if", "inputtype", "==", "pd", ".", "DataFrame", ":", "if", "isinstance", "(", "col", ",", "int", ")", ":", "def", "_wrapper", "(", "*", "args", ",", ...
Wrap a function applying to a single column to make a function applying to a multi-dimensional dataframe or ndarray Parameters ---------- fn : function Function that applies to a series or vector. col : str or int Index of column to which to apply `fn`. inputtype : class or ty...
[ "Wrap", "a", "function", "applying", "to", "a", "single", "column", "to", "make", "a", "function", "applying", "to", "a", "multi", "-", "dimensional", "dataframe", "or", "ndarray" ]
9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41
https://github.com/aisthesis/pynance/blob/9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41/pynance/common.py#L121-L156
train
62,147
aisthesis/pynance
pynance/common.py
has_na
def has_na(eqdata): """ Return false if `eqdata` contains no missing values. Parameters ---------- eqdata : DataFrame or ndarray Data to check for missing values (NaN, None) Returns ---------- answer : bool False iff `eqdata` contains no missing values. """ if i...
python
def has_na(eqdata): """ Return false if `eqdata` contains no missing values. Parameters ---------- eqdata : DataFrame or ndarray Data to check for missing values (NaN, None) Returns ---------- answer : bool False iff `eqdata` contains no missing values. """ if i...
[ "def", "has_na", "(", "eqdata", ")", ":", "if", "isinstance", "(", "eqdata", ",", "pd", ".", "DataFrame", ")", ":", "_values", "=", "eqdata", ".", "values", "else", ":", "_values", "=", "eqdata", "return", "len", "(", "_values", "[", "pd", ".", "isnu...
Return false if `eqdata` contains no missing values. Parameters ---------- eqdata : DataFrame or ndarray Data to check for missing values (NaN, None) Returns ---------- answer : bool False iff `eqdata` contains no missing values.
[ "Return", "false", "if", "eqdata", "contains", "no", "missing", "values", "." ]
9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41
https://github.com/aisthesis/pynance/blob/9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41/pynance/common.py#L158-L176
train
62,148
aisthesis/pynance
pynance/data/feat.py
add_const
def add_const(features): """ Prepend the constant feature 1 as first feature and return the modified feature set. Parameters ---------- features : ndarray or DataFrame """ content = np.empty((features.shape[0], features.shape[1] + 1), dtype='float64') content[:, 0] = 1. if isins...
python
def add_const(features): """ Prepend the constant feature 1 as first feature and return the modified feature set. Parameters ---------- features : ndarray or DataFrame """ content = np.empty((features.shape[0], features.shape[1] + 1), dtype='float64') content[:, 0] = 1. if isins...
[ "def", "add_const", "(", "features", ")", ":", "content", "=", "np", ".", "empty", "(", "(", "features", ".", "shape", "[", "0", "]", ",", "features", ".", "shape", "[", "1", "]", "+", "1", ")", ",", "dtype", "=", "'float64'", ")", "content", "["...
Prepend the constant feature 1 as first feature and return the modified feature set. Parameters ---------- features : ndarray or DataFrame
[ "Prepend", "the", "constant", "feature", "1", "as", "first", "feature", "and", "return", "the", "modified", "feature", "set", "." ]
9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41
https://github.com/aisthesis/pynance/blob/9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41/pynance/data/feat.py#L26-L42
train
62,149
aisthesis/pynance
pynance/data/feat.py
fromcols
def fromcols(selection, n_sessions, eqdata, **kwargs): """ Generate features from selected columns of a dataframe. Parameters ---------- selection : list or tuple of str Columns to be used as features. n_sessions : int Number of sessions over which to create features. eqda...
python
def fromcols(selection, n_sessions, eqdata, **kwargs): """ Generate features from selected columns of a dataframe. Parameters ---------- selection : list or tuple of str Columns to be used as features. n_sessions : int Number of sessions over which to create features. eqda...
[ "def", "fromcols", "(", "selection", ",", "n_sessions", ",", "eqdata", ",", "*", "*", "kwargs", ")", ":", "_constfeat", "=", "kwargs", ".", "get", "(", "'constfeat'", ",", "True", ")", "_outcols", "=", "[", "'Constant'", "]", "if", "_constfeat", "else", ...
Generate features from selected columns of a dataframe. Parameters ---------- selection : list or tuple of str Columns to be used as features. n_sessions : int Number of sessions over which to create features. eqdata : DataFrame Data from which to generate feature set. Mus...
[ "Generate", "features", "from", "selected", "columns", "of", "a", "dataframe", "." ]
9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41
https://github.com/aisthesis/pynance/blob/9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41/pynance/data/feat.py#L44-L84
train
62,150
aisthesis/pynance
pynance/data/feat.py
fromfuncs
def fromfuncs(funcs, n_sessions, eqdata, **kwargs): """ Generate features using a list of functions to apply to input data Parameters ---------- funcs : list of function Functions to apply to eqdata. Each function is expected to output a dataframe with index identical to a slice of ...
python
def fromfuncs(funcs, n_sessions, eqdata, **kwargs): """ Generate features using a list of functions to apply to input data Parameters ---------- funcs : list of function Functions to apply to eqdata. Each function is expected to output a dataframe with index identical to a slice of ...
[ "def", "fromfuncs", "(", "funcs", ",", "n_sessions", ",", "eqdata", ",", "*", "*", "kwargs", ")", ":", "_skipatstart", "=", "kwargs", ".", "get", "(", "'skipatstart'", ",", "0", ")", "_constfeat", "=", "kwargs", ".", "get", "(", "'constfeat'", ",", "Tr...
Generate features using a list of functions to apply to input data Parameters ---------- funcs : list of function Functions to apply to eqdata. Each function is expected to output a dataframe with index identical to a slice of `eqdata`. The slice must include at least `eqdata.index[...
[ "Generate", "features", "using", "a", "list", "of", "functions", "to", "apply", "to", "input", "data" ]
9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41
https://github.com/aisthesis/pynance/blob/9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41/pynance/data/feat.py#L86-L142
train
62,151
aisthesis/pynance
pynance/tech/simple.py
ln_growth
def ln_growth(eqdata, **kwargs): """ Return the natural log of growth. See also -------- :func:`growth` """ if 'outputcol' not in kwargs: kwargs['outputcol'] = 'LnGrowth' return np.log(growth(eqdata, **kwargs))
python
def ln_growth(eqdata, **kwargs): """ Return the natural log of growth. See also -------- :func:`growth` """ if 'outputcol' not in kwargs: kwargs['outputcol'] = 'LnGrowth' return np.log(growth(eqdata, **kwargs))
[ "def", "ln_growth", "(", "eqdata", ",", "*", "*", "kwargs", ")", ":", "if", "'outputcol'", "not", "in", "kwargs", ":", "kwargs", "[", "'outputcol'", "]", "=", "'LnGrowth'", "return", "np", ".", "log", "(", "growth", "(", "eqdata", ",", "*", "*", "kwa...
Return the natural log of growth. See also -------- :func:`growth`
[ "Return", "the", "natural", "log", "of", "growth", "." ]
9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41
https://github.com/aisthesis/pynance/blob/9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41/pynance/tech/simple.py#L71-L81
train
62,152
aisthesis/pynance
pynance/learn/metrics.py
mse
def mse(predicted, actual): """ Mean squared error of predictions. .. versionadded:: 0.5.0 Parameters ---------- predicted : ndarray Predictions on which to measure error. May contain a single or multiple column but must match `actual` in shape. actual : ndarray ...
python
def mse(predicted, actual): """ Mean squared error of predictions. .. versionadded:: 0.5.0 Parameters ---------- predicted : ndarray Predictions on which to measure error. May contain a single or multiple column but must match `actual` in shape. actual : ndarray ...
[ "def", "mse", "(", "predicted", ",", "actual", ")", ":", "diff", "=", "predicted", "-", "actual", "return", "np", ".", "average", "(", "diff", "*", "diff", ",", "axis", "=", "0", ")" ]
Mean squared error of predictions. .. versionadded:: 0.5.0 Parameters ---------- predicted : ndarray Predictions on which to measure error. May contain a single or multiple column but must match `actual` in shape. actual : ndarray Actual values against which to mea...
[ "Mean", "squared", "error", "of", "predictions", "." ]
9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41
https://github.com/aisthesis/pynance/blob/9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41/pynance/learn/metrics.py#L13-L36
train
62,153
aisthesis/pynance
pynance/opt/covcall.py
get
def get(eqprice, callprice, strike, shares=1, buycomm=0., excomm=0., dividend=0.): """ Metrics for covered calls. Parameters ---------- eqprice : float Price at which stock is purchased. callprice : float Price for which call is sold. strike : float Strike price of c...
python
def get(eqprice, callprice, strike, shares=1, buycomm=0., excomm=0., dividend=0.): """ Metrics for covered calls. Parameters ---------- eqprice : float Price at which stock is purchased. callprice : float Price for which call is sold. strike : float Strike price of c...
[ "def", "get", "(", "eqprice", ",", "callprice", ",", "strike", ",", "shares", "=", "1", ",", "buycomm", "=", "0.", ",", "excomm", "=", "0.", ",", "dividend", "=", "0.", ")", ":", "_index", "=", "[", "'Eq Cost'", ",", "'Option Premium'", ",", "'Commis...
Metrics for covered calls. Parameters ---------- eqprice : float Price at which stock is purchased. callprice : float Price for which call is sold. strike : float Strike price of call sold. shares : int, optional Number of shares of stock. Defaults to 1. buyc...
[ "Metrics", "for", "covered", "calls", "." ]
9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41
https://github.com/aisthesis/pynance/blob/9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41/pynance/opt/covcall.py#L17-L68
train
62,154
aisthesis/pynance
pynance/dateutils.py
is_bday
def is_bday(date, bday=None): """ Return true iff the given date is a business day. Parameters ---------- date : :class:`pandas.Timestamp` Any value that can be converted to a pandas Timestamp--e.g., '2012-05-01', dt.datetime(2012, 5, 1, 3) bday : :class:`pandas.tseries.offsets...
python
def is_bday(date, bday=None): """ Return true iff the given date is a business day. Parameters ---------- date : :class:`pandas.Timestamp` Any value that can be converted to a pandas Timestamp--e.g., '2012-05-01', dt.datetime(2012, 5, 1, 3) bday : :class:`pandas.tseries.offsets...
[ "def", "is_bday", "(", "date", ",", "bday", "=", "None", ")", ":", "_date", "=", "Timestamp", "(", "date", ")", "if", "bday", "is", "None", ":", "bday", "=", "CustomBusinessDay", "(", "calendar", "=", "USFederalHolidayCalendar", "(", ")", ")", "return", ...
Return true iff the given date is a business day. Parameters ---------- date : :class:`pandas.Timestamp` Any value that can be converted to a pandas Timestamp--e.g., '2012-05-01', dt.datetime(2012, 5, 1, 3) bday : :class:`pandas.tseries.offsets.CustomBusinessDay` Defaults to `C...
[ "Return", "true", "iff", "the", "given", "date", "is", "a", "business", "day", "." ]
9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41
https://github.com/aisthesis/pynance/blob/9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41/pynance/dateutils.py#L19-L45
train
62,155
aisthesis/pynance
pynance/data/compare.py
compare
def compare(eq_dfs, columns=None, selection='Adj Close'): """ Get the relative performance of multiple equities. .. versionadded:: 0.5.0 Parameters ---------- eq_dfs : list or tuple of DataFrame Performance data for multiple equities over a consistent time frame. columns : ...
python
def compare(eq_dfs, columns=None, selection='Adj Close'): """ Get the relative performance of multiple equities. .. versionadded:: 0.5.0 Parameters ---------- eq_dfs : list or tuple of DataFrame Performance data for multiple equities over a consistent time frame. columns : ...
[ "def", "compare", "(", "eq_dfs", ",", "columns", "=", "None", ",", "selection", "=", "'Adj Close'", ")", ":", "content", "=", "np", ".", "empty", "(", "(", "eq_dfs", "[", "0", "]", ".", "shape", "[", "0", "]", ",", "len", "(", "eq_dfs", ")", ")",...
Get the relative performance of multiple equities. .. versionadded:: 0.5.0 Parameters ---------- eq_dfs : list or tuple of DataFrame Performance data for multiple equities over a consistent time frame. columns : iterable of str, default None Labels to use for the columns of...
[ "Get", "the", "relative", "performance", "of", "multiple", "equities", "." ]
9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41
https://github.com/aisthesis/pynance/blob/9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41/pynance/data/compare.py#L14-L62
train
62,156
aisthesis/pynance
pynance/opt/spread/diag.py
Diag.diagbtrfly
def diagbtrfly(self, lowstrike, midstrike, highstrike, expiry1, expiry2): """ Metrics for evaluating a diagonal butterfly spread. Parameters ------------ opttype : str ('call' or 'put') Type of option on which to collect data. lowstrike : numeric ...
python
def diagbtrfly(self, lowstrike, midstrike, highstrike, expiry1, expiry2): """ Metrics for evaluating a diagonal butterfly spread. Parameters ------------ opttype : str ('call' or 'put') Type of option on which to collect data. lowstrike : numeric ...
[ "def", "diagbtrfly", "(", "self", ",", "lowstrike", ",", "midstrike", ",", "highstrike", ",", "expiry1", ",", "expiry2", ")", ":", "assert", "lowstrike", "<", "midstrike", "assert", "midstrike", "<", "highstrike", "assert", "pd", ".", "Timestamp", "(", "expi...
Metrics for evaluating a diagonal butterfly spread. Parameters ------------ opttype : str ('call' or 'put') Type of option on which to collect data. lowstrike : numeric Lower strike price. To be used for far put. midstrike : numeric Middle str...
[ "Metrics", "for", "evaluating", "a", "diagonal", "butterfly", "spread", "." ]
9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41
https://github.com/aisthesis/pynance/blob/9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41/pynance/opt/spread/diag.py#L113-L173
train
62,157
aisthesis/pynance
pynance/opt/core.py
Options.info
def info(self): """ Show expiration dates, equity price, quote time. Returns ------- self : :class:`~pynance.opt.core.Options` Returns a reference to the calling object to allow chaining. expiries : :class:`pandas.tseries.index.DatetimeIndex` ...
python
def info(self): """ Show expiration dates, equity price, quote time. Returns ------- self : :class:`~pynance.opt.core.Options` Returns a reference to the calling object to allow chaining. expiries : :class:`pandas.tseries.index.DatetimeIndex` ...
[ "def", "info", "(", "self", ")", ":", "print", "(", "\"Expirations:\"", ")", "_i", "=", "0", "for", "_datetime", "in", "self", ".", "data", ".", "index", ".", "levels", "[", "1", "]", ".", "to_pydatetime", "(", ")", ":", "print", "(", "\"{:2d} {}\"",...
Show expiration dates, equity price, quote time. Returns ------- self : :class:`~pynance.opt.core.Options` Returns a reference to the calling object to allow chaining. expiries : :class:`pandas.tseries.index.DatetimeIndex` Examples -------- ...
[ "Show", "expiration", "dates", "equity", "price", "quote", "time", "." ]
9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41
https://github.com/aisthesis/pynance/blob/9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41/pynance/opt/core.py#L69-L96
train
62,158
aisthesis/pynance
pynance/opt/core.py
Options.tolist
def tolist(self): """ Return the array as a list of rows. Each row is a `dict` of values. Facilitates inserting data into a database. .. versionadded:: 0.3.1 Returns ------- quotes : list A list in which each entry is a dictionary representing ...
python
def tolist(self): """ Return the array as a list of rows. Each row is a `dict` of values. Facilitates inserting data into a database. .. versionadded:: 0.3.1 Returns ------- quotes : list A list in which each entry is a dictionary representing ...
[ "def", "tolist", "(", "self", ")", ":", "return", "[", "_todict", "(", "key", ",", "self", ".", "data", ".", "loc", "[", "key", ",", ":", "]", ")", "for", "key", "in", "self", ".", "data", ".", "index", "]" ]
Return the array as a list of rows. Each row is a `dict` of values. Facilitates inserting data into a database. .. versionadded:: 0.3.1 Returns ------- quotes : list A list in which each entry is a dictionary representing a single options quote.
[ "Return", "the", "array", "as", "a", "list", "of", "rows", "." ]
9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41
https://github.com/aisthesis/pynance/blob/9eb0d78b60fe2a324ed328d026fedb6dbe8f7f41/pynance/opt/core.py#L119-L133
train
62,159
stephrdev/django-userprofiles
userprofiles/forms.py
RegistrationForm._generate_username
def _generate_username(self): """ Generate a unique username """ while True: # Generate a UUID username, removing dashes and the last 2 chars # to make it fit into the 30 char User.username field. Gracefully # handle any unlikely, but possible duplicate usernames. ...
python
def _generate_username(self): """ Generate a unique username """ while True: # Generate a UUID username, removing dashes and the last 2 chars # to make it fit into the 30 char User.username field. Gracefully # handle any unlikely, but possible duplicate usernames. ...
[ "def", "_generate_username", "(", "self", ")", ":", "while", "True", ":", "# Generate a UUID username, removing dashes and the last 2 chars", "# to make it fit into the 30 char User.username field. Gracefully", "# handle any unlikely, but possible duplicate usernames.", "username", "=", ...
Generate a unique username
[ "Generate", "a", "unique", "username" ]
79227566abe53ee9b834709b35ae276b40114c0b
https://github.com/stephrdev/django-userprofiles/blob/79227566abe53ee9b834709b35ae276b40114c0b/userprofiles/forms.py#L44-L57
train
62,160
vijaykatam/django-cache-manager
django_cache_manager/models.py
update_model_cache
def update_model_cache(table_name): """ Updates model cache by generating a new key for the model """ model_cache_info = ModelCacheInfo(table_name, uuid.uuid4().hex) model_cache_backend.share_model_cache_info(model_cache_info)
python
def update_model_cache(table_name): """ Updates model cache by generating a new key for the model """ model_cache_info = ModelCacheInfo(table_name, uuid.uuid4().hex) model_cache_backend.share_model_cache_info(model_cache_info)
[ "def", "update_model_cache", "(", "table_name", ")", ":", "model_cache_info", "=", "ModelCacheInfo", "(", "table_name", ",", "uuid", ".", "uuid4", "(", ")", ".", "hex", ")", "model_cache_backend", ".", "share_model_cache_info", "(", "model_cache_info", ")" ]
Updates model cache by generating a new key for the model
[ "Updates", "model", "cache", "by", "generating", "a", "new", "key", "for", "the", "model" ]
05142c44eb349d3f24f962592945888d9d367375
https://github.com/vijaykatam/django-cache-manager/blob/05142c44eb349d3f24f962592945888d9d367375/django_cache_manager/models.py#L21-L26
train
62,161
vijaykatam/django-cache-manager
django_cache_manager/models.py
invalidate_model_cache
def invalidate_model_cache(sender, instance, **kwargs): """ Signal receiver for models to invalidate model cache of sender and related models. Model cache is invalidated by generating new key for each model. Parameters ~~~~~~~~~~ sender The model class instance The actual in...
python
def invalidate_model_cache(sender, instance, **kwargs): """ Signal receiver for models to invalidate model cache of sender and related models. Model cache is invalidated by generating new key for each model. Parameters ~~~~~~~~~~ sender The model class instance The actual in...
[ "def", "invalidate_model_cache", "(", "sender", ",", "instance", ",", "*", "*", "kwargs", ")", ":", "logger", ".", "debug", "(", "'Received post_save/post_delete signal from sender {0}'", ".", "format", "(", "sender", ")", ")", "if", "django", ".", "VERSION", ">...
Signal receiver for models to invalidate model cache of sender and related models. Model cache is invalidated by generating new key for each model. Parameters ~~~~~~~~~~ sender The model class instance The actual instance being saved.
[ "Signal", "receiver", "for", "models", "to", "invalidate", "model", "cache", "of", "sender", "and", "related", "models", ".", "Model", "cache", "is", "invalidated", "by", "generating", "new", "key", "for", "each", "model", "." ]
05142c44eb349d3f24f962592945888d9d367375
https://github.com/vijaykatam/django-cache-manager/blob/05142c44eb349d3f24f962592945888d9d367375/django_cache_manager/models.py#L29-L55
train
62,162
vijaykatam/django-cache-manager
django_cache_manager/models.py
invalidate_m2m_cache
def invalidate_m2m_cache(sender, instance, model, **kwargs): """ Signal receiver for models to invalidate model cache for many-to-many relationship. Parameters ~~~~~~~~~~ sender The model class instance The instance whose many-to-many relation is updated. model The c...
python
def invalidate_m2m_cache(sender, instance, model, **kwargs): """ Signal receiver for models to invalidate model cache for many-to-many relationship. Parameters ~~~~~~~~~~ sender The model class instance The instance whose many-to-many relation is updated. model The c...
[ "def", "invalidate_m2m_cache", "(", "sender", ",", "instance", ",", "model", ",", "*", "*", "kwargs", ")", ":", "logger", ".", "debug", "(", "'Received m2m_changed signals from sender {0}'", ".", "format", "(", "sender", ")", ")", "update_model_cache", "(", "ins...
Signal receiver for models to invalidate model cache for many-to-many relationship. Parameters ~~~~~~~~~~ sender The model class instance The instance whose many-to-many relation is updated. model The class of the objects that are added to, removed from or cleared from the r...
[ "Signal", "receiver", "for", "models", "to", "invalidate", "model", "cache", "for", "many", "-", "to", "-", "many", "relationship", "." ]
05142c44eb349d3f24f962592945888d9d367375
https://github.com/vijaykatam/django-cache-manager/blob/05142c44eb349d3f24f962592945888d9d367375/django_cache_manager/models.py#L57-L72
train
62,163
vijaykatam/django-cache-manager
django_cache_manager/mixins.py
CacheKeyMixin.generate_key
def generate_key(self): """ Generate cache key for the current query. If a new key is created for the model it is then shared with other consumers. """ sql = self.sql() key, created = self.get_or_create_model_key() if created: db_table = self.model._me...
python
def generate_key(self): """ Generate cache key for the current query. If a new key is created for the model it is then shared with other consumers. """ sql = self.sql() key, created = self.get_or_create_model_key() if created: db_table = self.model._me...
[ "def", "generate_key", "(", "self", ")", ":", "sql", "=", "self", ".", "sql", "(", ")", "key", ",", "created", "=", "self", ".", "get_or_create_model_key", "(", ")", "if", "created", ":", "db_table", "=", "self", ".", "model", ".", "_meta", ".", "db_...
Generate cache key for the current query. If a new key is created for the model it is then shared with other consumers.
[ "Generate", "cache", "key", "for", "the", "current", "query", ".", "If", "a", "new", "key", "is", "created", "for", "the", "model", "it", "is", "then", "shared", "with", "other", "consumers", "." ]
05142c44eb349d3f24f962592945888d9d367375
https://github.com/vijaykatam/django-cache-manager/blob/05142c44eb349d3f24f962592945888d9d367375/django_cache_manager/mixins.py#L23-L39
train
62,164
vijaykatam/django-cache-manager
django_cache_manager/mixins.py
CacheKeyMixin.sql
def sql(self): """ Get sql for the current query. """ clone = self.query.clone() sql, params = clone.get_compiler(using=self.db).as_sql() return sql % params
python
def sql(self): """ Get sql for the current query. """ clone = self.query.clone() sql, params = clone.get_compiler(using=self.db).as_sql() return sql % params
[ "def", "sql", "(", "self", ")", ":", "clone", "=", "self", ".", "query", ".", "clone", "(", ")", "sql", ",", "params", "=", "clone", ".", "get_compiler", "(", "using", "=", "self", ".", "db", ")", ".", "as_sql", "(", ")", "return", "sql", "%", ...
Get sql for the current query.
[ "Get", "sql", "for", "the", "current", "query", "." ]
05142c44eb349d3f24f962592945888d9d367375
https://github.com/vijaykatam/django-cache-manager/blob/05142c44eb349d3f24f962592945888d9d367375/django_cache_manager/mixins.py#L41-L47
train
62,165
vijaykatam/django-cache-manager
django_cache_manager/mixins.py
CacheKeyMixin.get_or_create_model_key
def get_or_create_model_key(self): """ Get or create key for the model. Returns ~~~~~~~ (model_key, boolean) tuple """ model_cache_info = model_cache_backend.retrieve_model_cache_info(self.model._meta.db_table) if not model_cache_info: return...
python
def get_or_create_model_key(self): """ Get or create key for the model. Returns ~~~~~~~ (model_key, boolean) tuple """ model_cache_info = model_cache_backend.retrieve_model_cache_info(self.model._meta.db_table) if not model_cache_info: return...
[ "def", "get_or_create_model_key", "(", "self", ")", ":", "model_cache_info", "=", "model_cache_backend", ".", "retrieve_model_cache_info", "(", "self", ".", "model", ".", "_meta", ".", "db_table", ")", "if", "not", "model_cache_info", ":", "return", "uuid", ".", ...
Get or create key for the model. Returns ~~~~~~~ (model_key, boolean) tuple
[ "Get", "or", "create", "key", "for", "the", "model", "." ]
05142c44eb349d3f24f962592945888d9d367375
https://github.com/vijaykatam/django-cache-manager/blob/05142c44eb349d3f24f962592945888d9d367375/django_cache_manager/mixins.py#L49-L61
train
62,166
vijaykatam/django-cache-manager
django_cache_manager/mixins.py
CacheInvalidateMixin.invalidate_model_cache
def invalidate_model_cache(self): """ Invalidate model cache by generating new key for the model. """ logger.info('Invalidating cache for table {0}'.format(self.model._meta.db_table)) if django.VERSION >= (1, 8): related_tables = set( [f.related_model....
python
def invalidate_model_cache(self): """ Invalidate model cache by generating new key for the model. """ logger.info('Invalidating cache for table {0}'.format(self.model._meta.db_table)) if django.VERSION >= (1, 8): related_tables = set( [f.related_model....
[ "def", "invalidate_model_cache", "(", "self", ")", ":", "logger", ".", "info", "(", "'Invalidating cache for table {0}'", ".", "format", "(", "self", ".", "model", ".", "_meta", ".", "db_table", ")", ")", "if", "django", ".", "VERSION", ">=", "(", "1", ","...
Invalidate model cache by generating new key for the model.
[ "Invalidate", "model", "cache", "by", "generating", "new", "key", "for", "the", "model", "." ]
05142c44eb349d3f24f962592945888d9d367375
https://github.com/vijaykatam/django-cache-manager/blob/05142c44eb349d3f24f962592945888d9d367375/django_cache_manager/mixins.py#L66-L84
train
62,167
vijaykatam/django-cache-manager
django_cache_manager/mixins.py
CacheBackendMixin.cache_backend
def cache_backend(self): """ Get the cache backend Returns ~~~~~~~ Django cache backend """ if not hasattr(self, '_cache_backend'): if hasattr(django.core.cache, 'caches'): self._cache_backend = django.core.cache.caches[_cache_name] ...
python
def cache_backend(self): """ Get the cache backend Returns ~~~~~~~ Django cache backend """ if not hasattr(self, '_cache_backend'): if hasattr(django.core.cache, 'caches'): self._cache_backend = django.core.cache.caches[_cache_name] ...
[ "def", "cache_backend", "(", "self", ")", ":", "if", "not", "hasattr", "(", "self", ",", "'_cache_backend'", ")", ":", "if", "hasattr", "(", "django", ".", "core", ".", "cache", ",", "'caches'", ")", ":", "self", ".", "_cache_backend", "=", "django", "...
Get the cache backend Returns ~~~~~~~ Django cache backend
[ "Get", "the", "cache", "backend" ]
05142c44eb349d3f24f962592945888d9d367375
https://github.com/vijaykatam/django-cache-manager/blob/05142c44eb349d3f24f962592945888d9d367375/django_cache_manager/mixins.py#L90-L105
train
62,168
UDST/orca
orca/server/server.py
import_file
def import_file(filename): """ Import a file that will trigger the population of Orca. Parameters ---------- filename : str """ pathname, filename = os.path.split(filename) modname = re.match( r'(?P<modname>\w+)\.py', filename).group('modname') file, path, desc = imp.find_m...
python
def import_file(filename): """ Import a file that will trigger the population of Orca. Parameters ---------- filename : str """ pathname, filename = os.path.split(filename) modname = re.match( r'(?P<modname>\w+)\.py', filename).group('modname') file, path, desc = imp.find_m...
[ "def", "import_file", "(", "filename", ")", ":", "pathname", ",", "filename", "=", "os", ".", "path", ".", "split", "(", "filename", ")", "modname", "=", "re", ".", "match", "(", "r'(?P<modname>\\w+)\\.py'", ",", "filename", ")", ".", "group", "(", "'mod...
Import a file that will trigger the population of Orca. Parameters ---------- filename : str
[ "Import", "a", "file", "that", "will", "trigger", "the", "population", "of", "Orca", "." ]
07b34aeef13cc87c966b2e30cbe7e76cc9d3622c
https://github.com/UDST/orca/blob/07b34aeef13cc87c966b2e30cbe7e76cc9d3622c/orca/server/server.py#L27-L44
train
62,169
UDST/orca
orca/server/server.py
check_is_table
def check_is_table(func): """ Decorator that will check whether the "table_name" keyword argument to the wrapped function matches a registered Orca table. """ @wraps(func) def wrapper(**kwargs): if not orca.is_table(kwargs['table_name']): abort(404) return func(**kwa...
python
def check_is_table(func): """ Decorator that will check whether the "table_name" keyword argument to the wrapped function matches a registered Orca table. """ @wraps(func) def wrapper(**kwargs): if not orca.is_table(kwargs['table_name']): abort(404) return func(**kwa...
[ "def", "check_is_table", "(", "func", ")", ":", "@", "wraps", "(", "func", ")", "def", "wrapper", "(", "*", "*", "kwargs", ")", ":", "if", "not", "orca", ".", "is_table", "(", "kwargs", "[", "'table_name'", "]", ")", ":", "abort", "(", "404", ")", ...
Decorator that will check whether the "table_name" keyword argument to the wrapped function matches a registered Orca table.
[ "Decorator", "that", "will", "check", "whether", "the", "table_name", "keyword", "argument", "to", "the", "wrapped", "function", "matches", "a", "registered", "Orca", "table", "." ]
07b34aeef13cc87c966b2e30cbe7e76cc9d3622c
https://github.com/UDST/orca/blob/07b34aeef13cc87c966b2e30cbe7e76cc9d3622c/orca/server/server.py#L47-L58
train
62,170
UDST/orca
orca/server/server.py
check_is_column
def check_is_column(func): """ Decorator that will check whether the "table_name" and "col_name" keyword arguments to the wrapped function match a registered Orca table and column. """ @wraps(func) def wrapper(**kwargs): table_name = kwargs['table_name'] col_name = kwargs['c...
python
def check_is_column(func): """ Decorator that will check whether the "table_name" and "col_name" keyword arguments to the wrapped function match a registered Orca table and column. """ @wraps(func) def wrapper(**kwargs): table_name = kwargs['table_name'] col_name = kwargs['c...
[ "def", "check_is_column", "(", "func", ")", ":", "@", "wraps", "(", "func", ")", "def", "wrapper", "(", "*", "*", "kwargs", ")", ":", "table_name", "=", "kwargs", "[", "'table_name'", "]", "col_name", "=", "kwargs", "[", "'col_name'", "]", "if", "not",...
Decorator that will check whether the "table_name" and "col_name" keyword arguments to the wrapped function match a registered Orca table and column.
[ "Decorator", "that", "will", "check", "whether", "the", "table_name", "and", "col_name", "keyword", "arguments", "to", "the", "wrapped", "function", "match", "a", "registered", "Orca", "table", "and", "column", "." ]
07b34aeef13cc87c966b2e30cbe7e76cc9d3622c
https://github.com/UDST/orca/blob/07b34aeef13cc87c966b2e30cbe7e76cc9d3622c/orca/server/server.py#L61-L78
train
62,171
UDST/orca
orca/server/server.py
check_is_injectable
def check_is_injectable(func): """ Decorator that will check whether the "inj_name" keyword argument to the wrapped function matches a registered Orca injectable. """ @wraps(func) def wrapper(**kwargs): name = kwargs['inj_name'] if not orca.is_injectable(name): abort...
python
def check_is_injectable(func): """ Decorator that will check whether the "inj_name" keyword argument to the wrapped function matches a registered Orca injectable. """ @wraps(func) def wrapper(**kwargs): name = kwargs['inj_name'] if not orca.is_injectable(name): abort...
[ "def", "check_is_injectable", "(", "func", ")", ":", "@", "wraps", "(", "func", ")", "def", "wrapper", "(", "*", "*", "kwargs", ")", ":", "name", "=", "kwargs", "[", "'inj_name'", "]", "if", "not", "orca", ".", "is_injectable", "(", "name", ")", ":",...
Decorator that will check whether the "inj_name" keyword argument to the wrapped function matches a registered Orca injectable.
[ "Decorator", "that", "will", "check", "whether", "the", "inj_name", "keyword", "argument", "to", "the", "wrapped", "function", "matches", "a", "registered", "Orca", "injectable", "." ]
07b34aeef13cc87c966b2e30cbe7e76cc9d3622c
https://github.com/UDST/orca/blob/07b34aeef13cc87c966b2e30cbe7e76cc9d3622c/orca/server/server.py#L81-L93
train
62,172
UDST/orca
orca/server/server.py
schema
def schema(): """ All tables, columns, steps, injectables and broadcasts registered with Orca. Includes local columns on tables. """ tables = orca.list_tables() cols = {t: orca.get_table(t).columns for t in tables} steps = orca.list_steps() injectables = orca.list_injectables() broa...
python
def schema(): """ All tables, columns, steps, injectables and broadcasts registered with Orca. Includes local columns on tables. """ tables = orca.list_tables() cols = {t: orca.get_table(t).columns for t in tables} steps = orca.list_steps() injectables = orca.list_injectables() broa...
[ "def", "schema", "(", ")", ":", "tables", "=", "orca", ".", "list_tables", "(", ")", "cols", "=", "{", "t", ":", "orca", ".", "get_table", "(", "t", ")", ".", "columns", "for", "t", "in", "tables", "}", "steps", "=", "orca", ".", "list_steps", "(...
All tables, columns, steps, injectables and broadcasts registered with Orca. Includes local columns on tables.
[ "All", "tables", "columns", "steps", "injectables", "and", "broadcasts", "registered", "with", "Orca", ".", "Includes", "local", "columns", "on", "tables", "." ]
07b34aeef13cc87c966b2e30cbe7e76cc9d3622c
https://github.com/UDST/orca/blob/07b34aeef13cc87c966b2e30cbe7e76cc9d3622c/orca/server/server.py#L97-L111
train
62,173
UDST/orca
orca/server/server.py
table_preview
def table_preview(table_name): """ Returns the first five rows of a table as JSON. Inlcudes all columns. Uses Pandas' "split" JSON format. """ preview = orca.get_table(table_name).to_frame().head() return ( preview.to_json(orient='split', date_format='iso'), 200, {'Conte...
python
def table_preview(table_name): """ Returns the first five rows of a table as JSON. Inlcudes all columns. Uses Pandas' "split" JSON format. """ preview = orca.get_table(table_name).to_frame().head() return ( preview.to_json(orient='split', date_format='iso'), 200, {'Conte...
[ "def", "table_preview", "(", "table_name", ")", ":", "preview", "=", "orca", ".", "get_table", "(", "table_name", ")", ".", "to_frame", "(", ")", ".", "head", "(", ")", "return", "(", "preview", ".", "to_json", "(", "orient", "=", "'split'", ",", "date...
Returns the first five rows of a table as JSON. Inlcudes all columns. Uses Pandas' "split" JSON format.
[ "Returns", "the", "first", "five", "rows", "of", "a", "table", "as", "JSON", ".", "Inlcudes", "all", "columns", ".", "Uses", "Pandas", "split", "JSON", "format", "." ]
07b34aeef13cc87c966b2e30cbe7e76cc9d3622c
https://github.com/UDST/orca/blob/07b34aeef13cc87c966b2e30cbe7e76cc9d3622c/orca/server/server.py#L140-L150
train
62,174
UDST/orca
orca/server/server.py
table_describe
def table_describe(table_name): """ Return summary statistics of a table as JSON. Includes all columns. Uses Pandas' "split" JSON format. """ desc = orca.get_table(table_name).to_frame().describe() return ( desc.to_json(orient='split', date_format='iso'), 200, {'Content-...
python
def table_describe(table_name): """ Return summary statistics of a table as JSON. Includes all columns. Uses Pandas' "split" JSON format. """ desc = orca.get_table(table_name).to_frame().describe() return ( desc.to_json(orient='split', date_format='iso'), 200, {'Content-...
[ "def", "table_describe", "(", "table_name", ")", ":", "desc", "=", "orca", ".", "get_table", "(", "table_name", ")", ".", "to_frame", "(", ")", ".", "describe", "(", ")", "return", "(", "desc", ".", "to_json", "(", "orient", "=", "'split'", ",", "date_...
Return summary statistics of a table as JSON. Includes all columns. Uses Pandas' "split" JSON format.
[ "Return", "summary", "statistics", "of", "a", "table", "as", "JSON", ".", "Includes", "all", "columns", ".", "Uses", "Pandas", "split", "JSON", "format", "." ]
07b34aeef13cc87c966b2e30cbe7e76cc9d3622c
https://github.com/UDST/orca/blob/07b34aeef13cc87c966b2e30cbe7e76cc9d3622c/orca/server/server.py#L155-L165
train
62,175
UDST/orca
orca/server/server.py
table_definition
def table_definition(table_name): """ Get the source of a table function. If a table is registered DataFrame and not a function then all that is returned is {'type': 'dataframe'}. If the table is a registered function then the JSON returned has keys "type", "filename", "lineno", "text", and "h...
python
def table_definition(table_name): """ Get the source of a table function. If a table is registered DataFrame and not a function then all that is returned is {'type': 'dataframe'}. If the table is a registered function then the JSON returned has keys "type", "filename", "lineno", "text", and "h...
[ "def", "table_definition", "(", "table_name", ")", ":", "if", "orca", ".", "table_type", "(", "table_name", ")", "==", "'dataframe'", ":", "return", "jsonify", "(", "type", "=", "'dataframe'", ")", "filename", ",", "lineno", ",", "source", "=", "orca", "."...
Get the source of a table function. If a table is registered DataFrame and not a function then all that is returned is {'type': 'dataframe'}. If the table is a registered function then the JSON returned has keys "type", "filename", "lineno", "text", and "html". "text" is the raw text of the functi...
[ "Get", "the", "source", "of", "a", "table", "function", "." ]
07b34aeef13cc87c966b2e30cbe7e76cc9d3622c
https://github.com/UDST/orca/blob/07b34aeef13cc87c966b2e30cbe7e76cc9d3622c/orca/server/server.py#L170-L192
train
62,176
UDST/orca
orca/server/server.py
table_groupbyagg
def table_groupbyagg(table_name): """ Perform a groupby on a table and return an aggregation on a single column. This depends on some request parameters in the URL. "column" and "agg" must always be present, and one of "by" or "level" must be present. "column" is the table column on which aggregati...
python
def table_groupbyagg(table_name): """ Perform a groupby on a table and return an aggregation on a single column. This depends on some request parameters in the URL. "column" and "agg" must always be present, and one of "by" or "level" must be present. "column" is the table column on which aggregati...
[ "def", "table_groupbyagg", "(", "table_name", ")", ":", "table", "=", "orca", ".", "get_table", "(", "table_name", ")", "# column to aggregate", "column", "=", "request", ".", "args", ".", "get", "(", "'column'", ",", "None", ")", "if", "not", "column", "o...
Perform a groupby on a table and return an aggregation on a single column. This depends on some request parameters in the URL. "column" and "agg" must always be present, and one of "by" or "level" must be present. "column" is the table column on which aggregation will be performed, "agg" is the aggrega...
[ "Perform", "a", "groupby", "on", "a", "table", "and", "return", "an", "aggregation", "on", "a", "single", "column", "." ]
07b34aeef13cc87c966b2e30cbe7e76cc9d3622c
https://github.com/UDST/orca/blob/07b34aeef13cc87c966b2e30cbe7e76cc9d3622c/orca/server/server.py#L208-L259
train
62,177
UDST/orca
orca/server/server.py
column_preview
def column_preview(table_name, col_name): """ Return the first ten elements of a column as JSON in Pandas' "split" format. """ col = orca.get_table(table_name).get_column(col_name).head(10) return ( col.to_json(orient='split', date_format='iso'), 200, {'Content-Type': '...
python
def column_preview(table_name, col_name): """ Return the first ten elements of a column as JSON in Pandas' "split" format. """ col = orca.get_table(table_name).get_column(col_name).head(10) return ( col.to_json(orient='split', date_format='iso'), 200, {'Content-Type': '...
[ "def", "column_preview", "(", "table_name", ",", "col_name", ")", ":", "col", "=", "orca", ".", "get_table", "(", "table_name", ")", ".", "get_column", "(", "col_name", ")", ".", "head", "(", "10", ")", "return", "(", "col", ".", "to_json", "(", "orien...
Return the first ten elements of a column as JSON in Pandas' "split" format.
[ "Return", "the", "first", "ten", "elements", "of", "a", "column", "as", "JSON", "in", "Pandas", "split", "format", "." ]
07b34aeef13cc87c966b2e30cbe7e76cc9d3622c
https://github.com/UDST/orca/blob/07b34aeef13cc87c966b2e30cbe7e76cc9d3622c/orca/server/server.py#L274-L285
train
62,178
UDST/orca
orca/server/server.py
column_definition
def column_definition(table_name, col_name): """ Get the source of a column function. If a column is a registered Series and not a function then all that is returned is {'type': 'series'}. If the column is a registered function then the JSON returned has keys "type", "filename", "lineno", "tex...
python
def column_definition(table_name, col_name): """ Get the source of a column function. If a column is a registered Series and not a function then all that is returned is {'type': 'series'}. If the column is a registered function then the JSON returned has keys "type", "filename", "lineno", "tex...
[ "def", "column_definition", "(", "table_name", ",", "col_name", ")", ":", "col_type", "=", "orca", ".", "get_table", "(", "table_name", ")", ".", "column_type", "(", "col_name", ")", "if", "col_type", "!=", "'function'", ":", "return", "jsonify", "(", "type"...
Get the source of a column function. If a column is a registered Series and not a function then all that is returned is {'type': 'series'}. If the column is a registered function then the JSON returned has keys "type", "filename", "lineno", "text", and "html". "text" is the raw text of the functio...
[ "Get", "the", "source", "of", "a", "column", "function", "." ]
07b34aeef13cc87c966b2e30cbe7e76cc9d3622c
https://github.com/UDST/orca/blob/07b34aeef13cc87c966b2e30cbe7e76cc9d3622c/orca/server/server.py#L290-L314
train
62,179
UDST/orca
orca/server/server.py
column_describe
def column_describe(table_name, col_name): """ Return summary statistics of a column as JSON. Uses Pandas' "split" JSON format. """ col_desc = orca.get_table(table_name).get_column(col_name).describe() return ( col_desc.to_json(orient='split'), 200, {'Content-Type': 'app...
python
def column_describe(table_name, col_name): """ Return summary statistics of a column as JSON. Uses Pandas' "split" JSON format. """ col_desc = orca.get_table(table_name).get_column(col_name).describe() return ( col_desc.to_json(orient='split'), 200, {'Content-Type': 'app...
[ "def", "column_describe", "(", "table_name", ",", "col_name", ")", ":", "col_desc", "=", "orca", ".", "get_table", "(", "table_name", ")", ".", "get_column", "(", "col_name", ")", ".", "describe", "(", ")", "return", "(", "col_desc", ".", "to_json", "(", ...
Return summary statistics of a column as JSON. Uses Pandas' "split" JSON format.
[ "Return", "summary", "statistics", "of", "a", "column", "as", "JSON", ".", "Uses", "Pandas", "split", "JSON", "format", "." ]
07b34aeef13cc87c966b2e30cbe7e76cc9d3622c
https://github.com/UDST/orca/blob/07b34aeef13cc87c966b2e30cbe7e76cc9d3622c/orca/server/server.py#L319-L329
train
62,180
UDST/orca
orca/server/server.py
column_csv
def column_csv(table_name, col_name): """ Return a column as CSV using Pandas' default CSV output. """ csv = orca.get_table(table_name).get_column(col_name).to_csv(path=None) return csv, 200, {'Content-Type': 'text/csv'}
python
def column_csv(table_name, col_name): """ Return a column as CSV using Pandas' default CSV output. """ csv = orca.get_table(table_name).get_column(col_name).to_csv(path=None) return csv, 200, {'Content-Type': 'text/csv'}
[ "def", "column_csv", "(", "table_name", ",", "col_name", ")", ":", "csv", "=", "orca", ".", "get_table", "(", "table_name", ")", ".", "get_column", "(", "col_name", ")", ".", "to_csv", "(", "path", "=", "None", ")", "return", "csv", ",", "200", ",", ...
Return a column as CSV using Pandas' default CSV output.
[ "Return", "a", "column", "as", "CSV", "using", "Pandas", "default", "CSV", "output", "." ]
07b34aeef13cc87c966b2e30cbe7e76cc9d3622c
https://github.com/UDST/orca/blob/07b34aeef13cc87c966b2e30cbe7e76cc9d3622c/orca/server/server.py#L334-L340
train
62,181
UDST/orca
orca/server/server.py
injectable_repr
def injectable_repr(inj_name): """ Returns the type and repr of an injectable. JSON response has "type" and "repr" keys. """ i = orca.get_injectable(inj_name) return jsonify(type=str(type(i)), repr=repr(i))
python
def injectable_repr(inj_name): """ Returns the type and repr of an injectable. JSON response has "type" and "repr" keys. """ i = orca.get_injectable(inj_name) return jsonify(type=str(type(i)), repr=repr(i))
[ "def", "injectable_repr", "(", "inj_name", ")", ":", "i", "=", "orca", ".", "get_injectable", "(", "inj_name", ")", "return", "jsonify", "(", "type", "=", "str", "(", "type", "(", "i", ")", ")", ",", "repr", "=", "repr", "(", "i", ")", ")" ]
Returns the type and repr of an injectable. JSON response has "type" and "repr" keys.
[ "Returns", "the", "type", "and", "repr", "of", "an", "injectable", ".", "JSON", "response", "has", "type", "and", "repr", "keys", "." ]
07b34aeef13cc87c966b2e30cbe7e76cc9d3622c
https://github.com/UDST/orca/blob/07b34aeef13cc87c966b2e30cbe7e76cc9d3622c/orca/server/server.py#L354-L361
train
62,182
UDST/orca
orca/server/server.py
injectable_definition
def injectable_definition(inj_name): """ Get the source of an injectable function. If an injectable is a registered Python variable and not a function then all that is returned is {'type': 'variable'}. If the column is a registered function then the JSON returned has keys "type", "filename", "...
python
def injectable_definition(inj_name): """ Get the source of an injectable function. If an injectable is a registered Python variable and not a function then all that is returned is {'type': 'variable'}. If the column is a registered function then the JSON returned has keys "type", "filename", "...
[ "def", "injectable_definition", "(", "inj_name", ")", ":", "inj_type", "=", "orca", ".", "injectable_type", "(", "inj_name", ")", "if", "inj_type", "==", "'variable'", ":", "return", "jsonify", "(", "type", "=", "'variable'", ")", "else", ":", "filename", ",...
Get the source of an injectable function. If an injectable is a registered Python variable and not a function then all that is returned is {'type': 'variable'}. If the column is a registered function then the JSON returned has keys "type", "filename", "lineno", "text", and "html". "text" is the raw ...
[ "Get", "the", "source", "of", "an", "injectable", "function", "." ]
07b34aeef13cc87c966b2e30cbe7e76cc9d3622c
https://github.com/UDST/orca/blob/07b34aeef13cc87c966b2e30cbe7e76cc9d3622c/orca/server/server.py#L366-L388
train
62,183
UDST/orca
orca/server/server.py
list_broadcasts
def list_broadcasts(): """ List all registered broadcasts as a list of objects with keys "cast" and "onto". """ casts = [{'cast': b[0], 'onto': b[1]} for b in orca.list_broadcasts()] return jsonify(broadcasts=casts)
python
def list_broadcasts(): """ List all registered broadcasts as a list of objects with keys "cast" and "onto". """ casts = [{'cast': b[0], 'onto': b[1]} for b in orca.list_broadcasts()] return jsonify(broadcasts=casts)
[ "def", "list_broadcasts", "(", ")", ":", "casts", "=", "[", "{", "'cast'", ":", "b", "[", "0", "]", ",", "'onto'", ":", "b", "[", "1", "]", "}", "for", "b", "in", "orca", ".", "list_broadcasts", "(", ")", "]", "return", "jsonify", "(", "broadcast...
List all registered broadcasts as a list of objects with keys "cast" and "onto".
[ "List", "all", "registered", "broadcasts", "as", "a", "list", "of", "objects", "with", "keys", "cast", "and", "onto", "." ]
07b34aeef13cc87c966b2e30cbe7e76cc9d3622c
https://github.com/UDST/orca/blob/07b34aeef13cc87c966b2e30cbe7e76cc9d3622c/orca/server/server.py#L392-L399
train
62,184
UDST/orca
orca/server/server.py
broadcast_definition
def broadcast_definition(cast_name, onto_name): """ Return the definition of a broadcast as an object with keys "cast", "onto", "cast_on", "onto_on", "cast_index", and "onto_index". These are the same as the arguments to the ``broadcast`` function. """ if not orca.is_broadcast(cast_name, onto_n...
python
def broadcast_definition(cast_name, onto_name): """ Return the definition of a broadcast as an object with keys "cast", "onto", "cast_on", "onto_on", "cast_index", and "onto_index". These are the same as the arguments to the ``broadcast`` function. """ if not orca.is_broadcast(cast_name, onto_n...
[ "def", "broadcast_definition", "(", "cast_name", ",", "onto_name", ")", ":", "if", "not", "orca", ".", "is_broadcast", "(", "cast_name", ",", "onto_name", ")", ":", "abort", "(", "404", ")", "b", "=", "orca", ".", "get_broadcast", "(", "cast_name", ",", ...
Return the definition of a broadcast as an object with keys "cast", "onto", "cast_on", "onto_on", "cast_index", and "onto_index". These are the same as the arguments to the ``broadcast`` function.
[ "Return", "the", "definition", "of", "a", "broadcast", "as", "an", "object", "with", "keys", "cast", "onto", "cast_on", "onto_on", "cast_index", "and", "onto_index", ".", "These", "are", "the", "same", "as", "the", "arguments", "to", "the", "broadcast", "fun...
07b34aeef13cc87c966b2e30cbe7e76cc9d3622c
https://github.com/UDST/orca/blob/07b34aeef13cc87c966b2e30cbe7e76cc9d3622c/orca/server/server.py#L403-L417
train
62,185
UDST/orca
orca/server/server.py
step_definition
def step_definition(step_name): """ Get the source of a step function. Returned object has keys "filename", "lineno", "text" and "html". "text" is the raw text of the function, "html" has been marked up by Pygments. """ if not orca.is_step(step_name): abort(404) filename, lineno, s...
python
def step_definition(step_name): """ Get the source of a step function. Returned object has keys "filename", "lineno", "text" and "html". "text" is the raw text of the function, "html" has been marked up by Pygments. """ if not orca.is_step(step_name): abort(404) filename, lineno, s...
[ "def", "step_definition", "(", "step_name", ")", ":", "if", "not", "orca", ".", "is_step", "(", "step_name", ")", ":", "abort", "(", "404", ")", "filename", ",", "lineno", ",", "source", "=", "orca", ".", "get_step", "(", "step_name", ")", ".", "func_s...
Get the source of a step function. Returned object has keys "filename", "lineno", "text" and "html". "text" is the raw text of the function, "html" has been marked up by Pygments.
[ "Get", "the", "source", "of", "a", "step", "function", ".", "Returned", "object", "has", "keys", "filename", "lineno", "text", "and", "html", ".", "text", "is", "the", "raw", "text", "of", "the", "function", "html", "has", "been", "marked", "up", "by", ...
07b34aeef13cc87c966b2e30cbe7e76cc9d3622c
https://github.com/UDST/orca/blob/07b34aeef13cc87c966b2e30cbe7e76cc9d3622c/orca/server/server.py#L430-L443
train
62,186
UDST/orca
orca/utils/logutil.py
_add_log_handler
def _add_log_handler( handler, level=None, fmt=None, datefmt=None, propagate=None): """ Add a logging handler to Orca. Parameters ---------- handler : logging.Handler subclass level : int, optional An optional logging level that will apply only to this stream handler. ...
python
def _add_log_handler( handler, level=None, fmt=None, datefmt=None, propagate=None): """ Add a logging handler to Orca. Parameters ---------- handler : logging.Handler subclass level : int, optional An optional logging level that will apply only to this stream handler. ...
[ "def", "_add_log_handler", "(", "handler", ",", "level", "=", "None", ",", "fmt", "=", "None", ",", "datefmt", "=", "None", ",", "propagate", "=", "None", ")", ":", "if", "not", "fmt", ":", "fmt", "=", "US_LOG_FMT", "if", "not", "datefmt", ":", "date...
Add a logging handler to Orca. Parameters ---------- handler : logging.Handler subclass level : int, optional An optional logging level that will apply only to this stream handler. fmt : str, optional An optional format string that will be used for the log messages. ...
[ "Add", "a", "logging", "handler", "to", "Orca", "." ]
07b34aeef13cc87c966b2e30cbe7e76cc9d3622c
https://github.com/UDST/orca/blob/07b34aeef13cc87c966b2e30cbe7e76cc9d3622c/orca/utils/logutil.py#L47-L84
train
62,187
UDST/orca
orca/utils/logutil.py
log_to_stream
def log_to_stream(level=None, fmt=None, datefmt=None): """ Send log messages to the console. Parameters ---------- level : int, optional An optional logging level that will apply only to this stream handler. fmt : str, optional An optional format string that will be used...
python
def log_to_stream(level=None, fmt=None, datefmt=None): """ Send log messages to the console. Parameters ---------- level : int, optional An optional logging level that will apply only to this stream handler. fmt : str, optional An optional format string that will be used...
[ "def", "log_to_stream", "(", "level", "=", "None", ",", "fmt", "=", "None", ",", "datefmt", "=", "None", ")", ":", "_add_log_handler", "(", "logging", ".", "StreamHandler", "(", ")", ",", "fmt", "=", "fmt", ",", "datefmt", "=", "datefmt", ",", "propaga...
Send log messages to the console. Parameters ---------- level : int, optional An optional logging level that will apply only to this stream handler. fmt : str, optional An optional format string that will be used for the log messages. datefmt : str, optional ...
[ "Send", "log", "messages", "to", "the", "console", "." ]
07b34aeef13cc87c966b2e30cbe7e76cc9d3622c
https://github.com/UDST/orca/blob/07b34aeef13cc87c966b2e30cbe7e76cc9d3622c/orca/utils/logutil.py#L87-L105
train
62,188
UDST/orca
orca/orca.py
clear_all
def clear_all(): """ Clear any and all stored state from Orca. """ _TABLES.clear() _COLUMNS.clear() _STEPS.clear() _BROADCASTS.clear() _INJECTABLES.clear() _TABLE_CACHE.clear() _COLUMN_CACHE.clear() _INJECTABLE_CACHE.clear() for m in _MEMOIZED.values(): m.value.c...
python
def clear_all(): """ Clear any and all stored state from Orca. """ _TABLES.clear() _COLUMNS.clear() _STEPS.clear() _BROADCASTS.clear() _INJECTABLES.clear() _TABLE_CACHE.clear() _COLUMN_CACHE.clear() _INJECTABLE_CACHE.clear() for m in _MEMOIZED.values(): m.value.c...
[ "def", "clear_all", "(", ")", ":", "_TABLES", ".", "clear", "(", ")", "_COLUMNS", ".", "clear", "(", ")", "_STEPS", ".", "clear", "(", ")", "_BROADCASTS", ".", "clear", "(", ")", "_INJECTABLES", ".", "clear", "(", ")", "_TABLE_CACHE", ".", "clear", "...
Clear any and all stored state from Orca.
[ "Clear", "any", "and", "all", "stored", "state", "from", "Orca", "." ]
07b34aeef13cc87c966b2e30cbe7e76cc9d3622c
https://github.com/UDST/orca/blob/07b34aeef13cc87c966b2e30cbe7e76cc9d3622c/orca/orca.py#L48-L64
train
62,189
UDST/orca
orca/orca.py
_collect_variables
def _collect_variables(names, expressions=None): """ Map labels and expressions to registered variables. Handles argument matching. Example: _collect_variables(names=['zones', 'zone_id'], expressions=['parcels.zone_id']) Would return a dict representing: ...
python
def _collect_variables(names, expressions=None): """ Map labels and expressions to registered variables. Handles argument matching. Example: _collect_variables(names=['zones', 'zone_id'], expressions=['parcels.zone_id']) Would return a dict representing: ...
[ "def", "_collect_variables", "(", "names", ",", "expressions", "=", "None", ")", ":", "# Map registered variable labels to expressions.", "if", "not", "expressions", ":", "expressions", "=", "[", "]", "offset", "=", "len", "(", "names", ")", "-", "len", "(", "...
Map labels and expressions to registered variables. Handles argument matching. Example: _collect_variables(names=['zones', 'zone_id'], expressions=['parcels.zone_id']) Would return a dict representing: {'parcels': <DataFrameWrapper for zones>, 'zone_i...
[ "Map", "labels", "and", "expressions", "to", "registered", "variables", "." ]
07b34aeef13cc87c966b2e30cbe7e76cc9d3622c
https://github.com/UDST/orca/blob/07b34aeef13cc87c966b2e30cbe7e76cc9d3622c/orca/orca.py#L903-L962
train
62,190
UDST/orca
orca/orca.py
add_table
def add_table( table_name, table, cache=False, cache_scope=_CS_FOREVER, copy_col=True): """ Register a table with Orca. Parameters ---------- table_name : str Should be globally unique to this table. table : pandas.DataFrame or function If a function, the functio...
python
def add_table( table_name, table, cache=False, cache_scope=_CS_FOREVER, copy_col=True): """ Register a table with Orca. Parameters ---------- table_name : str Should be globally unique to this table. table : pandas.DataFrame or function If a function, the functio...
[ "def", "add_table", "(", "table_name", ",", "table", ",", "cache", "=", "False", ",", "cache_scope", "=", "_CS_FOREVER", ",", "copy_col", "=", "True", ")", ":", "if", "isinstance", "(", "table", ",", "Callable", ")", ":", "table", "=", "TableFuncWrapper", ...
Register a table with Orca. Parameters ---------- table_name : str Should be globally unique to this table. table : pandas.DataFrame or function If a function, the function should return a DataFrame. The function's argument names and keyword argument values will be match...
[ "Register", "a", "table", "with", "Orca", "." ]
07b34aeef13cc87c966b2e30cbe7e76cc9d3622c
https://github.com/UDST/orca/blob/07b34aeef13cc87c966b2e30cbe7e76cc9d3622c/orca/orca.py#L965-L1008
train
62,191
UDST/orca
orca/orca.py
table
def table( table_name=None, cache=False, cache_scope=_CS_FOREVER, copy_col=True): """ Decorates functions that return DataFrames. Decorator version of `add_table`. Table name defaults to name of function. The function's argument names and keyword argument values will be matched to regi...
python
def table( table_name=None, cache=False, cache_scope=_CS_FOREVER, copy_col=True): """ Decorates functions that return DataFrames. Decorator version of `add_table`. Table name defaults to name of function. The function's argument names and keyword argument values will be matched to regi...
[ "def", "table", "(", "table_name", "=", "None", ",", "cache", "=", "False", ",", "cache_scope", "=", "_CS_FOREVER", ",", "copy_col", "=", "True", ")", ":", "def", "decorator", "(", "func", ")", ":", "if", "table_name", ":", "name", "=", "table_name", "...
Decorates functions that return DataFrames. Decorator version of `add_table`. Table name defaults to name of function. The function's argument names and keyword argument values will be matched to registered variables when the function needs to be evaluated by Orca. The argument name "iter_var"...
[ "Decorates", "functions", "that", "return", "DataFrames", "." ]
07b34aeef13cc87c966b2e30cbe7e76cc9d3622c
https://github.com/UDST/orca/blob/07b34aeef13cc87c966b2e30cbe7e76cc9d3622c/orca/orca.py#L1011-L1035
train
62,192
UDST/orca
orca/orca.py
get_table
def get_table(table_name): """ Get a registered table. Decorated functions will be converted to `DataFrameWrapper`. Parameters ---------- table_name : str Returns ------- table : `DataFrameWrapper` """ table = get_raw_table(table_name) if isinstance(table, TableFuncWr...
python
def get_table(table_name): """ Get a registered table. Decorated functions will be converted to `DataFrameWrapper`. Parameters ---------- table_name : str Returns ------- table : `DataFrameWrapper` """ table = get_raw_table(table_name) if isinstance(table, TableFuncWr...
[ "def", "get_table", "(", "table_name", ")", ":", "table", "=", "get_raw_table", "(", "table_name", ")", "if", "isinstance", "(", "table", ",", "TableFuncWrapper", ")", ":", "table", "=", "table", "(", ")", "return", "table" ]
Get a registered table. Decorated functions will be converted to `DataFrameWrapper`. Parameters ---------- table_name : str Returns ------- table : `DataFrameWrapper`
[ "Get", "a", "registered", "table", "." ]
07b34aeef13cc87c966b2e30cbe7e76cc9d3622c
https://github.com/UDST/orca/blob/07b34aeef13cc87c966b2e30cbe7e76cc9d3622c/orca/orca.py#L1057-L1075
train
62,193
UDST/orca
orca/orca.py
table_type
def table_type(table_name): """ Returns the type of a registered table. The type can be either "dataframe" or "function". Parameters ---------- table_name : str Returns ------- table_type : {'dataframe', 'function'} """ table = get_raw_table(table_name) if isinstance...
python
def table_type(table_name): """ Returns the type of a registered table. The type can be either "dataframe" or "function". Parameters ---------- table_name : str Returns ------- table_type : {'dataframe', 'function'} """ table = get_raw_table(table_name) if isinstance...
[ "def", "table_type", "(", "table_name", ")", ":", "table", "=", "get_raw_table", "(", "table_name", ")", "if", "isinstance", "(", "table", ",", "DataFrameWrapper", ")", ":", "return", "'dataframe'", "elif", "isinstance", "(", "table", ",", "TableFuncWrapper", ...
Returns the type of a registered table. The type can be either "dataframe" or "function". Parameters ---------- table_name : str Returns ------- table_type : {'dataframe', 'function'}
[ "Returns", "the", "type", "of", "a", "registered", "table", "." ]
07b34aeef13cc87c966b2e30cbe7e76cc9d3622c
https://github.com/UDST/orca/blob/07b34aeef13cc87c966b2e30cbe7e76cc9d3622c/orca/orca.py#L1078-L1098
train
62,194
UDST/orca
orca/orca.py
add_column
def add_column( table_name, column_name, column, cache=False, cache_scope=_CS_FOREVER): """ Add a new column to a table from a Series or callable. Parameters ---------- table_name : str Table with which the column will be associated. column_name : str Name for the column...
python
def add_column( table_name, column_name, column, cache=False, cache_scope=_CS_FOREVER): """ Add a new column to a table from a Series or callable. Parameters ---------- table_name : str Table with which the column will be associated. column_name : str Name for the column...
[ "def", "add_column", "(", "table_name", ",", "column_name", ",", "column", ",", "cache", "=", "False", ",", "cache_scope", "=", "_CS_FOREVER", ")", ":", "if", "isinstance", "(", "column", ",", "Callable", ")", ":", "column", "=", "_ColumnFuncWrapper", "(", ...
Add a new column to a table from a Series or callable. Parameters ---------- table_name : str Table with which the column will be associated. column_name : str Name for the column. column : pandas.Series or callable Series should have an index matching the table to which it ...
[ "Add", "a", "new", "column", "to", "a", "table", "from", "a", "Series", "or", "callable", "." ]
07b34aeef13cc87c966b2e30cbe7e76cc9d3622c
https://github.com/UDST/orca/blob/07b34aeef13cc87c966b2e30cbe7e76cc9d3622c/orca/orca.py#L1101-L1143
train
62,195
UDST/orca
orca/orca.py
column
def column(table_name, column_name=None, cache=False, cache_scope=_CS_FOREVER): """ Decorates functions that return a Series. Decorator version of `add_column`. Series index must match the named table. Column name defaults to name of function. The function's argument names and keyword argument val...
python
def column(table_name, column_name=None, cache=False, cache_scope=_CS_FOREVER): """ Decorates functions that return a Series. Decorator version of `add_column`. Series index must match the named table. Column name defaults to name of function. The function's argument names and keyword argument val...
[ "def", "column", "(", "table_name", ",", "column_name", "=", "None", ",", "cache", "=", "False", ",", "cache_scope", "=", "_CS_FOREVER", ")", ":", "def", "decorator", "(", "func", ")", ":", "if", "column_name", ":", "name", "=", "column_name", "else", ":...
Decorates functions that return a Series. Decorator version of `add_column`. Series index must match the named table. Column name defaults to name of function. The function's argument names and keyword argument values will be matched to registered variables when the function needs to be evaluated ...
[ "Decorates", "functions", "that", "return", "a", "Series", "." ]
07b34aeef13cc87c966b2e30cbe7e76cc9d3622c
https://github.com/UDST/orca/blob/07b34aeef13cc87c966b2e30cbe7e76cc9d3622c/orca/orca.py#L1146-L1169
train
62,196
UDST/orca
orca/orca.py
_columns_for_table
def _columns_for_table(table_name): """ Return all of the columns registered for a given table. Parameters ---------- table_name : str Returns ------- columns : dict of column wrappers Keys will be column names. """ return {cname: col for (tname, cname), co...
python
def _columns_for_table(table_name): """ Return all of the columns registered for a given table. Parameters ---------- table_name : str Returns ------- columns : dict of column wrappers Keys will be column names. """ return {cname: col for (tname, cname), co...
[ "def", "_columns_for_table", "(", "table_name", ")", ":", "return", "{", "cname", ":", "col", "for", "(", "tname", ",", "cname", ")", ",", "col", "in", "_COLUMNS", ".", "items", "(", ")", "if", "tname", "==", "table_name", "}" ]
Return all of the columns registered for a given table. Parameters ---------- table_name : str Returns ------- columns : dict of column wrappers Keys will be column names.
[ "Return", "all", "of", "the", "columns", "registered", "for", "a", "given", "table", "." ]
07b34aeef13cc87c966b2e30cbe7e76cc9d3622c
https://github.com/UDST/orca/blob/07b34aeef13cc87c966b2e30cbe7e76cc9d3622c/orca/orca.py#L1188-L1204
train
62,197
UDST/orca
orca/orca.py
get_raw_column
def get_raw_column(table_name, column_name): """ Get a wrapped, registered column. This function cannot return columns that are part of wrapped DataFrames, it's only for columns registered directly through Orca. Parameters ---------- table_name : str column_name : str Returns ...
python
def get_raw_column(table_name, column_name): """ Get a wrapped, registered column. This function cannot return columns that are part of wrapped DataFrames, it's only for columns registered directly through Orca. Parameters ---------- table_name : str column_name : str Returns ...
[ "def", "get_raw_column", "(", "table_name", ",", "column_name", ")", ":", "try", ":", "return", "_COLUMNS", "[", "(", "table_name", ",", "column_name", ")", "]", "except", "KeyError", ":", "raise", "KeyError", "(", "'column {!r} not found for table {!r}'", ".", ...
Get a wrapped, registered column. This function cannot return columns that are part of wrapped DataFrames, it's only for columns registered directly through Orca. Parameters ---------- table_name : str column_name : str Returns ------- wrapped : _SeriesWrapper or _ColumnFuncWrappe...
[ "Get", "a", "wrapped", "registered", "column", "." ]
07b34aeef13cc87c966b2e30cbe7e76cc9d3622c
https://github.com/UDST/orca/blob/07b34aeef13cc87c966b2e30cbe7e76cc9d3622c/orca/orca.py#L1239-L1260
train
62,198
UDST/orca
orca/orca.py
_memoize_function
def _memoize_function(f, name, cache_scope=_CS_FOREVER): """ Wraps a function for memoization and ties it's cache into the Orca cacheing system. Parameters ---------- f : function name : str Name of injectable. cache_scope : {'step', 'iteration', 'forever'}, optional Sco...
python
def _memoize_function(f, name, cache_scope=_CS_FOREVER): """ Wraps a function for memoization and ties it's cache into the Orca cacheing system. Parameters ---------- f : function name : str Name of injectable. cache_scope : {'step', 'iteration', 'forever'}, optional Sco...
[ "def", "_memoize_function", "(", "f", ",", "name", ",", "cache_scope", "=", "_CS_FOREVER", ")", ":", "cache", "=", "{", "}", "@", "wraps", "(", "f", ")", "def", "wrapper", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "try", ":", "cache_key"...
Wraps a function for memoization and ties it's cache into the Orca cacheing system. Parameters ---------- f : function name : str Name of injectable. cache_scope : {'step', 'iteration', 'forever'}, optional Scope for which to cache data. Default is to cache forever (or u...
[ "Wraps", "a", "function", "for", "memoization", "and", "ties", "it", "s", "cache", "into", "the", "Orca", "cacheing", "system", "." ]
07b34aeef13cc87c966b2e30cbe7e76cc9d3622c
https://github.com/UDST/orca/blob/07b34aeef13cc87c966b2e30cbe7e76cc9d3622c/orca/orca.py#L1263-L1304
train
62,199