emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* Bug in org-table-convert-region?
@ 2013-05-27 22:59 Thorsten Jolitz
  2013-05-28  7:17 ` Sebastien Vauban
  0 siblings, 1 reply; 7+ messages in thread
From: Thorsten Jolitz @ 2013-05-27 22:59 UTC (permalink / raw)
  To: emacs-orgmode


Hi List,

using 'M-: (org-table-convert-region beg end 2) on this output (with
beg/end being the points before and after the tabular data)

,-------------------------------------------------------------------
| === Error on training data ===
|
| Correctly Classified Instances         147               98      %
| Incorrectly Classified Instances         3                2      %
| Kappa statistic                          0.97
| Mean absolute error                      0.0233
| Root mean squared error                  0.108
| Relative absolute error                  5.2482 %
| Root relative squared error             22.9089 %
| Total Number of Instances              150
`-------------------------------------------------------------------

I get what I want:

| Correctly Classified Instances   |       144 | 96 | % |
| Incorrectly Classified Instances |         6 |  4 | % |
| Kappa statistic                  |      0.94 |    |   |
| Mean absolute error              |     0.035 |    |   |
| Root mean squared error          |    0.1586 |    |   |
| Relative absolute error          |  7.8705 % |    |   |
| Root relative squared error      | 33.6353 % |    |   |
| Total Number of Instances        |       150 |    |   |


However, using 'C-u 2 M-x org-table-convert-region' on the marked region
yields this:

| Correctly   | Classified | Instances |       144 |      96 | % |
| Incorrectly | Classified | Instances |         6 |       4 | % |
| Kappa       | statistic  | 0.94      |           |         |   |
| Mean        | absolute   | error     |     0.035 |         |   |
| Root        | mean       | squared   |     error |  0.1586 |   |
| Relative    | absolute   | error     |    7.8705 |       % |   |
| Root        | relative   | squared   |     error | 33.6353 | % |
| Total       | Number     | of        | Instances |     150 |   |

From the comment-string:

,-----------------------------------------------------------------------
| (org-table-convert-region BEG0 END0 &optional SEPARATOR)
|
| Convert region to a table.[...]
| SEPARATOR specifies the field separator in the lines.  It can have the
| following values:
|
| '(4)     Use the comma as a field separator
| '(16)    Use a TAB as field separator
| integer  When a number, use that many spaces as field separator
| nil      When nil, the command tries to be smart and figure out the
`-----------------------------------------------------------------------

and from the elisp manual:

,-----------------------------------------------------------------------
| Here are the results of calling display-prefix with various raw prefix
| arguments:
|
|      C-u     M-x display-prefix  -| (4)
|
|      C-u C-u M-x display-prefix  -| (16)
|
|      C-u 3   M-x display-prefix  -| 3
`-----------------------------------------------------------------------

Looks like a bug in the argument handling?

--
cheers,
Thorsten

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Bug in org-table-convert-region?
  2013-05-27 22:59 Bug in org-table-convert-region? Thorsten Jolitz
@ 2013-05-28  7:17 ` Sebastien Vauban
  2013-05-28  9:03   ` Thorsten Jolitz
  0 siblings, 1 reply; 7+ messages in thread
From: Sebastien Vauban @ 2013-05-28  7:17 UTC (permalink / raw)
  To: emacs-orgmode-mXXj517/zsQ

Hi Thorsten,

