@@ -13,27 +13,31 @@ def test_numpy_datatype_binding(conn_cnx, db_parameters):
1313    all_data  =  [{
1414        'tz' : 'America/Los_Angeles' ,
1515        'float' : '1.79769313486e+308' ,
16+         'numpy_bool' : np .True_ ,
1617        'epoch_time' : epoch_time ,
1718        'current_time' : current_datetime64 ,
1819        'specific_date' : np .datetime64 ('2005-02-25T03:30' ),
1920        'expected_specific_date' : np .datetime64 ('2005-02-25T03:30' ).astype (datetime .datetime )
2021    }, {
2122        'tz' : 'Asia/Tokyo' ,
2223        'float' : '-1.79769313486e+308' ,
24+         'numpy_bool' : np .False_ ,
2325        'epoch_time' : epoch_time ,
2426        'current_time' : current_datetime64 ,
2527        'specific_date' : np .datetime64 ('1970-12-31T05:00:00' ),
2628        'expected_specific_date' : np .datetime64 ('1970-12-31T05:00:00' ).astype (datetime .datetime )
2729    }, {
2830        'tz' : 'America/New_York' ,
2931        'float' : '-1.79769313486e+308' ,
32+         'numpy_bool' : np .True_ ,
3033        'epoch_time' : epoch_time ,
3134        'current_time' : current_datetime64 ,
3235        'specific_date' : np .datetime64 ('1969-12-31T05:00:00' ),
3336        'expected_specific_date' : np .datetime64 ('1969-12-31T05:00:00' ).astype (datetime .datetime )
3437    }, {
3538        'tz' : 'UTC' ,
3639        'float' : '-1.79769313486e+308' ,
40+         'numpy_bool' : np .False_ ,
3741        'epoch_time' : epoch_time ,
3842        'current_time' : current_datetime64 ,
3943        'specific_date' : np .datetime64 ('1968-11-12T07:00:00.123' ),
@@ -53,7 +57,8 @@ def test_numpy_datatype_binding(conn_cnx, db_parameters):
5357    c8  timestamp_ntz, -- datetime64 
5458    c9  date,          -- datetime64 
5559    c10 timestamp_ltz, -- datetime64, 
56-     c11 timestamp_tz)  -- datetime64 
60+     c11 timestamp_tz,  -- datetime64 
61+     c12 boolean)       -- numpy.bool_ 
5762            """ .format (name = db_parameters ['name' ]))
5863            for  data  in  all_data :
5964                cnx .cursor ().execute (""" 
@@ -70,7 +75,8 @@ def test_numpy_datatype_binding(conn_cnx, db_parameters):
7075    c8, 
7176    c9, 
7277    c10, 
73-     c11 
78+     c11, 
79+     c12 
7480) 
7581VALUES( 
7682    %s, 
@@ -83,6 +89,7 @@ def test_numpy_datatype_binding(conn_cnx, db_parameters):
8389    %s, 
8490    %s, 
8591    %s, 
92+     %s, 
8693    %s)""" .format (
8794                    name = db_parameters ['name' ]), (
8895                    np .iinfo (np .int8 ).max ,
@@ -96,6 +103,7 @@ def test_numpy_datatype_binding(conn_cnx, db_parameters):
96103                    data ['current_time' ],
97104                    data ['current_time' ],
98105                    data ['specific_date' ],
106+                     data ['numpy_bool' ]
99107                ))
100108                rec  =  cnx .cursor ().execute (""" 
101109SELECT 
@@ -109,7 +117,8 @@ def test_numpy_datatype_binding(conn_cnx, db_parameters):
109117       c8, 
110118       c9, 
111119       c10, 
112-        c11 
120+        c11, 
121+        c12 
113122  FROM {name}""" .format (
114123                    name = db_parameters ['name' ])).fetchone ()
115124                assert  np .int8 (rec [0 ]) ==  np .iinfo (np .int8 ).max 
@@ -123,6 +132,7 @@ def test_numpy_datatype_binding(conn_cnx, db_parameters):
123132                assert  str (rec [8 ]) ==  str (data ['current_time' ])[0 :10 ]
124133                assert  rec [9 ] ==  datetime .datetime .fromtimestamp (epoch_time , rec [9 ].tzinfo )
125134                assert  rec [10 ] ==  data ['expected_specific_date' ].replace (tzinfo = rec [10 ].tzinfo )
135+                 assert  isinstance (rec [11 ], bool ) and  rec [11 ] ==  data ['numpy_bool' ] and  np .bool_ (rec [11 ]) ==  data ['numpy_bool' ]
126136                cnx .cursor ().execute (""" 
127137DELETE FROM {name}""" .format (name = db_parameters ['name' ]))
128138    finally :
0 commit comments