Bookmark and Share

Notice: On March 31, it was announced that Statalist is moving from an email list to a forum. The old list will shut down at the end of May, and its replacement, statalist.org is already up and running.


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: st: asarray_keys() error


From   Hua Peng <hpeng@stata.com>
To   statalist@hsphsun2.harvard.edu
Subject   Re: st: asarray_keys() error
Date   Fri, 24 May 2013 13:09:57 -0500

Matthew White <mwhite@poverty-action.org> discovered a bug in Mata
function asarray_keys().

        > mata:
        > A = asarray_create("string", 2)
        > asarray(A, ("type", "keep"), 1)
        > asarray(A, ("name", "char"), 2)
        > asarray_keys(A)
        >
        > However, -asarray_keys()- issues the following error message:
        >
        > asarray_keys_dup():  3201  vector required
        > asarray_keys():     -  function returned error
        > <istmt>:     -  function returned error
        >

Sergiy Radyakin <serjradyakin@gmail.com> confirmed the bug and said
it was likeliy due to collision of hashes generated by asarray_*().
 Mostly asarray_*() handles collisions correctly, but not in one case.

Sergiey offered a workaround.

The fix for the problem Matthew experienced and Sergiey identified
will be in the next ado-file update.

-- Bill                                              --  Hua
wgould@stata.com                     hpeng@stata.com


On 5/15/2013 4:35 PM, Matthew White wrote:
Hi Statalist members,

I'm running the following commands in Stata 12.1 SE:

mata:
A = asarray_create("string", 2)
asarray(A, ("type", "keep"), 1)
asarray(A, ("name", "char"), 2)
asarray_keys(A)

However, -asarray_keys()- issues the following error message:

asarray_keys_dup():  3201  vector required
asarray_keys():     -  function returned error
<istmt>:     -  function returned error

If I run -asarray()- for just one key, -asarray_keys()- does not
result in an error. For example:

mata:
A = asarray_create("string", 2)
asarray(A, ("type", "keep"), 1)
asarray_keys(A)
end

If I change any one of the elements of the keys, -asarray_keys()- also
does not result in an error:

mata:
A = asarray_create("string", 2)
asarray(A, ("example", "keep"), 1)
asarray(A, ("name", "char"), 2)
asarray_keys(A)
end

Any suggestions would be appreciated.

Thank you,
Matt White

--
Matthew White
Senior Project Associate
Innovations for Poverty Action
101 Whitney Avenue, New Haven, CT 06510 USA
www.poverty-action.org
*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


*
*   For searches and help try:
*   http://www.stata.com/help.cgi?search
*   http://www.stata.com/support/faqs/resources/statalist-faq/
*   http://www.ats.ucla.edu/stat/stata/


© Copyright 1996–2014 StataCorp LP   |   Terms of use   |   Privacy   |   Contact us   |   Site index