ImperialCollegeLondon / ImperialCollegeLondon/ReCoDE-PythonGUI

Feedback from Day 3

Open
#5 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
2
Forks
1
PR merge metrics
No merged PRs in 30d

Description

Readme
  • The explanations are ok, but it contains way too much code. Here you want to explain what is to be done, not show the same blocks of code that you will include in the python files, anyway.
Python_GUI_day3_simple.py
  • This contains a lot of unnecessary duplicated code. For example, modifying the create_data function of Day2 we can write:
def create_data(fun, j=0):
	"""Include explanation here"""
	x = np.arange(500) / 1000
	y = 0.5 + 0.5 * fun(50 * (x + j/1000))
	return x, y

And then update update_series could be written as:

def update_series(j):
	"""Include explanation here"""
	# You can even define these as global constants, as they will be reused
	tags = SERIAL_TAG1, SERIAL_TAG2, SERIAL_TAG3
	funs = np.cos, np.sin, np.tan
	labels = "cos", "sin", "tan"

	for tag, fun, label in zip(tags, funs, labels):
		x, y = create_data(fun, j)
		dpg.set_value(tag, [x, y])
	        dpg.set_item_label(tag, f"0.5 + 0.5 * {label}(x)")
  • The very same thing can be done with the blocks that create the three plots: extract the parts that change and put the common code in a loop, replacing the relevant bits, as just done.
  • Breakdown the big function into smaller chunks, as done above
Python_GUI_day3_file.py

More or less thee same comments already done for Days 2 and 3:

  • Exploit numpy capabilities for indexing data
  • Reduce code duplication by extracting the different parts and putting the common ones in a loop
  • Breakdown the big function into smaller chunks, as done above

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Inspect Python_GUI_day3_simple.py and Python_GUI_day3_file.py, along with the README, to determine whether the checked feedback has already been applied. Verify that repeated plot logic is consolidated, NumPy indexing is used, and large functions are split into smaller pieces; the work is done when the listed duplication and documentation concerns are resolved.

Written by the indexing model from the issue text.

Assessment

Tech stack
numpy, python
Domain
desktop
Issue type
Refactor
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.