Skip to content

Commit

Permalink
Require using tinyformat::format over format to fix conflict with…
Browse files Browse the repository at this point in the history
… `std::format`
  • Loading branch information
mtfishman committed Jul 17, 2023
2 parents fe8459a + 3f73826 commit 06c04b8
Show file tree
Hide file tree
Showing 40 changed files with 124 additions and 126 deletions.
8 changes: 4 additions & 4 deletions itensor/index.cc
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ operator==(IndexVal const& iv, Index const& I)
}

string
showDim(Index const& I) { return format("dim=%d",dim(I)); }
showDim(Index const& I) { return tinyformat::format("dim=%d",dim(I)); }

std::ostream&
operator<<(std::ostream& s, IndexVal const& iv)
Expand All @@ -407,7 +407,7 @@ TagSet
getTagSet(Args const& args,
Args::Name const& name)
{
if(!args.defined(name)) Error(format("Name %s not found in Args",name));
if(!args.defined(name)) Error(tinyformat::format("Name %s not found in Args",name));
return TagSet(args.getString(name));
}

Expand Down Expand Up @@ -788,7 +788,7 @@ h5_write(h5::group parent, std::string const& name, Index const& I)
for(auto n : range1(I.nblock()))
{
dims[n-1] = I.blocksize(n);
h5_write(qg,format("QN[%d]",n),I.qn(n));
h5_write(qg,tinyformat::format("QN[%d]",n),I.qn(n));
}
h5_write(qg,"dims",dims);
}
Expand Down Expand Up @@ -818,7 +818,7 @@ h5_read(h5::group parent, std::string const& name, Index & I)
auto qns = vector<QNInt>(nblocks);
for(auto n : range1(nblocks))
{
auto qn = h5_read<QN>(qg,format("QN[%d]",n));
auto qn = h5_read<QN>(qg,tinyformat::format("QN[%d]",n));
qns[n-1] = std::make_pair(qn,dims[n-1]);
}
I = Index(id,dim,toArrow(dir),tags,std::move(qns));
Expand Down
4 changes: 2 additions & 2 deletions itensor/indexset.cc
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,7 @@ h5_write(h5::group parent, std::string const& name, IndexSet const& is)
h5_write(g,"length",N);
for(auto n : range1(N))
{
auto iname = format("index_%d",n);
auto iname = tinyformat::format("index_%d",n);
h5_write(g,iname,is(n));
}
}
Expand All @@ -716,7 +716,7 @@ h5_read(h5::group parent, std::string const& name, IndexSet & is)
auto inds = IndexSetBuilder(N);
for(auto n : range1(N))
{
auto iname = format("index_%d",n);
auto iname = tinyformat::format("index_%d",n);
auto i = h5_read<Index>(g,iname);
inds.nextIndex(i);
}
Expand Down
2 changes: 1 addition & 1 deletion itensor/itdata/dense.cc
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ h5_read(h5::group parent, std::string const& name, Dense<V> & D)
{
auto g = parent.open_group(name);
auto type = h5_read_attribute<string>(g,"type");
if(type != juliaTypeNameOf(D)) Error(format("Group does not contain %s data in HDF5 file",typeNameOf(D)));
if(type != juliaTypeNameOf(D)) Error(tinyformat::format("Group does not contain %s data in HDF5 file",typeNameOf(D)));
auto data = h5_read<vector<V>>(g,"data");
D = Dense<V>(move(data));
}
Expand Down
2 changes: 1 addition & 1 deletion itensor/itdata/diag.cc
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ void
doTask(PrintIT& P, Diag<T> const& d)
{
auto type = std::is_same<T,Real>::value ? "Real" : "Cplx";
P.printInfo(d,format("Diag %s%s",type,d.allSame()?", all same":""),
P.printInfo(d,tinyformat::format("Diag %s%s",type,d.allSame()?", all same":""),
doTask(NormNoScale{},d));

auto r = P.is.order();
Expand Down
6 changes: 3 additions & 3 deletions itensor/itdata/dotask.h
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ callDoTask_Impl(stdx::choice<3>, Task& t, D1& d1, const D2& d2, ManageStore& m,
auto tname = typeNameOf(t);
auto d1name = typeNameOf(d1);
auto d2name = typeNameOf(d2);
throw ITError(format("2 parameter doTask not defined for task %s and storage types %s %s",tname,d1name,d2name));
throw ITError(tinyformat::format("2 parameter doTask not defined for task %s and storage types %s %s",tname,d1name,d2name));
//throw ITError("2 parameter doTask not defined for specified task or data type [2]");
}
template <typename Ret, typename Task, typename D1, typename D2>
Expand Down Expand Up @@ -533,7 +533,7 @@ call(RT& rt, Task& t, D& d, ManageStore& m, Return& ret)
{
auto tname = typeNameOf(t);
auto dname = typeNameOf(d);
throw ITError(format("doTask not defined for task %s and storage type %s",tname,dname));
throw ITError(tinyformat::format("doTask not defined for task %s and storage type %s",tname,dname));
}
}

Expand Down Expand Up @@ -621,7 +621,7 @@ applyToImpl(D2& d2)
auto tname = typeNameOf(t_);
auto d1name = typeNameOf(d1_);
auto d2name = typeNameOf(d2);
throw ITError(format("doTask not defined for task %s and storage types %s %s",tname,d1name,d2name));
throw ITError(tinyformat::format("doTask not defined for task %s and storage types %s %s",tname,d1name,d2name));
}
}

