Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix and test expressions of the form BoxExpression[[...]] #561

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

mmatera
Copy link
Contributor

@mmatera mmatera commented Sep 20, 2022

Another small fix to something that I found working on MakeBoxes. When a BoxExpression is passed as the first element to Part, since it does not have in general an attribute _elements, the evaluation ends with an unhandled exception. In particular, this happens to RowBox. This PR fixes it by providing an implementation for that method.

Copy link
Contributor

@TiagoCavalcante TiagoCavalcante left a comment

Choose a reason for hiding this comment

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

LGTM

@@ -305,6 +305,13 @@ def apply_list(self, boxes, evaluation):
result = RowBox(*items)
return result

@property
def elements(self):
Copy link
Member

Choose a reason for hiding this comment

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

It feels like something in the code or the API is wrong here.

I get nervous about "properties" doing possibly unbounded calculations such as self.to_expressions().

If I understand correctly, the caller somehow knows this is a compound Expression/Element and assumes that therefore it has an .element attribute which is of type Expression?

It feels like what should be happening that the caller should be asking instead for a conversion, that is, should be calling to_expression().elements

I need to think about this more.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It feels like something in the code or the API is wrong here.

Probably it is, but I tried to build over the existing API. At least, this is "localized" in this class.

I get nervous about "properties" doing possibly unbounded calculations such as self.to_expressions().

If I understand correctly, the caller somehow knows this is a compound Expression/Element and assumes that therefore it has an .element attribute which is of type Expression?

The problem is that Part assumes that an Expression has a property elements. This just provides the property by creating an Expression. A different possibility would be to implement a different rule for working with RowBoxes. I thought this change was simpler, but maybe there is a better approach.

It feels like what should be happening that the caller should be asking instead for a conversion, that is, should be calling to_expression().elements

I need to think about this more.

Sure.

@rocky
Copy link
Member

rocky commented Sep 22, 2022

The what is most appreciated. However the how may need some more thought or discussion.

@TiagoCavalcante
Copy link
Contributor

@mmatera what is the status of this PR?

@mmatera
Copy link
Contributor Author

mmatera commented Nov 20, 2022

@mmatera what is the status of this PR?

@TiagoCavalcante, by now, it is a reminder to something we need to fix.

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.

3 participants