Skip to content

Commit

Permalink
Merge pull request #44 from bankofcanada/dev
Browse files Browse the repository at this point in the history
Dev towards v0.6.2
  • Loading branch information
bbejanov authored Oct 31, 2023
2 parents 515c9a4 + f47459e commit 7bffcef
Show file tree
Hide file tree
Showing 16 changed files with 796 additions and 384 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,7 @@ Manifest.toml
coverage
*.cov

*.mem

docs/build
docs/Manifest.toml
5 changes: 3 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "TimeSeriesEcon"
uuid = "8b6756d2-c55c-11ea-2998-5f67ea17da60"
authors = ["Atai Akunov <[email protected]>", "Boyan Bejanov <[email protected]>", "Nicholas Labelle St-Pierre <[email protected]>"]
version = "0.6.1"
version = "0.6.2"

[deps]
CEnum = "fa961155-64e5-5f13-b03f-caf6b980ea82"
Expand All @@ -11,6 +11,7 @@ Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
MacroTools = "1914dd2f-81c6-5fcd-8719-6d5c9610ff09"
OrderedCollections = "bac558e1-5e72-5ebc-8fee-abe8a469f55d"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01"
Serialization = "9e88b42a-f829-5b0c-bbe9-9e923198166b"
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
Expand All @@ -19,7 +20,7 @@ TOML = "fa267f1f-6049-4f14-aa54-33bafae1ed76"

[compat]
CEnum = "0.4"
DataEcon_jll = "0.2.2"
DataEcon_jll = "0.3.1"
MacroTools = "0.5"
OrderedCollections = "1.4"
RecipesBase = "1.0"
Expand Down
206 changes: 130 additions & 76 deletions src/dataecon/C.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ export DataEcon_jll

using CEnum

function de_version()
ccall((:de_version, libdaec), Ptr{Cchar}, ())
end

function de_error(msg, len)
ccall((:de_error, libdaec), Cint, (Ptr{Cchar}, Csize_t), msg, len)
end
Expand All @@ -23,18 +27,24 @@ end
DE_BAD_AXIS_TYPE = -999
DE_BAD_CLASS = -998
DE_BAD_TYPE = -997
DE_BAD_NAME = -996
DE_SHORT_BUF = -995
DE_OBJ_DNE = -994
DE_AXIS_DNE = -993
DE_ARG = -992
DE_NO_OBJ = -991
DE_EXISTS = -990
DE_BAD_OBJ = -989
DE_NULL = -988
DE_DEL_ROOT = -987
DE_MIS_ATTR = -986
DE_INTERNAL = -985
DE_BAD_ELTYPE = -996
DE_BAD_ELTYPE_NONE = -995
DE_BAD_ELTYPE_DATE = -994
DE_BAD_NAME = -993
DE_BAD_FREQ = -992
DE_SHORT_BUF = -991
DE_OBJ_DNE = -990
DE_AXIS_DNE = -989
DE_ARG = -988
DE_NO_OBJ = -987
DE_EXISTS = -986
DE_BAD_OBJ = -985
DE_NULL = -984
DE_DEL_ROOT = -983
DE_MIS_ATTR = -982
DE_INEXACT = -981
DE_RANGE = -980
DE_INTERNAL = -979
end

const de_file = Ptr{Cvoid}
Expand All @@ -43,6 +53,14 @@ function de_open(fname, de)
ccall((:de_open, libdaec), Cint, (Ptr{Cchar}, Ptr{de_file}), fname, de)
end

function de_open_readonly(fname, de)
ccall((:de_open_readonly, libdaec), Cint, (Ptr{Cchar}, Ptr{de_file}), fname, de)
end

function de_open_memory(pde)
ccall((:de_open_memory, libdaec), Cint, (Ptr{de_file},), pde)
end

function de_close(de)
ccall((:de_close, libdaec), Cint, (de_file,), de)
end
Expand Down Expand Up @@ -81,70 +99,13 @@ end
type_any = -1
end

