Skip to content

Commit 9a1bbec

Browse files
Fix issue carpentries-incubator#394: Use class-based data loading in pure function solution
1 parent 6db44a6 commit 9a1bbec

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

_episodes/34-code-refactoring.md

+2-5
Original file line numberDiff line numberDiff line change
@@ -209,15 +209,12 @@ be harder to test but, when simplified like this, may only require a handful of
209209
>> The `analyse_data()` function now calls the `compute_standard_deviation_by_day()` function,
210210
>> while keeping all the logic for reading the data, processing it and showing it in a graph:
211211
>> ```python
212-
>> def analyse_data(data_dir):
212+
>> def analyse_data(data_source):
213213
>> """Calculates the standard deviation by day between datasets.
214214
>> Gets all the inflammation data from CSV files within a directory, works out the mean
215215
>> inflammation value for each day across all datasets, then visualises the
216216
>> standard deviation of these means on a graph."""
217-
>> data_file_paths = glob.glob(os.path.join(data_dir, 'inflammation*.csv'))
218-
>> if len(data_file_paths) == 0:
219-
>> raise ValueError(f"No inflammation csv's found in path {data_dir}")
220-
>> data = map(models.load_csv, data_file_paths)
217+
>> data = data_source.load_inflammation_data()
221218
>> daily_standard_deviation = compute_standard_deviation_by_day(data)
222219
>>
223220
>> graph_data = {

0 commit comments

Comments
 (0)