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: 1 addition & 2 deletions SeQuant/core/binary_node.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

#include <memory>
#include <sstream>
#include <stdexcept>
#include <type_traits>
#include <utility>

Expand Down Expand Up @@ -243,7 +242,7 @@ class FullBinaryNode {
if (n)
return n;
else
throw std::runtime_error(
throw Exception(
"Dereferenced nullptr: use leaf() or root() methods to check for "
"leaf and root nodes");
}
Expand Down
2 changes: 1 addition & 1 deletion SeQuant/core/context.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ class Context {
/// was default constructed)
std::shared_ptr<const IndexSpaceRegistry> index_space_registry() const;
/// @return a pointer to the IndexSpaceRegistry for this context.
/// @throw std::logic_error if the IndexSpaceRegistry is null
/// @throw Exception if the IndexSpaceRegistry is null
std::shared_ptr<IndexSpaceRegistry> mutable_index_space_registry() const;
/// \return IndexSpaceMetric of this context
IndexSpaceMetric metric() const;
Expand Down
3 changes: 2 additions & 1 deletion SeQuant/core/eval/backends/btas/result.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include <SeQuant/core/eval/result.hpp>
#include <SeQuant/core/math.hpp>
#include <SeQuant/core/utility/exception.hpp>

#include <btas/btas.h>

Expand All @@ -28,7 +29,7 @@ auto column_symmetrize_btas(btas::Tensor<Args...> const& arr) {
size_t const rank = arr.rank();

if (rank % 2 != 0)
throw std::domain_error("This function only supports even-ranked tensors");
throw Exception("This function only supports even-ranked tensors");

perm_t perm = iota(size_t{0}, rank) | ranges::to<perm_t>;

Expand Down
3 changes: 2 additions & 1 deletion SeQuant/core/eval/backends/tapp/result.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <SeQuant/core/eval/backends/tapp/tensor.hpp>
#include <SeQuant/core/eval/result.hpp>
#include <SeQuant/core/math.hpp>
#include <SeQuant/core/utility/exception.hpp>

namespace sequant {

Expand All @@ -27,7 +28,7 @@ auto column_symmetrize_tapp(TAPPTensor<T, Alloc> const& arr) {
size_t const rank = arr.rank();

if (rank % 2 != 0)
throw std::domain_error("This function only supports even-ranked tensors");
throw Exception("This function only supports even-ranked tensors");

perm_t perm = iota(size_t{0}, rank) | ranges::to<perm_t>;

Expand Down
4 changes: 2 additions & 2 deletions SeQuant/core/eval/backends/tapp/tensor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#ifdef SEQUANT_HAS_TAPP

#include <SeQuant/core/container.hpp>
#include <SeQuant/core/utility/exception.hpp>

#include <tapp.h>

Expand All @@ -13,7 +14,6 @@
#include <cstdint>
#include <memory>
#include <numeric>
#include <stdexcept>
#include <type_traits>
#include <vector>

Expand Down Expand Up @@ -60,7 +60,7 @@ inline void check_error(TAPP_error err) {
if (!TAPP_check_success(err)) {
char msg[256];
TAPP_explain_error(err, sizeof(msg), msg);
throw std::runtime_error(std::string("TAPP error: ") + msg);
throw Exception(std::string("TAPP error: ") + msg);
}
}

Expand Down
3 changes: 2 additions & 1 deletion SeQuant/core/eval/backends/tiledarray/result.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

#include <SeQuant/core/eval/result.hpp>
#include <SeQuant/core/math.hpp>
#include <SeQuant/core/utility/exception.hpp>

#include <TiledArray/einsum/tiledarray.h>
#include <tiledarray.h>
Expand All @@ -28,7 +29,7 @@ auto column_symmetrize_ta(TA::DistArray<Args...> const& arr) {

size_t const rank = arr.trange().rank();
if (rank % 2 != 0)
throw std::domain_error("This function only supports even-ranked tensors");
throw Exception("This function only supports even-ranked tensors");

TA::DistArray<Args...> result;

Expand Down
2 changes: 1 addition & 1 deletion SeQuant/core/eval/eval_expr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ EvalExprNode binarize(ExprPtr const& expr, IndexSet const& uncontract) {
if (expr->is<Product>()) //
return binarize(expr->as<Product>(), uncontract);

throw std::logic_error("Encountered unsupported expression in binarize.");
throw Exception("Encountered unsupported expression in binarize.");
}

} // namespace impl
Expand Down
12 changes: 5 additions & 7 deletions SeQuant/core/export/export.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include <ranges>
#include <set>
#include <span>
#include <stdexcept>
#include <tuple>
#include <type_traits>
#include <unordered_map>
Expand Down Expand Up @@ -75,7 +74,7 @@ class GenerationVisitor {
} else if (node->is_variable()) {
m_generator.persist(node->as_variable(), m_ctx);
} else {
throw std::runtime_error(
throw Exception(
"Root nodes are expected to be of type tensor or variable");
}

Expand Down Expand Up @@ -139,7 +138,7 @@ class GenerationVisitor {
return;
}
if (!node->is_tensor() && !node->is_variable()) {
throw std::runtime_error(
throw Exception(
"Unexpected expression type in "
"GenerationVisitor::load_or_create");
}
Expand Down Expand Up @@ -842,14 +841,13 @@ void export_groups(Range groups, Generator<Context> &generator, Context ctx) {

if (size(groups) > 1) {
if (!generator.supports_named_sections()) {
throw std::runtime_error("The generator for '" +
generator.get_format_name() +
"' doesn't support named sections");
throw Exception("The generator for '" + generator.get_format_name() +
"' doesn't support named sections");
}

for (const ExpressionGroup<T> &current : groups) {
if (!current.is_named()) {
throw std::runtime_error(
throw Exception(
"Can't have unnamed groups when exporting multiple groups at once");
}
}
Expand Down
8 changes: 4 additions & 4 deletions SeQuant/core/export/itf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ std::string ItfContext::get_name(const IndexSpace &space) const {
auto it = m_space_names.find(space);

if (it == m_space_names.end()) {
throw std::runtime_error("No name known for index space '" +
toUtf8(space.base_key()) + "'");
throw Exception("No name known for index space '" +
toUtf8(space.base_key()) + "'");
}

return it->second;
Expand All @@ -61,8 +61,8 @@ std::string ItfContext::get_tag(const IndexSpace &space) const {
auto it = m_tags.find(space);

if (it == m_tags.end()) {
throw std::runtime_error("No tag known for index space '" +
toUtf8(space.base_key()) + "'");
throw Exception("No tag known for index space '" +
toUtf8(space.base_key()) + "'");
}

return it->second;
Expand Down
17 changes: 7 additions & 10 deletions SeQuant/core/export/itf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ class ItfContext : public ReorderingContext {
/// Generator for ITF. ITF (Integrated Tensor Framework) is a domain-specific
/// language for tensor contractions used by parts of the Molpro quantum
/// chemistry program.
/// WIREs Comput Mol Sci 2012, 2: 242253 doi: 10.1002/wcms.82
/// WIREs Comput Mol Sci 2012, 2: 242-253 doi: 10.1002/wcms.82
template <typename Context = ItfContext>
class ItfGenerator : public Generator<Context> {
public:
Expand Down Expand Up @@ -131,7 +131,7 @@ class ItfGenerator : public Generator<Context> {

std::string represent(const Index &idx, const Context &ctx) const override {
if (idx.has_proto_indices()) {
throw std::runtime_error("ITF doesn't support proto indices");
throw Exception("ITF doesn't support proto indices");
}

const std::size_t ordinal = idx.ordinal().value();
Expand Down Expand Up @@ -203,8 +203,7 @@ class ItfGenerator : public Generator<Context> {
void create(const Tensor &tensor, bool zero_init,
const Context &ctx) override {
if (!zero_init) {
throw std::runtime_error(
"Can't create ITF tensor without setting it to zero");
throw Exception("Can't create ITF tensor without setting it to zero");
}

m_generated += "alloc " + represent(tensor, ctx) + "\n";
Expand Down Expand Up @@ -240,8 +239,7 @@ class ItfGenerator : public Generator<Context> {
void create(const Variable &variable, bool zero_init,
const Context &ctx) override {
if (!zero_init) {
throw std::runtime_error(
"Can't create ITF variable without setting it to zero");
throw Exception("Can't create ITF variable without setting it to zero");
}

m_generated += "alloc " + represent(variable, ctx) + "\n";
Expand Down Expand Up @@ -406,7 +404,7 @@ class ItfGenerator : public Generator<Context> {
const Product &product = expr.as<Product>();

if (product.factors().size() > 2) {
throw std::runtime_error("ITF can only handle binary contractions");
throw Exception("ITF can only handle binary contractions");
}

std::string repr;
Expand All @@ -426,11 +424,10 @@ class ItfGenerator : public Generator<Context> {
return repr;
} else if (expr.is<Sum>()) {
// TODO: Handle on-the-fly antisymmetrization (K[abij] - K[baij])
throw std::runtime_error("ITF doesn't support explicit summation");
throw Exception("ITF doesn't support explicit summation");
}

throw std::runtime_error(
"Unsupported expression type in ItfGenerator::compute");
throw Exception("Unsupported expression type in ItfGenerator::compute");
}
};

Expand Down
5 changes: 3 additions & 2 deletions SeQuant/core/export/julia_itensor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <SeQuant/core/expr.hpp>
#include <SeQuant/core/index.hpp>
#include <SeQuant/core/space.hpp>
#include <SeQuant/core/utility/exception.hpp>

#include <range/v3/view/join.hpp>
#include <range/v3/view/transform.hpp>
Expand Down Expand Up @@ -41,7 +42,7 @@ class JuliaITensorGenerator : public JuliaTensorOperationsGenerator<Context> {
void create(const Tensor &tensor, bool zero_init,
const Context &ctx) override {
if (!zero_init) {
throw std::runtime_error(
throw Exception(
"In Julia tensors can't be created without being initialized");
}

Expand Down Expand Up @@ -78,7 +79,7 @@ class JuliaITensorGenerator : public JuliaTensorOperationsGenerator<Context> {
void create(const Variable &variable, bool zero_init,
const Context &ctx) override {
if (!zero_init) {
throw std::runtime_error(
throw Exception(
"Julia doesn't support declaring a variable without initializing it");
}

Expand Down
5 changes: 3 additions & 2 deletions SeQuant/core/export/julia_tensor_kit.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include <SeQuant/core/expr.hpp>
#include <SeQuant/core/index.hpp>
#include <SeQuant/core/space.hpp>
#include <SeQuant/core/utility/exception.hpp>

#include <range/v3/view/enumerate.hpp>

Expand Down Expand Up @@ -35,7 +36,7 @@ class JuliaTensorKitGenerator : public JuliaTensorOperationsGenerator<Context> {
void create(const Tensor &tensor, bool zero_init,
const Context &ctx) override {
if (!zero_init) {
throw std::runtime_error(
throw Exception(
"In Julia tensors can't be created without being initialized");
}

Expand Down Expand Up @@ -79,7 +80,7 @@ class JuliaTensorKitGenerator : public JuliaTensorOperationsGenerator<Context> {
const std::size_t num_indices = tensor.num_indices();

if (braRank == 0 && num_indices > 0) {
throw std::runtime_error(
throw Exception(
"It is not (yet) clear how to represent a zero-dimensional domain "
"for a tensor in TensorKit");
}
Expand Down
4 changes: 2 additions & 2 deletions SeQuant/core/export/julia_tensor_operations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ std::string JuliaTensorOperationsGeneratorContext::get_tag(
auto it = m_index_tags.find(space);

if (it == m_index_tags.end()) {
throw std::runtime_error("No known tags for indices of space \"" +
toUtf8(space.base_key()) + "\"");
throw Exception("No known tags for indices of space \"" +
toUtf8(space.base_key()) + "\"");
}

return it->second;
Expand Down
8 changes: 4 additions & 4 deletions SeQuant/core/export/julia_tensor_operations.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class JuliaTensorOperationsGenerator : public Generator<Context> {

std::string represent(const Index &idx, const Context &) const override {
if (idx.has_proto_indices()) {
throw std::runtime_error("Proto Indices are not (yet) supported!");
throw Exception("Proto Indices are not (yet) supported!");
}

return toUtf8(idx.full_label());
Expand Down Expand Up @@ -127,7 +127,7 @@ class JuliaTensorOperationsGenerator : public Generator<Context> {
void create(const Tensor &tensor, bool zero_init,
const Context &ctx) override {
if (!zero_init) {
throw std::runtime_error(
throw Exception(
"In Julia tensors can't be created without being initialized");
}

Expand Down Expand Up @@ -171,7 +171,7 @@ class JuliaTensorOperationsGenerator : public Generator<Context> {
void create(const Variable &variable, bool zero_init,
const Context &ctx) override {
if (!zero_init) {
throw std::runtime_error(
throw Exception(
"Julia doesn't support declaring a variable without initializing it");
}

Expand Down Expand Up @@ -303,7 +303,7 @@ class JuliaTensorOperationsGenerator : public Generator<Context> {
return repr;
}

throw std::runtime_error("Unsupported expression type in to_julia_expr");
throw Exception("Unsupported expression type in to_julia_expr");
}

std::string tensor_name(const Tensor &tensor, const Context &ctx) const {
Expand Down
Loading