# Path: bertopic/_utils.py
# def check_documents_type(documents):
#     """ Check whether the input documents are indeed a list of strings """
#     if isinstance(documents, Iterable) and not isinstance(documents, str):
#         if not any([isinstance(doc, str) for doc in documents]):
#             raise TypeError("Make sure that the iterable only contains strings.")
# 
#     else:
#         raise TypeError("Make sure that the documents variable is an iterable containing strings only.")
# 
# def check_embeddings_shape(embeddings, docs):
#     """ Check if the embeddings have the correct shape """
#     if embeddings is not None:
#         if not any([isinstance(embeddings, np.ndarray), isinstance(embeddings, csr_matrix)]):
#             raise ValueError("Make sure to input embeddings as a numpy array or scipy.sparse.csr.csr_matrix. ")
#         else:
#             if embeddings.shape[0] != len(docs):
#                 raise ValueError("Make sure that the embeddings are a numpy array with shape: "
#                                  "(len(docs), vector_dim) where vector_dim is the dimensionality "
#                                  "of the vector embeddings. ")
# 
# class MyLogger:
#     def __init__(self, level):
#         self.logger = logging.getLogger('BERTopic')
#         self.set_level(level)
#         self._add_handler()
#         self.logger.propagate = False
# 
#     def info(self, message):
#         self.logger.info("{}".format(message))
# 
#     def set_level(self, level):
#         levels = ["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"]
#         if level in levels:
#             self.logger.setLevel(level)
# 
#     def _add_handler(self):
#         sh = logging.StreamHandler()
#         sh.setFormatter(logging.Formatter('%(asctime)s - %(name)s - %(message)s'))
#         self.logger.addHandler(sh)
# 
#         # Remove duplicate handlers
#         if len(self.logger.handlers) > 1:
#             self.logger.handlers = [self.logger.handlers[0]]


import pytest
import logging
import numpy as np
from bertopic._utils import check_documents_type, check_embeddings_shape, MyLogger
    logger = MyLogger("WARNING")
    assert isinstance(logger.logger, logging.Logger)
    assert logger.logger.level == 30


@pytest.mark.parametrize(
    "docs",
    [
        "A document not in an iterable",
        [None],
        5
    ],
)
def test_check_documents_type(docs):
    """ Making sure the checks for document type succeed """
    with pytest.raises(TypeError):
        check_documents_type(docs)


def test_check_embeddings_shape():
    """ Testing correct embeddings shape

    Checking for embeddings is typically done when custom embeddings
    are used instead of the default SentenceTransformer models. This means
    that the embeddings should have the correct shape, which is tested for
    in check_embeddings_shape.
    """
    docs = ["doc_one", "doc_two"]
    embeddings = np.array([[1, 2, 3],
                           [2, 3, 4]])

# Path: bertopic/_utils.py
# def check_documents_type(documents):
#     """ Check whether the input documents are indeed a list of strings """
#     if isinstance(documents, Iterable) and not isinstance(documents, str):
#         if not any([isinstance(doc, str) for doc in documents]):
#             raise TypeError("Make sure that the iterable only contains strings.")
# 
#     else:
#         raise TypeError("Make sure that the documents variable is an iterable containing strings only.")
# 
# def check_embeddings_shape(embeddings, docs):
#     """ Check if the embeddings have the correct shape """
#     if embeddings is not None:
#         if not any([isinstance(embeddings, np.ndarray), isinstance(embeddings, csr_matrix)]):
#             raise ValueError("Make sure to input embeddings as a numpy array or scipy.sparse.csr.csr_matrix. ")
#         else:
#             if embeddings.shape[0] != len(docs):
#                 raise ValueError("Make sure that the embeddings are a numpy array with shape: "
#                                  "(len(docs), vector_dim) where vector_dim is the dimensionality "
#                                  "of the vector embeddings. ")
# 
# class MyLogger:
#     def __init__(self, level):
#         self.logger = logging.getLogger('BERTopic')
#         self.set_level(level)
#         self._add_handler()
#         self.logger.propagate = False
# 
#     def info(self, message):
#         self.logger.info("{}".format(message))
# 
#     def set_level(self, level):
#         levels = ["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"]
#         if level in levels:
#             self.logger.setLevel(level)
# 
#     def _add_handler(self):
#         sh = logging.StreamHandler()
#         sh.setFormatter(logging.Formatter('%(asctime)s - %(name)s - %(message)s'))
#         self.logger.addHandler(sh)
# 
#         # Remove duplicate handlers
#         if len(self.logger.handlers) > 1:
#             self.logger.handlers = [self.logger.handlers[0]]


# Path: tests/test_utils.py
import pytest
import logging
import numpy as np
from bertopic._utils import check_documents_type, check_embeddings_shape, MyLogger

    logger = MyLogger("WARNING")
    assert isinstance(logger.logger, logging.Logger)
    assert logger.logger.level == 30


@pytest.mark.parametrize(
    "docs",
    [
        "A document not in an iterable",
        [None],
        5
    ],
)
def test_check_documents_type(docs):
    """ Making sure the checks for document type succeed """
    with pytest.raises(TypeError):
        check_documents_type(docs)


def test_check_embeddings_shape():
    """ Testing correct embeddings shape

    Checking for embeddings is typically done when custom embeddings
    are used instead of the default SentenceTransformer models. This means
    that the embeddings should have the correct shape, which is tested for
    in check_embeddings_shape.
    """
    docs = ["doc_one", "doc_two"]
    embeddings = np.array([[1, 2, 3],
                           [2, 3, 4]])

    check_embeddings_shape(embeddings, docs)