Skip to content

Commit

Permalink
Merge branch 'master' of github.com:pydy/pydy
Browse files Browse the repository at this point in the history
  • Loading branch information
moorepants committed Aug 23, 2024
2 parents 55cbd27 + ae850f8 commit 4966f1c
Show file tree
Hide file tree
Showing 11 changed files with 37 additions and 28 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/oldest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ jobs:
miniforge-variant: Mambaforge
- name: Install basic dependencies
run: |
mamba install -q -y coverage cython=0.29.* matplotlib=3.1.* nose numpy=1.16.* pythreejs sympy=1.5.* scipy=1.3.*
mamba install -q -y coverage cython=0.29.* matplotlib=3.1.* pytest pytest-cov numpy=1.16.* pythreejs sympy=1.5.* scipy=1.3.*
- name: Test with nose
run: nosetests -v --with-coverage --cover-package=pydy
run: pytest -cov .
- name: Test installation of PyDy
run: python setup.py install
10 changes: 7 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,12 @@ jobs:
miniforge-variant: Mambaforge
- name: Install basic dependencies
run: |
mamba install -q -y coverage cython matplotlib nose numpy pythreejs sympy scipy
- name: Test with nose
run: nosetests -v --with-coverage --cover-package=pydy
mamba install -q -y coverage cython matplotlib pytest pytest-cov numpy pythreejs sympy scipy
- name: Install window dependencies
if: ${{ matrix.os=='windows-latest' }}
run: |
mamba install -q -y pywin32
- name: Test with pytest
run: pytest --cov .
- name: Test installation of PyDy
run: python setup.py install
2 changes: 1 addition & 1 deletion bin/test
Original file line number Diff line number Diff line change
@@ -1 +1 @@
nosetests --with-coverage --cover-package=pydy_viz
pytest --cov .
10 changes: 6 additions & 4 deletions pydy/codegen/tests/test_c_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

import os

import pytest

from pkg_resources import parse_version
import sympy as sm
from nose.tools import assert_raises

from ...models import multi_mass_spring_damper
from ..c_code import CMatrixGenerator
Expand All @@ -14,7 +15,7 @@

class TestCMatrixGenerator():

def setup(self):
def setup_method(self):

self.prefix = 'boogly_bee'

Expand All @@ -40,7 +41,8 @@ def test_init(self):
# Make sure an error is risen if not enough arguments are provided.
arguments = self.arguments[:-1]

assert_raises(ValueError, CMatrixGenerator, arguments, self.matrices)
with pytest.raises(ValueError):
CMatrixGenerator(arguments, self.matrices)

def test_generate_cse(self):

Expand Down Expand Up @@ -1177,7 +1179,7 @@ def test_write(self):
with open(self.prefix + '.c') as f:
assert f.read() == source

def teardown(self):
def teardown_method(self):

if os.path.isfile(self.prefix + '.h'):
os.remove(self.prefix + '.h')
Expand Down
4 changes: 2 additions & 2 deletions pydy/codegen/tests/test_cython_code.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

class TestCythonMatrixGenerator(object):

def setup(self):
def setup_method(self):

self.prefix = 'boogly_bee'

Expand Down Expand Up @@ -187,7 +187,7 @@ def test_compile(self):

np.testing.assert_allclose(output, expected)

def teardown(self):
def teardown_method(self):

for suffix in ['_c.h', '_c.c', '_setup.py', '.pyx']:
filename = self.prefix + suffix
Expand Down
4 changes: 2 additions & 2 deletions pydy/codegen/tests/test_ode_function_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def test_cse_same_numerical_results():

class TestODEFunctionGenerator(object):

def setup(self):
def setup_method(self):

self.sys = models.multi_mass_spring_damper(2)
self.rhs = self.sys.eom_method.rhs()
Expand Down Expand Up @@ -275,7 +275,7 @@ class TestODEFunctionGeneratorSubclasses(object):
warnings.warn("Theano was not found so the related tests are being"
" skipped.", PyDyImportWarning)

def setup(self):
def setup_method(self):

self.sys = models.multi_mass_spring_damper()
# Best keep these in order, otherwise it may change between SymPy
Expand Down
2 changes: 1 addition & 1 deletion pydy/tests/test_system.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

class TestSystem():

def setup(self):
def setup_method(self):

# Create a simple system with one specified quantity.
self.sys = multi_mass_spring_damper(1, apply_gravity=True,
Expand Down
5 changes: 3 additions & 2 deletions pydy/tests/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#!/usr/bin/env python

import pytest

from pkg_resources import parse_version
from setuptools import __version__ as SETUPTOOLS_VERSION
from nose.tools import assert_raises

from sympy import cos, sin, tan, sqrt, Matrix
from sympy.physics.mechanics import dynamicsymbols
Expand All @@ -20,7 +21,7 @@ def test_sympy_equal_to_or_newer_than():
assert sympy_equal_to_or_newer_than('0.6.5', '0.7.6.dev')
assert not sympy_equal_to_or_newer_than('0.7.7', '0.7.6.dev')
if parse_version(SETUPTOOLS_VERSION) >= parse_version('8.0'):
with assert_raises(ValueError):
with pytest.raises(ValueError):
sympy_equal_to_or_newer_than('0.7.7', '0.7.6-git')


Expand Down
11 changes: 6 additions & 5 deletions pydy/viz/tests/test_scene.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
import shutil
import glob

import pytest

import numpy as np
from numpy.testing import assert_allclose
from sympy import symbols
import sympy.physics.mechanics as me
from nose.tools import assert_raises

from ...system import System
from ..shapes import Sphere
Expand All @@ -21,7 +22,7 @@

class TestScene(object):

def setup(self):
def setup_method(self):
"""Setups a simple 1 DoF mass spring damper system visualization."""

mass, stiffness, damping, gravity = symbols('m, k, c, g')
Expand Down Expand Up @@ -129,13 +130,13 @@ def test_setting_incompatible_attrs(self):
scene = Scene(self.ref_frame, self.origin, self.viz_frame,
times=self.sys.times)

with assert_raises(ValueError):
with pytest.raises(ValueError):
scene.system = self.sys

scene = Scene(self.ref_frame, self.origin, self.viz_frame,
system=self.sys)

with assert_raises(ValueError):
with pytest.raises(ValueError):
scene.times = self.sys.times

def test_clear_trajectories(self):
Expand Down Expand Up @@ -314,7 +315,7 @@ def test_generate_visualization_json_system(self):
assert scene._scene_info['constant_map'] == {'m': 1.0, 'k': 2.0,
'c': 3.0, 'g': 9.8}

def teardown(self):
def teardown_method(self):

try:
shutil.rmtree(Scene.pydy_directory)
Expand Down
10 changes: 6 additions & 4 deletions pydy/viz/tests/test_shapes.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

# external
import numpy as np
import pytest

from sympy import symbols
from numpy.testing import assert_allclose
from nose.tools import assert_raises

try:
import pythreejs as p3js
except ImportError:
Expand All @@ -29,19 +31,19 @@ def test_shape():

shape.name = 'shape1'
assert shape.name == 'shape1'
with assert_raises(TypeError):
with pytest.raises(TypeError):
shape.name = 1

shape.color = 'red'
assert shape.color == 'red'
with assert_raises(ValueError):
with pytest.raises(ValueError):
shape.color = 'puke'

shape.material = "water"
assert shape.material == "water"
shape.material = "WATER"
assert shape.material == "WATER"
with assert_raises(ValueError):
with pytest.raises(ValueError):
shape.material = 'fluffy cloth'

assert shape.generate_dict() == {"color": "red",
Expand Down
3 changes: 1 addition & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@
packages=find_packages(),
install_requires=install_requires,
extras_require=extras_require,
tests_require=['nose>=1.3.7'],
test_suite='nose.collector',
tests_require=['pytest', 'pytest-coverage'],
include_package_data=True,
classifiers=[
'Development Status :: 4 - Beta',
Expand Down

0 comments on commit 4966f1c

Please sign in to comment.