Skip to content

Commit

Permalink
TEST: Add python=3.9 (#574)
Browse files Browse the repository at this point in the history
* TEST: Add python=3.9

* TEST: Remove dependency on `tables`
  • Loading branch information
oyamad authored Mar 26, 2021
1 parent 5ba28ab commit 6ffbe57
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 90 deletions.
5 changes: 2 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ on:
branches:
- master
pull_request:

jobs:
tests:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest, ubuntu-latest, macos-latest]
python-version: [3.7, 3.8]
python-version: [3.7, 3.8, 3.9]
exclude:
- os: windows-latest
python-version: 3.7
Expand All @@ -38,7 +38,6 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install -U nose coverage numpy scipy pandas numba sympy ipython statsmodels flake8
pip install tables
python setup.py install
- name: Run Tests
run: |
Expand Down
3 changes: 1 addition & 2 deletions quantecon/tests/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,4 @@
@date : 2014-08-01 13:13:59
"""
from . util import (capture, get_data_dir, get_h5_data_file, write_array,
max_abs_diff, get_h5_data_group)
from . util import capture, get_data_dir, max_abs_diff
85 changes: 0 additions & 85 deletions quantecon/tests/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,8 @@
"""
import sys
import os
from os.path import join, exists
from contextlib import contextmanager
import numpy as np
import tables

if sys.version_info[0] == 2:
from cStringIO import StringIO
Expand Down Expand Up @@ -48,89 +46,6 @@ def get_data_dir():
return data_dir


def get_h5_data_file():
"""
return the data file used for holding test data. If the data
directory or file do not exist, they are created.
Notes
-----
This should ideally be called from a context manage as so::
with get_h5_data_file() as f:
# do stuff
This way we know the file will be closed and cleaned up properly
"""
data_dir = get_data_dir()

if not exists(data_dir):
os.mkdir(data_dir)

data_file = join(data_dir, "testing_data.h5")

return tables.open_file(data_file, "a", "Data for quantecon tests")


def get_h5_data_group(grp_name, parent="/", f=get_h5_data_file()):
"""
Try to fetch the group named grp_name from the file f. If it doesn't
yet exist, it is created
Parameters
----------
grp_name : str
A string specifying the name of the new group. This should be
only the group name, not including any information about the
group's parent (path)
parent : str, optional(default="/")
The parent or path for where the group should live. If nothing
is given, the group will be created at the root node `"/"`
f : hdf5 file, optional(default=get_h5_data_file())
The file where this should happen. The default is the data file
for these tests
Returns
-------
existed : bool
A boolean specifying whether the group existed or was created
group : tables.Group
The requested group
Examples
--------
with get_h5_data_file() as f:
my_group = get_h5_data_group("jv") # data for jv tests
Notes
-----
As with other code dealing with I/O from files, it is best to call
this function within a context manager as shown in the example.
"""
existed = True
try:
group = f.getNode(parent + grp_name)
except:
# doesn't exist
existed = False
msg = "data for {} tests".format(grp_name + ".py")
group = f.create_group(parent, grp_name, msg)

return existed, group


def write_array(f, grp, array, name):
"stores array in into group grp of h5 file f under name name"
atom = tables.Atom.from_dtype(array.dtype)
ds = f.createCArray(grp, name, atom, array.shape)
ds[:] = array


def max_abs_diff(a1, a2):
"return max absolute difference between two arrays"
return np.max(np.abs(a1 - a2))

0 comments on commit 6ffbe57

Please sign in to comment.