This project is a simple function plotter application built using PySide2 for the GUI and Matplotlib for plotting. The application allows users to input a mathematical function and plot its graph over a specified range.
- Input a function of
x
, e.g.,5*x^3 + 2*x
. - Specify minimum and maximum values for
x
. - Supports operators:
+
,-
,/
,*
,^
,log10()
,sqrt()
. - Input validation with user-friendly error messages.
- GUI built using PySide2.
- Plotting powered by Matplotlib.
This project is developed and tested using Python 3.9. Due to compatibility issues with PySide2 in newer Python versions, it is highly recommended to use Python 3.9 for running this application.
Download Python 3.9.6 from the official Python website: Python 3.9.6
The version used in this project is python3.9.6 that is mentioned above.
-
Clone the repository:
git clone https://github.com/HalemoGPA/master_micro_task.git cd master_micro_task
-
Create a virtual environment:
python -m venv master_micro master_micro\Scripts\activate # On macOS and Linux, use `source master_micro/bin/activate`
-
Install the required dependencies:
pip install -r requirements.txt
To run the application, execute the following command:
python src/main.py
To run the tests, use the following command:
pytest
- Function:
5*x^3 + 2*x
- Range:
0
to10
- Expected Output: Parabolic curve.
Basic Function
- Function:
5*x^3 + 2*x + !
- Range:
0
to10
- Expected Output: Error message: "Function contains invalid characters."
Invalid Character
- Function:
5*x^3 + 2*x -4/x + 7
- Range:
-10
to10
- Expected Output: Combined plot of Cubic and rational functions.
Complex Formula
- Function:
2*x^4 - log10(x) + sqrt(x)
- Range:
0
to50
- Expected Output: Combined plot of square root, logarithm, and quadratic function.
Complex Formula
- Function:
2*x^4 - log10(x) + sqrt(x)
- Range:
-50
to500
- Expected Output: Error message: "Min value must be non-negative for functions with log10 or sqrt."
Negative Input
- Function:
x
- Range:
a
to2
- Expected Output: Error message: "Min and Max values must be numbers."
Wrong Input
- Function:
x
- Range:
-inf
toinf
- Expected Output: Straight 45deg line from -inf to +inf
-inf to inf range
- Function:
5
- Range:
-10
to10
- Expected Output: Straight horizontal line from -inf to +inf
constant function
- Function:
- Range: to
- Expected Output: Error message: "Function cannot be empty."
constant function
- Function:
x
- Range:
10
to5
- Expected Output: Error message: "Min value must be less than Max value."
constant function
- Function:
x
- Range: to
5
- Expected Output: Error message: "Min and Max values cannot be empty."
constant function