





import unittest

from transformers import is_torch_available
from transformers.testing_utils import require_torch


if is_torch_available():
				import torch

				from transformers.generation import DisjunctiveConstraint

@require_torch
class       A_			(unittest.TestCase     ):
	def 	_lowercase							(       self						):






				'''simple docstring'''







				UpperCAmelCase  						=							[[1, 2, 4], [1, 2, 3, 4]]
				UpperCAmelCase  						=							DisjunctiveConstraint(lowercase__						)
				self.assertTrue(isinstance(dc.token_ids				,   lowercase__						)						)

				with self.assertRaises(lowercase__						):
							DisjunctiveConstraint(torch.LongTensor([[1, 2, 4], [1, 2, 3]]						)						)

				with self.assertRaises(lowercase__						):
							DisjunctiveConstraint([torch.LongTensor([1, 2, 4]						), torch.LongTensor([1, 2, 3, 4, 5]						)]						)
	def 	_lowercase							(       self						):






				'''simple docstring'''







				UpperCAmelCase  						=							[[1, 2], [1, 2, 3, 4]]

				with self.assertRaises(lowercase__						):
							DisjunctiveConstraint(lowercase__						)  # fails here
	def 	_lowercase							(       self						):






				'''simple docstring'''







				UpperCAmelCase  						=							[[1, 2, 3], [1, 2, 4]]

				UpperCAmelCase  						=							DisjunctiveConstraint(lowercase__						)

				UpperCAmelCase						,     UpperCAmelCase						,     UpperCAmelCase  						=							dc.update(1						)
				UpperCAmelCase  						=							stepped is True and completed is False and reset is False
				self.assertTrue(lowercase__						)
				self.assertTrue(not dc.completed						)
				self.assertTrue(dc.current_seq == [1]						)

				UpperCAmelCase						,     UpperCAmelCase						,     UpperCAmelCase  						=							dc.update(2						)
				UpperCAmelCase  						=							stepped is True and completed is False and reset is False
				self.assertTrue(lowercase__						)
				self.assertTrue(not dc.completed						)
				self.assertTrue(dc.current_seq == [1, 2]						)

				UpperCAmelCase						,     UpperCAmelCase						,     UpperCAmelCase  						=							dc.update(3						)
				UpperCAmelCase  						=							stepped is True and completed is True and reset is False
				self.assertTrue(lowercase__						)
				self.assertTrue(dc.completed						)  # Completed!
				self.assertTrue(dc.current_seq == [1, 2, 3]						)







	def 	_lowercase							(       self						):






				'''simple docstring'''







				UpperCAmelCase  						=							[[1, 2, 3], [1, 2, 4, 5], [1, 2, 5]]

				UpperCAmelCase  						=							DisjunctiveConstraint(lowercase__						)

				UpperCAmelCase						,     UpperCAmelCase						,     UpperCAmelCase  						=							dc.update(1						)
				self.assertTrue(not dc.completed						)
				self.assertTrue(dc.current_seq == [1]						)

				UpperCAmelCase						,     UpperCAmelCase						,     UpperCAmelCase  						=							dc.update(2						)
				self.assertTrue(not dc.completed						)
				self.assertTrue(dc.current_seq == [1, 2]						)

				UpperCAmelCase						,     UpperCAmelCase						,     UpperCAmelCase  						=							dc.update(4						)
				self.assertTrue(not dc.completed						)
				self.assertTrue(dc.current_seq == [1, 2, 4]						)

				UpperCAmelCase						,     UpperCAmelCase						,     UpperCAmelCase  						=							dc.update(5						)
				self.assertTrue(dc.completed						)  # Completed!
				self.assertTrue(dc.current_seq == [1, 2, 4, 5]						)

				dc.reset()

				UpperCAmelCase						,     UpperCAmelCase						,     UpperCAmelCase  						=							dc.update(1						)
				self.assertTrue(not dc.completed						)
				self.assertTrue(dc.remaining() == 3						)
				self.assertTrue(dc.current_seq == [1]						)

				UpperCAmelCase						,     UpperCAmelCase						,     UpperCAmelCase  						=							dc.update(2						)
				self.assertTrue(not dc.completed						)
				self.assertTrue(dc.remaining() == 2						)
				self.assertTrue(dc.current_seq == [1, 2]						)

				UpperCAmelCase						,     UpperCAmelCase						,     UpperCAmelCase  						=							dc.update(5						)
				self.assertTrue(dc.completed						)  # Completed!
				self.assertTrue(dc.remaining() == 0						)
				self.assertTrue(dc.current_seq == [1, 2, 5]						)




import re






def _lowerCamelCase  (		snake_case  ):

							if len(re.findall('[ATCG]'     , snake_case  )  ) != len(snake_case  ):
														raise ValueError('Invalid Strand'  )

							return dna.translate(dna.maketrans('ATCG'     , 'TAGC'  )  )


if __name__ == "__main__":
				import doctest

				doctest.testmod()






