Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove dtypes.int_/float_/int_array/float_array to eliminate confusion #5580

Merged
merged 2 commits into from
Jun 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions py/server/deephaven/csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ def read(
dht.byte: _JParsers.BYTE,
dht.char: _JParsers.CHAR,
dht.short: _JParsers.SHORT,
dht.int_: _JParsers.INT,
dht.int64: _JParsers.INT,
dht.long: _JParsers.LONG,
dht.float_: _JParsers.FLOAT_FAST,
dht.float64: _JParsers.FLOAT_FAST,
dht.double: _JParsers.DOUBLE,
dht.string: _JParsers.STRING,
dht.Instant: _JParsers.DATETIME,
Expand Down
8 changes: 0 additions & 8 deletions py/server/deephaven/dtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,6 @@ def __call__(self, *args, **kwargs):
"""Signed 64bit integer type"""
int64 = long
"""Signed 64bit integer type"""
int_ = long
"""Signed 64bit integer type"""
float32 = DType(j_name="float", qst_type=_JQstType.floatType(), is_primitive=True, np_type=np.float32)
"""Single-precision floating-point number type"""
single = float32
Expand All @@ -95,8 +93,6 @@ def __call__(self, *args, **kwargs):
"""Double-precision floating-point number type"""
double = float64
"""Double-precision floating-point number type"""
float_ = float64
"""Double-precision floating-point number type"""
string = DType(j_name="java.lang.String", qst_type=_JQstType.stringType(), np_type=np.str_)
"""String type"""
Character = DType(j_name="java.lang.Character")
Expand Down Expand Up @@ -143,8 +139,6 @@ def __call__(self, *args, **kwargs):
"""64bit integer array type"""
int64_array = long_array
"""64bit integer array type"""
int_array = long_array
"""64bit integer array type"""
single_array = DType(j_name='[F')
"""Single-precision floating-point array type"""
float32_array = single_array
Expand All @@ -153,8 +147,6 @@ def __call__(self, *args, **kwargs):
"""Double-precision floating-point array type"""
float64_array = double_array
"""Double-precision floating-point array type"""
float_array = double_array
"""Double-precision floating-point array type"""
string_array = DType(j_name='[Ljava.lang.String;')
"""Java String array type"""
boolean_array = DType(j_name='[Ljava.lang.Boolean;')
Expand Down
3 changes: 1 addition & 2 deletions py/server/deephaven/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,9 @@
from __future__ import annotations

from enum import Enum
from typing import List, Union
from typing import List, Union, Sequence

import jpy
import functools

from deephaven import DHError
from deephaven._wrapper import JObjectWrapper
Expand Down
2 changes: 1 addition & 1 deletion py/server/tests/test_column.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def get_x(i) -> int:
t_func = empty_table(n).update(["X = get_x(i)"])
# We want to test that casting on both PyObject and JObject works as expected.
self.assertEqual(t_list.columns[0].data_type, dtypes.PyObject)
self.assertEqual(t_func.columns[0].data_type, dtypes.int_)
self.assertEqual(t_func.columns[0].data_type, dtypes.int64)
t_func_str = t_func.to_string()
for v in x:
self.assertIn(str(int(v)), t_func_str)
Expand Down
8 changes: 4 additions & 4 deletions py/server/tests/test_csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@ def test_read_simple(self):

def test_read_header(self):
col_names = ["Strings", "Longs", "Floats"]
col_types = [dtypes.string, dtypes.long, dtypes.float_]
col_types = [dtypes.string, dtypes.long, dtypes.float64]
table_header = {k: v for k, v in zip(col_names, col_types)}
t = read_csv('tests/data/test_csv.csv', header=table_header)
t_col_names = [col.name for col in t.columns]
self.assertEqual(col_names, t_col_names)

def test_read_error_col_type(self):
col_names = ["Strings", "Longs", "Floats"]
col_types = [dtypes.string, dtypes.float_, dtypes.long]
col_types = [dtypes.string, dtypes.float64, dtypes.long]
table_header = {k: v for k, v in zip(col_names, col_types)}
with self.assertRaises(DHError) as cm:
t = read_csv('tests/data/test_csv.csv', header=table_header)
Expand All @@ -33,7 +33,7 @@ def test_read_error_col_type(self):

def test_read_error_quote(self):
col_names = ["Strings", "Longs", "Floats"]
col_types = [dtypes.string, dtypes.long, dtypes.float_]
col_types = [dtypes.string, dtypes.long, dtypes.float64]
table_header = {k: v for k, v in zip(col_names, col_types)}
with self.assertRaises(DHError) as cm:
t = read_csv('tests/data/test_csv.csv', header=table_header, quote=",")
Expand All @@ -48,7 +48,7 @@ def test_write(self):
self.assertEqual(t_cols, [col.name for col in t.columns])

col_names = ["Strings", "Longs", "Floats"]
col_types = [dtypes.string, dtypes.long, dtypes.float_]
col_types = [dtypes.string, dtypes.long, dtypes.float64]
table_header = {k: v for k, v in zip(col_names, col_types)}
t = read_csv('tests/data/test_csv.csv', header=table_header)
write_csv(t, "./test_write.csv", cols=col_names)
Expand Down
18 changes: 9 additions & 9 deletions py/server/tests/test_dtypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,20 @@ class DTypesTestCase(BaseTestCase):
def test_type_alias(self):
self.assertEqual(dtypes.byte, dtypes.int8)
self.assertEqual(dtypes.short, dtypes.int16)
self.assertEqual(dtypes.int_, dtypes.int64)
self.assertEqual(dtypes.int64, dtypes.int64)
self.assertEqual(dtypes.long, dtypes.int64)
self.assertEqual(dtypes.float_, dtypes.double)
self.assertEqual(dtypes.float_, dtypes.float64)
self.assertEqual(dtypes.float64, dtypes.double)
self.assertEqual(dtypes.float64, dtypes.float64)
self.assertEqual(dtypes.double, dtypes.float64)

def test_j_type(self):
self.assertEqual(dtypes.bool_.j_type, jpy.get_type("java.lang.Boolean"))
self.assertEqual(dtypes.byte.j_type, jpy.get_type("byte"))
self.assertEqual(dtypes.short.j_type, jpy.get_type("short"))
self.assertEqual(dtypes.char.j_type, jpy.get_type("char"))
self.assertEqual(dtypes.int_.j_type, jpy.get_type("long"))
self.assertEqual(dtypes.int64.j_type, jpy.get_type("long"))
self.assertEqual(dtypes.long.j_type, jpy.get_type("long"))
self.assertEqual(dtypes.float_.j_type, jpy.get_type("double"))
self.assertEqual(dtypes.float64.j_type, jpy.get_type("double"))
self.assertEqual(dtypes.double.j_type, jpy.get_type("double"))
self.assertEqual(dtypes.string.j_type, jpy.get_type("java.lang.String"))
self.assertEqual(dtypes.BigDecimal.j_type, jpy.get_type("java.math.BigDecimal"))
Expand All @@ -65,9 +65,9 @@ def test_np_type(self):
self.assertEqual(dtypes.byte.np_type, np.int8)
self.assertEqual(dtypes.short.np_type, np.int16)
self.assertEqual(dtypes.char.np_type, np.dtype('uint16'))
self.assertEqual(dtypes.int_.np_type, np.int64)
self.assertEqual(dtypes.int64.np_type, np.int64)
self.assertEqual(dtypes.long.np_type, np.int64)
self.assertEqual(dtypes.float_.np_type, np.float64)
self.assertEqual(dtypes.float64.np_type, np.float64)
self.assertEqual(dtypes.double.np_type, np.float64)
self.assertEqual(dtypes.string.np_type, np.str_)
self.assertEqual(dtypes.BigDecimal.np_type, np.object_)
Expand Down Expand Up @@ -95,7 +95,7 @@ def test_callable(self):
self.assertEqual(j_string.toString(), "abc")

def test_array(self):
j_array = dtypes.array(dtypes.int_, range(5))
j_array = dtypes.array(dtypes.int64, range(5))
np_array = np.frombuffer(j_array, np.int64)
expected = np.array([0, 1, 2, 3, 4], dtype=np.int64)
self.assertTrue(np.array_equal(np_array, expected))
Expand Down Expand Up @@ -136,7 +136,7 @@ def test_integer_array(self):

def test_floating_array(self):

nulls = {dtypes.float_: NULL_FLOAT, dtypes.double: NULL_DOUBLE}
nulls = {dtypes.float64: NULL_FLOAT, dtypes.double: NULL_DOUBLE}

np_array = np.array([float('nan'), 1.7976931348623157e+300, NULL_DOUBLE, 1.1, float('inf')], dtype=np.float64)
for dt, nv in nulls.items():
Expand Down
10 changes: 5 additions & 5 deletions py/server/tests/test_kafka_consumer.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def test_json_spec(self):
col_defs=[('Symbol', dtypes.string),
('Side', dtypes.string),
('Price', dtypes.double),
('Qty', dtypes.int_),
('Qty', dtypes.int64),
('Tstamp', dtypes.Instant)],
mapping={
'jsymbol': 'Symbol',
Expand All @@ -70,7 +70,7 @@ def test_json_spec(self):
'Symbol': dtypes.string,
'Side': dtypes.string,
'Price': dtypes.double,
'Qty': dtypes.int_,
'Qty': dtypes.int64,
'Tstamp': dtypes.Instant
},
mapping={
Expand Down Expand Up @@ -102,7 +102,7 @@ def test_json_spec(self):
self.assertEqual("Price", cols[5].name)
self.assertEqual(dtypes.double, cols[5].data_type)
self.assertEqual("Qty", cols[6].name)
self.assertEqual(dtypes.int_, cols[6].data_type)
self.assertEqual(dtypes.int64, cols[6].data_type)
self.assertEqual("Tstamp", cols[7].name)
self.assertEqual(dtypes.Instant, cols[7].data_type)

Expand Down Expand Up @@ -344,7 +344,7 @@ def test_json_spec_partitioned_table(self):
[('Symbol', dtypes.string),
('Side', dtypes.string),
('Price', dtypes.double),
('Qty', dtypes.int_),
('Qty', dtypes.int64),
('Tstamp', dtypes.Instant)],
mapping={
'jsymbol': 'Symbol',
Expand All @@ -368,7 +368,7 @@ def test_json_spec_partitioned_table(self):
self.assertEqual("Price", cols[5].name)
self.assertEqual(dtypes.double, cols[5].data_type)
self.assertEqual("Qty", cols[6].name)
self.assertEqual(dtypes.int_, cols[6].data_type)
self.assertEqual(dtypes.int64, cols[6].data_type)
self.assertEqual("Tstamp", cols[7].name)
self.assertEqual(dtypes.Instant, cols[7].data_type)

Expand Down
4 changes: 2 additions & 2 deletions py/server/tests/test_udf_scalar_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ def f2(x: float) -> Optional[int]:
...

t = empty_table(1).update("X = f2(f1(ii))")
self.assertEqual(t.columns[0].data_type, dtypes.int_)
self.assertEqual(t.columns[0].data_type, dtypes.int64)

with self.subTest("jpy.JType"):
def f1(x: jpy.JType) -> bool:
Expand Down Expand Up @@ -594,7 +594,7 @@ def use_c(c: Sequence) -> int:

t = empty_table(3).update(["C = make_c()", "V = use_c(C)"])
self.assertIsNotNone(t)
self.assertEqual(t.columns[1].data_type, dtypes.int_)
self.assertEqual(t.columns[1].data_type, dtypes.int64)

def misuse_c(c: int) -> int:
return c
Expand Down
Loading