




import json
import os
import pickle
import subprocess
from hashlib import mda
from pathlib import Path
from tempfile import gettempdir
from textwrap import dedent
from types import CodeType, FunctionType
from unittest import TestCase
from unittest.mock import patch

import pytest
from multiprocess import Pool
from packaging import version

import datasets
from datasets.fingerprint import Hasher, fingerprint_transform
from datasets.table import InMemoryTable

from .utils import (
    require_regex,
    require_spacy,
    require_spacy_model,
    require_tiktoken,
    require_torch,
    require_transformers,
)







class 				UpperCAmelCase:



	"""simple docstring"""






	def __init__(					self	,				lowerCamelCase    ) ->      List[str]:





								"""simple docstring"""


								lowercase__  :	Dict        =							foo







	def __call__(					self    ) ->      int:





								"""simple docstring"""


								return self.foo







class 				UpperCAmelCase(					datasets.Dataset					):



	"""simple docstring"""






	@fingerprint_transform(inplace=lowercase__    )
	def    __a     (					self	,				lowerCamelCase	,				*lowerCamelCase	,				**lowerCamelCase    ) ->      Tuple:





								"""simple docstring"""


								return DatasetChild(self.data	,				fingerprint=lowercase__    )







	@fingerprint_transform(inplace=lowercase__    )
	def    __a     (					self	,				lowerCamelCase	,				*lowerCamelCase	,				**lowerCamelCase    ) ->      List[Any]:





								"""simple docstring"""


								return DatasetChild(self.data	,				fingerprint=lowercase__    )







class 				UpperCAmelCase:



	"""simple docstring"""






	def __init__(					self	,				lowerCamelCase    ) ->      str:





								"""simple docstring"""


								lowercase__  :	Dict        =							callable

	def __call__(					self	,				*lowerCamelCase	,				**lowerCamelCase    ) ->      List[str]:





								"""simple docstring"""


								if self.callable is not None:
															return self.callable(*lowercase__	,				**lowercase__    )







	def __getstate__(					self    ) ->      Optional[Any]:





								"""simple docstring"""


								raise pickle.PicklingError()







class 				UpperCAmelCase(					snake_case_					):



	"""simple docstring"""






	@require_transformers
	@pytest.mark.integration
	def    __a     (					self    ) ->      str:





								"""simple docstring"""


								from transformers import AutoTokenizer

								def encode(lowerCamelCase    ):
															return tokenizer(lowercase__    )

								# TODO: add hash consistency tests across sessions
								lowercase__  :	List[Any]        =							AutoTokenizer.from_pretrained("bert-base-uncased"    )
								lowercase__  :	Tuple        =							mda(datasets.utils.py_utils.dumps(lowercase__    )    ).hexdigest()
								lowercase__  :	Tuple        =							mda(datasets.utils.py_utils.dumps(lambda lowerCamelCase    : tokenizer(lowercase__    )    )    ).hexdigest()
								lowercase__  :	str        =							mda(datasets.utils.py_utils.dumps(lowercase__    )    ).hexdigest()
								lowercase__  :	List[Any]        =							AutoTokenizer.from_pretrained("bert-base-cased"    )
								lowercase__  :	int        =							mda(datasets.utils.py_utils.dumps(lowercase__    )    ).hexdigest()
								lowercase__  :	int        =							mda(datasets.utils.py_utils.dumps(lambda lowerCamelCase    : tokenizer(lowercase__    )    )    ).hexdigest()
								lowercase__  :	List[str]        =							mda(datasets.utils.py_utils.dumps(lowercase__    )    ).hexdigest()
								lowercase__  :	Any        =							AutoTokenizer.from_pretrained("bert-base-uncased"    )
								lowercase__  :	Union[str, Any]        =							mda(datasets.utils.py_utils.dumps(lowercase__    )    ).hexdigest()
								lowercase__  :	str        =							mda(datasets.utils.py_utils.dumps(lambda lowerCamelCase    : tokenizer(lowercase__    )    )    ).hexdigest()
								lowercase__  :	Any        =							mda(datasets.utils.py_utils.dumps(lowercase__    )    ).hexdigest()
								self.assertEqual(lowercase__	,				lowercase__    )
								self.assertNotEqual(lowercase__	,				lowercase__    )
								self.assertEqual(lowercase__	,				lowercase__    )
								self.assertNotEqual(lowercase__	,				lowercase__    )
								self.assertEqual(lowercase__	,				lowercase__    )
								self.assertNotEqual(lowercase__	,				lowercase__    )

	@require_transformers
	@pytest.mark.integration
	def    __a     (					self    ) ->      Any:





								"""simple docstring"""


								from transformers import AutoTokenizer

								lowercase__  :	Optional[Any]        =							AutoTokenizer.from_pretrained("gpt2"    )
								lowercase__  :	Union[str, Any]        =							mda(datasets.utils.py_utils.dumps(lowercase__    )    ).hexdigest()
								tokenizer("Hello world !"    )  # call once to change the tokenizer's cache
								lowercase__  :	Tuple        =							mda(datasets.utils.py_utils.dumps(lowercase__    )    ).hexdigest()
								self.assertEqual(lowercase__	,				lowercase__    )







	@require_regex
	def    __a     (					self    ) ->      Tuple:





								"""simple docstring"""


								import regex

								lowercase__  :	Optional[Any]        =							regex.Regex("foo"    )
								lowercase__  :	List[str]        =							mda(datasets.utils.py_utils.dumps(lowercase__    )    ).hexdigest()
								lowercase__  :	Tuple        =							regex.Regex("bar"    )
								lowercase__  :	Optional[Any]        =							mda(datasets.utils.py_utils.dumps(lowercase__    )    ).hexdigest()
								lowercase__  :	Optional[Any]        =							regex.Regex("foo"    )
								lowercase__  :	Optional[int]        =							mda(datasets.utils.py_utils.dumps(lowercase__    )    ).hexdigest()
								self.assertEqual(lowercase__	,				lowercase__    )
								self.assertNotEqual(lowercase__	,				lowercase__    )







