Skip to content
Merged
Show file tree
Hide file tree
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
6 changes: 6 additions & 0 deletions .github/release-drafter-config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
name-template: 'v$NEXT_PATCH_VERSION 🌈'
tag-template: 'v$NEXT_PATCH_VERSION'
template: |
## What’s Changed

$CHANGES
56 changes: 56 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: CI

on:
push:
branches:
- master
pull_request:
branches:
- master

jobs:
build:

runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
python-version: [2.7, 3.5, 3.7, 3.8]
include:
- python-version: 2.7
pandas: 0.18.1
numpy: 1.11.3
- python-version: 3.5
pandas: 0.18.1
numpy: 1.11.3
- python-version: 3.7
pandas: 1.0.1
numpy: 1.18.1
- python-version: 3.8
pandas: 1.0.1
numpy: 1.18.1

steps:
- uses: actions/checkout@v1
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- uses: actions/cache@v1
with:
path: ~/.cache/pip
key: ${{ runner.os }}-${{ matrix.python-version }}-${{ matrix.pandas }}-${{ matrix.numpy }}-pip-${{ hashFiles('**/setup.py') }}
- name: Install dependencies
env:
PYTHONWARNINGS: ignore:DEPRECATION::pip._internal.cli.base_command
run: |
python -m pip install --upgrade pip
pip install pandas==${{ matrix.pandas }} numpy==${{ matrix.numpy }}
pip install -e .[test]
- name: Lint with flake8
run: |
flake8
- name: Run the tests
run: |
pytest
18 changes: 18 additions & 0 deletions .github/workflows/master-merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
name: On Master Merge

on:
push:
branches:
- master

jobs:
draft-release-publish:
name: Draft a new release
runs-on: ubuntu-latest
steps:
# Drafts your next Release notes as Pull Requests are merged into "master"
- uses: release-drafter/release-drafter@v5
with:
config-name: release-drafter-config.yml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
42 changes: 42 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Publish Python 🐍 distributions 📦 to PyPI
on:
release:
types: [published]

jobs:
build-n-publish:
name: Build and publish Python 🐍 distributions 📦 to TestPyPI
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@master
- name: Set up Python 3.7
uses: actions/setup-python@v1
with:
python-version: 3.7

- name: Build sdist
run: python setup.py sdist

- name: Publish distribution 📦 to Test PyPI
uses: pypa/gh-action-pypi-publish@master
with:
password: ${{ secrets.test_pypi_password }}
repository_url: https://test.pypi.org/legacy/

- name: Install from test and test running
run: |
python -m pip install --upgrade pip
pip install --extra-index-url https://test.pypi.org/simple qgrid
python -c 'import qgrid;print(qgrid.__version__)'
pip uninstall -y qgrid

- name: Publish distribution 📦 to PyPI
uses: pypa/gh-action-pypi-publish@master
with:
password: ${{ secrets.pypi_password }}

- name: Install and test running
run: |
python -m pip install --upgrade pip
pip install --extra-index-url qgrid
python -c 'import qgrid;print(qgrid.__version__)'
38 changes: 21 additions & 17 deletions qgrid/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from ._version import version_info, __version__
from ._version import version_info, __version__ # noqa F401

from .grid import (
enable,
Expand All @@ -9,25 +9,29 @@
set_grid_option,
show_grid,
QgridWidget,
QGridWidget
QGridWidget,
)


def _jupyter_nbextension_paths():
return [{
'section': 'notebook',
'src': 'static',
'dest': 'qgrid',
'require': 'qgrid/extension'
}]
return [
{
"section": "notebook",
"src": "static",
"dest": "qgrid",
"require": "qgrid/extension",
}
]


__all__ = [
'enable',
'disable',
'set_defaults',
'on',
'off',
'set_grid_option',
'show_grid',
'QgridWidget',
'QGridWidget'
"enable",
"disable",
"set_defaults",
"on",
"off",
"set_grid_option",
"show_grid",
"QgridWidget",
"QGridWidget",
]
14 changes: 10 additions & 4 deletions qgrid/_version.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
version_info = (1, 2, 0, 'final')
version_info = (1, 3, 0, "final")

