Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
morpheus.js
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Daria Zenkova
morpheus.js
Commits
996af225
Commit
996af225
authored
May 11, 2016
by
Joshua Gould
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
moved getDataType to util
parent
613448df
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
461 additions
and
454 deletions
+461
-454
src/matrix/vector_util.js
src/matrix/vector_util.js
+23
-36
src/util/util.js
src/util/util.js
+438
-418
No files found.
src/matrix/vector_util.js
View file @
996af225
morpheus
.
VectorUtil
=
function
()
{
morpheus
.
VectorUtil
=
function
()
{
};
morpheus
.
VectorUtil
.
createValueToIndicesMap
=
function
(
vector
)
{
morpheus
.
VectorUtil
.
createValueToIndicesMap
=
function
(
vector
)
{
if
(
!
vector
)
{
throw
'
vector is null
'
;
}
...
...
@@ -16,7 +16,7 @@ morpheus.VectorUtil.createValueToIndicesMap = function(vector) {
}
return
map
;
};
morpheus
.
VectorUtil
.
createValueToCountMap
=
function
(
vector
)
{
morpheus
.
VectorUtil
.
createValueToCountMap
=
function
(
vector
)
{
if
(
!
vector
)
{
throw
'
vector is null
'
;
}
...
...
@@ -39,7 +39,7 @@ morpheus.VectorUtil.createValueToCountMap = function(vector) {
}
return
map
;
};
morpheus
.
VectorUtil
.
maybeConvertToStringArray
=
function
(
vector
,
delim
)
{
morpheus
.
VectorUtil
.
maybeConvertToStringArray
=
function
(
vector
,
delim
)
{
var
newValues
=
[];
var
regex
=
new
RegExp
(
delim
);
var
found
=
false
;
...
...
@@ -63,7 +63,7 @@ morpheus.VectorUtil.maybeConvertToStringArray = function(vector, delim) {
return
found
;
};
morpheus
.
VectorUtil
.
maybeConvertStringToNumber
=
function
(
vector
)
{
morpheus
.
VectorUtil
.
maybeConvertStringToNumber
=
function
(
vector
)
{
var
newValues
=
[];
for
(
var
i
=
0
,
nrows
=
vector
.
size
();
i
<
nrows
;
i
++
)
{
...
...
@@ -81,7 +81,7 @@ morpheus.VectorUtil.maybeConvertStringToNumber = function(vector) {
vector
.
getProperties
().
set
(
morpheus
.
VectorKeys
.
DATA_TYPE
,
'
number
'
);
return
true
;
};
morpheus
.
VectorUtil
.
createValuesToIndicesMap
=
function
(
vectors
)
{
morpheus
.
VectorUtil
.
createValuesToIndicesMap
=
function
(
vectors
)
{
var
map
=
new
morpheus
.
Map
();
var
nvectors
=
vectors
.
length
;
if
(
vectors
[
0
]
==
null
)
{
...
...
@@ -104,7 +104,7 @@ morpheus.VectorUtil.createValuesToIndicesMap = function(vectors) {
}
return
map
;
};
morpheus
.
VectorUtil
.
createValuesToIndexMap
=
function
(
vectors
)
{
morpheus
.
VectorUtil
.
createValuesToIndexMap
=
function
(
vectors
)
{
var
map
=
new
morpheus
.
Map
();
var
nvectors
=
vectors
.
length
;
if
(
vectors
[
0
]
==
null
)
{
...
...
@@ -122,10 +122,10 @@ morpheus.VectorUtil.createValuesToIndexMap = function(vectors) {
}
return
map
;
};
morpheus
.
VectorUtil
.
containsMoreThanOneValue
=
function
(
vector
)
{
morpheus
.
VectorUtil
.
containsMoreThanOneValue
=
function
(
vector
)
{
return
morpheus
.
VectorUtil
.
containsMoreThanNValues
(
vector
,
1
);
};
morpheus
.
VectorUtil
.
containsMoreThanNValues
=
function
(
vector
,
n
)
{
morpheus
.
VectorUtil
.
containsMoreThanNValues
=
function
(
vector
,
n
)
{
var
s
=
new
morpheus
.
Set
();
for
(
var
j
=
0
,
size
=
vector
.
size
();
j
<
size
;
j
++
)
{
var
val
=
vector
.
getValue
(
j
);
...
...
@@ -136,7 +136,7 @@ morpheus.VectorUtil.containsMoreThanNValues = function(vector, n) {
}
return
false
;
};
morpheus
.
VectorUtil
.
createValueToIndexMap
=
function
(
vector
)
{
morpheus
.
VectorUtil
.
createValueToIndexMap
=
function
(
vector
)
{
var
map
=
new
morpheus
.
Map
();
for
(
var
j
=
0
,
size
=
vector
.
size
();
j
<
size
;
j
++
)
{
var
val
=
vector
.
getValue
(
j
);
...
...
@@ -144,7 +144,7 @@ morpheus.VectorUtil.createValueToIndexMap = function(vector) {
}
return
map
;
};
morpheus
.
VectorUtil
.
getValues
=
function
(
vector
,
excludeNull
)
{
morpheus
.
VectorUtil
.
getValues
=
function
(
vector
,
excludeNull
)
{
var
set
=
new
morpheus
.
Set
();
for
(
var
j
=
0
,
size
=
vector
.
size
();
j
<
size
;
j
++
)
{
var
val
=
vector
.
getValue
(
j
);
...
...
@@ -157,14 +157,14 @@ morpheus.VectorUtil.getValues = function(vector, excludeNull) {
array
.
sort
(
morpheus
.
SortKey
.
ASCENDING_COMPARATOR
);
return
array
;
};
morpheus
.
VectorUtil
.
getSet
=
function
(
vector
)
{
morpheus
.
VectorUtil
.
getSet
=
function
(
vector
)
{
var
set
=
new
morpheus
.
Set
();
for
(
var
j
=
0
,
size
=
vector
.
size
();
j
<
size
;
j
++
)
{
set
.
add
(
vector
.
getValue
(
j
));
}
return
set
;
};
morpheus
.
VectorUtil
.
createSpanMap
=
function
(
vector
)
{
morpheus
.
VectorUtil
.
createSpanMap
=
function
(
vector
)
{
var
previous
=
vector
.
getValue
(
0
);
// find 1st row with different value
var
startIndexToEndIndex
=
new
morpheus
.
Map
();
...
...
@@ -181,7 +181,7 @@ morpheus.VectorUtil.createSpanMap = function(vector) {
startIndexToEndIndex
.
set
(
start
,
vector
.
size
());
return
startIndexToEndIndex
;
};
morpheus
.
VectorUtil
.
toArray
=
function
(
vector
)
{
morpheus
.
VectorUtil
.
toArray
=
function
(
vector
)
{
var
array
=
[];
for
(
var
i
=
0
,
length
=
vector
.
size
();
i
<
length
;
i
++
)
{
var
val
=
vector
.
getValue
(
i
);
...
...
@@ -190,12 +190,12 @@ morpheus.VectorUtil.toArray = function(vector) {
return
array
;
};
morpheus
.
VectorUtil
.
arrayAsVector
=
function
(
array
,
name
)
{
morpheus
.
VectorUtil
.
arrayAsVector
=
function
(
array
,
name
)
{
var
v
=
new
morpheus
.
Vector
(
name
,
array
.
length
);
v
.
array
=
array
;
return
v
;
};
morpheus
.
VectorUtil
.
toString
=
function
(
vector
)
{
morpheus
.
VectorUtil
.
toString
=
function
(
vector
)
{
var
array
=
[];
for
(
var
i
=
0
,
length
=
vector
.
size
();
i
<
length
;
i
++
)
{
var
val
=
vector
.
getValue
(
i
);
...
...
@@ -204,31 +204,18 @@ morpheus.VectorUtil.toString = function(vector) {
return
array
.
join
(
'
,
'
);
};
morpheus
.
VectorUtil
.
getDataType
=
function
(
vector
)
{
morpheus
.
VectorUtil
.
getDataType
=
function
(
vector
)
{
var
dataType
=
vector
.
getProperties
().
get
(
morpheus
.
VectorKeys
.
DATA_TYPE
);
if
(
dataType
===
undefined
)
{
var
firstNonNull
=
morpheus
.
VectorUtil
.
getFirstNonNull
(
vector
);
var
isArray
=
morpheus
.
Util
.
isArray
(
firstNonNull
);
if
(
isArray
&&
firstNonNull
.
length
>
0
)
{
firstNonNull
=
firstNonNull
[
0
];
}
if
(
_
.
isString
(
firstNonNull
))
{
dataType
=
'
string
'
;
}
else
if
(
_
.
isNumber
(
firstNonNull
))
{
dataType
=
'
number
'
;
}
else
{
dataType
=
'
object
'
;
}
if
(
isArray
)
{
dataType
=
'
[
'
+
dataType
+
'
]
'
;
}
dataType
=
morpheus
.
Util
.
getDataType
(
firstNonNull
);
vector
.
getProperties
().
set
(
morpheus
.
VectorKeys
.
DATA_TYPE
,
dataType
);
}
return
dataType
;
};
morpheus
.
VectorUtil
.
getMinMax
=
function
(
vector
)
{
morpheus
.
VectorUtil
.
getMinMax
=
function
(
vector
)
{
var
min
=
Number
.
MAX_VALUE
;
var
max
=
-
Number
.
MAX_VALUE
;
var
fields
=
vector
.
getProperties
().
get
(
morpheus
.
VectorKeys
.
FIELDS
);
...
...
@@ -256,11 +243,11 @@ morpheus.VectorUtil.getMinMax = function(vector) {
}
}
return
{
min
:
min
,
max
:
max
min
:
min
,
max
:
max
};
};
morpheus
.
VectorUtil
.
getFirstNonNull
=
function
(
vector
)
{
morpheus
.
VectorUtil
.
getFirstNonNull
=
function
(
vector
)
{
for
(
var
i
=
0
,
length
=
vector
.
size
();
i
<
length
;
i
++
)
{
var
val
=
vector
.
getValue
(
i
);
if
(
val
!=
null
)
{
...
...
@@ -269,6 +256,6 @@ morpheus.VectorUtil.getFirstNonNull = function(vector) {
}
return
null
;
};
morpheus
.
VectorUtil
.
isNumber
=
function
(
vector
)
{
morpheus
.
VectorUtil
.
isNumber
=
function
(
vector
)
{
return
morpheus
.
VectorUtil
.
getDataType
(
vector
)
===
'
number
'
;
};
src/util/util.js
View file @
996af225
This diff is collapsed.
Click to expand it.
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