  We introduce cosmocnc, a Python package for computing the number count
likelihood of galaxy cluster catalogues in a fast, flexible and accurate way.
cosmocnc offers three types of likelihoods: an unbinned, a binned, and an
extreme value likelihood. It also supports the addition of stacked cluster
data, which is modelled consistently with the cluster catalogue. The unbinned
likelihood, which is the main focus of the code, can take an arbitrary number
of mass observables as input and deal with several complexities in the data,
such as variations in the properties of the cluster observable across the
survey footprint, the possibility of different clusters having measurements for
different combinations of mass observables, redshift measurement uncertainties,
and the presence on unconfirmed detections in the catalogue. If there are more
than one mass observables, the unbinned likelihood is computed with the
backward convolutional approach, a novel approach that is first implemented in
cosmocnc. After developing the likelihood formalism and describing its
implementation, we validate the code with synthetic Simons-Observatory-like
catalogues, finding excellent agreement between their properties and cosmocnc's
predictions and obtaining constraints on cosmological and scaling relation
parameters featuring negligible biases. cosmocnc is publicly available at
github.com/inigozubeldia/cosmocnc.