Thorsten Jolitz wrote:
> using 'M-: (org-table-convert-region beg end 2) on this output (with
> beg/end being the points before and after the tabular data)
>
> ,-------------------------------------------------------------------
> | === Error on training data ===
> |
> | Correctly Classified Instances         147               98      %
> | Incorrectly Classified Instances         3                2      %
> | Kappa statistic                          0.97
> | Mean absolute error                      0.0233
> | Root mean squared error                  0.108
> | Relative absolute error                  5.2482 %
> | Root relative squared error             22.9089 %
> | Total Number of Instances              150
> `-------------------------------------------------------------------
>
> I get what I want:
>
> | Correctly Classified Instances   |       144 | 96 | % |
> | Incorrectly Classified Instances |         6 |  4 | % |
> | Kappa statistic                  |      0.94 |    |   |
> | Mean absolute error              |     0.035 |    |   |
> | Root mean squared error          |    0.1586 |    |   |
> | Relative absolute error          |  7.8705 % |    |   |
> | Root relative squared error      | 33.6353 % |    |   |
> | Total Number of Instances        |       150 |    |   |

I doubt this table is the conversion of the above: figures are different ;-)
(nitpicking)

> However, using 'C-u 2 M-x org-table-convert-region' on the marked region
> yields this:
>
> | Correctly   | Classified | Instances |       144 |      96 | % |
> | Incorrectly | Classified | Instances |         6 |       4 | % |
> | Kappa       | statistic  | 0.94      |           |         |   |
> | Mean        | absolute   | error     |     0.035 |         |   |
> | Root        | mean       | squared   |     error |  0.1586 |   |
> | Relative    | absolute   | error     |    7.8705 |       % |   |
> | Root        | relative   | squared   |     error | 33.6353 | % |
> | Total       | Number     | of        | Instances |     150 |   |
>
> From the comment-string:
>
> ,-----------------------------------------------------------------------
> | (org-table-convert-region BEG0 END0 &optional SEPARATOR)
> |
> | Convert region to a table.[...]
> | SEPARATOR specifies the field separator in the lines.  It can have the
> | following values:
> |
> | '(4)     Use the comma as a field separator
> | '(16)    Use a TAB as field separator
> | integer  When a number, use that many spaces as field separator
> | nil      When nil, the command tries to be smart and figure out the
> `-----------------------------------------------------------------------
>
> and from the elisp manual:
>
> ,-----------------------------------------------------------------------
> | Here are the results of calling display-prefix with various raw prefix
> | arguments:
> |
> |      C-u     M-x display-prefix  -| (4)
> |
> |      C-u C-u M-x display-prefix  -| (16)
> |
> |      C-u 3   M-x display-prefix  -| 3
> `-----------------------------------------------------------------------
>
> Looks like a bug in the argument handling?

I don't have an answer, but one extra question (which popped up when reading
your analysis): how does Emacs see the difference between `C-u' and `C-u 4'?

That is, how to differentiate "Use the comma as a field separator" from "Use
4 spaces as field separator"?

Best regards,
  Seb

-- 
Sebastien Vauban

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Bug in org-table-convert-region?
  2013-05-28  7:17 ` Sebastien Vauban
@ 2013-05-28  9:03   ` Thorsten Jolitz
  2013-05-28  9:28     ` Sebastien Vauban
  0 siblings, 1 reply; 7+ messages in thread
From: Thorsten Jolitz @ 2013-05-28  9:03 UTC (permalink / raw)
  To: emacs-orgmode

"Sebastien Vauban" <sva-news@mygooglest.com>
writes:

Hi Sebastien,

[...]
>> From the comment-string:
>>
>> ,-----------------------------------------------------------------------
>> | (org-table-convert-region BEG0 END0 &optional SEPARATOR)
>> |
>> | Convert region to a table.[...]
>> | SEPARATOR specifies the field separator in the lines.  It can have the
>> | following values:
>> |
>> | '(4)     Use the comma as a field separator
>> | '(16)    Use a TAB as field separator
>> | integer  When a number, use that many spaces as field separator
>> | nil      When nil, the command tries to be smart and figure out the
>> `-----------------------------------------------------------------------
>> Looks like a bug in the argument handling?
>
> I don't have an answer, but one extra question (which popped up when reading
> your analysis): how does Emacs see the difference between `C-u' and `C-u 4'?
>
> That is, how to differentiate "Use the comma as a field separator" from "Use
> 4 spaces as field separator"?

The answer is here:

>> and from the elisp manual:
>>
>> ,-----------------------------------------------------------------------
>> | Here are the results of calling display-prefix with various raw prefix
>> | arguments:
>> |
>> |      C-u     M-x display-prefix  -| (4)
>> |
>> |      C-u C-u M-x display-prefix  -| (16)
>> |
>> |      C-u 3   M-x display-prefix  -| 3
>> `-----------------------------------------------------------------------

and in the (interactive "rP") specification:

,-------------------------------------------------------------------------
| ‘P’
|
|     The raw prefix argument. (Note that this ‘P’ is upper case.) No I/O.
|
| ‘r’
|
|     Point and the mark, as two numeric arguments, smallest first. This
|     is the only code letter that specifies two successive arguments
|     rather than one. No I/O.
`-------------------------------------------------------------------------

thus 

,---------------------------------------------------------
| (org-table-convert-region BEG0 END0 &optional SEPARATOR)
`---------------------------------------------------------

with C-u M-x org-table-convert-region should be e.g.

,----------------------------------------
| (org-table-convert-region 38  456 '(4))
`----------------------------------------

and C-u 3 M-x org-table-convert-region should be

,----------------------------------------
| (org-table-convert-region 38  456 3)
`----------------------------------------

but I checked with edebug, its actually 

,----------------------------------------
| (org-table-convert-region 38  456 nil)
`----------------------------------------

and "When nil, the command tries to be smart and figure out [itself]"

So the problem seems to be that 'C-u 3' doesn't work as expected in my
case. Could you check if it works for you?

--
cheers,
Thorsten

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Bug in org-table-convert-region?
  2013-05-28  9:03   ` Thorsten Jolitz
@ 2013-05-28  9:28     ` Sebastien Vauban
  2013-05-28 10:20       ` Thorsten Jolitz
  0 siblings, 1 reply; 7+ messages in thread
From: Sebastien Vauban @ 2013-05-28  9:28 UTC (permalink / raw)
  To: emacs-orgmode-mXXj517/zsQ

Thorsten,

Thorsten Jolitz wrote:
> "Sebastien Vauban" <sva-news-D0wtAvR13HarG/iDocfnWg@public.gmane.org> writes:
>>>
>>> ,-----------------------------------------------------------------------
>>> | (org-table-convert-region BEG0 END0 &optional SEPARATOR)
>>> |
>>> | Convert region to a table.[...]
>>> | SEPARATOR specifies the field separator in the lines.  It can have the
>>> | following values:
>>> |
>>> | '(4)     Use the comma as a field separator
>>> | '(16)    Use a TAB as field separator
>>> | integer  When a number, use that many spaces as field separator
>>> | nil      When nil, the command tries to be smart and figure out the
>>> `-----------------------------------------------------------------------
>>> Looks like a bug in the argument handling?
>>
>> I don't have an answer, but one extra question (which popped up when
>> reading your analysis): how does Emacs see the difference between `C-u' and
>> `C-u 4'?
>>
>> That is, how to differentiate "Use the comma as a field separator" from
>> "Use 4 spaces as field separator"?
>
> The answer is here:
>
>>> and from the elisp manual:
>>>
>>> ,-----------------------------------------------------------------------
>>> | Here are the results of calling display-prefix with various raw prefix
>>> | arguments:
>>> |
>>> |      C-u     M-x display-prefix  -| (4)
>>> |      C-u C-u M-x display-prefix  -| (16)
>>> |      C-u 3   M-x display-prefix  -| 3
>>> `-----------------------------------------------------------------------

OK. I now understand that:

- `C-u' gives an list argument of '(4)
- `C-u 4' gives a numeric argument of 4

So, that's the way to distinguish them.

> ,---------------------------------------------------------
> | (org-table-convert-region BEG0 END0 &optional SEPARATOR)
> `---------------------------------------------------------
>
> with C-u M-x org-table-convert-region should be e.g.
>
> ,----------------------------------------
> | (org-table-convert-region 38  456 '(4))
> `----------------------------------------
>
> and C-u 3 M-x org-table-convert-region should be
>
> ,----------------------------------------
> | (org-table-convert-region 38  456 3)
> `----------------------------------------
>
> but I checked with edebug, its actually 
>
> ,----------------------------------------
> | (org-table-convert-region 38  456 nil)
> `----------------------------------------
>
> and "When nil, the command tries to be smart and figure out [itself]"
>
> So the problem seems to be that 'C-u 3' doesn't work as expected in my
> case. Could you check if it works for you?

I've considered the following table:

test a b c
test  a  b  c
test   a   b   c
test    a    b    c
test     a     b     c
test      a      b      c

and tried to convert it with various configs:

- M-x org-table-convert-region
- C-u M-x org-table-convert-region
- C-u 4 M-x org-table-convert-region
- C-u 3 M-x org-table-convert-region

In all cases, when evaluating `separator' under edebug, it showed me `nil',
and always converted the table into this:

| test | a | b | c |
| test | a | b | c |
| test | a | b | c |
| test | a | b | c |
| test | a | b | c |
| test | a | b | c |

So, `separator' seems never to get a correct value, and to be constantly be
equal to `nil'. Dunno why, though.

Do you confirm this as well?

Best regards,
  Seb

-- 
Sebastien Vauban

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Bug in org-table-convert-region?
  2013-05-28  9:28     ` Sebastien Vauban
@ 2013-05-28 10:20       ` Thorsten Jolitz
  2013-05-28 11:47         ` [PATCH] org-table-convert-region (was Re: Bug in org-table-convert-region?) Thorsten Jolitz
  0 siblings, 1 reply; 7+ messages in thread
From: Thorsten Jolitz @ 2013-05-28 10:20 UTC (permalink / raw)
  To: emacs-orgmode

"Sebastien Vauban" <sva-news@mygooglest.com>
writes:

> I've considered the following table:
>
> test a b c
> test  a  b  c
> test   a   b   c
> test    a    b    c
> test     a     b     c
> test      a      b      c
>
> and tried to convert it with various configs:
>
> - M-x org-table-convert-region
> - C-u M-x org-table-convert-region
> - C-u 4 M-x org-table-convert-region
> - C-u 3 M-x org-table-convert-region
>
> In all cases, when evaluating `separator' under edebug, it showed me `nil',
> and always converted the table into this:
>
> | test | a | b | c |
> | test | a | b | c |
> | test | a | b | c |
> | test | a | b | c |
> | test | a | b | c |
> | test | a | b | c |
>
> So, `separator' seems never to get a correct value, and to be constantly be
> equal to `nil'. Dunno why, though.
>
> Do you confirm this as well?

Yes, I can confirm this. So either (interactive "rP") isn't a valid
combination, then its a bug in the org command3, or it is a valid
combination and should work - then its a bug in Emacs 24?

Evaluating the function works as expected though:

,-----------------------------------------
| M-: (org-table-convert-region beg end 2)
| 
| | test a b c |   |   |   |
| | test       | a | b | c |
| | test       | a | b | c |
| | test       | a | b | c |
| | test       | a | b | c |
| | test       | a | b | c |
| |            |   |   |   |
`-----------------------------------------


,-----------------------------------------
| M-: (org-table-convert-region beg end 3)
| 
| | test a b c    |   |   |   |
| | test  a  b  c |   |   |   |
| | test          | a | b | c |
| | test          | a | b | c |
| | test          | a | b | c |
| | test          | a | b | c |
| |               |   |   |   |
`-----------------------------------------


,-----------------------------------------
| M-: (org-table-convert-region beg end 4)
| 
| | test a b c       |   |   |   |
| | test  a  b  c    |   |   |   |
| | test   a   b   c |   |   |   |
| | test             | a | b | c |
| | test             | a | b | c |
| | test             | a | b | c |
| |                  |   |   |   |
`-----------------------------------------


-- 
cheers,
Thorsten

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH] org-table-convert-region (was Re: Bug in org-table-convert-region?)
  2013-05-28 10:20       ` Thorsten Jolitz
@ 2013-05-28 11:47         ` Thorsten Jolitz
  2013-06-01  5:46           ` Carsten Dominik
  0 siblings, 1 reply; 7+ messages in thread
From: Thorsten Jolitz @ 2013-05-28 11:47 UTC (permalink / raw)
  To: emacs-orgmode

Thorsten Jolitz <tjolitz@gmail.com> writes:

> Yes, I can confirm this. So either (interactive "rP") isn't a valid
> combination, then its a bug in the org command3, or it is a valid
> combination and should work - then its a bug in Emacs 24?

Its a bug in 'org-table-convert-region'. 

"PATCH":

replace

,-------------------
| (interactive "rP")
`-------------------

with

,---------------------
| (interactive "r\nP")
`---------------------

(Thanks to Andreas Röhler for the tip)

-- 
cheers,
Thorsten

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH] org-table-convert-region (was Re: Bug in org-table-convert-region?)
  2013-05-28 11:47         ` [PATCH] org-table-convert-region (was Re: Bug in org-table-convert-region?) Thorsten Jolitz
@ 2013-06-01  5:46           ` Carsten Dominik
  0 siblings, 0 replies; 7+ messages in thread
From: Carsten Dominik @ 2013-06-01  5:46 UTC (permalink / raw)
  To: Thorsten Jolitz; +Cc: emacs-orgmode


On 28.5.2013, at 13:47, Thorsten Jolitz <tjolitz@gmail.com> wrote:

> Thorsten Jolitz <tjolitz@gmail.com> writes:
> 
>> Yes, I can confirm this. So either (interactive "rP") isn't a valid
>> combination, then its a bug in the org command3, or it is a valid
>> combination and should work - then its a bug in Emacs 24?
> 
> Its a bug in 'org-table-convert-region'. 
> 
> "PATCH":
> 
> replace
> 
> ,-------------------
> | (interactive "rP")
> `-------------------
> 
> with
> 
> ,---------------------
> | (interactive "r\nP")
> `---------------------

I have made this Change.

- Carsten

> 
> (Thanks to Andreas Röhler for the tip)
> 
> -- 
> cheers,
> Thorsten
> 
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2013-06-01  5:46 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-05-27 22:59 Bug in org-table-convert-region? Thorsten Jolitz
2013-05-28  7:17 ` Sebastien Vauban
2013-05-28  9:03   ` Thorsten Jolitz
2013-05-28  9:28     ` Sebastien Vauban
2013-05-28 10:20       ` Thorsten Jolitz
2013-05-28 11:47         ` [PATCH] org-table-convert-region (was Re: Bug in org-table-convert-region?) Thorsten Jolitz
2013-06-01  5:46           ` Carsten Dominik

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).