INSTRUCTION stringlengths 1 8.43k | RESPONSE stringlengths 75 104k |
|---|---|
Get job statuses. | def statuses(ctx, page):
"""Get job statuses.
Uses [Caching](/references/polyaxon-cli/#caching)
Examples:
\b
```bash
$ polyaxon job -j 2 statuses
```
"""
user, project_name, _job = get_job_or_local(ctx.obj.get('project'), ctx.obj.get('job'))
page = page or 1
try:
r... |
Get job resources. | def resources(ctx, gpu):
"""Get job resources.
Uses [Caching](/references/polyaxon-cli/#caching)
Examples:
\b
```bash
$ polyaxon job -j 2 resources
```
For GPU resources
\b
```bash
$ polyaxon job -j 2 resources --gpu
```
"""
user, project_name, _job = get_job... |
Get job logs. | def logs(ctx, past, follow, hide_time):
"""Get job logs.
Uses [Caching](/references/polyaxon-cli/#caching)
Examples:
\b
```bash
$ polyaxon job -j 2 logs
```
\b
```bash
$ polyaxon job logs
```
"""
user, project_name, _job = get_job_or_local(ctx.obj.get('project'), ... |
Download outputs for job. | def outputs(ctx):
"""Download outputs for job.
Uses [Caching](/references/polyaxon-cli/#caching)
Examples:
\b
```bash
$ polyaxon job -j 1 outputs
```
"""
user, project_name, _job = get_job_or_local(ctx.obj.get('project'), ctx.obj.get('job'))
try:
PolyaxonClient().job.d... |
Prints as formatted JSON | def pprint(value):
"""Prints as formatted JSON"""
click.echo(
json.dumps(value,
sort_keys=True,
indent=4,
separators=(',', ': '))) |
Login to Polyaxon. | def login(token, username, password):
"""Login to Polyaxon."""
auth_client = PolyaxonClient().auth
if username:
# Use username / password login
if not password:
password = click.prompt('Please enter your password', type=str, hide_input=True)
password = password.strip(... |
Show current logged Polyaxon user. | def whoami():
"""Show current logged Polyaxon user."""
try:
user = PolyaxonClient().auth.get_user()
except (PolyaxonHTTPError, PolyaxonShouldExitError, PolyaxonClientException) as e:
Printer.print_error('Could not load user info.')
Printer.print_error('Error message `{}`.'.format(e))... |
Commands for build jobs. | def build(ctx, project, build): # pylint:disable=redefined-outer-name
"""Commands for build jobs."""
ctx.obj = ctx.obj or {}
ctx.obj['project'] = project
ctx.obj['build'] = build |
Get build job. | def get(ctx):
"""Get build job.
Uses [Caching](/references/polyaxon-cli/#caching)
Examples:
\b
```bash
$ polyaxon build -b 1 get
```
\b
```bash
$ polyaxon build --build=1 --project=project_name get
```
"""
user, project_name, _build = get_build_or_local(ctx.obj.ge... |
Delete build job. | def delete(ctx):
"""Delete build job.
Uses [Caching](/references/polyaxon-cli/#caching)
Example:
\b
```bash
$ polyaxon build delete
```
\b
```bash
$ polyaxon build -b 2 delete
```
"""
user, project_name, _build = get_build_or_local(ctx.obj.get('project'), ctx.obj.... |
Update build. | def update(ctx, name, description, tags):
"""Update build.
Uses [Caching](/references/polyaxon-cli/#caching)
Example:
\b
```bash
$ polyaxon build -b 2 update --description="new description for my build"
```
"""
user, project_name, _build = get_build_or_local(ctx.obj.get('project')... |
Stop build job. | def stop(ctx, yes):
"""Stop build job.
Uses [Caching](/references/polyaxon-cli/#caching)
Examples:
\b
```bash
$ polyaxon build stop
```
\b
```bash
$ polyaxon build -b 2 stop
```
"""
user, project_name, _build = get_build_or_local(ctx.obj.get('project'), ctx.obj.ge... |
Bookmark build job. | def bookmark(ctx):
"""Bookmark build job.
Uses [Caching](/references/polyaxon-cli/#caching)
Examples:
\b
```bash
$ polyaxon build bookmark
```
\b
```bash
$ polyaxon build -b 2 bookmark
```
"""
user, project_name, _build = get_build_or_local(ctx.obj.get('project'),... |
Get build job resources. | def resources(ctx, gpu):
"""Get build job resources.
Uses [Caching](/references/polyaxon-cli/#caching)
Examples:
\b
```bash
$ polyaxon build -b 2 resources
```
For GPU resources
\b
```bash
$ polyaxon build -b 2 resources --gpu
```
"""
user, project_name, _bui... |
Initialize a new polyaxonfile specification. | def init(project, polyaxonfile):
"""Initialize a new polyaxonfile specification."""
user, project_name = get_project_or_local(project)
try:
project_config = PolyaxonClient().project.get_project(user, project_name)
except (PolyaxonHTTPError, PolyaxonShouldExitError, PolyaxonClientException) as e:... |
Run polyaxonfile specification. | def run(ctx, project, file, name, tags, description, ttl, u, l): # pylint:disable=redefined-builtin
"""Run polyaxonfile specification.
Examples:
\b
```bash
$ polyaxon run -f file -f file_override ...
```
Upload before running
\b
```bash
$ polyaxon run -f file -u
```
... |
Commands for bookmarks. | def bookmark(ctx, username): # pylint:disable=redefined-outer-name
"""Commands for bookmarks."""
ctx.obj = ctx.obj or {}
ctx.obj['username'] = username |
List bookmarked projects for user. | def projects(ctx, page):
"""List bookmarked projects for user.
Uses [Caching](/references/polyaxon-cli/#caching)
Examples:
\b
```bash
$ polyaxon bookmark projects
```
\b
```bash
$ polyaxon bookmark -u adam projects
```
"""
user = get_username_or_local(ctx.obj.get(... |
Remove trailing spaces unless they are quoted with a backslash. | def _remove_trailing_spaces(line):
"""Remove trailing spaces unless they are quoted with a backslash."""
while line.endswith(' ') and not line.endswith('\\ '):
line = line[:-1]
return line.replace('\\ ', ' ') |
Yield all matching patterns for path. | def find_matching(cls, path, patterns):
"""Yield all matching patterns for path."""
for pattern in patterns:
if pattern.match(path):
yield pattern |
Check whether a path is ignored. For directories include a trailing slash. | def is_ignored(cls, path, patterns):
"""Check whether a path is ignored. For directories, include a trailing slash."""
status = None
for pattern in cls.find_matching(path, patterns):
status = pattern.is_exclude
return status |
Given a list of patterns returns a if a path matches any pattern. | def _matches_patterns(path, patterns):
"""Given a list of patterns, returns a if a path matches any pattern."""
for glob in patterns:
try:
if PurePath(path).match(glob):
return True
except TypeError:
pass
return False |
Returns a whether a path should be ignored or not. | def _ignore_path(cls, path, ignore_list=None, white_list=None):
"""Returns a whether a path should be ignored or not."""
ignore_list = ignore_list or []
white_list = white_list or []
return (cls._matches_patterns(path, ignore_list) and
not cls._matches_patterns(path, whit... |
Commands for experiment groups. | def group(ctx, project, group): # pylint:disable=redefined-outer-name
"""Commands for experiment groups."""
ctx.obj = ctx.obj or {}
ctx.obj['project'] = project
ctx.obj['group'] = group |
Get experiment group by uuid. | def get(ctx):
"""Get experiment group by uuid.
Uses [Caching](/references/polyaxon-cli/#caching)
Examples:
\b
```bash
$ polyaxon group -g 13 get
```
"""
user, project_name, _group = get_project_group_or_local(ctx.obj.get('project'),
... |
Delete experiment group. | def delete(ctx):
"""Delete experiment group.
Uses [Caching](/references/polyaxon-cli/#caching)
"""
user, project_name, _group = get_project_group_or_local(ctx.obj.get('project'),
ctx.obj.get('group'))
if not click.confirm("Are sure you wa... |
Update experiment group. | def update(ctx, name, description, tags):
"""Update experiment group.
Uses [Caching](/references/polyaxon-cli/#caching)
Example:
\b
```bash
$ polyaxon group -g 2 update --description="new description for this group"
```
\b
```bash
$ polyaxon update --tags="foo, bar"
```
... |
Stop experiments in the group. | def stop(ctx, yes, pending):
"""Stop experiments in the group.
Uses [Caching](/references/polyaxon-cli/#caching)
Examples: stop only pending experiments
\b
```bash
$ polyaxon group stop --pending
```
Examples: stop all unfinished
\b
```bash
$ polyaxon group stop
```
... |
Bookmark group. | def bookmark(ctx):
"""Bookmark group.
Uses [Caching](/references/polyaxon-cli/#caching)
Examples:
\b
```bash
$ polyaxon group bookmark
```
\b
```bash
$ polyaxon group -g 2 bookmark
```
"""
user, project_name, _group = get_project_group_or_local(ctx.obj.get('projec... |
Set and get the global configurations. | def config(list): # pylint:disable=redefined-builtin
"""Set and get the global configurations."""
if list:
_config = GlobalConfigManager.get_config_or_default()
Printer.print_header('Current config:')
dict_tabulate(_config.to_dict()) |
Get the global config values by keys. | def get(keys):
"""Get the global config values by keys.
Example:
\b
```bash
$ polyaxon config get host http_port
```
"""
_config = GlobalConfigManager.get_config_or_default()
if not keys:
return
print_values = {}
for key in keys:
if hasattr(_config, key):
... |
Set the global config values. | def set(verbose, # pylint:disable=redefined-builtin
host,
http_port,
ws_port,
use_https,
verify_ssl):
"""Set the global config values.
Example:
\b
```bash
$ polyaxon config set --hots=localhost http_port=80
```
"""
_config = GlobalConfigManager.... |
Activate a user. | def activate(username):
"""Activate a user.
Example:
\b
```bash
$ polyaxon user activate david
```
"""
try:
PolyaxonClient().user.activate_user(username)
except (PolyaxonHTTPError, PolyaxonShouldExitError, PolyaxonClientException) as e:
Printer.print_error('Could no... |
Delete a user. | def delete(username):
"""Delete a user.
Example:
\b
```bash
$ polyaxon user delete david
```
"""
try:
PolyaxonClient().user.delete_user(username)
except (PolyaxonHTTPError, PolyaxonShouldExitError, PolyaxonClientException) as e:
Printer.print_error('Could not delete... |
Deploy polyaxon. | def deploy(file, manager_path, check, dry_run): # pylint:disable=redefined-builtin
"""Deploy polyaxon."""
config = read_deployment_config(file)
manager = DeployManager(config=config,
filepath=file,
manager_path=manager_path,
... |
Teardown a polyaxon deployment given a config file. | def teardown(file): # pylint:disable=redefined-builtin
"""Teardown a polyaxon deployment given a config file."""
config = read_deployment_config(file)
manager = DeployManager(config=config, filepath=file)
exception = None
try:
if click.confirm('Would you like to execute pre-delete hooks?', ... |
Create a tar file based on the list of files passed | def create_tarfile(files, project_name):
"""Create a tar file based on the list of files passed"""
fd, filename = tempfile.mkstemp(prefix="polyaxon_{}".format(project_name), suffix='.tar.gz')
with tarfile.open(filename, "w:gz") as tar:
for f in files:
tar.add(f)
yield filename
... |
Prints the tensorboard url for project/ experiment/ experiment group. | def url(ctx):
"""Prints the tensorboard url for project/experiment/experiment group.
Uses [Caching](/references/polyaxon-cli/#caching)
Examples for project tensorboards:
\b
```bash
$ polyaxon tensorboard url
```
\b
```bash
$ polyaxon tensorboard -p mnist url
```
Exam... |
Start a tensorboard deployment for project/ experiment/ experiment group. | def start(ctx, file): # pylint:disable=redefined-builtin
"""Start a tensorboard deployment for project/experiment/experiment group.
Project tensorboard will aggregate all experiments under the project.
Experiment group tensorboard will aggregate all experiments under the group.
Experiment tensorboar... |
Stops the tensorboard deployment for project/ experiment/ experiment group if it exists. | def stop(ctx, yes):
"""Stops the tensorboard deployment for project/experiment/experiment group if it exists.
Uses [Caching](/references/polyaxon-cli/#caching)
Examples: stopping project tensorboard
\b
```bash
$ polyaxon tensorboard stop
```
Examples: stopping experiment group tensor... |
Check if the current cli version satisfies the server requirements | def check_cli_version():
"""Check if the current cli version satisfies the server requirements"""
if not CliConfigManager.should_check():
return
server_version = get_server_version()
current_version = get_current_version()
CliConfigManager.reset(current_version=current_version,
... |
Print the current version of the cli and platform. | def version(cli, platform):
"""Print the current version of the cli and platform."""
version_client = PolyaxonClient().version
cli = cli or not any([cli, platform])
if cli:
try:
server_version = version_client.get_cli_version()
except AuthorizationError:
session_e... |
Open dashboard in browser. | def dashboard(yes, url):
"""Open dashboard in browser."""
dashboard_url = "{}/app".format(PolyaxonClient().api_config.http_host)
if url:
click.echo(dashboard_url)
sys.exit(0)
if not yes:
click.confirm('Dashboard page will now open in your browser. Continue?',
... |
Grant superuser role to a user. | def grant(username):
"""Grant superuser role to a user.
Example:
\b
```bash
$ polyaxon superuser grant david
```
"""
try:
PolyaxonClient().user.grant_superuser(username)
except (PolyaxonHTTPError, PolyaxonShouldExitError, PolyaxonClientException) as e:
Printer.print... |
Revoke superuser role to a user. | def revoke(username):
"""Revoke superuser role to a user.
Example:
\b
```bash
$ polyaxon superuser revoke david
```
"""
try:
PolyaxonClient().user.revoke_superuser(username)
except (PolyaxonHTTPError, PolyaxonShouldExitError, PolyaxonClientException) as e:
Printer.p... |
Prints the notebook url for this project. | def url(ctx):
"""Prints the notebook url for this project.
Uses [Caching](/references/polyaxon-cli/#caching)
Example:
\b
```bash
$ polyaxon notebook url
```
"""
user, project_name = get_project_or_local(ctx.obj.get('project'))
try:
response = PolyaxonClient().project.g... |
Start a notebook deployment for this project. | def start(ctx, file, u): # pylint:disable=redefined-builtin
"""Start a notebook deployment for this project.
Uses [Caching](/references/polyaxon-cli/#caching)
Example:
\b
```bash
$ polyaxon notebook start -f file -f file_override ...
```
Example: upload before running
\b
``... |
Stops the notebook deployment for this project if it exists. | def stop(ctx, commit, yes):
"""Stops the notebook deployment for this project if it exists.
Uses [Caching](/references/polyaxon-cli/#caching)
"""
user, project_name = get_project_or_local(ctx.obj.get('project'))
if not yes and not click.confirm("Are sure you want to stop notebook "
... |
Polyaxon CLI tool to: | def cli(context, verbose):
""" Polyaxon CLI tool to:
* Parse, Validate, and Check Polyaxonfiles.
* Interact with Polyaxon server.
* Run and Monitor experiments.
Check the help available for each command listed below.
"""
configure_logger(verbose or GlobalConfigManager.get_val... |
Add platform specific checks | def check(self):
"""Add platform specific checks"""
if not self.is_valid:
raise PolyaxonDeploymentConfigError(
'Deployment type `{}` not supported'.format(self.deployment_type))
check = False
if self.is_kubernetes:
check = self.check_for_kubernetes... |
Install polyaxon using the current config to the correct platform. | def install(self):
"""Install polyaxon using the current config to the correct platform."""
if not self.is_valid:
raise PolyaxonDeploymentConfigError(
'Deployment type `{}` not supported'.format(self.deployment_type))
if self.is_kubernetes:
self.install_o... |
Upgrade deployment. | def upgrade(self):
"""Upgrade deployment."""
if not self.is_valid:
raise PolyaxonDeploymentConfigError(
'Deployment type `{}` not supported'.format(self.deployment_type))
if self.is_kubernetes:
self.upgrade_on_kubernetes()
elif self.is_docker_comp... |
Teardown Polyaxon. | def teardown(self, hooks=True):
"""Teardown Polyaxon."""
if not self.is_valid:
raise PolyaxonDeploymentConfigError(
'Deployment type `{}` not supported'.format(self.deployment_type))
if self.is_kubernetes:
self.teardown_on_kubernetes(hooks=hooks)
... |
Commands for projects. | def project(ctx, project): # pylint:disable=redefined-outer-name
"""Commands for projects."""
if ctx.invoked_subcommand not in ['create', 'list']:
ctx.obj = ctx.obj or {}
ctx.obj['project'] = project |
Create a new project. | def create(ctx, name, description, tags, private, init):
"""Create a new project.
Uses [Caching](/references/polyaxon-cli/#caching)
Example:
\b
```bash
$ polyaxon project create --name=cats-vs-dogs --description="Image Classification with DL"
```
"""
try:
tags = tags.split... |
List projects. | def list(page): # pylint:disable=redefined-builtin
"""List projects.
Uses [Caching](/references/polyaxon-cli/#caching)
"""
user = AuthConfigManager.get_value('username')
if not user:
Printer.print_error('Please login first. `polyaxon login --help`')
page = page or 1
try:
r... |
Get info for current project by project_name or user/ project_name. | def get(ctx):
"""Get info for current project, by project_name, or user/project_name.
Uses [Caching](/references/polyaxon-cli/#caching)
Examples:
To get current project:
\b
```bash
$ polyaxon project get
```
To get a project by name
\b
```bash
$ polyaxon project get... |
Delete project. | def delete(ctx):
"""Delete project.
Uses [Caching](/references/polyaxon-cli/#caching)
"""
user, project_name = get_project_or_local(ctx.obj.get('project'))
if not click.confirm("Are sure you want to delete project `{}/{}`".format(user, project_name)):
click.echo('Existing without deleting ... |
Update project. | def update(ctx, name, description, tags, private):
"""Update project.
Uses [Caching](/references/polyaxon-cli/#caching)
Example:
\b
```bash
$ polyaxon update foobar --description="Image Classification with DL using TensorFlow"
```
\b
```bash
$ polyaxon update mike1/foobar --d... |
List experiment groups for this project. | def groups(ctx, query, sort, page):
"""List experiment groups for this project.
Uses [Caching](/references/polyaxon-cli/#caching)
Examples:
Get all groups:
\b
```bash
$ polyaxon project groups
```
Get all groups with with status {created or running}, and
creation date betwee... |
List experiments for this project. | def experiments(ctx, metrics, declarations, independent, group, query, sort, page):
"""List experiments for this project.
Uses [Caching](/references/polyaxon-cli/#caching)
Examples:
Get all experiments:
\b
```bash
$ polyaxon project experiments
```
Get all experiments with with ... |
Set/ Sync git repo on this project. | def git(ctx, url, private, sync): # pylint:disable=assign-to-new-keyword
"""Set/Sync git repo on this project.
Uses [Caching](/references/polyaxon-cli/#caching)
Example:
\b
```bash
$ polyaxon project git --url=https://github.com/polyaxon/polyaxon-quick-start
```
\b
```bash
$... |
Enable/ Disable CI on this project. | def ci(ctx, enable, disable): # pylint:disable=assign-to-new-keyword
"""Enable/Disable CI on this project.
Uses [Caching](/references/polyaxon-cli/#caching)
Example:
\b
```bash
$ polyaxon project ci --enable
```
\b
```bash
$ polyaxon project ci --disable
```
"""
... |
Download code of the current project. | def download(ctx):
"""Download code of the current project."""
user, project_name = get_project_or_local(ctx.obj.get('project'))
try:
PolyaxonClient().project.download_repo(user, project_name)
except (PolyaxonHTTPError, PolyaxonShouldExitError, PolyaxonClientException) as e:
Printer.prin... |
write the object line ; additional args are packed in string | def write(self,file,optstring="",quote=False):
"""write the 'object' line; additional args are packed in string"""
classid = str(self.id)
if quote: classid = '"'+classid+'"'
# Only use a *single* space between tokens; both chimera's and pymol's DX parser
# does not properly imple... |
Edges of the grid cells origin at centre of 0 0.. 0 grid cell. | def edges(self):
"""Edges of the grid cells, origin at centre of 0,0,..,0 grid cell.
Only works for regular, orthonormal grids.
"""
return [self.delta[d,d] * numpy.arange(self.shape[d]+1) + self.origin[d]\
- 0.5*self.delta[d,d] for d in range(self.rank)] |
Write the * class array * section. | def write(self, file):
"""Write the *class array* section.
Parameters
----------
file : file
Raises
------
ValueError
If the `dxtype` is not a valid type, :exc:`ValueError` is
raised.
"""
if self.type not in self.dx_typ... |
Write the complete dx object to the file. | def write(self, filename):
"""Write the complete dx object to the file.
This is the simple OpenDX format which includes the data into
the header via the 'object array ... data follows' statement.
Only simple regular arrays are supported.
The format should be compatible with VM... |
Read DX field from file. | def read(self,file):
"""Read DX field from file.
dx = OpenDX.field.read(dxfile)
The classid is discarded and replaced with the one from the file.
"""
DXfield = self
p = DXParser(file)
p.parse(DXfield) |
iterator that returns ( component object ) in id order | def sorted_components(self):
"""iterator that returns (component,object) in id order"""
for component, object in \
sorted(self.components.items(),
key=lambda comp_obj: comp_obj[1].id):
yield component, object |
Return array data as ( edges grid ) i. e. a numpy nD histogram. | def histogramdd(self):
"""Return array data as (edges,grid), i.e. a numpy nD histogram."""
shape = self.components['positions'].shape
edges = self.components['positions'].edges()
hist = self.components['data'].array.reshape(shape)
return (hist,edges) |
Return text cast to the correct type or the selected type | def value(self,ascode=None):
"""Return text cast to the correct type or the selected type"""
if ascode is None:
ascode = self.code
return self.cast[ascode](self.text) |
Initialize the corresponding DXclass from the data. | def initialize(self):
"""Initialize the corresponding DXclass from the data.
class = DXInitObject.initialize()
"""
return self.DXclasses[self.type](self.id,**self.args) |
Parse the dx file and construct a DX field object with component classes. | def parse(self,DXfield):
"""Parse the dx file and construct a DX field object with component classes.
A :class:`field` instance *DXfield* must be provided to be
filled by the parser::
DXfield_object = OpenDX.field(*args)
parse(DXfield_object)
A tokenizer turns th... |
Level - 0 parser and main loop. | def __general(self):
"""Level-0 parser and main loop.
Look for a token that matches a level-1 parser and hand over control."""
while 1: # main loop
try:
tok = self.__peek() # only peek, apply_parser() will consume
except... |
Level - 1 parser for comments. | def __comment(self):
"""Level-1 parser for comments.
pattern: #.*
Append comment (with initial '# ' stripped) to all comments.
"""
tok = self.__consume()
self.DXfield.add_comment(tok.value())
self.set_parser('general') |
Level - 1 parser for objects. | def __object(self):
"""Level-1 parser for objects.
pattern: 'object' id 'class' type ...
id ::= integer|string|'"'white space string'"'
type ::= string
"""
self.__consume() # 'object'
classid = self.__consume().text
word = self.__con... |
Level - 2 parser for gridpositions. | def __gridpositions(self):
"""Level-2 parser for gridpositions.
pattern:
object 1 class gridpositions counts 97 93 99
origin -46.5 -45.5 -48.5
delta 1 0 0
delta 0 1 0
delta 0 0 1
"""
try:
tok = self.__consume()
except DXParserN... |
Level - 2 parser for gridconnections. | def __gridconnections(self):
"""Level-2 parser for gridconnections.
pattern:
object 2 class gridconnections counts 97 93 99
"""
try:
tok = self.__consume()
except DXParserNoTokens:
return
if tok.equals('counts'):
shape = []
... |
Level - 2 parser for arrays. | def __array(self):
"""Level-2 parser for arrays.
pattern:
object 3 class array type double rank 0 items 12 data follows
0 2 0
0 0 3.6
0 -2.0 1e-12
+4.534e+01 .34534 0.43654
attribute "dep" string "positions"
"""
try:
tok = self... |
Level - 2 parser for a DX field object. | def __field(self):
"""Level-2 parser for a DX field object.
pattern:
object "site map 1" class field
component "positions" value 1
component "connections" value 2
component "data" value 3
"""
try:
tok = self.__consume()
except DXParser... |
Set parsername as the current parser and apply it. | def use_parser(self,parsername):
"""Set parsername as the current parser and apply it."""
self.__parser = self.parsers[parsername]
self.__parser() |
Split s into tokens and update the token buffer. | def __tokenize(self,string):
"""Split s into tokens and update the token buffer.
__tokenize(string)
New tokens are appended to the token buffer, discarding white
space. Based on http://effbot.org/zone/xml-scanner.htm
"""
for m in self.dx_regex.finditer(string.strip()):... |
Add a new tokenized line from the file to the token buffer. | def __refill_tokenbuffer(self):
"""Add a new tokenized line from the file to the token buffer.
__refill_tokenbuffer()
Only reads a new line if the buffer is empty. It is safe to
call it repeatedly.
At end of file, method returns empty strings and it is up to
__peek and... |
Populate the instance from the plt file * filename *. | def read(self, filename):
"""Populate the instance from the plt file *filename*."""
from struct import calcsize, unpack
if not filename is None:
self.filename = filename
with open(self.filename, 'rb') as plt:
h = self.header = self._read_header(plt)
ne... |
Read header bytes try all possibilities for byte order/ size/ alignment. | def _read_header(self, pltfile):
"""Read header bytes, try all possibilities for byte order/size/alignment."""
nheader = struct.calcsize(self._headerfmt)
names = [r.key for r in self._header_struct]
binheader = pltfile.read(nheader)
def decode_header(bsaflag='@'):
h =... |
Return a mesh grid for N dimensions. | def ndmeshgrid(*arrs):
"""Return a mesh grid for N dimensions.
The input are N arrays, each of which contains the values along one axis of
the coordinate system. The arrays do not have to have the same number of
entries. The function returns arrays that can be fed into numpy functions
so that they ... |
Resample data to a new grid with edges * edges *. | def resample(self, edges):
"""Resample data to a new grid with edges *edges*.
This method creates a new grid with the data from the current
grid resampled to a regular grid specified by *edges*. The
order of the interpolation is set by
:attr:`Grid.interpolation_spline_order`: c... |
Resample to a new regular grid. | def resample_factor(self, factor):
"""Resample to a new regular grid.
Parameters
----------
factor : float
The number of grid cells are scaled with `factor` in each
dimension, i.e., ``factor * N_i`` cells along each
dimension i.
Returns
... |
compute/ update all derived data | def _update(self):
"""compute/update all derived data
Can be called without harm and is idem-potent.
Updates these attributes and methods:
:attr:`origin`
the center of the cell with index 0,0,0
:attr:`midpoints`
centre coordinate of each grid c... |
B - spline function over the data grid ( x y z ). | def interpolated(self):
"""B-spline function over the data grid(x,y,z).
The :func:`interpolated` function allows one to obtain data
values for any values of the coordinates::
interpolated([x1,x2,...],[y1,y2,...],[z1,z2,...]) -> F[x1,y1,z1],F[x2,y2,z2],...
The interpolation ... |
Load saved ( pickled or dx ) grid and edges from <filename >. pickle | def load(self, filename, file_format=None):
"""Load saved (pickled or dx) grid and edges from <filename>.pickle
Grid.load(<filename>.pickle)
Grid.load(<filename>.dx)
The load() method calls the class's constructor method and
completely resets all values, based on the load... |
Initializes Grid from a CCP4 file. | def _load_cpp4(self, filename):
"""Initializes Grid from a CCP4 file."""
ccp4 = CCP4.CCP4()
ccp4.read(filename)
grid, edges = ccp4.histogramdd()
self.__init__(grid=grid, edges=edges, metadata=self.metadata) |
Initializes Grid from a OpenDX file. | def _load_dx(self, filename):
"""Initializes Grid from a OpenDX file."""
dx = OpenDX.field(0)
dx.read(filename)
grid, edges = dx.histogramdd()
self.__init__(grid=grid, edges=edges, metadata=self.metadata) |
Initialize Grid from gOpenMol plt file. | def _load_plt(self, filename):
"""Initialize Grid from gOpenMol plt file."""
g = gOpenMol.Plt()
g.read(filename)
grid, edges = g.histogramdd()
self.__init__(grid=grid, edges=edges, metadata=self.metadata) |
export density to file using the given format. | def export(self, filename, file_format=None, type=None, typequote='"'):
"""export density to file using the given format.
The format can also be deduced from the suffix of the filename
though the *format* keyword takes precedence.
The default format for export() is 'dx'. Use 'dx' for
... |
Pickle the Grid object | def _export_python(self, filename, **kwargs):
"""Pickle the Grid object
The object is dumped as a dictionary with grid and edges: This
is sufficient to recreate the grid object with __init__().
"""
data = dict(grid=self.grid, edges=self.edges, metadata=self.metadata)
wit... |
Export the density grid to an OpenDX file. | def _export_dx(self, filename, type=None, typequote='"', **kwargs):
"""Export the density grid to an OpenDX file.
The file format is the simplest regular grid array and it is
also understood by VMD's and Chimera's DX reader; PyMOL
requires the dx `type` to be set to "double".
F... |
Returns the coordinates of the centers of all grid cells as an iterator. | def centers(self):
"""Returns the coordinates of the centers of all grid cells as an
iterator."""
for idx in numpy.ndindex(self.grid.shape):
yield self.delta * numpy.array(idx) + self.origin |
Check if * other * can be used in an arithmetic operation. | def check_compatible(self, other):
"""Check if *other* can be used in an arithmetic operation.
1) *other* is a scalar
2) *other* is a grid defined on the same edges
:Raises: :exc:`TypeError` if not compatible.
"""
if not (numpy.isreal(other) or self == other):
... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.