software running on production servers to handle live users and data of the intended audience. Note this is different from production quality code, which describes code that meets expectations in reliability, efficiency, etc., for production. Ideally, all code in production meets these expectations, but this is not always the case.
readable, simple, and concise. A characteristic of production quality code that is crucial for collaboration and maintainability in software development.
logically broken up into functions and modules. Also an important characteristic of production quality code that makes your code more organized, efficient, and reusable.
[ Code Experiment] -> [Code Refactoring] (Constantly)
in line comment (Explain when code cannot)
Reable code is preferable over having comments
def function_name (var1, var2=10, *args, **kwargs):
""" Purpose of this function
Parameters:
-----------
var1: array_like
Explanation
var2: int or float
Explanation
*args : iterable
Other arguments.
long_var_name : {'hi', 'ho'}, optional
Choices in brackets, default first when optional.
**kwargs : dict
Keyword arguments.
Returns:
-------
output list Explanation
"""
Return output
Reference: https://numpydoc.readthedocs.io/en/latest/format.html
README file
# Experiment: Intersection List
import time
import numpy as np
# Create sample date
list1 = list(range(1, 10001))
list2 = list(range(1, 5001))
# Experiment1: loop
start_time = time.time()
intersection_list1 = []
for item in list1:
if item in list2:
intersection_list1.append(item)
print('Experiment 1: loop, Duration: {:.4f} seconds'.format(time.time() - start_time))
# Experiment2: np.intersect1d
start_time = time.time()
intersection_list2 = np.intersect1d(list1, list2)
print('Experiment 2: np.inters., Duration: {:.4f} seconds'.format(time.time() - start_time))
# Experiment3: set
start_time = time.time()
intersection_list3 = set.intersection(set(list1), set(list2))
print('Experiment 3: set, Duration: {:.4f} seconds'.format(time.time() - start_time))
# Experiment: Conditional sum
import time
import numpy as np
# Create sample date
list1 = np.array(range(1, 100001)).astype(int)
# Experiment1: loop
start_time = time.time()
total1 = 0
for item in list1:
if item < 2000:
total1 += item
print('Experiment 1: loop, Duration: {:.4f} seconds'.format(time.time() - start_time))
# Experiment2: np.intersect1d
start_time = time.time()
total2 = (list1[list1 < 2000]).sum()
print('Experiment 2: numpy, Duration: {:.4f} seconds'.format(time.time() - start_time))
master
devlop
-> LOCAL □develop
Pull from develop branch master
devlop
-> LOCAL □develop
☑feature1
Create feature1 branch master
devlop
-> LOCAL □develop
☑feature1
Edit code in feature1 branchmaster
devlop
-> LOCAL □develop
☑feature1
Commit change of feature1 branchmaster
devlop
-> LOCAL ☑develop
□feature1
Switch to develop branchmaster
devlop
-> LOCAL □develop
□feature1
☑feature2
Create feature2 branchmaster
devlop
-> LOCAL □develop
□feature1
☑feature2
Edit feature2 branchmaster
devlop
-> LOCAL □develop
□feature1
☑feature2
Commi feature2 branchmaster
devlop
-> LOCAL ☑develop
□feature1
□feature2
Switch to Develop branchmaster
devlop
-> LOCAL ☑develop
□feature1
□feature2
Pull from latest Remote Develop branchmaster
devlop
-> LOCAL ☑develop
□feature1
Merge with feature2 branchmaster
devlop
-> LOCAL ☑develop
□feature1
Push to remote develop branchmaster
devlop
-> LOCAL □develop
☑feature1
Switch to feature1 branchmaster
devlop
-> LOCAL ☑develop
Review remote development and merge it to master☑ local active branch
master
devlop
-> LOCAL □develop
Pull from develop branch master
devlop
-> LOCAL □develop
☑model
Create model branch master
devlop
-> LOCAL □develop
☑model
Turn parameter and commit1 cv0.9master
devlop
-> LOCAL □develop
☑model
Turn parameter and commit2 cv0.8master
devlop
-> LOCAL □develop
☑model
Switch to commit2 cv0.9master
devlop
-> LOCAL ☑develop
□mode1
Switch to develop branchmaster
devlop
-> LOCAL ☑develop
□model
Pull from latest Remote Develop branchmaster
devlop
-> LOCAL ☑develop
Merge with model branchmaster
devlop
-> LOCAL ☑develop
Push to remote develop branchmaster
devlop
-> LOCAL ☑develop
Review remote development and merge it to master☑ local active branch
Be concise and use normal capitalization
Level for logging
Questions to ASK
Is the code clean and modular?
Is the code efficient?
Is documentation effective?
Is the code well tested?
Is the logging effective?
### Tips
Use a code linter to check
Provide code examples
https://github.com/lyst/MakingLyst/tree/master/code-reviews
https://www.kevinlondon.com/2015/05/05/code-review-best-practices.html
# Sample Test files
# compute_launch.py
# def days_until_launch(current_day, launch_day):
# """"Returns the days left before launch.
# current_day (int) - current day in integer
# launch_day (int) - launch day in integer
# """
# if launch_day < current_day:
# days_until_launch = 0
# else:
# days_until_launch = launch_day - current_day
# return days_until_launch
# test_compute_launch
# from compute_launch import days_until_launch
# def test_days_until_launch_4():
# assert(days_until_launch(22, 26) == 4)
# def test_days_until_launch_0():
# assert(days_until_launch(253, 253) == 0)
# def test_days_until_launch_0_negative():
# assert(days_until_launch(83, 64) == 0)
# def test_days_until_launch_1():
# assert(days_until_launch(9, 10) == 1)
Be concise and use normal capitalization
Level for logging
Questions to ASK
Is the code clean and modular?
Is the code efficient?
Is documentation effective?
Is the code well tested?
Is the logging effective?
https://github.com/lyst/MakingLyst/tree/master/code-reviews
https://www.kevinlondon.com/2015/05/05/code-review-best-practices.html
Variable Name Guidelines: