Skip to content

Commit

Permalink
Fix issue with single segment trend lines
Browse files Browse the repository at this point in the history
  • Loading branch information
philip-lee-ons committed Apr 8, 2020
1 parent 775e85b commit 8467b98
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion mobius/csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def categorise_paths(paths, name, date_lookup):
single_segment_lines.sort(key=lambda p: p.length())

short_trends = single_segment_lines[:-5]
single_segment_lines = single_segment_lines[:5]
single_segment_lines = single_segment_lines[-5:]

y_lines = sorted([path.start.imag for path in single_segment_lines])

Expand Down
Empty file added tests/__init__.py
Empty file.
23 changes: 23 additions & 0 deletions tests/test_csv.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# -*- coding: utf-8 -*-
from svgpathtools.path import Path, Line

import mobius


def test_single_segment_lines():
# Given
paths = [
(Path(Line(start=(24058.2+8686.78j), end=(24534.52+8686.78j))), None), # horizontal line - bottom
(Path(Line(start=(24058.2+8627.24j), end=(24534.52+8627.24j))), None), # horizontal line
(Path(Line(start=(24058.2+8567.7j), end=(24534.52+8567.7j))), None), # horizontal line - baseline
(Path(Line(start=(24058.2+8508.16j), end=(24534.52+8508.16j))), None), # horizontal line
(Path(Line(start=(24058.2+8448.62j), end=(24534.52+8448.62j))), None), # horizontal line - top
(Path(Line(start=(24523.2+8664.45j), end=(24534.54+8663.114000000001j))), None)] # Trend line

date_lookup = mobius.io.read_dates_lookup(filepath="../config/dates_lookup.csv")

# When
df = mobius.csv.csv_process(paths, 1, date_lookup, output_folder=None, plots=False, save=None)

# Then
assert round(df.at[42, "value"]) == -64

0 comments on commit 8467b98

Please sign in to comment.