I can imagine the hypothetical binary tilde being pretty for some kind of
equivalence. This is definitely not enough to motivate me to actually want
to add it. But I think this would read OK as equivalent:
numpy.allclose(arr1, arr2)
arr1 ~ arr2
However, the problem is that there are lot
On Mon, 24 Feb 2020 at 17:47, Aaron Hall via Python-ideas
wrote:
>
> The context for this is statistics , so I'll quote Wolfram on tilde in the
> context of statistics: http://mathworld.wolfram.com/Tilde.html
>
> "In statistics, the tilde is frequently used to mean "has the distribution
> (of),"
On 2/24/2020 2:59 PM, Guido van Rossum wrote:
The biggest problem remains that 99% of your explanation (and that of
others who seem to understand what you want) uses the words of the
application domain (statistics, stochastic variables, distributions)
in a way that is unhelpful to convey your n
Yes, at this point I think I must concede the battle. I thought I had discussed
this with core developers in the past, but I couldn't find the results. So here
we have it - making `~` a binary operator as well is a no-go.
Perhaps some better advocate than I will take it up in the future.
Thank
I may have led in that direction, and I know R only passingly, not well.
But my understanding is that thinking of a data structure that gets parsed
by an evaluator, e.g. "do a linear regression with this structure (and a
DataFrame)" is better than a lambda.
I'm sure it's possible to describe this
I am no expert on R, but R lazily evaluates arguments to functions; see
https://cran.r-project.org/doc/manuals/r-devel/R-lang.html#Argument-evaluation
(plus
the rest of that page, which is the language spec). Tilde is strictly used
for modeling. Also relevant would be the operator precedence
https:
24.02.20 22:02, Guido van Rossum пише:
Hm, that's actually an interesting take. Can you compare it to the kind
of "quoting" that happens in a lambda? Is there some kind of translation
of the OP's original example (Lottery ~ Literacy + Wealth + Region) to a
lambda involving those words?
I thin
On Mon, Feb 24, 2020 at 11:00 AM David Mertz wrote:
> Well... also, the meaning in R is quite a bit different from any of the
> meanings suggested by Wolfram. In fact, although the most common use in R
> is "depends on", it's technically just a generic delayed evaluation without
> any inherent s
But that behavior is specific to Jupyter and so it could similarly
provide auto-complete or syntax highlighting for usage of
`smf.ols(formula=...)`. Like PyCharm provides syntax highlighting for
strings used as the `pattern` argument for the various functions of the
`re` module. So if it's only fo
The biggest problem remains that 99% of your explanation (and that of
others who seem to understand what you want) uses the words of the
application domain (statistics, stochastic variables, distributions) in a
way that is unhelpful to convey your needs to those who are in a position
to implement a
Well... also, the meaning in R is quite a bit different from any of the
meanings suggested by Wolfram. In fact, although the most common use in R
is "depends on", it's technically just a generic delayed evaluation without
any inherent semantics at all. Or, that is to say, tilde is just a certain
Aaron Hall wrote:
> The context for this is statistics , so I'll quote Wolfram on tilde in the
> context of
> statistics: http://mathworld.wolfram.com/Tilde.html
> "In statistics, the tilde is frequently used to mean "has the distribution
> (of)," for
> instance, X∼N(0,1) means "the stochastic (r
The context for this is statistics , so I'll quote Wolfram on tilde in the
context of statistics: http://mathworld.wolfram.com/Tilde.html
"In statistics, the tilde is frequently used to mean "has the distribution
(of)," for instance, X∼N(0,1) means "the stochastic (random) variable X has the
di
This seems like a feature looking for a use-case.
I don't think the use case presented is good enough, since in this thread I've
seen it given three incompatible operator priorities (higher than `+`, lower
than `+`, and one that seems to be a sort of assignment?) and a handful of
loosely relate
On 24.02.20 13:24, Rhodri James wrote:
This seems a lot like trying to shoehorn something in so one can write
idiomatic R in Python. That on the whole sounds like a bad idea; a
friend of mine use to say he could write FORTRAN in any language but
no one else could read it. Wouldn't it be more p
I don't see what's wrong with the status quo:
smf.ols(formula='Lottery ~ Literacy + Wealth + Region', data=df)
If I understand correctly you want to use instead:
smf.ols(formula=df.Lottery ~ df.Literacy + df.Wealth + df.Region)
Or since some people favor indexing over attribute access
In mathematics, in my recollection, the tilde is used for
1. Unary approximate number
2. Binary equivalence
3. Binary congruence/isomorphism
The last is more formally an equal sign with tilde on top: ≅. I think maybe
just simplified for chalk boards where context makes it clear. Those are
all aki
On 2/24/20 7:24 AM, Rhodri James wrote:
This seems a lot like trying to shoehorn something in so one can write
idiomatic R in Python. That on the whole sounds like a bad idea; a
friend of mine use to say he could write FORTRAN in any language but
no one else could read it. Wouldn't it be mo
On 24/02/2020 00:59, Brendan Barnwell wrote:
On 2020-02-23 16:32, Guido van Rossum wrote:
> Assuming that the reader is familiar with the example `Lottery ~
> Literacy + Wealth + Region` is *not* going to work. I have literally no
> idea from what field that is taken or what the purpose of the
24.02.20 02:27, Aaron Hall via Python-ideas пише:
I have no behavior for integers in mind. I would expect high-level libraries to
want to implement behavior for it.
- sympy
- pandas, numpy, sklearn, statsmodels
- other mathematically minded libraries (monadic bind or compose?)
To do this we ne
On 2020-02-23 19:35, Aaron Hall via Python-ideas wrote:
My main goal here is to increase the flexibility of Python for
various domains where I have used `object0 ~ object1` - and can't yet
do so in Python.
You've said something like this a couple times in this thread, but
personally I don't f
Thanks for the feedback, David. Sources that demonstrate that "sim" is the
wrong semantic would be very much appreciated.
I chose "sim" because it's the same name and usual top usual result for an
infixed tilde in LaTeX.
And note that there is an implied relationship between the two sides in the
I am not yet a contributor to either, I have an invitation to contribute to
Sympy, and I have contributed to CPython, and I would like to be a contributor
on all of these libraries
(You might know me from my answers on Stack Overflow, and I gave the slots talk
at PyCon 2017 where we met - now
Jim, thanks for your feedback. I didn't intend for this to address the
interaction term syntax.
As you can see the R language has several ways of representing the same
information:
https://stat.ethz.ch/R-manual/R-devel/library/stats/html/formula.html
I would prefer to write, e.g.: `y ~ interac
Aside from all the other problems, 'sim' (~) in LaTeX and mathematics means
something completely different than 'depends on' (~) in R. Trying to
overload those meaning makes everything harder.
I would recommend doing what NumPy did for many years for matrix multiply.
Use an existing operator. Yes
Are you a contributor or core dev on one of those packages? That would be
useful context to have.
Also, did you see Jim Baker's module? How do you propose to translate
Patsy's ':' operator?
On Sun, Feb 23, 2020 at 5:22 PM Aaron Hall via Python-ideas <
python-ideas@python.org> wrote:
> > Is there
> Is there an existing function in one of the libraries you mention
> that has the desired behavior (in the context of that library)? That would
> help.
Yes, and we are currently parsing and evaluating strings to convey the meaning.
Patsy is currently used by statsmodels to parse strings in the
On 2020-02-23 15:58, Aaron Hall via Python-ideas wrote:
(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, x
Aaron,
It's too soon to start drafting a PEP. However you need to get at least one
core dev to understand your proposal well enough that they will act as a
*sponsor* for your proposal. Once you have a willing sponsor you can then
put it forward in PEP form. See PEP 1 for PEP sponsorship when the a
Supporting ~ as a binary operator is an interesting idea, especially given
the relatively limited usage of unary ~. However, the big hole in this
proposal for formulas is that there is a de facto standard "minilanguage"
for writing such formulas in Python, namely what Patsy supports:
https://patsy.
On 2020-02-23 16:32, Guido van Rossum wrote:
> Assuming that the reader is familiar with the example `Lottery ~
> Literacy + Wealth + Region` is *not* going to work. I have literally no
> idea from what field that is taken or what the purpose of the example
> is. Please don't expect that I can jus
Guido, thank you so much for your kind review.
I think I would prefer
```
(A ~ B) + C
```
as it would first create a coalescing object to which it knows C is added, and
this is the usual way it is used.
I believe Sympy could handle it easily either way, but dataframes/arrays less
well so (sinc
Aaron Hall wrote:
> Currently, Python only has ~ (tilde) in the context of a unary operation (like
> -, with __neg__(self), and +, __pos__(self)).
> ~ currently calls __invert__(self) in the unary context.
> I think it would be awesome to have in the language, as it would allow
> modelling along
I still can't follow this explanation.
Operators in Python have a priority, which determines order of evaluation.
In the example
A ~ B + C
is this equivalent to
A ~ (B + C)
or to
(A ~ B) + C
???
It's not unheard of to add an operator to Python that's primarily important
for a certain
I have no behavior for integers in mind. I would expect high-level libraries to
want to implement behavior for it.
- sympy
- pandas, numpy, sklearn, statsmodels
- other mathematically minded libraries (monadic bind or compose?)
To do this we need a name. I like `__sim__`. Then we'll need `__rsi
On 2020-02-23 16:00, João Matos wrote:
Hello,
Can't you use eval()?
This
return eval(expr)
instead of
return expr.evaluate()
You can use eval if expr is a string, but then you have the same
problems that were mentioned in a recent thread about "SQL strings":
it's not syntax-highlighted, s
Hello,
Can't you use eval()?
This
return eval(expr)
instead of
return expr.evaluate()
Best regards,
João Matos
On 23/02/2020 23:04, Brendan Barnwell wrote:
On 2020-02-23 14:38, Steven D'Aprano wrote:
Hi Aaron, and welcome!
Your proposal would be a lot more interesting to me if I knew wha
(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_
On 2020-02-23 14:38, Steven D'Aprano wrote:
Hi Aaron, and welcome!
Your proposal would be a lot more interesting to me if I knew what this
binary ~ would actually do, without having to go learn R or LaTeX.
You say:
I think it would be awesome to have in the language, as it would allow
modelli
Hi Aaron, and welcome!
Your proposal would be a lot more interesting to me if I knew what this
binary ~ would actually do, without having to go learn R or LaTeX.
You say:
> I think it would be awesome to have in the language, as it would allow
> modelling along the lines of R that we currently
23.02.20 23:51, Aaron Hall via Python-ideas пише:
This is not a fully baked idea, perhaps there's a good reason we haven't
added a binary `~`. It seems like I've seen discussion in the past. But
I couldn't find such discussion. And as I'm currently taking some
statistics courses, I'm getting R
41 matches
Mail list logo