body_hash
stringlengths
64
64
body
stringlengths
23
109k
docstring
stringlengths
1
57k
path
stringlengths
4
198
name
stringlengths
1
115
repository_name
stringlengths
7
111
repository_stars
float64
0
191k
lang
stringclasses
1 value
body_without_docstring
stringlengths
14
108k
unified
stringlengths
45
133k
64cea9c44b3dd6ea3ec3382664af2deb469b79d6290c551f8e1caebde5d4e441
def view_resource(self, resourceid: int) -> View: 'Simulate the view.php web interface resource: trigger events, completion, etc...\n\n Args:\n resourceid (int): resource instance id\n\n Returns:\n View: View Resource response\n ' res = self.moodle.post('mod_resource_view_resource', resourceid=resourceid) return self._tr(View, **res)
Simulate the view.php web interface resource: trigger events, completion, etc... Args: resourceid (int): resource instance id Returns: View: View Resource response
moodle/mod/resource/base.py
view_resource
Hardikris/moodlepy
0
python
def view_resource(self, resourceid: int) -> View: 'Simulate the view.php web interface resource: trigger events, completion, etc...\n\n Args:\n resourceid (int): resource instance id\n\n Returns:\n View: View Resource response\n ' res = self.moodle.post('mod_resource_view_resource', resourceid=resourceid) return self._tr(View, **res)
def view_resource(self, resourceid: int) -> View: 'Simulate the view.php web interface resource: trigger events, completion, etc...\n\n Args:\n resourceid (int): resource instance id\n\n Returns:\n View: View Resource response\n ' res = self.moodle.post('mod_resource_view_resource', resourceid=resourceid) return self._tr(View, **res)<|docstring|>Simulate the view.php web interface resource: trigger events, completion, etc... Args: resourceid (int): resource instance id Returns: View: View Resource response<|endoftext|>
4c8c357898f42b2c0b3a89b82f62cc8a512520d4b01096e5e9d94141627e515b
def login(self): '\n Return the login view.\n ' return LoginView.as_view(template_name='zinnia/login.html')(self.request)
Return the login view.
zinnia/views/mixins/entry_protection.py
login
vvojvoda/django-blog-zinnia
1,522
python
def login(self): '\n \n ' return LoginView.as_view(template_name='zinnia/login.html')(self.request)
def login(self): '\n \n ' return LoginView.as_view(template_name='zinnia/login.html')(self.request)<|docstring|>Return the login view.<|endoftext|>
d98e7550e3b61790ab7b8571c0cc69fd2309fc952dac0a2e9275d3c133b08e82
def password(self): '\n Return the password view.\n ' return self.response_class(request=self.request, template='zinnia/password.html', context={'error': self.error})
Return the password view.
zinnia/views/mixins/entry_protection.py
password
vvojvoda/django-blog-zinnia
1,522
python
def password(self): '\n \n ' return self.response_class(request=self.request, template='zinnia/password.html', context={'error': self.error})
def password(self): '\n \n ' return self.response_class(request=self.request, template='zinnia/password.html', context={'error': self.error})<|docstring|>Return the password view.<|endoftext|>
e689faeaade19dad61ff06729342102d3e57e4e68cb11953a6be0ac765116b88
def get(self, request, *args, **kwargs): '\n Do the login and password protection.\n ' response = super(EntryProtectionMixin, self).get(request, *args, **kwargs) if (self.object.login_required and (not request.user.is_authenticated)): return self.login() if (self.object.password and (self.object.password != self.request.session.get((self.session_key % self.object.pk)))): return self.password() return response
Do the login and password protection.
zinnia/views/mixins/entry_protection.py
get
vvojvoda/django-blog-zinnia
1,522
python
def get(self, request, *args, **kwargs): '\n \n ' response = super(EntryProtectionMixin, self).get(request, *args, **kwargs) if (self.object.login_required and (not request.user.is_authenticated)): return self.login() if (self.object.password and (self.object.password != self.request.session.get((self.session_key % self.object.pk)))): return self.password() return response
def get(self, request, *args, **kwargs): '\n \n ' response = super(EntryProtectionMixin, self).get(request, *args, **kwargs) if (self.object.login_required and (not request.user.is_authenticated)): return self.login() if (self.object.password and (self.object.password != self.request.session.get((self.session_key % self.object.pk)))): return self.password() return response<|docstring|>Do the login and password protection.<|endoftext|>
304797a196e3aa3328643de5c75a199ea02f682a009ff7e84695e7678daef13c
def post(self, request, *args, **kwargs): '\n Do the login and password protection.\n ' self.object = self.get_object() self.login() if self.object.password: entry_password = self.request.POST.get('entry_password') if entry_password: if (entry_password == self.object.password): self.request.session[(self.session_key % self.object.pk)] = self.object.password return self.get(request, *args, **kwargs) else: self.error = True return self.password() return self.get(request, *args, **kwargs)
Do the login and password protection.
zinnia/views/mixins/entry_protection.py
post
vvojvoda/django-blog-zinnia
1,522
python
def post(self, request, *args, **kwargs): '\n \n ' self.object = self.get_object() self.login() if self.object.password: entry_password = self.request.POST.get('entry_password') if entry_password: if (entry_password == self.object.password): self.request.session[(self.session_key % self.object.pk)] = self.object.password return self.get(request, *args, **kwargs) else: self.error = True return self.password() return self.get(request, *args, **kwargs)
def post(self, request, *args, **kwargs): '\n \n ' self.object = self.get_object() self.login() if self.object.password: entry_password = self.request.POST.get('entry_password') if entry_password: if (entry_password == self.object.password): self.request.session[(self.session_key % self.object.pk)] = self.object.password return self.get(request, *args, **kwargs) else: self.error = True return self.password() return self.get(request, *args, **kwargs)<|docstring|>Do the login and password protection.<|endoftext|>
4fc7806b8253e05fad081c74f28bac1a5da504ac2ded559925de8555f7a1caa4
def analyze(conn, query): "\n Analyze query using given connection and return :class:`QueryAnalysis`\n object. Analysis is performed using database specific EXPLAIN ANALYZE\n construct and then examining the results into structured format. Currently\n only PostgreSQL is supported.\n\n\n Getting query runtime (in database level) ::\n\n\n from sqlalchemy_utils import analyze\n\n\n analysis = analyze(conn, 'SELECT * FROM article')\n analysis.runtime # runtime as milliseconds\n\n\n Analyze can be very useful when testing that query doesn't issue a\n sequential scan (scanning all rows in table). You can for example write\n simple performance tests this way.::\n\n\n query = (\n session.query(Article.name)\n .order_by(Article.name)\n .limit(10)\n )\n analysis = analyze(self.connection, query)\n analysis.node_types # [u'Limit', u'Index Only Scan']\n\n assert 'Seq Scan' not in analysis.node_types\n\n\n .. versionadded: 0.26.17\n\n :param conn: SQLAlchemy Connection object\n :param query: SQLAlchemy Query object or query as a string\n " return QueryAnalysis(conn.execute(explain_analyze(query, buffers=True, format='json')).scalar())
Analyze query using given connection and return :class:`QueryAnalysis` object. Analysis is performed using database specific EXPLAIN ANALYZE construct and then examining the results into structured format. Currently only PostgreSQL is supported. Getting query runtime (in database level) :: from sqlalchemy_utils import analyze analysis = analyze(conn, 'SELECT * FROM article') analysis.runtime # runtime as milliseconds Analyze can be very useful when testing that query doesn't issue a sequential scan (scanning all rows in table). You can for example write simple performance tests this way.:: query = ( session.query(Article.name) .order_by(Article.name) .limit(10) ) analysis = analyze(self.connection, query) analysis.node_types # [u'Limit', u'Index Only Scan'] assert 'Seq Scan' not in analysis.node_types .. versionadded: 0.26.17 :param conn: SQLAlchemy Connection object :param query: SQLAlchemy Query object or query as a string
sqlalchemy_utils/functions/database.py
analyze
lnielsen/sqlalchemy-utils
1
python
def analyze(conn, query): "\n Analyze query using given connection and return :class:`QueryAnalysis`\n object. Analysis is performed using database specific EXPLAIN ANALYZE\n construct and then examining the results into structured format. Currently\n only PostgreSQL is supported.\n\n\n Getting query runtime (in database level) ::\n\n\n from sqlalchemy_utils import analyze\n\n\n analysis = analyze(conn, 'SELECT * FROM article')\n analysis.runtime # runtime as milliseconds\n\n\n Analyze can be very useful when testing that query doesn't issue a\n sequential scan (scanning all rows in table). You can for example write\n simple performance tests this way.::\n\n\n query = (\n session.query(Article.name)\n .order_by(Article.name)\n .limit(10)\n )\n analysis = analyze(self.connection, query)\n analysis.node_types # [u'Limit', u'Index Only Scan']\n\n assert 'Seq Scan' not in analysis.node_types\n\n\n .. versionadded: 0.26.17\n\n :param conn: SQLAlchemy Connection object\n :param query: SQLAlchemy Query object or query as a string\n " return QueryAnalysis(conn.execute(explain_analyze(query, buffers=True, format='json')).scalar())
def analyze(conn, query): "\n Analyze query using given connection and return :class:`QueryAnalysis`\n object. Analysis is performed using database specific EXPLAIN ANALYZE\n construct and then examining the results into structured format. Currently\n only PostgreSQL is supported.\n\n\n Getting query runtime (in database level) ::\n\n\n from sqlalchemy_utils import analyze\n\n\n analysis = analyze(conn, 'SELECT * FROM article')\n analysis.runtime # runtime as milliseconds\n\n\n Analyze can be very useful when testing that query doesn't issue a\n sequential scan (scanning all rows in table). You can for example write\n simple performance tests this way.::\n\n\n query = (\n session.query(Article.name)\n .order_by(Article.name)\n .limit(10)\n )\n analysis = analyze(self.connection, query)\n analysis.node_types # [u'Limit', u'Index Only Scan']\n\n assert 'Seq Scan' not in analysis.node_types\n\n\n .. versionadded: 0.26.17\n\n :param conn: SQLAlchemy Connection object\n :param query: SQLAlchemy Query object or query as a string\n " return QueryAnalysis(conn.execute(explain_analyze(query, buffers=True, format='json')).scalar())<|docstring|>Analyze query using given connection and return :class:`QueryAnalysis` object. Analysis is performed using database specific EXPLAIN ANALYZE construct and then examining the results into structured format. Currently only PostgreSQL is supported. Getting query runtime (in database level) :: from sqlalchemy_utils import analyze analysis = analyze(conn, 'SELECT * FROM article') analysis.runtime # runtime as milliseconds Analyze can be very useful when testing that query doesn't issue a sequential scan (scanning all rows in table). You can for example write simple performance tests this way.:: query = ( session.query(Article.name) .order_by(Article.name) .limit(10) ) analysis = analyze(self.connection, query) analysis.node_types # [u'Limit', u'Index Only Scan'] assert 'Seq Scan' not in analysis.node_types .. versionadded: 0.26.17 :param conn: SQLAlchemy Connection object :param query: SQLAlchemy Query object or query as a string<|endoftext|>
8003d61523f80ce520de6688cf3569784ba1ee133ffcf7a5d1a333b8404560d4
def escape_like(string, escape_char='*'): "\n Escape the string paremeter used in SQL LIKE expressions.\n\n ::\n\n from sqlalchemy_utils import escape_like\n\n\n query = session.query(User).filter(\n User.name.ilike(escape_like('John'))\n )\n\n\n :param string: a string to escape\n :param escape_char: escape character\n " return string.replace(escape_char, (escape_char * 2)).replace('%', (escape_char + '%')).replace('_', (escape_char + '_'))
Escape the string paremeter used in SQL LIKE expressions. :: from sqlalchemy_utils import escape_like query = session.query(User).filter( User.name.ilike(escape_like('John')) ) :param string: a string to escape :param escape_char: escape character
sqlalchemy_utils/functions/database.py
escape_like
lnielsen/sqlalchemy-utils
1
python
def escape_like(string, escape_char='*'): "\n Escape the string paremeter used in SQL LIKE expressions.\n\n ::\n\n from sqlalchemy_utils import escape_like\n\n\n query = session.query(User).filter(\n User.name.ilike(escape_like('John'))\n )\n\n\n :param string: a string to escape\n :param escape_char: escape character\n " return string.replace(escape_char, (escape_char * 2)).replace('%', (escape_char + '%')).replace('_', (escape_char + '_'))
def escape_like(string, escape_char='*'): "\n Escape the string paremeter used in SQL LIKE expressions.\n\n ::\n\n from sqlalchemy_utils import escape_like\n\n\n query = session.query(User).filter(\n User.name.ilike(escape_like('John'))\n )\n\n\n :param string: a string to escape\n :param escape_char: escape character\n " return string.replace(escape_char, (escape_char * 2)).replace('%', (escape_char + '%')).replace('_', (escape_char + '_'))<|docstring|>Escape the string paremeter used in SQL LIKE expressions. :: from sqlalchemy_utils import escape_like query = session.query(User).filter( User.name.ilike(escape_like('John')) ) :param string: a string to escape :param escape_char: escape character<|endoftext|>
3731742d475c2de7dc599acc91713e43ff67a13ff40114eb79b21d78870686bc
def has_index(column): "\n Return whether or not given column has an index. A column has an index if\n it has a single column index or it is the first column in compound column\n index.\n\n :param column: SQLAlchemy Column object\n\n .. versionadded: 0.26.2\n\n ::\n\n from sqlalchemy_utils import has_index\n\n\n class Article(Base):\n __tablename__ = 'article'\n id = sa.Column(sa.Integer, primary_key=True)\n title = sa.Column(sa.String(100))\n is_published = sa.Column(sa.Boolean, index=True)\n is_deleted = sa.Column(sa.Boolean)\n is_archived = sa.Column(sa.Boolean)\n\n __table_args__ = (\n sa.Index('my_index', is_deleted, is_archived),\n )\n\n\n table = Article.__table__\n\n has_index(table.c.is_published) # True\n has_index(table.c.is_deleted) # True\n has_index(table.c.is_archived) # False\n\n\n Also supports primary key indexes\n\n ::\n\n from sqlalchemy_utils import has_index\n\n\n class ArticleTranslation(Base):\n __tablename__ = 'article_translation'\n id = sa.Column(sa.Integer, primary_key=True)\n locale = sa.Column(sa.String(10), primary_key=True)\n title = sa.Column(sa.String(100))\n\n\n table = ArticleTranslation.__table__\n\n has_index(table.c.locale) # False\n has_index(table.c.id) # True\n " table = column.table if (not isinstance(table, sa.Table)): raise TypeError(('Only columns belonging to Table objects are supported. Given column belongs to %r.' % table)) return ((column is table.primary_key.columns.values()[0]) or any(((index.columns.values()[0] is column) for index in table.indexes)))
Return whether or not given column has an index. A column has an index if it has a single column index or it is the first column in compound column index. :param column: SQLAlchemy Column object .. versionadded: 0.26.2 :: from sqlalchemy_utils import has_index class Article(Base): __tablename__ = 'article' id = sa.Column(sa.Integer, primary_key=True) title = sa.Column(sa.String(100)) is_published = sa.Column(sa.Boolean, index=True) is_deleted = sa.Column(sa.Boolean) is_archived = sa.Column(sa.Boolean) __table_args__ = ( sa.Index('my_index', is_deleted, is_archived), ) table = Article.__table__ has_index(table.c.is_published) # True has_index(table.c.is_deleted) # True has_index(table.c.is_archived) # False Also supports primary key indexes :: from sqlalchemy_utils import has_index class ArticleTranslation(Base): __tablename__ = 'article_translation' id = sa.Column(sa.Integer, primary_key=True) locale = sa.Column(sa.String(10), primary_key=True) title = sa.Column(sa.String(100)) table = ArticleTranslation.__table__ has_index(table.c.locale) # False has_index(table.c.id) # True
sqlalchemy_utils/functions/database.py
has_index
lnielsen/sqlalchemy-utils
1
python
def has_index(column): "\n Return whether or not given column has an index. A column has an index if\n it has a single column index or it is the first column in compound column\n index.\n\n :param column: SQLAlchemy Column object\n\n .. versionadded: 0.26.2\n\n ::\n\n from sqlalchemy_utils import has_index\n\n\n class Article(Base):\n __tablename__ = 'article'\n id = sa.Column(sa.Integer, primary_key=True)\n title = sa.Column(sa.String(100))\n is_published = sa.Column(sa.Boolean, index=True)\n is_deleted = sa.Column(sa.Boolean)\n is_archived = sa.Column(sa.Boolean)\n\n __table_args__ = (\n sa.Index('my_index', is_deleted, is_archived),\n )\n\n\n table = Article.__table__\n\n has_index(table.c.is_published) # True\n has_index(table.c.is_deleted) # True\n has_index(table.c.is_archived) # False\n\n\n Also supports primary key indexes\n\n ::\n\n from sqlalchemy_utils import has_index\n\n\n class ArticleTranslation(Base):\n __tablename__ = 'article_translation'\n id = sa.Column(sa.Integer, primary_key=True)\n locale = sa.Column(sa.String(10), primary_key=True)\n title = sa.Column(sa.String(100))\n\n\n table = ArticleTranslation.__table__\n\n has_index(table.c.locale) # False\n has_index(table.c.id) # True\n " table = column.table if (not isinstance(table, sa.Table)): raise TypeError(('Only columns belonging to Table objects are supported. Given column belongs to %r.' % table)) return ((column is table.primary_key.columns.values()[0]) or any(((index.columns.values()[0] is column) for index in table.indexes)))
def has_index(column): "\n Return whether or not given column has an index. A column has an index if\n it has a single column index or it is the first column in compound column\n index.\n\n :param column: SQLAlchemy Column object\n\n .. versionadded: 0.26.2\n\n ::\n\n from sqlalchemy_utils import has_index\n\n\n class Article(Base):\n __tablename__ = 'article'\n id = sa.Column(sa.Integer, primary_key=True)\n title = sa.Column(sa.String(100))\n is_published = sa.Column(sa.Boolean, index=True)\n is_deleted = sa.Column(sa.Boolean)\n is_archived = sa.Column(sa.Boolean)\n\n __table_args__ = (\n sa.Index('my_index', is_deleted, is_archived),\n )\n\n\n table = Article.__table__\n\n has_index(table.c.is_published) # True\n has_index(table.c.is_deleted) # True\n has_index(table.c.is_archived) # False\n\n\n Also supports primary key indexes\n\n ::\n\n from sqlalchemy_utils import has_index\n\n\n class ArticleTranslation(Base):\n __tablename__ = 'article_translation'\n id = sa.Column(sa.Integer, primary_key=True)\n locale = sa.Column(sa.String(10), primary_key=True)\n title = sa.Column(sa.String(100))\n\n\n table = ArticleTranslation.__table__\n\n has_index(table.c.locale) # False\n has_index(table.c.id) # True\n " table = column.table if (not isinstance(table, sa.Table)): raise TypeError(('Only columns belonging to Table objects are supported. Given column belongs to %r.' % table)) return ((column is table.primary_key.columns.values()[0]) or any(((index.columns.values()[0] is column) for index in table.indexes)))<|docstring|>Return whether or not given column has an index. A column has an index if it has a single column index or it is the first column in compound column index. :param column: SQLAlchemy Column object .. versionadded: 0.26.2 :: from sqlalchemy_utils import has_index class Article(Base): __tablename__ = 'article' id = sa.Column(sa.Integer, primary_key=True) title = sa.Column(sa.String(100)) is_published = sa.Column(sa.Boolean, index=True) is_deleted = sa.Column(sa.Boolean) is_archived = sa.Column(sa.Boolean) __table_args__ = ( sa.Index('my_index', is_deleted, is_archived), ) table = Article.__table__ has_index(table.c.is_published) # True has_index(table.c.is_deleted) # True has_index(table.c.is_archived) # False Also supports primary key indexes :: from sqlalchemy_utils import has_index class ArticleTranslation(Base): __tablename__ = 'article_translation' id = sa.Column(sa.Integer, primary_key=True) locale = sa.Column(sa.String(10), primary_key=True) title = sa.Column(sa.String(100)) table = ArticleTranslation.__table__ has_index(table.c.locale) # False has_index(table.c.id) # True<|endoftext|>
282aef4894bccdc4eacd045a95853707de22c5eee8f7f02f53e1347a8b2ae38c
def has_unique_index(column): "\n Return whether or not given column has a unique index. A column has a\n unique index if it has a single column primary key index or it has a\n single column UniqueConstraint.\n\n :param column: SQLAlchemy Column object\n\n .. versionadded: 0.27.1\n\n ::\n\n from sqlalchemy_utils import has_unique_index\n\n\n class Article(Base):\n __tablename__ = 'article'\n id = sa.Column(sa.Integer, primary_key=True)\n title = sa.Column(sa.String(100))\n is_published = sa.Column(sa.Boolean, unique=True)\n is_deleted = sa.Column(sa.Boolean)\n is_archived = sa.Column(sa.Boolean)\n\n\n table = Article.__table__\n\n has_unique_index(table.c.is_published) # True\n has_unique_index(table.c.is_deleted) # False\n has_unique_index(table.c.id) # True\n\n\n :raises TypeError: if given column does not belong to a Table object\n " table = column.table if (not isinstance(table, sa.Table)): raise TypeError(('Only columns belonging to Table objects are supported. Given column belongs to %r.' % table)) pks = table.primary_key.columns return (((column is pks.values()[0]) and (len(pks) == 1)) or any(((match_columns(constraint.columns.values()[0], column) and (len(constraint.columns) == 1)) for constraint in column.table.constraints if isinstance(constraint, sa.sql.schema.UniqueConstraint))))
Return whether or not given column has a unique index. A column has a unique index if it has a single column primary key index or it has a single column UniqueConstraint. :param column: SQLAlchemy Column object .. versionadded: 0.27.1 :: from sqlalchemy_utils import has_unique_index class Article(Base): __tablename__ = 'article' id = sa.Column(sa.Integer, primary_key=True) title = sa.Column(sa.String(100)) is_published = sa.Column(sa.Boolean, unique=True) is_deleted = sa.Column(sa.Boolean) is_archived = sa.Column(sa.Boolean) table = Article.__table__ has_unique_index(table.c.is_published) # True has_unique_index(table.c.is_deleted) # False has_unique_index(table.c.id) # True :raises TypeError: if given column does not belong to a Table object
sqlalchemy_utils/functions/database.py
has_unique_index
lnielsen/sqlalchemy-utils
1
python
def has_unique_index(column): "\n Return whether or not given column has a unique index. A column has a\n unique index if it has a single column primary key index or it has a\n single column UniqueConstraint.\n\n :param column: SQLAlchemy Column object\n\n .. versionadded: 0.27.1\n\n ::\n\n from sqlalchemy_utils import has_unique_index\n\n\n class Article(Base):\n __tablename__ = 'article'\n id = sa.Column(sa.Integer, primary_key=True)\n title = sa.Column(sa.String(100))\n is_published = sa.Column(sa.Boolean, unique=True)\n is_deleted = sa.Column(sa.Boolean)\n is_archived = sa.Column(sa.Boolean)\n\n\n table = Article.__table__\n\n has_unique_index(table.c.is_published) # True\n has_unique_index(table.c.is_deleted) # False\n has_unique_index(table.c.id) # True\n\n\n :raises TypeError: if given column does not belong to a Table object\n " table = column.table if (not isinstance(table, sa.Table)): raise TypeError(('Only columns belonging to Table objects are supported. Given column belongs to %r.' % table)) pks = table.primary_key.columns return (((column is pks.values()[0]) and (len(pks) == 1)) or any(((match_columns(constraint.columns.values()[0], column) and (len(constraint.columns) == 1)) for constraint in column.table.constraints if isinstance(constraint, sa.sql.schema.UniqueConstraint))))
def has_unique_index(column): "\n Return whether or not given column has a unique index. A column has a\n unique index if it has a single column primary key index or it has a\n single column UniqueConstraint.\n\n :param column: SQLAlchemy Column object\n\n .. versionadded: 0.27.1\n\n ::\n\n from sqlalchemy_utils import has_unique_index\n\n\n class Article(Base):\n __tablename__ = 'article'\n id = sa.Column(sa.Integer, primary_key=True)\n title = sa.Column(sa.String(100))\n is_published = sa.Column(sa.Boolean, unique=True)\n is_deleted = sa.Column(sa.Boolean)\n is_archived = sa.Column(sa.Boolean)\n\n\n table = Article.__table__\n\n has_unique_index(table.c.is_published) # True\n has_unique_index(table.c.is_deleted) # False\n has_unique_index(table.c.id) # True\n\n\n :raises TypeError: if given column does not belong to a Table object\n " table = column.table if (not isinstance(table, sa.Table)): raise TypeError(('Only columns belonging to Table objects are supported. Given column belongs to %r.' % table)) pks = table.primary_key.columns return (((column is pks.values()[0]) and (len(pks) == 1)) or any(((match_columns(constraint.columns.values()[0], column) and (len(constraint.columns) == 1)) for constraint in column.table.constraints if isinstance(constraint, sa.sql.schema.UniqueConstraint))))<|docstring|>Return whether or not given column has a unique index. A column has a unique index if it has a single column primary key index or it has a single column UniqueConstraint. :param column: SQLAlchemy Column object .. versionadded: 0.27.1 :: from sqlalchemy_utils import has_unique_index class Article(Base): __tablename__ = 'article' id = sa.Column(sa.Integer, primary_key=True) title = sa.Column(sa.String(100)) is_published = sa.Column(sa.Boolean, unique=True) is_deleted = sa.Column(sa.Boolean) is_archived = sa.Column(sa.Boolean) table = Article.__table__ has_unique_index(table.c.is_published) # True has_unique_index(table.c.is_deleted) # False has_unique_index(table.c.id) # True :raises TypeError: if given column does not belong to a Table object<|endoftext|>
d9bca3891b75ac2699cba4bbf0c87e0da409553f8ab60cdaea298584ce6a9ee2
def is_auto_assigned_date_column(column): "\n Returns whether or not given SQLAlchemy Column object's is auto assigned\n DateTime or Date.\n\n :param column: SQLAlchemy Column object\n " return ((isinstance(column.type, sa.DateTime) or isinstance(column.type, sa.Date)) and (column.default or column.server_default or column.onupdate or column.server_onupdate))
Returns whether or not given SQLAlchemy Column object's is auto assigned DateTime or Date. :param column: SQLAlchemy Column object
sqlalchemy_utils/functions/database.py
is_auto_assigned_date_column
lnielsen/sqlalchemy-utils
1
python
def is_auto_assigned_date_column(column): "\n Returns whether or not given SQLAlchemy Column object's is auto assigned\n DateTime or Date.\n\n :param column: SQLAlchemy Column object\n " return ((isinstance(column.type, sa.DateTime) or isinstance(column.type, sa.Date)) and (column.default or column.server_default or column.onupdate or column.server_onupdate))
def is_auto_assigned_date_column(column): "\n Returns whether or not given SQLAlchemy Column object's is auto assigned\n DateTime or Date.\n\n :param column: SQLAlchemy Column object\n " return ((isinstance(column.type, sa.DateTime) or isinstance(column.type, sa.Date)) and (column.default or column.server_default or column.onupdate or column.server_onupdate))<|docstring|>Returns whether or not given SQLAlchemy Column object's is auto assigned DateTime or Date. :param column: SQLAlchemy Column object<|endoftext|>
31de4ce8cd58904a1d4428609c6df0d3a38989272874a8869c9572a8e9aa4457
def database_exists(url): "Check if a database exists.\n\n :param url: A SQLAlchemy engine URL.\n\n Performs backend-specific testing to quickly determine if a database\n exists on the server. ::\n\n database_exists('postgres://postgres@localhost/name') #=> False\n create_database('postgres://postgres@localhost/name')\n database_exists('postgres://postgres@localhost/name') #=> True\n\n Supports checking against a constructed URL as well. ::\n\n engine = create_engine('postgres://postgres@localhost/name')\n database_exists(engine.url) #=> False\n create_database(engine.url)\n database_exists(engine.url) #=> True\n\n " url = copy(make_url(url)) database = url.database if url.drivername.startswith('postgresql'): url.database = 'template1' else: url.database = None engine = sa.create_engine(url) if (engine.dialect.name == 'postgresql'): text = ("SELECT 1 FROM pg_database WHERE datname='%s'" % database) return bool(engine.execute(text).scalar()) elif (engine.dialect.name == 'mysql'): text = ("SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = '%s'" % database) return bool(engine.execute(text).scalar()) elif (engine.dialect.name == 'sqlite'): return ((database == ':memory:') or os.path.exists(database)) else: text = 'SELECT 1' try: url.database = database engine = sa.create_engine(url) engine.execute(text) return True except (ProgrammingError, OperationalError): return False
Check if a database exists. :param url: A SQLAlchemy engine URL. Performs backend-specific testing to quickly determine if a database exists on the server. :: database_exists('postgres://postgres@localhost/name') #=> False create_database('postgres://postgres@localhost/name') database_exists('postgres://postgres@localhost/name') #=> True Supports checking against a constructed URL as well. :: engine = create_engine('postgres://postgres@localhost/name') database_exists(engine.url) #=> False create_database(engine.url) database_exists(engine.url) #=> True
sqlalchemy_utils/functions/database.py
database_exists
lnielsen/sqlalchemy-utils
1
python
def database_exists(url): "Check if a database exists.\n\n :param url: A SQLAlchemy engine URL.\n\n Performs backend-specific testing to quickly determine if a database\n exists on the server. ::\n\n database_exists('postgres://postgres@localhost/name') #=> False\n create_database('postgres://postgres@localhost/name')\n database_exists('postgres://postgres@localhost/name') #=> True\n\n Supports checking against a constructed URL as well. ::\n\n engine = create_engine('postgres://postgres@localhost/name')\n database_exists(engine.url) #=> False\n create_database(engine.url)\n database_exists(engine.url) #=> True\n\n " url = copy(make_url(url)) database = url.database if url.drivername.startswith('postgresql'): url.database = 'template1' else: url.database = None engine = sa.create_engine(url) if (engine.dialect.name == 'postgresql'): text = ("SELECT 1 FROM pg_database WHERE datname='%s'" % database) return bool(engine.execute(text).scalar()) elif (engine.dialect.name == 'mysql'): text = ("SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = '%s'" % database) return bool(engine.execute(text).scalar()) elif (engine.dialect.name == 'sqlite'): return ((database == ':memory:') or os.path.exists(database)) else: text = 'SELECT 1' try: url.database = database engine = sa.create_engine(url) engine.execute(text) return True except (ProgrammingError, OperationalError): return False
def database_exists(url): "Check if a database exists.\n\n :param url: A SQLAlchemy engine URL.\n\n Performs backend-specific testing to quickly determine if a database\n exists on the server. ::\n\n database_exists('postgres://postgres@localhost/name') #=> False\n create_database('postgres://postgres@localhost/name')\n database_exists('postgres://postgres@localhost/name') #=> True\n\n Supports checking against a constructed URL as well. ::\n\n engine = create_engine('postgres://postgres@localhost/name')\n database_exists(engine.url) #=> False\n create_database(engine.url)\n database_exists(engine.url) #=> True\n\n " url = copy(make_url(url)) database = url.database if url.drivername.startswith('postgresql'): url.database = 'template1' else: url.database = None engine = sa.create_engine(url) if (engine.dialect.name == 'postgresql'): text = ("SELECT 1 FROM pg_database WHERE datname='%s'" % database) return bool(engine.execute(text).scalar()) elif (engine.dialect.name == 'mysql'): text = ("SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = '%s'" % database) return bool(engine.execute(text).scalar()) elif (engine.dialect.name == 'sqlite'): return ((database == ':memory:') or os.path.exists(database)) else: text = 'SELECT 1' try: url.database = database engine = sa.create_engine(url) engine.execute(text) return True except (ProgrammingError, OperationalError): return False<|docstring|>Check if a database exists. :param url: A SQLAlchemy engine URL. Performs backend-specific testing to quickly determine if a database exists on the server. :: database_exists('postgres://postgres@localhost/name') #=> False create_database('postgres://postgres@localhost/name') database_exists('postgres://postgres@localhost/name') #=> True Supports checking against a constructed URL as well. :: engine = create_engine('postgres://postgres@localhost/name') database_exists(engine.url) #=> False create_database(engine.url) database_exists(engine.url) #=> True<|endoftext|>
0890dd0d8e96042dd81308fbdb024d58009eec8366db4d975b3ca3f8b0e8733d
def create_database(url, encoding='utf8', template=None): "Issue the appropriate CREATE DATABASE statement.\n\n :param url: A SQLAlchemy engine URL.\n :param encoding: The encoding to create the database as.\n :param template:\n The name of the template from which to create the new database. At the\n moment only supported by PostgreSQL driver.\n\n To create a database, you can pass a simple URL that would have\n been passed to ``create_engine``. ::\n\n create_database('postgres://postgres@localhost/name')\n\n You may also pass the url from an existing engine. ::\n\n create_database(engine.url)\n\n Has full support for mysql, postgres, and sqlite. In theory,\n other database engines should be supported.\n " url = copy(make_url(url)) database = url.database if url.drivername.startswith('postgresql'): url.database = 'template1' elif (not url.drivername.startswith('sqlite')): url.database = None engine = sa.create_engine(url) if (engine.dialect.name == 'postgresql'): if (engine.driver == 'psycopg2'): from psycopg2.extensions import ISOLATION_LEVEL_AUTOCOMMIT engine.raw_connection().set_isolation_level(ISOLATION_LEVEL_AUTOCOMMIT) if (not template): template = 'template0' text = ("CREATE DATABASE %s ENCODING '%s' TEMPLATE %s" % (database, encoding, template)) engine.execute(text) elif (engine.dialect.name == 'mysql'): text = ("CREATE DATABASE %s CHARACTER SET = '%s'" % (database, encoding)) engine.execute(text) elif ((engine.dialect.name == 'sqlite') and (database != ':memory:')): open(database, 'w').close() else: text = ('CREATE DATABASE %s' % database) engine.execute(text)
Issue the appropriate CREATE DATABASE statement. :param url: A SQLAlchemy engine URL. :param encoding: The encoding to create the database as. :param template: The name of the template from which to create the new database. At the moment only supported by PostgreSQL driver. To create a database, you can pass a simple URL that would have been passed to ``create_engine``. :: create_database('postgres://postgres@localhost/name') You may also pass the url from an existing engine. :: create_database(engine.url) Has full support for mysql, postgres, and sqlite. In theory, other database engines should be supported.
sqlalchemy_utils/functions/database.py
create_database
lnielsen/sqlalchemy-utils
1
python
def create_database(url, encoding='utf8', template=None): "Issue the appropriate CREATE DATABASE statement.\n\n :param url: A SQLAlchemy engine URL.\n :param encoding: The encoding to create the database as.\n :param template:\n The name of the template from which to create the new database. At the\n moment only supported by PostgreSQL driver.\n\n To create a database, you can pass a simple URL that would have\n been passed to ``create_engine``. ::\n\n create_database('postgres://postgres@localhost/name')\n\n You may also pass the url from an existing engine. ::\n\n create_database(engine.url)\n\n Has full support for mysql, postgres, and sqlite. In theory,\n other database engines should be supported.\n " url = copy(make_url(url)) database = url.database if url.drivername.startswith('postgresql'): url.database = 'template1' elif (not url.drivername.startswith('sqlite')): url.database = None engine = sa.create_engine(url) if (engine.dialect.name == 'postgresql'): if (engine.driver == 'psycopg2'): from psycopg2.extensions import ISOLATION_LEVEL_AUTOCOMMIT engine.raw_connection().set_isolation_level(ISOLATION_LEVEL_AUTOCOMMIT) if (not template): template = 'template0' text = ("CREATE DATABASE %s ENCODING '%s' TEMPLATE %s" % (database, encoding, template)) engine.execute(text) elif (engine.dialect.name == 'mysql'): text = ("CREATE DATABASE %s CHARACTER SET = '%s'" % (database, encoding)) engine.execute(text) elif ((engine.dialect.name == 'sqlite') and (database != ':memory:')): open(database, 'w').close() else: text = ('CREATE DATABASE %s' % database) engine.execute(text)
def create_database(url, encoding='utf8', template=None): "Issue the appropriate CREATE DATABASE statement.\n\n :param url: A SQLAlchemy engine URL.\n :param encoding: The encoding to create the database as.\n :param template:\n The name of the template from which to create the new database. At the\n moment only supported by PostgreSQL driver.\n\n To create a database, you can pass a simple URL that would have\n been passed to ``create_engine``. ::\n\n create_database('postgres://postgres@localhost/name')\n\n You may also pass the url from an existing engine. ::\n\n create_database(engine.url)\n\n Has full support for mysql, postgres, and sqlite. In theory,\n other database engines should be supported.\n " url = copy(make_url(url)) database = url.database if url.drivername.startswith('postgresql'): url.database = 'template1' elif (not url.drivername.startswith('sqlite')): url.database = None engine = sa.create_engine(url) if (engine.dialect.name == 'postgresql'): if (engine.driver == 'psycopg2'): from psycopg2.extensions import ISOLATION_LEVEL_AUTOCOMMIT engine.raw_connection().set_isolation_level(ISOLATION_LEVEL_AUTOCOMMIT) if (not template): template = 'template0' text = ("CREATE DATABASE %s ENCODING '%s' TEMPLATE %s" % (database, encoding, template)) engine.execute(text) elif (engine.dialect.name == 'mysql'): text = ("CREATE DATABASE %s CHARACTER SET = '%s'" % (database, encoding)) engine.execute(text) elif ((engine.dialect.name == 'sqlite') and (database != ':memory:')): open(database, 'w').close() else: text = ('CREATE DATABASE %s' % database) engine.execute(text)<|docstring|>Issue the appropriate CREATE DATABASE statement. :param url: A SQLAlchemy engine URL. :param encoding: The encoding to create the database as. :param template: The name of the template from which to create the new database. At the moment only supported by PostgreSQL driver. To create a database, you can pass a simple URL that would have been passed to ``create_engine``. :: create_database('postgres://postgres@localhost/name') You may also pass the url from an existing engine. :: create_database(engine.url) Has full support for mysql, postgres, and sqlite. In theory, other database engines should be supported.<|endoftext|>
b9f25f3c9084a1f08a4fb36c7ec67fb8ac17b119917adf6e1f5221df69081dea
def drop_database(url): "Issue the appropriate DROP DATABASE statement.\n\n :param url: A SQLAlchemy engine URL.\n\n Works similar to the :ref:`create_database` method in that both url text\n and a constructed url are accepted. ::\n\n drop_database('postgres://postgres@localhost/name')\n drop_database(engine.url)\n\n " url = copy(make_url(url)) database = url.database if url.drivername.startswith('postgresql'): url.database = 'template1' elif (not url.drivername.startswith('sqlite')): url.database = None engine = sa.create_engine(url) if ((engine.dialect.name == 'sqlite') and (url.database != ':memory:')): os.remove(url.database) elif ((engine.dialect.name == 'postgresql') and (engine.driver == 'psycopg2')): from psycopg2.extensions import ISOLATION_LEVEL_AUTOCOMMIT engine.raw_connection().set_isolation_level(ISOLATION_LEVEL_AUTOCOMMIT) version = list(map(int, engine.execute('SHOW server_version;').first()[0].split('.'))) pid_column = ('pid' if ((version[0] >= 9) and (version[1] >= 2)) else 'procpid') text = ("\n SELECT pg_terminate_backend(pg_stat_activity.%(pid_column)s)\n FROM pg_stat_activity\n WHERE pg_stat_activity.datname = '%(database)s'\n AND %(pid_column)s <> pg_backend_pid();\n " % {'pid_column': pid_column, 'database': database}) engine.execute(text) text = ('DROP DATABASE %s' % database) engine.execute(text) else: text = ('DROP DATABASE %s' % database) engine.execute(text)
Issue the appropriate DROP DATABASE statement. :param url: A SQLAlchemy engine URL. Works similar to the :ref:`create_database` method in that both url text and a constructed url are accepted. :: drop_database('postgres://postgres@localhost/name') drop_database(engine.url)
sqlalchemy_utils/functions/database.py
drop_database
lnielsen/sqlalchemy-utils
1
python
def drop_database(url): "Issue the appropriate DROP DATABASE statement.\n\n :param url: A SQLAlchemy engine URL.\n\n Works similar to the :ref:`create_database` method in that both url text\n and a constructed url are accepted. ::\n\n drop_database('postgres://postgres@localhost/name')\n drop_database(engine.url)\n\n " url = copy(make_url(url)) database = url.database if url.drivername.startswith('postgresql'): url.database = 'template1' elif (not url.drivername.startswith('sqlite')): url.database = None engine = sa.create_engine(url) if ((engine.dialect.name == 'sqlite') and (url.database != ':memory:')): os.remove(url.database) elif ((engine.dialect.name == 'postgresql') and (engine.driver == 'psycopg2')): from psycopg2.extensions import ISOLATION_LEVEL_AUTOCOMMIT engine.raw_connection().set_isolation_level(ISOLATION_LEVEL_AUTOCOMMIT) version = list(map(int, engine.execute('SHOW server_version;').first()[0].split('.'))) pid_column = ('pid' if ((version[0] >= 9) and (version[1] >= 2)) else 'procpid') text = ("\n SELECT pg_terminate_backend(pg_stat_activity.%(pid_column)s)\n FROM pg_stat_activity\n WHERE pg_stat_activity.datname = '%(database)s'\n AND %(pid_column)s <> pg_backend_pid();\n " % {'pid_column': pid_column, 'database': database}) engine.execute(text) text = ('DROP DATABASE %s' % database) engine.execute(text) else: text = ('DROP DATABASE %s' % database) engine.execute(text)
def drop_database(url): "Issue the appropriate DROP DATABASE statement.\n\n :param url: A SQLAlchemy engine URL.\n\n Works similar to the :ref:`create_database` method in that both url text\n and a constructed url are accepted. ::\n\n drop_database('postgres://postgres@localhost/name')\n drop_database(engine.url)\n\n " url = copy(make_url(url)) database = url.database if url.drivername.startswith('postgresql'): url.database = 'template1' elif (not url.drivername.startswith('sqlite')): url.database = None engine = sa.create_engine(url) if ((engine.dialect.name == 'sqlite') and (url.database != ':memory:')): os.remove(url.database) elif ((engine.dialect.name == 'postgresql') and (engine.driver == 'psycopg2')): from psycopg2.extensions import ISOLATION_LEVEL_AUTOCOMMIT engine.raw_connection().set_isolation_level(ISOLATION_LEVEL_AUTOCOMMIT) version = list(map(int, engine.execute('SHOW server_version;').first()[0].split('.'))) pid_column = ('pid' if ((version[0] >= 9) and (version[1] >= 2)) else 'procpid') text = ("\n SELECT pg_terminate_backend(pg_stat_activity.%(pid_column)s)\n FROM pg_stat_activity\n WHERE pg_stat_activity.datname = '%(database)s'\n AND %(pid_column)s <> pg_backend_pid();\n " % {'pid_column': pid_column, 'database': database}) engine.execute(text) text = ('DROP DATABASE %s' % database) engine.execute(text) else: text = ('DROP DATABASE %s' % database) engine.execute(text)<|docstring|>Issue the appropriate DROP DATABASE statement. :param url: A SQLAlchemy engine URL. Works similar to the :ref:`create_database` method in that both url text and a constructed url are accepted. :: drop_database('postgres://postgres@localhost/name') drop_database(engine.url)<|endoftext|>
c35a396c1cc28cbdcbe5144dcdac9b88aeaa656da305e8a9a5f44e6291d2c4a6
def flash_errors(form): '\n Method for displaying flash messages with form errors.\n Pass the form as a parameter.\n ' for (field, errors) in form.errors.items(): for error in errors: flash((u'Error in the %s field - %s' % (getattr(form, field).label.text, error)), 'danger')
Method for displaying flash messages with form errors. Pass the form as a parameter.
autologin/server.py
flash_errors
ishandutta2007/autologin
164
python
def flash_errors(form): '\n Method for displaying flash messages with form errors.\n Pass the form as a parameter.\n ' for (field, errors) in form.errors.items(): for error in errors: flash((u'Error in the %s field - %s' % (getattr(form, field).label.text, error)), 'danger')
def flash_errors(form): '\n Method for displaying flash messages with form errors.\n Pass the form as a parameter.\n ' for (field, errors) in form.errors.items(): for error in errors: flash((u'Error in the %s field - %s' % (getattr(form, field).label.text, error)), 'danger')<|docstring|>Method for displaying flash messages with form errors. Pass the form as a parameter.<|endoftext|>
27f984b42e67891429b6ea1e0243a99a99ec10cc9724bf3c4e3ad49f445cebe4
def delete_directory_files(directory_path): '\n Method for deleting temporary html files created by\n show in browser process.\n ' for filename in os.listdir(directory_path): if (filename != 'README'): path = os.path.join(directory_path, filename) if os.path.isfile(path): os.unlink(path) else: shutil.rmtree(path)
Method for deleting temporary html files created by show in browser process.
autologin/server.py
delete_directory_files
ishandutta2007/autologin
164
python
def delete_directory_files(directory_path): '\n Method for deleting temporary html files created by\n show in browser process.\n ' for filename in os.listdir(directory_path): if (filename != 'README'): path = os.path.join(directory_path, filename) if os.path.isfile(path): os.unlink(path) else: shutil.rmtree(path)
def delete_directory_files(directory_path): '\n Method for deleting temporary html files created by\n show in browser process.\n ' for filename in os.listdir(directory_path): if (filename != 'README'): path = os.path.join(directory_path, filename) if os.path.isfile(path): os.unlink(path) else: shutil.rmtree(path)<|docstring|>Method for deleting temporary html files created by show in browser process.<|endoftext|>
22e726a7a44aef52784593555a09456827967ba7e1dec1276cb7a21706f0f361
def download_page(url, cookie_jar): '\n Request page using authenticated cookies (cookiejar).\n Download html source and save in browser directory, to\n be used by in show_in_browser().\n ' browser_dir = os.path.join(server_path, 'static/browser') delete_directory_files(browser_dir) filename = '{}.html'.format(uuid.uuid4()) filepath = os.path.join(browser_dir, filename) try: response = cookie_request(url, cookie_jar) except requests.RequestException as e: return (e, None) doc = html.document_fromstring(response.text) with open(filepath, 'wb') as f: f.write(html.tostring(doc)) return (None, filename)
Request page using authenticated cookies (cookiejar). Download html source and save in browser directory, to be used by in show_in_browser().
autologin/server.py
download_page
ishandutta2007/autologin
164
python
def download_page(url, cookie_jar): '\n Request page using authenticated cookies (cookiejar).\n Download html source and save in browser directory, to\n be used by in show_in_browser().\n ' browser_dir = os.path.join(server_path, 'static/browser') delete_directory_files(browser_dir) filename = '{}.html'.format(uuid.uuid4()) filepath = os.path.join(browser_dir, filename) try: response = cookie_request(url, cookie_jar) except requests.RequestException as e: return (e, None) doc = html.document_fromstring(response.text) with open(filepath, 'wb') as f: f.write(html.tostring(doc)) return (None, filename)
def download_page(url, cookie_jar): '\n Request page using authenticated cookies (cookiejar).\n Download html source and save in browser directory, to\n be used by in show_in_browser().\n ' browser_dir = os.path.join(server_path, 'static/browser') delete_directory_files(browser_dir) filename = '{}.html'.format(uuid.uuid4()) filepath = os.path.join(browser_dir, filename) try: response = cookie_request(url, cookie_jar) except requests.RequestException as e: return (e, None) doc = html.document_fromstring(response.text) with open(filepath, 'wb') as f: f.write(html.tostring(doc)) return (None, filename)<|docstring|>Request page using authenticated cookies (cookiejar). Download html source and save in browser directory, to be used by in show_in_browser().<|endoftext|>
b1fa610eec3c357afa2b6fabf473d5ca7c69f05b092df337e9df1cf2178c3f03
@app.route('/', methods=['GET', 'POST']) def index(): '\n Main app route.\n Hosts form used for testing autologin.\n User can submit credentials and URL,\n authenticated cookies returned.\n Also makes a request using extracted cookies,\n saves the source and allows you to view in browser.\n Useful for checking whether login was successful.\n ' from flask import request form = LoginForm(request.form) auto_login = AutoLogin() login_cookies = None login_links = None filename = None if ((request.method == 'POST') and form.validate()): url = form.url.data username = form.username.data password = form.password.data msg = 'Login requested for {url} with username={username} and password={password}'.format(url=url, username=username, password=password) try: login_cookie_jar = auto_login.auth_cookies_from_url(url, username, password) except AutoLoginException as e: flash(e, 'danger') else: login_cookies = login_cookie_jar.__dict__ (error, filename) = download_page(form.url.data, login_cookie_jar) if error: flash(error, 'danger') else: flash(msg, 'success') else: flash_errors(form) return render_template('index.html', form=form, login_cookies=login_cookies, login_links=login_links, filename=filename)
Main app route. Hosts form used for testing autologin. User can submit credentials and URL, authenticated cookies returned. Also makes a request using extracted cookies, saves the source and allows you to view in browser. Useful for checking whether login was successful.
autologin/server.py
index
ishandutta2007/autologin
164
python
@app.route('/', methods=['GET', 'POST']) def index(): '\n Main app route.\n Hosts form used for testing autologin.\n User can submit credentials and URL,\n authenticated cookies returned.\n Also makes a request using extracted cookies,\n saves the source and allows you to view in browser.\n Useful for checking whether login was successful.\n ' from flask import request form = LoginForm(request.form) auto_login = AutoLogin() login_cookies = None login_links = None filename = None if ((request.method == 'POST') and form.validate()): url = form.url.data username = form.username.data password = form.password.data msg = 'Login requested for {url} with username={username} and password={password}'.format(url=url, username=username, password=password) try: login_cookie_jar = auto_login.auth_cookies_from_url(url, username, password) except AutoLoginException as e: flash(e, 'danger') else: login_cookies = login_cookie_jar.__dict__ (error, filename) = download_page(form.url.data, login_cookie_jar) if error: flash(error, 'danger') else: flash(msg, 'success') else: flash_errors(form) return render_template('index.html', form=form, login_cookies=login_cookies, login_links=login_links, filename=filename)
@app.route('/', methods=['GET', 'POST']) def index(): '\n Main app route.\n Hosts form used for testing autologin.\n User can submit credentials and URL,\n authenticated cookies returned.\n Also makes a request using extracted cookies,\n saves the source and allows you to view in browser.\n Useful for checking whether login was successful.\n ' from flask import request form = LoginForm(request.form) auto_login = AutoLogin() login_cookies = None login_links = None filename = None if ((request.method == 'POST') and form.validate()): url = form.url.data username = form.username.data password = form.password.data msg = 'Login requested for {url} with username={username} and password={password}'.format(url=url, username=username, password=password) try: login_cookie_jar = auto_login.auth_cookies_from_url(url, username, password) except AutoLoginException as e: flash(e, 'danger') else: login_cookies = login_cookie_jar.__dict__ (error, filename) = download_page(form.url.data, login_cookie_jar) if error: flash(error, 'danger') else: flash(msg, 'success') else: flash_errors(form) return render_template('index.html', form=form, login_cookies=login_cookies, login_links=login_links, filename=filename)<|docstring|>Main app route. Hosts form used for testing autologin. User can submit credentials and URL, authenticated cookies returned. Also makes a request using extracted cookies, saves the source and allows you to view in browser. Useful for checking whether login was successful.<|endoftext|>
296901f790c6a603b85e0a5e0a854f6d9a1bc824d19757d5fa8cf6c2d75ec7e5
def test_no_config(config_no_file): '\n Tests we are able to parse an empty configuration, except it will fail on\n missing mandatory field ("shape").\n ' with pytest.raises(mergeconf.exceptions.MissingConfiguration) as e: config_no_file.merge() print(e.value.missing) assert (e.value.missing == 'shape, section2.count')
Tests we are able to parse an empty configuration, except it will fail on missing mandatory field ("shape").
tests/test_basic.py
test_no_config
ComputeCanada/mergeconf
0
python
def test_no_config(config_no_file): '\n Tests we are able to parse an empty configuration, except it will fail on\n missing mandatory field ("shape").\n ' with pytest.raises(mergeconf.exceptions.MissingConfiguration) as e: config_no_file.merge() print(e.value.missing) assert (e.value.missing == 'shape, section2.count')
def test_no_config(config_no_file): '\n Tests we are able to parse an empty configuration, except it will fail on\n missing mandatory field ("shape").\n ' with pytest.raises(mergeconf.exceptions.MissingConfiguration) as e: config_no_file.merge() print(e.value.missing) assert (e.value.missing == 'shape, section2.count')<|docstring|>Tests we are able to parse an empty configuration, except it will fail on missing mandatory field ("shape").<|endoftext|>
578727d4b6eacda0aad31a21ef0ff37ad4bbf7eb9bbc0ea4f2729574b02c1b15
def test_no_config_map(config_with_defaults): '\n Tests we are able to parse an empty configuration and get a map back.\n ' config_with_defaults.merge() assert (config_with_defaults['shape'] == 'triangle') assert (config_with_defaults.shape == 'triangle') d = config_with_defaults.to_dict() print('Config as dict:') print(d) assert (d == {'name': None, 'colour': 'blue', 'upsidedown': None, 'rightsideup': True, 'shape': 'triangle', 'section2': {'count': 13, 'z_index': 12, 'ratio': None, 'ferbs': '[1, 2, 3, 4]'}})
Tests we are able to parse an empty configuration and get a map back.
tests/test_basic.py
test_no_config_map
ComputeCanada/mergeconf
0
python
def test_no_config_map(config_with_defaults): '\n \n ' config_with_defaults.merge() assert (config_with_defaults['shape'] == 'triangle') assert (config_with_defaults.shape == 'triangle') d = config_with_defaults.to_dict() print('Config as dict:') print(d) assert (d == {'name': None, 'colour': 'blue', 'upsidedown': None, 'rightsideup': True, 'shape': 'triangle', 'section2': {'count': 13, 'z_index': 12, 'ratio': None, 'ferbs': '[1, 2, 3, 4]'}})
def test_no_config_map(config_with_defaults): '\n \n ' config_with_defaults.merge() assert (config_with_defaults['shape'] == 'triangle') assert (config_with_defaults.shape == 'triangle') d = config_with_defaults.to_dict() print('Config as dict:') print(d) assert (d == {'name': None, 'colour': 'blue', 'upsidedown': None, 'rightsideup': True, 'shape': 'triangle', 'section2': {'count': 13, 'z_index': 12, 'ratio': None, 'ferbs': '[1, 2, 3, 4]'}})<|docstring|>Tests we are able to parse an empty configuration and get a map back.<|endoftext|>
88fb392f04999a6837896ff11becd388ab0ed46038bb03ff4464ffdd684faf6c
def test_config_only_env(config): '\n Tests we are able to parse a config defined only in the environment.\n ' os.environ[envvarname('SHAPE')] = 'circle' os.environ[envvarname('UPSIDEDOWN')] = 'no' os.environ[envvarname('SECTION2_COUNT')] = '10' os.environ[envvarname('SECTION2_RATIO')] = '10.425' os.environ[envvarname('SECTION2_FUBAR')] = 'this does not even matter' config.merge() assert (config['shape'] == 'circle') assert (config['upsidedown'] == False) assert (config['rightsideup'] == True) assert (config['section2']['count'] == 10) assert (config['section2']['ratio'] == 10.425) assert (config.shape == 'circle') assert (config.upsidedown == False) assert (config.rightsideup == True) assert (config.section2.count == 10) assert (config.section2.ratio == 10.425) clean_up_env()
Tests we are able to parse a config defined only in the environment.
tests/test_basic.py
test_config_only_env
ComputeCanada/mergeconf
0
python
def test_config_only_env(config): '\n \n ' os.environ[envvarname('SHAPE')] = 'circle' os.environ[envvarname('UPSIDEDOWN')] = 'no' os.environ[envvarname('SECTION2_COUNT')] = '10' os.environ[envvarname('SECTION2_RATIO')] = '10.425' os.environ[envvarname('SECTION2_FUBAR')] = 'this does not even matter' config.merge() assert (config['shape'] == 'circle') assert (config['upsidedown'] == False) assert (config['rightsideup'] == True) assert (config['section2']['count'] == 10) assert (config['section2']['ratio'] == 10.425) assert (config.shape == 'circle') assert (config.upsidedown == False) assert (config.rightsideup == True) assert (config.section2.count == 10) assert (config.section2.ratio == 10.425) clean_up_env()
def test_config_only_env(config): '\n \n ' os.environ[envvarname('SHAPE')] = 'circle' os.environ[envvarname('UPSIDEDOWN')] = 'no' os.environ[envvarname('SECTION2_COUNT')] = '10' os.environ[envvarname('SECTION2_RATIO')] = '10.425' os.environ[envvarname('SECTION2_FUBAR')] = 'this does not even matter' config.merge() assert (config['shape'] == 'circle') assert (config['upsidedown'] == False) assert (config['rightsideup'] == True) assert (config['section2']['count'] == 10) assert (config['section2']['ratio'] == 10.425) assert (config.shape == 'circle') assert (config.upsidedown == False) assert (config.rightsideup == True) assert (config.section2.count == 10) assert (config.section2.ratio == 10.425) clean_up_env()<|docstring|>Tests we are able to parse a config defined only in the environment.<|endoftext|>
86aa9536d4157cca67880f6163e838b0ab2c887e2c73ddfe54ff72af29eb0ea1
def test_config_only_file(config): '\n Tests we are able to correctly parse a config defined only in a file.\n ' config.merge() assert (config['shape'] == 'circle') assert (config['upsidedown'] == False) assert (config['rightsideup'] == True) assert (config['section2']['count'] == 4) assert (config['section2']['ratio'] == 20.403)
Tests we are able to correctly parse a config defined only in a file.
tests/test_basic.py
test_config_only_file
ComputeCanada/mergeconf
0
python
def test_config_only_file(config): '\n \n ' config.merge() assert (config['shape'] == 'circle') assert (config['upsidedown'] == False) assert (config['rightsideup'] == True) assert (config['section2']['count'] == 4) assert (config['section2']['ratio'] == 20.403)
def test_config_only_file(config): '\n \n ' config.merge() assert (config['shape'] == 'circle') assert (config['upsidedown'] == False) assert (config['rightsideup'] == True) assert (config['section2']['count'] == 4) assert (config['section2']['ratio'] == 20.403)<|docstring|>Tests we are able to correctly parse a config defined only in a file.<|endoftext|>
8766fdb779aa5383d65ed4628bbfcbd296d1c41ce3dfa27f30160b01701e1199
def test_config_file_and_env(config): '\n Tests we are able to correctly parse a config defined in both file and\n in the environment, with environment taking precedence.\n ' os.environ[envvarname('SHAPE')] = 'triangle' os.environ[envvarname('UPSIDEDOWN')] = 'true' os.environ[envvarname('SECTION2_COUNT')] = '15' config.merge() assert (config['shape'] == 'triangle') assert (config['upsidedown'] == True) assert (config['rightsideup'] == True) assert (config['section2']['count'] == 15) assert (config['section2']['ratio'] == 20.403) clean_up_env()
Tests we are able to correctly parse a config defined in both file and in the environment, with environment taking precedence.
tests/test_basic.py
test_config_file_and_env
ComputeCanada/mergeconf
0
python
def test_config_file_and_env(config): '\n Tests we are able to correctly parse a config defined in both file and\n in the environment, with environment taking precedence.\n ' os.environ[envvarname('SHAPE')] = 'triangle' os.environ[envvarname('UPSIDEDOWN')] = 'true' os.environ[envvarname('SECTION2_COUNT')] = '15' config.merge() assert (config['shape'] == 'triangle') assert (config['upsidedown'] == True) assert (config['rightsideup'] == True) assert (config['section2']['count'] == 15) assert (config['section2']['ratio'] == 20.403) clean_up_env()
def test_config_file_and_env(config): '\n Tests we are able to correctly parse a config defined in both file and\n in the environment, with environment taking precedence.\n ' os.environ[envvarname('SHAPE')] = 'triangle' os.environ[envvarname('UPSIDEDOWN')] = 'true' os.environ[envvarname('SECTION2_COUNT')] = '15' config.merge() assert (config['shape'] == 'triangle') assert (config['upsidedown'] == True) assert (config['rightsideup'] == True) assert (config['section2']['count'] == 15) assert (config['section2']['ratio'] == 20.403) clean_up_env()<|docstring|>Tests we are able to correctly parse a config defined in both file and in the environment, with environment taking precedence.<|endoftext|>
8f7468638fa01c5384dc03013b9faab9ba26e3a68f40490641a4bc82a34a3c17
def test_config_missing_file(config): '\n Tests we handle a missing config file.\n ' with pytest.raises(mergeconf.exceptions.MissingConfigurationFile) as e: config.merge_file('test2_missing.conf') assert e assert (e.value.file == 'test2_missing.conf') clean_up_env()
Tests we handle a missing config file.
tests/test_basic.py
test_config_missing_file
ComputeCanada/mergeconf
0
python
def test_config_missing_file(config): '\n \n ' with pytest.raises(mergeconf.exceptions.MissingConfigurationFile) as e: config.merge_file('test2_missing.conf') assert e assert (e.value.file == 'test2_missing.conf') clean_up_env()
def test_config_missing_file(config): '\n \n ' with pytest.raises(mergeconf.exceptions.MissingConfigurationFile) as e: config.merge_file('test2_missing.conf') assert e assert (e.value.file == 'test2_missing.conf') clean_up_env()<|docstring|>Tests we handle a missing config file.<|endoftext|>
3634e89afc971aff4a00a2e4ac054e0f51981e601882308b3a133f1706e0d0a7
def test_unsupported_type(): '\n Tests the attempted use of an unsupported type throws an exception.\n ' conf = mergeconf.MergeConf('test') with pytest.raises(mergeconf.exceptions.UnsupportedType) as e: conf.add('SECTION1_NAME', type=list) assert (e.value.type == 'list')
Tests the attempted use of an unsupported type throws an exception.
tests/test_basic.py
test_unsupported_type
ComputeCanada/mergeconf
0
python
def test_unsupported_type(): '\n \n ' conf = mergeconf.MergeConf('test') with pytest.raises(mergeconf.exceptions.UnsupportedType) as e: conf.add('SECTION1_NAME', type=list) assert (e.value.type == 'list')
def test_unsupported_type(): '\n \n ' conf = mergeconf.MergeConf('test') with pytest.raises(mergeconf.exceptions.UnsupportedType) as e: conf.add('SECTION1_NAME', type=list) assert (e.value.type == 'list')<|docstring|>Tests the attempted use of an unsupported type throws an exception.<|endoftext|>
00334b64a7072d3b68539dcbdcea88dbbd16d6c8736b436f95a7d5a0066477ea
def test_default_values(config_with_defaults): '\n Tests a configuration initialized with defaults via a map and merging in\n a file.\n ' config_with_defaults.merge_file('tests/test2.conf') assert (config_with_defaults['shape'] == 'rectangle') assert (config_with_defaults['colour'] == 'blue') assert (config_with_defaults['upsidedown'] == False) assert (config_with_defaults['rightsideup'] == True) assert (config_with_defaults['section2']['count'] == 10) assert (config_with_defaults['section2']['ratio'] == 20.403) assert (config_with_defaults['section2']['z_index'] == 12)
Tests a configuration initialized with defaults via a map and merging in a file.
tests/test_basic.py
test_default_values
ComputeCanada/mergeconf
0
python
def test_default_values(config_with_defaults): '\n Tests a configuration initialized with defaults via a map and merging in\n a file.\n ' config_with_defaults.merge_file('tests/test2.conf') assert (config_with_defaults['shape'] == 'rectangle') assert (config_with_defaults['colour'] == 'blue') assert (config_with_defaults['upsidedown'] == False) assert (config_with_defaults['rightsideup'] == True) assert (config_with_defaults['section2']['count'] == 10) assert (config_with_defaults['section2']['ratio'] == 20.403) assert (config_with_defaults['section2']['z_index'] == 12)
def test_default_values(config_with_defaults): '\n Tests a configuration initialized with defaults via a map and merging in\n a file.\n ' config_with_defaults.merge_file('tests/test2.conf') assert (config_with_defaults['shape'] == 'rectangle') assert (config_with_defaults['colour'] == 'blue') assert (config_with_defaults['upsidedown'] == False) assert (config_with_defaults['rightsideup'] == True) assert (config_with_defaults['section2']['count'] == 10) assert (config_with_defaults['section2']['ratio'] == 20.403) assert (config_with_defaults['section2']['z_index'] == 12)<|docstring|>Tests a configuration initialized with defaults via a map and merging in a file.<|endoftext|>
300e4315000c706d41bd47461ee151d5b22656a4893c2e5b3a319e6e6d63d9f8
def test_add_with_defaults(config_with_defaults): '\n Tests a configuration initialized with defaults via a map.\n ' section2 = config_with_defaults.add_section('section2') section2.add('feels', value='heavy') section2.add('width', value=10) section2.add('transparent', value=False) section2.add('ferbity', value=4.2) section2.add('ferbs', value=[1, 2, 3, 4]) config_with_defaults.merge() assert (config_with_defaults['section2']['feels'] == 'heavy') assert (config_with_defaults['section2']['width'] == 10) assert (config_with_defaults['section2']['transparent'] == False) assert (config_with_defaults['section2']['ferbity'] == 4.2) assert (config_with_defaults['section2']['ferbs'] == '[1, 2, 3, 4]') assert (config_with_defaults.section2.ferbs == '[1, 2, 3, 4]')
Tests a configuration initialized with defaults via a map.
tests/test_basic.py
test_add_with_defaults
ComputeCanada/mergeconf
0
python
def test_add_with_defaults(config_with_defaults): '\n \n ' section2 = config_with_defaults.add_section('section2') section2.add('feels', value='heavy') section2.add('width', value=10) section2.add('transparent', value=False) section2.add('ferbity', value=4.2) section2.add('ferbs', value=[1, 2, 3, 4]) config_with_defaults.merge() assert (config_with_defaults['section2']['feels'] == 'heavy') assert (config_with_defaults['section2']['width'] == 10) assert (config_with_defaults['section2']['transparent'] == False) assert (config_with_defaults['section2']['ferbity'] == 4.2) assert (config_with_defaults['section2']['ferbs'] == '[1, 2, 3, 4]') assert (config_with_defaults.section2.ferbs == '[1, 2, 3, 4]')
def test_add_with_defaults(config_with_defaults): '\n \n ' section2 = config_with_defaults.add_section('section2') section2.add('feels', value='heavy') section2.add('width', value=10) section2.add('transparent', value=False) section2.add('ferbity', value=4.2) section2.add('ferbs', value=[1, 2, 3, 4]) config_with_defaults.merge() assert (config_with_defaults['section2']['feels'] == 'heavy') assert (config_with_defaults['section2']['width'] == 10) assert (config_with_defaults['section2']['transparent'] == False) assert (config_with_defaults['section2']['ferbity'] == 4.2) assert (config_with_defaults['section2']['ferbs'] == '[1, 2, 3, 4]') assert (config_with_defaults.section2.ferbs == '[1, 2, 3, 4]')<|docstring|>Tests a configuration initialized with defaults via a map.<|endoftext|>
ca4e93c158e90de11fc6bb061a9ecea4c490c1dd3254c3b8dfcfca70781805a0
def test_iterate_values(config_with_defaults): '\n Tests iteration through a configuration.\n ' config_with_defaults.merge_file('tests/test2.conf') print(config_with_defaults.to_dict()) it = iter(config_with_defaults) assert (next(it)[0] == 'colour') assert (next(it)[0] == 'shape') assert (next(it)[0] == 'name') assert (next(it)[0] == 'upsidedown') assert (next(it)[0] == 'rightsideup') for name in config_with_defaults.sections: assert (name == 'section2') section = config_with_defaults[name] it = iter(section) assert (next(it)[0] == 'count') assert (next(it)[0] == 'z_index') assert (next(it)[0] == 'ferbs') assert (next(it)[0] == 'ratio')
Tests iteration through a configuration.
tests/test_basic.py
test_iterate_values
ComputeCanada/mergeconf
0
python
def test_iterate_values(config_with_defaults): '\n \n ' config_with_defaults.merge_file('tests/test2.conf') print(config_with_defaults.to_dict()) it = iter(config_with_defaults) assert (next(it)[0] == 'colour') assert (next(it)[0] == 'shape') assert (next(it)[0] == 'name') assert (next(it)[0] == 'upsidedown') assert (next(it)[0] == 'rightsideup') for name in config_with_defaults.sections: assert (name == 'section2') section = config_with_defaults[name] it = iter(section) assert (next(it)[0] == 'count') assert (next(it)[0] == 'z_index') assert (next(it)[0] == 'ferbs') assert (next(it)[0] == 'ratio')
def test_iterate_values(config_with_defaults): '\n \n ' config_with_defaults.merge_file('tests/test2.conf') print(config_with_defaults.to_dict()) it = iter(config_with_defaults) assert (next(it)[0] == 'colour') assert (next(it)[0] == 'shape') assert (next(it)[0] == 'name') assert (next(it)[0] == 'upsidedown') assert (next(it)[0] == 'rightsideup') for name in config_with_defaults.sections: assert (name == 'section2') section = config_with_defaults[name] it = iter(section) assert (next(it)[0] == 'count') assert (next(it)[0] == 'z_index') assert (next(it)[0] == 'ferbs') assert (next(it)[0] == 'ratio')<|docstring|>Tests iteration through a configuration.<|endoftext|>
552d98d261faae54d5a66efc2946912885a1e9d46d22c2a78b348cd1c41b95a3
def test_unconfigured_section_allowed(config_not_strict): '\n Tests that an unconfigured section is caught and an exception thrown.\n ' config_not_strict.merge_file('tests/test3.conf') config_not_strict.validate() assert (config_not_strict['section2']['snurf'] == 'garbage') assert (config_not_strict['section3']['blarb'] == '32') assert (config_not_strict['section3']['snarf'] == 'this is the way the world ends')
Tests that an unconfigured section is caught and an exception thrown.
tests/test_basic.py
test_unconfigured_section_allowed
ComputeCanada/mergeconf
0
python
def test_unconfigured_section_allowed(config_not_strict): '\n \n ' config_not_strict.merge_file('tests/test3.conf') config_not_strict.validate() assert (config_not_strict['section2']['snurf'] == 'garbage') assert (config_not_strict['section3']['blarb'] == '32') assert (config_not_strict['section3']['snarf'] == 'this is the way the world ends')
def test_unconfigured_section_allowed(config_not_strict): '\n \n ' config_not_strict.merge_file('tests/test3.conf') config_not_strict.validate() assert (config_not_strict['section2']['snurf'] == 'garbage') assert (config_not_strict['section3']['blarb'] == '32') assert (config_not_strict['section3']['snarf'] == 'this is the way the world ends')<|docstring|>Tests that an unconfigured section is caught and an exception thrown.<|endoftext|>
92ded2897b25b7b73c6f7e0a8a49fbaf5f18f676cfdf7eb6787d94730d8e7533
def test_unconfigured_item_not_allowed(config_strict): '\n Tests that an unconfigured configuration item is caught and an exception thrown.\n ' with pytest.raises(mergeconf.exceptions.UndefinedConfiguration) as e: config_strict.merge_file('tests/test3.conf') config_strict.validate() assert (e.value.section == 'section2') assert (e.value.item == 'snurf')
Tests that an unconfigured configuration item is caught and an exception thrown.
tests/test_basic.py
test_unconfigured_item_not_allowed
ComputeCanada/mergeconf
0
python
def test_unconfigured_item_not_allowed(config_strict): '\n \n ' with pytest.raises(mergeconf.exceptions.UndefinedConfiguration) as e: config_strict.merge_file('tests/test3.conf') config_strict.validate() assert (e.value.section == 'section2') assert (e.value.item == 'snurf')
def test_unconfigured_item_not_allowed(config_strict): '\n \n ' with pytest.raises(mergeconf.exceptions.UndefinedConfiguration) as e: config_strict.merge_file('tests/test3.conf') config_strict.validate() assert (e.value.section == 'section2') assert (e.value.item == 'snurf')<|docstring|>Tests that an unconfigured configuration item is caught and an exception thrown.<|endoftext|>
3619079b41f8b3a6b72f317459c69c1a9dd82421b1d539d118f9e26900bae654
def test_unconfigured_section_not_allowed(config_strict): '\n Tests that an unconfigured configuration section is caught and an exception thrown.\n ' with pytest.raises(mergeconf.exceptions.UndefinedSection) as e: config_strict.merge_file('tests/test4.conf') config_strict.validate() assert (e.value.section == 'section3')
Tests that an unconfigured configuration section is caught and an exception thrown.
tests/test_basic.py
test_unconfigured_section_not_allowed
ComputeCanada/mergeconf
0
python
def test_unconfigured_section_not_allowed(config_strict): '\n \n ' with pytest.raises(mergeconf.exceptions.UndefinedSection) as e: config_strict.merge_file('tests/test4.conf') config_strict.validate() assert (e.value.section == 'section3')
def test_unconfigured_section_not_allowed(config_strict): '\n \n ' with pytest.raises(mergeconf.exceptions.UndefinedSection) as e: config_strict.merge_file('tests/test4.conf') config_strict.validate() assert (e.value.section == 'section3')<|docstring|>Tests that an unconfigured configuration section is caught and an exception thrown.<|endoftext|>
45f0fd02060a77daf727454ca9170002eec40f53050d993772d2d1c2bff1bdd4
def test_garbage_item_by_index(config): '\n Tests that attempted access of undefined variable results in an exception.\n ' config.merge() with pytest.raises(KeyError): print(config['whut'])
Tests that attempted access of undefined variable results in an exception.
tests/test_basic.py
test_garbage_item_by_index
ComputeCanada/mergeconf
0
python
def test_garbage_item_by_index(config): '\n \n ' config.merge() with pytest.raises(KeyError): print(config['whut'])
def test_garbage_item_by_index(config): '\n \n ' config.merge() with pytest.raises(KeyError): print(config['whut'])<|docstring|>Tests that attempted access of undefined variable results in an exception.<|endoftext|>
aaabb6b6607640b31d1657c5d77eaefb468ff297457d2ff5cc62edb15e3a32c1
def test_garbage_item_by_attribute(config): '\n Tests that attempted access of undefined variable results in an exception.\n ' config.merge() with pytest.raises(AttributeError): print(config.whut)
Tests that attempted access of undefined variable results in an exception.
tests/test_basic.py
test_garbage_item_by_attribute
ComputeCanada/mergeconf
0
python
def test_garbage_item_by_attribute(config): '\n \n ' config.merge() with pytest.raises(AttributeError): print(config.whut)
def test_garbage_item_by_attribute(config): '\n \n ' config.merge() with pytest.raises(AttributeError): print(config.whut)<|docstring|>Tests that attempted access of undefined variable results in an exception.<|endoftext|>
416010738ae8cc0e916477925b9dc309c94ac2043babece77675da41e2ca0a0f
def test_map(config): '\n Tests the map() function by building a list of mandatory configuration\n items.\n ' config.merge() def mandatories(sections, name, item): if item.mandatory: return f"{(('.'.join(sections) + '.') if sections else '')}{name}" return None res = config.map(mandatories) print(res) assert (res == ['shape', 'section2.count'])
Tests the map() function by building a list of mandatory configuration items.
tests/test_basic.py
test_map
ComputeCanada/mergeconf
0
python
def test_map(config): '\n Tests the map() function by building a list of mandatory configuration\n items.\n ' config.merge() def mandatories(sections, name, item): if item.mandatory: return f"{(('.'.join(sections) + '.') if sections else )}{name}" return None res = config.map(mandatories) print(res) assert (res == ['shape', 'section2.count'])
def test_map(config): '\n Tests the map() function by building a list of mandatory configuration\n items.\n ' config.merge() def mandatories(sections, name, item): if item.mandatory: return f"{(('.'.join(sections) + '.') if sections else )}{name}" return None res = config.map(mandatories) print(res) assert (res == ['shape', 'section2.count'])<|docstring|>Tests the map() function by building a list of mandatory configuration items.<|endoftext|>
e16572b5d34908074813c70193d69659325a0b7b32f769369756b81645a620d7
def test_args(config, argparser): '\n Tests that argument parsing is set up appropriately.\n ' config.config_argparser(argparser) args = argparser.parse_args(['--shape=square', '--upsidedown', '--section2-count=12']) assert (argparser.format_usage() == 'usage: test [-h] [-c CONFIG] [-d] [-q] [--shape SHAPE] [--colour COLOUR]\n [--upsidedown] [--rightsideup] [--section1-fluff FLUFF]\n [--section2-count COUNT] [--section2-ratio RATIO]\n') config.merge(args) assert (config.shape == 'square') assert (config.section1.fluff == 'light') assert (config.section2.count == 12) assert (config.upsidedown is True) assert (config.rightsideup is True) assert (config.debug is False) with pytest.raises(AttributeError): assert (config.whatnow is None)
Tests that argument parsing is set up appropriately.
tests/test_basic.py
test_args
ComputeCanada/mergeconf
0
python
def test_args(config, argparser): '\n \n ' config.config_argparser(argparser) args = argparser.parse_args(['--shape=square', '--upsidedown', '--section2-count=12']) assert (argparser.format_usage() == 'usage: test [-h] [-c CONFIG] [-d] [-q] [--shape SHAPE] [--colour COLOUR]\n [--upsidedown] [--rightsideup] [--section1-fluff FLUFF]\n [--section2-count COUNT] [--section2-ratio RATIO]\n') config.merge(args) assert (config.shape == 'square') assert (config.section1.fluff == 'light') assert (config.section2.count == 12) assert (config.upsidedown is True) assert (config.rightsideup is True) assert (config.debug is False) with pytest.raises(AttributeError): assert (config.whatnow is None)
def test_args(config, argparser): '\n \n ' config.config_argparser(argparser) args = argparser.parse_args(['--shape=square', '--upsidedown', '--section2-count=12']) assert (argparser.format_usage() == 'usage: test [-h] [-c CONFIG] [-d] [-q] [--shape SHAPE] [--colour COLOUR]\n [--upsidedown] [--rightsideup] [--section1-fluff FLUFF]\n [--section2-count COUNT] [--section2-ratio RATIO]\n') config.merge(args) assert (config.shape == 'square') assert (config.section1.fluff == 'light') assert (config.section2.count == 12) assert (config.upsidedown is True) assert (config.rightsideup is True) assert (config.debug is False) with pytest.raises(AttributeError): assert (config.whatnow is None)<|docstring|>Tests that argument parsing is set up appropriately.<|endoftext|>
6abeed1a2d3306e13d056a59265174411c6dc769f552bc30e6bea7cbabfe6326
def test_sample_config(config): '\n Test that the sample configuration is generated correctly.\n ' sample_config = config.sample_config() print('Sample configuration:\n\n```') print(sample_config) print('```') assert (sample_config == "# (str) Unique name for the thing\n#name =\n\n# (str) The shape of the thing\nshape =\n\n# (str) The colour of the thing\n#colour = black\n\n# (bool) Upside-downness of the thing\n#upsidedown =\n\n# (bool) Is this thing right-side-up\n#rightsideup = True\n\n[section1]\n# (str) What level of fluffiness does this item exhibit\n#fluff = light\n\n# (int) It's hard to come up with examples\n#density =\n\n[section2]\n# (int) How many of the thing\ncount =\n\n# (float) The ratio of thing to thang\n#ratio =")
Test that the sample configuration is generated correctly.
tests/test_basic.py
test_sample_config
ComputeCanada/mergeconf
0
python
def test_sample_config(config): '\n \n ' sample_config = config.sample_config() print('Sample configuration:\n\n```') print(sample_config) print('```') assert (sample_config == "# (str) Unique name for the thing\n#name =\n\n# (str) The shape of the thing\nshape =\n\n# (str) The colour of the thing\n#colour = black\n\n# (bool) Upside-downness of the thing\n#upsidedown =\n\n# (bool) Is this thing right-side-up\n#rightsideup = True\n\n[section1]\n# (str) What level of fluffiness does this item exhibit\n#fluff = light\n\n# (int) It's hard to come up with examples\n#density =\n\n[section2]\n# (int) How many of the thing\ncount =\n\n# (float) The ratio of thing to thang\n#ratio =")
def test_sample_config(config): '\n \n ' sample_config = config.sample_config() print('Sample configuration:\n\n```') print(sample_config) print('```') assert (sample_config == "# (str) Unique name for the thing\n#name =\n\n# (str) The shape of the thing\nshape =\n\n# (str) The colour of the thing\n#colour = black\n\n# (bool) Upside-downness of the thing\n#upsidedown =\n\n# (bool) Is this thing right-side-up\n#rightsideup = True\n\n[section1]\n# (str) What level of fluffiness does this item exhibit\n#fluff = light\n\n# (int) It's hard to come up with examples\n#density =\n\n[section2]\n# (int) How many of the thing\ncount =\n\n# (float) The ratio of thing to thang\n#ratio =")<|docstring|>Test that the sample configuration is generated correctly.<|endoftext|>
238c416d4dea4469dda006fb275fe125fca501e487e4ab7f1a12c17e1eb49040
def DrosophilaPseudoobscura(directed: bool=False, verbose: int=2, cache_path: str='graphs/string', **additional_graph_kwargs: Dict) -> EnsmallenGraph: 'Return new instance of the Drosophila pseudoobscura graph.\n\n The graph is automatically retrieved from the STRING repository. \n\n\t\n\n Parameters\n -------------------\n directed: bool = False,\n Wether to load the graph as directed or undirected.\n By default false.\n verbose: int = 2,\n Wether to show loading bars during the retrieval and building\n of the graph.\n cache_path: str = "graphs",\n Where to store the downloaded graphs.\n additional_graph_kwargs: Dict,\n Additional graph kwargs.\n\n Returns\n -----------------------\n Instace of Drosophila pseudoobscura graph.\n\n\tReport\n\t---------------------\n\tAt the time of rendering these methods (please see datetime below), the graph\n\thad the following characteristics:\n\t\n\tDatetime: 2021-02-02 17:22:18.103683\n\t\n\tThe undirected graph Drosophila pseudoobscura has 12603 nodes and 1334490\n\tweighted edges, of which none are self-loops. The graph is dense as it\n\thas a density of 0.01680 and has 11 connected components, where the component\n\twith most nodes has 12582 nodes and the component with the least nodes\n\thas 2 nodes. The graph median node degree is 131, the mean node degree\n\tis 211.77, and the node degree mode is 1. The top 5 most central nodes\n\tare 7237.FBpp0283442 (degree 3162), 7237.FBpp0281325 (degree 2389), 7237.FBpp0285259\n\t(degree 2280), 7237.FBpp0282015 (degree 2146) and 7237.FBpp0279413 (degree\n\t2103).\n\t\n\n\tReferences\n\t---------------------\n\tPlease cite the following if you use the data:\n\t\n\t@article{szklarczyk2019string,\n\t title={STRING v11: protein--protein association networks with increased coverage, supporting functional discovery in genome-wide experimental datasets},\n\t author={Szklarczyk, Damian and Gable, Annika L and Lyon, David and Junge, Alexander and Wyder, Stefan and Huerta-Cepas, Jaime and Simonovic, Milan and Doncheva, Nadezhda T and Morris, John H and Bork, Peer and others},\n\t journal={Nucleic acids research},\n\t volume={47},\n\t number={D1},\n\t pages={D607--D613},\n\t year={2019},\n\t publisher={Oxford University Press}\n\t}\n\t\n\n\tUsage example\n\t----------------------\n\tThe usage of this graph is relatively straightforward:\n\t\n\t.. code:: python\n\t\n\t # First import the function to retrieve the graph from the datasets\n\t from ensmallen_graph.datasets.string import DrosophilaPseudoobscura\n\t\n\t # Then load the graph\n\t graph = DrosophilaPseudoobscura()\n\t\n\t # Finally, you can do anything with it, for instance, compute its report:\n\t print(graph)\n\t\n\t # If you need to run a link prediction task with validation,\n\t # you can split the graph using a connected holdout as follows:\n\t train_graph, validation_graph = graph.connected_holdout(\n\t # You can use an 80/20 split the holdout, for example.\n\t train_size=0.8,\n\t # The random state is used to reproduce the holdout.\n\t random_state=42,\n\t # Wether to show a loading bar.\n\t verbose=True\n\t )\n\t\n\t # Remember that, if you need, you can enable the memory-time trade-offs:\n\t train_graph.enable(\n\t vector_sources=True,\n\t vector_destinations=True,\n\t vector_outbounds=True\n\t )\n\t\n\t # Consider using the methods made available in the Embiggen package\n\t # to run graph embedding or link prediction tasks.\n ' return AutomaticallyRetrievedGraph(graph_name='DrosophilaPseudoobscura', dataset='string', directed=directed, verbose=verbose, cache_path=cache_path, additional_graph_kwargs=additional_graph_kwargs)()
Return new instance of the Drosophila pseudoobscura graph. The graph is automatically retrieved from the STRING repository. Parameters ------------------- directed: bool = False, Wether to load the graph as directed or undirected. By default false. verbose: int = 2, Wether to show loading bars during the retrieval and building of the graph. cache_path: str = "graphs", Where to store the downloaded graphs. additional_graph_kwargs: Dict, Additional graph kwargs. Returns ----------------------- Instace of Drosophila pseudoobscura graph. Report --------------------- At the time of rendering these methods (please see datetime below), the graph had the following characteristics: Datetime: 2021-02-02 17:22:18.103683 The undirected graph Drosophila pseudoobscura has 12603 nodes and 1334490 weighted edges, of which none are self-loops. The graph is dense as it has a density of 0.01680 and has 11 connected components, where the component with most nodes has 12582 nodes and the component with the least nodes has 2 nodes. The graph median node degree is 131, the mean node degree is 211.77, and the node degree mode is 1. The top 5 most central nodes are 7237.FBpp0283442 (degree 3162), 7237.FBpp0281325 (degree 2389), 7237.FBpp0285259 (degree 2280), 7237.FBpp0282015 (degree 2146) and 7237.FBpp0279413 (degree 2103). References --------------------- Please cite the following if you use the data: @article{szklarczyk2019string, title={STRING v11: protein--protein association networks with increased coverage, supporting functional discovery in genome-wide experimental datasets}, author={Szklarczyk, Damian and Gable, Annika L and Lyon, David and Junge, Alexander and Wyder, Stefan and Huerta-Cepas, Jaime and Simonovic, Milan and Doncheva, Nadezhda T and Morris, John H and Bork, Peer and others}, journal={Nucleic acids research}, volume={47}, number={D1}, pages={D607--D613}, year={2019}, publisher={Oxford University Press} } Usage example ---------------------- The usage of this graph is relatively straightforward: .. code:: python # First import the function to retrieve the graph from the datasets from ensmallen_graph.datasets.string import DrosophilaPseudoobscura # Then load the graph graph = DrosophilaPseudoobscura() # Finally, you can do anything with it, for instance, compute its report: print(graph) # If you need to run a link prediction task with validation, # you can split the graph using a connected holdout as follows: train_graph, validation_graph = graph.connected_holdout( # You can use an 80/20 split the holdout, for example. train_size=0.8, # The random state is used to reproduce the holdout. random_state=42, # Wether to show a loading bar. verbose=True ) # Remember that, if you need, you can enable the memory-time trade-offs: train_graph.enable( vector_sources=True, vector_destinations=True, vector_outbounds=True ) # Consider using the methods made available in the Embiggen package # to run graph embedding or link prediction tasks.
bindings/python/ensmallen_graph/datasets/string/drosophilapseudoobscura.py
DrosophilaPseudoobscura
caufieldjh/ensmallen_graph
0
python
def DrosophilaPseudoobscura(directed: bool=False, verbose: int=2, cache_path: str='graphs/string', **additional_graph_kwargs: Dict) -> EnsmallenGraph: 'Return new instance of the Drosophila pseudoobscura graph.\n\n The graph is automatically retrieved from the STRING repository. \n\n\t\n\n Parameters\n -------------------\n directed: bool = False,\n Wether to load the graph as directed or undirected.\n By default false.\n verbose: int = 2,\n Wether to show loading bars during the retrieval and building\n of the graph.\n cache_path: str = "graphs",\n Where to store the downloaded graphs.\n additional_graph_kwargs: Dict,\n Additional graph kwargs.\n\n Returns\n -----------------------\n Instace of Drosophila pseudoobscura graph.\n\n\tReport\n\t---------------------\n\tAt the time of rendering these methods (please see datetime below), the graph\n\thad the following characteristics:\n\t\n\tDatetime: 2021-02-02 17:22:18.103683\n\t\n\tThe undirected graph Drosophila pseudoobscura has 12603 nodes and 1334490\n\tweighted edges, of which none are self-loops. The graph is dense as it\n\thas a density of 0.01680 and has 11 connected components, where the component\n\twith most nodes has 12582 nodes and the component with the least nodes\n\thas 2 nodes. The graph median node degree is 131, the mean node degree\n\tis 211.77, and the node degree mode is 1. The top 5 most central nodes\n\tare 7237.FBpp0283442 (degree 3162), 7237.FBpp0281325 (degree 2389), 7237.FBpp0285259\n\t(degree 2280), 7237.FBpp0282015 (degree 2146) and 7237.FBpp0279413 (degree\n\t2103).\n\t\n\n\tReferences\n\t---------------------\n\tPlease cite the following if you use the data:\n\t\n\t@article{szklarczyk2019string,\n\t title={STRING v11: protein--protein association networks with increased coverage, supporting functional discovery in genome-wide experimental datasets},\n\t author={Szklarczyk, Damian and Gable, Annika L and Lyon, David and Junge, Alexander and Wyder, Stefan and Huerta-Cepas, Jaime and Simonovic, Milan and Doncheva, Nadezhda T and Morris, John H and Bork, Peer and others},\n\t journal={Nucleic acids research},\n\t volume={47},\n\t number={D1},\n\t pages={D607--D613},\n\t year={2019},\n\t publisher={Oxford University Press}\n\t}\n\t\n\n\tUsage example\n\t----------------------\n\tThe usage of this graph is relatively straightforward:\n\t\n\t.. code:: python\n\t\n\t # First import the function to retrieve the graph from the datasets\n\t from ensmallen_graph.datasets.string import DrosophilaPseudoobscura\n\t\n\t # Then load the graph\n\t graph = DrosophilaPseudoobscura()\n\t\n\t # Finally, you can do anything with it, for instance, compute its report:\n\t print(graph)\n\t\n\t # If you need to run a link prediction task with validation,\n\t # you can split the graph using a connected holdout as follows:\n\t train_graph, validation_graph = graph.connected_holdout(\n\t # You can use an 80/20 split the holdout, for example.\n\t train_size=0.8,\n\t # The random state is used to reproduce the holdout.\n\t random_state=42,\n\t # Wether to show a loading bar.\n\t verbose=True\n\t )\n\t\n\t # Remember that, if you need, you can enable the memory-time trade-offs:\n\t train_graph.enable(\n\t vector_sources=True,\n\t vector_destinations=True,\n\t vector_outbounds=True\n\t )\n\t\n\t # Consider using the methods made available in the Embiggen package\n\t # to run graph embedding or link prediction tasks.\n ' return AutomaticallyRetrievedGraph(graph_name='DrosophilaPseudoobscura', dataset='string', directed=directed, verbose=verbose, cache_path=cache_path, additional_graph_kwargs=additional_graph_kwargs)()
def DrosophilaPseudoobscura(directed: bool=False, verbose: int=2, cache_path: str='graphs/string', **additional_graph_kwargs: Dict) -> EnsmallenGraph: 'Return new instance of the Drosophila pseudoobscura graph.\n\n The graph is automatically retrieved from the STRING repository. \n\n\t\n\n Parameters\n -------------------\n directed: bool = False,\n Wether to load the graph as directed or undirected.\n By default false.\n verbose: int = 2,\n Wether to show loading bars during the retrieval and building\n of the graph.\n cache_path: str = "graphs",\n Where to store the downloaded graphs.\n additional_graph_kwargs: Dict,\n Additional graph kwargs.\n\n Returns\n -----------------------\n Instace of Drosophila pseudoobscura graph.\n\n\tReport\n\t---------------------\n\tAt the time of rendering these methods (please see datetime below), the graph\n\thad the following characteristics:\n\t\n\tDatetime: 2021-02-02 17:22:18.103683\n\t\n\tThe undirected graph Drosophila pseudoobscura has 12603 nodes and 1334490\n\tweighted edges, of which none are self-loops. The graph is dense as it\n\thas a density of 0.01680 and has 11 connected components, where the component\n\twith most nodes has 12582 nodes and the component with the least nodes\n\thas 2 nodes. The graph median node degree is 131, the mean node degree\n\tis 211.77, and the node degree mode is 1. The top 5 most central nodes\n\tare 7237.FBpp0283442 (degree 3162), 7237.FBpp0281325 (degree 2389), 7237.FBpp0285259\n\t(degree 2280), 7237.FBpp0282015 (degree 2146) and 7237.FBpp0279413 (degree\n\t2103).\n\t\n\n\tReferences\n\t---------------------\n\tPlease cite the following if you use the data:\n\t\n\t@article{szklarczyk2019string,\n\t title={STRING v11: protein--protein association networks with increased coverage, supporting functional discovery in genome-wide experimental datasets},\n\t author={Szklarczyk, Damian and Gable, Annika L and Lyon, David and Junge, Alexander and Wyder, Stefan and Huerta-Cepas, Jaime and Simonovic, Milan and Doncheva, Nadezhda T and Morris, John H and Bork, Peer and others},\n\t journal={Nucleic acids research},\n\t volume={47},\n\t number={D1},\n\t pages={D607--D613},\n\t year={2019},\n\t publisher={Oxford University Press}\n\t}\n\t\n\n\tUsage example\n\t----------------------\n\tThe usage of this graph is relatively straightforward:\n\t\n\t.. code:: python\n\t\n\t # First import the function to retrieve the graph from the datasets\n\t from ensmallen_graph.datasets.string import DrosophilaPseudoobscura\n\t\n\t # Then load the graph\n\t graph = DrosophilaPseudoobscura()\n\t\n\t # Finally, you can do anything with it, for instance, compute its report:\n\t print(graph)\n\t\n\t # If you need to run a link prediction task with validation,\n\t # you can split the graph using a connected holdout as follows:\n\t train_graph, validation_graph = graph.connected_holdout(\n\t # You can use an 80/20 split the holdout, for example.\n\t train_size=0.8,\n\t # The random state is used to reproduce the holdout.\n\t random_state=42,\n\t # Wether to show a loading bar.\n\t verbose=True\n\t )\n\t\n\t # Remember that, if you need, you can enable the memory-time trade-offs:\n\t train_graph.enable(\n\t vector_sources=True,\n\t vector_destinations=True,\n\t vector_outbounds=True\n\t )\n\t\n\t # Consider using the methods made available in the Embiggen package\n\t # to run graph embedding or link prediction tasks.\n ' return AutomaticallyRetrievedGraph(graph_name='DrosophilaPseudoobscura', dataset='string', directed=directed, verbose=verbose, cache_path=cache_path, additional_graph_kwargs=additional_graph_kwargs)()<|docstring|>Return new instance of the Drosophila pseudoobscura graph. The graph is automatically retrieved from the STRING repository. Parameters ------------------- directed: bool = False, Wether to load the graph as directed or undirected. By default false. verbose: int = 2, Wether to show loading bars during the retrieval and building of the graph. cache_path: str = "graphs", Where to store the downloaded graphs. additional_graph_kwargs: Dict, Additional graph kwargs. Returns ----------------------- Instace of Drosophila pseudoobscura graph. Report --------------------- At the time of rendering these methods (please see datetime below), the graph had the following characteristics: Datetime: 2021-02-02 17:22:18.103683 The undirected graph Drosophila pseudoobscura has 12603 nodes and 1334490 weighted edges, of which none are self-loops. The graph is dense as it has a density of 0.01680 and has 11 connected components, where the component with most nodes has 12582 nodes and the component with the least nodes has 2 nodes. The graph median node degree is 131, the mean node degree is 211.77, and the node degree mode is 1. The top 5 most central nodes are 7237.FBpp0283442 (degree 3162), 7237.FBpp0281325 (degree 2389), 7237.FBpp0285259 (degree 2280), 7237.FBpp0282015 (degree 2146) and 7237.FBpp0279413 (degree 2103). References --------------------- Please cite the following if you use the data: @article{szklarczyk2019string, title={STRING v11: protein--protein association networks with increased coverage, supporting functional discovery in genome-wide experimental datasets}, author={Szklarczyk, Damian and Gable, Annika L and Lyon, David and Junge, Alexander and Wyder, Stefan and Huerta-Cepas, Jaime and Simonovic, Milan and Doncheva, Nadezhda T and Morris, John H and Bork, Peer and others}, journal={Nucleic acids research}, volume={47}, number={D1}, pages={D607--D613}, year={2019}, publisher={Oxford University Press} } Usage example ---------------------- The usage of this graph is relatively straightforward: .. code:: python # First import the function to retrieve the graph from the datasets from ensmallen_graph.datasets.string import DrosophilaPseudoobscura # Then load the graph graph = DrosophilaPseudoobscura() # Finally, you can do anything with it, for instance, compute its report: print(graph) # If you need to run a link prediction task with validation, # you can split the graph using a connected holdout as follows: train_graph, validation_graph = graph.connected_holdout( # You can use an 80/20 split the holdout, for example. train_size=0.8, # The random state is used to reproduce the holdout. random_state=42, # Wether to show a loading bar. verbose=True ) # Remember that, if you need, you can enable the memory-time trade-offs: train_graph.enable( vector_sources=True, vector_destinations=True, vector_outbounds=True ) # Consider using the methods made available in the Embiggen package # to run graph embedding or link prediction tasks.<|endoftext|>
3006fa4d72a36eb07543d3fe0d31362ea86ee2229dd3af10465533a1345d3388
def test_new_1d(self): 'Create a 1d fiber' a = Fiber([2, 4, 6], [3, 5, 7])
Create a 1d fiber
test/test_fiber.py
test_new_1d
Fibertree-Project/fibertree
2
python
def test_new_1d(self): a = Fiber([2, 4, 6], [3, 5, 7])
def test_new_1d(self): a = Fiber([2, 4, 6], [3, 5, 7])<|docstring|>Create a 1d fiber<|endoftext|>
46144b487028a2f29e2a3614af3a17cdd6268a3069c15ee9377cef735b04aead
def test_new_2d(self): 'Create a 1d fiber' b0 = Fiber([1, 4, 7], [2, 5, 8]) b1 = Fiber([2, 4, 6], [3, 5, 7]) a0 = Fiber([2, 4], [b0, b1])
Create a 1d fiber
test/test_fiber.py
test_new_2d
Fibertree-Project/fibertree
2
python
def test_new_2d(self): b0 = Fiber([1, 4, 7], [2, 5, 8]) b1 = Fiber([2, 4, 6], [3, 5, 7]) a0 = Fiber([2, 4], [b0, b1])
def test_new_2d(self): b0 = Fiber([1, 4, 7], [2, 5, 8]) b1 = Fiber([2, 4, 6], [3, 5, 7]) a0 = Fiber([2, 4], [b0, b1])<|docstring|>Create a 1d fiber<|endoftext|>
871ba4f9d3f578bfe3bf5b09541a0fd4ce0ae73466c07fdb23147c1bad08c00a
def test_new_empty(self): 'Create an empty fiber' a = Fiber([], [])
Create an empty fiber
test/test_fiber.py
test_new_empty
Fibertree-Project/fibertree
2
python
def test_new_empty(self): a = Fiber([], [])
def test_new_empty(self): a = Fiber([], [])<|docstring|>Create an empty fiber<|endoftext|>
5722e834303797a5aa7d34d87d3e98a57b55a22ca37d876ef9d39e0b0f3bd242
def test_fromYAMLfile_1D(self): 'Read a YAMLfile 1-D' a_ref = Fiber([2, 4, 6], [3, 5, 7]) a = Fiber.fromYAMLfile('./data/test_fiber-1.yaml') self.assertEqual(a, a_ref)
Read a YAMLfile 1-D
test/test_fiber.py
test_fromYAMLfile_1D
Fibertree-Project/fibertree
2
python
def test_fromYAMLfile_1D(self): a_ref = Fiber([2, 4, 6], [3, 5, 7]) a = Fiber.fromYAMLfile('./data/test_fiber-1.yaml') self.assertEqual(a, a_ref)
def test_fromYAMLfile_1D(self): a_ref = Fiber([2, 4, 6], [3, 5, 7]) a = Fiber.fromYAMLfile('./data/test_fiber-1.yaml') self.assertEqual(a, a_ref)<|docstring|>Read a YAMLfile 1-D<|endoftext|>
8365a80c3d3ef6e0f2d4bebe32e22da5350fc003c6806f368ec2a2a8a1f0ad25
def test_fromYAMLfile_2D(self): 'Read a YAMLfile 2-D' b0 = Fiber([1, 4, 7], [2, 5, 8]) b1 = Fiber([2, 4, 6], [3, 5, 7]) a_ref = Fiber([2, 4], [b0, b1]) a = Fiber.fromYAMLfile('./data/test_fiber-2.yaml') self.assertEqual(a, a_ref)
Read a YAMLfile 2-D
test/test_fiber.py
test_fromYAMLfile_2D
Fibertree-Project/fibertree
2
python
def test_fromYAMLfile_2D(self): b0 = Fiber([1, 4, 7], [2, 5, 8]) b1 = Fiber([2, 4, 6], [3, 5, 7]) a_ref = Fiber([2, 4], [b0, b1]) a = Fiber.fromYAMLfile('./data/test_fiber-2.yaml') self.assertEqual(a, a_ref)
def test_fromYAMLfile_2D(self): b0 = Fiber([1, 4, 7], [2, 5, 8]) b1 = Fiber([2, 4, 6], [3, 5, 7]) a_ref = Fiber([2, 4], [b0, b1]) a = Fiber.fromYAMLfile('./data/test_fiber-2.yaml') self.assertEqual(a, a_ref)<|docstring|>Read a YAMLfile 2-D<|endoftext|>
5f148d32a96022493d4a927067b6529197bc07d180bec83636445a8b55b68e02
def test_fromUncompressed_1D(self): 'Create from uncompressed 1-D' f_ref = Fiber([0, 1, 3, 4], [1, 2, 4, 5]) f = Fiber.fromUncompressed([1, 2, 0, 4, 5, 0]) self.assertEqual(f, f_ref)
Create from uncompressed 1-D
test/test_fiber.py
test_fromUncompressed_1D
Fibertree-Project/fibertree
2
python
def test_fromUncompressed_1D(self): f_ref = Fiber([0, 1, 3, 4], [1, 2, 4, 5]) f = Fiber.fromUncompressed([1, 2, 0, 4, 5, 0]) self.assertEqual(f, f_ref)
def test_fromUncompressed_1D(self): f_ref = Fiber([0, 1, 3, 4], [1, 2, 4, 5]) f = Fiber.fromUncompressed([1, 2, 0, 4, 5, 0]) self.assertEqual(f, f_ref)<|docstring|>Create from uncompressed 1-D<|endoftext|>
b60e75980d791435f2d37cab80cb4cd5cf4adfca18764b67d08b54b4f5de07fd
def test_fromUncompressed_2D(self): 'Create from uncompressed 2-D' a1 = Fiber([0, 1, 3, 4], [1, 2, 4, 5]) a2 = Fiber([2, 3], [3, 4]) f_ref = Fiber([0, 2], [a1, a2]) f = Fiber.fromUncompressed([[1, 2, 0, 4, 5, 0], [0, 0, 0, 0, 0, 0], [0, 0, 3, 4, 0, 0]]) self.assertEqual(f, f_ref)
Create from uncompressed 2-D
test/test_fiber.py
test_fromUncompressed_2D
Fibertree-Project/fibertree
2
python
def test_fromUncompressed_2D(self): a1 = Fiber([0, 1, 3, 4], [1, 2, 4, 5]) a2 = Fiber([2, 3], [3, 4]) f_ref = Fiber([0, 2], [a1, a2]) f = Fiber.fromUncompressed([[1, 2, 0, 4, 5, 0], [0, 0, 0, 0, 0, 0], [0, 0, 3, 4, 0, 0]]) self.assertEqual(f, f_ref)
def test_fromUncompressed_2D(self): a1 = Fiber([0, 1, 3, 4], [1, 2, 4, 5]) a2 = Fiber([2, 3], [3, 4]) f_ref = Fiber([0, 2], [a1, a2]) f = Fiber.fromUncompressed([[1, 2, 0, 4, 5, 0], [0, 0, 0, 0, 0, 0], [0, 0, 3, 4, 0, 0]]) self.assertEqual(f, f_ref)<|docstring|>Create from uncompressed 2-D<|endoftext|>
4e47f0bc1bcc3d9a1589ae758c714e18dfd676e7fc039713ff42377a39ad096a
def test_fromUncompressed_3D(self): 'Create from uncomrpessed 3-D' f_ref = Fiber.fromYAMLfile('./data/test_fiber-3.yaml') u_t = [[[1, 2, 3, 0], [1, 0, 3, 4], [0, 2, 3, 4], [1, 2, 0, 4]], [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]], [[1, 2, 3, 0], [1, 0, 3, 4], [0, 0, 0, 0], [1, 2, 0, 4]]] f = Fiber.fromUncompressed(u_t) self.assertEqual(f, f_ref)
Create from uncomrpessed 3-D
test/test_fiber.py
test_fromUncompressed_3D
Fibertree-Project/fibertree
2
python
def test_fromUncompressed_3D(self): f_ref = Fiber.fromYAMLfile('./data/test_fiber-3.yaml') u_t = [[[1, 2, 3, 0], [1, 0, 3, 4], [0, 2, 3, 4], [1, 2, 0, 4]], [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]], [[1, 2, 3, 0], [1, 0, 3, 4], [0, 0, 0, 0], [1, 2, 0, 4]]] f = Fiber.fromUncompressed(u_t) self.assertEqual(f, f_ref)
def test_fromUncompressed_3D(self): f_ref = Fiber.fromYAMLfile('./data/test_fiber-3.yaml') u_t = [[[1, 2, 3, 0], [1, 0, 3, 4], [0, 2, 3, 4], [1, 2, 0, 4]], [[0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0], [0, 0, 0, 0]], [[1, 2, 3, 0], [1, 0, 3, 4], [0, 0, 0, 0], [1, 2, 0, 4]]] f = Fiber.fromUncompressed(u_t) self.assertEqual(f, f_ref)<|docstring|>Create from uncomrpessed 3-D<|endoftext|>
f904ffb6a494aad24b2e9b3dd5e9196b31e65cd4471edacf92c3deb451af5a51
def test_fromUncompressed_1D_empty(self): 'Create empty tensor from uncompressed 1-D' f_ref = Fiber([], []) f = Fiber.fromUncompressed([0, 0, 0, 0, 0]) self.assertEqual(f, f_ref)
Create empty tensor from uncompressed 1-D
test/test_fiber.py
test_fromUncompressed_1D_empty
Fibertree-Project/fibertree
2
python
def test_fromUncompressed_1D_empty(self): f_ref = Fiber([], []) f = Fiber.fromUncompressed([0, 0, 0, 0, 0]) self.assertEqual(f, f_ref)
def test_fromUncompressed_1D_empty(self): f_ref = Fiber([], []) f = Fiber.fromUncompressed([0, 0, 0, 0, 0]) self.assertEqual(f, f_ref)<|docstring|>Create empty tensor from uncompressed 1-D<|endoftext|>
4cb4d487dad354e5fa496f6428854680a6b49ae5f499f29b46742d8f96424c8f
def test_fromUncompressed_2D_empty(self): 'Create empty tensor from uncompressed 2-D' f_ref = Fiber([], []) f = Fiber.fromUncompressed([[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]) self.assertEqual(f, f_ref)
Create empty tensor from uncompressed 2-D
test/test_fiber.py
test_fromUncompressed_2D_empty
Fibertree-Project/fibertree
2
python
def test_fromUncompressed_2D_empty(self): f_ref = Fiber([], []) f = Fiber.fromUncompressed([[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]) self.assertEqual(f, f_ref)
def test_fromUncompressed_2D_empty(self): f_ref = Fiber([], []) f = Fiber.fromUncompressed([[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0]]) self.assertEqual(f, f_ref)<|docstring|>Create empty tensor from uncompressed 2-D<|endoftext|>
f214410212bc7c3300c0bbe3ded6b9abe2feddd913284db870fb7123c7136ca5
def test_fromRandom_2D(self): 'Create a random 2D tensor' shape = [10, 10] fiber_ref = Fiber.fromUncompressed([[0, 10, 10, 1, 0, 9, 8, 0, 0, 3], [9, 1, 0, 10, 1, 0, 10, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 3, 0, 3, 5, 0, 5, 7, 0, 0], [6, 0, 0, 0, 0, 0, 6, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 2, 8, 2, 3, 7, 0, 0, 10], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 4, 0, 2, 9, 4, 0, 5], [6, 3, 0, 8, 0, 10, 0, 9, 4, 0]]) fiber = Fiber.fromRandom(shape, [0.5, 0.5], 10, seed=3) self.assertEqual(fiber, fiber_ref)
Create a random 2D tensor
test/test_fiber.py
test_fromRandom_2D
Fibertree-Project/fibertree
2
python
def test_fromRandom_2D(self): shape = [10, 10] fiber_ref = Fiber.fromUncompressed([[0, 10, 10, 1, 0, 9, 8, 0, 0, 3], [9, 1, 0, 10, 1, 0, 10, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 3, 0, 3, 5, 0, 5, 7, 0, 0], [6, 0, 0, 0, 0, 0, 6, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 2, 8, 2, 3, 7, 0, 0, 10], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 4, 0, 2, 9, 4, 0, 5], [6, 3, 0, 8, 0, 10, 0, 9, 4, 0]]) fiber = Fiber.fromRandom(shape, [0.5, 0.5], 10, seed=3) self.assertEqual(fiber, fiber_ref)
def test_fromRandom_2D(self): shape = [10, 10] fiber_ref = Fiber.fromUncompressed([[0, 10, 10, 1, 0, 9, 8, 0, 0, 3], [9, 1, 0, 10, 1, 0, 10, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 3, 0, 3, 5, 0, 5, 7, 0, 0], [6, 0, 0, 0, 0, 0, 6, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 2, 8, 2, 3, 7, 0, 0, 10], [0, 0, 0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 4, 0, 2, 9, 4, 0, 5], [6, 3, 0, 8, 0, 10, 0, 9, 4, 0]]) fiber = Fiber.fromRandom(shape, [0.5, 0.5], 10, seed=3) self.assertEqual(fiber, fiber_ref)<|docstring|>Create a random 2D tensor<|endoftext|>
f7bb995d81e5941a3eb4f3cc7d84a5ab39d4c94fed2fdad674a54313c2680e23
def test_getCoords(self): 'Extract coordinates' c_ref = [2, 4, 6] p_ref = [3, 5, 7] a = Fiber(c_ref, p_ref) c = a.getCoords() self.assertEqual(c, c_ref)
Extract coordinates
test/test_fiber.py
test_getCoords
Fibertree-Project/fibertree
2
python
def test_getCoords(self): c_ref = [2, 4, 6] p_ref = [3, 5, 7] a = Fiber(c_ref, p_ref) c = a.getCoords() self.assertEqual(c, c_ref)
def test_getCoords(self): c_ref = [2, 4, 6] p_ref = [3, 5, 7] a = Fiber(c_ref, p_ref) c = a.getCoords() self.assertEqual(c, c_ref)<|docstring|>Extract coordinates<|endoftext|>
a81e8c1cc0d9415378e1250dd94e306a24d65bb8d93e05020302bfcebcd4847a
def test_getPayloads(self): 'Extract payloads' c_ref = [2, 4, 6] p_ref = [3, 5, 7] a = Fiber(c_ref, p_ref) p = a.getPayloads() self.assertEqual(p, p_ref)
Extract payloads
test/test_fiber.py
test_getPayloads
Fibertree-Project/fibertree
2
python
def test_getPayloads(self): c_ref = [2, 4, 6] p_ref = [3, 5, 7] a = Fiber(c_ref, p_ref) p = a.getPayloads() self.assertEqual(p, p_ref)
def test_getPayloads(self): c_ref = [2, 4, 6] p_ref = [3, 5, 7] a = Fiber(c_ref, p_ref) p = a.getPayloads() self.assertEqual(p, p_ref)<|docstring|>Extract payloads<|endoftext|>
6bdfc418a489f303d357c23196bb43bee2dae17d08f95b717adedea627fd96a3
def test_isempty_1D(self): 'Test for empty fiber' a = Fiber([], []) self.assertTrue(a.isEmpty()) b = Fiber([0, 1], [0, 0]) self.assertTrue(b.isEmpty()) c = Fiber([0, 1], [0, 1]) self.assertFalse(c.isEmpty())
Test for empty fiber
test/test_fiber.py
test_isempty_1D
Fibertree-Project/fibertree
2
python
def test_isempty_1D(self): a = Fiber([], []) self.assertTrue(a.isEmpty()) b = Fiber([0, 1], [0, 0]) self.assertTrue(b.isEmpty()) c = Fiber([0, 1], [0, 1]) self.assertFalse(c.isEmpty())
def test_isempty_1D(self): a = Fiber([], []) self.assertTrue(a.isEmpty()) b = Fiber([0, 1], [0, 0]) self.assertTrue(b.isEmpty()) c = Fiber([0, 1], [0, 1]) self.assertFalse(c.isEmpty())<|docstring|>Test for empty fiber<|endoftext|>
1750a3cf032b169410a79795ddca8468711d78c88072a56a2656eb29f3cb5297
def test_isempty_2D(self): 'Test for empty fiber' a1 = Fiber([], []) a2 = Fiber([0, 1], [0, 0]) a3 = Fiber([0, 1], [0, 1]) a = Fiber([2, 3], [a1, a1]) self.assertTrue(a.isEmpty()) b = Fiber([3, 4], [a2, a2]) self.assertTrue(b.isEmpty()) c = Fiber([3, 4], [a1, a2]) self.assertTrue(c.isEmpty()) d = Fiber([4, 5], [a1, a3]) self.assertFalse(d.isEmpty())
Test for empty fiber
test/test_fiber.py
test_isempty_2D
Fibertree-Project/fibertree
2
python
def test_isempty_2D(self): a1 = Fiber([], []) a2 = Fiber([0, 1], [0, 0]) a3 = Fiber([0, 1], [0, 1]) a = Fiber([2, 3], [a1, a1]) self.assertTrue(a.isEmpty()) b = Fiber([3, 4], [a2, a2]) self.assertTrue(b.isEmpty()) c = Fiber([3, 4], [a1, a2]) self.assertTrue(c.isEmpty()) d = Fiber([4, 5], [a1, a3]) self.assertFalse(d.isEmpty())
def test_isempty_2D(self): a1 = Fiber([], []) a2 = Fiber([0, 1], [0, 0]) a3 = Fiber([0, 1], [0, 1]) a = Fiber([2, 3], [a1, a1]) self.assertTrue(a.isEmpty()) b = Fiber([3, 4], [a2, a2]) self.assertTrue(b.isEmpty()) c = Fiber([3, 4], [a1, a2]) self.assertTrue(c.isEmpty()) d = Fiber([4, 5], [a1, a3]) self.assertFalse(d.isEmpty())<|docstring|>Test for empty fiber<|endoftext|>
cf1c5c3e6c028148b9e5c2fa907757b454da6ee38b7b44d3de48aa4ec4ced59a
def test_nonempty_2D(self): 'Test for empty fiber' a1 = Fiber([], []) a2 = Fiber([0, 1], [0, 0]) a3 = Fiber([0, 1], [0, 1]) a = Fiber([1, 2, 3], [a1, a2, a3]) ne = a.nonEmpty() ne3 = Fiber([1], [1]) ne_ref = Fiber([3], [ne3]) self.assertEqual(ne, ne_ref)
Test for empty fiber
test/test_fiber.py
test_nonempty_2D
Fibertree-Project/fibertree
2
python
def test_nonempty_2D(self): a1 = Fiber([], []) a2 = Fiber([0, 1], [0, 0]) a3 = Fiber([0, 1], [0, 1]) a = Fiber([1, 2, 3], [a1, a2, a3]) ne = a.nonEmpty() ne3 = Fiber([1], [1]) ne_ref = Fiber([3], [ne3]) self.assertEqual(ne, ne_ref)
def test_nonempty_2D(self): a1 = Fiber([], []) a2 = Fiber([0, 1], [0, 0]) a3 = Fiber([0, 1], [0, 1]) a = Fiber([1, 2, 3], [a1, a2, a3]) ne = a.nonEmpty() ne3 = Fiber([1], [1]) ne_ref = Fiber([3], [ne3]) self.assertEqual(ne, ne_ref)<|docstring|>Test for empty fiber<|endoftext|>
41ae26c9afe12dda21be1a4d46fed83d0523e3340bf1b70672c59a9a841f2330
def test_setDefault(self): 'Test setting defaults - unimplemented' pass
Test setting defaults - unimplemented
test/test_fiber.py
test_setDefault
Fibertree-Project/fibertree
2
python
def test_setDefault(self): pass
def test_setDefault(self): pass<|docstring|>Test setting defaults - unimplemented<|endoftext|>
9b2f928f2c1e71784d5deef315b155314aa6a95938915dee42a248a26a23f86f
def test_setOwner(self): 'Test setting owner - unimplemented' pass
Test setting owner - unimplemented
test/test_fiber.py
test_setOwner
Fibertree-Project/fibertree
2
python
def test_setOwner(self): pass
def test_setOwner(self): pass<|docstring|>Test setting owner - unimplemented<|endoftext|>
99715ec77923cacf199a43d00f81a329508108b78d5ad7227dc0ad4aef13d526
def test_minCoord(self): 'Find minimum coordinate' c_ref = [2, 4, 6] p_ref = [3, 5, 7] c_min = min(c_ref) a = Fiber(c_ref, p_ref) self.assertEqual(a.minCoord(), c_min)
Find minimum coordinate
test/test_fiber.py
test_minCoord
Fibertree-Project/fibertree
2
python
def test_minCoord(self): c_ref = [2, 4, 6] p_ref = [3, 5, 7] c_min = min(c_ref) a = Fiber(c_ref, p_ref) self.assertEqual(a.minCoord(), c_min)
def test_minCoord(self): c_ref = [2, 4, 6] p_ref = [3, 5, 7] c_min = min(c_ref) a = Fiber(c_ref, p_ref) self.assertEqual(a.minCoord(), c_min)<|docstring|>Find minimum coordinate<|endoftext|>
39b5d2dcd54e4a4d2d9e940735776542ac5b2fc578709af3c027175585f60d5c
def test_maxCoord(self): 'Find minimum coordinate' c_ref = [2, 4, 6] p_ref = [3, 5, 7] c_max = max(c_ref) a = Fiber(c_ref, p_ref) self.assertEqual(a.maxCoord(), c_max)
Find minimum coordinate
test/test_fiber.py
test_maxCoord
Fibertree-Project/fibertree
2
python
def test_maxCoord(self): c_ref = [2, 4, 6] p_ref = [3, 5, 7] c_max = max(c_ref) a = Fiber(c_ref, p_ref) self.assertEqual(a.maxCoord(), c_max)
def test_maxCoord(self): c_ref = [2, 4, 6] p_ref = [3, 5, 7] c_max = max(c_ref) a = Fiber(c_ref, p_ref) self.assertEqual(a.maxCoord(), c_max)<|docstring|>Find minimum coordinate<|endoftext|>
4ec8226272323d3f40ddefea0081d2fd5a7f8e2f1f95099c66fbd2e21812044f
def test_values_2D(self): 'Count values in a 2-D fiber' a = Fiber.fromYAMLfile('./data/test_fiber-2.yaml') self.assertEqual(a.countValues(), 6)
Count values in a 2-D fiber
test/test_fiber.py
test_values_2D
Fibertree-Project/fibertree
2
python
def test_values_2D(self): a = Fiber.fromYAMLfile('./data/test_fiber-2.yaml') self.assertEqual(a.countValues(), 6)
def test_values_2D(self): a = Fiber.fromYAMLfile('./data/test_fiber-2.yaml') self.assertEqual(a.countValues(), 6)<|docstring|>Count values in a 2-D fiber<|endoftext|>
3461b3fd3e5b6de1e05e5a5116b7d24212d07ed79c6dbe8e55f9f7fa1e40f45d
def test_values_with_zero(self): 'Count values in a 1-D fiber with an explict zero' a = Fiber([1, 8, 9], [2, 0, 10]) self.assertEqual(a.countValues(), 2)
Count values in a 1-D fiber with an explict zero
test/test_fiber.py
test_values_with_zero
Fibertree-Project/fibertree
2
python
def test_values_with_zero(self): a = Fiber([1, 8, 9], [2, 0, 10]) self.assertEqual(a.countValues(), 2)
def test_values_with_zero(self): a = Fiber([1, 8, 9], [2, 0, 10]) self.assertEqual(a.countValues(), 2)<|docstring|>Count values in a 1-D fiber with an explict zero<|endoftext|>
31a66fbd821213eb824a1db922ae966275dfa69151a4b1b4e3e0071f4db2cea0
def test_iter(self): 'Test iteration over a fiber' c0 = [1, 8, 9] p0 = [2, 0, 10] a = Fiber(c0, p0) i = 0 for (c, p) in a: self.assertEqual(c, c0[i]) self.assertEqual(p, p0[i]) i += 1
Test iteration over a fiber
test/test_fiber.py
test_iter
Fibertree-Project/fibertree
2
python
def test_iter(self): c0 = [1, 8, 9] p0 = [2, 0, 10] a = Fiber(c0, p0) i = 0 for (c, p) in a: self.assertEqual(c, c0[i]) self.assertEqual(p, p0[i]) i += 1
def test_iter(self): c0 = [1, 8, 9] p0 = [2, 0, 10] a = Fiber(c0, p0) i = 0 for (c, p) in a: self.assertEqual(c, c0[i]) self.assertEqual(p, p0[i]) i += 1<|docstring|>Test iteration over a fiber<|endoftext|>
ac4d565539ad37bfbdd8bbf64f99cd21e5e887e8c46058c40fdaa8fbda8eb389
def test_iterShape(self): "Test iteration over a fiber's shape" c0 = [1, 8, 9] p0 = [2, 0, 10] c0_ans = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] p0_ans = [0, 2, 0, 0, 0, 0, 0, 0, 0, 10] a = Fiber(c0, p0) i = 0 for (c, p) in a.iterShape(): with self.subTest(test=f'Element {i}'): self.assertEqual(c, c0_ans[i]) self.assertEqual(p, p0_ans[i]) self.assertIsInstance(p, Payload) i += 1 with self.subTest(test='Test fiber internals'): self.assertEqual(a.coords, c0) self.assertEqual(a.payloads, p0)
Test iteration over a fiber's shape
test/test_fiber.py
test_iterShape
Fibertree-Project/fibertree
2
python
def test_iterShape(self): c0 = [1, 8, 9] p0 = [2, 0, 10] c0_ans = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] p0_ans = [0, 2, 0, 0, 0, 0, 0, 0, 0, 10] a = Fiber(c0, p0) i = 0 for (c, p) in a.iterShape(): with self.subTest(test=f'Element {i}'): self.assertEqual(c, c0_ans[i]) self.assertEqual(p, p0_ans[i]) self.assertIsInstance(p, Payload) i += 1 with self.subTest(test='Test fiber internals'): self.assertEqual(a.coords, c0) self.assertEqual(a.payloads, p0)
def test_iterShape(self): c0 = [1, 8, 9] p0 = [2, 0, 10] c0_ans = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] p0_ans = [0, 2, 0, 0, 0, 0, 0, 0, 0, 10] a = Fiber(c0, p0) i = 0 for (c, p) in a.iterShape(): with self.subTest(test=f'Element {i}'): self.assertEqual(c, c0_ans[i]) self.assertEqual(p, p0_ans[i]) self.assertIsInstance(p, Payload) i += 1 with self.subTest(test='Test fiber internals'): self.assertEqual(a.coords, c0) self.assertEqual(a.payloads, p0)<|docstring|>Test iteration over a fiber's shape<|endoftext|>
32da264ccd8afee786da7e27fe9c441251a58a7636c46a7b520b405234c1cac0
def test_iterShapeRef(self): "Test iteration over a fiber's shape with allocation" c0 = [1, 8, 9] p0 = [2, 0, 10] c0_ans = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] p0_ans = [0, 2, 0, 0, 0, 0, 0, 0, 0, 10] a = Fiber(c0, p0) i = 0 for (c, p) in a.iterShapeRef(): with self.subTest(test=f'Element {i}'): self.assertEqual(c, c0_ans[i]) self.assertEqual(p, p0_ans[i]) self.assertIsInstance(p, Payload) i += 1 with self.subTest(test='Test fiber internals'): self.assertEqual(a.coords, c0_ans) self.assertEqual(a.payloads, p0_ans)
Test iteration over a fiber's shape with allocation
test/test_fiber.py
test_iterShapeRef
Fibertree-Project/fibertree
2
python
def test_iterShapeRef(self): c0 = [1, 8, 9] p0 = [2, 0, 10] c0_ans = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] p0_ans = [0, 2, 0, 0, 0, 0, 0, 0, 0, 10] a = Fiber(c0, p0) i = 0 for (c, p) in a.iterShapeRef(): with self.subTest(test=f'Element {i}'): self.assertEqual(c, c0_ans[i]) self.assertEqual(p, p0_ans[i]) self.assertIsInstance(p, Payload) i += 1 with self.subTest(test='Test fiber internals'): self.assertEqual(a.coords, c0_ans) self.assertEqual(a.payloads, p0_ans)
def test_iterShapeRef(self): c0 = [1, 8, 9] p0 = [2, 0, 10] c0_ans = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9] p0_ans = [0, 2, 0, 0, 0, 0, 0, 0, 0, 10] a = Fiber(c0, p0) i = 0 for (c, p) in a.iterShapeRef(): with self.subTest(test=f'Element {i}'): self.assertEqual(c, c0_ans[i]) self.assertEqual(p, p0_ans[i]) self.assertIsInstance(p, Payload) i += 1 with self.subTest(test='Test fiber internals'): self.assertEqual(a.coords, c0_ans) self.assertEqual(a.payloads, p0_ans)<|docstring|>Test iteration over a fiber's shape with allocation<|endoftext|>
cceeaed57c2abd4adad4ae23b6286ed1ac6b1489f1c4aa7a2c3846ed6e8ffed5
def test_getitem_simple(self): 'Get item - simple' c_ref = [2, 4, 6, 8] p_ref = [3, 5, 7, 9] a = Fiber(c_ref, p_ref) (coord0, payload0) = a[0] self.assertEqual(coord0, 2) self.assertEqual(payload0, 3) (coord1, payload1) = a[1] self.assertEqual(coord1, 4) self.assertEqual(payload1, 5) (coord2, payload2) = a[(- 2)] self.assertEqual(coord2, 6) self.assertEqual(payload2, 7) (coord3, payload3) = a[(- 1)] self.assertEqual(coord3, 8) self.assertEqual(payload3, 9)
Get item - simple
test/test_fiber.py
test_getitem_simple
Fibertree-Project/fibertree
2
python
def test_getitem_simple(self): c_ref = [2, 4, 6, 8] p_ref = [3, 5, 7, 9] a = Fiber(c_ref, p_ref) (coord0, payload0) = a[0] self.assertEqual(coord0, 2) self.assertEqual(payload0, 3) (coord1, payload1) = a[1] self.assertEqual(coord1, 4) self.assertEqual(payload1, 5) (coord2, payload2) = a[(- 2)] self.assertEqual(coord2, 6) self.assertEqual(payload2, 7) (coord3, payload3) = a[(- 1)] self.assertEqual(coord3, 8) self.assertEqual(payload3, 9)
def test_getitem_simple(self): c_ref = [2, 4, 6, 8] p_ref = [3, 5, 7, 9] a = Fiber(c_ref, p_ref) (coord0, payload0) = a[0] self.assertEqual(coord0, 2) self.assertEqual(payload0, 3) (coord1, payload1) = a[1] self.assertEqual(coord1, 4) self.assertEqual(payload1, 5) (coord2, payload2) = a[(- 2)] self.assertEqual(coord2, 6) self.assertEqual(payload2, 7) (coord3, payload3) = a[(- 1)] self.assertEqual(coord3, 8) self.assertEqual(payload3, 9)<|docstring|>Get item - simple<|endoftext|>
b722bb326a4cffe24aedeee901997e363c153adf7d147fc1d352c95bd2327e68
def test_getitem_slice(self): 'Get item - slices' c_ref = [2, 4, 6, 8] p_ref = [3, 5, 7, 9] a = Fiber(c_ref, p_ref) slice1 = a[0:2] slice1_coord_ref = a.coords[0:2] slice1_payload_ref = a.payloads[0:2] slice1_ref = Fiber(slice1_coord_ref, slice1_payload_ref) self.assertEqual(slice1, slice1_ref)
Get item - slices
test/test_fiber.py
test_getitem_slice
Fibertree-Project/fibertree
2
python
def test_getitem_slice(self): c_ref = [2, 4, 6, 8] p_ref = [3, 5, 7, 9] a = Fiber(c_ref, p_ref) slice1 = a[0:2] slice1_coord_ref = a.coords[0:2] slice1_payload_ref = a.payloads[0:2] slice1_ref = Fiber(slice1_coord_ref, slice1_payload_ref) self.assertEqual(slice1, slice1_ref)
def test_getitem_slice(self): c_ref = [2, 4, 6, 8] p_ref = [3, 5, 7, 9] a = Fiber(c_ref, p_ref) slice1 = a[0:2] slice1_coord_ref = a.coords[0:2] slice1_payload_ref = a.payloads[0:2] slice1_ref = Fiber(slice1_coord_ref, slice1_payload_ref) self.assertEqual(slice1, slice1_ref)<|docstring|>Get item - slices<|endoftext|>
8baa9fd0b288a997ce9c87d7745c1dfbe086facd4c9cbb0802772255e3cc2bb0
def test_getitem_nD(self): 'Get item - multi-dimensional' c00 = [1, 2, 3] p00 = [2, 3, 4] f00 = Fiber(c00, p00) c01 = [4, 6, 8] p01 = [5, 7, 9] f01 = Fiber(c01, p01) c02 = [5, 7] p02 = [6, 8] f02 = Fiber(c02, p02) c0 = [4, 5, 8] p0 = [f00, f01, f02] f = Fiber(c0, p0) f_1_1 = f[(1, 1)] f_1_1_ref = CoordPayload(c0[1], f01[1]) self.assertEqual(f_1_1, f_1_1_ref) f_02_1 = f[(0:2, 1)] f_02_1_ref = Fiber(c0[0:2], [f00[1], f01[1]]) self.assertEqual(f_02_1, f_02_1_ref) f_12_1 = f[(1:2, 1)] f_12_1_ref = Fiber(c0[1:2], [f01[1]]) self.assertEqual(f_12_1, f_12_1_ref) f_02_01 = f[(0:2, 0:1)] f_02_01_ref = Fiber(c0[0:2], [f00[0:1], f01[0:1]]) self.assertEqual(f_02_01, f_02_01_ref) f_13_02 = f[(1:3, 0:2)] f_13_02_ref = Fiber(c0[1:3], [f01[0:2], f02[0:2]]) self.assertEqual(f_13_02, f_13_02_ref) f_13_12 = f[(1:3, 1:2)] f_13_12_ref = Fiber(c0[1:3], [f01[1:2], f02[1:2]]) self.assertEqual(f_13_12, f_13_12_ref)
Get item - multi-dimensional
test/test_fiber.py
test_getitem_nD
Fibertree-Project/fibertree
2
python
def test_getitem_nD(self): c00 = [1, 2, 3] p00 = [2, 3, 4] f00 = Fiber(c00, p00) c01 = [4, 6, 8] p01 = [5, 7, 9] f01 = Fiber(c01, p01) c02 = [5, 7] p02 = [6, 8] f02 = Fiber(c02, p02) c0 = [4, 5, 8] p0 = [f00, f01, f02] f = Fiber(c0, p0) f_1_1 = f[(1, 1)] f_1_1_ref = CoordPayload(c0[1], f01[1]) self.assertEqual(f_1_1, f_1_1_ref) f_02_1 = f[(0:2, 1)] f_02_1_ref = Fiber(c0[0:2], [f00[1], f01[1]]) self.assertEqual(f_02_1, f_02_1_ref) f_12_1 = f[(1:2, 1)] f_12_1_ref = Fiber(c0[1:2], [f01[1]]) self.assertEqual(f_12_1, f_12_1_ref) f_02_01 = f[(0:2, 0:1)] f_02_01_ref = Fiber(c0[0:2], [f00[0:1], f01[0:1]]) self.assertEqual(f_02_01, f_02_01_ref) f_13_02 = f[(1:3, 0:2)] f_13_02_ref = Fiber(c0[1:3], [f01[0:2], f02[0:2]]) self.assertEqual(f_13_02, f_13_02_ref) f_13_12 = f[(1:3, 1:2)] f_13_12_ref = Fiber(c0[1:3], [f01[1:2], f02[1:2]]) self.assertEqual(f_13_12, f_13_12_ref)
def test_getitem_nD(self): c00 = [1, 2, 3] p00 = [2, 3, 4] f00 = Fiber(c00, p00) c01 = [4, 6, 8] p01 = [5, 7, 9] f01 = Fiber(c01, p01) c02 = [5, 7] p02 = [6, 8] f02 = Fiber(c02, p02) c0 = [4, 5, 8] p0 = [f00, f01, f02] f = Fiber(c0, p0) f_1_1 = f[(1, 1)] f_1_1_ref = CoordPayload(c0[1], f01[1]) self.assertEqual(f_1_1, f_1_1_ref) f_02_1 = f[(0:2, 1)] f_02_1_ref = Fiber(c0[0:2], [f00[1], f01[1]]) self.assertEqual(f_02_1, f_02_1_ref) f_12_1 = f[(1:2, 1)] f_12_1_ref = Fiber(c0[1:2], [f01[1]]) self.assertEqual(f_12_1, f_12_1_ref) f_02_01 = f[(0:2, 0:1)] f_02_01_ref = Fiber(c0[0:2], [f00[0:1], f01[0:1]]) self.assertEqual(f_02_01, f_02_01_ref) f_13_02 = f[(1:3, 0:2)] f_13_02_ref = Fiber(c0[1:3], [f01[0:2], f02[0:2]]) self.assertEqual(f_13_02, f_13_02_ref) f_13_12 = f[(1:3, 1:2)] f_13_12_ref = Fiber(c0[1:3], [f01[1:2], f02[1:2]]) self.assertEqual(f_13_12, f_13_12_ref)<|docstring|>Get item - multi-dimensional<|endoftext|>
9fa6da425d9a5855b2bf17d9a5ba3407e20c45bf66db3426c9e86aa58b5e10f2
def test_setitem_scalar(self): 'test_setitem_scalar' f = Fiber([0, 1, 3], [1, 0, 4]) newf = Fiber([], []) newcoords = [None, 0, 1, 2, 3, 4] newpayloads = [6, (4, 8), newf, None] ans_c = [0, 1, 3] ans_p = [6, (4, 8), newf, newf] for i in range(len(f)): for (j, p) in enumerate(newpayloads): f[i] = p a = f[i] self.assertEqual(a.coord, ans_c[i]) self.assertEqual(a.payload, ans_p[j])
test_setitem_scalar
test/test_fiber.py
test_setitem_scalar
Fibertree-Project/fibertree
2
python
def (self): f = Fiber([0, 1, 3], [1, 0, 4]) newf = Fiber([], []) newcoords = [None, 0, 1, 2, 3, 4] newpayloads = [6, (4, 8), newf, None] ans_c = [0, 1, 3] ans_p = [6, (4, 8), newf, newf] for i in range(len(f)): for (j, p) in enumerate(newpayloads): f[i] = p a = f[i] self.assertEqual(a.coord, ans_c[i]) self.assertEqual(a.payload, ans_p[j])
def (self): f = Fiber([0, 1, 3], [1, 0, 4]) newf = Fiber([], []) newcoords = [None, 0, 1, 2, 3, 4] newpayloads = [6, (4, 8), newf, None] ans_c = [0, 1, 3] ans_p = [6, (4, 8), newf, newf] for i in range(len(f)): for (j, p) in enumerate(newpayloads): f[i] = p a = f[i] self.assertEqual(a.coord, ans_c[i]) self.assertEqual(a.payload, ans_p[j])<|docstring|>test_setitem_scalar<|endoftext|>
68ea8d800b034f9714af2181acb1c19e9fc62aa199b9c32f04c335e9ec88d532
def test_setitem_coordpayload(self): 'test_setitem_coordpayload' f = Fiber([0, 1, 3], [1, 0, 4]) newf = Fiber([], []) newcoords = [None, 0, 1, 2, 3, 4] newpayloads = [6, (4, 8), newf, None] ans_cvv = [[[0, 0, 0, 0], [0, 0, 0, 0], [None, None, None, None], [None, None, None, None], [None, None, None, None], [None, None, None, None]], [[1, 1, 1, 1], [None, None, None, None], [1, 1, 1, 1], [2, 2, 2, 2], [None, None, None, None], [None, None, None, None]], [[3, 3, 3, 3], [None, None, None, None], [None, None, None, None], [None, None, None, None], [3, 3, 3, 3], [4, 4, 4, 4]]] ans_pvv = [[[6, (4, 8), newf, newf], [6, (4, 8), newf, newf], [None, None, None, None], [None, None, None, None], [None, None, None, None], [None, None, None, None]], [[6, (4, 8), newf, newf], [None, None, None, None], [6, (4, 8), newf, newf], [6, (4, 8), newf, newf], [None, None, None, None], [None, None, None, None]], [[6, (4, 8), newf, newf], [None, None, None, None], [None, None, None, None], [None, None, None, None], [6, (4, 8), newf, newf], [6, (4, 8), newf, newf]]] for i in range(len(f)): for (j, c) in enumerate(newcoords): for (k, p) in enumerate(newpayloads): a = f[i] if (ans_cvv[i][j][k] is not None): f[i] = CoordPayload(c, p) b = f[i] self.assertEqual(b.coord, ans_cvv[i][j][k]) self.assertEqual(b.payload, ans_pvv[i][j][k]) else: with self.assertRaises(CoordinateError): f[i] = CoordPayload(c, p)
test_setitem_coordpayload
test/test_fiber.py
test_setitem_coordpayload
Fibertree-Project/fibertree
2
python
def (self): f = Fiber([0, 1, 3], [1, 0, 4]) newf = Fiber([], []) newcoords = [None, 0, 1, 2, 3, 4] newpayloads = [6, (4, 8), newf, None] ans_cvv = [[[0, 0, 0, 0], [0, 0, 0, 0], [None, None, None, None], [None, None, None, None], [None, None, None, None], [None, None, None, None]], [[1, 1, 1, 1], [None, None, None, None], [1, 1, 1, 1], [2, 2, 2, 2], [None, None, None, None], [None, None, None, None]], [[3, 3, 3, 3], [None, None, None, None], [None, None, None, None], [None, None, None, None], [3, 3, 3, 3], [4, 4, 4, 4]]] ans_pvv = [[[6, (4, 8), newf, newf], [6, (4, 8), newf, newf], [None, None, None, None], [None, None, None, None], [None, None, None, None], [None, None, None, None]], [[6, (4, 8), newf, newf], [None, None, None, None], [6, (4, 8), newf, newf], [6, (4, 8), newf, newf], [None, None, None, None], [None, None, None, None]], [[6, (4, 8), newf, newf], [None, None, None, None], [None, None, None, None], [None, None, None, None], [6, (4, 8), newf, newf], [6, (4, 8), newf, newf]]] for i in range(len(f)): for (j, c) in enumerate(newcoords): for (k, p) in enumerate(newpayloads): a = f[i] if (ans_cvv[i][j][k] is not None): f[i] = CoordPayload(c, p) b = f[i] self.assertEqual(b.coord, ans_cvv[i][j][k]) self.assertEqual(b.payload, ans_pvv[i][j][k]) else: with self.assertRaises(CoordinateError): f[i] = CoordPayload(c, p)
def (self): f = Fiber([0, 1, 3], [1, 0, 4]) newf = Fiber([], []) newcoords = [None, 0, 1, 2, 3, 4] newpayloads = [6, (4, 8), newf, None] ans_cvv = [[[0, 0, 0, 0], [0, 0, 0, 0], [None, None, None, None], [None, None, None, None], [None, None, None, None], [None, None, None, None]], [[1, 1, 1, 1], [None, None, None, None], [1, 1, 1, 1], [2, 2, 2, 2], [None, None, None, None], [None, None, None, None]], [[3, 3, 3, 3], [None, None, None, None], [None, None, None, None], [None, None, None, None], [3, 3, 3, 3], [4, 4, 4, 4]]] ans_pvv = [[[6, (4, 8), newf, newf], [6, (4, 8), newf, newf], [None, None, None, None], [None, None, None, None], [None, None, None, None], [None, None, None, None]], [[6, (4, 8), newf, newf], [None, None, None, None], [6, (4, 8), newf, newf], [6, (4, 8), newf, newf], [None, None, None, None], [None, None, None, None]], [[6, (4, 8), newf, newf], [None, None, None, None], [None, None, None, None], [None, None, None, None], [6, (4, 8), newf, newf], [6, (4, 8), newf, newf]]] for i in range(len(f)): for (j, c) in enumerate(newcoords): for (k, p) in enumerate(newpayloads): a = f[i] if (ans_cvv[i][j][k] is not None): f[i] = CoordPayload(c, p) b = f[i] self.assertEqual(b.coord, ans_cvv[i][j][k]) self.assertEqual(b.payload, ans_pvv[i][j][k]) else: with self.assertRaises(CoordinateError): f[i] = CoordPayload(c, p)<|docstring|>test_setitem_coordpayload<|endoftext|>
4cd0e1cefb79e1a13d2f5484d399784a3a5b17ae22f05f4a389caa3824fecb2f
def test_len(self): 'Find lenght of a fiber' a = Fiber.fromYAMLfile('./data/test_fiber-2.yaml') self.assertEqual(len(a), 2)
Find lenght of a fiber
test/test_fiber.py
test_len
Fibertree-Project/fibertree
2
python
def test_len(self): a = Fiber.fromYAMLfile('./data/test_fiber-2.yaml') self.assertEqual(len(a), 2)
def test_len(self): a = Fiber.fromYAMLfile('./data/test_fiber-2.yaml') self.assertEqual(len(a), 2)<|docstring|>Find lenght of a fiber<|endoftext|>
49a68116ceaa9c28f240efd8615674936244862df36798fe4f9d8ee6ba97bbbf
def test_getPayload(self): 'Access payloads' coords = [2, 4, 6] payloads = [3, 5, 7] a = Fiber(coords, payloads) test = [0, 4, 6, 3] answer_allocate = [0, 5, 7, 0] answer_noallocate = [None, 5, 7, None] answer_default = [(- 1), 5, 7, (- 1)] for i in range(len(test)): self.assertEqual(a.getPayload(test[i]), answer_allocate[i]) self.assertEqual(a.getPayload(test[i], allocate=True), answer_allocate[i]) self.assertEqual(a.getPayload(test[i], allocate=False), answer_noallocate[i]) self.assertEqual(a.getPayload(test[i], allocate=False, default=(- 1)), answer_default[i])
Access payloads
test/test_fiber.py
test_getPayload
Fibertree-Project/fibertree
2
python
def test_getPayload(self): coords = [2, 4, 6] payloads = [3, 5, 7] a = Fiber(coords, payloads) test = [0, 4, 6, 3] answer_allocate = [0, 5, 7, 0] answer_noallocate = [None, 5, 7, None] answer_default = [(- 1), 5, 7, (- 1)] for i in range(len(test)): self.assertEqual(a.getPayload(test[i]), answer_allocate[i]) self.assertEqual(a.getPayload(test[i], allocate=True), answer_allocate[i]) self.assertEqual(a.getPayload(test[i], allocate=False), answer_noallocate[i]) self.assertEqual(a.getPayload(test[i], allocate=False, default=(- 1)), answer_default[i])
def test_getPayload(self): coords = [2, 4, 6] payloads = [3, 5, 7] a = Fiber(coords, payloads) test = [0, 4, 6, 3] answer_allocate = [0, 5, 7, 0] answer_noallocate = [None, 5, 7, None] answer_default = [(- 1), 5, 7, (- 1)] for i in range(len(test)): self.assertEqual(a.getPayload(test[i]), answer_allocate[i]) self.assertEqual(a.getPayload(test[i], allocate=True), answer_allocate[i]) self.assertEqual(a.getPayload(test[i], allocate=False), answer_noallocate[i]) self.assertEqual(a.getPayload(test[i], allocate=False, default=(- 1)), answer_default[i])<|docstring|>Access payloads<|endoftext|>
a8a28f94ec3bf7503371f863125631cebc00bbb2e88366f991797bf5fdc6fb22
def test_getPayloadRef_update(self): 'Update payload references' coords = [2, 4, 6] payloads = [3, 5, 7] a = Fiber(coords, payloads) test = [0, 4, 5, 6, 3] update = [10, 11, 12, 13, 14] answer = [0, 5, 0, 7, 0] for i in range(len(test)): x = a.getPayload(test[i]) x <<= update[i] self.assertEqual(a.getPayload(test[i]), answer[i])
Update payload references
test/test_fiber.py
test_getPayloadRef_update
Fibertree-Project/fibertree
2
python
def test_getPayloadRef_update(self): coords = [2, 4, 6] payloads = [3, 5, 7] a = Fiber(coords, payloads) test = [0, 4, 5, 6, 3] update = [10, 11, 12, 13, 14] answer = [0, 5, 0, 7, 0] for i in range(len(test)): x = a.getPayload(test[i]) x <<= update[i] self.assertEqual(a.getPayload(test[i]), answer[i])
def test_getPayloadRef_update(self): coords = [2, 4, 6] payloads = [3, 5, 7] a = Fiber(coords, payloads) test = [0, 4, 5, 6, 3] update = [10, 11, 12, 13, 14] answer = [0, 5, 0, 7, 0] for i in range(len(test)): x = a.getPayload(test[i]) x <<= update[i] self.assertEqual(a.getPayload(test[i]), answer[i])<|docstring|>Update payload references<|endoftext|>
167961dfd431b11071928b5b4da4ee66f7a66ef1179f39c8c502053a942fbe8d
def test_getPayload_2(self): 'Access payloads - multilevel' a = Fiber.fromUncompressed([[1, 2, 0, 4, 5, 0], [0, 0, 0, 0, 0, 0], [0, 0, 3, 4, 0, 0]]) self.assertEqual(a.getPayload(2, 2), 3) test = [(0, 0), (2, 2), (0, 3), (2, 1)] answer_allocate = [1, 3, 4, 0] answer_noallocate = [1, 3, 4, None] for i in range(len(test)): p = a.getPayload(*test[i]) self.assertEqual(p, answer_allocate[i]) p = a.getPayload(*test[i], allocate=True) self.assertEqual(p, answer_allocate[i]) p = a.getPayload(*test[i], allocate=False) self.assertEqual(p, answer_noallocate[i])
Access payloads - multilevel
test/test_fiber.py
test_getPayload_2
Fibertree-Project/fibertree
2
python
def test_getPayload_2(self): a = Fiber.fromUncompressed([[1, 2, 0, 4, 5, 0], [0, 0, 0, 0, 0, 0], [0, 0, 3, 4, 0, 0]]) self.assertEqual(a.getPayload(2, 2), 3) test = [(0, 0), (2, 2), (0, 3), (2, 1)] answer_allocate = [1, 3, 4, 0] answer_noallocate = [1, 3, 4, None] for i in range(len(test)): p = a.getPayload(*test[i]) self.assertEqual(p, answer_allocate[i]) p = a.getPayload(*test[i], allocate=True) self.assertEqual(p, answer_allocate[i]) p = a.getPayload(*test[i], allocate=False) self.assertEqual(p, answer_noallocate[i])
def test_getPayload_2(self): a = Fiber.fromUncompressed([[1, 2, 0, 4, 5, 0], [0, 0, 0, 0, 0, 0], [0, 0, 3, 4, 0, 0]]) self.assertEqual(a.getPayload(2, 2), 3) test = [(0, 0), (2, 2), (0, 3), (2, 1)] answer_allocate = [1, 3, 4, 0] answer_noallocate = [1, 3, 4, None] for i in range(len(test)): p = a.getPayload(*test[i]) self.assertEqual(p, answer_allocate[i]) p = a.getPayload(*test[i], allocate=True) self.assertEqual(p, answer_allocate[i]) p = a.getPayload(*test[i], allocate=False) self.assertEqual(p, answer_noallocate[i])<|docstring|>Access payloads - multilevel<|endoftext|>
24a6ca9ecbf20a6c73940b67c05cdf780541c2dd40f0905a85775ff11d4270e0
def test_getPayload_2_update(self): 'Update payloads - multilevel' a = Fiber.fromUncompressed([[1, 2, 0, 4, 5, 0], [0, 0, 0, 0, 0, 0], [0, 0, 3, 4, 0, 0]]) test = [(0,), (1,), (2, 0), (2, 2), (1, 1)] update = [Fiber([3], [20]), Fiber([4], [21]), 22, 23, 24] check = [(0, 3), (1, 3), (2, 0), (2, 2), (1, 1)] answer = [20, 0, 0, 23, 0] for i in range(len(test)): with self.subTest(test=i): p = a.getPayload(*test[i], allocate=True) p <<= update[i] q = a.getPayload(*check[i]) self.assertEqual(q, answer[i])
Update payloads - multilevel
test/test_fiber.py
test_getPayload_2_update
Fibertree-Project/fibertree
2
python
def test_getPayload_2_update(self): a = Fiber.fromUncompressed([[1, 2, 0, 4, 5, 0], [0, 0, 0, 0, 0, 0], [0, 0, 3, 4, 0, 0]]) test = [(0,), (1,), (2, 0), (2, 2), (1, 1)] update = [Fiber([3], [20]), Fiber([4], [21]), 22, 23, 24] check = [(0, 3), (1, 3), (2, 0), (2, 2), (1, 1)] answer = [20, 0, 0, 23, 0] for i in range(len(test)): with self.subTest(test=i): p = a.getPayload(*test[i], allocate=True) p <<= update[i] q = a.getPayload(*check[i]) self.assertEqual(q, answer[i])
def test_getPayload_2_update(self): a = Fiber.fromUncompressed([[1, 2, 0, 4, 5, 0], [0, 0, 0, 0, 0, 0], [0, 0, 3, 4, 0, 0]]) test = [(0,), (1,), (2, 0), (2, 2), (1, 1)] update = [Fiber([3], [20]), Fiber([4], [21]), 22, 23, 24] check = [(0, 3), (1, 3), (2, 0), (2, 2), (1, 1)] answer = [20, 0, 0, 23, 0] for i in range(len(test)): with self.subTest(test=i): p = a.getPayload(*test[i], allocate=True) p <<= update[i] q = a.getPayload(*check[i]) self.assertEqual(q, answer[i])<|docstring|>Update payloads - multilevel<|endoftext|>
afda6a9072fd7278523f1ef4ad5e63d9f8d11951d44a259f3a9c9128ed5dee06
def test_getPayload_3(self): 'Access payloads - complex' a = Fiber.fromUncompressed([[1, 2, 0, 4, 5, 0], [0, 0, 0, 0, 0, 0], [0, 0, 3, 4, 0, 0]]) a_1 = Fiber([], []) a_2 = Fiber([2, 3], [3, 4]) self.assertEqual(a.getPayload(2), a_2) test = [(2,), (1,), (1, 2)] answer_allocate = [a_2, a_1, 0] answer_noallocate = [a_2, None, None] answer_default = [a_2, (- 1), (- 1)] for i in range(len(test)): p = a.getPayload(*test[i]) self.assertEqual(p, answer_allocate[i]) p = a.getPayload(*test[i], allocate=True) self.assertEqual(p, answer_allocate[i]) p = a.getPayload(*test[i], allocate=False) self.assertEqual(p, answer_noallocate[i]) p = a.getPayload(*test[i], allocate=False, default=(- 1)) self.assertEqual(p, answer_default[i])
Access payloads - complex
test/test_fiber.py
test_getPayload_3
Fibertree-Project/fibertree
2
python
def test_getPayload_3(self): a = Fiber.fromUncompressed([[1, 2, 0, 4, 5, 0], [0, 0, 0, 0, 0, 0], [0, 0, 3, 4, 0, 0]]) a_1 = Fiber([], []) a_2 = Fiber([2, 3], [3, 4]) self.assertEqual(a.getPayload(2), a_2) test = [(2,), (1,), (1, 2)] answer_allocate = [a_2, a_1, 0] answer_noallocate = [a_2, None, None] answer_default = [a_2, (- 1), (- 1)] for i in range(len(test)): p = a.getPayload(*test[i]) self.assertEqual(p, answer_allocate[i]) p = a.getPayload(*test[i], allocate=True) self.assertEqual(p, answer_allocate[i]) p = a.getPayload(*test[i], allocate=False) self.assertEqual(p, answer_noallocate[i]) p = a.getPayload(*test[i], allocate=False, default=(- 1)) self.assertEqual(p, answer_default[i])
def test_getPayload_3(self): a = Fiber.fromUncompressed([[1, 2, 0, 4, 5, 0], [0, 0, 0, 0, 0, 0], [0, 0, 3, 4, 0, 0]]) a_1 = Fiber([], []) a_2 = Fiber([2, 3], [3, 4]) self.assertEqual(a.getPayload(2), a_2) test = [(2,), (1,), (1, 2)] answer_allocate = [a_2, a_1, 0] answer_noallocate = [a_2, None, None] answer_default = [a_2, (- 1), (- 1)] for i in range(len(test)): p = a.getPayload(*test[i]) self.assertEqual(p, answer_allocate[i]) p = a.getPayload(*test[i], allocate=True) self.assertEqual(p, answer_allocate[i]) p = a.getPayload(*test[i], allocate=False) self.assertEqual(p, answer_noallocate[i]) p = a.getPayload(*test[i], allocate=False, default=(- 1)) self.assertEqual(p, answer_default[i])<|docstring|>Access payloads - complex<|endoftext|>
44ae50d73881cad3fe5911e632ffd5b20c958d0ea0f9e5549056cc54fa8e2426
def test_getPayload_shortcut(self): 'getPayload with shortcut' coords = [2, 4, 6] payloads = [3, 5, 7] a = Fiber(coords, payloads) test = [0, 4, 6, 3, 6] start_pos = [0, 0, 1, 1, Payload(2)] answer_saved_pos = [3, 1, 2, 3, 2] answer_saved_stats = [(1, 3), (2, 4), (3, 5), (4, 7), (5, 7)] for i in range(len(test)): p = a.getPayload(test[i], start_pos=start_pos[i]) saved_pos = a.getSavedPos() saved_pos_stats = a.getSavedPosStats(clear=False) self.assertEqual(saved_pos, answer_saved_pos[i]) self.assertEqual(saved_pos_stats, answer_saved_stats[i])
getPayload with shortcut
test/test_fiber.py
test_getPayload_shortcut
Fibertree-Project/fibertree
2
python
def test_getPayload_shortcut(self): coords = [2, 4, 6] payloads = [3, 5, 7] a = Fiber(coords, payloads) test = [0, 4, 6, 3, 6] start_pos = [0, 0, 1, 1, Payload(2)] answer_saved_pos = [3, 1, 2, 3, 2] answer_saved_stats = [(1, 3), (2, 4), (3, 5), (4, 7), (5, 7)] for i in range(len(test)): p = a.getPayload(test[i], start_pos=start_pos[i]) saved_pos = a.getSavedPos() saved_pos_stats = a.getSavedPosStats(clear=False) self.assertEqual(saved_pos, answer_saved_pos[i]) self.assertEqual(saved_pos_stats, answer_saved_stats[i])
def test_getPayload_shortcut(self): coords = [2, 4, 6] payloads = [3, 5, 7] a = Fiber(coords, payloads) test = [0, 4, 6, 3, 6] start_pos = [0, 0, 1, 1, Payload(2)] answer_saved_pos = [3, 1, 2, 3, 2] answer_saved_stats = [(1, 3), (2, 4), (3, 5), (4, 7), (5, 7)] for i in range(len(test)): p = a.getPayload(test[i], start_pos=start_pos[i]) saved_pos = a.getSavedPos() saved_pos_stats = a.getSavedPosStats(clear=False) self.assertEqual(saved_pos, answer_saved_pos[i]) self.assertEqual(saved_pos_stats, answer_saved_stats[i])<|docstring|>getPayload with shortcut<|endoftext|>
71053e7dbb7e0c211cbafabff3b93f78051b07dac27296f2e313d0614f647ace
def test_getPayloadRef(self): 'Get payload references' coords = [2, 4, 6] payloads = [3, 5, 7] a = Fiber(coords, payloads) test = [0, 4, 6, 3] answer = [0, 5, 7, 0] for i in range(len(test)): self.assertEqual(a.getPayloadRef(test[i]), answer[i])
Get payload references
test/test_fiber.py
test_getPayloadRef
Fibertree-Project/fibertree
2
python
def test_getPayloadRef(self): coords = [2, 4, 6] payloads = [3, 5, 7] a = Fiber(coords, payloads) test = [0, 4, 6, 3] answer = [0, 5, 7, 0] for i in range(len(test)): self.assertEqual(a.getPayloadRef(test[i]), answer[i])
def test_getPayloadRef(self): coords = [2, 4, 6] payloads = [3, 5, 7] a = Fiber(coords, payloads) test = [0, 4, 6, 3] answer = [0, 5, 7, 0] for i in range(len(test)): self.assertEqual(a.getPayloadRef(test[i]), answer[i])<|docstring|>Get payload references<|endoftext|>
35b59fca6580e82c556b65a6853edc50294020d29bc417f6b8bcc59f08d2afd7
def test_getPayloadRef_update(self): 'Update payload references' coords = [2, 4, 6] payloads = [3, 5, 7] a = Fiber(coords, payloads) test = [0, 4, 5, 6, 3] update = [10, 11, 12, 13, 14] answer = [10, 11, 12, 13, 14] for i in range(len(test)): x = a.getPayloadRef(test[i]) x <<= update[i] self.assertEqual(a.getPayload(test[i]), answer[i])
Update payload references
test/test_fiber.py
test_getPayloadRef_update
Fibertree-Project/fibertree
2
python
def test_getPayloadRef_update(self): coords = [2, 4, 6] payloads = [3, 5, 7] a = Fiber(coords, payloads) test = [0, 4, 5, 6, 3] update = [10, 11, 12, 13, 14] answer = [10, 11, 12, 13, 14] for i in range(len(test)): x = a.getPayloadRef(test[i]) x <<= update[i] self.assertEqual(a.getPayload(test[i]), answer[i])
def test_getPayloadRef_update(self): coords = [2, 4, 6] payloads = [3, 5, 7] a = Fiber(coords, payloads) test = [0, 4, 5, 6, 3] update = [10, 11, 12, 13, 14] answer = [10, 11, 12, 13, 14] for i in range(len(test)): x = a.getPayloadRef(test[i]) x <<= update[i] self.assertEqual(a.getPayload(test[i]), answer[i])<|docstring|>Update payload references<|endoftext|>
00644cf0759b983d833837f599b7c3caefeb462adf6b13be3f363cfded59edf8
def test_getPayloadRef2(self): 'Get payload references 2-D' t = Tensor(rank_ids=['m', 'n']) a = t.getRoot() test = [(0,), (2,), (1, 3), (2, 1)] answer = [Fiber([], []), Fiber([], []), 0, 0] for i in range(len(test)): p = a.getPayloadRef(*test[i]) self.assertEqual(p, answer[i]) with self.assertRaises(AssertionError): a.getPayloadRef(3, 2, 4)
Get payload references 2-D
test/test_fiber.py
test_getPayloadRef2
Fibertree-Project/fibertree
2
python
def test_getPayloadRef2(self): t = Tensor(rank_ids=['m', 'n']) a = t.getRoot() test = [(0,), (2,), (1, 3), (2, 1)] answer = [Fiber([], []), Fiber([], []), 0, 0] for i in range(len(test)): p = a.getPayloadRef(*test[i]) self.assertEqual(p, answer[i]) with self.assertRaises(AssertionError): a.getPayloadRef(3, 2, 4)
def test_getPayloadRef2(self): t = Tensor(rank_ids=['m', 'n']) a = t.getRoot() test = [(0,), (2,), (1, 3), (2, 1)] answer = [Fiber([], []), Fiber([], []), 0, 0] for i in range(len(test)): p = a.getPayloadRef(*test[i]) self.assertEqual(p, answer[i]) with self.assertRaises(AssertionError): a.getPayloadRef(3, 2, 4)<|docstring|>Get payload references 2-D<|endoftext|>
1c85c4f8cea9b227887f034f4eb1fe5255a5f8d5f4e6d06b9404b0ed940587c1
def test_getPayloadRef2_update(self): 'Update payload references 2-D' t = Tensor(rank_ids=['m', 'n']) a = t.getRoot() test = [(0,), (2,), (1, 3), (2, 1)] update = [Fiber([3], [20]), Fiber([4], [21]), 22, 23] check = [(0, 3), (2, 4), (1, 3), (2, 1)] answer = [20, 21, 22, 23] for i in range(len(test)): with self.subTest(test=i): p = a.getPayloadRef(*test[i]) p <<= update[i] q = a.getPayload(*check[i]) self.assertEqual(q, answer[i])
Update payload references 2-D
test/test_fiber.py
test_getPayloadRef2_update
Fibertree-Project/fibertree
2
python
def test_getPayloadRef2_update(self): t = Tensor(rank_ids=['m', 'n']) a = t.getRoot() test = [(0,), (2,), (1, 3), (2, 1)] update = [Fiber([3], [20]), Fiber([4], [21]), 22, 23] check = [(0, 3), (2, 4), (1, 3), (2, 1)] answer = [20, 21, 22, 23] for i in range(len(test)): with self.subTest(test=i): p = a.getPayloadRef(*test[i]) p <<= update[i] q = a.getPayload(*check[i]) self.assertEqual(q, answer[i])
def test_getPayloadRef2_update(self): t = Tensor(rank_ids=['m', 'n']) a = t.getRoot() test = [(0,), (2,), (1, 3), (2, 1)] update = [Fiber([3], [20]), Fiber([4], [21]), 22, 23] check = [(0, 3), (2, 4), (1, 3), (2, 1)] answer = [20, 21, 22, 23] for i in range(len(test)): with self.subTest(test=i): p = a.getPayloadRef(*test[i]) p <<= update[i] q = a.getPayload(*check[i]) self.assertEqual(q, answer[i])<|docstring|>Update payload references 2-D<|endoftext|>
d42ed06a020afaf22c7901fdf6838520bfbca04778d2b3274dc99bc7d5c1d5c1
def test_getPayloadRef_shortcut(self): 'getPayloadRef with shortcut' pass
getPayloadRef with shortcut
test/test_fiber.py
test_getPayloadRef_shortcut
Fibertree-Project/fibertree
2
python
def test_getPayloadRef_shortcut(self): pass
def test_getPayloadRef_shortcut(self): pass<|docstring|>getPayloadRef with shortcut<|endoftext|>
ab9d8829b7eea6d42f0f81cc9505efad71a969b440d1534aeea8d54263b08b25
def test_ilshift(self): '<<= infix operator' coords = [2, 4, 6, 8, 9, 12, 15, 16, 17, 20] payloads = [3, 5, 7, 9, 10, 13, 16, 17, 18, 21] a = Fiber(coords, payloads) b = Fiber() b <<= a self.assertEqual(a, b)
<<= infix operator
test/test_fiber.py
test_ilshift
Fibertree-Project/fibertree
2
python
def test_ilshift(self): coords = [2, 4, 6, 8, 9, 12, 15, 16, 17, 20] payloads = [3, 5, 7, 9, 10, 13, 16, 17, 18, 21] a = Fiber(coords, payloads) b = Fiber() b <<= a self.assertEqual(a, b)
def test_ilshift(self): coords = [2, 4, 6, 8, 9, 12, 15, 16, 17, 20] payloads = [3, 5, 7, 9, 10, 13, 16, 17, 18, 21] a = Fiber(coords, payloads) b = Fiber() b <<= a self.assertEqual(a, b)<|docstring|><<= infix operator<|endoftext|>
4105b457d005aa3305b8b00c53e1cb1c7aceadd2eaebb9457eb34fa08c79f9da
def test_getRange(self): 'getRange' coords = [2, 4, 6, 8, 9, 12, 15, 16, 17, 20] payloads = [3, 5, 7, 9, 10, 13, 16, 17, 18, 21] a = Fiber(coords, payloads) startc = [4, 3, 5, 13, 9, 15] size = [2, 3, 4, 2, 4, 3] end_coord = [6, 6, 9, 15, 13, 18] ans = [Fiber(coords[1:2], payloads[1:2]), Fiber(coords[1:2], payloads[1:2]), Fiber(coords[2:4], payloads[2:4]), Fiber([], []), Fiber(coords[4:6], payloads[4:6]), Fiber(coords[6:9], payloads[6:9])] for i in range(len(startc)): b = a.getRange(startc[i], size[i]) self.assertEqual(b, ans[i]) c = a.getRange(startc[i], end_coord=end_coord[i]) self.assertEqual(c, ans[i])
getRange
test/test_fiber.py
test_getRange
Fibertree-Project/fibertree
2
python
def test_(self): coords = [2, 4, 6, 8, 9, 12, 15, 16, 17, 20] payloads = [3, 5, 7, 9, 10, 13, 16, 17, 18, 21] a = Fiber(coords, payloads) startc = [4, 3, 5, 13, 9, 15] size = [2, 3, 4, 2, 4, 3] end_coord = [6, 6, 9, 15, 13, 18] ans = [Fiber(coords[1:2], payloads[1:2]), Fiber(coords[1:2], payloads[1:2]), Fiber(coords[2:4], payloads[2:4]), Fiber([], []), Fiber(coords[4:6], payloads[4:6]), Fiber(coords[6:9], payloads[6:9])] for i in range(len(startc)): b = a.(startc[i], size[i]) self.assertEqual(b, ans[i]) c = a.(startc[i], end_coord=end_coord[i]) self.assertEqual(c, ans[i])
def test_(self): coords = [2, 4, 6, 8, 9, 12, 15, 16, 17, 20] payloads = [3, 5, 7, 9, 10, 13, 16, 17, 18, 21] a = Fiber(coords, payloads) startc = [4, 3, 5, 13, 9, 15] size = [2, 3, 4, 2, 4, 3] end_coord = [6, 6, 9, 15, 13, 18] ans = [Fiber(coords[1:2], payloads[1:2]), Fiber(coords[1:2], payloads[1:2]), Fiber(coords[2:4], payloads[2:4]), Fiber([], []), Fiber(coords[4:6], payloads[4:6]), Fiber(coords[6:9], payloads[6:9])] for i in range(len(startc)): b = a.(startc[i], size[i]) self.assertEqual(b, ans[i]) c = a.(startc[i], end_coord=end_coord[i]) self.assertEqual(c, ans[i])<|docstring|>getRange<|endoftext|>
b12e3df05075d428326420e0a5f737e820a623dd3a33c53b99b7d47ebdea90cf
def test_getRange_flattened(self): 'getRange flattened coordinates' coords = [(0, 2), (0, 4), (0, 6), (0, 8), (0, 9), (1, 2), (1, 5), (1, 6), (1, 7), (2, 0)] payloads = [3, 5, 7, 9, 10, 13, 16, 17, 18, 21] a = Fiber(coords, payloads) startc = [(0, 4), (0, 3), (0, 5), (1, 3), (0, 9), (1, 5)] end_coord = [(0, 6), (0, 6), (0, 9), (1, 5), (1, 3), (1, 8)] ans = [Fiber(coords[1:2], payloads[1:2]), Fiber(coords[1:2], payloads[1:2]), Fiber(coords[2:4], payloads[2:4]), Fiber([], []), Fiber(coords[4:6], payloads[4:6]), Fiber(coords[6:9], payloads[6:9])] for i in range(len(startc)): c = a.getRange(startc[i], end_coord=end_coord[i]) self.assertEqual(c, ans[i])
getRange flattened coordinates
test/test_fiber.py
test_getRange_flattened
Fibertree-Project/fibertree
2
python
def test_getRange_flattened(self): coords = [(0, 2), (0, 4), (0, 6), (0, 8), (0, 9), (1, 2), (1, 5), (1, 6), (1, 7), (2, 0)] payloads = [3, 5, 7, 9, 10, 13, 16, 17, 18, 21] a = Fiber(coords, payloads) startc = [(0, 4), (0, 3), (0, 5), (1, 3), (0, 9), (1, 5)] end_coord = [(0, 6), (0, 6), (0, 9), (1, 5), (1, 3), (1, 8)] ans = [Fiber(coords[1:2], payloads[1:2]), Fiber(coords[1:2], payloads[1:2]), Fiber(coords[2:4], payloads[2:4]), Fiber([], []), Fiber(coords[4:6], payloads[4:6]), Fiber(coords[6:9], payloads[6:9])] for i in range(len(startc)): c = a.getRange(startc[i], end_coord=end_coord[i]) self.assertEqual(c, ans[i])
def test_getRange_flattened(self): coords = [(0, 2), (0, 4), (0, 6), (0, 8), (0, 9), (1, 2), (1, 5), (1, 6), (1, 7), (2, 0)] payloads = [3, 5, 7, 9, 10, 13, 16, 17, 18, 21] a = Fiber(coords, payloads) startc = [(0, 4), (0, 3), (0, 5), (1, 3), (0, 9), (1, 5)] end_coord = [(0, 6), (0, 6), (0, 9), (1, 5), (1, 3), (1, 8)] ans = [Fiber(coords[1:2], payloads[1:2]), Fiber(coords[1:2], payloads[1:2]), Fiber(coords[2:4], payloads[2:4]), Fiber([], []), Fiber(coords[4:6], payloads[4:6]), Fiber(coords[6:9], payloads[6:9])] for i in range(len(startc)): c = a.getRange(startc[i], end_coord=end_coord[i]) self.assertEqual(c, ans[i])<|docstring|>getRange flattened coordinates<|endoftext|>
343a35203a081fdbcac892f4176738d3cf6cda2bbcfdbb7b8b5c226acbbc8006
def test_getRange_shortcut(self): 'getRange_shortcut' coords = [2, 4, 6, 8, 9, 12] payloads = [3, 5, 7, 9, 10, 13] a = Fiber(coords, payloads) startc = [4, 3, 5, 13, 9] size = [2, 3, 4, 2, 3] startp = [0, 1, 2, 3, Payload(4)] ans = [[2, 2, None, None, None], [2, 2, None, None, None], [4, 4, 4, None, None], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5]] saved_pos_stats = (12, 15) for i in range(len(startc)): for (sp, aaa) in zip(startp, ans[i]): if (aaa is not None): b = a.getRange(startc[i], size[i], start_pos=sp) (self.assertEqual(a.getSavedPos(), aaa),) else: with self.assertRaises(AssertionError): b = a.getRange(startc[i], size[i], start_pos=sp) self.assertEqual(a.getSavedPosStats(), saved_pos_stats)
getRange_shortcut
test/test_fiber.py
test_getRange_shortcut
Fibertree-Project/fibertree
2
python
def test_(self): coords = [2, 4, 6, 8, 9, 12] payloads = [3, 5, 7, 9, 10, 13] a = Fiber(coords, payloads) startc = [4, 3, 5, 13, 9] size = [2, 3, 4, 2, 3] startp = [0, 1, 2, 3, Payload(4)] ans = [[2, 2, None, None, None], [2, 2, None, None, None], [4, 4, 4, None, None], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5]] saved_pos_stats = (12, 15) for i in range(len(startc)): for (sp, aaa) in zip(startp, ans[i]): if (aaa is not None): b = a.getRange(startc[i], size[i], start_pos=sp) (self.assertEqual(a.getSavedPos(), aaa),) else: with self.assertRaises(AssertionError): b = a.getRange(startc[i], size[i], start_pos=sp) self.assertEqual(a.getSavedPosStats(), saved_pos_stats)
def test_(self): coords = [2, 4, 6, 8, 9, 12] payloads = [3, 5, 7, 9, 10, 13] a = Fiber(coords, payloads) startc = [4, 3, 5, 13, 9] size = [2, 3, 4, 2, 3] startp = [0, 1, 2, 3, Payload(4)] ans = [[2, 2, None, None, None], [2, 2, None, None, None], [4, 4, 4, None, None], [5, 5, 5, 5, 5], [5, 5, 5, 5, 5]] saved_pos_stats = (12, 15) for i in range(len(startc)): for (sp, aaa) in zip(startp, ans[i]): if (aaa is not None): b = a.getRange(startc[i], size[i], start_pos=sp) (self.assertEqual(a.getSavedPos(), aaa),) else: with self.assertRaises(AssertionError): b = a.getRange(startc[i], size[i], start_pos=sp) self.assertEqual(a.getSavedPosStats(), saved_pos_stats)<|docstring|>getRange_shortcut<|endoftext|>
496e4613adf5567610c5d935c4dcb222d1899695d95958ba692d872ca18d5b5f
def test_append(self): 'Append element at end of fiber' coords = [2, 4, 6] payloads = [3, 5, 7] a = Fiber(coords, payloads) aa_coords = [2, 4, 6, 7] aa_payloads = [3, 5, 7, 10] aa_ref = Fiber(aa_coords, aa_payloads) retval = a.append(7, 10) self.assertIsNone(retval) self.assertEqual(a, aa_ref)
Append element at end of fiber
test/test_fiber.py
test_append
Fibertree-Project/fibertree
2
python
def test_append(self): coords = [2, 4, 6] payloads = [3, 5, 7] a = Fiber(coords, payloads) aa_coords = [2, 4, 6, 7] aa_payloads = [3, 5, 7, 10] aa_ref = Fiber(aa_coords, aa_payloads) retval = a.append(7, 10) self.assertIsNone(retval) self.assertEqual(a, aa_ref)
def test_append(self): coords = [2, 4, 6] payloads = [3, 5, 7] a = Fiber(coords, payloads) aa_coords = [2, 4, 6, 7] aa_payloads = [3, 5, 7, 10] aa_ref = Fiber(aa_coords, aa_payloads) retval = a.append(7, 10) self.assertIsNone(retval) self.assertEqual(a, aa_ref)<|docstring|>Append element at end of fiber<|endoftext|>
65f27472c561040903923acf58bb27dc04caaa7a4e08f97b022c24ff21c17f88
def test_append_empty(self): 'Append to empty fiber' a = Fiber([], []) a_ref = Fiber([4], [8]) retval = a.append(4, 8) self.assertIsNone(retval) self.assertEqual(a, a_ref)
Append to empty fiber
test/test_fiber.py
test_append_empty
Fibertree-Project/fibertree
2
python
def test_append_empty(self): a = Fiber([], []) a_ref = Fiber([4], [8]) retval = a.append(4, 8) self.assertIsNone(retval) self.assertEqual(a, a_ref)
def test_append_empty(self): a = Fiber([], []) a_ref = Fiber([4], [8]) retval = a.append(4, 8) self.assertIsNone(retval) self.assertEqual(a, a_ref)<|docstring|>Append to empty fiber<|endoftext|>
5005ee5289cd77682170738747632371cf08c292bb28b4870a96ca819eee8b9a
def test_append_assert(self): 'Append element at end of fiber - and assert' coords = [2, 4, 6] payloads = [3, 5, 7] a = Fiber(coords, payloads) with self.assertRaises(AssertionError): a.append(3, 10)
Append element at end of fiber - and assert
test/test_fiber.py
test_append_assert
Fibertree-Project/fibertree
2
python
def test_append_assert(self): coords = [2, 4, 6] payloads = [3, 5, 7] a = Fiber(coords, payloads) with self.assertRaises(AssertionError): a.append(3, 10)
def test_append_assert(self): coords = [2, 4, 6] payloads = [3, 5, 7] a = Fiber(coords, payloads) with self.assertRaises(AssertionError): a.append(3, 10)<|docstring|>Append element at end of fiber - and assert<|endoftext|>
c16a958b1092e34a8d6564333a37d1bb82d0724528d32704619ceed56533886f
def test_extend(self): 'Extend fiber' a_coords = [2, 4, 6] a_payloads = [3, 5, 7] a = Fiber(a_coords, a_payloads) b_coords = [7, 10, 12] b_payloads = [4, 6, 8] b = Fiber(b_coords, b_payloads) ae_coords = [2, 4, 6, 7, 10, 12] ae_payloads = [3, 5, 7, 4, 6, 8] ae_ref = Fiber(ae_coords, ae_payloads) retval = a.extend(b) self.assertIsNone(retval) self.assertEqual(a, ae_ref)
Extend fiber
test/test_fiber.py
test_extend
Fibertree-Project/fibertree
2
python
def test_extend(self): a_coords = [2, 4, 6] a_payloads = [3, 5, 7] a = Fiber(a_coords, a_payloads) b_coords = [7, 10, 12] b_payloads = [4, 6, 8] b = Fiber(b_coords, b_payloads) ae_coords = [2, 4, 6, 7, 10, 12] ae_payloads = [3, 5, 7, 4, 6, 8] ae_ref = Fiber(ae_coords, ae_payloads) retval = a.extend(b) self.assertIsNone(retval) self.assertEqual(a, ae_ref)
def test_extend(self): a_coords = [2, 4, 6] a_payloads = [3, 5, 7] a = Fiber(a_coords, a_payloads) b_coords = [7, 10, 12] b_payloads = [4, 6, 8] b = Fiber(b_coords, b_payloads) ae_coords = [2, 4, 6, 7, 10, 12] ae_payloads = [3, 5, 7, 4, 6, 8] ae_ref = Fiber(ae_coords, ae_payloads) retval = a.extend(b) self.assertIsNone(retval) self.assertEqual(a, ae_ref)<|docstring|>Extend fiber<|endoftext|>
e64388ffd2145147f332740537014ec79f06a9211f1d384921adaf274f4bb8e3
def test_extend_assert(self): 'Extend fiber - and assert' a_coords = [2, 4, 6] a_payloads = [3, 5, 7] a = Fiber(a_coords, a_payloads) b_coords = [6, 10, 12] b_payloads = [4, 6, 8] b = Fiber(b_coords, b_payloads) with self.assertRaises(AssertionError): a.extend(b) with self.assertRaises(AssertionError): a.extend(1)
Extend fiber - and assert
test/test_fiber.py
test_extend_assert
Fibertree-Project/fibertree
2
python
def test_extend_assert(self): a_coords = [2, 4, 6] a_payloads = [3, 5, 7] a = Fiber(a_coords, a_payloads) b_coords = [6, 10, 12] b_payloads = [4, 6, 8] b = Fiber(b_coords, b_payloads) with self.assertRaises(AssertionError): a.extend(b) with self.assertRaises(AssertionError): a.extend(1)
def test_extend_assert(self): a_coords = [2, 4, 6] a_payloads = [3, 5, 7] a = Fiber(a_coords, a_payloads) b_coords = [6, 10, 12] b_payloads = [4, 6, 8] b = Fiber(b_coords, b_payloads) with self.assertRaises(AssertionError): a.extend(b) with self.assertRaises(AssertionError): a.extend(1)<|docstring|>Extend fiber - and assert<|endoftext|>
aff572becbc598f6a1b9ff105f954058b53e2ab6d9e29947fd5b2971de50e7f2
def test_shape(self): 'Test determining shape of a fiber' a = Fiber.fromYAMLfile('./data/test_fiber-2.yaml') s = a.getShape() self.assertEqual(s, [5, 8])
Test determining shape of a fiber
test/test_fiber.py
test_shape
Fibertree-Project/fibertree
2
python
def test_shape(self): a = Fiber.fromYAMLfile('./data/test_fiber-2.yaml') s = a.getShape() self.assertEqual(s, [5, 8])
def test_shape(self): a = Fiber.fromYAMLfile('./data/test_fiber-2.yaml') s = a.getShape() self.assertEqual(s, [5, 8])<|docstring|>Test determining shape of a fiber<|endoftext|>
80a98bd0959c8582df4b85db6009651d59f842d58ce47e5dc24ec827c5f298eb
def test_shape_empty(self): 'Test determining shape of an empty fiber' a = Fiber([], []) s = a.getShape() self.assertEqual(s, [0])
Test determining shape of an empty fiber
test/test_fiber.py
test_shape_empty
Fibertree-Project/fibertree
2
python
def test_shape_empty(self): a = Fiber([], []) s = a.getShape() self.assertEqual(s, [0])
def test_shape_empty(self): a = Fiber([], []) s = a.getShape() self.assertEqual(s, [0])<|docstring|>Test determining shape of an empty fiber<|endoftext|>
c2991d42672e443a2b9301dcdc1782dbc96045df2001079768c525c0aca35242
def test_rankids(self): 'Test finding rankids of a fiber' a = Fiber.fromYAMLfile('./data/test_fiber-2.yaml') r = a.getRankIds() self.assertEqual(r, ['X.1', 'X.0'])
Test finding rankids of a fiber
test/test_fiber.py
test_rankids
Fibertree-Project/fibertree
2
python
def test_rankids(self): a = Fiber.fromYAMLfile('./data/test_fiber-2.yaml') r = a.getRankIds() self.assertEqual(r, ['X.1', 'X.0'])
def test_rankids(self): a = Fiber.fromYAMLfile('./data/test_fiber-2.yaml') r = a.getRankIds() self.assertEqual(r, ['X.1', 'X.0'])<|docstring|>Test finding rankids of a fiber<|endoftext|>
f7e29eff10a8f2c1cd5932ece5b82ab6a4bbff82e8a9f7e50c60cd5d4916476b
def test_uncompress(self): 'Test uncompress' uncompressed_ref = [[0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 5, 0, 0, 8], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 3, 0, 5, 0, 7, 0]] a = Fiber.fromYAMLfile('./data/test_fiber-2.yaml') uncompressed = a.uncompress() self.assertEqual(uncompressed, uncompressed_ref)
Test uncompress
test/test_fiber.py
test_uncompress
Fibertree-Project/fibertree
2
python
def test_uncompress(self): uncompressed_ref = [[0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 5, 0, 0, 8], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 3, 0, 5, 0, 7, 0]] a = Fiber.fromYAMLfile('./data/test_fiber-2.yaml') uncompressed = a.uncompress() self.assertEqual(uncompressed, uncompressed_ref)
def test_uncompress(self): uncompressed_ref = [[0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0, 0, 0], [0, 2, 0, 0, 5, 0, 0, 8], [0, 0, 0, 0, 0, 0, 0, 0], [0, 0, 3, 0, 5, 0, 7, 0]] a = Fiber.fromYAMLfile('./data/test_fiber-2.yaml') uncompressed = a.uncompress() self.assertEqual(uncompressed, uncompressed_ref)<|docstring|>Test uncompress<|endoftext|>
c29182b8ee3313d26c6a69bd7fb130b76d785a43025012a5de4ac2ba9ff5ee40
def test_uncompress_default(self): 'Test uncompress with non-zero default' uncompressed_ref = [[(- 1), (- 1), (- 1), (- 1), (- 1), (- 1), (- 1), (- 1)], [(- 1), (- 1), (- 1), (- 1), (- 1), (- 1), (- 1), (- 1)], [(- 1), 2, (- 1), (- 1), 5, (- 1), (- 1), 8], [(- 1), (- 1), (- 1), (- 1), (- 1), (- 1), (- 1), (- 1)], [(- 1), (- 1), 3, (- 1), 5, (- 1), 7, (- 1)]] a = Fiber.fromYAMLfile('./data/test_fiber-2.yaml') for (c, p) in a: p._setDefault((- 1)) uncompressed = a.uncompress() self.assertEqual(uncompressed, uncompressed_ref)
Test uncompress with non-zero default
test/test_fiber.py
test_uncompress_default
Fibertree-Project/fibertree
2
python
def test_uncompress_default(self): uncompressed_ref = [[(- 1), (- 1), (- 1), (- 1), (- 1), (- 1), (- 1), (- 1)], [(- 1), (- 1), (- 1), (- 1), (- 1), (- 1), (- 1), (- 1)], [(- 1), 2, (- 1), (- 1), 5, (- 1), (- 1), 8], [(- 1), (- 1), (- 1), (- 1), (- 1), (- 1), (- 1), (- 1)], [(- 1), (- 1), 3, (- 1), 5, (- 1), 7, (- 1)]] a = Fiber.fromYAMLfile('./data/test_fiber-2.yaml') for (c, p) in a: p._setDefault((- 1)) uncompressed = a.uncompress() self.assertEqual(uncompressed, uncompressed_ref)
def test_uncompress_default(self): uncompressed_ref = [[(- 1), (- 1), (- 1), (- 1), (- 1), (- 1), (- 1), (- 1)], [(- 1), (- 1), (- 1), (- 1), (- 1), (- 1), (- 1), (- 1)], [(- 1), 2, (- 1), (- 1), 5, (- 1), (- 1), 8], [(- 1), (- 1), (- 1), (- 1), (- 1), (- 1), (- 1), (- 1)], [(- 1), (- 1), 3, (- 1), 5, (- 1), 7, (- 1)]] a = Fiber.fromYAMLfile('./data/test_fiber-2.yaml') for (c, p) in a: p._setDefault((- 1)) uncompressed = a.uncompress() self.assertEqual(uncompressed, uncompressed_ref)<|docstring|>Test uncompress with non-zero default<|endoftext|>
7d9346d06aad068ba9e05689ce8ee981594d2aab384b1cef815e89470ad5247c
def test_project(self): 'Test projections' c = [0, 1, 10, 20] p = [1, 2, 11, 21] a = Fiber(c, p) cp = [1, 2, 11, 21] ap_ref = Fiber(cp, p) ap = a.project((lambda c: (c + 1))) self.assertEqual(ap, ap_ref)
Test projections
test/test_fiber.py
test_project
Fibertree-Project/fibertree
2
python
def test_project(self): c = [0, 1, 10, 20] p = [1, 2, 11, 21] a = Fiber(c, p) cp = [1, 2, 11, 21] ap_ref = Fiber(cp, p) ap = a.project((lambda c: (c + 1))) self.assertEqual(ap, ap_ref)
def test_project(self): c = [0, 1, 10, 20] p = [1, 2, 11, 21] a = Fiber(c, p) cp = [1, 2, 11, 21] ap_ref = Fiber(cp, p) ap = a.project((lambda c: (c + 1))) self.assertEqual(ap, ap_ref)<|docstring|>Test projections<|endoftext|>
e98966e1a11cf59d23b850a02c6c1d0a2ef1540f78d51264d3d06a0a51a70180
def test_prune(self): 'Test pruning a fiber' f = Fiber([2, 4, 6, 8], [4, 8, 12, 16]) fl2_ref = Fiber([2, 4], [4, 8]) fu2_ref = Fiber([6, 8], [12, 16]) f0 = f.prune((lambda n, c, p: (n < 2))) self.assertEqual(f0, fl2_ref) f1 = f.prune((lambda n, c, p: (c < 5))) self.assertEqual(f1, fl2_ref) f2 = f.prune((lambda n, c, p: (p < 10))) self.assertEqual(f2, fl2_ref) f3 = f.prune((lambda n, c, p: (n >= 2))) self.assertEqual(f3, fu2_ref) f4 = f.prune((lambda n, c, p: (c > 5))) self.assertEqual(f4, fu2_ref) f5 = f.prune((lambda n, c, p: (p > 10))) self.assertEqual(f5, fu2_ref) f6 = f.prune((lambda n, c, p: (True if (p < 10) else None))) self.assertEqual(f6, fl2_ref)
Test pruning a fiber
test/test_fiber.py
test_prune
Fibertree-Project/fibertree
2
python
def test_prune(self): f = Fiber([2, 4, 6, 8], [4, 8, 12, 16]) fl2_ref = Fiber([2, 4], [4, 8]) fu2_ref = Fiber([6, 8], [12, 16]) f0 = f.prune((lambda n, c, p: (n < 2))) self.assertEqual(f0, fl2_ref) f1 = f.prune((lambda n, c, p: (c < 5))) self.assertEqual(f1, fl2_ref) f2 = f.prune((lambda n, c, p: (p < 10))) self.assertEqual(f2, fl2_ref) f3 = f.prune((lambda n, c, p: (n >= 2))) self.assertEqual(f3, fu2_ref) f4 = f.prune((lambda n, c, p: (c > 5))) self.assertEqual(f4, fu2_ref) f5 = f.prune((lambda n, c, p: (p > 10))) self.assertEqual(f5, fu2_ref) f6 = f.prune((lambda n, c, p: (True if (p < 10) else None))) self.assertEqual(f6, fl2_ref)
def test_prune(self): f = Fiber([2, 4, 6, 8], [4, 8, 12, 16]) fl2_ref = Fiber([2, 4], [4, 8]) fu2_ref = Fiber([6, 8], [12, 16]) f0 = f.prune((lambda n, c, p: (n < 2))) self.assertEqual(f0, fl2_ref) f1 = f.prune((lambda n, c, p: (c < 5))) self.assertEqual(f1, fl2_ref) f2 = f.prune((lambda n, c, p: (p < 10))) self.assertEqual(f2, fl2_ref) f3 = f.prune((lambda n, c, p: (n >= 2))) self.assertEqual(f3, fu2_ref) f4 = f.prune((lambda n, c, p: (c > 5))) self.assertEqual(f4, fu2_ref) f5 = f.prune((lambda n, c, p: (p > 10))) self.assertEqual(f5, fu2_ref) f6 = f.prune((lambda n, c, p: (True if (p < 10) else None))) self.assertEqual(f6, fl2_ref)<|docstring|>Test pruning a fiber<|endoftext|>
c7552470c41165d6b8c9f76e487baa66f5a4b198d5c22fdadba6d3bec6a71e3b
def test_upzip(self): 'Test unzipping a fiber' c = [0, 1, 10, 20] p_a = [0, 1, 10, 20] p_b = [1, 2, 11, 21] p_ab = [(0, 1), (1, 2), (10, 11), (20, 21)] a_ref = Fiber(c, p_a) b_ref = Fiber(c, p_b) ab = Fiber(c, p_ab) (a, b) = ab.unzip() self.assertEqual(a, a_ref) self.assertEqual(b, b_ref)
Test unzipping a fiber
test/test_fiber.py
test_upzip
Fibertree-Project/fibertree
2
python
def test_upzip(self): c = [0, 1, 10, 20] p_a = [0, 1, 10, 20] p_b = [1, 2, 11, 21] p_ab = [(0, 1), (1, 2), (10, 11), (20, 21)] a_ref = Fiber(c, p_a) b_ref = Fiber(c, p_b) ab = Fiber(c, p_ab) (a, b) = ab.unzip() self.assertEqual(a, a_ref) self.assertEqual(b, b_ref)
def test_upzip(self): c = [0, 1, 10, 20] p_a = [0, 1, 10, 20] p_b = [1, 2, 11, 21] p_ab = [(0, 1), (1, 2), (10, 11), (20, 21)] a_ref = Fiber(c, p_a) b_ref = Fiber(c, p_b) ab = Fiber(c, p_ab) (a, b) = ab.unzip() self.assertEqual(a, a_ref) self.assertEqual(b, b_ref)<|docstring|>Test unzipping a fiber<|endoftext|>
4d0ac680285aae5c8069f39699f54c42d67839022a2c386c5c674b0cb451336c
def test_updateCoords(self): 'Update coords' c = [0, 1, 9, 10, 12, 31, 41] p = [0, 10, 20, 100, 120, 310, 410] f = Fiber(c, p) coords = 10 split = f.splitUniform(coords) flat_split = split.flattenRanks() flat_split.updateCoords((lambda i, c, p: c[1])) self.assertEqual(f, flat_split)
Update coords
test/test_fiber.py
test_updateCoords
Fibertree-Project/fibertree
2
python
def test_updateCoords(self): c = [0, 1, 9, 10, 12, 31, 41] p = [0, 10, 20, 100, 120, 310, 410] f = Fiber(c, p) coords = 10 split = f.splitUniform(coords) flat_split = split.flattenRanks() flat_split.updateCoords((lambda i, c, p: c[1])) self.assertEqual(f, flat_split)
def test_updateCoords(self): c = [0, 1, 9, 10, 12, 31, 41] p = [0, 10, 20, 100, 120, 310, 410] f = Fiber(c, p) coords = 10 split = f.splitUniform(coords) flat_split = split.flattenRanks() flat_split.updateCoords((lambda i, c, p: c[1])) self.assertEqual(f, flat_split)<|docstring|>Update coords<|endoftext|>
6affbc92a0cc08b5551843b7c990aa247f03a9e7df897ac11944e311e5a3d874
def test_updateCoords_reversed(self): 'Update coords - where coordinates need to be reversed' c = [0, 1, 9, 10, 12, 31, 41] p = [0, 10, 20, 100, 120, 310, 410] f = Fiber(c, p) f_ans = Fiber([(100 - c) for c in reversed(c)], list(reversed(p))) f.updateCoords((lambda i, c, p: (100 - c))) self.assertEqual(f, f_ans)
Update coords - where coordinates need to be reversed
test/test_fiber.py
test_updateCoords_reversed
Fibertree-Project/fibertree
2
python
def test_updateCoords_reversed(self): c = [0, 1, 9, 10, 12, 31, 41] p = [0, 10, 20, 100, 120, 310, 410] f = Fiber(c, p) f_ans = Fiber([(100 - c) for c in reversed(c)], list(reversed(p))) f.updateCoords((lambda i, c, p: (100 - c))) self.assertEqual(f, f_ans)
def test_updateCoords_reversed(self): c = [0, 1, 9, 10, 12, 31, 41] p = [0, 10, 20, 100, 120, 310, 410] f = Fiber(c, p) f_ans = Fiber([(100 - c) for c in reversed(c)], list(reversed(p))) f.updateCoords((lambda i, c, p: (100 - c))) self.assertEqual(f, f_ans)<|docstring|>Update coords - where coordinates need to be reversed<|endoftext|>
cc05d8ac85e405e31f40cb287d46a543134e28d89a46254f6affa3639c26b1b4
def test_add(self): 'Add fibers' a_coords = [2, 4, 6] a_payloads = [3, 5, 7] a = Fiber(a_coords, a_payloads) b_coords = [7, 10, 12] b_payloads = [4, 6, 8] b = Fiber(b_coords, b_payloads) ae_coords = [2, 4, 6, 7, 10, 12] ae_payloads = [3, 5, 7, 4, 6, 8] ae_ref = Fiber(ae_coords, ae_payloads) self.assertEqual((a + b), ae_ref)
Add fibers
test/test_fiber.py
test_add
Fibertree-Project/fibertree
2
python
def test_add(self): a_coords = [2, 4, 6] a_payloads = [3, 5, 7] a = Fiber(a_coords, a_payloads) b_coords = [7, 10, 12] b_payloads = [4, 6, 8] b = Fiber(b_coords, b_payloads) ae_coords = [2, 4, 6, 7, 10, 12] ae_payloads = [3, 5, 7, 4, 6, 8] ae_ref = Fiber(ae_coords, ae_payloads) self.assertEqual((a + b), ae_ref)
def test_add(self): a_coords = [2, 4, 6] a_payloads = [3, 5, 7] a = Fiber(a_coords, a_payloads) b_coords = [7, 10, 12] b_payloads = [4, 6, 8] b = Fiber(b_coords, b_payloads) ae_coords = [2, 4, 6, 7, 10, 12] ae_payloads = [3, 5, 7, 4, 6, 8] ae_ref = Fiber(ae_coords, ae_payloads) self.assertEqual((a + b), ae_ref)<|docstring|>Add fibers<|endoftext|>
1d8b0d8c6fa5e24d1e112cec633bc420c305bc91bab17ffe9d9aad51fa1af4c9
def test_iadd(self): 'iadd fibers' a_coords = [2, 4, 6] a_payloads = [3, 5, 7] a = Fiber(a_coords, a_payloads) b_coords = [7, 10, 12] b_payloads = [4, 6, 8] b = Fiber(b_coords, b_payloads) ae_coords = [2, 4, 6, 7, 10, 12] ae_payloads = [3, 5, 7, 4, 6, 8] ae_ref = Fiber(ae_coords, ae_payloads) a += b self.assertEqual(a, ae_ref)
iadd fibers
test/test_fiber.py
test_iadd
Fibertree-Project/fibertree
2
python
def test_iadd(self): a_coords = [2, 4, 6] a_payloads = [3, 5, 7] a = Fiber(a_coords, a_payloads) b_coords = [7, 10, 12] b_payloads = [4, 6, 8] b = Fiber(b_coords, b_payloads) ae_coords = [2, 4, 6, 7, 10, 12] ae_payloads = [3, 5, 7, 4, 6, 8] ae_ref = Fiber(ae_coords, ae_payloads) a += b self.assertEqual(a, ae_ref)
def test_iadd(self): a_coords = [2, 4, 6] a_payloads = [3, 5, 7] a = Fiber(a_coords, a_payloads) b_coords = [7, 10, 12] b_payloads = [4, 6, 8] b = Fiber(b_coords, b_payloads) ae_coords = [2, 4, 6, 7, 10, 12] ae_payloads = [3, 5, 7, 4, 6, 8] ae_ref = Fiber(ae_coords, ae_payloads) a += b self.assertEqual(a, ae_ref)<|docstring|>iadd fibers<|endoftext|>
fc664f20830a1bb3503901eb91759114a5c6d0e1e367635481b625fa21f99e3a
def test_and(self): 'Intersection test' a = Fiber([1, 5, 8, 9], [2, 6, 9, 10]) b = Fiber([0, 5, 9], [2, 7, 11]) ab_ref = Fiber([5, 9], [(6, 7), (10, 11)]) ab = (a & b) self.assertEqual(ab, ab_ref)
Intersection test
test/test_fiber.py
test_and
Fibertree-Project/fibertree
2
python
def test_and(self): a = Fiber([1, 5, 8, 9], [2, 6, 9, 10]) b = Fiber([0, 5, 9], [2, 7, 11]) ab_ref = Fiber([5, 9], [(6, 7), (10, 11)]) ab = (a & b) self.assertEqual(ab, ab_ref)
def test_and(self): a = Fiber([1, 5, 8, 9], [2, 6, 9, 10]) b = Fiber([0, 5, 9], [2, 7, 11]) ab_ref = Fiber([5, 9], [(6, 7), (10, 11)]) ab = (a & b) self.assertEqual(ab, ab_ref)<|docstring|>Intersection test<|endoftext|>