From 68eb7f9166aa9c6931591ca7a580f7e369b7259f Mon Sep 17 00:00:00 2001 From: "Hock, Martin" <martin.hock@fst.tu-darmstadt.de> Date: Thu, 2 Mar 2023 19:25:11 +0100 Subject: [PATCH] Remove obsolete files. Readme and requirements are also not needed --- example_item_data_dict.json | 17 ---- example_item_data_list.json | 17 ---- main_kpi.py | 13 --- test-classes.ipynb | 166 ------------------------------------ test-classes.py | 141 ------------------------------ 5 files changed, 354 deletions(-) delete mode 100644 example_item_data_dict.json delete mode 100644 example_item_data_list.json delete mode 100644 main_kpi.py delete mode 100644 test-classes.ipynb delete mode 100644 test-classes.py diff --git a/example_item_data_dict.json b/example_item_data_dict.json deleted file mode 100644 index 5cb49f7..0000000 --- a/example_item_data_dict.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "1":{ - "item_number":1, - "mass":10, - "delivery_time":1 - }, - "2":{ - "item_number":2, - "mass":20, - "delivery_time":2 - }, - "3":{ - "item_number":3, - "mass":30, - "delivery_time":3 - } -} \ No newline at end of file diff --git a/example_item_data_list.json b/example_item_data_list.json deleted file mode 100644 index e701f7d..0000000 --- a/example_item_data_list.json +++ /dev/null @@ -1,17 +0,0 @@ -[ - { - "item_number":1, - "mass":10, - "delivery_time":1 - }, - { - "item_number":2, - "mass":20, - "delivery_time":2 - }, - { - "item_number":3, - "mass":30, - "delivery_time":3 - } -] \ No newline at end of file diff --git a/main_kpi.py b/main_kpi.py deleted file mode 100644 index c4748e5..0000000 --- a/main_kpi.py +++ /dev/null @@ -1,13 +0,0 @@ -""" -FAIR Quality KPIs - -""" - - -def main(): - print("Hello ;-)") - pass - - -if __name__ == "__main__": - main() diff --git a/test-classes.ipynb b/test-classes.ipynb deleted file mode 100644 index 95e0adf..0000000 --- a/test-classes.ipynb +++ /dev/null @@ -1,166 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [], - "source": [ - "# import functions.lego_classes as lego_classes\n", - "from functions.classes import LegoItem\n", - "from functions.classes import LegoComponent" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "[<functions.lego_classes.LegoComponent object at 0x000002720F4BF7F0>, <functions.lego_classes.LegoComponent object at 0x000002720F4BF790>]\n" - ] - } - ], - "source": [ - "# Test manually creating some item and components\n", - "\n", - "item1 = LegoItem(1,0.10,10)\n", - "item2 = LegoItem(3,0.30,30)\n", - "item3 = LegoItem(2, 0.2,20)\n", - "\n", - "\n", - "\n", - "component1 = LegoComponent()\n", - "# component1.add_item(item1)\n", - "component2 = LegoComponent(item2) \n", - "\n", - "componentall = LegoComponent([component1,component2]) # This will be saved as items for some reasaon\n", - "# component3 = LegoComponent(item3,component1)\n", - "# component3.add(item2) # Can't really use an item twice\n", - "# component3.add(component2)\n", - "print(componentall.items)" - ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": {}, - "outputs": [], - "source": [] - }, - { - "cell_type": "code", - "execution_count": 9, - "metadata": {}, - "outputs": [], - "source": [ - "## Let's test the json stuff\n", - "import json\n", - "# import tkinter as tk\n" - ] - }, - { - "cell_type": "code", - "execution_count": 10, - "metadata": {}, - "outputs": [], - "source": [ - "# First level list handling\n", - "\n", - "def read_json(file_path):\n", - " with open(file_path, 'r') as f:\n", - " data = json.load(f)\n", - " return data\n", - "json_list_data = read_json('example_item_data_list.json')\n", - "# that produces a list, we'd prefer a dict\n", - "\n", - "# Clever way to just create an item for each listed element\n", - "def create_all_items(data):\n", - " items = []\n", - " for item_data in data:\n", - " item_number = item_data.get('item_number')\n", - " mass = item_data.get('mass')\n", - " delivery_time = item_data.get('delivery_time')\n", - " # specific_data = item_data.get('specific_data', {})\n", - " item = LegoItem(item_number, mass, delivery_time)\n", - " items.append(item)\n", - " return items\n", - "\n", - "all_items = create_all_items(json_list_data) \n", - "\n", - "# How to get entries for a specific item\n", - "def get_item_by_number(data, item_number):\n", - " datasheet = [item for item in data if item['item_number' ] == item_number] \n", - " return datasheet\n", - "\n", - "sheet1 = get_item_by_number(json_list_data, 2) # this is a list? meh\n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": 14, - "metadata": {}, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "<class 'dict'>\n", - "{'item_number': 1, 'mass': 10, 'delivery_time': 1}\n" - ] - } - ], - "source": [ - "# vs first level dict handling\n", - "\n", - "with open('example_item_data_dict.json') as json_file:\n", - " json_dict = json.load(json_file)\n", - " print(type(json_dict))\n", - " print(json_dict[\"1\"])\n", - "\n", - "sheet2_from_dict = json_dict[\"2\"]\n", - "# Create an item for this:\n", - "def create_item_from_sheet(dict):\n", - " item_number = dict[\"item_number\"]\n", - " mass = dict[\"mass\"]\n", - " delivery_time =[\"delivery_time\"]\n", - " item = LegoItem(item_number, mass, delivery_time)\n", - " return item\n", - "\n", - "itemfromdict = create_item_from_sheet(sheet2_from_dict)\n", - "\n" - ] - } - ], - "metadata": { - "kernelspec": { - "display_name": "Python 3", - "language": "python", - "name": "python3" - }, - "language_info": { - "codemirror_mode": { - "name": "ipython", - "version": 3 - }, - "file_extension": ".py", - "mimetype": "text/x-python", - "name": "python", - "nbconvert_exporter": "python", - "pygments_lexer": "ipython3", - "version": "3.10.7" - }, - "orig_nbformat": 4, - "vscode": { - "interpreter": { - "hash": "369f2c481f4da34e4445cda3fffd2e751bd1c4d706f27375911949ba6bb62e1c" - } - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/test-classes.py b/test-classes.py deleted file mode 100644 index e1009fd..0000000 --- a/test-classes.py +++ /dev/null @@ -1,141 +0,0 @@ -# import standard libraries -import json -import pprint - -# import classes from the classes module in functions package -from functions.classes import LegoComponent -from functions.classes import LegoAssembly -from functions.classes import ComponentCategory -from functions.classes import AggregationLayer -from functions.classes import KPIEncoder -from functions.classes import print_assembly_tree - -from functions.calculation_rules import kpi_sum -# Test manually creating some assemblies and components - -battery = LegoComponent("nice battery", ComponentCategory.BATTERY, "bat42", 1, 2, 3) -motor = LegoComponent("motor goes brrr", ComponentCategory.MOTOR, "motor", 1, 2, 3) -wheel = LegoComponent("much round wheel", ComponentCategory.WHEEL, "round", 1, 2, 3) - - -# Create subassemblies and combine to assembly (currently no parts present for this) -chassis = LegoAssembly("Chassis", AggregationLayer.ASSEMBLY) -door1 = LegoAssembly("Door 1", AggregationLayer.SUBASSEMBLY) -door2 = LegoAssembly("Door 2", AggregationLayer.SUBASSEMBLY) -chassis.add_assembly(door1) -chassis.add_assembly(door2) -chassis.properties - -engine = LegoAssembly("Engine", AggregationLayer.ASSEMBLY) -# Showcase cloning - one motor for each axis? -engine.add_component(motor.clone()) - - -fuel_tank = LegoAssembly("Fuel Tank", AggregationLayer.ASSEMBLY) -fuel_tank.add_component(battery.clone()) - - -wheels = LegoAssembly("Wheels", AggregationLayer.ASSEMBLY) -for _ in range(4): - wheels.add_component(wheel.clone()) - - -# Create and assemble the system level car -car = LegoAssembly("Car", AggregationLayer.SYSTEM) -car.add_assembly(chassis) -car.add_assembly(engine) -car.add_assembly(fuel_tank) -car.add_assembly(wheels) - - -## Printing - -print_assembly_tree(car) - -# Dump to json file -with open("car.json", "w") as fp: - json.dump(car.to_dict(), fp, cls=KPIEncoder) - -pprint.pprint(car.to_dict()) -pass - - -## Create components from datasheet -# Need to run the script from datasheets folder first -# Test loading dicts from datasheet jsons - -with open('datasheets/Achsen.json') as json_file: - Achsen = json.load(json_file) - -print((Achsen["Achse 5 studs"])) - -# This is hard to read, prettier please! - -pprint.pprint(Achsen) - -# Okay I'll use the 5 stud one -Achse5 = Achsen["Achse 5 studs"] # I'd prefer to call it via "Designnummer" -print(Achsen["Achse 5 studs"]["Designnummer"]) - -with open('datasheets/Räder.json') as json_file: - Raeder = json.load(json_file) -# Get me the expensive one -Radpreis = [] -for key in Raeder: # a list would work easier here than a dict - Radpreis.append(Raeder[key]["Preis [Euro]"]) -Radpreis = max(Radpreis) -for key in Raeder: - if Raeder[key]["Preis [Euro]"] == Radpreis: - TeuresRad=Raeder[key] - -# Also need a frame -with open('datasheets/Gestell.json') as json_file: - Gestelle = json.load(json_file) -Gestellbeschreibung = "Technic, Brick 1 x 8 with Holes" -Gestell = Gestelle[Gestellbeschreibung] - -# Create Components from these items -# LegoComponent(name: str, category: ComponentCategory, lego_id: str, cost: float, -# mass: float, delivery_time: int, layer: AggregationLayer = AggregationLayer.COMPONENT, **properties) -scooterframe = LegoComponent("running board", ComponentCategory.FRAME, - Gestell["Designnummer"], - Gestell["Preis [Euro]"], Gestell["Gewicht [g]"], - 0) - -scooterwheel = LegoComponent("Vorderrad", ComponentCategory.WHEEL, - TeuresRad["Designnummer"], - TeuresRad["Preis [Euro]"], TeuresRad["Gewicht [g]"], - 0) - -# TODO component with copy of dict from json -# Cloning is necessary because each lego object gets a unique id so you can't use the same part twice -scooterwheel2 = scooterwheel.clone() -scooterwheel2.description = "Hinterrad" -print([scooterwheel.uuid, scooterwheel2.uuid]) - - -# Lets Assembly, first the Assembly object, directly add the frame? -scooter = LegoAssembly("my first scooter", AggregationLayer.SYSTEM) -scooter.add_component(scooterframe) # only one per call for now -scooter.add_component(scooterwheel) -scooter.add_component(scooterwheel2) -# <Assembly>.add_assembly() works in the same way - -# Look at our work: -print(scooter) -print(scooter.children()) - -## First KPI mass should be a sum -listofmasses= [] -for c in scooter.components: - listofmasses.append(c.mass) -for a in scooter.assemblies: - # only checking one layer deep here - listofmasses.append(a.mass) - -# TODO example with get_component_list - -print(listofmasses) -print(kpi_sum(listofmasses)) - -print("theend") \ No newline at end of file -- GitLab