Opened 8 years ago

Closed 8 years ago

#791 closed defect (fixed)

Cannot change b-factors or occupancies

Reported by: Tristan Croll Owned by: eric
Priority: major Milestone:
Component: Core Version:
Keywords: Cc:
Blocked By: Blocking:
Notify when closed: Platform: all
Project: ChimeraX

Description

m = session.models.list()[0]
a = m.atoms[0]
a.bfactor
> 1.0

a.bfactor = 0.5
a.bfactor
> 1.0

I believe the culprit here is in CoordSet.cpp, in CoordSet::set_bfactor and ::set_occupancy - where you have

..._map.insert(...)


you want:

..._map.insert_or_assign(...)


From the documentation for std::unordered_map::insert:

Inserts element(s) into the container, if the container doesn't already contain an element with an equivalent key.

Change History (3)

comment:1 by Tristan Croll, 8 years ago

Oops, wait. insert_or_assign is a C++17 addition. But

..._map[a] = val;

works just fine.

comment:2 by pett, 8 years ago

You know, I would never in a million years have guessed that 'insert' doesn't actually insert elements, but essentially just silently fails. Conrad was pretty shocked too. Now I am going to have to grep my code for all uses of 'insert' and rectify the ones where it needs to actually insert things.

Thanks for the heads up.

--Eric

comment:3 by pett, 8 years ago

Resolution: fixed
Status: assignedclosed

Okay, after a code review finding no other instances of this usage (though I did find a problem with one of my uses of vector.insert!) -- fixed.

Note: See TracTickets for help on using tickets.