Author |
Topic  |
|
AlexD2
France
19 Posts |
Posted - 01/14/2014 : 5:37:32 PM
|
Origin Ver. and Service Release (Select Help-->About Origin): 9.1 SR1 Operating System: Windows7 32bit
Hello,
I was fiddling with the GetSize()/SetSize() vs .nrows using a range to a column dataset in a worksheet to get a feeling of how the column parameters, the dataset properties and the associated range are connected...
Now, there are some things I don't understand.
So, if I play with the SetSize() method, I change the dataset size (possibly destroying values if I shrink the dataset) and accordingly I change the number of rows of the column in which this dataset is stored (this is visible provided I actively refresh the worksheet after the operation). So that's all fine...
Now, if I reduce the number of rows (i.e. the column property) below the size of the dataset, the values that were in the rows that got removed disappear. So, ok... And if I display the dataset, whether using the predefined range or using the dataset name itself: >> type $(rDa) // Using the range >> type $(Book1_A) // Using the unique dataset name in both case only the values that are also display in the worksheet are printed in the command window. Similarly, if I use the dataset to make some computation (e.g. stats rDa, or stats Book1_A) the function only consider those data that are displayed both in the column and when using the type command. So this is fine too...
However, now if I ask for the value contained in those cells that are beyond the nrows limit: >> Cell(8,1)= // Where 8 > nrows I get the value that was there before I reduced nrows.
Also, if I restore the number of rows of the column to the value it had before I reduced nrows, the data that were in the corresponding cells reappear!
So my question is, where are those data stored? They don't seem to be in the dataset since they do not appear when using a type command, but still they are there...
And how comes that they still display when using the cell() function while they are not displaying via other methods?
Thanks,
AlexD2
|
|
Echo_Chu
China
Posts |
Posted - 01/15/2014 : 04:28:39 AM
|
Hi, AlexD2
It looks I can not reproduce your problem. Please look at my steps to see whether I understand you correctly.
1. Start with a new worksheet and run scripts below to fill column A with 15 values
range rr = 1;
rr.setsize(15);
rr=7;
2. Set row number of worksheet as 6 in the Worksheet Properties dialog(Press F4). You can not set number of rows in Column Properties dialog so I assume what you are talking about Worksheet Properties.
3. Run script below
cell(8,1)=
It returns cell(8,1)=--
However, if in step 2 you right click on row 6 and select Set as End in the context menu. Then there is value returned for cell(8,1). It is because Set as End only change the display of the dataset instead of reduce dataset. But with this method if you recover the rows and the full dataset will be also shown
Echo OriginLab Corp. |
 |
|
AlexD2
France
19 Posts |
Posted - 01/15/2014 : 06:04:24 AM
|
Dear Echo,
Thank you very much for replying.
I can reproduce what you have. So that's fine. But it s not exactly what I did, plus I am now confused with other things:
Some questions about your steps first: 1- After setting the row number to 6 in the Workheet Properties, while the data are indeed erased and the dataset and column size/length changed accordingly: >>rr.getsize()= rr.getsize()=6 >>rr.nrows= rr.nrows=6 If now I go to the Worksheet Properties, the row number is set to 14 and not to 6. I assume this is an internal limit - am I right? But also then, to what corresponds the value returned by rr.nrows=; ?
2- Why the script Cell(8,1)=; returns '--' rather than nothing? Also, this sets the dataset length and column row number to 8: >>rr.getsize()= rr.getsize()=8 >>rr.nrows= rr.nrows=8 Why is this so?
I think my main problem to understand the logic is that I don't know what are the different Origin objects involved in all these computation. There is a dataset object, there the worksheet object), but (see below what I did on my side) there is also a separate column object, and apparently other things (cf. the hidden data).
So I think I would need to have a global view of all these elements and how they are organized and interact between each others.
Now, what I did:
I did not use the Worksheet Properties dialog but I directly changed the nrows property with a rr.nrows=6; script.
Here below are the steps I followed. I copy-past everything to show all the tests I did, but you can directly jump towards the end of the scripts, to the most important part which starts at the lines: >>// I already saw that if I change the size of the dataset, >>// the nrows property changes accordingly: and which ends at the final question: >>// Are there hidden data??
Thanks for your help!
Best,
AlexD2
The tests I did:
>>range r41A = [Book4]1!A >>type %(r41A) [Book4]1!A >> >> r41A.SetSize(5) >> >>r41A.GetSize()= r41A.GetSize()=5 >>r41A.nrows= r41A.nrows=5 >> >>r41A = {1:8} >> >>r41A.GetSize()= r41A.GetSize()=8 >>r41A.nrows= r41A.nrows=8 >> >>Cell(8,1)= Cell(8,1)=8 >> >>// Changing the dataset size: >> >>r41A.SetSize(4) >> >>// Column content visually not changed >>// (Need to actively refresh the worksheet) >> >>// Requesting cell value >>Cell(1,1)= Cell(1,1)=1 // Ok >>Cell(4,1)= Cell(4,1)=4 // Ok >>Cell(5,1)= Cell(5,1)=-- //Ok (similar as with your script) >> >>// Value gone, but space in the dataset recreated >>// cf. My question above: >>// - why is there '--' rather than nothing? >>// - Why does the Cell() function creates empty element in dataset? >> >>Cell(10,1)= Cell(10,1)=-- // OK (same as above) >> >>Cell(30,1)= Cell(30,1)=-- // OK (same as above) >> >>// Is it systematic by default? >>// Create a new (4th) column and ask value: >> >>wks.AddCol() // Cells in the new column are empty >> >>Cell(2,4)= Cell(2,4)=-- // Now cells up to row 2 contain '--' >> >>// So indeed, it is a systematic behavior >> >>// Now, what if I go beyond the row limit? >> >>Cell(35,1)= Cell(35,1)=-- >> >>// Rows are added to the worksheet and cells get filled with '--' >>// So what does it mean? The dataset gets extended? >> >> >>// Let's ask about the column and dataset properties >> >>r41A.GetSize()= r41A.GetSize()=35 // So the dataset is extended >>r41A.nrows= r41A.nrows=35 // And the column property is changed accordingly >> >> >>// Now what about the column-dataset hierarchy? >>// i.e. which one depends upon the other? >>// Did the column setting changed according to the dataset, or did the dataset changed according to the column? >> >>// Probably they both changed together due to the call to Cell()... >> >>// But here are some different tests >> >>// First, let's check that both the dataset and column agree >>r41A.GetSize()= r41A.GetSize()=35 >>r41A.nrows= r41A.nrows=35 >> >>// I already saw that if I change the size of the dataset, >>// the nrows property changes accordingly: >>r41A.SetSize(4) >>r41A.GetSize()= r41A.GetSize()=4 >>r41A.nrows= r41A.nrows=4 // Ok >>// And indeed the -- disapear beyond the row 10! >>// Although one needs to "refresh" the window to see the change >> >>// Now let see if this is reciprocal >>// i.e. what happens if I change nrows >> >>// Reducing nrows >> >>r41A.nrows=2 >> >>// The data disapear from the worksheet >> >>r41A.GetSize()= r41A.GetSize()=2 >>r41A.nrows= r41A.nrows=2 >> >>// And apparently the range is reduced accordingly >>type $(r41A) 1 2 >> >>// Now if I re-increase nrows... >>r41A.nrows=3 >> >>// The data reappear! >>// So it seems that with the nrows property, I'm just changing >>// the range according to the number of rows, but not the dataset >> >>// What if I perform a computation with the range or the dataset... >> >>stats r41A
stats.mean = 2 stats.sd = 1 stats.n = 3 stats.min = 1 stats.max = 3 stats.sum = 6 stats.missing = 0
>>stats Book4_A
stats.mean = 2 stats.sd = 1 stats.n = 3 stats.min = 1 stats.max = 3 stats.sum = 6 stats.missing = 0
>>type $(Book4_A) 1 2 3 >> >>// So both the range and the dataset are limited to the nrows I set >>// But if I restore nrows, data reappear: >>r41A.nrows=4 >> >>// Are there hidden data?? >>
|
 |
