GitHub Issue: Custom Signal Creation Bug
Title
AttributeError when creating custom signal from menu
Labels
Description
Bug Report
Summary:
Creating a custom signal from the "Create" menu triggers an immediate AttributeError: 'NoneType' object has no attribute 'T'.
Steps to Reproduce:
- Launch DataLab
- Go to Signal panel
- Click "Create" menu → "Custom"
- The error occurs immediately
Expected Behavior:
- A dialog should appear asking for signal parameters (size, xmin, xmax)
- After confirmation, a curve editor should open
- User can edit the curve points interactively
- A custom signal is created successfully
Actual Behavior:
Application crashes with:
AttributeError: 'NoneType' object has no attribute 'T'
Root Cause:
When creating a custom signal from the menu, new_object() is called with edit=False (the default). This caused the setup_array() call to be skipped, leaving xyarray as None. Later, the code tried to access param.xyarray.T which failed.
Environment:
- DataLab version: 1.0.1
- Python version: [any]
- OS: Windows/Linux/macOS
Solution Implemented
Fix
Added a check in datalab/gui/newobject.py (lines 125-128) to force edit=True for CustomSignalParam instances, ensuring the user dialogs are always shown and the array is properly initialized.
# CustomSignalParam requires edit mode to initialize the xyarray.
# Without this, if edit=False (the default in new_object), the setup_array
# call would be skipped, leaving xyarray as None, which would cause an
# AttributeError when trying to access param.xyarray.T later.
if isinstance(param, OrigCustomSignalParam):
edit = True
Testing
Created comprehensive unit tests in datalab/tests/features/signal/custom_signal_bug_unit_test.py:
- Test
CustomSignalParam initialization
- Test
setup_array() functionality
- Test
generate_1d_data() behavior
- Test the bug fix prevents the AttributeError
All tests pass (4/4), and all existing tests continue to pass.
Files Changed
datalab/gui/newobject.py - Added fix to force edit mode for custom signals
datalab/tests/features/signal/custom_signal_bug_unit_test.py - New test file
CHANGELOG.md - Documented the bug fix
Verification
To verify the fix works:
- Launch DataLab with the fix applied
- Go to Signal panel
- Click "Create" menu → "Custom"
- First dialog appears asking for size, xmin, xmax
- After confirmation, second dialog with curve editor appears
- Edit the curve if desired
- Confirm to create the custom signal
- Custom signal is created successfully
GitHub Issue: Custom Signal Creation Bug
Title
AttributeErrorwhen creating custom signal from menuLabels
Description
Bug Report
Summary:
Creating a custom signal from the "Create" menu triggers an immediate
AttributeError: 'NoneType' object has no attribute 'T'.Steps to Reproduce:
Expected Behavior:
Actual Behavior:
Application crashes with:
Root Cause:
When creating a custom signal from the menu,
new_object()is called withedit=False(the default). This caused thesetup_array()call to be skipped, leavingxyarrayasNone. Later, the code tried to accessparam.xyarray.Twhich failed.Environment:
Solution Implemented
Fix
Added a check in
datalab/gui/newobject.py(lines 125-128) to forceedit=TrueforCustomSignalParaminstances, ensuring the user dialogs are always shown and the array is properly initialized.Testing
Created comprehensive unit tests in
datalab/tests/features/signal/custom_signal_bug_unit_test.py:CustomSignalParaminitializationsetup_array()functionalitygenerate_1d_data()behaviorAll tests pass (4/4), and all existing tests continue to pass.
Files Changed
datalab/gui/newobject.py- Added fix to force edit mode for custom signalsdatalab/tests/features/signal/custom_signal_bug_unit_test.py- New test fileCHANGELOG.md- Documented the bug fixVerification
To verify the fix works: