Jelajahi Sumber

set pandas version constraint

https://github.com/fphammerle/freesurfer-volume-reader/pull/4
Fabian Peter Hammerle 6 tahun lalu
induk
melakukan
4b18fcbf42
4 mengubah file dengan 30 tambahan dan 4 penghapusan
  1. 23 0
      .travis.yml
  2. 4 3
      freesurfer_volume_reader/__init__.py
  3. 2 1
      setup.py
  4. 1 0
      tests/hippocampus_test.py

+ 23 - 0
.travis.yml

@@ -10,9 +10,32 @@ python:
 # required for python >= 3.7
 dist: xenial
 
+env:
+# https://pypi.org/project/pandas/#history
+- PANDAS_VERSION=
+- PANDAS_VERSION=0.24.*
+- PANDAS_VERSION=0.23.*
+- PANDAS_VERSION=0.22.*
+- PANDAS_VERSION=0.21.*
+
+# https://travis-ci.org/fphammerle/freesurfer-volume-reader/builds/525556257
+matrix:
+  exclude:
+  - python: 3.7
+    env: PANDAS_VERSION=0.21.*
+  - python: 3.7
+    env: PANDAS_VERSION=0.22.*
+  - python: 3.7-dev
+    env: PANDAS_VERSION=0.21.*
+  - python: 3.7-dev
+    env: PANDAS_VERSION=0.22.*
+
 install:
 - pip install pipenv
 - pipenv sync --dev
+- if [ ! -z "$PANDAS_VERSION" ]; then
+    pipenv install --selective-upgrade "pandas==$PANDAS_VERSION";
+  fi
 - pipenv graph
 
 script:

+ 4 - 3
freesurfer_volume_reader/__init__.py

@@ -55,9 +55,10 @@ def parse_hippocampal_volume_file_path(volume_file_path: str) -> dict:
 
 
 def read_hippocampal_volume_file_dataframe(volume_file_path: str) -> pandas.DataFrame:
-    volumes_frame = pandas.DataFrame(
-        read_hippocampal_volumes_mm3(volume_file_path).items(),
-        columns=['subfield', 'volume_mm^3'])
+    volumes_frame = pandas.DataFrame([
+        {'subfield': s, 'volume_mm^3': v}
+        for s, v in read_hippocampal_volumes_mm3(volume_file_path).items()
+    ])
     for key, value in parse_hippocampal_volume_file_path(volume_file_path).items():
         volumes_frame[key] = value
     # volumes_frame['hemisphere'] = volumes_frame['hemisphere'].astype('category')

+ 2 - 1
setup.py

@@ -36,7 +36,8 @@ setuptools.setup(
         ],
     },
     install_requires=[
-        'pandas',
+        # pandas.DataFrame.drop(columns=[...], ...)
+        'pandas>=0.21.0',
     ],
     setup_requires=[
         'setuptools_scm',

+ 1 - 0
tests/hippocampus_test.py

@@ -158,6 +158,7 @@ def assert_main_volume_frame_equals(capsys, argv: list, expected_frame: pandas.D
     out, _ = capsys.readouterr()
     assert_volume_frames_equal(
         left=expected_frame,
+        # pandas.DataFrame.drop(columns=[...], ...) >= pandas0.21.0
         right=pandas.read_csv(io.StringIO(out)).drop(columns=['source_path']),
     )