Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle warnings #226

Merged
merged 15 commits into from
Mar 30, 2022
15 changes: 14 additions & 1 deletion .coveragerc
Original file line number Diff line number Diff line change
@@ -1 +1,14 @@
# Configuration for coverage.py[run]branch = Truesource = oct2pyinclude = */oct2py/*omit = */setup.py oct2py/compat.py oct2py/tests/* oct2py/ipython/tests/*[report]exclude_lines = def __repr__ if __name__ == .__main__.:
# Configuration for coverage.py

[run]
branch = True
omit =
*/setup.py
oct2py/compat.py
oct2py/tests/*
oct2py/ipython/tests/*

[report]
exclude_lines =
def __repr__
if __name__ == .__main__.:
1 change: 1 addition & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ jobs:
strategy:
matrix:
python-version: [3.7, 3.8, 3.9, '3.10']
fail-fast: false

steps:
- uses: actions/checkout@v2
Expand Down
52 changes: 52 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
ci:
skip: [check-jsonschema]

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.1.0
hooks:
- id: end-of-file-fixer
- id: check-case-conflict
- id: check-executables-have-shebangs
- id: requirements-txt-fixer
- id: check-added-large-files
- id: check-case-conflict
- id: check-toml
- id: check-yaml
- id: debug-statements
- id: forbid-new-submodules
- id: check-builtin-literals
# - id: trailing-whitespace

# - repo: https://github.com/psf/black
# rev: 22.3.0
# hooks:
# - id: black
# args: ["--line-length", "100"]

# - repo: https://github.com/PyCQA/isort
# rev: 5.10.1
# hooks:
# - id: isort
# files: \.py$
# args: [--profile=black]

# - repo: https://github.com/pycqa/flake8
# rev: 4.0.1
# hooks:
# - id: flake8
# additional_dependencies:
# [
# "flake8-bugbear==20.1.4",
# "flake8-logging-format==0.6.0",
# "flake8-implicit-str-concat==0.2.0",
# ]

- repo: https://github.com/sirosen/check-jsonschema
rev: 0.14.1
hooks:
- id: check-jsonschema
name: "Check GitHub Workflows"
files: ^\.github/workflows/
types: [yaml]
args: ["--schemafile", "https://json.schemastore.org/github-workflow"]
2 changes: 1 addition & 1 deletion CONTRIBUTORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ Patches and Suggestions
- Jonathan Suever
- Manuel Osdoba
- Josue Ortega
- Muhammad Yasirroni @yasirroni
- Muhammad Yasirroni @yasirroni
2 changes: 2 additions & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,5 @@ prune .git
prune docs/_build
prune dist
prune build

exclude .pre-commit-config.yaml
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ all: clean

install: clean
pip install -e .[docs,test]
pre-commit install
octave --eval "pkg install -forge control"
octave --eval "pkg install -forge signal"

Expand Down
1 change: 0 additions & 1 deletion docs/source/conversions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,3 @@ logical ndarray (of uint8)
sparse sparse
user defined object Oct2Py object pointer
=================== ======================

3 changes: 0 additions & 3 deletions docs/source/info.rst
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,3 @@ Oct2Py provides OctaveMagic_ for IPython, including inline plotting in
notebooks. This requires IPython >= 1.0.0.

.. _OctaveMagic: http://nbviewer.jupyter.org/github/blink1073/oct2py/blob/main/example/octavemagic_extension.ipynb?create=1



4 changes: 2 additions & 2 deletions oct2py/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ def __init__(self, logger=None, timeout=None,
else:
self.temp_dir = temp_dir
self.convert_to_float = convert_to_float
self._user_classes = dict()
self._function_ptrs = dict()
self._user_classes = {}
self._function_ptrs = {}
self.restart()

@property
Expand Down
9 changes: 6 additions & 3 deletions oct2py/dynamic.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@
import numpy as np

try:
from scipy.io.matlab.mio5 import MatlabObject
from scipy.io.matlab import MatlabObject
except ImportError:
pass
try:
from scipy.io.matlab.mio5 import MatlabObject
except ImportError:
pass

from .compat import PY2

Expand Down Expand Up @@ -191,7 +194,7 @@ def from_value(cls, value):
def to_value(cls, instance):
"""Convert to a value to send to Octave."""
if not isinstance(instance, OctaveUserClass) or not instance._attrs:
return dict()
return {}
# Bootstrap a MatlabObject from scipy.io
# From https://github.com/scipy/scipy/blob/93a0ea9e5d4aba1f661b6bb0e18f9c2d1fce436a/scipy/io/matlab/mio5.py#L435-L443
# and https://github.com/scipy/scipy/blob/93a0ea9e5d4aba1f661b6bb0e18f9c2d1fce436a/scipy/io/matlab/mio5_params.py#L224
Expand Down
12 changes: 8 additions & 4 deletions oct2py/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,14 @@

try:
from scipy.io import loadmat, savemat
from scipy.io.matlab.mio5 import MatlabObject, MatlabFunction
from scipy.sparse import spmatrix
from scipy.io.matlab import MatlabObject, MatlabFunction
except ImportError:
pass
try:
from scipy.io.matlab.mio5 import MatlabObject, MatlabFunction
except ImportError:
pass


try:
from pandas import Series, DataFrame
Expand All @@ -40,7 +44,7 @@ def read_file(path, session=None):
data = loadmat(path, struct_as_record=True)
except UnicodeDecodeError as e:
raise Oct2PyError(str(e))
out = dict()
out = {}
for (key, value) in data.items():
out[key] = _extract(value, session)
return out
Expand Down Expand Up @@ -333,7 +337,7 @@ def _encode(data, convert_to_float):

# Extract and encode values from dict-like objects.
if isinstance(data, dict):
out = dict()
out = {}
for (key, value) in data.items():
out[key] = _encode(value, ctf)
return out
Expand Down
2 changes: 1 addition & 1 deletion oct2py/ipython/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
from .octavemagic import load_ipython_extension
from .octavemagic import load_ipython_extension
2 changes: 1 addition & 1 deletion oct2py/ipython/ipython-COPYING.txt
Original file line number Diff line number Diff line change
Expand Up @@ -82,4 +82,4 @@ to indicate the copyright and license terms:
# Distributed under the terms of the Modified BSD License.
#
# The full license is in the file COPYING.txt, distributed with this software.
#-----------------------------------------------------------------------------
#-----------------------------------------------------------------------------
2 changes: 1 addition & 1 deletion oct2py/ipython/octavemagic.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@

import oct2py

from IPython.core.display import publish_display_data, display
from IPython.display import publish_display_data, display
from IPython.core.magic import (Magics, magics_class, line_magic,
line_cell_magic, needs_local_scope)
from IPython.testing.skipdoctest import skip_doctest
Expand Down
4 changes: 2 additions & 2 deletions oct2py/ipython/tests/test_octavemagic.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def setUpClass(cls):
cls.ip = get_ipython()
# This is just to get a minimally modified version of the changes
# working
cls.ip.magic('load_ext oct2py.ipython')
cls.ip.run_line_magic('load_ext', 'oct2py.ipython')
cls.ip.ex('import numpy as np')
cls.svgs_generated = 0

Expand Down Expand Up @@ -68,7 +68,7 @@ def test_octave_syntax_error(self):
try:
self.ip.run_cell_magic('octave', '', "a='1")
except Oct2PyError:
self.ip.magic('reload_ext oct2py.ipython')
self.ip.run_line_magic('reload_ext', 'oct2py.ipython')

def test_octave_error(self):
self.assertRaises(Oct2PyError, self.ip.run_cell_magic,
Expand Down
2 changes: 1 addition & 1 deletion oct2py/tests/test_misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def test_context_manager(self):
def test_singleton_sparses(self):
'''Make sure a singleton sparse matrix works'''
import scipy.sparse
data = scipy.sparse.csc.csc_matrix(1)
data = scipy.sparse.csc_matrix(1)
self.oc.push('x', data)
assert np.allclose(data.toarray(), self.oc.pull('x').toarray())
self.oc.push('y', [data])
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ test =
pandas
nbconvert
pytest-timeout
pre-commit
docs =
sphinx
sphinx-bootstrap-theme
Expand All @@ -53,4 +54,3 @@ upload-dir = docs/build/html

[wheel]
universal = 1