|
Echo_Chu
China
Posts |
Posted - 01/16/2014 : 04:34:29 AM
|
Hi, AlexD2,
Please see my comments in your post.
Dear Echo,
Thank you very much for replying.
I can reproduce what you have. So that's fine. But it s not exactly what I did, plus I am now confused with other things:
Some questions about your steps first: 1- After setting the row number to 6 in the Workheet Properties, while the data are indeed erased and the dataset and column size/length changed accordingly: >>rr.getsize()= rr.getsize()=6 >>rr.nrows= rr.nrows=6 If now I go to the Worksheet Properties, the row number is set to 14 and not to 6. I assume this is an internal limit - am I right? But also then, to what corresponds the value returned by rr.nrows=; ? [Echo]: The row number is set to 14 because Auto Add Rows is selected by default in Worksheet Properties>Miscellaneous tab rr.rows returns the rows of the rr range instead of rows of whole worksheet. wks.nrows will return the rows of whole worksheet and it is 14 while rr.nrows returns 6.
2- Why the script Cell(8,1)=; returns '--' rather than nothing? Also, this sets the dataset length and column row number to 8: >>rr.getsize()= rr.getsize()=8 >>rr.nrows= rr.nrows=8 Why is this so?
[Echo] cell(8,1) returns -- because -- is missing value. There is no values in rr so it returns a missing value.However, as cell(8,1) attemps to access the dataset rr so the size of rr turn to 8.
I think my main problem to understand the logic is that I don't know what are the different Origin objects involved in all these computation. There is a dataset object, there the worksheet object), but (see below what I did on my side) there is also a separate column object, and apparently other things (cf. the hidden data).
So I think I would need to have a global view of all these elements and how they are organized and interact between each others.
Now, what I did:
I did not use the Worksheet Properties dialog but I directly changed the nrows property with a rr.nrows=6; script.
Here below are the steps I followed. I copy-past everything to show all the tests I did, but you can directly jump towards the end of the scripts, to the most important part which starts at the lines: >>// I already saw that if I change the size of the dataset, >>// the nrows property changes accordingly: and which ends at the final question: >>// Are there hidden data??
Thanks for your help!
Best,
AlexD2
The tests I did:
>>range r41A = [Book4]1!A >>type %(r41A) [Book4]1!A >> >> r41A.SetSize(5) >> >>r41A.GetSize()= r41A.GetSize()=5 >>r41A.nrows= r41A.nrows=5 >> >>r41A = {1:8} >> >>r41A.GetSize()= r41A.GetSize()=8 >>r41A.nrows= r41A.nrows=8 >> >>Cell(8,1)= Cell(8,1)=8 >> >>// Changing the dataset size: >> >>r41A.SetSize(4) >> >>// Column content visually not changed >>// (Need to actively refresh the worksheet) >> >>// Requesting cell value >>Cell(1,1)= Cell(1,1)=1 // Ok >>Cell(4,1)= Cell(4,1)=4 // Ok >>Cell(5,1)= Cell(5,1)=-- //Ok (similar as with your script) >> >>// Value gone, but space in the dataset recreated >>// cf. My question above: >>// - why is there '--' rather than nothing? >>// - Why does the Cell() function creates empty element in dataset? [Echo] cell function returns -- because -- is missing value. There is no values store in the dataset so it returns a missing value.However, as the cell function attemps to access the dataset rr Origin extend the dataset rr and fill it with missing values automatically.
>> >>Cell(10,1)= Cell(10,1)=-- // OK (same as above) >> >>Cell(30,1)= Cell(30,1)=-- // OK (same as above) >> >>// Is it systematic by default? >>// Create a new (4th) column and ask value: >> >>wks.AddCol() // Cells in the new column are empty >> >>Cell(2,4)= Cell(2,4)=-- // Now cells up to row 2 contain '--' >> >>// So indeed, it is a systematic behavior >> >>// Now, what if I go beyond the row limit? >> >>Cell(35,1)= Cell(35,1)=-- >> >>// Rows are added to the worksheet and cells get filled with '--' >>// So what does it mean? The dataset gets extended? >> >> >>// Let's ask about the column and dataset properties >> >>r41A.GetSize()= r41A.GetSize()=35 // So the dataset is extended >>r41A.nrows= r41A.nrows=35 // And the column property is changed accordingly >> >> >>// Now what about the column-dataset hierarchy? >>// i.e. which one depends upon the other? >>// Did the column setting changed according to the dataset, or did the dataset changed according to the column?
[Echo]wks contains column, column contains dataset, dataset mainly refers to data values. column object also holds meta data like long name, unit et
>> >>// Probably they both changed together due to the call to Cell()... >> >>// But here are some different tests >> >>// First, let's check that both the dataset and column agree >>r41A.GetSize()= r41A.GetSize()=35 >>r41A.nrows= r41A.nrows=35 >> >>// I already saw that if I change the size of the dataset, >>// the nrows property changes accordingly: >>r41A.SetSize(4) >>r41A.GetSize()= r41A.GetSize()=4 >>r41A.nrows= r41A.nrows=4 // Ok >>// And indeed the -- disapear beyond the row 10! >>// Although one needs to "refresh" the window to see the change >> >>// Now let see if this is reciprocal >>// i.e. what happens if I change nrows >> >>// Reducing nrows >> >>r41A.nrows=2 >> >>// The data disapear from the worksheet >> >>r41A.GetSize()= r41A.GetSize()=2 >>r41A.nrows= r41A.nrows=2 >> >>// And apparently the range is reduced accordingly >>type $(r41A) 1 2 >> >>// Now if I re-increase nrows... >>r41A.nrows=3 >> >>// The data reappear! >>// So it seems that with the nrows property, I'm just changing >>// the range according to the number of rows, but not the dataset >> >>// What if I perform a computation with the range or the dataset... >> >>stats r41A
stats.mean = 2 stats.sd = 1 stats.n = 3 stats.min = 1 stats.max = 3 stats.sum = 6 stats.missing = 0
>>stats Book4_A
stats.mean = 2 stats.sd = 1 stats.n = 3 stats.min = 1 stats.max = 3 stats.sum = 6 stats.missing = 0
>>type $(Book4_A) 1 2 3 >> >>// So both the range and the dataset are limited to the nrows I set >>// But if I restore nrows, data reappear: >>r41A.nrows=4 >> >>// Are there hidden data?? [Echo] It is because both rr.setszie and rr.nrows change the size of the data range and you can use the data range with same size as you set in any further analysis. But we did not destroy data values internally. |
 |
