Skip to content

Conversation

@kwesiRutledge
Copy link
Collaborator

Summary

  • Redid the AsSimplifiedExpression method for Polynomial to clean it up + remove extra polynomials OR return a Monomial, or Variable, or Constant, if it makes sense.
  • Refactored a lot of the Plus, Multiply, and more to not make assumptions (especially for Polynomial objects) on output types.
  • Introduced some more templates.
    • Need to add more templates.
  • Added ToScalarExpressions() method for the all VectorExpressions.

@kwesiRutledge kwesiRutledge requested a review from Copilot October 13, 2025 04:33
@kwesiRutledge kwesiRutledge self-assigned this Oct 13, 2025
@codecov
Copy link

codecov bot commented Oct 13, 2025

Codecov Report

❌ Patch coverage is 87.16578% with 72 lines in your changes missing coverage. Please review.
✅ Project coverage is 87.09%. Comparing base (5fc58d9) to head (8ccf772).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
symbolic/monomial.go 65.38% 13 Missing and 5 partials ⚠️
symbolic/vector_expression.go 67.44% 14 Missing ⚠️
symbolic/matrix_expression.go 58.62% 9 Missing and 3 partials ⚠️
symbolic/variable.go 79.06% 9 Missing ⚠️
symbolic/polynomial_vector.go 83.72% 7 Missing ⚠️
symbolic/constant_matrix.go 90.90% 5 Missing ⚠️
symbolic/variable_vector.go 83.33% 5 Missing ⚠️
symbolic/monomial_vector.go 97.43% 1 Missing ⚠️
symbolic/polynomial.go 99.05% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #27      +/-   ##
==========================================
- Coverage   87.46%   87.09%   -0.38%     
==========================================
  Files          42       42              
  Lines        6432     6516      +84     
==========================================
+ Hits         5626     5675      +49     
- Misses        719      743      +24     
- Partials       87       98      +11     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

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 reworks the AsSimplifiedExpression method for Polynomial types and refactors arithmetic operations to avoid making assumptions about output types, particularly for Polynomial objects. The changes introduce template functions for vector operations and add a ToScalarExpressions() method to all VectorExpression types.

Key changes:

  • Enhanced polynomial simplification that can return Constants, Variables, or Monomials when appropriate
  • Refactored arithmetic operations to use templates and avoid type assumptions
  • Added ToScalarExpressions() method to vector expression types

Reviewed Changes

Copilot reviewed 27 out of 27 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
symbolic/polynomial.go Enhanced AsSimplifiedExpression() and Simplify() methods, refactored arithmetic operations
symbolic/vector_expression.go Added ToScalarExpressions() method and vector operation templates
symbolic/variable_vector.go Refactored Plus() and Multiply() to use templates
symbolic/polynomial_vector.go Updated arithmetic operations to use ConcretizeExpression()
symbolic/monomial.go Added IsVariable(), ToVariable() methods and enhanced Plus()
testing/symbolic/*.go Updated tests to expect simplified return types (Monomials, Variables, Constants)
examples/ Added new example scripts demonstrating substitution and derivatives

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Kwesi Rutledge and others added 2 commits October 13, 2025 00:49
Adding extra checks to prevent panics in Monomial.ToVariable() method

Co-authored-by: Copilot <[email protected]>
@kwesiRutledge kwesiRutledge merged commit 5549451 into main Oct 13, 2025
4 of 5 checks passed
@kwesiRutledge kwesiRutledge deleted the kr/fix/polynomial-simplify2 branch October 13, 2025 04:54
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.

2 participants