Skip to content

Type instability #23

@michaelgordy

Description

@michaelgordy

Not sure if this is a bug or a design issue, but certain operations are not type-stable. Say I am working with a model in which the solution can be expressed as a polynomial in (x,y), and that I need to have this polynomial as a function. In certain edge cases of the model, one of the variables (say, "y") will drop out. The problem from a programmer's perspective is that the polynomial in this case cannot be converted to a function of two variables, so one must resort to tedious case-checking. Example:

First a typical case in which f1() remains a function of two variables.

p <- mp("3 + x + 2 y + x^2 y + y^2", varorder = c("y", "x"))
f1 <- as.function(deriv(p, "y"), vars=c("y", "x"))

Now an edge case in which f1() becomes a function of only x.

p <- mp("3 + x + 2 y + x^2 y", varorder = c("y", "x"))
f1 <- as.function(deriv(p, "y"), vars=c("y", "x"))

When vars is specified (as in the above example), it seems desirable that the resulting function should accept the specified arguments, even if one or both inputs do not influence the output.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions