-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge 'develop' for gtools-1.0.1 (2018-07-23); bug fixes, typos
Bug fixes * `gegen, replace` gave the wrong result if the source was also the target (`tag` and `group` worked, but all other stats did not). * `gunique, by()` was affected by this bug and now works correctly. * `gcollapse, merge` exits with error if there are no observations. * Fixed typos in gtools.ado and help file Enhancements * `gunique, by()` no longer prints the top unique levels by default unless the user asks for them via `detail`. * Specified gtop is an alias in readthedocs examples. * Minor cosmetic updates to gtop
- Loading branch information
Showing
52 changed files
with
2,327 additions
and
2,083 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
*! version 1.0.0 21Jul2018 Mauricio Caceres Bravo, [email protected] | ||
*! version 1.0.1 23Jul2018 Mauricio Caceres Bravo, [email protected] | ||
*! Encode varlist using Jenkin's 128-bit spookyhash via C plugins | ||
|
||
* rc 17000 | ||
|
@@ -14,7 +14,7 @@ | |
|
||
capture program drop _gtools_internal | ||
program _gtools_internal, rclass | ||
version 13 | ||
version 13.1 | ||
global GTOOLS_USER_INTERNAL_VARABBREV `c(varabbrev)' | ||
* set varabbrev off | ||
|
||
|
@@ -1385,7 +1385,7 @@ program _gtools_internal, rclass | |
scalar __gtools_used_io = 0 | ||
scalar __gtools_ixfinish = 0 | ||
scalar __gtools_J = _N | ||
scalar __gtools_init_targ = ( "`ifin'" != "" ) & ("`merge'" != "") | ||
scalar __gtools_init_targ = ("`ifin'" != "") & ("`merge'" != "") | ||
|
||
if inlist("`anything'", "forceio", "switch") { | ||
local extravars `__gtools_sources' `__gtools_sources' `freq' | ||
|
@@ -1481,9 +1481,16 @@ program _gtools_internal, rclass | |
* 2. Sort indexed hash | ||
* 3. Determine group sizes and cut points | ||
* 4. Use index and group info to compute the function | ||
* | ||
* NOTE: If there are targets (as with egen, collapse, or generic | ||
* hash), they are replaced with missing values internally right | ||
* before writing the output. Special functions tag, group, | ||
* and count are initialized as well, should they have been | ||
* requested. | ||
|
||
if ( inlist("`gfunction'", "unique", "egen") ) { | ||
if ( inlist("`gfunction'", "unique", "egen", "hash") ) { | ||
local gcall hash | ||
scalar __gtools_init_targ = ("`ifin'" != "") & ("`replace'" != "") | ||
} | ||
else if ( inlist("`gfunction'", "contract") ) { | ||
local 0 `gcontract' | ||
|
@@ -2722,6 +2729,7 @@ program parse_by_types, rclass | |
exit 17005 | ||
} | ||
cap scalar drop __gtools_k_strL | ||
* disp as txt "(note: performance with strL variables is not optimized)" | ||
} | ||
else if ( ("`varstrL'" != "") & ("`forcestrl'" == "") ) { | ||
disp as err _n(1) "gtools failed to parse strL variables." | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
*! version 1.0.0 21Jul2018 Mauricio Caceres Bravo, [email protected] | ||
*! version 1.0.1 23Jul2018 Mauricio Caceres Bravo, [email protected] | ||
*! -collapse- implementation using C for faster processing | ||
|
||
capture program drop gcollapse | ||
program gcollapse, rclass | ||
version 13 | ||
version 13.1 | ||
global GTOOLS_USER_VARABBREV `c(varabbrev)' | ||
local 00 `0' | ||
|
||
|
@@ -627,6 +627,11 @@ program gcollapse, rclass | |
collapse `anything' `if' `in', `by' `cw' `fast' | ||
exit 0 | ||
} | ||
else if ( _rc == 17001 ) { | ||
local rc = _rc | ||
CleanExit | ||
error 2000 | ||
} | ||
else if ( _rc ) { | ||
local rc = _rc | ||
CleanExit | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
*! version 1.0.0 21Jul2018 Mauricio Caceres Bravo, [email protected] | ||
*! version 1.0.1 23Jul2018 Mauricio Caceres Bravo, [email protected] | ||
*! implementation -egen- using C for faster processing | ||
|
||
/* | ||
|
@@ -23,7 +23,7 @@ | |
|
||
capture program drop gegen | ||
program define gegen, byable(onecall) rclass | ||
version 13 | ||
version 13.1 | ||
|
||
local 00 `0' | ||
qui syntax anything(equalok) [if] [in] [aw fw iw pw], [by(str) *] | ||
|
@@ -287,20 +287,41 @@ program define gegen, byable(onecall) rclass | |
tempvar dummy | ||
local rename rename `dummy' `name' | ||
local addvar qui mata: st_addvar("`type'", "`dummy'") | ||
local noobs "" | ||
local retype = `retype' & 1 | ||
} | ||
else { | ||
|
||
* NOTE: Addvar should be "" with replace; the problem was that | ||
* the internals did not empty the variable before writing to | ||
* it. With if/in conditions, this caused problems because the | ||
* variable was not set to missing outside the range, as it | ||
* should. | ||
* | ||
* As a quickfix I thought I could just empty it before calling | ||
* internals. However, this causesd two issues: The variable | ||
* would be missing on error, and if the target is also a source, | ||
* the source would be all misssing when read by the plugin! | ||
* | ||
* The easiest fix was to require the target to not be in the | ||
* sources, but there was an easier fix! I already empty the | ||
* targets fot gcollapse, so I simply set that boolean to true | ||
* (init_targ) when gegen was called with replace! This impacts | ||
* the check in lines 489-492. | ||
|
||
cap confirm new variable `name' | ||
if ( _rc ) { | ||
local dummy `name' | ||
local rename "" | ||
local addvar qui replace `dummy' = . | ||
local addvar "" | ||
local noobs qui replace `dummy' = . | ||
local retype = `retype' & 0 | ||
} | ||
else { | ||
tempvar dummy | ||
local rename rename `dummy' `name' | ||
local addvar qui mata: st_addvar("`type'", "`dummy'") | ||
local noobs "" | ||
local retype = `retype' & 1 | ||
} | ||
} | ||
|
@@ -465,6 +486,13 @@ program define gegen, byable(onecall) rclass | |
global GTOOLS_CALLER "" di as err "{opth `ofcn'(varlist)} must call a numeric variable list." | ||
exit _rc | ||
} | ||
|
||
* See notes in lines 294-310 | ||
* if ( "`:list sources & dummy'" != "" ) { | ||
* if ( "`replace'" != "" ) local extra " even with -replace-" | ||
* di as error "Variable `dummy' canot be a source and a target`extra'" | ||
* exit 198 | ||
* } | ||
} | ||
} | ||
else if ( `rc' == 0 ) { | ||
|
@@ -578,6 +606,7 @@ program define gegen, byable(onecall) rclass | |
} | ||
else if ( `rc' == 17001 ) { | ||
if ( "${GTOOLS_DUPS}" == "" ) { | ||
`noobs' | ||
`rename' | ||
exit 0 | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.