Skip to content

Commit cd9addf

Browse files
committed
added dtype argument to LArray to set the type of the array explicitly instead of relying on auto-detection
1 parent 8ca0bd8 commit cd9addf

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

doc/source/changes/version_0_30.rst.inc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.. py:currentmodule:: larray
1+
.. py:currentmodule:: larray
22

33

44
Syntax changes
@@ -222,6 +222,8 @@ Miscellaneous improvements
222222
* renamed `a_min` and `a_max` arguments of :py:obj:`LArray.clip()` as `minval` and `maxval` respectively
223223
and made them optional (closes :issue:`747`).
224224

225+
* added dtype argument to LArray to set the type of the array explicitly instead of relying on auto-detection.
226+
225227
* implemented :py:obj:`LArray.reverse()` method to reverse one or several axes of an array (closes :issue:`631`).
226228

227229
* added :py:obj:`set_options` allowing to set options for larray within a ``with`` block or globally:

larray/core/array.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -578,6 +578,8 @@ class LArray(ABCLArray):
578578
meta : list of pairs or dict or OrderedDict or Metadata, optional
579579
Metadata (title, description, author, creation_date, ...) associated with the array.
580580
Keys must be strings. Values must be of type string, int, float, date, time or datetime.
581+
dtype : type, optional
582+
Datatype for the array. Defaults to None (inferred from the data).
581583
582584
Attributes
583585
----------
@@ -656,8 +658,8 @@ class LArray(ABCLArray):
656658
F 10 11 12
657659
"""
658660

659-
def __init__(self, data, axes=None, title=None, meta=None):
660-
data = np.asarray(data)
661+
def __init__(self, data, axes=None, title=None, meta=None, dtype=None):
662+
data = np.asarray(data, dtype=dtype)
661663
ndim = data.ndim
662664
if axes is None:
663665
axes = AxisCollection(data.shape)

0 commit comments

Comments
 (0)