Skip to content

thomas python example #191

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

Merged
merged 9 commits into from
Jul 3, 2018

Conversation

gammison
Copy link
Contributor

@gammison gammison commented Jul 1, 2018

No description provided.

@june128 june128 added the Implementation This provides an implementation for an algorithm. (Code and maybe md files are edited.) label Jul 1, 2018
Copy link
Contributor

@VikingScientist VikingScientist left a comment

Choose a reason for hiding this comment

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

Thanks for your contribution!

The code is, as far as I can tell, correct and should be included on trunk. There are a few minor style-issues that I would like too see changed to so it appears more consist with the rest of the python codes.

Also you'll have to fix the merge conflicts which came up after #188 was merged.

#Author: gammison

#note this example is inplace and destructive
def thomas(a:list,b:list,c:list,d:list):
Copy link
Contributor

Choose a reason for hiding this comment

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

We don't use type hints elsewhere in the python code. The code should have the same style and I would request that this PR leave it out. If you strongly feel that type hints are a good thing, then either make an issue discussing it or create a brand new PR introducing it in all python codes.

return d

#Complexity:
#Two loops,each take O(n), and a few contant time operations => T(n) = 2*O(n)+c*O(1) = O(n)
Copy link
Contributor

Choose a reason for hiding this comment

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

Complexity discussions should be left to the accompanying article and not in the source code. Please remove this

c=[4,5,0]
d=[7,5,3]
soln = thomas(a,b,c,d)
print(soln)
Copy link
Contributor

Choose a reason for hiding this comment

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

Wrap execution code into a main-method. See i.e. data_compression/huffman/code/python/huffman.py

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

style changes pushed

@gammison
Copy link
Contributor Author

gammison commented Jul 2, 2018

Merge from #188 resolved and style fixes completed

Copy link
Contributor

@Butt4cak3 Butt4cak3 left a comment

Choose a reason for hiding this comment

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

Thanks for contributing from me as well!

I, too, have some style related requests for you. Nothing major, mostly whitespace.

@@ -0,0 +1,43 @@
#Author: gammison
Copy link
Contributor

Choose a reason for hiding this comment

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

All the other Python code in the project puts a space between # and the comment text.

#Author: gammison

#note this example is inplace and destructive
def thomas(a,b,c,d):
Copy link
Contributor

Choose a reason for hiding this comment

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

There should be spaces after every comma in the parameter list.

d[0] = d[0] / b[0]

n = len(d) #number of equations to solve
#range is exclusive, loop will run from 1 to n-1
Copy link
Contributor

Choose a reason for hiding this comment

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

I think range() is common in enough to Python to leave this comment out.

b=[1,3,6]
c=[4,5,0]
d=[7,5,3]
soln = thomas(a,b,c,d)
Copy link
Contributor

Choose a reason for hiding this comment

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

Again, add some spaces before and after = and after every , to be in line with all the other code examples.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@VikingScientist
Copy link
Contributor

This looks good. I have no more objections and I think it's ready for merging

@Butt4cak3
Copy link
Contributor

I agree.

@Butt4cak3 Butt4cak3 merged commit 2d8d2ef into algorithm-archivists:master Jul 3, 2018
@gammison gammison deleted the tom_alg_python branch July 3, 2018 19:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Implementation This provides an implementation for an algorithm. (Code and maybe md files are edited.)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants