Code Monkey home page Code Monkey logo

Comments (3)

daanhb avatar daanhb commented on September 25, 2024

The second case seems to trigger this fallback:

ProductDomain(domains...) = TupleProductDomain(domains...)

Tuples are the default because it is the only safe choice. The reason the fallback is triggered is that [2,3] is not (yet) recognized as a Domain, it is only converted to a WrappedDomain later by the TupleProductDomain constructor. A solution may be to write instead:

ProductDomain(domains...) = _ProductDomain(map(Domain, domains)...)
_ProductDomain(domains...) = TupleProductDomain(domains...)
_ProductDomain(domains::VcatDomainElement...) = VcatDomain(domains...)

?

Perhaps conversion to a wrapped domain can also be avoided, but that is what currently happens anyway. An alternative may be to improve the logic of the ProductDomain constructor a bit and make it more robust.

from domainsets.jl.

dlfivefifty avatar dlfivefifty commented on September 25, 2024

I don't really need this yet so no rush, but perhaps when it comes up I can have a go and remove the need for WrappedDomain by making Domain and "interface".

from domainsets.jl.

daanhb avatar daanhb commented on September 25, 2024

Meanwhile I checked and the "fix" above seems to work at least for the example you gave.

More generally, Domain is largely an interface already but not everywhere. In this case, for future reference, there are at least two issues here:

  • I've often used convert(Domain{T}, d) as a generic way to ensure that the domain d actually has element type T, for example if the user has specified a T type in some concrete domain constructor. If d is not a Domain, this is where it ends up being wrapped (perhaps needlessly). However, it would be odd if convert(Domain{T}, d) returns something that is not actually a subtype of Domain, so we may want to use a different syntax for this purpose, so that an Array{T} can remain an Array{T}. And perhaps so that an Array{S} is converted to an Array{T}.
  • The VcatDomain assumes that the member domains have a dimension. It can then figure out how to efficiently go back and forth between static vectors and the elements of the member domains with the right size (e.g. (1,2,2) for a product of a univariate and two 2D-domains into a 5D VcatDomain.) The logic of the dimension function needs to be expanded somewhat to deal with non-Domain arguments, perhaps by looking at the eltype. Perhaps the name is too generic for that purpose.

So for these two reasons it is currently not possible to avoid the wrapping of the array.

from domainsets.jl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.