Coder Social home page Coder Social logo

Frame properties revisions about garnett HOT 6 CLOSED

bdice avatar bdice commented on August 23, 2024
Frame properties revisions

from garnett.

Comments (6)

klywang avatar klywang commented on August 23, 2024

Aspects of the issue that still need to be addressed:

  • The image property (and possibly others) should be supported)
    Bonds, groups, angle data etc. supported in GSD but not readable in glotzformats

from garnett.

bdice avatar bdice commented on August 23, 2024

Images are supported

The image property is supported now, as of ef49605.

The others (bonds, groups, angles...) are not yet supported. I think it's okay to leave that where it is for now, and consider it for a future improvement if/when someone needs it. These properties are much more important for biochemical studies where particles form molecules. Also only GSD and GTAR would support storing those, to my knowledge (would need to confirm this guess).

Handling Defaults

There is a bit of work left to do with handling defaults. This was discussed at a code development meeting on February 5, 2019.

Suppose you try to read a trajectory that doesn't store some piece of information (e.g. POS files don't store masses), like this:

>>> import glotzformats as gf
>>> with gf.read('FeSiUC.pos') as traj:
...   assert traj[0].mass is None
...
>>>

Currently, those "unstored" properties are set as None. At the meeting we decided that it would be better to raise AttributeError or similar if the user attempts to access a property that isn't defined by the original trajectory file. It's a question of how much we want to assume about the user's data, and it's probably safer to assume as little as possible. Let's discuss this further at our next meeting.

from garnett.

lyrivera avatar lyrivera commented on August 23, 2024

@bdice I think implementing the __getattribute__ method to the Frame class as illustrated below:

def __getattribute__(self, attr):
    value = super(Frame, self).__getattribute__(attr);
    if value is None:
        raise AttributeError
    else:
        return value;

will produce the desired behavior. However, it will break other parts of the code, specially the tests and writers that consistently check if attributes are None. These parts would need to be modified to appropriately catch the AttributeError instead of checking if frame.attribute is not None. Is this the way to go about this?

from garnett.

bdice avatar bdice commented on August 23, 2024

@lyrivera You're correct, the tests and writers would need to be changed as you described.

For the tests, you can use self.assertRaises like in this example, except for AttributeError: https://github.com/glotzerlab/glotzformats/blob/master/tests/test_trajectory.py#L88

For the writers, you'll want to try: ...(write the attribute data)... except AttributeError: ...(don't write anything, or write defaults if required by the format).

from garnett.

lyrivera avatar lyrivera commented on August 23, 2024

Sounds good. I'll work on it.

from garnett.

lyrivera avatar lyrivera commented on August 23, 2024

Resolved on PR #68. Closing now.

from garnett.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.