Exemplo n.º 1
0
 def on_save(self):
     """ Save the file to the previous filename  """
     if self.filename:
         save_yaml(self.model.workflow, self.filename)
         self.model.modified = False
     else:
         self.on_save_as()
Exemplo n.º 2
0
    def testSerializeWorkflowItemV1(self):
        with params_traits_comparator(Stats1DPlotParams):
            fh, filename = tempfile.mkstemp()
            try:
                os.close(fh)

                save_yaml(self.view,
                          filename,
                          lock_versions={
                              WorkflowItem: 1,
                              pd.Series: 1
                          })
                new_view = load_yaml(filename)
            finally:
                os.unlink(filename)

            self.maxDiff = None

            self.assertDictEqual(
                self.view.trait_get(
                    self.view.copyable_trait_names(
                        **{"status": lambda t: t is not True})),
                new_view.trait_get(
                    self.view.copyable_trait_names(
                        **{"status": lambda t: t is not True})))
Exemplo n.º 3
0
 def on_save_as(self):
     dialog = DefaultFileDialog(parent = self.window.control,
                                action = 'save as', 
                                default_suffix = "flow",
                                wildcard = (FileDialog.create_wildcard("Cytoflow workflow", "*.flow") + ';' + #@UndefinedVariable  
                                            FileDialog.create_wildcard("All files", "*")))                    #@UndefinedVariable  
     
     if dialog.open() == OK:
         save_yaml(self.model.workflow, dialog.path)
         self.filename = dialog.path
         self.model.modified = False
         self.window.title = "Cytoflow - " + self.filename
Exemplo n.º 4
0
    def testSerialize(self):
        fh, filename = tempfile.mkstemp()
        try:
            os.close(fh)

            save_yaml(self.op, filename)
            new_op = load_yaml(filename)

        finally:
            os.unlink(filename)

        self.maxDiff = None

        self.assertDictEqual(self.op.trait_get(self.op.copyable_trait_names()),
                             new_op.trait_get(self.op.copyable_trait_names()))
Exemplo n.º 5
0
    def testSerializeV1(self):
        with params_traits_comparator(HistogramPluginView, HistogramPlotParams):
            fh, filename = tempfile.mkstemp()
            try:
                os.close(fh)

                save_yaml(self.view, filename, lock_versions = {HistogramPlotParams : 1})
                new_view = load_yaml(filename)
            finally:
                os.unlink(filename)

            self.maxDiff = None

            self.assertDictEqual(self.view.trait_get(self.view.copyable_trait_names()),
                                 new_view.trait_get(self.view.copyable_trait_names()))
Exemplo n.º 6
0
    def testSerialize(self):
        with params_traits_comparator(BarChartPlotParams):
            fh, filename = tempfile.mkstemp()
            try:
                os.close(fh)

                save_yaml(self.view, filename)
                new_view = load_yaml(filename)
            finally:
                os.unlink(filename)

            self.maxDiff = None

            self.assertDictEqual(self.view.trait_get(self.view.copyable_trait_names(**{"status" : lambda t: t is not True})),
                                 new_view.trait_get(self.view.copyable_trait_names(**{"status" : lambda t: t is not True})))
    def testSerialize(self):
        with params_traits_comparator(DensityPlotParams):
            fh, filename = tempfile.mkstemp()
            try:
                os.close(fh)

                save_yaml(self.view, filename)
                new_view = load_yaml(filename)
            finally:
                os.unlink(filename)

            self.maxDiff = None

            self.assertDictEqual(self.view.trait_get(self.view.copyable_trait_names()),
                                 new_view.trait_get(self.view.copyable_trait_names()))
Exemplo n.º 8
0
 def testSerialize(self):
     wi = self.workflow.workflow[0]
     op = wi.operation
     fh, filename = tempfile.mkstemp()
     try:
         os.close(fh)
         
         save_yaml(op, filename)
         new_op = load_yaml(filename)
         
     finally:
         os.unlink(filename)
         
     self.maxDiff = None
     new_op.ret_events = op.ret_events
     self.assertDictEqual(op.trait_get(op.copyable_trait_names()),
                          new_op.trait_get(op.copyable_trait_names()))
