-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: improving performance on algorithm substitution
- Loading branch information
Showing
2 changed files
with
16 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
""" Utilities for working with the KiSAO ontology | ||
""" Utilities for working with the KiSAO onto7y | ||
:Author: Jonathan Karr <[email protected]> | ||
:Date: 2021-04-28 | ||
|
@@ -445,6 +445,12 @@ def get_preferred_substitute_algorithm(algorithm, alt_algorithms, substitution_p | |
if algorithm in alt_algorithms: | ||
return algorithm | ||
|
||
if ( | ||
ALGORITHM_SUBSTITUTION_POLICY_LEVELS[substitution_policy] | ||
<= ALGORITHM_SUBSTITUTION_POLICY_LEVELS[AlgorithmSubstitutionPolicy.SAME_METHOD] | ||
): | ||
raise AlgorithmCannotBeSubstitutedException("Algorithms cannot be substituted at policy '{}'.".format(substitution_policy.name)) | ||
|
||
sub_algorithms = get_substitutable_algorithms_for_policy(algorithm, substitution_policy=substitution_policy) | ||
alt_algorithm = None | ||
for possible_alt_algorithm in alt_algorithms: | ||
|
@@ -488,14 +494,15 @@ def get_preferred_substitute_algorithm_by_ids(algorithm, alt_algorithms, | |
Returns: | ||
:obj:`str`: KiSAO id of the preferred algorithm to execute (e.g., ``KISAO_0000088``) | ||
""" | ||
if ( | ||
if algorithm in alt_algorithms: | ||
return algorithm | ||
|
||
elif ( | ||
ALGORITHM_SUBSTITUTION_POLICY_LEVELS[substitution_policy] | ||
<= ALGORITHM_SUBSTITUTION_POLICY_LEVELS[AlgorithmSubstitutionPolicy.SAME_METHOD] | ||
): | ||
if algorithm in alt_algorithms: | ||
return algorithm | ||
else: | ||
raise AlgorithmCannotBeSubstitutedException("Algorithms cannot be substituted at policy '{}'.".format(substitution_policy.name)) | ||
raise AlgorithmCannotBeSubstitutedException("Algorithms cannot be substituted at policy '{}'.".format(substitution_policy.name)) | ||
|
||
else: | ||
kisao = Kisao() | ||
algorithm_term = kisao.get_term(algorithm) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters