Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
purescript-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
142
Issues
142
List
Board
Labels
Milestones
Merge Requests
4
Merge Requests
4
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
purescript-gargantext
Commits
d6d237c1
Commit
d6d237c1
authored
Feb 16, 2021
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[ngrams docs] score improvements
parent
0e9526b1
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
24 additions
and
8 deletions
+24
-8
Score.purs
src/Gargantext/Components/Score.purs
+2
-4
Array.purs
src/Gargantext/Utils/Array.purs
+13
-1
Spec.purs
test/Gargantext/Utils/Spec.purs
+9
-3
No files found.
src/Gargantext/Components/Score.purs
View file @
d6d237c1
...
...
@@ -14,6 +14,7 @@ import Gargantext.Prelude
import Gargantext.Routes (SessionRoute(NodeAPI))
import Gargantext.Sessions (Session, sessionId, get, delete, put)
import Gargantext.Types as GT
import Gargantext.Utils.Array as GUA
import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Reload as GUR
...
...
@@ -56,10 +57,7 @@ scoreElCpt = R.hooksComponentWithModule thisModule "scoreEl" cpt
option :: Choice -> R.Element
option c = H.option { value: showChoice c } [ H.text $ showChoice c ]
choices = [ Nothing
, Just 5
, Just 10
, Just 15 ]
choices = [ Nothing ] <> (Just <$> GUA.range 5 100 5)
showChoice :: Choice -> String
showChoice Nothing = "-"
...
...
src/Gargantext/Utils/Array.purs
View file @
d6d237c1
module Gargantext.Utils.Array (max, min, push) where
module Gargantext.Utils.Array (
max
, min
, push
, range) where
import Data.Array as A
import Data.Foldable (foldr)
import Data.Int as DI
import Data.Maybe (Maybe(..))
import Data.Ord as Ord
import Effect (Effect)
import Effect.Uncurried (EffectFn2, runEffectFn2)
import Math as Math
import Gargantext.Prelude
...
...
@@ -26,3 +32,9 @@ min xs = foldr reducer (A.head xs) xs
where
reducer _ Nothing = Nothing
reducer v (Just acc) = Just $ Ord.min acc v
-- | Create an array containing a range of integers, with given step
range :: Int -> Int -> Int -> Array Int
range start end step = map (\i -> start + i*step) $ A.range 0 end'
where
end' = DI.round $ Math.floor $ (DI.toNumber $ end - start) / (DI.toNumber step)
test/Gargantext/Utils/Spec.purs
View file @
d6d237c1
...
...
@@ -9,6 +9,7 @@ import Data.Generic.Rep (class Generic)
import Data.Generic.Rep.Show (genericShow)
import Gargantext.Utils as GU
import Gargantext.Utils.Argonaut (genericEnumDecodeJson, genericEnumEncodeJson, genericSumDecodeJson, genericSumEncodeJson)
import Gargantext.Utils.Array as GUA
import Gargantext.Utils.Crypto as Crypto
import Gargantext.Utils.Math as GUM
import Test.Spec (Spec, describe, it)
...
...
@@ -132,6 +133,11 @@ spec =
let hash2 = Crypto.hash ["b","a"]
hash1 `shouldEqual` hash2
------------------------------------------------------------------------
-- | Gargantext.Utils.Array tests
it "G.U.Array.range works correctly (include endpoint)" do
GUA.range 0 10 2 `shouldEqual` [0, 2, 4, 6, 8, 10]
GUA.range 0 10 5 `shouldEqual` [0, 5, 10]
it "G.U.Array.range works correctly (no endpoint)" do
GUA.range 0 11 2 `shouldEqual` [0, 2, 4, 6, 8, 10]
GUA.range 0 11 5 `shouldEqual` [0, 5, 10]
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