Skip to content

Commit 3c86994

Browse files
authored
ENH: add new type called FeatureTable[Unconstrained] (#386)
1 parent aba63b0 commit 3c86994

4 files changed

Lines changed: 22 additions & 6 deletions

File tree

q2_types/feature_table/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
BIOMV210DirFmt)
1111
from ._types import (FeatureTable, Frequency, RelativeFrequency,
1212
PresenceAbsence, Composition, Balance,
13-
PercentileNormalized, Design, Normalized)
13+
PercentileNormalized, Design, Normalized, Unconstrained)
1414

1515
__all__ = ['BIOMV100Format', 'BIOMV100DirFmt', 'FeatureTable', 'Frequency',
1616
'RelativeFrequency', 'PresenceAbsence', 'BIOMV210Format',
1717
'BIOMV210DirFmt', 'Composition', 'Balance', 'PercentileNormalized',
18-
'Design', 'Normalized']
18+
'Design', 'Normalized', 'Unconstrained']

q2_types/feature_table/_deferred_setup/__init__.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from .. import (BIOMV100Format, BIOMV210Format, BIOMV100DirFmt,
1616
BIOMV210DirFmt, FeatureTable, Frequency, RelativeFrequency,
1717
PresenceAbsence, Composition, Balance,
18-
PercentileNormalized, Design, Normalized)
18+
PercentileNormalized, Design, Normalized, Unconstrained)
1919

2020
from ...plugin_setup import plugin
2121

@@ -27,7 +27,8 @@
2727

2828
plugin.register_semantic_types(FeatureTable, Frequency, RelativeFrequency,
2929
PresenceAbsence, Balance, Composition,
30-
PercentileNormalized, Design, Normalized)
30+
PercentileNormalized, Design, Normalized,
31+
Unconstrained)
3132

3233
plugin.register_artifact_class(
3334
FeatureTable[Frequency],
@@ -81,5 +82,11 @@
8182
directory_format=BIOMV210DirFmt,
8283
description="A feature table that was normalized."
8384
)
84-
85+
plugin.register_artifact_class(
86+
FeatureTable[Unconstrained],
87+
directory_format=BIOMV210DirFmt,
88+
description="A feature table containing real-valued feature "
89+
"measurements represented in Euclidean space without "
90+
"constant-sum (compositional) constraints."
91+
)
8592
importlib.import_module('._transformers', __name__)

q2_types/feature_table/_types.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,6 @@
3434

3535
Normalized = SemanticType('Normalized',
3636
variant_of=FeatureTable.field['content'])
37+
38+
Unconstrained = SemanticType('Unconstrained',
39+
variant_of=FeatureTable.field['content'])

q2_types/feature_table/tests/test_types.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
RelativeFrequency, PercentileNormalized,
1515
Composition, Balance,
1616
PresenceAbsence, BIOMV210DirFmt, Design,
17-
Normalized)
17+
Normalized, Unconstrained)
1818

1919

2020
class TestTypes(TestPluginBase):
@@ -41,6 +41,9 @@ def test_balance_semantic_type_registration(self):
4141
def test_normalized_semantic_type_registration(self):
4242
self.assertRegisteredSemanticType(Normalized)
4343

44+
def test_unconstrained_semantic_type_registration(self):
45+
self.assertRegisteredSemanticType(Unconstrained)
46+
4447
def test_feature_table_semantic_type_to_v210_format_registration(self):
4548
self.assertSemanticTypeRegisteredToFormat(
4649
FeatureTable[Frequency],
@@ -66,6 +69,9 @@ def test_feature_table_semantic_type_to_v210_format_registration(self):
6669
self.assertSemanticTypeRegisteredToFormat(
6770
FeatureTable[Normalized],
6871
BIOMV210DirFmt)
72+
self.assertSemanticTypeRegisteredToFormat(
73+
FeatureTable[Unconstrained],
74+
BIOMV210DirFmt)
6975

7076

7177
if __name__ == "__main__":

0 commit comments

Comments
 (0)