示例#1
0
 def __post_init__(self) -> None:
     self._properties: StrDict = {}
     self.stock = Stock()
     self.expansion_policy = ExpansionPolicy(self)
     self.filter_policy = FilterPolicy(self)
     self.scorers = ScorerCollection(self)
     self.molecule_cost = MoleculeCost()
     self._logger = logger()
示例#2
0
def test_mol_cost_cache(mocker):
    mol = Molecule(smiles="CCCC")
    mocker.patch("aizynthfinder.context.cost.ZeroMoleculeCost.__call__")
    cost = MoleculeCost()
    cost[cost.selection].__call__.return_value = 5.0

    assert cost(mol) == 5.0
    assert cost(mol) == 5.0
    cost[cost.selection].__call__.assert_called_once()
示例#3
0
    def __post_init__(self) -> None:
        self._properties: StrDict = {}
        filename = os.path.join(data_path(), "config.yml")
        with open(filename, "r") as fileobj:
            _config = yaml.load(fileobj.read(), Loader=yaml.SafeLoader)
        self._update_from_config(_config)

        self.stock = Stock()
        self.expansion_policy = ExpansionPolicy(self)
        self.filter_policy = FilterPolicy(self)
        self.scorers = ScorerCollection(self)
        self.molecule_cost = MoleculeCost()
        self._logger = logger()
示例#4
0
def test_load_cost_from_config():
    cost = MoleculeCost()

    cost.load_from_config(zero={})

    assert len(cost) == 1
示例#5
0
def test_load_cost():
    cost = MoleculeCost()

    cost.load(ZeroMoleculeCost())
    assert len(cost) == 1
示例#6
0
def test_create_mol_cost():
    mol = Molecule(smiles="CCCC")

    assert MoleculeCost()(mol) == 0.0