Exemplo n.º 1
0
class LocalConnectivityH5(H5File):
    def __init__(self, path):
        super(LocalConnectivityH5, self).__init__(path)
        self.surface = Reference(LocalConnectivity.surface, self)
        self.matrix = SparseMatrix(LocalConnectivity.matrix, self)
        self.equation = Scalar(Attr(str), self, name='equation')
        self.cutoff = Scalar(LocalConnectivity.cutoff, self)

    def store(self, datatype, scalars_only=False, store_references=True):
        # type: (LocalConnectivity, bool, bool) -> None
        super(LocalConnectivityH5, self).store(datatype, scalars_only,
                                               store_references)
        # equations are such a special case that we will have to implement custom load store
        self.equation.store(datatype.equation.to_json(datatype.equation))

    def load_into(self, datatype):
        # type: (LocalConnectivity) -> None
        super(LocalConnectivityH5, self).load_into(datatype)

        eq = self.equation.load()
        eq = datatype.equation.from_json(eq)
        datatype.equation = eq

    def get_min_max_values(self):
        metadata = self.matrix.get_metadata()
        return metadata.min, metadata.max
Exemplo n.º 2
0
class LocalConnectivityH5(H5File):
    def __init__(self, path):
        super(LocalConnectivityH5, self).__init__(path)
        self.surface = Reference(LocalConnectivity.surface, self)
        self.matrix = SparseMatrix(LocalConnectivity.matrix, self)
        self.equation = EquationScalar(LocalConnectivity.equation, self)
        self.cutoff = Scalar(LocalConnectivity.cutoff, self)

    def store(self, datatype, scalars_only=False, store_references=True):
        # type: (LocalConnectivity, bool, bool) -> None
        super(LocalConnectivityH5, self).store(datatype, scalars_only, store_references)

    def load_into(self, datatype):
        # type: (LocalConnectivity) -> None
        super(LocalConnectivityH5, self).load_into(datatype)

    def get_min_max_values(self):
        metadata = self.matrix.get_metadata()
        return metadata.min, metadata.max
Exemplo n.º 3
0
class LocalConnectivityH5(H5File):
    def __init__(self, path):
        super(LocalConnectivityH5, self).__init__(path)
        self.surface = Reference(LocalConnectivity.surface, self)
        # this multidataset accessor works but something is off about it
        # this would be clearer
        # self.matrix, self.matrixindices, self.matrixindptr
        self.matrix = SparseMatrix(LocalConnectivity.matrix, self)
        # equation is an inlined reference
        # should this be a special equation scalar field?
        # or this?
        # this is clear about the structure, but obviously breaks the default store/load
        # self.equation_equation = Scalar(Equation.equation, self)
        # self.equation_parameters = Scalar(Equation.parameters, self)

        self.equation = Scalar(Attr(str), self, name='equation')
        self.cutoff = Scalar(LocalConnectivity.cutoff, self)

    # equations are such a special case that we will have to implement custom load store

    def store(self, datatype, scalars_only=False):
        self.surface.store(datatype.surface)
        self.matrix.store(datatype.matrix)
        self.cutoff.store(datatype.cutoff)
        self.equation.store(datatype.equation.to_json(datatype.equation))

    def load_into(self, datatype):
        datatype.gid = self.gid.load()
        datatype.matrix = self.matrix.load()
        datatype.cutoff = self.cutoff.load()
        eq = self.equation.load()
        eq = datatype.equation.from_json(eq)
        datatype.equation = eq

    def get_min_max_values(self):
        metadata = self.matrix.get_metadata()
        return metadata.min, metadata.max