Skip to content

Commit

Permalink
linting
Browse files Browse the repository at this point in the history
  • Loading branch information
JochenSiegWork committed Nov 15, 2024
1 parent 42dec40 commit 9de0025
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
13 changes: 7 additions & 6 deletions molpipeline/mol2any/mol2concatinated_vector.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,16 @@ def n_features(self) -> int:
@property
def feature_names(self) -> list[str]:
"""Return the feature names of concatenated elements."""
if self._feature_names_prefix is None:
# use element name as prefix
prefix_function = lambda elem_name: elem_name
else:
prefix_function = lambda elem_name: f"{self._feature_names_prefix}"
feature_names = []
for name, element in self._element_list:
if self._feature_names_prefix is None:
# use element name as prefix
prefix = name
else:
# use user specified prefix
prefix = self._feature_names_prefix

if hasattr(element, "feature_names"):
prefix = prefix_function(name)
feature_names.extend(
[f"{prefix}__{feature}" for feature in element.feature_names]
)
Expand Down
5 changes: 3 additions & 2 deletions tests/test_elements/test_mol2any/test_mol2concatenated.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def test_n_features(self) -> None:
net_charge_elem[1].n_features + 16 + physchem_elem[1].n_features,
)

def test_features_names(self) -> None:
def test_features_names(self) -> None: # pylint: disable=too-many-arguments
"""Test getting the names of features in the concatenated vector."""

physchem_elem = (
Expand Down Expand Up @@ -170,7 +170,7 @@ def test_features_names(self) -> None:

for elements_subset in powerset:
conc_elem = MolToConcatenatedVector(
elements_subset, feature_names_prefix=feature_names_prefix
list(elements_subset), feature_names_prefix=feature_names_prefix
)
feature_names = conc_elem.feature_names

Expand All @@ -182,6 +182,7 @@ def test_features_names(self) -> None:

seen_names = 0
for elem_name, elem in elements_subset:
self.assertTrue(hasattr(elem, "feature_names"))
elem_feature_names = elem.feature_names
elem_n_features = len(elem_feature_names)
relevant_names = feature_names[
Expand Down

0 comments on commit 9de0025

Please sign in to comment.