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

query errors when specifying parameters #939

Open
slwu89 opened this issue Sep 20, 2024 · 2 comments
Open

query errors when specifying parameters #939

slwu89 opened this issue Sep 20, 2024 · 2 comments

Comments

@slwu89
Copy link
Member

slwu89 commented Sep 20, 2024

query errors when specifying the parameter (ID of a certain object) when using a union type for an AttrType in the following schema. On Catlab v0.16.17.

using Catlab

@present MySch <: SchGraph begin
    (P,PV,S)::Ob
    Label::AttrType
    vlabel::Attr(V,Label)
    plabel::Attr(P,Label)
    Number::AttrType
    pv_number::Attr(PV,Number)
    s_number::Attr(S,Number)
    pv_v::Hom(PV,V)
    pv_p::Hom(PV,P)
    s_e::Hom(S,E)
    s_p::Hom(S,P)
end

@acset_type MyDataType(MySch, index=[:src,:tgt,:pv_p,:pv_v,:s_p,:s_e])

mydata = @acset MyDataType{String,Union{Float64,Int}} begin
    V=5
    vlabel="v" .* string.(1:5)
    E=9
    src=[1,1,1,2,2,2,3,3,4]
    tgt=[2,3,4,1,3,5,1,2,1]
    PV=10
    pv_p=[1,2,1,2,1,2,1,2,1,2]
    pv_v=[1,1,2,2,3,3,4,4,5,5]
    pv_number=rand([1,2,3],10)
    P=2
    plabel="p" .* string.(1:2)
    S=16
    s_p=[1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2]
    s_e=[1,2,3,4,5,6,7,8,9,1,3,4,6,7,8,9]
    s_number=rand([5,6.0,7],16)
end

query_uwd = @relation (v=vlab, v_id=v_id, p=plab, p_id=p_id, s_number=s_number) begin
    PV(_id=pv_id, pv_p=p_id, pv_v=v_id)
    P(_id=p_id, plabel=plab)
    V(_id=v_id, vlabel=vlab)
    E(_id=e_id, tgt=v_id)
    S(_id=s_id, s_e=e_id, s_p=p_id, s_number=s_number)
end

# queries when `Number` is a `Union{Float64,Int}`
query(mydata, query_uwd) # works
query(mydata, query_uwd, (v_id=1, )) # error
query(mydata, query_uwd, (s_number=5, )) # works
@slwu89 slwu89 changed the title query sometimes errors with AttrTypes of different Julia types query errors when specifying parameters Sep 20, 2024
@epatters
Copy link
Member

Alas, I guess this was not fixed in #923?

@slwu89
Copy link
Member Author

slwu89 commented Sep 20, 2024

I'm not sure @epatters, in this case, the error occurs when specifying the parameter of a part ID, rather than when using the parameters to specify attributes (which is weird). But in any case, I'll check it out in detail when I have time, making a note of the behavior here.

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

No branches or pull requests

2 participants