Conversation
…to commented-evaluation-process
…to commented-evaluation-process
* adding some pytests
|
@rocky, I was not sure about the change in the names, because it could produce certain confusion when merging other PRs. However, these names are closer to the convention. What do you think? |
…tomic.numbers` to `mathics.core.numbers.calculus` * the non-member ``apply_N`` was moved to the new module ``mathics.core.evaluators``. The logic of ``mathics.builtin.atomic.numeric.N.n_apply_with_prec`` was also moved to that module. * most of flake8 errors on the changed modules was fixed.
|
|
||
|
|
||
| def apply_nvalues(expr, prec, evaluation): | ||
| def apply_N(expr, prec, evaluation): |
There was a problem hiding this comment.
Note that evaluation has the last two parameters swapped. What's up here?
There was a problem hiding this comment.
The order of the parameters in apply_N (former apply_nvalues) is just the order that it had when it was the method N.apply_with_prec. On the other hand, the order in eval_N (former apply_N) is inverted because I wanted to put precision as an optional parameter, and then, it should go after evaluation, which is not optional.
I also used that to check if the names at some places were confused (because if it does, it will raise errors).
There was a problem hiding this comment.
Thanks for the explanation. This however then points out that this irregular and confusing.
For now, I think apply_N should be called apply_N_with_prec. (And we should rename N.apply_with_prec to N.apply_N_with_prec as well.
I also used that to check if the names at some places were confused (because if it does, it will raise errors).
This might seem like a clever trick or hack, but it's really the wrong way to handle the problem. The right way is to add types to the arguments and use flake8 or pylint to catch type errors rather than making parameter ordering.
There was a problem hiding this comment.
Thanks for the explanation. This however then points out that this irregular and confusing.
For now, I think
apply_Nshould be calledapply_N_with_prec. (And we should renameN.apply_with_prectoN.apply_N_with_precas well.
So, the idea would be to do not have prec as an optional argument, isn't it?
I also used that to check if the names at some places were confused (because if it does, it will raise errors).
This might seem like a clever trick or hack, but it's really the wrong way to handle the problem. The right way is to add types to the arguments and use flake8 or pylint to catch type errors rather than making parameter ordering.
Yes, but if both methods have the same parameters, flake8 and pylint are not able to distinguish which of the methods we need at some point of the code. But OK, I should have to add the types.
I just took a look at In the docstring It is not clear where the "reaches" a fixed point part is. I suppose this is the implied behavior of any kind of the Mathics/WL rewrite-rules apply process. The reason it doesn't feel to me like this clears things up yet, is because the whole apply/eval concept is too implicit and possibly inconsistent. So let me back up to make sure everyone is on the same page with respect to what "apply" and "eval" mean in Lisp functional programming as described in SICP (Sussman's and Abelson's The Structure and Interpretation of Computer Programs). This is where I am pretty sure Wolfram got his ideas from. He says he was following Lisp. Also, not that when I talk about "apply" I am not talking about Mathics/WL In functional programming and Lisp particular (but also true to some extent in Python and other programming languages) suppose I write: This in Lisp is a list, just like (10 4) is a list. It's "Head" (or in lisp "car") is In Lisp it is pretty easy to figure out what function to call and what it's arguments are. In WL this process is more involved with pattern matching and rule rewriting. Nevertheless I'll refer to this as the "apply" part, because that is totally analogous with what is done in Lisp. Any WL implementation has to do this kind of thing and so for lack of a better work "apply" seems to fit. Now after I call So having clarified (hopefully) what apply and eval both mean this is where the ugliness in our current code lies in my opinion. The apply step is what gets us to say Because the word If we were to go through the monster process of changing those My take to start out then to somehow document or comment we mean. |
Well,
yep. And also, maybe this claim of "reaching a fixed point" is also wrong: there is not an iterative process like in
Good!
Yes, and I think this is also due to many of these aspects was not clear enough for the people working on the project.
well, here I tried to follow the logic that we have before: when
OK, so, what should be the name?
I would prefer to not do that moster process.
|
Because things are a bit confusing and there isn't in my opinion a clear path, my opinion is just leave things for later when it will become clearer how all of this should be addressed. In my view efficiency we haven't achieved very effectively, although we have been very successful at making the code complicated and harder to understand. That's partly why I have been advocating no more speed improvements until we have a clearer idea of the big picture and a more modular and scalable structure and where we can measure and benchmark what's going on more effectively. Whatever complexity is there right now (whether or not in the name of "efficiency") let's just leave as is. I think we'll have to come back to this later. |
Improve association - rebase PR#90
sanity test to pass in a more aggressive sympy translation
Of particular interest were the changes to rewrite_apply_step which is where we will be focusing.
* adding some tests for apply_N * more verbose comments for apply_N * improving SameQ, numerify and the corresponding documentation. improving tests * CHANGES Co-authored-by: R. Bernstein <rocky@users.noreply.github.com>
{leaf,leaves}->element{s}, part 2
some more lea{f,ves} -> element{,s} converted in places we are currently
trying to describe and don't want to have to explain that by X we really
mean Y.
Create CODE_OF_CONDUCT.md
that we have two Atom classes. Make note of this, but defer a decision of what to do for later.
Mostly better code documentation...
Revise rewrite_apply_eval comment for threading.
leaf -> element more places
timing TraceEvaluation
|
This PR was reduced to a change of names. I close it and start again later. |
|
I am always a little sad when people work on things here and it has to be redone because of other work. Here though I'd say please hold off on any kind of evaluator/evaluation improvements for a while. We are in the process of reviewing all of this. So there is going to be an upheaval. here. And there is plenty of other things to do. For example, #167 seems like a simple isolated little thing (based on the work that was done in Symja). |
|
No problem. Most of the work here was merged in another PR. What is remaining here was a proposal of name changes. |
|
Relieved then. |
apply_N->eval_Nandapply_nvalues->apply_Nwhich is closer to the convention.Also, some improvements in the compatibility in the behavior of
SameQandExpression.numerifywere introduced, in order to implement the tests.