@cenum frequency_t::UInt32 begin
freq_none = 0
freq_unit = 1
freq_daily = 4
freq_bdaily = 5
freq_monthly = 8
freq_weekly = 16
freq_weekly_sun0 = 16
freq_weekly_mon = 17
freq_weekly_tue = 18
freq_weekly_wed = 19
freq_weekly_thu = 20
freq_weekly_fri = 21
freq_weekly_sat = 22
freq_weekly_sun7 = 23
freq_weekly_sun = 23
freq_quarterly = 32
freq_quarterly_jan = 33
freq_quarterly_feb = 34
freq_quarterly_mar = 35
freq_quarterly_apr = 33
freq_quarterly_may = 34
freq_quarterly_jun = 35
freq_quarterly_jul = 33
freq_quarterly_aug = 34
freq_quarterly_sep = 35
freq_quarterly_oct = 33
freq_quarterly_nov = 34
freq_quarterly_dec = 35
freq_halfyearly = 64
freq_halfyearly_jan = 65
freq_halfyearly_feb = 66
freq_halfyearly_mar = 67
freq_halfyearly_apr = 68
freq_halfyearly_may = 69
freq_halfyearly_jun = 70
freq_halfyearly_jul = 65
freq_halfyearly_aug = 66
freq_halfyearly_sep = 67
freq_halfyearly_oct = 68
freq_halfyearly_nov = 69
freq_halfyearly_dec = 70
freq_yearly = 128
freq_yearly_jan = 129
freq_yearly_feb = 130
freq_yearly_mar = 131
freq_yearly_apr = 132
freq_yearly_may = 133
freq_yearly_jun = 134
freq_yearly_jul = 135
freq_yearly_aug = 136
freq_yearly_sep = 137
freq_yearly_oct = 138
freq_yearly_nov = 139
freq_yearly_dec = 140
end

const obj_id_t = Int64

struct object_t
id::obj_id_t
pid::obj_id_t
class::class_t
type::type_t
obj_class::class_t
obj_type::type_t
name::Ptr{Cchar}
end

Expand Down Expand Up @@ -180,10 +141,89 @@ function de_find_fullpath(de, fullpath, id)
ccall((:de_find_fullpath, libdaec), Cint, (de_file, Ptr{Cchar}, Ptr{obj_id_t}), de, fullpath, id)
end

function de_catalog_size(de, pid, count)
ccall((:de_catalog_size, libdaec), Cint, (de_file, obj_id_t, Ptr{Int64}), de, pid, count)
end

function de_new_catalog(de, pid, name, id)
ccall((:de_new_catalog, libdaec), Cint, (de_file, obj_id_t, Ptr{Cchar}, Ptr{obj_id_t}), de, pid, name, id)
end

@cenum frequency_t::UInt32 begin
freq_none = 0
freq_unit = 11
freq_daily = 12
freq_bdaily = 13
freq_weekly = 16
freq_weekly_sun0 = 16
freq_weekly_mon = 17
freq_weekly_tue = 18
freq_weekly_wed = 19
freq_weekly_thu = 20
freq_weekly_fri = 21
freq_weekly_sat = 22
freq_weekly_sun7 = 23
freq_weekly_sun = 23
freq_monthly = 32
freq_quarterly = 64
freq_quarterly_jan = 65
freq_quarterly_feb = 66
freq_quarterly_mar = 67
freq_quarterly_apr = 65
freq_quarterly_may = 66
freq_quarterly_jun = 67
freq_quarterly_jul = 65
freq_quarterly_aug = 66
freq_quarterly_sep = 67
freq_quarterly_oct = 65
freq_quarterly_nov = 66
freq_quarterly_dec = 67
freq_halfyearly = 128
freq_halfyearly_jan = 129
freq_halfyearly_feb = 130
freq_halfyearly_mar = 131
freq_halfyearly_apr = 132
freq_halfyearly_may = 133
freq_halfyearly_jun = 134
freq_halfyearly_jul = 129
freq_halfyearly_aug = 130
freq_halfyearly_sep = 131
freq_halfyearly_oct = 132
freq_halfyearly_nov = 133
freq_halfyearly_dec = 134
freq_yearly = 256
freq_yearly_jan = 257
freq_yearly_feb = 258
freq_yearly_mar = 259
freq_yearly_apr = 260
freq_yearly_may = 261
freq_yearly_jun = 262
freq_yearly_jul = 263
freq_yearly_aug = 264
freq_yearly_sep = 265
freq_yearly_oct = 266
freq_yearly_nov = 267
freq_yearly_dec = 268
end

const date_t = Int64

function de_pack_year_period_date(freq, year, period, date)
ccall((:de_pack_year_period_date, libdaec), Cint, (frequency_t, Int32, UInt32, Ptr{date_t}), freq, year, period, date)
end

function de_unpack_year_period_date(freq, date, year, period)
ccall((:de_unpack_year_period_date, libdaec), Cint, (frequency_t, date_t, Ptr{Int32}, Ptr{UInt32}), freq, date, year, period)
end

function de_pack_calendar_date(freq, year, month, day, date)
ccall((:de_pack_calendar_date, libdaec), Cint, (frequency_t, Int32, UInt32, UInt32, Ptr{date_t}), freq, year, month, day, date)
end

function de_unpack_calendar_date(freq, date, year, month, day)
ccall((:de_unpack_calendar_date, libdaec), Cint, (frequency_t, date_t, Ptr{Int32}, Ptr{UInt32}, Ptr{UInt32}), freq, date, year, month, day)
end

struct scalar_t
object::object_t
frequency::frequency_t
Expand All @@ -209,7 +249,7 @@ end

struct axis_t
id::axis_id_t
type::axis_type_t
ax_type::axis_type_t
length::Int64
frequency::frequency_t
first::Int64
Expand All @@ -235,15 +275,16 @@ end
struct tseries_t
object::object_t
eltype::type_t
elfreq::frequency_t
axis::axis_t
nbytes::Int64
value::Ptr{Cvoid}
end

const vector_t = tseries_t

function de_store_tseries(de, pid, name, type, eltype, axis_id, nbytes, value, id)
ccall((:de_store_tseries, libdaec), Cint, (de_file, obj_id_t, Ptr{Cchar}, type_t, type_t, axis_id_t, Int64, Ptr{Cvoid}, Ptr{obj_id_t}), de, pid, name, type, eltype, axis_id, nbytes, value, id)
function de_store_tseries(de, pid, name, type, eltype, elfreq, axis_id, nbytes, value, id)
ccall((:de_store_tseries, libdaec), Cint, (de_file, obj_id_t, Ptr{Cchar}, type_t, type_t, frequency_t, axis_id_t, Int64, Ptr{Cvoid}, Ptr{obj_id_t}), de, pid, name, type, eltype, elfreq, axis_id, nbytes, value, id)
end

function de_load_tseries(de, id, tseries)
Expand All @@ -253,6 +294,7 @@ end
struct mvtseries_t
object::object_t
eltype::type_t
elfreq::frequency_t
axis1::axis_t
axis2::axis_t
nbytes::Int64
Expand All @@ -261,8 +303,8 @@ end

const matrix_t = mvtseries_t

function de_store_mvtseries(de, pid, name, type, eltype, axis1_id, axis2_id, nbytes, value, id)
ccall((:de_store_mvtseries, libdaec), Cint, (de_file, obj_id_t, Ptr{Cchar}, type_t, type_t, axis_id_t, axis_id_t, Int64, Ptr{Cvoid}, Ptr{obj_id_t}), de, pid, name, type, eltype, axis1_id, axis2_id, nbytes, value, id)
function de_store_mvtseries(de, pid, name, type, eltype, elfreq, axis1_id, axis2_id, nbytes, value, id)
ccall((:de_store_mvtseries, libdaec), Cint, (de_file, obj_id_t, Ptr{Cchar}, type_t, type_t, frequency_t, axis_id_t, axis_id_t, Int64, Ptr{Cvoid}, Ptr{obj_id_t}), de, pid, name, type, eltype, elfreq, axis1_id, axis2_id, nbytes, value, id)
end

function de_load_mvtseries(de, id, mvtseries)
Expand Down Expand Up @@ -295,4 +337,16 @@ function de_finalize_search(search)
ccall((:de_finalize_search, libdaec), Cint, (de_search,), search)
end

const DE_VERSION = "0.3.1"

const DE_VERNUM = 0x0310

const DE_VER_MAJOR = 0

const DE_VER_MINOR = 3

const DE_VER_REVISION = 1

const DE_VER_SUBREVISION = 0

end # module
Loading

0 comments on commit 7bffcef

Please sign in to comment.