gslab-econ / gslab_python

Python tools for GSLab
MIT License
13 stars 11 forks source link

PR for #183: Updated tests for SaveData in Python #185

Closed liaochris closed 2 months ago

liaochris commented 3 months ago

In https://github.com/gslab-econ/gslab_python/issues/183, I updated the unit tests for SaveData in Python to match the unit tests done in gslab_r. I also changed the test data to use data.csv from gslab_r.

liaochris commented 3 months ago

@zhizhongpu the previous version of test_main.py that you tested did not contain the new tests. When reviewing, please verify that when you run python test_main.py from gslab_misc/SaveData/tests that the tests all still pass.

Your output should match the one below

(base) cliao@cliao-J42WFDJVXF tests % python test_main.py
.The following keys are missing in some rows: num .
.........
----------------------------------------------------------------------
Ran 10 tests in 0.056s

OK
zhizhongpu commented 3 months ago

@liaochris

(base) zpu-mbp:gslab_python zpu$ cd gslab_misc/SaveData/tests
(base) zpu-mbp:tests zpu$ python test_main.py
Traceback (most recent call last):
  File "/Users/zpu/Documents/gh/gslab_python/gslab_misc/SaveData/tests/test_main.py", line 11, in <module>
    pd.set_option('future.no_silent_downcasting', True)
  File "/opt/anaconda3/lib/python3.11/site-packages/pandas/_config/config.py", line 272, in __call__
    return self.__func__(*args, **kwds)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/anaconda3/lib/python3.11/site-packages/pandas/_config/config.py", line 167, in _set_option
    key = _get_single_key(k, silent)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/anaconda3/lib/python3.11/site-packages/pandas/_config/config.py", line 132, in _get_single_key
    raise OptionError(f"No such keys(s): {repr(pat)}")
pandas._config.config.OptionError: No such keys(s): 'future.no_silent_downcasting'

Please react to this post if/when you start debugging this; I'll circle back to this at another time

liaochris commented 3 months ago

@zhizhongpu Can you run pip install . --use-pep517 in your root repo directory? It might be related to a pandas version issue.

zhizhongpu commented 3 months ago

thanks @liaochris the pip install didn't work but I switched to another conda environment and

(wo) zpu-mbp:tests zpu$ python test_main.py
.The following keys are missing in some rows: num .
.........
----------------------------------------------------------------------
Ran 10 tests in 0.053s

OK
(wo) zpu-mbp:tests zpu$
liaochris commented 3 months ago

@zhizhongpu interesting, what happens if you upgrade the pandas in your environment? pip install -U pandas.

liaochris commented 2 months ago

Summary comment: https://github.com/gslab-econ/gslab_python/issues/183#issuecomment-2315713707