Skip to content
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

Some functions are not type stable #251

Open
Sbozzolo opened this issue Mar 8, 2024 · 1 comment
Open

Some functions are not type stable #251

Sbozzolo opened this issue Mar 8, 2024 · 1 comment

Comments

@Sbozzolo
Copy link
Contributor

Sbozzolo commented Mar 8, 2024

I am finding that some functions are not type-stable.

For istance, if nc is a NCDatasets.NCDataset with a variable orog:

julia> Test.@inferred nc["orog"]
ERROR: return type CommonDataModel.CFVariable{Float32, 3, NCDatasets.Variable{Float32, 3, NCDataset{Nothing, Missing}}, CommonDataModel.Attributes{NCDatasets.Variable{Float32, 3, NCDataset{Nothing, Missing}}}, @NamedTuple{fillvalue::Nothing, missing_values::Tuple{}, scale_factor::Nothing, add_offset::Nothing, calendar::Nothing, time_origin::Nothing, time_factor::Nothing, maskingvalue::Missing}} does not match inferred return type CommonDataModel.CFVariable{_A, _B, NCDatasets.Variable{_A1, _B1, NCDataset{Nothing, Missing}}, CommonDataModel.Attributes{TDS}, NamedTuple{(:fillvalue, :missing_values, :scale_factor, :add_offset, :calendar, :time_origin, :time_factor, :maskingvalue), var"#s178"}} where {_A, _B, _A1, _B1, TDS<:(NCDatasets.Variable{_A, _B, NCDataset{Nothing, Missing}} where {_A, _B}), var"#s178"<:Tuple{Any, Tuple, Any, Any, Any, Any, Union{Nothing, Int64}, Missing}}

image

Others:

  • nc.attribs
  • nc.attrib["short_name"]
@Alexander-Barth
Copy link
Owner

Yes, this is known. There will always be a type instability somewhere because the actual type of the variable and attributes is stored in a file which is not accessible to the julia compiler. One should use barrier function to avoid spreading of the type instability.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants