Giter Site home page Giter Site logo

Comments (8)

apgorton avatar apgorton commented on July 22, 2024 1

The output is rather long. Here is the output up to the first assert error when run with pytest -vv

============================= test session starts =============================
platform win32 -- Python 3.11.3, pytest-7.1.3, pluggy-1.0.0 -- puterbot\.venv\Scripts\python.exe
cachedir: .pytest_cache
rootdir: puterbot
collecting ... collected 7 items

tests/puterbot/test_events.py::test_merge_consecutive_mouse_click_events FAILED [ 14%]
tests/puterbot/test_events.py::test_merge_consecutive_mouse_move_events FAILED [ 28%]
tests/puterbot/test_events.py::test_merge_consecutive_mouse_scroll_events FAILED [ 42%]
tests/puterbot/test_events.py::test_remove_redundant_mouse_move_events FAILED [ 57%]
tests/puterbot/test_events.py::test_merge_consecutive_keyboard_events FAILED [ 71%]
tests/puterbot/test_events.py::test_merge_consecutive_keyboard_events__grouped FAILED [ 85%]
tests/puterbot/test_events.py::test_discard_unused_events PASSED         [100%]

================================== FAILURES ===================================
__________________ test_merge_consecutive_mouse_click_events __________________

    def test_merge_consecutive_mouse_click_events():
        if OVERRIDE_DOUBLE_CLICK_INTERVAL_SECONDS:
            override_double_click_interval_seconds(
                OVERRIDE_DOUBLE_CLICK_INTERVAL_SECONDS
            )
        double_click_interval_seconds = get_double_click_interval_seconds()
        dt_short = double_click_interval_seconds / 10
        dt_long = double_click_interval_seconds * 10
        raw_events = [
            *make_click_events(dt_long, button_name="right"),
    
            # doubleclick
            *make_click_events(dt_short),
            *make_click_events(dt_long),
    
            # doubleclick
            *make_click_events(dt_short),
            *make_click_events(dt_long),
    
            *make_click_events(dt_long, button_name="right"),
    
            # singleclick
            *make_click_events(dt_long),
        ]
        logger.info(f"raw_events=\n{pformat(rows2dicts(raw_events))}")
        reset_timestamp()
        expected_events = rows2dicts([
            *make_click_events(dt_long, button_name="right"),
            make_doubleclick_event(
                dt_long,
                lambda: [
                    *make_click_events(dt_short),
                    *make_click_events(dt_long),
                ],
            ),
            make_doubleclick_event(
                dt_long,
                lambda: [
                    *make_click_events(dt_short),
                    *make_click_events(dt_long),
                ],
            ),
            *make_click_events(dt_long, button_name="right"),
            make_singleclick_event(
                dt_long,
                lambda: [
                    *make_click_events(dt_long),
                ]
            ),
        ])
        logger.info(f"expected_events=\n{pformat(expected_events)}")
        actual_events = rows2dicts(
            merge_consecutive_mouse_click_events(raw_events)
        )
        logger.info(f"actual_events=\n{pformat(actual_events)}")