_specifier_ = {'alpha': 'a', 'beta': 'b', 'candidate': 'rc', 'final': ''}
_specifier_ = {"alpha": "a", "beta": "b", "candidate": "rc", "final": ""}

__version__ = '%s.%s.%s%s'%(version_info[0], version_info[1], version_info[2],
'' if version_info[3]=='final' else _specifier_[version_info[3]]+str(version_info[4]))
__version__ = "%s.%s.%s%s" % (
version_info[0],
version_info[1],
version_info[2],
""
if version_info[3] == "final"
else _specifier_[version_info[3]] + str(version_info[4]),
)
7 changes: 5 additions & 2 deletions qgrid/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -856,7 +856,7 @@ def _update_table(self,
to_index = max(self._viewport_range[0] + PAGE_SIZE, 0)
new_df_range = (from_index, to_index)

if triggered_by is 'viewport_changed' and \
if triggered_by == 'viewport_changed' and \
self._df_range == new_df_range:
return

Expand Down Expand Up @@ -1431,12 +1431,15 @@ def _handle_qgrid_msg_helper(self, content):
try:
location = (self._df.index[content['row_index']],
content['column'])
old_value = self._df.loc[location]

val_to_set = content['value']
if col_info['type'] == 'datetime':
val_to_set = pd.to_datetime(val_to_set)
# pandas > 18.0 compat
if old_value.tz != val_to_set.tz:
val_to_set = val_to_set.tz_convert(tz=old_value.tz)

old_value = self._df.loc[location]
self._df.loc[location] = val_to_set

query = self._unfiltered_df[self._index_col_name] == \
Expand Down
19 changes: 8 additions & 11 deletions qgrid/pd_json/json.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ def _try_convert_data(self, name, data, use_dtypes=True,
try:
dtype = np.dtype(dtype)
return data.astype(dtype), True
except:
except Exception:
return data, False

if convert_dates:
Expand All @@ -474,7 +474,7 @@ def _try_convert_data(self, name, data, use_dtypes=True,
try:
data = data.astype('float64')
result = True
except:
except Exception:
pass

if data.dtype.kind == 'f':
Expand All @@ -485,7 +485,7 @@ def _try_convert_data(self, name, data, use_dtypes=True,
try:
data = data.astype('float64')
result = True
except:
except Exception:
pass

# do't coerce 0-len data
Expand All @@ -497,7 +497,7 @@ def _try_convert_data(self, name, data, use_dtypes=True,
if (new_data == data).all():
data = new_data
result = True
except:
except Exception:
pass

# coerce ints to 64
Expand All @@ -507,7 +507,7 @@ def _try_convert_data(self, name, data, use_dtypes=True,
try:
data = data.astype('int64')
result = True
except:
except Exception:
pass

return data, result
Expand All @@ -526,7 +526,7 @@ def _try_convert_to_date(self, data):
if new_data.dtype == 'object':
try:
new_data = data.astype('int64')
except:
except Exception:
pass

# ignore numbers that are out of range
Expand All @@ -543,7 +543,7 @@ def _try_convert_to_date(self, data):
unit=date_unit)
except ValueError:
continue
except:
except Exception:
break
return new_data, True
return data, False
Expand Down Expand Up @@ -649,12 +649,9 @@ def _parse_no_numpy(self):
self.obj = DataFrame(
loads(json, precise_float=self.precise_float), dtype=None)

def _process_converter(self, f, filt=None):
def _process_converter(self, f, filt=lambda col, c: True):
""" take a conversion function and possibly recreate the frame """

if filt is None:
filt = lambda col, c: True

needs_new_obj = False
new_obj = dict()
for i, (col, c) in enumerate(self.obj.iteritems()):
Expand Down
2 changes: 1 addition & 1 deletion qgrid/pd_json/normalize.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ def _pull_field(js, spec):

return result

if isinstance(data, list) and len(data) is 0:
if isinstance(data, list) and len(data) == 0:
return DataFrame()

# A bit of a hackjob
Expand Down
1 change: 0 additions & 1 deletion qgrid/tests/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@

Loading