Assignment 3
The US Department of Agriculture publishes price estimates for fruits and vegetables online. The most recent estimates are based on a 2013 survey of US retail stores.
The estimates are provided as a collection of MS Excel files, with one file per fruit or vegetable. The assignment3_data.zip
file contains the fruit and vegetable files in the directories fruit
and vegetables
, respectively.
Exercise 1.1. Use pandas to extract the “Fresh” row(s) from the fruit Excel files. Combine the data into a single data frame. Your data frame should look something like this:
| type | food | form | price_per_lb | yield | lb_per_cup | price_per_cup |
|---|---|---|---|---|---|---|
| fruit | watermelon | Fresh1 | 0.333412 | 0.52 | 0.330693 | 0.212033 |
| fruit | cantaloupe | Fresh1 | 0.535874 | 0.51 | 0.374786 | 0.3938 |
| vegetables | onions | Fresh1 | 1.03811 | 0.9 | 0.35274 | 0.406868 |
| … |
It’s okay if the rows and columns of your data frame are in a different order. These modules are especially relevant:
str
methodsos
os.path
- pandas:
read_excel()
,concat()
,.fillna()
,.str
, plotting methods
Ask questions and search the documentation/web to find the functions you need.
I set the path to the fruit directory and use a list comprehension to get fruit names.
import pandas as pd
import os
from os import listdir
from os.path import isfile, join
fruit_path = "data/fruit/"
num_files = sum(os.path.isfile(os.path.join(fruit_path, f)) for f in os.listdir(fruit_path))
onlyfiles = [f.split('.xlsx', 1)[0] for f in listdir(fruit_path) if isfile(join(fruit_path, f))]
col = ["type", "food", "form", "price_per_lb", "yield_v", "lb_per_cup", "price_per_cup"]
df = pd.DataFrame()
onlyfiles[1]
'apricots'
This is the extract function which will read in a fruit (input will be from onlyfiles), and extract specified values. It returns a dictionary.
def extract(fruit):
bkb = pd.read_excel(fruit_path + fruit+".xlsx", header= None, skiprows = [0,1,2])
fresh_row = bkb.iloc[0]
price_per_lb = fresh_row[1]
yield_v = fresh_row[3]
lb_per_cup = fresh_row[4]
price_per_cup = fresh_row[6]
lout = ["fruit", fruit, "Fresh1" , price_per_lb, yield_v, lb_per_cup, price_per_cup]
dout = {"type" : ["fruit"], "food" : [fruit], "form": ["Fresh1"], "price_per_lb" :[price_per_lb] , "yield_v":[yield_v], "lb_per_cup":[lb_per_cup], "price_per_cup":[price_per_cup]}
return dout
extract(onlyfiles[1])
{'food': ['apricots'],
'form': ['Fresh1'],
'lb_per_cup': [0.363762732605048],
'price_per_cup': [1.1891020280290363],
'price_per_lb': [3.040071967096438],
'type': ['fruit'],
'yield_v': [0.93]}
The getFruit function will get all the fruits in the fruit folder and create a data frame out of all the entries.
def getFruit(fruitList):
df2 = pd.DataFrame()
l = []
for f in fruitList:
if '$' not in f:
d = extract(f)
new_df = pd.DataFrame.from_dict(d)
l.append(new_df)
df2 = pd.concat(l, axis = 0)
return df2
fruit_df = getFruit(onlyfiles)
fruit_df
| food | form | lb_per_cup | price_per_cup | price_per_lb | type | yield_v | |
|---|---|---|---|---|---|---|---|
| 0 | apples | Fresh1 | 0.242508 | 0.422373 | 1.567515 | fruit | 0.90 |
| 0 | apricots | Fresh1 | 0.363763 | 1.189102 | 3.040072 | fruit | 0.93 |
| 0 | bananas | Fresh1 | 0.330693 | 0.292965 | 0.566983 | fruit | 0.64 |
| 0 | berries_mixed | Fresh1 | 0.330693 | 1.127735 | 3.410215 | fruit | 1.00 |
| 0 | blackberries | Fresh1 | 0.319670 | 1.922919 | 5.774708 | fruit | 0.96 |
| 0 | blueberries | Fresh1 | 0.319670 | 1.593177 | 4.734622 | fruit | 0.95 |
| 0 | cantaloupe | Fresh1 | 0.374786 | 0.393800 | 0.535874 | fruit | 0.51 |
| 0 | cherries | Fresh1 | 0.341717 | 1.334548 | 3.592990 | fruit | 0.92 |
| 0 | cranberries | Fresh1 | 0.123163 | 0.589551 | 4.786741 | fruit | 1.00 |
| 0 | dates | Fresh1 | 0.165347 | 0.792234 | 4.791351 | fruit | 1.00 |
| 0 | figs | Fresh1 | 0.165347 | 0.990068 | 5.748318 | fruit | 0.96 |
| 0 | fruit_cocktail | Fresh1 | NaN | NaN | NaN | fruit | NaN |
| 0 | grapefruit | Fresh1 | 0.462971 | 0.848278 | 0.897802 | fruit | 0.49 |
| 0 | grapes | Fresh1 | 0.330693 | 0.721266 | 2.093827 | fruit | 0.96 |
| 0 | honeydew | Fresh1 | 0.374786 | 0.649077 | 0.796656 | fruit | 0.46 |
| 0 | kiwi | Fresh1 | 0.385809 | 1.037970 | 2.044683 | fruit | 0.76 |
| 0 | mangoes | Fresh1 | 0.363763 | 0.705783 | 1.377563 | fruit | 0.71 |
| 0 | nectarines | Fresh1 | 0.319670 | 0.618667 | 1.761148 | fruit | 0.91 |
| 0 | oranges | Fresh1 | 0.407855 | 0.578357 | 1.035173 | fruit | 0.73 |
| 0 | papaya | Fresh1 | 0.308647 | 0.646174 | 1.298012 | fruit | 0.62 |
| 0 | peaches | Fresh1 | 0.341717 | 0.566390 | 1.591187 | fruit | 0.96 |
| 0 | pears | Fresh1 | 0.363763 | 0.590740 | 1.461575 | fruit | 0.90 |
| 0 | pineapple | Fresh1 | 0.363763 | 0.447686 | 0.627662 | fruit | 0.51 |
| 0 | plums | Fresh1 | 0.363763 | 0.707176 | 1.827416 | fruit | 0.94 |
| 0 | pomegranate | Fresh1 | 0.341717 | 1.326342 | 2.173590 | fruit | 0.56 |
| 0 | raspberries | Fresh1 | 0.319670 | 2.322874 | 6.975811 | fruit | 0.96 |
| 0 | strawberries | Fresh1 | 0.319670 | 0.802171 | 2.358808 | fruit | 0.94 |
| 0 | tangerines | Fresh1 | 0.407855 | 0.759471 | 1.377962 | fruit | 0.74 |
| 0 | watermelon | Fresh1 | 0.330693 | 0.212033 | 0.333412 | fruit | 0.52 |
Exercise 1.2. Reuse your code from exercise 1.1 to extract the “Fresh” row(s) from the vegetable Excel files.
Does your code produce the correct prices for tomatoes? If not, why not? Do any other files have the same problem as the tomatoes file?
You don’t need to extract the prices for these problem files. However, make sure the prices are extracted for files like asparagus that don’t have this problem.
Using the same code for fruit, I simply change the path to vegetables.
vegetable_path = "data/vegetables/"
onlyfiles = [f.split('.xlsx', 1)[0] for f in listdir(vegetable_path) if isfile(join(vegetable_path, f))]
def extract(vegetable):
bkb = pd.read_excel(vegetable_path + vegetable+".xlsx", header= None, skiprows = [0,1,2])
fresh_row = bkb.iloc[0]
price_per_lb = fresh_row[1]
yield_v = fresh_row[3]
lb_per_cup = fresh_row[4]
price_per_cup = fresh_row[6]
dout = {"type" : ["vegetable"], "food" : [vegetable], "form": ["Fresh1"], "price_per_lb" :[price_per_lb] , "yield_v":[yield_v], "lb_per_cup":[lb_per_cup], "price_per_cup":[price_per_cup]}
'''
vegetableSeries = pd.Series(data=["vegetable", vegetable, "Fresh1", price_per_lb, yield_v, lb_per_cup, price_per_cup], name = vegetable)
return vegetableSeries
'''
return dout
extract(onlyfiles[1])
{'food': ['artichoke'],
'form': ['Fresh1'],
'lb_per_cup': [0.38580895882353577],
'price_per_cup': [2.2749668026387808],
'price_per_lb': [2.2130504792860322],
'type': ['vegetable'],
'yield_v': [0.37530864197530867]}
def getVegetable(vegetableList):
df2 = pd.DataFrame()
l = []
for f in vegetableList:
if '$' not in f:
d = extract(f)
new_df = pd.DataFrame.from_dict(d)
l.append(new_df)
df2 = pd.concat(l, axis = 0)
return df2
vegetable_df = getVegetable(onlyfiles)
vegetable_df
| food | form | lb_per_cup | price_per_cup | price_per_lb | type | yield_v | |
|---|---|---|---|---|---|---|---|
| 0 | acorn_squash | Fresh1 | 0.451948 | 1.155360 | 1.17225 | vegetable | 0.458554 |
| 0 | artichoke | Fresh1 | 0.385809 | 2.274967 | 2.21305 | vegetable | 0.375309 |
| 0 | asparagus | Fresh1 | 0.396832 | 2.582272 | 3.21349 | vegetable | 0.493835 |
| 0 | avocados | Fresh1 | 0.31967 | 0.964886 | 2.23587 | vegetable | 0.740753 |
| 0 | beets | Fresh1 | 0.374786 | 0.586555 | 1.01728 | vegetable | 0.65 |
| 0 | blackeye_peas | Fresh1 | 0.374786 | 0.524954 | 0.910441 | vegetable | 0.65 |
| 0 | black_beans | Fresh1 | 0.385809 | 0.582025 | 0.98058 | vegetable | 0.65 |
| 0 | broccoli | Fresh1 | NaN | vegetable | |||
| 0 | brussels_sprouts | Fresh1 | 0.341717 | 0.890898 | 2.76355 | vegetable | 1.06 |
| 0 | butternut_squash | Fresh1 | 0.451948 | 0.787893 | 1.24474 | vegetable | 0.714 |
| 0 | cabbage | Fresh1 | 0.330693 | 0.245944 | 0.579208 | vegetable | 0.778797 |
| 0 | carrots | Fresh1 | NaN | NaN | NaN | vegetable | NaN |
| 0 | cauliflower | Fresh1 | NaN | vegetable | |||
| 0 | celery | Fresh1 | NaN | NaN | NaN | vegetable | NaN |
| 0 | collard_greens | Fresh1 | 0.286601 | 0.650001 | 2.63084 | vegetable | 1.16 |
| 0 | corn_sweet | Fresh1 | 0.363763 | 1.812497 | 2.69062 | vegetable | 0.54 |
| 0 | cucumbers | Fresh1 | 0.264555 | 0.353448 | 1.29593 | vegetable | 0.97 |
| 0 | great_northern_beans | Fresh1 | 0.385809 | 0.548392 | 0.923916 | vegetable | 0.65 |
| 0 | green_beans | Fresh1 | 0.275578 | 0.696606 | 2.13997 | vegetable | 0.846575 |
| 0 | green_peas | Fresh1 | 0.35274 | 0.549769 | 1.01307 | vegetable | 0.65 |
| 0 | green_peppers | Fresh1 | 0.264555 | 0.455022 | 1.41036 | vegetable | 0.82 |
| 0 | kale | Fresh1 | 0.286601 | 0.766262 | 2.8073 | vegetable | 1.05 |
| 0 | kidney_beans | Fresh1 | 0.385809 | 0.535194 | 0.90168 | vegetable | 0.65 |
| 0 | lentils | Fresh1 | 0.385809 | 0.196738 | 1.38504 | vegetable | 2.7161 |
| 0 | lettuce_iceberg | Fresh1 | 0.242508 | 0.309655 | 1.21304 | vegetable | 0.95 |
| 0 | lettuce_romaine | Fresh1 | NaN | vegetable | NaN | ||
| 0 | lima_beans | Fresh1 | 0.374786 | 0.797757 | 1.38357 | vegetable | 0.65 |
| 0 | mixed_vegetables | Fresh1 | NaN | vegetable | |||
| 0 | mushrooms | Fresh1 | NaN | NaN | NaN | vegetable | NaN |
| 0 | mustard_greens | Fresh1 | 0.308647 | 0.944032 | 2.56924 | vegetable | 0.84 |
| 0 | navy_beans | Fresh1 | 0.385809 | 0.575997 | 0.970423 | vegetable | 0.65 |
| 0 | okra | Fresh1 | 0.35274 | 1.473146 | 3.21355 | vegetable | 0.769474 |
| 0 | olives | Fresh1 | 0.297624 | 1.246102 | 4.18683 | vegetable | 1 |
| 0 | onions | Fresh1 | 0.35274 | 0.406868 | 1.03811 | vegetable | 0.9 |
| 0 | pinto_beans | Fresh1 | 0.385809 | 0.514129 | 0.86619 | vegetable | 0.65 |
| 0 | potatoes | Fresh1 | 0.264555 | 0.184017 | 0.56432 | vegetable | 0.811301 |
| 0 | pumpkin | Fresh1 | 0.540133 | 0.730411 | 1.35228 | vegetable | 1 |
| 0 | radish | Fresh1 | 0.275578 | 0.401618 | 1.31163 | vegetable | 0.9 |
| 0 | red_peppers | Fresh1 | 0.264555 | 0.734926 | 2.27794 | vegetable | 0.82 |
| 0 | spinach | Fresh1 | NaN | NaN | NaN | vegetable | NaN |
| 0 | summer_squash | Fresh1 | 0.396832 | 0.845480 | 1.63948 | vegetable | 0.7695 |
| 0 | sweet_potatoes | Fresh1 | 0.440925 | 0.499400 | 0.918897 | vegetable | 0.811301 |
| 0 | tomatoes | Fresh1 | NaN | NaN | NaN | vegetable | NaN |
| 0 | turnip_greens | Fresh1 | 0.31967 | 1.053526 | 2.47175 | vegetable | 0.75 |
The tomatoes entry does not have the correct information (it displays NaN for all its rows instead). Broccoli, celery, carrots, cauliflower, romaine lettuce, mixed vegetables, mushrooms, and spinach also have NaN values.
This is because these entries have nothing on the row which is labeled “Fresh”. There are different types of those vegetables which are sold at different prices.
Exercise 1.3. Remove rows without a price from the vegetable data frame and then combine the fruit and vegetable data frames. Make sure all columns of numbers are numeric (not strings).
I now combine the vegetable and fruit files into one data frame. I then clean for invalid entries.
vegetable_path = "data/vegetables/"
fruit_path = "data/fruit/"
num_files = sum(os.path.isfile(os.path.join(vegetable_path, f)) for f in os.listdir(vegetable_path))
vegetableFiles = [f.split('.xlsx', 1)[0] for f in listdir(vegetable_path) if isfile(join(vegetable_path, f))]
fruitFiles = [f.split('.xlsx', 1)[0] for f in listdir(fruit_path) if isfile(join(fruit_path, f))]
col = ["type", "food", "form", "price_per_lb", "yield_v", "lb_per_cup", "price_per_cup"]
df = pd.DataFrame()
#extract function, works for both fruits and veggies
def extract(typeO, path, obj):
bkb = pd.read_excel(path + obj+".xlsx", header= None, skiprows = [0,1,2])
fresh_row = bkb.iloc[0]
price_per_lb = fresh_row[1]
yield_v = fresh_row[3]
lb_per_cup = fresh_row[4]
price_per_cup = fresh_row[6]
dout = {"type" : [typeO], "food" : [obj], "form": ["Fresh1"], "price_per_lb" :[price_per_lb] , "yield_v":[yield_v], "lb_per_cup":[lb_per_cup], "price_per_cup":[price_per_cup]}
return dout
#extract function, works for both fruits and veggies
def extract(typeO, path, obj):
bkb = pd.read_excel(path + obj+".xlsx", header= None, skiprows = [0,1,2])
fresh_row = bkb.iloc[0]
price_per_lb = fresh_row[1]
yield_v = fresh_row[3]
lb_per_cup = fresh_row[4]
price_per_cup = fresh_row[6]
dout = {"type" : [typeO], "food" : [obj], "form": ["Fresh1"], "price_per_lb" :[price_per_lb] , "yield_v":[yield_v], "lb_per_cup":[lb_per_cup], "price_per_cup":[price_per_cup]}
return dout
#returns combined dataframe of both fruits and veggies
def getBoth(fruitList, vegetableList):
df2 = pd.DataFrame()
l = []
for f in fruitList:
if '$' not in f:
d = extract("fruit", fruit_path, f)
new_df = pd.DataFrame.from_dict(d)
l.append(new_df)
for f in vegetableList:
if '$' not in f:
d = extract("vegetables", vegetable_path, f)
new_df = pd.DataFrame.from_dict(d)
l.append(new_df)
df2 = pd.concat(l, axis = 0)
return df2
merged_df = getBoth(fruitFiles, vegetableFiles)
merged_df[:5]
| food | form | lb_per_cup | price_per_cup | price_per_lb | type | yield_v | |
|---|---|---|---|---|---|---|---|
| 0 | apples | Fresh1 | 0.242508 | 0.422373 | 1.56752 | fruit | 0.9 |
| 0 | apricots | Fresh1 | 0.363763 | 1.189102 | 3.04007 | fruit | 0.93 |
| 0 | bananas | Fresh1 | 0.330693 | 0.292965 | 0.566983 | fruit | 0.64 |
| 0 | berries_mixed | Fresh1 | 0.330693 | 1.127735 | 3.41021 | fruit | 1 |
| 0 | blackberries | Fresh1 | 0.31967 | 1.922919 | 5.77471 | fruit | 0.96 |
I now clean the data to remove invalid rows.
def cleanData(df):
df2 = df.apply(lambda x: pd.to_numeric(x, errors='ignore'))
df2 = df2[pd.notnull(df2['price_per_lb'])]
df2 = df2[pd.notnull(df2['price_per_cup'])]
return df2
clean_df = cleanData(merged_df)
clean_df
| food | form | lb_per_cup | price_per_cup | price_per_lb | type | yield_v | |
|---|---|---|---|---|---|---|---|
| 0 | apples | Fresh1 | 0.242508 | 0.422373 | 1.56752 | fruit | 0.9 |
| 0 | apricots | Fresh1 | 0.363763 | 1.189102 | 3.04007 | fruit | 0.93 |
| 0 | bananas | Fresh1 | 0.330693 | 0.292965 | 0.566983 | fruit | 0.64 |
| 0 | berries_mixed | Fresh1 | 0.330693 | 1.127735 | 3.41021 | fruit | 1 |
| 0 | blackberries | Fresh1 | 0.31967 | 1.922919 | 5.77471 | fruit | 0.96 |
| 0 | blueberries | Fresh1 | 0.31967 | 1.593177 | 4.73462 | fruit | 0.95 |
| 0 | cantaloupe | Fresh1 | 0.374786 | 0.393800 | 0.535874 | fruit | 0.51 |
| 0 | cherries | Fresh1 | 0.341717 | 1.334548 | 3.59299 | fruit | 0.92 |
| 0 | cranberries | Fresh1 | 0.123163 | 0.589551 | 4.78674 | fruit | 1 |
| 0 | dates | Fresh1 | 0.165347 | 0.792234 | 4.79135 | fruit | 1 |
| 0 | figs | Fresh1 | 0.165347 | 0.990068 | 5.74832 | fruit | 0.96 |
| 0 | grapefruit | Fresh1 | 0.462971 | 0.848278 | 0.897802 | fruit | 0.49 |
| 0 | grapes | Fresh1 | 0.330693 | 0.721266 | 2.09383 | fruit | 0.96 |
| 0 | honeydew | Fresh1 | 0.374786 | 0.649077 | 0.796656 | fruit | 0.46 |
| 0 | kiwi | Fresh1 | 0.385809 | 1.037970 | 2.04468 | fruit | 0.76 |
| 0 | mangoes | Fresh1 | 0.363763 | 0.705783 | 1.37756 | fruit | 0.71 |
| 0 | nectarines | Fresh1 | 0.31967 | 0.618667 | 1.76115 | fruit | 0.91 |
| 0 | oranges | Fresh1 | 0.407855 | 0.578357 | 1.03517 | fruit | 0.73 |
| 0 | papaya | Fresh1 | 0.308647 | 0.646174 | 1.29801 | fruit | 0.62 |
| 0 | peaches | Fresh1 | 0.341717 | 0.566390 | 1.59119 | fruit | 0.96 |
| 0 | pears | Fresh1 | 0.363763 | 0.590740 | 1.46157 | fruit | 0.9 |
| 0 | pineapple | Fresh1 | 0.363763 | 0.447686 | 0.627662 | fruit | 0.51 |
| 0 | plums | Fresh1 | 0.363763 | 0.707176 | 1.82742 | fruit | 0.94 |
| 0 | pomegranate | Fresh1 | 0.341717 | 1.326342 | 2.17359 | fruit | 0.56 |
| 0 | raspberries | Fresh1 | 0.31967 | 2.322874 | 6.97581 | fruit | 0.96 |
| 0 | strawberries | Fresh1 | 0.31967 | 0.802171 | 2.35881 | fruit | 0.94 |
| 0 | tangerines | Fresh1 | 0.407855 | 0.759471 | 1.37796 | fruit | 0.74 |
| 0 | watermelon | Fresh1 | 0.330693 | 0.212033 | 0.333412 | fruit | 0.52 |
| 0 | acorn_squash | Fresh1 | 0.451948 | 1.155360 | 1.17225 | vegetables | 0.458554 |
| 0 | artichoke | Fresh1 | 0.385809 | 2.274967 | 2.21305 | vegetables | 0.375309 |
| ... | ... | ... | ... | ... | ... | ... | ... |
| 0 | blackeye_peas | Fresh1 | 0.374786 | 0.524954 | 0.910441 | vegetables | 0.65 |
| 0 | black_beans | Fresh1 | 0.385809 | 0.582025 | 0.98058 | vegetables | 0.65 |
| 0 | brussels_sprouts | Fresh1 | 0.341717 | 0.890898 | 2.76355 | vegetables | 1.06 |
| 0 | butternut_squash | Fresh1 | 0.451948 | 0.787893 | 1.24474 | vegetables | 0.714 |
| 0 | cabbage | Fresh1 | 0.330693 | 0.245944 | 0.579208 | vegetables | 0.778797 |
| 0 | collard_greens | Fresh1 | 0.286601 | 0.650001 | 2.63084 | vegetables | 1.16 |
| 0 | corn_sweet | Fresh1 | 0.363763 | 1.812497 | 2.69062 | vegetables | 0.54 |
| 0 | cucumbers | Fresh1 | 0.264555 | 0.353448 | 1.29593 | vegetables | 0.97 |
| 0 | great_northern_beans | Fresh1 | 0.385809 | 0.548392 | 0.923916 | vegetables | 0.65 |
| 0 | green_beans | Fresh1 | 0.275578 | 0.696606 | 2.13997 | vegetables | 0.846575 |
| 0 | green_peas | Fresh1 | 0.35274 | 0.549769 | 1.01307 | vegetables | 0.65 |
| 0 | green_peppers | Fresh1 | 0.264555 | 0.455022 | 1.41036 | vegetables | 0.82 |
| 0 | kale | Fresh1 | 0.286601 | 0.766262 | 2.8073 | vegetables | 1.05 |
| 0 | kidney_beans | Fresh1 | 0.385809 | 0.535194 | 0.90168 | vegetables | 0.65 |
| 0 | lentils | Fresh1 | 0.385809 | 0.196738 | 1.38504 | vegetables | 2.7161 |
| 0 | lettuce_iceberg | Fresh1 | 0.242508 | 0.309655 | 1.21304 | vegetables | 0.95 |
| 0 | lima_beans | Fresh1 | 0.374786 | 0.797757 | 1.38357 | vegetables | 0.65 |
| 0 | mustard_greens | Fresh1 | 0.308647 | 0.944032 | 2.56924 | vegetables | 0.84 |
| 0 | navy_beans | Fresh1 | 0.385809 | 0.575997 | 0.970423 | vegetables | 0.65 |
| 0 | okra | Fresh1 | 0.35274 | 1.473146 | 3.21355 | vegetables | 0.769474 |
| 0 | olives | Fresh1 | 0.297624 | 1.246102 | 4.18683 | vegetables | 1 |
| 0 | onions | Fresh1 | 0.35274 | 0.406868 | 1.03811 | vegetables | 0.9 |
| 0 | pinto_beans | Fresh1 | 0.385809 | 0.514129 | 0.86619 | vegetables | 0.65 |
| 0 | potatoes | Fresh1 | 0.264555 | 0.184017 | 0.56432 | vegetables | 0.811301 |
| 0 | pumpkin | Fresh1 | 0.540133 | 0.730411 | 1.35228 | vegetables | 1 |
| 0 | radish | Fresh1 | 0.275578 | 0.401618 | 1.31163 | vegetables | 0.9 |
| 0 | red_peppers | Fresh1 | 0.264555 | 0.734926 | 2.27794 | vegetables | 0.82 |
| 0 | summer_squash | Fresh1 | 0.396832 | 0.845480 | 1.63948 | vegetables | 0.7695 |
| 0 | sweet_potatoes | Fresh1 | 0.440925 | 0.499400 | 0.918897 | vegetables | 0.811301 |
| 0 | turnip_greens | Fresh1 | 0.31967 | 1.053526 | 2.47175 | vegetables | 0.75 |
63 rows × 7 columns
Exercise 1.4. Discuss the questions below (a paragraph each is sufficient). Use plots to support your ideas.
- What kinds of fruits are the most expensive (per pound)? What kinds are the least expensive?
- How do the price distributions compare for fruit and vegetables?
- Which foods are the best value for the price?
- What’s something surprising about this data set?
- Which foods do you expect to provide the best combination of price, yield, and nutrition? A future assignment may combine this data set with another so you can check your hypothesis.
- Most expensive fruits are the berries (raspberries, blackberries, cranberries, blueberries) and figs/dates. The least expensive are bananas, watermelon, cantalope, and pineapple.
fruit_df.sort_values(['price_per_lb'], ascending = 0)[:9]
| food | form | lb_per_cup | price_per_cup | price_per_lb | type | yield_v | |
|---|---|---|---|---|---|---|---|
| 0 | raspberries | Fresh1 | 0.319670 | 2.322874 | 6.975811 | fruit | 0.96 |
| 0 | blackberries | Fresh1 | 0.319670 | 1.922919 | 5.774708 | fruit | 0.96 |
| 0 | figs | Fresh1 | 0.165347 | 0.990068 | 5.748318 | fruit | 0.96 |
| 0 | dates | Fresh1 | 0.165347 | 0.792234 | 4.791351 | fruit | 1.00 |
| 0 | cranberries | Fresh1 | 0.123163 | 0.589551 | 4.786741 | fruit | 1.00 |
| 0 | blueberries | Fresh1 | 0.319670 | 1.593177 | 4.734622 | fruit | 0.95 |
| 0 | cherries | Fresh1 | 0.341717 | 1.334548 | 3.592990 | fruit | 0.92 |
| 0 | berries_mixed | Fresh1 | 0.330693 | 1.127735 | 3.410215 | fruit | 1.00 |
| 0 | apricots | Fresh1 | 0.363763 | 1.189102 | 3.040072 | fruit | 0.93 |
fruit_df.sort_values(['price_per_lb'], ascending = 1)[:9]
| food | form | lb_per_cup | price_per_cup | price_per_lb | type | yield_v | |
|---|---|---|---|---|---|---|---|
| 0 | watermelon | Fresh1 | 0.330693 | 0.212033 | 0.333412 | fruit | 0.52 |
| 0 | cantaloupe | Fresh1 | 0.374786 | 0.393800 | 0.535874 | fruit | 0.51 |
| 0 | bananas | Fresh1 | 0.330693 | 0.292965 | 0.566983 | fruit | 0.64 |
| 0 | pineapple | Fresh1 | 0.363763 | 0.447686 | 0.627662 | fruit | 0.51 |
| 0 | honeydew | Fresh1 | 0.374786 | 0.649077 | 0.796656 | fruit | 0.46 |
| 0 | grapefruit | Fresh1 | 0.462971 | 0.848278 | 0.897802 | fruit | 0.49 |
| 0 | oranges | Fresh1 | 0.407855 | 0.578357 | 1.035173 | fruit | 0.73 |
| 0 | papaya | Fresh1 | 0.308647 | 0.646174 | 1.298012 | fruit | 0.62 |
| 0 | mangoes | Fresh1 | 0.363763 | 0.705783 | 1.377563 | fruit | 0.71 |
clean_df.boxplot("type", "price_per_lb")
plt.show()


