« first day (2889 days earlier)      last day (1592 days later) » 

1:10 AM
@b3m2a1 Yes found out about this by accident shortly after it was implemented.
491
Q: Implement ```-style (fenced) Markdown code blocks

Mathias BynensCurrently, Stack Exchange’s Markdown parser only allows four-space indents to represent code blocks: // some code // another line of code GitHub Flavored Markdown and other Markdown implementations allow for an alternative syntax, that doesn’t require indenting each code line: ``` // ...

Specifying a different language, however, was always possible. You had to include a specific html comment before your indented code-block.
 
1:25 AM
@ded7 These things are inherently hard. What I've seen often is that Mathematica fails to simplify expressions of such kind even if you give assumptions about number types and ranges.
If you have a real question behind this, feel free to ask it on main, where everyone can look at it.
 
 
4 hours later…
5:39 AM
@halirutan yeah I remember doing that but also remember having to look up how to do it every time. This is much more convenient.
 
6:03 AM
This's part of a package:
BeginPackage["YMat`"]
Unprotect@@Names["YMat`*"];
ClearAll@@Names["YMat`*"];

YMos::usage="YMos[n_Integer,list_?VectorQ, i_]"
YBjt::usage="YBjt[n_Integer,list_?VectorQ, i_]"
myPseudoInverse::usage="myPseudoInverse[m_List?MatrixQ/;Precision[m]===Infinity]"
Begin["`Private`"]

YMos[n_Integer,list_?VectorQ, i_]:=

Module[{M,idx,idx1, Y,gm,ro, RG},idx=Pick[Range[Length[list]],UnitStep[list-1] UnitStep[n-list],1];
M=ConstantArray[0,{n,n}];
idx1=list[[idx]];
gm=ToExpression["gm"<>IntegerString[{i}]];
Are two lines below really necessary?
Unprotect@@Names["YMat`*"];
ClearAll@@Names["YMat`*"];
 
6:26 AM
I'm have the contents below in script.mma and I'm running `MathematicaScript -script script.mma`. Sometimes it exits after printing "hello" and sometimes it executes all lines. What's going on? I feel like I'm doing something embarrassingly stupid.
```
Print["hello"];
obs = {{-3, 9}, {-2, 4}, {-1, 1}, {0, 0}, {1, 1}, {2, 4}, {3, 9}};
Export["/tmp/out.png", ListPlot[obs]];
Print["bye"];
```
When it prints "hello" only, there is no other output to stdout or stderr and the shell exit code is 0, and the PNG file is not created.
Same apparently unpredictable behaviour if the plot data is empty:

MathematicaScript -script script.mma

```mathematica
Print["hello"];
Export["/tmp/out.png", ListPlot[{}]];
Print["bye"];
```
$ MathematicaScript -version
WolframScript 1.2.0 for MacOSX-x86-64
 
7:37 AM
@anhnha It just prepares a clean slate. But that could instead have been written as Uprotect["YMat*"]; ClearAll["YMat*"]
 
@b3m2a1 what's the difference?
Also why does it have to unprotect as I don't see any conflict?
Can you explain what this command does?
idx=Pick[Range[Length[list]],UnitStep[list-1] UnitStep[n-list],1]
basically it's from this post:
https://mathematica.stackexchange.com/questions/167598/function-to-create-a-square-matrix-with-and-assign-values
 
@anhnha Just in case they used Protect anywhere.
There is no difference, but the version I presented might be a bit faster.
@anhnha Pick picks the elements in the first array that correspond the positions in the second array that contain the value passed as the third argument (defaults to True)
And it does it super fast
So use Pick when possible
UnitStep only ever returns 0 or 1 so you can use products of UnitStep calls to efficiently build filters
See this
Szabolcs wrote all the common cases into a package and you can read the source for that to learn how it works
 
7:53 AM
thanks
I don't see "list" is defined anywhere in the code
 
@anhnha ...
f[n_Integer, list_?VectorQ, vals_?MatrixQ]
 
oops
I misread it as type checking!
 
 
9 hours later…
4:32 PM
I wonder why Random`BlockRandomSeeding is not at the top level. It implements RandomSeeding: Random`BlockRandomSeeding[code, seeding]. It takes an optional third argument, but I don't know what it does. Everything I try results in no change of behavior. I thought it might be the Method.
 
looks like it is the head under which to issue messages for a bad second argument
 
Thanks!
 
what is the benefit to this function over BlockRandom with a RandomSeeding option?
 
D'oh, thanks again. I hadn't noticed the updated RandomSeeding option to BlockRandom. I guess there should be no advantage.
 
I think maybe the random seeding for top-level functions is implemented using that internal function, so they are probably equivalent.
I wasn't aware of the option either, assumed you would need to call SeedRandom after starting the BlockRandom
 
4:49 PM
I found the RandomSeeding option in FindInstance and followed the rabbit trail to BlockRandomSeeding.
I was confused because FindInstance[expr, vars, RandomSeeding -> Automatic] seemed to always generate the same solution, whereas asking for more than 1, FindInstance[expr, vars, n, RandomSeeding -> Automatic], seemed to always generate different solutions.
I guess that behavior does not violate the description: "Automatic: automatically reseed every time the function is called" does not say it will always use a new seed. :)
 

« first day (2889 days earlier)      last day (1592 days later) »