This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
api_costs = { | |
'gpt-4-1106-preview': {"input": 0.01, "output": 0.03, "unit": "$/1K tokens"}, | |
'gpt-4-1106-vision-preview': {"input": 0.01, "output": 0.03, "unit": "$/1K tokens"}, | |
'gpt-4': {"input": 0.03, "output": 0.06, "unit": "$/1K tokens"}, | |
'gpt-4-32k': {"input": 0.06, "output": 0.12, "unit": "$/1K tokens"}, | |
'gpt-3.5-turbo-1106': {"input": 0.0010, "output": 0.0020, "unit": "$/1K tokens"}, | |
'gpt-3.5-turbo-instruct': {"input": 0.0015, "output": 0.0020, "unit": "$/1K tokens"}, | |
'gpt-3.5-turbo': {"training": 0.0080, "input": 0.0030, "output": 0.0060, "unit": "$/1K tokens"}, | |
'davinci-002': {"training": 0.0060, "input": 0.0120, "output": 0.0120, "unit": "$/1K tokens"}, | |
'babbage-002': {"training": 0.0004, "input": 0.0016, "output": 0.0016, "unit": "$/1K tokens"}, |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from tested import validate_codec | |
Empty1 = type('Empty', (), {})() | |
print("\nEmpty1 = type('Empty', (), {})()") | |
print(f"{validate_codec(Empty1)=}") | |
_Empty2 = type('Empty', (), {}) | |
_Empty2.__module__ = __name__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# get raw df | |
import qo | |
df = qo.get_tables_from_url('https://en.wikipedia.org/wiki/List_of_salaries_of_heads_of_state_and_government')[3] | |
df = df.set_index('State') | |
# formatting and extracting salaries |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
I've often seen that “color of musical notes” thing, | |
and I always wondered about it (especially because I’d like to use it as educational support when I teach my (reluctant) | |
daughter music). | |
The mappings I see are not always consistent, but one comes up most often; | |
the one where the red-to-violet range is mapped to the C-to-B range. | |
Now this could just so happen to be correct, but the choice that C as the canonical root note of a scale seems | |
to be arbitrary, whereas red as the first color is a physical reality, leading me to think that: | |
- The choice of C as the root note was purposely based on the red-to-violet correspondence | |
- It’s a crock of s**t |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from inspect import signature, Signature | |
class Compose: | |
def __init__(self, *funcs): | |
"""Performs function composition. | |
That is, get a callable that is equivalent to a chain of callables. | |
For example, if `f`, `h`, and `g` are three functions, the function | |
``` | |
c = Compose(f, h, g) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Code that prints this table (meant to study the type-differences of different callables): | |
``` | |
MethodType FunctionType has_self qualname_levels dunders | |
name | |
class method True False True 2 27 | |
instance method False True False 2 35 | |
static method False True False 2 35 | |
"instantiated" class method True False True 2 27 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Prints a diagnosis (object kind and import depth) of the imports that can be obtained from the (top level) module. | |
That is, those objects that can by imported by doing: | |
``` | |
from module import obj | |
``` | |
though the object's code may be several package levels down (say module.sub1.sub2.obj). | |
``` | |
$ python print_top_level_diagnosis.py numpy |
NewerOlder