Open In App

SymPy | Partition.conjugate() in Python

Last Updated : 26 Aug, 2019
Improve
Improve
Like Article
Like
Save
Share
Report

Partition.conjugate() : conjugate() is a sympy Python library function that returns the conjugate partition of the argumented partition.

Syntax : sympy.combinatorics.partitions.Partition.conjugate()

Return : conjugate partition

Code #1 : conjugate() Example




# Python code explaining
# SymPy.conjugate()
  
# importing SymPy libraries
from sympy.combinatorics.partitions import Partition
from sympy.combinatorics.partitions import IntegerPartition
  
# Using from sympy.combinatorics.partitions.Partition.conjugate() method 
p = IntegerPartition([312, 14, 23])
print ('Conjugate : ', p.conjugate)


Output :

Conjugate : [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 2, 2, 2, 2, 2, 2, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1]

Code #2 : conjugate() Example – showing ValueError.




# Python code explaining
# SymPy.conjugate()
  
# importing SymPy libraries
from sympy.combinatorics.partitions import Partition
from sympy.combinatorics.partitions import IntegerPartition
  
# Using from sympy.combinatorics.partitions.Partition.conjugate() method 
  
# Only positive elements are required 
# so this will generate error
p = IntegerPartition([312, 14, -10, 23, -1])
print ('Conjugate : ', p.conjugate)


Output :

ValueError: The summands must all be positive.



Like Article
Suggest improvement
Previous
Next
Share your thoughts in the comments

Similar Reads