Skip to content

Erroneous use of getNamespaceVersion() in a comparison #607

@TimTaylor

Description

@TimTaylor

As pointed out in this thread on R-devel, the following line could break at a future (sufficiently high) release of reticulate:

if(getNamespaceVersion("reticulate") >= "1.36.0") "r-keras"

getNamespaceVersion("reticulate")
#>  version 
#> "1.39.0"
getNamespaceVersion("reticulate") >= "1.99.0"
#> version 
#>   FALSE
getNamespaceVersion("reticulate") >= "1.100.0"
#> version 
#>    TRUE

This can be solved with either the suggested compareVersion() or via wrapping with as.package_version():

compareVersion(getNamespaceVersion("reticulate"), "1.38.0") >= 0
#> [1] TRUE
compareVersion(getNamespaceVersion("reticulate"), "1.100.0") >= 0
#> [1] FALSE

as.package_version(getNamespaceVersion("reticulate")) >= "1.38.0"
#> [1] TRUE
as.package_version(getNamespaceVersion("reticulate")) >= "1.100.0"
#> [1] FALSE

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions