Commit 4a69e010 authored by jlaura's avatar jlaura Committed by Trent Hare
Browse files

Adds serialization to Ls (#18)

* Adds Cassini-ISS supports and begins refactor to generic.

* Finalizes refactor to generic framer

* Refactors out bad class attribute

* mend

* Adds conftest fixtures and model serialization.

* Adds serialization to Ls
parent b317fdb2
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -4,9 +4,14 @@ import pytest

import usgscam as cam

# TODO: This should cycle through all of our JSON instantiation examples
def test_pickle_io(generic_model):
    pfile = pickle.dumps(generic_model, 2)
    loaded_model = pickle.loads(pfile)
    assert generic_model.name == loaded_model.name
    assert isinstance(loaded_model, cam.genericframe.SensorModel)

def test_ls_pickle_io(ctx_model):
    pfile = pickle.dumps(ctx_model, 2)
    loaded_model = pickle.loads(pfile)
    assert ctx_model.name == loaded_model.name
    assert isinstance(loaded_model, cam.genericls.SensorModel)
+1 −0
Original line number Diff line number Diff line
@@ -64,6 +64,7 @@ cdef extern from "UsgsAstroLsSensorModel.h":
        string getSensorMode()
        CppEllipsoid getEllipsoid()
        void setEllipsoid(const CppEllipsoid &ellipsoid)
        void replaceModelState(const string& argState);

cdef extern from "UsgsAstroLsPlugin.h":
    cdef cppclass CppGenericLsPlugin "UsgsAstroLsPlugin":
+10 −0
Original line number Diff line number Diff line
@@ -23,6 +23,12 @@ cdef class SensorModel:
    def __dealloc__(self):
        del self.thisptr

    def __getstate__(self):
        return self.state.encode()

    def __setstate__(self, state):
        self.state = state

    @staticmethod
    cdef factory(CppGenericLsSensorModel *obj):
        py_obj = result = SensorModel.__new__(SensorModel, _raw=True)
@@ -208,6 +214,10 @@ cdef class SensorModel:
        """
        return self.thisptr.getModelState().decode()

    @state.setter
    def state(self, state):
        self.thisptr.replaceModelState(state)

    @property
    def name(self):
        """