Exemplo n.º 9
0
    def testSerialize(self):
        with params_traits_comparator(_BleedthroughControl), \
                params_traits_comparator(_TranslationControl):
            fh, filename = tempfile.mkstemp()
            try:
                os.close(fh)

                save_yaml(self.op, filename)
                new_op = load_yaml(filename)
            finally:
                os.unlink(filename)

            self.maxDiff = None

            self.assertDictEqual(
                self.op.trait_get(self.op.copyable_trait_names()),
                new_op.trait_get(self.op.copyable_trait_names()))
Exemplo n.º 10
0
    def testSerialize(self):
        with params_traits_comparator(WorkflowItem, ImportPluginOp, ChannelStatisticPluginOp):
            fh, filename = tempfile.mkstemp()
            try:
                os.close(fh)
                 
                save_yaml(self.workflow.workflow, filename)
                new_workflow = load_yaml(filename)
                 
            finally:
                os.unlink(filename)
                 
            self.maxDiff = None

            for i in range(len(new_workflow)):
                self.assertDictEqual(self.workflow.workflow[i].trait_get(self.workflow.workflow[i].copyable_trait_names(status = lambda t: t is not True)),
                                     new_workflow[i].trait_get(self.workflow.workflow[i].copyable_trait_names(status = lambda t: t is not True)))
Exemplo n.º 11
0
 def testSerializeV1(self):
     HistogramPlotParams.__eq__ = traits_eq
     HistogramPlotParams.__hash__ = traits_hash
     
     fh, filename = tempfile.mkstemp()
     try:
         os.close(fh)
         
         save_yaml(self.view, filename, lock_versions = {HistogramPlotParams : 1})
         new_view = load_yaml(filename)
         
     finally:
         os.unlink(filename)
         
     self.maxDiff = None
                  
     self.assertDictEqual(self.view.trait_get(self.view.copyable_trait_names()),
                          new_view.trait_get(self.view.copyable_trait_names()))
Exemplo n.º 12
0
 def testSerialize(self):
     Stats2DPlotParams.__eq__ = traits_eq
     Stats2DPlotParams.__hash__ = traits_hash
     
     fh, filename = tempfile.mkstemp()
     try:
         os.close(fh)
            
         save_yaml(self.view, filename)
         new_view = load_yaml(filename)
            
     finally:
         os.unlink(filename)
            
     self.maxDiff = None
                     
     self.assertDictEqual(self.view.trait_get(self.view.copyable_trait_names()),
                          new_view.trait_get(self.view.copyable_trait_names()))
Exemplo n.º 13
0
    def testSerialize(self):
        with params_traits_comparator(EmptyPlotParams):
            fh, filename = tempfile.mkstemp()
            try:
                os.close(fh)

                save_yaml(self.view, filename)
                new_view = load_yaml(filename)
            finally:
                os.unlink(filename)

            self.maxDiff = None

            old_traits = self.view.trait_get(self.view.copyable_trait_names())
            new_traits = new_view.trait_get(self.view.copyable_trait_names())

            # we don't serialize the result
            old_traits['result'] = None

            self.assertDictEqual(old_traits, new_traits)
Exemplo n.º 14
0
    def testSerialize(self):

        _BleedthroughControl.__eq__ = traits_eq
        _BleedthroughControl.__hash__ = traits_hash

        _TranslationControl.__eq__ = traits_eq
        _TranslationControl.__hash__ = traits_hash

        fh, filename = tempfile.mkstemp()
        try:
            os.close(fh)

            save_yaml(self.op, filename)
            new_op = load_yaml(filename)

        finally:
            os.unlink(filename)

        self.maxDiff = None

        self.assertDictEqual(self.op.trait_get(self.op.copyable_trait_names()),
                             new_op.trait_get(self.op.copyable_trait_names()))
Exemplo n.º 15
0
    def testSerializeWorkflowItemV1(self):
        Stats1DPlotParams.__eq__ = traits_eq
        Stats1DPlotParams.__hash__ = traits_hash

        fh, filename = tempfile.mkstemp()
        try:
            os.close(fh)

            save_yaml(self.view,
                      filename,
                      lock_versions={
                          WorkflowItem: 1,
                          pandas.Series: 1
                      })
            new_view = load_yaml(filename)

        finally:
            os.unlink(filename)

        self.maxDiff = None

        self.assertDictEqual(
            self.view.trait_get(self.view.copyable_trait_names()),
            new_view.trait_get(self.view.copyable_trait_names()))