bcych / BiCEP_GUI

GUI for using the BiCEP method (Cych et al, 2021) on paleointensity data.
5 stars 3 forks source link

generate_arai_plot_table function error #2

Closed duserzym closed 3 years ago

duserzym commented 3 years ago

I was trying to follow your _BC01 Bias Corrected Estimation of Paleointensity notebook but line BiCEP.generate_arai_plot_table('example_data') failed to execute and threw error: Cannot interpret '<attribute 'dtype' of 'numpy.generic' objects>' as a data type. I am using the most recent Pmagpy package pulled from the Github project page.

Full error message:


AttributeError Traceback (most recent call last) ~/Github/PmagPy/pmagpy/contribution_builder.py in init(self, directory, read_tables, custom_filenames, single_file, dmodel, vocabulary) 39 try: ---> 40 self.data_model = Contribution.dmodel 41 except AttributeError:

AttributeError: type object 'Contribution' has no attribute 'dmodel'

During handling of the above exception, another exception occurred:

TypeError Traceback (most recent call last)

in ----> 1 BiCEP.generate_arai_plot_table('example_data') ~/Github/BiCEP_GUI/modules_and_scripts/BiCEP_functions.py in generate_arai_plot_table(outputname) 1281 """ 1282 #This cell constructs the 'measurements' dataframe with samples and sites added -> 1283 status,measurements=cb.add_sites_to_meas_table('./') 1284 measurements=measurements[measurements.specimen.str.contains('#')==False] 1285 measurements_old=measurements ~/Github/PmagPy/pmagpy/contribution_builder.py in add_sites_to_meas_table(dir_path) 2383 """ 2384 reqd_tables = ['measurements', 'specimens', 'samples', 'sites'] -> 2385 con = Contribution(dir_path, read_tables=reqd_tables) 2386 # check that all required tables are available 2387 missing_tables = [] ~/Github/PmagPy/pmagpy/contribution_builder.py in __init__(self, directory, read_tables, custom_filenames, single_file, dmodel, vocabulary) 40 self.data_model = Contribution.dmodel 41 except AttributeError: ---> 42 Contribution.dmodel = data_model.DataModel() 43 self.data_model = Contribution.dmodel 44 if isinstance(vocabulary, cv.Vocabulary): ~/Github/PmagPy/pmagpy/data_model3.py in __init__(self, offline) 26 self.offline = offline 27 if not len(DM): ---> 28 self.dm, self.crit_map = self.get_data_model() 29 DM = self.dm 30 CRIT_MAP = self.crit_map ~/Github/PmagPy/pmagpy/data_model3.py in get_data_model(self) 48 print('-I- Using online data model') 49 #self.cache_data_model(dm) ---> 50 return self.parse_response(dm) 51 # if online is not available, get cached dm 52 dm = self.get_dm_offline() ~/Github/PmagPy/pmagpy/data_model3.py in parse_response(self, raw) 179 tables = raw.json()['tables'] 180 crit = raw.json()['criteria_map'] --> 181 return self.parse(tables, crit) 182 183 ~/Github/PmagPy/pmagpy/data_model3.py in parse(self, data_model, crit) 156 for table_name in ['measurements', 'specimens', 'samples', 'sites', 'locations', 157 'contribution', 'criteria', 'images', 'ages']: --> 158 crit_map.loc[table_name] = np.nan 159 160 return data_model, crit_map ~/anaconda3/lib/python3.7/site-packages/pandas/core/indexing.py in __setitem__(self, key, value) 668 key = com.apply_if_callable(key, self.obj) 669 indexer = self._get_setitem_indexer(key) --> 670 self._setitem_with_indexer(indexer, value) 671 672 def _validate_key(self, key, axis: int): ~/anaconda3/lib/python3.7/site-packages/pandas/core/indexing.py in _setitem_with_indexer(self, indexer, value) 872 873 if missing: --> 874 return self._setitem_with_indexer_missing(indexer, value) 875 876 # set ~/anaconda3/lib/python3.7/site-packages/pandas/core/indexing.py in _setitem_with_indexer_missing(self, indexer, value) 1118 raise ValueError("cannot set a row with mismatched columns") 1119 -> 1120 value = Series(value, index=self.obj.columns, name=indexer) 1121 1122 self.obj._data = self.obj.append(value)._data ~/anaconda3/lib/python3.7/site-packages/pandas/core/series.py in __init__(self, data, index, dtype, name, copy, fastpath) 303 data = data.copy() 304 else: --> 305 data = sanitize_array(data, index, dtype, copy, raise_cast_failure=True) 306 307 data = SingleBlockManager(data, index, fastpath=True) ~/anaconda3/lib/python3.7/site-packages/pandas/core/construction.py in sanitize_array(data, index, dtype, copy, raise_cast_failure) 463 value = maybe_cast_to_datetime(value, dtype) 464 --> 465 subarr = construct_1d_arraylike_from_scalar(value, len(index), dtype) 466 467 else: ~/anaconda3/lib/python3.7/site-packages/pandas/core/dtypes/cast.py in construct_1d_arraylike_from_scalar(value, length, dtype) 1459 value = ensure_str(value) 1460 -> 1461 subarr = np.empty(length, dtype=dtype) 1462 subarr.fill(value) 1463 TypeError: Cannot interpret '' as a data type
duserzym commented 3 years ago

This issue is related to the pandas version. Updating pandas from 1.0.1 to 1.3.2 solved the problem.