Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions Framework/API/inc/MantidAPI/ScopedWorkspace.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,6 @@ class MANTID_API_DLL ScopedWorkspace {
/// Generates a tricky name which is unique within ADS
static std::string generateUniqueName();

/// Generates a random alpha-numeric string
static std::string randomString(size_t len);

/// Length of workspace names generated
static const size_t NAME_LENGTH;
};
Expand Down
23 changes: 3 additions & 20 deletions Framework/API/src/ScopedWorkspace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
#include "MantidAPI/AnalysisDataService.h"
#include "MantidAPI/ScopedWorkspace.h"
#include "MantidAPI/WorkspaceGroup.h"
#include "MantidKernel/Strings.h"

using Mantid::Kernel::Strings::randomString;

namespace Mantid::API {

Expand Down Expand Up @@ -97,24 +100,4 @@ std::string ScopedWorkspace::generateUniqueName() {

return newName;
}

/**
* Generates random alpha-numeric string.
* @param len :: Length of the string
* @return Random string of the given length
*/
std::string ScopedWorkspace::randomString(size_t len) {
static const std::string alphabet = "0123456789abcdefghijklmnopqrstuvwxyz";

std::string result;
result.reserve(len);

while (result.size() != len) {
size_t randPos = ((rand() % (alphabet.size() - 1)));
result.push_back(alphabet[randPos]);
}

return result;
}

} // namespace Mantid::API
1 change: 0 additions & 1 deletion Framework/API/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ if(CXXTEST_FOUND)
Mantid::Nexus
Mantid::NexusGeometry
${BCRYPT}
Boost::filesystem
gmock
Python::Python
)
Expand Down
2 changes: 1 addition & 1 deletion Framework/Algorithms/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1083,7 +1083,7 @@ set_property(TARGET Algorithms PROPERTY FOLDER "MantidFramework")
target_link_libraries(
Algorithms
PUBLIC Mantid::API Mantid::HistogramData Mantid::Kernel Mantid::Geometry Mantid::Indexing
PRIVATE Mantid::DataObjects Mantid::Parallel Mantid::Types Boost::filesystem
PRIVATE Mantid::DataObjects Mantid::Parallel Mantid::Types
)

# Add the unit tests directory
Expand Down
13 changes: 6 additions & 7 deletions Framework/Algorithms/src/CorelliCalibrationDatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@

#include <boost/algorithm/string/classification.hpp>
#include <boost/algorithm/string/split.hpp>
#include <boost/filesystem.hpp>
#include <boost/filesystem/operations.hpp>
#include <filesystem>
#include <sstream>
#include <string>