class 				UpperCAmelCase(					snake_case_					):



	"""simple docstring"""






	def    __a     (					self    ) ->      Any:





								"""simple docstring"""


								def func():
															return foo

								lowercase__  :	Union[str, Any]        =							[0]
								lowercase__  :	Optional[int]        =							mda(datasets.utils.py_utils.dumps(lowercase__    )    ).hexdigest()
								lowercase__  :	Tuple        =							[1]
								lowercase__  :	List[Any]        =							mda(datasets.utils.py_utils.dumps(lowercase__    )    ).hexdigest()
								lowercase__  :	int        =							[0]
								lowercase__  :	List[str]        =							mda(datasets.utils.py_utils.dumps(lowercase__    )    ).hexdigest()
								self.assertEqual(lowercase__	,				lowercase__    )
								self.assertNotEqual(lowercase__	,				lowercase__    )

	def    __a     (					self    ) ->      Union[str, Any]:





								"""simple docstring"""


								def func():
															pass

								lowercase__  :	List[str]        =							mda(datasets.utils.py_utils.dumps(lowercase__    )    ).hexdigest()

								def func():
															pass

								lowercase__  :	Union[str, Any]        =							mda(datasets.utils.py_utils.dumps(lowercase__    )    ).hexdigest()
								self.assertEqual(lowercase__	,				lowercase__    )

	def    __a     (					self    ) ->      List[Any]:





								"""simple docstring"""


								lowercase__  :	str        =							mda(datasets.utils.py_utils.dumps(Foo([0]    )    )    ).hexdigest()
								lowercase__  :	List[Any]        =							mda(datasets.utils.py_utils.dumps(Foo([1]    )    )    ).hexdigest()
								lowercase__  :	Optional[int]        =							mda(datasets.utils.py_utils.dumps(Foo([0]    )    )    ).hexdigest()
								self.assertEqual(lowercase__	,				lowercase__    )
								self.assertNotEqual(lowercase__	,				lowercase__    )

	def    __a     (					self    ) ->      Optional[int]:





								"""simple docstring"""


								lowercase__  :	Any        =							mda(datasets.utils.py_utils.dumps(Foo([0]    ).__call__    )    ).hexdigest()
								lowercase__  :	List[Any]        =							mda(datasets.utils.py_utils.dumps(Foo([1]    ).__call__    )    ).hexdigest()
								lowercase__  :	Tuple        =							mda(datasets.utils.py_utils.dumps(Foo([0]    ).__call__    )    ).hexdigest()
								self.assertEqual(lowercase__	,				lowercase__    )
								self.assertNotEqual(lowercase__	,				lowercase__    )

	def    __a     (					self    ) ->      int:





								"""simple docstring"""


								lowercase__  :	List[Any]        =							(
								    "co_argcount",
								    "co_kwonlyargcount",
								    "co_nlocals",
								    "co_stacksize",
								    "co_flags",
								    "co_code",
								    "co_consts",
								    "co_names",
								    "co_varnames",
								    "co_filename",
								    "co_name",
								    "co_firstlineno",
								    "co_lnotab",
								    "co_freevars",
								    "co_cellvars",
								)

								def _create_code_pyaa(*lowerCamelCase    ):
															if hasattr(args[-3]	,				"encode"    ):
																						lowercase__  :	Union[str, Any]        =							list(lowercase__    )
																						lowercase__  :	List[str]        =							args[-3].encode()  # co_lnotab
																						lowercase__  :	List[Any]        =							args[-10].encode()  # co_code
															if hasattr(lowercase__	,				"co_posonlyargcount"    ):
																						if len(lowercase__    ) == 16:
																													return CodeType(*lowercase__    )
																						elif len(lowercase__    ) == 15:
																													return CodeType(args[0]	,				0	,				*args[1:]    )
																						return CodeType(args[0]	,				0	,				0	,				*args[1:]    )
															elif hasattr(lowercase__	,				"co_kwonlyargcount"    ):
																						if len(lowercase__    ) == 16:
																													return CodeType(args[0]	,				*args[2:]    )
																						elif len(lowercase__    ) == 15:
																													return CodeType(*lowercase__    )
																						return CodeType(args[0]	,				0	,				*args[1:]    )
															if len(lowercase__    ) == 16:
																						return CodeType(args[0]	,				*args[3:]    )
															elif len(lowercase__    ) == 15:
																						return CodeType(args[0]	,				*args[2:]    )
															return CodeType(*lowercase__    )

								def create_ipython_func(lowerCamelCase	,				lowerCamelCase    ):
															def func():
																						return returned_obj

															lowercase__  :	Dict        =							func.__code__
															# Use _create_code from dill in order to make it work for different python versions
															if datasets.config.PY_VERSION < version.parse("3.8"    ):
																						lowercase__  :	Optional[int]        =							_create_code_pyaa(
																						    *[getattr(lowercase__	,				lowercase__    ) if k != "co_filename" else co_filename for k in code_args_pyaa]    )
															else:
																						lowercase__  :	List[str]        =							code.replace(co_filename=lowercase__    )
															return FunctionType(lowercase__	,				func.__globals__	,				func.__name__	,				func.__defaults__	,				func.__closure__    )

								lowercase__ ,       lowercase__  :	Union[str, Any]        =							"<ipython-input-2-e0383a102aae>", [0]
								lowercase__  :	str        =							mda(datasets.utils.py_utils.dumps(create_ipython_func(lowercase__	,				lowercase__    )    )    ).hexdigest()
								lowercase__ ,       lowercase__  :	Union[str, Any]        =							"<ipython-input-2-e0383a102aae>", [1]
								lowercase__  :	Union[str, Any]        =							mda(datasets.utils.py_utils.dumps(create_ipython_func(lowercase__	,				lowercase__    )    )    ).hexdigest()
								lowercase__ ,       lowercase__  :	List[str]        =							"<ipython-input-5-713f6613acf3>", [0]
								lowercase__  :	Union[str, Any]        =							mda(datasets.utils.py_utils.dumps(create_ipython_func(lowercase__	,				lowercase__    )    )    ).hexdigest()
								self.assertEqual(lowercase__	,				lowercase__    )
								self.assertNotEqual(lowercase__	,				lowercase__    )

								lowercase__ ,       lowercase__  :	Optional[Any]        =							os.path.join(gettempdir()	,				"ipykernel_12345"	,				"321456789.py"    ), [0]
								lowercase__  :	Tuple        =							mda(datasets.utils.py_utils.dumps(create_ipython_func(lowercase__	,				lowercase__    )    )    ).hexdigest()
								lowercase__ ,       lowercase__  :	Optional[Any]        =							os.path.join(gettempdir()	,				"ipykernel_12345"	,				"321456789.py"    ), [1]
								lowercase__  :	List[Any]        =							mda(datasets.utils.py_utils.dumps(create_ipython_func(lowercase__	,				lowercase__    )    )    ).hexdigest()
								lowercase__ ,       lowercase__  :	List[Any]        =							os.path.join(gettempdir()	,				"ipykernel_12345"	,				"654123987.py"    ), [0]
								lowercase__  :	str        =							mda(datasets.utils.py_utils.dumps(create_ipython_func(lowercase__	,				lowercase__    )    )    ).hexdigest()
								self.assertEqual(lowercase__	,				lowercase__    )
								self.assertNotEqual(lowercase__	,				lowercase__    )







	def    __a     (					self    ) ->      Optional[int]:





								"""simple docstring"""


								lowercase__ ,       lowercase__  :	List[str]        =							[0], [1]

								def func():
															return foo, bar

								lowercase__  :	Optional[Any]        =							"__main__"

								def globalvars_mocka_side_effect(lowerCamelCase	,				*lowerCamelCase	,				**lowerCamelCase    ):
															return {"foo": foo, "bar": bar}

								def globalvars_mocka_side_effect(lowerCamelCase	,				*lowerCamelCase	,				**lowerCamelCase    ):
															return {"bar": bar, "foo": foo}

								with patch("dill.detect.globalvars"	,				side_effect=lowercase__    ) as globalvars_mocka:
															lowercase__  :	Optional[int]        =							mda(datasets.utils.py_utils.dumps(lowercase__    )    ).hexdigest()
															self.assertGreater(globalvars_mocka.call_count	,				0    )
								with patch("dill.detect.globalvars"	,				side_effect=lowercase__    ) as globalvars_mocka:
															lowercase__  :	List[str]        =							mda(datasets.utils.py_utils.dumps(lowercase__    )    ).hexdigest()
															self.assertGreater(globalvars_mocka.call_count	,				0    )
								self.assertEqual(lowercase__	,				lowercase__    )







