Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: st: asarray_keys() error
From
Sergiy Radyakin <[email protected]>
To
"[email protected]" <[email protected]>
Subject
Re: st: asarray_keys() error
Date
Thu, 16 May 2013 10:03:18 -0400
Dear Matthew,
I can confirm the problem also reproducible in Stata 11.2.
The problem is likely the collision of hashes generated with hash1()
function. Such collisions are unlikely, though possible. This is also
consistent with your observation of changing the keys does not
generate the error. Note that the problem does not occur if you add a
"_" (an underscore) to each of your keys. (but this is data-dependent,
there will be a combination that will collide again, but perhaps you
will be lucky not to encounter it in your data). Would this would be a
suitable workaround for you?
Best, Sergiy Radyakin
mata:
A = asarray_create("string", 2)
asarray(A, ("_type", "_keep"), 1)
asarray(A, ("_name", "_char"), 2)
asarray_stats(A)
asarray_keys(A)
end
: asarray_keys(A)
1 2
+-----------------+
1 | _name _char |
2 | _type _keep |
+-----------------+
On Wed, May 15, 2013 at 5:35 PM, Matthew White
<[email protected]> 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/