Skip to content
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
9 changes: 7 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ cmake_minimum_required(VERSION 3.11)

cmake_policy(SET CMP0074 NEW)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

if (APPLE)
set(CMAKE_XCODE_GENERATE_SCHEME ON)
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.8)
Expand Down Expand Up @@ -107,10 +111,11 @@ foreach (project_dir ${PROJECT_DIRS})
list(APPEND json_files "${CMAKE_BINARY_DIR}/json/${project_dir}.json")

add_custom_command(OUTPUT "${CMAKE_BINARY_DIR}/json/${project_dir}.json"
COMMAND ${CMAKE_COMMAND} -E make_directory "${CMAKE_BINARY_DIR}/json/"
COMMAND $<TARGET_FILE:${project_dir}> ARGS "${CMAKE_BINARY_DIR}/json/"
COMMENT "Generating JSON for ${project_dir}"
)

DEPENDS ${project_dir}
)
endif ()
endforeach ()

Expand Down
2 changes: 1 addition & 1 deletion flucoma/doc/cli/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def transform_data(client, data):
'glob_filter': lambda x: re.match('Buf(?!Compose).*',x.stem) is not None,
'parameter_link': cli_jinja_parameter_link,
'write_cross_ref': (cli_visit_flucoma_reference,cli_depart_flucoma_reference),
'code_block': '<code>{}</code>',
'code_block': lambda p: f'<code>{p.lower()}</code>',
'writer': FluidHTMLWriter,
'rst_render': rst_filter,
'topic_extension':'html',
Expand Down
2 changes: 1 addition & 1 deletion flucoma/doc/max/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def write_max_indices(idx,program_args):
'types': max_type_map,
'glob': '**/*.json',
'parameter_link': max_jinja_parameter_link,
'code_block': '<m>{}</m>',
'code_block': lambda p: f"<m>{p.lower()}</m>",
'writer': FluidHTMLWriter,
'rst_render': rst_filter,
'write_cross_ref': (max_visit_flucoma_reference,
Expand Down
2 changes: 1 addition & 1 deletion flucoma/doc/pd/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ def transform_data(client, data):
'glob': '**/*.json',
'parameter_link': pd_jinja_parameter_link,
'write_cross_ref': (pd_visit_flucoma_reference,pd_depart_flucoma_reference),
'code_block': '<m>{}</m>',
'code_block': lambda p: f'<code>{p.lower()}</code>',
'writer': FluidHTMLWriter,
'rst_render': rst_filter,
'topic_extension': 'html',
Expand Down
11 changes: 11 additions & 0 deletions flucoma/doc/rst/html.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

from .common import LoggingDocutilsReader

from docutils import nodes
from docutils.utils import Reporter
from docutils.core import publish_parts
from docutils.writers import html4css1
Expand All @@ -35,6 +36,10 @@ def depart_reference(self,node):
self.depart_flucoma_reference(node)
else:
super().depart_reference(node)





class FluidHTMLWriter(html4css1.Writer):
"""docutils writer for Max ref
Expand All @@ -55,6 +60,12 @@ def visit_flucoma_topic(self,node):

def depart_flucoma_reference(self,node):
partial(driver['write_cross_ref'][1], data = index)(self,node)

def visit_literal(self, node) :
f = driver.get('code_block',lambda x: x)
self.body.append(f(node.astext()))
raise nodes.SkipNode


self.translator_class = ConcreteTranslator

Expand Down
34 changes: 31 additions & 3 deletions flucoma/doc/sc/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from ..transformers import tidy_split, filter_fixed_controls
from flucoma.doc.rst.scdoc import SCDocWriter,rst_filter
from .defaults import defaults
import copy

def buffer_reference_role(role, rawtext, text, lineno, inliner,
options={}, content=[]):
Expand Down Expand Up @@ -72,9 +73,13 @@ def sc_transform_data(object_name,data):
params = {x['name']:x for x in data.pop('parameters')}

data['attributes'] = OrderedDict(
(filter_fixed_controls(params,fixed=False))
**filter_fixed_controls(params,fixed=False)
)



# filter(lambda x: x['runtimemax'] == True, params)

fftSettings = data['attributes'].pop('fftSettings',None)
if fftSettings: #only works because they're last in the list
data['attributes'] = {
Expand All @@ -84,6 +89,29 @@ def sc_transform_data(object_name,data):
'fftSize': fftSettings['fft']
}


def maxParamName(pname):
return 'max' + pname[0].upper() + pname[1:]

def maxParamDoc(v):
return {
'name': maxParamName(v['name']),
'constraints':{},
'default': -1,
'description': f"Manually sets a maximum value for ``{v['name']}``. Can only be set at object instantiation. Default value of -1 sets this to the initial value of ``{v['name']}``",
'displayName': f"Maximum {v['displayName']}",
'fixed':False,
'size':1
}

if(object_name.startswith('Buf') == False):
runtime_max_params = { maxParamName(name): maxParamDoc(data) for name, data in params.items() if data.get('runtimemax',False) == True}

data['attributes'] = {
**data['attributes'],
**runtime_max_params
}

#HPSS horrors
def spliceAttrs(key):
if key in data['attributes']:
Expand All @@ -104,7 +132,7 @@ def spliceAttrs(key):
data['attributes'] = {**data['attributes'], 'padding': padding}

data['arguments'] = OrderedDict(
filter_fixed_controls(params,fixed=True)
**filter_fixed_controls(params,fixed=True)
)

data['messages'] = {x['name']:x for x in data.pop('messages')}
Expand All @@ -128,7 +156,7 @@ def configure_jinja(environment, client_index, args):
'glob': '**/*.json',
'parameter_link': sc_jinja_parameter_link,
# 'write_cross_ref': (sc_visit_flucoma_reference,sc_depart_flucoma_reference),
'code_block': 'code::{}::',
'code_block': lambda p: f'code::{p}::',
'writer': SCDocWriter,
'rst_render': rst_filter,
'topic_extension': 'schelp',
Expand Down
46 changes: 38 additions & 8 deletions flucoma/doc/transformers.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,28 @@
import logging
from flucoma.doc import logger
from collections import OrderedDict
import copy

"""
takes a an nested dict of controls, each assumed to have a 'fixed' key, returns an iterator to fixed = True by default. If elements don't have a 'fixed' key then you'll get a KeyError

returns an iterator
"""
def filter_fixed_controls(controls,fixed=True):
return filter(lambda x: x[1]['fixed'] == fixed, controls.items())
def filter_fixed_controls(controls,fixed=True):

# def fil(item):
# return item[1].get('fixed',False) == fixed

return { k: v for k,v in controls.items() if v.get('fixed',False) == fixed}
# return [ (k,v) for k,v in controls.items() if v.get('fixed',False) == True]
# return filter(lambda x: x[1]['fixed'] == fixed, controls.items())

def filter_primary_controls(controls):
# primaries = filter(lambda x: x[1].get('primary',False) == True, controls.items())
primaries = copy.deepcopy({ k: v for k,v in controls.items() if v.get('primary',False) == True})
for n,v in primaries.items():
v['description'] = f"Shorthand argument for ``{n}``"
return primaries

"""
given a [comma] separated string,break it up discarding empty items and trimming whitespace
Expand Down Expand Up @@ -59,6 +73,21 @@ def default_transform(object_name, data):
'type': 'long'
})

