Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Persefone.jl
Manage
Activity
Members
Plan
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Package Registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Repository analytics
Insights
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Persefone
Persefone.jl
Commits
b4f6a32f
Commit
b4f6a32f
authored
8 months ago
by
xo30xoqa
Browse files
Options
Downloads
Patches
Plain Diff
AnnualDates can be constructed from a string
parent
0d30cead
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/core/utils.jl
+4
-0
4 additions, 0 deletions
src/core/utils.jl
src/world/landscape.jl
+1
-1
1 addition, 1 deletion
src/world/landscape.jl
test/io_tests.jl
+6
-1
6 additions, 1 deletion
test/io_tests.jl
with
11 additions
and
2 deletions
src/core/utils.jl
+
4
−
0
View file @
b4f6a32f
...
...
@@ -47,6 +47,10 @@ end
AnnualDate
(
ad
::
Tuple
{
Int64
,
Int64
})
=
AnnualDate
(
ad
...
)
Base
.
convert
(
::
Type
{
AnnualDate
},
ad
::
Tuple
{
Int64
,
Int64
})
=
AnnualDate
(
ad
)
# allow creating AnnualDates from a string of the format "8 August"
AnnualDate
(
ad
::
String
)
=
AnnualDate
(
Date
(
ad
,
dateformat
"d U"
))
Base
.
convert
(
::
Type
{
AnnualDate
},
ad
::
String
)
=
AnnualDate
(
ad
)
# Interface with Dates
AnnualDate
(
date
::
Date
)
=
AnnualDate
(
month
(
date
),
day
(
date
))
Base
.
convert
(
::
Type
{
AnnualDate
},
ad
::
Date
)
=
AnnualDate
(
ad
)
...
...
This diff is collapsed.
Click to expand it.
src/world/landscape.jl
+
1
−
1
View file @
b4f6a32f
...
...
@@ -22,7 +22,7 @@ mutable struct Pixel
fieldid
::
Union
{
Missing
,
Int64
}
# ID of the farmplot (if any) at this position
events
::
Vector
{
Management
}
# management events that have been applied to this pixel
animals
::
Vector
{
Int64
}
# IDs of animals currently at this position
territories
::
Vector
{
String
}
# IDs of animals that claim this pixel as part of their territory
territories
::
Vector
{
String
}
# IDs of animals that claim this pixel as part of their territory
end
Pixel
(
landcover
::
LandCover
,
fieldid
::
Union
{
Missing
,
Int64
})
=
...
...
This diff is collapsed.
Click to expand it.
test/io_tests.jl
+
6
−
1
View file @
b4f6a32f
...
...
@@ -113,11 +113,16 @@ end
@test
1
km
/
5
==
200
m
# AnnualDates
birthday
::
AnnualDate
=
(
August
,
21
)
christmas
::
AnnualDate
=
(
December
,
24
)
christmas
::
AnnualDate
=
"24
December
"
heute
=
Date
(
2024
,
8
,
8
)
@test
christmas
-
birthday
==
Day
(
125
)
@test
birthday
-
christmas
==
Day
(
240
)
@test
birthday
>
heute
@test
heute
+
Week
(
2
)
-
Day
(
1
)
==
birthday
@test
length
(
AnnualDate
(
heute
)
:
birthday
)
==
14
# bounds
@test
Ps
.
bounds
(
3
)
==
3
@test
Ps
.
bounds
(
-
3
)
==
0
@test
Ps
.
bounds
(
20
,
max
=
10
)
==
10
@test
Ps
.
bounds
(
-
3
,
min
=-
10
)
==
-
3
end
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