Skip to content

ChecklistParameter bug #3229

@Qi-henry

Description

@Qi-henry

Short description

Code to reproduce

import pyqtgraph as pg
import numpy as np

Expected behavior

Real behavior

An error occurred?
Post the full traceback inside these 'code fences'!

Tested environment(s)

  • PyQtGraph version: 0.13.7
  • Qt Python binding: 2.4.2
  • Python version: 3.9.0
  • NumPy version: 1.26.4
  • Operating system: Windows 10
  • Installation method:

Additional context

    @staticmethod
    def mapping(limits):
        # Return forward and reverse mapping objects given a limit specification
        forward = OrderedDict()  ## {name: value, ...}
        reverse = ([], [])       ## ([value, ...], [name, ...])
        if not isinstance(limits, dict):
            limits = {str(l): l for l in limits}
        for k, v in limits.items():
            forward[k] = v
            reverse[0].append(v)
            reverse[1].append(k)
        return forward, reverse

    def _intersectionWithLimits(self, values: list):
        """
        Returns the (names, values) from limits that intersect with ``values``.
        """
        allowedNames = []
        allowedValues = []
        # Could be replaced by "value in self.reverse[0]" and "reverse[0].index",
        # but this allows for using pg.eq to cover more diverse value options
        for val in values:
            for limitName, limitValue in zip(*self.reverse):
                if fn.eq(limitValue, val):
                    allowedNames.append(limitName)
                    allowedValues.append(val)
                    break
        return allowedNames, allowedValues

In the mapping(limits),reverse = ([], []) ## ([value, ...], [name, ...]) assigns the first array of a set as' value 'and the second array as' name'. In the _intersectionWithLimits(self, values: list) function, assign the value of the first score group to limitName and the value of the second score group to limitValue. Resulting in normal use only when the array element is str in the 'limits' of ChecklistParameterItem

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions