From 19d850ed5e1474a5e82cd98537db3f398fbacc18 Mon Sep 17 00:00:00 2001 From: HLWeil Date: Thu, 7 Mar 2024 15:13:28 +0100 Subject: [PATCH] several small cleanups according to PR #317 comments --- README.md | 2 +- build/ProjectInfo.fs | 3 +- pytests/arc_table_tests.ipynb | 238 -------------------------- pytests/composite_header_tests.ipynb | 238 -------------------------- src/ARCtrl/ARCtrl.fsproj | 3 + src/ISA/ISA.Json/ArcTypes/ArcTable.fs | 2 +- src/ISA/ISA/ArcTypes/ArcTable.fs | 6 +- src/ISA/ISA/Fable.fs | 33 +--- testpy.cmd | 2 - 9 files changed, 11 insertions(+), 516 deletions(-) delete mode 100644 pytests/arc_table_tests.ipynb delete mode 100644 pytests/composite_header_tests.ipynb delete mode 100644 testpy.cmd diff --git a/README.md b/README.md index fa9a85c1..37adbe4d 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ Currently we provide some documentation in form of markdown files in the `/docs` - [.NET SDK](https://dotnet.microsoft.com/en-us/download) - verify with `dotnet --version` (Tested with 7.0.306) - [Python](https://www.python.org/downloads/) - - verify with `py --version` (Tested with 3.12.2) + - verify with `py --version` (Tested with 3.12.2, known to work only for >=3.11) ### Local Setup diff --git a/build/ProjectInfo.fs b/build/ProjectInfo.fs index 9ee30ed3..86eeca28 100644 --- a/build/ProjectInfo.fs +++ b/build/ProjectInfo.fs @@ -30,7 +30,8 @@ let gitHome = $"https://github.com/{gitOwner}" let projectRepo = $"https://github.com/{gitOwner}/{project}" -let netPkgDir = "dist/pkg" + +let netPkgDir = "./dist/net" let npmPkgDir = "./dist/js" let pyPkgDir = "./dist/py" diff --git a/pytests/arc_table_tests.ipynb b/pytests/arc_table_tests.ipynb deleted file mode 100644 index 19762e5e..00000000 --- a/pytests/arc_table_tests.ipynb +++ /dev/null @@ -1,238 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": 1, - "metadata": { - "dotnet_interactive": { - "language": "fsharp" - }, - "polyglot_notebook": { - "kernelName": "fsharp" - } - }, - "outputs": [], - "source": [ - "from __future__ import annotations\n", - "from array import array as array_3\n", - "from typing import (Any, Callable, TypeVar)\n", - "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", - "from fable_modules.fable_library.list import (FSharpList, of_array, is_empty, iterate, append as append_1, cons, singleton as singleton_1)\n", - "from fable_modules.fable_library.map import of_list\n", - "from fable_modules.fable_library.map_util import (add_to_dict, get_item_from_dict)\n", - "from fable_modules.fable_library.mutable_map import Dictionary\n", - "from fable_modules.fable_library.option import value as value_8\n", - "from fable_modules.fable_library.range import range_big_int\n", - "from fable_modules.fable_library.seq import (to_list, delay, collect, singleton, append, to_array, map)\n", - "from fable_modules.fable_library.string_ import (to_text, printf)\n", - "from fable_modules.fable_library.system_text import (StringBuilder__ctor, StringBuilder__AppendLine_Z721C83C5)\n", - "from fable_modules.fable_library.types import (Array, to_string)\n", - "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", - "from fable_modules.fable_pyxpecto.pyxpecto import Helper_expectError\n", - "from fable_modules.fable_pyxpecto.pyxpecto import TestCase\n", - "from src.ISA.ISA.ArcTypes.arc_table_aux import try_find_duplicate_unique_in_array\n", - "from src.ISA.ISA.ArcTypes.arc_table import ArcTable\n", - "from src.ISA.ISA.ArcTypes.arc_table_aux import (SanityChecks_validateColumnIndex, SanityChecks_validateRowIndex, try_find_duplicate_unique)\n", - "from src.ISA.ISA.ArcTypes.composite_cell import CompositeCell\n", - "from src.ISA.ISA.ArcTypes.composite_column import CompositeColumn\n", - "from src.ISA.ISA.ArcTypes.composite_header import (IOType, CompositeHeader)\n", - "from src.ISA.ISA.ArcTypes.identifier_setters import set_arc_table_name\n", - "from src.ISA.ISA.JsonTypes.ontology_annotation import OntologyAnnotation\n", - "from library import (Test_testList, Test_testCase, Expect_sequenceEqual, Expect_isTrue, Expect_notEqual, Expect_throws, Expect_isNone, Expect_isSome, Expect_containsAll, Expect_isFalse)\n", - "\n", - "__A = TypeVar(\"__A\")\n", - "\n", - "TableName: str = \"Test\"\n", - "\n", - "oa_species: OntologyAnnotation = OntologyAnnotation.from_string(\"species\", \"GO\", \"GO:0123456\")\n", - "\n", - "oa_chlamy: OntologyAnnotation = OntologyAnnotation.from_string(\"Chlamy\", \"NCBI\", \"NCBI:0123456\")\n", - "\n", - "oa_instrument_model: OntologyAnnotation = OntologyAnnotation.from_string(\"instrument model\", \"MS\", \"MS:0123456\")\n", - "\n", - "oa_sciexinstrument_model: OntologyAnnotation = OntologyAnnotation.from_string(\"SCIEX instrument model\", \"MS\", \"MS:654321\")\n", - "\n", - "oa_temperature: OntologyAnnotation = OntologyAnnotation.from_string(\"temperature\", \"NCIT\", \"NCIT:0123210\")\n", - "\n", - "def table_values_printable(table: ArcTable) -> FSharpList[str]:\n", - " def _arrow1027(__unit: None=None, table: Any=table) -> IEnumerable_1[str]:\n", - " def _arrow1026(match_value: Any) -> IEnumerable_1[str]:\n", - " active_pattern_result: tuple[tuple[int, int], CompositeCell] = match_value\n", - " return singleton((((((\"(\" + str(active_pattern_result[0][0])) + \",\") + str(active_pattern_result[0][1])) + \") \") + str(active_pattern_result[1])) + \"\")\n", - "\n", - " return collect(_arrow1026, table.Values)\n", - "\n", - " return to_list(delay(_arrow1027))\n", - "\n", - "\n", - "def create_cells_free_text(pretext: Any, count: int) -> Array[CompositeCell]:\n", - " def _arrow1030(i: int, pretext: Any=pretext, count: Any=count) -> CompositeCell:\n", - " return CompositeCell.create_free_text((((\"\" + str(pretext)) + \"_\") + str(i)) + \"\")\n", - "\n", - " return initialize(count, _arrow1030, None)\n", - "\n", - "\n", - "def create_cells_term(count: int) -> Array[CompositeCell]:\n", - " def _arrow1032(_arg: int, count: Any=count) -> CompositeCell:\n", - " return CompositeCell.create_term(oa_sciexinstrument_model)\n", - "\n", - " return initialize(count, _arrow1032, None)\n", - "\n", - "\n", - "def create_cells_unitized(count: int) -> Array[CompositeCell]:\n", - " def _arrow1035(i: int, count: Any=count) -> CompositeCell:\n", - " return CompositeCell.create_unitized(int32_to_string(i), OntologyAnnotation.empty())\n", - "\n", - " return initialize(count, _arrow1035, None)\n", - "\n", - "\n", - "column_input: CompositeColumn = CompositeColumn.create(CompositeHeader(11, IOType(0)), create_cells_free_text(\"Source\", 5))\n", - "\n", - "column_output: CompositeColumn = CompositeColumn.create(CompositeHeader(12, IOType(1)), create_cells_free_text(\"Sample\", 5))\n", - "\n", - "column_component: CompositeColumn = CompositeColumn.create(CompositeHeader(0, oa_instrument_model), create_cells_term(5))\n", - "\n", - "column_param: CompositeColumn = CompositeColumn.create(CompositeHeader(3, OntologyAnnotation.empty()), create_cells_unitized(5))\n", - "\n", - "def create_test_table(__unit: None=None) -> ArcTable:\n", - " t: ArcTable = ArcTable.init(TableName)\n", - " columns: Array[CompositeColumn] = [column_input, column_output, column_param, column_component, column_param]\n", - " t.AddColumns(columns)\n", - " return t\n" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [], - "source": [ - "table1: ArcTable = create_test_table()" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "8821596988035483298" - ] - }, - "execution_count": 5, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "# table1.GetHeadersHashCode()\n", - "from src.ISA.ISA.helper import HashCodes_boxHashArray\n", - "\n", - "# HashCodes_boxHashArray(list(table1.Headers))\n", - "\n", - "from fable_modules.fable_library.util import (get_enumerator, dispose, equals, structural_hash, identity_hash, number_hash, IEnumerable_1, ignore, is_iterable)\n", - "_A = TypeVar(\"_A\")\n", - "\n", - "copy_of_struct: _A = table1.Headers[0]\n", - "identity_hash(copy_of_struct)\n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": 23, - "metadata": {}, - "outputs": [ - { - "ename": "TypeError", - "evalue": "unhashable type: 'OntologyAnnotation'", - "output_type": "error", - "traceback": [ - "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[1;31mTypeError\u001b[0m Traceback (most recent call last)", - "\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 33\u001b[0m identity_hash(oa)\n\u001b[0;32m 35\u001b[0m p \u001b[39m=\u001b[39m CompositeHeader\u001b[39m.\u001b[39mparameter(oa)\n\u001b[1;32m---> 36\u001b[0m identity_hash(p)\n", - "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", - "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", - "\u001b[1;31mTypeError\u001b[0m: unhashable type: 'OntologyAnnotation'" - ] - } - ], - "source": [ - "from fable_modules.fable_library.array_ import (contains, fold, partition, exactly_one)\n", - "\n", - "a = table1.Headers\n", - "\n", - "# def folder(acc: int, o: _A, a: Any=a) -> int:\n", - "# def _arrow67(__unit: None=None, acc: Any=acc, o: Any=o) -> int:\n", - "# copy_of_struct: _A = o\n", - "# return identity_hash(copy_of_struct)\n", - "\n", - "# return ((-1640531527 + _arrow67()) + (acc << 6)) + (acc >> 2)\n", - "\n", - "# failt\n", - "# fold(folder, 0, a)\n", - "\n", - "\n", - "# identity_hash(table1.Headers[0])\n", - "# identity_hash(table1.Headers[1])\n", - "# failt\n", - "# identity_hash(table1.Headers[2])\n", - "# identity_hash(table1.Headers[3])\n", - "# identity_hash(table1.Headers[4])\n", - "\n", - "\n", - "# failt\n", - "# identity_hash(column_param.Header)\n", - "\n", - "\n", - "\n", - "table1.Headers[2]\n", - "\n", - "oa = OntologyAnnotation.empty()\n", - "\n", - "identity_hash(oa)\n", - "\n", - "# p = CompositeHeader.parameter(oa)\n", - "\n", - "# identity_hash(p)\n", - "\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.11.0" - }, - "polyglot_notebook": { - "kernelInfo": { - "defaultKernelName": "fsharp", - "items": [ - { - "aliases": [], - "languageName": "fsharp", - "name": "fsharp" - } - ] - } - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/pytests/composite_header_tests.ipynb b/pytests/composite_header_tests.ipynb deleted file mode 100644 index 19762e5e..00000000 --- a/pytests/composite_header_tests.ipynb +++ /dev/null @@ -1,238 +0,0 @@ -{ - "cells": [ - { - "cell_type": "code", - "execution_count": 1, - "metadata": { - "dotnet_interactive": { - "language": "fsharp" - }, - "polyglot_notebook": { - "kernelName": "fsharp" - } - }, - "outputs": [], - "source": [ - "from __future__ import annotations\n", - "from array import array as array_3\n", - "from typing import (Any, Callable, TypeVar)\n", - "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", - "from fable_modules.fable_library.list import (FSharpList, of_array, is_empty, iterate, append as append_1, cons, singleton as singleton_1)\n", - "from fable_modules.fable_library.map import of_list\n", - "from fable_modules.fable_library.map_util import (add_to_dict, get_item_from_dict)\n", - "from fable_modules.fable_library.mutable_map import Dictionary\n", - "from fable_modules.fable_library.option import value as value_8\n", - "from fable_modules.fable_library.range import range_big_int\n", - "from fable_modules.fable_library.seq import (to_list, delay, collect, singleton, append, to_array, map)\n", - "from fable_modules.fable_library.string_ import (to_text, printf)\n", - "from fable_modules.fable_library.system_text import (StringBuilder__ctor, StringBuilder__AppendLine_Z721C83C5)\n", - "from fable_modules.fable_library.types import (Array, to_string)\n", - "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", - "from fable_modules.fable_pyxpecto.pyxpecto import Helper_expectError\n", - "from fable_modules.fable_pyxpecto.pyxpecto import TestCase\n", - "from src.ISA.ISA.ArcTypes.arc_table_aux import try_find_duplicate_unique_in_array\n", - "from src.ISA.ISA.ArcTypes.arc_table import ArcTable\n", - "from src.ISA.ISA.ArcTypes.arc_table_aux import (SanityChecks_validateColumnIndex, SanityChecks_validateRowIndex, try_find_duplicate_unique)\n", - "from src.ISA.ISA.ArcTypes.composite_cell import CompositeCell\n", - "from src.ISA.ISA.ArcTypes.composite_column import CompositeColumn\n", - "from src.ISA.ISA.ArcTypes.composite_header import (IOType, CompositeHeader)\n", - "from src.ISA.ISA.ArcTypes.identifier_setters import set_arc_table_name\n", - "from src.ISA.ISA.JsonTypes.ontology_annotation import OntologyAnnotation\n", - "from library import (Test_testList, Test_testCase, Expect_sequenceEqual, Expect_isTrue, Expect_notEqual, Expect_throws, Expect_isNone, Expect_isSome, Expect_containsAll, Expect_isFalse)\n", - "\n", - "__A = TypeVar(\"__A\")\n", - "\n", - "TableName: str = \"Test\"\n", - "\n", - "oa_species: OntologyAnnotation = OntologyAnnotation.from_string(\"species\", \"GO\", \"GO:0123456\")\n", - "\n", - "oa_chlamy: OntologyAnnotation = OntologyAnnotation.from_string(\"Chlamy\", \"NCBI\", \"NCBI:0123456\")\n", - "\n", - "oa_instrument_model: OntologyAnnotation = OntologyAnnotation.from_string(\"instrument model\", \"MS\", \"MS:0123456\")\n", - "\n", - "oa_sciexinstrument_model: OntologyAnnotation = OntologyAnnotation.from_string(\"SCIEX instrument model\", \"MS\", \"MS:654321\")\n", - "\n", - "oa_temperature: OntologyAnnotation = OntologyAnnotation.from_string(\"temperature\", \"NCIT\", \"NCIT:0123210\")\n", - "\n", - "def table_values_printable(table: ArcTable) -> FSharpList[str]:\n", - " def _arrow1027(__unit: None=None, table: Any=table) -> IEnumerable_1[str]:\n", - " def _arrow1026(match_value: Any) -> IEnumerable_1[str]:\n", - " active_pattern_result: tuple[tuple[int, int], CompositeCell] = match_value\n", - " return singleton((((((\"(\" + str(active_pattern_result[0][0])) + \",\") + str(active_pattern_result[0][1])) + \") \") + str(active_pattern_result[1])) + \"\")\n", - "\n", - " return collect(_arrow1026, table.Values)\n", - "\n", - " return to_list(delay(_arrow1027))\n", - "\n", - "\n", - "def create_cells_free_text(pretext: Any, count: int) -> Array[CompositeCell]:\n", - " def _arrow1030(i: int, pretext: Any=pretext, count: Any=count) -> CompositeCell:\n", - " return CompositeCell.create_free_text((((\"\" + str(pretext)) + \"_\") + str(i)) + \"\")\n", - "\n", - " return initialize(count, _arrow1030, None)\n", - "\n", - "\n", - "def create_cells_term(count: int) -> Array[CompositeCell]:\n", - " def _arrow1032(_arg: int, count: Any=count) -> CompositeCell:\n", - " return CompositeCell.create_term(oa_sciexinstrument_model)\n", - "\n", - " return initialize(count, _arrow1032, None)\n", - "\n", - "\n", - "def create_cells_unitized(count: int) -> Array[CompositeCell]:\n", - " def _arrow1035(i: int, count: Any=count) -> CompositeCell:\n", - " return CompositeCell.create_unitized(int32_to_string(i), OntologyAnnotation.empty())\n", - "\n", - " return initialize(count, _arrow1035, None)\n", - "\n", - "\n", - "column_input: CompositeColumn = CompositeColumn.create(CompositeHeader(11, IOType(0)), create_cells_free_text(\"Source\", 5))\n", - "\n", - "column_output: CompositeColumn = CompositeColumn.create(CompositeHeader(12, IOType(1)), create_cells_free_text(\"Sample\", 5))\n", - "\n", - "column_component: CompositeColumn = CompositeColumn.create(CompositeHeader(0, oa_instrument_model), create_cells_term(5))\n", - "\n", - "column_param: CompositeColumn = CompositeColumn.create(CompositeHeader(3, OntologyAnnotation.empty()), create_cells_unitized(5))\n", - "\n", - "def create_test_table(__unit: None=None) -> ArcTable:\n", - " t: ArcTable = ArcTable.init(TableName)\n", - " columns: Array[CompositeColumn] = [column_input, column_output, column_param, column_component, column_param]\n", - " t.AddColumns(columns)\n", - " return t\n" - ] - }, - { - "cell_type": "code", - "execution_count": 2, - "metadata": {}, - "outputs": [], - "source": [ - "table1: ArcTable = create_test_table()" - ] - }, - { - "cell_type": "code", - "execution_count": 5, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "8821596988035483298" - ] - }, - "execution_count": 5, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "# table1.GetHeadersHashCode()\n", - "from src.ISA.ISA.helper import HashCodes_boxHashArray\n", - "\n", - "# HashCodes_boxHashArray(list(table1.Headers))\n", - "\n", - "from fable_modules.fable_library.util import (get_enumerator, dispose, equals, structural_hash, identity_hash, number_hash, IEnumerable_1, ignore, is_iterable)\n", - "_A = TypeVar(\"_A\")\n", - "\n", - "copy_of_struct: _A = table1.Headers[0]\n", - "identity_hash(copy_of_struct)\n", - "\n" - ] - }, - { - "cell_type": "code", - "execution_count": 23, - "metadata": {}, - "outputs": [ - { - "ename": "TypeError", - "evalue": "unhashable type: 'OntologyAnnotation'", - "output_type": "error", - "traceback": [ - "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m", - "\u001b[1;31mTypeError\u001b[0m Traceback (most recent call last)", - "\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 33\u001b[0m identity_hash(oa)\n\u001b[0;32m 35\u001b[0m p \u001b[39m=\u001b[39m CompositeHeader\u001b[39m.\u001b[39mparameter(oa)\n\u001b[1;32m---> 36\u001b[0m identity_hash(p)\n", - "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", - "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", - "\u001b[1;31mTypeError\u001b[0m: unhashable type: 'OntologyAnnotation'" - ] - } - ], - "source": [ - "from fable_modules.fable_library.array_ import (contains, fold, partition, exactly_one)\n", - "\n", - "a = table1.Headers\n", - "\n", - "# def folder(acc: int, o: _A, a: Any=a) -> int:\n", - "# def _arrow67(__unit: None=None, acc: Any=acc, o: Any=o) -> int:\n", - "# copy_of_struct: _A = o\n", - "# return identity_hash(copy_of_struct)\n", - "\n", - "# return ((-1640531527 + _arrow67()) + (acc << 6)) + (acc >> 2)\n", - "\n", - "# failt\n", - "# fold(folder, 0, a)\n", - "\n", - "\n", - "# identity_hash(table1.Headers[0])\n", - "# identity_hash(table1.Headers[1])\n", - "# failt\n", - "# identity_hash(table1.Headers[2])\n", - "# identity_hash(table1.Headers[3])\n", - "# identity_hash(table1.Headers[4])\n", - "\n", - "\n", - "# failt\n", - "# identity_hash(column_param.Header)\n", - "\n", - "\n", - "\n", - "table1.Headers[2]\n", - "\n", - "oa = OntologyAnnotation.empty()\n", - "\n", - "identity_hash(oa)\n", - "\n", - "# p = CompositeHeader.parameter(oa)\n", - "\n", - "# identity_hash(p)\n", - "\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.11.0" - }, - "polyglot_notebook": { - "kernelInfo": { - "defaultKernelName": "fsharp", - "items": [ - { - "aliases": [], - "languageName": "fsharp", - "name": "fsharp" - } - ] - } - } - }, - "nbformat": 4, - "nbformat_minor": 2 -} diff --git a/src/ARCtrl/ARCtrl.fsproj b/src/ARCtrl/ARCtrl.fsproj index 79de8a7e..ab3699c3 100644 --- a/src/ARCtrl/ARCtrl.fsproj +++ b/src/ARCtrl/ARCtrl.fsproj @@ -51,6 +51,9 @@ + + + diff --git a/src/ISA/ISA.Json/ArcTypes/ArcTable.fs b/src/ISA/ISA.Json/ArcTypes/ArcTable.fs index 44bd86c9..9de244c6 100644 --- a/src/ISA/ISA.Json/ArcTypes/ArcTable.fs +++ b/src/ISA/ISA.Json/ArcTypes/ArcTable.fs @@ -160,7 +160,7 @@ module ArcTableExtensions = member this.ToCompressedJsonString(?spaces) : string = let spaces = defaultArg spaces 0 - let stringTable = Dictionary() + let stringTable = Dictionary() let oaTable = Dictionary() let cellTable = Dictionary() let arcTable = ArcTable.compressedEncoder stringTable oaTable cellTable this diff --git a/src/ISA/ISA/ArcTypes/ArcTable.fs b/src/ISA/ISA/ArcTypes/ArcTable.fs index afe35ddb..0c43d20c 100644 --- a/src/ISA/ISA/ArcTypes/ArcTable.fs +++ b/src/ISA/ISA/ArcTypes/ArcTable.fs @@ -271,7 +271,7 @@ type ArcTable(name: string, headers: ResizeArray, values: Syste // Sanity check here too, to avoid removing things from mutable to fail in the middle Array.iter (fun index -> SanityChecks.validateColumnIndex index this.ColumnCount false) indexArr /// go from highest to lowest so no wrong column gets removed after index shift - let indexArr = indexArr |> ARCtrl.ISA.Fable.Array.sortDescending + let indexArr = indexArr |> Array.sortDescending Array.iter (fun index -> this.RemoveColumn index) indexArr static member removeColumns(indexArr:int []) = @@ -476,7 +476,7 @@ type ArcTable(name: string, headers: ResizeArray, values: Syste // Sanity check here too, to avoid removing things from mutable to fail in the middle Array.iter (fun index -> ArcTableAux.SanityChecks.validateRowIndex index this.RowCount false) indexArr /// go from highest to lowest so no wrong column gets removed after index shift - let indexArr = indexArr |> ARCtrl.ISA.Fable.Array.sortDescending + let indexArr = indexArr |> Array.sortDescending Array.iter (fun index -> this.RemoveRow index) indexArr static member removeRows (indexArr:int []) = @@ -757,7 +757,7 @@ type ArcTable(name: string, headers: ResizeArray, values: Syste |> String.concat "\n" member this.StructurallyEquals (other: ArcTable) = - let sort = Array.ofSeq >> ARCtrl.ISA.Fable.Array.sortBy (function |KeyValue (key,_) -> key) + let sort = Array.ofSeq >> Array.sortBy (function |KeyValue (key,_) -> key) let n = this.Name = other.Name let headers = Aux.compareSeq this.Headers other.Headers let values = Aux.compareSeq (sort this.Values) (sort other.Values) diff --git a/src/ISA/ISA/Fable.fs b/src/ISA/ISA/Fable.fs index e4d2c2ec..fb8286e0 100644 --- a/src/ISA/ISA/Fable.fs +++ b/src/ISA/ISA/Fable.fs @@ -118,35 +118,4 @@ let distinct_generic l1 = let hashSeq (s:seq<'a>) = s |> Seq.map (fun x -> x.GetHashCode()) - |> Seq.reduce (fun a b -> a + b) - -module Array = - - - let sort (a : 'T []) = - #if FABLE_COMPILER_PYTHON - a |> List.ofArray |> List.sort |> Array.ofList - #else - a |> Array.sort - #endif - - let sortBy (f : 'T -> 'U) (a : 'T []) = - #if FABLE_COMPILER_PYTHON - a |> List.ofArray |> List.sortBy f |> Array.ofList - #else - a |> Array.sortBy f - #endif - - let sortDescending (a : 'T []) = - #if FABLE_COMPILER_PYTHON - a |> List.ofArray |> List.sortDescending |> Array.ofList - #else - a |> Array.sortDescending - #endif - - let sortDescendingBy (f : 'T -> 'U) (a : 'T []) = - #if FABLE_COMPILER_PYTHON - a |> List.ofArray |> List.sortByDescending f |> Array.ofList - #else - a |> Array.sortByDescending f - #endif + |> Seq.reduce (fun a b -> a + b) \ No newline at end of file diff --git a/testpy.cmd b/testpy.cmd deleted file mode 100644 index 045ac823..00000000 --- a/testpy.cmd +++ /dev/null @@ -1,2 +0,0 @@ -dotnet fable .\tests\ISA\ISA.Tests --lang py -o ./pytests --nocache -python .\pytests\main.py \ No newline at end of file