Giter Club home page Giter Club logo

prmdict's Introduction

Description

Module designed for loading and parsing Deal.II parameter files. The main class prmdict extends Python's native dict class to offer functionality specific to Deal.II parameter files.

Features

  • Load parameters from a file or string input
  • Serialize data structure to Deal.II .prm file
  • Find and set keys using hierarchical paths

Installation

Place the module in the appropriate directory and import it using Python's import statement.

Class Definitions

prmdict

Inherits from dict. Responsible for parsing and storing Deal.II parameters.

Methods

  • __init__ (file=None, file_path=None): Initializes the class, accepting a string or a file path as arguments.

  • parse(file): Reads a .prm file or string and populates the dictionary.

  • dict2prm(indentation_level=0): Converts the dictionary into a .prm compatible list of strings.

  • save_prm(file_path): Saves the current state to a .prm file at the specified path.

  • find_key_path(key): Searches for a given key in the dictionary and returns its hierarchical path.

  • set(path, value): Sets a value using a hierarchical path.

Example Usage

prm = prmdict(file_path="path/to/file.prm")
prm.set("path/to/key", value)
prm.save_prm("path/to/new_file.prm")

current_value = prm.find_key_path("some_key")

Current Limitations

  • If more than one subsection has the same key, find_key_path will not behave as expected.

prmdict's People

Contributors

gbdemiranda avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.