GithubHelp home page GithubHelp logo

pypif's Introduction

pypif

status PyPI version

About

Tools to serialize and deserialize to and from the PIF schema. This package provides python objects for each object in the PIF schema and methods for serialization and deserialization.

There is a companion Java library called JPIF.

Installation

Requirements

  • Python >= 2.7 or >= 3.3

Setup

pypif is published on PyPI, so it can be installed with pip:

$ pip install pypif

Example

The following example creates a PIF record that saves the band gap of MgO2 as equal to 7.8 eV.

from pypif import pif
from pypif.obj import *


chemical_system = ChemicalSystem()
chemical_system.chemical_formula = 'MgO2'

band_gap = Property()
band_gap.name = 'Band gap'
band_gap.scalars = 7.8
band_gap.units = 'eV'

chemical_system.properties = band_gap

print(pif.dumps(chemical_system, indent=4))

This example will serialize to the following JSON representation:

{
    "category": "system.chemical",
    "chemicalFormula": "MgO2",
    "properties": {
        "units": "eV",
        "name": "Band gap",
        "scalars": [
            {
                "value": 7.8
            }
        ]
    }
}

Schema

A detailed discussion of the PIF schema and usage are available at http://citrine.io/pif.

pypif's People

Contributors

joannehill avatar kjaym avatar kjmichel avatar latture avatar maxhutch avatar saurabh02 avatar sinistral avatar ventura-rivera avatar wardlt avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pypif's Issues

pif.dump(s) should not allow write of illegal records

pif.load(s) only works when the object being read is a System-type object with a category field. pif.dump(s) should be modified so that it cannot print anything that cannot be read by load(s). Practically, this means that only System-type objects should be serializable.

python3 support

This project seems to install fine on python3; it is likely very nearly common subset. Could the tests be run in python3 to verify support?

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.