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

Error handling when trying to nondimensionalize unitless numbers #198

Merged
merged 4 commits into from
Jun 19, 2024

Conversation

albert-de-montserrat
Copy link
Member

Adresses #197. Trying to non-dimensionalize non-GeoUnits types results into an error, instead of hanging forever.

julia>     @test_throws ArgumentError nondimensionalize(5, CharUnits_GEO)       
Test Passed
      Thrown: ArgumentError

julia>     @test_throws ArgumentError nondimensionalize(5e0, CharUnits_GEO)     
Test Passed
      Thrown: ArgumentError
julia>     @test_throws ArgumentError nondimensionalize([10 1; 20 30.0], CharUnits_GEO)
Test Passed
      Thrown: ArgumentError

julia>     @test_throws ArgumentError nondimensionalize((10, 1), CharUnits_GEO) 
Test Passed
      Thrown: ArgumentError
julia>     @test_throws ArgumentError nondimensionalize((10e0, 1e0), CharUnits_GEO)
Test Passed
      Thrown: ArgumentError

@albert-de-montserrat
Copy link
Member Author

CC @ArneSpang

@albert-de-montserrat
Copy link
Member Author

Not it also handles empty arrays

julia> nondimensionalize([], CharDim)
ERROR: ArgumentError: The input parameter should have units
Stacktrace:
 [1] nondimensionalize(::Vector{Any}, ::GeoUnits{GEO})
   @ GeoParams.Units c:\Users\albert\Desktop\DevPkgs\GeoParams.jl\src\Units.jl:605
 [2] top-level scope
   @ REPL[8]:1

julia> nondimensionalize(Float64[], CharDim)
ERROR: ArgumentError: The input parameter should have units      
Stacktrace:
 [1] nondimensionalize(::Vector{Float64}, ::GeoUnits{GEO})       
   @ GeoParams.Units c:\Users\albert\Desktop\DevPkgs\GeoParams.jl\src\Units.jl:605
 [2] top-level scope
   @ REPL[9]:1   

Copy link

codecov bot commented Jun 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Additional details and impacted files

📢 Thoughts on this report? Let us know!

@albert-de-montserrat albert-de-montserrat merged commit 4995219 into main Jun 19, 2024
16 of 19 checks passed
@albert-de-montserrat
Copy link
Member Author

closes #197

@aelligp aelligp deleted the adm/dimerror branch December 5, 2024 15:00
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

Successfully merging this pull request may close these issues.

1 participant