-
Notifications
You must be signed in to change notification settings - Fork 24
feat(few-shot): add a few-shot example for #1 #2
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -681,4 +681,83 @@ assert create_folds(range(12), 2) == [range(0, 6), range(6, 12)] | |
| assert create_folds(range(8), 2) == [range(0, 4), range(4, 8)] | ||
| assert create_folds(range(25), -5) == [] | ||
| assert create_folds(range(6), 2) == [range(0, 3), range(3, 6)] | ||
| ``` | ||
| ``` | ||
|
|
||
| ### Example 10 | ||
| [Code] | ||
| import math | ||
|
|
||
| def alt2temp(h, mmHg=29.92): | ||
| if mmHg != 29.92: | ||
| dh = ((8.95e10 * 288.15) / | ||
| (-32.174 * 28.964) * | ||
| math.log(mmHg / 29.92)) | ||
| h += dh | ||
| To = 518.69 | ||
| if h > 36089: | ||
| T = 389.99 | ||
| else: | ||
| T = To * (1 - 6.87559e-6 * h) | ||
| return T | ||
|
|
||
| [Property] | ||
| category: code generation (function implementation) | ||
| language: Python | ||
| concepts: mathematical modeling, environmental physics, parameter default values | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. mathematical modeling and environmental physics are too vague concepts. Try to relate to the logic like formula calculation / logarithm using.. |
||
|
|
||
| [Instruction] | ||
| Write a Python function that converts altitude to temperature using the standard atmosphere model. The function should also adjust for variations in barometric pressure given by the parameter mmHg. | ||
|
Comment on lines
+708
to
+709
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The instruction loses context. "the standard atmosphere model" is not explained and terms like "barometric pressure", "mmHg" are strange. Try to make it more declarative, logical, and understandable by humans, incorporating more unique coding features. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I thought The Standard Atmosphere was common knowledge: https://engineering.purdue.edu/~andrisan/Courses/AAE490A_S2002/Atmosphere.pdf Or do you think more explanation is needed regardless of common knowledge? 🤔 |
||
|
|
||
| [Response] | ||
| [Reasoning] | ||
| To compute the temperature at a given altitude, considering the barometric pressure, we can use the standard atmospheric model modified for non-standard pressures. The function altitude_to_temperature calculates the temperature at a specified altitude h, adjusting the altitude if the barometric pressure mmHg differs from the standard 29.92 inches of Hg. The temperature calculation depends on whether the altitude is above or below 36,089 feet. | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 29.92 cannot be derived from the instruction, so the response is not aligned |
||
|
|
||
| [Implementation] | ||
| Here is an implementation of the desired function: | ||
|
|
||
| ```python | ||
| import math | ||
|
|
||
| def altitude_to_temperature(h, mmHg=29.92): | ||
| """ | ||
| Converts altitude (in feet) to temperature (in Kelvin) under varying barometric pressures. | ||
| The default barometric pressure is set at 29.92 inches of Hg. | ||
|
|
||
| Parameters: | ||
| h (float): Altitude in feet. | ||
| mmHg (float): Current barometric pressure in inches of mercury. | ||
|
|
||
| Returns: | ||
| float: Temperature in Kelvin. | ||
| """ | ||
| if mmHg != 29.92: | ||
| # Calculate the corrected altitude based on the current pressure | ||
| dh = ((8.95e10 * 288.15) / (-32.174 * 28.964) * math.log(mmHg / 29.92)) | ||
| h += dh | ||
|
|
||
| # Define the baseline temperature at sea level | ||
| base_t = 518.69 | ||
| if h > 36089: | ||
| # Use constant temperature above 36,089 feet | ||
| return = 389.99 | ||
|
|
||
| # Calculate temperature based on altitude below 36,089 feet | ||
| return base_t * (1 - 6.87559e-6 * h) | ||
| ``` | ||
|
|
||
| [Explanation] | ||
| This function handles the conversion of altitude to temperature by adjusting for differences in barometric pressure from the standard. The math.log function is used to adjust the altitude based on the deviation of mmHg from 29.92. | ||
|
|
||
| If the altitude exceeds 36,089 feet, a constant temperature is used, as specified by standard atmospheric models. Below this altitude, the temperature decreases linearly with an increase in altitude according to the given formula. | ||
|
|
||
| [Tests] | ||
| The test cases below can validate the functionality in various scenarios: | ||
|
|
||
| ```python | ||
| # Test at sea level under standard pressure | ||
| assert round(altitude_to_temperature(0), 2) == 518.69 | ||
| # Test at 40,000 feet under standard pressure | ||
| assert altitude_to_temperature(40000) == 389.99 | ||
| # Test with non-standard barometric pressure | ||
| assert round(altitude_to_temperature(10000, 30.92), 2) != 518.69 | ||
| ``` | ||