| Conditions | 1 |
| Total Lines | 75 |
| Code Lines | 52 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | import pytest |
||
| 52 | # assert 'add_attribute' in DataEngine.test_pd.registry |
||
| 53 | # assert 'add_attribute' in DataEngine.test_pd._commands |
||
| 54 | # assert 'add_attribute' not in DataEngine.registry |
||
| 55 | # |
||
| 56 | # assert type(DataEngine.test_pd._commands['add_attribute']) == Command |
||
| 57 | # |
||
| 58 | # cmd = data_manager.command.add_attribute |
||
| 59 | # assert type(cmd._receiver) == types.FunctionType |
||
| 60 | # assert cmd._method == '__call__' |
||
| 61 | # cmd.args = [datapoints, [_ for _ in range(1, len(datapoints) + 1)], 'test_attr'] |
||
| 62 | # |
||
| 63 | # from green_magic.utils.commands import Invoker, CommandHistory |
||
| 64 | # inv = Invoker(CommandHistory()) |
||
| 65 | # inv.execute_command(cmd) |
||
| 66 | # |
||
| 67 | # assert set(datapoints.attributes) == set(_ for _ in list(test_json_data['attributes']) + ['test_attr']) |
||
| 68 | # |
||
| 69 | # @DataEngine.dec() |
||
| 70 | # def list_to_encoded(_datapoints, values, new_attribute): |
||
| 71 | # _datapoints.observations[new_attribute] = values |
||
| 72 | # |
||
| 73 | # assert 'list_to_encoded' in DataEngine.registry |
||
| 74 | # assert 'list_to_encoded' not in DataEngine.test_pd.registry |
||
| 75 |