This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import logging | |
import inspect | |
def verbose_function(dump_args: bool = True, dump_return: bool = False, dump_args_at_exit: bool = False): | |
""" | |
Decorator to print function call details. | |
This can include: | |
* input parameters names and effective values | |
* output parameters (if they were modified by the function) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def lambda_apriori_ratio_from_interval(value: float, interval: Interval) -> float: | |
""" | |
Returns 1 for a value at the center of the interval | |
Return 1.3 for a value at the border of the interval | |
i.e the values at the border are multiplied by 1.3 | |
(and are thus less likely to be a minimum) | |
""" | |
# x is between -0.5 and 0.5 (0 is the interval center) | |
x = math_utils.unlerp(interval.Min, interval.Max, value) - 0.5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Namespace MyLibrary: an example namespace that will be exported to python as a module | |
namespace MyLibrary | |
{ | |
// Types of full screen modes (enum class) | |
enum class FullScreenMode | |
{ | |
NoFullScreen, | |
FullScreen, // Full screen with specified resolution |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace Internal | |
{ | |
struct SliderAdaptiveInterval | |
{ | |
float max() const { return pow(10.f, CurrentPower); } | |
void SetTargetValue(float targetValue) | |
{ | |
assert (targetValue >= 0.f); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Beware, this code does use `<functional>` | |
// (because I was lazy. It is possible to rewrite the logic in terms of Begin/End) | |
// It works if the gui function that you pass as a parameter is nicely grouped | |
// (i.e. ` ImGui::GetItemID` and `ImGui::GetItemRectSize` will return its correct ID and size) | |
#include "imgui.h" | |
#include "imgui_internal.h" | |
#include <unordered_map> | |
#include <functional> | |
using VoidFunction = std::function<void()>; |
OlderNewer