Giter Site home page Giter Site logo

ycecream's Introduction

Salabim is a Python library for object-oriented discrete event simulation (DES) and animation.

Introduction

Discrete event simulation (DES) finds applications in various logistical domains including production facilities, warehousing, airports, hospitals, mining, materials handling, steel mills, and computer network analysis.

Salabim follows a well-proven and intuitive process description method similar to Tomas and Must.
The package provides:

  • Components
  • Queues
  • Resources
  • Stores
  • States
  • Monitors for data collection and presentation
  • 2D and 3D animation (including video production) (see below)
  • Tracing facilities
  • Advanced statistical sampling

In contrast to some other Python DES packages, salabim does not require the use of yield statements for process control, making it more straightforward to use. Salabim has minimal requirements, especially when animation is disabled.

Some salabim animations

Features and documentation

  • Cross-platform support: salabim runs on Windows, macOS, Linux, iOS/iPadOS (Pythonista), and can even be used with "Python In Excel".
  • Comprehensive documentation: Visit www.salabim.org/manual for detailed documentation.

Resources

The salabim package can be found on GitHub: www.github.com/salabim/salabim

And on PyPI: https://pypi.org/project/salabim/

Contributing and Reporting Issues

Contributions to salabim are highly appreciated! You can contribute by issuing a pull request or submitting an issue on GitHub. Alternatively, you can use the salabim Google user group for discussions and reporting issues.

License

Salabim is licensed under the MIT License. For details, please refer to the LICENSE file.

Support

Ruud van der Ham, the core developer, is available and willing to help users with issues related to the package and modeling in general. He also provides services such as code and model reviews, consultancy, and training.

Getting Started

To start using salabim, visit www.salabim.org for installation instructions and further details.

Badges

PyPI PyPI - Python Version PyPI - Implementation PyPI - License Black GitHub last commit

ycecream's People

Contributors

salabim avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

ycecream's Issues

Coloring option

Do you have any thoughts on how I can easily add coloring to this library? Which method/function is best to do this in? Can I do this without modifying the library?

Question/Feature Request: return timing information only

I'd like to compare two functions loop1 and loop2, running each of them count times, and compare the average durations.

I've raised a separate issue about capturing the output e.g. y| returned None from loop1() in 0.414763 seconds and it's easy enough to parse that string to get just the duration 0.414763 as a float or datetime object, but I wondered if it would be an easy enough enhancement to add keyword argument e.g. x = y(loop(), duration_only=True) for users just wanting to record durations and do further analysis (calculate the mean, plot a graph comparing the two loops etc)?

Or have I just missed an easy way of achieving this from the README?

import requests
from ycecream import y

@y(show_exit=True, show_enter=False)
def loop1():
    x = page*count
    for i in range(len(x)):
        s=len(x)

@y(show_exit=True, show_enter=False)
def loop2():
    x = page*count
    lx = len(x)
    for i in range(lx):
        s = lx

if __name__ == "__main__":
    page = requests.get('https://www.bbc.co.uk/news').text
    count = 10
    for loop in [loop1, loop2]:
        results=[]
        for run in range(10):
            result = y(loop(), as_str=True, )
            results.append(result)
        print(results)

OUTPUT

y| returned None from loop1() in 0.414763 seconds
y| returned None from loop1() in 0.418484 seconds
y| returned None from loop1() in 0.408090 seconds
y| returned None from loop1() in 0.406661 seconds
y| returned None from loop1() in 0.418872 seconds
y| returned None from loop1() in 0.413751 seconds
y| returned None from loop1() in 0.418103 seconds
y| returned None from loop1() in 0.406673 seconds
y| returned None from loop1() in 0.406783 seconds
y| returned None from loop1() in 0.412694 seconds
['y| loop(): None\n', 'y| loop(): None\n', 'y| loop(): None\n', 'y| loop(): None\n', 'y| loop(): None\n', 'y| loop(): None\n', 'y| loop(): None\n', 'y| loop(): None\n', 'y| loop(): None\n', 'y| loop(): None\n']        
y| returned None from loop2() in 0.157985 seconds
y| returned None from loop2() in 0.158627 seconds
y| returned None from loop2() in 0.160737 seconds
y| returned None from loop2() in 0.165181 seconds
y| returned None from loop2() in 0.171878 seconds
y| returned None from loop2() in 0.165958 seconds
y| returned None from loop2() in 0.164515 seconds
y| returned None from loop2() in 0.160872 seconds
y| returned None from loop2() in 0.160113 seconds
y| returned None from loop2() in 0.165789 seconds
['y| loop(): None\n', 'y| loop(): None\n', 'y| loop(): None\n', 'y| loop(): None\n', 'y| loop(): None\n', 'y| loop(): None\n', 'y| loop(): None\n', 'y| loop(): None\n', 'y| loop(): None\n', 'y| loop(): None\n']        

Make ycecream work from REPL

As of now, ycecream doesn't work from a REPL. (Neither does IceCream).
Some more research is required to see whether and how REPLs could be supported.

Decorator args can't be over-written?

I might be just implementing this badly but it seems like a function decorated with y() can be overwritten using y.configure(**kwargs) but can't be overwritten with y(func, **kwargs). See line highlighed with # below:

import requests
from ycecream import y

@y()
def loop1():
    x = page*count
    for i in range(len(x)):
        s=len(x)

@y()
def loop2():
    x = page*count
    lx = len(x)
    for i in range(lx):
        s = lx

if __name__ == "__main__":
    page = requests.get('https://www.bbc.co.uk/news').text
    count = 10
    for loop in [loop1, loop2]:
        results=[]
        for run in range(10):
            #
            result = y(loop(), as_str=True, show_exit=False, show_enter=False)
            #
            results.append(result)
        print(results)
y| called loop1()
y| returned None from loop1() in 0.389231 seconds
y| called loop1()
y| returned None from loop1() in 0.402950 seconds
y| called loop1()
y| returned None from loop1() in 0.408621 seconds
y| called loop1()
y| returned None from loop1() in 0.388503 seconds
y| called loop1()
y| returned None from loop1() in 0.400655 seconds
y| called loop1()
y| returned None from loop1() in 0.393405 seconds
y| called loop1()
y| returned None from loop1() in 0.392923 seconds
y| called loop1()
y| returned None from loop1() in 0.388210 seconds
y| called loop1()
y| returned None from loop1() in 0.383815 seconds
y| called loop1()
y| returned None from loop1() in 0.408438 seconds
['y| loop(): None\n', 'y| loop(): None\n', 'y| loop(): None\n', 'y| loop(): None\n', 'y| loop(): None\n', 'y| loop(): None\n', 'y| loop(): None\n', 'y| loop(): None\n', 'y| loop(): None\n', 'y| loop(): None\n']  

Feature request: Hard line length limit

This is probably a weird request, because it's motivated by running on a weird platform:

Can we have a setting which very strictly enforces the line length limit? So, even if the value being printed is a single string and doesn't have any natural breaking/wrapping point, if it's too long to fit, then just truncate it or wrap it anyway?

TypeError: 'NoneType' object is not subscriptable

Getting TypeError: 'NoneType' object is not subscriptable when using the example usage on README:

from ycecream import y

def add2(i):
    return i + 2

y(add2(1000))

Full error message is:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/mylocaluser/test-ycecream/venv/lib/python3.8/site-packages/ycecream/ycecream.py", line 220, in __call__
    this_line = frame.code_context[0].strip()
TypeError: 'NoneType' object is not subscriptable

Using new isolated venv with the following packages and their versions:

Package    Version
---------- -------
pip        21.0.1
setuptools 49.2.1
ycecream   1.1.4

as_str=True not returning same output

I'm trying to catch just the 'exit' output with the ultimate goal of calculating and comparing the average run time of two functions (loop1 and loop2). When I set show_exit=True, show_enter=False the default output to screen is what I want to capture with as_str=True, but what I get is the default result y| loop(): None\n

import requests
from ycecream import y

@y(show_exit=True, show_enter=False)
def loop1():
    x = page*count
    for i in range(len(x)):
        s=len(x)

@y(show_exit=True, show_enter=False)
def loop2():
    x = page*count
    lx = len(x)
    for i in range(lx):
        s = lx

if __name__ == "__main__":
    page = requests.get('https://www.bbc.co.uk/news').text
    count = 10
    for loop in [loop1, loop2]:
        results=[]
        for run in range(10):
            result = y(loop(), as_str=True, )
            results.append(result)
        print(results)

OUTPUT

y| returned None from loop1() in 0.414763 seconds
y| returned None from loop1() in 0.418484 seconds
y| returned None from loop1() in 0.408090 seconds
y| returned None from loop1() in 0.406661 seconds
y| returned None from loop1() in 0.418872 seconds
y| returned None from loop1() in 0.413751 seconds
y| returned None from loop1() in 0.418103 seconds
y| returned None from loop1() in 0.406673 seconds
y| returned None from loop1() in 0.406783 seconds
y| returned None from loop1() in 0.412694 seconds
['y| loop(): None\n', 'y| loop(): None\n', 'y| loop(): None\n', 'y| loop(): None\n', 'y| loop(): None\n', 'y| loop(): None\n', 'y| loop(): None\n', 'y| loop(): None\n', 'y| loop(): None\n', 'y| loop(): None\n']        
y| returned None from loop2() in 0.157985 seconds
y| returned None from loop2() in 0.158627 seconds
y| returned None from loop2() in 0.160737 seconds
y| returned None from loop2() in 0.165181 seconds
y| returned None from loop2() in 0.171878 seconds
y| returned None from loop2() in 0.165958 seconds
y| returned None from loop2() in 0.164515 seconds
y| returned None from loop2() in 0.160872 seconds
y| returned None from loop2() in 0.160113 seconds
y| returned None from loop2() in 0.165789 seconds
['y| loop(): None\n', 'y| loop(): None\n', 'y| loop(): None\n', 'y| loop(): None\n', 'y| loop(): None\n', 'y| loop(): None\n', 'y| loop(): None\n', 'y| loop(): None\n', 'y| loop(): None\n', 'y| loop(): None\n']        

ycecream printing in ASCII instead of Unicode?

When y-ing a string containing the character "ΓΆ", ycecream throws the following exception:

Traceback (most recent call last):
  File "/p4w/apps/front_end/graphql_support.py", line 754, in user
    y(response)
  File "/usr/local/lib/python3.8/dist-packages/ycecream/ycecream.py", line 607, in __call__
    this.do_output(out)
  File "/usr/local/lib/python3.8/dist-packages/ycecream/ycecream.py", line 740, in do_output
    print(s, file=sys.stderr)
UnicodeEncodeError: 'ascii' codec can't encode character '\xf6' in position 729: ordinal not in range(128)

Why is ycecream even trying to use the ascii codec? Shouldn't it be unicode by default?
The locale is set to UTF-8 correctly. Is there some other settings that can be changed somewhere?

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.