Re: [BangPypers] Fwd: Need a help on reviewing a python code. Message-ID: cacimrglh7bharoas710ofojd8g2i_liynbywka1640dvk5r...@mail.gmail.com
Very minor comments. 1. planet.py: from math import pi as PI Unless there is a name conflict with the identifier being used. You could avoid using as in the import. Here I guess, you wanted constants in capitals (perhaps a linter tool required). In that case, you could write it as import math; and use it is math.pi 2.input_parser.py Keep the import yaml at the top along with other imports. There is no reason to have it hidden in the methods. 3. cmdline_parser.py : You don't need a trailing blackslash here. self.parser.add_argument(--config, dest='config_file', \ Since the break is happening within (, the implicit line joiners will take care of having all the arguments within (). 4. arbitory_solar_system.py: ab_solar_system = ArbitarySolarSystem(config='system.yaml') You could assign CONSTANTS to various .yaml files. That said, everything else looks good to me and code was pythonic too. I believe, you used some tools like pep8, flake8 to do automatic style fixes. Thank you, Senthil On Fri, Jul 17, 2015 at 3:55 AM, Ramesh Rajagopal mail2.rame...@gmail.com wrote: With regards to the below thread-id, I have posted my code into github account. Please have a look at and review it. https://github.com/rameshrajagopal/alignment Regards, Ramesh Message: 1 Date: Fri, 17 Jul 2015 01:13:13 +0530 From: Gora Mohanty g...@mimirtech.com To: Bangalore Python Users Group - India bangpypers@python.org Subject: Re: [BangPypers] Fwd: Need a help on reviewing a python code. Message-ID: cacimrglh7bharoas710ofojd8g2i_liynbywka1640dvk5r...@mail.gmail.com Content-Type: text/plain; charset=UTF-8 Hi, Just forget it. The problem statement itself is so badly broken that it is unfixable, IMHO. To quote from problem.txt: The application will not determine the alignments itself. Instead, the application must be able to load a set of plugins at runtime that will determine whether a particular configuration of planets is 'aligned' according to whatever definition the plugin uses for alignment. Yes, and without the specification of an interface, I suppose Moses will come down from the mountain to tell us how a particular plugin decides how a planet is alignedOh my God/aligned. IMHO, it is just not worth even applying to such companies as their basic recruitment process seems not to work. Regards, Gora On 17 July 2015 at 00:54, Senthil Kumaran sent...@uthcode.com wrote: Agree with Anuvrat. Paste your code in https://gist.github.com/ or upload it github/bitcket and share it again. I will help with the review. Thanks, Senthil On Thu, Jul 16, 2015 at 3:40 AM, Anuvrat Parashar anuv...@anuvrat.in wrote: 1. alignment.tar.gs is missing. 2. please consider hosting the code on github / bitbucket instead of attaching heavy files. On Thu, Jul 16, 2015 at 3:49 PM, Ramesh Rajagopal mail2.rame...@gmail.com wrote: -- Forwarded message -- From: Ramesh Rajagopal mail2.rame...@gmail.com Date: Jul 16, 2015 3:30 PM Subject: Fwd: Need a help on reviewing a python code. To: bangpypers@python.org Cc: Hello All, It would be very helpful, if you can review a small code which I had written in python. It is purely for my personal development perspective. I had a got an assignment from a company, they rejected my assignment without exactly stating what is the problem with my code. They just conveyed that it doesn't look like a pythonic way. I would like to understand my mistakes and improve on this. It would be good if you can help me on this. I am attaching the problem.txt(which has the assignment details, we need to make assumptions), then solution as alignment.tar.gz file. Looking forward you reply. Regards, Ramesh ___ BangPypers mailing list BangPypers@python.org https://mail.python.org/mailman/listinfo/bangpypers -- Anuvrat Parashar http://anuvrat.in http://anuvrat.in ___ BangPypers mailing list BangPypers@python.org https://mail.python.org/mailman/listinfo/bangpypers ___ BangPypers mailing list BangPypers@python.org https://mail.python.org/mailman/listinfo/bangpypers ___ BangPypers mailing list BangPypers@python.org https://mail.python.org/mailman/listinfo/bangpypers ___ BangPypers mailing list BangPypers@python.org https://mail.python.org/mailman/listinfo/bangpypers
[BangPypers] Fwd: Need a help on reviewing a python code. Message-ID: cacimrglh7bharoas710ofojd8g2i_liynbywka1640dvk5r...@mail.gmail.com
With regards to the below thread-id, I have posted my code into github account. Please have a look at and review it. https://github.com/rameshrajagopal/alignment Regards, Ramesh Message: 1 Date: Fri, 17 Jul 2015 01:13:13 +0530 From: Gora Mohanty g...@mimirtech.com To: Bangalore Python Users Group - India bangpypers@python.org Subject: Re: [BangPypers] Fwd: Need a help on reviewing a python code. Message-ID: cacimrglh7bharoas710ofojd8g2i_liynbywka1640dvk5r...@mail.gmail.com Content-Type: text/plain; charset=UTF-8 Hi, Just forget it. The problem statement itself is so badly broken that it is unfixable, IMHO. To quote from problem.txt: The application will not determine the alignments itself. Instead, the application must be able to load a set of plugins at runtime that will determine whether a particular configuration of planets is 'aligned' according to whatever definition the plugin uses for alignment. Yes, and without the specification of an interface, I suppose Moses will come down from the mountain to tell us how a particular plugin decides how a planet is alignedOh my God/aligned. IMHO, it is just not worth even applying to such companies as their basic recruitment process seems not to work. Regards, Gora On 17 July 2015 at 00:54, Senthil Kumaran sent...@uthcode.com wrote: Agree with Anuvrat. Paste your code in https://gist.github.com/ or upload it github/bitcket and share it again. I will help with the review. Thanks, Senthil On Thu, Jul 16, 2015 at 3:40 AM, Anuvrat Parashar anuv...@anuvrat.in wrote: 1. alignment.tar.gs is missing. 2. please consider hosting the code on github / bitbucket instead of attaching heavy files. On Thu, Jul 16, 2015 at 3:49 PM, Ramesh Rajagopal mail2.rame...@gmail.com wrote: -- Forwarded message -- From: Ramesh Rajagopal mail2.rame...@gmail.com Date: Jul 16, 2015 3:30 PM Subject: Fwd: Need a help on reviewing a python code. To: bangpypers@python.org Cc: Hello All, It would be very helpful, if you can review a small code which I had written in python. It is purely for my personal development perspective. I had a got an assignment from a company, they rejected my assignment without exactly stating what is the problem with my code. They just conveyed that it doesn't look like a pythonic way. I would like to understand my mistakes and improve on this. It would be good if you can help me on this. I am attaching the problem.txt(which has the assignment details, we need to make assumptions), then solution as alignment.tar.gz file. Looking forward you reply. Regards, Ramesh ___ BangPypers mailing list BangPypers@python.org https://mail.python.org/mailman/listinfo/bangpypers -- Anuvrat Parashar http://anuvrat.in http://anuvrat.in ___ BangPypers mailing list BangPypers@python.org https://mail.python.org/mailman/listinfo/bangpypers ___ BangPypers mailing list BangPypers@python.org https://mail.python.org/mailman/listinfo/bangpypers ___ BangPypers mailing list BangPypers@python.org https://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] Fwd: Need a help on reviewing a python code.
1. alignment.tar.gs is missing. 2. please consider hosting the code on github / bitbucket instead of attaching heavy files. On Thu, Jul 16, 2015 at 3:49 PM, Ramesh Rajagopal mail2.rame...@gmail.com wrote: -- Forwarded message -- From: Ramesh Rajagopal mail2.rame...@gmail.com Date: Jul 16, 2015 3:30 PM Subject: Fwd: Need a help on reviewing a python code. To: bangpypers@python.org Cc: Hello All, It would be very helpful, if you can review a small code which I had written in python. It is purely for my personal development perspective. I had a got an assignment from a company, they rejected my assignment without exactly stating what is the problem with my code. They just conveyed that it doesn't look like a pythonic way. I would like to understand my mistakes and improve on this. It would be good if you can help me on this. I am attaching the problem.txt(which has the assignment details, we need to make assumptions), then solution as alignment.tar.gz file. Looking forward you reply. Regards, Ramesh ___ BangPypers mailing list BangPypers@python.org https://mail.python.org/mailman/listinfo/bangpypers -- Anuvrat Parashar http://anuvrat.in http://anuvrat.in ___ BangPypers mailing list BangPypers@python.org https://mail.python.org/mailman/listinfo/bangpypers
[BangPypers] Fwd: Need a help on reviewing a python code.
-- Forwarded message -- From: Ramesh Rajagopal mail2.rame...@gmail.com Date: Jul 16, 2015 3:30 PM Subject: Fwd: Need a help on reviewing a python code. To: bangpypers@python.org Cc: Hello All, It would be very helpful, if you can review a small code which I had written in python. It is purely for my personal development perspective. I had a got an assignment from a company, they rejected my assignment without exactly stating what is the problem with my code. They just conveyed that it doesn't look like a pythonic way. I would like to understand my mistakes and improve on this. It would be good if you can help me on this. I am attaching the problem.txt(which has the assignment details, we need to make assumptions), then solution as alignment.tar.gz file. Looking forward you reply. Regards, Ramesh Create a command line application to print out planets that are aligned. The application should work for an arbitrary solar system. The planets in the solar system will be define in a configuration file with the following format, system: - name: planet-A theta: 0 radius: 1 period: 20 - name: planet-B theta: 0 radius: 5 period: 30 - name: planet-C theta: 2 radius: 10 period: 60 So each planet has a name, an initial angle (theta) given in radians, a radius from the sun that it orbits, and length of time it takes to orbit the sun (period). Assume that the orbit of each planet is a circle centered on the sun. The position of each planet can be described by a radius and an angle. The radius is constant, but the angle varies with time, i.e. at time 't' the angle of a planet is given by, theta + 2 pi t / period The application will not determine the alignments itself. Instead, the application must be able to load a set of plugins at runtime that will determine whether a particular configuration of planets is 'aligned' according to whatever definition the plugin uses for alignment. The application must take arguments for the configuration file, a list of plugins to load, and the time to calculate the alignment for. For example, ./alignment.py --config system.yaml --plugins ~/foo.py ~/bar.py ~/baz.py --time 10 and the output will have the format, foo: planet-A, planet-B bar: planet-B, planet-C bar: planet-A, planet-B baz: planet-A, planet-B, planet-C where the application prints out the aligned planets on a new line with the name of the plugin that return the alignment. The application is expected to well documented and clear. Provide explanations for the design decisions (e.g. provide rationale for why you did or did not use a particular package). Where there is ambiguity in the problem, state the assumptions you used to solve it. The application should support versions 2.7.x and 3.3.x (or greater) of python. The application should come with a simple setup.py for installation, and an example plugin that treats planets as aligned if they are within 5 degrees of one another relative to the sun A small commandline application which sets up arbitory solar system based on the config file provided. It also prints the alignment of the planets based on plugins provided. Installing the application: -- a) tar xjvf alignment-0.1.tar.gz b) cd alignment c) python setup.py install How to run the application: -- python alignment.py --config sample_config_file --plugins plugin1 plugin2 plugin3 --time 10 e.g: python alignment.py --config plugins/sample.yaml --plugins plugins/five_degree_alignment.py --time 10 Command Line Alignment Application -- This is simple command line application which sets up arbitory solar system based on the provided configuration files. It also allows to run the plugin during runtime to decide the alignment of planets based on the decision made by plugins. Design Decisions: 1) Arbitory Solar System is setup based on the given system config file. It also exposes APIs for dynamically adding planet and removing planet from the solar system. Hence in order to add/search/remove quickly, the planet information has been kept under dictionary. 2) Current Arbitory Solar System planet's doesn't orbit the sun. It just gives information from the initial position where it will be after the 'time' ticks. This can be extended by having start() method to orbit the sun. 3) It is assumed that the period and 'time' ticks comes from the command line, has been considered having some units of measurement. This assumption makes the calculation easy without need to conversion. 4) InputParser class has been created to handle multiple file formats. Current one just supports yaml parser, since we are dealing with only yaml files as of now. This class can be extended to parse different file format as well. 5) It is assumed the plugin's file will make all the decision about whether two planets
Re: [BangPypers] Fwd: Need a help on reviewing a python code.
Hi, Just forget it. The problem statement itself is so badly broken that it is unfixable, IMHO. To quote from problem.txt: The application will not determine the alignments itself. Instead, the application must be able to load a set of plugins at runtime that will determine whether a particular configuration of planets is 'aligned' according to whatever definition the plugin uses for alignment. Yes, and without the specification of an interface, I suppose Moses will come down from the mountain to tell us how a particular plugin decides how a planet is alignedOh my God/aligned. IMHO, it is just not worth even applying to such companies as their basic recruitment process seems not to work. Regards, Gora On 17 July 2015 at 00:54, Senthil Kumaran sent...@uthcode.com wrote: Agree with Anuvrat. Paste your code in https://gist.github.com/ or upload it github/bitcket and share it again. I will help with the review. Thanks, Senthil On Thu, Jul 16, 2015 at 3:40 AM, Anuvrat Parashar anuv...@anuvrat.in wrote: 1. alignment.tar.gs is missing. 2. please consider hosting the code on github / bitbucket instead of attaching heavy files. On Thu, Jul 16, 2015 at 3:49 PM, Ramesh Rajagopal mail2.rame...@gmail.com wrote: -- Forwarded message -- From: Ramesh Rajagopal mail2.rame...@gmail.com Date: Jul 16, 2015 3:30 PM Subject: Fwd: Need a help on reviewing a python code. To: bangpypers@python.org Cc: Hello All, It would be very helpful, if you can review a small code which I had written in python. It is purely for my personal development perspective. I had a got an assignment from a company, they rejected my assignment without exactly stating what is the problem with my code. They just conveyed that it doesn't look like a pythonic way. I would like to understand my mistakes and improve on this. It would be good if you can help me on this. I am attaching the problem.txt(which has the assignment details, we need to make assumptions), then solution as alignment.tar.gz file. Looking forward you reply. Regards, Ramesh ___ BangPypers mailing list BangPypers@python.org https://mail.python.org/mailman/listinfo/bangpypers -- Anuvrat Parashar http://anuvrat.in http://anuvrat.in ___ BangPypers mailing list BangPypers@python.org https://mail.python.org/mailman/listinfo/bangpypers ___ BangPypers mailing list BangPypers@python.org https://mail.python.org/mailman/listinfo/bangpypers ___ BangPypers mailing list BangPypers@python.org https://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] Fwd: Need a help on reviewing a python code.
Agree with Anuvrat. Paste your code in https://gist.github.com/ or upload it github/bitcket and share it again. I will help with the review. Thanks, Senthil On Thu, Jul 16, 2015 at 3:40 AM, Anuvrat Parashar anuv...@anuvrat.in wrote: 1. alignment.tar.gs is missing. 2. please consider hosting the code on github / bitbucket instead of attaching heavy files. On Thu, Jul 16, 2015 at 3:49 PM, Ramesh Rajagopal mail2.rame...@gmail.com wrote: -- Forwarded message -- From: Ramesh Rajagopal mail2.rame...@gmail.com Date: Jul 16, 2015 3:30 PM Subject: Fwd: Need a help on reviewing a python code. To: bangpypers@python.org Cc: Hello All, It would be very helpful, if you can review a small code which I had written in python. It is purely for my personal development perspective. I had a got an assignment from a company, they rejected my assignment without exactly stating what is the problem with my code. They just conveyed that it doesn't look like a pythonic way. I would like to understand my mistakes and improve on this. It would be good if you can help me on this. I am attaching the problem.txt(which has the assignment details, we need to make assumptions), then solution as alignment.tar.gz file. Looking forward you reply. Regards, Ramesh ___ BangPypers mailing list BangPypers@python.org https://mail.python.org/mailman/listinfo/bangpypers -- Anuvrat Parashar http://anuvrat.in http://anuvrat.in ___ BangPypers mailing list BangPypers@python.org https://mail.python.org/mailman/listinfo/bangpypers ___ BangPypers mailing list BangPypers@python.org https://mail.python.org/mailman/listinfo/bangpypers
Re: [BangPypers] Fwd: Need a help on reviewing a python code.
On Thu, Jul 16, 2015 at 12:43 PM, Gora Mohanty g...@mimirtech.com wrote: IMHO, it is just not worth even applying to such companies as their basic recruitment process seems not to work. Agree. Irrespective of that, this list 'bangpypers' focusses on python language ecosystem. So, I thought, we could help with the idiomaticity of the code, if provided and be helpful to the learner. -- Senthil ___ BangPypers mailing list BangPypers@python.org https://mail.python.org/mailman/listinfo/bangpypers