Skip to content

Commit 969eeb0

Browse files
committed
Fix tests
To fix tests that were broken by the most recent commits, we should remember to check that an Indices property was indeed found. A common idiom in Cadabra is to not declare it when doing simple things. Also, we need to account for products of traceless matrices that have no parent. Even when there is a parent, we need to let its multiplier be propagated from the child. Signed-off-by: Connor Behan <[email protected]>
1 parent 0e64c8d commit 969eeb0

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
lines changed

core/Algorithm.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
3434
#include "properties/Indices.hh"
3535
#include "properties/Coordinate.hh"
3636
#include "properties/Symbol.hh"
37+
#include "properties/Trace.hh"
3738
#include "properties/DependsBase.hh"
3839

3940
#include <sstream>
@@ -319,7 +320,8 @@ void Algorithm::propagate_zeroes(post_order_iterator& it, const iterator& topnod
319320
return;
320321

321322
const Derivative *der=kernel.properties.get<Derivative>(walk);
322-
if(*walk->name=="\\prod" || der) {
323+
const Trace *trace=kernel.properties.get<Trace>(walk);
324+
if(*walk->name=="\\prod" || der || trace) {
323325
if(der && it->is_index()) return;
324326
walk->multiplier=rat_set.insert(0).first;
325327
it=walk;

core/algorithms/canonicalise.cc

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,14 @@ bool canonicalise::remove_traceless_traces(iterator& it)
5858
while(indit!=end_index(facit)) {
5959
bool incremented_now=false;
6060
auto ind=kernel.properties.get<Indices>(indit, true);
61-
if(ind->set_name==trl->index_set_name) {
62-
incremented_now=true;
63-
++ihits;
61+
if(ind) {
62+
if(ind->set_name==trl->index_set_name) {
63+
incremented_now=true;
64+
++ihits;
65+
}
6466
}
67+
else incremented_now=true;
68+
// Having no name is treated as having the right name
6569
if(countmap.find(Ex(indit))==countmap.end()) {
6670
countmap.insert(Ex(indit));
6771
}
@@ -72,7 +76,7 @@ bool canonicalise::remove_traceless_traces(iterator& it)
7276
++indit;
7377
}
7478
iterator parent=it;
75-
if (tr.number_of_children(parent)==1) parent=tr.parent(it);
79+
if (tr.number_of_children(it)==1 && !tr.is_head(it)) parent=tr.parent(it);
7680
const Trace *trace=kernel.properties.get<Trace>(parent);
7781
if(trace) {
7882
int tmp;
@@ -86,7 +90,7 @@ bool canonicalise::remove_traceless_traces(iterator& it)
8690
auto ind=kernel.properties.get<Indices>(indit, true);
8791
if(ind->set_name==trl->index_set_name && ind->set_name==trace->index_set_name) ++ehits;
8892
if(ehits - ihits > 1) {
89-
zero(parent->multiplier);
93+
zero(it->multiplier);
9094
return true;
9195
}
9296
++indit;

core/properties/WeylTensor.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,10 @@ void WeylTensor::validate(const Kernel& kernel, const Ex& pat) const
3535
index_iterator indit=index_iterator::begin(kernel.properties, pat.begin());
3636
auto ind=kernel.properties.get<Indices>(indit, true);
3737
// We cannot access the right things from parse()
38-
WeylTensor *ptr = const_cast<WeylTensor*>(this);
39-
ptr->index_set_name=ind->set_name;
38+
if(ind) {
39+
WeylTensor *ptr = const_cast<WeylTensor*>(this);
40+
ptr->index_set_name=ind->set_name;
41+
}
4042
}
4143

4244
void WeylTensor::latex(std::ostream& str) const

0 commit comments

Comments
 (0)