Skip to content

Commit

Permalink
upgrade to Py3.12
Browse files Browse the repository at this point in the history
  • Loading branch information
jmschrei committed Jul 7, 2024
1 parent fa29944 commit 68d369a
Show file tree
Hide file tree
Showing 27 changed files with 83 additions and 28 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/python-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest, macOS-latest]
python-version: ['3.8', '3.9', '3.10']
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']

steps:
- uses: actions/checkout@v3
Expand Down
2 changes: 1 addition & 1 deletion tests/distributions/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import numpy
import torch

from nose.tools import assert_raises
from ..tools import assert_raises
from numpy.testing import assert_array_almost_equal


Expand Down
2 changes: 1 addition & 1 deletion tests/distributions/test_bernoulli.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from ._utils import _test_efd_from_summaries
from ._utils import _test_raises

from nose.tools import assert_raises
from ..tools import assert_raises
from numpy.testing import assert_array_almost_equal


Expand Down
2 changes: 1 addition & 1 deletion tests/distributions/test_categorical.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from ._utils import _test_predictions
from ._utils import _test_raises

from nose.tools import assert_raises
from ..tools import assert_raises
from numpy.testing import assert_array_almost_equal


Expand Down
2 changes: 1 addition & 1 deletion tests/distributions/test_conditional_categorical.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from ._utils import _test_predictions
from ._utils import _test_raises

from nose.tools import assert_raises
from ..tools import assert_raises
from numpy.testing import assert_array_almost_equal


Expand Down
2 changes: 1 addition & 1 deletion tests/distributions/test_dirac_delta.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from ._utils import _test_efd_from_summaries
from ._utils import _test_raises

from nose.tools import assert_raises
from ..tools import assert_raises
from numpy.testing import assert_array_almost_equal


Expand Down
2 changes: 1 addition & 1 deletion tests/distributions/test_exponential.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from ._utils import _test_efd_from_summaries
from ._utils import _test_raises

from nose.tools import assert_raises
from ..tools import assert_raises
from numpy.testing import assert_array_almost_equal


Expand Down
2 changes: 1 addition & 1 deletion tests/distributions/test_gamma.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from ._utils import _test_efd_from_summaries
from ._utils import _test_raises

from nose.tools import assert_raises
from ..tools import assert_raises
from numpy.testing import assert_array_almost_equal


Expand Down
2 changes: 1 addition & 1 deletion tests/distributions/test_independent_component.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from ._utils import _test_efd_from_summaries
from ._utils import _test_raises

from nose.tools import assert_raises
from ..tools import assert_raises
from numpy.testing import assert_array_almost_equal


Expand Down
2 changes: 1 addition & 1 deletion tests/distributions/test_joint_categorical.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from ._utils import _test_predictions
from ._utils import _test_raises

from nose.tools import assert_raises
from ..tools import assert_raises
from numpy.testing import assert_array_almost_equal


Expand Down
2 changes: 1 addition & 1 deletion tests/distributions/test_normal_diagonal.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from ._utils import _test_efd_from_summaries
from ._utils import _test_raises

from nose.tools import assert_raises
from ..tools import assert_raises
from numpy.testing import assert_array_almost_equal

SQRT_2_PI = 2.50662827463
Expand Down
2 changes: 1 addition & 1 deletion tests/distributions/test_normal_full.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from ._utils import _test_efd_from_summaries
from ._utils import _test_raises

from nose.tools import assert_raises
from ..tools import assert_raises
from numpy.testing import assert_array_almost_equal

SQRT_2_PI = 2.50662827463
Expand Down
2 changes: 1 addition & 1 deletion tests/distributions/test_poisson.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from ._utils import _test_efd_from_summaries
from ._utils import _test_raises

from nose.tools import assert_raises
from ..tools import assert_raises
from numpy.testing import assert_array_almost_equal


Expand Down
2 changes: 1 addition & 1 deletion tests/distributions/test_student_t.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from ._utils import _test_efd_from_summaries
from ._utils import _test_raises

from nose.tools import assert_raises
from ..tools import assert_raises
from numpy.testing import assert_array_almost_equal

SQRT_2_PI = 2.50662827463
Expand Down
2 changes: 1 addition & 1 deletion tests/distributions/test_uniform.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from ._utils import _test_efd_from_summaries
from ._utils import _test_raises

from nose.tools import assert_raises
from ..tools import assert_raises
from numpy.testing import assert_array_almost_equal


Expand Down
2 changes: 1 addition & 1 deletion tests/hmm/test_dense_hmm.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from ..distributions._utils import _test_efd_from_summaries
from ..distributions._utils import _test_raises

