Skip to content

Adds linear algebra operations#196

Open
DrPaulSharp wants to merge 4 commits intorefactor_24from
refactor_24_linalg
Open

Adds linear algebra operations#196
DrPaulSharp wants to merge 4 commits intorefactor_24from
refactor_24_linalg

Conversation

@DrPaulSharp
Copy link
Contributor

This PR adds linear algebra operations for quantities. Note that it introduces a new dependency, sympy, which has the BSD licence. https://www.sympy.org/en/index.html

@DrPaulSharp DrPaulSharp requested a review from krzywon March 19, 2026 14:23
codescene-delta-analysis[bot]

This comment was marked as outdated.

codescene-delta-analysis[bot]

This comment was marked as outdated.

Copy link
Collaborator

@krzywon krzywon left a comment

Choose a reason for hiding this comment

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

I'm conflicted on this one and will need to think more on it. Overall, it seems fine, but I think I need a real use case for having these operations with the data object. Is the plan to apply them to SAS data?

requirements.txt Outdated
# Calculation
numpy
scipy
sympy
Copy link
Collaborator

Choose a reason for hiding this comment

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

Adding another requirement is never ideal, especially for something we've never had to do before. If we haven't had to do this operation previously, is there a good justification for adding it now?

What are the real world use-cases for adding these operations?

return np.linalg.det(self.a.evaluate(variables))

def _derivative(self, hash_value: int) -> Operation:
return Trace(sp.adjugate(self.a) * self.a._derivative(hash_value))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Adding an entire dependency for a single use seems excessive. Are there other operation we might use the package for in the future?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, I'm inclined to agree overall. It's better to use this dependency than write code for the adjugate operation but we only need it here and I've added the determinant as something that might be useful rather than having a definite use case. I can take the determinant operation out and put it on ice for now and we can put the rest in if that sounds like a good plan?

Copy link

@codescene-delta-analysis codescene-delta-analysis bot left a comment

Choose a reason for hiding this comment

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

No quality gates enabled for this code.

See analysis details in CodeScene

Quality Gate Profile: Custom Configuration
Install CodeScene MCP: safeguard and uplift AI-generated code. Catch issues early with our IDE extension and CLI tool.

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