Skip to content

Commit

Permalink
Merge branch 'develop' into dirac_converter_msd
Browse files Browse the repository at this point in the history
  • Loading branch information
ye-luo authored Oct 5, 2021
2 parents 9414af2 + c093820 commit 1a71e25
Show file tree
Hide file tree
Showing 8 changed files with 79 additions and 16 deletions.
6 changes: 6 additions & 0 deletions nexus/lib/versions.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
# 3.7 https://www.python.org/dev/peps/pep-0537/
# 3.8 https://www.python.org/dev/peps/pep-0569/
# 3.9 https://www.python.org/dev/peps/pep-0596/
# 3.10 https://www.python.org/dev/peps/pep-0619/
python3 = '''
3.3.0 2012-09-29
3.3.1 2013-04-06
Expand All @@ -107,6 +108,7 @@
3.7.4 2019-07-08
3.8.0 2019-10-21
3.9.0 2020-06-08
3.10.0 2021-10-04
''',
# numpy releases
# https://github.com/numpy/numpy/releases
Expand Down Expand Up @@ -843,6 +845,7 @@ def check(self,write=True,exit=False,full=False,n=0,pad=' '):
spglib_available = False
pycifrw_available = False
seekpath_available = False
cif2cell_available = False

numpy_supported = False
scipy_supported = False
Expand All @@ -852,6 +855,7 @@ def check(self,write=True,exit=False,full=False,n=0,pad=' '):
spglib_supported = False
pycifrw_supported = False
seekpath_supported = False
cif2cell_supported = False

try: # versioning info is never worth failure
versions = Versions()
Expand All @@ -864,6 +868,7 @@ def check(self,write=True,exit=False,full=False,n=0,pad=' '):
spglib_available = versions.available('spglib')
pycifrw_available = versions.available('pycifrw')
seekpath_available = versions.available('seekpath')
cif2cell_available = versions.available('cif2cell')

numpy_supported = versions.supported('numpy')
scipy_supported = versions.supported('scipy')
Expand All @@ -873,6 +878,7 @@ def check(self,write=True,exit=False,full=False,n=0,pad=' '):
spglib_supported = versions.supported('spglib')
pycifrw_supported = versions.supported('pycifrw')
seekpath_supported = versions.supported('seekpath')
cif2cell_supported = versions.supported('cif2cell')
except:
versions = None
#end try
Expand Down
2 changes: 1 addition & 1 deletion nexus/tests/unit/test_structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -676,7 +676,7 @@ def test_read_write():



