Skip to content

Commit 633e245

Browse files
committed
integer evaluation now requires sign to be in position 0
1 parent 9a8f03b commit 633e245

File tree

2 files changed

+40
-1
lines changed

2 files changed

+40
-1
lines changed

src/_arraykit.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -714,8 +714,10 @@ AK_TP_resolve_field(AK_TypeParser* tp,
714714
if (tp->count_digit == 0) return TPS_STRING;
715715
// int
716716
if (tp->count_j == 0 &&
717-
tp->count_e == 0 &&
717+
tp->count_sign <= 1 &&
718+
tp->last_sign_pos <= 0 &&
718719
tp->count_decimal == 0 &&
720+
tp->count_e == 0 &&
719721
tp->count_paren_close == 0 &&
720722
tp->count_paren_open == 0 &&
721723
tp->count_nan == 0 &&

test/test_delimited_to_arrays.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ def test_iterable_str_to_array_1d_int_13(self) -> None:
156156
with self.assertRaises(TypeError):
157157
a1 = iterable_str_to_array_1d(['3.000', '4.000', '1.000'], dtype=int, thousandschar=',')
158158

159+
159160
#---------------------------------------------------------------------------
160161

161162
def test_iterable_str_to_array_1d_uint_1(self) -> None:
@@ -703,6 +704,42 @@ def test_delimited_to_arrays_parse_i(self) -> None:
703704
post2 = delimited_to_arrays(msg, axis=1, skipinitialspace=True)
704705
self.assertEqual([a.tolist() for a in post2], [['a', 'b'], [10, 20], ['foo', 'c']])
705706

707+
def test_delimited_to_arrays_parse_j(self) -> None:
708+
msg = [
709+
'2021,2021-04-01,4',
710+
'2022,2022-05-01,3',
711+
]
712+
post1 = delimited_to_arrays(msg, axis=1, skipinitialspace=False)
713+
self.assertEqual([a.tolist() for a in post1], [[2021, 2022], ['2021-04-01', '2022-05-01'], [4, 3]])
714+
715+
716+
def test_delimited_to_arrays_parse_k(self) -> None:
717+
msg = [
718+
'2021,2021-04,4',
719+
'2022,2022-05,3',
720+
]
721+
post1 = delimited_to_arrays(msg, axis=1, skipinitialspace=False)
722+
self.assertEqual([a.tolist() for a in post1], [[2021, 2022], ['2021-04', '2022-05'], [4, 3]])
723+
724+
725+
def test_delimited_to_arrays_parse_l(self) -> None:
726+
msg = [
727+
'1,2,3',
728+
'2-,2-0,-3',
729+
]
730+
post1 = delimited_to_arrays(msg, axis=1, skipinitialspace=False)
731+
self.assertEqual([a.tolist() for a in post1], [['1', '2-'], ['2', '2-0'], [3, -3]])
732+
733+
def test_delimited_to_arrays_parse_m(self) -> None:
734+
msg = [
735+
' 1, 2,3',
736+
' 2-, 2-0, -3',
737+
]
738+
post1 = delimited_to_arrays(msg, axis=1, skipinitialspace=False)
739+
self.assertEqual([a.tolist() for a in post1], [[' 1', ' 2-'], [' 2', ' 2-0'], [3, -3]])
740+
741+
742+
# import ipdb; ipdb.set_trace()
706743

707744
#---------------------------------------------------------------------------
708745
def test_delimited_to_arrays_float_a(self) -> None:

0 commit comments

Comments
 (0)