repo_id
stringclasses
409 values
prefix
large_stringlengths
34
36.3k
target
large_stringlengths
1
498
assertion_type
stringclasses
31 values
difficulty
stringclasses
8 values
test_file
stringlengths
10
121
test_function
stringlengths
1
104
test_class
stringlengths
0
51
lineno
int32
2
11.3k
commit_idx
int32
MolecularAI/aizynthfinder
def test_create_graph(setup_complete_mcts_tree): tree, nodes = setup_complete_mcts_tree graph = tree.graph() assert len(graph) == 3 assert list(graph.successors(nodes[0])) == [nodes[1]] assert list(graph.successors(nodes[1])) ==
[nodes[2]]
assert
collection
tests/mcts/test_tree.py
test_create_graph
50
null
MolecularAI/aizynthfinder
import random import pytest from aizynthfinder.search.breadth_first.search_tree import SearchTree def test_routes(default_config, setup_policies, setup_stock): random.seed(666) root_smi = "CN1CCC(C(=O)c2cccc(NC(=O)c3ccc(F)cc3)c2F)CC1" child1_smi = ["O", "CN1CCC(Cl)CC1", "N#Cc1cccc(NC(=O)c2ccc(F)cc2)c1F"]...
2
assert
numeric_literal
tests/breadth_first/test_search.py
test_routes
102
null
MolecularAI/aizynthfinder
from aizynthfinder.chem.serialization import MoleculeSerializer, MoleculeDeserializer from aizynthfinder.chem import Molecule, TreeMolecule def test_deserialize_tree_mols(): store = { 123: { "smiles": "CCC", "class": "TreeMolecule", "parent": None, "transform...
2
assert
numeric_literal
tests/chem/test_serialization.py
test_deserialize_tree_mols
71
null
MolecularAI/aizynthfinder
from aizynthfinder.chem import TreeMolecule from aizynthfinder.chem.serialization import MoleculeDeserializer, MoleculeSerializer from aizynthfinder.search.mcts import MctsNode, MctsSearchTree, MctsState def test_serialize_node(setup_mcts_search): serializer = MoleculeSerializer() root, _, _ = setup_mcts_searc...
[]
assert
collection
tests/mcts/test_serialization.py
test_serialize_node
39
null
MolecularAI/aizynthfinder
from aizynthfinder.chem.serialization import MoleculeSerializer, MoleculeDeserializer from aizynthfinder.chem import Molecule, TreeMolecule def test_deserialize_tree_mols(): store = { 123: { "smiles": "CCC", "class": "TreeMolecule", "parent": None, "transform...
None
assert
none_literal
tests/chem/test_serialization.py
test_deserialize_tree_mols
68
null
MolecularAI/aizynthfinder
import pytest from aizynthfinder.context.collection import ContextCollection def test_select_single_collection(): collection = SingleStringCollection() collection.load("key1", "value1") collection.load("key2", "value2") collection.selection = "key1" assert collection.selection ==
"key1"
assert
string_literal
tests/context/test_collection.py
test_select_single_collection
176
null
MolecularAI/aizynthfinder
import numpy as np from aizynthfinder.search.retrostar.search_tree import SearchTree from aizynthfinder.chem.serialization import MoleculeSerializer def test_one_iteration(setup_search_tree): tree = setup_search_tree tree.one_iteration() assert len(tree.root.children) == 1 assert len(tree.root.chil...
3
assert
numeric_literal
tests/retrostar/test_retrostar.py
test_one_iteration
13
null
MolecularAI/aizynthfinder
import pytest from aizynthfinder.search.breadth_first.nodes import MoleculeNode from aizynthfinder.chem.serialization import MoleculeSerializer, MoleculeDeserializer def setup_root(default_config): def wrapper(smiles): return MoleculeNode.create_root(smiles, config=default_config) return wrapper def...
grandchild2.mol
assert
complex_expr
tests/breadth_first/test_nodes.py
test_serialization_deserialization
75
null
MolecularAI/aizynthfinder
from aizynthfinder.chem import ( FixedRetroReaction, SmilesBasedRetroReaction, TemplatedRetroReaction, TreeMolecule, UniqueMolecule, hash_reactions, ) def test_create_fixed_reaction(): smiles = "[C:1](=[O:2])([cH3:3])[N:4][cH3:5]>>Cl[C:1](=[O:2])[cH3:3].[N:4][cH3:5]" mol = UniqueMolecul...
smiles
assert
variable
tests/chem/test_reaction.py
test_create_fixed_reaction
122
null
MolecularAI/aizynthfinder
import os import gzip import json import pytest import pandas as pd from aizynthfinder.utils.files import ( cat_datafiles, split_file, start_processes, read_datafile, save_datafile, ) def create_dummy_file(tmpdir, mocker): patched_tempfile = mocker.patch("aizynthfinder.utils.files.tempfile.mk...
"d\ne"
assert
string_literal
tests/utils/test_file_utils.py
test_split_file_odd
62
null
MolecularAI/aizynthfinder
import pytest import sys import pandas as pd from aizynthfinder.chem import Molecule from aizynthfinder.context.stock import ( StockException, ) from aizynthfinder.context.stock.queries import HAS_MOLBLOOM from aizynthfinder.tools.make_stock import ( extract_plain_smiles, extract_smiles_from_module, m...
2
assert
numeric_literal
tests/context/test_stock.py
test_load_csv_stock
37
null
MolecularAI/aizynthfinder
from aizynthfinder.chem import ( FixedRetroReaction, SmilesBasedRetroReaction, TemplatedRetroReaction, TreeMolecule, UniqueMolecule, hash_reactions, ) def test_mapped_atom_bonds(): mol = TreeMolecule(smiles="[CH3:1][NH:2][C:3](C)=[O:4]", parent=None) reaction = SmilesBasedRetroReaction(...
[(1, 2)]
assert
collection
tests/chem/test_reaction.py
test_mapped_atom_bonds
199
null
MolecularAI/aizynthfinder
from aizynthfinder.chem import ( FixedRetroReaction, SmilesBasedRetroReaction, TemplatedRetroReaction, TreeMolecule, UniqueMolecule, hash_reactions, ) def test_fixed_retroreaction_to_smiles_based_retroreaction_no_metadata(): mol = UniqueMolecule(smiles="CNC(C)=O") reactant1 = UniqueMole...
"CNC(C)=O"
assert
string_literal
tests/chem/test_reaction.py
test_fixed_retroreaction_to_smiles_based_retroreaction_no_metadata
168
null
MolecularAI/aizynthfinder
import pytest from aizynthfinder.search.mcts.node import ParetoMctsNode from aizynthfinder.search.mcts import MctsSearchTree def generate_root(default_config): def wrapper(smiles, config=None): return ParetoMctsNode.create_root( smiles, tree=None, config=config or default_config ) ...
view_post["values"]
assert
complex_expr
tests/mcts/test_multiobjective.py
test_backpropagate
72
null
MolecularAI/aizynthfinder
import pytest from aizynthfinder.chem import TreeMolecule from aizynthfinder.context.policy import ( MultiExpansionStrategy, TemplateBasedExpansionStrategy, ) from aizynthfinder.utils.exceptions import PolicyException def test_load_templated_expansion_strategy_from_csv( default_config, mock_onnx_model, tm...
["template", "metadata"]
assert
collection
tests/context/test_expansion_strategies.py
test_load_templated_expansion_strategy_from_csv
195
null
MolecularAI/aizynthfinder
import os from tarfile import TarFile import numpy as np import pytest from aizynthfinder.analysis import TreeAnalysis, RouteCollection from aizynthfinder.analysis.routes import SUPPORT_CLUSTERING from aizynthfinder.analysis.utils import RouteSelectionArguments from aizynthfinder.reactiontree import ReactionTree from...
2
assert
numeric_literal
tests/test_analysis.py
test_sort_nodes_scorer
62
null
MolecularAI/aizynthfinder
import numpy as np import networkx as nx from aizynthfinder.search.retrostar.nodes import MoleculeNode from aizynthfinder.chem.serialization import MoleculeSerializer, MoleculeDeserializer from aizynthfinder.search.andor_trees import ReactionTreeFromAndOrTrace def test_conversion_to_reaction_tree( setup_star_root...
3
assert
numeric_literal
tests/retrostar/test_retrostar_nodes.py
test_conversion_to_reaction_tree
136
null
MolecularAI/aizynthfinder
import pytest from aizynthfinder.context.collection import ContextCollection def test_empty_collection(): collection = StringCollection() assert len(collection) == 0 assert collection.selection ==
[]
assert
collection
tests/context/test_collection.py
test_empty_collection
23
null
MolecularAI/aizynthfinder
from aizynthfinder.chem import TreeMolecule from aizynthfinder.chem.serialization import MoleculeDeserializer, MoleculeSerializer from aizynthfinder.search.mcts import MctsNode, MctsSearchTree, MctsState def test_serialize_deserialize_state(default_config): mol = TreeMolecule(parent=None, smiles="CCC", transform=1...
id(mol)
assert
func_call
tests/mcts/test_serialization.py
test_serialize_deserialize_state
16
null
MolecularAI/aizynthfinder
from aizynthfinder.analysis import TreeAnalysis from aizynthfinder.context.scoring import ( NumberOfReactionsScorer, StateScorer, ) from aizynthfinder.search.mcts import MctsSearchTree def test_custom_reward(setup_aizynthfinder): """Test using different custom reward functions for MCTS and route building."...
[post_process_reward_scorer]
assert
collection
tests/mcts/test_reward.py
test_custom_reward
84
null
MolecularAI/aizynthfinder
import numpy as np from aizynthfinder.search.retrostar.search_tree import SearchTree from aizynthfinder.chem.serialization import MoleculeSerializer def test_one_expansion_with_finder(setup_aizynthfinder): """ Test the building of this tree: root | child 1 ...
2
assert
numeric_literal
tests/retrostar/test_retrostar.py
test_one_expansion_with_finder
65
null
MolecularAI/aizynthfinder
import pytest from aizynthfinder.search.mcts.node import ParetoMctsNode from aizynthfinder.search.mcts import MctsSearchTree def generate_root(default_config): def wrapper(smiles, config=None): return ParetoMctsNode.create_root( smiles, tree=None, config=config or default_config ) ...
[None, None, None]
assert
collection
tests/mcts/test_multiobjective.py
test_expand_root_node
44
null
MolecularAI/aizynthfinder
def test_route_to_node(setup_complete_mcts_tree): tree, nodes = setup_complete_mcts_tree actions, route_nodes = nodes[2].path_to() assert len(actions) == 2 assert len(nodes) ==
3
assert
numeric_literal
tests/mcts/test_tree.py
test_route_to_node
37
null
MolecularAI/aizynthfinder
import os from unittest import mock import pytest from aizynthfinder.aizynthfinder import AiZynthFinder from aizynthfinder.context.config import Configuration from aizynthfinder.context.stock import StockException def test_load_from_file(write_yaml): filename = write_yaml( { "search": { ...
"mcts"
assert
string_literal
tests/context/test_mcts_config.py
test_load_from_file
45
null
MolecularAI/aizynthfinder
def test_promising_child_of_root(setup_mcts_search): root, _, _ = setup_mcts_search root.expand() child = root.promising_child() view = root.children_view() assert view["objects"][0] is
child
assert
variable
tests/mcts/test_node.py
test_promising_child_of_root
78
null
MolecularAI/aizynthfinder
import pytest from aizynthfinder.search.mcts.node import ParetoMctsNode from aizynthfinder.search.mcts import MctsSearchTree def generate_root(default_config): def wrapper(smiles, config=None): return ParetoMctsNode.create_root( smiles, tree=None, config=config or default_config ) ...
3
assert
numeric_literal
tests/mcts/test_multiobjective.py
test_expand_root_node
40
null
MolecularAI/aizynthfinder
import pytest from aizynthfinder.context.collection import ContextCollection def test_empty_single_collection(): collection = SingleStringCollection() assert len(collection) == 0 assert collection.selection is
None
assert
none_literal
tests/context/test_collection.py
test_empty_single_collection
166
null
MolecularAI/aizynthfinder
import random import pytest from aizynthfinder.search.breadth_first.search_tree import SearchTree def test_search_incomplete(default_config, setup_policies, setup_stock): root_smi = "CN1CCC(C(=O)c2cccc(NC(=O)c3ccc(F)cc3)c2F)CC1" child1_smi = ["CN1CCC(Cl)CC1", "N#Cc1cccc(NC(=O)c2ccc(F)cc2)c1F", "O"] child...
8
assert
numeric_literal
tests/breadth_first/test_search.py
test_search_incomplete
70
null
MolecularAI/aizynthfinder
from aizynthfinder.chem import TreeMolecule from aizynthfinder.chem.serialization import MoleculeDeserializer, MoleculeSerializer from aizynthfinder.search.mcts import MctsNode, MctsSearchTree, MctsState def test_deserialize_node(setup_mcts_search, default_config): serializer = MoleculeSerializer() root, _, _ ...
str(child.state)
assert
func_call
tests/mcts/test_serialization.py
test_deserialize_node
110
null
MolecularAI/aizynthfinder
import pytest from aizynthfinder.context.collection import ContextCollection def test_deselect_all(): collection = StringCollection() collection.load("key1", "value1") collection.load("key2", "value2") collection.selection = ("key1", "key2") assert len(collection) ==
2
assert
numeric_literal
tests/context/test_collection.py
test_deselect_all
140
null
MolecularAI/aizynthfinder
import os from tarfile import TarFile import pytest from aizynthfinder.utils import image from aizynthfinder.chem import TreeMolecule, TemplatedRetroReaction def setup_graph(): mol1 = TreeMolecule(smiles="CCCO", parent=None) reaction = TemplatedRetroReaction(mol=mol1, smarts="") return [mol1], [reaction]...
tarobj.getnames()
assert
func_call
tests/utils/test_image.py
test_visjs_page
46
null
MolecularAI/aizynthfinder
import numpy as np import pytest import aizynthfinder.utils.models as models from aizynthfinder.utils.models import ( SUPPORT_EXTERNAL_APIS, ExternalModelViaGRPC, ExternalModelViaREST, ) def setup_rest_mock(mocker): models.TF_SERVING_HOST = "localhost" models.TF_SERVING_REST_PORT = "255" mocke...
[0.0, 1.0]
assert
collection
tests/utils/test_external_tf_models.py
test_predict_tf_rest_model
125
null
MolecularAI/aizynthfinder
import pytest from aizynthfinder.search.breadth_first.nodes import MoleculeNode from aizynthfinder.chem.serialization import MoleculeSerializer, MoleculeDeserializer def setup_root(default_config): def wrapper(smiles): return MoleculeNode.create_root(smiles, config=default_config) return wrapper def...
len(root.children)
assert
func_call
tests/breadth_first/test_nodes.py
test_serialization_deserialization
68
null
MolecularAI/aizynthfinder
from aizynthfinder.chem import ( FixedRetroReaction, SmilesBasedRetroReaction, TemplatedRetroReaction, TreeMolecule, UniqueMolecule, hash_reactions, ) def test_retro_reaction(get_action): reaction = get_action(applicable=True) products1 = reaction.reactants assert products1[0][0].s...
"CNO"
assert
string_literal
tests/chem/test_reaction.py
test_retro_reaction
16
null
MolecularAI/aizynthfinder
from aizynthfinder.chem import TreeMolecule from aizynthfinder.chem.serialization import MoleculeDeserializer, MoleculeSerializer from aizynthfinder.search.mcts import MctsNode, MctsSearchTree, MctsState def test_serialize_deserialize_state(default_config): mol = TreeMolecule(parent=None, smiles="CCC", transform=1...
1
assert
numeric_literal
tests/mcts/test_serialization.py
test_serialize_deserialize_state
15
null
MolecularAI/aizynthfinder
def test_route_to_node(setup_complete_mcts_tree): tree, nodes = setup_complete_mcts_tree actions, route_nodes = nodes[2].path_to() assert len(actions) == 2 assert len(nodes) == 3 assert nodes[0] == route_nodes[0] assert nodes[1] ==
route_nodes[1]
assert
complex_expr
tests/mcts/test_tree.py
test_route_to_node
39
null
MolecularAI/aizynthfinder
import pytest from aizynthfinder.context.collection import ContextCollection def test_add_single_item(): collection = StringCollection() collection.load("key1", "value1") assert len(collection) == 1 assert collection.items ==
["key1"]
assert
collection
tests/context/test_collection.py
test_add_single_item
32
null
MolecularAI/aizynthfinder
import pytest from aizynthfinder.reactiontree import ReactionTree def test_route_node_depth_from_mcts(setup_branched_reaction_tree): rt = setup_branched_reaction_tree() mols = list(rt.molecules()) assert rt.depth(mols[0]) == 0 assert rt.depth(mols[1]) == 2 assert rt.depth(mols[2]) == 2 asser...
4
assert
numeric_literal
tests/test_reactiontree.py
test_route_node_depth_from_mcts
65
null
MolecularAI/aizynthfinder
import pytest from aizynthfinder.chem import TreeMolecule from aizynthfinder.context.policy import ( MultiExpansionStrategy, TemplateBasedExpansionStrategy, ) from aizynthfinder.utils.exceptions import PolicyException def test_load_templated_expansion_strategy( default_config, setup_template_expansion_pol...
3
assert
numeric_literal
tests/context/test_expansion_strategies.py
test_load_templated_expansion_strategy
163
null
MolecularAI/aizynthfinder
import glob import json import os import sys from typing import Dict, List import pandas as pd import pytest import yaml from aizynthfinder.analysis import RouteCollection from aizynthfinder.chem import MoleculeException from aizynthfinder.interfaces import AiZynthApp from aizynthfinder.interfaces.aizynthapp import m...
output.out
assert
complex_expr
tests/test_cli.py
test_cli_single_smiles
164
null
MolecularAI/aizynthfinder
from networkx import get_node_attributes, set_node_attributes import numpy as np import pytest from aizynthfinder.chem import Molecule, UniqueMolecule from aizynthfinder.context.config import Configuration from aizynthfinder.context.scoring import ( AverageTemplateOccurrenceScorer, BrokenBondsScorer, Combi...
5
assert
numeric_literal
tests/context/test_score.py
test_template_occurrence_scorer
99
null
MolecularAI/aizynthfinder
import pytest from aizynthfinder.chem import TreeMolecule from aizynthfinder.context.policy import ( MultiExpansionStrategy, TemplateBasedExpansionStrategy, ) from aizynthfinder.utils.exceptions import PolicyException def test_multi_expansion_strategy(default_config, setup_template_expansion_policy): expa...
[0.7, 0.2, 0.7, 0.2]
assert
collection
tests/context/test_expansion_strategies.py
test_multi_expansion_strategy
47
null
MolecularAI/aizynthfinder
import pytest from aizynthfinder.context.collection import ContextCollection def test_select_single_collection(): collection = SingleStringCollection() collection.load("key1", "value1") collection.load("key2", "value2") collection.selection = "key1" assert collection.selection == "key1" col...
"key2"
assert
string_literal
tests/context/test_collection.py
test_select_single_collection
180
null
MolecularAI/aizynthfinder
import numpy as np import pytest from aizynthfinder.chem import ( SmilesBasedRetroReaction, TemplatedRetroReaction, TreeMolecule, ) from aizynthfinder.context.policy import ( BondFilter, FrozenSubstructureFilter, QuickKerasFilter, ReactantsCountFilter, TemplateBasedDirectExpansionStrate...
[0.7]
assert
collection
tests/context/test_policy.py
test_get_actions
118
null
MolecularAI/aizynthfinder
import pytest from aizynthfinder.reactiontree import ReactionTree def test_route_node_depth_from_mcts(setup_branched_reaction_tree): rt = setup_branched_reaction_tree() mols = list(rt.molecules()) assert rt.depth(mols[0]) ==
0
assert
numeric_literal
tests/test_reactiontree.py
test_route_node_depth_from_mcts
62
null
MolecularAI/aizynthfinder
from aizynthfinder.chem import TreeMolecule from aizynthfinder.chem.serialization import MoleculeDeserializer, MoleculeSerializer from aizynthfinder.search.mcts import MctsNode, MctsSearchTree, MctsState def test_serialize_deserialize_state(default_config): mol = TreeMolecule(parent=None, smiles="CCC", transform=1...
state0.mols[0]
assert
complex_expr
tests/mcts/test_serialization.py
test_serialize_deserialize_state
26
null
MolecularAI/aizynthfinder
import pytest from aizynthfinder.search.breadth_first.nodes import MoleculeNode from aizynthfinder.chem.serialization import MoleculeSerializer, MoleculeDeserializer def setup_root(default_config): def wrapper(smiles): return MoleculeNode.create_root(smiles, config=default_config) return wrapper def...
reaction.smarts
assert
complex_expr
tests/breadth_first/test_nodes.py
test_serialization_deserialization
71
null
MolecularAI/aizynthfinder
from aizynthfinder.analysis import TreeAnalysis from aizynthfinder.context.scoring import ( NumberOfReactionsScorer, StateScorer, ) from aizynthfinder.search.mcts import MctsSearchTree def test_reward_node_backward_compatibility(default_config): reward_scorer = repr(NumberOfReactionsScorer()) default_c...
reward_scorer
assert
variable
tests/mcts/test_reward.py
test_reward_node_backward_compatibility
116
null
MolecularAI/aizynthfinder
import os from unittest import mock import pytest from aizynthfinder.aizynthfinder import AiZynthFinder from aizynthfinder.context.config import Configuration from aizynthfinder.context.stock import StockException def test_load_stock(write_yaml, create_dummy_stock1): stock_filename = create_dummy_stock1("hdf5") ...
["test"]
assert
collection
tests/context/test_mcts_config.py
test_load_stock
132
null
MolecularAI/aizynthfinder
import random import pytest from aizynthfinder.search.breadth_first.search_tree import SearchTree def test_one_iteration(default_config, setup_policies, setup_stock): root_smi = "CN1CCC(C(=O)c2cccc(NC(=O)c3ccc(F)cc3)c2F)CC1" child1_smi = ["CN1CCC(Cl)CC1", "N#Cc1cccc(NC(=O)c2ccc(F)cc2)c1F", "O"] child2_sm...
1
assert
numeric_literal
tests/breadth_first/test_search.py
test_one_iteration
26
null
MolecularAI/aizynthfinder
from networkx import get_node_attributes, set_node_attributes import numpy as np import pytest from aizynthfinder.chem import Molecule, UniqueMolecule from aizynthfinder.context.config import Configuration from aizynthfinder.context.scoring import ( AverageTemplateOccurrenceScorer, BrokenBondsScorer, Combi...
1
assert
numeric_literal
tests/context/test_score.py
test_scorers_one_mcts_node
154
null
MolecularAI/aizynthfinder
import pytest from aizynthfinder.search.mcts.node import ParetoMctsNode from aizynthfinder.search.mcts import MctsSearchTree def generate_root(default_config): def wrapper(smiles, config=None): return ParetoMctsNode.create_root( smiles, tree=None, config=config or default_config ) ...
2
assert
numeric_literal
tests/mcts/test_multiobjective.py
test_setup_weighted_sum_tree
88
null
MolecularAI/aizynthfinder
def test_backpropagation(setup_complete_mcts_tree, mocker): tree, nodes = setup_complete_mcts_tree for node in nodes: node.backpropagate = mocker.MagicMock() score = tree.reward_scorer[tree.reward_scorer_name](nodes[2]) tree.backpropagate(nodes[2]) nodes[0].backpropagate.assert_called_onc...
score)
assert_*
variable
tests/mcts/test_tree.py
test_backpropagation
26
null
MolecularAI/aizynthfinder
import pytest from aizynthfinder.search.breadth_first.nodes import MoleculeNode from aizynthfinder.chem.serialization import MoleculeSerializer, MoleculeDeserializer def setup_root(default_config): def wrapper(smiles): return MoleculeNode.create_root(smiles, config=default_config) return wrapper def...
root.mol
assert
complex_expr
tests/breadth_first/test_nodes.py
test_serialization_deserialization
67
null
MolecularAI/aizynthfinder
from aizynthfinder.chem import ( FixedRetroReaction, SmilesBasedRetroReaction, TemplatedRetroReaction, TreeMolecule, UniqueMolecule, hash_reactions, ) def test_smiles_based_retroreaction(): mol = TreeMolecule(smiles="CNC(C)=O", parent=None) reaction = SmilesBasedRetroReaction(mol, react...
"CN"
assert
string_literal
tests/chem/test_reaction.py
test_smiles_based_retroreaction
92
null
MolecularAI/aizynthfinder
import pytest from aizynthfinder.chem import TreeMolecule from aizynthfinder.context.policy import ( MultiExpansionStrategy, TemplateBasedExpansionStrategy, ) from aizynthfinder.utils.exceptions import PolicyException def test_multi_expansion_strategy_wo_additive_expansion( default_config, setup_template_...
[0.7, 0.2]
assert
collection
tests/context/test_expansion_strategies.py
test_multi_expansion_strategy_wo_additive_expansion
68
null
MolecularAI/aizynthfinder
import pytest from aizynthfinder.context.collection import ContextCollection def test_empty_collection(): collection = StringCollection() assert len(collection) ==
0
assert
numeric_literal
tests/context/test_collection.py
test_empty_collection
22
null
MolecularAI/aizynthfinder
from aizynthfinder.chem import TreeMolecule from aizynthfinder.chem.serialization import MoleculeDeserializer, MoleculeSerializer from aizynthfinder.search.mcts import MctsNode, MctsSearchTree, MctsState def test_serialize_deserialize_tree( setup_complete_mcts_tree, default_config, mocker, tmpdir, ): ...
mocker.ANY)
assert_*
complex_expr
tests/mcts/test_serialization.py
test_serialize_deserialize_tree
130
null
MolecularAI/aizynthfinder
import os import gzip import json import pytest import pandas as pd from aizynthfinder.utils.files import ( cat_datafiles, split_file, start_processes, read_datafile, save_datafile, ) def create_dummy_file(tmpdir, mocker): patched_tempfile = mocker.patch("aizynthfinder.utils.files.tempfile.mk...
data2.b.to_list()
assert
func_call
tests/utils/test_file_utils.py
test_save_load_datafile_roundtrip
146
null
MolecularAI/aizynthfinder
from aizynthfinder.chem import ( FixedRetroReaction, SmilesBasedRetroReaction, TemplatedRetroReaction, TreeMolecule, UniqueMolecule, hash_reactions, ) def test_retro_reaction_copy(get_action): reaction = get_action() _ = reaction.reactants copy_ = reaction.copy() assert isinst...
reaction.index
assert
complex_expr
tests/chem/test_reaction.py
test_retro_reaction_copy
77
null
MolecularAI/aizynthfinder
def test_route_to_node(setup_complete_mcts_tree): tree, nodes = setup_complete_mcts_tree actions, route_nodes = nodes[2].path_to() assert len(actions) == 2 assert len(nodes) == 3 assert nodes[0] ==
route_nodes[0]
assert
complex_expr
tests/mcts/test_tree.py
test_route_to_node
38
null
MolecularAI/aizynthfinder
from aizynthfinder.aizynthfinder import AiZynthExpander def test_expander_defaults(get_one_step_expansion, setup_policies): expander = AiZynthExpander() setup_policies(get_one_step_expansion, config=expander.config) smi = "CCCCOc1ccc(CC(=O)N(C)O)cc1" reactions = expander.do_expansion(smi) assert ...
1
assert
numeric_literal
tests/test_expander.py
test_expander_defaults
12
null
MolecularAI/aizynthfinder
def test_promising_child_of_root(setup_mcts_search): root, _, _ = setup_mcts_search root.expand() child = root.promising_child() view = root.children_view() assert view["objects"][0] is child assert root.children ==
[child]
assert
collection
tests/mcts/test_node.py
test_promising_child_of_root
79
null
MolecularAI/aizynthfinder
from aizynthfinder.chem import TreeMolecule, SmilesBasedRetroReaction from aizynthfinder.utils.bonds import BrokenBonds def test_focussed_bonds_broken(): mol = TreeMolecule(smiles="[CH3:1][NH:2][C:3](C)=[O:4]", parent=None) reaction = SmilesBasedRetroReaction( mol, mapped_prod_smiles="[CH3:1][N...
[(2, 3)]
assert
collection
tests/utils/test_bonds.py
test_focussed_bonds_broken
19
null
MolecularAI/aizynthfinder
from aizynthfinder.chem.serialization import MoleculeSerializer, MoleculeDeserializer from aizynthfinder.chem import Molecule, TreeMolecule def test_chaining(): serializer = MoleculeSerializer() mol1 = TreeMolecule(parent=None, smiles="CCC", transform=1) mol2 = TreeMolecule(smiles="CCO", parent=mol1) ...
id(mol1)
assert
func_call
tests/chem/test_serialization.py
test_chaining
86
null
MolecularAI/aizynthfinder
import pytest from rdkit import Chem from aizynthfinder.chem import MoleculeException, Molecule def test_sanitize(): mol = Molecule(smiles="O", sanitize=True) assert Chem.MolToSmiles(mol.rd_mol) == "O" mol = Molecule(smiles="c1ccccc1(C)(C)") with pytest.raises(MoleculeException): mol.saniti...
"CC1(C)CCCCC1"
assert
string_literal
tests/chem/test_mol.py
test_sanitize
57
null
MolecularAI/aizynthfinder
from networkx import get_node_attributes, set_node_attributes import numpy as np import pytest from aizynthfinder.chem import Molecule, UniqueMolecule from aizynthfinder.context.config import Configuration from aizynthfinder.context.scoring import ( AverageTemplateOccurrenceScorer, BrokenBondsScorer, Combi...
4
assert
numeric_literal
tests/context/test_score.py
test_scoring_branched_mcts_tree
188
null
MolecularAI/aizynthfinder
import logging import pandas as pd import pytest from aizynthfinder.aizynthfinder import AiZynthFinder def state_smiles(state): return [mol.smiles for mol in state.mols] def test_dead_end_expansion(setup_aizynthfinder): """ Test the building of this tree: root root cannot be expanded ...
0
assert
numeric_literal
tests/test_finder.py
test_dead_end_expansion
40
null
MolecularAI/aizynthfinder
from aizynthfinder.chem import TreeMolecule, SmilesBasedRetroReaction from aizynthfinder.utils.bonds import BrokenBonds def test_focussed_bonds_not_broken(): mol = TreeMolecule(smiles="[CH3:1][NH:2][C:3](C)=[O:4]", parent=None) reaction = SmilesBasedRetroReaction( mol, mapped_prod_smiles="[CH3:...
True
assert
bool_literal
tests/utils/test_bonds.py
test_focussed_bonds_not_broken
34
null
MolecularAI/aizynthfinder
import numpy as np import pytest from aizynthfinder.chem import ( SmilesBasedRetroReaction, TemplatedRetroReaction, TreeMolecule, ) from aizynthfinder.context.policy import ( BondFilter, FrozenSubstructureFilter, QuickKerasFilter, ReactantsCountFilter, TemplateBasedDirectExpansionStrate...
None
assert
none_literal
tests/context/test_policy.py
test_get_actions_using_rdkit
177
null
MolecularAI/aizynthfinder
from typing import Dict, List import numpy as np import pytest import pytest_mock from aizynthfinder.utils import models def test_local_onnx_model_length(mock_onnx_model: pytest_mock.MockerFixture) -> None: onnx_model = models.LocalOnnxModel("test_model.onnx") output = len(onnx_model) expected_output = 3 ...
expected_output
assert
variable
tests/utils/test_local_onnx_model.py
test_local_onnx_model_length
22
null
MolecularAI/aizynthfinder
import glob import json import os import sys from typing import Dict, List import pandas as pd import pytest import yaml from aizynthfinder.analysis import RouteCollection from aizynthfinder.chem import MoleculeException from aizynthfinder.interfaces import AiZynthApp from aizynthfinder.interfaces.aizynthapp import m...
0
assert
numeric_literal
tests/test_cli.py
test_cli_multiple_smiles_unsanitizable
316
null
MolecularAI/aizynthfinder
import numpy as np import pytest from aizynthfinder.chem import ( SmilesBasedRetroReaction, TemplatedRetroReaction, TreeMolecule, ) from aizynthfinder.context.policy import ( BondFilter, FrozenSubstructureFilter, QuickKerasFilter, ReactantsCountFilter, TemplateBasedDirectExpansionStrate...
2
assert
numeric_literal
tests/context/test_policy.py
test_reactants_count_rejection
389
null
MolecularAI/aizynthfinder
def test_select_leaf_root(setup_complete_mcts_tree): tree, nodes = setup_complete_mcts_tree nodes[0].is_expanded = False leaf = tree.select_leaf() assert leaf is
nodes[0]
assert
complex_expr
tests/mcts/test_tree.py
test_select_leaf_root
7
null
MolecularAI/aizynthfinder
import pytest from aizynthfinder.reactiontree import ReactionTree def test_mcts_route_to_reactiontree(setup_linear_mcts, load_reaction_tree): def remove_metadata(tree_dict): if "metadata" in tree_dict: tree_dict["metadata"] = {} for child in tree_dict.get("children", []): r...
3
assert
numeric_literal
tests/test_reactiontree.py
test_mcts_route_to_reactiontree
26
null
MolecularAI/aizynthfinder
from aizynthfinder.aizynthfinder import AiZynthExpander def test_expander_top1(get_one_step_expansion, setup_policies): expander = AiZynthExpander() setup_policies(get_one_step_expansion, config=expander.config) smi = "CCCCOc1ccc(CC(=O)N(C)O)cc1" reactions = expander.do_expansion(smi, return_n=1) ...
["CCCCOc1ccc(CC(=O)Cl)cc1", "CNO"]
assert
collection
tests/test_expander.py
test_expander_top1
33
null
MolecularAI/aizynthfinder
import os import gzip import json import pytest import pandas as pd from aizynthfinder.utils.files import ( cat_datafiles, split_file, start_processes, read_datafile, save_datafile, ) def create_dummy_file(tmpdir, mocker): patched_tempfile = mocker.patch("aizynthfinder.utils.files.tempfile.mk...
"c\nd"
assert
string_literal
tests/utils/test_file_utils.py
test_split_file_even
47
null
MolecularAI/aizynthfinder
import os from unittest import mock import pytest from aizynthfinder.aizynthfinder import AiZynthFinder from aizynthfinder.context.config import Configuration from aizynthfinder.context.stock import StockException def test_init_search_yaml(write_yaml, create_dummy_templates, mock_onnx_model): templates_filename ...
[[1, 2]]
assert
collection
tests/context/test_mcts_config.py
test_init_search_yaml
388
null
MolecularAI/aizynthfinder
import logging import pandas as pd import pytest from aizynthfinder.aizynthfinder import AiZynthFinder def state_smiles(state): return [mol.smiles for mol in state.mols] def test_two_expansions_two_children(setup_aizynthfinder): """ Test the building of this tree: root / ...
5
assert
numeric_literal
tests/test_finder.py
test_two_expansions_two_children
239
null
MolecularAI/aizynthfinder
import pytest import sys import pandas as pd from aizynthfinder.chem import Molecule from aizynthfinder.context.stock import ( StockException, ) from aizynthfinder.context.stock.queries import HAS_MOLBLOOM from aizynthfinder.tools.make_stock import ( extract_plain_smiles, extract_smiles_from_module, m...
8
assert
numeric_literal
tests/context/test_stock.py
test_extract_smiles_from_plain_file
474
null
MolecularAI/aizynthfinder
import os from unittest import mock import pytest from aizynthfinder.aizynthfinder import AiZynthFinder from aizynthfinder.context.config import Configuration from aizynthfinder.context.stock import StockException def test_update_search(default_config): config = default_config assert config.search.algorithm...
6
assert
numeric_literal
tests/context/test_mcts_config.py
test_update_search
75
null
MolecularAI/aizynthfinder
import os import gzip import json import pytest import pandas as pd from aizynthfinder.utils.files import ( cat_datafiles, split_file, start_processes, read_datafile, save_datafile, ) def create_dummy_file(tmpdir, mocker): patched_tempfile = mocker.patch("aizynthfinder.utils.files.tempfile.mk...
"e\nf"
assert
string_literal
tests/utils/test_file_utils.py
test_split_file_even
48
null
MolecularAI/aizynthfinder
import pytest from aizynthfinder.search.mcts.node import ParetoMctsNode from aizynthfinder.search.mcts import MctsSearchTree def generate_root(default_config): def wrapper(smiles, config=None): return ParetoMctsNode.create_root( smiles, tree=None, config=config or default_config ) ...
[1, 1, 1]
assert
collection
tests/mcts/test_multiobjective.py
test_expand_root_node
43
null
MolecularAI/aizynthfinder
import numpy as np import networkx as nx from aizynthfinder.search.retrostar.nodes import MoleculeNode from aizynthfinder.chem.serialization import MoleculeSerializer, MoleculeDeserializer from aizynthfinder.search.andor_trees import ReactionTreeFromAndOrTrace def test_conversion_to_reaction_tree( setup_star_root...
root.mol.inchi_key
assert
complex_expr
tests/retrostar/test_retrostar_nodes.py
test_conversion_to_reaction_tree
139
null
MolecularAI/aizynthfinder
import logging import pandas as pd import pytest from aizynthfinder.aizynthfinder import AiZynthFinder def state_smiles(state): return [mol.smiles for mol in state.mols] def test_three_expansions(setup_aizynthfinder): """ Test the building of this tree: root | ...
4
assert
numeric_literal
tests/test_finder.py
test_three_expansions
300
null
MolecularAI/aizynthfinder
from aizynthfinder.chem.serialization import MoleculeSerializer, MoleculeDeserializer from aizynthfinder.chem import Molecule, TreeMolecule def test_add_single_mol(): serializer = MoleculeSerializer() mol = Molecule(smiles="CCC") id_ = serializer[mol] assert id_ ==
id(mol)
assert
func_call
tests/chem/test_serialization.py
test_add_single_mol
17
null
MolecularAI/aizynthfinder
import os from tarfile import TarFile import numpy as np import pytest from aizynthfinder.analysis import TreeAnalysis, RouteCollection from aizynthfinder.analysis.routes import SUPPORT_CLUSTERING from aizynthfinder.analysis.utils import RouteSelectionArguments from aizynthfinder.reactiontree import ReactionTree from...
5
assert
numeric_literal
tests/test_analysis.py
test_sort_nodes
20
null
MolecularAI/aizynthfinder
import pytest from aizynthfinder.reactiontree import ReactionTree def test_route_node_depth_from_json(load_reaction_tree): dict_ = load_reaction_tree("branched_route.json") rt = ReactionTree.from_dict(dict_) # Molecules loaded in a different order than when created from MCTS mols = list(rt.molecules...
6
assert
numeric_literal
tests/test_reactiontree.py
test_route_node_depth_from_json
93
null
MolecularAI/aizynthfinder
from aizynthfinder.chem import TreeMolecule from aizynthfinder.chem.serialization import MoleculeDeserializer, MoleculeSerializer from aizynthfinder.search.mcts import MctsNode, MctsSearchTree, MctsState def test_serialize_deserialize_state(default_config): mol = TreeMolecule(parent=None, smiles="CCC", transform=1...
scorer(node0)
assert
func_call
tests/mcts/test_serialization.py
test_serialize_deserialize_state
28
null
MolecularAI/aizynthfinder
from aizynthfinder.chem import TreeMolecule, SmilesBasedRetroReaction from aizynthfinder.utils.bonds import BrokenBonds def test_focussed_bonds_not_broken(): mol = TreeMolecule(smiles="[CH3:1][NH:2][C:3](C)=[O:4]", parent=None) reaction = SmilesBasedRetroReaction( mol, mapped_prod_smiles="[CH3:...
[]
assert
collection
tests/utils/test_bonds.py
test_focussed_bonds_not_broken
33
null
MolecularAI/aizynthfinder
import numpy as np from aizynthfinder.search.retrostar.search_tree import SearchTree from aizynthfinder.chem.serialization import MoleculeSerializer def test_one_iteration_filter_unfeasible(setup_search_tree): tree = setup_search_tree smi = "CN1CCC(C(=O)c2cccc(NC(=O)c3ccc(F)cc3)c2F)CC1>>CN1CCC(Cl)CC1.N#Cc1ccc...
0
assert
numeric_literal
tests/retrostar/test_retrostar.py
test_one_iteration_filter_unfeasible
22
null
MolecularAI/aizynthfinder
from aizynthfinder.chem.serialization import MoleculeSerializer, MoleculeDeserializer from aizynthfinder.chem import Molecule, TreeMolecule def test_add_tree_mol(): serializer = MoleculeSerializer() mol1 = TreeMolecule(parent=None, smiles="CCC", transform=1) mol2 = TreeMolecule(smiles="CCO", parent=mol1) ...
id(mol2)
assert
func_call
tests/chem/test_serialization.py
test_add_tree_mol
28
null
MolecularAI/aizynthfinder
import numpy as np import pytest from aizynthfinder.chem import ( SmilesBasedRetroReaction, TemplatedRetroReaction, TreeMolecule, ) from aizynthfinder.context.policy import ( BondFilter, FrozenSubstructureFilter, QuickKerasFilter, ReactantsCountFilter, TemplateBasedDirectExpansionStrate...
3
assert
numeric_literal
tests/context/test_policy.py
test_load_expansion_policy_from_config_files
49
null
MolecularAI/aizynthfinder
import pytest from aizynthfinder.chem import TreeMolecule from aizynthfinder.context.policy import ( MultiExpansionStrategy, TemplateBasedExpansionStrategy, ) from aizynthfinder.utils.exceptions import PolicyException def test_multi_expansion_strategy_cutoff( default_config, setup_template_expansion_polic...
4
assert
numeric_literal
tests/context/test_expansion_strategies.py
test_multi_expansion_strategy_cutoff
136
null
MolecularAI/aizynthfinder
from aizynthfinder.chem.serialization import MoleculeSerializer, MoleculeDeserializer from aizynthfinder.chem import Molecule, TreeMolecule def test_chaining(): serializer = MoleculeSerializer() mol1 = TreeMolecule(parent=None, smiles="CCC", transform=1) mol2 = TreeMolecule(smiles="CCO", parent=mol1) ...
id_
assert
variable
tests/chem/test_serialization.py
test_chaining
85
null
MolecularAI/aizynthfinder
import glob import json import os import sys from typing import Dict, List import pandas as pd import pytest import yaml from aizynthfinder.analysis import RouteCollection from aizynthfinder.chem import MoleculeException from aizynthfinder.interfaces import AiZynthApp from aizynthfinder.interfaces.aizynthapp import m...
4
assert
numeric_literal
tests/test_cli.py
test_cli_multiple_smiles
211
null
MolecularAI/aizynthfinder
from aizynthfinder.chem import ( FixedRetroReaction, SmilesBasedRetroReaction, TemplatedRetroReaction, TreeMolecule, UniqueMolecule, hash_reactions, ) def test_mapped_atom_bonds_rdchiral(): smi = "CC(C)C[C:1](=O)[N:2](C)O" mol = TreeMolecule(smiles=smi, parent=None) smarts = ( ...
[(2, 8), (2, 9)]
assert
collection
tests/chem/test_reaction.py
test_mapped_atom_bonds_rdchiral
219
null
MolecularAI/aizynthfinder
import os from tarfile import TarFile import numpy as np import pytest from aizynthfinder.analysis import TreeAnalysis, RouteCollection from aizynthfinder.analysis.routes import SUPPORT_CLUSTERING from aizynthfinder.analysis.utils import RouteSelectionArguments from aizynthfinder.reactiontree import ReactionTree from...
0
assert
numeric_literal
tests/test_analysis.py
test_sort_nodes
25
null
MolecularAI/aizynthfinder
import numpy as np import networkx as nx from aizynthfinder.search.retrostar.nodes import MoleculeNode from aizynthfinder.chem.serialization import MoleculeSerializer, MoleculeDeserializer from aizynthfinder.search.andor_trees import ReactionTreeFromAndOrTrace def test_conversion_to_reaction_tree( setup_star_root...
reaction.reaction_smiles()
assert
func_call
tests/retrostar/test_retrostar_nodes.py
test_conversion_to_reaction_tree
142
null
MolecularAI/aizynthfinder
import numpy as np from aizynthfinder.search.retrostar.search_tree import SearchTree from aizynthfinder.chem.serialization import MoleculeSerializer def test_serialization_deserialization( mocker, setup_search_tree, tmpdir, default_config ): tree = setup_search_tree tree.one_iteration() mocked_json_d...
mocker.ANY)
assert_*
complex_expr
tests/retrostar/test_retrostar.py
test_serialization_deserialization
90
null