pr-omethe-us / PyKED

Python interface to the ChemKED database format
https://pr-omethe-us.github.io/PyKED/
BSD 3-Clause "New" or "Revised" License
14 stars 15 forks source link

Uncertainty in time-histories #116

Open jsantner opened 6 years ago

jsantner commented 6 years ago

Background

While working on #115 , I had gotten to a point where I thought I had solved my issues - the error message had changed significantly but all Travis tests passed. I figured I now had some problem with my particular input file. But, after working further, it seems there is an issue when using uncertainty in time-histories. Am I formatting the uncertainty incorrectly somehow? Should I just skip the validation step? Or, is PyKED unable to handle uncertainty in time-histories?

Code sample, preferably able to be copy-pasted and run with no changes

See my forked version of the code here: https://github.com/jsantner/PyKED/tree/uncertainty In this commit, I altered one of the yaml files to include uncertainty in the time history:

time-histories:
       - type: volume
         time:
           units: s
           column: 0
         quantity:
           units: cm3
           column: 1
        uncertainty:  
            type: relative
            value: 0.01
         values:
           filename: rcm_history.csv 

Expected behavior

I didn't expect any error messages

Actual behavior, including any error messages

I receive the following traceback, with equivalent results in the Travis job linked here.

  File "C:/Users/jsantne/Documents/GitHub/rcm-workshop/workshop.py", line 84, in load_files
    database.append(pyked.ChemKED(fpath))

  File "c:\users\jsantne\documents\github\pyked-jsantner\pyked\chemked.py", line 122, in __init__
    self.validate_yaml(self._properties)

  File "c:\users\jsantne\documents\github\pyked-jsantner\pyked\chemked.py", line 183, in validate_yaml
    for key, value in validator.errors.items():

  File "C:\Users\jsantne\AppData\Local\Continuum\Anaconda3\lib\site-packages\cerberus\validator.py", line 391, in errors
    return self.error_handler(self._errors)

  File "C:\Users\jsantne\AppData\Local\Continuum\Anaconda3\lib\site-packages\cerberus\errors.py", line 473, in __call__
    self.extend(errors)

  File "C:\Users\jsantne\AppData\Local\Continuum\Anaconda3\lib\site-packages\cerberus\errors.py", line 375, in extend
    self.add(error)

  File "C:\Users\jsantne\AppData\Local\Continuum\Anaconda3\lib\site-packages\cerberus\errors.py", line 482, in add
    self.insert_logic_error(error)

  File "C:\Users\jsantne\AppData\Local\Continuum\Anaconda3\lib\site-packages\cerberus\errors.py", line 549, in insert_logic_error
    raise NotImplementedError

NotImplementedError

PyKED/ChemKED version, Python version, OS version

PyKED version: my own forked repo that can read csv files for tiem history Python version: 3.6 OS version: Windows 10

bryanwweber commented 6 years ago

What version of Cerberus do you have installed? You should install 1.1 (but not 1.2, because that's broken for another reason).

It looks like your spacing is not correct, the uncertainty key needs to be vertically aligned with the time key. Make sure you're using spaces, not tabs, to handle the indentation.

bryanwweber commented 6 years ago

If you really want to get into the weeds of fixing this and related issues, we're discussing changing how the validation works over here: https://github.com/pr-omethe-us/PyKED/issues/103

jsantner commented 6 years ago

I have Cerberus 1.1. I saw that my error is added to the list of errors instead of being raised in cerberus 1.2, but like you said - 1.2 is broken for another reason. I fixed my spacing, but it still doesn't work (see here: https://travis-ci.org/jsantner/PyKED/builds/392733269). Do you have any examples including uncertainty in time-history that don't raise a NotImplementedError?

For now, I'll just have to use skip_validation=True

I'll look at #103 and get involved there, thanks.