-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Kris Brown
committed
Oct 24, 2024
1 parent
764b4c0
commit 2e8b3d0
Showing
42 changed files
with
4,334 additions
and
3,271 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ name = "Catlab" | |
uuid = "134e5e36-593f-5add-ad60-77f754baafbe" | ||
license = "MIT" | ||
authors = ["Evan Patterson <[email protected]>"] | ||
version = "0.16.18" | ||
version = "0.17.1" | ||
|
||
[deps] | ||
ACSets = "227ef7b5-1206-438b-ac65-934d6da304b8" | ||
|
@@ -37,12 +37,9 @@ SCS = "c946c3f1-0d1f-5ce8-9dea-7daa1f7e2d13" | |
TikzPictures = "37f6aa50-8035-52d0-81c2-5a1d08754b2d" | ||
|
||
[extensions] | ||
CatlabConvexExt = "Convex" | ||
CatlabDataFramesExt = "DataFrames" | ||
CatlabGraphsExt = "Graphs" | ||
CatlabGraphvizExt = "Graphviz_jll" | ||
CatlabMetaGraphsExt = "MetaGraphs" | ||
CatlabSCSExt = "SCS" | ||
CatlabTikzPicturesExt = "TikzPictures" | ||
|
||
[compat] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
""" This depends on FinSets, so must come afterwards """ | ||
module DiscreteCats | ||
|
||
export DiscreteCat | ||
|
||
import ..Categories: ob, hom, dom, codom, compose, id, ob_map, hom_map | ||
|
||
""" Discrete category on a finite set. | ||
The only morphisms in a discrete category are the identities, which are here | ||
identified with the objects. | ||
""" | ||
@struct_hash_equal struct DiscreteCat{Ob,Any} <: FinCat{Ob,Ob} | ||
set::FinSet | ||
end | ||
DiscreteCat(n::Integer) = DiscreteCat(FinSet(n)) | ||
|
||
FinCat(s::Union{FinSet,Integer}) = DiscreteCat(s) | ||
|
||
ob_generators(C::DiscreteCat) = C.set | ||
hom_generators(::DiscreteCat) = () | ||
ob_generator(C::DiscreteCat, x) = x ∈ C.set ? x : error("$x ∉ $(C.set)") | ||
ob_generator_name(C::DiscreteCat, x) = x | ||
hom(C::DiscreteCat, x) = ob_generator(C, x) | ||
|
||
is_discrete(::DiscreteCat) = true | ||
graph(C::DiscreteCat{Int,FinSetInt}) = Graph(length(C.set)) | ||
|
||
dom(C::DiscreteCat{T}, f) where T = f::T | ||
codom(C::DiscreteCat{T}, f) where T = f::T | ||
id(C::DiscreteCat{T}, x) where T = x::T | ||
compose(C::DiscreteCat{T}, f, g) where T = (f::T == g::T) ? f : | ||
error("Nontrivial composite in discrete category: $f != $g") | ||
|
||
hom_map(F::FinDomFunctor{<:DiscreteCat}, x) = id(codom(F), ob_map(F, x)) | ||
|
||
Base.show(io::IO, C::DiscreteCat{Int,FinSetInt}) = | ||
print(io, "FinCat($(length(C.set)))") | ||
|
||
end # module |
Oops, something went wrong.