Universal Boxes

Issue #113 resolved
Matthew Spellings created an issue

As discussed in developer meeting on 2016/07/27, it would be convenient if we wouldn't have to shuffle box representations around constantly among freud, glotzformats, and plato. Freud uses box.get{Lx,Ly,Lz,TiltFactorXY,...}() functions. Glotzformats uses a class with attributes (Lx, Ly, Lz, ...). Plato uses an array [Lx, Ly, Lz, ...]. Since we wouldn't want any one of these packages to be prerequisites for the other, a neutral "stock python" solution that describes the basic things we need to keep track of would be useful. I propose the following neutral ground:

from collections import namedtuple
Box = namedtuple('Box', ['Lx', 'Ly', 'Lz', 'xy', 'xz', 'yz'])

This way, as long as any box class exposes these six members (easy to do even if the internal representation is different with properties), it will be able to be used interchangeably. Individual box classes in freud, glotzformats, and so on will also be free to expose whatever extra functionality they wish (calculating volume, computing a box matrix, etc).

Comments (9)

  1. Eric Harper

    Going through old notes and found "weird if z=0, is2D=True"; this should fix/address issue if indeed this issue still exists (was from 3/5/16)

  2. Eric Harper

    Thanks! Btw I have a few notes of some features we should think about adding (basically people trying to construct 2D boxes and not realizing they got a 3D box)

  3. Eric Harper

    @mspells @csadorf was this already resolved? I think @csadorf fixed this, but the issue wasn't closed.

  4. Log in to comment