Pandas 2.0 breaks some tests
cdeline opened this issue · 6 comments
There is a release candidate out Pandas 2.0.0rc0 which breaks some tests:
FAILED tests/test_bifacial_radiance.py::test_readWeatherFile_subhourly - TypeError: Could not convert 01.01.2020 to numeric
FAILED tests/test_mismatch.py::test_MAD - NotImplementedError
FAILED tests/test_mismatch.py::test_analysisIrradianceandPowerMismatch - NotImplementedError
Traceback on the first issue, stated issue is TypeError: Could not convert '01.01.2020' to numeric
The above exception was the direct cause of the following exception:
def test_readWeatherFile_subhourly():
# need to test out is_leap_and_29Feb and _subhourlydatatoGencumskyformat
# and len(tmydata) != 8760 and _readSOLARGIS
name = "_test_readWeatherFile_subhourly_gencumsky"
demo = bifacial_radiance.RadianceObj(name)
-> metdata = demo.readWeatherFile(weatherFile=MET_FILENAME4, source='solargis', tz_convert_val= 2 )
C:\Users\cdeline\Documents\Python Scripts\Bifacial_Radiance\tests\test_bifacial_radiance.py:545:
C:\Users\cdeline\Documents\Python Scripts\Bifacial_Radiance\bifacial_radiance\main.py:950: in readWeatherFile
tmydata_trunc = self._saveTempTMY(metdata, filename=tempMetDatatitle,
C:\Users\cdeline\Documents\Python Scripts\Bifacial_Radiance\bifacial_radiance\main.py:1086: in _saveTempTMY
gencumskydata = _subhourlydatatoGencumskyformat(gencumskydata,
C:\Users\cdeline\Documents\Python Scripts\Bifacial_Radiance\bifacial_radiance\main.py:267: in _subhourlydatatoGencumskyformat
gencumskydata = gencumskydata.resample('60T', closed='right', label='right').mean()
Traceback on the second issue. this is related to implementation of mad_fn
which apparently needs to be updated for Pandas 2.0
def test_MAD():
assert bifacial_radiance.mismatch.mad_fn(TEST_ARRAY) == \
pytest.approx(2433.333,abs = 0.001)
->temp = bifacial_radiance.mismatch.mad_fn(pd.DataFrame(TEST_ARRAY))
C:\Users\cdeline\Documents\Python Scripts\Bifacial_Radiance\tests\test_mismatch.py:56:
C:\Users\cdeline\Documents\Python Scripts\Bifacial_Radiance\bifacial_radiance\mismatch.py:188: in mad_fn
return (np.abs(np.subtract.outer(data,data)).sum()/float(data.len())**2 / np.mean(data))*100
C:\Users\cdeline.conda\envs\pandas2\Lib\site-packages\pandas\core\generic.py:1995: in array_ufunc
return arraylike.array_ufunc(self, ufunc, method, *inputs, **kwargs)
Traceback on the third issue, also due to mad_fn
breaking with Pandas 2.0:
def test_analysisIrradianceandPowerMismatch():
#analysisIrradianceandPowerMismatch(testfolder, writefiletitle,
# portraitorlandscape, bififactor,
# numcells=72, downsamplingmethod='byCenter'):
#testfolder = r'C:\Users\cdeline\Documents\Python Scripts\Bifacial_Radiance\tests\results_mismatch'
#writefiletitle = r'C:\Users\cdeline\Documents\Python Scripts\Bifacial_Radiance\tests\mismatch.txt'
testfolder = os.path.join(TESTDIR,'results_mismatch')
writefiletitle = os.path.join(TESTDIR,'mismatch.txt')
-> bifacial_radiance.mismatch.analysisIrradianceandPowerMismatch(testfolder, writefiletitle,
'portrait', bififactor=1,
numcells=72, downsamplingmethod='byCenter')
C:\Users\cdeline\Documents\Python Scripts\Bifacial_Radiance\tests\test_mismatch.py:74:
C:\Users\cdeline\Documents\Python Scripts\Bifacial_Radiance\bifacial_radiance\mismatch.py:325: in analysisIrradianceandPowerMismatch
dfst['MAD/G_Total'] = mad_fn(Poat.T)
C:\Users\cdeline\Documents\Python Scripts\Bifacial_Radiance\bifacial_radiance\mismatch.py:188: in mad_fn
return (np.abs(np.subtract.outer(data,data)).sum()/float(data.len())**2 / np.mean(data))*100
#439 also had an issue with solargis, tagging issue in case solving this pandas solves that one
This is now breaking tests in main. Until this gets fixed, I'm updating setup.py for pandas < 2.0.