Skip to content

Commit

Permalink
fix numpy str
Browse files Browse the repository at this point in the history
  • Loading branch information
hanjinliu committed Jun 21, 2024
1 parent fec3728 commit 9c23ca6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
4 changes: 3 additions & 1 deletion tabulous/_qt/_table/_base/_table_wrappers.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ def __init__(
_layout.addWidget(sizegrip, False, Qt.AlignmentFlag.AlignRight)

self.setLayout(_layout)
_screen_rect = QtGui.QGuiApplication.primaryScreen().geometry()
_screen_rect = QtGui.QGuiApplication.screenAt(
parent.mapToGlobal(parent.geometry().topLeft())
).geometry()
_screen_center = _screen_rect.center()
self.resize(int(_screen_rect.width() * 0.8), int(_screen_rect.height() * 0.8))
self.move(_screen_center - self.rect().center())
Expand Down
14 changes: 11 additions & 3 deletions tabulous/_slice_op.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
from __future__ import annotations

import numpy as np

# utility functions for working with slices


Expand Down Expand Up @@ -51,11 +53,17 @@ def as_sized(sl: slice, size: int, allow_negative: bool = False):
def fmt(sl: slice) -> str:
"""Format a slice as a string."""
if isinstance(sl, slice):
s0 = repr(sl.start) if sl.start is not None else ""
s1 = repr(sl.stop) if sl.stop is not None else ""
s0 = _repr(sl.start) if sl.start is not None else ""
s1 = _repr(sl.stop) if sl.stop is not None else ""
return f"{s0}:{s1}"
return repr(sl)
return _repr(sl)


def has_none(sl: slice):
return sl.start is None or sl.stop is None


def _repr(x) -> str:
if isinstance(x, np.number):
return str(x)
return repr(x)

0 comments on commit 9c23ca6

Please sign in to comment.