def test_variant_of_field_members(self): Bar = SemanticType('Bar') Foo = SemanticType('Foo', field_names='foo', field_members={'foo': List[Bar]}) with self.assertRaisesRegex(TypeError, 'is not a variant'): Foo[List[Bar]]
def test_to_ast_semantic(self): Foo = SemanticType('Foo') ast = List[Foo].to_ast() self.assertEqual(ast['fields'][0], Foo.to_ast()) self.assertEqual(ast['type'], 'collection')
def is_concrete(self): Foo = SemanticType('Foo') self.assertFalse(List[Foo].is_concrete()) self.assertFalse(Set[Int].is_concrete())
def test_union_inside_collection(self): Foo = SemanticType('Foo') Bar = SemanticType('Bar') self.assertTrue(List[Foo] <= List[Foo | Bar])
def test_set_semantic_type(self): Foo = SemanticType('Foo') self.assertTrue(is_collection_type(Set[Foo])) self.assertTrue(is_semantic_type(Set[Foo])) self.assertFalse(is_primitive_type(Set[Foo]))
def test_variant_of_alt(self): Foo = SemanticType('Foo', field_names='foo') Bar = SemanticType('Bar', variant_of=Foo.field['foo']) with self.assertRaisesRegex(TypeError, 'is not a variant'): Foo[Set[Bar]]
# ---------------------------------------------------------------------------- # Copyright (c) 2021, QIIME 2 development team. # # Distributed under the terms of the Modified BSD License. # # The full license is in the file LICENSE, distributed with this software. # ---------------------------------------------------------------------------- from q2_types.feature_data import FeatureData from qiime2.core.type import SemanticType RankedProteinAlignment = SemanticType('RankedProteinAlignment', variant_of=FeatureData.field['type']) PositionMapping = SemanticType('PositionMapping', variant_of=FeatureData.field['type'])
def test_to_ast_semantic(self): Foo = SemanticType('Foo') ast = List[Foo].to_ast() self.assertEqual(ast['fields'][0], Foo.to_ast()) self.assertEqual(ast['type'], 'collection')