runtime_max_params = filter(lambda x: x.get('runtimemax',False) ==True, data['parameters'])

for r in runtime_max_params:
r['size'] = 1
data['parameters'].append({
'name': f"max{r['name']}",
'constraints':{},
'default': -1,
'description': f"Manually sets a maximum value for ``{r['name']}``. Can only be set at object instantiation. The default of -1 sets this equal to the initial value of ``{r['name']}``",
'displayName': f"Maximum {r['displayName']}",
'fixed':False,
'size':1,
'type': r['type']
})

if(data['input_type'] == 'control'):
data['parameters'].insert(0,{
'name':'inputsize',
Expand All @@ -80,17 +109,18 @@ def default_transform(object_name, data):
'size': 1,
'type': 'long'
})

params = {x['name']:x for x in data.pop('parameters')}

data['attributes'] = OrderedDict(
sorted(filter_fixed_controls(params,fixed=False))
sorted(filter_fixed_controls(params,fixed=False).items())
)

data['arguments'] = OrderedDict(
filter_fixed_controls(params,fixed=True)
)

data['arguments'] = {
**filter_primary_controls(params),
**filter_fixed_controls(params,fixed=True)
}

data['messages'] = {x['name']:x for x in data.pop('messages')}

for n,m in data['messages'].items():
Expand Down
20 changes: 11 additions & 9 deletions flucoma/doc/validate/controls.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,33 +32,35 @@ def render_constraints_markup(control):
}

special_invariants = {
'fftFrame': '``(FFT Size / 2) + 1`` (see fft settings)',
'maxFFTFrame': '``(max FFT Size / 2) + 1`` (see maxFFTSize)'
'fftFrame': '(FFT Size / 2) + 1 (see fft settings)',
'maxFFTFrame': '(max FFT Size / 2) + 1 (see maxFFTSize)'
}

resultStr = '\n**Constraints**\n\n'

upperLimits = constraints.get('upper',[])
lowerLimits = constraints.get('lower',[])

upperLimits = [upperLimits] if not isinstance(upperLimits,list) else upperLimits
lowerLimits = [lowerLimits] if not isinstance(lowerLimits,list) else lowerLimits

upperStrs = [special_invariants.get(c,f'{c}') for c in upperLimits]
lowerStrs = [special_invariants.get(c,f'{c}') for c in lowerLimits]

if 'max' in constraints: upperStrs.append(str(constraints['max']))
if 'min' in constraints: lowerStrs.append(str(constraints['min']))
if 'min' in constraints: lowerStrs.append(str(constraints['min']))
if(control.get('runtimemax',False)):
upperStrs.append(f"max{control['name']}")

if len(lowerStrs) > 1:
resultStr += f"* Minimum: MAX({', '.join(lowerStrs)})\n"
resultStr += f"* Minimum: MAX(``{', '.join(lowerStrs)}``)\n"
elif len(lowerStrs) == 1:
resultStr += f"* Minimum: {lowerStrs[0]}\n"
resultStr += f"* Minimum: ``{lowerStrs[0]}``\n"

if len(upperStrs) > 1:
resultStr += f"* Maximum: MIN({', '.join(upperStrs)})\n"
resultStr += f"* Maximum: MIN(``{', '.join(upperStrs)}``)\n"
elif len(upperStrs) == 1:
resultStr += f"* Maximum: {upperStrs[0]}\n"
resultStr += f"* Maximum: ``{upperStrs[0]}``\n"

if 'snap' in constraints:
resultStr += f"* Snaps to {snaps[constraints['snap']]} \n"
Expand Down
35 changes: 31 additions & 4 deletions include/FluidParameterDump.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,17 @@ struct Constraint<FFTParams::FFTSettingsConstraint<MaxFFT>>
}
};

template <>
struct Constraint<LongRuntimeMaxParam::RuntimeMaxConstraint>
{
template <size_t Offset, typename Tuple>
static json::object_t::value_type
dump(const LongRuntimeMaxParam::RuntimeMaxConstraint&, Tuple&)
{
return {"runtimemax",-1};
}
};

template <typename C, typename AllParams>
Constraint<C> makeConstraint(C c, AllParams& p)
{
Expand Down Expand Up @@ -296,6 +307,11 @@ class ParameterDump
return p.defaultValue;
}

static index makeValue(const LongRuntimeMaxT& p)
{
return p.defaultValue();
}

template <typename Param>
static std::enable_if_t<!isDetected<DefaultValue, Param>::value, std::string>
makeValue(Param&)
Expand Down Expand Up @@ -384,6 +400,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 LongRuntimeMaxT&) { return "long"; }
static std::string getParamType(const ChoicesT&) { return "choices"; }

static std::string
Expand All @@ -406,16 +423,22 @@ class ParameterDump
template <size_t Offset, typename P, typename Tuple, typename All>
static json jsonify_param(P& p, Tuple& tuple, All& allParams)
{
constexpr bool fixed = std::tuple_element<2, Tuple>::type::value;
json j;
using fixed_el_type = std::decay_t<typename std::tuple_element<2, Tuple>::type>;
constexpr bool fixed = std::is_same<fixed_el_type, Fixed<true>>::value;
constexpr bool primary = std::is_same<fixed_el_type, Primary>::value;

json j;

j["name"] = p.name;
j["displayName"] = p.displayName;
// j["default"] = p.defaultValue;
j["default"] = makeValue(p);
j["fixed"] = fixed;
j["type"] = getParamType(p);
j["size"] = p.fixedSize;


j["runtimemax"] = std::is_same<P,const LongRuntimeMaxT>::value;
j["primary"] = primary;

// constraints
auto& constraintsTuple = std::get<1>(tuple);
using constraintsTupleType = std::decay_t<decltype(constraintsTuple)>;
Expand Down Expand Up @@ -446,6 +469,10 @@ class ParameterDump
std::copy(p.strings, p.strings + p.numOptions, strings.begin());
j["values"] = strings;
j["type"] = "enum";

j["runtimemax"] = false;
j["primary"] = false;

return j;
}

Expand Down
7 changes: 0 additions & 7 deletions script/dump-posttarget.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,6 @@
# (grant agreement No 725899).


target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_14)

set_target_properties(${PROJECT_NAME} PROPERTIES
CXX_STANDARD_REQUIRED ON
CXX_STANDARD 14
CXX_EXTENSIONS OFF
)

target_link_libraries(${PROJECT_NAME} PRIVATE
FLUID_DECOMPOSITION FLUID_DUMP
Expand Down