class 				UpperCAmelCase(					snake_case_					):



	"""simple docstring"""






	def    __a     (					self    ) ->      Optional[int]:





								"""simple docstring"""


								lowercase__  :	Any        =							Hasher.hash("hello"    )
								lowercase__  :	Union[str, Any]        =							Hasher.hash("hello"    )
								lowercase__  :	List[str]        =							Hasher.hash("there"    )
								self.assertEqual(lowercase__	,				lowercase__    )
								self.assertNotEqual(lowercase__	,				lowercase__    )

	def    __a     (					self    ) ->      Optional[int]:





								"""simple docstring"""


								lowercase__  :	Any        =							Hasher.hash(Foo("hello"    )    )
								lowercase__  :	Any        =							Hasher.hash(Foo("hello"    )    )
								lowercase__  :	Union[str, Any]        =							Hasher.hash(Foo("there"    )    )
								self.assertEqual(lowercase__	,				lowercase__    )
								self.assertNotEqual(lowercase__	,				lowercase__    )

	def    __a     (					self    ) ->      Any:





								"""simple docstring"""


								lowercase__  :	Union[str, Any]        =							Hasher()
								for x in ["hello", Foo("hello"    )]:
															hasher.update(lowercase__    )
								lowercase__  :	str        =							hasher.hexdigest()
								lowercase__  :	Optional[Any]        =							Hasher()
								for x in ["hello", Foo("hello"    )]:
															hasher.update(lowercase__    )
								lowercase__  :	Optional[int]        =							hasher.hexdigest()
								lowercase__  :	Tuple        =							Hasher()
								for x in ["there", Foo("there"    )]:
															hasher.update(lowercase__    )
								lowercase__  :	List[Any]        =							hasher.hexdigest()
								self.assertEqual(lowercase__	,				lowercase__    )
								self.assertNotEqual(lowercase__	,				lowercase__    )

	def    __a     (					self    ) ->      int:





								"""simple docstring"""


								with self.assertRaises(pickle.PicklingError    ):
															Hasher.hash(UnpicklableCallable(Foo("hello"    )    )    )

	def    __a     (					self    ) ->      Optional[int]:





								"""simple docstring"""


								lowercase__  :	str        =							"abc"
								lowercase__  :	int        =							[string, string]  # two strings have the same ids
								lowercase__  :	str        =							[string, string]
								lowercase__  :	List[str]        =							json.loads(f"""[\"{string}\", \"{string}\"]"""    )  # two strings have different ids
								self.assertIs(obja[0]	,				lowercase__    )
								self.assertIs(obja[0]	,				obja[1]    )
								self.assertIs(obja[0]	,				lowercase__    )
								self.assertIs(obja[0]	,				obja[1]    )
								self.assertIsNot(obja[0]	,				lowercase__    )
								self.assertIsNot(obja[0]	,				obja[1]    )
								lowercase__  :	List[str]        =							Hasher.hash(lowercase__    )
								lowercase__  :	Union[str, Any]        =							Hasher.hash(lowercase__    )
								lowercase__  :	Optional[Any]        =							Hasher.hash(lowercase__    )
								self.assertEqual(lowercase__	,				lowercase__    )
								self.assertEqual(lowercase__	,				lowercase__    )

	@require_tiktoken
	def    __a     (					self    ) ->      List[Any]:





								"""simple docstring"""


								import tiktoken

								lowercase__  :	Optional[int]        =							tiktoken.get_encoding("gpt2"    )
								lowercase__  :	Union[str, Any]        =							mda(datasets.utils.py_utils.dumps(lowercase__    )    ).hexdigest()
								lowercase__  :	Tuple        =							tiktoken.get_encoding("r50k_base"    )
								lowercase__  :	Dict        =							mda(datasets.utils.py_utils.dumps(lowercase__    )    ).hexdigest()
								lowercase__  :	Any        =							tiktoken.get_encoding("gpt2"    )
								lowercase__  :	Tuple        =							mda(datasets.utils.py_utils.dumps(lowercase__    )    ).hexdigest()
								self.assertEqual(lowercase__	,				lowercase__    )
								self.assertNotEqual(lowercase__	,				lowercase__    )

	@require_torch
	def    __a     (					self    ) ->      str:





								"""simple docstring"""


								import torch

								lowercase__  :	int        =							torch.tensor([1.0]    )
								lowercase__  :	Dict        =							mda(datasets.utils.py_utils.dumps(lowercase__    )    ).hexdigest()
								lowercase__  :	List[Any]        =							torch.tensor([2.0]    )
								lowercase__  :	Any        =							mda(datasets.utils.py_utils.dumps(lowercase__    )    ).hexdigest()
								lowercase__  :	int        =							torch.tensor([1.0]    )
								lowercase__  :	int        =							mda(datasets.utils.py_utils.dumps(lowercase__    )    ).hexdigest()
								self.assertEqual(lowercase__	,				lowercase__    )
								self.assertNotEqual(lowercase__	,				lowercase__    )







	@require_spacy
	@require_spacy_model("en_core_web_sm"    )
	@require_spacy_model("fr_core_news_sm"    )
	@pytest.mark.integration
	def    __a     (					self    ) ->      Optional[Any]:





								"""simple docstring"""


								import spacy

								lowercase__  :	Tuple        =							spacy.load("en_core_web_sm"    )
								lowercase__  :	Any        =							mda(datasets.utils.py_utils.dumps(lowercase__    )    ).hexdigest()
								lowercase__  :	List[str]        =							spacy.load("fr_core_news_sm"    )
								lowercase__  :	Tuple        =							mda(datasets.utils.py_utils.dumps(lowercase__    )    ).hexdigest()
								lowercase__  :	Dict        =							spacy.load("en_core_web_sm"    )
								lowercase__  :	Tuple        =							mda(datasets.utils.py_utils.dumps(lowercase__    )    ).hexdigest()
								self.assertEqual(lowercase__	,				lowercase__    )
								self.assertNotEqual(lowercase__	,				lowercase__    )

