From a1124684ea02d23301b67743ff761112fe9389ab Mon Sep 17 00:00:00 2001 From: Kevin F Date: Wed, 17 Jan 2024 14:14:21 +0100 Subject: [PATCH 1/4] Update readme badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d16efadd..c1ca93c7 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ and __JavaScript__! ❤️ | Version | Downloads | | :--------|-----------:| |Nuget|Nuget| -|NPM|NPM| +|NPM|NPM| ## Install From b21e3bcb0a5679b5ec5494555d9e9d23822bdc9a Mon Sep 17 00:00:00 2001 From: Kevin F Date: Wed, 17 Jan 2024 17:18:21 +0100 Subject: [PATCH 2/4] Extend ArcTable.Join :sparkles::white_check_mark: --- src/ISA/ISA/ArcTypes/ArcTable.fs | 14 +++++--- tests/ISA/ISA.Tests/ArcTable.Tests.fs | 50 ++++++++++++++++++++++----- 2 files changed, 50 insertions(+), 14 deletions(-) diff --git a/src/ISA/ISA/ArcTypes/ArcTable.fs b/src/ISA/ISA/ArcTypes/ArcTable.fs index 58db8d0f..f9eb5e3f 100644 --- a/src/ISA/ISA/ArcTypes/ArcTable.fs +++ b/src/ISA/ISA/ArcTypes/ArcTable.fs @@ -503,12 +503,17 @@ type ArcTable(name: string, headers: ResizeArray, values: Syste /// /// This function can be used to join two arc tables. /// + /// If not set default to append. -1 will also append. /// The table to join to this table. /// Can add only headers, header with unitized cell information, headers with values. /// if set to true will replace unique columns. - member this.Join(table:ArcTable, ?joinOptions: TableJoinOptions, ?forceReplace: bool, ?SkipFillMissing) : unit = + member this.Join(table:ArcTable, ?index: int, ?joinOptions: TableJoinOptions, ?forceReplace: bool, ?skipFillMissing) : unit = let joinOptions = defaultArg joinOptions TableJoinOptions.Headers let forceReplace = defaultArg forceReplace false + let skipFillMissing = defaultArg skipFillMissing true + let mutable index = defaultArg index this.ColumnCount + index <- if index = -1 then this.ColumnCount else index //make -1 default to append to make function usage more fluent. + SanityChecks.validateColumnIndex index this.ColumnCount true let onlyHeaders = joinOptions = TableJoinOptions.Headers let columns = let pre = table.Columns @@ -528,7 +533,6 @@ type ArcTable(name: string, headers: ResizeArray, values: Syste | WithValues -> pre SanityChecks.validateNoDuplicateUniqueColumns columns columns |> Array.iter (fun x -> SanityChecks.validateColumn x) - let mutable index = this.ColumnCount columns |> Array.iter (fun col -> let prevHeadersCount = this.Headers.Count @@ -536,12 +540,12 @@ type ArcTable(name: string, headers: ResizeArray, values: Syste // Check if more headers, otherwise `ArcTableAux.insertColumn` replaced a column and we do not need to increase index. if this.Headers.Count > prevHeadersCount then index <- index + 1 ) - if not(SkipFillMissing = Some true) then Unchecked.fillMissingCells this.Headers this.Values + if not(skipFillMissing) then Unchecked.fillMissingCells this.Headers this.Values - static member join(table:ArcTable, ?joinOptions: TableJoinOptions, ?forceReplace: bool) = + static member join(table:ArcTable, ?index: int, ?joinOptions: TableJoinOptions, ?forceReplace: bool) = fun (this: ArcTable) -> let copy = this.Copy() - copy.Join(table,?joinOptions=joinOptions,?forceReplace=forceReplace) + copy.Join(table,?index=index,?joinOptions=joinOptions,?forceReplace=forceReplace) copy static member insertParameterValue (t : ArcTable) (p : ProcessParameterValue) : ArcTable = diff --git a/tests/ISA/ISA.Tests/ArcTable.Tests.fs b/tests/ISA/ISA.Tests/ArcTable.Tests.fs index 8a7a38c5..3e5de3ea 100644 --- a/tests/ISA/ISA.Tests/ArcTable.Tests.fs +++ b/tests/ISA/ISA.Tests/ArcTable.Tests.fs @@ -2081,11 +2081,43 @@ let private tests_UpdateRefWithSheet = ] let private tests_Join = testList "Join" [ + testList "index" [ + testCase "ensure default is append" <| fun _ -> + let table1 = create_testTable() + let columnCount = table1.ColumnCount + let table2 = create_testTable() + table2.RemoveColumn 0 // rmv input + table2.RemoveColumn 0 // rmv output + let expectedJoinCount = columnCount + table2.ColumnCount + table1.Join(table2) + Expect.equal table1.ColumnCount expectedJoinCount "new column count" + Expect.equal (table1.Headers.[columnCount]) (table2.Headers.[0]) "column equal" + testCase "ensure -1 defaults to append" <| fun _ -> + let table1 = create_testTable() + let columnCount = table1.ColumnCount + let table2 = create_testTable() + table2.RemoveColumn 0 // rmv input + table2.RemoveColumn 0 // rmv output + let expectedJoinCount = columnCount + table2.ColumnCount + table1.Join(table2,-1) + Expect.equal table1.ColumnCount expectedJoinCount "new column count" + Expect.equal (table1.Headers.[columnCount]) (table2.Headers.[0]) "column equal" + testCase "insert at start" <| fun _ -> + let table1 = create_testTable() + let columnCount = table1.ColumnCount + let table2 = create_testTable() + table2.RemoveColumn 0 // rmv input + table2.RemoveColumn 0 // rmv output + let expectedJoinCount = columnCount + table2.ColumnCount + table1.Join(table2,0) + Expect.equal table1.ColumnCount expectedJoinCount "new column count" + Expect.equal (table1.Headers.[0]) (table2.Headers.[0]) "column equal" + ] testList "TableJoinOption.Headers" [ testCase "Add to empty" <| fun _ -> let table = ArcTable.init("MyTable") let joinTable = create_testTable() - table.Join(joinTable,TableJoinOptions.Headers) + table.Join(joinTable,-1,TableJoinOptions.Headers) Expect.equal table.ColumnCount 5 "columnCount" // test headers Expect.equal table.Headers.[0] (CompositeHeader.Input IOType.Source) "Header input" @@ -2098,12 +2130,12 @@ let private tests_Join = testList "Join" [ testCase "Add to duplicate" <| fun _ -> let table = create_testTable() let joinTable = create_testTable() - let func = fun () -> table.Join(joinTable,TableJoinOptions.Headers) + let func = fun () -> table.Join(joinTable,-1,TableJoinOptions.Headers) Expect.throws func "This should fail as we try to add multiple inputs/outputs to one table" testCase "Add to duplicate, forceReplace" <| fun _ -> let table = create_testTable() let joinTable = create_testTable() - table.Join(joinTable,TableJoinOptions.Headers, true) + table.Join(joinTable,-1,TableJoinOptions.Headers,true) Expect.equal table.ColumnCount 8 "We expect 8 columns as there are 5 per table with 2 unique 5 + (5-2) = 8" // headers Expect.equal table.Headers.[0] (CompositeHeader.Input IOType.Source) "Header input" @@ -2123,7 +2155,7 @@ let private tests_Join = testList "Join" [ ResizeArray([CompositeHeader.Input IOType.ImageFile]), System.Collections.Generic.Dictionary() ) - table.Join(joinTable,TableJoinOptions.Headers, true) + table.Join(joinTable,-1,TableJoinOptions.Headers,true) Expect.equal table.ColumnCount 5 "columnCount" // test headers Expect.equal table.Headers.[0] (CompositeHeader.Input IOType.ImageFile) "Here should be new image input" @@ -2142,7 +2174,7 @@ let private tests_Join = testList "Join" [ column_component |] joinTable.AddColumns(columns) - table.Join(joinTable,TableJoinOptions.WithUnit) + table.Join(joinTable,-1,TableJoinOptions.WithUnit) Expect.equal table.ColumnCount 1 "column count" Expect.equal table.RowCount 0 "row count" testCase "Add to empty, with unit" <| fun _ -> @@ -2158,11 +2190,11 @@ let private tests_Join = testList "Join" [ ) |] joinTable.AddColumns(columns) - table.Join(joinTable,TableJoinOptions.WithUnit) + table.Join(joinTable,-1,TableJoinOptions.WithUnit, skipFillMissing=false) Expect.equal table.ColumnCount 2 "column count" Expect.equal table.RowCount 5 "row count" - Expect.equal table.Values.[0,0] (CompositeCell.createTerm OntologyAnnotation.empty) "empty term cell" - Expect.equal table.Values.[1,0] (CompositeCell.createUnitized("",oa_temperature)) "temperature unit cell" + Expect.equal table.Values.[(0,0)] (CompositeCell.createTerm OntologyAnnotation.empty) "empty term cell" + Expect.equal table.Values.[(1,0)] (CompositeCell.createUnitized("",oa_temperature)) "temperature unit cell" ] testList "TableJoinOption.WithValues" [ testCase "Add to empty" <| fun _ -> @@ -2178,7 +2210,7 @@ let private tests_Join = testList "Join" [ ) |] joinTable.AddColumns(columns) - table.Join(joinTable,TableJoinOptions.WithValues) + table.Join(joinTable,-1,TableJoinOptions.WithValues) Expect.equal table.ColumnCount 2 "column count" Expect.equal table.RowCount 5 "row count" Expect.equal table.Values.[0,0] (CompositeCell.createTerm oa_SCIEXInstrumentModel) "sciex instrument model" From 66b15f67214f10ee3cfbb97cca0ccf738c8ffb6c Mon Sep 17 00:00:00 2001 From: Kevin F Date: Wed, 17 Jan 2024 17:28:48 +0100 Subject: [PATCH 3/4] Update to v1.0.5 --- RELEASE_NOTES.md | 10 ++++++++++ build/release_package.json | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 087b44c8..0575dcc4 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,3 +1,13 @@ +### 1.0.5+b21e3bc (Released 2024-1-17) +* Additions: + * [[#b21e3bc](https://github.com/nfdi4plants/ARCtrl/commit/b21e3bcb0a5679b5ec5494555d9e9d23822bdc9a)] Extend ArcTable.Join :sparkles::white_check_mark: + * [[#a112468](https://github.com/nfdi4plants/ARCtrl/commit/a1124684ea02d23301b67743ff761112fe9389ab)] Update readme badge + * [[#a0144e1](https://github.com/nfdi4plants/ARCtrl/commit/a0144e1282bb1e8206378eb6bb8b23619eb666e6)] Merge pull request #295 from nfdi4plants/Freymaurer-patch-1 + * [[#9e5c1f6](https://github.com/nfdi4plants/ARCtrl/commit/9e5c1f67b676d63dcb69b586089e1e74ca1c2814)] Update README.md + * [[#6e0755b](https://github.com/nfdi4plants/ARCtrl/commit/6e0755b5e1c28bb72814247dad1e4ab457e25e40)] update and release version 1.0.4 +* Bugfixes: + * [[#8dd99e8](https://github.com/nfdi4plants/ARCtrl/commit/8dd99e82fc93add2950860d6eb185686be21f9ba)] Merge pull request #294 from nfdi4plants/fix_annotationValue_read + ### 1.0.4+167fae8 (Released 2024-1-15) * Additions: * [[#167fae8](https://github.com/nfdi4plants/ARCtrl/commit/167fae8bcaa14d8e24055f60ac031b13d8b47199)] add json functions for better function names in js :sparkles: diff --git a/build/release_package.json b/build/release_package.json index 38ed9653..b2892844 100644 --- a/build/release_package.json +++ b/build/release_package.json @@ -1,6 +1,6 @@ { "name": "@nfdi4plants/arctrl", - "version": "1.0.4+167fae8", + "version": "1.0.5+b21e3bc", "description": "Top level ARC DataModel and API function descriptions.", "type": "module", "main": "index.js", From 13428ca85f366eb13ba02b8557bec52bc643bab8 Mon Sep 17 00:00:00 2001 From: Kevin F Date: Mon, 22 Jan 2024 13:37:43 +0100 Subject: [PATCH 4/4] Revert unintended change in default! --- src/ISA/ISA/ArcTypes/ArcTable.fs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/ISA/ISA/ArcTypes/ArcTable.fs b/src/ISA/ISA/ArcTypes/ArcTable.fs index f9eb5e3f..141c0d35 100644 --- a/src/ISA/ISA/ArcTypes/ArcTable.fs +++ b/src/ISA/ISA/ArcTypes/ArcTable.fs @@ -510,7 +510,7 @@ type ArcTable(name: string, headers: ResizeArray, values: Syste member this.Join(table:ArcTable, ?index: int, ?joinOptions: TableJoinOptions, ?forceReplace: bool, ?skipFillMissing) : unit = let joinOptions = defaultArg joinOptions TableJoinOptions.Headers let forceReplace = defaultArg forceReplace false - let skipFillMissing = defaultArg skipFillMissing true + let skipFillMissing = defaultArg skipFillMissing false let mutable index = defaultArg index this.ColumnCount index <- if index = -1 then this.ColumnCount else index //make -1 default to append to make function usage more fluent. SanityChecks.validateColumnIndex index this.ColumnCount true