Skip to content

Python port#14

Merged
JeffreyMinucci merged 31 commits intomainfrom
python-port
Oct 29, 2025
Merged

Python port#14
JeffreyMinucci merged 31 commits intomainfrom
python-port

Conversation

@JeffreyMinucci
Copy link
Collaborator

This pull request introduces a pure Python implementation of BeePop+. Users can select whether to use the original c++ engine or the newer Python engine for BeePop+. Additional improvements include macOS support (python engine only), updated documentation, and code organization for the pybeepop+ project. The README.md was also edited for clarity and completeness.

*** Pure Python version of BeePop+**

Platform and CI Support

  • Added macOS for arm64 and intel macs (macos-13, macos-14) to the CI build matrix in .github/workflows/ci-build-publish.yml, ensuring that wheels are built and tested for macOS in addition to Windows and Ubuntu. Conditional steps ensure that macOS builds use only the Python engine, as C++ is not supported. [1] [2]
  • Unified and expanded the test workflow to cover Ubuntu, Windows, and macOS in .github/workflows/run-tests.yml (renamed from run-tests-ubuntu.yml), and removed the redundant Windows-only test workflow. This streamlines CI and guarantees cross-platform test coverage. [1] [2]

Documentation Overhaul

  • Overhauled the README.md to provide clear installation instructions, engine selection guidance, platform-specific notes, and a detailed quick start guide. The new documentation includes explicit instructions for using both the C++ and Python engines, and clarifies macOS limitations,.
  • Expanded sections for contributing, bug reporting, and support, and added EPA disclaimer.

Copy link

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

This PR adds dual-engine support to PyBeePop, enabling the package to run simulations using either a C++ engine or a pure Python engine. The key changes include:

  • Introduction of engine selection mechanism with engine parameter supporting "auto", "cpp", and "python" modes
  • Implementation of a complete Python port of the BeePop+ C++ simulation engine
  • Addition of macOS support through the Python engine (C++ not available on macOS)
  • Extensive new test coverage for dual-engine functionality and exception parity

Reviewed Changes

Copilot reviewed 35 out of 36 changed files in this pull request and generated 51 comments.

Show a summary per file
File Description
tests/test_pybeepop.py Parameterized existing tests to run with both engine types; added duplicate import statements
tests/test_dual_engine.py New comprehensive test suite for dual-engine functionality and exception parity
tests/test_adapters.py New test suite for engine adapter interface compliance
pyproject.toml Version bump to 0.2.0; added macOS support and dylib files
pybeepop_example.ipynb Updated with engine selection documentation and examples
pybeepop/pybeepop.py Major refactor to support dual-engine architecture with adapter pattern
pybeepop/exceptions.py New custom exception classes with enhanced error reporting
pybeepop/engine_interface.py Protocol definition for engine interface compatibility
pybeepop/beepop/* Complete Python port of C++ BeePop+ simulation engine modules

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

Comment on lines 176 to 177
import pybeepop.tools as tools
import pybeepop.tools as tools
Copy link

Copilot AI Oct 29, 2025

Choose a reason for hiding this comment

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

Duplicate import of pybeepop.tools as tools on consecutive lines. Remove one of the duplicate imports.

Copilot uses AI. Check for mistakes.
Comment on lines 449 to 450
import pybeepop.tools as tools
import pybeepop.tools as tools
Copy link

Copilot AI Oct 29, 2025

Choose a reason for hiding this comment

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

Duplicate import of pybeepop.tools as tools on consecutive lines. Remove one of the duplicate imports.

Copilot uses AI. Check for mistakes.
Comment on lines 480 to 481
import pybeepop.tools as tools
import pybeepop.tools as tools
Copy link

Copilot AI Oct 29, 2025

Choose a reason for hiding this comment

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

Duplicate import of pybeepop.tools as tools on consecutive lines. Remove one of the duplicate imports.

Copilot uses AI. Check for mistakes.
Comment on lines 132 to 133
destination.enabled = self.enabled
destination.file_format_version = self.file_format_version
Copy link

Copilot AI Oct 29, 2025

Choose a reason for hiding this comment

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

Duplicate assignment of destination.enabled and destination.file_format_version on lines 131-132 and 133-134. Remove the duplicate lines 133-134.

Suggested change
destination.enabled = self.enabled
destination.file_format_version = self.file_format_version

Copilot uses AI. Check for mistakes.
Comment on lines +1569 to +1574
# def set_miticide_treatment(self, start_day_num, duration, mortality, enable):
# pass

# def set_miticide_treatment_from_treatments(self, treatments, enable):
# pass

Copy link

Copilot AI Oct 29, 2025

Choose a reason for hiding this comment

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

This comment appears to contain commented-out code.

Suggested change
# def set_miticide_treatment(self, start_day_num, duration, mortality, enable):
# pass
# def set_miticide_treatment_from_treatments(self, treatments, enable):
# pass

Copilot uses AI. Check for mistakes.
Returns:
str: Info log as newline-separated string.
"""
...
Copy link

Copilot AI Oct 29, 2025

Choose a reason for hiding this comment

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

This statement has no effect.

Copilot uses AI. Check for mistakes.
Returns:
str: Version string (e.g., "1.15.25").
"""
...
Copy link

Copilot AI Oct 29, 2025

Choose a reason for hiding this comment

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

This statement has no effect.

Copilot uses AI. Check for mistakes.

This method should be idempotent and safe to call multiple times.
"""
...
Copy link

Copilot AI Oct 29, 2025

Choose a reason for hiding this comment

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

This statement has no effect.

Copilot uses AI. Check for mistakes.
return True
except Exception as e:
raise e
return False
Copy link

Copilot AI Oct 29, 2025

Choose a reason for hiding this comment

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

This statement is unreachable.

Suggested change
return False

Copilot uses AI. Check for mistakes.
@JeffreyMinucci JeffreyMinucci merged commit 19b526e into main Oct 29, 2025
13 checks passed
@JeffreyMinucci JeffreyMinucci deleted the python-port branch October 29, 2025 21:33
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.

1 participant