File tree Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Expand file tree Collapse file tree 1 file changed +12
-0
lines changed Original file line number Diff line number Diff line change 4
4
CondaPkg. add (" numpy" )
5
5
6
6
td = pyimport (" numpy" ). timedelta64
7
+ get_unit (x) = pyconvert (String, pyimport (" numpy" ). datetime_data (x)[0 ])
7
8
@testset for x in [
8
9
- 1_000_000_000 ,
9
10
- 1_000_000 ,
30
31
y2 = pytimedelta64 (Unit (x))
31
32
@test pyeq (Bool, y, y2)
32
33
@test pyeq (Bool, y, td (x, " $pyunit " ))
34
+ @test get_unit (y) == " $pyunit "
35
+ @test get_unit (y2) == " $pyunit "
33
36
end
37
+ x = pytimedelta64 (Second (60 ))
38
+ @test get_unit (x) == " s"
39
+ x = pytimedelta64 (Second (60 ); canonicalize = true )
40
+ @test get_unit (x) == " m"
41
+
42
+ PythonCall. Convert. CANONICALIZE_TIMEDELTA64[] = true
43
+ @test pyconvert (Dates. CompoundPeriod, pytimedelta64 (Second (60 )),). periods[1 ] isa Minute
44
+ PythonCall. Convert. CANONICALIZE_TIMEDELTA64[] = false
45
+ @test pyconvert (Dates. CompoundPeriod, pytimedelta64 (Second (60 )),). periods[1 ] isa Second
34
46
end
35
47
36
48
@testitem " datetime64" begin
You can’t perform that action at this time.
0 commit comments