if versions.pycifrw_available:
if versions.pycifrw_available and versions.cif2cell_available:
def test_read_cif():
"""
Read La2CuO4 structure from a CIF file.
Expand Down
11 changes: 6 additions & 5 deletions src/QMCDrivers/QMCDriverNew.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,13 @@ void QMCDriverNew::checkNumCrowdsLTNumThreads(const int num_crowds)
* - initialize Estimators
* - initialize Walkers
*/
void QMCDriverNew::startup(xmlNodePtr cur, QMCDriverNew::AdjustedWalkerCounts awc)
void QMCDriverNew::startup(xmlNodePtr cur, const QMCDriverNew::AdjustedWalkerCounts& awc)
{
app_summary() << this->QMCType << " Driver running with target_walkers = " << awc.global_walkers << std::endl
<< " walkers_per_rank = " << awc.walkers_per_rank << std::endl
<< " num_crowds = " << awc.walkers_per_crowd.size() << std::endl
<< " on rank 0, walkers_per_crowd = " << awc.walkers_per_crowd << std::endl
app_summary() << QMCType << " Driver running with" << std::endl
<< " total_walkers = " << awc.global_walkers << std::endl
<< " walkers_per_rank = " << awc.walkers_per_rank << std::endl
<< " num_crowds = " << awc.walkers_per_crowd.size() << std::endl
<< " on rank 0, walkers_per_crowd = " << awc.walkers_per_crowd << std::endl
<< std::endl;

// set num_global_walkers explicitly and then make local walkers.
Expand Down
2 changes: 1 addition & 1 deletion src/QMCDrivers/QMCDriverNew.h
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ class QMCDriverNew : public QMCDriverInterface, public MPIObjectBase
* And these are the arguments to the branch_engine and estimator_manager
* Constructors or these objects should be created elsewhere.
*/
void startup(xmlNodePtr cur, QMCDriverNew::AdjustedWalkerCounts awc);
void startup(xmlNodePtr cur, const QMCDriverNew::AdjustedWalkerCounts& awc);

static void initialLogEvaluation(int crowd_id, UPtrVector<Crowd>& crowds, UPtrVector<ContextForSteps>& step_context);

Expand Down
24 changes: 18 additions & 6 deletions src/Utilities/StlPrettyPrint.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,32 @@
namespace qmcplusplus
{

/** collapsed vector printout
* [3, 3, 2, 2] is printed as [3(x2), 2(x2)]
*/
template<typename T>
std::ostream& operator<<(std::ostream& out, const std::vector<T>& rhs)
{
out << "[";
if (!rhs.empty())
auto cursor = rhs.begin();
while (cursor != rhs.end())
{
auto last = rhs.end();
last--;
copy(rhs.begin(), last, std::ostream_iterator<T>(out, ", "));
out << *last;
// each iteration handles one unique value
const T ref_value = *cursor;
size_t count = 1;
while (++cursor != rhs.end() && *cursor == ref_value)
count++;
out << ref_value;
// identical elements are collapsed
if (count > 1)
out << "(x" << count << ")";
// if not the last element, add a separator
if (cursor != rhs.end())
out << ", ";
}
out << "]";
return out;
}

}
} // namespace qmcplusplus
#endif
1 change: 1 addition & 0 deletions src/Utilities/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ add_executable(
test_project_data.cpp
test_rng_control.cpp
test_output_manager.cpp
test_StlPrettyPrint.cpp
test_StdRandom.cpp)
target_link_libraries(${UTEST_EXE} catch_main qmcutil)

Expand Down
3 changes: 0 additions & 3 deletions src/Utilities/tests/for_testing/test_RandomForTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,6 @@

#include "catch.hpp"
#include "RandomForTest.cpp"
#include "../StlPrettyPrint.hpp"
#include <iostream>
#include <string>

/** \file
*/
Expand Down
46 changes: 46 additions & 0 deletions src/Utilities/tests/test_StlPrettyPrint.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
//////////////////////////////////////////////////////////////////////////////////////
// This file is distributed under the University of Illinois/NCSA Open Source License.
// See LICENSE file in top directory for details.
//
// Copyright (c) 2021 QMCPACK developers.
//
// File developed by: Ye Luo, yeluo@anl.gov, Argonne National Laboratory
//
// File created by: Ye Luo, yeluo@anl.gov, Argonne National Laboratory
//////////////////////////////////////////////////////////////////////////////////////

#include "catch.hpp"
#include <sstream>
#include "StlPrettyPrint.hpp"

namespace qmcplusplus
{
TEST_CASE("StlPrettyPrint", "[utilities]")
{
std::ostringstream msg;
std::vector<int> vec;

msg << vec;
CHECK(msg.str() == "[]");

msg.str(std::string());
vec = {4, 4, 3, 3};
msg << vec;
CHECK(msg.str() == "[4(x2), 3(x2)]");

msg.str(std::string());
vec = {4, 4, 3};
msg << vec;
CHECK(msg.str() == "[4(x2), 3]");

msg.str(std::string());
vec = {4, 3, 3};
msg << vec;
CHECK(msg.str() == "[4, 3(x2)]");

msg.str(std::string());
vec = {4, 3, 2};
msg << vec;
CHECK(msg.str() == "[4, 3, 2]");
}
} // namespace qmcplusplus

0 comments on commit 1a71e25

Please sign in to comment.