Open mmikhasenko opened 2 years ago
A prototype is below. Should go to separate branch, and merged once ready
struct xProductPDF{N} dims::SVector{N,pdf} keys::SVector{N,Symbol} end xProductPDF(; kwargs...) = xProductPDF{length(kwargs)}(SVector(values(kwargs)...), SVector(keys(kwargs)...)) function generate(N, X::xProductPDF; kwarg...) data_vectors = generate.(N, X.dims; kwarg...) ntv = NamedTuple{Tuple(X.keys)}.(zip(data_vectors...)) return ntv end # _| _| _| _| # _|_|_| _|_| _| _| _| _|_|_|_| _|_|_| # _| _| _| _| _| _| _| _| _|_|_|_|_| _| _| # _| _| _| _| _| _| _| _| _| _| # _| _| _| _|_|_| _| _|_| _| _|_|_| @testset "cross-product PDF" begin # test pdf1 = pdf((x;p)->x.^2; lims=(-1,2), p=∅) pdf2 = pdf((x;p)->x.^4; lims=(-1,2), p=∅) X = xProductPDF(;x=pdf1, y=pdf2) s = generate(100, X) # @test length(s) == 100 @test hasproperty(s[1], :x) @test hasproperty(s[1], :y) # s = generate(50, X; Nbins=300) @test length(s) == 50 end
A prototype is below. Should go to separate branch, and merged once ready