Expand Down
6 changes: 3 additions & 3 deletions itensor/itdata/qdense.cc
Original file line number Diff line number Diff line change
Expand Up @@ -420,14 +420,14 @@ template<typename T>
void
doTask(PrintIT& P, QDense<T> const& d)
{
auto name = format("QDense %s",typeName<T>());
auto name = tinyformat::format("QDense %s",typeName<T>());
if(not P.print_data)
{
P.printInfo(d,name,doTask(NormNoScale{},d));
return;
}

P.s << format("QDense %s {%d blocks; data size %d}\n",
P.s << tinyformat::format("QDense %s {%d blocks; data size %d}\n",
typeName<T>(),d.offsets.size(),d.size());
//Real scalefac = 1.0;
//if(!P.x.isTooBigForReal()) scalefac = P.x.real0();
Expand Down Expand Up @@ -1057,7 +1057,7 @@ h5_read(h5::group parent, std::string const& name, QDense<V> & D)
auto type = h5_read_attribute<string>(g,"type");
if(type != juliaTypeNameOf(D))
{
Error(format("Group does not contain %s or %s data in HDF5 file",typeNameOf(D),juliaTypeNameOf(D)));
Error(tinyformat::format("Group does not contain %s or %s data in HDF5 file",typeNameOf(D),juliaTypeNameOf(D)));
}
auto N = h5_read<long>(g,"ndims");
auto off_array = offsets_to_array(D.offsets,N);
Expand Down
2 changes: 1 addition & 1 deletion itensor/itdata/qdiag.cc
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ template<typename T>
void
doTask(PrintIT& P, QDiag<T> const& d)
{
P.s << format("QDiag%s%s\n",typeName<T>(),d.allSame()?" (all same)":"");
P.s << tinyformat::format("QDiag%s%s\n",typeName<T>(),d.allSame()?" (all same)":"");
Real scalefac = 1.0;
if(!P.x.isTooBigForReal()) scalefac = P.x.real0();
else P.s << "(omitting too large scale factor)\n";
Expand Down
10 changes: 5 additions & 5 deletions itensor/itdata/task_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,14 @@ struct PrintIT
Real nrm_no_scale = -1)
{
#ifndef USESCALE
s << format("{norm=%.2f (%s)}\n",std::fabs(scalefac)*nrm_no_scale,type_name);
s << tinyformat::format("{norm=%.2f (%s)}\n",std::fabs(scalefac)*nrm_no_scale,type_name);
#else
s << "{log(scale)=" << format("%.2f",x.logNum());
s << "{log(scale)=" << tinyformat::format("%.2f",x.logNum());
if(nrm_no_scale > 0)
{
if(!x.isTooBigForReal()) s << ", norm=";
else s << ", norm(omitting large scale)=";
s << format("%.2f",std::fabs(scalefac)*nrm_no_scale);
s << tinyformat::format("%.2f",std::fabs(scalefac)*nrm_no_scale);
}
s << " (" << type_name << ")}\n";
#endif
Expand Down Expand Up @@ -166,7 +166,7 @@ struct ApplyIT
void
applyITImpl(stdx::choice<2>,T1, T2 &)
{
auto msg = format("Apply: function doesn't map %s->%s",typeName<T1>(),typeName<T2>());
auto msg = tinyformat::format("Apply: function doesn't map %s->%s",typeName<T1>(),typeName<T2>());
Error(msg);
}
template<typename T1, typename T2>
Expand Down Expand Up @@ -507,7 +507,7 @@ checkEltInd(IndexSet const& is,
print("inds = ");
for(auto j : inds) print(1+j," ");
println();
Error(format("Out of range: IndexVal at position %d has val %d > %s",1+k,1+i,Index(is[k])));
Error(tinyformat::format("Out of range: IndexVal at position %d has val %d > %s",1+k,1+i,Index(is[k])));
}
}
}
Expand Down
24 changes: 12 additions & 12 deletions itensor/itensor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ eltC() const
if(inds().order() != 0)
{
PrintData(inds());
Error(format("Wrong number of IndexVals passed to elt/eltC (expected 0, got %d)",inds().order()));
Error(tinyformat::format("Wrong number of IndexVals passed to elt/eltC (expected 0, got %d)",inds().order()));
}
constexpr size_t size = 0;
auto inds = IntArray(size);
Expand Down Expand Up @@ -125,7 +125,7 @@ eltC(std::vector<IndexVal> const& ivs) const
println("Indices provided = ");
for(auto& iv : ivs) println(iv.index);
println("---------------------------------------------");
Error(format("Wrong number of IndexVals passed to elt/eltC (expected %d, got %d)",inds().order(),size));
Error(tinyformat::format("Wrong number of IndexVals passed to elt/eltC (expected %d, got %d)",inds().order(),size));
}

auto ints = IntArray(size);
Expand Down Expand Up @@ -167,7 +167,7 @@ set(std::vector<IndexVal> const& ivals,
println("Indices provided = ");
for(auto& iv : ivals) println(iv.index);
println("---------------------------------------------");
Error(format("Wrong number of IndexVals passed to set (expected %d, got %d)",
Error(tinyformat::format("Wrong number of IndexVals passed to set (expected %d, got %d)",
inds().order(),size));
}
auto inds = IntArray(is_.order(),0);
Expand All @@ -190,7 +190,7 @@ set(Cplx val)
{
if(0 != size_t(inds().order()))
{
Error(format("Wrong number of IndexVals passed to set (expected %d, got 0)",
Error(tinyformat::format("Wrong number of IndexVals passed to set (expected %d, got 0)",
inds().order()));
}
auto inds = IntArray(0,1);
Expand Down Expand Up @@ -219,7 +219,7 @@ set(std::vector<int> const& ints,
println("Indices provided = ");
for(auto& iv : ints) println(iv);
println("---------------------------------------------");
Error(format("Wrong number of IndexVals passed to set (expected %d, got %d)",
Error(tinyformat::format("Wrong number of IndexVals passed to set (expected %d, got %d)",
inds().order(),size));
}
auto inds = IntArray(is_.order(),0);
Expand Down Expand Up @@ -640,7 +640,7 @@ permute(IndexSet const& iset)
println("---------------------------------------------");
println("Indices provided = \n",iset,"\n");
println("---------------------------------------------");
Error(format("Wrong number of Indexes passed to permute (expected %d, got %d)",r,iset.order()));
Error(tinyformat::format("Wrong number of Indexes passed to permute (expected %d, got %d)",r,iset.order()));
}

// Get permutation
Expand Down Expand Up @@ -843,7 +843,7 @@ h5_read(h5::group parent, std::string const& name, ITensor & I)
else if(s_type == "Dense{ComplexF64}") store = h5_readStore<DenseCplx>(g,store_name);
else if(s_type == "BlockSparse{Float64}") store = h5_readStore<QDenseReal>(g,store_name);
else if(s_type == "BlockSparse{ComplexF64}") store = h5_readStore<QDenseCplx>(g,store_name);
else error(format("Reading of ITensor storage type %s not yet supported",s_type));
else error(tinyformat::format("Reading of ITensor storage type %s not yet supported",s_type));

I = ITensor(is,std::move(store));
}
Expand Down Expand Up @@ -924,7 +924,7 @@ checkSameDiv(ITensor const& T1,
{
if(div(T1) != div(T2))
{
Error(format("div(T1)=%s must equal div(T2)=%s when adding T1+T2",div(T1),div(T2)));
Error(tinyformat::format("div(T1)=%s must equal div(T2)=%s when adding T1+T2",div(T1),div(T2)));
}
}
}
Expand Down Expand Up @@ -1670,7 +1670,7 @@ moveToFront(IndexSet const& isf, IndexSet const& is)
println("---------------------------------------------");
println("Indices provided = \n",isf," '...'\n");
println("---------------------------------------------");
Error(format("Wrong number of indices passed to permute (expected < %d, got %d)",r,rf));
Error(tinyformat::format("Wrong number of indices passed to permute (expected < %d, got %d)",r,rf));
}

auto iso = IndexSet(r);
Expand All @@ -1685,7 +1685,7 @@ moveToFront(IndexSet const& isf, IndexSet const& is)
println("---------------------------------------------");
println("Indices provided = \n",isf," '...'\n");
println("---------------------------------------------");
Error(format("Bad index passed to permute"));
Error(tinyformat::format("Bad index passed to permute"));
}
iso[i] = I;
i++;
Expand Down Expand Up @@ -1717,7 +1717,7 @@ moveToBack(IndexSet const& isb, IndexSet const& is)
println("---------------------------------------------");
println("Indices provided = \n'...' ",isb,"\n");
println("---------------------------------------------");
Error(format("Wrong number of indices passed to permute (expected < %d, got %d)",r,rb));
Error(tinyformat::format("Wrong number of indices passed to permute (expected < %d, got %d)",r,rb));
}

auto iso = IndexSet(r);
Expand All @@ -1732,7 +1732,7 @@ moveToBack(IndexSet const& isb, IndexSet const& is)
println("---------------------------------------------");
println("Indices provided = \n'...' ",isb,"\n");
println("---------------------------------------------");
Error(format("Bad index passed to permute"));
Error(tinyformat::format("Bad index passed to permute"));
}
iso[i] = I;
i++;
Expand Down
8 changes: 4 additions & 4 deletions itensor/itensor_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ eltC(IV const& iv1, IVs&&... ivs) const
println("Indices provided = ");
for(auto& iv : vals) println(iv.index);
println("---------------------------------------------");
Error(format("Wrong number of IndexVals passed to elt/eltC (expected %d, got %d)",
Error(tinyformat::format("Wrong number of IndexVals passed to elt/eltC (expected %d, got %d)",
inds().order(),size));
}

Expand Down Expand Up @@ -130,7 +130,7 @@ eltC(std::vector<Int> const& ints) const
print("Indices provided = ");
for(auto i : ints) print(" ",i);
println("\n---------------------------------------------");
Error(format("Wrong number of ints passed to elt/eltC (expected %d, got %d)",
Error(tinyformat::format("Wrong number of ints passed to elt/eltC (expected %d, got %d)",
inds().order(),size));
}

Expand Down Expand Up @@ -350,7 +350,7 @@ set(IV const& iv1, VArgs&&... vargs)
println("Indices provided = ");
for(auto& iv : vals) println(iv.index);
println("---------------------------------------------");
Error(format("Wrong number of IndexVals passed to set (expected %d, got %d)",
Error(tinyformat::format("Wrong number of IndexVals passed to set (expected %d, got %d)",
inds().order(),size));
}
auto inds = IntArray(is_.order(),0);
Expand Down Expand Up @@ -389,7 +389,7 @@ set(Int iv1, VArgs&&... vargs)
for(auto& i : ints) print(" ",1+i);
println();
println("---------------------------------------------");
Error(format("Wrong number of ints passed to set (expected %d, got %d)",
Error(tinyformat::format("Wrong number of ints passed to set (expected %d, got %d)",
inds().order(),size));
}
//TODO: if !store_ and !is_real, call allocCplx instead
Expand Down
4 changes: 2 additions & 2 deletions itensor/mps/DMRGObserver.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,8 @@ measure(Args const& args)
if(b == 1 && ha == 2)
{
if(!printeigs) println();
auto swstr = (nsweep>0) ? format("%d/%d",sw,nsweep)
: format("%d",sw);
auto swstr = (nsweep>0) ? tinyformat::format("%d/%d",sw,nsweep)
: tinyformat::format("%d",sw);
println(" Largest link dim during sweep ",swstr," was ",(max_eigs > 1 ? max_eigs : 1));
max_eigs = -1;
println(" Largest truncation error: ",(max_te > 0 ? max_te : 0.));
Expand Down

0 comments on commit 06c04b8

Please sign in to comment.