From b8d6ce9be79a0f95694c352131bd6fc0ede954a4 Mon Sep 17 00:00:00 2001 From: kathrynoh23 <126970932+kathrynoh23@users.noreply.github.com> Date: Sat, 9 Sep 2023 12:59:54 -0400 Subject: [PATCH] Kathryn Odell-Hamilton Stopped working on section 2023.8.25 Within Unit 2, lab_scatter, I used the top-down method for planning_scatter.md, transform.py writing code to transform data with function, and build the scatter plot. I'm requesting assistance to complete several sections within transform.py and scatterplot.py files. Checkpoint 1 I believe I could write about a quarter or small segments of the code for the scatterplot.py, but would not be able to complete it without guidance from an instructor. The top-down method to break down the process of the scatterplot into small blocks was straight forward when thinking, planning, and writing it out. Honestly, I wouldn't know how to begin the scatterplot program without additional information and instruction from the instructor. It's abstract and frustrating. I don't have the background experience using Python. Checkpoint 2 From 2.1, minimum to 2.4, clamp, I understood how to and code the simple functions with transforming data. From 2.5, ratio to the end, 2.8, get_y_values, I was confused and lost. I felt the information provided was minimal, my perspective only. I could look back to the beginning information to use some of the strategies, but unable to complete these sections. I rewatched the videos and searched within Discord to see what issues if any my colleagues were faced with. There was little information online about transforming data with functions using def statements with only a return and not printing. More examples and explanation needed to be provided to better understand what was expected. Checkpoint 3 The program scatterplot.py is incomplete with the following: Find the scaled y-position for the point. Use draw_point(scaled_x, scaled_y, color, size) to draw the point. Also, it won't run correctly because transform.py file is incomplete. Sections 2.5, ratio to the end, 2.8, get_y_values I understood the scatterplot.py and how the data from the other files was imported into this program file. From Checkpoint 1, I would have still used the same format and structure. You could create programs to visualize data such at charts and diagrams. --- .DS_Store | Bin 0 -> 6148 bytes planning_scatter.md | 27 +++++++++--- poetry.lock | 97 +++++++++++++++++++++++++------------------- scatterplot.py | 16 ++++++++ transform.py | 58 ++++++++++++++++++++++---- 5 files changed, 143 insertions(+), 55 deletions(-) create mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..5008ddfcf53c02e82d7eee2e57c38e5672ef89f6 GIT binary patch literal 6148 zcmeH~Jr2S!425mzP>H1@V-^m;4Wg<&0T*E43hX&L&p$$qDprKhvt+--jT7}7np#A3 zem<@ulZcFPQ@L2!n>{z**++&mCkOWA81W14cNZlEfg7;MkzE(HCqgga^y>{tEnwC%0;vJ&^%eQ zLs35+`xjp>T0=3.5.0)", "flake8-simplify", "isort", "mypy (>=0.990)", "ruff", "sphinx-lint", "types-requests"] -test = ["cython", "filelock", "html5lib", "pytest (>=4.6)"] +test = ["cython (>=3.0)", "filelock", "html5lib", "pytest (>=4.6)", "setuptools (>=67.0)"] [[package]] name = "sphinx-basic-ng" @@ -393,45 +393,54 @@ docs = ["furo", "ipython", "myst-parser", "sphinx-copybutton", "sphinx-inline-ta [[package]] name = "sphinxcontrib-applehelp" -version = "1.0.4" +version = "1.0.7" description = "sphinxcontrib-applehelp is a Sphinx extension which outputs Apple help books" optional = false -python-versions = ">=3.8" +python-versions = ">=3.9" files = [ - {file = "sphinxcontrib-applehelp-1.0.4.tar.gz", hash = "sha256:828f867945bbe39817c210a1abfd1bc4895c8b73fcaade56d45357a348a07d7e"}, - {file = "sphinxcontrib_applehelp-1.0.4-py3-none-any.whl", hash = "sha256:29d341f67fb0f6f586b23ad80e072c8e6ad0b48417db2bde114a4c9746feb228"}, + {file = "sphinxcontrib_applehelp-1.0.7-py3-none-any.whl", hash = "sha256:094c4d56209d1734e7d252f6e0b3ccc090bd52ee56807a5d9315b19c122ab15d"}, + {file = "sphinxcontrib_applehelp-1.0.7.tar.gz", hash = "sha256:39fdc8d762d33b01a7d8f026a3b7d71563ea3b72787d5f00ad8465bd9d6dfbfa"}, ] +[package.dependencies] +Sphinx = ">=5" + [package.extras] lint = ["docutils-stubs", "flake8", "mypy"] test = ["pytest"] [[package]] name = "sphinxcontrib-devhelp" -version = "1.0.2" -description = "sphinxcontrib-devhelp is a sphinx extension which outputs Devhelp document." +version = "1.0.5" +description = "sphinxcontrib-devhelp is a sphinx extension which outputs Devhelp documents" optional = false -python-versions = ">=3.5" +python-versions = ">=3.9" files = [ - {file = "sphinxcontrib-devhelp-1.0.2.tar.gz", hash = "sha256:ff7f1afa7b9642e7060379360a67e9c41e8f3121f2ce9164266f61b9f4b338e4"}, - {file = "sphinxcontrib_devhelp-1.0.2-py2.py3-none-any.whl", hash = "sha256:8165223f9a335cc1af7ffe1ed31d2871f325254c0423bc0c4c7cd1c1e4734a2e"}, + {file = "sphinxcontrib_devhelp-1.0.5-py3-none-any.whl", hash = "sha256:fe8009aed765188f08fcaadbb3ea0d90ce8ae2d76710b7e29ea7d047177dae2f"}, + {file = "sphinxcontrib_devhelp-1.0.5.tar.gz", hash = "sha256:63b41e0d38207ca40ebbeabcf4d8e51f76c03e78cd61abe118cf4435c73d4212"}, ] +[package.dependencies] +Sphinx = ">=5" + [package.extras] lint = ["docutils-stubs", "flake8", "mypy"] test = ["pytest"] [[package]] name = "sphinxcontrib-htmlhelp" -version = "2.0.1" +version = "2.0.4" description = "sphinxcontrib-htmlhelp is a sphinx extension which renders HTML help files" optional = false -python-versions = ">=3.8" +python-versions = ">=3.9" files = [ - {file = "sphinxcontrib-htmlhelp-2.0.1.tar.gz", hash = "sha256:0cbdd302815330058422b98a113195c9249825d681e18f11e8b1f78a2f11efff"}, - {file = "sphinxcontrib_htmlhelp-2.0.1-py3-none-any.whl", hash = "sha256:c38cb46dccf316c79de6e5515e1770414b797162b23cd3d06e67020e1d2a6903"}, + {file = "sphinxcontrib_htmlhelp-2.0.4-py3-none-any.whl", hash = "sha256:8001661c077a73c29beaf4a79968d0726103c5605e27db92b9ebed8bab1359e9"}, + {file = "sphinxcontrib_htmlhelp-2.0.4.tar.gz", hash = "sha256:6c26a118a05b76000738429b724a0568dbde5b72391a688577da08f11891092a"}, ] +[package.dependencies] +Sphinx = ">=5" + [package.extras] lint = ["docutils-stubs", "flake8", "mypy"] test = ["html5lib", "pytest"] @@ -452,30 +461,36 @@ test = ["flake8", "mypy", "pytest"] [[package]] name = "sphinxcontrib-qthelp" -version = "1.0.3" -description = "sphinxcontrib-qthelp is a sphinx extension which outputs QtHelp document." +version = "1.0.6" +description = "sphinxcontrib-qthelp is a sphinx extension which outputs QtHelp documents" optional = false -python-versions = ">=3.5" +python-versions = ">=3.9" files = [ - {file = "sphinxcontrib-qthelp-1.0.3.tar.gz", hash = "sha256:4c33767ee058b70dba89a6fc5c1892c0d57a54be67ddd3e7875a18d14cba5a72"}, - {file = "sphinxcontrib_qthelp-1.0.3-py2.py3-none-any.whl", hash = "sha256:bd9fc24bcb748a8d51fd4ecaade681350aa63009a347a8c14e637895444dfab6"}, + {file = "sphinxcontrib_qthelp-1.0.6-py3-none-any.whl", hash = "sha256:bf76886ee7470b934e363da7a954ea2825650013d367728588732c7350f49ea4"}, + {file = "sphinxcontrib_qthelp-1.0.6.tar.gz", hash = "sha256:62b9d1a186ab7f5ee3356d906f648cacb7a6bdb94d201ee7adf26db55092982d"}, ] +[package.dependencies] +Sphinx = ">=5" + [package.extras] lint = ["docutils-stubs", "flake8", "mypy"] test = ["pytest"] [[package]] name = "sphinxcontrib-serializinghtml" -version = "1.1.5" -description = "sphinxcontrib-serializinghtml is a sphinx extension which outputs \"serialized\" HTML files (json and pickle)." +version = "1.1.9" +description = "sphinxcontrib-serializinghtml is a sphinx extension which outputs \"serialized\" HTML files (json and pickle)" optional = false -python-versions = ">=3.5" +python-versions = ">=3.9" files = [ - {file = "sphinxcontrib-serializinghtml-1.1.5.tar.gz", hash = "sha256:aa5f6de5dfdf809ef505c4895e51ef5c9eac17d0f287933eb49ec495280b6952"}, - {file = "sphinxcontrib_serializinghtml-1.1.5-py2.py3-none-any.whl", hash = "sha256:352a9a00ae864471d3a7ead8d7d79f5fc0b57e8b3f95e9867eb9eb28999b92fd"}, + {file = "sphinxcontrib_serializinghtml-1.1.9-py3-none-any.whl", hash = "sha256:9b36e503703ff04f20e9675771df105e58aa029cfcbc23b8ed716019b7416ae1"}, + {file = "sphinxcontrib_serializinghtml-1.1.9.tar.gz", hash = "sha256:0c64ff898339e1fac29abd2bf5f11078f3ec413cfe9c046d3120d7ca65530b54"}, ] +[package.dependencies] +Sphinx = ">=5" + [package.extras] lint = ["docutils-stubs", "flake8", "mypy"] test = ["pytest"] diff --git a/scatterplot.py b/scatterplot.py index 50f66fb..37964e9 100644 --- a/scatterplot.py +++ b/scatterplot.py @@ -35,6 +35,22 @@ def draw_scatterplot(data, size=5, color="black"): def draw_axes(data): "Draws the scatter plot's axes." + draw_x_axis() + x_values = get_x_values(data) + xmin, xmax = bounds(x_values) + ticks = get_tick_values(xmin, xmax) + for tick in ticks: + screen_x_position = scale(tick, xmin, xmax, 0, constants.PLOT_WIDTH) + draw_x_tick(screen_x_position, tick) + + draw_y_axis() + "Draws the scatter plot's axes." + y_values = get_y_values(data) + ymin, ymax = bounds(y_values) + ticks = get_tick_values(ymin, ymax) + for tick in ticks: + screen_y_position = scale(tick, ymin, ymax, 0, constants.PLOT_WIDTH) + draw_y_tick(screen_y_position, tick) def draw_points(data, color, size): "Draws the scatter plot's points." diff --git a/transform.py b/transform.py index 64819b7..5152272 100644 --- a/transform.py +++ b/transform.py @@ -6,38 +6,80 @@ def maximum(data): "Returns the largest number in data" - raise NotImplementedError + largest = None + for number in data: + if largest is None: + largest = number + if number > largest: + largest = number + return largest def minimum(data): "Returns the smallest number in data" - raise NotImplementedError + smallest = None + for number in data: + if smallest is None: + smallest = number + if number < smallest: + smallest = number + return smallest def bounds(data): "Returns a list of the smallest and largest numbers in data" - raise NotImplementedError + smallest = None + largest = None + for numbers in data: + if numbers < smallest: + smallest = numbers + elif numbers > largest: + largest = numbers + return smallest, largest def clamp(value, low, high): """Clamps a value to a range from low to 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. """ - raise NotImplementedError + if value < low: + return low + elif value > high: + return high + else: + return value def ratio(value, start, end): """Returns a number from 0.0 to 1.0, representing how far along value is from start to end. The return value is clamped to [0, 1], so even if value is lower than start, the return value will not be lower than 0.0. """ - raise NotImplementedError + + """??? Is this correct?""" + value = (value - start) / (end - start) + if value >= 0: + return 0 + elif value <= 1.0: + return 1.0 + else: + return value def scale(value, domain_min, domain_max, range_min, range_max): "Given a value within a domain, returns the scaled equivalent within range." - raise NotImplementedError + + """???? I'm unsure how to code def scale""" + value = range_min + r * (range_max - range_min) + + return value def get_x_values(points): "Returns the first value for each point in points." - raise NotImplementedError + + """???? I'm unsure how to code def get_x_values""" + points = x_values + return value def get_y_values(points): "Returns the second value for each point in points." - raise NotImplementedError + + """???? I'm unsure how to code def get_y_values""" + points = y_values + return value