Expand Down Expand Up @@ -280,7 +279,7 @@ TableWorkspace_sptr CalibrationTableHandler::saveCompomentDatabase(const std::st
// Load the database file for the specific component to a table workspace
// if extant, otherwise instantiate an empty table
TableWorkspace_sptr compcaltable = nullptr;
if (boost::filesystem::exists(filename)) {
if (std::filesystem::exists(filename)) {
compcaltable = loadComponentCalibrationTable(filename, tablewsname);
} else {
compcaltable = createCalibrationTableWorkspace(tablewsname, true);
Expand Down Expand Up @@ -646,7 +645,7 @@ bool CorelliCalibrationDatabase::isFileExist(const std::string &filepath) {

// TODO - replace by std::filesystem::exists(filename) until C++17 is properly
// supported
return boost::filesystem::exists(filepath);
return std::filesystem::exists(filepath);
}

//-----------------------------------------------------------------------------
Expand All @@ -657,9 +656,9 @@ bool CorelliCalibrationDatabase::isFileExist(const std::string &filepath) {
* @return
*/
std::string CorelliCalibrationDatabase::joinPath(const std::string &directory, const std::string &basename) {
boost::filesystem::path dir(directory);
boost::filesystem::path file(basename);
boost::filesystem::path fullpath = dir / file;
std::filesystem::path dir(directory);
std::filesystem::path file(basename);
std::filesystem::path fullpath = dir / file;

return fullpath.string();
}
Expand Down
1 change: 0 additions & 1 deletion Framework/Algorithms/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ if(CXXTEST_FOUND)
Mantid::DataObjects
Mantid::Kernel
Boost::boost
Boost::filesystem
${BCRYPT}
gmock
)
Expand Down
42 changes: 21 additions & 21 deletions Framework/Algorithms/test/CorelliCalibrationDatabaseTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#include "MantidDataObjects/EventWorkspace.h"
#include "MantidKernel/DateAndTime.h"
#include "MantidKernel/TimeSeriesProperty.h"
#include <boost/filesystem.hpp>
#include <filesystem>
#include <fstream>

using Mantid::Algorithms::CorelliCalibrationDatabase;
Expand Down Expand Up @@ -50,11 +50,11 @@ class CorelliCalibrationDatabaseTest : public CxxTest::TestSuite {
void test_file_io() {
// create directory
std::string test_dir{"TestCorelliCalibrationX"};
boost::filesystem::create_directory(test_dir);
TS_ASSERT(boost::filesystem::is_directory(test_dir));
std::filesystem::create_directory(test_dir);
TS_ASSERT(std::filesystem::is_directory(test_dir));

// clean
boost::filesystem::remove_all(test_dir);
std::filesystem::remove_all(test_dir);
}

//-----------------------------------------------------------------------------
Expand Down Expand Up @@ -125,20 +125,20 @@ class CorelliCalibrationDatabaseTest : public CxxTest::TestSuite {
// component file: name, remove file if it does exist, save and check file
// existence
const std::string testcalibtablefilename{"/tmp/testsourcedb2.csv"};
boost::filesystem::remove(testcalibtablefilename);
std::filesystem::remove(testcalibtablefilename);
calib_handler.saveCalibrationTable(testcalibtablefilename);
TS_ASSERT(boost::filesystem::exists(testcalibtablefilename));
TS_ASSERT(std::filesystem::exists(testcalibtablefilename));
// load file and check
TableWorkspace_sptr duptable = loadCSVtoTable(testcalibtablefilename, "DuplicatedSource");
TS_ASSERT_EQUALS(duptable->rowCount(), 3);
TS_ASSERT_DELTA(duptable->cell<double>(2, 6), 0.3424, 0.00001);

// Test: save single component file
const std::string testsamplecalfilename{"/tmp/testsampledb2.csv"};
boost::filesystem::remove(testsamplecalfilename);
std::filesystem::remove(testsamplecalfilename);
// save
calib_handler.saveCompomentDatabase("20201117", "sample-position", testsamplecalfilename);
TS_ASSERT(boost::filesystem::exists(testsamplecalfilename));
TS_ASSERT(std::filesystem::exists(testsamplecalfilename));

// load
TableWorkspace_sptr dupsampletable =
Expand All @@ -162,9 +162,9 @@ class CorelliCalibrationDatabaseTest : public CxxTest::TestSuite {
// create directory database
std::string calibdir{"/tmp/TestCorelliCalibration1117"};
// clean previous
boost::filesystem::remove_all(calibdir);
std::filesystem::remove_all(calibdir);
// create data base
boost::filesystem::create_directory(calibdir);
std::filesystem::create_directory(calibdir);
// create a previously generated database file
// will create the following files:
// moderator.csv, sample-position.csv, bank2.csv, bank42.csv
Expand Down Expand Up @@ -206,11 +206,11 @@ class CorelliCalibrationDatabaseTest : public CxxTest::TestSuite {
TS_ASSERT_EQUALS(combinedcalibws->cell<std::string>(4, 0), "bank42/sixteenpack");

// Output 2: search the saved output calibration file
boost::filesystem::path pdir(calibdir);
boost::filesystem::path pbase("corelli_instrument_20201117.csv");
boost::filesystem::path ptodaycalfile = pdir / pbase;
std::filesystem::path pdir(calibdir);
std::filesystem::path pbase("corelli_instrument_20201117.csv");
std::filesystem::path ptodaycalfile = pdir / pbase;
std::string todaycalfile = ptodaycalfile.string();
TS_ASSERT(boost::filesystem::exists(todaycalfile));
TS_ASSERT(std::filesystem::exists(todaycalfile));
// load and compare
// ... ...

Expand Down Expand Up @@ -341,13 +341,13 @@ class CorelliCalibrationDatabaseTest : public CxxTest::TestSuite {
*/
void create_existing_database_files(const std::string &calibdir, std::vector<std::string> &banks) {

boost::filesystem::path dir(calibdir);
std::filesystem::path dir(calibdir);

for (auto bankname : banks) {
// create full path database name
std::string basename = bankname + ".csv";
boost::filesystem::path basepath(basename);
boost::filesystem::path fullpath = dir / basename;
std::filesystem::path basepath(basename);
std::filesystem::path fullpath = dir / basename;
std::string filename = fullpath.string();
// write file
std::ofstream bankofs(filename, std::ofstream::out);
Expand All @@ -369,13 +369,13 @@ class CorelliCalibrationDatabaseTest : public CxxTest::TestSuite {
void verify_component_files(const std::string &calfiledir, const std::string &component,
size_t expectedrecordsnumber) {
// Create full file path
boost::filesystem::path pdir(calfiledir);
boost::filesystem::path pbase(component + ".csv");
boost::filesystem::path pcompcalfile = pdir / pbase;
std::filesystem::path pdir(calfiledir);
std::filesystem::path pbase(component + ".csv");
std::filesystem::path pcompcalfile = pdir / pbase;
std::string compcalfile = pcompcalfile.string();

// Assert file existence
TS_ASSERT(boost::filesystem::exists(compcalfile));
TS_ASSERT(std::filesystem::exists(compcalfile));

// Load table
TableWorkspace_sptr tablews = loadCSVtoTable(compcalfile, "CorelliVerify_" + component);
Expand Down
2 changes: 1 addition & 1 deletion Framework/Crystal/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ include_directories(inc)
target_link_libraries(
Crystal
PUBLIC Mantid::API Mantid::Geometry Mantid::Kernel
PRIVATE Mantid::DataObjects Mantid::Indexing Boost::filesystem
PRIVATE Mantid::DataObjects Mantid::Indexing
)

# Add the unit tests directory
Expand Down
26 changes: 11 additions & 15 deletions Framework/Crystal/src/SCDCalibratePanels2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/xml_parser.hpp>

#include <boost/filesystem.hpp>
#include <boost/math/special_functions/round.hpp>
#include <cmath>
#include <filesystem>
#include <fstream>
#include <iostream>
#include <sstream>
Expand Down Expand Up @@ -1435,7 +1435,7 @@ void SCDCalibratePanels2::profileL1(Mantid::API::IPeaksWorkspace_sptr &pws,
}
}

double xValues[7] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; // xValues is not used
const double xValues[7] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; // xValues is not used

// scan from -4cm to 4cm along dL1 where the minimum is supposed to be at 0 for null
// case with instrument at the engineering position
Expand Down Expand Up @@ -1464,8 +1464,7 @@ void SCDCalibratePanels2::profileL1(Mantid::API::IPeaksWorkspace_sptr &pws,
}

// output to file
auto filenamebase = boost::filesystem::temp_directory_path();
filenamebase /= boost::filesystem::unique_path("profileSCDCalibratePanels2_L1.csv");
auto filenamebase = std::filesystem::temp_directory_path() / "profileSCDCalibratePanels2_L1.csv";
std::ofstream profL1File;
profL1File.open(filenamebase.string());
profL1File << msgrst.str();
Expand Down Expand Up @@ -1538,8 +1537,8 @@ void SCDCalibratePanels2::profileBanks(Mantid::API::IPeaksWorkspace_sptr &pws,
target[i * 3 + j] = qv[j];
}
}
//
double xValues[7] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; // xValues is not used

const double xValues[7] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; // xValues is not used

// NOTE: very expensive scan of the parameter space
for (double dx = -1e-2; dx < 1e-2; dx += 2e-2 / 20.0) {
Expand Down Expand Up @@ -1585,9 +1584,8 @@ void SCDCalibratePanels2::profileBanks(Mantid::API::IPeaksWorkspace_sptr &pws,
}

// output to file
auto filenamebase = boost::filesystem::temp_directory_path();
std::string fnbase = "profileSCDCalibratePanels2_" + bankname + ".csv";
filenamebase /= boost::filesystem::unique_path(fnbase);
const std::string csvname = "profileSCDCalibratePanels2_" + bankname + ".csv";
auto filenamebase = std::filesystem::temp_directory_path() / csvname;
std::ofstream profBankFile;
profBankFile.open(filenamebase.string());
profBankFile << msgrst.str();
Expand Down Expand Up @@ -1644,7 +1642,7 @@ void SCDCalibratePanels2::profileT0(Mantid::API::IPeaksWorkspace_sptr &pws,
}
}

double xValues[7] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; // xValues is not used
const double xValues[7] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; // xValues is not used

// scan from -10 ~ 10 ms along dT0
double deltaT0 = -10;
Expand All @@ -1671,8 +1669,7 @@ void SCDCalibratePanels2::profileT0(Mantid::API::IPeaksWorkspace_sptr &pws,
}

// output to file
auto filenamebase = boost::filesystem::temp_directory_path();
filenamebase /= boost::filesystem::unique_path("profileSCDCalibratePanels2_T0.csv");
auto filenamebase = std::filesystem::temp_directory_path() / "profileSCDCalibratePanels2_T0.csv";
std::ofstream profL1File;
profL1File.open(filenamebase.string());
profL1File << msgrst.str();
Expand Down Expand Up @@ -1722,7 +1719,7 @@ void SCDCalibratePanels2::profileL1T0(Mantid::API::IPeaksWorkspace_sptr &pws,
}
}

double xValues[7] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; // xValues is not used
const double xValues[7] = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0}; // xValues is not used

// profile begin
for (double deltaL1 = -4e-2; deltaL1 < 4e-2; deltaL1 += 1e-4) {
Expand All @@ -1748,8 +1745,7 @@ void SCDCalibratePanels2::profileL1T0(Mantid::API::IPeaksWorkspace_sptr &pws,
}

// output to file
auto filenamebase = boost::filesystem::temp_directory_path();
filenamebase /= boost::filesystem::unique_path("profileSCDCalibratePanels2_L1T0.csv");
auto filenamebase = std::filesystem::temp_directory_path() / "profileSCDCalibratePanels2_L1T0.csv";
std::ofstream profL1File;
profL1File.open(filenamebase.string());
profL1File << msgrst.str();
Expand Down
2 changes: 1 addition & 1 deletion Framework/Crystal/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ if(CXXTEST_FOUND)

cxxtest_add_test(CrystalTest ${TEST_FILES})
target_link_libraries(
CrystalTest PRIVATE Mantid::Crystal Mantid::DataHandling Mantid::MDAlgorithms Mantid::Nexus Boost::filesystem gmock
CrystalTest PRIVATE Mantid::Crystal Mantid::DataHandling Mantid::MDAlgorithms Mantid::Nexus gmock
)
add_framework_test_helpers(CrystalTest)
add_dependencies(CrystalTest Algorithms CurveFitting)
Expand Down
7 changes: 0 additions & 7 deletions Framework/Crystal/test/SCDCalibratePanels2ObjFuncTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
#include "MantidKernel/Logger.h"
#include "MantidKernel/Unit.h"

#include <boost/filesystem.hpp>
#include <boost/math/constants/constants.hpp>
#include <boost/math/special_functions/round.hpp>
#include <cxxtest/TestSuite.h>
Expand Down Expand Up @@ -83,9 +82,6 @@ class SCDCalibratePanels2ObjFuncTest : public CxxTest::TestSuite {
void test_rot_shift() {
g_log.notice() << "test_rot_shift() starts.\n";

// Generate unique temp files
auto filenamebase = boost::filesystem::temp_directory_path();
filenamebase /= boost::filesystem::unique_path("testBank_%%%%%%%%");
// Make a clone of the standard peak workspace
PeaksWorkspace_sptr pws = m_pws->clone();
Mantid::API::IPeaksWorkspace_sptr ipws = std::dynamic_pointer_cast<Mantid::API::IPeaksWorkspace>(pws);
Expand Down Expand Up @@ -143,9 +139,6 @@ class SCDCalibratePanels2ObjFuncTest : public CxxTest::TestSuite {
void test_detector_resize() {
g_log.notice() << "test_Bank() starts.\n";

// Generate unique temp files
auto filenamebase = boost::filesystem::temp_directory_path();
filenamebase /= boost::filesystem::unique_path("testBank_%%%%%%%%");
// Make a clone of the standard peak workspace
PeaksWorkspace_sptr pws = m_pws->clone();
Mantid::API::IPeaksWorkspace_sptr ipws = std::dynamic_pointer_cast<Mantid::API::IPeaksWorkspace>(pws);
Expand Down
Loading
Loading