Skip to content

CSVExporter now can export x- and y-axis errors#1805

Closed
3fon3fonov wants to merge 3 commits intopyqtgraph:masterfrom
3fon3fonov:exostriker_branch
Closed

CSVExporter now can export x- and y-axis errors#1805
3fon3fonov wants to merge 3 commits intopyqtgraph:masterfrom
3fon3fonov:exostriker_branch

Conversation

@3fon3fonov
Copy link
Copy Markdown
Contributor

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.

{'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']},
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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]):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

@j9ac9k
Copy link
Copy Markdown
Member

j9ac9k commented May 27, 2021

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

  1. I can verify it gives the output you expect under a use-case you expect
  2. It doesn't blow up on a different use-case.

Thanks again for the PR!


for indx, item in enumerate(self.item.items):

if self.item.items[indx].__class__.__name__ == "InfiniteLine":
Copy link
Copy Markdown
Member

@j9ac9k j9ac9k Jun 2, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

instead of checking for classname and doing matchup, you can do ....

from ..GraphicsItems import InfiniteLine, FillBewteenItem, TextItem

...


if isinstance(item, (InfiniteLine, FillBetweenItem, TextItem)):
    continue

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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])

@j9ac9k
Copy link
Copy Markdown
Member

j9ac9k commented Jun 2, 2021

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.

Copy link
Copy Markdown
Contributor Author

@3fon3fonov 3fon3fonov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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!

{'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']},
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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":
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This leads to

    from ..GraphicsItems import InfiniteLine, FillBewteenItem, TextItem
ModuleNotFoundError: No module named 'pyqtgraph.GraphicsItems'

@j9ac9k j9ac9k linked an issue Jul 15, 2021 that may be closed by this pull request
@j9ac9k
Copy link
Copy Markdown
Member

j9ac9k commented Sep 5, 2022

Superseded by #2405

@j9ac9k j9ac9k closed this Sep 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Error bars must be also exported with .csv export

2 participants