0
$\begingroup$

Ive made a module to expand a list by reflections and translations. Here is the block.

 makeBZ001[x_] := Block[{rt1, , rt2, rt3, dat = x, temp1, temp2, temp3, rm, tempfull,
 full, rtt, res},
 rt1 = ReflectionTransform[{1, -1}];
 temp1 = dat;
 temp1[[All, ;; 2]] = rt1[temp1[[All, ;; 2]]];
 rt2 = ReflectionTransform[{1, 0}];
 temp2 = DeleteDuplicates[Join[dat, temp1]];
 temp2[[All, ;; 2]] = rt2[temp2[[All, ;; 2]]];
 rt3 = ReflectionTransform[{0, -1}];
 temp3 = DeleteDuplicates[Join[dat, temp1, temp2]];
 temp3[[All, ;; 2]] = rt3[temp3[[All, ;; 2]]];
 tempfull = DeleteDuplicates[Join[dat, temp1, temp2, temp3]];
 rm = RegionMember[Polygon[{{0.0, 1.0}, {1.0, 0.0}, {0.0, -1.0}, {-1.0, 0.0}}]];
 full = Pick[tempfull, rm[tempfull[[All, ;; 2]]]];
 rtt = RotationTransform[\[Pi]/180 45];
 res = full;
 res[[All, ;; 2]] = rtt[res[[All, ;; 2]]];
 res
 ]

Now, I've tested the code without the Block and it works as expected, no problems. However, when I call it after making a block it causes the kernel to crash.

test = makeBZ001[data]; 

Any ideas about whats causing this issue?

Vesion is (*11.3.0 for Microsoft Windows (64-bit) (March 7, 2018)*)

Here is an example of the data: sampledata

After the data runs through all the procedures and its plotted it looks like this, enter image description here

Edit I've tried the code on my desktop and it runs fine, seems to be some sort of issue with the memory, Im guessing.

$\endgroup$
7
  • $\begingroup$ Could you provide an example of input and the expected output? It is also a good idea to say what your $Version is when it comes to questions of the kind. On my machine ("11.2.0 for Microsoft Windows (64-bit) (September 11, 2017)") there is no crash when RandomReal[1, {5, 3}] is supplied as input. $\endgroup$ Commented Sep 20, 2018 at 16:05
  • $\begingroup$ Thank you for quick cooperation :) But the sample data file you provided shows only one cell with "csv" inside :( $\endgroup$ Commented Sep 20, 2018 at 16:29
  • $\begingroup$ @Anton.Sakovich fixed! The sample data is working now. $\endgroup$ Commented Sep 20, 2018 at 16:56
  • $\begingroup$ I've manage to isolate the problem to the Pick command. I even switch the order to make all reflections and rotations firsts, and this works well. However it crashes when doing Pick in the last step. $\endgroup$ Commented Sep 20, 2018 at 17:53
  • $\begingroup$ Are you saying that data = Import["j11.csv"], then makeBZ001[data];, will crash the kernel? I.e., it beeps, the notebook doesn't change, and the In[...] counter resets to 1? I can't reproduce that in M11.3 / macOS 10.13. $\endgroup$
    – Szabolcs
    Commented Sep 20, 2018 at 19:30

1 Answer 1

1
$\begingroup$

Everything works in my version 11.3

makeBZ001[x_] := 
 Block[{rt1, , rt2, rt3, dat = x, temp1, temp2, temp3, rm, tempfull, 
   full, rtt, res}, rt1 = ReflectionTransform[{1, -1}];
  temp1 = dat;
  temp1[[All, ;; 2]] = rt1[temp1[[All, ;; 2]]];
  rt2 = ReflectionTransform[{1, 0}];
  temp2 = DeleteDuplicates[Join[dat, temp1]];
  temp2[[All, ;; 2]] = rt2[temp2[[All, ;; 2]]];
  rt3 = ReflectionTransform[{0, -1}];
  temp3 = DeleteDuplicates[Join[dat, temp1, temp2]];
  temp3[[All, ;; 2]] = rt3[temp3[[All, ;; 2]]];
  tempfull = DeleteDuplicates[Join[dat, temp1, temp2, temp3]];
  rm = RegionMember[
    Polygon[{{0.0, 1.0}, {1.0, 0.0}, {0.0, -1.0}, {-1.0, 0.0}}]];
  full = Pick[tempfull, rm[tempfull[[All, ;; 2]]]];
  rtt = RotationTransform[\[Pi]/180 45];
  res = full;
  res[[All, ;; 2]] = rtt[res[[All, ;; 2]]];
  res]
data = Import["C:\\Users\\Alexander Trounev\\Desktop\\j11.csv"]

p = makeBZ001[data]

ListPlot3D[p, Mesh -> None, InterpolationOrder -> 3, 
 ColorFunction -> "SouthwestColors"]

fig1

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.