MCPcopy Create free account
hub / github.com/MrNeRF/LichtFeld-Studio / reset

Method reset

src/python/lfs/py_params.cpp:608–643  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

606 }
607
608 void PyOptimizationParams::reset(const std::string& prop_id) {
609 auto meta = PropertyRegistry::instance().get_property("optimization", prop_id);
610 if (!meta) {
611 throw std::runtime_error("Unknown property: " + prop_id);
612 }
613
614 std::any default_val;
615 switch (meta->type) {
616 case PropType::Float:
617 default_val = static_cast<float>(meta->default_value);
618 break;
619 case PropType::Int:
620 default_val = static_cast<int>(meta->default_value);
621 break;
622 case PropType::SizeT:
623 default_val = static_cast<size_t>(meta->default_value);
624 break;
625 case PropType::Bool:
626 default_val = meta->default_value > 0.5;
627 break;
628 case PropType::String:
629 default_val = meta->default_string;
630 break;
631 case PropType::Enum:
632 default_val = meta->default_enum;
633 break;
634 default:
635 throw std::runtime_error("Unsupported property type for reset");
636 }
637
638 auto& p = params();
639 auto ref = PropertyObjectRef::cpp(&p);
640 std::any old_value = meta->getter(ref);
641 meta->setter(ref, default_val);
642 PropertyRegistry::instance().notify("optimization", prop_id, old_value, default_val);
643 }
644
645 nb::list PyOptimizationParams::properties() const {
646 auto* group = PropertyRegistry::instance().get_group("optimization");

Callers 6

setInputMethod · 0.45
begin_frameMethod · 0.45
end_tableMethod · 0.45
destroyMethod · 0.45
setInputMethod · 0.45

Calls 6

instanceFunction · 0.85
paramsFunction · 0.85
getterMethod · 0.80
setterMethod · 0.80
get_propertyMethod · 0.45
notifyMethod · 0.45

Tested by

no test coverage detected