I'm doing text parsing in Julia and need to test if certain strings are blank (in order to parse into floats). I have been using isblank() booleans in <0.4 Julia, but after upgrading to 0.4, I get the following warning:
julia> isblank(q)
WARNING: isblank(s::AbstractString) is deprecated, use all((c->begin
c == ' ' || c == '\t'
end),s) instead.
in depwarn at deprecated.jl:73
in isblank at deprecated.jl:50
while loading no file, in expression starting on line 0
true
What replaced isblank()? Is the above really the replacement? My googling didn't turn up anything useful.
Yes, that is the replacement.
Basically in #5939 and related issues, it was revealed that answering isblank is a lot harder than it might first appear given Unicode complexities.
The deprecation occurred in #8233.
Everything looks natural, it must be a replacement in new version, you can add the line bellow in your code and replace (using Ctrl+H) all isblank( with isblk(. I wish it works for you.
isblk(s)=all((c->begin c == ' ' || c == '\t' end),s)
now isblk([]) # => true
Related
I am trying to use Run Keyword If with or but for some reason it does not work and I could not understand why. It shows me an error No keyword with name 'or' found. I assume there is some syntax error. I also tried with OR but it did not work.
Keyword 1
Check Walkthrough Guide Opened
Go to ${WALKTHROUGH_URL}
Open Walkthrough Guide If It's Closed
Wait Until Element Is Visible ${WELCOME_POPUP} ${WFE_TIMEOUT}
Page Should Contain Element ${POPUP_TITLE}
Keyword 2
${ELEMS}= Execute JavaScript return localStorage.getItem('peopleAnalyticsTourDismiss')
Run Keyword If ('${ELEMS}' == 'true') or (${ELEMS}' == 'None') Run Keywords
... Execute Javascript localStorage.setItem('peopleAnalyticsTourDismiss', 'false')
... AND Reload Page
You need to convert the two spaces on either side of "or" to a single space. Robot sees the two or more spaces and thinks "or" is the keyword to run.
Run Keyword If ('${ELEMS}' == 'true') or (${ELEMS}' == 'None') Run Keywords
# ^^ ^^
Robot Framework is understanding your OR as the second argument of the keyword Run Keyword If. Switch the double spaces for a single one, like the example below:
Run Keyword If ('${ELEMS}' == 'true') or (${ELEMS}' == 'None') Run Keywords
This way, robot will understand ('${ELEMS}' == 'true') or (${ELEMS}' == 'None') as just one argument of Run Keyword If, with is the condition one.
If you still have doubts, I've found this issue with a similar problem, and a good solution as an example.
Other thing that can be giving you some trouble, is that you missed a ' in the beggining of the second comparison: or (${ELEMS}' == 'None'). Try changing it for one of the options below:
or ('${ELEMS}' == 'None')
or ("${ELEMS}" == "None")
or ("""${ELEMS}""" == """None""")
Please refer to the Builtin library for doubts about triple quotes.
I am learning from the book Learn Python The Hard Way 3.6, by Zed Shaw
There are a series of 6 target.write commands towards the bottom of the script and he wants me to simplify them into a single target.write command using strings formats and escapes. However, I am stuck.
Here is the original code:
from sys import argv
script, filename = argv
print(f"We're going to erase {filename}")
print("If you don't want that, hit CTRL-C (^C).")
print("If you do want that, hit RETURN.")
input("?")
print("Opening the file...")
target = open(filename,'w')
print("Truncating the file. Goodbye!")
target.truncate()
print("Now I'm going to ask you for three lines")
line1 = input("line 1:")
line2 = input("line 2:")
line3 = input("line 3:")
print("Im going to write these to the file.")
target.write(line1)
target.write("\n")
target.write(line2)
target.write("\n")
target.write(line3)
target.write("\n")
print("And finnaly, we close it")
target.close()
So far I have tried
target.write(line1),(line2),(line3)
but this gives a logical error of only writing to one line not all three.
target.write(line1) + (line2) + (line3)
with this one I get error
'unsupported operand types for +: 'int' + 'str'
target.write(line1),\n,(line2)\n(line3),\n
with this one I get error:
unexpected character after line continuation character
(<string>,line 22)
I have been googling and searching here for answers but have not found anything. One person posted a very similar question except for Zed's 2.7 book. However I am reading Zed's 3.6 book so the answers were no help to me unfortunately.
I'm not sure what you have and haven't covered so far in the book as I'm not familiar with it but one way to do what you want is to format the string first and then pass it to the write method like this:
target.write("{0}\n{1}\n{2}\n".format(line1, line2, line3))
I am new to Python and I am having issues when breaking a line of code. I am using Python 3.6 on Spyder.
When I try to break any line and I run the code, Python reads only until before the backslash and retrieves and error. For example, I want to break
a = 1 + 2 + 3
into
a = (a + b \
+ 3)
It gives me the error SyntaxError: unexpected EOF while parsing.
I have checked with and without the backslash, and with different indentations in the second line.
I have read the way of breaking a line of code is this one...is there anything I have to activate on my IDE or something like that?
If you use parenthesis the line break is implicit, so you could break your line after the plus sign like so:
a = (a + b +
3)
Or like so:
a = (a + b
+ 3)
By the guidelines the backslash needs only to be used if necessary, otherwise please use the implicit one.
I am using lintr to ensure my code meets good R style guidelines, but for some reason, the commas_linter does not catch it when I do not put a space after a comma if there is a blank line preceding the erroneous line. Am I doing something wrong, or is this a bug in the package?
Here's a MWE
file: Test.r
#random comment
a <- c(4,5)
b = 7
Then, I run the following:
lintr::lint("./Test.r", linters = list(spacesAfterCommas = commas_linter,
useArrowForAssignments = assignment_linter))
The only error I get is the following:
./Test.r:4:3: style: Use <-, not =, for assignment.
b = 7
^
Why is the commas_linter not catching my error?
I noticed a strange malfunction in using findFn function (library sos) and I can't find out the source. While it works fine on my Windows XP pc, it does not on my Vista one.
library (sos)
findFn("randomization test")
# in both finds 72 results
findFn("{randomization test}")
# In XP finds 19 or about so, but in Vista whenever I use {} and more than one word inside,
# I keep getting the following:
found 0 matches
x has zero rows; nothing to display.
Warning message:
In findFn("{randomization test}") :
HIT not found in HTML; processing one page only.
R ver = 2.10.1 and packages updated.
Any ideas where the problem might be?
Bonus: As it's obvious, I was looking for functions about tests for randomized experiments
In the source code of the sos package, findFn.R, line 80, I found the mistake
if (substr(string, 1, 1) != "{")
string <- gsub(" ", "+", string)
This "if" is wrong, with an != instead of ==, and therefore the space doesn't get translated into a +. The quick solution would be to use the "+" syntax yourself
so:
> findFn("{randomization+test}")
found 19 matches