23ws-LLMcoder/LLMcoder-GitHub-Python-Mix-Direct
Dataset Card for LLMcoder-GitHub-Python-Mix-Direct Python target autocomplete suggestions in the format of conversations for OpenAI's fine-tuning. Dataset Details Dataset Description Curated by: [More Information Needed] Funded by [optional]: [More Information Needed] Shared by [optional]: [More Information Needed] Language(s) (NLP): [More Information Needed] License: [More Information Needed] Dataset Sources [optional] The data… See the full description on the dataset page: https://huggingface.co/datasets/23ws-LLMcoder/LLMcoder-GitHub-Python-Mix-Direct.
0216
1) + exponent2 whole_digits = total_digits3 decimal_places = 04 elif len(digittuple) > abs(exponent):5 # 123.456 total_digits = len(digittuple)7 whole_digits = total_digits - abs(exponent)8 decimal_places = abs(exponent)9 else:10 # 0.00123411 total_digits = abs(exponent)12 whole_digits = 013 decimal_places = total_digits14 15 if self.max_digits is not None and total_digits > self.max_digits:16 self.fail('max_digits', max_digits=self.max_digits)17 if self.decimal_places is not None and decimal_places > self.decimal_places:18 self.fail('max_decimal_places', max_decimal_places=self.decimal_places)19 if self.max_whole_digits is not None and whole_digits > self.max_whole_digits:20 self.fail('max_whole_digits', max_whole_digits=self.max_whole_digits)21 22 return value23 24 def to_representation(self, value):25 coerce_to_string = getattr(self, 'coerce_to_string', api_settings.COERCE_DECIMAL_TO_STRING)26 27 if value is None:28 if coerce_to_string:29 return ''30 else:31 return None32 33 if not isinstance(value, decimal.Decimal):34 value = decimal.Decimal(str(value).strip())35 36 quantized = self.quantize(value)37 38 if self.normalize_output:39 quantized = quantized.normalize()40 41 if not coerce_to_string:42 return quantized43 if self.localize:44 return localize_input(quantized)45 46 return '{:f}'.format(quantized)47 48 def quantize(self, value):49 """50 Quantize the decimal value to the configured precision.51 """52 if self.decimal_places is None:53 return value54 55 context = decimal.getcontext().copy()56 if self.max_digits is not None:57 context.prec = self.max_digits58 return value.quantize(59 decimal.Decimal('.1') ** self.decimal_places,60 rounding=self.rounding,61 context=context62 )63 64 65# Date & time fields...66 67class DateTimeField(Field):68 default_error_messages = {69 'invalid': _('Datetime has wrong format. Use one of these formats instead: {format}.'),70 'date': _('Expected a datetime but got a date.'),71 'make_aware': _('Invalid datetime for the timezone "{timezone}".'),72 'overflow': _('Datetime value out of range.')73 }74 datetime_parser = datetime.datetime.strptime75 76 def __init__(self, format=empty, input_formats=None, default_timezone=None, **kwargs):77 if format is not empty:78 self.format = format79 if input_formats is not None:80 self.input_formats = input_formats81 if default_timezone is not None:82 self.timezone = default_timezone83 super().__init__(**kwargs)84 85 def enforce_timezone(self, value):86 """87 When `self.default_timezone` is `None`, always return naive datetimes.88 When `self.default_timezone` is not `None`, always return aware datetimes.89 """90 field_timezone = self.timezone if hasattr(self, 'timezone') else self.default_timezone()91 92 if field_timezone is not None:93 if timezone.is_aware(value):94 try:95 return value.astimezone(field_timezone)96 except OverflowError:97 self.fail('overflow')98 try:99 dt = timezone.make_aware(value, field_timezone)100 # When the resulting datetime is a ZoneInfo instance, it won't necessarily101 # throw given an invalid datetime, so we need to specifically check.102 if not valid_datetime(dt):103 self.fail('make_aware', timezone=field_timezone)104 return dt105 except Exception as e:106 if pytz and isinstance(e, pytz.exceptions.InvalidTimeError):107 self.fail('make_aware', timezone=field_timezone)108 raise e109 elif (field_timezone is None) and timezone.is_aware(value):110 return timezone.make_naive(value, datetime.timezone.utc)111 return value112 113 def default_timezone(self):114 return timezone.get_current_timezone() if settings.USE_TZ else None115 116 def to_internal_value(self, value):117 input_formats = getattr(self, 'input_formats', api_settings.DATETIME_INPUT_FORMATS)118 119 if isinstance(value, datetime.date) and not isinstance(value, datetime.datetime):120 self.fail('date')121 122 if isinstance(value, datetime.datetime):123 return self.enforce_timezone(value)124 125 for input_format in input_formats:126 with contextlib.suppress(ValueError, TypeError):127 if input_format.lower() == ISO_8601:128 parsed = parse_datetime(value)129 if parsed is not None:130 return self.enforce_timezone(parsed)131 132 parsed = self.datetime_parser(value, input_format)133 return self.enforce_timezone(parsed)134 135 humanized_format = humanize_datetime.datetime_formats(input_formats)136 self.fail('invalid', format=humanized_format)137 138 def to_representation(self, value):139 if not value:140 return None141 142 output_format = getattr(self, 'format', api_settings.DATETIME_FORMAT)143 144 if output_format is None or isinstance(value, str):145 return value146 147 value = self.enforce_timezone(value)148 149 if output_format.lower() == ISO_8601:150 value = value.isoformat()151 if value.endswith('+00:00'):152 value = value[:-6] + 'Z'153 return value154 return value.strftime(output_format)155 156 157class DateField(Field):158 default_error_messages = {159 'invalid': _('Date has wrong format. Use one of these formats instead: {format}.'),160 'datetime': _('Expected a date but got a datetime.'),161 }162 datetime_parser = datetime.datetime.strptime163 164 def __init__(self, format=empty, input_formats=None, **kwargs):165 if format is not empty:166 self.format = format167 if input_formats is not None:168 self.input_formats = input_formats169 super().__init__(**kwargs)170 171 def to_internal_value(self, value):172 input_formats = getattr(self, 'input_formats', api_settings.DATE_INPUT_FORMATS)173 174 if isinstance(value, datetime.datetime):175 self.fail('datetime')176 177 if isinstance(value, datetime.date):178 return value179 180 for input_format in input_formats:181 if input_format.lower() == ISO_8601:182 try:183 parsed = parse_date(value)184 except (ValueError, TypeError):185 pass186 else:187 if parsed is not None:188 return parsed189 else:190 try:191 parsed = self.datetime_parser(value, input_format)192 except (ValueError, TypeError):193 pass194 else:195 return parsed.date()196 197 humanized_format = humanize_datetime.date_formats(input_formats)198 self.fail('invalid', format=humanized_format)199 200 def to_representation(self, value):201 if not value:202 return None203 204 output_format = getattr(self, 'format', api_settings.DATE_FORMAT)205 206 if output_format is None or isinstance(value, str):207 return value208 209 # Applying a `DateField` to a datetime value is almost always210 # not a sensible thing to do, as it means naively dropping211 # any explicit or implicit timezone info.212 assert not isinstance(value, datetime.datetime), (213 'Expected a `date`, but got a `datetime`. Refusing to coerce, '214 'as this may mean losing timezone information. Use a custom '215 'read-only field and deal with timezone issues explicitly.'216 )217 218 if output_format.lower() == ISO_8601:219 return value.isoformat()220 221 return value.strftime(output_format)222 223 224class TimeField(Field):225 defau