« first day (1876 days earlier)      last day (2609 days later) » 

2:15 AM
@Mr.Wizard ... some code:
@Mr.Wizard perhaps you should delete the messages after you have read them
 
2:31 AM
@WReach Thank you.
 
 
7 hours later…
9:36 AM
Am I the only one that thinks these answers are plain wrong?
4
Q: Centroid of country shape

vitoHow can I use RegionCentroid[] to find geometric centroid of the given country shape? GeoGraphics[{EdgeForm[Black], FaceForm[Black], Polygon[Entity["Country","Italy"]]}, GeoBackground -> None, PlotRange -> All]

They're not necessarily off by much for most countries, but the Earth is not flat.
Which seems to be the implicit assumption here.
 
9:48 AM
@kirma David's answer may be correct: CountryData["Italy", "CenterLocationLink"] depending what stands behind it. And yes, it would be good to ask OP about assumptions.
 
10:07 AM
@Kuba Yep, that might be right. It's not obvious how that result has been formed, though.
Maybe I care eventually enough to write an answer with Canada as an example...
 
 
1 hour later…
11:20 AM
This issue has existed on Linux for as long as I can remember:
6
Q: Front End does not respond to keys (version 10.2, Linux)

halirutanI was often complaining about the front end performance under Linux, but it seems I could pin down a very critical issue. I made a screen-cast that shows how to reproduce the issue Screen-cast on YouTube How to reproduce: Open a fresh Mathematica and type some code. In the screen-cast I used ...

It is still there in 11.0.1.
Very disappointing. It's why I hate using Mathematica on Linux. And because I use Mathematica a lot, I ended up hating to use Linux ...
I don't feel safe being stuck with OS X, expensive Macs, and at the mercy of Apple. But Windows sucks for scientific programming and Linux sucks for using Mathematica.
 
@C.E. and others who feel well in web world, any tips with:
0
Q: Inconsistent behavior of URLRead

KubaIt seems that sources of URL* related features are not initialized properly which leads to problems in many cases. Please follow those steps to reproduce the problem: Let's deploy a test api: api = First @ CloudDeploy @ APIFunction[ {} , HTTPResponse["", <|"Content" -> "TEST", "StatusCo...

And I'm not even done with #daily-fun with mathematica for today, I just found that problem trying to prepare a minimal example of another one :)
 
11:54 AM
Something I had not realized before is that an Image can be of "Bit" type and have all three RGB channels.
 
12:27 PM
@Szabolcs It really is OK most of the time. And you have to remember that even the front end on OSX is lightyears away from the one that runs on Windows.
 
12:45 PM
@halirutan except of resolution handling.
 
1:09 PM
@halirutan Is it only copy/paste that triggers it? Until I read your post, I wasn't sure what caused it. All I knew was that it kept happening every time I used Mathematica on Linux.
@Kuba Well, it runs in low resolution and it is consistent. That's much better than some of the half-hdpi-aware programs that show big and tiny UI elements side by side.
 
@Szabolcs I wouldn't dare to complain if documentation was correct about that.
Sure you are right, there are more important problems
 
1:50 PM
@Szabolcs If I remember correctly, yes. When I experience weird behaviour, I often try to stop and reproduce it. When my memory doesn't fail me, I discovered this bug when I was writing a post on SE or trying something out that was given in an answer.
 
Do you use M on Linux most of the time?
 
I just saw that at some point the FE was really messed up, so I restarted it and tried again. After a while, I could pin it down to the moment when I copied the code into the notebook.
@Szabolcs Yes. At home I'm completely on Linux. I don't like to work on my MacBook. At work I have a MacPro. So it's probably 60% Linux.
The real problematic part is, that many bugs I have reported years ago are still in 11. That is really annoying.
 
2:11 PM
@C.E. additional question, how to quickly reproduce 401 without using CloudDeploy with HttpResponse? Just to show 401
 
@Kuba Sorry, don't know.
 
ok :(
so I can't report a bug because there is a feature, smart!
 
2:31 PM
@Kuba would this work? URLRead["https://www.httpwatch.com/httpgallery/authentication/authenticatedimag‌​e/default.aspx?0.678044293601594"]
 
@chuy it return 404 not 401
 
hmm I get a 401
 
:/
 
Did you hit cancel on the window that pops up?
 
no window pops up :)
 
2:34 PM
ah ha
how about this? URLRead[HTTPRequest[URL["https://www.httpwatch.com/httpgallery/authentication/a‌​uthenticatedimage/default.aspx"],<|"Query"-> ToString@RandomReal[]|>]]
or better: URLRead[HTTPRequest[URL["https://www.httpwatch.com/httpgallery/authentication/a‌​uthenticatedimage/default.aspx"],<|"Query"-> ToString@RandomReal[]|>, Interactive->False]]
 
@chuy sorry on V11.0.1 Win10 it returns 404
 
interesting, I am on Windows 7 and using 11.0.1
 
2:52 PM
@chuy :-/
after
URLRead[HTTPRequest[
URL["https://www.httpwatch.com/httpgallery/authentication/\
a‌​uthenticatedimage/default.aspx"], <|
"Query" -> ToString@RandomReal[]|>, Interactive -> False]]
 
is there some non-printing character messing things up?
 
Maybe URLRead["https://httpbin.org/status/401", Interactive -> False]
 
@MichaelHale Thanks :)
@MichaelHale @chuy so no I can show another bug :)
URLRead["https://httpbin.org/status/401", Interactive -> False]
this returns 401
and Interactive prevents the dialog
Quit[] and run URLRead[... as a first action
dialog pops up :D
Only during first run.
The fix is to:
URLFetch; URLRead["https://httpbin.org/status/401",
 Interactive -> False]
because it is URLFetch which is loaded to late and some options are not passed correctly or something
#Daily-fun
 
3:10 PM
@xzczd 请问你是怎么把gif上传到评论里的?
@xzczd 是不是到问问题的地方上传,然后把地址复制出来?
 
@MichaelHale @chuy
0
Q: Inconsistent Authorization Dialog (401) handling

KubaThis issue is similar to one from a recent report: Inconsistent HTTPResponse handling but I decided to post a separate question because I have a fix for this one and not for the linked one. So, let's call where we should not: URLRead["https://httpbin.org/status/401", Interactive -> False] ...

 
@Kuba I did see the interactive auth trigger once on some code that I thought for sure had Interactive->False set. So maybe this was the cause. Good to know.
 
@MichaelHale yep, it is hard to track or to capture as it fixes itself :)
 
3:27 PM
@yode 是的……
 
@xzczd And you mean this?
 
……
I mean this:
Paste[]
ToExpression@First@NotebookRead@Experimental`NextCell[]
NotebookDelete@Experimental`NextCell[EvaluationCell[], All, 2]
 
The code work for you?
@xzczd
 
@yode Of course. I can make another .gif if you like?
 
@xzczd
 
3:37 PM
@yode
……@yode You should not add the ;
Or at least use
Paste[]
pic = ToExpression@First@NotebookRead@Experimental`NextCell[];
NotebookDelete@Experimental`NextCell[];
pic
 
@xzczd
你后面这个赋值给pic的方法可用
 
……因为现在我第二行加了个分号,所以,第三行的最后一个参数必须为1
 
另外,我得请教你个问题,困了我好久,
3
A: Help me understand this behaviour of the standard evaluation procedure with `Unevaluated`

Mr.WizardI believe we can explain this behavior by referencing: Working with Unevaluated Expressions - Robby Villegas Unevaluated must be wrapper before argument evaluation, not after, else it isn't stripped. Recall our discussion of the over-arching evaluator, and the fact that your inputs ...

 
……嗯?等下
 
