pyFAI
pyFAI copied to clipboard
please add support for pathlib in pyFAI
Hello, when using pathlib instead of a str in pyFAI.load, I get this error message.
It would be nice to support out of the box pathlib :)
PONI = PUBLISHED / "scan_0567_0002_0.poni"
ai = pyFAI.load(PONI)
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-15-49f83512f163> in <module>()
1 PONI = PUBLISHED / "scan_0567_0002_0.poni"
2
----> 3 ai = pyFAI.load(PONI)
4
5 fns = [ROOT / "scan_{:04d}_01.nxs".format(i) for i in range(567)]
/usr/lib/python3/dist-packages/pyFAI/__init__.py in load(filename)
83 """
84 from .azimuthalIntegrator import AzimuthalIntegrator
---> 85 return AzimuthalIntegrator.sload(filename)
86
87
/usr/lib/python3/dist-packages/pyFAI/geometry.py in sload(cls, filename)
1192 """
1193 inst = cls()
-> 1194 inst.load(filename)
1195 return inst
1196
/usr/lib/python3/dist-packages/pyFAI/geometry.py in load(self, filename)
1203 :return: itself with updated parameters
1204 """
-> 1205 poni = ponifile.PoniFile(data=filename)
1206 self._init_from_poni(poni)
1207 return self
/usr/lib/python3/dist-packages/pyFAI/io/ponifile.py in __init__(self, data)
67 self.read_from_file(data)
68 else:
---> 69 self.read_from_duck(data)
70
71 def read_from_file(self, filename):
/usr/lib/python3/dist-packages/pyFAI/io/ponifile.py in read_from_duck(self, duck)
147 """
148 # TODO: It would be good to test attribute types
--> 149 self._dist = duck.dist
150 self._poni1 = duck.poni1
151 self._poni2 = duck.poni2
AttributeError: 'PurePosixPath' object has no attribute 'dist'
quite straight forwards ... PR welcome
In that case can you add a tag showing that this is trivial.
then I will ask my apprentice to look after these trivial changes.
thanks
Fred