Skip to content

Commit

Permalink
Provide a matrix of expeted attribute lengths for different py, scipy…
Browse files Browse the repository at this point in the history
… versions. Update metal.yaml to restrict python versions with noarch python
  • Loading branch information
gb119 committed Oct 1, 2023
1 parent fe6cd15 commit 3f842e9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
6 changes: 3 additions & 3 deletions recipe/meta.yaml
Expand Up @@ -17,13 +17,13 @@ build:

requirements:
build:
- python
- python >=3.7 <3.12
- pytest
- pytest-runner

run:
- python
- scipy>1.4
- python >=3.7 <3.12
- scipy>1.7
- numpy >=1.18
- matplotlib >=3.0
- scikit-image >=0.17
Expand Down
19 changes: 15 additions & 4 deletions tests/Stoner/Image/test_core.py
Expand Up @@ -13,13 +13,15 @@
from os import path
import tempfile
import os
import sys
import shutil
from PIL import Image

from scipy.version import version as spv

spv=[int(x) for x in spv.split(".")]


#data arrays for testing - some useful small images for tests

thisdir=path.dirname(__file__)
Expand All @@ -30,6 +32,17 @@ def shares_memory(arr1, arr2):
ret = np.may_share_memory(arr1, arr2)
return ret

def _expected():
"""Return number of image attributes for different versions of python and scipy."""
py=sys.version_info.minor
scipy=spv[1]

data={6:{7:1056,7:1058,8:1062,9:1087,10:1089,11:1089},
8:{6:1056,7:1058,8:1062,9:1087,10:1089,11:1089},
9:{6:1056,7:1058,8:1062,9:1087,10:1089,11:1089},
10:{6:1056,7:1062,8:1062,9:1062,10:1089,11:1089},
11:{6:1056,7:1062,8:1062,9:1062,10:1089,11:1089}}
return data[py][scipy]

#random array shape 3,4
selfarr = np.array([[ 0.41674764, 0.66100043, 0.91755303, 0.33796703],
Expand Down Expand Up @@ -290,8 +303,7 @@ def test_other_funcs():

def test_attrs():
attrs=[x for x in dir(ImageArray([])) if not x.startswith("_")]
expected={6:1056,7:1062,8:1062,9:1062,10:1089,11:1089}.get(spv[1],1054)
assert len(attrs)==expected,"Length of ImageArray dir failed. {}".format(len(attrs))
assert len(attrs)==_expected(),"Length of ImageArray dir failed. {}".format(len(attrs))



Expand Down Expand Up @@ -362,8 +374,7 @@ def test_methods():
with pytest.raises(TypeError):
i2-"Gobble"
attrs=[x for x in dir(i2) if not x.startswith("_")]
expected={6:1060, 7:1066,8:1066,9:1066,10:1093,11:1093}.get(spv[1],1058)
assert len(attrs)==expected,"Length of ImageFile dir failed. {}:{}".format(expected,len(attrs))
assert len(attrs)==_expected()+4,"Length of ImageFile dir failed. {}:{}".format(expected,len(attrs))
assert image._repr_png_().startswith(b'\x89PNG\r\n'),"Failed to do ImageFile png representation"


Expand Down

0 comments on commit 3f842e9

Please sign in to comment.