他这里写的你看得懂不?
我真是醉你后面写的这种我之前试过很多次都没成功。。原来是少个了first。。
另外,我之前还试了用WRrench的办法来捕获这个Print,但也没成功
`Reap[Internal`HandlerBlock[{"Wolfram.System.Print", Sow[#] &},
For[i = 1, i < 5, i++, Print[Prime[i]]]]]`
 
3:54 PM
@yode ……可是你贴的最后一个GIF上面写了First啊
那个奇怪的现象我这里好像没法重现
 
我感觉是版本的问题,我联系过wolfram,但他们不认为Paste有bug
 
……就在刚才,我用某种方法造成了Paste的无限复制
 
这问题我就不管了,mma的bug也不是一个两个,感觉天天在跟bug打交道
 
但是我还没找到稳定重现这个现象的方法。不确定是笔记本Bug还是我操作不当
 
我也是,我也出现过了你那情况
我出现了一样的情况。。。
能帮我理解下Unevaluated的行为不?我上次提问了一次,那m_good好像很不高兴的样子
 
4:00 PM
WReach那个捕捉剪贴板的方法你是在哪找到的?目标输出是啥?我这里好像成功了欸
{Null, {{HoldComplete[2], HoldComplete[3], HoldComplete[5], HoldComplete[7]}}}
输出是这个
 
但我至今也没能理解Mr.Wizard说的这些是什么意‌​思
 
好吧,说Unevaluated。我觉得我是理解了的
 
我也成功了,我是说怎么改装一下,让它捕捉Paste的Print
 
……不一定能行吧?Print走的“管道”和剪贴版一样吗?
 
我认为这样应该可以,但是为知道为什么不行,这些undocumental函数很难理解
Reap[Internal`HandlerBlock[{"Wolfram.System.Print",
Sow[ReleaseHold[#]] &}, Paste[]]]
不是,它是捕捉Wolfram.System.Print的结果
 
4:04 PM
我倾向于认为不行。这个其实可以单开个主题的。
好了,说Unevaluated
首先我之前谈显式存在那个帖子你看了吗?
 
你说贴吧吗?
还是哪里?
 
Unevaluated里面的坑虽多,但我觉得Mr.Wizard在那帖里所谈的问题其实算是其中相对容易理解的部分了‘
 
啊,没有,我的帐号之前被盗过,现在不管我说什么都会有人删我的贴,所以我就不用贴吧了
 
这函数恶心到我了,也可能是我英语太差,Mr.Wizard说的那些我看了20次不止(另外,咱在大厅里聊这么high会不会不太好,或者得单独找个房间?)
 
4:08 PM
@yode 你把这个看了吧,Mr.Wizard所说的内容和这个是类似的。
……嗯,单开个房间吧。
@yode Let's continue the discussion in this room: chat.stackexchange.com/rooms/55014/…
 
Nobody expects the Chinese invasion!
;)
 
@kirma Sorry dude 囧
As a compensation, let me summarize the useful part of the discussion above in English.
1. There seems to be some kind of bug in front-end, under certain conditions, the code piece:
Paste[];
ToExpression@First@NotebookRead@Experimental`NextCell[]
NotebookDelete@Experimental`NextCell[EvaluationCell[], All, 2]
will cause an infinite loop of pasting
Sadly we haven't find a stable way to reproduce the phenomenon currently.
……OK, it's not a bug, just a misoperation, I forgot to copy a picture first, so the code piece is Paste[]ed again and again...
2. The phenomenon on this gif:
might be a bug. I can't reproduce it in v9.0.1.
 
4:35 PM
@xzczd No problem at all, just a bit amusing. :)
 
3. WRrench uses the following code to catch the content printed by Print:
Reap[Internal`HandlerBlock[{"Wolfram.System.Print", Sow[#] &},
For[i = 1, i < 5, i++, Print[Prime[i]]]]]
Can this approach be used to catch the content printed by Paste[]?
(This question is too hard so I suggest yode to ask it in the main site.
4. The usage of Unevaluated is so confusing!
Period :)
 
 
2 hours later…
7:01 PM
Hey folks, when defining nested inner functions i.e. f[..] = Module[... g[...] := ...] should one put "g" in the local variables list for "Module"?
 
@Evan If you want g to be local then yes
Otherwise no
 
when would you not want the function to be local? I'm kinda used to say... def a(..): ... def b(...): ... in python, in which case b would seem local
 
@Evan A typical pattern for a closure, for example, uses that
 
uses which?
 
@Evan
For example
Sorry, I misread you. An example where you might want it non-local could be
Module[{count=0},
g[x_] := (count=count+1; count+x)
]
so g[2] gives 2. Run it again, gives 3. Again, gives 4
and the state is in a hidden variable conut
or if you are using the Module variable just to do some intermediate math
Module[{lala},
lala=something[];
With[{lolo=lala}, g[x_]:= lolo+x
]
The idea is just that the module variables get renamed with some weird suffix, so you can, in principle, only refer to them while inside the module
 
7:18 PM
ahh... reminds me of macro hygene
 
There can be many cases where you are only in the module to hide some variable while defining another one that should be visible outside
 
Well mmm... what if I had something like
Well okay... in your example, why would you not want g to be local?
if I used the symbol g somewhere else, in the program, couldn't that be problematic?
 
@Evan If it was local to that module, you couldn't use it at all
from outside the module
If you want to only use it in some short lexical scope, you can put it in another module if you like
or, you can just give up on hiding "count". It's a style thing
 
why not hide g and count, and return g?
 
@Evan you also have contexts
@Evan That's another option. But if it's not a function, it doesn't make much sense to do:
gg = Module[{count=0},
g[x_] := (count=count+1; count+x);
]
Sorry
gg = Module[{count=0},
g[x_] := (count=count+1; count+x);
g
]
Sorry again
gg = Module[{count=0, g},
g[x_] := (count=count+1; count+x);
g
]
That doesn't have advantges, and is uselessly weirder, than just


Module[{count=0},
gg[x_] := (count=count+1; count+x);
]
 
7:25 PM
okay I think I see what's going on now
what if I want a new "counter object" for each time I call gg?
 
Then what's the point of a counter object
 
like I have some new copy of count, with a function "g" that closes over that copy of count?
 
Well, then do
createGg[]:=Module[{gg, counter=0},
gg[x_]:=(counter=counter+1; counter+x);
gg
]
g1 = createGg[];
g1[2]; g1[2]...
g2 = createGg[];...
Module is not making gg local. It's making it unique, and inaccessible by name (sort of)
Same with counter
 
wait does Module add this unique $1234 suffix?
I'm mostly familiar with closures from other languages
I guess everything here is a symbol within some namespace?
 
@Evan everything is an expression, which is in itself a tree of expressions. Leaves are called atoms, and one type of atom are symbols
And symbols are the stuff to which the evaluation rules are attached to
 
7:33 PM
hmm okay
 
Yes, Module adds the unique suffix
 
okay I think I see now how this works. Thank you so much for your help!
 
No problem, good luck
 
I really am itching to learn to use mathematica as a proper programming language rather than something I just cram unruly expressions through Integrate and pray and wait a few minutes for
 
@Evan it's very worth it
 
7:35 PM
yeah especially with something like JLink
 
 
2 hours later…
9:52 PM
@Kuba @Mr.Wizard Could you defreeze this please? chat.stackexchange.com/rooms/29579/packagedata-net
@C.E. Are you still working on PackageData?
 
10:16 PM
Should be done
 
10:30 PM
@Szabolcs Is there work that needs to be done?
@Szabolcs It didn't catch on as one might have hoped... ten visitors a day including the traffic that the ad here on SE brings in...
 

« first day (1876 days earlier)      last day (2609 days later) »