hoffstadt / hoffstadt/DearPyGui

add_scatter_series crashes when references to numpy ndarray are passed

Open
#2,577 1 comment 0 reactions 0 assignees View on GitHub
state: pending type: bug
Dominant language
C++
Stars
15.6k
Forks
783
PR merge metrics
No merged PRs in 30d

Description

## Version of Dear PyGui

Version: 2.1.0
Operating System: Windows 11

## My Issue/Question

While using add_scatter_series with references to a numpy ndarray (see code below) an exception is raised. This can be avoided by copying the relevant data before or creating a list.

> Exception has occurred: SystemError returned a result with an exception set
File "...", line 32, in
dpg.add_scatter_series(sindatax, sindatay, label="0.5 + 0.5 * sin(x)", parent="y_axis", tag="series_tag")
SystemError: returned a result with an exception set

Is it the expected behavior that an exception is raised here?

## To Reproduce

Run the script below.

## Expected behavior

add_scatter_plot should work when references to ndarrays are used.

## Standalone, minimal, complete and verifiable example

```python
import dearpygui.dearpygui as dpg
from math import sin
import numpy as np

dpg.create_context()

sindata = np.zeros((500,2))
for i in range(0, 500):
sindata[i,0] = i / 1000
sindata[i,1] = 0.5 + 0.5 * sin(50 * i / 1000)

with dpg.window(label="Tutorial", tag="win"):
with dpg.plot(label="Line Series", height=400, width=400):

dpg.add_plot_axis(dpg.mvXAxis, label="x")
dpg.add_plot_axis(dpg.mvYAxis, label="y", tag="y_axis")

sindatax = sindata[:,0]
sindatay = sindata[:,1]

# === WORKAROUND / FIX No. 1 ===
#sindatax = np.copy(sindata[:,0])
#sindatay = np.copy(sindata[:,1])

# === WORKAROUND / FIX No. 2 ===
#sindatax = sindata[:,0].tolist()
#sindatay = sindata[:,1].tolist()

# Crashes here
dpg.add_scatter_series(sindatax, sindatay, label="0.5 + 0.5 * sin(x)", parent="y_axis", tag="series_tag")

dpg.create_viewport(title='Custom Title', width=800, height=600)
dpg.setup_dearpygui()
dpg.show_viewport()
dpg.start_dearpygui()
dpg.destroy_context()
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.