>       assert expected_events == actual_events
E       AssertionError: assert [{'mouse_button_name': 'right',\n  'mouse_pressed': True,\n  'name': 'click',\n  'timestamp': 0.0},\n {'mouse_button_name': 'right',\n  'mouse_pressed': False,\n  'name': 'click',\n  'timestamp': 0.275},\n {'children': [{'mouse_pressed': True, 'timestamp': 5.775},\n               {'mouse_pressed': False, 'timestamp': 6.050000000000001},\n               {'mouse_pressed': True, 'timestamp': 6.105},\n               {'mouse_pressed': False, 'timestamp': 6.380000000000001}],\n  'mouse_button_name': 'left',\n  'name': 'doubleclick',\n  'timestamp': 5.775},\n {'children': [{'mouse_pressed': True, 'timestamp': 11.880000000000003},\n               {'mouse_pressed': False, 'timestamp': 12.155000000000003},\n               {'mouse_pressed': True, 'timestamp': 12.210000000000003},\n               {'mouse_pressed': False, 'timestamp': 12.485000000000003}],\n  'mouse_button_name': 'left',\n  'name': 'doubleclick',\n  'timestamp': 11.275},\n {'mouse_button_name': 'right',\n  'mouse_pressed': True,\n  'name': 'click',\n  'timestamp': 16.775},\n {'mouse_button_name': 'right',\n  'mouse_pressed': False,\n  'name': 'click',\n  'timestamp': 17.049999999999997},\n {'children': [{'mouse_pressed': True, 'timestamp': 23.76},\n               {'mouse_pressed': False, 'timestamp': 24.035}],\n  'mouse_button_name': 'left',\n  'name': 'singleclick',\n  'timestamp': 22.549999999999997}] == [{'mouse_button_name': 'right',\n  'mouse_pressed': True,\n  'name': 'click',\n  'timestamp': 0.0},\n {'mouse_button_name': 'right',\n  'mouse_pressed': False,\n  'name': 'click',\n  'timestamp': 0.275},\n {'children': [{'mouse_pressed': True, 'timestamp': 5.775},\n               {'mouse_pressed': False, 'timestamp': 6.050000000000001},\n               {'mouse_pressed': True, 'timestamp': 6.105},\n               {'mouse_pressed': False, 'timestamp': 6.380000000000001}],\n  'mouse_button_name': 'left',\n  'name': 'doubleclick',\n  'timestamp': 5.775},\n {'children': [{'mouse_pressed': True, 'timestamp': 11.88},\n               {'mouse_pressed': False, 'timestamp': 12.155000000000001},\n               {'mouse_pressed': True, 'timestamp': 12.21},\n               {'mouse_pressed': False, 'timestamp': 12.485000000000001}],\n  'mouse_button_name': 'left',\n  'name': 'doubleclick',\n  'timestamp': 11.275},\n {'mouse_button_name': 'right',\n  'mouse_pressed': True,\n  'name': 'click',\n  'timestamp': 16.775},\n {'mouse_button_name': 'right',\n  'mouse_pressed': False,\n  'name': 'click',\n  'timestamp': 17.049999999999997},\n {'children': [{'mouse_pressed': True, 'timestamp': 23.759999999999998},\n               {'mouse_pressed': False, 'timestamp': 24.034999999999997}],\n  'mouse_button_name': 'left',\n  'name': 'singleclick',\n  'timestamp': 22.549999999999997}]
E         At index 3 diff: {'name': 'doubleclick', 'timestamp': 11.275, 'mouse_button_name': 'left', 'children': [{'timestamp': 11.880000000000003, 'mouse_pressed': True}, {'timestamp': 12.155000000000003, 'mouse_pressed': False}, {'timestamp': 12.210000000000003, 'mouse_pressed': True}, {'timestamp': 12.485000000000003, 'mouse_pressed': False}]} != {'name': 'doubleclick', 'timestamp': 11.275, 'mouse_button_name': 'left', 'children': [{'timestamp': 11.88, 'mouse_pressed': True}, {'timestamp': 12.155000000000001, 'mouse_pressed': False}, {'timestamp': 12.21, 'mouse_pressed': True}, {'timestamp': 12.485000000000001, 'mouse_pressed': False}]}
E         Full diff:
E           [
E            {'mouse_button_name': 'right',
E             'mouse_pressed': True,
E             'name': 'click',
E             'timestamp': 0.0},
E            {'mouse_button_name': 'right',
E             'mouse_pressed': False,
E             'name': 'click',
E             'timestamp': 0.275},
E            {'children': [{'mouse_pressed': True, 'timestamp': 5.775},
E                          {'mouse_pressed': False, 'timestamp': 6.050000000000001},
E                          {'mouse_pressed': True, 'timestamp': 6.105},
E                          {'mouse_pressed': False, 'timestamp': 6.380000000000001}],
E             'mouse_button_name': 'left',
E             'name': 'doubleclick',
E             'timestamp': 5.775},
E         -  {'children': [{'mouse_pressed': True, 'timestamp': 11.88},
E         +  {'children': [{'mouse_pressed': True, 'timestamp': 11.880000000000003},
E         ?                                                          +++++++++++++
E         -                {'mouse_pressed': False, 'timestamp': 12.155000000000001},
E         ?                                                                       ^
E         +                {'mouse_pressed': False, 'timestamp': 12.155000000000003},
E         ?                                                                       ^
E         -                {'mouse_pressed': True, 'timestamp': 12.21},
E         +                {'mouse_pressed': True, 'timestamp': 12.210000000000003},
E         ?                                                          +++++++++++++
E         -                {'mouse_pressed': False, 'timestamp': 12.485000000000001}],
E         ?                                                                       ^
E         +                {'mouse_pressed': False, 'timestamp': 12.485000000000003}],
E         ?                                                                       ^
E             'mouse_button_name': 'left',
E             'name': 'doubleclick',
E             'timestamp': 11.275},
E            {'mouse_button_name': 'right',
E             'mouse_pressed': True,
E             'name': 'click',
E             'timestamp': 16.775},
E            {'mouse_button_name': 'right',
E             'mouse_pressed': False,
E             'name': 'click',
E             'timestamp': 17.049999999999997},
E         -  {'children': [{'mouse_pressed': True, 'timestamp': 23.759999999999998},
E         ?                                                         ^^^^^^^^^^^^^^
E         +  {'children': [{'mouse_pressed': True, 'timestamp': 23.76},
E         ?                                                         ^
E         -                {'mouse_pressed': False, 'timestamp': 24.034999999999997}],
E         ?                                                           ^^^^^^^^^^^^^
E         +                {'mouse_pressed': False, 'timestamp': 24.035}],
E         ?                                                           ^
E             'mouse_button_name': 'left',
E             'name': 'singleclick',
E             'timestamp': 22.549999999999997},
E           ]

tests\puterbot\test_events.py:255: AssertionError
---------------------------- Captured stderr call -----------------------------

Failing tests:

=========================== short test summary info ===========================
FAILED tests/puterbot/test_events.py::test_merge_consecutive_mouse_click_events
FAILED tests/puterbot/test_events.py::test_merge_consecutive_mouse_move_events
FAILED tests/puterbot/test_events.py::test_merge_consecutive_mouse_scroll_events
FAILED tests/puterbot/test_events.py::test_remove_redundant_mouse_move_events
FAILED tests/puterbot/test_events.py::test_merge_consecutive_keyboard_events
FAILED tests/puterbot/test_events.py::test_merge_consecutive_keyboard_events__grouped
========================= 6 failed, 1 passed in 1.05s =========================

from openadapt.

abrichr avatar abrichr commented on July 22, 2024 1

@apgorton please try #20 🙏

from openadapt.

apgorton avatar apgorton commented on July 22, 2024 1

The tests now pass with it.

from openadapt.

abrichr avatar abrichr commented on July 22, 2024

Thanks @apgorton ! Can you please include the complete output so that we can see which tests are failing?

As a workaround try setting OVERRIDE_DOUBLE_CLICK_INTERVAL_SECONDS = 10 in https://github.com/MLDSAI/puterbot/blob/main/tests/puterbot/test_events.py#L30

from openadapt.

apgorton avatar apgorton commented on July 22, 2024

Thanks @apgorton ! Can you please include the complete output so that we can see which tests are failing?

As a workaround try setting OVERRIDE_DOUBLE_CLICK_INTERVAL_SECONDS = 10 in https://github.com/MLDSAI/puterbot/blob/main/tests/puterbot/test_events.py#L30

I tried this, same result.

from openadapt.

abrichr avatar abrichr commented on July 22, 2024

Can you please clarify what you mean by "same result"? i.e. do you mean just that the tests are still failing, or that the log output is exactly the same?

Can you please set OVERRIDE_DOUBLE_CLICK_INTERVAL_SECONDS = 10, run pytest, and paste the results here?

from openadapt.

apgorton avatar apgorton commented on July 22, 2024

The timestamps are larger but the failure is the same. The difference between the timestamps being compared is roughly the same.

>       assert expected_events == actual_events
E       AssertionError: assert [{'mouse_button_name': 'right',\n  'mouse_pressed': True,\n  'name': 'click',\n  'timestamp': 0.0},\n {'mouse_button_name': 'right',\n  'mouse_pressed': False,\n  'name': 'click',\n  'timestamp': 0.275},\n {'children': [{'mouse_pressed': True, 'timestamp': 100.275},\n               {'mouse_pressed': False, 'timestamp': 100.55000000000001},\n               {'mouse_pressed': True, 'timestamp': 101.55000000000001},\n               {'mouse_pressed': False, 'timestamp': 101.82500000000002}],\n  'mouse_button_name': 'left',\n  'name': 'doubleclick',\n  'timestamp': 100.275},\n {'children': [{'mouse_pressed': True, 'timestamp': 201.82500000000005},\n               {'mouse_pressed': False, 'timestamp': 202.10000000000005},\n               {'mouse_pressed': True, 'timestamp': 203.10000000000005},\n               {'mouse_pressed': False, 'timestamp': 203.37500000000006}],\n  'mouse_button_name': 'left',\n  'name': 'doubleclick',\n  'timestamp': 200.275},\n {'mouse_button_name': 'right',\n  'mouse_pressed': True,\n  'name': 'click',\n  'timestamp': 300.275},\n {'mouse_button_name': 'right',\n  'mouse_pressed': False,\n  'name': 'click',\n  'timestamp': 300.54999999999995},\n {'children': [{'mouse_pressed': True, 'timestamp': 403.65000000000003},\n               {'mouse_pressed': False, 'timestamp': 403.925}],\n  'mouse_button_name': 'left',\n  'name': 'singleclick',\n  'timestamp': 400.54999999999995}] == [{'mouse_button_name': 'right',\n  'mouse_pressed': True,\n  'name': 'click',\n  'timestamp': 0.0},\n {'mouse_button_name': 'right',\n  'mouse_pressed': False,\n  'name': 'click',\n  'timestamp': 0.275},\n {'children': [{'mouse_pressed': True, 'timestamp': 100.275},\n               {'mouse_pressed': False, 'timestamp': 100.55000000000001},\n               {'mouse_pressed': True, 'timestamp': 101.55000000000001},\n               {'mouse_pressed': False, 'timestamp': 101.82500000000002}],\n  'mouse_button_name': 'left',\n  'name': 'doubleclick',\n  'timestamp': 100.275},\n {'children': [{'mouse_pressed': True, 'timestamp': 201.82500000000002},\n               {'mouse_pressed': False, 'timestamp': 202.10000000000002},\n               {'mouse_pressed': True, 'timestamp': 203.10000000000002},\n               {'mouse_pressed': False, 'timestamp': 203.37500000000003}],\n  'mouse_button_name': 'left',\n  'name': 'doubleclick',\n  'timestamp': 200.275},\n {'mouse_button_name': 'right',\n  'mouse_pressed': True,\n  'name': 'click',\n  'timestamp': 300.275},\n {'mouse_button_name': 'right',\n  'mouse_pressed': False,\n  'name': 'click',\n  'timestamp': 300.54999999999995},\n {'children': [{'mouse_pressed': True, 'timestamp': 403.65},\n               {'mouse_pressed': False, 'timestamp': 403.92499999999995}],\n  'mouse_button_name': 'left',\n  'name': 'singleclick',\n  'timestamp': 400.54999999999995}]
E         At index 3 diff: {'name': 'doubleclick', 'timestamp': 200.275, 'mouse_button_name': 'left', 'children': [{'timestamp': 201.82500000000005, 'mouse_pressed': True}, {'timestamp': 202.10000000000005, 'mouse_pressed': False}, {'timestamp': 203.10000000000005, 'mouse_pressed': True}, {'timestamp': 203.37500000000006, 'mouse_pressed': False}]} != {'name': 'doubleclick', 'timestamp': 200.275, 'mouse_button_name': 'left', 'children': [{'timestamp': 201.82500000000002, 'mouse_pressed': True}, {'timestamp': 202.10000000000002, 'mouse_pressed': False}, {'timestamp': 203.10000000000002, 'mouse_pressed': True}, {'timestamp': 203.37500000000003, 'mouse_pressed': False}]}
E         Full diff:
E           [
E            {'mouse_button_name': 'right',
E             'mouse_pressed': True,
E             'name': 'click',
E             'timestamp': 0.0},
E            {'mouse_button_name': 'right',
E             'mouse_pressed': False,
E             'name': 'click',
E             'timestamp': 0.275},
E            {'children': [{'mouse_pressed': True, 'timestamp': 100.275},
E                          {'mouse_pressed': False, 'timestamp': 100.55000000000001},
E                          {'mouse_pressed': True, 'timestamp': 101.55000000000001},
E                          {'mouse_pressed': False, 'timestamp': 101.82500000000002}],
E             'mouse_button_name': 'left',
E             'name': 'doubleclick',
E             'timestamp': 100.275},
E         -  {'children': [{'mouse_pressed': True, 'timestamp': 201.82500000000002},
E         ?                                                                      ^
E         +  {'children': [{'mouse_pressed': True, 'timestamp': 201.82500000000005},
E         ?                                                                      ^
E         -                {'mouse_pressed': False, 'timestamp': 202.10000000000002},
E         ?                                                                       ^
E         +                {'mouse_pressed': False, 'timestamp': 202.10000000000005},
E         ?                                                                       ^
E         -                {'mouse_pressed': True, 'timestamp': 203.10000000000002},
E         ?                                                                      ^
E         +                {'mouse_pressed': True, 'timestamp': 203.10000000000005},
E         ?                                                                      ^
E         -                {'mouse_pressed': False, 'timestamp': 203.37500000000003}],
E         ?                                                                       ^
E         +                {'mouse_pressed': False, 'timestamp': 203.37500000000006}],
E         ?                                                                       ^
E             'mouse_button_name': 'left',
E             'name': 'doubleclick',
E             'timestamp': 200.275},
E            {'mouse_button_name': 'right',
E             'mouse_pressed': True,
E             'name': 'click',
E             'timestamp': 300.275},
E            {'mouse_button_name': 'right',
E             'mouse_pressed': False,
E             'name': 'click',
E             'timestamp': 300.54999999999995},
E         -  {'children': [{'mouse_pressed': True, 'timestamp': 403.65},
E         +  {'children': [{'mouse_pressed': True, 'timestamp': 403.65000000000003},
E         ?                                                           ++++++++++++
E         -                {'mouse_pressed': False, 'timestamp': 403.92499999999995}],
E         ?                                                            -----------
E         +                {'mouse_pressed': False, 'timestamp': 403.925}],
E             'mouse_button_name': 'left',
E             'name': 'singleclick',
E             'timestamp': 400.54999999999995},
E           ]

from openadapt.

abrichr avatar abrichr commented on July 22, 2024

Thank you! Looks like a floating point issue. Easiest fix is just to truncate timestamps to e.g. 6 decimal places.

e.g. implement a function truncate_timestamp(events), then modify all the tests in test_events.py to process expected_events and actual_events with it.

from openadapt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.