(Apologies for the html email, it was poorly formatted, making my example very 
difficult to follow. So let me try to give better examples.)

With sympy we would be able to create meaningful behavior for:

```
from sympy import symbols

y, x1, x2 = symbols('y x1 x2')

model = y ~ x1 + x2

model.is_linear() # -> True/False? (just an example!)
```

or 

```
from sympy import symbols

theta, N, mu, sigma = symbols('theta N mu sigma')

distribution = theta ~ N(mu, sigma)
distribution.sample() # -> a symbolic sampling from the normal distribution
```

and for dataframes, arrays, or matrices, we could do something like:

```
model = df.y ~ df.x1 + df.x2
model.fit()
test_predictions = model.predict(df_test)
```

I would assume strict evaluation and minimal computation done to return 
whatever "model" object we get back from the operation.

But as it stands, we can't use the operator, as it doesn't support a binary 
operation. To Serhiy's point (a different reply to my first post), 
`__sim__(self, other)` could be so implemented for integers, but that's not the 
domain I am particularly interested in. I consider this akin to the adoption of 
`@` for `__matmul__(self, other)`. We would not implement behavior for it, we 
would merely provide language support the `a ~ b` usage.

- The name "sim" is taken from LaTeX. I think it would be beneficial to stick 
to it.
- The semantic usage comes from R and the field of statistics. 

I do not intend to suggest we use R's evaluation model though - names would 
still need to exist in the namespace and would call the `__sim__` method of the 
first object (or `__rsim__` on the second). (To be complete, we'd also want 
`__isim__` for in-place, `a ~= b` but I don't currently have a strong 
motivating use-case for it.)
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/4TCCRH2AJDFGLYF25TKRNLQ5DZ3RCAYZ/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to