Skip to content

ParamDump and python: add choices param type #90

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion flucoma/doc/cli/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ def cli_type_map(type):
'enum':'int',
'fft': 'int',
'dataset':'symbol',
'labelset':'symbol'
'labelset':'symbol',
'chocies': 'symbol'
}[type]

def transform_data(client, data):
Expand Down
3 changes: 2 additions & 1 deletion flucoma/doc/max/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ def max_type_map(type):
'enum':'int',
'fft': 'int',
'dataset':'symbol',
'labelset':'symbol'
'labelset':'symbol',
'choices':'symbol'
}[type]


Expand Down
3 changes: 2 additions & 1 deletion flucoma/doc/pd/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ def pd_type_map(type):
'enum':'int',
'fft': 'int',
'dataset':'symbol',
'labelset':'symbol'
'labelset':'symbol',
'choices':'symbol'
}[type]

def transform_data(client, data):
Expand Down
3 changes: 2 additions & 1 deletion flucoma/doc/sc/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ def sc_type_map(type):
'enum':'Integer',
'fft': 'Integer',
'dataset':'FluidDataSet',
'labelset':'FluidLabelSet'
'labelset':'FluidLabelSet',
'chocies': 'Symbol'
}[type]


Expand Down
25 changes: 23 additions & 2 deletions include/FluidParameterDump.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ under the European Union’s Horizon 2020 research and innovation programme
// for convenience
using json = nlohmann::json;


namespace fluid {
namespace client {

Expand Down Expand Up @@ -240,6 +241,8 @@ std::string getArgType(BufferT::type) { return "buffer"; }

std::string getArgType(InputBufferT::type) { return "buffer"; }

std::string getArgType(ChoicesT::type&) { return "choices"; }

std::string getArgType(SharedClientRef<dataset::DataSetClient>)
{
return "DataSet";
Expand All @@ -250,7 +253,6 @@ std::string getArgType(SharedClientRef<labelset::LabelSetClient>)
return "LabelSet";
}


std::string getArgType(SharedClientRef<const dataset::DataSetClient>&)
{
return "Input DataSet";
Expand Down Expand Up @@ -293,7 +295,7 @@ class ParameterDump
{
return p.defaultValue;
}

template <typename Param>
static std::enable_if_t<!isDetected<DefaultValue, Param>::value, std::string>
makeValue(Param&)
Expand Down Expand Up @@ -382,6 +384,7 @@ class ParameterDump
static std::string getParamType(const FFTParamsT&) { return "fft"; }
static std::string getParamType(const EnumT&) { return "enum"; }
static std::string getParamType(const LongArrayT&) { return "long"; }
static std::string getParamType(const ChoicesT&) { return "choices"; }

static std::string
getParamType(const SharedClientRef<dataset::DataSetClient>::ParamType&)
Expand Down Expand Up @@ -446,6 +449,24 @@ class ParameterDump
return j;
}

template <size_t Offset, typename Tuple, typename All>
static json jsonify_param(const ChoicesT& p, Tuple&, All&)
{
json j;
j["name"] = p.name;
j["displayName"] = p.displayName;
std::vector<std::string> strings(p.numOptions);
std::copy(p.strings, p.strings + p.numOptions, strings.begin());
j["default"] = strings;
j["fixed"] = false;
j["type"] = getParamType(p);
j["size"] = 1;

// j["values"] = strings;
j["type"] = "choices";
return j;
}

template <typename Tuple, size_t... Is>
static std::array<std::string, sizeof...(Is)>
doArgs(Tuple& args, std::index_sequence<Is...>)
Expand Down