diff --git a/src/sage/combinat/partition.py b/src/sage/combinat/partition.py index 57de84aae55..423ea6a3730 100644 --- a/src/sage/combinat/partition.py +++ b/src/sage/combinat/partition.py @@ -5812,26 +5812,7 @@ def __classcall_private__(cls, n=None, **kwargs): """ if n == infinity: raise ValueError("n cannot be infinite") - if n is None or n is NN or n is NonNegativeIntegers(): - if len(kwargs) > 0: - if len(kwargs) == 1: - if 'max_part' in kwargs: - return Partitions_all_bounded(kwargs['max_part']) - if 'regular' in kwargs: - return RegularPartitions_all(kwargs['regular']) - if 'restricted' in kwargs: - return RestrictedPartitions_all(kwargs['restricted']) - elif len(kwargs) == 2: - if 'regular' in kwargs: - if kwargs['regular'] < 1 or kwargs['regular'] not in ZZ: - raise ValueError("the regularity must be a positive integer") - if 'max_part' in kwargs: - return RegularPartitions_bounded(kwargs['regular'], kwargs['max_part']) - if 'max_length' in kwargs: - return RegularPartitions_truncated(kwargs['regular'], kwargs['max_length']) - raise ValueError("the size must be specified with any keyword argument") - return Partitions_all() - elif isinstance(n, (int,Integer)): + if isinstance(n, (int,Integer)): if len(kwargs) == 0: return Partitions_n(n) @@ -5885,6 +5866,25 @@ def __classcall_private__(cls, n=None, **kwargs): kwargs.get('min_length',0)) del kwargs['inner'] return Partitions_with_constraints(n, **kwargs) + elif n is None or n is NN or n is NonNegativeIntegers(): + if len(kwargs) > 0: + if len(kwargs) == 1: + if 'max_part' in kwargs: + return Partitions_all_bounded(kwargs['max_part']) + if 'regular' in kwargs: + return RegularPartitions_all(kwargs['regular']) + if 'restricted' in kwargs: + return RestrictedPartitions_all(kwargs['restricted']) + elif len(kwargs) == 2: + if 'regular' in kwargs: + if kwargs['regular'] < 1 or kwargs['regular'] not in ZZ: + raise ValueError("the regularity must be a positive integer") + if 'max_part' in kwargs: + return RegularPartitions_bounded(kwargs['regular'], kwargs['max_part']) + if 'max_length' in kwargs: + return RegularPartitions_truncated(kwargs['regular'], kwargs['max_length']) + raise ValueError("the size must be specified with any keyword argument") + return Partitions_all() raise ValueError("n must be an integer or be equal to one of " "None, NN, NonNegativeIntegers()")