Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python coding cleanups #25

Open
jllanfranchi opened this issue Jan 28, 2017 · 1 comment
Open

Python coding cleanups #25

jllanfranchi opened this issue Jan 28, 2017 · 1 comment
Milestone

Comments

@jllanfranchi
Copy link

jllanfranchi commented Jan 28, 2017

  • Run the code through pylint to get general feedback on Python coding conventions and also basic bugs you might not otherwise catch
  • E.g.: one example I see is you shouldn't use type(x) == T; use instead isinstance(x, T).
    Obviously this is secondary to getting the code working and performant, but it's always easier to start early rather than build up a large codebase and then check with pylint.
  • FTYPE should be a single global value, and should not be changed. Function / parameter names should be all lower-case (possibly with underscores) and NOT be the same as the "globals" e.g. FTYPE. FTYPE so a function can take an argument ftype but be assigned the global FTYPE as a default, but within the function, it should make use of ftype. I.e.: func(x, y, ftype=FTYPE) is workable. func(x, y, FTYPE) or using FTYPE within the function if FTYPE is ever to be changed is not workable.
  • n_events argument indicates "number of events" yet there is also a number_of_events argument (GPUHist class / method(s))
  • Think through the logic of testing and implement it modularly; as it stands, there's a lot of copy-paste code in there, and things doing odd things with peculiar arguments to functions (e.g. creating an array NOT on the gpu (create_array(device_array=False)) returns a second value (usually reserved for a gpu-based array), but it's just a regular numpy array... then your subsequent code assignes that value to a variable d_input_data and might or might not work with it).
@mhieronymus mhieronymus added this to the Version 1.0 milestone Jan 29, 2017
@mhieronymus
Copy link
Owner

mhieronymus commented Feb 6, 2017

  • Using pylint
  • use isinstance (already changed it on many occasions)
  • Don't mess up global and local variables (FTYPE)
  • Rename n_events and number_of_events (n_events is now sample and number_of_events is now n_events because it makes more sense than before)
  • Rework the logic of the code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants