samila/test/nft_upload_test.py

35 wiersze
1.0 KiB
Python
Czysty Zwykły widok Historia

2021-10-12 18:04:17 +00:00
# -*- coding: utf-8 -*-
"""
>>> import os
>>> import math
>>> import random
2021-10-12 18:15:05 +00:00
>>> import time
2021-10-12 19:13:04 +00:00
>>> from samila import GenerativeImage, Projection
2021-10-12 19:20:27 +00:00
>>> from samila.params import VALID_COLORS
2021-10-12 18:04:17 +00:00
>>> def f1(x,y):
... result = random.uniform(-1,1) * x**2 - math.sin(y**2) + abs(y-x)
... return result
>>> def f2(x,y):
... result = random.uniform(-1,1) * y**3 - math.cos(x**2) + 2*x
... return result
>>> g = GenerativeImage(f1,f2)
>>> g.generate()
>>> g.plot()
>>> NFT_STORAGE_API_KEY = os.environ["NFT_STORAGE_API_KEY"]
>>> g.generate()
2021-10-12 19:13:04 +00:00
>>> random_projection = random.choice(list(Projection))
>>> random_color = random.choice(VALID_COLORS)
>>> random_bgcolor = random.choice(VALID_COLORS)
>>> g.plot(projection=random_projection,color=random_color,bgcolor=random_bgcolor)
2021-10-12 18:15:05 +00:00
>>> counter = 0
2021-10-15 21:44:56 +00:00
>>> try_limit = 5
2021-10-12 18:15:05 +00:00
>>> status = False
>>> while(status == False and counter<try_limit):
... result = g.nft_storage(api_key=NFT_STORAGE_API_KEY)
... counter = counter + 1
... status = result["status"]
2021-10-15 21:44:56 +00:00
... time.sleep(5)
2021-10-12 18:15:05 +00:00
>>> status
2021-10-12 18:04:17 +00:00
True
"""