Skip to content
Snippets Groups Projects
Commit 9eb84164 authored by Samuel Jones's avatar Samuel Jones
Browse files

Re #24049 Interrim commit

parent 9cce3ddb
No related branches found
No related tags found
No related merge requests found
Showing
with 317 additions and 126 deletions
...@@ -25,22 +25,51 @@ public: ...@@ -25,22 +25,51 @@ public:
void observeAll(bool turnOn = true); void observeAll(bool turnOn = true);
void observeAdd(bool turnOn = true); void observeAdd(bool turnOn = true);
void observeReplace(bool turnOn = true);
void observeDelete(bool turnOn = true);
virtual void anyChangeHandle() {} virtual void anyChangeHandle() {}
protected: protected:
virtual void addHandle(const std::string &wsName, virtual void addHandle(const std::string &wsName, const Workspace_sptr ws);
const Workspace_sptr ws); virtual void replaceHandle(const std::string &wsName,
const Workspace_sptr ws);
virtual void deleteHandle(const std::string &wsName, const Workspace_sptr ws);
private: private:
bool m_observingAdd; bool m_observingAdd, m_observingReplace, m_observingDelete;
void _addHandle(
const Poco::AutoPtr<AnalysisDataServiceImpl::AddNotification> &pNf);
void _replaceHandle(
const Poco::AutoPtr<AnalysisDataServiceImpl::AfterReplaceNotification>
&pNf);
void _deleteHandle(
const Poco::AutoPtr<AnalysisDataServiceImpl::PostDeleteNotification>
&pNf);
void _addHandle(const Poco::AutoPtr<AnalysisDataServiceImpl::AddNotification> &pNf){
this->anyChangeHandle();
this->addHandle(pNf->objectName(), pNf->object());
}
/// Poco::NObserver for AddNotification. /// Poco::NObserver for AddNotification.
Poco::NObserver<AnalysisDataServiceObserver, AnalysisDataServiceImpl::AddNotification> Poco::NObserver<AnalysisDataServiceObserver,
AnalysisDataServiceImpl::AddNotification>
m_addObserver; m_addObserver;
/// Poco::NObserver for ReplaceNotification.
Poco::NObserver<AnalysisDataServiceObserver,
AnalysisDataServiceImpl::AfterReplaceNotification>
m_replaceObserver;
/// Poco::NObserver for DeleteNotification.
Poco::NObserver<AnalysisDataServiceObserver,
AnalysisDataServiceImpl::PostDeleteNotification>
m_deleteObserver;
/// Poco::NObserver for ClearNotification
/// Poco::NObserver for RenameNotification
/// Poco::NObserver for GroupNotification
/// Poco::NObserver for UnGroupNotification
}; };
} // namespace API } // namespace API
......
...@@ -10,13 +10,20 @@ ...@@ -10,13 +10,20 @@
AnalysisDataServiceObserver::AnalysisDataServiceObserver() AnalysisDataServiceObserver::AnalysisDataServiceObserver()
: m_addObserver(*this, &AnalysisDataServiceObserver::_addHandle) {} : m_addObserver(*this, &AnalysisDataServiceObserver::_addHandle) {}
AnalysisDataServiceObserver::~AnalysisDataServiceObserver(){ AnalysisDataServiceObserver::~AnalysisDataServiceObserver() {
// Turn off/remove all observers // Turn off/remove all observers
this->observeAll(false); this->observeAll(false);
} }
// ------------------------------------------------------------
// Observe Methods
// ------------------------------------------------------------
void AnalysisDataServiceObserver::observeAll(bool turnOn) { void AnalysisDataServiceObserver::observeAll(bool turnOn) {
this->observeAdd(turnOn); this->observeAdd(turnOn);
this->observeReplace(turnOn);
this->observeDelete(turnOn);
} }
void AnalysisDataServiceObserver::observeAdd(bool turnOn) { void AnalysisDataServiceObserver::observeAdd(bool turnOn) {
...@@ -30,8 +37,68 @@ void AnalysisDataServiceObserver::observeAdd(bool turnOn) { ...@@ -30,8 +37,68 @@ void AnalysisDataServiceObserver::observeAdd(bool turnOn) {
m_observingAdd = turnOn; m_observingAdd = turnOn;
} }
void AnalysisDataServiceObserver::observeReplace(bool turnOn) {
if (turnOn && !m_observingReplace) {
AnalysisDataService::Instance().notificationCenter.addObserver(
m_ReplaceObserver);
} else if (!turnOn && m_observingReplace) {
AnalysisDataService::Instance().notificationCenter.removeObserver(
m_ReplaceObserver);
}
m_observingReplace = turnOn;
}
void AnalysisDataServiceObserver::observeDelete(bool turnOn) {
if (turnOn && !m_observingDelete) {
AnalysisDataService::Instance().notificationCenter.addObserver(
m_deleteObserver);
} else if (!turnOn && m_observingDelete) {
AnalysisDataService::Instance().notificationCenter.removeObserver(
m_deleteObserver);
}
m_observingDelete = turnOn;
}
// ------------------------------------------------------------
// Virtual Methods
// ------------------------------------------------------------
void AnalysisDataServiceObserver::addHandle( void AnalysisDataServiceObserver::addHandle(
const std::string &wsName, const Mantid::API::Workspace_sptr ws) { const std::string &wsName, const Mantid::API::Workspace_sptr ws) {
UNUSED_ARG(wsName) UNUSED_ARG(wsName)
UNUSED_ARG(ws) UNUSED_ARG(ws)
} }
\ No newline at end of file
void AnalysisDataServiceObserver::replaceHandle(
const std::string &wsName, const Mantid::API::Workspace_sptr ws) {
UNUSED_ARG(wsName)
UNUSED_ARG(ws)
}
void AnalysisDataServiceObserver::deleteHandle(
const std::string &wsName, const Mantid::API::Workspace_sptr ws) {
UNUSED_ARG(wsName)
UNUSED_ARG(ws)
}
// ------------------------------------------------------------
// Private Methods
// ------------------------------------------------------------
void AnalysisDataServiceObserver::_addHandle(
const Poco::AutoPtr<AnalysisDataServiceImpl::AddNotification> &pNf) {
this->anyChangeHandle();
this->addHandle(pNf->objectName(), pNf->object());
}
void AnalysisDataServiceObserver::_replaceHandle(
const Poco::AutoPtr<AnalysisDataServiceImpl::AfterReplaceNotification>
&pNf) {
this->anyChangeHandle();
this->replaceHandle(pNf->objectName(), pNf->object());
}
void AnalysisDataServiceObserver::_deleteHandle(
const Poco::AutoPtr<AnalysisDataServiceImpl::AfterReplaceNotification>
&pNf) {
this->anyChangeHandle();
this->deleteHandle(pNf->objectName(), pNf->object());
}
// Mantid Repository : https://github.com/mantidproject/mantid
//
// Copyright &copy; 2013 ISIS Rutherford Appleton Laboratory UKRI,
// NScD Oak Ridge National Laboratory, European Spallation Source
// & Institut Laue - Langevin
// SPDX - License - Identifier: GPL - 3.0 +
#ifndef MANTID_PYTHONINTERFACE_ANALYSISDATASERVICEOBSERVERADAPTER_H_
#define MANTID_PYTHONINTERFACE_ANALYSISDATASERVICEOBSERVERADAPTER_H_
#include "MantidAPI/AnalysisDataServiceObserver.h"
#include <boost/python/wrapper.hpp>
namespace Mantid {
namespace PythonInterface {
/**
A wrapper class helping to export AnalysisDataServiceObserver to python.
It provides access from the C++ side to methods defined in python
on subclasses of AnalysisDataServiceObserver.
This allows the virtual methods to be overriden by python subclasses.
*/
class DLLExport AnalysisDataServiceObserverAdapter
: public API::AnalysisDataServiceObserver {
public:
explicit AnalysisDataServiceObserverAdapter(PyObject *self);
AnalysisDataServiceObserverAdapter(
const AnalysisDataServiceObserverAdapter &) = delete;
AnalysisDataServiceObserverAdapter &
operator=(const AnalysisDataServiceObserverAdapter &) = delete;
void anyChangeHandle() override;
private:
/// Return the PyObject that owns this wrapper, i.e. self
inline PyObject *getSelf() const { return m_self; }
/// Value of "self" used by python to refer to an instance of this class
PyObject *m_self;
};
} // namespace PythonInterface
} // namespace Mantid
#endif /*MANTID_PYTHONINTERFACE_ANALYSISDATASERVICEOBSERVERADAPTER_H_*/
\ No newline at end of file
...@@ -100,6 +100,7 @@ set ( SRC_FILES ...@@ -100,6 +100,7 @@ set ( SRC_FILES
src/PythonAlgorithm/DataProcessorAdapter.cpp src/PythonAlgorithm/DataProcessorAdapter.cpp
src/CloneMatrixWorkspace.cpp src/CloneMatrixWorkspace.cpp
src/ExtractWorkspace.cpp src/ExtractWorkspace.cpp
src/Exports/AnalysisDataServiceObserverAdapter.cpp
) )
set ( INC_FILES set ( INC_FILES
...@@ -110,6 +111,7 @@ set ( INC_FILES ...@@ -110,6 +111,7 @@ set ( INC_FILES
${HEADER_DIR}/api/FitFunctions/IPeakFunctionAdapter.h ${HEADER_DIR}/api/FitFunctions/IPeakFunctionAdapter.h
${HEADER_DIR}/api/PythonAlgorithm/AlgorithmAdapter.h ${HEADER_DIR}/api/PythonAlgorithm/AlgorithmAdapter.h
${HEADER_DIR}/api/PythonAlgorithm/DataProcessorAdapter.h ${HEADER_DIR}/api/PythonAlgorithm/DataProcessorAdapter.h
${HEADER_DIR}/api/AnalysisDataServiceObserverAdapter.h
${HEADER_DIR}/api/BinaryOperations.h ${HEADER_DIR}/api/BinaryOperations.h
${HEADER_DIR}/api/CloneMatrixWorkspace.h ${HEADER_DIR}/api/CloneMatrixWorkspace.h
${HEADER_DIR}/api/ExtractWorkspace.h ${HEADER_DIR}/api/ExtractWorkspace.h
......
...@@ -5,26 +5,22 @@ ...@@ -5,26 +5,22 @@
// & Institut Laue - Langevin // & Institut Laue - Langevin
// SPDX - License - Identifier: GPL - 3.0 + // SPDX - License - Identifier: GPL - 3.0 +
#include "MantidAPI/AnalysisDataServiceObserver.h" #include "MantidAPI/AnalysisDataServiceObserver.h"
#include "MantidPythonInterface/api/AnalysisDataServiceObserverAdapter.h"
#include "MantidPythonInterface/kernel/GetPointer.h" #include "MantidPythonInterface/kernel/GetPointer.h"
#include <boost/python/class.hpp>
#include <boost/python/bases.hpp> #include <boost/python/bases.hpp>
#include <boost/python/register_ptr_to_python.hpp> #include <boost/python/class.hpp>
using namespace Mantid::API; using namespace Mantid::API;
using namespace Mantid::PythonInterface;
using namespace boost::python; using namespace boost::python;
void export_AnalysisDataServiceObserver() { void export_AnalysisDataServiceObserver() {
boost::python::register_ptr_to_python<
boost::shared_ptr<AnalysisDataServiceObserver>>();
boost::python::class_<AnalysisDataServiceObserver, bases<>, boost::python::class_<AnalysisDataServiceObserver, bases<>,
boost::shared_ptr<AnalysisDataServiceObserver>, boost::noncopyable>( AnalysisDataServiceObserverAdapter, boost::noncopyable>(
"AnalysisDataServiceObserver", "AnalysisDataServiceObserver",
"Observes AnalysisDataService notifications: all only") "Observes AnalysisDataService notifications: all only")
.def("observeAll", &AnalysisDataServiceObserver::observeAll, (arg("self"), arg("on")), .def("observeAll", &AnalysisDataServiceObserverAdapter::observeAll,
"Observe AnalysisDataService for any changes") (arg("self"), arg("on")),
.def("anyChangeHandle", &AnalysisDataServiceObserver::anyChangeHandle, arg("self"), "Observe AnalysisDataService for any changes");
"Override this to change the effect of what happens when a change occurs in the ADS");
} }
\ No newline at end of file
// Mantid Repository : https://github.com/mantidproject/mantid
//
// Copyright &copy; 2018 ISIS Rutherford Appleton Laboratory UKRI,
// NScD Oak Ridge National Laboratory, European Spallation Source
// & Institut Laue - Langevin
// SPDX - License - Identifier: GPL - 3.0 +
#include "MantidPythonInterface/api/AnalysisDataServiceObserverAdapter.h"
#include "MantidAPI/AnalysisDataServiceObserver.h"
#include "MantidPythonInterface/core/CallMethod.h"
#include <iostream>
namespace Mantid {
namespace PythonInterface {
AnalysisDataServiceObserverAdapter::AnalysisDataServiceObserverAdapter(
PyObject *self)
: API::AnalysisDataServiceObserver(), m_self(self) {}
void AnalysisDataServiceObserverAdapter::anyChangeHandle() {
try {
return callMethod<void>(getSelf(), "anyChangeHandle");
} catch (UndefinedAttributeError &) {
return;
}
}
} // namespace PythonInterface
} // namespace Mantid
...@@ -203,8 +203,7 @@ class MainWindow(QMainWindow): ...@@ -203,8 +203,7 @@ class MainWindow(QMainWindow):
# Set up the project object # Set up the project object
from mantidqt.project.project import Project from mantidqt.project.project import Project
project_save_filename = "mantidsave.project" self.project = Project()
self.project = Project(project_save_filename)
# uses default configuration as necessary # uses default configuration as necessary
self.readSettings(CONF) self.readSettings(CONF)
......
...@@ -69,6 +69,11 @@ endif () ...@@ -69,6 +69,11 @@ endif ()
mantidqt/dialogs/test/test_algorithm_dialog.py mantidqt/dialogs/test/test_algorithm_dialog.py
mantidqt/dialogs/test/test_spectraselectiondialog.py mantidqt/dialogs/test/test_spectraselectiondialog.py
mantidqt/project/test/test_projectloader.py
mantidqt/project/test/test_projectsaver.py
mantidqt/project/test/test_workspaceloader.py
mantidqt/project/test/test_workspacesaver.py
mantidqt/utils/test/test_async.py mantidqt/utils/test/test_async.py
mantidqt/utils/test/test_modal_tester.py mantidqt/utils/test/test_modal_tester.py
mantidqt/utils/test/test_qt_utils.py mantidqt/utils/test/test_qt_utils.py
......
...@@ -9,10 +9,9 @@ ...@@ -9,10 +9,9 @@
from __future__ import (absolute_import, division, print_function, unicode_literals) from __future__ import (absolute_import, division, print_function, unicode_literals)
import os import os
import glob import re
from qtpy.QtWidgets import QFileDialog, QMessageBox from qtpy.QtWidgets import QFileDialog, QMessageBox
from mantid import logger
from mantid.api import AnalysisDataService, AnalysisDataServiceObserver from mantid.api import AnalysisDataService, AnalysisDataServiceObserver
from mantidqt.io import open_a_file_dialog from mantidqt.io import open_a_file_dialog
from mantidqt.project.projectloader import ProjectLoader from mantidqt.project.projectloader import ProjectLoader
...@@ -20,28 +19,24 @@ from mantidqt.project.projectsaver import ProjectSaver ...@@ -20,28 +19,24 @@ from mantidqt.project.projectsaver import ProjectSaver
class Project(AnalysisDataServiceObserver): class Project(AnalysisDataServiceObserver):
def __init__(self, project_save_name): def __init__(self):
super(Project, self).__init__()
# Has the project been saved # Has the project been saved
self.saved = False self.saved = False
# Last save locations # Last save locations
self.last_project_location = None self.last_project_location = None
self.project_save_name = project_save_name self.observeAll(True)
self.ads_observer = AnalysisDataServiceObserver()
self.ads_observer.observeAll(True) self.project_file_ext = ".mtdproj"
def save(self): def save(self):
if self.last_project_location is None: if self.last_project_location is None:
self.save_project_as() self.save_as()
else: else:
# Clear directory before saving to remove old workspaces # Clear unused workspaces
files = glob.glob(self.last_project_location + '/.*') self._clear_unused_workspaces(self.last_project_location)
for f in files:
try:
os.remove(f)
except OSError as e:
logger.debug("Whilst cleaning project directory error was thrown: " + e)
# Actually save # Actually save
workspaces_to_save = AnalysisDataService.getObjectNames() workspaces_to_save = AnalysisDataService.getObjectNames()
project_saver = ProjectSaver(self.project_save_name) project_saver = ProjectSaver(self.project_save_name)
...@@ -53,7 +48,8 @@ class Project(AnalysisDataServiceObserver): ...@@ -53,7 +48,8 @@ class Project(AnalysisDataServiceObserver):
directory = None directory = None
# Check if it exists # Check if it exists
first_pass = True first_pass = True
while first_pass or (not os.path.exists(directory) and os.path.exists(directory + "mantidsave.project")): while first_pass or (not os.path.exists(directory) and os.path.exists(directory + (os.path.basename(directory)
+ ".mtdproj"))):
first_pass = False first_pass = False
directory = open_a_file_dialog(accept_mode=QFileDialog.AcceptSave, file_mode=QFileDialog.DirectoryOnly) directory = open_a_file_dialog(accept_mode=QFileDialog.AcceptSave, file_mode=QFileDialog.DirectoryOnly)
if directory is None: if directory is None:
...@@ -63,7 +59,7 @@ class Project(AnalysisDataServiceObserver): ...@@ -63,7 +59,7 @@ class Project(AnalysisDataServiceObserver):
# todo: get a list of workspaces but to be implemented on GUI implementation # todo: get a list of workspaces but to be implemented on GUI implementation
self.last_project_location = directory self.last_project_location = directory
workspaces_to_save = AnalysisDataService.getObjectNames() workspaces_to_save = AnalysisDataService.getObjectNames()
project_saver = ProjectSaver(self.project_save_name) project_saver = ProjectSaver(self.project_file_ext)
project_saver.save_project(directory=directory, workspace_to_save=workspaces_to_save, interfaces_to_save=None) project_saver.save_project(directory=directory, workspace_to_save=workspaces_to_save, interfaces_to_save=None)
self.saved = True self.saved = True
...@@ -77,7 +73,7 @@ class Project(AnalysisDataServiceObserver): ...@@ -77,7 +73,7 @@ class Project(AnalysisDataServiceObserver):
if directory is None: if directory is None:
# Cancel close dialogs # Cancel close dialogs
return return
project_loader = ProjectLoader(self.project_save_name) project_loader = ProjectLoader(self.project_file_ext)
project_loader.load_project(directory) project_loader.load_project(directory)
self.last_project_location = directory self.last_project_location = directory
...@@ -103,3 +99,20 @@ class Project(AnalysisDataServiceObserver): ...@@ -103,3 +99,20 @@ class Project(AnalysisDataServiceObserver):
def anyChangeHandle(self): def anyChangeHandle(self):
self.modified_project() self.modified_project()
@staticmethod
def _clear_unused_workspaces(path):
files_to_remove = []
list_dir = os.listdir(path)
current_workspaces = AnalysisDataService.getObjectNames()
for item in list_dir:
# Don't count or check files that do not end in .nxs, and check that they are not in current workspaces
# without the .nxs
if bool(re.search('$.nxs', item)):
workspace_name = item.replace(".nxs", "")
if workspace_name not in current_workspaces:
files_to_remove.append(item)
# Actually remove them
for filename in files_to_remove:
os.remove(path + "/" + filename)
...@@ -9,8 +9,9 @@ ...@@ -9,8 +9,9 @@
from __future__ import (absolute_import, division, print_function, unicode_literals) from __future__ import (absolute_import, division, print_function, unicode_literals)
import json import json
import os
import workspaceloader from mantidqt.project import workspaceloader
from mantid import AnalysisDataService as ADS from mantid import AnalysisDataService as ADS
from mantid import logger from mantid import logger
...@@ -25,28 +26,29 @@ def _confirm_all_workspaces_loaded(workspaces_to_confirm): ...@@ -25,28 +26,29 @@ def _confirm_all_workspaces_loaded(workspaces_to_confirm):
class ProjectLoader(object): class ProjectLoader(object):
def __init__(self, project_load_name): def __init__(self, project_file_ext):
self.project_reader = ProjectReader(project_load_name) self.project_reader = ProjectReader(project_file_ext)
self.workspace_loader = workspaceloader.WorkspaceLoader() self.workspace_loader = workspaceloader.WorkspaceLoader()
self.project_file_ext = project_file_ext
def load_project(self, directory): def load_project(self, directory):
# Read project # Read project
self.project_reader.read_project(directory) self.project_reader.read_project(directory)
# Load in the workspaces # Load in the workspaces
self.workspace_loader.load_workspaces(directory=directory) self.workspace_loader.load_workspaces(directory=directory, project_file_ext=self.project_file_ext)
return _confirm_all_workspaces_loaded(workspaces_to_confirm=self.project_reader.workspace_names) return _confirm_all_workspaces_loaded(workspaces_to_confirm=self.project_reader.workspace_names)
class ProjectReader(object): class ProjectReader(object):
def __init__(self, project_load_name): def __init__(self, project_file_ext):
self.workspace_names = None self.workspace_names = None
self.interfaces_dicts = None self.interfaces_dicts = None
self.plot_dicts = None self.plot_dicts = None
self.project_load_name = project_load_name self.project_file_ext = project_file_ext
def read_project(self, directory): def read_project(self, directory):
f = open(directory + "/" + self.project_load_name) f = open(directory + "/" + (os.path.basename(directory) + self.project_file_ext))
json_data = json.load(f) json_data = json.load(f)
self.workspace_names = json_data["workspaces"] self.workspace_names = json_data["workspaces"]
self.interfaces_dicts = json_data["interfaces"] self.interfaces_dicts = json_data["interfaces"]
...@@ -9,16 +9,15 @@ ...@@ -9,16 +9,15 @@
from __future__ import (absolute_import, division, print_function, unicode_literals) from __future__ import (absolute_import, division, print_function, unicode_literals)
from json import dump from json import dump
from os import makedirs import os
from os.path import isdir
from mantidqt.project import workspacesaver from mantidqt.project import workspacesaver
from mantid import logger from mantid import logger
class ProjectSaver(object): class ProjectSaver(object):
def __init__(self, project_save_name): def __init__(self, project_file_ext):
self.project_save_name = project_save_name self.project_file_ext = project_file_ext
def save_project(self, directory, workspace_to_save=None, interfaces_to_save=None): def save_project(self, directory, workspace_to_save=None, interfaces_to_save=None):
""" """
...@@ -47,12 +46,12 @@ class ProjectSaver(object): ...@@ -47,12 +46,12 @@ class ProjectSaver(object):
# Pass dicts to Project Writer # Pass dicts to Project Writer
writer = ProjectWriter(dictionaries_to_save, directory, workspace_saver.get_output_list(), writer = ProjectWriter(dictionaries_to_save, directory, workspace_saver.get_output_list(),
self.project_save_name) self.project_file_ext)
writer.write_out() writer.write_out()
class ProjectWriter(object): class ProjectWriter(object):
def __init__(self, dicts, save_location, workspace_names, project_save_name): def __init__(self, dicts, save_location, workspace_names, project_file_ext):
""" """
:param dicts: :param dicts:
...@@ -62,7 +61,7 @@ class ProjectWriter(object): ...@@ -62,7 +61,7 @@ class ProjectWriter(object):
self.dicts_to_save = dicts self.dicts_to_save = dicts
self.workspace_names = workspace_names self.workspace_names = workspace_names
self.directory = save_location self.directory = save_location
self.project_save_name = project_save_name self.project_file_ext = project_file_ext
def write_out(self): def write_out(self):
""" """
...@@ -72,8 +71,8 @@ class ProjectWriter(object): ...@@ -72,8 +71,8 @@ class ProjectWriter(object):
workspace_interface_dict = {"workspaces": self.workspace_names, "interfaces": self.dicts_to_save} workspace_interface_dict = {"workspaces": self.workspace_names, "interfaces": self.dicts_to_save}
# Open file and save the string to it alongside the workspace_names # Open file and save the string to it alongside the workspace_names
file_name = self.directory + '/' + self.project_save_name file_name = self.directory + '/' + (os.path.basename(self.directory) + self.project_file_ext)
if not isdir(self.directory): if not os.path.isdir(self.directory):
makedirs(self.directory) os.makedirs(self.directory)
f = open(file_name, 'w+') f = open(file_name, 'w+')
dump(obj=workspace_interface_dict, fp=f) dump(obj=workspace_interface_dict, fp=f)
...@@ -9,23 +9,24 @@ ...@@ -9,23 +9,24 @@
import unittest import unittest
from os.path import isdir, expanduser from os.path import isdir
from shutil import rmtree from shutil import rmtree
import tempfile
from mantid.api import AnalysisDataService as ADS from mantid.api import AnalysisDataService as ADS
from mantid.simpleapi import CreateSampleWorkspace from mantid.simpleapi import CreateSampleWorkspace
from mantidqt.project import projectloader, projectsaver from mantidqt.project import projectloader, projectsaver
project_file_name = "mantidsave.project" project_file_ext = ".mtdproj"
working_directory = expanduser("~") + "/project_loader_test" working_directory = tempfile.mkdtemp()
class ProjectLoaderTest(unittest.TestCase): class ProjectLoaderTest(unittest.TestCase):
def setUp(self): def setUp(self):
ws1_name = "ws1" ws1_name = "ws1"
ADS.addOrReplace(ws1_name, CreateSampleWorkspace(OutputWorkspace=ws1_name)) ADS.addOrReplace(ws1_name, CreateSampleWorkspace(OutputWorkspace=ws1_name))
project_saver = projectsaver.ProjectSaver(project_file_name) project_saver = projectsaver.ProjectSaver(project_file_ext)
project_saver.save_project(workspace_to_save=[ws1_name], directory=working_directory) project_saver.save_project(workspace_to_save=[ws1_name], directory=working_directory)
def tearDown(self): def tearDown(self):
...@@ -34,7 +35,7 @@ class ProjectLoaderTest(unittest.TestCase): ...@@ -34,7 +35,7 @@ class ProjectLoaderTest(unittest.TestCase):
rmtree(working_directory) rmtree(working_directory)
def test_project_loading(self): def test_project_loading(self):
project_loader = projectloader.ProjectLoader(project_file_name) project_loader = projectloader.ProjectLoader(project_file_ext)
self.assertTrue(project_loader.load_project(working_directory)) self.assertTrue(project_loader.load_project(working_directory))
...@@ -50,7 +51,7 @@ class ProjectReaderTest(unittest.TestCase): ...@@ -50,7 +51,7 @@ class ProjectReaderTest(unittest.TestCase):
def setUp(self): def setUp(self):
ws1_name = "ws1" ws1_name = "ws1"
ADS.addOrReplace(ws1_name, CreateSampleWorkspace(OutputWorkspace=ws1_name)) ADS.addOrReplace(ws1_name, CreateSampleWorkspace(OutputWorkspace=ws1_name))
project_saver = projectsaver.ProjectSaver(project_file_name) project_saver = projectsaver.ProjectSaver(project_file_ext)
project_saver.save_project(workspace_to_save=[ws1_name], directory=working_directory) project_saver.save_project(workspace_to_save=[ws1_name], directory=working_directory)
def tearDown(self): def tearDown(self):
...@@ -59,7 +60,7 @@ class ProjectReaderTest(unittest.TestCase): ...@@ -59,7 +60,7 @@ class ProjectReaderTest(unittest.TestCase):
rmtree(working_directory) rmtree(working_directory)
def test_project_reading(self): def test_project_reading(self):
project_reader = projectloader.ProjectReader(project_file_name) project_reader = projectloader.ProjectReader(project_file_ext)
project_reader.read_project(working_directory) project_reader.read_project(working_directory)
self.assertEqual(["ws1"], project_reader.workspace_names) self.assertEqual(["ws1"], project_reader.workspace_names)
self.assertEqual({}, project_reader.interfaces_dicts) self.assertEqual({}, project_reader.interfaces_dicts)
...@@ -9,8 +9,7 @@ ...@@ -9,8 +9,7 @@
import unittest import unittest
import tempfile import tempfile
from os import listdir import os
from os.path import isdir
from shutil import rmtree from shutil import rmtree
from mantid.api import AnalysisDataService as ADS from mantid.api import AnalysisDataService as ADS
...@@ -18,7 +17,7 @@ from mantid.simpleapi import CreateSampleWorkspace ...@@ -18,7 +17,7 @@ from mantid.simpleapi import CreateSampleWorkspace
from mantidqt.project import projectsaver from mantidqt.project import projectsaver
project_file_name = "mantidsave.mtdproj" project_file_ext = ".mtdproj"
working_directory = tempfile.mkdtemp() working_directory = tempfile.mkdtemp()
...@@ -28,14 +27,14 @@ class ProjectSaverTest(unittest.TestCase): ...@@ -28,14 +27,14 @@ class ProjectSaverTest(unittest.TestCase):
def setUp(self): def setUp(self):
# In case it was hard killed and is still present # In case it was hard killed and is still present
if isdir(working_directory): if os.path.isdir(working_directory):
rmtree(working_directory) rmtree(working_directory)
def test_only_one_workspace_saving(self): def test_only_one_workspace_saving(self):
ws1_name = "ws1" ws1_name = "ws1"
ADS.addOrReplace(ws1_name, CreateSampleWorkspace(OutputWorkspace=ws1_name)) ADS.addOrReplace(ws1_name, CreateSampleWorkspace(OutputWorkspace=ws1_name))
project_saver = projectsaver.ProjectSaver(project_file_name) project_saver = projectsaver.ProjectSaver(project_file_ext)
file_name = working_directory + "/" + project_file_name file_name = working_directory + "/" + os.path.basename(working_directory) + project_file_ext
saved_file = "{\"interfaces\": {}, \"workspaces\": [\"ws1\"]}" saved_file = "{\"interfaces\": {}, \"workspaces\": [\"ws1\"]}"
project_saver.save_project(workspace_to_save=[ws1_name], directory=working_directory) project_saver.save_project(workspace_to_save=[ws1_name], directory=working_directory)
...@@ -45,10 +44,10 @@ class ProjectSaverTest(unittest.TestCase): ...@@ -45,10 +44,10 @@ class ProjectSaverTest(unittest.TestCase):
self.assertEqual(f.read(), saved_file) self.assertEqual(f.read(), saved_file)
# Check workspace is saved # Check workspace is saved
list_of_files = listdir(working_directory) list_of_files = os.listdir(working_directory)
self.assertEqual(len(list_of_files), 2) self.assertEqual(len(list_of_files), 2)
self.assertTrue(project_file_name in list_of_files) self.assertTrue(os.path.basename(working_directory) + project_file_ext in list_of_files)
self.assertTrue(ws1_name in list_of_files) self.assertTrue(ws1_name + ".nxs" in list_of_files)
def test_only_multiple_workspaces_saving(self): def test_only_multiple_workspaces_saving(self):
ws1_name = "ws1" ws1_name = "ws1"
...@@ -61,8 +60,8 @@ class ProjectSaverTest(unittest.TestCase): ...@@ -61,8 +60,8 @@ class ProjectSaverTest(unittest.TestCase):
CreateSampleWorkspace(OutputWorkspace=ws3_name) CreateSampleWorkspace(OutputWorkspace=ws3_name)
CreateSampleWorkspace(OutputWorkspace=ws4_name) CreateSampleWorkspace(OutputWorkspace=ws4_name)
CreateSampleWorkspace(OutputWorkspace=ws5_name) CreateSampleWorkspace(OutputWorkspace=ws5_name)
project_saver = projectsaver.ProjectSaver(project_file_name) project_saver = projectsaver.ProjectSaver(project_file_ext)
file_name = working_directory + "/" + project_file_name file_name = working_directory + "/" + os.path.basename(working_directory) + project_file_ext
saved_file = "{\"interfaces\": {}, \"workspaces\": [\"ws1\", \"ws2\", \"ws3\", \"ws4\", \"ws5\"]}" saved_file = "{\"interfaces\": {}, \"workspaces\": [\"ws1\", \"ws2\", \"ws3\", \"ws4\", \"ws5\"]}"
project_saver.save_project(workspace_to_save=[ws1_name, ws2_name, ws3_name, ws4_name, ws5_name], project_saver.save_project(workspace_to_save=[ws1_name, ws2_name, ws3_name, ws4_name, ws5_name],
...@@ -73,14 +72,14 @@ class ProjectSaverTest(unittest.TestCase): ...@@ -73,14 +72,14 @@ class ProjectSaverTest(unittest.TestCase):
self.assertEqual(f.read(), saved_file) self.assertEqual(f.read(), saved_file)
# Check workspace is saved # Check workspace is saved
list_of_files = listdir(working_directory) list_of_files = os.listdir(working_directory)
self.assertEqual(len(list_of_files), 6) self.assertEqual(len(list_of_files), 6)
self.assertTrue(project_file_name in list_of_files) self.assertTrue(os.path.basename(working_directory) + project_file_ext in list_of_files)
self.assertTrue(ws1_name in list_of_files) self.assertTrue(ws1_name + ".nxs" in list_of_files)
self.assertTrue(ws2_name in list_of_files) self.assertTrue(ws2_name + ".nxs" in list_of_files)
self.assertTrue(ws3_name in list_of_files) self.assertTrue(ws3_name + ".nxs" in list_of_files)
self.assertTrue(ws4_name in list_of_files) self.assertTrue(ws4_name + ".nxs" in list_of_files)
self.assertTrue(ws5_name in list_of_files) self.assertTrue(ws5_name + ".nxs" in list_of_files)
def test_only_saving_one_workspace_when_multiple_are_present_in_the_ADS(self): def test_only_saving_one_workspace_when_multiple_are_present_in_the_ADS(self):
ws1_name = "ws1" ws1_name = "ws1"
...@@ -89,8 +88,8 @@ class ProjectSaverTest(unittest.TestCase): ...@@ -89,8 +88,8 @@ class ProjectSaverTest(unittest.TestCase):
CreateSampleWorkspace(OutputWorkspace=ws1_name) CreateSampleWorkspace(OutputWorkspace=ws1_name)
CreateSampleWorkspace(OutputWorkspace=ws2_name) CreateSampleWorkspace(OutputWorkspace=ws2_name)
CreateSampleWorkspace(OutputWorkspace=ws3_name) CreateSampleWorkspace(OutputWorkspace=ws3_name)
project_saver = projectsaver.ProjectSaver() project_saver = projectsaver.ProjectSaver(project_file_ext)
file_name = working_directory + "/" + project_file_name file_name = working_directory + "/" + os.path.basename(working_directory) + project_file_ext
saved_file = "{\"interfaces\": {}, \"workspaces\": [\"ws1\"]}" saved_file = "{\"interfaces\": {}, \"workspaces\": [\"ws1\"]}"
project_saver.save_project(workspace_to_save=[ws1_name], directory=working_directory) project_saver.save_project(workspace_to_save=[ws1_name], directory=working_directory)
...@@ -100,10 +99,10 @@ class ProjectSaverTest(unittest.TestCase): ...@@ -100,10 +99,10 @@ class ProjectSaverTest(unittest.TestCase):
self.assertEqual(f.read(), saved_file) self.assertEqual(f.read(), saved_file)
# Check workspace is saved # Check workspace is saved
list_of_files = listdir(working_directory) list_of_files = os.listdir(working_directory)
self.assertEqual(len(list_of_files), 2) self.assertEqual(len(list_of_files), 2)
self.assertTrue(project_file_name in list_of_files) self.assertTrue(os.path.basename(working_directory) + project_file_ext in list_of_files)
self.assertTrue(ws1_name in list_of_files) self.assertTrue(ws1_name + ".nxs" in list_of_files)
#def test_only_one_interface_saving(self): #def test_only_one_interface_saving(self):
...@@ -126,14 +125,14 @@ class ProjectWriterTest(unittest.TestCase): ...@@ -126,14 +125,14 @@ class ProjectWriterTest(unittest.TestCase):
def setUp(self): def setUp(self):
# In case it was hard killed and is still present # In case it was hard killed and is still present
if isdir(working_directory): if os.path.isdir(working_directory):
rmtree(working_directory) rmtree(working_directory)
def test_write_out_on_just_dicts(self): def test_write_out_on_just_dicts(self):
workspace_list = [] workspace_list = []
small_dict = {"interface1": {"value1": 2, "value2": 3}, "interface2": {"value3": 4, "value4": 5}} small_dict = {"interface1": {"value1": 2, "value2": 3}, "interface2": {"value3": 4, "value4": 5}}
project_writer = projectsaver.ProjectWriter(small_dict, working_directory, workspace_list, project_file_name) project_writer = projectsaver.ProjectWriter(small_dict, working_directory, workspace_list, project_file_ext)
file_name = working_directory + "/" + project_file_name file_name = working_directory + "/" + os.path.basename(working_directory) + project_file_ext
saved_file = "{\"interfaces\": {\"interface1\": {\"value2\": 3, \"value1\": 2}, \"interface2\": {\"value4\"" \ saved_file = "{\"interfaces\": {\"interface1\": {\"value2\": 3, \"value1\": 2}, \"interface2\": {\"value4\"" \
": 5, \"value3\": 4}}, \"workspaces\": []}" ": 5, \"value3\": 4}}, \"workspaces\": []}"
...@@ -145,8 +144,8 @@ class ProjectWriterTest(unittest.TestCase): ...@@ -145,8 +144,8 @@ class ProjectWriterTest(unittest.TestCase):
def test_write_out_on_just_workspaces(self): def test_write_out_on_just_workspaces(self):
workspace_list = ["ws1", "ws2", "ws3", "ws4"] workspace_list = ["ws1", "ws2", "ws3", "ws4"]
small_dict = {} small_dict = {}
project_writer = projectsaver.ProjectWriter(small_dict, working_directory, workspace_list, project_file_name) project_writer = projectsaver.ProjectWriter(small_dict, working_directory, workspace_list, project_file_ext)
file_name = working_directory + "/" + project_file_name file_name = working_directory + "/" + os.path.basename(working_directory) + project_file_ext
saved_file = "{\"interfaces\": {}, \"workspaces\": [\"ws1\", \"ws2\", \"ws3\", \"ws4\"]}" saved_file = "{\"interfaces\": {}, \"workspaces\": [\"ws1\", \"ws2\", \"ws3\", \"ws4\"]}"
project_writer.write_out() project_writer.write_out()
...@@ -157,8 +156,8 @@ class ProjectWriterTest(unittest.TestCase): ...@@ -157,8 +156,8 @@ class ProjectWriterTest(unittest.TestCase):
def test_write_out_on_both_workspaces_and_dicts(self): def test_write_out_on_both_workspaces_and_dicts(self):
workspace_list = ["ws1", "ws2", "ws3", "ws4"] workspace_list = ["ws1", "ws2", "ws3", "ws4"]
small_dict = {"interface1": {"value1": 2, "value2": 3}, "interface2": {"value3": 4, "value4": 5}} small_dict = {"interface1": {"value1": 2, "value2": 3}, "interface2": {"value3": 4, "value4": 5}}
project_writer = projectsaver.ProjectWriter(small_dict, working_directory, workspace_list, project_file_name) project_writer = projectsaver.ProjectWriter(small_dict, working_directory, workspace_list, project_file_ext)
file_name = working_directory + "/" + project_file_name file_name = working_directory + "/" + os.path.basename(working_directory) + project_file_ext
saved_file = "{\"interfaces\": {\"interface1\": {\"value2\": 3, \"value1\": 2}, \"interface2\": {\"value4\":" \ saved_file = "{\"interfaces\": {\"interface1\": {\"value2\": 3, \"value1\": 2}, \"interface2\": {\"value4\":" \
" 5, \"value3\": 4}}, \"workspaces\": [\"ws1\", \"ws2\", \"ws3\", \"ws4\"]}" " 5, \"value3\": 4}}, \"workspaces\": [\"ws1\", \"ws2\", \"ws3\", \"ws4\"]}"
project_writer.write_out() project_writer.write_out()
......
...@@ -9,30 +9,30 @@ ...@@ -9,30 +9,30 @@
import unittest import unittest
from os.path import isdir, expanduser from os.path import isdir
from shutil import rmtree from shutil import rmtree
import tempfile
from mantid.api import AnalysisDataService as ADS from mantid.api import AnalysisDataService as ADS
from mantid.simpleapi import CreateSampleWorkspace from mantid.simpleapi import CreateSampleWorkspace
from mantidqt.project import projectsaver, workspaceloader from mantidqt.project import projectsaver, workspaceloader
working_directory = expanduser("~") + "/workspace_loader_test"
class WorkspaceLoaderTest(unittest.TestCase): class WorkspaceLoaderTest(unittest.TestCase):
def setUp(self): def setUp(self):
ws1_name = "ws1" self.working_directory = tempfile.mkdtemp()
ADS.addOrReplace(ws1_name, CreateSampleWorkspace(OutputWorkspace=ws1_name)) self.ws1_name = "ws1"
project_saver = projectsaver.ProjectSaver() self.project_ext = ".mtdproj"
project_saver.save_project(workspace_to_save=[ws1_name], directory=working_directory) ADS.addOrReplace(self.ws1_name, CreateSampleWorkspace(OutputWorkspace=self.ws1_name))
project_saver = projectsaver.ProjectSaver(self.project_ext)
project_saver.save_project(workspace_to_save=[self.ws1_name], directory=self.working_directory)
def tearDown(self): def tearDown(self):
ADS.clear() ADS.clear()
if isdir(working_directory): if isdir(self.working_directory):
rmtree(working_directory) rmtree(self.working_directory)
def test_workspace_loading(self): def test_workspace_loading(self):
workspace_loader = workspaceloader.WorkspaceLoader() workspace_loader = workspaceloader.WorkspaceLoader()
workspace_loader.load_workspaces(working_directory) workspace_loader.load_workspaces(self.working_directory, self.project_ext)
self.assertEqual(ADS.getObjectNames(), ["ws1"]) self.assertEqual(ADS.getObjectNames(), [self.ws1_name])
...@@ -9,9 +9,10 @@ ...@@ -9,9 +9,10 @@
import unittest import unittest
from os import listdir, mkdir from os import listdir
from os.path import isdir, expanduser from os.path import isdir
from shutil import rmtree from shutil import rmtree
import tempfile
from mantid.api import AnalysisDataService as ADS, IMDEventWorkspace # noqa from mantid.api import AnalysisDataService as ADS, IMDEventWorkspace # noqa
from mantid.dataobjects import MDHistoWorkspace, MaskWorkspace # noqa from mantid.dataobjects import MDHistoWorkspace, MaskWorkspace # noqa
...@@ -19,33 +20,30 @@ from mantidqt.project import workspacesaver ...@@ -19,33 +20,30 @@ from mantidqt.project import workspacesaver
from mantid.simpleapi import (CreateSampleWorkspace, CreateMDHistoWorkspace, LoadMD, LoadMask, MaskDetectors, # noqa from mantid.simpleapi import (CreateSampleWorkspace, CreateMDHistoWorkspace, LoadMD, LoadMask, MaskDetectors, # noqa
ExtractMask) # noqa ExtractMask) # noqa
working_directory = expanduser("~") + "/workspace_saver_test_directory"
class WorkspaceSaverTest(unittest.TestCase): class WorkspaceSaverTest(unittest.TestCase):
def setUp(self): def setUp(self):
if not isdir(working_directory): self.working_directory = tempfile.mkdtemp()
mkdir(working_directory)
def tearDown(self): def tearDown(self):
ADS.clear() ADS.clear()
if isdir(working_directory): if isdir(self.working_directory):
rmtree(working_directory) rmtree(self.working_directory)
def test_saving_single_workspace(self): def test_saving_single_workspace(self):
ws_saver = workspacesaver.WorkspaceSaver(working_directory) ws_saver = workspacesaver.WorkspaceSaver(self.working_directory)
ws1 = CreateSampleWorkspace() ws1 = CreateSampleWorkspace()
ws1_name = "ws1" ws1_name = "ws1"
ADS.addOrReplace(ws1_name, ws1) ADS.addOrReplace(ws1_name, ws1)
ws_saver.save_workspaces([ws1_name]) ws_saver.save_workspaces([ws1_name])
list_of_files = listdir(working_directory) list_of_files = listdir(self.working_directory)
self.assertEqual(len(list_of_files), 1) self.assertEqual(len(list_of_files), 1)
self.assertEqual(list_of_files[0], ws1_name) self.assertEqual(list_of_files[0], ws1_name)
def test_saving_multiple_workspaces(self): def test_saving_multiple_workspaces(self):
ws_saver = workspacesaver.WorkspaceSaver(working_directory) ws_saver = workspacesaver.WorkspaceSaver(self.working_directory)
ws1 = CreateSampleWorkspace() ws1 = CreateSampleWorkspace()
ws1_name = "ws1" ws1_name = "ws1"
ws2 = CreateSampleWorkspace() ws2 = CreateSampleWorkspace()
...@@ -55,13 +53,13 @@ class WorkspaceSaverTest(unittest.TestCase): ...@@ -55,13 +53,13 @@ class WorkspaceSaverTest(unittest.TestCase):
ADS.addOrReplace(ws2_name, ws2) ADS.addOrReplace(ws2_name, ws2)
ws_saver.save_workspaces([ws1_name, ws2_name]) ws_saver.save_workspaces([ws1_name, ws2_name])
list_of_files = listdir(working_directory) list_of_files = listdir(self.working_directory)
self.assertEqual(len(list_of_files), 2) self.assertEqual(len(list_of_files), 2)
self.assertEqual(list_of_files[0], ws2_name) self.assertEqual(list_of_files[0], ws2_name)
self.assertEqual(list_of_files[1], ws1_name) self.assertEqual(list_of_files[1], ws1_name)
def test_when_MDWorkspace_is_in_ADS(self): def test_when_MDWorkspace_is_in_ADS(self):
ws_saver = workspacesaver.WorkspaceSaver(working_directory) ws_saver = workspacesaver.WorkspaceSaver(self.working_directory)
ws1 = CreateMDHistoWorkspace(SignalInput='1,2,3,4,5,6,7,8,9', ErrorInput='1,1,1,1,1,1,1,1,1', ws1 = CreateMDHistoWorkspace(SignalInput='1,2,3,4,5,6,7,8,9', ErrorInput='1,1,1,1,1,1,1,1,1',
Dimensionality='2', Extents='-1,1,-1,1', NumberOfBins='3,3', Names='A,B', Dimensionality='2', Extents='-1,1,-1,1', NumberOfBins='3,3', Names='A,B',
Units='U,T') Units='U,T')
...@@ -70,13 +68,13 @@ class WorkspaceSaverTest(unittest.TestCase): ...@@ -70,13 +68,13 @@ class WorkspaceSaverTest(unittest.TestCase):
ADS.addOrReplace(ws1_name, ws1) ADS.addOrReplace(ws1_name, ws1)
ws_saver.save_workspaces([ws1_name]) ws_saver.save_workspaces([ws1_name])
list_of_files = listdir(working_directory) list_of_files = listdir(self.working_directory)
self.assertEqual(len(list_of_files), 1) self.assertEqual(len(list_of_files), 1)
self.assertEqual(list_of_files[0], ws1_name) self.assertEqual(list_of_files[0], ws1_name)
self._load_MDWorkspace_and_test_it(ws1_name) self._load_MDWorkspace_and_test_it(ws1_name)
def _load_MDWorkspace_and_test_it(self, save_name): def _load_MDWorkspace_and_test_it(self, save_name):
filename = working_directory + '/' + save_name filename = self.working_directory + '/' + save_name
ws = LoadMD(Filename=filename) ws = LoadMD(Filename=filename)
ws_is_a_mdworkspace = isinstance(ws, IMDEventWorkspace) or isinstance(ws, MDHistoWorkspace) ws_is_a_mdworkspace = isinstance(ws, IMDEventWorkspace) or isinstance(ws, MDHistoWorkspace)
self.assertEqual(ws_is_a_mdworkspace, True) self.assertEqual(ws_is_a_mdworkspace, True)
...@@ -13,13 +13,22 @@ from os import path, listdir ...@@ -13,13 +13,22 @@ from os import path, listdir
from mantid import logger from mantid import logger
# List of extensions to ignore
ignore_exts = [".py"]
class WorkspaceLoader(object): class WorkspaceLoader(object):
def load_workspaces(self, directory): @staticmethod
def load_workspaces(directory, project_file_ext):
# Include passed project file extension in ignore_exts from projects
ignore_exts.append(project_file_ext)
from mantid.simpleapi import Load # noqa from mantid.simpleapi import Load # noqa
filenames = listdir(directory) filenames = listdir(directory)
for filename in filenames: for filename in filenames:
workspace_name, file_ext = path.splitext(filename) workspace_name, file_ext = path.splitext(filename)
if file_ext != u'.project': # if file_ext not in [".mtdproj", ".py"]:
if file_ext not in ignore_exts:
try: try:
Load(directory + "/" + filename, OutputWorkspace=workspace_name) Load(directory + "/" + filename, OutputWorkspace=workspace_name)
except BaseException as exception: except BaseException as exception:
......
...@@ -51,10 +51,10 @@ class WorkspaceSaver(object): ...@@ -51,10 +51,10 @@ class WorkspaceSaver(object):
if isinstance(workspace, MDHistoWorkspace) or isinstance(workspace, IMDEventWorkspace): if isinstance(workspace, MDHistoWorkspace) or isinstance(workspace, IMDEventWorkspace):
# Save normally using SaveMD # Save normally using SaveMD
SaveMD(InputWorkspace=workspace_name, Filename=place_to_save_workspace) SaveMD(InputWorkspace=workspace_name, Filename=place_to_save_workspace + ".nxs")
else: else:
# Save normally using SaveNexusProcessed # Save normally using SaveNexusProcessed
SaveNexusProcessed(InputWorkspace=workspace_name, Filename=place_to_save_workspace) SaveNexusProcessed(InputWorkspace=workspace_name, Filename=place_to_save_workspace + ".nxs")
self.output_list.append(workspace_name) self.output_list.append(workspace_name)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment