Code Monkey home page Code Monkey logo

Comments (3)

mckfarm avatar mckfarm commented on June 24, 2024 1

Works perfectly, thank you!

from qsdsan.

yalinli2 avatar yalinli2 commented on June 24, 2024

Hi @mckfarm great question! The better way to save the Components objs to be used elsewhere is actually by saving/loading them as pickles (a lot of things happen when creating and compiling components, so direct reverse engineering is hard), you can use qs.utils.save_pickle and qs.utils.load_pickle instead.

To save as pickle files

>>> from qsdsan.utils import create_example_components, save_pickle
>>> cmps = create_example_components()
>>> cmps.show()
CompiledComponents([H2O, CO2, N2O, NaCl, H2SO4, CH4, Methanol, Ethanol])
>>> save_pickle(cmps, 'components') # make sure you know the saved path

Then in another kernel session, you can reload the pickle file by

>>> from qsdsan.utils import load_pickle
>>> cmps_copy = load_pickle('components')
>>> cmps_copy.show()
CompiledComponents([H2O, CO2, N2O, NaCl, H2SO4, CH4, Methanol, Ethanol])

However, when looking at your question, I realized that there seems to be a block missing on the tutorial you pointed to, and there was no documentation on those pickle functions, there was also a load_pickled_cmps function that's confusing (you can ignore this function for now).

I'll keep this issue open as a reminder to update these docs (hopefully this weekend?), thank you!

from qsdsan.

yalinli2 avatar yalinli2 commented on June 24, 2024

Done & closed with 126498c

from qsdsan.

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.