def testScatterplot(self): import numpy as np import matplotlib.pyplot as plt flow.ScatterplotView(xchannel="V2-A", ychannel="Y2-A", xscale="linear", yscale="linear", huefacet="Dox").plot(self.ex) ax = plt.gca() np.testing.assert_array_equal( ax.get_xticks(), np.array([-500., 0., 500., 1000., 1500., 2000., 2500., 3000.]), ) np.testing.assert_array_equal( ax.get_yticks(), np.array([ -10000., 0., 10000., 20000., 30000., 40000., 50000., 60000., 70000. ]), ) flow.ScatterplotView(xchannel="V2-A", ychannel="Y2-A", xscale="log", yscale="log", huefacet="Dox").plot(self.ex) ax = plt.gca() np.testing.assert_array_equal( ax.get_xticks(), np.array([1.e-2, 1.e-1, 1., 1.e1, 1.e2, 1.e3, 1.e4, 1.e5]), ) np.testing.assert_array_equal( ax.get_yticks(), np.array([1.e-2, 1.e-1, 1., 1.e1, 1.e2, 1.e3, 1.e4, 1.e+05, 1.e6]), ) flow.ScatterplotView(xchannel="V2-A", ychannel="Y2-A", xscale="logicle", yscale="logicle", huefacet="Dox").plot(self.ex) ax = plt.gca() np.testing.assert_array_equal( ax.get_xticks(), np.array([-100., 0., 100., 1000.]), ) np.testing.assert_array_equal( ax.get_yticks(), np.array([-100., 0., 100., 1000., 10000.]), ) # try setting default scale and _not_ setting xscale, yscale flow.set_default_scale("log") self.assertEqual(flow.get_default_scale(), "log") flow.ScatterplotView(xchannel="V2-A", ychannel="Y2-A", huefacet="Dox").plot(self.ex) ax = plt.gca() np.testing.assert_array_equal( ax.get_xticks(), np.array([1.e-2, 1.e-1, 1., 1.e1, 1.e2, 1.e3, 1.e4, 1.e5]), ) np.testing.assert_array_equal( ax.get_yticks(), np.array([1.e-2, 1.e-1, 1., 1.e1, 1.e2, 1.e3, 1.e4, 1.e+05, 1.e6]), ) flow.set_default_scale("linear") # reset the default scale
def _default_scale_changed(self, new_scale): cytoflow.set_default_scale(new_scale)
def recv_main(self, parent_conn): while parent_conn.poll(None): try: (msg, payload) = parent_conn.recv() except EOFError: return logging.debug("RemoteWorkflow.recv_main :: {}".format(msg)) try: if msg == Msg.NEW_WORKFLOW: self.workflow = [] for new_item in payload: wi = RemoteWorkflowItem() wi.lock.acquire() wi.matplotlib_events = self.matplotlib_events wi.plot_lock = self.plot_lock wi.copy_traits(new_item, status=lambda t: t is not True) self.workflow.append(wi) # load the data from ImportOp. This should kick off # the chain of handlers to apply the rest of the # operations, too. manipulate exec_q directly so we # don't run into timing issues; we want this to be run # first. if self.workflow[0] == wi: self.exec_q.put((0, (wi, wi.apply))) for wi in self.workflow: wi.lock.release() elif msg == Msg.ADD_ITEMS: (idx, new_item) = payload wi = RemoteWorkflowItem() wi.copy_traits(new_item) wi.matplotlib_events = self.matplotlib_events wi.plot_lock = self.plot_lock self.workflow.insert(idx, wi) elif msg == Msg.REMOVE_ITEMS: idx = payload self.workflow.remove(self.workflow[idx]) elif msg == Msg.SELECT: idx = payload if idx == -1: self.selected = None else: self.selected = self.workflow[idx] elif msg == Msg.UPDATE_OP: (idx, new_op, update_type) = payload wi = self.workflow[idx] with wi.lock: wi.operation.copy_traits( new_op, status=lambda t: t is not True, fixed=lambda t: t is not True) wi.operation.changed = update_type elif msg == Msg.UPDATE_VIEW: (idx, new_view, update_type) = payload view_id = new_view.id wi = self.workflow[idx] try: view = next((x for x in wi.views if x.id == view_id)) except StopIteration: logging.warn( "RemoteWorkflow: Couldn't find view {}".format( view_id)) continue with wi.lock: view.copy_traits(new_view, status=lambda t: t is not True, fixed=lambda t: t is not True) view.changed = update_type elif msg == Msg.CHANGE_CURRENT_VIEW: (idx, view) = payload wi = self.workflow[idx] try: wi.current_view = next( (x for x in wi.views if x.id == view.id)) except StopIteration: wi.views.append(view) wi.current_view = view wi.command = "plot" elif msg == Msg.CHANGE_CURRENT_PLOT: (idx, plot) = payload wi = self.workflow[idx] wi.current_plot = plot elif msg == Msg.CHANGE_DEFAULT_SCALE: new_scale = payload cytoflow.set_default_scale(new_scale) elif msg == Msg.ESTIMATE: idx = payload wi = self.workflow[idx] wi.command = "estimate" else: raise RuntimeError("Bad command in the remote workflow") except Exception: log_exception()
def _default_scale_changed(self, new_scale): logging.debug("LocalWorkflow._default_scale_changed :: {}".format( (new_scale))) cytoflow.set_default_scale(new_scale) self.message_q.put((Msg.CHANGE_DEFAULT_SCALE, new_scale))
def recv_main(self): while this.parent_conn.poll(None): try: (msg, payload) = this.parent_conn.recv() except EOFError: return logging.debug("RemoteWorkflow.recv_main :: {}".format(msg)) if msg == Msg.NEW_WORKFLOW: self.workflow = payload elif msg == Msg.ADD_ITEMS: (idx, new_item) = payload self.workflow.insert(idx, new_item) elif msg == Msg.REMOVE_ITEMS: idx = payload self.workflow.remove(self.workflow[idx]) elif msg == Msg.SELECT: idx = payload if idx == -1: self.selected = None else: self.selected = self.workflow[idx] elif msg == Msg.UPDATE_OP: (idx, trait, new_value) = payload wi = self.workflow[idx] if wi.operation.trait_get(trait)[trait] != new_value: self.updating_traits.add((wi.operation, trait)) wi.operation.trait_set(**{trait : new_value}) elif msg == Msg.CHANGE_CURRENT_VIEW: (idx, view) = payload wi = self.workflow[idx] try: wi.current_view = next((x for x in wi.views if x.id == view.id)) except StopIteration: wi.views.append(view) wi.current_view = view if wi == self.selected: self.plot(wi) elif msg == Msg.CHANGE_CURRENT_PLOT: (idx, plot) = payload wi = self.workflow[idx] wi.current_plot = plot if wi == self.selected: self.plot(wi) elif msg == Msg.UPDATE_VIEW: (idx, view_id, trait, new_value) = payload wi = self.workflow[idx] try: view = next((x for x in wi.views if x.id == view_id)) except StopIteration: logging.warn("RemoteWorkflow: Couldn't find view {}".format(view_id)) continue if view.trait_get(trait)[trait] != new_value: self.updating_traits.add((view, trait)) view.trait_set(**{trait : new_value}) elif msg == Msg.CHANGE_DEFAULT_SCALE: new_scale = payload cytoflow.set_default_scale(new_scale) elif msg == Msg.ESTIMATE: idx = payload self.workflow[idx].estimate = True elif msg == Msg.GET_LOG: self.message_q.put((Msg.GET_LOG, guiutil.child_log.getvalue())) else: raise RuntimeError("Bad command in the remote workflow")
def _default_scale_changed(self, new_scale): logging.debug("LocalWorkflow._default_scale_changed :: {}" .format((new_scale))) cytoflow.set_default_scale(new_scale) self.message_q.put((Msg.CHANGE_DEFAULT_SCALE, new_scale))