Welcome to ImageReader
Clarifai Account
You need to create a Clarifai account in order to use this extension.
Follow this steps:
-
Go to https://developer.clarifai.com/signup/ and sign up for a free API key. You need to verify your email address in order to use more than 100 monthly requests.
-
Go then to https://developer.clarifai.com/account/applications/ and click "My First Application".
-
In the section "Scopes" select the option "Predict on Public and Custom Models" and then click on "Create API key".
-
Once finished loading copy the API key to the clipboard.
-
Open ImageReader option page in the Chrome Extension tab and paste your API key.
OCR.Space Account (optional)
In order to use the text recognition inside images you need to create a OCR.Space account.
Now you can already use ImageReader! But before, take a look at the options you can use:
- Text recognition: if contained, extracts text in images.
- Analyze private images: analizes no-public images.
- Automatic page language recognition: inserts the description into the language used on the page.
- Default labeling language: always inserts the description in a given language.
If the automatic page recognition is enabled, it will be used this language if it's not detected any in the page.
- Accuracy threshold: determines the percentage of accuracy of the description.
Thank you for using ImageReader.


--- layout: post title: D3.js Bar Chart using YAML and Jekyll title: D3.js Bar Chart using YAML and Jekyll ---
This is a test page - a proof of concept. Using D3.js - a bar chart is created; driven from dynamically generated JSON, from YAML stored in the _data folder within this repository, running Jekyll.
The YAML can be found in _data/bar-chart.yaml, but is transformed into the JSON needed for this chart, using /data/bar-chart.json, demonstrating how YAML can be used to drive visualizations on Github.


