Skip to content

Improve error message when calling unite or intersect #2

@carlos-adir

Description

@carlos-adir

The functions unite and intersect call general_doer, but if any error happens it's hard to diagnose

src/shapepy/geometry/curve.py:661: in bezier_and_bezier
    left = rbool.unite(*tuple({p[0]} for p in pairs))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
../../.cache/pypoetry/virtualenvs/shapepy-ScE41tDE-py3.12/lib/python3.12/site-packages/rbool/bool1d.py:142: in unite
    return general_doer(subsets, or_func)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

subsets = (), function = <function unite.<locals>.or_func at 0x7d3e267fad40>

    def general_doer(
        subsets: Iterable[SubSetR1], function: Callable[[Real], bool]
    ) -> SubSetR1:
        """
        Receives a group of SubSetR1 and makes the union, the intersection,
        or the inversion depending on the given function.
    
        This is an internal function and should not be used careless
        """
        subsets = tuple(map(Future.convert, subsets))
        if not all(isinstance(subset, SubSetR1) for subset in subsets):
            raise TypeError
        set_all_knots: Set[Real] = set()
        for subset in subsets:
            set_all_knots |= set(extract_knots(subset))
        all_knots: List[Real] = sorted(set_all_knots)
        eval_knots: List[Real] = [0] * (2 * len(all_knots) + 1)
>       eval_knots[0] = all_knots[0] - 1
                        ^^^^^^^^^^^^
E       IndexError: list index out of range

../../.cache/pypoetry/virtualenvs/shapepy-ScE41tDE-py3.12/lib/python3.12/site-packages/rbool/bool1d.py:50: IndexError

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No fields configured for Task.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions