Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
P
pymc3
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
0
Merge Requests
0
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ynic-debian
pymc3
Commits
fd79d1f2
Commit
fd79d1f2
authored
Apr 09, 2020
by
Tirth Patel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fir array_wrap to support any dimensional input
parent
18a2c3bf
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
1 deletion
+16
-1
pymc3/gp/cov.py
pymc3/gp/cov.py
+6
-1
pymc3/tests/test_gp.py
pymc3/tests/test_gp.py
+10
-0
No files found.
pymc3/gp/cov.py
View file @
fd79d1f2
...
...
@@ -116,12 +116,17 @@ class Covariance:
return
Exponentiated
(
self
,
other
)
raise
ValueError
(
"A covariance function can only be exponentiated by a scalar value"
)
def
__array_wrap__
(
self
,
result
):
"""
Required to allow radd/rmul by numpy arrays.
"""
result
=
np
.
squeeze
(
result
)
if
len
(
result
.
shape
)
<=
1
:
result
=
result
.
reshape
(
1
,
1
)
elif
len
(
result
.
shape
)
>
2
:
raise
ValueError
(
f"cannot combine a covariance function with array of shape
{
result
.
shape
}
"
)
r
,
c
=
result
.
shape
A
=
np
.
zeros
((
r
,
c
))
for
i
in
range
(
r
):
...
...
pymc3/tests/test_gp.py
View file @
fd79d1f2
...
...
@@ -165,6 +165,11 @@ class TestCovAdd:
K_true
=
theano
.
function
([],
cov_true
(
X
))()
assert
np
.
allclose
(
K
,
K_true
)
def
test_inv_rightadd
(
self
):
M
=
np
.
random
.
randn
(
2
,
2
,
2
)
with
pytest
.
raises
(
ValueError
,
match
=
r"cannot combine"
):
cov
=
M
+
pm
.
gp
.
cov
.
ExpQuad
(
1
,
1.
)
class
TestCovProd
:
def
test_symprod_cov
(
self
):
...
...
@@ -237,6 +242,11 @@ class TestCovProd:
npt
.
assert_allclose
(
np
.
diag
(
K1
),
K2d
,
atol
=
1e-5
)
npt
.
assert_allclose
(
np
.
diag
(
K2
),
K1d
,
atol
=
1e-5
)
def
test_inv_rightprod
(
self
):
M
=
np
.
random
.
randn
(
2
,
2
,
2
)
with
pytest
.
raises
(
ValueError
,
match
=
r"cannot combine"
):
cov
=
M
+
pm
.
gp
.
cov
.
ExpQuad
(
1
,
1.
)
class
TestCovExponentiation
:
def
test_symexp_cov
(
self
):
X
=
np
.
linspace
(
0
,
1
,
10
)[:,
None
]
...
...
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