Example #1
0
    def parse(self):
        """Parse the list into proper data format while doing error checking"""
        from numpy import array
        import string

        #check that it it is 2 or 3 dimensional
        if array(self.points).ndim is 2:
            #we have a single list of points
            tempCoords = libsmac.coord_t()
            tempCoordlist = libsmac.coordlist_t()
            for i in range(0, len(self.points)):
                tempCoords[:] = self.points[i]
                tempCoordlist.append(tempCoords)
            #copy coordlist to our object
            self.coords = tempCoordlist
            self.pointInformation = {"a": self.coords}
            self.dimension = len(self.points[0])

        elif array(self.points).ndim is 3:
            #we have a multi list!
            self.dimension = array(self.points)[0][0].size
            if len(self.points) > 26:
                raise FormatError(
                    self, "Python multilist has a maximum of 26 types allowed")

            for i in range(0, len(self.points)):
                tempCoords = libsmac.coord_t()
                tempCoordlist = libsmac.coordlist_t()
                for j in range(0, len(self.points[0])):
                    tempCoords[:] = self.points[i][j]
                    tempCoordlist.append(tempCoords)
                self.pointInformation[
                    string.ascii_lowercase[i]] = tempCoordlist
                del tempCoords
                del tempCoordlist
        else:
            raise FormatError(
                self, "PythonList.parse list must be 2 or 3 dimensional")
Example #2
0
    def parse(self):
        """Parse the list into proper data format while doing error checking"""
        from numpy import array
        import string


        #check that it it is 2 or 3 dimensional
        if array(self.points).ndim is 2:
            #we have a single list of points
            tempCoords = libsmac.coord_t();
            tempCoordlist = libsmac.coordlist_t()
            for i in range(0,len(self.points)):
                tempCoords[:] = self.points[i]
                tempCoordlist.append(tempCoords)
            #copy coordlist to our object
            self.coords = tempCoordlist
            self.pointInformation = {"a":self.coords}
            self.dimension = len(self.points[0])

        elif array(self.points).ndim is 3:
            #we have a multi list!
            self.dimension = array(self.points)[0][0].size
            if len(self.points) > 26:
                raise FormatError(self, "Python multilist has a maximum of 26 types allowed")

            for i in range(0,len(self.points)):
                tempCoords = libsmac.coord_t();
                tempCoordlist = libsmac.coordlist_t()
                for j in range(0,len(self.points[0])):
                    tempCoords[:] = self.points[i][j]
                    tempCoordlist.append(tempCoords)
                self.pointInformation[string.ascii_lowercase[i]] = tempCoordlist
                del tempCoords
                del tempCoordlist
        else:
            raise FormatError(self, "PythonList.parse list must be 2 or 3 dimensional")
Example #3
0
        typeText = elem.text
        typeList = []
        for line in typeText.splitlines():
            typeList.append(a)

        # After filtering copy over to the coordlist
        data = {}
        for index, type in enumerate(typeText):
            if not data.has_key(type):
                data[key] = []
            data.key.append(pointList[index])

        # Copy over the data into coords, and save into the point information
        for type, pointList in data.iteritems():
            # Copy over the coordinates to C++
            coords = libsmac.coordlist_t()
            coords[:] = pointList

            # Save the object in the pointInformation
            self.pointInformation[type] = coords

    def __str__(self):
        """String representation of the hoomd file format"""
        return self.formatName + "{" + self.filename + ":" + self.dimension + "}"

    # Implementation of the BaseFormat interface
    def getText(self):
        return self.text

    def getFormatName(self):
        return self.formatName
Example #4
0
        typeText = elem.text
        typeList = []
        for line in typeText.splitlines():
            typeList.append(a)

        # After filtering copy over to the coordlist
        data = {}
        for index, type in enumerate(typeText):
            if not data.has_key(type):
                data[key] = []
            data.key.append(pointList[index])

        # Copy over the data into coords, and save into the point information
        for type, pointList in data.iteritems():
            # Copy over the coordinates to C++
            coords = libsmac.coordlist_t()
            coords[:] = pointList

            # Save the object in the pointInformation
            self.pointInformation[type] = coords

    def __str__(self):
        """String representation of the hoomd file format"""
        return self.formatName + "{" + self.filename + ":" + self.dimension + "}"
    # Implementation of the BaseFormat interface
    def getText(self):
        return self.text

    def getFormatName(self):
        return self.formatName