CSVExporter now can export x- and y-axis errors#1805
CSVExporter now can export x- and y-axis errors#18053fon3fonov wants to merge 3 commits intopyqtgraph:masterfrom 3fon3fonov:exostriker_branch
Conversation
pyqtgraph/exporters/CSVExporter.py
Outdated
| {'name': 'separator', 'title': translate("Exporter", 'separator'), 'type': 'list', 'value': 'comma', 'values': ['comma', 'tab']}, | ||
| {'name': 'precision', 'title': translate("Exporter", 'precision'), 'type': 'int', 'value': 10, 'limits': [0, None]}, | ||
| {'name': 'columnMode', 'title': translate("Exporter", 'columnMode'), 'type': 'list', 'values': ['(x,y) per plot', '(x,y,y,y) for all plots']} | ||
| {'name': 'separator', 'type': 'list', 'value': 'comma', 'values': ['comma', 'tab']}, |
There was a problem hiding this comment.
for these sections can you re-add the sections 'title': translate("Exporter", 'separator') bits that you can see if you look at the removed lines? That code is what allows for i18n language translation compatability
There was a problem hiding this comment.
Sure! I have no idea why these are removed. I suspect I modified a bit older file.
| fd.write(' %s' % sep) | ||
|
|
||
| # write data e_y value | ||
| if d is not None and len(d)>2 and d[2] is not None and i < len(d[2]): |
There was a problem hiding this comment.
I'm not familiar with the exporters here much, can you detail what the data structure of d is like, and specifically what you're looking for in this if-statement?
|
Hi @3fon3fonov thanks for the PR! I left some in-line comments, I'm not that familiar with the CSV exporter, so I'm likely going to have some questions that may seem silly coming from a maintainer. Also, can you provide a working example of trying to use the CSV exporter and not having it provide the data you want? What would likely be easiest is if you modify one of the examples. I ask mostly because
Thanks again for the PR! |
|
|
||
| for indx, item in enumerate(self.item.items): | ||
|
|
||
| if self.item.items[indx].__class__.__name__ == "InfiniteLine": |
There was a problem hiding this comment.
instead of checking for classname and doing matchup, you can do ....
from ..GraphicsItems import InfiniteLine, FillBewteenItem, TextItem
...
if isinstance(item, (InfiniteLine, FillBetweenItem, TextItem)):
continueThere was a problem hiding this comment.
This leads to
from ..GraphicsItems import InfiniteLine, FillBewteenItem, TextItem
ModuleNotFoundError: No module named 'pyqtgraph.GraphicsItems'
| data[1].append(yerr) | ||
| data[1] = tuple(data[1]) | ||
|
|
||
| if "left" in self.item.items[indx].opts: |
There was a problem hiding this comment.
these if-statements have some near identical code, consider consolidating them.
One suggestion would be to use a for loop
for option in ['top', 'left']:
if option in item.opts:
err = item.opt[option]
data[1] = list(data[1]
data[1].append(err)
data[1] = tuple(data[1])|
Hi @3fon3fonov I added some more comments, also looks like something broke since the first commit you made. Lastly, could you add some comments to some of the things you're checking. For example, why are you filtering out items that are TextItem, InfiniteLine and FillBetweenItem. |
3fon3fonov
left a comment
There was a problem hiding this comment.
Hi @3fon3fonov
I added some more comments, also looks like something broke since the first commit you made.
Lastly, could you add some comments to some of the things you're checking. For example, why are you filtering out items that are TextItem, InfiniteLine and FillBetweenItem.
Sorry! I know it is taking too long to fix the issues in this git pull. I have not forgotten! I will look at these ASAP!
pyqtgraph/exporters/CSVExporter.py
Outdated
| {'name': 'separator', 'title': translate("Exporter", 'separator'), 'type': 'list', 'value': 'comma', 'values': ['comma', 'tab']}, | ||
| {'name': 'precision', 'title': translate("Exporter", 'precision'), 'type': 'int', 'value': 10, 'limits': [0, None]}, | ||
| {'name': 'columnMode', 'title': translate("Exporter", 'columnMode'), 'type': 'list', 'values': ['(x,y) per plot', '(x,y,y,y) for all plots']} | ||
| {'name': 'separator', 'type': 'list', 'value': 'comma', 'values': ['comma', 'tab']}, |
There was a problem hiding this comment.
Sure! I have no idea why these are removed. I suspect I modified a bit older file.
|
|
||
| for indx, item in enumerate(self.item.items): | ||
|
|
||
| if self.item.items[indx].__class__.__name__ == "InfiniteLine": |
There was a problem hiding this comment.
This leads to
from ..GraphicsItems import InfiniteLine, FillBewteenItem, TextItem
ModuleNotFoundError: No module named 'pyqtgraph.GraphicsItems'
|
Superseded by #2405 |
CSVExporter now can export x- and y-axis errors, if such are introduced by the ErrorBarItem. This is my fix, and it works well for the Exo-Striker tool. Yet, a more elegant code solution could exist.