I'm getting an infuriating syntax error in streamlit that I can't figure out. This code works totally fine and displays the chart:
ward_housing_cost = alt.Chart(df_ward).mark_bar().encode(
alt.X('Ward:N', axis=alt.Axis(format='d')),
alt.Y('avg_housing_cost_ward:Q', title = 'rating of housing cost',
scale=alt.Scale(domain=(0, 5))
).properties(title = 'Rating of housing cost by ward')
st.altair_chart(ward_housing_cost)
...but this one gets the syntax error:
ward_streets_sidewalks = alt.Chart(df_ward).mark_bar().encode(
alt.X('Ward:N'),
alt.Y('avg_streets_sidewalks_ward:Q', title = 'rating of maintenance of
streets/sidewalks')
).properties(title = 'Rating of maintenance of streets/sidewalks by ward')
st.altair_chart(ward_streets_sidewalks)
here is what the error looks like:
File "/app/shs2021/streamlit_app.py", line 90
ward_streets_sidewalks = alt.Chart(df_ward).mark_bar().encode(
^
SyntaxError: invalid syntax
I have tried everything I can think of including rewriting the thing from scratch, renaming the chart, etc.
The answer is: there WAS a syntax error, but it was in the block of code ABOVE where the error said it was. I didn't realize that was possible; thanks #joelostblom for the heads up.
Related
So I'm taking Udacity's Swift for Developers course. I attempted to look at the forums for this question but oddly, they were quiet. This is the programming prompt:
var forwardString = "stressed"
var backwardsString = forwardString.characters.reversed()
print(backwardsString)
var lottaLikes = "If likeyou wanna learn Swift likeyou should build lots of small apps cuz it's likea good way to practice."
var noLikes = lottaLikes.replacingOccurrences(of:"like", with:"")
print(noLikes)
For whatever reason, I keep getting this error message:
Be sure that you have replaced all occurences of the word "like" and removed any extra spaces.
What am I missing here? If you need clarification on this I would be happy to provide it.
Thank you
It may be that your code gets the job done, but only because your variable lottaLikes is written in a weird way. You usually would have two spaces surrounding the word "like" so just removing the word would leave 2 spaces in a row. I would suggest writing the following line:
var noLikes = lottaLikes.replacingOccurrences(of:"like ", with:"")
It may be that Udacity is not checking the actual output, but the code itself. If so, It may be looking for something like I wrote above.
If this still does not work, you may want to write another line like so:
var noExtraSpaces = noLikes.replacingOccurences(of: " ", with: " ")
My question is a little bit stupid, but still, I would like someone who can help me if he/she face the same problem as me.
I copy the codes directly from MATLAB mathwork:
anonrosen = #(x)(100*(x(2) - x(1)^2)^2 + (1-x(1))^2);
opts = optimoptions(#fmincon,'Algorithm','interior-point');
problem = createOptimProblem('fmincon','x0',randn(2,1),...
'objective',anonrosen,'lb',[-2;-2],'ub',[2;2],'options',opts);
However, it gives the following error message:
Undefined function 'createOptimProblem' for input arguments of type 'optim.options.Fmincon'.
createOptimProblem should be a built-in function, but with the presence of the error message, I wonder if I need to declare sth before using createOptimProblem, what should I do?
I am using R2013a version
I built a report in crystal reports (version 11.5.12.1838 - yes it's old, but I have no ability to upgrade it, it comes with the software we use for cash reporting).
I have this formula:
if (DateTime({#Date1}) = Datetime({rpcRGHL5DayBalanceView;1.1date}))
then
{rpcRGHL5DayBalanceView;1.1}
else
999999999999.99
The report runs and exports fine within crystal as well as the application we use. However, when using CrExport.exe (free command line tool) the report fails to generate and provides this error.
Error : A string is required here. Details: errorKind Error in File RGHL-5DayBalanceView {25B5C1DE-4C71-4A2D-816E-165F95A6B03B}.rpt:
Error in formula Balance1:
'if (DateTime({#Date1}) = Datetime({rpcRGHL5DayBalanceView;1.1date}))
then ' A string is required here. Details: errorKind
This seems to happen when the parameter I pass in via the command line differs from the stored value on the report. If I pass in the same value, the report generates, but the data is not updated. The data that was saved on the report is what I get.
I use this CrExport.exe with several other reports with no problem. Not sure if it's a bug in the command line tool or not.
Also, if I change the values from numeric to text via this code.
if (DateTime({#Date1}) = Datetime({rpcRGHL5DayBalanceView;1.1date}))
then
ToText({rpcRGHL5DayBalanceView;1.1},0)
else
ToText(999999999999.99)
Then I get this error from the command line program.
Error : Too many arguments have been given to this function. Details: errorKind
Error in File RGHL-5DayBalanceView {98633D00-5B70-4B7D-839C-1D0CEB359AE9}.rpt:
Error in formula Balance1: 'if (DateTime({#Date1}) = Datetime({rpcRGHL5DayBalanceView;1.1date})) then
'Too many arguments have been given to this function.
Details: errorKind
Any help is much appreciated. Let me know if more information is needed and I will do what I can to provide it.
try like this:
if (DateTime(CStr({#Date1})) = Datetime({rpcRGHL5DayBalanceView;1.1date}))
then
ToText(CStr({rpcRGHL5DayBalanceView;1.1}),0)
else
ToText(999999999999.99)
I have a date field inserted in a Lucene database with the following code:
Document.Add(new NumericField("TimeStamp", Field.Store.YES, true).SetLongValue(Data.TimeStamp.ToBinary()));
And I have the following query:
var Sort = new Sort(new SortField("TimeStamp", SortField.LONG, true));
var ParsedQuery = ParseQuery(_Parser, SearchQuery);
var Filter = new QueryWrapperFilter(ParsedQuery);
var Hits = _Searcher.Search(ParsedQuery, Filter, Skip + Limit, Sort);
But it crashes when executing the search method with the following:
A first chance exception of type 'Lucene.Net.QueryParsers.QueryParser.LookaheadSuccess' occurred in Lucene.Net.dll
A first chance exception of type 'System.IO.IOException' occurred in Lucene.Net.dll
A first chance exception of type 'System.IO.IOException' occurred in Lucene.Net.dll
A first chance exception of type 'System.AccessViolationException' occurred in HDIndexing.dll
Additional information: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
If I replace the Sort variable with one of the constants, such as Sort.RELEVANCE then the search works properly.
The problem comes from my custom search.
Incidentally I noticed something else odd and I do not know if these is a connection: If I inspect my Lucene DB with the Luke tool, all my fields are reported to be strings:
http://i.stack.imgur.com/SnlSD.png
I do not know if this is a bug in Luke or something is wrong with how Lucene is set up on my end.
I tried to change the sort to a type 'string' to see what would happen, but it crashes the same way, so either way, the type of the field doesn't seem to have an impact.
Has anyone experienced that problem before?
It could be similar to someone else's post: lucene.net sort not working access violation
I am using the tm and wordcloud packages in R 2.15.1.
I am trying to make a word cloud from a DTM. Here is the code:
library(wordcloud)
thedtmsparse = inspect(sparse)
trymatrix = t(thedtmsparse)
colnames(trymatrix) = c()
comparison.cloud(trymatrix, max.words=15, random.order=FALSE)
I get the following error from the last command:
Error in strwidth(words[i], cex = size[i], ...) : invalid 'cex' value
I have used the same code on another DTM where it worked fine and I got the word cloud.
Can somebody tell me a fix for the error?
Ravi
You haven't provided reproducible code (probably a big reason no one answered your question), so I can only venture to guess what the problem might be.
I faced this same error, so I'll share my experience. The problem was I had NA's instead of 0's in my term document matrix. Simply fixing that fixed that problem.