Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions .github/workflows/linting.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Linting

on:
push:
branches: [ "main", "master" ]
pull_request:
branches: [ "main", "master" ]

jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.13"

- name: Install Ruff
run: |
python -m pip install --upgrade pip
pip install ruff

- name: Run Ruff Lint
run: ruff check .

- name: Run Ruff Format Check
run: ruff format --check .
1 change: 0 additions & 1 deletion Canvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@


class MplCanvas(FigureCanvasQTAgg):

def __init__(self, parent=None, width=6, height=6, dpi=100):
fig = Figure(figsize=(width, height), dpi=dpi)
self.axes = fig.add_subplot(111)
Expand Down
1 change: 0 additions & 1 deletion CanvasThreeD.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@


class MplCanvas(FigureCanvasQTAgg):

def __init__(self, parent=None, width=6, height=6, dpi=100):
fig = Figure(figsize=(width, height), dpi=dpi)
self.axes = fig.add_subplot(projection="3d")
Expand Down
1 change: 0 additions & 1 deletion CheckCreateDirectory.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ def check_create_dir(path):
isExist = os.path.exists(path)

if not isExist:

# Create a new directory because it does not exist
os.makedirs(path)
print("The new directory is created!")
Expand Down
2 changes: 1 addition & 1 deletion Circle.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import CircleCalc
import Canvas
import SaveFig
from Shape import *
from Shape import ShapeFunctionality

# Get the absolute path to the directory where this script is located
SCRIPT_DIR = Path(__file__).resolve().parent
Expand Down
2 changes: 1 addition & 1 deletion Cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import CubeCalc
import CanvasThreeD
import SaveFig
from Shape import *
from Shape import ShapeFunctionality

# Get the absolute path to the directory where this script is located
SCRIPT_DIR = Path(__file__).resolve().parent
Expand Down
2 changes: 1 addition & 1 deletion Ellipse.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import EllipseCalc
import Canvas
import SaveFig
from Shape import *
from Shape import ShapeFunctionality

# Get the absolute path to the directory where this script is located
SCRIPT_DIR = Path(__file__).resolve().parent
Expand Down
2 changes: 1 addition & 1 deletion Ellipsoid.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import EllipsoidCalc
import CanvasThreeD
import SaveFig
from Shape import *
from Shape import ShapeFunctionality

# Get the absolute path to the directory where this script is located
SCRIPT_DIR = Path(__file__).resolve().parent
Expand Down
37 changes: 17 additions & 20 deletions MathApp.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import sys
from pathlib import Path
import matplotlib

matplotlib.use("Qt5Agg")

from PyQt5.QtWidgets import (
QApplication,
Expand All @@ -22,26 +25,21 @@

from PyQt5 import QtCore

# Get the absolute path to the directory where this script is located
SCRIPT_DIR = Path(__file__).resolve().parent

from Circle import *
from Sphere import *
from Ellipse import *
from Ellipsoid import *
from Square import *
from Cube import *

import matplotlib

matplotlib.use("Qt5Agg")
from Circle import WindowCircle
from Sphere import WindowSphere
from Ellipse import WindowEllipse
from Ellipsoid import WindowEllipsoid
from Square import WindowSquare
from Cube import WindowCube

from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg
from matplotlib.figure import Figure

# Get the absolute path to the directory where this script is located
SCRIPT_DIR = Path(__file__).resolve().parent

class MplCanvas(FigureCanvasQTAgg):

class MplCanvas(FigureCanvasQTAgg):
def __init__(self, parent=None, width=5, height=5, dpi=100):
fig = Figure(figsize=(width, height), dpi=dpi)
self.axes = fig.add_subplot(111)
Expand All @@ -50,7 +48,6 @@ def __init__(self, parent=None, width=5, height=5, dpi=100):


class MainWindow(QMainWindow):

def __init__(self):
super().__init__()

Expand All @@ -75,9 +72,9 @@ def __init__(self):
buttonClose = QPushButton("Close")
buttonClose.clicked.connect(app.closeAllWindows)

l = QHBoxLayout()
l.addStretch(1)
l.addWidget(buttonClose)
layout = QHBoxLayout()
layout.addStretch(1)
layout.addWidget(buttonClose)

l2 = QVBoxLayout()

Expand Down Expand Up @@ -122,7 +119,7 @@ def __init__(self):
button6.clicked.connect(lambda checked: self.toggle_window(self.window6))
l3.addWidget(button6, 3, 1)

l2.addLayout(l)
l2.addLayout(layout)

w = QWidget()
w.setLayout(l2)
Expand Down Expand Up @@ -198,7 +195,7 @@ def _createMenuBar(self):
geometryMenu.addAction(self.squareAction)
geometryMenu.addAction(self.cubeAction)

helpMenu = menuBar.addMenu("&Help")
menuBar.addMenu("&Help")


app = QApplication(sys.argv)
Expand Down
1 change: 0 additions & 1 deletion Shape.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@


class ShapeFunctionality:

def custom_messagebox(self, text="Error!"):
"""
Displays a custom message box with an error icon.
Expand Down
2 changes: 1 addition & 1 deletion Sphere.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import SphereCalc
import CanvasThreeD
import SaveFig
from Shape import *
from Shape import ShapeFunctionality

# Get the absolute path to the directory where this script is located
SCRIPT_DIR = Path(__file__).resolve().parent
Expand Down
2 changes: 1 addition & 1 deletion Square.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import SquareCalc
import Canvas
import SaveFig
from Shape import *
from Shape import ShapeFunctionality

# Get the absolute path to the directory where this script is located
SCRIPT_DIR = Path(__file__).resolve().parent
Expand Down
3 changes: 1 addition & 2 deletions Tests/test_circle.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@

# setting path
sys.path.append("../PyQtMathApp")
from CircleCalc import *
from CircleCalc import Circle


class CircleTest(unittest.TestCase):

def test_init_valid_radius(self):
"""Tests initialization with a valid positive radius."""
circle = Circle(5.0)
Expand Down
3 changes: 1 addition & 2 deletions Tests/test_cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@

# setting path
sys.path.append("../PyQtMathApp")
from CubeCalc import *
from CubeCalc import Cube


class TestSquare(unittest.TestCase):

def test_init_valid_side_length(self):
"""Tests initialization with a valid positive side length."""
cube = Cube(5.526)
Expand Down
17 changes: 8 additions & 9 deletions Tests/test_ellipse.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import unittest
import sys
from math import pi
import math

# setting path
sys.path.append("../PyQtMathApp")
from EllipseCalc import *
from EllipseCalc import Ellipse


class EllipseTest(unittest.TestCase):

def test_init_valid_axes(self):
"""Tests initialization with valid positive axis lengths."""
ellipse = Ellipse(5.0, 3.0)
Expand Down Expand Up @@ -68,15 +67,15 @@ def test_init_very_small_positive_major_axis(self):
ellipse = Ellipse(0.000001, 3.0)
self.assertAlmostEqual(
ellipse.circumference(),
round(pi * math.sqrt(2 * (0.000001**2 + 3.0**2)), 5),
round(math.pi * math.sqrt(2 * (0.000001**2 + 3.0**2)), 5),
)

def test_init_very_large_major_axis(self):
"""Tests initialization with a very large major axis."""
ellipse = Ellipse(1000000.0, 3.0)
self.assertAlmostEqual(
ellipse.circumference(),
round(pi * math.sqrt(2 * (1000000.0**2 + 3.0**2)), 5),
round(math.pi * math.sqrt(2 * (1000000.0**2 + 3.0**2)), 5),
)

def test_init_empty_string_major_axis(self):
Expand All @@ -98,21 +97,21 @@ def test_init_empty_string_minor_axis(self):
def test_circumference(self):
"""Tests circumference calculation for various axis lengths."""
ellipse = Ellipse(3.0, 1.0)
expected_circumference = round(pi * math.sqrt(2 * (3.0**2 + 1.0**2)), 5)
expected_circumference = round(math.pi * math.sqrt(2 * (3.0**2 + 1.0**2)), 5)
self.assertEqual(ellipse.circumference(), expected_circumference)

ellipse = Ellipse(8.0, 4.0)
expected_circumference = round(pi * math.sqrt(2 * (8.0**2 + 4.0**2)), 5)
expected_circumference = round(math.pi * math.sqrt(2 * (8.0**2 + 4.0**2)), 5)
self.assertEqual(ellipse.circumference(), expected_circumference)

def test_area(self):
"""Tests area calculation for various axis lengths."""
ellipse = Ellipse(2.0, 1.5)
expected_area = round(pi * 2.0 * 1.5, 5)
expected_area = round(math.pi * 2.0 * 1.5, 5)
self.assertEqual(ellipse.area(), expected_area)

ellipse = Ellipse(7.0, 3.0)
expected_area = round(pi * 7.0 * 3.0, 5)
expected_area = round(math.pi * 7.0 * 3.0, 5)
self.assertEqual(ellipse.area(), expected_area)

def test_get_description(self):
Expand Down
3 changes: 1 addition & 2 deletions Tests/test_ellipsoid.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@

# setting path
sys.path.append("../PyQtMathApp")
from EllipsoidCalc import *
from EllipsoidCalc import Ellipsoid


class EllipsoidTest(unittest.TestCase):

def test_init_valid_dimensions(self):
"""Tests initialization with valid positive semi-axes."""
ellipsoid = Ellipsoid(5.0, 3.0, 2.0)
Expand Down
5 changes: 1 addition & 4 deletions Tests/test_sphere.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
import unittest
import sys
from math import pi

# setting path
sys.path.append("../PyQtMathApp")
from SphereCalc import *
from SphereCalc import Sphere

import unittest
import math


class SphereTest(unittest.TestCase):

def test_init_valid_radius(self):
"""Tests initialization with a valid positive radius."""
sphere = Sphere(5.0)
Expand Down
3 changes: 1 addition & 2 deletions Tests/test_square.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@

# setting path
sys.path.append("../PyQtMathApp")
from SquareCalc import *
from SquareCalc import Square


class TestSquare(unittest.TestCase):

def test_init_valid_side_length(self):
"""Tests initialization with a valid positive side length."""
square = Square(5.0)
Expand Down
Loading