Skip to content

Update to Python 3#34

Closed
Seanny123 wants to merge 5 commits intoPOVME:masterfrom
Seanny123:master
Closed

Update to Python 3#34
Seanny123 wants to merge 5 commits intoPOVME:masterfrom
Seanny123:master

Conversation

@Seanny123
Copy link

This is my naive attempt to update the code to Python 3 using the 2to3 tool. I was hoping the tool would do all the work and then running the basic example would magically work. Unfortunately, when I run:

python3 ../../POVME3.py sample_input.ini 

It gives an obscure error:

Reading frames from 4NSS.pdb
Traceback (most recent call last):
  File "../../POVME3.py", line 2204, in <module>
    if __name__ == "__main__": dorun = runit(sys.argv)
  File "../../POVME3.py", line 1795, in __init__
    index_and_pdbs = self.load_multi_frame_pdb(parameters[PDBFileName], parameters)
  File "../../POVME3.py", line 1707, in load_multi_frame_pdb
    molecules = Multithreading([(pdb_strings[idx], idx + 1, parameters) for idx in range(len(pdb_strings))], parameters[NumProcessors], MultithreadingStringToMoleculeTask)
  File "../../POVME3.py", line 145, in __init__
    for item in inputs: single_thread.value_func(item, None)
  File "../../POVME3.py", line 1254, in value_func
    resseq_reindex = False)
  File "/home/sean/git/POVME/POVME/packages/pymolecule/pymolecule.py", line 1101, in load_pdb_into_using_file_object
    self.__parent_molecule.get_atom_information()[f]
  File "<__array_function__ internals>", line 6, in append_fields
  File "/home/sean/.conda/envs/py37/lib/python3.7/site-packages/numpy/lib/recfunctions.py", line 740, in append_fields
    output = recursive_fill_fields(data, output)
  File "<__array_function__ internals>", line 6, in recursive_fill_fields
  File "/home/sean/.conda/envs/py37/lib/python3.7/site-packages/numpy/lib/recfunctions.py", line 78, in recursive_fill_fields
    output[field][:len(current)] = current
  File "/home/sean/.conda/envs/py37/lib/python3.7/site-packages/numpy/ma/core.py", line 3327, in __setitem__
    _data[indx] = dval
ValueError: could not broadcast input array from shape (0,1) into shape (0)

Other things which would help this code:

  1. Using black for automatic code formatting
  2. Using pytest to run the tests

Sean Aubin added 5 commits December 13, 2019 14:22
Used the tool `2to3` to convert code to Python 3
semi-automatically. A lot of iterators are needlessly
converted to lists.
@j-wags
Copy link
Contributor

j-wags commented Jan 4, 2020

Thanks for taking a swing at this, @Seanny123. I worked a bit on this over the holidays. The major issue is that pymolecule.py makes really heavy use of numpy character arrays for string operations, and in Python 3, numpy changes those to byte arrays. So, basically it's horrible, and all sorts of things break.

I'm working on a minimum working fix in #35. It's slow going, but I'm making forward progress, little by little.

@Seanny123
Copy link
Author

Old and obsolete.

@Seanny123 Seanny123 closed this Sep 29, 2021
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

Successfully merging this pull request may close these issues.

2 participants