Coder Social home page Coder Social logo

Issue on "from_peakssuite" about swprocess HOT 2 CLOSED

seguj avatar seguj commented on September 20, 2024
Issue on "from_peakssuite"

from swprocess.

Comments (2)

jpvantassel avatar jpvantassel commented on September 20, 2024

Hi @seguj,

You have diagnosed the issue correctly, each Peak object must be associated with a unique identifier. When you load from a .max file that unique identifier is the start time of the associated time window. As you have processed your data twice, once with RTBF and once with FK and loaded the two associated .max files into two PeakSuite objects both contain the same identifiers and therefore cannot be merged into a single PeakSuite object.

In regards to a solution, I would suggest simply renaming the identifier so that each Peak in the PeakSuite will be unique. A clear and easy way to do this would be to loop across all the Peak objects in the PeakSuite and append an "rtbf" or "fk" to the end of each of the current identifiers to ensure they are unique. Once you have done this, you can merge the two PeakSuites together into a single PeakSuite.

All the best,
Joe

from swprocess.

seguj avatar seguj commented on September 20, 2024

Dear, Joseph

Thanks for the fast reply!

As you recommended, I simply modified 'from_json' in 'PeaksSuite.'
I'm attaching that code for anyone facing the same issue.

def from_json(cls, fnames, label):
    if isinstance(fnames, str):
        fnames = [fnames]

    try:
        iter(fnames)
    except TypeError:
        fnames = [str(fnames)]

    dicts = []
    print(fnames)
    for fname in fnames):
        with open(fname, "r") as f:
            _data = json.load(f)
            _keys = [key for key in _data]
            _keys_label = [f'{key}.{label}' for key in _data]
            for _key, _key_label in zip(_keys, _keys_label):
                _data[_key_label] = _data.pop(_key)
            dicts.append(_data)
            
            # dicts.append(json.load(f))
    return cls.from_dict(dicts)

Best regards,
Youngjun

from swprocess.

Related Issues (20)

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.