def test_empty_project(self): dirname = abspath(join(self.root_dir, "empty_project")) self.directories.append(dirname) p = Project(project_save_path=dirname) p.save() p2 = Project.from_dir(dirname) self.assert_(compare_projects(p, p2))
def create_simple_project(): """ Returns a simple project with a single experiment and a single context """ ctx = DataContext(name="main") ctx["a"] = 5 ctx["b"] = 7 ctx["c"] = 11 proj = Project(contexts=[ctx]) exp = Experiment(code=SAMPLE_CODE_1, shared_context=ctx) proj.add_experiment(exp) return proj
def _new_project(self): """ Implementation for creating a new project. This can contain UI code. """ # fixme: Ask user it they want to save. If so, do it. self.workbench.app.project.save() # Close any editors associated with the old project. # (Perhaps) all of them. # fixme, we just close the current experiment. old_editor = self.get_editor(self.workbench.app.project) old_editor.close() # Create a new project and set it as the application project. self.workbench.app.project = Project() self.workbench.app.project.add_experiment(Experiment()) # Bring it up in the editor. self.edit(self.workbench.app.project)
def __init__(self, code=None, data_context=None, *args, **kwargs): super(Application, self).__init__(*args, **kwargs) # Set the global app object in the scripting module. scripting.app = self self.project = Project() if data_context is not None: self.project.add_context(data_context) if code is not None: exp = Experiment(code=code, shared_context=data_context) else: exp = Experiment(shared_context=data_context) self.project.add_experiment(exp) # XXX: the @on_trait_change decorator is not working for this! self.on_trait_change( self._context_items_modified, 'project:active_experiment:context:items_modified')
def create_multi_experiment_proj(): """ Returns a project with two contexts and two experiments. """ ctx = DataContext(name="main") ctx["a"] = 5 ctx["b"] = 7 ctx["c"] = 11 ctx2 = DataContext(name="secondary") ctx2["a"] = 4 ctx2["b"] = 16 ctx2["c"] = 32 ctx2["m"] = 64 ctx2["n"] = 128 proj = Project(contexts=[ctx, ctx2]) e1 = Experiment(code=SAMPLE_CODE_1, shared_context=ctx) e2 = Experiment(code=SAMPLE_CODE_2, shared_context=ctx) proj.experiments = [e1, e2] return proj
def new_project(self): """ Set the active project on the application. """ #fixme: This is no different than setting the actual trait. # perhaps get rid of it. self.project = Project()