shirtsgroup/cg_openmm

list of quantities vs. quantity with list as value

cwalker7 opened this issue · 0 comments

There are two ways of making lists with simtk units, which can cause issues when getting their values if we don't use some standard convention throughout cg_openmm.

  1. a list of quantities
[0*unit.degrees, 180*unit.degrees]
[Quantity(value=0, unit=degree), Quantity(value=180, unit=degree)]
  1. a quantity whose value is a list
[0,180]*unit.degrees
Quantity(value=[0, 180], unit=degree)

Indexing works the same way for both methods.
However, we can't apply value_in_unit(unit.degrees) to the first case. We can apply it only to the second case.

I came up with some logic in cg_build.add_force (see #102 ) to handle both types of lists, but it seems like this is an issue that comes up in many other places (especially the free energy / entropy / enthalpy code)