-
Notifications
You must be signed in to change notification settings - Fork 4
Add form-csv to yaml converter #140
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
7727d76
Add form-csv to yaml converter
Dvermetten a11d48d
Add OPL_form as example form output
Dvermetten ce8b323
add WIP changes to form conversion
Dvermetten e41e48c
Avoid duplicates and empty optional fields
Dvermetten b7b4faf
Update detection of existing columns
Dvermetten 39675fe
Remove duplicated entry
Dvermetten 63f9a12
Covert Present/Not Present to yes/no
Dvermetten 9ec294a
Fix yes-no conversion + add new problems from form
Dvermetten a460c27
remove duplicate entry
Dvermetten 63ddee2
Merge branch 'main' into feat/form_to_yaml
Dvermetten ecc90e5
Update html
Dvermetten 0c465c0
redo merge
Dvermetten 167a0b3
Add link back and re-generate html
kvdblom File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| import pandas as pd | ||
| import yaml | ||
|
|
||
| csv_file = "OPL_form.csv" | ||
| yaml_file = "problems.yaml" | ||
|
|
||
|
|
||
| translations = { | ||
| # "Timestamp", | ||
| # "Submitter Name", | ||
| # "Submitter Email", | ||
| "Short name of Suite / Problem / Generator" : "name", | ||
| "Type" : "suite/generator/single", | ||
| "Types of input variables" : "variable type", | ||
| "Number of Input variables (number or range or 'scalable')" : "dimensionality", | ||
| "Number of Objectives (number or range or 'scalable')" : "objectives", | ||
| "Problem Characteristics [Constrained]":"constraints", | ||
| "Problem Characteristics [Dynamic]":"dynamic", | ||
| "Problem Characteristics [Noisy]":"noise", | ||
| "Problem Characteristics [Multi-modal]":"multimodal", | ||
| # "Problem Characteristics [Partial evaluations possible]", | ||
| "Problem Characteristics [Multiple fidelities]":"multi-fidelity", | ||
| "Problem Source":"source (real-world/artificial)", | ||
| "Link to Implementation" :"implementation", | ||
| "Short description of problem(s)":"textual description", | ||
| # "Do you wish to provide some more detailed information about the proposed problems?", | ||
|
kvdblom marked this conversation as resolved.
Outdated
|
||
| # "Full name of suite", | ||
| # "Constraint Properties", | ||
| # "Number of constraints", | ||
| # "Type of Dynamicism", | ||
| # "Form of noise model", | ||
| # "Type of noise space", | ||
| # "Other noise properties", | ||
| # "Description of multimodality", | ||
| "Citation / reference": "reference", | ||
| # "Key challenges / characteristics", | ||
| # "Scientific motivation for the proposed suite / problem / generator", | ||
| # "Limitations of the proposed suite / problem / generator", | ||
| # "Implemenation languages", | ||
| # "Links to implementations", | ||
| # "Approximate time to evaluate a single solution (or times if e.g. multi-fidelity)", | ||
| # "Links to examples of usage of the proposed suite / problem / generator", | ||
| "Other relevant information":"other info", | ||
| # "Feedback about the form" | ||
| } | ||
|
|
||
| # Read the csv file | ||
| data = pd.read_csv(csv_file) | ||
|
|
||
| # Handle empty cells being read as 'NaN', by emptying them again | ||
| data = data.fillna("") | ||
| data2 = data.rename(columns=translations) | ||
| data2.drop(columns=[col for col in data2.columns if col not in translations.values()], inplace=True) | ||
| data2 = data2[data2['name'] != 'test'] | ||
|
|
||
| # Write the yaml file | ||
| with open(yaml_file, "a") as out_file: | ||
| yaml.dump(data2.to_dict(orient="records"), out_file, | ||
| sort_keys=False) # Prevent columns being reordered alphabetically | ||
This file contains hidden or 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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.