Skip to content

Feature_A_6#12

Open
prtm-bg wants to merge 50 commits into
dGhoshIIEST:Group_Afrom
prtm-bg:main
Open

Feature_A_6#12
prtm-bg wants to merge 50 commits into
dGhoshIIEST:Group_Afrom
prtm-bg:main

Conversation

@prtm-bg
Copy link
Copy Markdown

@prtm-bg prtm-bg commented Mar 23, 2026

Integration of Binary Operations to the Base Calculator.

prtm-bg and others added 30 commits March 16, 2026 15:06
added init py and binop module
FeatureA_6 core functions
FeatureA_6 Basic Arithmetic Functions
Add input validation for binary strings
Revert "Update binary.py by deepjit"
Revert "Add input validation for binary strings"
Added execption.py for input validation.
feature: add binary complement operations
calculator.py now has function drivers for evaluating binary operations.
prtm-bg and others added 14 commits March 22, 2026 19:05
Binary Operation Integration with Base Calculator Operation .py file
fixed duplicate divide.
fixed import path for exceptions module
added imports for multiply and divide
Removed project structure section from README.
fixed import path for exceptions module
fixed subtraction function
fixed ones complement function:
issue: modular arithmetic kills the carry
fix: let the carry naturally extend the bit length
Copilot AI review requested due to automatic review settings March 23, 2026 12:40
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a binary-number feature set to the existing calculator codebase, including conversion utilities, binary arithmetic/complement operations, custom exceptions, and CI coverage for the new module.

Changes:

  • Introduces modules/binary.py (+ re-exports) and modules/exceptions.py for binary operations and domain-specific errors.
  • Extends Calculator with an evaluate() string router to invoke binary features and arithmetic via simple expression parsing.
  • Adds unit tests for the binary module and updates CI workflow to run tests and report coverage.

Reviewed changes

Copilot reviewed 9 out of 10 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
calculator.py Adds imports for binary features and implements Calculator.evaluate() expression routing/parsing.
modules/binary.py Implements binary↔decimal conversion, binary arithmetic, and 1’s/2’s complement helpers.
modules/exceptions.py Adds custom exceptions for invalid binary input and negative subtraction results.
modules/__init__.py Re-exports binary functions at the package level.
tests/testbinary.py Adds unit tests covering conversions, arithmetic, complements, and invalid input.
tests/__init__.py Exposes tests via star import (package init).
test_calculator.py Renames duplicate divide tests to distinct names.
README.md Documents binary features, input format, and how to run tests.
.github/workflows/tests.yml Adds GitHub Actions workflow to run tests and produce a coverage report.
.gitignore Adds common Python/IDE/OS ignores.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread modules/binary.py
Comment thread tests/binary_tests.py
Comment thread tests/__init__.py Outdated
Comment thread calculator.py Outdated
Comment thread calculator.py Outdated
Comment thread calculator.py Outdated
Comment thread calculator.py Outdated
prtm-bg and others added 5 commits April 3, 2026 10:51
Refactor Calculator class by removing unused imports and methods, and adding a mode attribute for future extensions.
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 7 out of 8 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread modules/binary.py
Comment on lines +3 to +5
import re
import sys

Copy link

Copilot AI Apr 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

re and sys are imported but never used in this module. Unused imports can trigger linting failures and make dependencies unclear; please remove them (or use them if intentionally needed).

Suggested change
import re
import sys

Copilot uses AI. Check for mistakes.
Comment thread modules/binary.py
Comment on lines +179 to +180

return Calculator.evaluate(self.mode)
Copy link

Copilot AI Apr 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When self.mode != 2, this method calls Calculator.evaluate(self.mode), which ignores the provided expression and (given the current base implementation) just prints and returns None. This makes Binary.evaluate(...) silently return None outside binary mode; consider either delegating to a properly-typed base evaluate(self, expression) implementation or raising a clear error for unsupported modes.

Suggested change
return Calculator.evaluate(self.mode)
raise ValueError(f"Unsupported mode for Binary.evaluate: {self.mode}")

Copilot uses AI. Check for mistakes.
Comment thread tests/binary_tests.py

def test_missing_prefix(self):
with self.assertRaises(InvalidBinaryInputError):
binary_to_decimal("1021")
Copy link

Copilot AI Apr 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test_missing_prefix currently passes "1021", which would raise InvalidBinaryInputError due to the invalid digit 2 even if the missing prefix were accepted. If the intent is to require the B' prefix, add a case like "1010" (valid bits but missing prefix) or adjust the test name/expectation to match the actual validation behavior.

Suggested change
binary_to_decimal("1021")
binary_to_decimal("1010")

Copilot uses AI. Check for mistakes.
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi # Installs any dependencies you have
- name: Test with unittest
run: python -m unittest discover # Runs the unittest discover command
run: PYTHONPATH=. python -m unittest discover # Runs the unittest discover command
Copy link

Copilot AI Apr 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

python -m unittest discover uses the default pattern test*.py, so tests/binary_tests.py will not be executed in this workflow. Either rename the test file to match test*.py (e.g., tests/test_binary.py) or update the discover command to use a pattern that includes *_tests.py and/or the tests/ start directory.

Suggested change
run: PYTHONPATH=. python -m unittest discover # Runs the unittest discover command
run: PYTHONPATH=. python -m unittest discover -s tests -p "*test*.py" # Runs unittest discovery against the tests directory and includes files such as test_*.py and *_tests.py

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants