Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cmtj updates #77

Merged
merged 5 commits into from
Aug 24, 2024
Merged

Cmtj updates #77

merged 5 commits into from
Aug 24, 2024

Conversation

LemurPwned
Copy link
Owner

@LemurPwned LemurPwned commented Aug 24, 2024

Summary by Sourcery

Enhance the CMTJ simulator Streamlit app by adding a domain fitting feature and a navigation system for better user experience. Refactor the app's parameter input sections for improved organization and update the Dockerfile to support the new app structure. Introduce a devcontainer configuration to streamline the development environment setup.

New Features:

  • Introduce a new domain fitting feature in the Streamlit app, allowing users to fit M(H) data to a multidomain model.
  • Add a new navigation system in the Streamlit app with separate pages for domain fitting and spectrum fitting.

Enhancements:

  • Refactor the Streamlit app to use expanders for better organization of simulation parameters and layer parameters.
  • Improve the amplitude scan function in the linear utilities by optimizing the handling of forward and backward scans.

Build:

  • Update the Dockerfile to include the assets directory and change the command to run the new navigation script.

Deployment:

  • Add a devcontainer configuration for setting up a development environment with Python 3 and necessary extensions.

@LemurPwned LemurPwned merged commit 6d6fbd6 into master Aug 24, 2024
5 checks passed
Copy link

sourcery-ai bot commented Aug 24, 2024

Reviewer's Guide by Sourcery

This pull request implements several updates to the CMTJ simulator application, including UI improvements, new functionality for domain fitting, and changes to the application structure. The changes focus on enhancing user experience, adding new features, and improving code organization.

File-Level Changes

Change Details Files
Restructured the UI layout and improved user interaction
  • Moved the 'Number of layers' input to the sidebar
  • Grouped simulation parameters into expandable sections
  • Reorganized the sidebar layout for better clarity
  • Added expanders for layer parameters, interlayer parameters, and simulation & control parameters
view/streamlit_app.py
Added new domain fitting functionality
  • Created a new file for domain fitting implementation
  • Implemented UI for domain fitting parameters
  • Added simulation and rendering functions for domain fitting
  • Introduced file upload functionality for experimental data
view/domain.py
Improved simulation functions and utilities
  • Added a new function to create a single domain
  • Updated the amplitude_scan function to handle back-to-back scans
  • Added utility functions for reading M-H data
view/simulation_fns.py
cmtj/utils/linear.py
view/helpers.py
Restructured the application navigation
  • Created a new navigation file (nav.py) to manage multiple pages
  • Added support for domain fitting and spectrum fitting pages
  • Updated the Dockerfile to use the new navigation structure
view/nav.py
docker/Dockerfile.app
Added development container configuration
  • Created a devcontainer.json file for consistent development environments
  • Specified Python version, extensions, and port forwarding for the development container
.devcontainer/devcontainer.json

Tips
  • Trigger a new Sourcery review by commenting @sourcery-ai review on the pull request.
  • Continue your discussion with Sourcery by replying directly to review comments.
  • You can change your review settings at any time by accessing your dashboard:
    • Enable or disable the Sourcery-generated pull request summary or reviewer's guide;
    • Change the review language;
  • You can always contact us if you have any questions or feedback.

@LemurPwned LemurPwned deleted the cmtj-updates branch August 24, 2024 10:02
Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @LemurPwned - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider implementing a more robust state management solution to reduce reliance on Streamlit's session state for complex data.
  • The UI improvements and modularization are good. Consider further componentization to improve maintainability as the application grows.
Here's what I looked at during the review
  • 🟡 General issues: 3 issues found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.

@@ -12,6 +12,25 @@
VSD_procedure)


def create_single_domain(id_: str) -> Layer:
Copy link

Choose a reason for hiding this comment

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

suggestion: Improve modularity of create_single_domain function

Consider refactoring create_single_domain() to accept parameters instead of reading directly from st.session_state. This would improve modularity, make the function more reusable, and easier to test.

def create_single_domain(id_: str, anisotropy_axis: str, **kwargs) -> Layer:

@@ -6,6 +6,20 @@
from cmtj.utils import Filters


def read_mh_data():
Copy link

Choose a reason for hiding this comment

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

suggestion: Consider generalizing read_mh_data function

The read_mh_data() function is specific to a particular file format. Consider generalizing this function to handle various input formats, making it more flexible and reusable.

def read_data(file_format='mh'):
    filedata = st.session_state.upload.read().decode("utf-8")
    lines = filedata.split("\n")

    if file_format == 'mh':
        return parse_mh_data(lines)
    elif file_format == 'other_format':
        return parse_other_format(lines)
    else:
        raise ValueError(f"Unsupported file format: {file_format}")

@@ -0,0 +1,231 @@
from threading import RLock
Copy link

Choose a reason for hiding this comment

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

suggestion: Consider modularizing the domain.py file

The domain.py file is quite long and handles multiple responsibilities. Consider splitting it into smaller, more focused components to improve maintainability and readability.

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.

1 participant