Integer Partition Refinement in Sage

I don't currently have Sage installed but browsing the documentation seems to indicate that taking a closed interval (with one end of the interval being your partition in question and the other end being the finest, all-ones partition) of the IntegerPartitions poset should do the trick.

EDIT: I just tested it on SageMathCell, an online Sage interface, and it seems to work fine.

> P = Posets.IntegerPartitions(6);
> print(P.closed_interval((3,2,1), P.top()));
> P = Posets.IntegerPartitions(7);
> print(P.closed_interval((4,3), P.top()));

[(3, 2, 1), (3, 1, 1, 1), (2, 2, 1, 1), (2, 1, 1, 1, 1), (1, 1, 1, 1, 1, 1)]
[(4, 3), (4, 2, 1), (4, 1, 1, 1), (3, 3, 1), (3, 2, 2), (3, 2, 1, 1), (3, 1, 1, 1, 1), (2, 2, 2, 1), (2, 2, 1, 1, 1), (2, 1, 1, 1, 1, 1), (1, 1, 1, 1, 1, 1, 1)]

EDIT #2: You can also use is_gequal() to test if one partition is a refinement of another.

> P = Posets.IntegerPartitions(6);
> P.is_gequal((2,2,1,1), (3,3));

True

> P = Posets.IntegerPartitions(6);
> P.is_gequal((4,2), (3,3));

False

Good question. But the list of refinements of a composition is implemented. Thus you can do the following:

def finer(p):
    # Return the list of all partitions refining the given partition ``p``.
    # 
    # EXAMPLES::
    # 
    #     sage: finer(Partition([3,2,1]))
    #     [[1, 1, 1, 1, 1, 1], [2, 1, 1, 1, 1], [2, 2, 1, 1], [3, 1, 1, 1], [3, 2, 1]]
    P = Partitions() # just the constructor
    c = Compositions()(p) # make p into a composition
    return uniq([P(sorted(d, reverse=True)) for d in c.finer()])

This is probably not a very fast method, though... (The uniq is a blunt weapon.)