8000 minor cleanups, added one FIXME · larray-project/larray@972418e · GitHub
[go: up one dir, main page]

Skip to content

Commit 972418e

Browse files
committed
minor cleanups, added one FIXME
1 parent 92fe417 commit 972418e

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

larray.py

Copy file name to clipboard
Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ def range_to_slice(seq):
327327

328328
def larray_equal(first, other):
329329
return (first.axes == other.axes and
330-
np.array_equal(np.asarray(first), np.asarray(other)))
330+
np.array_equal(first.asarray(), other.asarray()))
331331

332332

333333
class Axis(object):
@@ -498,7 +498,7 @@ def __repr__(self):
498498

499499
def unaryop(opname):
500500
def func(self):
501-
method = getattr(np.asarray(self), '__%s__' % opname)
501+
method = getattr(self.asarray(), '__%s__' % opname)
502502
return LArray(method(), self.axes)
503503
return func
504504

@@ -717,7 +717,7 @@ def as_table(self):
717717
# result[1].append('total')
718718
else:
719719
result = []
720-
data = np.asarray(self).ravel()
720+
data = self.asarray().ravel()
721721
if axes_labels is not None:
722722
categ_values = list(product(*axes_labels[:-1]))
723723
else:
@@ -756,7 +756,7 @@ def _axis_aggregate(self, op, axes):
756756
op is an aggregate function: func(arr, axis=(0, 1))
757757
axes is a tuple of axes (Axis objects or integers)
758758
"""
759-
src_data = np.asarray(self)
759+
src_data = self.asarray()
760760
if not axes:
761761
# scalars do not need to be wrapped in LArray
762762
return op(src_data)
@@ -850,6 +850,7 @@ def _group_aggregate(self, op, kwargs, commutative=False):
850850
del arr
851851
if killaxis:
852852
assert group_idx[agg_axis_idx] == 0
853+
#FIXME: if this is the only axis, it will break
853854
res_data = res_data[group_idx]
854855
res = LArray(res_data, res_axes)
855856

@@ -917,9 +918,9 @@ def to_excel(self, filename, sep=None):
917918
worksheet = workbook.add_worksheet('Sheet1')
918919
worksheet.write_row(0, 1, self.axes[-1].labels)
919920
if self.ndim == 2:
920-
worksheet.write_column(1, 0, self.axes[-2].labels)
921-
for row, data in enumerate(np.asarray(self)):
922-
worksheet.write_row(1+row, 1, data)
921+
worksheet.write_column(1, 0, self.axes[-2].labels)
922+
for row, data in enumerate(self.asarray()):
923+
worksheet.write_row(1 + row, 1, data)
923924

924925
def transpose(self, *args):
925926
axes_names = set(axis.name for axis in args)

0 commit comments

Comments
 (0)
0