Comments (3)
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.
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
1 ─ nothing
│ %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
1 ─ nothing
│ %2 = Base.getproperty(acs, :parts)::ACSets.LVectors.LVector{(:Box, :Port, :OuterPort, :Junction), Int64}
│ %3 = Base.getindex(%2, type)::Any
└── return %3
from catlab.jl.
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)
- Compute colimit of empty diagram for DynamicACSets HOT 1
- Integrate ACSets.NautyInterface
- Reexport GATlab from Catlab
- VarFunction Serialization
- Fix an empty tuple problem ahead of Julia 1.10
- GATs are missing from API docs
- Warnings about cross references from docs build
- Move from JSON.jl to JSON3.jl
- Constraints on attributes in `maximum_common_subobject` HOT 5
- Maximum_common_subobject changes ordering
- Better graphviz support for bipartite graphs HOT 1
- Refactor FinSets from FinSetImpls, etc
- Add features to VM based hom search
- Ambiguities detected from Aqua
- Question about abstract vs. concrete type in `enumerate_paths` HOT 2
- `SigmaMigrationFunctor` method uses an undefined variable HOT 2
- Bug in `product` keyword arguments
- free-floating URLs not parsed well by documenter HOT 1
- Coproduct with looseACSetTransformations HOT 2
- Parameters in queries for attributes that are unions HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from catlab.jl.