Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error in numpy/ list multiplication inside mutate_smi_list #9

Closed
sofroniewn opened this issue Jul 26, 2022 · 2 comments
Closed

error in numpy/ list multiplication inside mutate_smi_list #9

sofroniewn opened this issue Jul 26, 2022 · 2 comments
Assignees

Comments

@sofroniewn
Copy link

Hello, I am trying to run the provided example, but get the following error

$ python ./example.py
    Unique and valid fragments generated: 107308
    Unique and valid fragments generated: 107308
On generation 0/200
/Users/nsofroniew/opt/anaconda3/envs/chem/lib/python3.9/site-packages/janus/janus.py:457: RuntimeWarning: overflow encountered in power
  prob_ = 1.0 / (3.0 ** ((F_50_val - fitness) / (F_50_val - F_25_val)) + 1)
    (Explr) Top Fitness: 15.811199999999957
    (Explr) Top Smile: CCCCCCCCCCCCCCCCOP(=O)(O)Oc1ccc(C=Cc2ccc(OP(=O)(O)OCCCCCCCCCCCCCCCC)cc2)cc1
Traceback (most recent call last):
  File "/Users/nsofroniew/Documents/code/chem/janus/tests/./example.py", line 81, in <module>
  File "/Users/nsofroniew/opt/anaconda3/envs/chem/lib/python3.9/site-packages/janus/janus.py", line 317, in run
    mut_smi_loc = self.mutate_smi_list(smiles_local_search, "local")
  File "/Users/nsofroniew/opt/anaconda3/envs/chem/lib/python3.9/site-packages/janus/janus.py", line 137, in mutate_smi_list
    smi_list = smi_list * num_random_samples
numpy.core._exceptions._UFuncNoLoopError: ufunc 'multiply' did not contain a loop with signature matching types (dtype('<U98'), dtype('int64')) -> None

It looks like smi_list has become a numpy array, which is unintended and it should be a list. This can be fixed by making this line

smi_list = smi_list * num_random_samples
be

    smi_list = list(smi_list) * num_random_samples

There could be other, more desirable fixes that avoid this problem altogether. I am happy to submit a PR if this fix is desired though.

@sofroniewn
Copy link
Author

Looks like the array in question might come from

population_sort = np.array(self.population)[idx_sort]

@sofroniewn sofroniewn changed the title error is numpy/ list multiplication error ns numpy/ list multiplication inside mutate_smi_list Jul 26, 2022
@sofroniewn sofroniewn changed the title error ns numpy/ list multiplication inside mutate_smi_list error in numpy/ list multiplication inside mutate_smi_list Jul 26, 2022
@gkwt gkwt self-assigned this Jul 26, 2022
@gkwt
Copy link
Collaborator

gkwt commented Jul 26, 2022

Thanks for reporting this issue. It will be fixed in the next push!

@gkwt gkwt closed this as completed Jul 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants