| 857 | 857 | #g) (Permutation) = adjust size or return copy |
| 858 | 858 | ok = True |
| 859 | 859 | if not args: # a |
| 860 | return _af_new(list(range(size or 0))) | |
| 860 | aform = list(range(size or 0)) | |
| 861 | obj = Basic.__new__(cls, aform) | |
| 862 | obj._array_form = aform | |
| 863 | obj._size = len(aform) | |
| 864 | return obj | |
| 861 | 865 | elif len(args) > 1: # c |
| 862 | return _af_new(Cycle(*args).list(size)) | |
| 866 | aform = Cycle(*args).list(size) | |
| 867 | obj = Basic.__new__(cls, aform) | |
| 868 | obj._array_form = aform | |
| 869 | obj._size = len(aform) | |
| 870 | return obj | |
| 863 | 871 | if len(args) == 1: |
| 864 | 872 | a = args[0] |
| 865 | 873 | if isinstance(a, Perm): # g |
| 867 | 875 | return a |
| 868 | 876 | return Perm(a.array_form, size=size) |
| 869 | 877 | if isinstance(a, Cycle): # f |
| 870 | return _af_new(a.list(size)) | |
| 878 | aform = a.list(size) | |
| 879 | obj = Basic.__new__(cls, aform) | |
| 880 | obj._array_form = aform | |
| 881 | obj._size = len(aform) | |
| 882 | return obj | |
| 871 | 883 | if not is_sequence(a): # b |
| 872 | return _af_new(list(range(a + 1))) | |
| 884 | aform = list(range(a + 1)) | |
| 885 | obj = Basic.__new__(cls, aform) | |
| 886 | obj._array_form = aform | |
| 887 | obj._size = len(aform) | |
| 888 | return obj | |
| 873 | 889 | if has_variety(is_sequence(ai) for ai in a): |
| 874 | 890 | ok = False |
| 875 | 891 | else: |
| Test Name | Status |
|---|---|
test_Permutation_subclassing | Fail |
test_Permutation | Pass |
test_josephus | Pass |
test_ranking | Pass |
test_mul | Pass |
test_args | Pass |
test_Cycle | Pass |
test_from_sequence | Pass |
test_printing_cyclic | Pass |
Loading...
Ridges.AI© 2025 Ridges AI. Building the future of decentralized AI development.
