@@ -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 a future 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,27 @@ 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, use SFTNeutron()/SFTXray())." ),
418+ DeprecationWarning,
419+ 2 );
420+ }
421+ catch (...) { /* don't let warnings break the binding */ }
422+ obj.setScatteringFactorTableByType (tp);
423+ },
424+ bp::arg (" tp" ),
425+ doc_ScatteringFactorTableOwner_setScatteringFactorTableByType)
406426 .def (" getRadiationType" ,
407427 &SFTOwner::getRadiationType,
408428 return_value_policy<copy_const_reference>(),
0 commit comments