@pytest.mark.integration
def  snake_case_					(		SCREAMING_SNAKE_CASE_    )      ->			List[Any]:
							lowercase__  :	Dict        =							tmp_path / "dir1"
							lowercase__  :	Optional[int]        =							tmp_path / "dir2"
							dira.mkdir()
							dira.mkdir()
							lowercase__  :	Union[str, Any]        =							"script.py"
							lowercase__  :	List[str]        =							dedent(
							    "\n    from datasets.fingerprint import Hasher\n    def foo():\n        pass\n    print(Hasher.hash(foo))\n    "    )
							lowercase__  :	List[Any]        =							dira / script_filename
							lowercase__  :	Optional[int]        =							dira / script_filename
							with script_patha.open("w"    ) as f:
														f.write(SCREAMING_SNAKE_CASE_    )
							with script_patha.open("w"    ) as f:
														f.write(SCREAMING_SNAKE_CASE_    )
							lowercase__  :	Any        =							subprocess.check_output(["python", str(SCREAMING_SNAKE_CASE_    )]    )
							lowercase__  :	Optional[int]        =							subprocess.check_output(["python", str(SCREAMING_SNAKE_CASE_    )]    )
							assert fingerprinta == fingerprinta
def  snake_case_					(		)      ->			str:
							lowercase__  :	Tuple        =							{"a": [0, 1, 2]}
							lowercase__  :	List[Any]        =							DatasetChild(InMemoryTable.from_pydict(SCREAMING_SNAKE_CASE_    )    )
							lowercase__  :	Any        =							dataset.funca()._fingerprint
							assert expected_fingerprint == dataset.funca()._fingerprint
							assert expected_fingerprint != dataset.funca()._fingerprint

							with Pool(2    ) as p:
														assert expected_fingerprint == p.apply_async(dataset.funca    ).get()._fingerprint
														assert expected_fingerprint != p.apply_async(dataset.funca    ).get()._fingerprint
