Hi all,
In the following, everything after the \in is highlighted grey as if it were a comment.
Thanks for all the good work!
Anand Patil
def half_normal_like(x, tau): r""" half_normal_like(x, tau)
Half-normal log-likelihood, a normal distribution with mean 0 and limited to the domain :math:`x \in [0, \Infty)`.
.. math:: f(x \mid \tau) = \sqrt{\frac{2\tau}{\pi}}\exp \left{ {\frac{-x^2 \tau}{2}}\right}
:Parameters: x : float :math:`x \ge 0` tau : float :math:`\tau > 0`
""" # try: # constrain(tau, lower=0) # constrain(x, lower=0, allow_equal=True) # except ZeroProbability: # return -Inf return flib.hnormal(x, tau)
Hmm,
We have the grammar set to treat "raw" strings as a regular expression. They were introduced to the python language specifically to make writing regular expressions easier, so this seems logical.
Anyway, the grammar thinks that you're LaTeX code is a regular expression. My suggestion would be to remove the "r" from before your doc-string. Is there a particular reason you are using them?
–Alex
On Aug 11, 2007, at 9:04 PM, Anand Patil wrote:
def half_normal_like(x, tau): r""" half_normal_like(x, tau)
Half-normal log-likelihood, a normal distribution with mean 0
and limited to the domain :math:`x \in [0, \Infty)`.
.. math:: f(x \mid \tau) = \sqrt{\frac{2\tau}{\pi}}\exp
\left{ {\frac{-x^2 \tau}{2}}\right}
:Parameters: x : float :math:`x \ge 0` tau : float :math:`\tau > 0` """ # try: # constrain(tau, lower=0) # constrain(x, lower=0, allow_equal=True) # except ZeroProbability: # return -Inf return flib.hnormal(x, tau)
Alex Ross wrote:
We have the grammar set to treat "raw" strings as a regular expression. They were introduced to the python language specifically to make writing regular expressions easier, so this seems logical.
Anyway, the grammar thinks that you're LaTeX code is a regular expression. My suggestion would be to remove the "r" from before your doc-string. Is there a particular reason you are using them?
I'm more and more convinced as time goes on that we should just stop trying to interpret raw strings as regexps.
-Jacob
I think you are probably right. Does anyone else have an opinion on this?
I agree this doesn't seem right, and can produce some confusing results. On the other hand, it's very nice to have regex highlighting. Wouldn't it be possible to have the first string located within a re.XXXXX('') pattern be highlighted as regex? Am I wrong, or are those the only places where regex appear? I suppose then it would have to behave differently depending on whether or not the 'r' was appended...
Eric
On Aug 13, 2007, at 5:59 AM, Eric Abrahamsen wrote:
I think you are probably right. Does anyone else have an opinion on this?
I agree this doesn't seem right, and can produce some confusing results. On the other hand, it's very nice to have regex highlighting.
I prefer to trade-off false-positives for the nicety of regex highlighting.
Wouldn't it be possible to have the first string located within a re.XXXXX('') pattern be highlighted as regex? Am I wrong, or are those the only places where regex appear?
s = r"...." pattern = re.compile(s)
is always, possible, if contrived. I think re.XXXXX is an interesting suggestion though.
j.
I think you are probably right. Does anyone else have an opinion on this?
I agree this doesn't seem right, and can produce some confusing results. On the other hand, it's very nice to have regex highlighting.
I prefer to trade-off false-positives for the nicety of regex highlighting.
Wouldn't it be possible to have the first string located within a re.XXXXX('') pattern be highlighted as regex? Am I wrong, or are those the only places where regex appear?
s = r"...." pattern = re.compile(s)
is always, possible, if contrived. I think re.XXXXX is an interesting suggestion though.
I'm in the same boat with Jay.
I think it's kind of nice to have special highlighting for regex's. I'd settle for it only being switched on when we have re.* (r"regex" ... ) if the "always a regex w/ r" " really isn't suitable for others.
-steve
I agree that it's very nice to have highlighted re's if possible.
What if we did something like matching r"(?#) … " as a regular expression string? The would give us something explicit to match, but it would also mean you'd have to add it to any of your preexisting re's.