repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
inveniosoftware/invenio-db
invenio_db/shared.py
do_sqlite_connect
def do_sqlite_connect(dbapi_connection, connection_record): """Ensure SQLite checks foreign key constraints. For further details see "Foreign key support" sections on https://docs.sqlalchemy.org/en/latest/dialects/sqlite.html#foreign-key-support """ # Enable foreign key constraint checking curs...
python
def do_sqlite_connect(dbapi_connection, connection_record): """Ensure SQLite checks foreign key constraints. For further details see "Foreign key support" sections on https://docs.sqlalchemy.org/en/latest/dialects/sqlite.html#foreign-key-support """ # Enable foreign key constraint checking curs...
[ "def", "do_sqlite_connect", "(", "dbapi_connection", ",", "connection_record", ")", ":", "# Enable foreign key constraint checking", "cursor", "=", "dbapi_connection", ".", "cursor", "(", ")", "cursor", ".", "execute", "(", "'PRAGMA foreign_keys=ON'", ")", "cursor", "."...
Ensure SQLite checks foreign key constraints. For further details see "Foreign key support" sections on https://docs.sqlalchemy.org/en/latest/dialects/sqlite.html#foreign-key-support
[ "Ensure", "SQLite", "checks", "foreign", "key", "constraints", "." ]
train
https://github.com/inveniosoftware/invenio-db/blob/9009a4cf79574083e129909cf3d2656568550184/invenio_db/shared.py#L82-L91
inveniosoftware/invenio-db
invenio_db/shared.py
SQLAlchemy.apply_driver_hacks
def apply_driver_hacks(self, app, info, options): """Call before engine creation.""" # Don't forget to apply hacks defined on parent object. super(SQLAlchemy, self).apply_driver_hacks(app, info, options) if info.drivername == 'sqlite': connect_args = options.setdefault('conn...
python
def apply_driver_hacks(self, app, info, options): """Call before engine creation.""" # Don't forget to apply hacks defined on parent object. super(SQLAlchemy, self).apply_driver_hacks(app, info, options) if info.drivername == 'sqlite': connect_args = options.setdefault('conn...
[ "def", "apply_driver_hacks", "(", "self", ",", "app", ",", "info", ",", "options", ")", ":", "# Don't forget to apply hacks defined on parent object.", "super", "(", "SQLAlchemy", ",", "self", ")", ".", "apply_driver_hacks", "(", "app", ",", "info", ",", "options"...
Call before engine creation.
[ "Call", "before", "engine", "creation", "." ]
train
https://github.com/inveniosoftware/invenio-db/blob/9009a4cf79574083e129909cf3d2656568550184/invenio_db/shared.py#L32-L79
inveniosoftware/invenio-db
invenio_db/cli.py
create
def create(verbose): """Create tables.""" click.secho('Creating all tables!', fg='yellow', bold=True) with click.progressbar(_db.metadata.sorted_tables) as bar: for table in bar: if verbose: click.echo(' Creating table {0}'.format(table)) table.create(bind=_db...
python
def create(verbose): """Create tables.""" click.secho('Creating all tables!', fg='yellow', bold=True) with click.progressbar(_db.metadata.sorted_tables) as bar: for table in bar: if verbose: click.echo(' Creating table {0}'.format(table)) table.create(bind=_db...
[ "def", "create", "(", "verbose", ")", ":", "click", ".", "secho", "(", "'Creating all tables!'", ",", "fg", "=", "'yellow'", ",", "bold", "=", "True", ")", "with", "click", ".", "progressbar", "(", "_db", ".", "metadata", ".", "sorted_tables", ")", "as",...
Create tables.
[ "Create", "tables", "." ]
train
https://github.com/inveniosoftware/invenio-db/blob/9009a4cf79574083e129909cf3d2656568550184/invenio_db/cli.py#L49-L58
inveniosoftware/invenio-db
invenio_db/cli.py
drop
def drop(verbose): """Drop tables.""" click.secho('Dropping all tables!', fg='red', bold=True) with click.progressbar(reversed(_db.metadata.sorted_tables)) as bar: for table in bar: if verbose: click.echo(' Dropping table {0}'.format(table)) table.drop(bind=_d...
python
def drop(verbose): """Drop tables.""" click.secho('Dropping all tables!', fg='red', bold=True) with click.progressbar(reversed(_db.metadata.sorted_tables)) as bar: for table in bar: if verbose: click.echo(' Dropping table {0}'.format(table)) table.drop(bind=_d...
[ "def", "drop", "(", "verbose", ")", ":", "click", ".", "secho", "(", "'Dropping all tables!'", ",", "fg", "=", "'red'", ",", "bold", "=", "True", ")", "with", "click", ".", "progressbar", "(", "reversed", "(", "_db", ".", "metadata", ".", "sorted_tables"...
Drop tables.
[ "Drop", "tables", "." ]
train
https://github.com/inveniosoftware/invenio-db/blob/9009a4cf79574083e129909cf3d2656568550184/invenio_db/cli.py#L67-L76
inveniosoftware/invenio-db
invenio_db/cli.py
init
def init(): """Create database.""" click.secho('Creating database {0}'.format(_db.engine.url), fg='green') if not database_exists(str(_db.engine.url)): create_database(str(_db.engine.url))
python
def init(): """Create database.""" click.secho('Creating database {0}'.format(_db.engine.url), fg='green') if not database_exists(str(_db.engine.url)): create_database(str(_db.engine.url))
[ "def", "init", "(", ")", ":", "click", ".", "secho", "(", "'Creating database {0}'", ".", "format", "(", "_db", ".", "engine", ".", "url", ")", ",", "fg", "=", "'green'", ")", "if", "not", "database_exists", "(", "str", "(", "_db", ".", "engine", "."...
Create database.
[ "Create", "database", "." ]
train
https://github.com/inveniosoftware/invenio-db/blob/9009a4cf79574083e129909cf3d2656568550184/invenio_db/cli.py#L81-L86
inveniosoftware/invenio-db
invenio_db/cli.py
destroy
def destroy(): """Drop database.""" click.secho('Destroying database {0}'.format(_db.engine.url), fg='red', bold=True) if _db.engine.name == 'sqlite': try: drop_database(_db.engine.url) except FileNotFoundError as e: click.secho('Sqlite database has no...
python
def destroy(): """Drop database.""" click.secho('Destroying database {0}'.format(_db.engine.url), fg='red', bold=True) if _db.engine.name == 'sqlite': try: drop_database(_db.engine.url) except FileNotFoundError as e: click.secho('Sqlite database has no...
[ "def", "destroy", "(", ")", ":", "click", ".", "secho", "(", "'Destroying database {0}'", ".", "format", "(", "_db", ".", "engine", ".", "url", ")", ",", "fg", "=", "'red'", ",", "bold", "=", "True", ")", "if", "_db", ".", "engine", ".", "name", "=...
Drop database.
[ "Drop", "database", "." ]
train
https://github.com/inveniosoftware/invenio-db/blob/9009a4cf79574083e129909cf3d2656568550184/invenio_db/cli.py#L94-L105
quantmind/dynts
dynts/stats/rolling.py
rollingOperation.rolling
def rolling(self, op): """Fast rolling operation with O(log n) updates where n is the window size """ missing = self.missing ismissing = self.ismissing window = self.window it = iter(self.iterable) queue = deque(islice(it, window)) ol = self.skip...
python
def rolling(self, op): """Fast rolling operation with O(log n) updates where n is the window size """ missing = self.missing ismissing = self.ismissing window = self.window it = iter(self.iterable) queue = deque(islice(it, window)) ol = self.skip...
[ "def", "rolling", "(", "self", ",", "op", ")", ":", "missing", "=", "self", ".", "missing", "ismissing", "=", "self", ".", "ismissing", "window", "=", "self", ".", "window", "it", "=", "iter", "(", "self", ".", "iterable", ")", "queue", "=", "deque",...
Fast rolling operation with O(log n) updates where n is the window size
[ "Fast", "rolling", "operation", "with", "O", "(", "log", "n", ")", "updates", "where", "n", "is", "the", "window", "size" ]
train
https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/stats/rolling.py#L65-L83
doakey3/DashTable
dashtable/dashutils/get_span_column_count.py
get_span_column_count
def get_span_column_count(span): """ Find the length of a colspan. Parameters ---------- span : list of lists of int The [row, column] pairs that make up the span Returns ------- columns : int The number of columns included in the span Example ------- Consi...
python
def get_span_column_count(span): """ Find the length of a colspan. Parameters ---------- span : list of lists of int The [row, column] pairs that make up the span Returns ------- columns : int The number of columns included in the span Example ------- Consi...
[ "def", "get_span_column_count", "(", "span", ")", ":", "columns", "=", "1", "first_column", "=", "span", "[", "0", "]", "[", "1", "]", "for", "i", "in", "range", "(", "len", "(", "span", ")", ")", ":", "if", "span", "[", "i", "]", "[", "1", "]"...
Find the length of a colspan. Parameters ---------- span : list of lists of int The [row, column] pairs that make up the span Returns ------- columns : int The number of columns included in the span Example ------- Consider this table:: +------+-----------...
[ "Find", "the", "length", "of", "a", "colspan", "." ]
train
https://github.com/doakey3/DashTable/blob/744cfb6a717fa75a8092c83ebcd49b2668023681/dashtable/dashutils/get_span_column_count.py#L1-L39
eaton-lab/toytree
toytree/TreeStyle.py
TreeStyle.to_dict
def to_dict(self): "returns self as a dictionary with _underscore subdicts corrected." ndict = {} for key, val in self.__dict__.items(): if key[0] == "_": ndict[key[1:]] = val else: ndict[key] = val return ndict
python
def to_dict(self): "returns self as a dictionary with _underscore subdicts corrected." ndict = {} for key, val in self.__dict__.items(): if key[0] == "_": ndict[key[1:]] = val else: ndict[key] = val return ndict
[ "def", "to_dict", "(", "self", ")", ":", "ndict", "=", "{", "}", "for", "key", ",", "val", "in", "self", ".", "__dict__", ".", "items", "(", ")", ":", "if", "key", "[", "0", "]", "==", "\"_\"", ":", "ndict", "[", "key", "[", "1", ":", "]", ...
returns self as a dictionary with _underscore subdicts corrected.
[ "returns", "self", "as", "a", "dictionary", "with", "_underscore", "subdicts", "corrected", "." ]
train
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/TreeStyle.py#L164-L172
doakey3/DashTable
dashtable/dashutils/get_span_char_width.py
get_span_char_width
def get_span_char_width(span, column_widths): """ Sum the widths of the columns that make up the span, plus the extra. Parameters ---------- span : list of lists of int list of [row, column] pairs that make up the span column_widths : list of int The widths of the columns that m...
python
def get_span_char_width(span, column_widths): """ Sum the widths of the columns that make up the span, plus the extra. Parameters ---------- span : list of lists of int list of [row, column] pairs that make up the span column_widths : list of int The widths of the columns that m...
[ "def", "get_span_char_width", "(", "span", ",", "column_widths", ")", ":", "start_column", "=", "span", "[", "0", "]", "[", "1", "]", "column_count", "=", "get_span_column_count", "(", "span", ")", "total_width", "=", "0", "for", "i", "in", "range", "(", ...
Sum the widths of the columns that make up the span, plus the extra. Parameters ---------- span : list of lists of int list of [row, column] pairs that make up the span column_widths : list of int The widths of the columns that make up the table Returns ------- total_width ...
[ "Sum", "the", "widths", "of", "the", "columns", "that", "make", "up", "the", "span", "plus", "the", "extra", "." ]
train
https://github.com/doakey3/DashTable/blob/744cfb6a717fa75a8092c83ebcd49b2668023681/dashtable/dashutils/get_span_char_width.py#L4-L30
inveniosoftware/invenio-db
invenio_db/utils.py
rebuild_encrypted_properties
def rebuild_encrypted_properties(old_key, model, properties): """Rebuild a model's EncryptedType properties when the SECRET_KEY is changed. :param old_key: old SECRET_KEY. :param model: the affected db model. :param properties: list of properties to rebuild. """ inspector = reflection.Inspector...
python
def rebuild_encrypted_properties(old_key, model, properties): """Rebuild a model's EncryptedType properties when the SECRET_KEY is changed. :param old_key: old SECRET_KEY. :param model: the affected db model. :param properties: list of properties to rebuild. """ inspector = reflection.Inspector...
[ "def", "rebuild_encrypted_properties", "(", "old_key", ",", "model", ",", "properties", ")", ":", "inspector", "=", "reflection", ".", "Inspector", ".", "from_engine", "(", "db", ".", "engine", ")", "primary_key_names", "=", "inspector", ".", "get_primary_keys", ...
Rebuild a model's EncryptedType properties when the SECRET_KEY is changed. :param old_key: old SECRET_KEY. :param model: the affected db model. :param properties: list of properties to rebuild.
[ "Rebuild", "a", "model", "s", "EncryptedType", "properties", "when", "the", "SECRET_KEY", "is", "changed", "." ]
train
https://github.com/inveniosoftware/invenio-db/blob/9009a4cf79574083e129909cf3d2656568550184/invenio_db/utils.py#L21-L58
inveniosoftware/invenio-db
invenio_db/utils.py
create_alembic_version_table
def create_alembic_version_table(): """Create alembic_version table.""" alembic = current_app.extensions['invenio-db'].alembic if not alembic.migration_context._has_version_table(): alembic.migration_context._ensure_version_table() for head in alembic.script_directory.revision_map._real_head...
python
def create_alembic_version_table(): """Create alembic_version table.""" alembic = current_app.extensions['invenio-db'].alembic if not alembic.migration_context._has_version_table(): alembic.migration_context._ensure_version_table() for head in alembic.script_directory.revision_map._real_head...
[ "def", "create_alembic_version_table", "(", ")", ":", "alembic", "=", "current_app", ".", "extensions", "[", "'invenio-db'", "]", ".", "alembic", "if", "not", "alembic", ".", "migration_context", ".", "_has_version_table", "(", ")", ":", "alembic", ".", "migrati...
Create alembic_version table.
[ "Create", "alembic_version", "table", "." ]
train
https://github.com/inveniosoftware/invenio-db/blob/9009a4cf79574083e129909cf3d2656568550184/invenio_db/utils.py#L61-L67
inveniosoftware/invenio-db
invenio_db/utils.py
drop_alembic_version_table
def drop_alembic_version_table(): """Drop alembic_version table.""" if _db.engine.dialect.has_table(_db.engine, 'alembic_version'): alembic_version = _db.Table('alembic_version', _db.metadata, autoload_with=_db.engine) alembic_version.drop(bind=_db.engine)
python
def drop_alembic_version_table(): """Drop alembic_version table.""" if _db.engine.dialect.has_table(_db.engine, 'alembic_version'): alembic_version = _db.Table('alembic_version', _db.metadata, autoload_with=_db.engine) alembic_version.drop(bind=_db.engine)
[ "def", "drop_alembic_version_table", "(", ")", ":", "if", "_db", ".", "engine", ".", "dialect", ".", "has_table", "(", "_db", ".", "engine", ",", "'alembic_version'", ")", ":", "alembic_version", "=", "_db", ".", "Table", "(", "'alembic_version'", ",", "_db"...
Drop alembic_version table.
[ "Drop", "alembic_version", "table", "." ]
train
https://github.com/inveniosoftware/invenio-db/blob/9009a4cf79574083e129909cf3d2656568550184/invenio_db/utils.py#L70-L75
inveniosoftware/invenio-db
invenio_db/utils.py
versioning_model_classname
def versioning_model_classname(manager, model): """Get the name of the versioned model class.""" if manager.options.get('use_module_name', True): return '%s%sVersion' % ( model.__module__.title().replace('.', ''), model.__name__) else: return '%sVersion' % (model.__name__,)
python
def versioning_model_classname(manager, model): """Get the name of the versioned model class.""" if manager.options.get('use_module_name', True): return '%s%sVersion' % ( model.__module__.title().replace('.', ''), model.__name__) else: return '%sVersion' % (model.__name__,)
[ "def", "versioning_model_classname", "(", "manager", ",", "model", ")", ":", "if", "manager", ".", "options", ".", "get", "(", "'use_module_name'", ",", "True", ")", ":", "return", "'%s%sVersion'", "%", "(", "model", ".", "__module__", ".", "title", "(", "...
Get the name of the versioned model class.
[ "Get", "the", "name", "of", "the", "versioned", "model", "class", "." ]
train
https://github.com/inveniosoftware/invenio-db/blob/9009a4cf79574083e129909cf3d2656568550184/invenio_db/utils.py#L78-L84
inveniosoftware/invenio-db
invenio_db/utils.py
versioning_models_registered
def versioning_models_registered(manager, base): """Return True if all versioning models have been registered.""" declared_models = base._decl_class_registry.keys() return all(versioning_model_classname(manager, c) in declared_models for c in manager.pending_classes)
python
def versioning_models_registered(manager, base): """Return True if all versioning models have been registered.""" declared_models = base._decl_class_registry.keys() return all(versioning_model_classname(manager, c) in declared_models for c in manager.pending_classes)
[ "def", "versioning_models_registered", "(", "manager", ",", "base", ")", ":", "declared_models", "=", "base", ".", "_decl_class_registry", ".", "keys", "(", ")", "return", "all", "(", "versioning_model_classname", "(", "manager", ",", "c", ")", "in", "declared_m...
Return True if all versioning models have been registered.
[ "Return", "True", "if", "all", "versioning", "models", "have", "been", "registered", "." ]
train
https://github.com/inveniosoftware/invenio-db/blob/9009a4cf79574083e129909cf3d2656568550184/invenio_db/utils.py#L87-L91
quantmind/dynts
dynts/stats/variates.py
vector_to_symmetric
def vector_to_symmetric(v): '''Convert an iterable into a symmetric matrix.''' np = len(v) N = (int(sqrt(1 + 8*np)) - 1)//2 if N*(N+1)//2 != np: raise ValueError('Cannot convert vector to symmetric matrix') sym = ndarray((N,N)) iterable = iter(v) for r in range(N): f...
python
def vector_to_symmetric(v): '''Convert an iterable into a symmetric matrix.''' np = len(v) N = (int(sqrt(1 + 8*np)) - 1)//2 if N*(N+1)//2 != np: raise ValueError('Cannot convert vector to symmetric matrix') sym = ndarray((N,N)) iterable = iter(v) for r in range(N): f...
[ "def", "vector_to_symmetric", "(", "v", ")", ":", "np", "=", "len", "(", "v", ")", "N", "=", "(", "int", "(", "sqrt", "(", "1", "+", "8", "*", "np", ")", ")", "-", "1", ")", "//", "2", "if", "N", "*", "(", "N", "+", "1", ")", "//", "2",...
Convert an iterable into a symmetric matrix.
[ "Convert", "an", "iterable", "into", "a", "symmetric", "matrix", "." ]
train
https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/stats/variates.py#L7-L18
quantmind/dynts
dynts/stats/variates.py
Variates.cov
def cov(self, ddof=None, bias=0): '''The covariance matrix from the aggregate sample. It accepts an optional parameter for the degree of freedoms. :parameter ddof: If not ``None`` normalization is by (N - ddof), where N is the number of observations; this overrides the value im...
python
def cov(self, ddof=None, bias=0): '''The covariance matrix from the aggregate sample. It accepts an optional parameter for the degree of freedoms. :parameter ddof: If not ``None`` normalization is by (N - ddof), where N is the number of observations; this overrides the value im...
[ "def", "cov", "(", "self", ",", "ddof", "=", "None", ",", "bias", "=", "0", ")", ":", "N", "=", "self", ".", "n", "M", "=", "N", "if", "bias", "else", "N", "-", "1", "M", "=", "M", "if", "ddof", "is", "None", "else", "N", "-", "ddof", "re...
The covariance matrix from the aggregate sample. It accepts an optional parameter for the degree of freedoms. :parameter ddof: If not ``None`` normalization is by (N - ddof), where N is the number of observations; this overrides the value implied by bias. The default value ...
[ "The", "covariance", "matrix", "from", "the", "aggregate", "sample", ".", "It", "accepts", "an", "optional", "parameter", "for", "the", "degree", "of", "freedoms", ".", ":", "parameter", "ddof", ":", "If", "not", "None", "normalization", "is", "by", "(", "...
train
https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/stats/variates.py#L60-L71
quantmind/dynts
dynts/stats/variates.py
Variates.corr
def corr(self): '''The correlation matrix''' cov = self.cov() N = cov.shape[0] corr = ndarray((N,N)) for r in range(N): for c in range(r): corr[r,c] = corr[c,r] = cov[r,c]/sqrt(cov[r,r]*cov[c,c]) corr[r,r] = 1. return corr
python
def corr(self): '''The correlation matrix''' cov = self.cov() N = cov.shape[0] corr = ndarray((N,N)) for r in range(N): for c in range(r): corr[r,c] = corr[c,r] = cov[r,c]/sqrt(cov[r,r]*cov[c,c]) corr[r,r] = 1. return corr
[ "def", "corr", "(", "self", ")", ":", "cov", "=", "self", ".", "cov", "(", ")", "N", "=", "cov", ".", "shape", "[", "0", "]", "corr", "=", "ndarray", "(", "(", "N", ",", "N", ")", ")", "for", "r", "in", "range", "(", "N", ")", ":", "for",...
The correlation matrix
[ "The", "correlation", "matrix" ]
train
https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/stats/variates.py#L73-L82
quantmind/dynts
dynts/stats/functions.py
calmar
def calmar(sharpe, T = 1.0): ''' Calculate the Calmar ratio for a Weiner process @param sharpe: Annualized Sharpe ratio @param T: Time interval in years ''' x = 0.5*T*sharpe*sharpe return x/qp(x)
python
def calmar(sharpe, T = 1.0): ''' Calculate the Calmar ratio for a Weiner process @param sharpe: Annualized Sharpe ratio @param T: Time interval in years ''' x = 0.5*T*sharpe*sharpe return x/qp(x)
[ "def", "calmar", "(", "sharpe", ",", "T", "=", "1.0", ")", ":", "x", "=", "0.5", "*", "T", "*", "sharpe", "*", "sharpe", "return", "x", "/", "qp", "(", "x", ")" ]
Calculate the Calmar ratio for a Weiner process @param sharpe: Annualized Sharpe ratio @param T: Time interval in years
[ "Calculate", "the", "Calmar", "ratio", "for", "a", "Weiner", "process" ]
train
https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/stats/functions.py#L9-L17
quantmind/dynts
dynts/stats/functions.py
calmarnorm
def calmarnorm(sharpe, T, tau = 1.0): ''' Multiplicator for normalizing calmar ratio to period tau ''' return calmar(sharpe,tau)/calmar(sharpe,T)
python
def calmarnorm(sharpe, T, tau = 1.0): ''' Multiplicator for normalizing calmar ratio to period tau ''' return calmar(sharpe,tau)/calmar(sharpe,T)
[ "def", "calmarnorm", "(", "sharpe", ",", "T", ",", "tau", "=", "1.0", ")", ":", "return", "calmar", "(", "sharpe", ",", "tau", ")", "/", "calmar", "(", "sharpe", ",", "T", ")" ]
Multiplicator for normalizing calmar ratio to period tau
[ "Multiplicator", "for", "normalizing", "calmar", "ratio", "to", "period", "tau" ]
train
https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/stats/functions.py#L20-L24
inveniosoftware/invenio-db
invenio_db/alembic/35c1075e6360_force_naming_convention.py
upgrade
def upgrade(): """Upgrade database.""" op.execute('COMMIT') # See https://bitbucket.org/zzzeek/alembic/issue/123 ctx = op.get_context() metadata = ctx.opts['target_metadata'] metadata.naming_convention = NAMING_CONVENTION metadata.bind = ctx.connection.engine insp = Inspector.from_engine(ct...
python
def upgrade(): """Upgrade database.""" op.execute('COMMIT') # See https://bitbucket.org/zzzeek/alembic/issue/123 ctx = op.get_context() metadata = ctx.opts['target_metadata'] metadata.naming_convention = NAMING_CONVENTION metadata.bind = ctx.connection.engine insp = Inspector.from_engine(ct...
[ "def", "upgrade", "(", ")", ":", "op", ".", "execute", "(", "'COMMIT'", ")", "# See https://bitbucket.org/zzzeek/alembic/issue/123", "ctx", "=", "op", ".", "get_context", "(", ")", "metadata", "=", "ctx", ".", "opts", "[", "'target_metadata'", "]", "metadata", ...
Upgrade database.
[ "Upgrade", "database", "." ]
train
https://github.com/inveniosoftware/invenio-db/blob/9009a4cf79574083e129909cf3d2656568550184/invenio_db/alembic/35c1075e6360_force_naming_convention.py#L31-L98
doakey3/DashTable
dashtable/data2simplerst/data2simplerst.py
data2simplerst
def data2simplerst(table, spans=[[[0, 0]]], use_headers=True, headers_row=0): """ Convert table data to a simple rst table Parameters ---------- table : list of lists of str A table of strings. spans : list of lists of lists of int A list of spans. A span is a list of [Row, Colu...
python
def data2simplerst(table, spans=[[[0, 0]]], use_headers=True, headers_row=0): """ Convert table data to a simple rst table Parameters ---------- table : list of lists of str A table of strings. spans : list of lists of lists of int A list of spans. A span is a list of [Row, Colu...
[ "def", "data2simplerst", "(", "table", ",", "spans", "=", "[", "[", "[", "0", ",", "0", "]", "]", "]", ",", "use_headers", "=", "True", ",", "headers_row", "=", "0", ")", ":", "table", "=", "copy", ".", "deepcopy", "(", "table", ")", "table_ok", ...
Convert table data to a simple rst table Parameters ---------- table : list of lists of str A table of strings. spans : list of lists of lists of int A list of spans. A span is a list of [Row, Column] pairs of table cells that are joined together. use_headers : bool, optiona...
[ "Convert", "table", "data", "to", "a", "simple", "rst", "table" ]
train
https://github.com/doakey3/DashTable/blob/744cfb6a717fa75a8092c83ebcd49b2668023681/dashtable/data2simplerst/data2simplerst.py#L13-L153
doakey3/DashTable
dashtable/html2data/restructify/add_links.py
add_links
def add_links(converted_text, html): """ Add the links to the bottom of the text """ soup = BeautifulSoup(html, 'html.parser') link_exceptions = [ 'footnote-reference', 'fn-backref', 'citation-reference' ] footnotes = {} citations = {} backrefs = {} lin...
python
def add_links(converted_text, html): """ Add the links to the bottom of the text """ soup = BeautifulSoup(html, 'html.parser') link_exceptions = [ 'footnote-reference', 'fn-backref', 'citation-reference' ] footnotes = {} citations = {} backrefs = {} lin...
[ "def", "add_links", "(", "converted_text", ",", "html", ")", ":", "soup", "=", "BeautifulSoup", "(", "html", ",", "'html.parser'", ")", "link_exceptions", "=", "[", "'footnote-reference'", ",", "'fn-backref'", ",", "'citation-reference'", "]", "footnotes", "=", ...
Add the links to the bottom of the text
[ "Add", "the", "links", "to", "the", "bottom", "of", "the", "text" ]
train
https://github.com/doakey3/DashTable/blob/744cfb6a717fa75a8092c83ebcd49b2668023681/dashtable/html2data/restructify/add_links.py#L5-L65
quantmind/dynts
dynts/data/__init__.py
TimeSerieLoader.load
def load(self, providers, symbols, start, end, logger, backend, **kwargs): '''Load symbols data. :keyword providers: Dictionary of registered data providers. :keyword symbols: list of symbols to load. :keyword start: start date. :keyword end: end date. :keyword lo...
python
def load(self, providers, symbols, start, end, logger, backend, **kwargs): '''Load symbols data. :keyword providers: Dictionary of registered data providers. :keyword symbols: list of symbols to load. :keyword start: start date. :keyword end: end date. :keyword lo...
[ "def", "load", "(", "self", ",", "providers", ",", "symbols", ",", "start", ",", "end", ",", "logger", ",", "backend", ",", "*", "*", "kwargs", ")", ":", "# Preconditioning on dates\r", "logger", "=", "logger", "or", "logging", ".", "getLogger", "(", "se...
Load symbols data. :keyword providers: Dictionary of registered data providers. :keyword symbols: list of symbols to load. :keyword start: start date. :keyword end: end date. :keyword logger: instance of :class:`logging.Logger` or ``None``. :keyword backend: :clas...
[ "Load", "symbols", "data", ".", ":", "keyword", "providers", ":", "Dictionary", "of", "registered", "data", "providers", ".", ":", "keyword", "symbols", ":", "list", "of", "symbols", "to", "load", ".", ":", "keyword", "start", ":", "start", "date", ".", ...
train
https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/data/__init__.py#L90-L133
quantmind/dynts
dynts/data/__init__.py
TimeSerieLoader.dates
def dates(self, start, end): '''Internal function which perform pre-conditioning on dates: :keyword start: start date. :keyword end: end date. This function makes sure the *start* and *end* date are consistent. It *never fails* and always return a two-element tuple containing *start*, *end* with *star...
python
def dates(self, start, end): '''Internal function which perform pre-conditioning on dates: :keyword start: start date. :keyword end: end date. This function makes sure the *start* and *end* date are consistent. It *never fails* and always return a two-element tuple containing *start*, *end* with *star...
[ "def", "dates", "(", "self", ",", "start", ",", "end", ")", ":", "td", "=", "date", ".", "today", "(", ")", "end", "=", "safetodate", "(", "end", ")", "or", "td", "end", "=", "end", "if", "end", "<=", "td", "else", "td", "start", "=", "safetoda...
Internal function which perform pre-conditioning on dates: :keyword start: start date. :keyword end: end date. This function makes sure the *start* and *end* date are consistent. It *never fails* and always return a two-element tuple containing *start*, *end* with *start* less or equal *end* and *end* never a...
[ "Internal", "function", "which", "perform", "pre", "-", "conditioning", "on", "dates", ":", ":", "keyword", "start", ":", "start", "date", ".", ":", "keyword", "end", ":", "end", "date", ".", "This", "function", "makes", "sure", "the", "*", "start", "*",...
train
https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/data/__init__.py#L135-L153
quantmind/dynts
dynts/data/__init__.py
TimeSerieLoader.parse_symbol
def parse_symbol(self, symbol, providers): '''Parse a symbol to obtain information regarding ticker, field and provider. Must return an instance of :attr:`symboldata`. :keyword symbol: string associated with market data to load. :keyword providers: dictionary of :class:`dynts.data....
python
def parse_symbol(self, symbol, providers): '''Parse a symbol to obtain information regarding ticker, field and provider. Must return an instance of :attr:`symboldata`. :keyword symbol: string associated with market data to load. :keyword providers: dictionary of :class:`dynts.data....
[ "def", "parse_symbol", "(", "self", ",", "symbol", ",", "providers", ")", ":", "separator", "=", "settings", ".", "field_separator", "symbol", "=", "str", "(", "symbol", ")", "bits", "=", "symbol", ".", "split", "(", "separator", ")", "pnames", "=", "pro...
Parse a symbol to obtain information regarding ticker, field and provider. Must return an instance of :attr:`symboldata`. :keyword symbol: string associated with market data to load. :keyword providers: dictionary of :class:`dynts.data.DataProvider` instances av...
[ "Parse", "a", "symbol", "to", "obtain", "information", "regarding", "ticker", "field", "and", "provider", ".", "Must", "return", "an", "instance", "of", ":", "attr", ":", "symboldata", ".", ":", "keyword", "symbol", ":", "string", "associated", "with", "mark...
train
https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/data/__init__.py#L155-L210
quantmind/dynts
dynts/data/__init__.py
TimeSerieLoader.symbol_for_ticker
def symbol_for_ticker(self, ticker, field, provider, providers): '''Return an instance of *symboldata* containing information about the data provider, the data provider ticker name and the data provider field.''' provider = provider or settings.default_provider if provider: pro...
python
def symbol_for_ticker(self, ticker, field, provider, providers): '''Return an instance of *symboldata* containing information about the data provider, the data provider ticker name and the data provider field.''' provider = provider or settings.default_provider if provider: pro...
[ "def", "symbol_for_ticker", "(", "self", ",", "ticker", ",", "field", ",", "provider", ",", "providers", ")", ":", "provider", "=", "provider", "or", "settings", ".", "default_provider", "if", "provider", ":", "provider", "=", "providers", ".", "get", "(", ...
Return an instance of *symboldata* containing information about the data provider, the data provider ticker name and the data provider field.
[ "Return", "an", "instance", "of", "*", "symboldata", "*", "containing", "information", "about", "the", "data", "provider", "the", "data", "provider", "ticker", "name", "and", "the", "data", "provider", "field", "." ]
train
https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/data/__init__.py#L212-L219
quantmind/dynts
dynts/data/__init__.py
TimeSerieLoader.preprocess
def preprocess(self, ticker, start, end, logger, backend, **kwargs): '''Preprocess **hook**. This is first loading hook and it is **called before requesting data** from a dataprovider. It must return an instance of :attr:`TimeSerieLoader.preprocessdata`. By default it returns:: self.preprocessdata(in...
python
def preprocess(self, ticker, start, end, logger, backend, **kwargs): '''Preprocess **hook**. This is first loading hook and it is **called before requesting data** from a dataprovider. It must return an instance of :attr:`TimeSerieLoader.preprocessdata`. By default it returns:: self.preprocessdata(in...
[ "def", "preprocess", "(", "self", ",", "ticker", ",", "start", ",", "end", ",", "logger", ",", "backend", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "preprocessdata", "(", "intervals", "=", "(", "(", "start", ",", "end", ")", ",", ")...
Preprocess **hook**. This is first loading hook and it is **called before requesting data** from a dataprovider. It must return an instance of :attr:`TimeSerieLoader.preprocessdata`. By default it returns:: self.preprocessdata(intervals = ((start,end),)) It could be overritten to modify the intervals. If ...
[ "Preprocess", "**", "hook", "**", ".", "This", "is", "first", "loading", "hook", "and", "it", "is", "**", "called", "before", "requesting", "data", "**", "from", "a", "dataprovider", ".", "It", "must", "return", "an", "instance", "of", ":", "attr", ":", ...
train
https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/data/__init__.py#L230-L244
quantmind/dynts
dynts/data/__init__.py
DataProviders.register
def register(self, provider): '''Register a new data provider. *provider* must be an instance of DataProvider. If provider name is already available, it will be replaced.''' if isinstance(provider,type): provider = provider() self[provider.code] = provider
python
def register(self, provider): '''Register a new data provider. *provider* must be an instance of DataProvider. If provider name is already available, it will be replaced.''' if isinstance(provider,type): provider = provider() self[provider.code] = provider
[ "def", "register", "(", "self", ",", "provider", ")", ":", "if", "isinstance", "(", "provider", ",", "type", ")", ":", "provider", "=", "provider", "(", ")", "self", "[", "provider", ".", "code", "]", "=", "provider" ]
Register a new data provider. *provider* must be an instance of DataProvider. If provider name is already available, it will be replaced.
[ "Register", "a", "new", "data", "provider", ".", "*", "provider", "*", "must", "be", "an", "instance", "of", "DataProvider", ".", "If", "provider", "name", "is", "already", "available", "it", "will", "be", "replaced", "." ]
train
https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/data/__init__.py#L274-L279
quantmind/dynts
dynts/data/__init__.py
DataProviders.unregister
def unregister(self, provider): '''Unregister an existing data provider. *provider* must be an instance of DataProvider. If provider name is already available, it will be replaced. ''' if isinstance(provider, type): provider = provider() if isinstance...
python
def unregister(self, provider): '''Unregister an existing data provider. *provider* must be an instance of DataProvider. If provider name is already available, it will be replaced. ''' if isinstance(provider, type): provider = provider() if isinstance...
[ "def", "unregister", "(", "self", ",", "provider", ")", ":", "if", "isinstance", "(", "provider", ",", "type", ")", ":", "provider", "=", "provider", "(", ")", "if", "isinstance", "(", "provider", ",", "DataProvider", ")", ":", "provider", "=", "provider...
Unregister an existing data provider. *provider* must be an instance of DataProvider. If provider name is already available, it will be replaced.
[ "Unregister", "an", "existing", "data", "provider", ".", "*", "provider", "*", "must", "be", "an", "instance", "of", "DataProvider", ".", "If", "provider", "name", "is", "already", "available", "it", "will", "be", "replaced", "." ]
train
https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/data/__init__.py#L281-L291
quantmind/dynts
dynts/dsl/__init__.py
parse
def parse(timeseries_expression, method=None, functions=None, debug=False): '''Function for parsing :ref:`timeseries expressions <dsl-script>`. If succesful, it returns an instance of :class:`dynts.dsl.Expr` which can be used to to populate timeseries or scatters once data is available. Parsing is...
python
def parse(timeseries_expression, method=None, functions=None, debug=False): '''Function for parsing :ref:`timeseries expressions <dsl-script>`. If succesful, it returns an instance of :class:`dynts.dsl.Expr` which can be used to to populate timeseries or scatters once data is available. Parsing is...
[ "def", "parse", "(", "timeseries_expression", ",", "method", "=", "None", ",", "functions", "=", "None", ",", "debug", "=", "False", ")", ":", "if", "not", "parsefunc", ":", "raise", "ExpressionError", "(", "'Could not parse. No parser installed.'", ")", "functi...
Function for parsing :ref:`timeseries expressions <dsl-script>`. If succesful, it returns an instance of :class:`dynts.dsl.Expr` which can be used to to populate timeseries or scatters once data is available. Parsing is implemented using the ply_ module, an implementation of lex and yacc parsing t...
[ "Function", "for", "parsing", ":", "ref", ":", "timeseries", "expressions", "<dsl", "-", "script", ">", ".", "If", "succesful", "it", "returns", "an", "instance", "of", ":", "class", ":", "dynts", ".", "dsl", ".", "Expr", "which", "can", "be", "used", ...
train
https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/dsl/__init__.py#L18-L43
quantmind/dynts
dynts/dsl/__init__.py
evaluate
def evaluate(expression, start=None, end=None, loader=None, logger=None, backend=None, **kwargs): '''Evaluate a timeseries ``expression`` into an instance of :class:`dynts.dsl.dslresult` which can be used to obtain timeseries and/or scatters. This is probably the most used function of ...
python
def evaluate(expression, start=None, end=None, loader=None, logger=None, backend=None, **kwargs): '''Evaluate a timeseries ``expression`` into an instance of :class:`dynts.dsl.dslresult` which can be used to obtain timeseries and/or scatters. This is probably the most used function of ...
[ "def", "evaluate", "(", "expression", ",", "start", "=", "None", ",", "end", "=", "None", ",", "loader", "=", "None", ",", "logger", "=", "None", ",", "backend", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "isinstance", "(", "expression", ...
Evaluate a timeseries ``expression`` into an instance of :class:`dynts.dsl.dslresult` which can be used to obtain timeseries and/or scatters. This is probably the most used function of the library. :parameter expression: A timeseries expression string or an instance of :class:`dynts.dsl.E...
[ "Evaluate", "a", "timeseries", "expression", "into", "an", "instance", "of", ":", "class", ":", "dynts", ".", "dsl", ".", "dslresult", "which", "can", "be", "used", "to", "obtain", "timeseries", "and", "/", "or", "scatters", ".", "This", "is", "probably", ...
train
https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/dsl/__init__.py#L46-L90
doakey3/DashTable
dashtable/grid2data/grid2data.py
grid2data
def grid2data(text): """ Convert Grid table to data (the kind used by Dashtable) Parameters ---------- text : str The text must be a valid rst table Returns ------- table : list of lists of str spans : list of lists of lists of int A span is a list of [row, column] p...
python
def grid2data(text): """ Convert Grid table to data (the kind used by Dashtable) Parameters ---------- text : str The text must be a valid rst table Returns ------- table : list of lists of str spans : list of lists of lists of int A span is a list of [row, column] p...
[ "def", "grid2data", "(", "text", ")", ":", "try", ":", "import", "docutils", ".", "statemachine", "import", "docutils", ".", "parsers", ".", "rst", ".", "tableparser", "except", "ImportError", ":", "print", "(", "\"ERROR: You must install the docutils library to use...
Convert Grid table to data (the kind used by Dashtable) Parameters ---------- text : str The text must be a valid rst table Returns ------- table : list of lists of str spans : list of lists of lists of int A span is a list of [row, column] pairs that define a group of ...
[ "Convert", "Grid", "table", "to", "data", "(", "the", "kind", "used", "by", "Dashtable", ")" ]
train
https://github.com/doakey3/DashTable/blob/744cfb6a717fa75a8092c83ebcd49b2668023681/dashtable/grid2data/grid2data.py#L6-L108
eaton-lab/toytree
toytree/Multitree.py
MultiTree.get_consensus_tree
def get_consensus_tree(self, cutoff=0.0, best_tree=None): """ Returns an extended majority rule consensus tree as a Toytree object. Node labels include 'support' values showing the occurrence of clades in the consensus tree across trees in the input treelist. Clades with suppor...
python
def get_consensus_tree(self, cutoff=0.0, best_tree=None): """ Returns an extended majority rule consensus tree as a Toytree object. Node labels include 'support' values showing the occurrence of clades in the consensus tree across trees in the input treelist. Clades with suppor...
[ "def", "get_consensus_tree", "(", "self", ",", "cutoff", "=", "0.0", ",", "best_tree", "=", "None", ")", ":", "if", "best_tree", ":", "raise", "NotImplementedError", "(", "\"best_tree option not yet supported.\"", ")", "cons", "=", "ConsensusTree", "(", "self", ...
Returns an extended majority rule consensus tree as a Toytree object. Node labels include 'support' values showing the occurrence of clades in the consensus tree across trees in the input treelist. Clades with support below 'cutoff' are collapsed into polytomies. If you enter an option...
[ "Returns", "an", "extended", "majority", "rule", "consensus", "tree", "as", "a", "Toytree", "object", ".", "Node", "labels", "include", "support", "values", "showing", "the", "occurrence", "of", "clades", "in", "the", "consensus", "tree", "across", "trees", "i...
train
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/Multitree.py#L172-L196
eaton-lab/toytree
toytree/Multitree.py
MultiTree.draw_tree_grid
def draw_tree_grid(self, nrows=None, ncols=None, start=0, fixed_order=False, shared_axis=False, **kwargs): """ Draw a slice of x*y trees into a x,y grid non-overlapping. Parameters: ----------- x (int): N...
python
def draw_tree_grid(self, nrows=None, ncols=None, start=0, fixed_order=False, shared_axis=False, **kwargs): """ Draw a slice of x*y trees into a x,y grid non-overlapping. Parameters: ----------- x (int): N...
[ "def", "draw_tree_grid", "(", "self", ",", "nrows", "=", "None", ",", "ncols", "=", "None", ",", "start", "=", "0", ",", "fixed_order", "=", "False", ",", "shared_axis", "=", "False", ",", "*", "*", "kwargs", ")", ":", "# return nothing if tree is empty", ...
Draw a slice of x*y trees into a x,y grid non-overlapping. Parameters: ----------- x (int): Number of grid cells in x dimension. Default=automatically set. y (int): Number of grid cells in y dimension. Default=automatically set. start (int): ...
[ "Draw", "a", "slice", "of", "x", "*", "y", "trees", "into", "a", "x", "y", "grid", "non", "-", "overlapping", "." ]
train
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/Multitree.py#L201-L280
eaton-lab/toytree
toytree/Multitree.py
MultiTree.draw_cloud_tree
def draw_cloud_tree(self, axes=None, html=False, fixed_order=True, **kwargs): """ Draw a series of trees overlapping each other in coordinate space. The order of tip_labels is fixed in cloud trees so that trees with discordant relationships can be seen ...
python
def draw_cloud_tree(self, axes=None, html=False, fixed_order=True, **kwargs): """ Draw a series of trees overlapping each other in coordinate space. The order of tip_labels is fixed in cloud trees so that trees with discordant relationships can be seen ...
[ "def", "draw_cloud_tree", "(", "self", ",", "axes", "=", "None", ",", "html", "=", "False", ",", "fixed_order", "=", "True", ",", "*", "*", "kwargs", ")", ":", "# return nothing if tree is empty", "if", "not", "self", ".", "treelist", ":", "print", "(", ...
Draw a series of trees overlapping each other in coordinate space. The order of tip_labels is fixed in cloud trees so that trees with discordant relationships can be seen in conflict. To change the tip order use the 'fixed_order' argument in toytree.mtree() when creating the MultiTree o...
[ "Draw", "a", "series", "of", "trees", "overlapping", "each", "other", "in", "coordinate", "space", ".", "The", "order", "of", "tip_labels", "is", "fixed", "in", "cloud", "trees", "so", "that", "trees", "with", "discordant", "relationships", "can", "be", "see...
train
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/Multitree.py#L283-L363
eaton-lab/toytree
toytree/Multitree.py
ConsensusTree.hash_trees
def hash_trees(self): "hash ladderized tree topologies" observed = {} for idx, tree in enumerate(self.treelist): nwk = tree.write(tree_format=9) hashed = md5(nwk.encode("utf-8")).hexdigest() if hashed not in observed: observed[hashed] = ...
python
def hash_trees(self): "hash ladderized tree topologies" observed = {} for idx, tree in enumerate(self.treelist): nwk = tree.write(tree_format=9) hashed = md5(nwk.encode("utf-8")).hexdigest() if hashed not in observed: observed[hashed] = ...
[ "def", "hash_trees", "(", "self", ")", ":", "observed", "=", "{", "}", "for", "idx", ",", "tree", "in", "enumerate", "(", "self", ".", "treelist", ")", ":", "nwk", "=", "tree", ".", "write", "(", "tree_format", "=", "9", ")", "hashed", "=", "md5", ...
hash ladderized tree topologies
[ "hash", "ladderized", "tree", "topologies" ]
train
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/Multitree.py#L407-L418
eaton-lab/toytree
toytree/Multitree.py
ConsensusTree.find_clades
def find_clades(self): "Count clade occurrences." # index names from the first tree ndict = {j: i for i, j in enumerate(self.names)} namedict = {i: j for i, j in enumerate(self.names)} # store counts clade_counts = {} for tidx, ncopies in self.treedict.items(): ...
python
def find_clades(self): "Count clade occurrences." # index names from the first tree ndict = {j: i for i, j in enumerate(self.names)} namedict = {i: j for i, j in enumerate(self.names)} # store counts clade_counts = {} for tidx, ncopies in self.treedict.items(): ...
[ "def", "find_clades", "(", "self", ")", ":", "# index names from the first tree", "ndict", "=", "{", "j", ":", "i", "for", "i", ",", "j", "in", "enumerate", "(", "self", ".", "names", ")", "}", "namedict", "=", "{", "i", ":", "j", "for", "i", ",", ...
Count clade occurrences.
[ "Count", "clade", "occurrences", "." ]
train
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/Multitree.py#L421-L462
eaton-lab/toytree
toytree/Multitree.py
ConsensusTree.filter_clades
def filter_clades(self): "Remove conflicting clades and those < cutoff to get majority rule" passed = [] carrs = np.array([list(i[0]) for i in self.clade_counts], dtype=int) freqs = np.array([i[1] for i in self.clade_counts]) for idx in range(carrs.shape[0]): conflic...
python
def filter_clades(self): "Remove conflicting clades and those < cutoff to get majority rule" passed = [] carrs = np.array([list(i[0]) for i in self.clade_counts], dtype=int) freqs = np.array([i[1] for i in self.clade_counts]) for idx in range(carrs.shape[0]): conflic...
[ "def", "filter_clades", "(", "self", ")", ":", "passed", "=", "[", "]", "carrs", "=", "np", ".", "array", "(", "[", "list", "(", "i", "[", "0", "]", ")", "for", "i", "in", "self", ".", "clade_counts", "]", ",", "dtype", "=", "int", ")", "freqs"...
Remove conflicting clades and those < cutoff to get majority rule
[ "Remove", "conflicting", "clades", "and", "those", "<", "cutoff", "to", "get", "majority", "rule" ]
train
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/Multitree.py#L465-L492
eaton-lab/toytree
toytree/Multitree.py
ConsensusTree.build_trees
def build_trees(self): "Build an unrooted consensus tree from filtered clade counts." # storage nodes = {} idxarr = np.arange(len(self.fclade_counts[0][0])) queue = [] ## create dict of clade counts and set keys countdict = defaultdict(int) for clade, co...
python
def build_trees(self): "Build an unrooted consensus tree from filtered clade counts." # storage nodes = {} idxarr = np.arange(len(self.fclade_counts[0][0])) queue = [] ## create dict of clade counts and set keys countdict = defaultdict(int) for clade, co...
[ "def", "build_trees", "(", "self", ")", ":", "# storage", "nodes", "=", "{", "}", "idxarr", "=", "np", ".", "arange", "(", "len", "(", "self", ".", "fclade_counts", "[", "0", "]", "[", "0", "]", ")", ")", "queue", "=", "[", "]", "## create dict of ...
Build an unrooted consensus tree from filtered clade counts.
[ "Build", "an", "unrooted", "consensus", "tree", "from", "filtered", "clade", "counts", "." ]
train
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/Multitree.py#L495-L557
Lilykos/pyphonetics
pyphonetics/phonetics/phonetic_algorithm.py
PhoneticAlgorithm.sounds_like
def sounds_like(self, word1, word2): """Compare the phonetic representations of 2 words, and return a boolean value.""" return self.phonetics(word1) == self.phonetics(word2)
python
def sounds_like(self, word1, word2): """Compare the phonetic representations of 2 words, and return a boolean value.""" return self.phonetics(word1) == self.phonetics(word2)
[ "def", "sounds_like", "(", "self", ",", "word1", ",", "word2", ")", ":", "return", "self", ".", "phonetics", "(", "word1", ")", "==", "self", ".", "phonetics", "(", "word2", ")" ]
Compare the phonetic representations of 2 words, and return a boolean value.
[ "Compare", "the", "phonetic", "representations", "of", "2", "words", "and", "return", "a", "boolean", "value", "." ]
train
https://github.com/Lilykos/pyphonetics/blob/7f55cccc1135e6015520a895eb6859318a4b6111/pyphonetics/phonetics/phonetic_algorithm.py#L20-L22
Lilykos/pyphonetics
pyphonetics/phonetics/phonetic_algorithm.py
PhoneticAlgorithm.distance
def distance(self, word1, word2, metric='levenshtein'): """Get the similarity of the words, using the supported distance metrics.""" if metric in self.distances: distance_func = self.distances[metric] return distance_func(self.phonetics(word1), self.phonetics(word2)) else...
python
def distance(self, word1, word2, metric='levenshtein'): """Get the similarity of the words, using the supported distance metrics.""" if metric in self.distances: distance_func = self.distances[metric] return distance_func(self.phonetics(word1), self.phonetics(word2)) else...
[ "def", "distance", "(", "self", ",", "word1", ",", "word2", ",", "metric", "=", "'levenshtein'", ")", ":", "if", "metric", "in", "self", ".", "distances", ":", "distance_func", "=", "self", ".", "distances", "[", "metric", "]", "return", "distance_func", ...
Get the similarity of the words, using the supported distance metrics.
[ "Get", "the", "similarity", "of", "the", "words", "using", "the", "supported", "distance", "metrics", "." ]
train
https://github.com/Lilykos/pyphonetics/blob/7f55cccc1135e6015520a895eb6859318a4b6111/pyphonetics/phonetics/phonetic_algorithm.py#L24-L30
doakey3/DashTable
dashtable/data2rst/get_output_row_heights.py
get_output_row_heights
def get_output_row_heights(table, spans): """ Get the heights of the rows of the output table. Parameters ---------- table : list of lists of str spans : list of lists of int Returns ------- heights : list of int The heights of each row in the output table """ heigh...
python
def get_output_row_heights(table, spans): """ Get the heights of the rows of the output table. Parameters ---------- table : list of lists of str spans : list of lists of int Returns ------- heights : list of int The heights of each row in the output table """ heigh...
[ "def", "get_output_row_heights", "(", "table", ",", "spans", ")", ":", "heights", "=", "[", "]", "for", "row", "in", "table", ":", "heights", ".", "append", "(", "-", "1", ")", "for", "row", "in", "range", "(", "len", "(", "table", ")", ")", ":", ...
Get the heights of the rows of the output table. Parameters ---------- table : list of lists of str spans : list of lists of int Returns ------- heights : list of int The heights of each row in the output table
[ "Get", "the", "heights", "of", "the", "rows", "of", "the", "output", "table", "." ]
train
https://github.com/doakey3/DashTable/blob/744cfb6a717fa75a8092c83ebcd49b2668023681/dashtable/data2rst/get_output_row_heights.py#L5-L53
quantmind/dynts
dynts/lib/fallback/operators.py
smedian
def smedian(olist,nobs): '''Generalised media for odd and even number of samples''' if nobs: rem = nobs % 2 midpoint = nobs // 2 me = olist[midpoint] if not rem: me = 0.5 * (me + olist[midpoint-1]) return me else: return NaN
python
def smedian(olist,nobs): '''Generalised media for odd and even number of samples''' if nobs: rem = nobs % 2 midpoint = nobs // 2 me = olist[midpoint] if not rem: me = 0.5 * (me + olist[midpoint-1]) return me else: return NaN
[ "def", "smedian", "(", "olist", ",", "nobs", ")", ":", "if", "nobs", ":", "rem", "=", "nobs", "%", "2", "midpoint", "=", "nobs", "//", "2", "me", "=", "olist", "[", "midpoint", "]", "if", "not", "rem", ":", "me", "=", "0.5", "*", "(", "me", "...
Generalised media for odd and even number of samples
[ "Generalised", "media", "for", "odd", "and", "even", "number", "of", "samples" ]
train
https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/lib/fallback/operators.py#L41-L51
quantmind/dynts
dynts/lib/fallback/operators.py
roll_mean
def roll_mean(input, window): '''Apply a rolling mean function to an array. This is a simple rolling aggregation.''' nobs, i, j, sum_x = 0,0,0,0. N = len(input) if window > N: raise ValueError('Out of bound') output = np.ndarray(N-window+1,dtype=input.dtype) for val in inpu...
python
def roll_mean(input, window): '''Apply a rolling mean function to an array. This is a simple rolling aggregation.''' nobs, i, j, sum_x = 0,0,0,0. N = len(input) if window > N: raise ValueError('Out of bound') output = np.ndarray(N-window+1,dtype=input.dtype) for val in inpu...
[ "def", "roll_mean", "(", "input", ",", "window", ")", ":", "nobs", ",", "i", ",", "j", ",", "sum_x", "=", "0", ",", "0", ",", "0", ",", "0.", "N", "=", "len", "(", "input", ")", "if", "window", ">", "N", ":", "raise", "ValueError", "(", "'Out...
Apply a rolling mean function to an array. This is a simple rolling aggregation.
[ "Apply", "a", "rolling", "mean", "function", "to", "an", "array", ".", "This", "is", "a", "simple", "rolling", "aggregation", "." ]
train
https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/lib/fallback/operators.py#L76-L107
quantmind/dynts
dynts/lib/fallback/operators.py
roll_sd
def roll_sd(input, window, scale = 1.0, ddof = 0): '''Apply a rolling standard deviation function to an array. This is a simple rolling aggregation of squared sums.''' nobs, i, j, sx, sxx = 0,0,0,0.,0. N = len(input) sqrt = np.sqrt if window > N: raise ValueError('Out of bound') ...
python
def roll_sd(input, window, scale = 1.0, ddof = 0): '''Apply a rolling standard deviation function to an array. This is a simple rolling aggregation of squared sums.''' nobs, i, j, sx, sxx = 0,0,0,0.,0. N = len(input) sqrt = np.sqrt if window > N: raise ValueError('Out of bound') ...
[ "def", "roll_sd", "(", "input", ",", "window", ",", "scale", "=", "1.0", ",", "ddof", "=", "0", ")", ":", "nobs", ",", "i", ",", "j", ",", "sx", ",", "sxx", "=", "0", ",", "0", ",", "0", ",", "0.", ",", "0.", "N", "=", "len", "(", "input"...
Apply a rolling standard deviation function to an array. This is a simple rolling aggregation of squared sums.
[ "Apply", "a", "rolling", "standard", "deviation", "function", "to", "an", "array", ".", "This", "is", "a", "simple", "rolling", "aggregation", "of", "squared", "sums", "." ]
train
https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/lib/fallback/operators.py#L110-L148
doakey3/DashTable
dashtable/dashutils/check_span.py
check_span
def check_span(span, table): """ Ensure the span is valid. A span is a list of [row, column] pairs. These coordinates must form a rectangular shape. For example, this span will cause an error because it is not rectangular in shape.:: span = [[0, 1], [0, 2], [1, 0]] Spans must be ...
python
def check_span(span, table): """ Ensure the span is valid. A span is a list of [row, column] pairs. These coordinates must form a rectangular shape. For example, this span will cause an error because it is not rectangular in shape.:: span = [[0, 1], [0, 2], [1, 0]] Spans must be ...
[ "def", "check_span", "(", "span", ",", "table", ")", ":", "if", "not", "type", "(", "span", ")", "is", "list", ":", "return", "\"Spans must be a list of lists\"", "for", "pair", "in", "span", ":", "if", "not", "type", "(", "pair", ")", "is", "list", ":...
Ensure the span is valid. A span is a list of [row, column] pairs. These coordinates must form a rectangular shape. For example, this span will cause an error because it is not rectangular in shape.:: span = [[0, 1], [0, 2], [1, 0]] Spans must be * Rectanglular * A list of li...
[ "Ensure", "the", "span", "is", "valid", "." ]
train
https://github.com/doakey3/DashTable/blob/744cfb6a717fa75a8092c83ebcd49b2668023681/dashtable/dashutils/check_span.py#L7-L81
doakey3/DashTable
dashtable/data2rst/merge_all_cells.py
merge_all_cells
def merge_all_cells(cells): """ Loop through list of cells and piece them together one by one Parameters ---------- cells : list of dashtable.data2rst.Cell Returns ------- grid_table : str The final grid table """ current = 0 while len(cells) > 1: count = 0...
python
def merge_all_cells(cells): """ Loop through list of cells and piece them together one by one Parameters ---------- cells : list of dashtable.data2rst.Cell Returns ------- grid_table : str The final grid table """ current = 0 while len(cells) > 1: count = 0...
[ "def", "merge_all_cells", "(", "cells", ")", ":", "current", "=", "0", "while", "len", "(", "cells", ")", ">", "1", ":", "count", "=", "0", "while", "count", "<", "len", "(", "cells", ")", ":", "cell1", "=", "cells", "[", "current", "]", "cell2", ...
Loop through list of cells and piece them together one by one Parameters ---------- cells : list of dashtable.data2rst.Cell Returns ------- grid_table : str The final grid table
[ "Loop", "through", "list", "of", "cells", "and", "piece", "them", "together", "one", "by", "one" ]
train
https://github.com/doakey3/DashTable/blob/744cfb6a717fa75a8092c83ebcd49b2668023681/dashtable/data2rst/merge_all_cells.py#L5-L44
eaton-lab/toytree
toytree/utils.py
bpp2newick
def bpp2newick(bppnewick): "converts bpp newick format to normal newick" regex1 = re.compile(r" #[-+]?[0-9]*\.?[0-9]*[:]") regex2 = re.compile(r" #[-+]?[0-9]*\.?[0-9]*[;]") regex3 = re.compile(r": ") new = regex1.sub(":", bppnewick) new = regex2.sub(";", new) new = regex3.sub(":", new) r...
python
def bpp2newick(bppnewick): "converts bpp newick format to normal newick" regex1 = re.compile(r" #[-+]?[0-9]*\.?[0-9]*[:]") regex2 = re.compile(r" #[-+]?[0-9]*\.?[0-9]*[;]") regex3 = re.compile(r": ") new = regex1.sub(":", bppnewick) new = regex2.sub(";", new) new = regex3.sub(":", new) r...
[ "def", "bpp2newick", "(", "bppnewick", ")", ":", "regex1", "=", "re", ".", "compile", "(", "r\" #[-+]?[0-9]*\\.?[0-9]*[:]\"", ")", "regex2", "=", "re", ".", "compile", "(", "r\" #[-+]?[0-9]*\\.?[0-9]*[;]\"", ")", "regex3", "=", "re", ".", "compile", "(", "r\":...
converts bpp newick format to normal newick
[ "converts", "bpp", "newick", "format", "to", "normal", "newick" ]
train
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/utils.py#L396-L404
eaton-lab/toytree
toytree/utils.py
return_small_clade
def return_small_clade(treenode): "used to produce balanced trees, returns a tip node from the smaller clade" node = treenode while 1: if node.children: c1, c2 = node.children node = sorted([c1, c2], key=lambda x: len(x.get_leaves()))[0] else: return node
python
def return_small_clade(treenode): "used to produce balanced trees, returns a tip node from the smaller clade" node = treenode while 1: if node.children: c1, c2 = node.children node = sorted([c1, c2], key=lambda x: len(x.get_leaves()))[0] else: return node
[ "def", "return_small_clade", "(", "treenode", ")", ":", "node", "=", "treenode", "while", "1", ":", "if", "node", ".", "children", ":", "c1", ",", "c2", "=", "node", ".", "children", "node", "=", "sorted", "(", "[", "c1", ",", "c2", "]", ",", "key"...
used to produce balanced trees, returns a tip node from the smaller clade
[ "used", "to", "produce", "balanced", "trees", "returns", "a", "tip", "node", "from", "the", "smaller", "clade" ]
train
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/utils.py#L408-L416
eaton-lab/toytree
toytree/utils.py
fuzzy_match_tipnames
def fuzzy_match_tipnames(ttree, names, wildcard, regex, mrca=True, mono=True): """ Used in multiple internal functions (e.g., .root()) and .drop_tips()) to select an internal mrca node, or multiple tipnames, using fuzzy matching so that every name does not need to be written out by hand. name: verb...
python
def fuzzy_match_tipnames(ttree, names, wildcard, regex, mrca=True, mono=True): """ Used in multiple internal functions (e.g., .root()) and .drop_tips()) to select an internal mrca node, or multiple tipnames, using fuzzy matching so that every name does not need to be written out by hand. name: verb...
[ "def", "fuzzy_match_tipnames", "(", "ttree", ",", "names", ",", "wildcard", ",", "regex", ",", "mrca", "=", "True", ",", "mono", "=", "True", ")", ":", "# require arguments", "if", "not", "any", "(", "[", "names", ",", "wildcard", ",", "regex", "]", ")...
Used in multiple internal functions (e.g., .root()) and .drop_tips()) to select an internal mrca node, or multiple tipnames, using fuzzy matching so that every name does not need to be written out by hand. name: verbose list wildcard: matching unique string regex: regex expression mrca: return ...
[ "Used", "in", "multiple", "internal", "functions", "(", "e", ".", "g", ".", ".", "root", "()", ")", "and", ".", "drop_tips", "()", ")", "to", "select", "an", "internal", "mrca", "node", "or", "multiple", "tipnames", "using", "fuzzy", "matching", "so", ...
train
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/utils.py#L424-L497
eaton-lab/toytree
toytree/utils.py
TreeMod.node_scale_root_height
def node_scale_root_height(self, treeheight=1): """ Returns a toytree copy with all nodes scaled so that the root height equals the value entered for treeheight. """ # make tree height = 1 * treeheight ctree = self._ttree.copy() _height = ctree.treenode.height ...
python
def node_scale_root_height(self, treeheight=1): """ Returns a toytree copy with all nodes scaled so that the root height equals the value entered for treeheight. """ # make tree height = 1 * treeheight ctree = self._ttree.copy() _height = ctree.treenode.height ...
[ "def", "node_scale_root_height", "(", "self", ",", "treeheight", "=", "1", ")", ":", "# make tree height = 1 * treeheight", "ctree", "=", "self", ".", "_ttree", ".", "copy", "(", ")", "_height", "=", "ctree", ".", "treenode", ".", "height", "for", "node", "i...
Returns a toytree copy with all nodes scaled so that the root height equals the value entered for treeheight.
[ "Returns", "a", "toytree", "copy", "with", "all", "nodes", "scaled", "so", "that", "the", "root", "height", "equals", "the", "value", "entered", "for", "treeheight", "." ]
train
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/utils.py#L30-L41
eaton-lab/toytree
toytree/utils.py
TreeMod.node_slider
def node_slider(self, seed=None): """ Returns a toytree copy with node heights modified while retaining the same topology but not necessarily node branching order. Node heights are moved up or down uniformly between their parent and highest child node heights in 'levelorder' f...
python
def node_slider(self, seed=None): """ Returns a toytree copy with node heights modified while retaining the same topology but not necessarily node branching order. Node heights are moved up or down uniformly between their parent and highest child node heights in 'levelorder' f...
[ "def", "node_slider", "(", "self", ",", "seed", "=", "None", ")", ":", "# I don't think user's should need to access prop", "prop", "=", "0.999", "assert", "isinstance", "(", "prop", ",", "float", ")", ",", "\"prop must be a float\"", "assert", "prop", "<", "1", ...
Returns a toytree copy with node heights modified while retaining the same topology but not necessarily node branching order. Node heights are moved up or down uniformly between their parent and highest child node heights in 'levelorder' from root to tips. The total tree height is ret...
[ "Returns", "a", "toytree", "copy", "with", "node", "heights", "modified", "while", "retaining", "the", "same", "topology", "but", "not", "necessarily", "node", "branching", "order", ".", "Node", "heights", "are", "moved", "up", "or", "down", "uniformly", "betw...
train
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/utils.py#L44-L77
eaton-lab/toytree
toytree/utils.py
TreeMod.node_multiplier
def node_multiplier(self, multiplier=0.5, seed=None): """ Returns a toytree copy with all nodes multiplied by a constant sampled uniformly between (multiplier, 1/multiplier). """ random.seed(seed) ctree = self._ttree.copy() low, high = sorted([multiplier, 1. / mu...
python
def node_multiplier(self, multiplier=0.5, seed=None): """ Returns a toytree copy with all nodes multiplied by a constant sampled uniformly between (multiplier, 1/multiplier). """ random.seed(seed) ctree = self._ttree.copy() low, high = sorted([multiplier, 1. / mu...
[ "def", "node_multiplier", "(", "self", ",", "multiplier", "=", "0.5", ",", "seed", "=", "None", ")", ":", "random", ".", "seed", "(", "seed", ")", "ctree", "=", "self", ".", "_ttree", ".", "copy", "(", ")", "low", ",", "high", "=", "sorted", "(", ...
Returns a toytree copy with all nodes multiplied by a constant sampled uniformly between (multiplier, 1/multiplier).
[ "Returns", "a", "toytree", "copy", "with", "all", "nodes", "multiplied", "by", "a", "constant", "sampled", "uniformly", "between", "(", "multiplier", "1", "/", "multiplier", ")", "." ]
train
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/utils.py#L80-L92
eaton-lab/toytree
toytree/utils.py
TreeMod.make_ultrametric
def make_ultrametric(self, strategy=1): """ Returns a tree with branch lengths transformed so that the tree is ultrametric. Strategies include (1) tip-align: extend tips to the length of the fartest tip from the root; (2) non-parametric rate-smoothing: minimize ancestor-descend...
python
def make_ultrametric(self, strategy=1): """ Returns a tree with branch lengths transformed so that the tree is ultrametric. Strategies include (1) tip-align: extend tips to the length of the fartest tip from the root; (2) non-parametric rate-smoothing: minimize ancestor-descend...
[ "def", "make_ultrametric", "(", "self", ",", "strategy", "=", "1", ")", ":", "ctree", "=", "self", ".", "_ttree", ".", "copy", "(", ")", "if", "strategy", "==", "1", ":", "for", "node", "in", "ctree", ".", "treenode", ".", "traverse", "(", ")", ":"...
Returns a tree with branch lengths transformed so that the tree is ultrametric. Strategies include (1) tip-align: extend tips to the length of the fartest tip from the root; (2) non-parametric rate-smoothing: minimize ancestor-descendant local rates on branches to align tips ( not yet ...
[ "Returns", "a", "tree", "with", "branch", "lengths", "transformed", "so", "that", "the", "tree", "is", "ultrametric", ".", "Strategies", "include", "(", "1", ")", "tip", "-", "align", ":", "extend", "tips", "to", "the", "length", "of", "the", "fartest", ...
train
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/utils.py#L95-L115
eaton-lab/toytree
toytree/utils.py
RandomTree.coaltree
def coaltree(ntips, ne=None, seed=None): """ Returns a coalescent tree with ntips samples and waiting times between coalescent events drawn from the kingman coalescent: (4N)/(k*(k-1)), where N is population size and k is sample size. Edge lengths on the tree are in generations. ...
python
def coaltree(ntips, ne=None, seed=None): """ Returns a coalescent tree with ntips samples and waiting times between coalescent events drawn from the kingman coalescent: (4N)/(k*(k-1)), where N is population size and k is sample size. Edge lengths on the tree are in generations. ...
[ "def", "coaltree", "(", "ntips", ",", "ne", "=", "None", ",", "seed", "=", "None", ")", ":", "# seed generator", "random", ".", "seed", "(", "seed", ")", "# convert units", "coalunits", "=", "False", "if", "not", "ne", ":", "coalunits", "=", "True", "n...
Returns a coalescent tree with ntips samples and waiting times between coalescent events drawn from the kingman coalescent: (4N)/(k*(k-1)), where N is population size and k is sample size. Edge lengths on the tree are in generations. If no Ne argument is entered then edge lengths are r...
[ "Returns", "a", "coalescent", "tree", "with", "ntips", "samples", "and", "waiting", "times", "between", "coalescent", "events", "drawn", "from", "the", "kingman", "coalescent", ":", "(", "4N", ")", "/", "(", "k", "*", "(", "k", "-", "1", "))", "where", ...
train
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/utils.py#L218-L275
eaton-lab/toytree
toytree/utils.py
RandomTree.unittree
def unittree(ntips, treeheight=1.0, seed=None): """ Returns a random tree topology w/ N tips and a root height set to 1 or a user-entered treeheight value. Descendant nodes are evenly spaced between the root and time 0. Parameters ----------- ntips (int): ...
python
def unittree(ntips, treeheight=1.0, seed=None): """ Returns a random tree topology w/ N tips and a root height set to 1 or a user-entered treeheight value. Descendant nodes are evenly spaced between the root and time 0. Parameters ----------- ntips (int): ...
[ "def", "unittree", "(", "ntips", ",", "treeheight", "=", "1.0", ",", "seed", "=", "None", ")", ":", "# seed generator", "random", ".", "seed", "(", "seed", ")", "# generate tree with N tips.", "tmptree", "=", "TreeNode", "(", ")", "tmptree", ".", "populate",...
Returns a random tree topology w/ N tips and a root height set to 1 or a user-entered treeheight value. Descendant nodes are evenly spaced between the root and time 0. Parameters ----------- ntips (int): The number of tips in the randomly generated tree tre...
[ "Returns", "a", "random", "tree", "topology", "w", "/", "N", "tips", "and", "a", "root", "height", "set", "to", "1", "or", "a", "user", "-", "entered", "treeheight", "value", ".", "Descendant", "nodes", "are", "evenly", "spaced", "between", "the", "root"...
train
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/utils.py#L279-L320
eaton-lab/toytree
toytree/utils.py
RandomTree.imbtree
def imbtree(ntips, treeheight=1.0): """ Return an imbalanced (comb-like) tree topology. """ rtree = toytree.tree() rtree.treenode.add_child(name="0") rtree.treenode.add_child(name="1") for i in range(2, ntips): # empty node cherry = toytre...
python
def imbtree(ntips, treeheight=1.0): """ Return an imbalanced (comb-like) tree topology. """ rtree = toytree.tree() rtree.treenode.add_child(name="0") rtree.treenode.add_child(name="1") for i in range(2, ntips): # empty node cherry = toytre...
[ "def", "imbtree", "(", "ntips", ",", "treeheight", "=", "1.0", ")", ":", "rtree", "=", "toytree", ".", "tree", "(", ")", "rtree", ".", "treenode", ".", "add_child", "(", "name", "=", "\"0\"", ")", "rtree", ".", "treenode", ".", "add_child", "(", "nam...
Return an imbalanced (comb-like) tree topology.
[ "Return", "an", "imbalanced", "(", "comb", "-", "like", ")", "tree", "topology", "." ]
train
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/utils.py#L324-L347
eaton-lab/toytree
toytree/utils.py
RandomTree.baltree
def baltree(ntips, treeheight=1.0): """ Returns a balanced tree topology. """ # require even number of tips if ntips % 2: raise ToytreeError("balanced trees must have even number of tips.") # make first cherry rtree = toytree.tree() rtree.tree...
python
def baltree(ntips, treeheight=1.0): """ Returns a balanced tree topology. """ # require even number of tips if ntips % 2: raise ToytreeError("balanced trees must have even number of tips.") # make first cherry rtree = toytree.tree() rtree.tree...
[ "def", "baltree", "(", "ntips", ",", "treeheight", "=", "1.0", ")", ":", "# require even number of tips", "if", "ntips", "%", "2", ":", "raise", "ToytreeError", "(", "\"balanced trees must have even number of tips.\"", ")", "# make first cherry", "rtree", "=", "toytre...
Returns a balanced tree topology.
[ "Returns", "a", "balanced", "tree", "topology", "." ]
train
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/utils.py#L351-L389
doakey3/DashTable
dashtable/dashutils/get_span_char_height.py
get_span_char_height
def get_span_char_height(span, row_heights): """ Get the height of a span in the number of newlines it fills. Parameters ---------- span : list of list of int A list of [row, column] pairs that make up the span row_heights : list of int A list of the number of newlines for each ...
python
def get_span_char_height(span, row_heights): """ Get the height of a span in the number of newlines it fills. Parameters ---------- span : list of list of int A list of [row, column] pairs that make up the span row_heights : list of int A list of the number of newlines for each ...
[ "def", "get_span_char_height", "(", "span", ",", "row_heights", ")", ":", "start_row", "=", "span", "[", "0", "]", "[", "0", "]", "row_count", "=", "get_span_row_count", "(", "span", ")", "total_height", "=", "0", "for", "i", "in", "range", "(", "start_r...
Get the height of a span in the number of newlines it fills. Parameters ---------- span : list of list of int A list of [row, column] pairs that make up the span row_heights : list of int A list of the number of newlines for each row in the table Returns ------- total_heigh...
[ "Get", "the", "height", "of", "a", "span", "in", "the", "number", "of", "newlines", "it", "fills", "." ]
train
https://github.com/doakey3/DashTable/blob/744cfb6a717fa75a8092c83ebcd49b2668023681/dashtable/dashutils/get_span_char_height.py#L4-L28
doakey3/DashTable
dashtable/html2data/html2data.py
html2data
def html2data(html_string): """ Convert an html table to a data table and spans. Parameters ---------- html_string : str The string containing the html table Returns ------- table : list of lists of str spans : list of lists of lists of int A span is a list of [row,...
python
def html2data(html_string): """ Convert an html table to a data table and spans. Parameters ---------- html_string : str The string containing the html table Returns ------- table : list of lists of str spans : list of lists of lists of int A span is a list of [row,...
[ "def", "html2data", "(", "html_string", ")", ":", "spans", "=", "extract_spans", "(", "html_string", ")", "column_count", "=", "get_html_column_count", "(", "html_string", ")", "row_count", "=", "get_html_row_count", "(", "spans", ")", "count", "=", "0", "while"...
Convert an html table to a data table and spans. Parameters ---------- html_string : str The string containing the html table Returns ------- table : list of lists of str spans : list of lists of lists of int A span is a list of [row, column] pairs that define what cells ...
[ "Convert", "an", "html", "table", "to", "a", "data", "table", "and", "spans", "." ]
train
https://github.com/doakey3/DashTable/blob/744cfb6a717fa75a8092c83ebcd49b2668023681/dashtable/html2data/html2data.py#L7-L40
eaton-lab/toytree
toytree/Toytree.py
ToyTree.newick
def newick(self, tree_format=0): "Returns newick represenation of the tree in its current state." # checks one of root's children for features and extra feats. if self.treenode.children: features = {"name", "dist", "support", "height", "idx"} testnode = self.treenode.chil...
python
def newick(self, tree_format=0): "Returns newick represenation of the tree in its current state." # checks one of root's children for features and extra feats. if self.treenode.children: features = {"name", "dist", "support", "height", "idx"} testnode = self.treenode.chil...
[ "def", "newick", "(", "self", ",", "tree_format", "=", "0", ")", ":", "# checks one of root's children for features and extra feats.", "if", "self", ".", "treenode", ".", "children", ":", "features", "=", "{", "\"name\"", ",", "\"dist\"", ",", "\"support\"", ",", ...
Returns newick represenation of the tree in its current state.
[ "Returns", "newick", "represenation", "of", "the", "tree", "in", "its", "current", "state", "." ]
train
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/Toytree.py#L132-L140
eaton-lab/toytree
toytree/Toytree.py
ToyTree.get_edge_values
def get_edge_values(self, feature='idx'): """ Returns edge values in the order they are plotted (see .get_edges()) """ elist = [] for cidx in self._coords.edges[:, 1]: node = self.treenode.search_nodes(idx=cidx)[0] elist.append( (node.__get...
python
def get_edge_values(self, feature='idx'): """ Returns edge values in the order they are plotted (see .get_edges()) """ elist = [] for cidx in self._coords.edges[:, 1]: node = self.treenode.search_nodes(idx=cidx)[0] elist.append( (node.__get...
[ "def", "get_edge_values", "(", "self", ",", "feature", "=", "'idx'", ")", ":", "elist", "=", "[", "]", "for", "cidx", "in", "self", ".", "_coords", ".", "edges", "[", ":", ",", "1", "]", ":", "node", "=", "self", ".", "treenode", ".", "search_nodes...
Returns edge values in the order they are plotted (see .get_edges())
[ "Returns", "edge", "values", "in", "the", "order", "they", "are", "plotted", "(", "see", ".", "get_edges", "()", ")" ]
train
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/Toytree.py#L173-L183
eaton-lab/toytree
toytree/Toytree.py
ToyTree.get_edge_values_from_dict
def get_edge_values_from_dict(self, node_value_dict=None, include_stem=True): """ Enter a dictionary mapping node 'idx' or tuple of tipnames to values that you want mapped to the stem and descendant edges that node. Edge values are returned in proper plot order to be entered to the ...
python
def get_edge_values_from_dict(self, node_value_dict=None, include_stem=True): """ Enter a dictionary mapping node 'idx' or tuple of tipnames to values that you want mapped to the stem and descendant edges that node. Edge values are returned in proper plot order to be entered to the ...
[ "def", "get_edge_values_from_dict", "(", "self", ",", "node_value_dict", "=", "None", ",", "include_stem", "=", "True", ")", ":", "# map node idxs to the order in which edges are plotted", "idxs", "=", "{", "j", ":", "i", "for", "(", "i", ",", "j", ")", "in", ...
Enter a dictionary mapping node 'idx' or tuple of tipnames to values that you want mapped to the stem and descendant edges that node. Edge values are returned in proper plot order to be entered to the edge_colors or edge_widths arguments to draw(). To see node idx values use node_lab...
[ "Enter", "a", "dictionary", "mapping", "node", "idx", "or", "tuple", "of", "tipnames", "to", "values", "that", "you", "want", "mapped", "to", "the", "stem", "and", "descendant", "edges", "that", "node", ".", "Edge", "values", "are", "returned", "in", "prop...
train
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/Toytree.py#L186-L242
eaton-lab/toytree
toytree/Toytree.py
ToyTree.get_mrca_idx_from_tip_labels
def get_mrca_idx_from_tip_labels(self, names=None, wildcard=None, regex=None): """ Returns the node idx label of the most recent common ancestor node for the clade that includes the selected tips. Arguments can use fuzzy name matching: a list of tip names, wildcard selector, or regex st...
python
def get_mrca_idx_from_tip_labels(self, names=None, wildcard=None, regex=None): """ Returns the node idx label of the most recent common ancestor node for the clade that includes the selected tips. Arguments can use fuzzy name matching: a list of tip names, wildcard selector, or regex st...
[ "def", "get_mrca_idx_from_tip_labels", "(", "self", ",", "names", "=", "None", ",", "wildcard", "=", "None", ",", "regex", "=", "None", ")", ":", "if", "not", "any", "(", "[", "names", ",", "wildcard", ",", "regex", "]", ")", ":", "raise", "ToytreeErro...
Returns the node idx label of the most recent common ancestor node for the clade that includes the selected tips. Arguments can use fuzzy name matching: a list of tip names, wildcard selector, or regex string.
[ "Returns", "the", "node", "idx", "label", "of", "the", "most", "recent", "common", "ancestor", "node", "for", "the", "clade", "that", "includes", "the", "selected", "tips", ".", "Arguments", "can", "use", "fuzzy", "name", "matching", ":", "a", "list", "of"...
train
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/Toytree.py#L245-L255
eaton-lab/toytree
toytree/Toytree.py
ToyTree.get_node_values
def get_node_values( self, feature=None, show_root=False, show_tips=False, ): """ Returns node values from tree object in node plot order. To modify values you must modify the .treenode object directly by setting new 'features'. For example ...
python
def get_node_values( self, feature=None, show_root=False, show_tips=False, ): """ Returns node values from tree object in node plot order. To modify values you must modify the .treenode object directly by setting new 'features'. For example ...
[ "def", "get_node_values", "(", "self", ",", "feature", "=", "None", ",", "show_root", "=", "False", ",", "show_tips", "=", "False", ",", ")", ":", "# access nodes in the order they will be plotted", "ndict", "=", "self", ".", "get_node_dict", "(", "return_internal...
Returns node values from tree object in node plot order. To modify values you must modify the .treenode object directly by setting new 'features'. For example for node in ttree.treenode.traverse(): node.add_feature("PP", 100) By default node and tip values are hidden (set t...
[ "Returns", "node", "values", "from", "tree", "object", "in", "node", "plot", "order", ".", "To", "modify", "values", "you", "must", "modify", "the", ".", "treenode", "object", "directly", "by", "setting", "new", "features", ".", "For", "example" ]
train
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/Toytree.py#L268-L313
eaton-lab/toytree
toytree/Toytree.py
ToyTree.get_node_dict
def get_node_dict(self, return_internal=False, return_nodes=False): """ Return node labels as a dictionary mapping {idx: name} where idx is the order of nodes in 'preorder' traversal. Used internally by the func .get_node_values() to return values in proper order. return_inter...
python
def get_node_dict(self, return_internal=False, return_nodes=False): """ Return node labels as a dictionary mapping {idx: name} where idx is the order of nodes in 'preorder' traversal. Used internally by the func .get_node_values() to return values in proper order. return_inter...
[ "def", "get_node_dict", "(", "self", ",", "return_internal", "=", "False", ",", "return_nodes", "=", "False", ")", ":", "if", "return_internal", ":", "if", "return_nodes", ":", "return", "{", "i", ".", "idx", ":", "i", "for", "i", "in", "self", ".", "t...
Return node labels as a dictionary mapping {idx: name} where idx is the order of nodes in 'preorder' traversal. Used internally by the func .get_node_values() to return values in proper order. return_internal: if True all nodes are returned, if False only tips. return_nodes: if True r...
[ "Return", "node", "labels", "as", "a", "dictionary", "mapping", "{", "idx", ":", "name", "}", "where", "idx", "is", "the", "order", "of", "nodes", "in", "preorder", "traversal", ".", "Used", "internally", "by", "the", "func", ".", "get_node_values", "()", ...
train
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/Toytree.py#L316-L344
eaton-lab/toytree
toytree/Toytree.py
ToyTree.get_tip_coordinates
def get_tip_coordinates(self, axis=None): """ Returns coordinates of the tip positions for a tree. If no argument for axis then a 2-d array is returned. The first column is the x coordinates the second column is the y-coordinates. If you enter an argument for axis then a 1-d ar...
python
def get_tip_coordinates(self, axis=None): """ Returns coordinates of the tip positions for a tree. If no argument for axis then a 2-d array is returned. The first column is the x coordinates the second column is the y-coordinates. If you enter an argument for axis then a 1-d ar...
[ "def", "get_tip_coordinates", "(", "self", ",", "axis", "=", "None", ")", ":", "# get coordinates array", "coords", "=", "self", ".", "get_node_coordinates", "(", ")", "if", "axis", "==", "'x'", ":", "return", "coords", "[", ":", "self", ".", "ntips", ",",...
Returns coordinates of the tip positions for a tree. If no argument for axis then a 2-d array is returned. The first column is the x coordinates the second column is the y-coordinates. If you enter an argument for axis then a 1-d array will be returned of just that axis.
[ "Returns", "coordinates", "of", "the", "tip", "positions", "for", "a", "tree", ".", "If", "no", "argument", "for", "axis", "then", "a", "2", "-", "d", "array", "is", "returned", ".", "The", "first", "column", "is", "the", "x", "coordinates", "the", "se...
train
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/Toytree.py#L347-L360
eaton-lab/toytree
toytree/Toytree.py
ToyTree.get_tip_labels
def get_tip_labels(self, idx=None): """ Returns tip labels in the order they will be plotted on the tree, i.e., starting from zero axis and counting up by units of 1 (bottom to top in right-facing trees; left to right in down-facing). If 'idx' is indicated then a list of tip la...
python
def get_tip_labels(self, idx=None): """ Returns tip labels in the order they will be plotted on the tree, i.e., starting from zero axis and counting up by units of 1 (bottom to top in right-facing trees; left to right in down-facing). If 'idx' is indicated then a list of tip la...
[ "def", "get_tip_labels", "(", "self", ",", "idx", "=", "None", ")", ":", "if", "not", "idx", ":", "return", "self", ".", "treenode", ".", "get_leaf_names", "(", ")", "[", ":", ":", "-", "1", "]", "else", ":", "treenode", "=", "self", ".", "treenode...
Returns tip labels in the order they will be plotted on the tree, i.e., starting from zero axis and counting up by units of 1 (bottom to top in right-facing trees; left to right in down-facing). If 'idx' is indicated then a list of tip labels descended from that node will be returned,...
[ "Returns", "tip", "labels", "in", "the", "order", "they", "will", "be", "plotted", "on", "the", "tree", "i", ".", "e", ".", "starting", "from", "zero", "axis", "and", "counting", "up", "by", "units", "of", "1", "(", "bottom", "to", "top", "in", "righ...
train
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/Toytree.py#L363-L386
eaton-lab/toytree
toytree/Toytree.py
ToyTree.is_bifurcating
def is_bifurcating(self, include_root=True): """ Returns False if there is a polytomy in the tree, including if the tree is unrooted (basal polytomy), unless you use the include_root=False argument. """ ctn1 = -1 + (2 * len(self)) ctn2 = -2 + (2 * len(self)) ...
python
def is_bifurcating(self, include_root=True): """ Returns False if there is a polytomy in the tree, including if the tree is unrooted (basal polytomy), unless you use the include_root=False argument. """ ctn1 = -1 + (2 * len(self)) ctn2 = -2 + (2 * len(self)) ...
[ "def", "is_bifurcating", "(", "self", ",", "include_root", "=", "True", ")", ":", "ctn1", "=", "-", "1", "+", "(", "2", "*", "len", "(", "self", ")", ")", "ctn2", "=", "-", "2", "+", "(", "2", "*", "len", "(", "self", ")", ")", "if", "self", ...
Returns False if there is a polytomy in the tree, including if the tree is unrooted (basal polytomy), unless you use the include_root=False argument.
[ "Returns", "False", "if", "there", "is", "a", "polytomy", "in", "the", "tree", "including", "if", "the", "tree", "is", "unrooted", "(", "basal", "polytomy", ")", "unless", "you", "use", "the", "include_root", "=", "False", "argument", "." ]
train
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/Toytree.py#L403-L415
eaton-lab/toytree
toytree/Toytree.py
ToyTree.ladderize
def ladderize(self, direction=0): """ Ladderize tree (order descendants) so that top child has fewer descendants than the bottom child in a left to right tree plot. To reverse this pattern use direction=1. """ nself = deepcopy(self) nself.treenode.ladderize(dire...
python
def ladderize(self, direction=0): """ Ladderize tree (order descendants) so that top child has fewer descendants than the bottom child in a left to right tree plot. To reverse this pattern use direction=1. """ nself = deepcopy(self) nself.treenode.ladderize(dire...
[ "def", "ladderize", "(", "self", ",", "direction", "=", "0", ")", ":", "nself", "=", "deepcopy", "(", "self", ")", "nself", ".", "treenode", ".", "ladderize", "(", "direction", "=", "direction", ")", "nself", ".", "_fixed_order", "=", "None", "nself", ...
Ladderize tree (order descendants) so that top child has fewer descendants than the bottom child in a left to right tree plot. To reverse this pattern use direction=1.
[ "Ladderize", "tree", "(", "order", "descendants", ")", "so", "that", "top", "child", "has", "fewer", "descendants", "than", "the", "bottom", "child", "in", "a", "left", "to", "right", "tree", "plot", ".", "To", "reverse", "this", "pattern", "use", "directi...
train
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/Toytree.py#L420-L430
eaton-lab/toytree
toytree/Toytree.py
ToyTree.collapse_nodes
def collapse_nodes(self, min_dist=1e-6, min_support=0): """ Returns a copy of the tree where internal nodes with dist <= min_dist are deleted, resulting in a collapsed tree. e.g.: newtre = tre.collapse_nodes(min_dist=0.001) newtre = tre.collapse_nodes(min_support=50) """...
python
def collapse_nodes(self, min_dist=1e-6, min_support=0): """ Returns a copy of the tree where internal nodes with dist <= min_dist are deleted, resulting in a collapsed tree. e.g.: newtre = tre.collapse_nodes(min_dist=0.001) newtre = tre.collapse_nodes(min_support=50) """...
[ "def", "collapse_nodes", "(", "self", ",", "min_dist", "=", "1e-6", ",", "min_support", "=", "0", ")", ":", "nself", "=", "self", ".", "copy", "(", ")", "for", "node", "in", "nself", ".", "treenode", ".", "traverse", "(", ")", ":", "if", "not", "no...
Returns a copy of the tree where internal nodes with dist <= min_dist are deleted, resulting in a collapsed tree. e.g.: newtre = tre.collapse_nodes(min_dist=0.001) newtre = tre.collapse_nodes(min_support=50)
[ "Returns", "a", "copy", "of", "the", "tree", "where", "internal", "nodes", "with", "dist", "<", "=", "min_dist", "are", "deleted", "resulting", "in", "a", "collapsed", "tree", ".", "e", ".", "g", ".", ":" ]
train
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/Toytree.py#L433-L447
eaton-lab/toytree
toytree/Toytree.py
ToyTree.drop_tips
def drop_tips(self, names=None, wildcard=None, regex=None): """ Returns a copy of the tree with the selected tips removed. The entered value can be a name or list of names. To prune on an internal node to create a subtree see the .prune() function instead. Parameters: ti...
python
def drop_tips(self, names=None, wildcard=None, regex=None): """ Returns a copy of the tree with the selected tips removed. The entered value can be a name or list of names. To prune on an internal node to create a subtree see the .prune() function instead. Parameters: ti...
[ "def", "drop_tips", "(", "self", ",", "names", "=", "None", ",", "wildcard", "=", "None", ",", "regex", "=", "None", ")", ":", "# make a deepcopy of the tree", "nself", "=", "self", ".", "copy", "(", ")", "# return if nothing to drop", "if", "not", "any", ...
Returns a copy of the tree with the selected tips removed. The entered value can be a name or list of names. To prune on an internal node to create a subtree see the .prune() function instead. Parameters: tips: list of tip names. # example: ptre = tre.drop_tips(['a', 'b...
[ "Returns", "a", "copy", "of", "the", "tree", "with", "the", "selected", "tips", "removed", ".", "The", "entered", "value", "can", "be", "a", "name", "or", "list", "of", "names", ".", "To", "prune", "on", "an", "internal", "node", "to", "create", "a", ...
train
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/Toytree.py#L451-L489
eaton-lab/toytree
toytree/Toytree.py
ToyTree.rotate_node
def rotate_node( self, names=None, wildcard=None, regex=None, idx=None, # modify_tree=False, ): """ Returns a ToyTree with the selected node rotated for plotting. tip colors do not align correct currently if nodes are rotated... ...
python
def rotate_node( self, names=None, wildcard=None, regex=None, idx=None, # modify_tree=False, ): """ Returns a ToyTree with the selected node rotated for plotting. tip colors do not align correct currently if nodes are rotated... ...
[ "def", "rotate_node", "(", "self", ",", "names", "=", "None", ",", "wildcard", "=", "None", ",", "regex", "=", "None", ",", "idx", "=", "None", ",", "# modify_tree=False,", ")", ":", "# make a copy", "revd", "=", "{", "j", ":", "i", "for", "(", "i", ...
Returns a ToyTree with the selected node rotated for plotting. tip colors do not align correct currently if nodes are rotated...
[ "Returns", "a", "ToyTree", "with", "the", "selected", "node", "rotated", "for", "plotting", ".", "tip", "colors", "do", "not", "align", "correct", "currently", "if", "nodes", "are", "rotated", "..." ]
train
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/Toytree.py#L493-L542
eaton-lab/toytree
toytree/Toytree.py
ToyTree.resolve_polytomy
def resolve_polytomy( self, dist=1.0, support=100, recursive=True): """ Returns a copy of the tree with all polytomies randomly resolved. Does not transform tree in-place. """ nself = self.copy() nself.treenode.resolve_polytomy( ...
python
def resolve_polytomy( self, dist=1.0, support=100, recursive=True): """ Returns a copy of the tree with all polytomies randomly resolved. Does not transform tree in-place. """ nself = self.copy() nself.treenode.resolve_polytomy( ...
[ "def", "resolve_polytomy", "(", "self", ",", "dist", "=", "1.0", ",", "support", "=", "100", ",", "recursive", "=", "True", ")", ":", "nself", "=", "self", ".", "copy", "(", ")", "nself", ".", "treenode", ".", "resolve_polytomy", "(", "default_dist", "...
Returns a copy of the tree with all polytomies randomly resolved. Does not transform tree in-place.
[ "Returns", "a", "copy", "of", "the", "tree", "with", "all", "polytomies", "randomly", "resolved", ".", "Does", "not", "transform", "tree", "in", "-", "place", "." ]
train
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/Toytree.py#L545-L560
eaton-lab/toytree
toytree/Toytree.py
ToyTree.unroot
def unroot(self): """ Returns a copy of the tree unrooted. Does not transform tree in-place. """ nself = self.copy() nself.treenode.unroot() nself.treenode.ladderize() nself._coords.update() return nself
python
def unroot(self): """ Returns a copy of the tree unrooted. Does not transform tree in-place. """ nself = self.copy() nself.treenode.unroot() nself.treenode.ladderize() nself._coords.update() return nself
[ "def", "unroot", "(", "self", ")", ":", "nself", "=", "self", ".", "copy", "(", ")", "nself", ".", "treenode", ".", "unroot", "(", ")", "nself", ".", "treenode", ".", "ladderize", "(", ")", "nself", ".", "_coords", ".", "update", "(", ")", "return"...
Returns a copy of the tree unrooted. Does not transform tree in-place.
[ "Returns", "a", "copy", "of", "the", "tree", "unrooted", ".", "Does", "not", "transform", "tree", "in", "-", "place", "." ]
train
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/Toytree.py#L563-L571
eaton-lab/toytree
toytree/Toytree.py
ToyTree.root
def root(self, names=None, wildcard=None, regex=None): """ (Re-)root a tree by creating selecting a existing split in the tree, or creating a new node to split an edge in the tree. Rooting location is selected by entering the tips descendant from one child of the root split (e.g....
python
def root(self, names=None, wildcard=None, regex=None): """ (Re-)root a tree by creating selecting a existing split in the tree, or creating a new node to split an edge in the tree. Rooting location is selected by entering the tips descendant from one child of the root split (e.g....
[ "def", "root", "(", "self", ",", "names", "=", "None", ",", "wildcard", "=", "None", ",", "regex", "=", "None", ")", ":", "# make a deepcopy of the tree", "nself", "=", "self", ".", "copy", "(", ")", "# get treenode of the common ancestor of selected tips", "try...
(Re-)root a tree by creating selecting a existing split in the tree, or creating a new node to split an edge in the tree. Rooting location is selected by entering the tips descendant from one child of the root split (e.g., names='a' or names=['a', 'b']). You can alternatively select a li...
[ "(", "Re", "-", ")", "root", "a", "tree", "by", "creating", "selecting", "a", "existing", "split", "in", "the", "tree", "or", "creating", "a", "new", "node", "to", "split", "an", "edge", "in", "the", "tree", ".", "Rooting", "location", "is", "selected"...
train
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/Toytree.py#L574-L659
eaton-lab/toytree
toytree/Toytree.py
ToyTree.draw
def draw( self, tree_style=None, height=None, width=None, axes=None, orient=None, tip_labels=None, tip_labels_colors=None, tip_labels_style=None, tip_labels_align=None, node_labels=None, node_labels_style=None, ...
python
def draw( self, tree_style=None, height=None, width=None, axes=None, orient=None, tip_labels=None, tip_labels_colors=None, tip_labels_style=None, tip_labels_align=None, node_labels=None, node_labels_style=None, ...
[ "def", "draw", "(", "self", ",", "tree_style", "=", "None", ",", "height", "=", "None", ",", "width", "=", "None", ",", "axes", "=", "None", ",", "orient", "=", "None", ",", "tip_labels", "=", "None", ",", "tip_labels_colors", "=", "None", ",", "tip_...
Plot a Toytree tree, returns a tuple of Toyplot (Canvas, Axes) objects. Parameters: ----------- tree_style: str One of several preset styles for tree plotting. The default is 'n' (normal). Other options inlude 'c' (coalescent), 'd' (dark), and 'm' (multitree)...
[ "Plot", "a", "Toytree", "tree", "returns", "a", "tuple", "of", "Toyplot", "(", "Canvas", "Axes", ")", "objects", "." ]
train
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/Toytree.py#L664-L823
doakey3/DashTable
dashtable/data2rst/cell/get_merge_direction.py
get_merge_direction
def get_merge_direction(cell1, cell2): """ Determine the side of cell1 that can be merged with cell2. This is based on the location of the two cells in the table as well as the compatability of their height and width. For example these cells can merge:: cell1 cell2 merge "RIGHT" ...
python
def get_merge_direction(cell1, cell2): """ Determine the side of cell1 that can be merged with cell2. This is based on the location of the two cells in the table as well as the compatability of their height and width. For example these cells can merge:: cell1 cell2 merge "RIGHT" ...
[ "def", "get_merge_direction", "(", "cell1", ",", "cell2", ")", ":", "cell1_left", "=", "cell1", ".", "column", "cell1_right", "=", "cell1", ".", "column", "+", "cell1", ".", "column_count", "cell1_top", "=", "cell1", ".", "row", "cell1_bottom", "=", "cell1",...
Determine the side of cell1 that can be merged with cell2. This is based on the location of the two cells in the table as well as the compatability of their height and width. For example these cells can merge:: cell1 cell2 merge "RIGHT" +-----+ +------+ +-----+------+ ...
[ "Determine", "the", "side", "of", "cell1", "that", "can", "be", "merged", "with", "cell2", "." ]
train
https://github.com/doakey3/DashTable/blob/744cfb6a717fa75a8092c83ebcd49b2668023681/dashtable/data2rst/cell/get_merge_direction.py#L1-L74
eaton-lab/toytree
toytree/TreeParser.py
parse_nhx
def parse_nhx(NHX_string): """ NHX format: [&&NHX:prop1=value1:prop2=value2] MB format: ((a[&Z=1,Y=2], b[&Z=1,Y=2]):1.0[&L=1,W=0], ... """ # store features ndict = {} # parse NHX or MB features if "[&&NHX:" in NHX_string: NHX_string = NHX_string.replace("[&&NHX:", "") ...
python
def parse_nhx(NHX_string): """ NHX format: [&&NHX:prop1=value1:prop2=value2] MB format: ((a[&Z=1,Y=2], b[&Z=1,Y=2]):1.0[&L=1,W=0], ... """ # store features ndict = {} # parse NHX or MB features if "[&&NHX:" in NHX_string: NHX_string = NHX_string.replace("[&&NHX:", "") ...
[ "def", "parse_nhx", "(", "NHX_string", ")", ":", "# store features", "ndict", "=", "{", "}", "# parse NHX or MB features", "if", "\"[&&NHX:\"", "in", "NHX_string", ":", "NHX_string", "=", "NHX_string", ".", "replace", "(", "\"[&&NHX:\"", ",", "\"\"", ")", "NHX_s...
NHX format: [&&NHX:prop1=value1:prop2=value2] MB format: ((a[&Z=1,Y=2], b[&Z=1,Y=2]):1.0[&L=1,W=0], ...
[ "NHX", "format", ":", "[", "&&NHX", ":", "prop1", "=", "value1", ":", "prop2", "=", "value2", "]", "MB", "format", ":", "((", "a", "[", "&Z", "=", "1", "Y", "=", "2", "]", "b", "[", "&Z", "=", "1", "Y", "=", "2", "]", ")", ":", "1", ".", ...
train
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/TreeParser.py#L586-L605
eaton-lab/toytree
toytree/TreeParser.py
TreeParser.get_data_from_intree
def get_data_from_intree(self): """ Load *data* from a file or string and return as a list of strings. The data contents could be one newick string; a multiline NEXUS format for one tree; multiple newick strings on multiple lines; or multiple newick strings in a multiline NEXUS f...
python
def get_data_from_intree(self): """ Load *data* from a file or string and return as a list of strings. The data contents could be one newick string; a multiline NEXUS format for one tree; multiple newick strings on multiple lines; or multiple newick strings in a multiline NEXUS f...
[ "def", "get_data_from_intree", "(", "self", ")", ":", "# load string: filename or data stream", "if", "isinstance", "(", "self", ".", "intree", ",", "(", "str", ",", "bytes", ")", ")", ":", "# strip it", "self", ".", "intree", "=", "self", ".", "intree", "."...
Load *data* from a file or string and return as a list of strings. The data contents could be one newick string; a multiline NEXUS format for one tree; multiple newick strings on multiple lines; or multiple newick strings in a multiline NEXUS format. In any case, we will read in the data...
[ "Load", "*", "data", "*", "from", "a", "file", "or", "string", "and", "return", "as", "a", "list", "of", "strings", ".", "The", "data", "contents", "could", "be", "one", "newick", "string", ";", "a", "multiline", "NEXUS", "format", "for", "one", "tree"...
train
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/TreeParser.py#L196-L228
eaton-lab/toytree
toytree/TreeParser.py
TreeParser.parse_nexus
def parse_nexus(self): "get newick data from NEXUS" if self.data[0].strip().upper() == "#NEXUS": nex = NexusParser(self.data) self.data = nex.newicks self.tdict = nex.tdict
python
def parse_nexus(self): "get newick data from NEXUS" if self.data[0].strip().upper() == "#NEXUS": nex = NexusParser(self.data) self.data = nex.newicks self.tdict = nex.tdict
[ "def", "parse_nexus", "(", "self", ")", ":", "if", "self", ".", "data", "[", "0", "]", ".", "strip", "(", ")", ".", "upper", "(", ")", "==", "\"#NEXUS\"", ":", "nex", "=", "NexusParser", "(", "self", ".", "data", ")", "self", ".", "data", "=", ...
get newick data from NEXUS
[ "get", "newick", "data", "from", "NEXUS" ]
train
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/TreeParser.py#L231-L236
eaton-lab/toytree
toytree/TreeParser.py
TreeParser.get_treenodes
def get_treenodes(self): "test format of intree nex/nwk, extra features" if not self.multitree: # get TreeNodes from Newick extractor = Newick2TreeNode(self.data[0].strip(), fmt=self.fmt) # extract one tree self.treenodes.append(extractor.newick_...
python
def get_treenodes(self): "test format of intree nex/nwk, extra features" if not self.multitree: # get TreeNodes from Newick extractor = Newick2TreeNode(self.data[0].strip(), fmt=self.fmt) # extract one tree self.treenodes.append(extractor.newick_...
[ "def", "get_treenodes", "(", "self", ")", ":", "if", "not", "self", ".", "multitree", ":", "# get TreeNodes from Newick", "extractor", "=", "Newick2TreeNode", "(", "self", ".", "data", "[", "0", "]", ".", "strip", "(", ")", ",", "fmt", "=", "self", ".", ...
test format of intree nex/nwk, extra features
[ "test", "format", "of", "intree", "nex", "/", "nwk", "extra", "features" ]
train
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/TreeParser.py#L239-L255
eaton-lab/toytree
toytree/TreeParser.py
Newick2TreeNode.newick_from_string
def newick_from_string(self): "Reads a newick string in the New Hampshire format." # split on parentheses to traverse hierarchical tree structure for chunk in self.data.split("(")[1:]: # add child to make this node a parent. self.current_parent = ( self.r...
python
def newick_from_string(self): "Reads a newick string in the New Hampshire format." # split on parentheses to traverse hierarchical tree structure for chunk in self.data.split("(")[1:]: # add child to make this node a parent. self.current_parent = ( self.r...
[ "def", "newick_from_string", "(", "self", ")", ":", "# split on parentheses to traverse hierarchical tree structure", "for", "chunk", "in", "self", ".", "data", ".", "split", "(", "\"(\"", ")", "[", "1", ":", "]", ":", "# add child to make this node a parent.", "self"...
Reads a newick string in the New Hampshire format.
[ "Reads", "a", "newick", "string", "in", "the", "New", "Hampshire", "format", "." ]
train
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/TreeParser.py#L319-L352
eaton-lab/toytree
toytree/TreeParser.py
NexusParser.extract_tree_block
def extract_tree_block(self): "iterate through data file to extract trees" lines = iter(self.data) while 1: try: line = next(lines).strip() except StopIteration: break # enter trees block if line.lower(...
python
def extract_tree_block(self): "iterate through data file to extract trees" lines = iter(self.data) while 1: try: line = next(lines).strip() except StopIteration: break # enter trees block if line.lower(...
[ "def", "extract_tree_block", "(", "self", ")", ":", "lines", "=", "iter", "(", "self", ".", "data", ")", "while", "1", ":", "try", ":", "line", "=", "next", "(", "lines", ")", ".", "strip", "(", ")", "except", "StopIteration", ":", "break", "# enter ...
iterate through data file to extract trees
[ "iterate", "through", "data", "file", "to", "extract", "trees" ]
train
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/TreeParser.py#L422-L454
eaton-lab/toytree
versioner.py
parse_command_line
def parse_command_line(): """ Parse CLI args.""" ## create the parser parser = argparse.ArgumentParser( formatter_class=argparse.RawDescriptionHelpFormatter, epilog=""" * Example command-line usage: ## push test branch to conda --label=conda-test for travis CI ./versioner.py -p toyt...
python
def parse_command_line(): """ Parse CLI args.""" ## create the parser parser = argparse.ArgumentParser( formatter_class=argparse.RawDescriptionHelpFormatter, epilog=""" * Example command-line usage: ## push test branch to conda --label=conda-test for travis CI ./versioner.py -p toyt...
[ "def", "parse_command_line", "(", ")", ":", "## create the parser", "parser", "=", "argparse", ".", "ArgumentParser", "(", "formatter_class", "=", "argparse", ".", "RawDescriptionHelpFormatter", ",", "epilog", "=", "\"\"\"\n * Example command-line usage: \n\n ## push test b...
Parse CLI args.
[ "Parse", "CLI", "args", "." ]
train
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/versioner.py#L293-L354
eaton-lab/toytree
versioner.py
Version.get_git_status
def get_git_status(self): """ Gets git and init versions and commits since the init version """ ## get git branch self._get_git_branch() ## get tag in the init file self._get_init_release_tag() ## get log commits since <tag> try: self...
python
def get_git_status(self): """ Gets git and init versions and commits since the init version """ ## get git branch self._get_git_branch() ## get tag in the init file self._get_init_release_tag() ## get log commits since <tag> try: self...
[ "def", "get_git_status", "(", "self", ")", ":", "## get git branch", "self", ".", "_get_git_branch", "(", ")", "## get tag in the init file", "self", ".", "_get_init_release_tag", "(", ")", "## get log commits since <tag>", "try", ":", "self", ".", "_get_log_commits", ...
Gets git and init versions and commits since the init version
[ "Gets", "git", "and", "init", "versions", "and", "commits", "since", "the", "init", "version" ]
train
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/versioner.py#L39-L67
eaton-lab/toytree
versioner.py
Version.push_git_package
def push_git_package(self): """ if no conflicts then write new tag to """ ## check for conflicts, then write to local files self._pull_branch_from_origin() ## log commits to releasenotes if self.deploy: self._write_commits_to_release_notes() ...
python
def push_git_package(self): """ if no conflicts then write new tag to """ ## check for conflicts, then write to local files self._pull_branch_from_origin() ## log commits to releasenotes if self.deploy: self._write_commits_to_release_notes() ...
[ "def", "push_git_package", "(", "self", ")", ":", "## check for conflicts, then write to local files", "self", ".", "_pull_branch_from_origin", "(", ")", "## log commits to releasenotes", "if", "self", ".", "deploy", ":", "self", ".", "_write_commits_to_release_notes", "(",...
if no conflicts then write new tag to
[ "if", "no", "conflicts", "then", "write", "new", "tag", "to" ]
train
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/versioner.py#L72-L92
eaton-lab/toytree
versioner.py
Version._pull_branch_from_origin
def _pull_branch_from_origin(self): """ Pulls from origin/master, if you have unmerged conflicts it will raise an exception. You will need to resolve these. """ try: ## self.repo.git.pull() subprocess.check_call(["git", "pull", "origin", self.branch]) ...
python
def _pull_branch_from_origin(self): """ Pulls from origin/master, if you have unmerged conflicts it will raise an exception. You will need to resolve these. """ try: ## self.repo.git.pull() subprocess.check_call(["git", "pull", "origin", self.branch]) ...
[ "def", "_pull_branch_from_origin", "(", "self", ")", ":", "try", ":", "## self.repo.git.pull()", "subprocess", ".", "check_call", "(", "[", "\"git\"", ",", "\"pull\"", ",", "\"origin\"", ",", "self", ".", "branch", "]", ")", "except", "Exception", "as", "inst"...
Pulls from origin/master, if you have unmerged conflicts it will raise an exception. You will need to resolve these.
[ "Pulls", "from", "origin", "/", "master", "if", "you", "have", "unmerged", "conflicts", "it", "will", "raise", "an", "exception", ".", "You", "will", "need", "to", "resolve", "these", "." ]
train
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/versioner.py#L105-L117
eaton-lab/toytree
versioner.py
Version._get_init_release_tag
def _get_init_release_tag(self): """ parses init.py to get previous version """ self.init_version = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", open(self.init_file, "r").read(), re.M).group(1)
python
def _get_init_release_tag(self): """ parses init.py to get previous version """ self.init_version = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]", open(self.init_file, "r").read(), re.M).group(1)
[ "def", "_get_init_release_tag", "(", "self", ")", ":", "self", ".", "init_version", "=", "re", ".", "search", "(", "r\"^__version__ = ['\\\"]([^'\\\"]*)['\\\"]\"", ",", "open", "(", "self", ".", "init_file", ",", "\"r\"", ")", ".", "read", "(", ")", ",", "re...
parses init.py to get previous version
[ "parses", "init", ".", "py", "to", "get", "previous", "version" ]
train
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/versioner.py#L121-L127
eaton-lab/toytree
versioner.py
Version._get_log_commits
def _get_log_commits(self): """ calls git log to complile a change list """ ## check if update is necessary cmd = "git log --pretty=oneline {}..".format(self.init_version) cmdlist = shlex.split(cmd) commits = subprocess.check_output(cmdlist) ## Sp...
python
def _get_log_commits(self): """ calls git log to complile a change list """ ## check if update is necessary cmd = "git log --pretty=oneline {}..".format(self.init_version) cmdlist = shlex.split(cmd) commits = subprocess.check_output(cmdlist) ## Sp...
[ "def", "_get_log_commits", "(", "self", ")", ":", "## check if update is necessary", "cmd", "=", "\"git log --pretty=oneline {}..\"", ".", "format", "(", "self", ".", "init_version", ")", "cmdlist", "=", "shlex", ".", "split", "(", "cmd", ")", "commits", "=", "s...
calls git log to complile a change list
[ "calls", "git", "log", "to", "complile", "a", "change", "list" ]
train
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/versioner.py#L131-L141
eaton-lab/toytree
versioner.py
Version._write_commits_to_release_notes
def _write_commits_to_release_notes(self): """ writes commits to the releasenotes file by appending to the end """ with open(self.release_file, 'a') as out: out.write("==========\n{}\n".format(self.tag)) for commit in self.commits: try: ...
python
def _write_commits_to_release_notes(self): """ writes commits to the releasenotes file by appending to the end """ with open(self.release_file, 'a') as out: out.write("==========\n{}\n".format(self.tag)) for commit in self.commits: try: ...
[ "def", "_write_commits_to_release_notes", "(", "self", ")", ":", "with", "open", "(", "self", ".", "release_file", ",", "'a'", ")", "as", "out", ":", "out", ".", "write", "(", "\"==========\\n{}\\n\"", ".", "format", "(", "self", ".", "tag", ")", ")", "f...
writes commits to the releasenotes file by appending to the end
[ "writes", "commits", "to", "the", "releasenotes", "file", "by", "appending", "to", "the", "end" ]
train
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/versioner.py#L145-L157
eaton-lab/toytree
versioner.py
Version._write_new_tag_to_init
def _write_new_tag_to_init(self): """ Write version to __init__.py by editing in place """ for line in fileinput.input(self.init_file, inplace=1): if line.strip().startswith("__version__"): line = "__version__ = \"" + self.tag + "\"" print(line.str...
python
def _write_new_tag_to_init(self): """ Write version to __init__.py by editing in place """ for line in fileinput.input(self.init_file, inplace=1): if line.strip().startswith("__version__"): line = "__version__ = \"" + self.tag + "\"" print(line.str...
[ "def", "_write_new_tag_to_init", "(", "self", ")", ":", "for", "line", "in", "fileinput", ".", "input", "(", "self", ".", "init_file", ",", "inplace", "=", "1", ")", ":", "if", "line", ".", "strip", "(", ")", ".", "startswith", "(", "\"__version__\"", ...
Write version to __init__.py by editing in place
[ "Write", "version", "to", "__init__", ".", "py", "by", "editing", "in", "place" ]
train
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/versioner.py#L161-L168
eaton-lab/toytree
versioner.py
Version._write_branch_and_tag_to_meta_yaml
def _write_branch_and_tag_to_meta_yaml(self): """ Write branch and tag to meta.yaml by editing in place """ ## set the branch to pull source from with open(self.meta_yaml.replace("meta", "template"), 'r') as infile: dat = infile.read() newdat = dat.format(...
python
def _write_branch_and_tag_to_meta_yaml(self): """ Write branch and tag to meta.yaml by editing in place """ ## set the branch to pull source from with open(self.meta_yaml.replace("meta", "template"), 'r') as infile: dat = infile.read() newdat = dat.format(...
[ "def", "_write_branch_and_tag_to_meta_yaml", "(", "self", ")", ":", "## set the branch to pull source from", "with", "open", "(", "self", ".", "meta_yaml", ".", "replace", "(", "\"meta\"", ",", "\"template\"", ")", ",", "'r'", ")", "as", "infile", ":", "dat", "=...
Write branch and tag to meta.yaml by editing in place
[ "Write", "branch", "and", "tag", "to", "meta", ".", "yaml", "by", "editing", "in", "place" ]
train
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/versioner.py#L172-L182
eaton-lab/toytree
versioner.py
Version._revert_tag_in_init
def _revert_tag_in_init(self): """ Write version to __init__.py by editing in place """ for line in fileinput.input(self.init_file, inplace=1): if line.strip().startswith("__version__"): line = "__version__ = \"" + self.init_version + "\"" print(li...
python
def _revert_tag_in_init(self): """ Write version to __init__.py by editing in place """ for line in fileinput.input(self.init_file, inplace=1): if line.strip().startswith("__version__"): line = "__version__ = \"" + self.init_version + "\"" print(li...
[ "def", "_revert_tag_in_init", "(", "self", ")", ":", "for", "line", "in", "fileinput", ".", "input", "(", "self", ".", "init_file", ",", "inplace", "=", "1", ")", ":", "if", "line", ".", "strip", "(", ")", ".", "startswith", "(", "\"__version__\"", ")"...
Write version to __init__.py by editing in place
[ "Write", "version", "to", "__init__", ".", "py", "by", "editing", "in", "place" ]
train
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/versioner.py#L199-L209
eaton-lab/toytree
versioner.py
Version._push_new_tag_to_git
def _push_new_tag_to_git(self): """ tags a new release and pushes to origin/master """ print("Pushing new version to git") ## stage the releasefile and initfileb subprocess.call(["git", "add", self.release_file]) subprocess.call(["git", "add", self.in...
python
def _push_new_tag_to_git(self): """ tags a new release and pushes to origin/master """ print("Pushing new version to git") ## stage the releasefile and initfileb subprocess.call(["git", "add", self.release_file]) subprocess.call(["git", "add", self.in...
[ "def", "_push_new_tag_to_git", "(", "self", ")", ":", "print", "(", "\"Pushing new version to git\"", ")", "## stage the releasefile and initfileb", "subprocess", ".", "call", "(", "[", "\"git\"", ",", "\"add\"", ",", "self", ".", "release_file", "]", ")", "subproce...
tags a new release and pushes to origin/master
[ "tags", "a", "new", "release", "and", "pushes", "to", "origin", "/", "master" ]
train
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/versioner.py#L216-L238
eaton-lab/toytree
versioner.py
Version.build_conda_packages
def build_conda_packages(self): """ Run the Linux build and use converter to build OSX """ ## check if update is necessary #if self.nversion == self.pversion: # raise SystemExit("Exited: new version == existing version") ## tmp dir bldir = "./tmp-bld" ...
python
def build_conda_packages(self): """ Run the Linux build and use converter to build OSX """ ## check if update is necessary #if self.nversion == self.pversion: # raise SystemExit("Exited: new version == existing version") ## tmp dir bldir = "./tmp-bld" ...
[ "def", "build_conda_packages", "(", "self", ")", ":", "## check if update is necessary", "#if self.nversion == self.pversion:", "# raise SystemExit(\"Exited: new version == existing version\")", "## tmp dir", "bldir", "=", "\"./tmp-bld\"", "if", "not", "os", ".", "path", ".", ...
Run the Linux build and use converter to build OSX
[ "Run", "the", "Linux", "build", "and", "use", "converter", "to", "build", "OSX" ]
train
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/versioner.py#L247-L285
doakey3/DashTable
dashtable/dashutils/get_span_row_count.py
get_span_row_count
def get_span_row_count(span): """ Gets the number of rows included in a span Parameters ---------- span : list of lists of int The [row, column] pairs that make up the span Returns ------- rows : int The number of rows included in the span Example ------- C...
python
def get_span_row_count(span): """ Gets the number of rows included in a span Parameters ---------- span : list of lists of int The [row, column] pairs that make up the span Returns ------- rows : int The number of rows included in the span Example ------- C...
[ "def", "get_span_row_count", "(", "span", ")", ":", "rows", "=", "1", "first_row", "=", "span", "[", "0", "]", "[", "0", "]", "for", "i", "in", "range", "(", "len", "(", "span", ")", ")", ":", "if", "span", "[", "i", "]", "[", "0", "]", ">", ...
Gets the number of rows included in a span Parameters ---------- span : list of lists of int The [row, column] pairs that make up the span Returns ------- rows : int The number of rows included in the span Example ------- Consider this table:: +--------+--...
[ "Gets", "the", "number", "of", "rows", "included", "in", "a", "span" ]
train
https://github.com/doakey3/DashTable/blob/744cfb6a717fa75a8092c83ebcd49b2668023681/dashtable/dashutils/get_span_row_count.py#L1-L41
quantmind/dynts
dynts/utils/section.py
asarray
def asarray(x, dtype=None): '''Convert ``x`` into a ``numpy.ndarray``.''' iterable = scalarasiter(x) if isinstance(iterable, ndarray): return iterable else: if not hasattr(iterable, '__len__'): iterable = list(iterable) if dtype == object_type: a ...
python
def asarray(x, dtype=None): '''Convert ``x`` into a ``numpy.ndarray``.''' iterable = scalarasiter(x) if isinstance(iterable, ndarray): return iterable else: if not hasattr(iterable, '__len__'): iterable = list(iterable) if dtype == object_type: a ...
[ "def", "asarray", "(", "x", ",", "dtype", "=", "None", ")", ":", "iterable", "=", "scalarasiter", "(", "x", ")", "if", "isinstance", "(", "iterable", ",", "ndarray", ")", ":", "return", "iterable", "else", ":", "if", "not", "hasattr", "(", "iterable", ...
Convert ``x`` into a ``numpy.ndarray``.
[ "Convert", "x", "into", "a", "numpy", ".", "ndarray", "." ]
train
https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/utils/section.py#L21-L35
quantmind/dynts
dynts/utils/section.py
ascolumn
def ascolumn(x, dtype = None): '''Convert ``x`` into a ``column``-type ``numpy.ndarray``.''' x = asarray(x, dtype) return x if len(x.shape) >= 2 else x.reshape(len(x),1)
python
def ascolumn(x, dtype = None): '''Convert ``x`` into a ``column``-type ``numpy.ndarray``.''' x = asarray(x, dtype) return x if len(x.shape) >= 2 else x.reshape(len(x),1)
[ "def", "ascolumn", "(", "x", ",", "dtype", "=", "None", ")", ":", "x", "=", "asarray", "(", "x", ",", "dtype", ")", "return", "x", "if", "len", "(", "x", ".", "shape", ")", ">=", "2", "else", "x", ".", "reshape", "(", "len", "(", "x", ")", ...
Convert ``x`` into a ``column``-type ``numpy.ndarray``.
[ "Convert", "x", "into", "a", "column", "-", "type", "numpy", ".", "ndarray", "." ]
train
https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/utils/section.py#L38-L41