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

Add live_info_terminal, closes #436 #441

Merged
merged 4 commits into from
Feb 13, 2024
Merged

Add live_info_terminal, closes #436 #441

merged 4 commits into from
Feb 13, 2024

Conversation

basnijholt
Copy link
Member

@basnijholt basnijholt commented Aug 20, 2023

Description

Screen Recording 2023-08-20 at 1 19 30 PM

Use like:

python live-info-example.py

import adaptive
import asyncio
import random

offset = random.uniform(-0.5, 0.5)


def peak(x, offset=offset, wait=True):
    from random import random
    from time import sleep

    a = 0.01
    if wait:
        # we pretend that this is a slow function
        sleep(random())

    return x + a**2 / (a**2 + (x - offset) ** 2)

learner = adaptive.Learner1D(peak, bounds=(-1, 1))
runner = adaptive.Runner(learner, loss_goal=0.01)


async def run(runner, fname: str):
    runner.live_info_terminal(overwrite_previous=True)
    await runner.task
    runner.learner.save(fname)


runner.ioloop.run_until_complete(run(runner, "learner.pkl"))

Fixes #436

Checklist

  • Fixed style issues using pre-commit run --all (first install using pip install pre-commit)
  • pytest passed

Type of change

Check relevant option(s).

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • (Code) style fix or documentation update
  • This change requires a documentation update

@basnijholt basnijholt changed the title Add live_info_terminal, closes #436 Add live_info_terminal, closes #436 Feb 13, 2024
@basnijholt basnijholt enabled auto-merge (squash) February 13, 2024 19:00
@basnijholt basnijholt merged commit 6c2bc1f into main Feb 13, 2024
12 checks passed
@basnijholt basnijholt deleted the text-pbar branch February 13, 2024 19:06
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.

Use in script with BlockingRunner: get log and/or feedback on progress
1 participant