|
AlexD2
France
19 Posts |
Posted - 01/16/2014 : 11:16:05 AM
|
Hi Echo,
Thank you for answering.
Some things are a bit clearer to me now.
However, you did not answer my main question about the hidden values.
As I described above, under some resizing conditions some values that were at the end of a dataset do not display anymore, neither in the worksheet column, neither if I use the 'type $()' command on the range variable, nor (and this is the more striking...) if I use the type $() command directly on the dataset variable itself.
So it is not just a matter of "display" problem: whether the column size and range size are fitted to the dataset size or not, the values are not anymore in the dataset either (at least this is what the type $() command directly performed on the dataset variable says).
However, those values that disappeared can reappear in the dataset after some re-sizing operation (see my script).
Thus my question: - since these values were not anymore stored in the dataset, where were they still stored? - or if they were still in the dataset, why don't they display when calling 'type $(Book4_A)' for instance? How can some values be and not be in the dataset in the same time? ("To be or not to be...", Origin meeting both Shakespear and Schrodinger at the same time? :))
Thanks,
Alex
|
 |
|
Echo_Chu
China
Posts |
Posted - 01/17/2014 : 12:57:06 AM
|
Hi, Alex
It is only because we did not destroy the data internally
It is like you have 20 values stand in a line. Then we reduce the size of container, data range, to make it only can carry 10 values. So when you analyse or type the container, only the values in the container will be taken into account. And if you change the size of container to 15, then 15 values will be take into account.
Echo |
 |
|
|
Topic  |
|
|
|