from nose.tools import assert_raises
from ..tools import assert_raises
from numpy.testing import assert_array_almost_equal
from numpy.testing import assert_array_equal

Expand Down
2 changes: 1 addition & 1 deletion tests/hmm/test_sparse_hmm.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from ..distributions._utils import _test_efd_from_summaries
from ..distributions._utils import _test_raises

from nose.tools import assert_raises
from ..tools import assert_raises
from numpy.testing import assert_array_almost_equal
from numpy.testing import assert_array_equal

Expand Down
2 changes: 1 addition & 1 deletion tests/test_bayes_classifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from .distributions._utils import _test_efd_from_summaries
from .distributions._utils import _test_raises

from nose.tools import assert_raises
from .tools import assert_raises
from numpy.testing import assert_array_almost_equal


Expand Down
2 changes: 1 addition & 1 deletion tests/test_bayesian_network.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from pomegranate.distributions import ConditionalCategorical


from nose.tools import assert_raises
from .tools import assert_raises
from numpy.testing import assert_array_equal
from numpy.testing import assert_array_almost_equal

Expand Down
2 changes: 1 addition & 1 deletion tests/test_bayesian_network_structure_learning.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from pomegranate.distributions import Categorical
from pomegranate.distributions import ConditionalCategorical

from nose.tools import assert_raises
from .tools import assert_raises
from numpy.testing import assert_array_almost_equal


Expand Down
2 changes: 1 addition & 1 deletion tests/test_factor_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from pomegranate.distributions import Categorical
from pomegranate.distributions import JointCategorical

from nose.tools import assert_raises
from .tools import assert_raises
from numpy.testing import assert_array_almost_equal


Expand Down
2 changes: 1 addition & 1 deletion tests/test_gmm.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from .distributions._utils import _test_efd_from_summaries
from .distributions._utils import _test_raises

from nose.tools import assert_raises
from .tools import assert_raises
from numpy.testing import assert_array_almost_equal


Expand Down
2 changes: 1 addition & 1 deletion tests/test_kmeans.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from .distributions._utils import _test_efd_from_summaries
from .distributions._utils import _test_raises

from nose.tools import assert_raises
from .tools import assert_raises
from numpy.testing import assert_array_almost_equal


Expand Down
2 changes: 1 addition & 1 deletion tests/test_markov_chain.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from .distributions._utils import _test_efd_from_summaries
from .distributions._utils import _test_raises

from nose.tools import assert_raises
from .tools import assert_raises
from numpy.testing import assert_array_almost_equal


Expand Down
2 changes: 1 addition & 1 deletion tests/test_semisupervised.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from pomegranate.hmm import DenseHMM
from pomegranate.distributions import Exponential

from nose.tools import assert_raises
from .tools import assert_raises
from numpy.testing import assert_array_equal
from numpy.testing import assert_array_almost_equal

Expand Down
6 changes: 3 additions & 3 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
from pomegranate._utils import _check_parameter
from pomegranate._utils import partition_sequences

from nose.tools import assert_almost_equal
from nose.tools import assert_equal
from nose.tools import assert_raises
from .tools import assert_almost_equal
from .tools import assert_equal
from .tools import assert_raises
from numpy.testing import assert_array_equal
from numpy.testing import assert_array_almost_equal

Expand Down
55 changes: 55 additions & 0 deletions tests/tools.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# tools.py
# Author: Jacob Schreiber <[email protected]>

'''
Tools taken from nose since it can no longer be installed after Py3.12.
'''


import re
import unittest


__all__ = ['ok_', 'eq_']

# Use the same flag as unittest itself to prevent descent into these functions:
__unittest = 1


def ok_(expr, msg=None):
"""Shorthand for assert. Saves 3 whole characters!
"""
if not expr:
raise AssertionError(msg)


def eq_(a, b, msg=None):
"""Shorthand for 'assert a == b, "%r != %r" % (a, b)
"""
if not a == b:
raise AssertionError(msg or "%r != %r" % (a, b))


#
# Expose assert* from unittest.TestCase
# - give them pep8 style names
#
caps = re.compile('([A-Z])')

def pep8(name):
return caps.sub(lambda m: '_' + m.groups()[0].lower(), name)

class Dummy(unittest.TestCase):
def nop():
pass
_t = Dummy('nop')

for at in [ at for at in dir(_t)
if at.startswith('assert') and not '_' in at ]:
pepd = pep8(at)
vars()[pepd] = getattr(_t, at)
__all__.append(pepd)

del Dummy
del _t
del pep8

0 comments on commit 68d369a

Please sign in to comment.