Compare commits

..

No commits in common. "f6cfe7235a27b98d7ef9a5131322e19448135116" and "d373f4693da80ca284bf1a15efd582fb3e3b66dc" have entirely different histories.

4 changed files with 26 additions and 74 deletions

View File

@ -4,28 +4,9 @@
- Draw the axes. - Draw the axes.
- Draw the x-axis. - Draw the x-axis.
- Draw the line. - Draw the line.
- Find the range of the x-values - ...
- Divide the range by 5
- Start at the origin. Label it with the lowest x-value
- repeat until at the end of the axis:
- add 1/5 of the range to the x-value
- move to the right 1/5 of the length of the axis
- draw a tick mark and label with the next x-value
- Draw the y-axis. - Draw the y-axis.
- Draw the line. - Draw the line.
- Find the range of the y-values - ...
- Divide the range by 5
- Start at the origin. Label it with the lowest y-value
- repeat until at the end of the axis:
- add 1/5 of the range to the y-value
- move up 1/5 of the length of the axis
- draw a tick mark and label with the next y-value
- Plot the points. - Plot the points.
- Repeat for each point: - ...
- Start with turtle at the "origin"
- move to the right the amount of the difference between the x-value and the lowest x- value
- move up the amount of the difference between the y-value and the lowest y-value
- plot the point
- return to the "origin"

6
poetry.lock generated
View File

@ -342,13 +342,13 @@ files = [
[[package]] [[package]]
name = "sphinx" name = "sphinx"
version = "7.1.2" version = "7.1.1"
description = "Python documentation generator" description = "Python documentation generator"
optional = false optional = false
python-versions = ">=3.8" python-versions = ">=3.8"
files = [ files = [
{file = "sphinx-7.1.2-py3-none-any.whl", hash = "sha256:d170a81825b2fcacb6dfd5a0d7f578a053e45d3f2b153fecc948c37344eb4cbe"}, {file = "sphinx-7.1.1-py3-none-any.whl", hash = "sha256:4e6c5ea477afa0fb90815210fd1312012e1d7542589ab251ac9b53b7c0751bce"},
{file = "sphinx-7.1.2.tar.gz", hash = "sha256:780f4d32f1d7d1126576e0e5ecc19dc32ab76cd24e950228dcf7b1f6d3d9e22f"}, {file = "sphinx-7.1.1.tar.gz", hash = "sha256:59b8e391f0768a96cd233e8300fe7f0a8dc2f64f83dc2a54336a9a84f428ff4e"},
] ]
[package.dependencies] [package.dependencies]

View File

@ -21,14 +21,14 @@ test(minimum, [[0, 1, 2, 3]], 0)
test(minimum, [[-10, -20, -30]], -30) test(minimum, [[-10, -20, -30]], -30)
test(bounds, [[0, 1, 2, 3]], [0, 3]) test(bounds, [[0, 1, 2, 3]], [0, 3])
test(bounds, [[-10, -20, -30]], [-30, -10]) test(bounds, [[-10, -20, -30]], [-30, -10])
test(clamp, [10, 0, 100], 10) test(clamp, [[10, 0, 100]], 10)
test(clamp, [-10, 0, 100], 0) test(clamp, [[-10, 0, 100]], 0)
test(clamp, [104, 0, 100], 100) test(clamp, [[104, 0, 100]], 100)
test(ratio, [5, 0, 10], 0.5) test(ratio, [[5, 0, 10]], 0.5)
test(ratio, [167, 100, 200], 0.67) test(ratio, [[167, 100, 200]], 0.67)
test(ratio, [8, 10, 0], 0.2) test(ratio, [[8, 10, 0]], 0.2)
test(ratio, [4, 10, 20], 0.0) test(ratio, [[4, 10, 20]], 0.0)
test(scale, [4, 0, 10, 0, 100], 40) test(scale, [[4, 0, 10, 0, 100]], 40)
test(scale, [180, 120, 240, 0, 100], 50) test(scale, [[180, 120, 240, 0, 100]], 50)
test(get_x_values, [[[0, 5], [1, 5], [2, 5]]], [0, 1, 2]) test(get_x_values, [[[0, 5], [1, 5], [2, 5]]], [0, 1, 2])
test(get_y_values, [[[0, 5], [1, 5], [2, 5]]], [5, 5, 5]) test(get_y_values, [[[0, 5], [1, 5], [2, 5]]], [5, 5, 5])

View File

@ -6,67 +6,38 @@
def maximum(data): def maximum(data):
"Returns the largest number in data" "Returns the largest number in data"
highest = None raise NotImplementedError
for number in data:
if highest is None:
highest = number
if number > highest:
highest = number
return highest
def minimum(data): def minimum(data):
"Returns the smallest number in data" "Returns the smallest number in data"
lowest = None raise NotImplementedError
for number in data:
if lowest is None:
lowest = number
if number < lowest:
lowest = number
return lowest
def bounds(data): def bounds(data):
"Returns a list of the smallest and largest numbers in data" "Returns a list of the smallest and largest numbers in data"
min = minimum(data) raise NotImplementedError
max = maximum(data)
bounds = [min, max]
return bounds
def clamp(value, low, high): def clamp(value, low, high):
"""Clamps a value to a range from low to high. """Clamps a value to a range from low to high.
Returns value if it is between low and high. Returns value if it is between low and high.
If value is lower than low, returns low. If value is higher than high, returns high. If value is lower than low, returns low. If value is higher than high, returns high.
""" """
if value < low: raise NotImplementedError
return low
elif value > high:
return high
else:
return value
def ratio(value, start, end): def ratio(value, start, end):
"""Returns a number from 0.0 to 1.0, representing how far along value is """Returns a number from 0.0 to 1.0, representing how far along value is from start to end.
from start to end.The return value is clamped to [0, 1], so even if value The return value is clamped to [0, 1], so even if value is lower than start, the return
is lower than start, the return value will not be lower than 0.0. value will not be lower than 0.0.
""" """
number = ((value - start)/(end - start)) raise NotImplementedError
number = clamp(number, 0.0, 1.0)
return number
def scale(value, domain_min, domain_max, range_min, range_max): def scale(value, domain_min, domain_max, range_min, range_max):
"Given a value within a domain, returns the scaled equivalent within range." "Given a value within a domain, returns the scaled equivalent within range."
r = ratio(value, domain_min, domain_max) raise NotImplementedError
return range_min + r*(range_max - range_min)
def get_x_values(points): def get_x_values(points):
"Returns the first value for each point in points." "Returns the first value for each point in points."
x_list = [] raise NotImplementedError
for data in points:
x_list.append(data[0])
return x_list
def get_y_values(points): def get_y_values(points):
"Returns the second value for each point in points." "Returns the second value for each point in points."
y_list = [] raise NotImplementedError
for data in points:
y_list.append(data[1])
return y_list