def  snake_case_					(		)      ->			Union[str, Any]:
							lowercase__  :	Dict        =							{"a": [0, 1, 2]}







							class 				UpperCAmelCase(					datasets.Dataset					):



								"""simple docstring"""






								@fingerprint_transform(inplace=lowercase__    )
								def    __a     (					self	,				lowerCamelCase    ) ->      Any:





															"""simple docstring"""


															return DummyDatasetChild(self.data	,				fingerprint=lowercase__    )

							lowercase__  :	int        =							DummyDatasetChild(InMemoryTable.from_pydict(SCREAMING_SNAKE_CASE_    )    ).func()







							class 				UpperCAmelCase(					datasets.Dataset					):



								"""simple docstring"""






								@fingerprint_transform(inplace=lowercase__	,				version="1.0.0"    )
								def    __a     (					self	,				lowerCamelCase    ) ->      int:





															"""simple docstring"""


															return DummyDatasetChild(self.data	,				fingerprint=lowercase__    )

							lowercase__  :	List[str]        =							DummyDatasetChild(InMemoryTable.from_pydict(SCREAMING_SNAKE_CASE_    )    ).func()







							class 				UpperCAmelCase(					datasets.Dataset					):



								"""simple docstring"""






								@fingerprint_transform(inplace=lowercase__	,				version="2.0.0"    )
								def    __a     (					self	,				lowerCamelCase    ) ->      Dict:





															"""simple docstring"""


															return DummyDatasetChild(self.data	,				fingerprint=lowercase__    )

							lowercase__  :	Any        =							DummyDatasetChild(InMemoryTable.from_pydict(SCREAMING_SNAKE_CASE_    )    ).func()

							assert len({fingeprint_no_version, fingeprint_a, fingeprint_a}    ) == 3




