diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 3b3bc458c7..16b68ca12b 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -31,6 +31,7 @@ Since last release **Removed:** * Removed the ResourceBuff class and replaced its instances with ResBuf (#1755) +* Removed reference to deprecated ``ProgTranslator::Context`` class (#1811) **Fixed:** @@ -38,6 +39,7 @@ Since last release * Removed GTest source code from code coverage reports (#1759) * Updated action versions to avoid node.js deprecation (#1802) * Removed the module imports in `cyclus/__init__.py` and removed the need for multi-phase initialization of Cython modules (#1809) +* No longer use deprecated Numpy Cython api when Cython>=3 (#1811) * ResTracker Extract gave the wrong parent_id to one of the child resources (#1806) diff --git a/cyclus/CMakeLists.txt b/cyclus/CMakeLists.txt index 6c9179b02c..463c4ec0bb 100644 --- a/cyclus/CMakeLists.txt +++ b/cyclus/CMakeLists.txt @@ -38,6 +38,9 @@ foreach(file ${CYCLUS_CYTHON_FILES}) set_target_properties(${targ} PROPERTIES LINKER_LANGUAGE CXX OUTPUT_NAME ${name} LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}") + if (CYTHON_VERSION_MAJOR GREATER_EQUAL 3) + target_compile_definitions(${targ} PRIVATE NPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION) + endif() # the following install is needed so that CMake sets the correct RPATH for the # python extension modules, even though they are installed (with the wrong RPATH) # by setup.py, along with the pure python files. diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3f948191a3..d05b552d7d 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -150,12 +150,15 @@ if(Cython_FOUND) ADD_LIBRARY(${name} ${_cc_file}) SET(CythonModuleSrc ${CythonModuleSrc} ${_cc_file}) - SET_TARGET_PROPERTIES(${name} PROPERTIES + SET_TARGET_PROPERTIES(${name} PROPERTIES OUTPUT_NAME "${name}" PREFIX "" INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib" INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib" ) + IF (CYTHON_VERSION_MAJOR GREATER_EQUAL 3) + TARGET_COMPILE_DEFINITIONS(${name} PRIVATE NPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION) + ENDIF() TARGET_LINK_LIBRARIES(${name} dl ${NoCythonLibs}) diff --git a/src/context.h b/src/context.h index 3892006f58..e46a11e09c 100644 --- a/src/context.h +++ b/src/context.h @@ -198,8 +198,14 @@ class Context { } Agent* m = protos_[proto_name]; + if (m == NULL) { + throw KeyError("Null prototype for " + proto_name); + } T* casted(NULL); Agent* clone = m->Clone(); + if (clone == NULL) { + throw StateError("Clone operation failed for " + proto_name); + } casted = dynamic_cast(clone); if (casted == NULL) { PyDelAgent(clone->id()); diff --git a/src/infile_tree.cc b/src/infile_tree.cc index 1540b4c7ff..5af4fa575d 100644 --- a/src/infile_tree.cc +++ b/src/infile_tree.cc @@ -10,7 +10,7 @@ namespace cyclus { -#if LIBXMLXX_MAJOR_VERSION == 2 +#if LIBXMLXX_MAJOR_VERSION == 2 typedef xmlpp::NodeSet NodeSet; typedef xmlpp::Node::NodeList const_NodeList; #else @@ -76,7 +76,7 @@ std::string InfileTree::GetString(std::string query, int index) { dynamic_cast(nodeset.at(index)); if (!element) { - throw CastError("Node: " + element->get_name() + + throw CastError("Node: " + nodeset.at(index)->get_name() + " is not an Element node."); } @@ -90,7 +90,7 @@ std::string InfileTree::GetString(std::string query, int index) { dynamic_cast(element->get_children().front()); if (!text) { - throw CastError("Node: " + text->get_name() + " is not a Text node."); + throw CastError("Node: " + element->get_name() + " is not a Text node."); } return text->get_content(); @@ -129,7 +129,7 @@ InfileTree* InfileTree::GetEngineFromQuery(std::string query, int index) { xmlpp::Element* element = dynamic_cast(nodeset.at(index)); if (!element) { - throw CastError("Node: " + element->get_name() + + throw CastError("Node: " + nodeset.at(index)->get_name() + " is not an Element node."); } diff --git a/src/package.cc b/src/package.cc index b5ab64e301..1e601c5b20 100644 --- a/src/package.cc +++ b/src/package.cc @@ -146,6 +146,7 @@ int TransportUnit::MaxShippablePackages(int pkgs) { } return shippable; } + return 0; } TransportUnit::TransportUnit(std::string name, int fill_min, int fill_max, std::string strategy) : diff --git a/src/prog_translator.cc b/src/prog_translator.cc index cf6a284442..50d387c541 100644 --- a/src/prog_translator.cc +++ b/src/prog_translator.cc @@ -230,15 +230,5 @@ void ProgTranslator::FromProg() { } } -ProgTranslator::Context::Context() { - throw DepricationError("Class ProgTranslator::Context is now deprecated " - "in favor of ProgTranslatorContext."); -} - -ProgTranslator::Context::~Context() { - throw DepricationError("Class ProgTranslator::Context is now deprecated " - "in favor of ProgTranslatorContext."); -} - } // namespace cyclus diff --git a/src/toolkit/building_manager.cc b/src/toolkit/building_manager.cc index adfe55f1d9..ea616438e9 100644 --- a/src/toolkit/building_manager.cc +++ b/src/toolkit/building_manager.cc @@ -3,8 +3,6 @@ #include "prog_translator.h" #include "CoinPackedVector.hpp" -// Headers in this file below this pragma have all warnings shushed. -#pragma GCC system_header #include "OsiCbcSolverInterface.hpp" namespace cyclus { diff --git a/src/toolkit/matl_sell_policy.cc b/src/toolkit/matl_sell_policy.cc index 50e6105e18..f6f86980ea 100644 --- a/src/toolkit/matl_sell_policy.cc +++ b/src/toolkit/matl_sell_policy.cc @@ -208,13 +208,13 @@ std::set::Ptr> MatlSellPolicy::GetMatlBids( // overflow to negative int limit std::string s; if (manager() != NULL) - s + " Agent: " + s += " Agent: " + Trader::manager()->prototype() + "-" + std::to_string(Trader::manager()->id()) + ". "; - s + "This is likely due to too much material (did you forget a " - + "throughput?) or small package limits relative to the " - + "quantity available. qty: " + std::to_string(qty) - + ", and each bid would be: " + std::to_string(bid_qty); + s += "This is likely due to too much material (did you forget a "; + s += "throughput?) or small package limits relative to the "; + s += "quantity available. qty: " + std::to_string(qty); + s += ", and each bid would be: " + std::to_string(bid_qty); Package::ExceedsSplitLimits(n_full_bids, s); bids.assign(n_full_bids, bid_qty); diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index eb6138bf28..2acf0a7d3a 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -7,7 +7,10 @@ SET(GENERATED_TEST_LIST "" CACHE INTERNAL "") SET(GENERATED_FILTER_LIST "" CACHE INTERNAL "") SET(GENERATED_TEST_SOURCE_LIST "" CACHE INTERNAL "") -include(FetchContent) +INCLUDE(FetchContent) +IF (CMAKE_VERSION GREATER_EQUAL 3.24) + CMAKE_POLICY(SET CMP0135 NEW) +ENDIF() FetchContent_Declare( googletest BUILD_GMOCK FALSE # do not build googlemock subproject diff --git a/tests/prog_translator_tests.cc b/tests/prog_translator_tests.cc index 63ab0b17b8..c7c20dfc16 100644 --- a/tests/prog_translator_tests.cc +++ b/tests/prog_translator_tests.cc @@ -280,11 +280,5 @@ TEST(ProgTranslatorTests, translation) { delete iface; } -TEST(ProgTranslatorTests, depricated) { - - // confirm depricated error is thrown - ASSERT_THROW(new ProgTranslator::Context(), DepricationError); -} - } // namespace cyclus