Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
T
TimeDataFrames.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
Container registry
Model registry
Operate
Environments
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
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
DynareJulia
TimeDataFrames.jl
Commits
ee68782b
Commit
ee68782b
authored
5 years ago
by
MichelJuillard
Browse files
Options
Downloads
Patches
Plain Diff
beginning of copy()
parent
5364ac18
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/TimeDataFrames.jl
+50
-1
50 additions, 1 deletion
src/TimeDataFrames.jl
with
50 additions
and
1 deletion
src/TimeDataFrames.jl
+
50
−
1
View file @
ee68782b
...
...
@@ -85,7 +85,56 @@ Base.view(df::TimeDataFrame, idx::CartesianIndex{2}) = view(df, idx[1], idx[2])
Base
.
setindex!
(
df
::
TimeDataFrame
,
val
,
idx
::
CartesianIndex
{
2
})
=
(
df
[
idx
[
1
],
idx
[
2
]]
=
val
)
Base
.
broadcastable
(
df
::
TimeDataFrame
)
=
df
Base
.
broadcastable
(
tdf
::
TimeDataFrame
)
=
tdf
struct
TimeDataFrameStyle
<:
Base
.
Broadcast
.
BroadcastStyle
end
Base
.
Broadcast
.
BroadcastStyle
(
::
Type
{
<:
TimeDataFrame
})
=
TimeDataFrameStyle
()
Base
.
Broadcast
.
BroadcastStyle
(
::
TimeDataFrameStyle
,
::
Base
.
Broadcast
.
BroadcastStyle
)
=
TimeDataFrameStyle
()
Base
.
Broadcast
.
BroadcastStyle
(
::
Base
.
Broadcast
.
BroadcastStyle
,
::
TimeDataFrameStyle
)
=
TimeDataFrameStyle
()
Base
.
Broadcast
.
BroadcastStyle
(
::
TimeDataFrameStyle
,
::
TimeDataFrameStyle
)
=
TimeDataFrameStyle
()
function
Base.copy
(
bc
::
Base
.
Broadcast
.
Broadcasted
{
TimeDataFrameStyle
})
ndim
=
length
(
axes
(
bc
))
if
ndim
!=
2
throw
(
DimensionMismatch
(
"cannot broadcast a time data frame into
$
ndim dimensions"
))
end
data
bcf
=
Base
.
Broadcast
.
flatten
(
bc
)
colnames
=
unique!
([
_names
(
df
)
for
df
in
bcf
.
args
if
df
isa
AbstractDataFrame
])
if
length
(
colnames
)
!=
1
wrongnames
=
setdiff
(
union
(
colnames
...
),
intersect
(
colnames
...
))
if
isempty
(
wrongnames
)
throw
(
ArgumentError
(
"Column names in broadcasted data frames "
*
"must have the same order"
))
else
msg
=
join
(
wrongnames
,
", "
,
" and "
)
throw
(
ArgumentError
(
"Column names in broadcasted data frames must match. "
*
"Non matching column names are
$
msg"
))
end
end
nrows
=
length
(
axes
(
bcf
)[
1
])
df
=
DataFrame
()
for
i
in
axes
(
bcf
)[
2
]
if
nrows
==
0
col
=
Any
[]
else
bcf′
=
getcolbc
(
bcf
,
i
)
v1
=
bcf′
[
CartesianIndex
(
1
,
i
)]
startcol
=
similar
(
Vector
{
typeof
(
v1
)},
nrows
)
startcol
[
1
]
=
v1
col
=
copyto_widen!
(
startcol
,
bcf′
,
2
,
i
)
end
df
[
!
,
colnames
[
1
][
i
]]
=
col
end
return
df
end
Base
.
ndims
(
::
TimeDataFrame
)
=
2
Base
.
ndims
(
::
Type
{
<:
TimeDataFrame
})
=
2
index
(
df
::
TimeDataFrame
)
=
getfield
(
getfield
(
df
,
:
data
),
:
colindex
)
...
...
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