<commit_before>"""
Defined callback functions of mouse event
"""
import logging
import sys

import numpy as np

sys.path.append('../')
from support.profiling import func_profiling
from support.tkconvert import TkConverter

LOGGER = logging.getLogger(__name__)

@func_profiling
def draw_symmetric_line_by_cv2(e, widget=None, image=None, color='255'):
    if widget is None:
        LOGGER.error('No widget has been selected.')
    elif image is None:
        LOGGER.error('No image has been selected.')
        return None
    elif not isinstance(image, np.ndarray):
        LOGGER.error('Image {} is not in np.ndarray format.'.format(type(image)))
        return None
    else:
        # draw the line by OpenCV
        h, w, channels = image.shape
        cv2.line(image, (e.x, 0), (e.x, h), color, 2)

        # update the image to widget
        photo = TkConverter.ndarray_to_photo(image)
        widget.configure(image=photo)<commit_msg>modified: mouse event as handler class<commit_after>"""
Defined callback functions of mouse event
"""
import logging
import sys

import numpy as np

sys.path.append('../')
from src.view.template import MothViewerTemplate
from src.support.profiling import func_profiling
from src.support.tkconvert import TkConverter

LOGGER = logging.getLogger(__name__)

class MothMouseHandler(MothViewerTemplate):
    def __init__(self):
        super().__init__()

# @func_profiling
# def draw_symmetric_line_by_cv2(e, widget=None, image=None, color='255'):
#     if widget is None:
#         LOGGER.error('No widget has been selected.')
#     elif image is None:
#         LOGGER.error('No image has been selected.')
#         return None
#     elif not isinstance(image, np.ndarray):
#         LOGGER.error('Image {} is not in np.ndarray format.'.format(type(image)))
#         return None
#     else:
#         # draw the line by OpenCV
#         h, w, channels = image.shape
#         cv2.line(image, (e.x, 0), (e.x, h), color, 2)

#         # update the image to widget
#         photo = TkConverter.ndarray_to_photo(image)
#         widget.configure(image=photo)
{'fraction_non_alphanumeric': 0.11020992366412213, 'fraction_numerical': 0.006679389312977099, 'mean_word_length': 3.1607142857142856, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7446547', 'n_tokens_mistral': 653, 'n_tokens_neox': 642, 'n_words': 191}