Brett Zamir
on 2012-07-06 03:26:03
@ekim: No, var_export in php.js currently does not support recursive references (or flag them as errors). Feel free to add support!
@Hans Henrik: We cannot use JSON.stringify for a few reasons: 1) JSON doesn't allow functions; JSON is only a subset of JavaScript intended for safely conveying data across platform. 2) JSON methods are not supported in older browsers. 3) PHP's var_export detects other properties like resources as do we (in our own way, even though JS does not have resource types). As far as your point about the 2nd argument, I have fixed it in Git (along with fixing some JSLint issues). Thanks!
Hans Henrik
on 2012-05-31 00:14:42
here is an alternate, much simpler implementation.. (since the javascript's var_export equalent seems to be JSON.stringify)
function var_export (mixed_expression, bool_return) {
if (bool_return != true) {
this.echo(JSON.stringify(mixed_expression));
return null;
} else {
return JSON.stringify(mixed_expression);
}
}
also, in the current code, bool_return !== true should be bool_return != true
(php's var_export don't care if you call var_export(blabla,1) or call var_export(blabla,true); )
ekim
on 2011-04-20 03:17:29
RA=[]; RA[1]=RA;
curse={re:RA}; curse.s=curse;
Can the output strings for RA and curse be posted to see what they look like?
Kevin van Zonneveld
on 2009-07-14 12:40:27
@ Brett Zamir & Brian Tafoya: Good job guys!
Brett Zamir
on 2009-07-13 16:40:08
Fixed in SVN. Thanks for the report!
In the meantime, convert "[^]" to "[\s\S]" (no quotes). The former works in PHP and Mozilla JavaScript but not IE--also fixed in the remaining functions which had this problem.
Brian Tafoya
on 2009-07-13 04:26:01
According to IE, there is an error within the regex on line 74...
funcParts = mixed_expression.toString().match(/function .*?\((.*?)\) \{([^]*)\}/);
Claims it is expecting an ']' but I was not able to resolve this.
Brett Zamir
on 2009-04-17 02:45:50
Hello Tom,
You might look at our serialize implementation http://phpjs.org/functions/view/508 for support for some JS types.
As you might already be aware, you can also get some of this with JSON. See http://json.org if you're not familiar with it or are looking for an existing parser/stringifier (Mozilla provides access to these natively for JSON parsing/stringifying if you were working with Firefox extensions). You technically can just use "eval()" for parsing, but that is unsafe, especially if user input could creep into the expression, unless you know what you're doing with it.
However, it is true that JSON (as with serialize() in some cases) does not allow other JS types, specifically functions (as you list) including as classes, the "undefined" type, Date objects, RegExp objects, and the built-in Error types (see https://developer.mozilla.org/en/Core_JavaScript_1.5_Reference/Global_Objects/Error ) (unless these are represented in some other way, just as strings or objects), and does not capture the prototype for objects.
That would be a useful option to have, I think, so if someone can implement it, maybe we can have a switch in the function to determine what kind of output to give. For most types, it shouldn't be too hard to do, as you could usually just rely on "toString()" (at least as a base), though you'd have to grab any user-defined prototype object on a function, etc. ...
This is a good example of the cases where being able to have configuration options is useful. php_check_syntax() has a similar dilemma to yours.
We've already built in some support for this which can be used now: PHP-style ini options. So, we could define our own "ini" for this function, using "phpjs." as the "extension prefix" (e.g., "phpjs.var_export_as_js"), and then allow users to use an ini file or ini_set() to set a non-default behavior. The function in turn would do a check like:
// this.php_js.ini would be set earlier, by ini_set(), an ini file
// which directly added to this.php_js.ini (fastest), or by parsing a
// PHP-style ini file (no support for the latter yet).
//
if (this.php_js && this.php_js.ini && this.php_js.ini.local_value['phpjs.var_export_as_js']) { // each ini should define local_value and global_value, so that it is possible to revert within the script back from ini_set() to the default behavior.
...
}
Note that references to 'this' will also work for the non-namespaced version of PHP.JS as it refers to the window object (PHP.JS reserves one global, "php_js", in the non-namespaced version).
At some point in the future, I think Kevin agreed in principle to allowing the namespaced version to accept configuration options in the constructor (e.g., $P = new PHP_JS({phpjs.var_export_as_js:true, ...})), so that, e.g., you could specify that by default you wanted var_export to work with JS.
Tom
on 2009-04-16 16:57:13
The returned representation of provided function is valid PHP code (which is correct). But does anyone have a JS var_export function whose returned representation is valid javascript code? The returned value should be string and it could be passed to eval() function
Examples:
var a = new Array(12, '13', 'abc', 'line1\nline2\nline3');
var js_code = var_export(a);
/*
the returned value should be:
"{0:12, 1:'13', 2:'abc', 3:'line1\nline2\nline3'}"
*/
var b = {'key1':4, 'key2':'5', 'key3':'xxx\n123', 555:'text'};
js_code = var_export(b);
/*
the returned value should be:
"{'key1':4, 'key2':'5', 'key3':'xxx\n123', 555:'text'}"
*/
var c = 123;
js_code = var_export(c); // "123"
var d = '321';
js_code = var_export(d); // "'321'"
var e = 'multilne\ntext';
js_code = var_export(e); // "'multiline\ntext'"
function add(x, y)
{
res = x + y;
return res;
}
var js_code = var_export(add);
/*
the returned value should be:
"function add(x, y) { res = x + y; return res; }"
*/
Thanks.
johnrembo
on 2008-08-22 12:35:57
currently this function fails on objects that contain any method. Also, I suggest to use typeof instead of instanceof:
var phpBridge = {
var_export: function (mixed_content) {
var variable=mixed_content;
var __pad_lines = function ( x ) {
return x.split("\n").join("\n ");
};
var retstr = "";
if(typeof variable == ('object' || 'array')) {
var iret = "";
for(i in variable) {
iret=iret+"\n"+this.var_export(i,true)+" => "+this.var_export(variable[i], true)+",";
}
retstr = "array ("+__pad_lines(iret)+"\n)";
} else if( variable === null) {
retstr = "NULL";
} else if ( typeof variable == 'function') {
retstr="'function'";
} else {
retstr = (!isNaN( variable )) ? variable : "'" + variable.replace('/(["\'\])/g', "\\$1").replace('/\0/g', "\\0") + "'";
}
return retstr;
}
}
Kevin van Zonneveld
on 2008-07-20 12:32:29
@ Oleg Butuzov: I'd think it would be great to have a sleep function, but this implementation locks up the browser. Maybe we could investigate in an alternative implementation based on setTimeout or something?
Oleg Butuzov (http://made.com.ua)
on 2008-07-19 21:24:13
sleep ?
function sleep(seconds) {
for(var i=seconds; i > 0; i--) {
var start = Number(new Date().getTime());
while (true) {
if ( (new Date().getTime() - start) > 1000) {
break;
}
}
}
}


1. Type your name
First name:
*
Second name:
*
2. Select your gender
Male
Female
3. Your age
Age:
*
3. Select at least one source of income
Salary from a Job
Individual activity
Passive income
Passive means income from stocks, bonds, funds and real estate.
Business
4. Select your education
-- select an option --
None
High-school
Bachelor
Master
Doctorate
5. Please describe why do you need a loan
Previous
Next
1
2
3
4
5


# Copyright (c) 2022 International Institute for Applied Systems Analysis.
# All rights reserved. The use and distribution terms for this software
# are covered by the MIT License (http://opensource.org/licenses/MIT)
# which can be found in the file LICENSE at the root of this distribution.
# By using this software in any fashion, you are agreeing to be bound by
# the terms of this license.
# You must not remove this notice, or any other, from this software.
"""Net CO2 emissions and radiative forcing curves from Hansel et al. (2020)."""
__author__ = "Anna Shchiptsova"
__copyright__ = "Copyright (c) 2022 IIASA"
__license__ = "MIT"
import numpy as np # type: ignore
#: Net CO2 FFI emissions curve (GtCO2).
emissions_ffi_co2 = np.array([
35.7404, 37.6787, 29.0282, 29.4648, 29.4406,
28.9376, 27.9357, 26.4317, 24.4262, 21.931,
18.9743, 15.5854, 11.7991, 7.6487, 3.16449,
-1.62853, -6.71595, -12.1001])
#: Curve with ratios of non-CO2 radiative forcing to CO2 radiative forcing (-).
radiative_forcing_non_co2 = np.array([
0.31, 0.455, 0.514, 0.58, 0.586,
0.592, 0.562, 0.533, 0.496, 0.462,
0.443, 0.425, 0.411, 0.397, 0.382,
0.367, 0.352, 0.337])
[docs]def emissions_land_use_co2(n_points):
"""AFOLU emissions (GtCO2)."""
e_points = np.zeros(n_points)
e_points[0] = 2.6
for x_points in range(1, n_points):
e_points[x_points] = e_points[x_points - 1] * (1 - 0.115)
return e_points


var soLinger: Int
Returns setting for SockOpt.LINGER.
See Also: SRTO_LINGER
IOException
- if can't get SockOpt
value
- the linger time on close
IOException
- if can't set SockOpt
Getter
Gets the value of the SockOpt.LINGER option for this SRT socket.
Getter Return
linger time on close in seconds
Setter
Sets the value of the SockOpt.LINGER option for this SRT socket.


Blackest Night's Tim Seeley Reveals Where He Drew the Line
by Evangelia GalanisTim Seeley, author of Tales from the Dark Multiverse: Blackest Night, recently sat down with CBR to talk about his work on the book. The original Blackest Night dealt with a lot of heavy topics regarding death, but according to Seeley, there was one scene he wouldn't even touch.
2009's Blackest Night explored the possibility of multiple deceased DC characters returning to life. But there was a caveat --they weren't really themselves. The deceased characters resurrected by Nekron were merely reanimated corpses, presenting the heroes with horrifying zombified versions of beloved characters from their past. For Donna Troy, this meant she was confronted with her dead son, Robbie Troy.
Click the button below to start this article in quick view.
When the conversation shifted to Donna's interaction with Robbie, Seeley said, "That was grim! That was grim. That was one thing I knew, that we can't go as dark as that. That's my own self-limiting. We're not gonna do anything in which Wonder Girl crushes the head of her baby. We're just not gonna do it. And as a new dad, I can't go there."
The scene in question occurs in the Blackest Night: Titans tie-in issues. Donna is initially stunned by the reappearance of her infant son and ex-husband, Terry Long. However, it soon becomes clear that this isn't her Robbie.
After a heartbreaking interaction with her fellow Titans, Donna declares that these people from their past aren't really them. She rips out Terry's heart, declaring that he's dead to her. As for Robbie, Donna cannot bear to look at him, shedding a tear as she crushes the baby's head. Afterwards, she tearfully whispers, "I'm sorry."
Tales from the Dark Multiverse: Blackest Night #1 is on sale now from DC Comics.
https://schema.orgBreadcrumbListListItem1Homehttps://www.cbr.com/ListItem2Comicshttps://www.cbr.com/category/comics/ListItem3Comic Newshttps://www.cbr.com/category/comics/news/ListItem4Blackest Night's Tim Seeley Reveals Where He Drew the Linehttps://www.cbr.com/blackest-night-tim-seeley-draws-the-line/


Hi, my name is Beth Giobbe.
I am seeking a
Front‑End Web Developer job,
in‑person or hybrid, in the
Boston Metrowest area.
I started learning computer programming at age 14 and spent my high
school years writing business applications. After earning an
electrical engineering degree and working in that field for 2
years, I shifted back to software development because it is easy
and fun and I’m good at it.
I have continued learning over the
years, mostly on the job, from short courses and tutorials and
from other people’s code. Having taken online courses in database
and Ruby on Rails, I expect to add back-end skills quickly.
Outside of work, I grow vegetables and herbs in my raised-bed
garden, make herbal medicines, and enjoy reading cozy mysteries and
the occasional sci-fi/adventure story.


[1]
The screen is big, crystal clear and easy to read.
[2]
[3]
Layout of information on the screen is very good and easy to follow.


--- layout: default ---
Here you can find a collection of some the programming problems I have solved. They are solved using different programming languages such as Python, C++, and Java. You may also view my uHunt statistics here.


Detects non-default constructor in serializable classes (which is not allowed by IonObjectSerializer)


We thank you for choosing happication. We look forward to working together. The specialized team will contact you for more details


Port-knocking the a obfuscation-as-security technique. It basically means that after knocking on ports in a specific sequence a certain port will open automatically. It seems to be more popular in Capture-the-flag contests than real life networks.
Opening
So, how do we actually knock? As mentioned before a knock is essentially just sending a packet to a specific port.
Knock
apt-get install knockd
Then you simply type: knock [ip] [port]. For example: knock <IP_ADDRESS> 4000 5000 6000
Nmap/bash
for x in 4000 5000 6000; do nmap -Pn --host_timeout 201 --max-retries 0 -p $x server_ip_address; done
Netcat
nc <IP_ADDRESS> 4000
nc <IP_ADDRESS> 5000
nc <IP_ADDRESS> 6000
nc <IP_ADDRESS> 8888
Sniff it
One way hack a server with port-knocking implemented would be to sniff for packets on the network. So if you are on the same network and able to make MITM, you can just sniff that traffic and then find the sequence.


Testing results for the OpenADR ontology.
The following table lists the OpenADR ontology requirements and the OpenADR ontology satisfies them.
There are four possible results for each requirement:
| Identifier | Category | Competency Question | Result |
|---|---|---|---|
| oadr1 | Event | Events are generated by the VTN | |
| oadr2 | Device | Events are sent to targets | |
| oadr3 | Target | A target includes a resource and its VEN | |
| oadr4 | Device | Some events require a response | |
| oadr5 | Opt | A response is required, the VEN acknowledges its opt-in or out-out disposition | |
| oadr6 | Event | Events are included in the distribute event | |
| oadr7 | Event | Distribute events includes zero or more events | |
| oadr8 | Event | An event includes the following attributes: modificationNumber, modificationDateTime, modificationReason, priority, marketContext, createdDateTime, eventStatus, testEvent, comment | |
| oadr9 | Event | A active period defines the start time and duration of the event | |
| oadr10 | Event | The event also defines a randomization time window | |
| oadr11 | Event | An event includes a signal | |
| oadr12 | Event | An event also defines a ramp up and recovery period | |
| oadr13 | Event | Events may contain multiple event signals | |
| oadr14 | Event | Event signals may contain target elements | |
| oadr15 | VEN | A VEN is a communication endpoint that represents one or more logical resources | |
| oadr16 | Signal | There are different types of signals | |
| oadr17 | Report | There are three two types of reports: metada and data report | |
| oadr18 | Report | The data report can be of type history report and telemetry report | |
| oadr19 | Report | A report includes the following atributes: id and duration | |
| oadr20 | Report | A report defines a sampling rate | |
| oadr21 | Sampling | A sampling rate has a minimum and maximum period | |
| oadr22 | Sampling | A sampling rate has an attribute to determine whether or not data is sampled as it changes | |
| oadr23 | Opt | The type of schedules that a VEN is allowed to issue: optIn, optOut, or both | |
| oadr24 | Signal | Each signal element contains a signalType such as level or price | |
| oadr25 | Signal | Each signal has a set of intervals | |
| oadr26 | Signal | Each signal has the following attributes: name, type and item base | |
| oadr27 | VTN | Each VTN has a period of temporary availability for a specific set of targets | |
| oadr28 | VTN | Each VTN has a period of temporary unavailability for a specific set of targets | |
| oadr29 | Asset | Assets are physical entities | |
| oadr30 | Asset | An asset comprise a resource | |
| oadr31 | Resource | An resource may be managet by the VEN | |
| oadr32 | Resource | There may be one or more resources behind a VEN | |
| oadr33 | Signal | Each signal, event and report has a market context | |
| oadr34 | Event | An event can have more than one event descriptros | |
| oadr35 | Report | A report can have more than one report descriptors | |
| oadr36 | Signal | A signal can have more than one interval | |
| oadr37 | Signal | Each interval in a signal is related to a typical value |
The following table summarises the metrics related to the OpenADR ontology
| Metric | Result |
|---|---|
| Percentage of covered requirement | 100% |
| Percentage of requirements with terms that are undefined in the ontology | 0% |
| Percentage of requirements that lead to conflict | 0% |
| Percentage of tested terms | 44.18% |


|
Serial Wombat Arduino Library
|
Combine and input and output pin for a protected output. More...
#include <SerialWombatProtectedOutput.h>
Public Member Functions | |
| SerialWombatProtectedOutput (SerialWombat &serialWombat) | |
| Constructor for SerialWombatProtectedOutput. More... | |
| void | begin (uint8_t pin, uint8_t monitoredPin) |
| void | configure (PO_COMPARE_t compareMode, uint16_t compareValue, uint8_t debounceTime, SerialWombatPinState_t activeState, SerialWombatPinState_t safeState) |
| bool | isInSafeState () |
| Queries the Serial Wombat to see if the protected output has entered safe mode due to a fault. More... | |
| void | makeInput () |
| Turn off protection features and make the protected pin an input. More... | |
| void | digitalWrite (uint8_t state) |
| Turn off the protection features and make the protected pin an unprotected output. More... | |
Combine and input and output pin for a protected output.
The SerialWombtProtectedOutput class is assigned to a Serial Wombat output. It monitors another previously configured pin's public data, such as a digital I/O value or an Analog input. If the monitored value does not meet expectations, then the protected pin changes values to a configured state. This allows the Serial Wombat to constantly verify a condition without the need for constant polling from the host device.
The period of time that a mismatch must occur before going to the safeState is configurable.
Video Tutorial
| SerialWombatProtectedOutput::SerialWombatProtectedOutput | ( | SerialWombat & | serialWombat | ) |
Constructor for SerialWombatProtectedOutput.
| serialWombat | The serial Wombat on which the Protected Output runs |
| void SerialWombatProtectedOutput::begin | ( | uint8_t | pin, |
| uint8_t | monitoredPin | ||
| ) |
Initialize the Protected Output. No pin state changes happen with this function
| pin | The output pin of the Protected output Valid values for SW4A: 0-3 SW4B: 1-3 |
| monitoredPin | The input pin for the Protected Output. Must be initialized before this call |
| void SerialWombatProtectedOutput::configure | ( | PO_COMPARE_t | compareMode, |
| uint16_t | compareValue, | ||
| uint8_t | debounceTime, | ||
| SerialWombatPinState_t | activeState, | ||
| SerialWombatPinState_t | safeState | ||
| ) |
Configure a protected output. This function will change the pin output to activeState unless fault conditions are met
| compareMode | Enumerated type of PO_COMPARE_t . |
| compareValue | A 16 bit unsigned value that will be compared with the public data from the monitored pin and compared based on compareMode |
| debounceTime | How long, in mS the compareMode fault condition must exist before transitioning to safeState |
| activeState | The initial, pre-fault state for the output (SW_LOW, SW_HIGH, SW_INPUT). Do not use Arduino HIGH or LOW or INPUT constants. |
| safeState | The safe, post-fault state for the output (SW_LOW, SW_HIGH, SW_INPUT). Do not use Arduino HIGH or LOW or INPUT constants. |
| void SerialWombatProtectedOutput::digitalWrite | ( | uint8_t | state | ) |
Turn off the protection features and make the protected pin an unprotected output.
This function is compatible with the Arduino digital write, and therefore uses HIGH and LOW as parameters rather than SW_HIGH or SW_LOW /param state HIGH or LOW
| bool SerialWombatProtectedOutput::isInSafeState | ( | ) |
Queries the Serial Wombat to see if the protected output has entered safe mode due to a fault.
| void SerialWombatProtectedOutput::makeInput | ( | ) |
Turn off protection features and make the protected pin an input.


email<EMAIL_ADDRESS>tel:<PHONE_NUMBER>
We welcome any questions or comments you may have about our company, services or training opportunities.
foxyform
If you have any issues with the form then please send an email directly to: info@minedminds.org


OPENBOX(1) OPENBOX(1) NAME openbox-gnome-session — Run a GNOME session with Openbox as the window manager DESCRIPTION openbox-gnome-session runs a GNOME session with Openbox as the window manager. openbox-gnome-session does not take any command line arguments. SEE ALSO openbox(1), openbox-kde-session(1), openbox-session(1). The program's full documentation is available on the website: http://openbox.org/ Please report bugs to: http://bugzilla.icculus.org/ OPENBOX(1)


Commander X16 Emulator
This is an emulator for the Commander X16 computer system. It only depends on SDL2 and should compile on all modern operating systems.
Starting
You can start x16emu
/x16emu.exe
either by double-clicking it, or from the command line. The latter allows you to specify additional arguments.
- When starting
x16emu
without arguments, it will pick up the system ROM (rom.bin
) and the character ROM (chargen.bin
) from the executable's directory.
- The system ROM and character ROM filenames/paths can be overridden with the
-rom
and -char
command line arguments.
-sdcard
lets you specify an SD card image (partition table + FAT32).
-prg
leys you specify a .prg
file that gets injected into RAM after start.
- When compiled with
#define TRACE
, -trace
will enable an instruction trace on stdout.
Run x16emu -h
to see all command line options.
Functions while running
- Cmd + R will reset the computer.
- Cmd + S will save a memory dump (40 KB main RAM + 2 MB bankable RAM) to disk.
(These shortcuts currently only work on macOS.)
Host Filesystem Interface
If the system ROM contains any version of the KERNAL, the LOAD ($FFD5
) and SAVE ($FFD8
) KERNAL calls are intercepted by the emulator if the device is 1 (which is the default). So the BASIC statements
LOAD"$
LOAD"FOO.PRG
LOAD"IMAGE.PRG",1,1
SAVE"BAR.PRG
will target the host computer's local filesystem.
Using the KERNAL/BASIC environment
Please see the KERNAL/BASIC documentation.
Features
- CPU: Full 6502 instruction set ("fake6502")
- VERA
- Mostly cycle exact emulation
- Supports almost all features: composer, two layers, sprites, progressive/interlaced
- VIA
- ROM/RAM banking
- PS/2 keyboard
- SD card (SPI)
- A 60 Hz interrupt is injected independently of the VIA settings.
Missing Features
- CPU
- Only supports the 6502 instruction set, not the 65C02 additions.
- VERA
- Does not support IRQs
- Does not support the "CURRENT_FIELD" bit
- Does not sprite z-depth, collisions or limitations
- Only supports the first 16 sprites
- Interlaced modes (NTSC/RGB) don't render at the full horizontal fidelity
- VIA
- Does not support counters/timers/IRQs
- Does not support game controllers
- Sound
License
Copyright (c) 2019 Michael Steil<EMAIL_ADDRESS>www.pagetable.com. All rights reserved. License: 2-clause BSD
Release Notes
Release 27
- Command line overhaul. Supports
-rom
, -char
, -sdcard
and -prg
.
- ROM and char filename defaults, so x16emu can be started without arguments.
- Host Filesystem Interface supports LOAD"$"
- macOS and Windows packaging logic in Makefile
Release 26
- better sprite support (clipping, palette offset, flipping)
- better border support
- KERNAL can set up interlaced NTSC mode with scaling and borders (compile time option)
Release 25
- sdcard: fixed LOAD,x,1 to load to the correct addressg
- sdcard: all temp data will be on bank #255; current bank will remain unchanged
- DOS: support for DOS commands ("UI", "I", "V", ...) and more status messages (e.g. 26,WRITE PROTECT ON,00,00)
- BASIC: "DOS" command. Without argument: print disk status; with "$" argument: show directory; with "8" or "9" argument: switch default drive; otherwise: send DOS command; also accessible through F7/F8
- Vera: cycle exact rendering, NTSC, interlacing, border
Release 24
- SD card support
- pass path to SD card image as third argument
- access SD card as drive 8
- the local PC/Mac disk is still drive 1
- modulo debugging, this would work on a real X16 with the SD card (plus level shifters) hooked up to VIA#2PB as described in sdcard.c in the emulator surce
Release 23
- Updated emulator and ROM to spec 0.6 – the ROM image should work on a real X16 with VERA 0.6 now.
Release 22
SYS65375 (SWAPPER) now also clears the screen, avoid ing side effects.
Release 21
- support for $ and % number prefixes in BASIC
- support for C128 KERNAL APIs LKUPLA, LKUPSA and CLOSE_ALL
Release 20
- Toggle fullscreen using Cmd+F or Cmd+return
- new BASIC instructions and functions:
- MON: enter monitor; no more SYS65280 required
- VPEEK(bank, address)
- VPOKE bank, address, value example: VPOKE4,0,VPEEK(4,0) OR 32 [for 256 color BASIC]
Release 19
- fixed cursor trail bug
- fixed f7 key in PS/2 driver
- f keys are assigned with shortcuts now: F1: LIST F2: <enter monitor> F3: RUN F4: <switch 40/80> F5: LOAD F6: SAVE" F7: DOS"$ <doesn't work yet> F8: DOS <doesn't work yet>
Release 18
- Fixed scrolling in 40x30 mode when there are double lines on the screen.
Release 17
- video RAM support in the monitor (SYS65280)
- 40x30 screen support (SYS65375 to toggle)
Release 16
- Integrated monitor, start with SYS65280 rom.bin is now 3*8 KB:
- 0: BASIC (bank 0 at $C000)
- 1: KERNAL ($E000)
- 2: UTIL (bank 1 at $C000)
Release 15
- correct text mode video RAM layout both in emulator and KERNAL
Release 14
- KERNAL: fast scrolling
- KERNAL: upper/lower switching using CHR$($0E)/CHR$($8E)
- KERNAL: banking init
- KERNAL: new PS/2 driver
- Emulator: VERA updates (more modes, second data port)
- Emulator: RAM and ROM banks start out as all 1 bits
Release 13
- Supports mode 7 (8bpp bitmap).
Release 12
- Supports 8bpp tile mode (mode 4)
Release 11
- The emulator and the KERNAL now speak the bit-level PS/2 protocol over VIA#2 PA0/PA1. The system behaves the same, but keyboard input in the ROM should work on a real device.
Release 10
updated KERNAL with proper power-on message
Release 9
LOAD and SAVE commands are intercepted by the emulator, can be used to access local file system, like this:
LOAD"TETRIS.PRG
SAVE"TETRIS.PRG
No device number is necessary. Loading absolute works like this:
LOAD"FILE.PRG",1,1
Release 8
Release 7
- Now with banking. POKE40801,n to switch the RAM bank at $A000. POKE40800,n to switch the ROM bank at $C000. The ROM file at the command line can be up to 72 KB now (layout: 0: bank 0, 1: KERNAL, 2: bank 1, 3: bank 2 etc.), and the RAM that Cmd+S saves is 2088KB ($0000-$9F00: regular RAM, $9F00-$9FFF: unused, $A000+: extra banks)
Release 6
- Vera emulation now matches the complete spec dated 2019-07-06: correct video address space layout, palette format, redefinable character set
Release 5
- BASIC now starts at $0401 (39679 BASIC BYTES FREE)
Release 4
- Cmd+S now saves all of memory (linear 64 KB for now, including ROM) to "memory.bin", "memory-1.bin", "memory-2.bin", etc. You can extract parts of it with Unix "dd", like: dd if=memory.bin of=basic.bin bs=1 skip=2049 count=38655
Release 3
- Supports PRG file as third argument, which is injected after "READY.", so BASIC programs work as well.
Release 2
Release 1
- 6502 core, fake PS/2 keyboard emulation (PS/2 data bytes appear at VIA#1 PB) and text mode Vera emulation
- KERNAL/BASIC modified for memory layout, missing VIC, Vera text mode and PS/2 keyboard


All Classes
Block
BRS
BRSIndexProgressive
BRSIndexProgressiveDiv
BRSIndexProgressiveDivExhaustive
Grid
InputFileParser
POI
Rectangle
ResultsWriter
RunBRS
ScoreFunction
ScoreFunctionCount
ScoreFunctionDistinctKeywords
ScoreFunctionTotalScore
SpatialObject
UtilityScoreFunction


Index of the Suttas of the Saɱyutta Nikāya
Nidana Vagga
Kassapa Saɱyutta
II. Nidāna Vagga
BD: On The Downbound
PTS: The Nidana Book
WP: Connected Discourses on Causation
Book V.
Chapter 16.
Kassapa Saɱyutta, II.194
PTS: Kindred Sayings on Kassapa, II.131
WP: Connected Discourses with Kassapa, I.662
1. Saṇtuṭṭha Suttaɱ, II.194
PTS: Contented, II.131
WP: Content, I.662
2. Anottāpi Suttaɱ, II.195
PTS: Careless, II.132
WP: Unafraid of Wrongdoing, I.663
3. Candupama Suttaɱ, II.197
BIT: Warren, Buddhism in Translations, The Mendicant Ideal
PTS: Comparable to the Moon, II.133
WP: Like the Moon, I.664
4. Kulūpaga Suttaɱ, II.200
PTS: Visiting the Families, II.135
WP: A Visitor of Families, I.665
5. Jiṇṇa Suttaɱ, II.202
PTS: Grown Old, II.136
WP: Old, I.666
ATI: Old
6. Paṭhama Ovāda Suttaɱ, II.203
PTS: Exhortation (1), II.137
WP: Exhortation 1, I.667
7. Dutiya Ovāda Suttaɱ, II.205
PTS: Exhortation 2, II.139
WP: Exhortation 2, I.669
8. Tatiya Ovāda Suttaɱ, II.208
PTS: Exhorting 3, II.140
WP: Exhortation 3, I.670
9. Jhānābhiññā Suttaɱ, II.210
PTS: Jhāna and Super-knowledge, II.141
WP: Jhānas and Direct Knowledges, I.671
10. Bhikkhun'upassaya Suttaɱ, II.214
PTS: The Sisters' Quarters, II.145
WP: The Bhikkhunis' Quarters, I.674
11. Cīvara Suttaɱ, II.217
PTS: The Robe, II.146
WP: The Robe, I.676
12. Tathāgata Param-Māraṇa Suttaɱ, II.222
PTS: After Death, II.150
WP: After Death, I.679
13. Saddhamma-Patirūpaka Suttaɱ, II.223
PTS: A counterfeit Norm, 151
WP: The Counterfeit of the True Dhamma, I.680
ATI: A Counterfeit of the True Dhamma
MNL: An Image of the True Teaching


{% extends 'base.html' %} {% block title %} {{ 'Submitted Scores List - University of Warwick Archery Club' }} {% endblock %} {% block main_content %}
All scores listed below are awaiting approval or rejection.


@xrdocs Formatting Useful Tips
This Tutorial gives a quick walkthrough of some of the functionalities available with @xrdocs. While some of these tips may be hidden/less-known Markdown techniques, most of them showcase custom css classes that have been provided with @xrdocs to give you a true editor experience while still using Markdown.
Link to other posts
Include and use the “base_path” variable so that you only have to use relative URLs for other posts (tutorials/blogs/tech-docs) on the same website. Referencing the link is then similar to any Markdown link of the form:
[link title/context](complete link)
For example:
Link back to the xrdocs Tutorial: @xrdocs How-To
{% include base_path %}
Link back to the xrdocs Tutorial: [@xrdocs How-To]({{ base_path }}/helpdocs/xrdocs-how-to)
How to hide your posts from indexing temporarily
Quite often you’d like to be able to publish your blog/tutorial to the website but not have it be indexed or tweeted automatically till you’re ready.
This is pretty simple to enable.
Hit the metadata button on the right hand side as shown below:
When the metadata fields open up, enter position: hidden
into the raw metadata field as shown below:
Now save/commit the blog. It will only be visible if you have the link to it. How do you get the link?
Hit the settings button on the right hand side as shown:
Copy the filename that shows up under the directory you’re posting under (remove the .md at the end) and append to the link where you expect the blog/tutorial to show up.
So, if the blog needs to appear under https://xrdocs.github.io/telemetry/blogs/
and filename as determined above is 2016-07-23-my-new-blog.md
then the link to the blog will be:
https://xrdocs.github.io/telemetry/blogs/2016-07-23-my-new-blog/
How do you go live after hiding it?
Going live is simple. Hit the metadata button again and replace position: hidden
with position: top
as shown below:
Save and Commit. You’re live! and will tweeted out on https://twitter.com/xrdocs in upto an hour.
Add new lines (carriage return)
This is sort of a known secret with markdown. Markdown just outputs text directly on the next line as you hit enter. If you want to add more carriage returns to your text, then add 2+ spaces at the end of a line and hit enter.
Like this.
This is sort of a known secret with markdown. Markdown just outputs text directly on the next
line as you hit enter. If you want to add more carriage returns to your text, then add 2+ spaces
at the end of a line and hit enter.
<2 spaces here >
Like this.
Formatting inside a code block!
Sometimes you might want to highlight text inside a code block or to show it in a bold font. By default, markdown doesn’t support it. But, here is a technique that can be used and it delivers great results:
Instead of using:
```
Your code here
```
Use this exact set up:

Your code here

The advantage?
I could now easily use the
(bold) tag or
(highlight) tag or the
(custom color highlight) tag from html to make my code content stand out.
For example, if I use:

function filesize
{
local file=$1
size=`stat -c %s $file 2>/dev/null` # linux
if [[ $? -eq 0 ]]; then
echo $size
return 0
fi
eval $(stat -s $file) # macos
if [[ $? -eq 0 ]]; then
echo $st_size
return 0
fi
echo 0
return -1
}

Then the result is:
function filesize
{
local file=$1
size=`stat -c %s $file 2>/dev/null` # linux
if [[ $? -eq 0 ]]; then
echo $size
return 0
fi
eval $(stat -s $file) # macos
if [[ $? -eq 0 ]]; then
echo $st_size
return 0
fi
echo 0
return -1
}
P.S. You can get the color code for your favorite highlight color from here: Color Codes
Text Alignment
Align text blocks with the following classes.
Left aligned text .text-left
Left aligned text
{: .text-left}
Center aligned text. .text-center
Center aligned text.
{: .text-center}
Right aligned text. .text-right
Right aligned text.
{: .text-right}
Justified text. .text-justify
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque vel eleifend odio, eu elementum purus. In hac habitasse platea dictumst. Fusce sed sapien eleifend, sollicitudin neque non, faucibus est. Proin tempus nisi eu arcu facilisis, eget venenatis eros consequat.”
Justified text..text-justify
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque vel eleifend odio, eu elementum purus. In hac habitasse platea dictumst. Fusce sed sapien eleifend, sollicitudin neque non, faucibus est. Proin tempus nisi eu arcu facilisis, eget venenatis eros consequat.”
{: .text-justify}
No wrap text. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque vel eleifend odio, eu elementum purus. In hac habitasse platea dictumst. Fusce sed sapien eleifend, sollicitudin neque non, faucibus est. Proin tempus nisi eu arcu facilisis, eget venenatis eros consequat.”.text-nowrap
No wrap text. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque vel eleifend odio, eu elementum purus. In hac habitasse platea dictumst. Fusce sed sapien eleifend, sollicitudin neque non, faucibus est. Proin tempus nisi eu arcu facilisis, eget venenatis eros consequat.
{: .text-nowrap}
Image Alignment
Position images with the following classes.
The image above happens to be centered.
![image-center](/images/filename.jpg){: .align-center}
The rest of this paragraph is filler for the sake of seeing the text wrap around the 150×150 image, which is left aligned. There should be plenty of room above, below, and to the right of the image. Just look at him there — Hey guy! Way to rock that left side. I don’t care what the right aligned image says, you look great. Don’t let anyone else tell you differently.
![image-left](/images/filename.jpg){: .align-left}
And now we’re going to shift things to the right align. Again, there should be plenty of room above, below, and to the left of the image. Just look at him there — Hey guy! Way to rock that right side. I don’t care what the left aligned image says, you look great. Don’t let anyone else tell you differently.
![image-right](/images/filename.jpg){: .align-right}
The image above should extend outside of the parent container on right.
![full](/images/filename.jpg)
{: .full}
Buttons
Make any link standout more when applying the .btn
class.
This is a success button: Text
This is a success button: [Text](#link){: .btn .btn--success}
| Button Type | Example | Class | Kramdown |
|---|---|---|---|
| Default | Text | .btn |
[Text](#link){: .btn} |
| Success | Text | .btn .btn--success |
[Text](#link){: .btn .btn--success} |
| Warning | Text | .btn .btn--warning |
[Text](#link){: .btn .btn--warning} |
| Danger | Text | .btn .btn--danger |
[Text](#link){: .btn .btn--danger} |
| Info | Text | .btn .btn--info |
[Text](#link){: .btn .btn--info} |
| Inverse | Text | .btn .btn--inverse |
[Text](#link){: .btn .btn--inverse} |
| Light Outline | Text | .btn .btn--light-outline |
[Text](#link){: .btn .btn--light-outline} |
| Button Size | Example | Class | Kramdown |
|---|---|---|---|
| X-Large | X-Large Button | .btn .btn--x-large |
[Text](#link){: .btn .btn--x-large} |
| Large | Large Button | .btn .btn--large |
[Text](#link){: .btn .btn--large} |
| Default | Default Button | .btn |
[Text](#link){: .btn} |
| Small | Small Button | .btn .btn--small |
[Text](#link){: .btn .btn--small} |
Notices
Call attention to a block of text.
| Notice Type | Class |
|---|---|
| Default | .notice |
| Primary | .notice--primary |
| Info | .notice--info |
| Warning | .notice--warning |
| Success | .notice--success |
| Danger | .notice--danger |
Watch out! This paragraph of text has been emphasized with the {: .notice}
class.
**Watch out!** This paragraph of text has been emphasized with the `{: .notice}` class.
{: .notice}
Watch out! This paragraph of text has been emphasized with the {: .notice--primary}
class.
**Watch out!** This paragraph of text has been emphasized with the `{: .notice--primary}` class.
{: .notice--primary}
Watch out! This paragraph of text has been emphasized with the {: .notice--info}
class.
**Watch out!** This paragraph of text has been emphasized with the `{: .notice--info}` class.
{: .notice--info}
Watch out! This paragraph of text has been emphasized with the {: .notice--warning}
class.
**Watch out!** This paragraph of text has been emphasized with the `{: .notice--warning}` class.
{: .notice--warning}
Watch out! This paragraph of text has been emphasized with the {: .notice--success}
class.
**Watch out!** This paragraph of text has been emphasized with the `{: .notice--success}` class.
{: .notice--success}
Watch out! This paragraph of text has been emphasized with the {: .notice--danger}
class.
**Watch out!** This paragraph of text has been emphasized with the `{: .notice--danger}` class.
{: .notice--danger}
Use block quotes “>” to add lists to your “notices”
You can also add the
.notice
class to a

element,but we won’t get into that.
- Bullet point 1
- Bullet point 2
>
Use block quotes ">" to add lists to your "notices"
>
You can also add the `.notice` class to a `<div>` element, but we won't get into that.
>
* Bullet point 1
* Bullet point 2
{: .notice}
Adding a Table of Contents to a page
To include an auto-generated table of contents for posts and pages, add the following helper before any actual content in your post or page.
{% include toc %}
| Parameter | Required | Description | Default |
|---|---|---|---|
| title | Optional | Table of contents title. | toc_label in UI Text data file. |
| icon | Optional | Table of contents icon (shows before the title). | Font Awesome file-text icon. Any other FA icon can be used instead. |
TOC example with custom title and icon
{% include toc icon="table" title="My Table of Contents" %}
Leave a Comment


{{test}} Test
{%- for question in questions -%}
{{question}}
Strongly Disagree
Strongly Agree
{%- endfor -%}


Time of day:
Morning
Noon
Afternoon
Evening
Direct shadows general:
Change shadow on objects basis:
Buildings shadow:
Zoning volume shadows:
Crane shadows:


Andre Weiner, Tomislav Maric
TU Braunschweig, Institute of Fluid
Mechanics
Goals of flow control:
Categories of flow control:
active: energy input vs. efficiency gain
Categories of active flow control:
How to find the control law?
Closed-loop flow control with variable Reynolds number; source: F. Gabriel 2021.
Why CFD-based DRL?
Create an intelligent agent that learns to map states to actions such that expected returns are maximized.
$s_t$ - state $s$ at time $t$ (observation)
$s$ should be low-dimensional
$a_t$ - action $a$ at time $t$
$a$ should be low-dimensional
reward and reward function
$r=-c_d - 0.1 |c_l|$
$r_t$ - reward at time $t$
$c_d$, $c_l$ - drag and lift coefficient
experience tuple
$$ \left\{ s_t, a_t, r_{t+1}, s_{t+1}\right\} $$
trajectory
$ \left\{s_0, a_0, r_1, s_1\right\} $
$ \left\{s_1, a_1, r_2, s_3\right\} $
$\left\{ ...\right\} $
Long-term consequences:
$$ G_t = \sum\limits_{l=0}^{N_t-t} \gamma^l r_{t+l} $$
What to expect in a given state?
$$ L_V = \frac{1}{N_\tau N_t} \sum\limits_{\tau = 1}^{N_\tau}\sum\limits_{t = 1}^{N_t} \left( V(s_t^\tau) - G_t^\tau \right)^2 $$
Was the selected action a good one?
$$\delta_t = R_t + \gamma V(s_{t+1}) - V(s_t) $$ $$ A_t^{GAE} = \sum\limits_{l=0}^{N_t-t} (\gamma \lambda)^l \delta_{t+l} $$
Making good actions more likely:
$$ J_\pi = \frac{1}{N_\tau N_t} \sum\limits_{\tau = 1}^{N_\tau}\sum\limits_{t = 1}^{N_t} \left( \frac{\pi(a_t|s_t)}{\pi^{old}(a_t|s_t)} A^{GAE,\tau}_t\right) $$
Cylinder benchmark case; $Re=100$.
Proximal policy optimization (PPO) workflow (GAE - generalized advantage estimate).
3 steps to solve a new control problem
openfoam/test_cases/rotatingCylinder2D
inputs for control law
probes
{
type probes;
libs (sampling);
executeControl runTime;
executeInterval 0.01;
writeControl runTime;
writeInterval 0.01;
timeStart 4.0;
fields (p);
probeLocations
(
(0.3 0.15 0.005)
...
);
}
quantities defining control objective
forces
{
type forceCoeffs;
libs (forces);
executeControl runTime;
executeInterval 0.01;
writeControl runTime;
writeInterval 0.01;
timeStart 4.0;
patches
(
cylinder
);
coefficients (Cd Cl);
...
}
define how to run the simulation
openfoam/src/agentRotatingWallVelocity
getting the state
if (timeToControl && update_omega_)
{
const volScalarField& p =
this->db().lookupObject<volScalarField>("p");
scalarField p_sample = probes_.sample(p);
...
}
Policy network predicts probability density function(s) for action(s).
Comparison of Gauss and Beta distribution.
getting the next action I
torch::Tensor features = torch::from_blob(
p_sample.data(), {1, p_sample.size()},
torch::TensorOptions().dtype(torch::kFloat64)
);
std::vector<torch::jit::IValue> policyFeatures{features};
torch::Tensor dist_parameters = policy_.forward(policyFeatures).toTensor();
scalar alpha = dist_parameters[0][0].item<double>();
scalar beta = dist_parameters[0][1].item<double>();
getting the next action II
std::gamma_distribution<double> distribution_1(alpha, 1.0);
std::gamma_distribution<double> distribution_2(beta, 1.0);
scalar omega_pre_scale;
if (train_)
{
// sample from Beta distribution during training
double number_1 = distribution_1(gen_);
double number_2 = distribution_2(gen_);
omega_pre_scale = number_1 / (number_1 + number_2);
}
else
{
// use expected (mean) angular velocity
omega_pre_scale = alpha / (alpha + beta);
}
// rescale to actionspace
omega_ = (omega_pre_scale - 0.5) * 2 * abs_omega_max_;
using the boundary condition in 0.org/U
cylinder
{
type agentRotatingWallVelocity;
origin (0.2 0.2 0.0);
axis (0 0 1);
policy "policy.pt";
probesDict "probes";
train true;
seed 0;
absOmegaMax 5.0;
value uniform (0 0 0);
}
drlfoam/environment/rotating_cylinder.py
some convenience functions
def _parse_forces(path: str) -> DataFrame:
forces = read_csv(path, sep="\t", comment="#",
header=None, names=["t", "cd", "cl"])
return forces
def _parse_probes(path: str, n_probes: int) -> DataFrame:
names = ["t"] + [f"p{i}" for i in range(n_probes)]
return read_csv(
path, header=None, names=names,
comment="#", delim_whitespace=True
)
derived class
class RotatingCylinder2D(Environment):
def __init__(self, r1: float = 3.0,
r2: float = 1.0, r3: float=0.1):
super(RotatingCylinder2D, self).__init__(
join(TESTCASE_PATH, "rotatingCylinder2D"),
"Allrun.pre", "Allrun", "Allclean", 2, 12, 1
)
...
def _reward(self, cd: pt.Tensor, cl: pt.Tensor) -> pt.Tensor:
return self._r1 - (self._r2 * cd + self._r3 * cl.abs())
...
how to run a training
DEFAULT_CONFIG = {
"rotatingCylinder2D" : {
"policy_dict" : {
"n_layers": 2,
"n_neurons": 64,
"activation": pt.nn.functional.relu
},
"value_dict" : {
"n_layers": 2,
"n_neurons": 64,
"activation": pt.nn.functional.relu
}
}
...
config = SlurmConfig(
n_tasks=env.mpi_ranks,
n_nodes=1,
partition="queue-1",
time="03:00:00",
constraint="c5a.24xlarge",
modules=["openmpi/4.1.5"],
commands_pre=[
"source /fsx/OpenFOAM/OpenFOAM-v2206/etc/bashrc",\
"source /fsx/drlfoam_main/setup-env"
]
)
buffer = SlurmBuffer(training_path, ...)
#!/bin/bash
#SBATCH --job-name=train_cylinder
#SBATCH --ntasks=6
#SBATCH --output=%x_%j.out
#SBATCH --partition=queue-1
#SBATCH --constraint=c5a.24xlarge
source /fsx/OpenFOAM/OpenFOAM-v2206/etc/bashrc
source /fsx/drlfoam_main/setup-env
source /fsx/drlfoam_main/pydrl/bin/activate
python3 run_training.py -o first_training \
-i 100 -r 10 -b 10 -f 8 \
-e slurm &> log.first_training
evaluating a policy
base
and clean uppolicy_trace_xxx.pt
policy.pt
train 0;
in 0.org/UtimeStart ...;
in system/Allrun.pre
Comparison of controlled and uncontrolled drag coefficient.
Evaluation of final policy.
more control problems
more advanced DRL topics
$\rightarrow$ Advances in the application of reinforcement learning to flow control problems
Wed, 09:00-09:20, room 4H
data-driven modeling SIG meeting
Thu, 5:15-6:15 pm, room 4H
3rd OpenFOAM-ML hackathon (register)
Jul 24-26
thanks to
Darshan Thummar, Fabian Gabriel, Jan Erik Schulze, Tom Krogmann, Janis Geise
Ajay Navilarekal Rajgopal, Guilherme Lindner, Julian Bissantz, Morgan Kerhouant, Mosayeb Shams, Tomislav Marić
Neil Ashton


guice-multibindings-2.0.jar
.请参阅: 说明
| 类 | 说明 |
|---|---|
| MapBinder<K,V> |
An API to bind multiple map entries separately, only to later inject them as
a complete map.
|
| MapBinder.RealMapBinder<K,V> |
The actual mapbinder plays several roles:
As a MapBinder, it acts as a factory for LinkedBindingBuilders for
each of the map's values.
|
| MapBinder.RealMapBinder.MapBinderProviderWithDependencies<K,V> | |
| Multibinder<T> |
An API to bind multiple values separately, only to later inject them as a
complete collection.
|
| Multibinder.RealMultibinder<T> |
The actual multibinder plays several roles:
As a Multibinder, it acts as a factory for LinkedBindingBuilders for
each of the set's elements.
|
guice-multibindings-2.0.jar
.