Skip to content

Commit

Permalink
Merge pull request #140 from BCDA-APS/107-bug-test-files-some-crash-t…
Browse files Browse the repository at this point in the history
…he-app

Solve performance issues when loading folders
  • Loading branch information
rodolakis authored Jun 12, 2024
2 parents 7b693cb + 8e62556 commit 84cbaea
Show file tree
Hide file tree
Showing 31 changed files with 374 additions and 476 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ jobs:
name: mdaviz-docs
path: docs/build/html
# ${{ steps.deployment.outputs.artifact }}

- name: Publish (push gh-pages branch) only on demand
uses: peaceiris/actions-gh-pages@v4
if: ${{ github.event.inputs.deploy }}
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -172,4 +172,5 @@ dev_*.py
mdaviz/resources/*.py

# temporary files from Microsoft
~*
~*
Untitled.ipynb
24 changes: 24 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: check-toml
- id: check-ast
- id: check-merge-conflict
- id: check-added-large-files
- id: mixed-line-ending
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/kynan/nbstripout
rev: 0.7.1
hooks:
- id: nbstripout
- repo: https://github.com/astral-sh/ruff-pre-commit
# Ruff version.
rev: v0.3.2
hooks:
# Run the linter.
- id: ruff
args: [--fix]
# Run the formatter.
- id: ruff-format
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Python Qt5 application to visualize mda data.

GH tag | GH release | PyPI
--- | --- | ---
--- | --- | ---
[![tag](https://img.shields.io/github/tag/BCDA-APS/mdaviz.svg)](https://github.com/BCDA-APS/mdaviz/tags) | [![release](https://img.shields.io/github/release/BCDA-APS/mdaviz.svg)](https://github.com/BCDA-APS/mdaviz/releases) | [![PyPi](https://img.shields.io/pypi/v/mdaviz.svg)](https://pypi.python.org/pypi/mdaviz)

Python version(s) | Unit Tests | Code Coverage | License
Expand All @@ -20,5 +20,5 @@ For complete installation guide, see [https://bcda-aps.github.io/mdaviz/](https:

## Acknowledgements

"This product includes software produced by UChicago Argonne, LLC
"This product includes software produced by UChicago Argonne, LLC
under Contract No. DE-AC02-06CH11357 with the Department of Energy."
2 changes: 1 addition & 1 deletion docs/source/changes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@
Changes
=======

TODO
TODO
6 changes: 3 additions & 3 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ Documentation
:align: center
:figclass: align-center
:figwidth: 100%
Screenshot of the mdaviz GUI displaying sample data.

Screenshot of the mdaviz GUI displaying sample data.

.. toctree::
:maxdepth: 1
Expand Down Expand Up @@ -68,5 +68,5 @@ About
Acknowledgements
================

"This product includes software produced by UChicago Argonne, LLC
"This product includes software produced by UChicago Argonne, LLC
under Contract No. DE-AC02-06CH11357 with the Department of Energy."
2 changes: 1 addition & 1 deletion docs/source/license.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ License
=======

.. literalinclude:: ../../mdaviz/LICENSE
:language: text
:language: text
30 changes: 15 additions & 15 deletions mdaviz/LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,27 @@ BCDA, Advanced Photon Source, Argonne National Laboratory

OPEN SOURCE LICENSE

Redistribution and use in source and binary forms, with or without
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer. Software changes,
modifications, or derivative works, should be noted with comments and
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer. Software changes,
modifications, or derivative works, should be noted with comments and
the author and organization's name.

2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

3. Neither the names of UChicago Argonne, LLC or the Department of Energy
nor the names of its contributors may be used to endorse or promote
products derived from this software without specific prior written
3. Neither the names of UChicago Argonne, LLC or the Department of Energy
nor the names of its contributors may be used to endorse or promote
products derived from this software without specific prior written
permission.

4. The software and the end-user documentation included with the
4. The software and the end-user documentation included with the
redistribution, if any, must include the following acknowledgment:

"This product includes software produced by UChicago Argonne, LLC
"This product includes software produced by UChicago Argonne, LLC
under Contract No. DE-AC02-06CH11357 with the Department of Energy."

****************************************************************************
Expand All @@ -38,11 +38,11 @@ DISCLAIMER

THE SOFTWARE IS SUPPLIED "AS IS" WITHOUT WARRANTY OF ANY KIND.

Neither the United States GOVERNMENT, nor the United States Department
of Energy, NOR uchicago argonne, LLC, nor any of their employees, makes
any warranty, express or implied, or assumes any legal liability or
responsibility for the accuracy, completeness, or usefulness of any
information, data, apparatus, product, or process disclosed, or
Neither the United States GOVERNMENT, nor the United States Department
of Energy, NOR uchicago argonne, LLC, nor any of their employees, makes
any warranty, express or implied, or assumes any legal liability or
responsibility for the accuracy, completeness, or usefulness of any
information, data, apparatus, product, or process disclosed, or
represents that its use would not infringe privately owned rights.

****************************************************************************
12 changes: 3 additions & 9 deletions mdaviz/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ def gui(directory):

app = QtWidgets.QApplication(sys.argv)
main_window = MainWindow(directory=directory)
main_window.setStatus(
f"Application started, loading {pathlib.Path(directory).absolute()} ..."
)
main_window.setStatus(f"Application started, loading {pathlib.Path(directory).absolute()} ...")
main_window.show()
sys.exit(app.exec())

Expand Down Expand Up @@ -74,16 +72,12 @@ def main(): # for future command-line options

# Ensure the path is absolute (starts with a "/")
if not directory.startswith("/"):
print(
f"\n\nERROR: The specified directory is not an absolute path:\n\t{directory}\n"
)
print(f"\n\nERROR: The specified directory is not an absolute path:\n\t{directory}\n")
sys.exit(1)

# Check if the directory exists
if not directory_path.exists() or not directory_path.is_dir():
print(
f"\n\nERROR: The specified directory does not exist or is not a directory:\n\t{directory}\n"
)
print(f"\n\nERROR: The specified directory does not exist or is not a directory:\n\t{directory}\n")
sys.exit(1)

logging.basicConfig(level=options.log.upper())
Expand Down
23 changes: 5 additions & 18 deletions mdaviz/chartview.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
from functools import partial
from itertools import cycle
import numpy
from pathlib import Path
from PyQt5 import QtCore, QtWidgets
from . import utils

Expand Down Expand Up @@ -414,11 +413,7 @@ def calculateBasicMath(self, x_data, y_data):
x_at_y_min = x_array[y_min_index]
x_at_y_max = x_array[y_max_index]
# Calculate x_com and y_mean
x_com = (
numpy.sum(x_array * y_array) / numpy.sum(y_array)
if numpy.sum(y_array) != 0
else None
)
x_com = numpy.sum(x_array * y_array) / numpy.sum(y_array) if numpy.sum(y_array) != 0 else None
y_mean = numpy.mean(y_array)
return (x_at_y_min, y_min), (x_at_y_max, y_max), x_com, y_mean

Expand All @@ -430,9 +425,7 @@ def onRemoveCursor(self, cursor_num):
cross.remove()
self.cursors[cursor_num] = None
self.cursors[f"pos{cursor_num}"] = None
self.cursors[f"text{cursor_num}"] = (
"middle click" if cursor_num == 1 else "right click"
)
self.cursors[f"text{cursor_num}"] = "middle click" if cursor_num == 1 else "right click"
self.cursors["diff"] = "n/a"
self.cursors["midpoint"] = "n/a"
self.updateCursorInfo()
Expand Down Expand Up @@ -493,12 +486,8 @@ def calculateCursors(self):
delta_y = y2 - y1
midpoint_x = (x1 + x2) / 2
midpoint_y = (y1 + y2) / 2
self.cursors["diff"] = (
f"({utils.num2fstr(delta_x)}, {utils.num2fstr(delta_y)})"
)
self.cursors["midpoint"] = (
f"({utils.num2fstr(midpoint_x)}, {utils.num2fstr(midpoint_y)})"
)
self.cursors["diff"] = f"({utils.num2fstr(delta_x)}, {utils.num2fstr(delta_y)})"
self.cursors["midpoint"] = f"({utils.num2fstr(midpoint_x)}, {utils.num2fstr(midpoint_y)})"
self.updateCursorInfo()

def updateCursorInfo(self):
Expand All @@ -525,9 +514,7 @@ class CurveManager(QtCore.QObject):
curveUpdated = QtCore.pyqtSignal(
str, bool, bool
) # Emit curveID, recompute_y (bool) & update_x (bool) when a curve is updated
allCurvesRemoved = QtCore.pyqtSignal(
bool
) # Emit a doNotClearCheckboxes bool when all curve are removed
allCurvesRemoved = QtCore.pyqtSignal(bool) # Emit a doNotClearCheckboxes bool when all curve are removed

def __init__(self, parent=None):
super().__init__(parent)
Expand Down
4 changes: 1 addition & 3 deletions mdaviz/data_table_view.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
from PyQt5 import QtCore, QtWidgets
from . import utils
from PyQt5 import QtWidgets

HEADERS = ["X", "Y"]


class DataTableView(QtWidgets.QWidget):

def __init__(self, data, parent):
"""
This class is responsible for setting up a table view widget, managing the data displayed within it,
Expand Down
Loading

0 comments on commit 84cbaea

Please sign in to comment.