chmarti1 / PYroMat

PYroMat thermodynamic properties in Python
http://pyromat.org
Other
71 stars 13 forks source link

[Review] Example for pyromat.info() in docs does not work #55

Closed espottesmith closed 2 years ago

espottesmith commented 2 years ago

In the README, the following example is given:

>>> import pyromat as pm
>>> O2 = pm.get('ig.O2')
>>> h = O2.h(492,1.01)  # enthalpy at 492K, 1.01bar
>>> pm.info('O2')     # where did these data come from?
>>> pm.config['unit_pressure'] = 'psi'  # Don't like working in bar?

However, attempting the info() function with pyromat 2.2.1, I get an error:

PM ERR: No substanced named "O2" was found in the loaded data.
---------------------------------------------------------------------------
PMParamError                              Traceback (most recent call last)
Input In [19], in <cell line: 1>()
----> 1 pm.info('O2')

File ~/miniconda3/envs/romat/lib/python3.9/site-packages/pyromat/__init__.py:275, in info(members, target, **kwarg)
    273     members = [members]
    274 elif isinstance(members, str):
--> 275     members = [get(members)]
    277 # If operating verbosely, we'll need to print to stdout
    278 if target is None:

File ~/miniconda3/envs/romat/lib/python3.9/site-packages/pyromat/__init__.py:81, in get(idstr)
     79 if out is None:
     80     utility.print_error('No substanced named "' + str(idstr) + '" was found in the loaded data.')
---> 81     raise utility.PMParamError('Invalid substance ID string')
     82 return out

PMParamError: Invalid substance ID string

This is resolved if the phase is included (i.e. by running pm.info("ig.O2")).

Please change the README to reflect proper usage of the info() function, or else change info() to enable functionality without specifying phase information.

chmarti1 commented 2 years ago

Thanks for the heads-up. v2.2.0 changed the behavior of info() and I forgot to update the README to reflect the new UI. Good catch.