




"""simple docstring"""

import pyarrow.parquet as pq
import pytest

from datasets import Audio, Dataset, DatasetDict, Features, NamedSplit, Sequence, Value, config
from datasets.features.image import Image
from datasets.io.parquet import ParquetDatasetReader, ParquetDatasetWriter, get_writer_batch_size

from ..utils import assert_arrow_memory_doesnt_increase, assert_arrow_memory_increases

def 		lowercase_      (		_UpperCAmelCase  ,      _UpperCAmelCase	):




	"""simple docstring"""






	assert isinstance(_UpperCAmelCase  ,      _UpperCAmelCase	)
	assert dataset.num_rows == 4
	assert dataset.num_columns == 3
	assert dataset.column_names == ["col_1", "col_2", "col_3"]
	for feature, expected_dtype in expected_features.items():
		assert dataset.features[feature].dtype == expected_dtype

@pytest.mark.parametrize('''keep_in_memory'''  ,      [False, True]	)
def 		lowercase_      (		_UpperCAmelCase  ,      _UpperCAmelCase  ,      _UpperCAmelCase	):




	"""simple docstring"""






	A_  :				Optional[Any]	   =		tmp_path / '''cache'''
	A_  :				Tuple	   =		{'''col_1''': '''string''', '''col_2''': '''int64''', '''col_3''': '''float64'''}
	with assert_arrow_memory_increases() if keep_in_memory else assert_arrow_memory_doesnt_increase():
		A_  :				str	   =		ParquetDatasetReader(_UpperCAmelCase  ,      cache_dir=_UpperCAmelCase  ,      keep_in_memory=_UpperCAmelCase	).read()
	_check_parquet_dataset(_UpperCAmelCase  ,      _UpperCAmelCase	)

@pytest.mark.parametrize(
    '''features'''  ,      [
        None,
        {'''col_1''': '''string''', '''col_2''': '''int64''', '''col_3''': '''float64'''},
        {'''col_1''': '''string''', '''col_2''': '''string''', '''col_3''': '''string'''},
        {'''col_1''': '''int32''', '''col_2''': '''int32''', '''col_3''': '''int32'''},
        {'''col_1''': '''float32''', '''col_2''': '''float32''', '''col_3''': '''float32'''},
    ]  ,      )
def 		lowercase_      (		_UpperCAmelCase  ,      _UpperCAmelCase  ,      _UpperCAmelCase	):




	"""simple docstring"""






	A_  :				List[str]	   =		tmp_path / '''cache'''
	A_  :				List[Any]	   =		{'''col_1''': '''string''', '''col_2''': '''int64''', '''col_3''': '''float64'''}
	A_  :				Optional[Any]	   =		features.copy() if features else default_expected_features
	A_  :				List[Any]	   =		(
	    Features({feature: Value(_UpperCAmelCase	) for feature, dtype in features.items()}	) if features is not None else None
	)
	A_  :				Union[str, Any]	   =		ParquetDatasetReader(_UpperCAmelCase  ,      features=_UpperCAmelCase  ,      cache_dir=_UpperCAmelCase	).read()
	_check_parquet_dataset(_UpperCAmelCase  ,      _UpperCAmelCase	)

@pytest.mark.parametrize('''split'''  ,      [None, NamedSplit('''train'''	), '''train''', '''test''']	)
def 		lowercase_      (		_UpperCAmelCase  ,      _UpperCAmelCase  ,      _UpperCAmelCase	):




	"""simple docstring"""






	A_  :				List[Any]	   =		tmp_path / '''cache'''
	A_  :				Optional[int]	   =		{'''col_1''': '''string''', '''col_2''': '''int64''', '''col_3''': '''float64'''}
	A_  :				str	   =		ParquetDatasetReader(_UpperCAmelCase  ,      cache_dir=_UpperCAmelCase  ,      split=_UpperCAmelCase	).read()
	_check_parquet_dataset(_UpperCAmelCase  ,      _UpperCAmelCase	)
	assert dataset.split == split if split else "train"

@pytest.mark.parametrize('''path_type'''  ,      [str, list]	)
def 		lowercase_      (		_UpperCAmelCase  ,      _UpperCAmelCase  ,      _UpperCAmelCase	):




	"""simple docstring"""






	if issubclass(_UpperCAmelCase  ,      _UpperCAmelCase	):
		A_  :				Optional[Any]	   =		parquet_path
	elif issubclass(_UpperCAmelCase  ,      _UpperCAmelCase	):
		A_  :				Dict	   =		[parquet_path]
	A_  :				List[str]	   =		tmp_path / '''cache'''
	A_  :				int	   =		{'''col_1''': '''string''', '''col_2''': '''int64''', '''col_3''': '''float64'''}
	A_  :				str	   =		ParquetDatasetReader(_UpperCAmelCase  ,      cache_dir=_UpperCAmelCase	).read()
	_check_parquet_dataset(_UpperCAmelCase  ,      _UpperCAmelCase	)

def 		lowercase_      (		_UpperCAmelCase  ,      _UpperCAmelCase  ,      _UpperCAmelCase=("train",)	):




	"""simple docstring"""






	assert isinstance(_UpperCAmelCase  ,      _UpperCAmelCase	)
	for split in splits:
		A_  :				Dict	   =		dataset_dict[split]
		assert dataset.num_rows == 4
		assert dataset.num_columns == 3
		assert dataset.column_names == ["col_1", "col_2", "col_3"]
		for feature, expected_dtype in expected_features.items():
			assert dataset.features[feature].dtype == expected_dtype

@pytest.mark.parametrize('''keep_in_memory'''  ,      [False, True]	)
def 		lowercase_      (		_UpperCAmelCase  ,      _UpperCAmelCase  ,      _UpperCAmelCase	):




	"""simple docstring"""






	A_  :				Dict	   =		tmp_path / '''cache'''
	A_  :				int	   =		{'''col_1''': '''string''', '''col_2''': '''int64''', '''col_3''': '''float64'''}
	with assert_arrow_memory_increases() if keep_in_memory else assert_arrow_memory_doesnt_increase():
		A_  :				Union[str, Any]	   =		ParquetDatasetReader(
		    {'''train''': parquet_path}  ,      cache_dir=_UpperCAmelCase  ,      keep_in_memory=_UpperCAmelCase	).read()
	_check_parquet_datasetdict(_UpperCAmelCase  ,      _UpperCAmelCase	)

@pytest.mark.parametrize(
    '''features'''  ,      [
        None,
        {'''col_1''': '''string''', '''col_2''': '''int64''', '''col_3''': '''float64'''},
        {'''col_1''': '''string''', '''col_2''': '''string''', '''col_3''': '''string'''},
        {'''col_1''': '''int32''', '''col_2''': '''int32''', '''col_3''': '''int32'''},
        {'''col_1''': '''float32''', '''col_2''': '''float32''', '''col_3''': '''float32'''},
    ]  ,      )
def 		lowercase_      (		_UpperCAmelCase  ,      _UpperCAmelCase  ,      _UpperCAmelCase	):




	"""simple docstring"""






	A_  :				int	   =		tmp_path / '''cache'''
	A_  :				List[str]	   =		{'''col_1''': '''string''', '''col_2''': '''int64''', '''col_3''': '''float64'''}
	A_  :				str	   =		features.copy() if features else default_expected_features
	A_  :				Optional[int]	   =		(
	    Features({feature: Value(_UpperCAmelCase	) for feature, dtype in features.items()}	) if features is not None else None
	)
	A_  :				int	   =		ParquetDatasetReader({'''train''': parquet_path}  ,      features=_UpperCAmelCase  ,      cache_dir=_UpperCAmelCase	).read()
	_check_parquet_datasetdict(_UpperCAmelCase  ,      _UpperCAmelCase	)

