Giter Site home page Giter Site logo

Comments (3)

samuelsonric avatar samuelsonric commented on June 21, 2024

The function junction has a similar problem:

using Catlab.ACSetInterface, Catlab.WiringDiagrams

wd = singleton_diagram(UntypedUWD, 1000000);

function collect_junctions_1(wd)
    js = Int[]
    for i in ports(wd)::UnitRange{Int}
        push!(js, junction(wd, i))
    end
    js
end

function collect_junctions_2(wd)
    js = Int[]
    _js = collect(subpart(wd, :junction))
    for i in ports(wd)::UnitRange{Int}
        push!(js, _js[i])
    end
    js
end

Then

collect_junctions_1(wd)
@time collect_junctions_1(wd);

outputs 0.206502 seconds (3.00 M allocations: 177.620 MiB).

On the other hand,

collect_junctions_2(wd)
@time collect_junctions_2(wd);

outputs 0.006355 seconds (19 allocations: 17.411 MiB)

from catlab.jl.

jpfairbanks avatar jpfairbanks commented on June 21, 2024

Thanks for the catch here. According to @code_warntype it is a problem in ACsets parts code.

julia> @code_warntype parts(wd, :Port)
MethodInstance for ACSets.ACSetInterface.parts(::UntypedUWD, ::Symbol)
  from parts(acs, type) @ ACSets.ACSetInterface ~/.julia/packages/ACSets/1pqJM/src/ACSetInterface.jl:36
Arguments
  #self#::Core.Const(ACSets.ACSetInterface.parts)
  acs::UntypedUWD
  type::Symbol
Body::Any
1nothing%2 = ACSets.ACSetInterface.nparts(acs, type)::Any%3 = (1:%2)::Any
└──      return %3

nparts has the same problem

julia> @code_warntype nparts(wd, :Port)
MethodInstance for ACSets.ACSetInterface.nparts(::UntypedUWD, ::Symbol)
  from nparts(acs::SimpleACSet, type::Symbol) @ ACSets.DenseACSets ~/.julia/packages/ACSets/1pqJM/src/DenseACSets.jl:341
Arguments
  #self#::Core.Const(ACSets.ACSetInterface.nparts)
  acs::UntypedUWD
  type::Symbol
Body::Any
1nothing%2 = Base.getproperty(acs, :parts)::ACSets.LVectors.LVector{(:Box, :Port, :OuterPort, :Junction), Int64}%3 = Base.getindex(%2, type)::Any
└──      return %3

from catlab.jl.

jpfairbanks avatar jpfairbanks commented on June 21, 2024

Full MWE:

using Catlab.WiringDiagrams
using Catlab.CategoricalAlgebra

wd = singleton_diagram(UntypedUWD, 1000000);

@code_warntype nparts(wd, :Port)

I tested on Catlab 14 and 13 so this isn't a (recent) regression. with the ACSets refactor.

from catlab.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.