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

Tree tutorials translated into Python. #16620

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

PPaye
Copy link

@PPaye PPaye commented Oct 7, 2024

This Pull request:

Adds to the root/tutorials/*.C macros their respective python scripts.
Enjoy this "pyroothonic" syntax style.

  • [yes] tested changes locally
  • [yes] updated the docs (if necessary)

@PPaye PPaye requested a review from couet as a code owner October 7, 2024 11:45
sin,
cos,
sqrt,
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For consistency this parenthesis should be aligned under sqrt

Copy link
Contributor

@silverweed silverweed left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this contribution!

I started adding some comments here and there (all about code style and commented-out-code basically) but then I realized there's just too many files and it'd get repetitive.

I'll summarize my comments in: I believe before adding these tutorials we should also clean them up a bit in the process: at the very least by removing all commented out code (or explaining why it's there) and using a consistent style to aid readability.

Also, I'm not sure it's a good idea to add all the tutorials in the same PR, and especially not in the same commit. Ideally each tutorial should have its own commit, or at least be grouped in smaller chunks.

I know it's quite a bit of work, but this is code that many users will use as an example to write their own programs, so it should be as clean as possible!


# utils
def to_c( ls ):
return (c_double * len(ls) )( * ls )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would add a newline between the functions for readability. Also please use consistent spacing for the parentheses (prefer (ls) to ( ls ) and so on)

#
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#
print( "Geting and Compiling libEvent.so with ACLiC.")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo: "Geting".
Also see comment above for consistent parentheses spacing

],

check = True,

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove empty newline here

ROOTSYS = str( gROOT.GetDataDir() )
#
for event_file in event_files:
#os.rename( event_file, ROOTSYS + "/include/" + event_file )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove commented-out code


#
# Moving Event* files to root/include directory.
# There was no other option, AddIncludePaths, AddDynamicPath weren't working well.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comment doesn't look like it should belong to a tutorial. If we can't figure out why those alternative didn't work, we should either figure it out or not mention them

#gSystem.CompileMacro( source_Event, "gO ")
gSystem.CompileMacro( source_Event, )

# libEven.so
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove all this commented-out code

#gSystem.GetDynamicPath( )


#import sys
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove

gSystem.AddDynamicPath( "./Event" )
# No need. It seems ACLiC already does that.
#
#ROOT.gSystem.Load("libEvent.so") # Inherited from .C Version.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If unneeded, please remove

TH1F,
TGraph,
TLatex,
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consistently align parentheses


#utils
def to_c( ls ):
return (c_double * len(ls) )( * ls )
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comment in the file above (spacing, newlines)

@pcanal pcanal requested review from vepadulano and removed request for couet October 9, 2024 20:13
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

Successfully merging this pull request may close these issues.

3 participants