Skip to content

Commit 41f3884

Browse files
Remove
1 parent d20dab1 commit 41f3884

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

chemicalx/data/contextfeatureset.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,15 +134,15 @@ def get_context_feature_count(self) -> int:
134134
"""Getting the number of feature dimensions.
135135
136136
Returns:
137-
int: The number of feature dimensions.
137+
feature_count (int): The number of feature dimensions.
138138
"""
139+
feature_count = None
139140
if len(self.__dict__) > 0:
140141
contexts = list(self.keys())
141142
first_context = contexts[0]
142143
feature_vector = self.__dict__[first_context]
143-
return feature_vector.shape[1]
144-
else:
145-
return 0
144+
feature_count = feature_vector.shape[1]
145+
return feature_count
146146

147147
def get_feature_matrix(self, contexts: List[str]) -> np.ndarray:
148148
"""Getting the feature matrix for a list of contexts.

tests/unit/test_datastructures.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,16 @@ def setUp(self):
1616
def test_get(self):
1717
assert self.context_feature_set["context_2"].shape == (1, 3)
1818
assert ("context_2" in self.context_feature_set) == True
19+
assert self.context_feature_set.has_context("context_2") == True
1920

2021
def test_copy(self):
2122
self.another_context_feature_set = self.context_feature_set.copy()
2223
assert len(self.another_context_feature_set) == len(self.context_feature_set)
2324

25+
del self.another_context_feature_set["context_1"]
26+
del self.another_context_feature_set["context_2"]
27+
assert self.another_context_feature_set.get_context_feature_count() == None
28+
2429
def test_len(self):
2530
assert len(self.context_feature_set) == 2
2631

@@ -48,6 +53,10 @@ def test_iteration(self):
4853
feature_vector = self.context_feature_set[context]
4954
assert feature_vector.shape == (1, 3)
5055

56+
def test_clearing(self):
57+
self.context_feature_set.clear()
58+
assert len(self.context_feature_set) == 0
59+
5160

5261
class TestDrugFeatureSet(unittest.TestCase):
5362
"""

0 commit comments

Comments
 (0)