Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
haskell-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
160
Issues
160
List
Board
Labels
Milestones
Merge Requests
14
Merge Requests
14
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gargantext
haskell-gargantext
Commits
690629a4
Commit
690629a4
authored
Jan 20, 2025
by
Alfredo Di Napoli
Committed by
Alfredo Di Napoli
Feb 27, 2025
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor createIndices
parent
8f4d901a
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
15 deletions
+15
-15
gargantext.cabal
gargantext.cabal
+1
-0
LinearAlgebra.hs
src/Gargantext/Core/LinearAlgebra.hs
+9
-13
LinearAlgebra.hs
test/Test/Core/LinearAlgebra.hs
+5
-2
No files found.
gargantext.cabal
View file @
690629a4
...
...
@@ -709,6 +709,7 @@ common testDependencies
, aeson ^>= 2.1.2.1
, aeson-qq
, async ^>= 2.2.4
, bimap >= 0.5.0
, bytestring ^>= 0.11.5.3
, cache >= 0.1.3.0
, containers ^>= 0.6.7
...
...
src/Gargantext/Core/LinearAlgebra.hs
View file @
690629a4
{-# LANGUAGE DerivingStrategies #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-|
Module : Gargantext.Core.LinearAlgebra
Description : Linear Algebra utility functions
...
...
@@ -19,27 +20,22 @@ module Gargantext.Core.LinearAlgebra (
,
createIndices
)
where
import
Prelude
import
Data.Bimap
(
Bimap
)
import
Data.Bimap
qualified
as
Bimap
import
Data.Map.Strict
(
Map
)
import
Data.Map.Strict
qualified
as
M
import
Data.Set
qualified
as
S
import
Data.Set
(
Set
)
import
Data.Map.Strict
(
Map
)
import
Data.Foldable
(
foldl'
)
import
Prelude
newtype
Index
=
Index
{
_Index
::
Int
}
deriving
newtype
(
Eq
,
Show
,
Ord
,
Num
,
Enum
)
createIndices
::
Ord
t
=>
Map
(
t
,
t
)
b
->
(
Map
t
Index
,
Map
Index
t
)
createIndices
::
Ord
t
=>
Map
(
t
,
t
)
b
->
Bimap
Index
t
createIndices
=
set2indices
.
map2set
where
map2set
::
Ord
t
=>
Map
(
t
,
t
)
a
->
Set
t
map2set
cs'
=
foldl'
(
\
s
((
t1
,
t2
),
_
)
->
insert
[
t1
,
t2
]
s
)
S
.
empty
(
M
.
toList
cs'
)
where
insert
as
s
=
foldl'
(
\
s'
t
->
S
.
insert
t
s'
)
s
as
map2set
cs'
=
foldr
(
\
(
t1
,
t2
)
s
->
S
.
insert
t1
$!
S
.
insert
t2
$!
s
)
mempty
$
M
.
keys
cs'
set2indices
::
Ord
t
=>
Set
t
->
(
Map
t
Index
,
Map
Index
t
)
set2indices
s
=
(
M
.
fromList
toIndex'
,
M
.
fromList
fromIndex'
)
where
fromIndex'
=
zip
[
0
..
]
xs
toIndex'
=
zip
xs
[
0
..
]
xs
=
S
.
toList
s
set2indices
::
Ord
t
=>
Set
t
->
Bimap
Index
t
set2indices
s
=
foldr
(
uncurry
Bimap
.
insert
)
Bimap
.
empty
(
zip
[
0
..
]
$
S
.
toList
s
)
test/Test/Core/LinearAlgebra.hs
View file @
690629a4
...
...
@@ -9,6 +9,9 @@ import Test.Tasty
import
Gargantext.Core.Viz.Graph.Index
qualified
as
Legacy
import
Data.Map.Strict
(
Map
)
import
Data.Map.Strict
qualified
as
M
import
Data.Bimap
(
Bimap
)
import
qualified
Data.Bimap
as
Bimap
import
Data.Bifunctor
(
first
)
compareImplementations
::
(
Arbitrary
a
,
Eq
b
,
Show
b
)
=>
(
a
->
b
)
...
...
@@ -19,8 +22,8 @@ compareImplementations :: (Arbitrary a, Eq b, Show b)
compareImplementations
implementation1
implementation2
mapResults
inputData
=
implementation1
inputData
===
mapResults
(
implementation2
inputData
)
mapCreateIndices
::
(
Map
t
Legacy
.
Index
,
Map
Legacy
.
Index
t
)
->
(
Map
t
LA
.
Index
,
Map
LA
.
Index
t
)
mapCreateIndices
(
m1
,
m2
)
=
(
M
.
map
LA
.
Index
m1
,
M
.
mapKeys
LA
.
Index
m2
)
mapCreateIndices
::
Ord
t
=>
(
Map
t
Legacy
.
Index
,
Map
Legacy
.
Index
t
)
->
Bimap
LA
.
Index
t
mapCreateIndices
(
_m1
,
m2
)
=
Bimap
.
fromList
$
map
(
first
LA
.
Index
)
$
M
.
toList
m2
tests
::
TestTree
tests
=
testGroup
"LinearAlgebra"
[
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment