How to compute the canonical divisor of a smooth variety
I cant seem to find any sort of documentation for how to compute the canonical divisor KX of a variety. My example is quite simpe: I'm just trying to compute the (anti)canonical divisor −KX of the Segre variety P2×P2⊂P8 intersected by a quadric Q⊂P8 which will be a prime Fano variety so that −KX is a hyperplane section — I'm able to construct the intersection and save it as a subscheme in SageMath, but cant get much information outside of that.
It seems like the only real way to do this in SageMath is with toric varieties which is a bit frustrating.
Please include the construction in SageMath in the question, to aid people who might have a clue. It looks like Macaulay2 contains canonical divisor functionality.