def  snake_case_					(		)      ->			int:
							# AttributeError: module 'dill._dill' has no attribute 'stack'
							lowercase__  :	Optional[int]        =							Hasher()
							hasher.update(lambda SCREAMING_SNAKE_CASE_    : x    )





from __future__ import annotations

import math
import random
def  snake_case_					(		SCREAMING_SNAKE_CASE_    ,SCREAMING_SNAKE_CASE_    ,SCREAMING_SNAKE_CASE_    )      ->			list[int]:
							lowercase__  :	List[Any]        =							d * e - 1
							lowercase__  :	Any        =							0
							lowercase__  :	Dict        =							0
							while p == 0:
														lowercase__  :	Dict        =							random.randint(2    ,n - 1    )
														lowercase__  :	int        =							k
														while True:
																					if t % 2 == 0:
																												lowercase__  :	str        =							t // 2
																												lowercase__  :	int        =							(g**t) % n
																												lowercase__  :	List[Any]        =							math.gcd(x - 1    ,SCREAMING_SNAKE_CASE_    )
																												if x > 1 and y > 1:
																																			lowercase__  :	Any        =							y
																																			lowercase__  :	Optional[int]        =							n // y
																																			break  # find the correct factors
																					else:
																												break  # t is not divisible by 2, break and choose another g
							return sorted([p, q]    )


if __name__ == "__main__":
						import doctest

						doctest.testmod()