I am having issues with Pytheos, I am trying to run file "10_pvt-eos_fit" with my data but I get an error message when I get to part 4. I copied my data in the example data set excel file, I did not change anything in the code, except for the data file title.
I figured the error happens only when the last number of the example data is changed. For example, the example data set has 84 rows of values, if I change the first 83 rows to my values I don't get an error message. The error happens when I change the last row. I compared the statistics of the example data set to my data and I cannot understand why this happens. I also tried to add a line of code where the last row is ignored, so I can obtain the fit for my data only, but I get the same error message. I also made sure the format of the numbers in the excel document is consistent in my file.
I think it may be a bug in the package.
The error is:
TypeError Traceback (most recent call last)
File ~/opt/anaconda3/lib/python3.9/site-packages/uncertainties/core.py:3297, in ufloat(nominal_value, std_dev, tag)
3295 try:
3296 # Standard case:
-> 3297 return Variable(nominal_value, std_dev, tag=tag)
3298 # Exception types raised by, respectively: tuple or string that
3299 # can be converted through float() (case of a number with no
3300 # uncertainty), and string that cannot be converted through
3301 # float():
File ~/opt/anaconda3/lib/python3.9/site-packages/uncertainties/core.py:2778, in Variable.init(self, value, std_dev, tag)
2776 super(Variable, self).init(value, LinearCombination({self: 1.}))
-> 2778 self.std_dev = std_dev # Assignment through a Python property
2780 self.tag = tag
File ~/opt/anaconda3/lib/python3.9/site-packages/uncertainties/core.py:2798, in Variable.std_dev(self, std_dev)
2790 @std_dev.setter
2791 def std_dev(self, std_dev):
2792
(...)
2796 # separately for NaN. But this is not guaranteed, even if it
2797 # should work on most platforms.)
-> 2798 if std_dev < 0 and not isinfinite(std_dev):
2799 raise NegativeStdDev("The standard deviation cannot be negative")
TypeError: '<' not supported between instances of 'NoneType' and 'int'
During handling of the above exception, another exception occurred:
AttributeError Traceback (most recent call last)
Input In [18], in <cell line: 1>()
22 print(fit_result.fit_report())
23 # plot fitting results
---> 24 eos.plot.thermal_fit_result(fit_result, p_err=unp.std_devs(p), v_err=unp.std_devs(v), title=key)
File ~/opt/anaconda3/lib/python3.9/site-packages/pytheos/plot/thermal_fit.py:109, in thermal_fit_result(fit_result, v_residual, v_label, temp_fitline, figsize, height_ratios, ms_data, p_err, v_err, cbar_loc, pdf_filen, title)
107 p_data = fit_result.data
108 p_datafit = fit_result.best_fit
--> 109 v0 = uct.ufloat(fit_result.params['st_v0'].value,
110 fit_result.params['st_v0'].stderr)
111 sm = plt.cm.ScalarMappable(cmap=c_map,
112 norm=plt.Normalize(
113 vmin=300., vmax=temp_data.max()))
114 a = sm.to_rgba(temp_fitline)
File ~/opt/anaconda3/lib/python3.9/site-packages/uncertainties/core.py:3310, in ufloat(nominal_value, std_dev, tag)
3307 tag_arg = std_dev # 2 positional arguments form
3309 try:
-> 3310 final_ufloat = ufloat_obsolete(nominal_value, tag_arg)
3311 except: # The input is incorrect, not obsolete
3312 raise
File ~/opt/anaconda3/lib/python3.9/site-packages/uncertainties/core.py:3253, in ufloat_obsolete(representation, tag)
3251 return ufloat(representation[0], representation[1], tag)
3252 else:
-> 3253 return ufloat_fromstr(representation, tag)
File ~/opt/anaconda3/lib/python3.9/site-packages/uncertainties/core.py:3237, in ufloat_fromstr(representation, tag)
3177 def ufloat_fromstr(representation, tag=None):
3178 """
3179 Return a new random variable (Variable object) from a string.
3180
(...)
3233 uncertainty on the last digits of the nominal value).
3234 """
3236 (nominal_value, std_dev) = str_to_number_with_uncert(
-> 3237 representation.strip())
3239 return ufloat(nominal_value, std_dev, tag)
AttributeError: 'float' object has no attribute 'strip'
I am having issues with Pytheos, I am trying to run file "10_pvt-eos_fit" with my data but I get an error message when I get to part 4. I copied my data in the example data set excel file, I did not change anything in the code, except for the data file title.
I figured the error happens only when the last number of the example data is changed. For example, the example data set has 84 rows of values, if I change the first 83 rows to my values I don't get an error message. The error happens when I change the last row. I compared the statistics of the example data set to my data and I cannot understand why this happens. I also tried to add a line of code where the last row is ignored, so I can obtain the fit for my data only, but I get the same error message. I also made sure the format of the numbers in the excel document is consistent in my file.
I think it may be a bug in the package.
The error is:
TypeError Traceback (most recent call last)
File ~/opt/anaconda3/lib/python3.9/site-packages/uncertainties/core.py:3297, in ufloat(nominal_value, std_dev, tag)
3295 try:
3296 # Standard case:
-> 3297 return Variable(nominal_value, std_dev, tag=tag)
3298 # Exception types raised by, respectively: tuple or string that
3299 # can be converted through float() (case of a number with no
3300 # uncertainty), and string that cannot be converted through
3301 # float():
File ~/opt/anaconda3/lib/python3.9/site-packages/uncertainties/core.py:2778, in Variable.init(self, value, std_dev, tag)
2776 super(Variable, self).init(value, LinearCombination({self: 1.}))
-> 2778 self.std_dev = std_dev # Assignment through a Python property
2780 self.tag = tag
File ~/opt/anaconda3/lib/python3.9/site-packages/uncertainties/core.py:2798, in Variable.std_dev(self, std_dev)
2790 @std_dev.setter
2791 def std_dev(self, std_dev):
2792
(...)
2796 # separately for NaN. But this is not guaranteed, even if it
2797 # should work on most platforms.)
-> 2798 if std_dev < 0 and not isinfinite(std_dev):
2799 raise NegativeStdDev("The standard deviation cannot be negative")
TypeError: '<' not supported between instances of 'NoneType' and 'int'
During handling of the above exception, another exception occurred:
AttributeError Traceback (most recent call last)
Input In [18], in <cell line: 1>()
22 print(fit_result.fit_report())
23 # plot fitting results
---> 24 eos.plot.thermal_fit_result(fit_result, p_err=unp.std_devs(p), v_err=unp.std_devs(v), title=key)
File ~/opt/anaconda3/lib/python3.9/site-packages/pytheos/plot/thermal_fit.py:109, in thermal_fit_result(fit_result, v_residual, v_label, temp_fitline, figsize, height_ratios, ms_data, p_err, v_err, cbar_loc, pdf_filen, title)
107 p_data = fit_result.data
108 p_datafit = fit_result.best_fit
--> 109 v0 = uct.ufloat(fit_result.params['st_v0'].value,
110 fit_result.params['st_v0'].stderr)
111 sm = plt.cm.ScalarMappable(cmap=c_map,
112 norm=plt.Normalize(
113 vmin=300., vmax=temp_data.max()))
114 a = sm.to_rgba(temp_fitline)
File ~/opt/anaconda3/lib/python3.9/site-packages/uncertainties/core.py:3310, in ufloat(nominal_value, std_dev, tag)
3307 tag_arg = std_dev # 2 positional arguments form
3309 try:
-> 3310 final_ufloat = ufloat_obsolete(nominal_value, tag_arg)
3311 except: # The input is incorrect, not obsolete
3312 raise
File ~/opt/anaconda3/lib/python3.9/site-packages/uncertainties/core.py:3253, in ufloat_obsolete(representation, tag)
3251 return ufloat(representation[0], representation[1], tag)
3252 else:
-> 3253 return ufloat_fromstr(representation, tag)
File ~/opt/anaconda3/lib/python3.9/site-packages/uncertainties/core.py:3237, in ufloat_fromstr(representation, tag)
3177 def ufloat_fromstr(representation, tag=None):
3178 """
3179 Return a new random variable (Variable object) from a string.
3180
(...)
3233 uncertainty on the last digits of the nominal value).
3234 """
3236 (nominal_value, std_dev) = str_to_number_with_uncert(
-> 3237 representation.strip())
3239 return ufloat(nominal_value, std_dev, tag)
AttributeError: 'float' object has no attribute 'strip'