Skip to content

Enhance testing for creating parameters from saved states#2319

Merged
j9ac9k merged 4 commits intopyqtgraph:masterfrom
ntjess:fix-checklist-state
Sep 14, 2022
Merged

Enhance testing for creating parameters from saved states#2319
j9ac9k merged 4 commits intopyqtgraph:masterfrom
ntjess:fix-checklist-state

Conversation

@ntjess
Copy link
Copy Markdown
Contributor

@ntjess ntjess commented May 31, 2022

Before this PR, parameters like e.g. checklist would save states that couldn't reproduce their parameter layout. Fix this for the specific fail types of checklist and calendar while ensuring all other parameter types can successfully recreate themselves.

During testing, a few other issues with checklists came up and were resolved, so the branch name is a bit of a misnomer now

  • exclusive checklists now propagate changing values correctly
  • Clear All, Select All, and default buttons now force changes even when there is a pending proxy signal

@ntjess ntjess marked this pull request as ready for review May 31, 2022 22:06
@ntjess ntjess marked this pull request as draft May 31, 2022 22:19
@ntjess ntjess force-pushed the fix-checklist-state branch from 3b7a8d3 to 7c21f05 Compare June 1, 2022 00:24
ntjess added 4 commits May 31, 2022 20:31
Revealed bug in Calendar item when no initial value was set, so that was changed too
- Previously, no code checked for proper conditions to enable the default button for a checklist. Note that this implementation still doesn't define behavior for comparing to default when changing exclusive from "false" to "true"
- When a button changes param to default, all, or none selected, make sure this isn't overridden by a pending proxy signal from child changes
When set to "exclusive", the comparison logic failed to set only one parameter to "True"!
@ntjess ntjess force-pushed the fix-checklist-state branch from 7c21f05 to 21fde92 Compare June 1, 2022 00:33
@ntjess ntjess marked this pull request as ready for review June 1, 2022 04:37
created = _buildParamTypes.makeAllParamTypes()
state = created.saveState()
created2 = pt.Parameter.create(**state)
assert pg.eq(state, created2.saveState()) No newline at end of file
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add new-line here

state = super().saveState(filter)
fmt = self._interpretFormat()
state['value'] = state['value'].toString(fmt)
if state['value'] is not None:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

under what conditions would this be None? Also is there a case where the key value would be missing and we should use state.get('value') instead?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

value is guaranteed to exist in the state and is None if nothing is initially specified.

I see two easy options for a better initial value if the user doesn't specify anything:

  • QDate() would give a null/invalid (but date-like) value
  • QDate.currentDate() is what the calendar widget's selected day defaults to. I'd lean toward this one since it's intuitive based on the calendar being displayed. Of course, a minor downside is potentially non-reproducible results overtime due to a changing default value.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think QDate.currentDate() is a pretty good default, but I think changing this might be a bit out of scope for this PR.

@j9ac9k
Copy link
Copy Markdown
Member

j9ac9k commented Sep 10, 2022

Going to close/re-open to trigger a new CI test.

@j9ac9k j9ac9k closed this Sep 10, 2022
@j9ac9k j9ac9k reopened this Sep 10, 2022
@j9ac9k j9ac9k merged commit 09ab51e into pyqtgraph:master Sep 14, 2022
@ntjess ntjess deleted the fix-checklist-state branch November 26, 2022 00:25
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.

2 participants