mirror of
https://github.com/bertptrs/adventofcode.git
synced 2025-12-25 21:00:31 +01:00
Remove numpy dependency.
This commit is contained in:
@@ -10,7 +10,6 @@ import io
|
|||||||
import re
|
import re
|
||||||
import subprocess
|
import subprocess
|
||||||
import matplotlib.pyplot as plt
|
import matplotlib.pyplot as plt
|
||||||
import numpy as np
|
|
||||||
|
|
||||||
|
|
||||||
def get_args():
|
def get_args():
|
||||||
@@ -30,7 +29,6 @@ def cloc_usage(src_dir):
|
|||||||
data = io.StringIO(output, newline='')
|
data = io.StringIO(output, newline='')
|
||||||
|
|
||||||
reader = csv.reader(data, dialect='unix')
|
reader = csv.reader(data, dialect='unix')
|
||||||
days = []
|
|
||||||
values = []
|
values = []
|
||||||
|
|
||||||
for line in reader:
|
for line in reader:
|
||||||
@@ -40,23 +38,19 @@ def cloc_usage(src_dir):
|
|||||||
match = re.search(r"\d+", line[1])
|
match = re.search(r"\d+", line[1])
|
||||||
if match:
|
if match:
|
||||||
day = int(match.group(0))
|
day = int(match.group(0))
|
||||||
days.append(day)
|
values.append([day] + [int(x) for x in line[2:]])
|
||||||
values.append(list(int(x) for x in line[2:]))
|
|
||||||
|
|
||||||
data = list(zip(days, values))
|
values.sort()
|
||||||
data.sort()
|
values = tuple(zip(*values))
|
||||||
|
|
||||||
days, values = list(zip(*data))
|
return values[0], values[1:]
|
||||||
values = np.array(values)
|
|
||||||
|
|
||||||
return days, values
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
args = get_args()
|
args = get_args()
|
||||||
days, values = cloc_usage(args.source)
|
days, values = cloc_usage(args.source)
|
||||||
|
|
||||||
for sequence in values.transpose():
|
for sequence in values:
|
||||||
plt.plot(days, sequence)
|
plt.plot(days, sequence)
|
||||||
|
|
||||||
plt.xlabel('Day')
|
plt.xlabel('Day')
|
||||||
|
|||||||
Reference in New Issue
Block a user