Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "ExtendableGrids"
uuid = "cfc395e8-590f-11e8-1f13-43a2532b2fa8"
authors = ["Juergen Fuhrmann <juergen.fuhrmann@wias-berlin.de>", "Christian Merdon <christian.merdon@wias-berlin.de>", "Johannes Taraz <johannes.taraz@gmail.com>", "Patrick Jaap <patrick.jaap@wias-berlin.de>"]
version = "1.14.2"
authors = ["Juergen Fuhrmann <juergen.fuhrmann@wias-berlin.de>", "Christian Merdon <christian.merdon@wias-berlin.de>", "Johannes Taraz <johannes.taraz@gmail.com>", "Patrick Jaap <patrick.jaap@wias-berlin.de>"]

[deps]
AbstractTrees = "1520ce14-60c1-5f80-bbc7-55ef81b5835c"
Expand All @@ -19,6 +19,7 @@ SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
StatsBase = "2913bbd2-ae8a-5f71-8c99-4fb6c76f3a91"
UUIDs = "cf7118a7-6976-5b1a-9a39-7adc72f591a4"
WeakDepHelpers = "7869a13a-7328-4bcf-a489-0f4bb64497c7"
WriteVTK = "64499a7a-5c06-52f2-abe2-ccb03c286192"

[weakdeps]
Expand Down Expand Up @@ -53,5 +54,6 @@ StatsBase = "0.34"
TetGen = "1.5.1, 2"
Triangulate = "2.3.2, 3"
UUIDs = "1.6"
WeakDepHelpers = "0.1.0"
WriteVTK = "1.14"
julia = "1.9"
2 changes: 2 additions & 0 deletions src/ExtendableGrids.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ using Printf
using Random
using Dates
using LinearAlgebra
using WeakDepHelpers
import Graphs

const WEAKDEP_METHOD_ERROR_HINT_CACHE = WeakDepCache()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You also need the __init__ hook manually added.

https://github.com/QuantumSavory/QuantumClifford.jl/blob/master/src/init.jl#L19-L21

function __init__()
    if isdefined(Base.Experimental, :register_error_hint)
        Base.Experimental.register_error_hint(MethodError) do io, exc, argtypes, kwargs
            method_error_hint_callback(WEAKDEP_METHOD_ERROR_HINT_CACHE, io, exc, argtypes, kwargs)
        end
    end
end

Let me know if this seems distasteful and we can figure out a cleaner API.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be a lot of boilerplate for every code wanting to use WeakDepHelpers.
I have implemented and tested it and it works now.
I have also moved everything within init into a register_weakdep_cache function that receives the cache singleton. I think it might be helpful to add this to WeakDepHelpers to increase usability

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I concur @jpthiele .

I am happy to take care of the implementation. Could you post an issue on the WeakDepHelpers tracker with an example boilerplate that you would find "reasonably pleasant / unobtrusive"? Or do you think that just a pre-defined register_weakdep_cache would be sufficient?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this predefined function might be sufficient. Makes it easier to use for those not too familiar with the hinting system while still being easy enough to be copied and modified by expert users if needed.


include("adjacency.jl")
export Adjacency, VariableTargetAdjacency, FixedTargetAdjacency
Expand Down
16 changes: 5 additions & 11 deletions src/io.jl
Original file line number Diff line number Diff line change
Expand Up @@ -162,19 +162,12 @@ function simplexgrid(file::String; format = "", kwargs...)
end

function simplexgrid(file::String, ::Type{Val{:msh}}; kwargs...)
return try
simplexgrid_from_gmsh(file)
catch e
throw(ErrorException("Missing Gmsh extension. Add Gmsh.jl to your environment and import it to read msh files."))
end
simplexgrid_from_gmsh(file)
end

function simplexgrid(file::String, ::Type{Val{:geo}}; kwargs...)
return try
simplexgrid_from_gmsh(file)
catch e
throw(ErrorException("Missing Gmsh extension. Add Gmsh.jl to your environment and import it to read geo files."))
end

simplexgrid_from_gmsh(file)
end

function simplexgrid(file::String, ::Type{Val{:sg}}; kwargs...)
Expand Down Expand Up @@ -272,7 +265,8 @@ function simplexgrid(file::String, ::Type{Val{:sg}}; kwargs...)
return g
end

function simplexgrid_from_gmsh end
@declare_method_is_in_extension WEAKDEP_METHOD_ERROR_HINT_CACHE simplexgrid_from_gmsh (:Gmsh,)
# function simplexgrid_from_gmsh end

function simplexgrid_to_gmsh end

Expand Down