Fixed incorrect dimensions plotting error
This commit is contained in:
parent
9ea4a29d2d
commit
89e12d250f
@ -11,7 +11,7 @@ from .types import FunctionType, OperatorType, ValueType
|
|||||||
class Expression(abc.ABC):
|
class Expression(abc.ABC):
|
||||||
"""
|
"""
|
||||||
Abstract base class for a single parsed expression as a tree data
|
Abstract base class for a single parsed expression as a tree data
|
||||||
structure. It also defines its public function for triggering
|
structure. It also defines its public function for triggering
|
||||||
evaluation. Each child class sets `_evaluator` property to a
|
evaluation. Each child class sets `_evaluator` property to a
|
||||||
function that accepts variables values and produces numpy array.
|
function that accepts variables values and produces numpy array.
|
||||||
"""
|
"""
|
||||||
|
@ -16,6 +16,7 @@ import numpy as np
|
|||||||
from .button_group import ButtonGroup
|
from .button_group import ButtonGroup
|
||||||
from .constants import FUNCTION_NAMES
|
from .constants import FUNCTION_NAMES
|
||||||
from .graph_requester import GraphRequester
|
from .graph_requester import GraphRequester
|
||||||
|
from .utils import size
|
||||||
|
|
||||||
from parser import Parser
|
from parser import Parser
|
||||||
|
|
||||||
@ -189,6 +190,23 @@ class PlotterDialog(QDialog):
|
|||||||
x = Parser(x_expr).evaluate(self.variable_values)
|
x = Parser(x_expr).evaluate(self.variable_values)
|
||||||
y = Parser(y_expr).evaluate(self.variable_values)
|
y = Parser(y_expr).evaluate(self.variable_values)
|
||||||
|
|
||||||
|
if size(x) != size(y):
|
||||||
|
dlg = QMessageBox(
|
||||||
|
QMessageBox.Critical,
|
||||||
|
"Ошибка",
|
||||||
|
"\n\n".join(
|
||||||
|
(
|
||||||
|
"Выражения имеют разную размерность",
|
||||||
|
f'y: "{y}" -> {size(y)}',
|
||||||
|
f'x: "{x}" -> {size(x)}',
|
||||||
|
)
|
||||||
|
),
|
||||||
|
)
|
||||||
|
dlg.exec()
|
||||||
|
|
||||||
|
graph_requester.LineEditY.setFocus()
|
||||||
|
return
|
||||||
|
|
||||||
xs.append(x)
|
xs.append(x)
|
||||||
ys.append(y)
|
ys.append(y)
|
||||||
labels.append(label)
|
labels.append(label)
|
||||||
|
10
PyQt-Plotter-Dialog/plotter_dialog/utils.py
Normal file
10
PyQt-Plotter-Dialog/plotter_dialog/utils.py
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
import numpy as np
|
||||||
|
|
||||||
|
from parser.types import ValueType
|
||||||
|
|
||||||
|
|
||||||
|
def size(x: ValueType) -> int:
|
||||||
|
if isinstance(x, np.ndarray):
|
||||||
|
return x.size
|
||||||
|
else:
|
||||||
|
return 1
|
Loading…
x
Reference in New Issue
Block a user