@@ -158,8 +158,11 @@ const char* doc_ScatteringFactorTableOwner_setScatteringFactorTableByType = "\
158158Set internal ScatteringFactorTable according to specified string type.\n \
159159\n \
160160tp -- string identifier of a registered ScatteringFactorTable type.\n \
161- Use ScatteringFactorTable.getRegisteredTypes for the allowed values.\n \
161+ Use ScatteringFactorTable.getRegisteredTypes for the allowed values.\n \
162162\n \
163+ Deprecated: This method is deprecated and will be removed in the 2.0.0 release.\n \
164+ Use direct assignment to the `scatteringfactortable` property instead, for example:\n \
165+ obj.scatteringfactortable = SFTNeutron()\n \
163166No return value.\n \
164167" ;
165168
@@ -399,10 +402,28 @@ void wrap_ScatteringFactorTable()
399402 getsftable,
400403 setsftable<ScatteringFactorTableOwner,ScatteringFactorTable>,
401404 doc_ScatteringFactorTableOwner_scatteringfactortable)
405+ // deprecated: prefer assigning the `scatteringfactortable` property
402406 .def (" setScatteringFactorTableByType" ,
403- &SFTOwner::setScatteringFactorTableByType,
404- bp::arg (" tp" ),
405- doc_ScatteringFactorTableOwner_setScatteringFactorTableByType)
407+ +[](SFTOwner& obj, const std::string& tp)
408+ {
409+ namespace bp = boost::python;
410+ try
411+ {
412+ bp::object warnings = bp::import (" warnings" );
413+ bp::object builtins = bp::import (" builtins" );
414+ bp::object DeprecationWarning = builtins.attr (" DeprecationWarning" );
415+ warnings.attr (" warn" )(
416+ std::string (" setScatteringFactorTableByType is deprecated; "
417+ " assign the 'scatteringfactortable' property directly, for example:\n "
418+ " obj.scatteringfactortable = SFTNeutron()" ),
419+ DeprecationWarning,
420+ 2 );
421+ }
422+ catch (...) { /* don't let warnings break the binding */ }
423+ obj.setScatteringFactorTableByType (tp);
424+ },
425+ bp::arg (" tp" ),
426+ doc_ScatteringFactorTableOwner_setScatteringFactorTableByType)
406427 .def (" getRadiationType" ,
407428 &SFTOwner::getRadiationType,
408429 return_value_policy<copy_const_reference>(),
0 commit comments