Skip to content

Organize paramtypes#1919

Merged
j9ac9k merged 15 commits intopyqtgraph:masterfrom
ntjess:organize-paramtypes
Aug 2, 2021
Merged

Organize paramtypes#1919
j9ac9k merged 15 commits intopyqtgraph:masterfrom
ntjess:organize-paramtypes

Conversation

@ntjess
Copy link
Copy Markdown
Contributor

@ntjess ntjess commented Jul 24, 2021

To prevent the extraordinary merge hassle of last parameter type PR, this organization:

  • Makes a new file for each parameter type
  • Allows parameter items to be registered without belonging to a parameter
  • Splits WidgetParameterItem implementations into actually separate items like BoolParameterItem, ColorParameterItem, etc.
  • A script to auto-generate parameter types documentation

For reviewers: The content of each Parameter/Item is unchanged -- the only modifications are to the imports

@ntjess
Copy link
Copy Markdown
Contributor Author

ntjess commented Jul 24, 2021

@j9ac9k sorry to increase the PR count so soon 😆

@ntjess
Copy link
Copy Markdown
Contributor Author

ntjess commented Jul 24, 2021

@ixjlyons Any idea why the docs failed? It says there is a problem but I'm not sure how to find out what it was...

@j9ac9k
Copy link
Copy Markdown
Member

j9ac9k commented Jul 24, 2021

From the docs build:

/home/docs/checkouts/readthedocs.org/user_builds/pyqtgraph/checkouts/1919/doc/source/../../pyqtgraph/parametertree/parameterTypes/basetypes.py:docstring of pyqtgraph.parametertree.parameterTypes.basetypes.SimpleParameter:5: WARNING: Unexpected indentation.
/home/docs/checkouts/readthedocs.org/user_builds/pyqtgraph/checkouts/1919/doc/source/../../pyqtgraph/parametertree/parameterTypes/numeric.py:docstring of pyqtgraph.parametertree.parameterTypes.numeric.NumericParameterItem:5: WARNING: Unexpected indentation.
/home/docs/checkouts/readthedocs.org/user_builds/pyqtgraph/checkouts/1919/doc/source/../../pyqtgraph/parametertree/parameterTypes/numeric.py:docstring of pyqtgraph.parametertree.parameterTypes.numeric.NumericParameterItem:6: WARNING: Block quote ends without a blank line; unexpected unindent.

I believe we have our sphinx config set to error on warning.

@j9ac9k
Copy link
Copy Markdown
Member

j9ac9k commented Jul 24, 2021

@j9ac9k sorry to increase the PR count so soon 😆

You're not going to hear me complain about a PR that will make the library easier to maintain.

@ntjess
Copy link
Copy Markdown
Contributor Author

ntjess commented Jul 24, 2021

@NilsNemitz Right, I didn't realize until Ogi's comment that warnings equate to errors with the current build specifications

@ntjess
Copy link
Copy Markdown
Contributor Author

ntjess commented Jul 24, 2021

I'm also a little confused... Where is the unexpected indent? It looks similar to other documentation. It's not tabs either, just making sure

image

@j9ac9k
Copy link
Copy Markdown
Member

j9ac9k commented Jul 24, 2021

I would recommend migrating to numpy-docstyle ...we're slowly moving over in that direction, it's a bit easier to read, preserves horizontal space. We haven't been enforcing it, given much of the library isn't of that format. TargetItem.py has some examples of how to format there that may be useful. I think PyCharm (or really any popular IDE/editor) has extensions to auto-populate/format a stub that you can just fill in.

But to directly answer your question, I'm not sure what sphinx is talking about (my doc-formatting game is weak). I can recreate the doc-build environment and help diagnose in a bit.

@NilsNemitz
Copy link
Copy Markdown
Contributor

Dear @ntjess , I think it might mostly be complaining about the missing blank line.
And it might be expecting that blank line before the
========= =================== section.

@ntjess ntjess force-pushed the organize-paramtypes branch from e1a6189 to bfbdd8c Compare July 24, 2021 14:36
@ntjess ntjess force-pushed the organize-paramtypes branch from bfbdd8c to c813e0f Compare July 24, 2021 14:45
Parameters
----------

.. autoclass:: SimpleParameter
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 have somewhat of a preference for keeping these as just the ClassName here. The difference is the signature rendered in the docs:

class pyqtgraph.parametertree.parameterTypes.SliderParameter(**opts)

vs.

class pyqtgraph.parametertree.parameterTypes.slider.SliderParameter(**opts)

Since they will almost always be imported via from pyqtgraph.parametertree import parameterTypes, the old version may be a little less confusing.

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.

Currently the items are ordered by appearance in PARAM_TYPES. Do you think they should be ordered alphabetically instead while I'm making changes? Not sure which is preferable.

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 don't have a strong preference. I guess I'd lean toward alphabetical so it's a little easier to find something when scrolling, but if I know what I'm looking for I'd probably ctrl+f or use the search box anyway.

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.

Scratch that -- I thought I took out set logic but that means order changes almost every time the script is run... I think I will sort so the order is deterministic and makes clear where new parameters should be added

@@ -0,0 +1,42 @@
import os.path
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.

Script seems fine to me, just highlights that we really should try to migrate toward using sphinx-autogen/autosummary. My issue is it usually seems to require some templating/theming which isn't really a passion of mine.

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.

Yeah, this is more of a stand-in but certainly not the best long-term solution

- `registerParameterItemType`:
  * added to docs and parametertree.__init__
  * Remove unsed PARAM_TYPES global
  * Hyperlink to `registerParameterType`
- parameter tree rst:
  * Alphabetize entries
  * Rebuild RST without fully qualified class name
  * Add note at file header that it is auto generated
@ntjess ntjess force-pushed the organize-paramtypes branch from de378df to 174d4cf Compare July 31, 2021 22:03

def setAddList(self, vals):
"""Change the list of options available for the user to add to the group."""
self.setOpts(addList=vals) No newline at end of file
Copy link
Copy Markdown
Member

@j9ac9k j9ac9k Aug 1, 2021

Choose a reason for hiding this comment

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

nit-pick; looks like this file needs a newline at the end.

EDIT: a number of files look like they need new-lines after the last line of code.

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.

I didn't realize this was a requirement, apologies. I'll configure my settings accordingly

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.

I ran a script which found a few other repo files without newlines. Should a quick PR be added for them?

examples/exampleLoaderTemplate_pyside2.py
examples/exampleLoaderTemplate_pyside6.py
examples/initExample.py
examples/optics/__init__.py
examples/verlet_chain/__init__.py
pyqtgraph/canvas/__init__.py
pyqtgraph/console/__init__.py
pyqtgraph/dockarea/__init__.py
pyqtgraph/flowchart/__init__.py
pyqtgraph/imageview/__init__.py
pyqtgraph/ordereddict.py
pyqtgraph/util/get_resolution.py
pyqtgraph/util/pil_fix.py
pyqtgraph/widgets/FeedbackButton.py
pyqtgraph/widgets/VerticalLabel.py
tests/test_Point.py

@j9ac9k
Copy link
Copy Markdown
Member

j9ac9k commented Aug 1, 2021

My only issue here is lack of \n at the end of the files; also the static code checker picked up some unused imports that should probably be removed.

@ntjess
Copy link
Copy Markdown
Contributor Author

ntjess commented Aug 1, 2021

@j9ac9k Wow, CodeQL is actually helpful when it doesn't trigger all 300 warnings across the project for an unrelated PR 😆

@j9ac9k
Copy link
Copy Markdown
Member

j9ac9k commented Aug 2, 2021

@ntjess if you think this guy is ready for merging, probably should remove the draft status 👍🏻

@ntjess ntjess marked this pull request as ready for review August 2, 2021 05:03
@j9ac9k
Copy link
Copy Markdown
Member

j9ac9k commented Aug 2, 2021

This PR is now showing merge conflicts (likely having to do with #1939 ) ...sorry for the trouble @ntjess ! Once that's resolved we can merge.

ntjess added a commit to ntjess/pyqtgraph that referenced this pull request Aug 2, 2021
Note: intentionally leaves out instance in parametertypes.py to avoid merge conflict with pyqtgraph#1919
ntjess added a commit to ntjess/pyqtgraph that referenced this pull request Aug 2, 2021
Note: intentionally leaves out instance in parametertypes.py to avoid merge conflict with pyqtgraph#1919
@ntjess
Copy link
Copy Markdown
Contributor Author

ntjess commented Aug 2, 2021

@ksunden If you used a script to find unneeded castings before, it might be good to run the same script on this branch to make sure I didn't miss anything

ntjess added a commit to ntjess/pyqtgraph that referenced this pull request Aug 2, 2021
Note: intentionally avoids files moved / already adjusted from pyqtgraph#1919
@j9ac9k j9ac9k merged commit 4bf1866 into pyqtgraph:master Aug 2, 2021
@ntjess ntjess deleted the organize-paramtypes branch August 5, 2021 13:24
pijyoi added a commit to pijyoi/pyqtgraph that referenced this pull request Dec 2, 2021
prior to PR pyqtgraph#1919, there was no ptree.types.ColorMapParameter, and
type "colormap" was handled directly by ptree.types.SimpleParameter.

PR pyqtgraph#1919 created ColorMapParameter as a sub-class of SimpleParameter,
and moved colormap specific functionality into ColorMapParameter.
Hence RangeColorMapItem now needs to derive from ColorMapParameter.
ntjess pushed a commit to ntjess/pyqtgraph that referenced this pull request Dec 10, 2021
prior to PR pyqtgraph#1919, there was no ptree.types.ColorMapParameter, and
type "colormap" was handled directly by ptree.types.SimpleParameter.

PR pyqtgraph#1919 created ColorMapParameter as a sub-class of SimpleParameter,
and moved colormap specific functionality into ColorMapParameter.
Hence RangeColorMapItem now needs to derive from ColorMapParameter.
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.

4 participants