10

Test cases are not convincing. I understand that the program doesn't crash, and by visual inspection of the code it seems to do the right things. However, it is pretty much impossible to check how the potential of 5000 random charges should look like. I'd rather see at least two elementary potentials: one of a single charge, and one of a dipole. No naked ...


8

Some minor improvements can be applied to your code; you have the following method: public double calculatePotentialAt(double otherPointXCoordinate, double otherPointYCoordinate) { double electrostaticConstant = 8.99e09; double distanceInXCoordinate = otherPointXCoordinate - pointXCoordinate; double distanceInYCoordinate = otherPointYCoordinate - ...


7

Whitespace There should be a blank line between two method definitions. Also, some blank lines inside of the methods would give the code room to breathe, and allow you to visually separate individual "steps" from each other, for example in your main method: int n = Integer.parseInt(args[0]); double step = Double.parseDouble(args[1]); Turtle turtle =...


5

Instead of grouping by the invoice on each category, I would reverse the logic. Group per invoice, and then classify that invoice. categories = pd.concat( classify_invoice(data) for invoice, data in df.groupby("invoice") ) | | 0 | |---:|:--------------| | 0 | OneJuice | | 1 | OneJuice | | 2 | Healthy | | 3 | ...


5

Your code is pretty impressive. Many python programmers don't know how to use pandas as well as you. Your code might not look very "Pythonic", but you did a great job utilizing vectorized methods with indexing. In this answer, I include one section on Python code conventions and a second attempting to optimizing your code. Python Code Conventions ...


4

In addition to Marc's answer: Add some test cases needing simplification of the result, e.g. 1/10 + 1/15 = 1/6. If numerators or denominators reach ~50000, their products (computed in intermediate steps) will exceed the integer range, even if the simplified result fits well into that range. You can improve that by using long for the intermediate calculations ...


3

Here I provide a different approach to solve this problem more efficiently. Compared with OP's solution, the primary optimization comes in the following aspects: Calling isin four times for each item class (Dessert, Hot, Juice, Milk) is inefficient. A better approach is to join the original DataFrame df with a Series that maps each item to a class, and then ...


3

This is not a complete answer, only a couple of observations. This answer sits on top of Marc's excellent answer and further refines his code. Here's what I did: The biggest change is that I changed class Rational into a record. The reduction in code is not quite as dramatic as in some of the artificial examples you have probably seen, since we're not using ...


3

Formatting Run your code through a style checker / formatter to make it more readable and follow a standardized code style. For example this one https://codebeautify.org/javaviewer Don't repeat yourself 1 Complex minusOne = new Complex(-1.0 ,0.0); You are defining this in more than one place. This should be a final member at the beginning of your class. Don'...


2

About __optimize__ Identifiers starting with double underscores are reserved. Also, why is this written as a lambda instead of as a regular function? You're also not reading and writing to standard I/O, so this function wouldn't have any effect anyway. Avoid creating type aliases outside of a class or namespace Don't declare using ValueType = int in the ...


2

First improvement I see is mathematical: to check if a number n is prime, it's sufficient to verify that it's not divisible by any integer between 2 and math.ceil(math.sqrt(n)) (don't forget to import math at the top of your file). That's going to make your program more efficient. Another improvement would be to split the code that deals with getting the ...


2

I agree with Abdur keep it simple with one class. Other things that could be improved is: Add a data base, you could use pickle or shelve to store user names and passwords.basic start to shelves 2)Add a button for new users right away. 3)your use of relx and rely has some overlapping side effects you might be better off using x and y with real coordinates. ...


2

Some usual PEP8 comments: username_clear.delete(0,END) -> username_clear.delete(0, END) in_use.place(relx= 0.0, rely= 0.7, anchor= "sw") -> in_use.place(relx=0.0, rely=0.7, anchor="sw") New_user should have either been NewUser for a class name or new_user in other cases Choose meaningful names & avoid typos Avoid typos like: ...


1

A few remarks, mainly focussing on the Histogram class. Separation of concerns Your application contains different parts: algorithmic parts (collecting histogram data), user interface parts (draw() methods), and main() methods. You already separate these concerns into different methods, which is a good thing. But I recommend to go one step further, and to ...


Only top voted, non community-wiki answers of a minimum length are eligible