-
Notifications
You must be signed in to change notification settings - Fork 57
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
Scalars in acset transformations #935
Comments
In Julia, unlike in say R, scalars are not identified with one-element vectors and I think we should respect that. OTOH, I agree that that error message is scary and unhelpful. If it's a common mistake, I would suggest that we catch the mistake earlier in the call stack and throw an informative error message with a suggestion about what the user should have typed instead. |
@epatters if that's the design convention to stick to, that makes sense to me. In that case, I could suggest changing Catlab.jl/src/categorical_algebra/CSets.jl Lines 465 to 466 in b71a5b8
coerce_component(::Symbol, f::T, dom_size::Int, codom_size::Int; kw...) where {T<:Integer} and coerce_component(::Symbol, f::AbstractVector{<:Integer}, dom_size::Int, codom_size::Int; kw...) , where the first will throw an informative error, assuming that by that point coerce_component will be getting integers or vectors of integers. Happy to make a small PR.
|
Thanks @slwu89! Happy to accept that PR. |
When defining an acset transformation from a domain acset with only 1 element in some Ob's set, sometimes a scalar will sneak into the
components
rather than a vector. When this hitscoerce_component
it results in a rather scary method error (see below). Because defining acset transformations can be rather complex, when seeing this kind of error a user might fruitlessly spend time looking for a bug in the mapping, instead of something "simple" like using a scalar rather than a vector in thecomponents
.It would be nice to let
coerce_component
allow for scalars, or make the necessary conversion somewhere in the call stack, if it doesn't cause any problems with the rest of the code design.The text was updated successfully, but these errors were encountered: