|
| 1 | +{ |
| 2 | + "cells": [ |
| 3 | + { |
| 4 | + "cell_type": "code", |
| 5 | + "execution_count": 1, |
| 6 | + "metadata": { |
| 7 | + "dotnet_interactive": { |
| 8 | + "language": "fsharp" |
| 9 | + }, |
| 10 | + "polyglot_notebook": { |
| 11 | + "kernelName": "fsharp" |
| 12 | + } |
| 13 | + }, |
| 14 | + "outputs": [], |
| 15 | + "source": [ |
| 16 | + "from __future__ import annotations\n", |
| 17 | + "from array import array as array_3\n", |
| 18 | + "from typing import (Any, Callable, TypeVar)\n", |
| 19 | + "from fable_modules.fable_library.array_ import (initialize, add_range_in_place, map as map_1, indexed, reverse as reverse_1, append as append_2, map_indexed, take, fill)\n", |
| 20 | + "from fable_modules.fable_library.list import (FSharpList, of_array, is_empty, iterate, append as append_1, cons, singleton as singleton_1)\n", |
| 21 | + "from fable_modules.fable_library.map import of_list\n", |
| 22 | + "from fable_modules.fable_library.map_util import (add_to_dict, get_item_from_dict)\n", |
| 23 | + "from fable_modules.fable_library.mutable_map import Dictionary\n", |
| 24 | + "from fable_modules.fable_library.option import value as value_8\n", |
| 25 | + "from fable_modules.fable_library.range import range_big_int\n", |
| 26 | + "from fable_modules.fable_library.seq import (to_list, delay, collect, singleton, append, to_array, map)\n", |
| 27 | + "from fable_modules.fable_library.string_ import (to_text, printf)\n", |
| 28 | + "from fable_modules.fable_library.system_text import (StringBuilder__ctor, StringBuilder__AppendLine_Z721C83C5)\n", |
| 29 | + "from fable_modules.fable_library.types import (Array, to_string)\n", |
| 30 | + "from fable_modules.fable_library.util import (IEnumerable_1, int32_to_string, assert_equal, equals as equals_4, safe_hash, to_enumerable, ignore, compare_arrays, equal_arrays, array_hash)\n", |
| 31 | + "from fable_modules.fable_pyxpecto.pyxpecto import Helper_expectError\n", |
| 32 | + "from fable_modules.fable_pyxpecto.pyxpecto import TestCase\n", |
| 33 | + "from src.ISA.ISA.ArcTypes.arc_table_aux import try_find_duplicate_unique_in_array\n", |
| 34 | + "from src.ISA.ISA.ArcTypes.arc_table import ArcTable\n", |
| 35 | + "from src.ISA.ISA.ArcTypes.arc_table_aux import (SanityChecks_validateColumnIndex, SanityChecks_validateRowIndex, try_find_duplicate_unique)\n", |
| 36 | + "from src.ISA.ISA.ArcTypes.composite_cell import CompositeCell\n", |
| 37 | + "from src.ISA.ISA.ArcTypes.composite_column import CompositeColumn\n", |
| 38 | + "from src.ISA.ISA.ArcTypes.composite_header import (IOType, CompositeHeader)\n", |
| 39 | + "from src.ISA.ISA.ArcTypes.identifier_setters import set_arc_table_name\n", |
| 40 | + "from src.ISA.ISA.JsonTypes.ontology_annotation import OntologyAnnotation\n", |
| 41 | + "from library import (Test_testList, Test_testCase, Expect_sequenceEqual, Expect_isTrue, Expect_notEqual, Expect_throws, Expect_isNone, Expect_isSome, Expect_containsAll, Expect_isFalse)\n", |
| 42 | + "\n", |
| 43 | + "__A = TypeVar(\"__A\")\n", |
| 44 | + "\n", |
| 45 | + "TableName: str = \"Test\"\n", |
| 46 | + "\n", |
| 47 | + "oa_species: OntologyAnnotation = OntologyAnnotation.from_string(\"species\", \"GO\", \"GO:0123456\")\n", |
| 48 | + "\n", |
| 49 | + "oa_chlamy: OntologyAnnotation = OntologyAnnotation.from_string(\"Chlamy\", \"NCBI\", \"NCBI:0123456\")\n", |
| 50 | + "\n", |
| 51 | + "oa_instrument_model: OntologyAnnotation = OntologyAnnotation.from_string(\"instrument model\", \"MS\", \"MS:0123456\")\n", |
| 52 | + "\n", |
| 53 | + "oa_sciexinstrument_model: OntologyAnnotation = OntologyAnnotation.from_string(\"SCIEX instrument model\", \"MS\", \"MS:654321\")\n", |
| 54 | + "\n", |
| 55 | + "oa_temperature: OntologyAnnotation = OntologyAnnotation.from_string(\"temperature\", \"NCIT\", \"NCIT:0123210\")\n", |
| 56 | + "\n", |
| 57 | + "def table_values_printable(table: ArcTable) -> FSharpList[str]:\n", |
| 58 | + " def _arrow1027(__unit: None=None, table: Any=table) -> IEnumerable_1[str]:\n", |
| 59 | + " def _arrow1026(match_value: Any) -> IEnumerable_1[str]:\n", |
| 60 | + " active_pattern_result: tuple[tuple[int, int], CompositeCell] = match_value\n", |
| 61 | + " return singleton((((((\"(\" + str(active_pattern_result[0][0])) + \",\") + str(active_pattern_result[0][1])) + \") \") + str(active_pattern_result[1])) + \"\")\n", |
| 62 | + "\n", |
| 63 | + " return collect(_arrow1026, table.Values)\n", |
| 64 | + "\n", |
| 65 | + " return to_list(delay(_arrow1027))\n", |
| 66 | + "\n", |
| 67 | + "\n", |
| 68 | + "def create_cells_free_text(pretext: Any, count: int) -> Array[CompositeCell]:\n", |
| 69 | + " def _arrow1030(i: int, pretext: Any=pretext, count: Any=count) -> CompositeCell:\n", |
| 70 | + " return CompositeCell.create_free_text((((\"\" + str(pretext)) + \"_\") + str(i)) + \"\")\n", |
| 71 | + "\n", |
| 72 | + " return initialize(count, _arrow1030, None)\n", |
| 73 | + "\n", |
| 74 | + "\n", |
| 75 | + "def create_cells_term(count: int) -> Array[CompositeCell]:\n", |
| 76 | + " def _arrow1032(_arg: int, count: Any=count) -> CompositeCell:\n", |
| 77 | + " return CompositeCell.create_term(oa_sciexinstrument_model)\n", |
| 78 | + "\n", |
| 79 | + " return initialize(count, _arrow1032, None)\n", |
| 80 | + "\n", |
| 81 | + "\n", |
| 82 | + "def create_cells_unitized(count: int) -> Array[CompositeCell]:\n", |
| 83 | + " def _arrow1035(i: int, count: Any=count) -> CompositeCell:\n", |
| 84 | + " return CompositeCell.create_unitized(int32_to_string(i), OntologyAnnotation.empty())\n", |
| 85 | + "\n", |
| 86 | + " return initialize(count, _arrow1035, None)\n", |
| 87 | + "\n", |
| 88 | + "\n", |
| 89 | + "column_input: CompositeColumn = CompositeColumn.create(CompositeHeader(11, IOType(0)), create_cells_free_text(\"Source\", 5))\n", |
| 90 | + "\n", |
| 91 | + "column_output: CompositeColumn = CompositeColumn.create(CompositeHeader(12, IOType(1)), create_cells_free_text(\"Sample\", 5))\n", |
| 92 | + "\n", |
| 93 | + "column_component: CompositeColumn = CompositeColumn.create(CompositeHeader(0, oa_instrument_model), create_cells_term(5))\n", |
| 94 | + "\n", |
| 95 | + "column_param: CompositeColumn = CompositeColumn.create(CompositeHeader(3, OntologyAnnotation.empty()), create_cells_unitized(5))\n", |
| 96 | + "\n", |
| 97 | + "def create_test_table(__unit: None=None) -> ArcTable:\n", |
| 98 | + " t: ArcTable = ArcTable.init(TableName)\n", |
| 99 | + " columns: Array[CompositeColumn] = [column_input, column_output, column_param, column_component, column_param]\n", |
| 100 | + " t.AddColumns(columns)\n", |
| 101 | + " return t\n" |
| 102 | + ] |
| 103 | + }, |
| 104 | + { |
| 105 | + "cell_type": "code", |
| 106 | + "execution_count": 2, |
| 107 | + "metadata": {}, |
| 108 | + "outputs": [], |
| 109 | + "source": [ |
| 110 | + "table1: ArcTable = create_test_table()" |
| 111 | + ] |
| 112 | + }, |
| 113 | + { |
| 114 | + "cell_type": "code", |
| 115 | + "execution_count": 5, |
| 116 | + "metadata": {}, |
| 117 | + "outputs": [ |
| 118 | + { |
| 119 | + "data": { |
| 120 | + "text/plain": [ |
| 121 | + "8821596988035483298" |
| 122 | + ] |
| 123 | + }, |
| 124 | + "execution_count": 5, |
| 125 | + "metadata": {}, |
| 126 | + "output_type": "execute_result" |
| 127 | + } |
| 128 | + ], |
| 129 | + "source": [ |
| 130 | + "# table1.GetHeadersHashCode()\n", |
| 131 | + "from src.ISA.ISA.helper import HashCodes_boxHashArray\n", |
| 132 | + "\n", |
| 133 | + "# HashCodes_boxHashArray(list(table1.Headers))\n", |
| 134 | + "\n", |
| 135 | + "from fable_modules.fable_library.util import (get_enumerator, dispose, equals, structural_hash, identity_hash, number_hash, IEnumerable_1, ignore, is_iterable)\n", |
| 136 | + "_A = TypeVar(\"_A\")\n", |
| 137 | + "\n", |
| 138 | + "copy_of_struct: _A = table1.Headers[0]\n", |
| 139 | + "identity_hash(copy_of_struct)\n", |
| 140 | + "\n" |
| 141 | + ] |
| 142 | + }, |
| 143 | + { |
| 144 | + "cell_type": "code", |
| 145 | + "execution_count": 23, |
| 146 | + "metadata": {}, |
| 147 | + "outputs": [ |
| 148 | + { |
| 149 | + "ename": "TypeError", |
| 150 | + "evalue": "unhashable type: 'OntologyAnnotation'", |
| 151 | + "output_type": "error", |
| 152 | + "traceback": [ |
| 153 | + "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", |
| 154 | + "\u001b[1;31mTypeError\u001b[0m Traceback (most recent call last)", |
| 155 | + "\u001b[1;32mc:\\Users\\HLWei\\source\\repos\\ARC_tools\\ARCtrl\\pytests\\arc_table_tests.ipynb Cell 4\u001b[0m line \u001b[0;36m3\n\u001b[0;32m <a href='vscode-notebook-cell:/c%3A/Users/HLWei/source/repos/ARC_tools/ARCtrl/pytests/arc_table_tests.ipynb#W6sZmlsZQ%3D%3D?line=32'>33</a>\u001b[0m identity_hash(oa)\n\u001b[0;32m <a href='vscode-notebook-cell:/c%3A/Users/HLWei/source/repos/ARC_tools/ARCtrl/pytests/arc_table_tests.ipynb#W6sZmlsZQ%3D%3D?line=34'>35</a>\u001b[0m p \u001b[39m=\u001b[39m CompositeHeader\u001b[39m.\u001b[39mparameter(oa)\n\u001b[1;32m---> <a href='vscode-notebook-cell:/c%3A/Users/HLWei/source/repos/ARC_tools/ARCtrl/pytests/arc_table_tests.ipynb#W6sZmlsZQ%3D%3D?line=35'>36</a>\u001b[0m identity_hash(p)\n", |
| 156 | + "File \u001b[1;32mc:\\Users\\HLWei\\source\\repos\\ARC_tools\\ARCtrl\\pytests\\fable_modules\\fable_library\\util.py:2642\u001b[0m, in \u001b[0;36midentity_hash\u001b[1;34m(x)\u001b[0m\n\u001b[0;32m 2639\u001b[0m \u001b[39mreturn\u001b[39;00m x\u001b[39m.\u001b[39mGetHashCode()\n\u001b[0;32m 2641\u001b[0m \u001b[39mif\u001b[39;00m is_hashable_py(x):\n\u001b[1;32m-> 2642\u001b[0m \u001b[39mreturn\u001b[39;00m \u001b[39mhash\u001b[39m(x)\n\u001b[0;32m 2644\u001b[0m \u001b[39mreturn\u001b[39;00m physical_hash(x)\n", |
| 157 | + "File \u001b[1;32mc:\\Users\\HLWei\\source\\repos\\ARC_tools\\ARCtrl\\pytests\\fable_modules\\fable_library\\types.py:85\u001b[0m, in \u001b[0;36mUnion.__hash__\u001b[1;34m(self)\u001b[0m\n\u001b[0;32m 83\u001b[0m \u001b[39mdef\u001b[39;00m \u001b[39m__hash__\u001b[39m(\u001b[39mself\u001b[39m) \u001b[39m-\u001b[39m\u001b[39m>\u001b[39m \u001b[39mint\u001b[39m:\n\u001b[0;32m 84\u001b[0m hashes \u001b[39m=\u001b[39m \u001b[39mmap\u001b[39m(\u001b[39mhash\u001b[39m, \u001b[39mself\u001b[39m\u001b[39m.\u001b[39mfields)\n\u001b[1;32m---> 85\u001b[0m \u001b[39mreturn\u001b[39;00m \u001b[39mhash\u001b[39m((\u001b[39mhash\u001b[39m(\u001b[39mself\u001b[39m\u001b[39m.\u001b[39mtag), \u001b[39m*\u001b[39mhashes))\n", |
| 158 | + "\u001b[1;31mTypeError\u001b[0m: unhashable type: 'OntologyAnnotation'" |
| 159 | + ] |
| 160 | + } |
| 161 | + ], |
| 162 | + "source": [ |
| 163 | + "from fable_modules.fable_library.array_ import (contains, fold, partition, exactly_one)\n", |
| 164 | + "\n", |
| 165 | + "a = table1.Headers\n", |
| 166 | + "\n", |
| 167 | + "# def folder(acc: int, o: _A, a: Any=a) -> int:\n", |
| 168 | + "# def _arrow67(__unit: None=None, acc: Any=acc, o: Any=o) -> int:\n", |
| 169 | + "# copy_of_struct: _A = o\n", |
| 170 | + "# return identity_hash(copy_of_struct)\n", |
| 171 | + "\n", |
| 172 | + "# return ((-1640531527 + _arrow67()) + (acc << 6)) + (acc >> 2)\n", |
| 173 | + "\n", |
| 174 | + "# failt\n", |
| 175 | + "# fold(folder, 0, a)\n", |
| 176 | + "\n", |
| 177 | + "\n", |
| 178 | + "# identity_hash(table1.Headers[0])\n", |
| 179 | + "# identity_hash(table1.Headers[1])\n", |
| 180 | + "# failt\n", |
| 181 | + "# identity_hash(table1.Headers[2])\n", |
| 182 | + "# identity_hash(table1.Headers[3])\n", |
| 183 | + "# identity_hash(table1.Headers[4])\n", |
| 184 | + "\n", |
| 185 | + "\n", |
| 186 | + "# failt\n", |
| 187 | + "# identity_hash(column_param.Header)\n", |
| 188 | + "\n", |
| 189 | + "\n", |
| 190 | + "\n", |
| 191 | + "table1.Headers[2]\n", |
| 192 | + "\n", |
| 193 | + "oa = OntologyAnnotation.empty()\n", |
| 194 | + "\n", |
| 195 | + "identity_hash(oa)\n", |
| 196 | + "\n", |
| 197 | + "# p = CompositeHeader.parameter(oa)\n", |
| 198 | + "\n", |
| 199 | + "# identity_hash(p)\n", |
| 200 | + "\n", |
| 201 | + "\n" |
| 202 | + ] |
| 203 | + } |
| 204 | + ], |
| 205 | + "metadata": { |
| 206 | + "kernelspec": { |
| 207 | + "display_name": "Python 3", |
| 208 | + "language": "python", |
| 209 | + "name": "python3" |
| 210 | + }, |
| 211 | + "language_info": { |
| 212 | + "codemirror_mode": { |
| 213 | + "name": "ipython", |
| 214 | + "version": 3 |
| 215 | + }, |
| 216 | + "file_extension": ".py", |
| 217 | + "mimetype": "text/x-python", |
| 218 | + "name": "python", |
| 219 | + "nbconvert_exporter": "python", |
| 220 | + "pygments_lexer": "ipython3", |
| 221 | + "version": "3.11.0" |
| 222 | + }, |
| 223 | + "polyglot_notebook": { |
| 224 | + "kernelInfo": { |
| 225 | + "defaultKernelName": "fsharp", |
| 226 | + "items": [ |
| 227 | + { |
| 228 | + "aliases": [], |
| 229 | + "languageName": "fsharp", |
| 230 | + "name": "fsharp" |
| 231 | + } |
| 232 | + ] |
| 233 | + } |
| 234 | + } |
| 235 | + }, |
| 236 | + "nbformat": 4, |
| 237 | + "nbformat_minor": 2 |
| 238 | +} |
0 commit comments