What xvalues are allowed for create_continuous

This pipeline works

input(value: { x_point: [0.095,0.23], y_point: [2000,2010] })
->
unnest([x_point, y_point]) as foo
->
group({ to_lookup_table(key: x_point, value: y_point, options: { unique: true }) as lookup_table })
->
select({
	create_continuous(
	[0.095,0.23],
	x -> lookup(lookup_table, x)) as testCurve
})
->
select({
        apply_continuous(testCurve, 0.1) as y01,
        apply_continuous(testCurve, 0.2) as y02})
->
save(name: 'output.csv')

and produces

y01	y02
2000.37037	2007.777778

but if I change the create_continuous to

create_continuous(
	[0.09**6**,0.23],
	x -> lookup(lookup_table, x)) as testCurve

then it outputs null for both results.

Setting either of the xvalues that fall above and below the requested apply_continuous values to anything other than exactly what they are in the to_lookup_table call causes this behaviour.

Kia ora,

This is more related to the behaviour of the lookup() function than it is related to create_continuous(). The create_continuous() function should basically accept any x-value range.

The problem here is the create_continuous() lambda expression is producing a null result for one of the x values. Normally, the apply_continous() tries to interpolate between the two closest x values. However, in this case one of the x values produces a null result.

Currently in RiskScape, any arithmetic involving a null value will always produce a null result, e.g.

riskscape expr eval "null_of('integer') + 2000"
<nothing>

So the interpolation between a valid number and null is producing a null result, which is what you’re seeing coming out of your pipeline.

The reason you’re getting a null value is because the lookup() function is trying to lookup a value that doesn’t exist in the table (0.096). If you changed the lambda expression to use zero instead of null, then you would get non-null results from your pipeline, e.g.

input(value: { x_point: [0.095,0.23], y_point: [2000,2010] })
->
unnest([x_point, y_point]) as foo
->
group({ to_lookup_table(key: x_point, value: y_point, options: { unique: true }) as lookup_table })
->
select({
	create_continuous(
	[0.096,0.23],
	x -> if_null(lookup(lookup_table, x), 0)) as testCurve
})
->
select({
        apply_continuous(testCurve, 0.1) as y01,
        apply_continuous(testCurve, 0.2) as y02})
->
save(name: 'output.csv')

Hope that helps.