`size` has no method matching size(::Data{Float32}) when using nested composite type in julia -
say defined composite type "data" follows:
type dataformat format1::datatype format2::uint format3::uint format4::ptr{none} end type data{t} <: abstractvector{t} value::vector{t} format::dataformat end
it's ok when run myformat = dataformat(float32, 0, 0, c_null)
. run mydata = data{float32}([0.1, 0.2, 0.3], myformat)
, these errors appear:
error showing value of type data{float32}: error: `size` has no method matching size(::data{float32}) in writemime @ replutil.jl:18 in display @ repl.jl:117 in display @ repl.jl:120 in display @ multimedia.jl:149 in print_response @ repl.jl:139 in print_response @ repl.jl:124 in anonymous @ repl.jl:586 in run_interface @ /opt/homebrew-cask/caskroom/julia/0.3.7/julia- 0.3.7.app/contents/resources/julia/lib/julia/sys.dylib in run_frontend @ /opt/homebrew-cask/caskroom/julia/0.3.7/julia-0.3.7.app/contents/resources/julia/lib/julia/sys.dylib in run_repl @ /opt/homebrew-cask/caskroom/julia/0.3.7/julia-0.3.7.app/contents/resources/julia/lib/julia/sys.dylib in _start @ /opt/homebrew-cask/caskroom/julia/0.3.7/julia-0.3.7.app/contents/resources/julia/lib/julia/sys.dylib
it seems broken julia's size() function, how can fix it? i'm new julia , don't know whether it's choice use "nested" composite type this?
it's relatively straightforward extend size
:
julia> import base.size julia> size(d::data) = size(d.value) size (generic function 51 methods)
if want datatype support other operations iteration , indexing you'll need define getindex
, start, next, length , done
edit: see comment below why start, next, length , done not necessary.
Comments
Post a Comment