Opened 5 years ago

Closed 5 years ago

Last modified 5 years ago

#3337 closed defect (fixed)

Error assigning non-contiguous array to atom.bfactors

Reported by: Tristan Croll Owned by: Tom Goddard
Priority: normal Milestone:
Component: Core Version:
Keywords: Cc: Eric Pettersen
Blocked By: Blocking:
Notify when closed: Platform: all
Project: ChimeraX

Description

The following bug report has been submitted:
Platform:        Linux-3.10.0-1062.9.1.el7.x86_64-x86_64-with-centos-7.7.1908-Core
ChimeraX Version: 1.0rc202005270557 (2020-05-27 05:57:28 UTC)
Description
A little bit of numpy weirdness going on:

{{{
from chimerax.atomic import selected_atoms
sel = selected_atoms(session)
sel.bfactors.shape
# (2,)
sel.bfactors[::-1].shape
# (2,)
sel.bfactors = sel.bfactors[::-1]

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-13-0c90188795d4> in <module>
----> 1 selected_atoms(session).bfactors = selected_atoms(session).bfactors[::-1]

/opt/UCSF/ChimeraX/lib/python3.7/site-packages/chimerax/atomic/molc.py in set_prop(self, values)
    216                     # Allocate numpy array of values to pass to C.
    217                     va = empty((n,value_count), value_type)
--> 218                     va[:] = values
    219                     v = pointer(va)
    220                 cset(self._c_pointers, n, v)

ValueError: could not broadcast input array from shape (2) into shape (2,1)

sel.bfactors = sel.bfactors
# Fine

import numpy
sel.bfactors = numpy.require(sel.bfactors[::-1], requirements='C')
# Fine

}}}

Log:
UCSF ChimeraX version: 1.0rc202005270557 (2020-05-27)  
© 2016-2020 Regents of the University of California. All rights reserved.  
How to cite UCSF ChimeraX  

> open sCoat_AlF4_refine_13.pdb

Chain information for sCoat_AlF4_refine_13.pdb #1  
---  
Chain | Description  
A | No description available  
  

> dssp

> isolde start

> set selectionWidth 4

Chain information for sCoat_AlF4_refine_13.pdb  
---  
Chain | Description  
1.2/A | No description available  
  
Done loading forcefield  

> set bgColor white

Discarding unrecognised/unsupported data array /H8_4_1/H8_4_1/ISYM_H8_4_1 Y  

> addh

Summary of feedback from adding hydrogens to sCoat_AlF4_refine_13.pdb #1.2  
---  
notes | No usable SEQRES records for sCoat_AlF4_refine_13.pdb (#1.2) chain A;
guessing termini instead  
Chain-initial residues that are actual N termini: /A ARG 41  
Chain-initial residues that are not actual N termini:  
Chain-final residues that are actual C termini:  
Chain-final residues that are not actual C termini: /A ARG 678  
633 hydrogen bonds  
/A ARG 678 is not terminus, removing H atom from 'C'  
4854 hydrogens added  
  

> hide HC

> view :ALF

> view :273

> select up

86 atoms, 83 bonds, 1 model selected  

> select up

268 atoms, 267 bonds, 1 model selected  

> select clear

> select clear

Updating bulk solvent parameters...  

> select #1

9577 atoms, 9625 bonds, 32 models selected  

> select clear

Updating bulk solvent parameters...  

> color bfactor

9577 atoms, 662 residues, atom bfactor range 35.5 to 346  

> ui tool show Shell

/opt/UCSF/ChimeraX/lib/python3.7/site-packages/IPython/core/history.py:226:
UserWarning: IPython History requires SQLite, your history will not be saved  
warn("IPython History requires SQLite, your history will not be saved")  

> color bfactor

9577 atoms, 662 residues, atom bfactor range 35.5 to 346  




OpenGL version: 3.3.0 NVIDIA 440.33.01
OpenGL renderer: TITAN Xp/PCIe/SSE2
OpenGL vendor: NVIDIA Corporation
Manufacturer: Dell Inc.
Model: Precision T5600
OS: CentOS Linux 7 Core
Architecture: 64bit ELF
CPU: 32 Intel(R) Xeon(R) CPU E5-2687W 0 @ 3.10GHz
Cache Size: 20480 KB
Memory:
	              total        used        free      shared  buff/cache   available
	Mem:            62G        8.6G         28G        243M         25G         53G
	Swap:          4.9G          0B        4.9G

Graphics:
	03:00.0 VGA compatible controller [0300]: NVIDIA Corporation GP102 [TITAN Xp] [10de:1b02] (rev a1)	
	Subsystem: NVIDIA Corporation Device [10de:11df]	
	Kernel driver in use: nvidia
PyQt version: 5.12.3
Compiled Qt version: 5.12.4
Runtime Qt version: 5.12.8

Change History (4)

comment:1 by Eric Pettersen, 5 years ago

Cc: Eric Pettersen added
Component: UnassignedCore
Owner: set to Tom Goddard
Platform: all
Project: ChimeraX
Status: newassigned
Summary: ChimeraX bug report submissionNumpy problems

comment:2 by Tom Goddard, 5 years ago

Resolution: fixed
Status: assignedclosed
Summary: Numpy problemsError assigning non-contiguous array to atom.bfactors

Fixed in ChimeraX 1.1.

Assigning a molecular collection attribute like bfactors with a non C-ordered array (in this case stride is -1) requires the code to copy the array to C-order (ie stride 1) before calling C++ code. The array being copied to had the wrong shape (n,1) instead of (n,). It is surprising this error wasn't hit in the past few years. Assigning with a non C-ordered array is apparently exceedingly rare.

in reply to:  3 ; comment:3 by Tristan Croll, 5 years ago

Yeah - only reason it came up is I thought it would be a quick and easy way to swap the B-factors of two atoms.

 
 

 


in reply to:  4 ; comment:4 by goddard@…, 5 years ago

Code that never gets executed is scary stuff.  That code could never have worked when assigning a non C-ordered array of scalar values.  (It would work for assigning non C-order rgba colors).  So it must be that none of our code has used it.  It has me curious now, how much of ChimeraX code is dead code, never or almost never executed?
Note: See TracTickets for help on using tickets.