Skip to content

Instantly share code, notes, and snippets.

import numpy
import math
import random
def generate_positions(n):
positions = []
for i in range(n):
positions.append((random.random(), random.random(), random.random()))
return positions
@matthewturk
matthewturk / annotate.json
Created August 14, 2020 13:21
Example annotation from yt pytest
[
{
"path": "yt/arraytypes.py",
"line": 7,
"func_name": "blankRecordArray",
"type_comments": [
"(Dict[str, List[str]], int) -> numpy.recarray"
],
"samples": 310
},
{
"g": [
1,
"Symbol('(mass)', positive=True)",
0,
"\\rm{g}"
],
"s": [
1,
"Symbol('(time)', positive=True)",
@matthewturk
matthewturk / parser.py
Created July 2, 2020 19:00
Simple parser for yamly stuff
import yt
import yaml
my_obj = yaml.load(open("what_want_to_do.yml"))
i = 0
for dataset_filename in my_obj['dataset']:
ds = yt.load(dataset_filename)
for projection in my_obj['projection_plots']:
for axis in projection['axes']:
@matthewturk
matthewturk / field_definition.json
Created April 2, 2020 17:22
field definition draft schema
{
"title": "FieldDefinition",
"type": "object",
"properties": {
"validators": {
"title": "Validators",
"default": [],
"type": "array",
"items": {
"anyOf": [
@matthewturk
matthewturk / output.txt
Last active February 5, 2020 16:16
unit differences in yt 3 and yt 4
>>> oa['grid_left_edges'] - on['grid_left_edges']
unyt_array([[-3.05474414e+24, -3.05474414e+24, -3.05474414e+24],
[-3.05474414e+24, -3.05474414e+24, -3.05474414e+24],
[-3.05474414e+24, -3.05474414e+24, -3.05474414e+24],
...,
[ 2.29105810e+24, 1.52737207e+24, 2.29105810e+24],
[ 1.52737207e+24, 2.29105810e+24, 2.29105810e+24],
[ 2.29105810e+24, 2.29105810e+24, 2.29105810e+24]], 'code_length')
>>> on['grid_left_edges']
unyt_array([[-3.08560014e+24, -3.08560014e+24, -3.08560014e+24],
@matthewturk
matthewturk / check_pooch.py
Last active January 9, 2020 18:22
pooch ideas
import pooch
for line in open("registry.txt"):
name, sha, url = line.split()
registry[name] = sha
urls[name] = url
GOODBOY = pooch.create(
# This is still the default in case the environment variable isn't defined
path=pooch.os_cache("yt"),
[success] 3.60% yt.frontends.athena_pp.tests.test_outputs.FieldValues_AM06_out1_00400_all_velocity_magnitude: 20.1119s
[success] 3.46% yt.frontends.athena_pp.tests.test_outputs.FieldValues_AM06_out1_00400_sphere_('max', (0_1, 'unitary'))_velocity_magnitude: 19.3312s
[success] 2.73% yt.frontends.athena_pp.tests.test_outputs.ProjectionValues_AM06_out1_00400_sphere_('max', (0_1, 'unitary'))_velocity_magnitude_0_density: 15.2401s
[success] 2.72% yt.frontends.athena_pp.tests.test_outputs.ProjectionValues_AM06_out1_00400_sphere_('max', (0_1, 'unitary'))_velocity_magnitude_2_density: 15.2296s
[success] 2.72% yt.frontends.athena_pp.tests.test_outputs.ProjectionValues_AM06_out1_00400_sphere_('max', (0_1, 'unitary'))_velo
@matthewturk
matthewturk / galaxy0030.json
Last active October 22, 2019 15:37
some 2d data in json
{
"density": [
[
3.676411957510513e-27,
4.233186247069095e-27,
4.7960308251482965e-27,
5.211452721200936e-27,
5.5704058574457245e-27,
5.968494805162153e-27,
6.3183200611758625e-27,
======================================================================
ERROR: test_derived_field (yt.data_objects.tests.test_data_containers.TestDataContainers)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/home/matthewturk/yt/yt/yt/data_objects/tests/test_data_containers.py", line 134, in test_derived_field
ds = fake_particle_ds()
File "/home/matthewturk/yt/yt/yt/testing.py", line 303, in fake_particle_ds
ds = load_particles(data, 1.0, bbox=bbox, over_refine_factor = over_refine_factor)
TypeError: load_particles() got an unexpected keyword argument 'over_refine_factor'