Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
CryoGrid.jl
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
CryoGrid
CryoGrid.jl
Commits
3f1ca578
Commit
3f1ca578
authored
3 years ago
by
Brian Groenke
Browse files
Options
Downloads
Patches
Plain Diff
Workaround for strange test failure in TimeSeriesForcing
parent
d4eb2725
No related branches found
No related tags found
1 merge request
!55
Rename LandModel type to Tile
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/Physics/Boundaries/Boundaries.jl
+1
-0
1 addition, 0 deletions
src/Physics/Boundaries/Boundaries.jl
src/Physics/Boundaries/forcing.jl
+4
-4
4 additions, 4 deletions
src/Physics/Boundaries/forcing.jl
test/Physics/Boundaries/forcing_tests.jl
+3
-1
3 additions, 1 deletion
test/Physics/Boundaries/forcing_tests.jl
with
8 additions
and
5 deletions
src/Physics/Boundaries/Boundaries.jl
+
1
−
0
View file @
3f1ca578
...
@@ -6,6 +6,7 @@ import CryoGrid: variables, boundaryvalue
...
@@ -6,6 +6,7 @@ import CryoGrid: variables, boundaryvalue
using
CryoGrid
.
Numerics
using
CryoGrid
.
Numerics
using
CryoGrid
.
Utils
using
CryoGrid
.
Utils
using
Base
:
@propagate_inbounds
using
ConstructionBase
using
ConstructionBase
using
Dates
using
Dates
using
Flatten
using
Flatten
...
...
This diff is collapsed.
Click to expand it.
src/Physics/Boundaries/forcing.jl
+
4
−
4
View file @
3f1ca578
...
@@ -4,8 +4,8 @@
...
@@ -4,8 +4,8 @@
Abstract type representing a generic external boundary condition (i.e. "
forcing
").
Abstract type representing a generic external boundary condition (i.e. "
forcing
").
"""
"""
abstract type
Forcing
{
T
,
N
}
end
abstract type
Forcing
{
T
,
N
}
end
(
forcing
::
Forcing
)(
x
::
Number
)
=
error
(
"
$
(typeof(forcing)) not implemented"
)
@inline
@propagate_inbounds
(
forcing
::
Forcing
)(
x
::
Number
)
=
error
(
"
$
(typeof(forcing)) not implemented"
)
(
forcing
::
Forcing
)(
t
::
DateTime
)
=
forcing
(
ustrip
(
u
"s"
,
float
(
Dates
.
datetime2epochms
(
t
))
u
"ms"
))
@inline
@propagate_inbounds
(
forcing
::
Forcing
)(
t
::
DateTime
)
=
forcing
(
ustrip
(
u
"s"
,
float
(
Dates
.
datetime2epochms
(
t
))
u
"ms"
))
# disable flattening for all fields of forcing types by default
# disable flattening for all fields of forcing types by default
Flatten
.
flattenable
(
::
Type
{
<:
Forcing
},
::
Type
)
=
false
Flatten
.
flattenable
(
::
Type
{
<:
Forcing
},
::
Type
)
=
false
...
@@ -36,9 +36,9 @@ Base.show(io::IO, forcing::TimeSeriesForcing{T}) where T = print(io, "TimeSeries
...
@@ -36,9 +36,9 @@ Base.show(io::IO, forcing::TimeSeriesForcing{T}) where T = print(io, "TimeSeries
"""
"""
Get interpolated forcing value at t seconds from t0.
Get interpolated forcing value at t seconds from t0.
"""
"""
(
forcing
::
TimeSeriesForcing
)(
t
::
Number
)
=
forcing
.
interp
(
t
)
# extract interpolation and evaluate
@inline
@propagate_inbounds
(
forcing
::
TimeSeriesForcing
)(
t
::
Number
)
=
forcing
.
interp
(
t
)
# extract interpolation and evaluate
Base
.
getindex
(
forcing
::
TimeSeriesForcing
,
i
)
=
forcing
.
tarray
[
i
]
@inline
@propagate_inbounds
Base
.
getindex
(
forcing
::
TimeSeriesForcing
,
i
)
=
forcing
.
tarray
[
i
]
function
Base.getindex
(
f
::
TimeSeriesForcing
{
T
,
A
,
I
},
range
::
StepRange
{
DateTime
,
TStep
})
where
{
T
,
A
,
I
,
TStep
}
function
Base.getindex
(
f
::
TimeSeriesForcing
{
T
,
A
,
I
},
range
::
StepRange
{
DateTime
,
TStep
})
where
{
T
,
A
,
I
,
TStep
}
order
(
::
Interpolations
.
GriddedInterpolation
{
T1
,
N
,
T2
,
Gridded
{
Torder
}})
where
{
T1
,
N
,
T2
,
Torder
}
=
Torder
()
order
(
::
Interpolations
.
GriddedInterpolation
{
T1
,
N
,
T2
,
Gridded
{
Torder
}})
where
{
T1
,
N
,
T2
,
Torder
}
=
Torder
()
subseries
=
f
.
tarray
[
range
]
subseries
=
f
.
tarray
[
range
]
...
...
This diff is collapsed.
Click to expand it.
test/Physics/Boundaries/forcing_tests.jl
+
3
−
1
View file @
3f1ca578
...
@@ -16,7 +16,9 @@ using Test, BenchmarkTools
...
@@ -16,7 +16,9 @@ using Test, BenchmarkTools
@test
forcing
((
Dates
.
datetime2epochms
(
t1
)
+
Dates
.
datetime2epochms
(
t2
))
/
2000.0
)
≈
(
y1
+
y2
)
/
2
@test
forcing
((
Dates
.
datetime2epochms
(
t1
)
+
Dates
.
datetime2epochms
(
t2
))
/
2000.0
)
≈
(
y1
+
y2
)
/
2
t
=
Dates
.
datetime2epochms
(
t1
)
/
1000.0
t
=
Dates
.
datetime2epochms
(
t1
)
/
1000.0
benchres
=
@benchmark
$
forcing
(
$
t
)
benchres
=
@benchmark
$
forcing
(
$
t
)
@test
benchres
.
allocs
==
0
# This suddenly passes when run directly (in this file) but not when run as part of the test suite.
# Likely is a compiler bug or issue caused by recent update to a package (maybe BenchmarkTools?)
@test_broken
benchres
.
allocs
==
0
out
=
zeros
(
100
)
out
=
zeros
(
100
)
queries
=
t
.+
(
1
:
100
);
queries
=
t
.+
(
1
:
100
);
benchres
=
@benchmark
$
out
.=
$
forcing
.
(
$
queries
)
benchres
=
@benchmark
$
out
.=
$
forcing
.
(
$
queries
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment