id
int32
0
252k
repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
8,200
quiltdata/quilt
compiler/quilt/tools/store.py
PackageStore.prune
def prune(self, objs=None): """ Clean up objects not referenced by any packages. Try to prune all objects by default. """ if objs is None: objdir = os.path.join(self._path, self.OBJ_DIR) objs = os.listdir(objdir) remove_objs = set(objs) fo...
python
def prune(self, objs=None): """ Clean up objects not referenced by any packages. Try to prune all objects by default. """ if objs is None: objdir = os.path.join(self._path, self.OBJ_DIR) objs = os.listdir(objdir) remove_objs = set(objs) fo...
[ "def", "prune", "(", "self", ",", "objs", "=", "None", ")", ":", "if", "objs", "is", "None", ":", "objdir", "=", "os", ".", "path", ".", "join", "(", "self", ".", "_path", ",", "self", ".", "OBJ_DIR", ")", "objs", "=", "os", ".", "listdir", "("...
Clean up objects not referenced by any packages. Try to prune all objects by default.
[ "Clean", "up", "objects", "not", "referenced", "by", "any", "packages", ".", "Try", "to", "prune", "all", "objects", "by", "default", "." ]
651853e7e89a8af86e0ff26167e752efa5878c12
https://github.com/quiltdata/quilt/blob/651853e7e89a8af86e0ff26167e752efa5878c12/compiler/quilt/tools/store.py#L365-L383
8,201
quiltdata/quilt
compiler/quilt/tools/store.py
PackageStore.save_dataframe
def save_dataframe(self, dataframe): """ Save a DataFrame to the store. """ storepath = self.temporary_object_path(str(uuid.uuid4())) # switch parquet lib parqlib = self.get_parquet_lib() if isinstance(dataframe, pd.DataFrame): #parqlib is ParquetLib....
python
def save_dataframe(self, dataframe): """ Save a DataFrame to the store. """ storepath = self.temporary_object_path(str(uuid.uuid4())) # switch parquet lib parqlib = self.get_parquet_lib() if isinstance(dataframe, pd.DataFrame): #parqlib is ParquetLib....
[ "def", "save_dataframe", "(", "self", ",", "dataframe", ")", ":", "storepath", "=", "self", ".", "temporary_object_path", "(", "str", "(", "uuid", ".", "uuid4", "(", ")", ")", ")", "# switch parquet lib", "parqlib", "=", "self", ".", "get_parquet_lib", "(", ...
Save a DataFrame to the store.
[ "Save", "a", "DataFrame", "to", "the", "store", "." ]
651853e7e89a8af86e0ff26167e752efa5878c12
https://github.com/quiltdata/quilt/blob/651853e7e89a8af86e0ff26167e752efa5878c12/compiler/quilt/tools/store.py#L436-L472
8,202
quiltdata/quilt
compiler/quilt/tools/store.py
PackageStore.load_numpy
def load_numpy(self, hash_list): """ Loads a numpy array. """ assert len(hash_list) == 1 self._check_hashes(hash_list) with open(self.object_path(hash_list[0]), 'rb') as fd: return np.load(fd, allow_pickle=False)
python
def load_numpy(self, hash_list): """ Loads a numpy array. """ assert len(hash_list) == 1 self._check_hashes(hash_list) with open(self.object_path(hash_list[0]), 'rb') as fd: return np.load(fd, allow_pickle=False)
[ "def", "load_numpy", "(", "self", ",", "hash_list", ")", ":", "assert", "len", "(", "hash_list", ")", "==", "1", "self", ".", "_check_hashes", "(", "hash_list", ")", "with", "open", "(", "self", ".", "object_path", "(", "hash_list", "[", "0", "]", ")",...
Loads a numpy array.
[ "Loads", "a", "numpy", "array", "." ]
651853e7e89a8af86e0ff26167e752efa5878c12
https://github.com/quiltdata/quilt/blob/651853e7e89a8af86e0ff26167e752efa5878c12/compiler/quilt/tools/store.py#L474-L481
8,203
quiltdata/quilt
compiler/quilt/tools/store.py
PackageStore.get_file
def get_file(self, hash_list): """ Returns the path of the file - but verifies that the hash is actually present. """ assert len(hash_list) == 1 self._check_hashes(hash_list) return self.object_path(hash_list[0])
python
def get_file(self, hash_list): """ Returns the path of the file - but verifies that the hash is actually present. """ assert len(hash_list) == 1 self._check_hashes(hash_list) return self.object_path(hash_list[0])
[ "def", "get_file", "(", "self", ",", "hash_list", ")", ":", "assert", "len", "(", "hash_list", ")", "==", "1", "self", ".", "_check_hashes", "(", "hash_list", ")", "return", "self", ".", "object_path", "(", "hash_list", "[", "0", "]", ")" ]
Returns the path of the file - but verifies that the hash is actually present.
[ "Returns", "the", "path", "of", "the", "file", "-", "but", "verifies", "that", "the", "hash", "is", "actually", "present", "." ]
651853e7e89a8af86e0ff26167e752efa5878c12
https://github.com/quiltdata/quilt/blob/651853e7e89a8af86e0ff26167e752efa5878c12/compiler/quilt/tools/store.py#L493-L499
8,204
quiltdata/quilt
compiler/quilt/tools/store.py
PackageStore.save_metadata
def save_metadata(self, metadata): """ Save metadata to the store. """ if metadata in (None, {}): return None if SYSTEM_METADATA in metadata: raise StoreException("Not allowed to store %r in metadata" % SYSTEM_METADATA) path = self.temporary_obje...
python
def save_metadata(self, metadata): """ Save metadata to the store. """ if metadata in (None, {}): return None if SYSTEM_METADATA in metadata: raise StoreException("Not allowed to store %r in metadata" % SYSTEM_METADATA) path = self.temporary_obje...
[ "def", "save_metadata", "(", "self", ",", "metadata", ")", ":", "if", "metadata", "in", "(", "None", ",", "{", "}", ")", ":", "return", "None", "if", "SYSTEM_METADATA", "in", "metadata", ":", "raise", "StoreException", "(", "\"Not allowed to store %r in metada...
Save metadata to the store.
[ "Save", "metadata", "to", "the", "store", "." ]
651853e7e89a8af86e0ff26167e752efa5878c12
https://github.com/quiltdata/quilt/blob/651853e7e89a8af86e0ff26167e752efa5878c12/compiler/quilt/tools/store.py#L521-L544
8,205
quiltdata/quilt
compiler/quilt/tools/store.py
PackageStore.save_package_contents
def save_package_contents(self, root, team, owner, pkgname): """ Saves the in-memory contents to a file in the local package repository. """ assert isinstance(root, RootNode) instance_hash = hash_contents(root) pkg_path = self.package_path(team, owner, pkgname) ...
python
def save_package_contents(self, root, team, owner, pkgname): """ Saves the in-memory contents to a file in the local package repository. """ assert isinstance(root, RootNode) instance_hash = hash_contents(root) pkg_path = self.package_path(team, owner, pkgname) ...
[ "def", "save_package_contents", "(", "self", ",", "root", ",", "team", ",", "owner", ",", "pkgname", ")", ":", "assert", "isinstance", "(", "root", ",", "RootNode", ")", "instance_hash", "=", "hash_contents", "(", "root", ")", "pkg_path", "=", "self", ".",...
Saves the in-memory contents to a file in the local package repository.
[ "Saves", "the", "in", "-", "memory", "contents", "to", "a", "file", "in", "the", "local", "package", "repository", "." ]
651853e7e89a8af86e0ff26167e752efa5878c12
https://github.com/quiltdata/quilt/blob/651853e7e89a8af86e0ff26167e752efa5878c12/compiler/quilt/tools/store.py#L546-L570
8,206
quiltdata/quilt
compiler/quilt/tools/store.py
PackageStore._move_to_store
def _move_to_store(self, srcpath, objhash): """ Make the object read-only and move it to the store. """ destpath = self.object_path(objhash) if os.path.exists(destpath): # Windows: delete any existing object at the destination. os.chmod(destpath, S_IWUSR) ...
python
def _move_to_store(self, srcpath, objhash): """ Make the object read-only and move it to the store. """ destpath = self.object_path(objhash) if os.path.exists(destpath): # Windows: delete any existing object at the destination. os.chmod(destpath, S_IWUSR) ...
[ "def", "_move_to_store", "(", "self", ",", "srcpath", ",", "objhash", ")", ":", "destpath", "=", "self", ".", "object_path", "(", "objhash", ")", "if", "os", ".", "path", ".", "exists", "(", "destpath", ")", ":", "# Windows: delete any existing object at the d...
Make the object read-only and move it to the store.
[ "Make", "the", "object", "read", "-", "only", "and", "move", "it", "to", "the", "store", "." ]
651853e7e89a8af86e0ff26167e752efa5878c12
https://github.com/quiltdata/quilt/blob/651853e7e89a8af86e0ff26167e752efa5878c12/compiler/quilt/tools/store.py#L572-L582
8,207
quiltdata/quilt
compiler/quilt/tools/store.py
PackageStore.add_to_package_numpy
def add_to_package_numpy(self, root, ndarray, node_path, target, source_path, transform, custom_meta): """ Save a Numpy array to the store. """ filehash = self.save_numpy(ndarray) metahash = self.save_metadata(custom_meta) self._add_to_package_contents(root, node_path, [f...
python
def add_to_package_numpy(self, root, ndarray, node_path, target, source_path, transform, custom_meta): """ Save a Numpy array to the store. """ filehash = self.save_numpy(ndarray) metahash = self.save_metadata(custom_meta) self._add_to_package_contents(root, node_path, [f...
[ "def", "add_to_package_numpy", "(", "self", ",", "root", ",", "ndarray", ",", "node_path", ",", "target", ",", "source_path", ",", "transform", ",", "custom_meta", ")", ":", "filehash", "=", "self", ".", "save_numpy", "(", "ndarray", ")", "metahash", "=", ...
Save a Numpy array to the store.
[ "Save", "a", "Numpy", "array", "to", "the", "store", "." ]
651853e7e89a8af86e0ff26167e752efa5878c12
https://github.com/quiltdata/quilt/blob/651853e7e89a8af86e0ff26167e752efa5878c12/compiler/quilt/tools/store.py#L638-L644
8,208
quiltdata/quilt
compiler/quilt/tools/store.py
PackageStore.add_to_package_package_tree
def add_to_package_package_tree(self, root, node_path, pkgnode): """ Adds a package or sub-package tree from an existing package to this package's contents. """ if node_path: ptr = root for node in node_path[:-1]: ptr = ptr.children.setdefa...
python
def add_to_package_package_tree(self, root, node_path, pkgnode): """ Adds a package or sub-package tree from an existing package to this package's contents. """ if node_path: ptr = root for node in node_path[:-1]: ptr = ptr.children.setdefa...
[ "def", "add_to_package_package_tree", "(", "self", ",", "root", ",", "node_path", ",", "pkgnode", ")", ":", "if", "node_path", ":", "ptr", "=", "root", "for", "node", "in", "node_path", "[", ":", "-", "1", "]", ":", "ptr", "=", "ptr", ".", "children", ...
Adds a package or sub-package tree from an existing package to this package's contents.
[ "Adds", "a", "package", "or", "sub", "-", "package", "tree", "from", "an", "existing", "package", "to", "this", "package", "s", "contents", "." ]
651853e7e89a8af86e0ff26167e752efa5878c12
https://github.com/quiltdata/quilt/blob/651853e7e89a8af86e0ff26167e752efa5878c12/compiler/quilt/tools/store.py#L658-L671
8,209
quiltdata/quilt
compiler/quilt/__init__.py
_install_interrupt_handler
def _install_interrupt_handler(): """Suppress KeyboardInterrupt traceback display in specific situations If not running in dev mode, and if executed from the command line, then we raise SystemExit instead of KeyboardInterrupt. This provides a clean exit. :returns: None if no action is taken, orig...
python
def _install_interrupt_handler(): """Suppress KeyboardInterrupt traceback display in specific situations If not running in dev mode, and if executed from the command line, then we raise SystemExit instead of KeyboardInterrupt. This provides a clean exit. :returns: None if no action is taken, orig...
[ "def", "_install_interrupt_handler", "(", ")", ":", "# These would clutter the quilt.x namespace, so they're imported here instead.", "import", "os", "import", "sys", "import", "signal", "import", "pkg_resources", "from", ".", "tools", "import", "const", "# Check to see what en...
Suppress KeyboardInterrupt traceback display in specific situations If not running in dev mode, and if executed from the command line, then we raise SystemExit instead of KeyboardInterrupt. This provides a clean exit. :returns: None if no action is taken, original interrupt handler otherwise
[ "Suppress", "KeyboardInterrupt", "traceback", "display", "in", "specific", "situations" ]
651853e7e89a8af86e0ff26167e752efa5878c12
https://github.com/quiltdata/quilt/blob/651853e7e89a8af86e0ff26167e752efa5878c12/compiler/quilt/__init__.py#L23-L80
8,210
quiltdata/quilt
compiler/quilt/nodes.py
GroupNode._data_keys
def _data_keys(self): """ every child key referencing a dataframe """ return [name for name, child in iteritems(self._children) if not isinstance(child, GroupNode)]
python
def _data_keys(self): """ every child key referencing a dataframe """ return [name for name, child in iteritems(self._children) if not isinstance(child, GroupNode)]
[ "def", "_data_keys", "(", "self", ")", ":", "return", "[", "name", "for", "name", ",", "child", "in", "iteritems", "(", "self", ".", "_children", ")", "if", "not", "isinstance", "(", "child", ",", "GroupNode", ")", "]" ]
every child key referencing a dataframe
[ "every", "child", "key", "referencing", "a", "dataframe" ]
651853e7e89a8af86e0ff26167e752efa5878c12
https://github.com/quiltdata/quilt/blob/651853e7e89a8af86e0ff26167e752efa5878c12/compiler/quilt/nodes.py#L162-L166
8,211
quiltdata/quilt
compiler/quilt/nodes.py
GroupNode._group_keys
def _group_keys(self): """ every child key referencing a group that is not a dataframe """ return [name for name, child in iteritems(self._children) if isinstance(child, GroupNode)]
python
def _group_keys(self): """ every child key referencing a group that is not a dataframe """ return [name for name, child in iteritems(self._children) if isinstance(child, GroupNode)]
[ "def", "_group_keys", "(", "self", ")", ":", "return", "[", "name", "for", "name", ",", "child", "in", "iteritems", "(", "self", ".", "_children", ")", "if", "isinstance", "(", "child", ",", "GroupNode", ")", "]" ]
every child key referencing a group that is not a dataframe
[ "every", "child", "key", "referencing", "a", "group", "that", "is", "not", "a", "dataframe" ]
651853e7e89a8af86e0ff26167e752efa5878c12
https://github.com/quiltdata/quilt/blob/651853e7e89a8af86e0ff26167e752efa5878c12/compiler/quilt/nodes.py#L168-L172
8,212
quiltdata/quilt
compiler/quilt/nodes.py
GroupNode._data
def _data(self, asa=None): """ Merges all child dataframes. Only works for dataframes stored on disk - not in memory. """ hash_list = [] stack = [self] alldfs = True store = None while stack: node = stack.pop() if isinstance(node, G...
python
def _data(self, asa=None): """ Merges all child dataframes. Only works for dataframes stored on disk - not in memory. """ hash_list = [] stack = [self] alldfs = True store = None while stack: node = stack.pop() if isinstance(node, G...
[ "def", "_data", "(", "self", ",", "asa", "=", "None", ")", ":", "hash_list", "=", "[", "]", "stack", "=", "[", "self", "]", "alldfs", "=", "True", "store", "=", "None", "while", "stack", ":", "node", "=", "stack", ".", "pop", "(", ")", "if", "i...
Merges all child dataframes. Only works for dataframes stored on disk - not in memory.
[ "Merges", "all", "child", "dataframes", ".", "Only", "works", "for", "dataframes", "stored", "on", "disk", "-", "not", "in", "memory", "." ]
651853e7e89a8af86e0ff26167e752efa5878c12
https://github.com/quiltdata/quilt/blob/651853e7e89a8af86e0ff26167e752efa5878c12/compiler/quilt/nodes.py#L184-L220
8,213
quiltdata/quilt
compiler/quilt/nodes.py
GroupNode._set
def _set(self, path, value, build_dir=''): """Create and set a node by path This creates a node from a filename or pandas DataFrame. If `value` is a filename, it must be relative to `build_dir`. `value` is stored as the export path. `build_dir` defaults to the current dire...
python
def _set(self, path, value, build_dir=''): """Create and set a node by path This creates a node from a filename or pandas DataFrame. If `value` is a filename, it must be relative to `build_dir`. `value` is stored as the export path. `build_dir` defaults to the current dire...
[ "def", "_set", "(", "self", ",", "path", ",", "value", ",", "build_dir", "=", "''", ")", ":", "assert", "isinstance", "(", "path", ",", "list", ")", "and", "len", "(", "path", ")", ">", "0", "if", "isinstance", "(", "value", ",", "pd", ".", "Data...
Create and set a node by path This creates a node from a filename or pandas DataFrame. If `value` is a filename, it must be relative to `build_dir`. `value` is stored as the export path. `build_dir` defaults to the current directory, but may be any arbitrary directory ...
[ "Create", "and", "set", "a", "node", "by", "path" ]
651853e7e89a8af86e0ff26167e752efa5878c12
https://github.com/quiltdata/quilt/blob/651853e7e89a8af86e0ff26167e752efa5878c12/compiler/quilt/nodes.py#L222-L276
8,214
quiltdata/quilt
registry/quilt_server/views.py
handle_api_exception
def handle_api_exception(error): """ Converts an API exception into an error response. """ _mp_track( type="exception", status_code=error.status_code, message=error.message, ) response = jsonify(dict( message=error.message )) response.status_code = error....
python
def handle_api_exception(error): """ Converts an API exception into an error response. """ _mp_track( type="exception", status_code=error.status_code, message=error.message, ) response = jsonify(dict( message=error.message )) response.status_code = error....
[ "def", "handle_api_exception", "(", "error", ")", ":", "_mp_track", "(", "type", "=", "\"exception\"", ",", "status_code", "=", "error", ".", "status_code", ",", "message", "=", "error", ".", "message", ",", ")", "response", "=", "jsonify", "(", "dict", "(...
Converts an API exception into an error response.
[ "Converts", "an", "API", "exception", "into", "an", "error", "response", "." ]
651853e7e89a8af86e0ff26167e752efa5878c12
https://github.com/quiltdata/quilt/blob/651853e7e89a8af86e0ff26167e752efa5878c12/registry/quilt_server/views.py#L188-L202
8,215
quiltdata/quilt
registry/quilt_server/views.py
api
def api(require_login=True, schema=None, enabled=True, require_admin=False, require_anonymous=False): """ Decorator for API requests. Handles auth and adds the username as the first argument. """ if require_admin: require_login = True if schema is not None: Draft4Validat...
python
def api(require_login=True, schema=None, enabled=True, require_admin=False, require_anonymous=False): """ Decorator for API requests. Handles auth and adds the username as the first argument. """ if require_admin: require_login = True if schema is not None: Draft4Validat...
[ "def", "api", "(", "require_login", "=", "True", ",", "schema", "=", "None", ",", "enabled", "=", "True", ",", "require_admin", "=", "False", ",", "require_anonymous", "=", "False", ")", ":", "if", "require_admin", ":", "require_login", "=", "True", "if", ...
Decorator for API requests. Handles auth and adds the username as the first argument.
[ "Decorator", "for", "API", "requests", ".", "Handles", "auth", "and", "adds", "the", "username", "as", "the", "first", "argument", "." ]
651853e7e89a8af86e0ff26167e752efa5878c12
https://github.com/quiltdata/quilt/blob/651853e7e89a8af86e0ff26167e752efa5878c12/registry/quilt_server/views.py#L204-L283
8,216
quiltdata/quilt
registry/quilt_server/views.py
_private_packages_allowed
def _private_packages_allowed(): """ Checks if the current user is allowed to create private packages. In the public cloud, the user needs to be on a paid plan. There are no restrictions in other deployments. """ if not HAVE_PAYMENTS or TEAM_ID: return True customer = _get_or_creat...
python
def _private_packages_allowed(): """ Checks if the current user is allowed to create private packages. In the public cloud, the user needs to be on a paid plan. There are no restrictions in other deployments. """ if not HAVE_PAYMENTS or TEAM_ID: return True customer = _get_or_creat...
[ "def", "_private_packages_allowed", "(", ")", ":", "if", "not", "HAVE_PAYMENTS", "or", "TEAM_ID", ":", "return", "True", "customer", "=", "_get_or_create_customer", "(", ")", "plan", "=", "_get_customer_plan", "(", "customer", ")", "return", "plan", "!=", "Payme...
Checks if the current user is allowed to create private packages. In the public cloud, the user needs to be on a paid plan. There are no restrictions in other deployments.
[ "Checks", "if", "the", "current", "user", "is", "allowed", "to", "create", "private", "packages", "." ]
651853e7e89a8af86e0ff26167e752efa5878c12
https://github.com/quiltdata/quilt/blob/651853e7e89a8af86e0ff26167e752efa5878c12/registry/quilt_server/views.py#L566-L578
8,217
quiltdata/quilt
compiler/quilt/tools/command.py
_create_auth
def _create_auth(team, timeout=None): """ Reads the credentials, updates the access token if necessary, and returns it. """ url = get_registry_url(team) contents = _load_auth() auth = contents.get(url) if auth is not None: # If the access token expires within a minute, update it. ...
python
def _create_auth(team, timeout=None): """ Reads the credentials, updates the access token if necessary, and returns it. """ url = get_registry_url(team) contents = _load_auth() auth = contents.get(url) if auth is not None: # If the access token expires within a minute, update it. ...
[ "def", "_create_auth", "(", "team", ",", "timeout", "=", "None", ")", ":", "url", "=", "get_registry_url", "(", "team", ")", "contents", "=", "_load_auth", "(", ")", "auth", "=", "contents", ".", "get", "(", "url", ")", "if", "auth", "is", "not", "No...
Reads the credentials, updates the access token if necessary, and returns it.
[ "Reads", "the", "credentials", "updates", "the", "access", "token", "if", "necessary", "and", "returns", "it", "." ]
651853e7e89a8af86e0ff26167e752efa5878c12
https://github.com/quiltdata/quilt/blob/651853e7e89a8af86e0ff26167e752efa5878c12/compiler/quilt/tools/command.py#L227-L248
8,218
quiltdata/quilt
compiler/quilt/tools/command.py
_create_session
def _create_session(team, auth): """ Creates a session object to be used for `push`, `install`, etc. """ session = requests.Session() session.hooks.update(dict( response=partial(_handle_response, team) )) session.headers.update({ "Content-Type": "application/json", "A...
python
def _create_session(team, auth): """ Creates a session object to be used for `push`, `install`, etc. """ session = requests.Session() session.hooks.update(dict( response=partial(_handle_response, team) )) session.headers.update({ "Content-Type": "application/json", "A...
[ "def", "_create_session", "(", "team", ",", "auth", ")", ":", "session", "=", "requests", ".", "Session", "(", ")", "session", ".", "hooks", ".", "update", "(", "dict", "(", "response", "=", "partial", "(", "_handle_response", ",", "team", ")", ")", ")...
Creates a session object to be used for `push`, `install`, etc.
[ "Creates", "a", "session", "object", "to", "be", "used", "for", "push", "install", "etc", "." ]
651853e7e89a8af86e0ff26167e752efa5878c12
https://github.com/quiltdata/quilt/blob/651853e7e89a8af86e0ff26167e752efa5878c12/compiler/quilt/tools/command.py#L250-L269
8,219
quiltdata/quilt
compiler/quilt/tools/command.py
_get_session
def _get_session(team, timeout=None): """ Creates a session or returns an existing session. """ global _sessions # pylint:disable=C0103 session = _sessions.get(team) if session is None: auth = _create_auth(team, timeout) _sessions[team] = session = _create_session(team...
python
def _get_session(team, timeout=None): """ Creates a session or returns an existing session. """ global _sessions # pylint:disable=C0103 session = _sessions.get(team) if session is None: auth = _create_auth(team, timeout) _sessions[team] = session = _create_session(team...
[ "def", "_get_session", "(", "team", ",", "timeout", "=", "None", ")", ":", "global", "_sessions", "# pylint:disable=C0103", "session", "=", "_sessions", ".", "get", "(", "team", ")", "if", "session", "is", "None", ":", "auth", "=", "_create_auth", "(", "te...
Creates a session or returns an existing session.
[ "Creates", "a", "session", "or", "returns", "an", "existing", "session", "." ]
651853e7e89a8af86e0ff26167e752efa5878c12
https://github.com/quiltdata/quilt/blob/651853e7e89a8af86e0ff26167e752efa5878c12/compiler/quilt/tools/command.py#L273-L285
8,220
quiltdata/quilt
compiler/quilt/tools/command.py
_check_team_login
def _check_team_login(team): """ Disallow simultaneous public cloud and team logins. """ contents = _load_auth() for auth in itervalues(contents): existing_team = auth.get('team') if team and team != existing_team: raise CommandException( "Can't log in as...
python
def _check_team_login(team): """ Disallow simultaneous public cloud and team logins. """ contents = _load_auth() for auth in itervalues(contents): existing_team = auth.get('team') if team and team != existing_team: raise CommandException( "Can't log in as...
[ "def", "_check_team_login", "(", "team", ")", ":", "contents", "=", "_load_auth", "(", ")", "for", "auth", "in", "itervalues", "(", "contents", ")", ":", "existing_team", "=", "auth", ".", "get", "(", "'team'", ")", "if", "team", "and", "team", "!=", "...
Disallow simultaneous public cloud and team logins.
[ "Disallow", "simultaneous", "public", "cloud", "and", "team", "logins", "." ]
651853e7e89a8af86e0ff26167e752efa5878c12
https://github.com/quiltdata/quilt/blob/651853e7e89a8af86e0ff26167e752efa5878c12/compiler/quilt/tools/command.py#L351-L366
8,221
quiltdata/quilt
compiler/quilt/tools/command.py
_check_team_exists
def _check_team_exists(team): """ Check that the team registry actually exists. """ if team is None: return hostname = urlparse(get_registry_url(team)).hostname try: socket.gethostbyname(hostname) except IOError: try: # Do we have internet? so...
python
def _check_team_exists(team): """ Check that the team registry actually exists. """ if team is None: return hostname = urlparse(get_registry_url(team)).hostname try: socket.gethostbyname(hostname) except IOError: try: # Do we have internet? so...
[ "def", "_check_team_exists", "(", "team", ")", ":", "if", "team", "is", "None", ":", "return", "hostname", "=", "urlparse", "(", "get_registry_url", "(", "team", ")", ")", ".", "hostname", "try", ":", "socket", ".", "gethostbyname", "(", "hostname", ")", ...
Check that the team registry actually exists.
[ "Check", "that", "the", "team", "registry", "actually", "exists", "." ]
651853e7e89a8af86e0ff26167e752efa5878c12
https://github.com/quiltdata/quilt/blob/651853e7e89a8af86e0ff26167e752efa5878c12/compiler/quilt/tools/command.py#L375-L393
8,222
quiltdata/quilt
compiler/quilt/tools/command.py
login_with_token
def login_with_token(refresh_token, team=None): """ Authenticate using an existing token. """ # Get an access token and a new refresh token. _check_team_id(team) auth = _update_auth(team, refresh_token) url = get_registry_url(team) contents = _load_auth() contents[url] = auth _s...
python
def login_with_token(refresh_token, team=None): """ Authenticate using an existing token. """ # Get an access token and a new refresh token. _check_team_id(team) auth = _update_auth(team, refresh_token) url = get_registry_url(team) contents = _load_auth() contents[url] = auth _s...
[ "def", "login_with_token", "(", "refresh_token", ",", "team", "=", "None", ")", ":", "# Get an access token and a new refresh token.", "_check_team_id", "(", "team", ")", "auth", "=", "_update_auth", "(", "team", ",", "refresh_token", ")", "url", "=", "get_registry_...
Authenticate using an existing token.
[ "Authenticate", "using", "an", "existing", "token", "." ]
651853e7e89a8af86e0ff26167e752efa5878c12
https://github.com/quiltdata/quilt/blob/651853e7e89a8af86e0ff26167e752efa5878c12/compiler/quilt/tools/command.py#L417-L430
8,223
quiltdata/quilt
compiler/quilt/tools/command.py
generate
def generate(directory, outfilename=DEFAULT_BUILDFILE): """ Generate a build-file for quilt build from a directory of source files. """ try: buildfilepath = generate_build_file(directory, outfilename=outfilename) except BuildException as builderror: raise CommandException(str(bui...
python
def generate(directory, outfilename=DEFAULT_BUILDFILE): """ Generate a build-file for quilt build from a directory of source files. """ try: buildfilepath = generate_build_file(directory, outfilename=outfilename) except BuildException as builderror: raise CommandException(str(bui...
[ "def", "generate", "(", "directory", ",", "outfilename", "=", "DEFAULT_BUILDFILE", ")", ":", "try", ":", "buildfilepath", "=", "generate_build_file", "(", "directory", ",", "outfilename", "=", "outfilename", ")", "except", "BuildException", "as", "builderror", ":"...
Generate a build-file for quilt build from a directory of source files.
[ "Generate", "a", "build", "-", "file", "for", "quilt", "build", "from", "a", "directory", "of", "source", "files", "." ]
651853e7e89a8af86e0ff26167e752efa5878c12
https://github.com/quiltdata/quilt/blob/651853e7e89a8af86e0ff26167e752efa5878c12/compiler/quilt/tools/command.py#L445-L455
8,224
quiltdata/quilt
compiler/quilt/tools/command.py
build
def build(package, path=None, dry_run=False, env='default', force=False, build_file=False): """ Compile a Quilt data package, either from a build file or an existing package node. :param package: short package specifier, i.e. 'team:user/pkg' :param path: file path, git url, or existing package node ...
python
def build(package, path=None, dry_run=False, env='default', force=False, build_file=False): """ Compile a Quilt data package, either from a build file or an existing package node. :param package: short package specifier, i.e. 'team:user/pkg' :param path: file path, git url, or existing package node ...
[ "def", "build", "(", "package", ",", "path", "=", "None", ",", "dry_run", "=", "False", ",", "env", "=", "'default'", ",", "force", "=", "False", ",", "build_file", "=", "False", ")", ":", "# TODO: rename 'path' param to 'target'?", "team", ",", "_", ",", ...
Compile a Quilt data package, either from a build file or an existing package node. :param package: short package specifier, i.e. 'team:user/pkg' :param path: file path, git url, or existing package node
[ "Compile", "a", "Quilt", "data", "package", "either", "from", "a", "build", "file", "or", "an", "existing", "package", "node", "." ]
651853e7e89a8af86e0ff26167e752efa5878c12
https://github.com/quiltdata/quilt/blob/651853e7e89a8af86e0ff26167e752efa5878c12/compiler/quilt/tools/command.py#L502-L533
8,225
quiltdata/quilt
compiler/quilt/tools/command.py
build_from_node
def build_from_node(package, node): """ Compile a Quilt data package from an existing package node. """ team, owner, pkg, subpath = parse_package(package, allow_subpath=True) _check_team_id(team) store = PackageStore() pkg_root = get_or_create_package(store, team, owner, pkg, subpath) ...
python
def build_from_node(package, node): """ Compile a Quilt data package from an existing package node. """ team, owner, pkg, subpath = parse_package(package, allow_subpath=True) _check_team_id(team) store = PackageStore() pkg_root = get_or_create_package(store, team, owner, pkg, subpath) ...
[ "def", "build_from_node", "(", "package", ",", "node", ")", ":", "team", ",", "owner", ",", "pkg", ",", "subpath", "=", "parse_package", "(", "package", ",", "allow_subpath", "=", "True", ")", "_check_team_id", "(", "team", ")", "store", "=", "PackageStore...
Compile a Quilt data package from an existing package node.
[ "Compile", "a", "Quilt", "data", "package", "from", "an", "existing", "package", "node", "." ]
651853e7e89a8af86e0ff26167e752efa5878c12
https://github.com/quiltdata/quilt/blob/651853e7e89a8af86e0ff26167e752efa5878c12/compiler/quilt/tools/command.py#L568-L618
8,226
quiltdata/quilt
compiler/quilt/tools/command.py
build_from_path
def build_from_path(package, path, dry_run=False, env='default', outfilename=DEFAULT_BUILDFILE): """ Compile a Quilt data package from a build file. Path can be a directory, in which case the build file will be generated automatically. """ team, owner, pkg, subpath = parse_package(package, allow_sub...
python
def build_from_path(package, path, dry_run=False, env='default', outfilename=DEFAULT_BUILDFILE): """ Compile a Quilt data package from a build file. Path can be a directory, in which case the build file will be generated automatically. """ team, owner, pkg, subpath = parse_package(package, allow_sub...
[ "def", "build_from_path", "(", "package", ",", "path", ",", "dry_run", "=", "False", ",", "env", "=", "'default'", ",", "outfilename", "=", "DEFAULT_BUILDFILE", ")", ":", "team", ",", "owner", ",", "pkg", ",", "subpath", "=", "parse_package", "(", "package...
Compile a Quilt data package from a build file. Path can be a directory, in which case the build file will be generated automatically.
[ "Compile", "a", "Quilt", "data", "package", "from", "a", "build", "file", ".", "Path", "can", "be", "a", "directory", "in", "which", "case", "the", "build", "file", "will", "be", "generated", "automatically", "." ]
651853e7e89a8af86e0ff26167e752efa5878c12
https://github.com/quiltdata/quilt/blob/651853e7e89a8af86e0ff26167e752efa5878c12/compiler/quilt/tools/command.py#L620-L646
8,227
quiltdata/quilt
compiler/quilt/tools/command.py
log
def log(package): """ List all of the changes to a package on the server. """ team, owner, pkg = parse_package(package) session = _get_session(team) response = session.get( "{url}/api/log/{owner}/{pkg}/".format( url=get_registry_url(team), owner=owner, ...
python
def log(package): """ List all of the changes to a package on the server. """ team, owner, pkg = parse_package(package) session = _get_session(team) response = session.get( "{url}/api/log/{owner}/{pkg}/".format( url=get_registry_url(team), owner=owner, ...
[ "def", "log", "(", "package", ")", ":", "team", ",", "owner", ",", "pkg", "=", "parse_package", "(", "package", ")", "session", "=", "_get_session", "(", "team", ")", "response", "=", "session", ".", "get", "(", "\"{url}/api/log/{owner}/{pkg}/\"", ".", "fo...
List all of the changes to a package on the server.
[ "List", "all", "of", "the", "changes", "to", "a", "package", "on", "the", "server", "." ]
651853e7e89a8af86e0ff26167e752efa5878c12
https://github.com/quiltdata/quilt/blob/651853e7e89a8af86e0ff26167e752efa5878c12/compiler/quilt/tools/command.py#L648-L669
8,228
quiltdata/quilt
compiler/quilt/tools/command.py
push
def push(package, is_public=False, is_team=False, reupload=False, hash=None): """ Push a Quilt data package to the server """ team, owner, pkg, subpath = parse_package(package, allow_subpath=True) _check_team_id(team) session = _get_session(team) store, pkgroot = PackageStore.find_package(t...
python
def push(package, is_public=False, is_team=False, reupload=False, hash=None): """ Push a Quilt data package to the server """ team, owner, pkg, subpath = parse_package(package, allow_subpath=True) _check_team_id(team) session = _get_session(team) store, pkgroot = PackageStore.find_package(t...
[ "def", "push", "(", "package", ",", "is_public", "=", "False", ",", "is_team", "=", "False", ",", "reupload", "=", "False", ",", "hash", "=", "None", ")", ":", "team", ",", "owner", ",", "pkg", ",", "subpath", "=", "parse_package", "(", "package", ",...
Push a Quilt data package to the server
[ "Push", "a", "Quilt", "data", "package", "to", "the", "server" ]
651853e7e89a8af86e0ff26167e752efa5878c12
https://github.com/quiltdata/quilt/blob/651853e7e89a8af86e0ff26167e752efa5878c12/compiler/quilt/tools/command.py#L671-L766
8,229
quiltdata/quilt
compiler/quilt/tools/command.py
version_list
def version_list(package): """ List the versions of a package. """ team, owner, pkg = parse_package(package) session = _get_session(team) response = session.get( "{url}/api/version/{owner}/{pkg}/".format( url=get_registry_url(team), owner=owner, pkg=p...
python
def version_list(package): """ List the versions of a package. """ team, owner, pkg = parse_package(package) session = _get_session(team) response = session.get( "{url}/api/version/{owner}/{pkg}/".format( url=get_registry_url(team), owner=owner, pkg=p...
[ "def", "version_list", "(", "package", ")", ":", "team", ",", "owner", ",", "pkg", "=", "parse_package", "(", "package", ")", "session", "=", "_get_session", "(", "team", ")", "response", "=", "session", ".", "get", "(", "\"{url}/api/version/{owner}/{pkg}/\"",...
List the versions of a package.
[ "List", "the", "versions", "of", "a", "package", "." ]
651853e7e89a8af86e0ff26167e752efa5878c12
https://github.com/quiltdata/quilt/blob/651853e7e89a8af86e0ff26167e752efa5878c12/compiler/quilt/tools/command.py#L768-L784
8,230
quiltdata/quilt
compiler/quilt/tools/command.py
version_add
def version_add(package, version, pkghash, force=False): """ Add a new version for a given package hash. Version format needs to follow PEP 440. Versions are permanent - once created, they cannot be modified or deleted. """ team, owner, pkg = parse_package(package) session = _get_session(te...
python
def version_add(package, version, pkghash, force=False): """ Add a new version for a given package hash. Version format needs to follow PEP 440. Versions are permanent - once created, they cannot be modified or deleted. """ team, owner, pkg = parse_package(package) session = _get_session(te...
[ "def", "version_add", "(", "package", ",", "version", ",", "pkghash", ",", "force", "=", "False", ")", ":", "team", ",", "owner", ",", "pkg", "=", "parse_package", "(", "package", ")", "session", "=", "_get_session", "(", "team", ")", "try", ":", "Vers...
Add a new version for a given package hash. Version format needs to follow PEP 440. Versions are permanent - once created, they cannot be modified or deleted.
[ "Add", "a", "new", "version", "for", "a", "given", "package", "hash", "." ]
651853e7e89a8af86e0ff26167e752efa5878c12
https://github.com/quiltdata/quilt/blob/651853e7e89a8af86e0ff26167e752efa5878c12/compiler/quilt/tools/command.py#L786-L819
8,231
quiltdata/quilt
compiler/quilt/tools/command.py
tag_list
def tag_list(package): """ List the tags of a package. """ team, owner, pkg = parse_package(package) session = _get_session(team) response = session.get( "{url}/api/tag/{owner}/{pkg}/".format( url=get_registry_url(team), owner=owner, pkg=pkg )...
python
def tag_list(package): """ List the tags of a package. """ team, owner, pkg = parse_package(package) session = _get_session(team) response = session.get( "{url}/api/tag/{owner}/{pkg}/".format( url=get_registry_url(team), owner=owner, pkg=pkg )...
[ "def", "tag_list", "(", "package", ")", ":", "team", ",", "owner", ",", "pkg", "=", "parse_package", "(", "package", ")", "session", "=", "_get_session", "(", "team", ")", "response", "=", "session", ".", "get", "(", "\"{url}/api/tag/{owner}/{pkg}/\"", ".", ...
List the tags of a package.
[ "List", "the", "tags", "of", "a", "package", "." ]
651853e7e89a8af86e0ff26167e752efa5878c12
https://github.com/quiltdata/quilt/blob/651853e7e89a8af86e0ff26167e752efa5878c12/compiler/quilt/tools/command.py#L821-L837
8,232
quiltdata/quilt
compiler/quilt/tools/command.py
tag_add
def tag_add(package, tag, pkghash): """ Add a new tag for a given package hash. Unlike versions, tags can have an arbitrary format, and can be modified and deleted. When a package is pushed, it gets the "latest" tag. """ team, owner, pkg = parse_package(package) session = _get_session(...
python
def tag_add(package, tag, pkghash): """ Add a new tag for a given package hash. Unlike versions, tags can have an arbitrary format, and can be modified and deleted. When a package is pushed, it gets the "latest" tag. """ team, owner, pkg = parse_package(package) session = _get_session(...
[ "def", "tag_add", "(", "package", ",", "tag", ",", "pkghash", ")", ":", "team", ",", "owner", ",", "pkg", "=", "parse_package", "(", "package", ")", "session", "=", "_get_session", "(", "team", ")", "session", ".", "put", "(", "\"{url}/api/tag/{owner}/{pkg...
Add a new tag for a given package hash. Unlike versions, tags can have an arbitrary format, and can be modified and deleted. When a package is pushed, it gets the "latest" tag.
[ "Add", "a", "new", "tag", "for", "a", "given", "package", "hash", "." ]
651853e7e89a8af86e0ff26167e752efa5878c12
https://github.com/quiltdata/quilt/blob/651853e7e89a8af86e0ff26167e752efa5878c12/compiler/quilt/tools/command.py#L839-L861
8,233
quiltdata/quilt
compiler/quilt/tools/command.py
install_via_requirements
def install_via_requirements(requirements_str, force=False): """ Download multiple Quilt data packages via quilt.xml requirements file. """ if requirements_str[0] == '@': path = requirements_str[1:] if os.path.isfile(path): yaml_data = load_yaml(path) if 'packages...
python
def install_via_requirements(requirements_str, force=False): """ Download multiple Quilt data packages via quilt.xml requirements file. """ if requirements_str[0] == '@': path = requirements_str[1:] if os.path.isfile(path): yaml_data = load_yaml(path) if 'packages...
[ "def", "install_via_requirements", "(", "requirements_str", ",", "force", "=", "False", ")", ":", "if", "requirements_str", "[", "0", "]", "==", "'@'", ":", "path", "=", "requirements_str", "[", "1", ":", "]", "if", "os", ".", "path", ".", "isfile", "(",...
Download multiple Quilt data packages via quilt.xml requirements file.
[ "Download", "multiple", "Quilt", "data", "packages", "via", "quilt", ".", "xml", "requirements", "file", "." ]
651853e7e89a8af86e0ff26167e752efa5878c12
https://github.com/quiltdata/quilt/blob/651853e7e89a8af86e0ff26167e752efa5878c12/compiler/quilt/tools/command.py#L879-L895
8,234
quiltdata/quilt
compiler/quilt/tools/command.py
access_list
def access_list(package): """ Print list of users who can access a package. """ team, owner, pkg = parse_package(package) session = _get_session(team) lookup_url = "{url}/api/access/{owner}/{pkg}/".format(url=get_registry_url(team), owner=owner, pkg=pkg) response = session.get(lookup_url) ...
python
def access_list(package): """ Print list of users who can access a package. """ team, owner, pkg = parse_package(package) session = _get_session(team) lookup_url = "{url}/api/access/{owner}/{pkg}/".format(url=get_registry_url(team), owner=owner, pkg=pkg) response = session.get(lookup_url) ...
[ "def", "access_list", "(", "package", ")", ":", "team", ",", "owner", ",", "pkg", "=", "parse_package", "(", "package", ")", "session", "=", "_get_session", "(", "team", ")", "lookup_url", "=", "\"{url}/api/access/{owner}/{pkg}/\"", ".", "format", "(", "url", ...
Print list of users who can access a package.
[ "Print", "list", "of", "users", "who", "can", "access", "a", "package", "." ]
651853e7e89a8af86e0ff26167e752efa5878c12
https://github.com/quiltdata/quilt/blob/651853e7e89a8af86e0ff26167e752efa5878c12/compiler/quilt/tools/command.py#L1061-L1074
8,235
quiltdata/quilt
compiler/quilt/tools/command.py
delete
def delete(package): """ Delete a package from the server. Irreversibly deletes the package along with its history, tags, versions, etc. """ team, owner, pkg = parse_package(package) answer = input( "Are you sure you want to delete this package and its entire history? " "Type '...
python
def delete(package): """ Delete a package from the server. Irreversibly deletes the package along with its history, tags, versions, etc. """ team, owner, pkg = parse_package(package) answer = input( "Are you sure you want to delete this package and its entire history? " "Type '...
[ "def", "delete", "(", "package", ")", ":", "team", ",", "owner", ",", "pkg", "=", "parse_package", "(", "package", ")", "answer", "=", "input", "(", "\"Are you sure you want to delete this package and its entire history? \"", "\"Type '%s' to confirm: \"", "%", "package"...
Delete a package from the server. Irreversibly deletes the package along with its history, tags, versions, etc.
[ "Delete", "a", "package", "from", "the", "server", "." ]
651853e7e89a8af86e0ff26167e752efa5878c12
https://github.com/quiltdata/quilt/blob/651853e7e89a8af86e0ff26167e752efa5878c12/compiler/quilt/tools/command.py#L1096-L1116
8,236
quiltdata/quilt
compiler/quilt/tools/command.py
search
def search(query, team=None): """ Search for packages """ if team is None: team = _find_logged_in_team() if team is not None: session = _get_session(team) response = session.get("%s/api/search/" % get_registry_url(team), params=dict(q=query)) print("* Packages in tea...
python
def search(query, team=None): """ Search for packages """ if team is None: team = _find_logged_in_team() if team is not None: session = _get_session(team) response = session.get("%s/api/search/" % get_registry_url(team), params=dict(q=query)) print("* Packages in tea...
[ "def", "search", "(", "query", ",", "team", "=", "None", ")", ":", "if", "team", "is", "None", ":", "team", "=", "_find_logged_in_team", "(", ")", "if", "team", "is", "not", "None", ":", "session", "=", "_get_session", "(", "team", ")", "response", "...
Search for packages
[ "Search", "for", "packages" ]
651853e7e89a8af86e0ff26167e752efa5878c12
https://github.com/quiltdata/quilt/blob/651853e7e89a8af86e0ff26167e752efa5878c12/compiler/quilt/tools/command.py#L1118-L1142
8,237
quiltdata/quilt
compiler/quilt/tools/command.py
ls
def ls(): # pylint:disable=C0103 """ List all installed Quilt data packages """ for pkg_dir in PackageStore.find_store_dirs(): print("%s" % pkg_dir) packages = PackageStore(pkg_dir).ls_packages() for package, tag, pkghash in sorted(packages): pri...
python
def ls(): # pylint:disable=C0103 """ List all installed Quilt data packages """ for pkg_dir in PackageStore.find_store_dirs(): print("%s" % pkg_dir) packages = PackageStore(pkg_dir).ls_packages() for package, tag, pkghash in sorted(packages): pri...
[ "def", "ls", "(", ")", ":", "# pylint:disable=C0103", "for", "pkg_dir", "in", "PackageStore", ".", "find_store_dirs", "(", ")", ":", "print", "(", "\"%s\"", "%", "pkg_dir", ")", "packages", "=", "PackageStore", "(", "pkg_dir", ")", ".", "ls_packages", "(", ...
List all installed Quilt data packages
[ "List", "all", "installed", "Quilt", "data", "packages" ]
651853e7e89a8af86e0ff26167e752efa5878c12
https://github.com/quiltdata/quilt/blob/651853e7e89a8af86e0ff26167e752efa5878c12/compiler/quilt/tools/command.py#L1144-L1152
8,238
quiltdata/quilt
compiler/quilt/tools/command.py
inspect
def inspect(package): """ Inspect package details """ team, owner, pkg = parse_package(package) store, pkgroot = PackageStore.find_package(team, owner, pkg) if pkgroot is None: raise CommandException("Package {package} not found.".format(package=package)) def _print_children(childr...
python
def inspect(package): """ Inspect package details """ team, owner, pkg = parse_package(package) store, pkgroot = PackageStore.find_package(team, owner, pkg) if pkgroot is None: raise CommandException("Package {package} not found.".format(package=package)) def _print_children(childr...
[ "def", "inspect", "(", "package", ")", ":", "team", ",", "owner", ",", "pkg", "=", "parse_package", "(", "package", ")", "store", ",", "pkgroot", "=", "PackageStore", ".", "find_package", "(", "team", ",", "owner", ",", "pkg", ")", "if", "pkgroot", "is...
Inspect package details
[ "Inspect", "package", "details" ]
651853e7e89a8af86e0ff26167e752efa5878c12
https://github.com/quiltdata/quilt/blob/651853e7e89a8af86e0ff26167e752efa5878c12/compiler/quilt/tools/command.py#L1154-L1194
8,239
quiltdata/quilt
compiler/quilt/tools/command.py
load
def load(pkginfo, hash=None): """ functional interface to "from quilt.data.USER import PKG" """ node, pkgroot, info = _load(pkginfo, hash) for subnode_name in info.subpath: node = node[subnode_name] return node
python
def load(pkginfo, hash=None): """ functional interface to "from quilt.data.USER import PKG" """ node, pkgroot, info = _load(pkginfo, hash) for subnode_name in info.subpath: node = node[subnode_name] return node
[ "def", "load", "(", "pkginfo", ",", "hash", "=", "None", ")", ":", "node", ",", "pkgroot", ",", "info", "=", "_load", "(", "pkginfo", ",", "hash", ")", "for", "subnode_name", "in", "info", ".", "subpath", ":", "node", "=", "node", "[", "subnode_name"...
functional interface to "from quilt.data.USER import PKG"
[ "functional", "interface", "to", "from", "quilt", ".", "data", ".", "USER", "import", "PKG" ]
651853e7e89a8af86e0ff26167e752efa5878c12
https://github.com/quiltdata/quilt/blob/651853e7e89a8af86e0ff26167e752efa5878c12/compiler/quilt/tools/command.py#L1351-L1359
8,240
CalebBell/fluids
fluids/core.py
c_ideal_gas
def c_ideal_gas(T, k, MW): r'''Calculates speed of sound `c` in an ideal gas at temperature T. .. math:: c = \sqrt{kR_{specific}T} Parameters ---------- T : float Temperature of fluid, [K] k : float Isentropic exponent of fluid, [-] MW : float Molecular weig...
python
def c_ideal_gas(T, k, MW): r'''Calculates speed of sound `c` in an ideal gas at temperature T. .. math:: c = \sqrt{kR_{specific}T} Parameters ---------- T : float Temperature of fluid, [K] k : float Isentropic exponent of fluid, [-] MW : float Molecular weig...
[ "def", "c_ideal_gas", "(", "T", ",", "k", ",", "MW", ")", ":", "Rspecific", "=", "R", "*", "1000.", "/", "MW", "return", "(", "k", "*", "Rspecific", "*", "T", ")", "**", "0.5" ]
r'''Calculates speed of sound `c` in an ideal gas at temperature T. .. math:: c = \sqrt{kR_{specific}T} Parameters ---------- T : float Temperature of fluid, [K] k : float Isentropic exponent of fluid, [-] MW : float Molecular weight of fluid, [g/mol] Retur...
[ "r", "Calculates", "speed", "of", "sound", "c", "in", "an", "ideal", "gas", "at", "temperature", "T", "." ]
57f556752e039f1d3e5a822f408c184783db2828
https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/core.py#L82-L123
8,241
CalebBell/fluids
fluids/core.py
Reynolds
def Reynolds(V, D, rho=None, mu=None, nu=None): r'''Calculates Reynolds number or `Re` for a fluid with the given properties for the specified velocity and diameter. .. math:: Re = \frac{D \cdot V}{\nu} = \frac{\rho V D}{\mu} Inputs either of any of the following sets: * V, D, density `rh...
python
def Reynolds(V, D, rho=None, mu=None, nu=None): r'''Calculates Reynolds number or `Re` for a fluid with the given properties for the specified velocity and diameter. .. math:: Re = \frac{D \cdot V}{\nu} = \frac{\rho V D}{\mu} Inputs either of any of the following sets: * V, D, density `rh...
[ "def", "Reynolds", "(", "V", ",", "D", ",", "rho", "=", "None", ",", "mu", "=", "None", ",", "nu", "=", "None", ")", ":", "if", "rho", "and", "mu", ":", "nu", "=", "mu", "/", "rho", "elif", "not", "nu", ":", "raise", "Exception", "(", "'Eithe...
r'''Calculates Reynolds number or `Re` for a fluid with the given properties for the specified velocity and diameter. .. math:: Re = \frac{D \cdot V}{\nu} = \frac{\rho V D}{\mu} Inputs either of any of the following sets: * V, D, density `rho` and kinematic viscosity `mu` * V, D, and dyna...
[ "r", "Calculates", "Reynolds", "number", "or", "Re", "for", "a", "fluid", "with", "the", "given", "properties", "for", "the", "specified", "velocity", "and", "diameter", "." ]
57f556752e039f1d3e5a822f408c184783db2828
https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/core.py#L128-L184
8,242
CalebBell/fluids
fluids/core.py
Peclet_heat
def Peclet_heat(V, L, rho=None, Cp=None, k=None, alpha=None): r'''Calculates heat transfer Peclet number or `Pe` for a specified velocity `V`, characteristic length `L`, and specified properties for the given fluid. .. math:: Pe = \frac{VL\rho C_p}{k} = \frac{LV}{\alpha} Inputs either of a...
python
def Peclet_heat(V, L, rho=None, Cp=None, k=None, alpha=None): r'''Calculates heat transfer Peclet number or `Pe` for a specified velocity `V`, characteristic length `L`, and specified properties for the given fluid. .. math:: Pe = \frac{VL\rho C_p}{k} = \frac{LV}{\alpha} Inputs either of a...
[ "def", "Peclet_heat", "(", "V", ",", "L", ",", "rho", "=", "None", ",", "Cp", "=", "None", ",", "k", "=", "None", ",", "alpha", "=", "None", ")", ":", "if", "rho", "and", "Cp", "and", "k", ":", "alpha", "=", "k", "/", "(", "rho", "*", "Cp",...
r'''Calculates heat transfer Peclet number or `Pe` for a specified velocity `V`, characteristic length `L`, and specified properties for the given fluid. .. math:: Pe = \frac{VL\rho C_p}{k} = \frac{LV}{\alpha} Inputs either of any of the following sets: * V, L, density `rho`, heat capacit...
[ "r", "Calculates", "heat", "transfer", "Peclet", "number", "or", "Pe", "for", "a", "specified", "velocity", "V", "characteristic", "length", "L", "and", "specified", "properties", "for", "the", "given", "fluid", "." ]
57f556752e039f1d3e5a822f408c184783db2828
https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/core.py#L187-L246
8,243
CalebBell/fluids
fluids/core.py
Fourier_heat
def Fourier_heat(t, L, rho=None, Cp=None, k=None, alpha=None): r'''Calculates heat transfer Fourier number or `Fo` for a specified time `t`, characteristic length `L`, and specified properties for the given fluid. .. math:: Fo = \frac{k t}{C_p \rho L^2} = \frac{\alpha t}{L^2} Inputs either...
python
def Fourier_heat(t, L, rho=None, Cp=None, k=None, alpha=None): r'''Calculates heat transfer Fourier number or `Fo` for a specified time `t`, characteristic length `L`, and specified properties for the given fluid. .. math:: Fo = \frac{k t}{C_p \rho L^2} = \frac{\alpha t}{L^2} Inputs either...
[ "def", "Fourier_heat", "(", "t", ",", "L", ",", "rho", "=", "None", ",", "Cp", "=", "None", ",", "k", "=", "None", ",", "alpha", "=", "None", ")", ":", "if", "rho", "and", "Cp", "and", "k", ":", "alpha", "=", "k", "/", "(", "rho", "*", "Cp"...
r'''Calculates heat transfer Fourier number or `Fo` for a specified time `t`, characteristic length `L`, and specified properties for the given fluid. .. math:: Fo = \frac{k t}{C_p \rho L^2} = \frac{\alpha t}{L^2} Inputs either of any of the following sets: * t, L, density `rho`, heat cap...
[ "r", "Calculates", "heat", "transfer", "Fourier", "number", "or", "Fo", "for", "a", "specified", "time", "t", "characteristic", "length", "L", "and", "specified", "properties", "for", "the", "given", "fluid", "." ]
57f556752e039f1d3e5a822f408c184783db2828
https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/core.py#L288-L348
8,244
CalebBell/fluids
fluids/core.py
Graetz_heat
def Graetz_heat(V, D, x, rho=None, Cp=None, k=None, alpha=None): r'''Calculates Graetz number or `Gz` for a specified velocity `V`, diameter `D`, axial distance `x`, and specified properties for the given fluid. .. math:: Gz = \frac{VD^2\cdot C_p \rho}{x\cdot k} = \frac{VD^2}{x \alpha} Inp...
python
def Graetz_heat(V, D, x, rho=None, Cp=None, k=None, alpha=None): r'''Calculates Graetz number or `Gz` for a specified velocity `V`, diameter `D`, axial distance `x`, and specified properties for the given fluid. .. math:: Gz = \frac{VD^2\cdot C_p \rho}{x\cdot k} = \frac{VD^2}{x \alpha} Inp...
[ "def", "Graetz_heat", "(", "V", ",", "D", ",", "x", ",", "rho", "=", "None", ",", "Cp", "=", "None", ",", "k", "=", "None", ",", "alpha", "=", "None", ")", ":", "if", "rho", "and", "Cp", "and", "k", ":", "alpha", "=", "k", "/", "(", "rho", ...
r'''Calculates Graetz number or `Gz` for a specified velocity `V`, diameter `D`, axial distance `x`, and specified properties for the given fluid. .. math:: Gz = \frac{VD^2\cdot C_p \rho}{x\cdot k} = \frac{VD^2}{x \alpha} Inputs either of any of the following sets: * V, D, x, density `rho...
[ "r", "Calculates", "Graetz", "number", "or", "Gz", "for", "a", "specified", "velocity", "V", "diameter", "D", "axial", "distance", "x", "and", "specified", "properties", "for", "the", "given", "fluid", "." ]
57f556752e039f1d3e5a822f408c184783db2828
https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/core.py#L390-L454
8,245
CalebBell/fluids
fluids/core.py
Schmidt
def Schmidt(D, mu=None, nu=None, rho=None): r'''Calculates Schmidt number or `Sc` for a fluid with the given parameters. .. math:: Sc = \frac{\mu}{D\rho} = \frac{\nu}{D} Inputs can be any of the following sets: * Diffusivity, dynamic viscosity, and density * Diffusivity and kinematic ...
python
def Schmidt(D, mu=None, nu=None, rho=None): r'''Calculates Schmidt number or `Sc` for a fluid with the given parameters. .. math:: Sc = \frac{\mu}{D\rho} = \frac{\nu}{D} Inputs can be any of the following sets: * Diffusivity, dynamic viscosity, and density * Diffusivity and kinematic ...
[ "def", "Schmidt", "(", "D", ",", "mu", "=", "None", ",", "nu", "=", "None", ",", "rho", "=", "None", ")", ":", "if", "rho", "and", "mu", ":", "return", "mu", "/", "(", "rho", "*", "D", ")", "elif", "nu", ":", "return", "nu", "/", "D", "else...
r'''Calculates Schmidt number or `Sc` for a fluid with the given parameters. .. math:: Sc = \frac{\mu}{D\rho} = \frac{\nu}{D} Inputs can be any of the following sets: * Diffusivity, dynamic viscosity, and density * Diffusivity and kinematic viscosity Parameters ---------- D :...
[ "r", "Calculates", "Schmidt", "number", "or", "Sc", "for", "a", "fluid", "with", "the", "given", "parameters", "." ]
57f556752e039f1d3e5a822f408c184783db2828
https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/core.py#L457-L512
8,246
CalebBell/fluids
fluids/core.py
Lewis
def Lewis(D=None, alpha=None, Cp=None, k=None, rho=None): r'''Calculates Lewis number or `Le` for a fluid with the given parameters. .. math:: Le = \frac{k}{\rho C_p D} = \frac{\alpha}{D} Inputs can be either of the following sets: * Diffusivity and Thermal diffusivity * Diffusivity, heat...
python
def Lewis(D=None, alpha=None, Cp=None, k=None, rho=None): r'''Calculates Lewis number or `Le` for a fluid with the given parameters. .. math:: Le = \frac{k}{\rho C_p D} = \frac{\alpha}{D} Inputs can be either of the following sets: * Diffusivity and Thermal diffusivity * Diffusivity, heat...
[ "def", "Lewis", "(", "D", "=", "None", ",", "alpha", "=", "None", ",", "Cp", "=", "None", ",", "k", "=", "None", ",", "rho", "=", "None", ")", ":", "if", "k", "and", "Cp", "and", "rho", ":", "alpha", "=", "k", "/", "(", "rho", "*", "Cp", ...
r'''Calculates Lewis number or `Le` for a fluid with the given parameters. .. math:: Le = \frac{k}{\rho C_p D} = \frac{\alpha}{D} Inputs can be either of the following sets: * Diffusivity and Thermal diffusivity * Diffusivity, heat capacity, thermal conductivity, and density Parameters ...
[ "r", "Calculates", "Lewis", "number", "or", "Le", "for", "a", "fluid", "with", "the", "given", "parameters", "." ]
57f556752e039f1d3e5a822f408c184783db2828
https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/core.py#L515-L574
8,247
CalebBell/fluids
fluids/core.py
Confinement
def Confinement(D, rhol, rhog, sigma, g=g): r'''Calculates Confinement number or `Co` for a fluid in a channel of diameter `D` with liquid and gas densities `rhol` and `rhog` and surface tension `sigma`, under the influence of gravitational force `g`. .. math:: \text{Co}=\frac{\left[\frac{\sig...
python
def Confinement(D, rhol, rhog, sigma, g=g): r'''Calculates Confinement number or `Co` for a fluid in a channel of diameter `D` with liquid and gas densities `rhol` and `rhog` and surface tension `sigma`, under the influence of gravitational force `g`. .. math:: \text{Co}=\frac{\left[\frac{\sig...
[ "def", "Confinement", "(", "D", ",", "rhol", ",", "rhog", ",", "sigma", ",", "g", "=", "g", ")", ":", "return", "(", "sigma", "/", "(", "g", "*", "(", "rhol", "-", "rhog", ")", ")", ")", "**", "0.5", "/", "D" ]
r'''Calculates Confinement number or `Co` for a fluid in a channel of diameter `D` with liquid and gas densities `rhol` and `rhog` and surface tension `sigma`, under the influence of gravitational force `g`. .. math:: \text{Co}=\frac{\left[\frac{\sigma}{g(\rho_l-\rho_g)}\right]^{0.5}}{D} Para...
[ "r", "Calculates", "Confinement", "number", "or", "Co", "for", "a", "fluid", "in", "a", "channel", "of", "diameter", "D", "with", "liquid", "and", "gas", "densities", "rhol", "and", "rhog", "and", "surface", "tension", "sigma", "under", "the", "influence", ...
57f556752e039f1d3e5a822f408c184783db2828
https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/core.py#L666-L720
8,248
CalebBell/fluids
fluids/core.py
Morton
def Morton(rhol, rhog, mul, sigma, g=g): r'''Calculates Morton number or `Mo` for a liquid and vapor with the specified properties, under the influence of gravitational force `g`. .. math:: Mo = \frac{g \mu_l^4(\rho_l - \rho_g)}{\rho_l^2 \sigma^3} Parameters ---------- rhol : f...
python
def Morton(rhol, rhog, mul, sigma, g=g): r'''Calculates Morton number or `Mo` for a liquid and vapor with the specified properties, under the influence of gravitational force `g`. .. math:: Mo = \frac{g \mu_l^4(\rho_l - \rho_g)}{\rho_l^2 \sigma^3} Parameters ---------- rhol : f...
[ "def", "Morton", "(", "rhol", ",", "rhog", ",", "mul", ",", "sigma", ",", "g", "=", "g", ")", ":", "mul2", "=", "mul", "*", "mul", "return", "g", "*", "mul2", "*", "mul2", "*", "(", "rhol", "-", "rhog", ")", "/", "(", "rhol", "*", "rhol", "...
r'''Calculates Morton number or `Mo` for a liquid and vapor with the specified properties, under the influence of gravitational force `g`. .. math:: Mo = \frac{g \mu_l^4(\rho_l - \rho_g)}{\rho_l^2 \sigma^3} Parameters ---------- rhol : float Density of liquid phase, [kg/m^3...
[ "r", "Calculates", "Morton", "number", "or", "Mo", "for", "a", "liquid", "and", "vapor", "with", "the", "specified", "properties", "under", "the", "influence", "of", "gravitational", "force", "g", "." ]
57f556752e039f1d3e5a822f408c184783db2828
https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/core.py#L723-L767
8,249
CalebBell/fluids
fluids/core.py
Prandtl
def Prandtl(Cp=None, k=None, mu=None, nu=None, rho=None, alpha=None): r'''Calculates Prandtl number or `Pr` for a fluid with the given parameters. .. math:: Pr = \frac{C_p \mu}{k} = \frac{\nu}{\alpha} = \frac{C_p \rho \nu}{k} Inputs can be any of the following sets: * Heat capacity, dynam...
python
def Prandtl(Cp=None, k=None, mu=None, nu=None, rho=None, alpha=None): r'''Calculates Prandtl number or `Pr` for a fluid with the given parameters. .. math:: Pr = \frac{C_p \mu}{k} = \frac{\nu}{\alpha} = \frac{C_p \rho \nu}{k} Inputs can be any of the following sets: * Heat capacity, dynam...
[ "def", "Prandtl", "(", "Cp", "=", "None", ",", "k", "=", "None", ",", "mu", "=", "None", ",", "nu", "=", "None", ",", "rho", "=", "None", ",", "alpha", "=", "None", ")", ":", "if", "k", "and", "Cp", "and", "mu", ":", "return", "Cp", "*", "m...
r'''Calculates Prandtl number or `Pr` for a fluid with the given parameters. .. math:: Pr = \frac{C_p \mu}{k} = \frac{\nu}{\alpha} = \frac{C_p \rho \nu}{k} Inputs can be any of the following sets: * Heat capacity, dynamic viscosity, and thermal conductivity * Thermal diffusivity and kinem...
[ "r", "Calculates", "Prandtl", "number", "or", "Pr", "for", "a", "fluid", "with", "the", "given", "parameters", "." ]
57f556752e039f1d3e5a822f408c184783db2828
https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/core.py#L811-L876
8,250
CalebBell/fluids
fluids/core.py
Grashof
def Grashof(L, beta, T1, T2=0, rho=None, mu=None, nu=None, g=g): r'''Calculates Grashof number or `Gr` for a fluid with the given properties, temperature difference, and characteristic length. .. math:: Gr = \frac{g\beta (T_s-T_\infty)L^3}{\nu^2} = \frac{g\beta (T_s-T_\infty)L^3\rho^2}{\mu^...
python
def Grashof(L, beta, T1, T2=0, rho=None, mu=None, nu=None, g=g): r'''Calculates Grashof number or `Gr` for a fluid with the given properties, temperature difference, and characteristic length. .. math:: Gr = \frac{g\beta (T_s-T_\infty)L^3}{\nu^2} = \frac{g\beta (T_s-T_\infty)L^3\rho^2}{\mu^...
[ "def", "Grashof", "(", "L", ",", "beta", ",", "T1", ",", "T2", "=", "0", ",", "rho", "=", "None", ",", "mu", "=", "None", ",", "nu", "=", "None", ",", "g", "=", "g", ")", ":", "if", "rho", "and", "mu", ":", "nu", "=", "mu", "/", "rho", ...
r'''Calculates Grashof number or `Gr` for a fluid with the given properties, temperature difference, and characteristic length. .. math:: Gr = \frac{g\beta (T_s-T_\infty)L^3}{\nu^2} = \frac{g\beta (T_s-T_\infty)L^3\rho^2}{\mu^2} Inputs either of any of the following sets: * L, beta, T...
[ "r", "Calculates", "Grashof", "number", "or", "Gr", "for", "a", "fluid", "with", "the", "given", "properties", "temperature", "difference", "and", "characteristic", "length", "." ]
57f556752e039f1d3e5a822f408c184783db2828
https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/core.py#L879-L946
8,251
CalebBell/fluids
fluids/core.py
Froude
def Froude(V, L, g=g, squared=False): r'''Calculates Froude number `Fr` for velocity `V` and geometric length `L`. If desired, gravity can be specified as well. Normally the function returns the result of the equation below; Froude number is also often said to be defined as the square of the equation be...
python
def Froude(V, L, g=g, squared=False): r'''Calculates Froude number `Fr` for velocity `V` and geometric length `L`. If desired, gravity can be specified as well. Normally the function returns the result of the equation below; Froude number is also often said to be defined as the square of the equation be...
[ "def", "Froude", "(", "V", ",", "L", ",", "g", "=", "g", ",", "squared", "=", "False", ")", ":", "Fr", "=", "V", "/", "(", "L", "*", "g", ")", "**", "0.5", "if", "squared", ":", "Fr", "*=", "Fr", "return", "Fr" ]
r'''Calculates Froude number `Fr` for velocity `V` and geometric length `L`. If desired, gravity can be specified as well. Normally the function returns the result of the equation below; Froude number is also often said to be defined as the square of the equation below. .. math:: Fr = \frac{V}{...
[ "r", "Calculates", "Froude", "number", "Fr", "for", "velocity", "V", "and", "geometric", "length", "L", ".", "If", "desired", "gravity", "can", "be", "specified", "as", "well", ".", "Normally", "the", "function", "returns", "the", "result", "of", "the", "e...
57f556752e039f1d3e5a822f408c184783db2828
https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/core.py#L1028-L1077
8,252
CalebBell/fluids
fluids/core.py
Stokes_number
def Stokes_number(V, Dp, D, rhop, mu): r'''Calculates Stokes Number for a given characteristic velocity `V`, particle diameter `Dp`, characteristic diameter `D`, particle density `rhop`, and fluid viscosity `mu`. .. math:: \text{Stk} = \frac{\rho_p V D_p^2}{18\mu_f D} Parameters ----...
python
def Stokes_number(V, Dp, D, rhop, mu): r'''Calculates Stokes Number for a given characteristic velocity `V`, particle diameter `Dp`, characteristic diameter `D`, particle density `rhop`, and fluid viscosity `mu`. .. math:: \text{Stk} = \frac{\rho_p V D_p^2}{18\mu_f D} Parameters ----...
[ "def", "Stokes_number", "(", "V", ",", "Dp", ",", "D", ",", "rhop", ",", "mu", ")", ":", "return", "rhop", "*", "V", "*", "(", "Dp", "*", "Dp", ")", "/", "(", "18.0", "*", "mu", "*", "D", ")" ]
r'''Calculates Stokes Number for a given characteristic velocity `V`, particle diameter `Dp`, characteristic diameter `D`, particle density `rhop`, and fluid viscosity `mu`. .. math:: \text{Stk} = \frac{\rho_p V D_p^2}{18\mu_f D} Parameters ---------- V : float Characteristic...
[ "r", "Calculates", "Stokes", "Number", "for", "a", "given", "characteristic", "velocity", "V", "particle", "diameter", "Dp", "characteristic", "diameter", "D", "particle", "density", "rhop", "and", "fluid", "viscosity", "mu", "." ]
57f556752e039f1d3e5a822f408c184783db2828
https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/core.py#L1644-L1688
8,253
CalebBell/fluids
fluids/core.py
Suratman
def Suratman(L, rho, mu, sigma): r'''Calculates Suratman number, `Su`, for a fluid with the given characteristic length, density, viscosity, and surface tension. .. math:: \text{Su} = \frac{\rho\sigma L}{\mu^2} Parameters ---------- L : float Characteristic length [m] rho :...
python
def Suratman(L, rho, mu, sigma): r'''Calculates Suratman number, `Su`, for a fluid with the given characteristic length, density, viscosity, and surface tension. .. math:: \text{Su} = \frac{\rho\sigma L}{\mu^2} Parameters ---------- L : float Characteristic length [m] rho :...
[ "def", "Suratman", "(", "L", ",", "rho", ",", "mu", ",", "sigma", ")", ":", "return", "rho", "*", "sigma", "*", "L", "/", "(", "mu", "*", "mu", ")" ]
r'''Calculates Suratman number, `Su`, for a fluid with the given characteristic length, density, viscosity, and surface tension. .. math:: \text{Su} = \frac{\rho\sigma L}{\mu^2} Parameters ---------- L : float Characteristic length [m] rho : float Density of fluid, [kg/...
[ "r", "Calculates", "Suratman", "number", "Su", "for", "a", "fluid", "with", "the", "given", "characteristic", "length", "density", "viscosity", "and", "surface", "tension", "." ]
57f556752e039f1d3e5a822f408c184783db2828
https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/core.py#L1828-L1878
8,254
CalebBell/fluids
fluids/core.py
nu_mu_converter
def nu_mu_converter(rho, mu=None, nu=None): r'''Calculates either kinematic or dynamic viscosity, depending on inputs. Used when one type of viscosity is known as well as density, to obtain the other type. Raises an error if both types of viscosity or neither type of viscosity is provided. .. math:...
python
def nu_mu_converter(rho, mu=None, nu=None): r'''Calculates either kinematic or dynamic viscosity, depending on inputs. Used when one type of viscosity is known as well as density, to obtain the other type. Raises an error if both types of viscosity or neither type of viscosity is provided. .. math:...
[ "def", "nu_mu_converter", "(", "rho", ",", "mu", "=", "None", ",", "nu", "=", "None", ")", ":", "if", "(", "nu", "and", "mu", ")", "or", "not", "rho", "or", "(", "not", "nu", "and", "not", "mu", ")", ":", "raise", "Exception", "(", "'Inputs must ...
r'''Calculates either kinematic or dynamic viscosity, depending on inputs. Used when one type of viscosity is known as well as density, to obtain the other type. Raises an error if both types of viscosity or neither type of viscosity is provided. .. math:: \nu = \frac{\mu}{\rho} .. math:: ...
[ "r", "Calculates", "either", "kinematic", "or", "dynamic", "viscosity", "depending", "on", "inputs", ".", "Used", "when", "one", "type", "of", "viscosity", "is", "known", "as", "well", "as", "density", "to", "obtain", "the", "other", "type", ".", "Raises", ...
57f556752e039f1d3e5a822f408c184783db2828
https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/core.py#L2158-L2199
8,255
CalebBell/fluids
fluids/core.py
Engauge_2d_parser
def Engauge_2d_parser(lines, flat=False): '''Not exposed function to read a 2D file generated by engauge-digitizer; for curve fitting. ''' z_values = [] x_lists = [] y_lists = [] working_xs = [] working_ys = [] new_curve = True for line in lines: if line.strip() == '...
python
def Engauge_2d_parser(lines, flat=False): '''Not exposed function to read a 2D file generated by engauge-digitizer; for curve fitting. ''' z_values = [] x_lists = [] y_lists = [] working_xs = [] working_ys = [] new_curve = True for line in lines: if line.strip() == '...
[ "def", "Engauge_2d_parser", "(", "lines", ",", "flat", "=", "False", ")", ":", "z_values", "=", "[", "]", "x_lists", "=", "[", "]", "y_lists", "=", "[", "]", "working_xs", "=", "[", "]", "working_ys", "=", "[", "]", "new_curve", "=", "True", "for", ...
Not exposed function to read a 2D file generated by engauge-digitizer; for curve fitting.
[ "Not", "exposed", "function", "to", "read", "a", "2D", "file", "generated", "by", "engauge", "-", "digitizer", ";", "for", "curve", "fitting", "." ]
57f556752e039f1d3e5a822f408c184783db2828
https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/core.py#L2869-L2910
8,256
CalebBell/fluids
fluids/compressible.py
isothermal_work_compression
def isothermal_work_compression(P1, P2, T, Z=1): r'''Calculates the work of compression or expansion of a gas going through an isothermal process. .. math:: W = zRT\ln\left(\frac{P_2}{P_1}\right) Parameters ---------- P1 : float Inlet pressure, [Pa] P2 : float Outle...
python
def isothermal_work_compression(P1, P2, T, Z=1): r'''Calculates the work of compression or expansion of a gas going through an isothermal process. .. math:: W = zRT\ln\left(\frac{P_2}{P_1}\right) Parameters ---------- P1 : float Inlet pressure, [Pa] P2 : float Outle...
[ "def", "isothermal_work_compression", "(", "P1", ",", "P2", ",", "T", ",", "Z", "=", "1", ")", ":", "return", "Z", "*", "R", "*", "T", "*", "log", "(", "P2", "/", "P1", ")" ]
r'''Calculates the work of compression or expansion of a gas going through an isothermal process. .. math:: W = zRT\ln\left(\frac{P_2}{P_1}\right) Parameters ---------- P1 : float Inlet pressure, [Pa] P2 : float Outlet pressure, [Pa] T : float Temperature of...
[ "r", "Calculates", "the", "work", "of", "compression", "or", "expansion", "of", "a", "gas", "going", "through", "an", "isothermal", "process", "." ]
57f556752e039f1d3e5a822f408c184783db2828
https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/compressible.py#L38-L102
8,257
CalebBell/fluids
fluids/compressible.py
isentropic_T_rise_compression
def isentropic_T_rise_compression(T1, P1, P2, k, eta=1): r'''Calculates the increase in temperature of a fluid which is compressed or expanded under isentropic, adiabatic conditions assuming constant Cp and Cv. The polytropic model is the same equation; just provide `n` instead of `k` and use a polytro...
python
def isentropic_T_rise_compression(T1, P1, P2, k, eta=1): r'''Calculates the increase in temperature of a fluid which is compressed or expanded under isentropic, adiabatic conditions assuming constant Cp and Cv. The polytropic model is the same equation; just provide `n` instead of `k` and use a polytro...
[ "def", "isentropic_T_rise_compression", "(", "T1", ",", "P1", ",", "P2", ",", "k", ",", "eta", "=", "1", ")", ":", "dT", "=", "T1", "*", "(", "(", "P2", "/", "P1", ")", "**", "(", "(", "k", "-", "1.0", ")", "/", "k", ")", "-", "1.0", ")", ...
r'''Calculates the increase in temperature of a fluid which is compressed or expanded under isentropic, adiabatic conditions assuming constant Cp and Cv. The polytropic model is the same equation; just provide `n` instead of `k` and use a polytropic efficienty for `eta` instead of a isentropic efficien...
[ "r", "Calculates", "the", "increase", "in", "temperature", "of", "a", "fluid", "which", "is", "compressed", "or", "expanded", "under", "isentropic", "adiabatic", "conditions", "assuming", "constant", "Cp", "and", "Cv", ".", "The", "polytropic", "model", "is", ...
57f556752e039f1d3e5a822f408c184783db2828
https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/compressible.py#L212-L264
8,258
CalebBell/fluids
fluids/compressible.py
isentropic_efficiency
def isentropic_efficiency(P1, P2, k, eta_s=None, eta_p=None): r'''Calculates either isentropic or polytropic efficiency from the other type of efficiency. .. math:: \eta_s = \frac{(P_2/P_1)^{(k-1)/k}-1} {(P_2/P_1)^{\frac{k-1}{k\eta_p}}-1} .. math:: \eta_p = \frac{\left(k - 1\ri...
python
def isentropic_efficiency(P1, P2, k, eta_s=None, eta_p=None): r'''Calculates either isentropic or polytropic efficiency from the other type of efficiency. .. math:: \eta_s = \frac{(P_2/P_1)^{(k-1)/k}-1} {(P_2/P_1)^{\frac{k-1}{k\eta_p}}-1} .. math:: \eta_p = \frac{\left(k - 1\ri...
[ "def", "isentropic_efficiency", "(", "P1", ",", "P2", ",", "k", ",", "eta_s", "=", "None", ",", "eta_p", "=", "None", ")", ":", "if", "eta_s", "is", "None", "and", "eta_p", ":", "return", "(", "(", "P2", "/", "P1", ")", "**", "(", "(", "k", "-"...
r'''Calculates either isentropic or polytropic efficiency from the other type of efficiency. .. math:: \eta_s = \frac{(P_2/P_1)^{(k-1)/k}-1} {(P_2/P_1)^{\frac{k-1}{k\eta_p}}-1} .. math:: \eta_p = \frac{\left(k - 1\right) \log{\left (\frac{P_{2}}{P_{1}} \right )}}{k \log{\le...
[ "r", "Calculates", "either", "isentropic", "or", "polytropic", "efficiency", "from", "the", "other", "type", "of", "efficiency", "." ]
57f556752e039f1d3e5a822f408c184783db2828
https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/compressible.py#L267-L320
8,259
CalebBell/fluids
fluids/compressible.py
P_isothermal_critical_flow
def P_isothermal_critical_flow(P, fd, D, L): r'''Calculates critical flow pressure `Pcf` for a fluid flowing isothermally and suffering pressure drop caused by a pipe's friction factor. .. math:: P_2 = P_{1} e^{\frac{1}{2 D} \left(D \left(\operatorname{LambertW} {\left (- e^{\frac{1}{D} \le...
python
def P_isothermal_critical_flow(P, fd, D, L): r'''Calculates critical flow pressure `Pcf` for a fluid flowing isothermally and suffering pressure drop caused by a pipe's friction factor. .. math:: P_2 = P_{1} e^{\frac{1}{2 D} \left(D \left(\operatorname{LambertW} {\left (- e^{\frac{1}{D} \le...
[ "def", "P_isothermal_critical_flow", "(", "P", ",", "fd", ",", "D", ",", "L", ")", ":", "# Correct branch of lambertw found by trial and error", "lambert_term", "=", "float", "(", "lambertw", "(", "-", "exp", "(", "(", "-", "D", "-", "L", "*", "fd", ")", "...
r'''Calculates critical flow pressure `Pcf` for a fluid flowing isothermally and suffering pressure drop caused by a pipe's friction factor. .. math:: P_2 = P_{1} e^{\frac{1}{2 D} \left(D \left(\operatorname{LambertW} {\left (- e^{\frac{1}{D} \left(- D - L f_d\right)} \right )} + 1\right) ...
[ "r", "Calculates", "critical", "flow", "pressure", "Pcf", "for", "a", "fluid", "flowing", "isothermally", "and", "suffering", "pressure", "drop", "caused", "by", "a", "pipe", "s", "friction", "factor", "." ]
57f556752e039f1d3e5a822f408c184783db2828
https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/compressible.py#L452-L499
8,260
CalebBell/fluids
fluids/compressible.py
P_upstream_isothermal_critical_flow
def P_upstream_isothermal_critical_flow(P, fd, D, L): '''Not part of the public API. Reverses `P_isothermal_critical_flow`. Examples -------- >>> P_upstream_isothermal_critical_flow(P=389699.7317645518, fd=0.00185, ... L=1000., D=0.5) 1000000.0000000001 ''' lambertw_term = float(lambert...
python
def P_upstream_isothermal_critical_flow(P, fd, D, L): '''Not part of the public API. Reverses `P_isothermal_critical_flow`. Examples -------- >>> P_upstream_isothermal_critical_flow(P=389699.7317645518, fd=0.00185, ... L=1000., D=0.5) 1000000.0000000001 ''' lambertw_term = float(lambert...
[ "def", "P_upstream_isothermal_critical_flow", "(", "P", ",", "fd", ",", "D", ",", "L", ")", ":", "lambertw_term", "=", "float", "(", "lambertw", "(", "-", "exp", "(", "-", "(", "fd", "*", "L", "+", "D", ")", "/", "D", ")", ",", "-", "1", ")", "...
Not part of the public API. Reverses `P_isothermal_critical_flow`. Examples -------- >>> P_upstream_isothermal_critical_flow(P=389699.7317645518, fd=0.00185, ... L=1000., D=0.5) 1000000.0000000001
[ "Not", "part", "of", "the", "public", "API", ".", "Reverses", "P_isothermal_critical_flow", "." ]
57f556752e039f1d3e5a822f408c184783db2828
https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/compressible.py#L502-L512
8,261
CalebBell/fluids
fluids/compressible.py
is_critical_flow
def is_critical_flow(P1, P2, k): r'''Determines if a flow of a fluid driven by pressure gradient P1 - P2 is critical, for a fluid with the given isentropic coefficient. This function calculates critical flow pressure, and checks if this is larger than P2. If so, the flow is critical and choked. Par...
python
def is_critical_flow(P1, P2, k): r'''Determines if a flow of a fluid driven by pressure gradient P1 - P2 is critical, for a fluid with the given isentropic coefficient. This function calculates critical flow pressure, and checks if this is larger than P2. If so, the flow is critical and choked. Par...
[ "def", "is_critical_flow", "(", "P1", ",", "P2", ",", "k", ")", ":", "Pcf", "=", "P_critical_flow", "(", "P1", ",", "k", ")", "return", "Pcf", ">", "P2" ]
r'''Determines if a flow of a fluid driven by pressure gradient P1 - P2 is critical, for a fluid with the given isentropic coefficient. This function calculates critical flow pressure, and checks if this is larger than P2. If so, the flow is critical and choked. Parameters ---------- P1 : float...
[ "r", "Determines", "if", "a", "flow", "of", "a", "fluid", "driven", "by", "pressure", "gradient", "P1", "-", "P2", "is", "critical", "for", "a", "fluid", "with", "the", "given", "isentropic", "coefficient", ".", "This", "function", "calculates", "critical", ...
57f556752e039f1d3e5a822f408c184783db2828
https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/compressible.py#L515-L554
8,262
CalebBell/fluids
fluids/friction.py
one_phase_dP
def one_phase_dP(m, rho, mu, D, roughness=0, L=1, Method=None): r'''Calculates single-phase pressure drop. This is a wrapper around other methods. Parameters ---------- m : float Mass flow rate of fluid, [kg/s] rho : float Density of fluid, [kg/m^3] mu : float Viscos...
python
def one_phase_dP(m, rho, mu, D, roughness=0, L=1, Method=None): r'''Calculates single-phase pressure drop. This is a wrapper around other methods. Parameters ---------- m : float Mass flow rate of fluid, [kg/s] rho : float Density of fluid, [kg/m^3] mu : float Viscos...
[ "def", "one_phase_dP", "(", "m", ",", "rho", ",", "mu", ",", "D", ",", "roughness", "=", "0", ",", "L", "=", "1", ",", "Method", "=", "None", ")", ":", "D2", "=", "D", "*", "D", "V", "=", "m", "/", "(", "0.25", "*", "pi", "*", "D2", "*", ...
r'''Calculates single-phase pressure drop. This is a wrapper around other methods. Parameters ---------- m : float Mass flow rate of fluid, [kg/s] rho : float Density of fluid, [kg/m^3] mu : float Viscosity of fluid, [Pa*s] D : float Diameter of pipe, [m] ...
[ "r", "Calculates", "single", "-", "phase", "pressure", "drop", ".", "This", "is", "a", "wrapper", "around", "other", "methods", "." ]
57f556752e039f1d3e5a822f408c184783db2828
https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/friction.py#L3874-L3918
8,263
CalebBell/fluids
fluids/flow_meter.py
discharge_coefficient_to_K
def discharge_coefficient_to_K(D, Do, C): r'''Converts a discharge coefficient to a standard loss coefficient, for use in computation of the actual pressure drop of an orifice or other device. .. math:: K = \left[\frac{\sqrt{1-\beta^4(1-C^2)}}{C\beta^2} - 1\right]^2 Parameters ...
python
def discharge_coefficient_to_K(D, Do, C): r'''Converts a discharge coefficient to a standard loss coefficient, for use in computation of the actual pressure drop of an orifice or other device. .. math:: K = \left[\frac{\sqrt{1-\beta^4(1-C^2)}}{C\beta^2} - 1\right]^2 Parameters ...
[ "def", "discharge_coefficient_to_K", "(", "D", ",", "Do", ",", "C", ")", ":", "beta", "=", "Do", "/", "D", "beta2", "=", "beta", "*", "beta", "beta4", "=", "beta2", "*", "beta2", "return", "(", "(", "1.0", "-", "beta4", "*", "(", "1.0", "-", "C",...
r'''Converts a discharge coefficient to a standard loss coefficient, for use in computation of the actual pressure drop of an orifice or other device. .. math:: K = \left[\frac{\sqrt{1-\beta^4(1-C^2)}}{C\beta^2} - 1\right]^2 Parameters ---------- D : float Upstream inte...
[ "r", "Converts", "a", "discharge", "coefficient", "to", "a", "standard", "loss", "coefficient", "for", "use", "in", "computation", "of", "the", "actual", "pressure", "drop", "of", "an", "orifice", "or", "other", "device", "." ]
57f556752e039f1d3e5a822f408c184783db2828
https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/flow_meter.py#L438-L484
8,264
CalebBell/fluids
fluids/particle_size_distribution.py
ParticleSizeDistributionContinuous.dn
def dn(self, fraction, n=None): r'''Computes the diameter at which a specified `fraction` of the distribution falls under. Utilizes a bounded solver to search for the desired diameter. Parameters ---------- fraction : float Fraction of the distribution which...
python
def dn(self, fraction, n=None): r'''Computes the diameter at which a specified `fraction` of the distribution falls under. Utilizes a bounded solver to search for the desired diameter. Parameters ---------- fraction : float Fraction of the distribution which...
[ "def", "dn", "(", "self", ",", "fraction", ",", "n", "=", "None", ")", ":", "if", "fraction", "==", "1.0", ":", "# Avoid returning the maximum value of the search interval", "fraction", "=", "1.0", "-", "epsilon", "if", "fraction", "<", "0", ":", "raise", "V...
r'''Computes the diameter at which a specified `fraction` of the distribution falls under. Utilizes a bounded solver to search for the desired diameter. Parameters ---------- fraction : float Fraction of the distribution which should be under the calculated ...
[ "r", "Computes", "the", "diameter", "at", "which", "a", "specified", "fraction", "of", "the", "distribution", "falls", "under", ".", "Utilizes", "a", "bounded", "solver", "to", "search", "for", "the", "desired", "diameter", "." ]
57f556752e039f1d3e5a822f408c184783db2828
https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/particle_size_distribution.py#L1360-L1417
8,265
CalebBell/fluids
fluids/particle_size_distribution.py
ParticleSizeDistribution.fit
def fit(self, x0=None, distribution='lognormal', n=None, **kwargs): '''Incomplete method to fit experimental values to a curve. It is very hard to get good initial guesses, which are really required for this. Differential evolution is promissing. This API is likely to change in the futur...
python
def fit(self, x0=None, distribution='lognormal', n=None, **kwargs): '''Incomplete method to fit experimental values to a curve. It is very hard to get good initial guesses, which are really required for this. Differential evolution is promissing. This API is likely to change in the futur...
[ "def", "fit", "(", "self", ",", "x0", "=", "None", ",", "distribution", "=", "'lognormal'", ",", "n", "=", "None", ",", "*", "*", "kwargs", ")", ":", "dist", "=", "{", "'lognormal'", ":", "PSDLognormal", ",", "'GGS'", ":", "PSDGatesGaudinSchuhman", ","...
Incomplete method to fit experimental values to a curve. It is very hard to get good initial guesses, which are really required for this. Differential evolution is promissing. This API is likely to change in the future.
[ "Incomplete", "method", "to", "fit", "experimental", "values", "to", "a", "curve", ".", "It", "is", "very", "hard", "to", "get", "good", "initial", "guesses", "which", "are", "really", "required", "for", "this", ".", "Differential", "evolution", "is", "promi...
57f556752e039f1d3e5a822f408c184783db2828
https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/particle_size_distribution.py#L1881-L1905
8,266
CalebBell/fluids
fluids/particle_size_distribution.py
ParticleSizeDistribution.Dis
def Dis(self): '''Representative diameters of each bin. ''' return [self.di_power(i, power=1) for i in range(self.N)]
python
def Dis(self): '''Representative diameters of each bin. ''' return [self.di_power(i, power=1) for i in range(self.N)]
[ "def", "Dis", "(", "self", ")", ":", "return", "[", "self", ".", "di_power", "(", "i", ",", "power", "=", "1", ")", "for", "i", "in", "range", "(", "self", ".", "N", ")", "]" ]
Representative diameters of each bin.
[ "Representative", "diameters", "of", "each", "bin", "." ]
57f556752e039f1d3e5a822f408c184783db2828
https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/particle_size_distribution.py#L1908-L1911
8,267
CalebBell/fluids
fluids/geometry.py
SA_tank
def SA_tank(D, L, sideA=None, sideB=None, sideA_a=0, sideB_a=0, sideA_f=None, sideA_k=None, sideB_f=None, sideB_k=None, full_output=False): r'''Calculates the surface are of a cylindrical tank with optional heads. In the degenerate case of being provided with only `D` and `L`, provides...
python
def SA_tank(D, L, sideA=None, sideB=None, sideA_a=0, sideB_a=0, sideA_f=None, sideA_k=None, sideB_f=None, sideB_k=None, full_output=False): r'''Calculates the surface are of a cylindrical tank with optional heads. In the degenerate case of being provided with only `D` and `L`, provides...
[ "def", "SA_tank", "(", "D", ",", "L", ",", "sideA", "=", "None", ",", "sideB", "=", "None", ",", "sideA_a", "=", "0", ",", "sideB_a", "=", "0", ",", "sideA_f", "=", "None", ",", "sideA_k", "=", "None", ",", "sideB_f", "=", "None", ",", "sideB_k",...
r'''Calculates the surface are of a cylindrical tank with optional heads. In the degenerate case of being provided with only `D` and `L`, provides the surface area of a cylinder. Parameters ---------- D : float Diameter of the cylindrical section of the tank, [m] L : float Lengt...
[ "r", "Calculates", "the", "surface", "are", "of", "a", "cylindrical", "tank", "with", "optional", "heads", ".", "In", "the", "degenerate", "case", "of", "being", "provided", "with", "only", "D", "and", "L", "provides", "the", "surface", "area", "of", "a", ...
57f556752e039f1d3e5a822f408c184783db2828
https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/geometry.py#L1192-L1287
8,268
CalebBell/fluids
fluids/geometry.py
pitch_angle_solver
def pitch_angle_solver(angle=None, pitch=None, pitch_parallel=None, pitch_normal=None): r'''Utility to take any two of `angle`, `pitch`, `pitch_parallel`, and `pitch_normal` and calculate the other two. This is useful for applications with tube banks, as in shell and tube heat exchang...
python
def pitch_angle_solver(angle=None, pitch=None, pitch_parallel=None, pitch_normal=None): r'''Utility to take any two of `angle`, `pitch`, `pitch_parallel`, and `pitch_normal` and calculate the other two. This is useful for applications with tube banks, as in shell and tube heat exchang...
[ "def", "pitch_angle_solver", "(", "angle", "=", "None", ",", "pitch", "=", "None", ",", "pitch_parallel", "=", "None", ",", "pitch_normal", "=", "None", ")", ":", "if", "angle", "is", "not", "None", "and", "pitch", "is", "not", "None", ":", "pitch_normal...
r'''Utility to take any two of `angle`, `pitch`, `pitch_parallel`, and `pitch_normal` and calculate the other two. This is useful for applications with tube banks, as in shell and tube heat exchangers or air coolers and allows for a wider range of user input. .. math:: \text{pitch normal} = \t...
[ "r", "Utility", "to", "take", "any", "two", "of", "angle", "pitch", "pitch_parallel", "and", "pitch_normal", "and", "calculate", "the", "other", "two", ".", "This", "is", "useful", "for", "applications", "with", "tube", "banks", "as", "in", "shell", "and", ...
57f556752e039f1d3e5a822f408c184783db2828
https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/geometry.py#L3030-L3113
8,269
CalebBell/fluids
fluids/geometry.py
A_hollow_cylinder
def A_hollow_cylinder(Di, Do, L): r'''Returns the surface area of a hollow cylinder. .. math:: A = \pi D_o L + \pi D_i L + 2\cdot \frac{\pi D_o^2}{4} - 2\cdot \frac{\pi D_i^2}{4} Parameters ---------- Di : float Diameter of the hollow in the cylinder, [m] Do : float ...
python
def A_hollow_cylinder(Di, Do, L): r'''Returns the surface area of a hollow cylinder. .. math:: A = \pi D_o L + \pi D_i L + 2\cdot \frac{\pi D_o^2}{4} - 2\cdot \frac{\pi D_i^2}{4} Parameters ---------- Di : float Diameter of the hollow in the cylinder, [m] Do : float ...
[ "def", "A_hollow_cylinder", "(", "Di", ",", "Do", ",", "L", ")", ":", "side_o", "=", "pi", "*", "Do", "*", "L", "side_i", "=", "pi", "*", "Di", "*", "L", "cap_circle", "=", "pi", "*", "Do", "**", "2", "/", "4", "*", "2", "cap_removed", "=", "...
r'''Returns the surface area of a hollow cylinder. .. math:: A = \pi D_o L + \pi D_i L + 2\cdot \frac{\pi D_o^2}{4} - 2\cdot \frac{\pi D_i^2}{4} Parameters ---------- Di : float Diameter of the hollow in the cylinder, [m] Do : float Diameter of the exterior of the ...
[ "r", "Returns", "the", "surface", "area", "of", "a", "hollow", "cylinder", "." ]
57f556752e039f1d3e5a822f408c184783db2828
https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/geometry.py#L3285-L3315
8,270
CalebBell/fluids
fluids/geometry.py
A_multiple_hole_cylinder
def A_multiple_hole_cylinder(Do, L, holes): r'''Returns the surface area of a cylinder with multiple holes. Calculation will naively return a negative value or other impossible result if the number of cylinders added is physically impossible. Holes may be of different shapes, but must be perpendicular t...
python
def A_multiple_hole_cylinder(Do, L, holes): r'''Returns the surface area of a cylinder with multiple holes. Calculation will naively return a negative value or other impossible result if the number of cylinders added is physically impossible. Holes may be of different shapes, but must be perpendicular t...
[ "def", "A_multiple_hole_cylinder", "(", "Do", ",", "L", ",", "holes", ")", ":", "side_o", "=", "pi", "*", "Do", "*", "L", "cap_circle", "=", "pi", "*", "Do", "**", "2", "/", "4", "*", "2", "A", "=", "cap_circle", "+", "side_o", "for", "Di", ",", ...
r'''Returns the surface area of a cylinder with multiple holes. Calculation will naively return a negative value or other impossible result if the number of cylinders added is physically impossible. Holes may be of different shapes, but must be perpendicular to the axis of the cylinder. .. math:: ...
[ "r", "Returns", "the", "surface", "area", "of", "a", "cylinder", "with", "multiple", "holes", ".", "Calculation", "will", "naively", "return", "a", "negative", "value", "or", "other", "impossible", "result", "if", "the", "number", "of", "cylinders", "added", ...
57f556752e039f1d3e5a822f408c184783db2828
https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/geometry.py#L3346-L3384
8,271
CalebBell/fluids
fluids/geometry.py
TANK.V_from_h
def V_from_h(self, h, method='full'): r'''Method to calculate the volume of liquid in a fully defined tank given a specified height `h`. `h` must be under the maximum height. If the method is 'chebyshev', and the coefficients have not yet been calculated, they are created by calling `se...
python
def V_from_h(self, h, method='full'): r'''Method to calculate the volume of liquid in a fully defined tank given a specified height `h`. `h` must be under the maximum height. If the method is 'chebyshev', and the coefficients have not yet been calculated, they are created by calling `se...
[ "def", "V_from_h", "(", "self", ",", "h", ",", "method", "=", "'full'", ")", ":", "if", "method", "==", "'full'", ":", "return", "V_from_h", "(", "h", ",", "self", ".", "D", ",", "self", ".", "L", ",", "self", ".", "horizontal", ",", "self", ".",...
r'''Method to calculate the volume of liquid in a fully defined tank given a specified height `h`. `h` must be under the maximum height. If the method is 'chebyshev', and the coefficients have not yet been calculated, they are created by calling `set_chebyshev_approximators`. Parameter...
[ "r", "Method", "to", "calculate", "the", "volume", "of", "liquid", "in", "a", "fully", "defined", "tank", "given", "a", "specified", "height", "h", ".", "h", "must", "be", "under", "the", "maximum", "height", ".", "If", "the", "method", "is", "chebyshev"...
57f556752e039f1d3e5a822f408c184783db2828
https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/geometry.py#L1713-L1744
8,272
CalebBell/fluids
fluids/geometry.py
TANK.h_from_V
def h_from_V(self, V, method='spline'): r'''Method to calculate the height of liquid in a fully defined tank given a specified volume of liquid in it `V`. `V` must be under the maximum volume. If the method is 'spline', and the interpolation table is not yet defined, creates it by callin...
python
def h_from_V(self, V, method='spline'): r'''Method to calculate the height of liquid in a fully defined tank given a specified volume of liquid in it `V`. `V` must be under the maximum volume. If the method is 'spline', and the interpolation table is not yet defined, creates it by callin...
[ "def", "h_from_V", "(", "self", ",", "V", ",", "method", "=", "'spline'", ")", ":", "if", "method", "==", "'spline'", ":", "if", "not", "self", ".", "table", ":", "self", ".", "set_table", "(", ")", "return", "float", "(", "self", ".", "interp_h_from...
r'''Method to calculate the height of liquid in a fully defined tank given a specified volume of liquid in it `V`. `V` must be under the maximum volume. If the method is 'spline', and the interpolation table is not yet defined, creates it by calling the method set_table. If the method is...
[ "r", "Method", "to", "calculate", "the", "height", "of", "liquid", "in", "a", "fully", "defined", "tank", "given", "a", "specified", "volume", "of", "liquid", "in", "it", "V", ".", "V", "must", "be", "under", "the", "maximum", "volume", ".", "If", "the...
57f556752e039f1d3e5a822f408c184783db2828
https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/geometry.py#L1746-L1779
8,273
CalebBell/fluids
fluids/geometry.py
TANK.set_table
def set_table(self, n=100, dx=None): r'''Method to set an interpolation table of liquids levels versus volumes in the tank, for a fully defined tank. Normally run by the h_from_V method, this may be run prior to its use with a custom specification. Either the number of points on the tabl...
python
def set_table(self, n=100, dx=None): r'''Method to set an interpolation table of liquids levels versus volumes in the tank, for a fully defined tank. Normally run by the h_from_V method, this may be run prior to its use with a custom specification. Either the number of points on the tabl...
[ "def", "set_table", "(", "self", ",", "n", "=", "100", ",", "dx", "=", "None", ")", ":", "if", "dx", ":", "self", ".", "heights", "=", "np", ".", "linspace", "(", "0", ",", "self", ".", "h_max", ",", "int", "(", "self", ".", "h_max", "/", "dx...
r'''Method to set an interpolation table of liquids levels versus volumes in the tank, for a fully defined tank. Normally run by the h_from_V method, this may be run prior to its use with a custom specification. Either the number of points on the table, or the vertical distance between s...
[ "r", "Method", "to", "set", "an", "interpolation", "table", "of", "liquids", "levels", "versus", "volumes", "in", "the", "tank", "for", "a", "fully", "defined", "tank", ".", "Normally", "run", "by", "the", "h_from_V", "method", "this", "may", "be", "run", ...
57f556752e039f1d3e5a822f408c184783db2828
https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/geometry.py#L1781-L1802
8,274
CalebBell/fluids
fluids/geometry.py
TANK._V_solver_error
def _V_solver_error(self, Vtarget, D, L, horizontal, sideA, sideB, sideA_a, sideB_a, sideA_f, sideA_k, sideB_f, sideB_k, sideA_a_ratio, sideB_a_ratio): '''Function which uses only the variables given, and the TANK class itself, to determine how far from the ...
python
def _V_solver_error(self, Vtarget, D, L, horizontal, sideA, sideB, sideA_a, sideB_a, sideA_f, sideA_k, sideB_f, sideB_k, sideA_a_ratio, sideB_a_ratio): '''Function which uses only the variables given, and the TANK class itself, to determine how far from the ...
[ "def", "_V_solver_error", "(", "self", ",", "Vtarget", ",", "D", ",", "L", ",", "horizontal", ",", "sideA", ",", "sideB", ",", "sideA_a", ",", "sideB_a", ",", "sideA_f", ",", "sideA_k", ",", "sideB_f", ",", "sideB_k", ",", "sideA_a_ratio", ",", "sideB_a_...
Function which uses only the variables given, and the TANK class itself, to determine how far from the desired volume, Vtarget, the volume produced by the specified parameters in a new TANK instance is. Should only be used by solve_tank_for_V method.
[ "Function", "which", "uses", "only", "the", "variables", "given", "and", "the", "TANK", "class", "itself", "to", "determine", "how", "far", "from", "the", "desired", "volume", "Vtarget", "the", "volume", "produced", "by", "the", "specified", "parameters", "in"...
57f556752e039f1d3e5a822f408c184783db2828
https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/geometry.py#L1843-L1856
8,275
CalebBell/fluids
fluids/geometry.py
PlateExchanger.plate_exchanger_identifier
def plate_exchanger_identifier(self): '''Method to create an identifying string in format 'L' + wavelength + 'A' + amplitude + 'B' + chevron angle-chevron angle. Wavelength and amplitude are specified in units of mm and rounded to two decimal places. ''' s = ('L' + str(round(se...
python
def plate_exchanger_identifier(self): '''Method to create an identifying string in format 'L' + wavelength + 'A' + amplitude + 'B' + chevron angle-chevron angle. Wavelength and amplitude are specified in units of mm and rounded to two decimal places. ''' s = ('L' + str(round(se...
[ "def", "plate_exchanger_identifier", "(", "self", ")", ":", "s", "=", "(", "'L'", "+", "str", "(", "round", "(", "self", ".", "wavelength", "*", "1000", ",", "2", ")", ")", "+", "'A'", "+", "str", "(", "round", "(", "self", ".", "amplitude", "*", ...
Method to create an identifying string in format 'L' + wavelength + 'A' + amplitude + 'B' + chevron angle-chevron angle. Wavelength and amplitude are specified in units of mm and rounded to two decimal places.
[ "Method", "to", "create", "an", "identifying", "string", "in", "format", "L", "+", "wavelength", "+", "A", "+", "amplitude", "+", "B", "+", "chevron", "angle", "-", "chevron", "angle", ".", "Wavelength", "and", "amplitude", "are", "specified", "in", "units...
57f556752e039f1d3e5a822f408c184783db2828
https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/geometry.py#L2163-L2171
8,276
CalebBell/fluids
fluids/numerics/__init__.py
linspace
def linspace(start, stop, num=50, endpoint=True, retstep=False, dtype=None): '''Port of numpy's linspace to pure python. Does not support dtype, and returns lists of floats. ''' num = int(num) start = start * 1. stop = stop * 1. if num <= 0: return [] if endpoint: if nu...
python
def linspace(start, stop, num=50, endpoint=True, retstep=False, dtype=None): '''Port of numpy's linspace to pure python. Does not support dtype, and returns lists of floats. ''' num = int(num) start = start * 1. stop = stop * 1. if num <= 0: return [] if endpoint: if nu...
[ "def", "linspace", "(", "start", ",", "stop", ",", "num", "=", "50", ",", "endpoint", "=", "True", ",", "retstep", "=", "False", ",", "dtype", "=", "None", ")", ":", "num", "=", "int", "(", "num", ")", "start", "=", "start", "*", "1.", "stop", ...
Port of numpy's linspace to pure python. Does not support dtype, and returns lists of floats.
[ "Port", "of", "numpy", "s", "linspace", "to", "pure", "python", ".", "Does", "not", "support", "dtype", "and", "returns", "lists", "of", "floats", "." ]
57f556752e039f1d3e5a822f408c184783db2828
https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/numerics/__init__.py#L361-L392
8,277
CalebBell/fluids
fluids/numerics/__init__.py
derivative
def derivative(func, x0, dx=1.0, n=1, args=(), order=3): '''Reimplementation of SciPy's derivative function, with more cached coefficients and without using numpy. If new coefficients not cached are needed, they are only calculated once and are remembered. ''' if order < n + 1: raise ValueEr...
python
def derivative(func, x0, dx=1.0, n=1, args=(), order=3): '''Reimplementation of SciPy's derivative function, with more cached coefficients and without using numpy. If new coefficients not cached are needed, they are only calculated once and are remembered. ''' if order < n + 1: raise ValueEr...
[ "def", "derivative", "(", "func", ",", "x0", ",", "dx", "=", "1.0", ",", "n", "=", "1", ",", "args", "=", "(", ")", ",", "order", "=", "3", ")", ":", "if", "order", "<", "n", "+", "1", ":", "raise", "ValueError", "if", "order", "%", "2", "=...
Reimplementation of SciPy's derivative function, with more cached coefficients and without using numpy. If new coefficients not cached are needed, they are only calculated once and are remembered.
[ "Reimplementation", "of", "SciPy", "s", "derivative", "function", "with", "more", "cached", "coefficients", "and", "without", "using", "numpy", ".", "If", "new", "coefficients", "not", "cached", "are", "needed", "they", "are", "only", "calculated", "once", "and"...
57f556752e039f1d3e5a822f408c184783db2828
https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/numerics/__init__.py#L547-L561
8,278
CalebBell/fluids
fluids/numerics/__init__.py
polyder
def polyder(c, m=1, scl=1, axis=0): '''not quite a copy of numpy's version because this was faster to implement. ''' c = list(c) cnt = int(m) if cnt == 0: return c n = len(c) if cnt >= n: c = c[:1]*0 else: for i in range(cnt): n = n - 1 c...
python
def polyder(c, m=1, scl=1, axis=0): '''not quite a copy of numpy's version because this was faster to implement. ''' c = list(c) cnt = int(m) if cnt == 0: return c n = len(c) if cnt >= n: c = c[:1]*0 else: for i in range(cnt): n = n - 1 c...
[ "def", "polyder", "(", "c", ",", "m", "=", "1", ",", "scl", "=", "1", ",", "axis", "=", "0", ")", ":", "c", "=", "list", "(", "c", ")", "cnt", "=", "int", "(", "m", ")", "if", "cnt", "==", "0", ":", "return", "c", "n", "=", "len", "(", ...
not quite a copy of numpy's version because this was faster to implement.
[ "not", "quite", "a", "copy", "of", "numpy", "s", "version", "because", "this", "was", "faster", "to", "implement", "." ]
57f556752e039f1d3e5a822f408c184783db2828
https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/numerics/__init__.py#L620-L640
8,279
CalebBell/fluids
fluids/numerics/__init__.py
horner_log
def horner_log(coeffs, log_coeff, x): '''Technically possible to save one addition of the last term of coeffs is removed but benchmarks said nothing was saved''' tot = 0.0 for c in coeffs: tot = tot*x + c return tot + log_coeff*log(x)
python
def horner_log(coeffs, log_coeff, x): '''Technically possible to save one addition of the last term of coeffs is removed but benchmarks said nothing was saved''' tot = 0.0 for c in coeffs: tot = tot*x + c return tot + log_coeff*log(x)
[ "def", "horner_log", "(", "coeffs", ",", "log_coeff", ",", "x", ")", ":", "tot", "=", "0.0", "for", "c", "in", "coeffs", ":", "tot", "=", "tot", "*", "x", "+", "c", "return", "tot", "+", "log_coeff", "*", "log", "(", "x", ")" ]
Technically possible to save one addition of the last term of coeffs is removed but benchmarks said nothing was saved
[ "Technically", "possible", "to", "save", "one", "addition", "of", "the", "last", "term", "of", "coeffs", "is", "removed", "but", "benchmarks", "said", "nothing", "was", "saved" ]
57f556752e039f1d3e5a822f408c184783db2828
https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/numerics/__init__.py#L679-L685
8,280
CalebBell/fluids
fluids/numerics/__init__.py
implementation_optimize_tck
def implementation_optimize_tck(tck): '''Converts 1-d or 2-d splines calculated with SciPy's `splrep` or `bisplrep` to a format for fastest computation - lists in PyPy, and numpy arrays otherwise. Only implemented for 3 and 5 length `tck`s. ''' if IS_PYPY: return tck else: ...
python
def implementation_optimize_tck(tck): '''Converts 1-d or 2-d splines calculated with SciPy's `splrep` or `bisplrep` to a format for fastest computation - lists in PyPy, and numpy arrays otherwise. Only implemented for 3 and 5 length `tck`s. ''' if IS_PYPY: return tck else: ...
[ "def", "implementation_optimize_tck", "(", "tck", ")", ":", "if", "IS_PYPY", ":", "return", "tck", "else", ":", "if", "len", "(", "tck", ")", "==", "3", ":", "tck", "[", "0", "]", "=", "np", ".", "array", "(", "tck", "[", "0", "]", ")", "tck", ...
Converts 1-d or 2-d splines calculated with SciPy's `splrep` or `bisplrep` to a format for fastest computation - lists in PyPy, and numpy arrays otherwise. Only implemented for 3 and 5 length `tck`s.
[ "Converts", "1", "-", "d", "or", "2", "-", "d", "splines", "calculated", "with", "SciPy", "s", "splrep", "or", "bisplrep", "to", "a", "format", "for", "fastest", "computation", "-", "lists", "in", "PyPy", "and", "numpy", "arrays", "otherwise", ".", "Only...
57f556752e039f1d3e5a822f408c184783db2828
https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/numerics/__init__.py#L870-L889
8,281
CalebBell/fluids
fluids/numerics/__init__.py
py_bisect
def py_bisect(f, a, b, args=(), xtol=_xtol, rtol=_rtol, maxiter=_iter, ytol=None, full_output=False, disp=True): '''Port of SciPy's C bisect routine. ''' fa = f(a, *args) fb = f(b, *args) if fa*fb > 0.0: raise ValueError("f(a) and f(b) must have different signs") elif fa =...
python
def py_bisect(f, a, b, args=(), xtol=_xtol, rtol=_rtol, maxiter=_iter, ytol=None, full_output=False, disp=True): '''Port of SciPy's C bisect routine. ''' fa = f(a, *args) fb = f(b, *args) if fa*fb > 0.0: raise ValueError("f(a) and f(b) must have different signs") elif fa =...
[ "def", "py_bisect", "(", "f", ",", "a", ",", "b", ",", "args", "=", "(", ")", ",", "xtol", "=", "_xtol", ",", "rtol", "=", "_rtol", ",", "maxiter", "=", "_iter", ",", "ytol", "=", "None", ",", "full_output", "=", "False", ",", "disp", "=", "Tru...
Port of SciPy's C bisect routine.
[ "Port", "of", "SciPy", "s", "C", "bisect", "routine", "." ]
57f556752e039f1d3e5a822f408c184783db2828
https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/numerics/__init__.py#L1058-L1089
8,282
CalebBell/fluids
fluids/control_valve.py
is_choked_turbulent_l
def is_choked_turbulent_l(dP, P1, Psat, FF, FL=None, FLP=None, FP=None): r'''Calculates if a liquid flow in IEC 60534 calculations is critical or not, for use in IEC 60534 liquid valve sizing calculations. Either FL may be provided or FLP and FP, depending on the calculation process. .. math:: ...
python
def is_choked_turbulent_l(dP, P1, Psat, FF, FL=None, FLP=None, FP=None): r'''Calculates if a liquid flow in IEC 60534 calculations is critical or not, for use in IEC 60534 liquid valve sizing calculations. Either FL may be provided or FLP and FP, depending on the calculation process. .. math:: ...
[ "def", "is_choked_turbulent_l", "(", "dP", ",", "P1", ",", "Psat", ",", "FF", ",", "FL", "=", "None", ",", "FLP", "=", "None", ",", "FP", "=", "None", ")", ":", "if", "FLP", "and", "FP", ":", "return", "dP", ">=", "(", "FLP", "/", "FP", ")", ...
r'''Calculates if a liquid flow in IEC 60534 calculations is critical or not, for use in IEC 60534 liquid valve sizing calculations. Either FL may be provided or FLP and FP, depending on the calculation process. .. math:: \Delta P > F_L^2(P_1 - F_F P_{sat}) .. math:: \Delta P >= \l...
[ "r", "Calculates", "if", "a", "liquid", "flow", "in", "IEC", "60534", "calculations", "is", "critical", "or", "not", "for", "use", "in", "IEC", "60534", "liquid", "valve", "sizing", "calculations", ".", "Either", "FL", "may", "be", "provided", "or", "FLP",...
57f556752e039f1d3e5a822f408c184783db2828
https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/control_valve.py#L259-L310
8,283
CalebBell/fluids
fluids/control_valve.py
is_choked_turbulent_g
def is_choked_turbulent_g(x, Fgamma, xT=None, xTP=None): r'''Calculates if a gas flow in IEC 60534 calculations is critical or not, for use in IEC 60534 gas valve sizing calculations. Either xT or xTP must be provided, depending on the calculation process. .. math:: x \ge F_\gamma x_T .. m...
python
def is_choked_turbulent_g(x, Fgamma, xT=None, xTP=None): r'''Calculates if a gas flow in IEC 60534 calculations is critical or not, for use in IEC 60534 gas valve sizing calculations. Either xT or xTP must be provided, depending on the calculation process. .. math:: x \ge F_\gamma x_T .. m...
[ "def", "is_choked_turbulent_g", "(", "x", ",", "Fgamma", ",", "xT", "=", "None", ",", "xTP", "=", "None", ")", ":", "if", "xT", ":", "return", "x", ">=", "Fgamma", "*", "xT", "elif", "xTP", ":", "return", "x", ">=", "Fgamma", "*", "xTP", "else", ...
r'''Calculates if a gas flow in IEC 60534 calculations is critical or not, for use in IEC 60534 gas valve sizing calculations. Either xT or xTP must be provided, depending on the calculation process. .. math:: x \ge F_\gamma x_T .. math:: x \ge F_\gamma x_{TP} Parameters -----...
[ "r", "Calculates", "if", "a", "gas", "flow", "in", "IEC", "60534", "calculations", "is", "critical", "or", "not", "for", "use", "in", "IEC", "60534", "gas", "valve", "sizing", "calculations", ".", "Either", "xT", "or", "xTP", "must", "be", "provided", "d...
57f556752e039f1d3e5a822f408c184783db2828
https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/control_valve.py#L313-L360
8,284
CalebBell/fluids
fluids/control_valve.py
Reynolds_valve
def Reynolds_valve(nu, Q, D1, FL, Fd, C): r'''Calculates Reynolds number of a control valve for a liquid or gas flowing through it at a specified Q, for a specified D1, FL, Fd, C, and with kinematic viscosity `nu` according to IEC 60534 calculations. .. math:: Re_v = \frac{N_4 F_d Q}{\nu \sqrt{...
python
def Reynolds_valve(nu, Q, D1, FL, Fd, C): r'''Calculates Reynolds number of a control valve for a liquid or gas flowing through it at a specified Q, for a specified D1, FL, Fd, C, and with kinematic viscosity `nu` according to IEC 60534 calculations. .. math:: Re_v = \frac{N_4 F_d Q}{\nu \sqrt{...
[ "def", "Reynolds_valve", "(", "nu", ",", "Q", ",", "D1", ",", "FL", ",", "Fd", ",", "C", ")", ":", "return", "N4", "*", "Fd", "*", "Q", "/", "nu", "/", "(", "C", "*", "FL", ")", "**", "0.5", "*", "(", "FL", "**", "2", "*", "C", "**", "2...
r'''Calculates Reynolds number of a control valve for a liquid or gas flowing through it at a specified Q, for a specified D1, FL, Fd, C, and with kinematic viscosity `nu` according to IEC 60534 calculations. .. math:: Re_v = \frac{N_4 F_d Q}{\nu \sqrt{C F_L}}\left(\frac{F_L^2 C^2} {N_2D^4}...
[ "r", "Calculates", "Reynolds", "number", "of", "a", "control", "valve", "for", "a", "liquid", "or", "gas", "flowing", "through", "it", "at", "a", "specified", "Q", "for", "a", "specified", "D1", "FL", "Fd", "C", "and", "with", "kinematic", "viscosity", "...
57f556752e039f1d3e5a822f408c184783db2828
https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/control_valve.py#L363-L403
8,285
CalebBell/fluids
fluids/control_valve.py
Reynolds_factor
def Reynolds_factor(FL, C, d, Rev, full_trim=True): r'''Calculates the Reynolds number factor `FR` for a valve with a Reynolds number `Rev`, diameter `d`, flow coefficient `C`, liquid pressure recovery factor `FL`, and with either full or reduced trim, all according to IEC 60534 calculations. If f...
python
def Reynolds_factor(FL, C, d, Rev, full_trim=True): r'''Calculates the Reynolds number factor `FR` for a valve with a Reynolds number `Rev`, diameter `d`, flow coefficient `C`, liquid pressure recovery factor `FL`, and with either full or reduced trim, all according to IEC 60534 calculations. If f...
[ "def", "Reynolds_factor", "(", "FL", ",", "C", ",", "d", ",", "Rev", ",", "full_trim", "=", "True", ")", ":", "if", "full_trim", ":", "n1", "=", "N2", "/", "(", "min", "(", "C", "/", "d", "**", "2", ",", "0.04", ")", ")", "**", "2", "# C/d**2...
r'''Calculates the Reynolds number factor `FR` for a valve with a Reynolds number `Rev`, diameter `d`, flow coefficient `C`, liquid pressure recovery factor `FL`, and with either full or reduced trim, all according to IEC 60534 calculations. If full trim: .. math:: F_{R,1a} = 1 + \left(\f...
[ "r", "Calculates", "the", "Reynolds", "number", "factor", "FR", "for", "a", "valve", "with", "a", "Reynolds", "number", "Rev", "diameter", "d", "flow", "coefficient", "C", "liquid", "pressure", "recovery", "factor", "FL", "and", "with", "either", "full", "or...
57f556752e039f1d3e5a822f408c184783db2828
https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/control_valve.py#L461-L547
8,286
CalebBell/fluids
fluids/units.py
func_args
def func_args(func): '''Basic function which returns a tuple of arguments of a function or method. ''' try: return tuple(inspect.signature(func).parameters) except: return tuple(inspect.getargspec(func).args)
python
def func_args(func): '''Basic function which returns a tuple of arguments of a function or method. ''' try: return tuple(inspect.signature(func).parameters) except: return tuple(inspect.getargspec(func).args)
[ "def", "func_args", "(", "func", ")", ":", "try", ":", "return", "tuple", "(", "inspect", ".", "signature", "(", "func", ")", ".", "parameters", ")", "except", ":", "return", "tuple", "(", "inspect", ".", "getargspec", "(", "func", ")", ".", "args", ...
Basic function which returns a tuple of arguments of a function or method.
[ "Basic", "function", "which", "returns", "a", "tuple", "of", "arguments", "of", "a", "function", "or", "method", "." ]
57f556752e039f1d3e5a822f408c184783db2828
https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/units.py#L51-L58
8,287
CalebBell/fluids
fluids/optional/pychebfun.py
cast_scalar
def cast_scalar(method): """ Cast scalars to constant interpolating objects """ @wraps(method) def new_method(self, other): if np.isscalar(other): other = type(self)([other],self.domain()) return method(self, other) return new_method
python
def cast_scalar(method): """ Cast scalars to constant interpolating objects """ @wraps(method) def new_method(self, other): if np.isscalar(other): other = type(self)([other],self.domain()) return method(self, other) return new_method
[ "def", "cast_scalar", "(", "method", ")", ":", "@", "wraps", "(", "method", ")", "def", "new_method", "(", "self", ",", "other", ")", ":", "if", "np", ".", "isscalar", "(", "other", ")", ":", "other", "=", "type", "(", "self", ")", "(", "[", "oth...
Cast scalars to constant interpolating objects
[ "Cast", "scalars", "to", "constant", "interpolating", "objects" ]
57f556752e039f1d3e5a822f408c184783db2828
https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/optional/pychebfun.py#L75-L84
8,288
CalebBell/fluids
fluids/optional/pychebfun.py
dct
def dct(data): """ Compute DCT using FFT """ N = len(data)//2 fftdata = fftpack.fft(data, axis=0)[:N+1] fftdata /= N fftdata[0] /= 2. fftdata[-1] /= 2. if np.isrealobj(data): data = np.real(fftdata) else: data = fftdata return data
python
def dct(data): """ Compute DCT using FFT """ N = len(data)//2 fftdata = fftpack.fft(data, axis=0)[:N+1] fftdata /= N fftdata[0] /= 2. fftdata[-1] /= 2. if np.isrealobj(data): data = np.real(fftdata) else: data = fftdata return data
[ "def", "dct", "(", "data", ")", ":", "N", "=", "len", "(", "data", ")", "//", "2", "fftdata", "=", "fftpack", ".", "fft", "(", "data", ",", "axis", "=", "0", ")", "[", ":", "N", "+", "1", "]", "fftdata", "/=", "N", "fftdata", "[", "0", "]",...
Compute DCT using FFT
[ "Compute", "DCT", "using", "FFT" ]
57f556752e039f1d3e5a822f408c184783db2828
https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/optional/pychebfun.py#L637-L650
8,289
CalebBell/fluids
fluids/optional/pychebfun.py
Polyfun._cutoff
def _cutoff(self, coeffs, vscale): """ Compute cutoff index after which the coefficients are deemed negligible. """ bnd = self._threshold(vscale) inds = np.nonzero(abs(coeffs) >= bnd) if len(inds[0]): N = inds[0][-1] else: N = 0 re...
python
def _cutoff(self, coeffs, vscale): """ Compute cutoff index after which the coefficients are deemed negligible. """ bnd = self._threshold(vscale) inds = np.nonzero(abs(coeffs) >= bnd) if len(inds[0]): N = inds[0][-1] else: N = 0 re...
[ "def", "_cutoff", "(", "self", ",", "coeffs", ",", "vscale", ")", ":", "bnd", "=", "self", ".", "_threshold", "(", "vscale", ")", "inds", "=", "np", ".", "nonzero", "(", "abs", "(", "coeffs", ")", ">=", "bnd", ")", "if", "len", "(", "inds", "[", ...
Compute cutoff index after which the coefficients are deemed negligible.
[ "Compute", "cutoff", "index", "after", "which", "the", "coefficients", "are", "deemed", "negligible", "." ]
57f556752e039f1d3e5a822f408c184783db2828
https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/optional/pychebfun.py#L203-L213
8,290
CalebBell/fluids
fluids/optional/pychebfun.py
Polyfun.same_domain
def same_domain(self, fun2): """ Returns True if the domains of two objects are the same. """ return np.allclose(self.domain(), fun2.domain(), rtol=1e-14, atol=1e-14)
python
def same_domain(self, fun2): """ Returns True if the domains of two objects are the same. """ return np.allclose(self.domain(), fun2.domain(), rtol=1e-14, atol=1e-14)
[ "def", "same_domain", "(", "self", ",", "fun2", ")", ":", "return", "np", ".", "allclose", "(", "self", ".", "domain", "(", ")", ",", "fun2", ".", "domain", "(", ")", ",", "rtol", "=", "1e-14", ",", "atol", "=", "1e-14", ")" ]
Returns True if the domains of two objects are the same.
[ "Returns", "True", "if", "the", "domains", "of", "two", "objects", "are", "the", "same", "." ]
57f556752e039f1d3e5a822f408c184783db2828
https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/optional/pychebfun.py#L241-L245
8,291
CalebBell/fluids
fluids/optional/pychebfun.py
Polyfun.restrict
def restrict(self,subinterval): """ Return a Polyfun that matches self on subinterval. """ if (subinterval[0] < self._domain[0]) or (subinterval[1] > self._domain[1]): raise ValueError("Can only restrict to subinterval") return self.from_function(self, subinterval)
python
def restrict(self,subinterval): """ Return a Polyfun that matches self on subinterval. """ if (subinterval[0] < self._domain[0]) or (subinterval[1] > self._domain[1]): raise ValueError("Can only restrict to subinterval") return self.from_function(self, subinterval)
[ "def", "restrict", "(", "self", ",", "subinterval", ")", ":", "if", "(", "subinterval", "[", "0", "]", "<", "self", ".", "_domain", "[", "0", "]", ")", "or", "(", "subinterval", "[", "1", "]", ">", "self", ".", "_domain", "[", "1", "]", ")", ":...
Return a Polyfun that matches self on subinterval.
[ "Return", "a", "Polyfun", "that", "matches", "self", "on", "subinterval", "." ]
57f556752e039f1d3e5a822f408c184783db2828
https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/optional/pychebfun.py#L395-L401
8,292
CalebBell/fluids
fluids/optional/pychebfun.py
Chebfun.basis
def basis(self, n): """ Chebyshev basis functions T_n. """ if n == 0: return self(np.array([1.])) vals = np.ones(n+1) vals[1::2] = -1 return self(vals)
python
def basis(self, n): """ Chebyshev basis functions T_n. """ if n == 0: return self(np.array([1.])) vals = np.ones(n+1) vals[1::2] = -1 return self(vals)
[ "def", "basis", "(", "self", ",", "n", ")", ":", "if", "n", "==", "0", ":", "return", "self", "(", "np", ".", "array", "(", "[", "1.", "]", ")", ")", "vals", "=", "np", ".", "ones", "(", "n", "+", "1", ")", "vals", "[", "1", ":", ":", "...
Chebyshev basis functions T_n.
[ "Chebyshev", "basis", "functions", "T_n", "." ]
57f556752e039f1d3e5a822f408c184783db2828
https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/optional/pychebfun.py#L435-L443
8,293
CalebBell/fluids
fluids/optional/pychebfun.py
Chebfun.sum
def sum(self): """ Evaluate the integral over the given interval using Clenshaw-Curtis quadrature. """ ak = self.coefficients() ak2 = ak[::2] n = len(ak2) Tints = 2/(1-(2*np.arange(n))**2) val = np.sum((Tints*ak2.T).T, axis=0) a_, b_ = self...
python
def sum(self): """ Evaluate the integral over the given interval using Clenshaw-Curtis quadrature. """ ak = self.coefficients() ak2 = ak[::2] n = len(ak2) Tints = 2/(1-(2*np.arange(n))**2) val = np.sum((Tints*ak2.T).T, axis=0) a_, b_ = self...
[ "def", "sum", "(", "self", ")", ":", "ak", "=", "self", ".", "coefficients", "(", ")", "ak2", "=", "ak", "[", ":", ":", "2", "]", "n", "=", "len", "(", "ak2", ")", "Tints", "=", "2", "/", "(", "1", "-", "(", "2", "*", "np", ".", "arange",...
Evaluate the integral over the given interval using Clenshaw-Curtis quadrature.
[ "Evaluate", "the", "integral", "over", "the", "given", "interval", "using", "Clenshaw", "-", "Curtis", "quadrature", "." ]
57f556752e039f1d3e5a822f408c184783db2828
https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/optional/pychebfun.py#L449-L460
8,294
CalebBell/fluids
fluids/optional/pychebfun.py
Chebfun.integrate
def integrate(self): """ Return the object representing the primitive of self over the domain. The output starts at zero on the left-hand side of the domain. """ coeffs = self.coefficients() a,b = self.domain() int_coeffs = 0.5*(b-a)*poly.chebyshev.chebint(coeffs)...
python
def integrate(self): """ Return the object representing the primitive of self over the domain. The output starts at zero on the left-hand side of the domain. """ coeffs = self.coefficients() a,b = self.domain() int_coeffs = 0.5*(b-a)*poly.chebyshev.chebint(coeffs)...
[ "def", "integrate", "(", "self", ")", ":", "coeffs", "=", "self", ".", "coefficients", "(", ")", "a", ",", "b", "=", "self", ".", "domain", "(", ")", "int_coeffs", "=", "0.5", "*", "(", "b", "-", "a", ")", "*", "poly", ".", "chebyshev", ".", "c...
Return the object representing the primitive of self over the domain. The output starts at zero on the left-hand side of the domain.
[ "Return", "the", "object", "representing", "the", "primitive", "of", "self", "over", "the", "domain", ".", "The", "output", "starts", "at", "zero", "on", "the", "left", "-", "hand", "side", "of", "the", "domain", "." ]
57f556752e039f1d3e5a822f408c184783db2828
https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/optional/pychebfun.py#L462-L471
8,295
CalebBell/fluids
fluids/optional/pychebfun.py
Chebfun.differentiate
def differentiate(self, n=1): """ n-th derivative, default 1. """ ak = self.coefficients() a_, b_ = self.domain() for _ in range(n): ak = self.differentiator(ak) return self.from_coeff((2./(b_-a_))**n*ak, domain=self.domain())
python
def differentiate(self, n=1): """ n-th derivative, default 1. """ ak = self.coefficients() a_, b_ = self.domain() for _ in range(n): ak = self.differentiator(ak) return self.from_coeff((2./(b_-a_))**n*ak, domain=self.domain())
[ "def", "differentiate", "(", "self", ",", "n", "=", "1", ")", ":", "ak", "=", "self", ".", "coefficients", "(", ")", "a_", ",", "b_", "=", "self", ".", "domain", "(", ")", "for", "_", "in", "range", "(", "n", ")", ":", "ak", "=", "self", ".",...
n-th derivative, default 1.
[ "n", "-", "th", "derivative", "default", "1", "." ]
57f556752e039f1d3e5a822f408c184783db2828
https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/optional/pychebfun.py#L473-L481
8,296
CalebBell/fluids
fluids/optional/pychebfun.py
Chebfun.sample_function
def sample_function(self, f, N): """ Sample a function on N+1 Chebyshev points. """ x = self.interpolation_points(N+1) return f(x)
python
def sample_function(self, f, N): """ Sample a function on N+1 Chebyshev points. """ x = self.interpolation_points(N+1) return f(x)
[ "def", "sample_function", "(", "self", ",", "f", ",", "N", ")", ":", "x", "=", "self", ".", "interpolation_points", "(", "N", "+", "1", ")", "return", "f", "(", "x", ")" ]
Sample a function on N+1 Chebyshev points.
[ "Sample", "a", "function", "on", "N", "+", "1", "Chebyshev", "points", "." ]
57f556752e039f1d3e5a822f408c184783db2828
https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/optional/pychebfun.py#L538-L543
8,297
CalebBell/fluids
fluids/optional/pychebfun.py
Chebfun.interpolator
def interpolator(self, x, values): """ Returns a polynomial with vector coefficients which interpolates the values at the Chebyshev points x """ # hacking the barycentric interpolator by computing the weights in advance p = Bary([0.]) N = len(values) weights = np....
python
def interpolator(self, x, values): """ Returns a polynomial with vector coefficients which interpolates the values at the Chebyshev points x """ # hacking the barycentric interpolator by computing the weights in advance p = Bary([0.]) N = len(values) weights = np....
[ "def", "interpolator", "(", "self", ",", "x", ",", "values", ")", ":", "# hacking the barycentric interpolator by computing the weights in advance", "p", "=", "Bary", "(", "[", "0.", "]", ")", "N", "=", "len", "(", "values", ")", "weights", "=", "np", ".", "...
Returns a polynomial with vector coefficients which interpolates the values at the Chebyshev points x
[ "Returns", "a", "polynomial", "with", "vector", "coefficients", "which", "interpolates", "the", "values", "at", "the", "Chebyshev", "points", "x" ]
57f556752e039f1d3e5a822f408c184783db2828
https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/optional/pychebfun.py#L582-L596
8,298
CalebBell/fluids
fluids/drag.py
drag_sphere
def drag_sphere(Re, Method=None, AvailableMethods=False): r'''This function handles calculation of drag coefficient on spheres. Twenty methods are available, all requiring only the Reynolds number of the sphere. Most methods are valid from Re=0 to Re=200,000. A correlation will be automatically selected...
python
def drag_sphere(Re, Method=None, AvailableMethods=False): r'''This function handles calculation of drag coefficient on spheres. Twenty methods are available, all requiring only the Reynolds number of the sphere. Most methods are valid from Re=0 to Re=200,000. A correlation will be automatically selected...
[ "def", "drag_sphere", "(", "Re", ",", "Method", "=", "None", ",", "AvailableMethods", "=", "False", ")", ":", "def", "list_methods", "(", ")", ":", "methods", "=", "[", "]", "for", "key", ",", "(", "func", ",", "Re_min", ",", "Re_max", ")", "in", "...
r'''This function handles calculation of drag coefficient on spheres. Twenty methods are available, all requiring only the Reynolds number of the sphere. Most methods are valid from Re=0 to Re=200,000. A correlation will be automatically selected if none is specified. The full list of correlations valid...
[ "r", "This", "function", "handles", "calculation", "of", "drag", "coefficient", "on", "spheres", ".", "Twenty", "methods", "are", "available", "all", "requiring", "only", "the", "Reynolds", "number", "of", "the", "sphere", ".", "Most", "methods", "are", "valid...
57f556752e039f1d3e5a822f408c184783db2828
https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/drag.py#L1028-L1101
8,299
CalebBell/fluids
fluids/drag.py
v_terminal
def v_terminal(D, rhop, rho, mu, Method=None): r'''Calculates terminal velocity of a falling sphere using any drag coefficient method supported by `drag_sphere`. The laminar solution for Re < 0.01 is first tried; if the resulting terminal velocity does not put it in the laminar regime, a numerical solut...
python
def v_terminal(D, rhop, rho, mu, Method=None): r'''Calculates terminal velocity of a falling sphere using any drag coefficient method supported by `drag_sphere`. The laminar solution for Re < 0.01 is first tried; if the resulting terminal velocity does not put it in the laminar regime, a numerical solut...
[ "def", "v_terminal", "(", "D", ",", "rhop", ",", "rho", ",", "mu", ",", "Method", "=", "None", ")", ":", "'''The following would be the ideal implementation. The actual function is\n optimized for speed, not readability\n def err(V):\n Re = rho*V*D/mu\n Cd = Barat...
r'''Calculates terminal velocity of a falling sphere using any drag coefficient method supported by `drag_sphere`. The laminar solution for Re < 0.01 is first tried; if the resulting terminal velocity does not put it in the laminar regime, a numerical solution is used. .. math:: v_t = \sqrt{\fr...
[ "r", "Calculates", "terminal", "velocity", "of", "a", "falling", "sphere", "using", "any", "drag", "coefficient", "method", "supported", "by", "drag_sphere", ".", "The", "laminar", "solution", "for", "Re", "<", "0", ".", "01", "is", "first", "tried", ";", ...
57f556752e039f1d3e5a822f408c184783db2828
https://github.com/CalebBell/fluids/blob/57f556752e039f1d3e5a822f408c184783db2828/fluids/drag.py#L1104-L1185