diff --git a/doc/source/changes/version_0_26.rst.inc b/doc/source/changes/version_0_26.rst.inc index 4cba8336c..01fd7d33a 100644 --- a/doc/source/changes/version_0_26.rst.inc +++ b/doc/source/changes/version_0_26.rst.inc @@ -267,6 +267,18 @@ Miscellaneous improvements * allowed passing an axis to `set_labels` as 'labels' argument (closes :issue:`408`). +* added data type (dtype) to array.info (closes :issue:`454`): + + >>> arr = ndtest((2, 2), dtype=float) + >>> arr + a\b b0 b1 + a0 0.0 1.0 + a1 2.0 3.0 + >>> arr.info + 2 x 2 + a [2]: 'a0' 'a1' + b [2]: 'b0' 'b1' + dtype: float64 Fixes ----- diff --git a/larray/core/array.py b/larray/core/array.py index e92791c95..dad55837c 100644 --- a/larray/core/array.py +++ b/larray/core/array.py @@ -3211,17 +3211,19 @@ def info(self): 2 x 2 nat [2]: 'BE' 'FO' sex [2]: 'M' 'F' + dtype: float64 >>> mat1 = LArray(np.ones((2, 2)), [nat, sex], 'test matrix') >>> mat1.info test matrix 2 x 2 nat [2]: 'BE' 'FO' sex [2]: 'M' 'F' + dtype: float64 """ if self.title: - return ReprString(self.title + '\n' + self.axes.info) + return ReprString(self.title + '\n' + self.axes.info + '\ndtype: ' + self.dtype.name) else: - return self.axes.info + return ReprString(self.axes.info + '\ndtype: ' + self.dtype.name) def ratio(self, *axes): """Returns an array with all values divided by the sum of values along given axes. diff --git a/larray/core/session.py b/larray/core/session.py index 06c3e67bb..f9cb6f4f9 100644 --- a/larray/core/session.py +++ b/larray/core/session.py @@ -624,12 +624,15 @@ def items(self): ... print("{}: {}".format(k, v.info)) arr2: 4 a [4]: 'a0' 'a1' 'a2' 'a3' + dtype: int64 arr1: 2 x 2 a [2]: 'a0' 'a1' b [2]: 'b0' 'b1' + dtype: int64 arr3: 3 x 2 a [3]: 'a0' 'a1' 'a2' b [2]: 'b0' 'b1' + dtype: int64 """ return self._objects.items() diff --git a/larray/tests/test_array.py b/larray/tests/test_array.py index 9a1fb215b..bed56917d 100644 --- a/larray/tests/test_array.py +++ b/larray/tests/test_array.py @@ -164,7 +164,8 @@ def test_info(self): age [116]: 0 1 2 ... 113 114 115 geo [44]: 'A11' 'A12' 'A13' ... 'A92' 'A93' 'A21' sex [2]: 'M' 'F' - lipro [15]: 'P01' 'P02' 'P03' ... 'P13' 'P14' 'P15'""" + lipro [15]: 'P01' 'P02' 'P03' ... 'P13' 'P14' 'P15' +dtype: float64""" self.assertEqual(self.larray.info, expected) def test_str(self):