Skip to content

Fix the bug when type_map has only one element#1196

Merged
wanghan-iapcm merged 2 commits intodeepmodeling:masterfrom
marian-code:patch-2
Oct 13, 2021
Merged

Fix the bug when type_map has only one element#1196
wanghan-iapcm merged 2 commits intodeepmodeling:masterfrom
marian-code:patch-2

Conversation

@marian-code
Copy link
Contributor

Numpy has a bit odd behavior I ran into. The method ndarray.loadtxt() when loading from array file of length 1 outputs only the array element, not array of length=1.

import numpy as np

np.__version__
"1.20.3"

!cat array.raw
A

np.loadtxt("array.raw").tolist()
"A"

This breaks code in this place:

atom_type_ = [type_map.index(self.type_map[ii]) for ii in self.atom_type]
the list comprehension will try to iterate through characters in string and fail.

Numpy has a bit odd behavior I ran into. The method `ndarray.loadtxt()` when loading from array file of length 1 outputs only the array element, not array of length=1.

```python
import numpy as np

np.__version__
"1.20.3"

!cat array.raw
A

np.loadtxt("array.raw").tolist()
"A"
```
@codecov-commenter
Copy link

codecov-commenter commented Oct 8, 2021

Codecov Report

Merging #1196 (8dbb492) into master (5a84796) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #1196   +/-   ##
=======================================
  Coverage   76.04%   76.04%           
=======================================
  Files          91       91           
  Lines        7258     7258           
=======================================
  Hits         5519     5519           
  Misses       1739     1739           
Impacted Files Coverage Δ
deepmd/utils/data.py 91.31% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5a84796...8dbb492. Read the comment docs.

@wanghan-iapcm wanghan-iapcm changed the title Update data.py Fix the bug when type_map has only one element Oct 9, 2021
@njzjz njzjz requested a review from amcadmus October 12, 2021 09:28
@wanghan-iapcm wanghan-iapcm merged commit d477507 into deepmodeling:master Oct 13, 2021
@njzjz njzjz mentioned this pull request Oct 14, 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.

[BUG] deepmd GPU version cannot read dpdate-typed dataset, but CPU version can

4 participants