pycauset.CausalSet
The CausalSet class represents a causal set, a discrete partial order. It is the primary object of PyCauset: a TriangularBitMatrix (the causal relations) plus provenance (the spacetime + seed it was sprinkled from, or an attached embedding).
Parameters
- n (int, optional): The number of elements to sprinkle. Either
nordensityis required. - density (float, optional): The sprinkling density;
nis drawn asPoisson(density × volume). - spacetime (Spacetime, optional): The spacetime to sprinkle into. Defaults to a 2D Minkowski diamond.
- seed (int | str, optional): The random seed. Defaults to a random seed.
- matrix (TriangularBitMatrix, optional): A pre-existing causal matrix (used by
load()). If provided, sprinkling is skipped. - validate (bool): When
True(default), a suppliedmatrixis validated as a strict partial order.
Properties
causal_matrix / C
The causal matrix (C[i, j] == 1 iff i ≺ j). C is an alias.
n / N
The number of elements.
density / rho
The sprinkling density, n / volume.
spacetime
The spacetime used for sprinkling.
embedding
The attached coordinate embedding (time-labelled), or None for a native (regenerated) causet.
Methods
validate
Validates that the order is a strict partial order (reflexive-free, antisymmetric, transitive). Raises ValueError on the first violation.
coordinates
Returns the spacetime coordinates of the elements, the attached embedding for a custom-Spacetime causet, or regenerated from (spacetime, seed) for a native causet. Raises UserWarning above 100,000 elements unless force=True.
links
The link (Hasse) matrix, the transitive reduction L = C & ~(C@C).
past / future
Indices i with i ≺ x (past) or x ≺ i (future).
interval
The Alexandrov interval I(x, y) = future(x) ∩ past(y).
is_chain / is_antichain
Whether the given elements are pairwise comparable / pairwise incomparable.
longest_chain
A longest causal chain (indices); its length is the poset's height.
layers
Ranked layering: layers[k] holds the elements whose longest past-chain has length k+1.
relation_fraction
The fraction of element pairs that are causally related (R / C(n, 2)).
myrheim_meyer_dimension
The Myrheim–Meyer dimension estimate, inverting the relation fraction f(d) = Γ(d+1)Γ(d/2)/(2Γ(3d/2)).
plot_embedding / plot_hasse / plot_causal_matrix
def plot_embedding(self, **kwargs) -> Figure
def plot_hasse(self, **kwargs) -> Figure
def plot_causal_matrix(self, **kwargs) -> Figure
Visualization methods (lazy Plotly import). See plot_embedding et al.
save / load
Save/load to/from the single-file .pycauset container.
Example
import pycauset as pc
c = pc.causet(n=500, spacetime=pc.MinkowskiDiamond(2), seed=42)
c.validate()
links = c.links()
d = c.myrheim_meyer_dimension()