Skip to content
Open
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
10 changes: 5 additions & 5 deletions jupyter_datatables/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ def _repr_datatable_(self, options: dict = None, classes: list = None):
})

# column types
options.update({'columnDefs': _get_columns_defs(self, options)})
options['columnDefs'] = _get_columns_defs(self, options)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function _repr_datatable_ refactored with the following changes:


# pop buttons, we need to use them separately
buttons = options.pop("buttons", [])
Expand All @@ -262,11 +262,11 @@ def _repr_datatable_(self, options: dict = None, classes: list = None):
adjusted = False

if config.defaults.limit is not None:
n = len(self)

# compute the sample size, it will be used for the data preview
# to speed up computation
if len(self) > config.defaults.limit:
n = len(self)

sample_size = getattr(config.defaults, 'sample_size', None) or min([
n, _calculate_sample_size(n)
])
Expand Down Expand Up @@ -298,7 +298,7 @@ def _repr_datatable_(self, options: dict = None, classes: list = None):
sample_size = len(df)

sort = config.defaults.sort
if sort == True or sort == 'index':
if sort in [True, 'index']:
df.sort_index(inplace=True)
elif sort:
df.sort_values(inplace=True)
Expand Down Expand Up @@ -410,7 +410,7 @@ def _smart_ceil(x: typing.Union[int, float], order: int = None) -> int:

The 'nearest' is chosen based on the order of the given number
"""
order = int(order) if order else len(str(math.ceil(x)))
order = order if order else len(str(math.ceil(x)))
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function _smart_ceil refactored with the following changes:

if order <= 0:
raise ValueError("`order` must be integer >= 0")
mod = math.pow(10, min([order, 3]))
Expand Down