@pytest.mark.parametrize('''split'''  ,      [None, NamedSplit('''train'''	), '''train''', '''test''']	)
def 		lowercase_      (		_UpperCAmelCase  ,      _UpperCAmelCase  ,      _UpperCAmelCase	):




	"""simple docstring"""






	if split:
		A_  :				Optional[int]	   =		{split: parquet_path}
	else:
		A_  :				Optional[int]	   =		'''train'''
		A_  :				Dict	   =		{'''train''': parquet_path, '''test''': parquet_path}
	A_  :				List[Any]	   =		tmp_path / '''cache'''
	A_  :				str	   =		{'''col_1''': '''string''', '''col_2''': '''int64''', '''col_3''': '''float64'''}
	A_  :				Union[str, Any]	   =		ParquetDatasetReader(_UpperCAmelCase  ,      cache_dir=_UpperCAmelCase	).read()
	_check_parquet_datasetdict(_UpperCAmelCase  ,      _UpperCAmelCase  ,      splits=list(path.keys()	)	)
	assert all(dataset[split].split == split for split in path.keys()	)

def 		lowercase_      (		_UpperCAmelCase  ,      _UpperCAmelCase	):




	"""simple docstring"""






	A_  :				Tuple	   =		ParquetDatasetWriter(_UpperCAmelCase  ,      tmp_path / '''foo.parquet'''	)
	assert writer.write() > 0
	A_  :				Optional[Any]	   =		pq.ParquetFile(tmp_path / '''foo.parquet'''	)
	A_  :				Any	   =		pf.read()
	assert dataset.data.table == output_table

def 		lowercase_      (		_UpperCAmelCase  ,      _UpperCAmelCase	):




	"""simple docstring"""






	A_  :				Dict	   =		str(shared_datadir / '''test_image_rgb.jpg'''	)
	A_  :				Union[str, Any]	   =		{'''image''': [image_path]}
	A_  :				List[str]	   =		Features({'''image''': Image()}	)
	A_  :				List[str]	   =		Dataset.from_dict(_UpperCAmelCase  ,      features=_UpperCAmelCase	)
	A_  :				Dict	   =		ParquetDatasetWriter(_UpperCAmelCase  ,      tmp_path / '''foo.parquet'''	)
	assert writer.write() > 0

	A_  :				Optional[int]	   =		Dataset.from_parquet(str(tmp_path / '''foo.parquet'''	)	)
	assert dataset.features == reloaded_dataset.features

	A_  :				str	   =		ParquetDatasetReader(str(tmp_path / '''foo.parquet'''	)  ,      streaming=_UpperCAmelCase	).read()
	assert dataset.features == reloaded_iterable_dataset.features

@pytest.mark.parametrize(
    '''feature, expected'''  ,      [
        (Features({'''foo''': Value('''int32'''	)}	), None),
        (Features({'''image''': Image(), '''foo''': Value('''int32'''	)}	), config.PARQUET_ROW_GROUP_SIZE_FOR_IMAGE_DATASETS),
        (Features({'''nested''': Sequence(Audio()	)}	), config.PARQUET_ROW_GROUP_SIZE_FOR_AUDIO_DATASETS),
    ]  ,      )
def 		lowercase_      (		_UpperCAmelCase  ,      _UpperCAmelCase	):




	"""simple docstring"""






	assert get_writer_batch_size(_UpperCAmelCase	) == expected











"""simple docstring"""

import requests
from bsa import BeautifulSoup

def 		lowercase_      (		_UpperCAmelCase = "https://www.worldometers.info/coronavirus"	):




	"""simple docstring"""






	A_  :				str	   =		BeautifulSoup(requests.get(_UpperCAmelCase	).text  ,      '''html.parser'''	)
	A_  :				Union[str, Any]	   =		soup.findAll('''h1'''	)
	A_  :				Union[str, Any]	   =		soup.findAll('''div'''  ,      {'''class''': '''maincounter-number'''}	)
	keys += soup.findAll('''span'''  ,      {'''class''': '''panel-title'''}	)
	values += soup.findAll('''div'''  ,      {'''class''': '''number-table-main'''}	)
	return {key.text.strip(): value.text.strip() for key, value in zip(_UpperCAmelCase  ,      _UpperCAmelCase	)}


if __name__ == "__main__":
		print('\033[1m' + 'COVID-19 Status of the World' + '\033[0m\n')
		for key, value in world_covidaa_stats().items():
				print(f'{key}\n{value}\n')





