Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Miscellaneous improvements #69

Draft
wants to merge 34 commits into
base: main
Choose a base branch
from
Draft

Miscellaneous improvements #69

wants to merge 34 commits into from

Conversation

kmnhan
Copy link
Owner

@kmnhan kmnhan commented Nov 19, 2024

This should be the last PR prior to 3.1.0 release.

If numba 0.61 arrives soon, explicit python 3.13 support will also be incorporated here.

Copy link

codecov bot commented Nov 19, 2024

❌ 2 Tests Failed:

Tests completed Failed Passed Skipped
735 2 733 0
View the top 2 failed tests by shortest run time
tests.interactive.test_imagetool::test_itool_rotate
Stack Traces | 0.525s run time
qtbot = <pytestqt.qtbot.QtBot object at 0x7fd26d6f86e0>
accept_dialog = <class 'tests.conftest._DialogHandler'>

    #x1B[0m#x1B[94mdef#x1B[39;49;00m #x1B[92mtest_itool_rotate#x1B[39;49;00m(qtbot, accept_dialog):#x1B[90m#x1B[39;49;00m
        data = xr.DataArray(np.arange(#x1B[94m25#x1B[39;49;00m).reshape((#x1B[94m5#x1B[39;49;00m, #x1B[94m5#x1B[39;49;00m)).astype(#x1B[96mfloat#x1B[39;49;00m), dims=[#x1B[33m"#x1B[39;49;00m#x1B[33mx#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m, #x1B[33m"#x1B[39;49;00m#x1B[33my#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m])#x1B[90m#x1B[39;49;00m
        win = itool(data, execute=#x1B[94mFalse#x1B[39;49;00m)#x1B[90m#x1B[39;49;00m
        qtbot.addWidget(win)#x1B[90m#x1B[39;49;00m
    #x1B[90m#x1B[39;49;00m
        #x1B[90m# Test dialog#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
        #x1B[94mdef#x1B[39;49;00m #x1B[92m_set_dialog_params#x1B[39;49;00m(dialog: RotationDialog) -> #x1B[94mNone#x1B[39;49;00m:#x1B[90m#x1B[39;49;00m
            dialog.angle_spin.setValue(#x1B[94m60.0#x1B[39;49;00m)#x1B[90m#x1B[39;49;00m
            dialog.reshape_check.setChecked(#x1B[94mTrue#x1B[39;49;00m)#x1B[90m#x1B[39;49;00m
            dialog.new_window_check.setChecked(#x1B[94mFalse#x1B[39;49;00m)#x1B[90m#x1B[39;49;00m
    #x1B[90m#x1B[39;49;00m
        accept_dialog(win.mnb._rotate, pre_call=_set_dialog_params)#x1B[90m#x1B[39;49;00m
    #x1B[90m#x1B[39;49;00m
        #x1B[90m# Check if the data is rotated#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
        xarray.testing.assert_allclose(#x1B[90m#x1B[39;49;00m
            win.slicer_area._data,#x1B[90m#x1B[39;49;00m
            erlab.analysis.transform.rotate(data, angle=#x1B[94m60.0#x1B[39;49;00m, reshape=#x1B[94mTrue#x1B[39;49;00m),#x1B[90m#x1B[39;49;00m
        )#x1B[90m#x1B[39;49;00m
    #x1B[90m#x1B[39;49;00m
        #x1B[90m# Test guidelines#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
        win.slicer_area.set_data(data)#x1B[90m#x1B[39;49;00m
        win.slicer_area.main_image.set_guidelines(#x1B[94m3#x1B[39;49;00m)#x1B[90m#x1B[39;49;00m
        #x1B[94massert#x1B[39;49;00m win.slicer_area.main_image.is_guidelines_visible#x1B[90m#x1B[39;49;00m
    #x1B[90m#x1B[39;49;00m
        win.slicer_area.main_image._guidelines_items[#x1B[94m0#x1B[39;49;00m].setAngle(#x1B[94m90.0#x1B[39;49;00m - #x1B[94m30.0#x1B[39;49;00m)#x1B[90m#x1B[39;49;00m
        win.slicer_area.main_image._guidelines_items[-#x1B[94m1#x1B[39;49;00m].setPos((#x1B[94m3.0#x1B[39;49;00m, #x1B[94m3.1#x1B[39;49;00m))#x1B[90m#x1B[39;49;00m
    #x1B[90m#x1B[39;49;00m
        #x1B[94mdef#x1B[39;49;00m #x1B[92m_set_dialog_params#x1B[39;49;00m(dialog: RotationDialog) -> #x1B[94mNone#x1B[39;49;00m:#x1B[90m#x1B[39;49;00m
            #x1B[94massert#x1B[39;49;00m dialog.angle_spin.value() == #x1B[94m30.0#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
            #x1B[94massert#x1B[39;49;00m dialog.center_spins[#x1B[94m0#x1B[39;49;00m].value() == #x1B[94m3.0#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
            #x1B[94massert#x1B[39;49;00m dialog.center_spins[#x1B[94m1#x1B[39;49;00m].value() == #x1B[94m3.1#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
            dialog.copy_button.click()#x1B[90m#x1B[39;49;00m
            dialog.reshape_check.setChecked(#x1B[94mTrue#x1B[39;49;00m)#x1B[90m#x1B[39;49;00m
            dialog.new_window_check.setChecked(#x1B[94mFalse#x1B[39;49;00m)#x1B[90m#x1B[39;49;00m
    #x1B[90m#x1B[39;49;00m
        accept_dialog(win.mnb._rotate, pre_call=_set_dialog_params)#x1B[90m#x1B[39;49;00m
    #x1B[90m#x1B[39;49;00m
        #x1B[90m# Check if the data is rotated#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
        xarray.testing.assert_allclose(#x1B[90m#x1B[39;49;00m
            win.slicer_area._data,#x1B[90m#x1B[39;49;00m
            erlab.analysis.transform.rotate(#x1B[90m#x1B[39;49;00m
                data, angle=#x1B[94m30.0#x1B[39;49;00m, center=(#x1B[94m3.0#x1B[39;49;00m, #x1B[94m3.1#x1B[39;49;00m), reshape=#x1B[94mTrue#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
            ),#x1B[90m#x1B[39;49;00m
        )#x1B[90m#x1B[39;49;00m
    #x1B[90m#x1B[39;49;00m
        #x1B[90m# Test copy button#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
        #x1B[94massert#x1B[39;49;00m pyperclip.paste().startswith(#x1B[33m"#x1B[39;49;00m#x1B[33mera.transform.rotate#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m)#x1B[90m#x1B[39;49;00m
    #x1B[90m#x1B[39;49;00m
        #x1B[90m# Transpose should remove guidelines#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
        qtbot.keyClick(win, QtCore.Qt.Key.Key_T)#x1B[90m#x1B[39;49;00m
>       #x1B[94massert#x1B[39;49;00m #x1B[95mnot#x1B[39;49;00m win.slicer_area.main_image.is_guidelines_visible#x1B[90m#x1B[39;49;00m
#x1B[1m#x1B[31mE       assert not True#x1B[0m
#x1B[1m#x1B[31mE        +  where True = <erlab.interactive.imagetool.core.ItoolPlotItem object at 0x7fd2385cd4f0>.is_guidelines_visible#x1B[0m
#x1B[1m#x1B[31mE        +    where <erlab.interactive.imagetool.core.ItoolPlotItem object at 0x7fd2385cd4f0> = <erlab.interactive.imagetool.core.ImageSlicerArea object at 0x7fd23889de50>.main_image#x1B[0m
#x1B[1m#x1B[31mE        +      where <erlab.interactive.imagetool.core.ImageSlicerArea object at 0x7fd23889de50> = <erlab.interactive.imagetool.ImageTool object at 0x7fd23889def0>.slicer_area#x1B[0m

#x1B[1m#x1B[31mtests/interactive/test_imagetool.py#x1B[0m:426: AssertionError
tests.interactive.test_imagetool::test_itool_load
Stack Traces | 0.881s run time
qtbot = <pytestqt.qtbot.QtBot object at 0x7fd24012ecf0>
move_and_compare_values = <function _move_and_compare_values at 0x7fd26fae9800>
accept_dialog = <class 'tests.conftest._DialogHandler'>

    #x1B[0m#x1B[94mdef#x1B[39;49;00m #x1B[92mtest_itool_load#x1B[39;49;00m(qtbot, move_and_compare_values, accept_dialog):#x1B[90m#x1B[39;49;00m
        data = xr.DataArray(#x1B[90m#x1B[39;49;00m
            np.arange(#x1B[94m25#x1B[39;49;00m).reshape((#x1B[94m5#x1B[39;49;00m, #x1B[94m5#x1B[39;49;00m)),#x1B[90m#x1B[39;49;00m
            dims=[#x1B[33m"#x1B[39;49;00m#x1B[33mx#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m, #x1B[33m"#x1B[39;49;00m#x1B[33my#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m],#x1B[90m#x1B[39;49;00m
            coords={#x1B[33m"#x1B[39;49;00m#x1B[33mx#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m: np.arange(#x1B[94m5#x1B[39;49;00m), #x1B[33m"#x1B[39;49;00m#x1B[33my#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m: np.arange(#x1B[94m5#x1B[39;49;00m)},#x1B[90m#x1B[39;49;00m
        )#x1B[90m#x1B[39;49;00m
    #x1B[90m#x1B[39;49;00m
        win = itool(np.zeros((#x1B[94m2#x1B[39;49;00m, #x1B[94m2#x1B[39;49;00m)), execute=#x1B[94mFalse#x1B[39;49;00m)#x1B[90m#x1B[39;49;00m
        qtbot.addWidget(win)#x1B[90m#x1B[39;49;00m
        #x1B[94mwith#x1B[39;49;00m qtbot.waitExposed(win):#x1B[90m#x1B[39;49;00m
            win.show()#x1B[90m#x1B[39;49;00m
            win.activateWindow()#x1B[90m#x1B[39;49;00m
    #x1B[90m#x1B[39;49;00m
        tmp_dir = tempfile.TemporaryDirectory()#x1B[90m#x1B[39;49;00m
        filename = #x1B[33mf#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m#x1B[33m{#x1B[39;49;00mtmp_dir.name#x1B[33m}#x1B[39;49;00m#x1B[33m/data.h5#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m#x1B[90m#x1B[39;49;00m
        data.to_netcdf(filename, engine=#x1B[33m"#x1B[39;49;00m#x1B[33mh5netcdf#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m)#x1B[90m#x1B[39;49;00m
    #x1B[90m#x1B[39;49;00m
        #x1B[94mdef#x1B[39;49;00m #x1B[92m_go_to_file#x1B[39;49;00m(dialog: QtWidgets.QFileDialog):#x1B[90m#x1B[39;49;00m
            dialog.setDirectory(tmp_dir.name)#x1B[90m#x1B[39;49;00m
            dialog.selectFile(filename)#x1B[90m#x1B[39;49;00m
            focused = dialog.focusWidget()#x1B[90m#x1B[39;49;00m
            #x1B[94mif#x1B[39;49;00m #x1B[96misinstance#x1B[39;49;00m(focused, QtWidgets.QLineEdit):#x1B[90m#x1B[39;49;00m
                focused.setText(#x1B[33m"#x1B[39;49;00m#x1B[33mdata.h5#x1B[39;49;00m#x1B[33m"#x1B[39;49;00m)#x1B[90m#x1B[39;49;00m
    #x1B[90m#x1B[39;49;00m
        accept_dialog(#x1B[94mlambda#x1B[39;49;00m: win._open_file(native=#x1B[94mFalse#x1B[39;49;00m), pre_call=_go_to_file)#x1B[90m#x1B[39;49;00m
>       move_and_compare_values(qtbot, win, [#x1B[94m12.0#x1B[39;49;00m, #x1B[94m7.0#x1B[39;49;00m, #x1B[94m6.0#x1B[39;49;00m, #x1B[94m11.0#x1B[39;49;00m])#x1B[90m#x1B[39;49;00m

#x1B[1m#x1B[31mtests/interactive/test_imagetool.py#x1B[0m:73: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
#x1B[1m#x1B[31mtests/conftest.py#x1B[0m:272: in _move_and_compare_values
    #x1B[0massert_almost_equal(win.array_slicer.point_value(cursor), expected[#x1B[94m1#x1B[39;49;00m])#x1B[90m#x1B[39;49;00m
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

args = (np.float64(12.0), 7.0), kwds = {}

    #x1B[0m#x1B[37m@wraps#x1B[39;49;00m(func)#x1B[90m#x1B[39;49;00m
    #x1B[94mdef#x1B[39;49;00m #x1B[92minner#x1B[39;49;00m(*args, **kwds):#x1B[90m#x1B[39;49;00m
        #x1B[94mwith#x1B[39;49;00m #x1B[96mself#x1B[39;49;00m._recreate_cm():#x1B[90m#x1B[39;49;00m
>           #x1B[94mreturn#x1B[39;49;00m func(*args, **kwds)#x1B[90m#x1B[39;49;00m
#x1B[1m#x1B[31mE           AssertionError: #x1B[0m
#x1B[1m#x1B[31mE           Arrays are not almost equal to 7 decimals#x1B[0m
#x1B[1m#x1B[31mE            ACTUAL: np.float64(12.0)#x1B[0m
#x1B[1m#x1B[31mE            DESIRED: 7.0#x1B[0m

#x1B[1m#x1B[.../hostedtoolcache/Python/3.12.7.../x64/lib/python3.12/contextlib.py#x1B[0m:81: AssertionError

To view more test analytics, go to the Test Analytics Dashboard
Got feedback? Let us know on Github

Accelerates initial import time by refactoring heavy imports to reside inside functions.

Importing the plotting module no longer automatically imports the colormap packages `cmocean`, `cmasher`, and `colorcet`. The user must add manual import statements.
…space

Enables users to save multiple ImageTool windows to a single file using the manager.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant