alteryx / alteryx/featuretools
Increase the usage of augmented assignment statements
- Langage dominant
- Python
- Étoiles
- 7.7k
- Forks
- 915
- Métriques de merge des PR
- Aucune PR mergée en 30 j
Description
:eyes: Some source code analysis tools can help to find opportunities for improving software components.
:thought_balloon: I propose to [increase the usage of augmented assignment statements](https://docs.python.org/3/reference/simple_stmts.html#augmented-assignment-statements "Augmented assignment statements") accordingly.
```diff
diff --git a/featuretools/computational_backends/utils.py b/featuretools/computational_backends/utils.py
index f0bf2fe..94e2c74 100644
--- a/featuretools/computational_backends/utils.py
+++ b/featuretools/computational_backends/utils.py
@@ -67,7 +67,7 @@ def datetime_round(dt, freq):
# No support for weeks in datetime.datetime
if unit == 'w':
unit = 'd'
- value = value * 7
+ value *= 7
freq = str(value) + unit
return dt.dt.floor(freq)
else:
@@ -97,7 +97,7 @@ def gather_approximate_features(feature_set):
base_feature = feature.base_features[0]
while isinstance(base_feature, DirectFeature):
- path = path + base_feature.relationship_path
+ path += base_feature.relationship_path
base_feature = base_feature.base_features[0]
if isinstance(base_feature, AggregationFeature):
diff --git a/featuretools/demo/flight.py b/featuretools/demo/flight.py
index 05d7a5a..ca7a495 100644
--- a/featuretools/demo/flight.py
+++ b/featuretools/demo/flight.py
@@ -229,7 +229,7 @@ def filter_data(clean_data,
if categorical_filter is not None:
tmp = False
for key, values in categorical_filter.items():
- tmp = tmp | clean_data[key].isin(values)
+ tmp |= clean_data[key].isin(values)
clean_data = clean_data[tmp]
return clean_data
diff --git a/featuretools/entityset/entityset.py b/featuretools/entityset/entityset.py
index 8e72541..5c9b519 100644
--- a/featuretools/entityset/entityset.py
+++ b/featuretools/entityset/entityset.py
@@ -1316,7 +1316,7 @@ class EntitySet(object):
lti_mask = df[lti_col] > time_last - training_window
else:
lti_mask = df[lti_col] >= time_last - training_window
- mask = mask | lti_mask
+ mask |= lti_mask
else:
warnings.warn(
"Using training_window but last_time_index is "
diff --git a/featuretools/primitives/standard/aggregation_primitives.py b/featuretools/primitives/standard/aggregation_primitives.py
index c78d590..693a7c8 100644
--- a/featuretools/primitives/standard/aggregation_primitives.py
+++ b/featuretools/primitives/standard/aggregation_primitives.py
@@ -415,7 +415,7 @@ class AvgTimeBetween(AggregationPrimitive):
# between values, len(x)-1 = len(diff(x))
avg = (x.max() - x.min()) / (len(x) - 1)
- avg = avg * 1e-9
+ avg *= 1e-9
# long form:
# diff_in_ns = x.diff().iloc[1:].astype('int64')
@@ -741,8 +741,8 @@ class Trend(AggregationPrimitive):
else:
y = df['y'].values
- x = x - x.mean()
- y = y - y.mean()
+ x -= x.mean()
+ y -= y.mean()
# prevent divide by zero error
if len(np.unique(x)) == 1:
```
Guide de contribution
Ouvrir le guide de contribution
Évaluation
Cette issue n'a pas encore été évaluée.