GithubHelp home page GithubHelp logo

Comments (6)

mcaceresb avatar mcaceresb commented on May 26, 2024

This is by design. fcollapse is smarter than gcollapse in assigning small variable types while preventing overflow. I do not think this is feasible for me, however, because I have to create the typed variable before doing any operations. This is the smartest I could be:

  • For bytes, I can use int as the target type for N up to 327.
  • For int, I can use long as target for N up to 65,592.

These are relatively small Ns, so I didn't think to check. Past that, I would risk overflows because I don't know the result until after I compute the sum. An int can hold integers up to 2^15-28, and past 65,592 obs a long would overflow.

from stata-gtools.

mcaceresb avatar mcaceresb commented on May 26, 2024

Not automatic, but perhaps faster than compress: I could add an option so that instead of assuming the worst possible theoretical case I check the range (or maybe even the sum, since I'd be looping over the variable anyway) and then decide the type based on that. Good compromise? It would still involve some overhead but maybe not as much. Let me know.

from stata-gtools.

jorpppp avatar jorpppp commented on May 26, 2024

from stata-gtools.

mcaceresb avatar mcaceresb commented on May 26, 2024

This is in the develop branch; will hit master when I get a chance to run the tests. You should be able to try it out via

gtools, upgrade branch(develop)

Add option sumcheck to gcollapse

from stata-gtools.

jorpppp avatar jorpppp commented on May 26, 2024

from stata-gtools.

mcaceresb avatar mcaceresb commented on May 26, 2024

Note to self: This is still a problem with weights, where a sum might overflow but it is not detected.

from stata-gtools.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.