{"_id":"doc-en-astropy__astropy-11693-bb1913bcbeb2b447b64871ef410945453a252e77e83481c4f8dd5e789ccf22d6","title":"","text":" return world[0] if self.world_n_dim == 1 else tuple(world) def world_to_pixel_values(self, *world_arrays): pixel = self.all_world2pix(*world_arrays, 0)<\/del> # avoid circular import from astropy.wcs.wcs import NoConvergence try: pixel = self.all_world2pix(*world_arrays, 0) except NoConvergence as e: warnings.warn(str(e)) # use best_solution contained in the exception and format the same # way as all_world2pix does (using _array_converter) pixel = self._array_converter(lambda *args: e.best_solution, 'input', *world_arrays, 0)<\/ins> return pixel[0] if self.pixel_n_dim == 1 else tuple(pixel) @property"} {"_id":"doc-en-astropy__astropy-12057-9ef4fa5d88a257ea53d519a38d9a1be1733da486859e0b16dda194adf9347f50","title":"","text":" def _propagate_divide(self, other_uncert, result_data, correlation): return None def represent_as(self, other_uncert): \"\"\"Convert this uncertainty to a different uncertainty type. Parameters ---------- other_uncert : `NDUncertainty` subclass The `NDUncertainty` subclass to convert to. Returns ------- resulting_uncertainty : `NDUncertainty` instance An instance of ``other_uncert`` subclass containing the uncertainty converted to the new uncertainty type. Raises ------ TypeError If either the initial or final subclasses do not support conversion, a `TypeError` is raised. \"\"\" as_variance = getattr(self, \"_convert_to_variance\", None) if as_variance is None: raise TypeError( f\"{type(self)} does not support conversion to another \" \"uncertainty type.\" ) from_variance = getattr(other_uncert, \"_convert_from_variance\", None) if from_variance is None: raise TypeError( f\"{other_uncert.__name__} does not support conversion from \" \"another uncertainty type.\" ) return from_variance(as_variance())<\/ins> class UnknownUncertainty(NDUncertainty): \"\"\"This class implements any unknown uncertainty type."} {"_id":"doc-en-astropy__astropy-12057-12a464f4e5be68c467ca9ec48d8f4758687e5cdfb1f30b1f74afe0e7f9738cd3","title":"","text":" def _data_unit_to_uncertainty_unit(self, value): return value def _convert_to_variance(self): new_array = None if self.array is None else self.array ** 2 new_unit = None if self.unit is None else self.unit ** 2 return VarianceUncertainty(new_array, unit=new_unit) @classmethod def _convert_from_variance(cls, var_uncert): new_array = None if var_uncert.array is None else var_uncert.array ** (1 \/ 2) new_unit = None if var_uncert.unit is None else var_uncert.unit ** (1 \/ 2) return cls(new_array, unit=new_unit)<\/ins> class VarianceUncertainty(_VariancePropagationMixin, NDUncertainty): \"\"\""} {"_id":"doc-en-astropy__astropy-12057-4fde89d7e342b19f5072379924281b9aae23cdcc411d78aff1f0dbfe87ec8237","title":"","text":" def _data_unit_to_uncertainty_unit(self, value): return value ** 2 def _convert_to_variance(self): return self @classmethod def _convert_from_variance(cls, var_uncert): return var_uncert<\/ins> def _inverse(x): \"\"\"Just a simple inverse for use in the InverseVariance\"\"\""} {"_id":"doc-en-astropy__astropy-12057-eba64d22638a06b435a26930f448574a9edd4989fcc47195861197639fe2f1f7","title":"","text":" def _data_unit_to_uncertainty_unit(self, value): return 1 \/ value ** 2 def _convert_to_variance(self): new_array = None if self.array is None else 1 \/ self.array new_unit = None if self.unit is None else 1 \/ self.unit return VarianceUncertainty(new_array, unit=new_unit) @classmethod def _convert_from_variance(cls, var_uncert): new_array = None if var_uncert.array is None else 1 \/ var_uncert.array new_unit = None if var_uncert.unit is None else 1 \/ var_uncert.unit return cls(new_array, unit=new_unit)<\/ins>"} {"_id":"doc-en-astropy__astropy-12318-3c97b18f5fa72f993092c4d0d24c5fab1640d760d3615c0fa00bb3a2558b64d5","title":"","text":" Blackbody temperature. scale : float or `~astropy.units.Quantity` ['dimensionless'] Scale factor<\/del> Scale factor. If dimensionless, input units will assumed to be in Hz and output units in (erg \/ (cm ** 2 * s * Hz * sr). If not dimensionless, must be equivalent to either (erg \/ (cm ** 2 * s * Hz * sr) or erg \/ (cm ** 2 * s * AA * sr), in which case the result will be returned in the requested units and the scale will be stripped of units (with the float value applied).<\/ins> Notes -----"} {"_id":"doc-en-astropy__astropy-12318-66cd77d0c01c5e7ef6e39244f2418a61e455b094a23a5d2b8ea98f625f0c00a3","title":"","text":" scale = Parameter(default=1.0, min=0, description=\"Scale factor\") # We allow values without units to be passed when evaluating the model, and # in this case the input x values are assumed to be frequencies in Hz.<\/del> # in this case the input x values are assumed to be frequencies in Hz or wavelengths # in AA (depending on the choice of output units controlled by units on scale # and stored in self._output_units during init).<\/ins> _input_units_allow_dimensionless = True # We enable the spectral equivalency by default for the spectral axis input_units_equivalencies = {'x': u.spectral()} # Store the native units returned by B_nu equation _native_units = u.erg \/ (u.cm ** 2 * u.s * u.Hz * u.sr) # Store the base native output units. If scale is not dimensionless, it # must be equivalent to one of these. If equivalent to SLAM, then # input_units will expect AA for 'x', otherwise Hz. _native_output_units = {'SNU': u.erg \/ (u.cm ** 2 * u.s * u.Hz * u.sr), 'SLAM': u.erg \/ (u.cm ** 2 * u.s * u.AA * u.sr)} def __init__(self, *args, **kwargs): scale = kwargs.get('scale', None) # Support scale with non-dimensionless unit by stripping the unit and # storing as self._output_units. if hasattr(scale, 'unit') and not scale.unit.is_equivalent(u.dimensionless_unscaled): output_units = scale.unit if not output_units.is_equivalent(self._native_units, u.spectral_density(1*u.AA)): raise ValueError(f\"scale units not dimensionless or in surface brightness: {output_units}\") kwargs['scale'] = scale.value self._output_units = output_units else: self._output_units = self._native_units return super().__init__(*args, **kwargs)<\/ins> def evaluate(self, x, temperature, scale): \"\"\"Evaluate the model. "} {"_id":"doc-en-astropy__astropy-12318-5b7f2e593254d369681b227fed7b1a57d1ddeeb24a3cbb744392ee2b816ff4b5","title":"","text":" ---------- x : float, `~numpy.ndarray`, or `~astropy.units.Quantity` ['frequency'] Frequency at which to compute the blackbody. If no units are given, this defaults to Hz.<\/del> this defaults to Hz (or AA if `scale` was initialized with units equivalent to erg \/ (cm ** 2 * s * AA * sr)).<\/ins> temperature : float, `~numpy.ndarray`, or `~astropy.units.Quantity` Temperature of the blackbody. If no units are given, this defaults"} {"_id":"doc-en-astropy__astropy-12318-f80b9b5fd7ef477b55c4110a61c71f31be45529e4d68d8787aabb69f04c6d39c","title":"","text":" else: in_temp = temperature if not isinstance(x, u.Quantity): # then we assume it has input_units which depends on the # requested output units (either Hz or AA) in_x = u.Quantity(x, self.input_units['x']) else: in_x = x<\/ins> # Convert to units for calculations, also force double precision with u.add_enabled_equivalencies(u.spectral() + u.temperature()): freq = u.Quantity(x, u.Hz, dtype=np.float64)<\/del> freq = u.Quantity(in_x, u.Hz, dtype=np.float64)<\/ins> temp = u.Quantity(in_temp, u.K) # check the units of scale and setup the output units bb_unit = u.erg \/ (u.cm ** 2 * u.s * u.Hz * u.sr) # default unit # use the scale that was used at initialization for determining the units to return # to support returning the right units when fitting where units are stripped if hasattr(self.scale, \"unit\") and self.scale.unit is not None: # check that the units on scale are covertable to surface brightness units if not self.scale.unit.is_equivalent(bb_unit, u.spectral_density(x)): raise ValueError( f\"scale units not surface brightness: {self.scale.unit}\" ) # use the scale passed to get the value for scaling if hasattr(scale, \"unit\"): mult_scale = scale.value else: mult_scale = scale bb_unit = self.scale.unit else: mult_scale = scale<\/del> # Check if input values are physically possible if np.any(temp < 0): raise ValueError(f\"Temperature should be positive: {temp}\")"} {"_id":"doc-en-astropy__astropy-12318-111c36e5722fd3c15b4740751a7223cc5cc0e2de249c05fff257cc7b86f5f9ed","title":"","text":" # Calculate blackbody flux bb_nu = 2.0 * const.h * freq ** 3 \/ (const.c ** 2 * boltzm1) \/ u.sr y = mult_scale * bb_nu.to(bb_unit, u.spectral_density(freq))<\/del> if self.scale.unit is not None: # Will be dimensionless at this point, but may not be dimensionless_unscaled if not hasattr(scale, 'unit'): # during fitting, scale will be passed without units # but we still need to convert from the input dimensionless # to dimensionless unscaled scale = scale * self.scale.unit scale = scale.to(u.dimensionless_unscaled).value # NOTE: scale is already stripped of any input units y = scale * bb_nu.to(self._output_units, u.spectral_density(freq))<\/ins> # If the temperature parameter has no unit, we should return a unitless # value. This occurs for instance during fitting, since we drop the"} {"_id":"doc-en-astropy__astropy-12318-addb288fdb32491b2daf5a04712a203f42db1a5ba3d735d1ec23170af6ba9a8a","title":"","text":" @property def input_units(self): # The input units are those of the 'x' value, which should always be # Hz. Because we do this, and because input_units_allow_dimensionless # is set to True, dimensionless values are assumed to be in Hz. return {self.inputs[0]: u.Hz}<\/del> # The input units are those of the 'x' value, which will depend on the # units compatible with the expected output units. if self._output_units.is_equivalent(self._native_output_units['SNU']): return {self.inputs[0]: u.Hz} else: # only other option is equivalent with SLAM return {self.inputs[0]: u.AA}<\/ins> def _parameter_units_for_data_units(self, inputs_unit, outputs_unit): return {\"temperature\": u.K}"} {"_id":"doc-en-astropy__astropy-12318-c9bef5c7dd260ba8c94ba45117e39e8ea0f5ba324ae6044e797e501460b6a61f","title":"","text":" @property def bolometric_flux(self): \"\"\"Bolometric flux.\"\"\" if self.scale.unit is not None: # Will be dimensionless at this point, but may not be dimensionless_unscaled scale = self.scale.quantity.to(u.dimensionless_unscaled) else: scale = self.scale.value<\/ins> # bolometric flux in the native units of the planck function native_bolflux = ( self.scale.value * const.sigma_sb * self.temperature ** 4 \/ np.pi<\/del> scale * const.sigma_sb * self.temperature ** 4 \/ np.pi<\/ins> ) # return in more \"astro\" units return native_bolflux.to(u.erg \/ (u.cm ** 2 * u.s))"} {"_id":"doc-en-astropy__astropy-12544-1f922bde3820a988e7cc95675d7fe33318a82e76ac414047435df0ccaeee24f9","title":"","text":" def read_table_fits(input, hdu=None, astropy_native=False, memmap=False, character_as_bytes=True, unit_parse_strict='warn'):<\/del> character_as_bytes=True, unit_parse_strict='warn', mask_invalid=True):<\/ins> \"\"\" Read a Table object from an FITS file "} {"_id":"doc-en-astropy__astropy-12544-a8ce1e87579474fa67aef10b7a114cb2fab6c0eda0bd0d09af9de1bc59e73aee","title":"","text":" fit the table in memory, you may be better off leaving memory mapping off. However, if your table would not fit in memory, you should set this to `True`. When set to `True` then ``mask_invalid`` is set to `False` since the masking would cause loading the full data array.<\/ins> character_as_bytes : bool, optional If `True`, string columns are stored as Numpy byte arrays (dtype ``S``) and are converted on-the-fly to unicode strings when accessing"} {"_id":"doc-en-astropy__astropy-12544-837e9f7262d6fc6bdce30ad0a81216aebb04f2a5ad1c0b491dbfaec0101d231a","title":"","text":" :class:`~astropy.units.core.UnrecognizedUnit`. Values are the ones allowed by the ``parse_strict`` argument of :class:`~astropy.units.core.Unit`: ``raise``, ``warn`` and ``silent``. mask_invalid : bool, optional By default the code masks NaNs in float columns and empty strings in string columns. Set this parameter to `False` to avoid the performance penalty of doing this masking step. The masking is always deactivated when using ``memmap=True`` (see above).<\/ins> \"\"\" "} {"_id":"doc-en-astropy__astropy-12544-9086e01e85bfc9dd7f8afea1a46b0be8b6ff41138378585a1ac32bdba90b5e68","title":"","text":" else: if memmap: # using memmap is not compatible with masking invalid value by # default so we deactivate the masking mask_invalid = False<\/ins> hdulist = fits_open(input, character_as_bytes=character_as_bytes, memmap=memmap) "} {"_id":"doc-en-astropy__astropy-12544-653c452137d0eca23800094029d84a028dfe6a8a9854612459ea539eb25450c6","title":"","text":" hdulist, hdu=hdu, astropy_native=astropy_native, unit_parse_strict=unit_parse_strict, mask_invalid=mask_invalid,<\/ins> ) finally: hdulist.close()"} {"_id":"doc-en-astropy__astropy-12544-52d7fee14ce128a0c740f7fb93ec0bf97b952f180ce82fd6b26276854150ca85","title":"","text":" # Return a MaskedColumn even if no elements are masked so # we roundtrip better. masked = True elif issubclass(coltype, np.inexact):<\/del> elif mask_invalid and issubclass(coltype, np.inexact):<\/ins> mask = np.isnan(data[col.name]) elif issubclass(coltype, np.character):<\/del> elif mask_invalid and issubclass(coltype, np.character):<\/ins> mask = col.array == b'' if masked or np.any(mask):"} {"_id":"doc-en-astropy__astropy-12825-d38f70c75b315c09fd33130d9bc7e796f5b6845a40a5df2bf65392031b61832c","title":"","text":" This is required when the object is used as a mixin column within a table, but can be used as a general way to store meta information. \"\"\" attrs_from_parent = BaseColumnInfo.attr_names<\/del> attr_names = BaseColumnInfo.attr_names | {'groups'} _attrs_no_copy = BaseColumnInfo._attrs_no_copy | {'groups'} attrs_from_parent = attr_names<\/ins> _supports_indexing = True def new_like(self, cols, length, metadata_conflicts='warn', name=None):diff --git a\/astropy\/table\/groups.py b\/astropy\/table\/groups.py-- a\/astropy\/table\/groups.py<\/del>++ b\/astropy\/table\/groups.py<\/ins>"} {"_id":"doc-en-astropy__astropy-12825-aa64244ce035a7c8c9699285879f9fc324b36f523e557d31d064c6e711cd7829","title":"","text":" class ColumnGroups(BaseGroups): def __init__(self, parent_column, indices=None, keys=None): self.parent_column = parent_column # parent Column self.parent_table = parent_column.parent_table<\/del> self.parent_table = parent_column.info.parent_table<\/ins> self._indices = indices self._keys = keys "} {"_id":"doc-en-astropy__astropy-12825-f77542acc5686b3da68eb6f31265bd275f7a7bdb006c248dff3df03897846405","title":"","text":" return self._keys def aggregate(self, func): from .column import MaskedColumn<\/del> from .column import MaskedColumn, Column from astropy.utils.compat import NUMPY_LT_1_20<\/ins> i0s, i1s = self.indices[:-1], self.indices[1:] par_col = self.parent_column"} {"_id":"doc-en-astropy__astropy-12825-1f20f26b04bd2888db8d090e4428e7c31290aacff60e6ff539b2b2d250c2c1a7","title":"","text":" mean_case = func is np.mean try: if not masked and (reduceat or sum_case or mean_case): # For numpy < 1.20 there is a bug where reduceat will fail to # raise an exception for mixin columns that do not support the # operation. For details see: # https:\/\/github.com\/astropy\/astropy\/pull\/12825#issuecomment-1082412447 # Instead we try the function directly with a 2-element version # of the column if NUMPY_LT_1_20 and not isinstance(par_col, Column) and len(par_col) > 0: func(par_col[[0, 0]])<\/ins> if mean_case: vals = np.add.reduceat(par_col, i0s) \/ np.diff(self.indices) else:"} {"_id":"doc-en-astropy__astropy-12825-f0b766fbb8d7f4c3248ea648912b93c33dca174b6f081b3b7b838fbed7446918","title":"","text":" vals = func.reduceat(par_col, i0s) else: vals = np.array([func(par_col[i0: i1]) for i0, i1 in zip(i0s, i1s)]) out = par_col.__class__(vals)<\/ins> except Exception as err: raise TypeError(\"Cannot aggregate column '{}' with type '{}'\" .format(par_col.info.name, par_col.info.dtype)) from err out = par_col.__class__(data=vals, name=par_col.info.name, description=par_col.info.description, unit=par_col.info.unit, format=par_col.info.format, meta=par_col.info.meta)<\/del> raise TypeError(\"Cannot aggregate column '{}' with type '{}': {}\" .format(par_col.info.name, par_col.info.dtype, err)) from err out_info = out.info for attr in ('name', 'unit', 'format', 'description', 'meta'): try: setattr(out_info, attr, getattr(par_col.info, attr)) except AttributeError: pass<\/ins> return out def filter(self, func):"} {"_id":"doc-en-astropy__astropy-12825-e82ca042448e626c7a185cf5d767d89991351377577883271eb417f5382fe40b","title":"","text":" new_col = col.take(i0s) else: try: new_col = col.groups.aggregate(func)<\/del> new_col = col.info.groups.aggregate(func)<\/ins> except TypeError as err: warnings.warn(str(err), AstropyUserWarning) continuediff --git a\/astropy\/utils\/data_info.py b\/astropy\/utils\/data_info.py-- a\/astropy\/utils\/data_info.py<\/del>++ b\/astropy\/utils\/data_info.py<\/ins>"} {"_id":"doc-en-astropy__astropy-12825-714bfc4c09f59edf74c5a4e074dd411d25a23033a295b6fe54cb3a79c6b59b0c","title":"","text":" Note that this class is defined here so that mixins can use it without importing the table package. \"\"\" attr_names = DataInfo.attr_names.union(['parent_table', 'indices'])<\/del> attr_names = DataInfo.attr_names | {'parent_table', 'indices'}<\/ins> _attrs_no_copy = set(['parent_table', 'indices']) # Context for serialization. This can be set temporarily via"} {"_id":"doc-en-astropy__astropy-12825-6eb53efc926fde0501dc587005e801aa44b50ae664b49dce8dc38d6ff1abab1e","title":"","text":" self._attrs['name'] = name @property def groups(self): # This implementation for mixin columns essentially matches the Column # property definition. `groups` is a read-only property here and # depends on the parent table of the column having `groups`. This will # allow aggregating mixins as long as they support those operations. from astropy.table import groups return self._attrs.setdefault('groups', groups.ColumnGroups(self._parent))<\/ins> class ParentDtypeInfo(MixinInfo): \"\"\"Mixin that gets info.dtype from parent\"\"\""} {"_id":"doc-en-astropy__astropy-12880-8cf81a9f1d119b3144733a1e5b5b60a4f592b8369050d4b81ccd3e9f692a3ebb","title":"","text":" match = re.match(ecsv_header_re, lines[0].strip(), re.VERBOSE) if not match: raise core.InconsistentTableError(no_header_msg) # ecsv_version could be constructed here, but it is not currently used.<\/del> # Construct ecsv_version for backwards compatibility workarounds. self.ecsv_version = tuple(int(v or 0) for v in match.groups())<\/ins> try: header = meta.get_header_from_yaml(lines)"} {"_id":"doc-en-astropy__astropy-12880-a9b80c763949014f42fc3054bebf7351c4b1deec6854816774b6282a75bc9ecf","title":"","text":" setattr(col, attr, header_cols[col.name][attr]) col.dtype = header_cols[col.name]['datatype'] if col.dtype not in ECSV_DATATYPES:<\/del> # Require col dtype to be a valid ECSV datatype. However, older versions # of astropy writing ECSV version 0.9 and earlier had inadvertently allowed # numpy datatypes like datetime64 or object or python str, which are not in the ECSV standard. # For back-compatibility with those existing older files, allow reading with no error. if col.dtype not in ECSV_DATATYPES and self.ecsv_version > (0, 9, 0):<\/ins> raise ValueError(f'datatype {col.dtype!r} of column {col.name!r} ' f'is not in allowed values {ECSV_DATATYPES}')"} {"_id":"doc-en-astropy__astropy-12891-c7b27e6e1c3d462ae25341b265f00c6b576ef1b7942bcc999c475f581f8521d0","title":"","text":" # LOCAL from astropy import config as _configfrom astropy.utils.compat import NUMPY_LT_1_20, NUMPY_LT_1_22<\/ins> from astropy.utils.compat.misc import override__dir__ from astropy.utils.data_info import ParentDtypeInfo from astropy.utils.exceptions import AstropyDeprecationWarning, AstropyWarning"} {"_id":"doc-en-astropy__astropy-12891-36ff21aa79ba452bc8a41a7093b23f935bb3a62f4784d52bfecb3fdade7f2a82","title":"","text":" def trace(self, offset=0, axis1=0, axis2=1, dtype=None, out=None): return self._wrap_function(np.trace, offset, axis1, axis2, dtype, out=out) def var(self, axis=None, dtype=None, out=None, ddof=0, keepdims=False): return self._wrap_function(np.var, axis, dtype, out=out, ddof=ddof, keepdims=keepdims, unit=self.unit**2) def std(self, axis=None, dtype=None, out=None, ddof=0, keepdims=False): return self._wrap_function(np.std, axis, dtype, out=out, ddof=ddof, keepdims=keepdims) def mean(self, axis=None, dtype=None, out=None, keepdims=False): return self._wrap_function(np.mean, axis, dtype, out=out, keepdims=keepdims)<\/del> if NUMPY_LT_1_20: def var(self, axis=None, dtype=None, out=None, ddof=0, keepdims=False): return self._wrap_function(np.var, axis, dtype, out=out, ddof=ddof, keepdims=keepdims, unit=self.unit**2) else: def var(self, axis=None, dtype=None, out=None, ddof=0, keepdims=False, *, where=True): return self._wrap_function(np.var, axis, dtype, out=out, ddof=ddof, keepdims=keepdims, where=where, unit=self.unit**2) if NUMPY_LT_1_20: def std(self, axis=None, dtype=None, out=None, ddof=0, keepdims=False): return self._wrap_function(np.std, axis, dtype, out=out, ddof=ddof, keepdims=keepdims) else: def std(self, axis=None, dtype=None, out=None, ddof=0, keepdims=False, *, where=True): return self._wrap_function(np.std, axis, dtype, out=out, ddof=ddof, keepdims=keepdims, where=where) if NUMPY_LT_1_20: def mean(self, axis=None, dtype=None, out=None, keepdims=False): return self._wrap_function(np.mean, axis, dtype, out=out, keepdims=keepdims) else: def mean(self, axis=None, dtype=None, out=None, keepdims=False, *, where=True): return self._wrap_function(np.mean, axis, dtype, out=out, keepdims=keepdims, where=where)<\/ins> def round(self, decimals=0, out=None): return self._wrap_function(np.round, decimals, out=out)"} {"_id":"doc-en-astropy__astropy-12891-896015eee9f3e299520062c380a4233dd96ce2121bdc32e325351790a86d46de","title":"","text":" def ediff1d(self, to_end=None, to_begin=None): return self._wrap_function(np.ediff1d, to_end, to_begin) def nansum(self, axis=None, out=None, keepdims=False): return self._wrap_function(np.nansum, axis, out=out, keepdims=keepdims)<\/del> if NUMPY_LT_1_22: def nansum(self, axis=None, out=None, keepdims=False): return self._wrap_function(np.nansum, axis, out=out, keepdims=keepdims) else: def nansum(self, axis=None, out=None, keepdims=False, *, initial=None, where=True): return self._wrap_function(np.nansum, axis, out=out, keepdims=keepdims, initial=initial, where=where)<\/ins> def insert(self, obj, values, axis=None): \"\"\"diff --git a\/astropy\/utils\/masked\/core.py b\/astropy\/utils\/masked\/core.py-- a\/astropy\/utils\/masked\/core.py<\/del>++ b\/astropy\/utils\/masked\/core.py<\/ins>"} {"_id":"doc-en-astropy__astropy-12891-785750b35ef804a512a10e105f0a19b8037f0bc075396116ff751c0746595104","title":"","text":" np.minimum(out, dmax, out=out, where=True if mmax is None else ~mmax) return masked_out def mean(self, axis=None, dtype=None, out=None, keepdims=False):<\/del> def mean(self, axis=None, dtype=None, out=None, keepdims=False, *, where=True):<\/ins> # Implementation based on that in numpy\/core\/_methods.py # Cast bool, unsigned int, and int to float64 by default, # and do float16 at higher precision."} {"_id":"doc-en-astropy__astropy-12891-0d2bb1b5140d48be0b6151458670cab7f392bee7252a818910480cea1565ed00","title":"","text":" dtype = np.dtype('f4') is_float16_result = out is None where = ~self.mask & where<\/ins> result = self.sum(axis=axis, dtype=dtype, out=out, keepdims=keepdims, where=~self.mask) n = np.add.reduce(~self.mask, axis=axis, keepdims=keepdims)<\/del> keepdims=keepdims, where=where) n = np.add.reduce(where, axis=axis, keepdims=keepdims)<\/ins> result \/= n if is_float16_result: result = result.astype(self.dtype) return result def var(self, axis=None, dtype=None, out=None, ddof=0, keepdims=False):<\/del> def var(self, axis=None, dtype=None, out=None, ddof=0, keepdims=False, *, where=True): where_final = ~self.mask & where<\/ins> # Simplified implementation based on that in numpy\/core\/_methods.py n = np.add.reduce(~self.mask, axis=axis, keepdims=keepdims)[...]<\/del> n = np.add.reduce(where_final, axis=axis, keepdims=keepdims)[...]<\/ins> # Cast bool, unsigned int, and int to float64 by default. if dtype is None and issubclass(self.dtype.type, (np.integer, np.bool_)): dtype = np.dtype('f8') mean = self.mean(axis=axis, dtype=dtype, keepdims=True)<\/del> mean = self.mean(axis=axis, dtype=dtype, keepdims=True, where=where)<\/ins> x = self - mean x *= x.conjugate() # Conjugate just returns x if not complex. result = x.sum(axis=axis, dtype=dtype, out=out, keepdims=keepdims, where=~x.mask)<\/del> keepdims=keepdims, where=where_final)<\/ins> n -= ddof n = np.maximum(n, 0, out=n) result \/= n result._mask |= (n == 0) return result def std(self, axis=None, dtype=None, out=None, ddof=0, keepdims=False):<\/del> def std(self, axis=None, dtype=None, out=None, ddof=0, keepdims=False, *, where=True):<\/ins> result = self.var(axis=axis, dtype=dtype, out=out, ddof=ddof, keepdims=keepdims)<\/del> keepdims=keepdims, where=where)<\/ins> return np.sqrt(result, out=result) def __bool__(self):"} {"_id":"doc-en-astropy__astropy-12891-461c8008db3fe0297023bb8abdffaf54d02b4d5583bf9691de6226e0f806c52c","title":"","text":" result = super().__bool__() return result and not self.mask def any(self, axis=None, out=None, keepdims=False):<\/del> def any(self, axis=None, out=None, keepdims=False, *, where=True):<\/ins> return np.logical_or.reduce(self, axis=axis, out=out, keepdims=keepdims, where=~self.mask)<\/del> keepdims=keepdims, where=~self.mask & where)<\/ins> def all(self, axis=None, out=None, keepdims=False):<\/del> def all(self, axis=None, out=None, keepdims=False, *, where=True):<\/ins> return np.logical_and.reduce(self, axis=axis, out=out, keepdims=keepdims, where=~self.mask)<\/del> keepdims=keepdims, where=~self.mask & where)<\/ins> # Following overrides needed since somehow the ndarray implementation # does not actually call these."} {"_id":"doc-en-astropy__astropy-12907-a022313e494955a1538b81014455ab0bf28750c10fc4cbb17469f7802538561c","title":"","text":" cright = _coord_matrix(right, 'right', noutp) else: cright = np.zeros((noutp, right.shape[1])) cright[-right.shape[0]:, -right.shape[1]:] = 1<\/del> cright[-right.shape[0]:, -right.shape[1]:] = right<\/ins> return np.hstack([cleft, cright])"} {"_id":"doc-en-astropy__astropy-12962-0c9b6ea4d9ff78210a619951aa1b240d954631d3923d5a7a1a9376b450990063","title":"","text":" self._uncertainty = value def to_hdu(self, hdu_mask='MASK', hdu_uncertainty='UNCERT', hdu_flags=None, wcs_relax=True, key_uncertainty_type='UTYPE'):<\/del> hdu_flags=None, wcs_relax=True, key_uncertainty_type='UTYPE', as_image_hdu=False):<\/ins> \"\"\"Creates an HDUList object from a CCDData object. Parameters"} {"_id":"doc-en-astropy__astropy-12962-ae5694e1a1dc9a8887cb2b1fdd2ac95ef61a09c5c766d2f53af840d37e87bd7d","title":"","text":" .. versionadded:: 3.1 as_image_hdu : bool If this option is `True`, the first item of the returned `~astropy.io.fits.HDUList` is a `~astropy.io.fits.ImageHDU`, instead of the default `~astropy.io.fits.PrimaryHDU`.<\/ins> Raises ------ ValueError"} {"_id":"doc-en-astropy__astropy-12962-9bcf15e12dc18238d14b17098897036bff81110feac8d99c4b5c63da2856f178","title":"","text":" # not header. wcs_header = self.wcs.to_header(relax=wcs_relax) header.extend(wcs_header, useblanks=False, update=True) hdus = [fits.PrimaryHDU(self.data, header)]<\/del> if as_image_hdu: hdus = [fits.ImageHDU(self.data, header)] else: hdus = [fits.PrimaryHDU(self.data, header)]<\/ins> if hdu_mask and self.mask is not None: # Always assuming that the mask is a np.ndarray (check that it has"} {"_id":"doc-en-astropy__astropy-12962-4e57d039388dfe89af57082043dd1c02feb68fc8d6f809d4d7c173eadf27ade8","title":"","text":" def fits_ccddata_writer( ccd_data, filename, hdu_mask='MASK', hdu_uncertainty='UNCERT', hdu_flags=None, key_uncertainty_type='UTYPE', **kwd):<\/del> hdu_flags=None, key_uncertainty_type='UTYPE', as_image_hdu=False, **kwd):<\/ins> \"\"\" Write CCDData object to FITS file. "} {"_id":"doc-en-astropy__astropy-12962-27065dfeffdce54bc7785e87043cf0a2a95d25363fbd0654aae571c10c983f88","title":"","text":" .. versionadded:: 3.1 as_image_hdu : bool If this option is `True`, the first item of the returned `~astropy.io.fits.HDUList` is a `~astropy.io.fits.ImageHDU`, instead of the default `~astropy.io.fits.PrimaryHDU`.<\/ins> kwd : All additional keywords are passed to :py:mod:`astropy.io.fits` "} {"_id":"doc-en-astropy__astropy-12962-41663b3f47a694f6a0bfeb134db634c116a1d8fb05ebb3641f6cded6ec9864e4","title":"","text":" \"\"\" hdu = ccd_data.to_hdu( hdu_mask=hdu_mask, hdu_uncertainty=hdu_uncertainty, key_uncertainty_type=key_uncertainty_type, hdu_flags=hdu_flags)<\/del> key_uncertainty_type=key_uncertainty_type, hdu_flags=hdu_flags, as_image_hdu=as_image_hdu) if as_image_hdu: hdu.insert(0, fits.PrimaryHDU())<\/ins> hdu.writeto(filename, **kwd)"} {"_id":"doc-en-astropy__astropy-13032-26cb018d4dd8536d73072f18e0375148daef327f60ec93d73c475ac01666f543","title":"","text":" for key, value in bounding_box.items(): self[key] = value @property def _available_input_index(self): model_input_index = [self._get_index(_input) for _input in self._model.inputs] return [_input for _input in model_input_index if _input not in self._ignored]<\/ins> def _validate_sequence(self, bounding_box, order: str = None): \"\"\"Validate passing tuple of tuples representation (or related) and setting them.\"\"\" order = self._get_order(order)"} {"_id":"doc-en-astropy__astropy-13032-88c44b5f958bed00bad9342f8fd40cfa95276b57fb7fa13c816b28d127fda5ee","title":"","text":" bounding_box = bounding_box[::-1] for index, value in enumerate(bounding_box): self[index] = value<\/del> self[self._available_input_index[index]] = value<\/ins> @property def _n_inputs(self) -> int:"} {"_id":"doc-en-astropy__astropy-13032-eb2da6e9b2c8daeea0448b822e6e4f98f1fb1518974a8bc53cd1999f5c10f92a","title":"","text":" def _validate(self, bounding_box, order: str = None): \"\"\"Validate and set any representation\"\"\" if self._n_inputs == 1 and not isinstance(bounding_box, dict): self[0] = bounding_box<\/del> self[self._available_input_index[0]] = bounding_box<\/ins> else: self._validate_iterable(bounding_box, order) "} {"_id":"doc-en-astropy__astropy-13032-c902251221fbdf02445b382c9288c835c3fb430bd3619c8407c4f3e691d0ae4b","title":"","text":" order = bounding_box.order if _preserve_ignore: ignored = bounding_box.ignored bounding_box = bounding_box.intervals<\/del> bounding_box = bounding_box.named_intervals<\/ins> new = cls({}, model, ignored=ignored, order=order) new._validate(bounding_box)"} {"_id":"doc-en-astropy__astropy-13033-3c967f361c709857b4989e43b44f1bf4efb0036f143cc6f3008ff0d01e99ea2a","title":"","text":" _required_columns_relax = False def _check_required_columns(self): def as_scalar_or_list_str(obj): if not hasattr(obj, \"__len__\"): return f\"'{obj}'\" elif len(obj) == 1: return f\"'{obj[0]}'\" else: return str(obj)<\/ins> if not self._required_columns_enabled: return"} {"_id":"doc-en-astropy__astropy-13033-02a11e10e3b89e8bba85109d43c1ea8672ae633443f6b80cc78efde8cac1d47a","title":"","text":" elif self.colnames[:len(required_columns)] != required_columns: raise ValueError(\"{} object is invalid - expected '{}' \" \"as the first column{} but found '{}'\" .format(self.__class__.__name__, required_columns[0], plural, self.colnames[0]))<\/del> raise ValueError(\"{} object is invalid - expected {} \" \"as the first column{} but found {}\" .format(self.__class__.__name__, as_scalar_or_list_str(required_columns), plural, as_scalar_or_list_str(self.colnames[:len(required_columns)])))<\/ins> if (self._required_columns_relax and self._required_columns == self.colnames[:len(self._required_columns)]):"} {"_id":"doc-en-astropy__astropy-13068-02b8ef35c208dc7ef0d0fc3b27588fb43383668747985bbb6efa7db0050ef556","title":"","text":" @precision.setter def precision(self, val): del self.cache if not isinstance(val, int) or val < 0 or val > 9: raise ValueError('precision attribute must be an int between ' '0 and 9')<\/del> self._time.precision = val @propertydiff --git a\/astropy\/time\/formats.py b\/astropy\/time\/formats.py-- a\/astropy\/time\/formats.py<\/del>++ b\/astropy\/time\/formats.py<\/ins>"} {"_id":"doc-en-astropy__astropy-13068-165488f45d975016f8632c053345f7f32a23c65422d36c2b8226329fcdeeecfe","title":"","text":" def jd2_filled(self): return np.nan_to_num(self.jd2) if self.masked else self.jd2 @property def precision(self): return self._precision @precision.setter def precision(self, val): #Verify precision is 0-9 (inclusive) if not isinstance(val, int) or val < 0 or val > 9: raise ValueError('precision attribute must be an int between ' '0 and 9') self._precision = val<\/ins> @lazyproperty def cache(self): \"\"\""} {"_id":"doc-en-astropy__astropy-13073-4ed5b18137eebc4b79edbedfebdff0bb5fb63ee93ede2697ab7da2ae03cf2086","title":"","text":" \"\"\"Output table as a dict of column objects keyed on column name. The table data are stored as plain python lists within the column objects. \"\"\" # User-defined converters which gets set in ascii.ui if a `converter` kwarg # is supplied.<\/ins> converters = {}<\/ins> # Derived classes must define default_converters and __call__ @staticmethod"} {"_id":"doc-en-astropy__astropy-13073-9f11813b1ec143d91a5dc54dd7b0d5d312010e523335d69c6b12f52aae12992d","title":"","text":" \"\"\"Validate the format for the type converters and then copy those which are valid converters for this column (i.e. converter type is a subclass of col.type)\"\"\" # Allow specifying a single converter instead of a list of converters. # The input `converters` must be a ``type`` value that can init np.dtype. try: # Don't allow list-like things that dtype accepts assert type(converters) is type converters = [numpy.dtype(converters)] except (AssertionError, TypeError): pass<\/ins> converters_out = [] try: for converter in converters: converter_func, converter_type = converter<\/del> try: converter_func, converter_type = converter except TypeError as err: if str(err).startswith('cannot unpack'): converter_func, converter_type = convert_numpy(converter) else: raise<\/ins> if not issubclass(converter_type, NoType): raise ValueError()<\/del> raise ValueError('converter_type must be a subclass of NoType')<\/ins> if issubclass(converter_type, col.type): converters_out.append((converter_func, converter_type)) except (ValueError, TypeError):<\/del> except (ValueError, TypeError) as err:<\/ins> raise ValueError('Error: invalid format for converters, see ' 'documentation\\n{}'.format(converters))<\/del> f'documentation\\n{converters}: {err}')<\/ins> return converters_out def _convert_vals(self, cols):diff --git a\/astropy\/io\/ascii\/docs.py b\/astropy\/io\/ascii\/docs.py-- a\/astropy\/io\/ascii\/docs.py<\/del>++ b\/astropy\/io\/ascii\/docs.py<\/ins>"} {"_id":"doc-en-astropy__astropy-13073-e10c662ed72188b4f7950993aa0d0443b812f1e6bac2c0757234a994ad495cb7","title":"","text":" Line index for the end of data not counting comment or blank lines. This value can be negative to count from the end. converters : dict Dictionary of converters. Keys in the dictionary are columns names, values are converter functions. In addition to single column names you can use wildcards via `fnmatch` to select multiple columns.<\/del> Dictionary of converters to specify output column dtypes. Each key in the dictionary is a column name or else a name matching pattern including wildcards. The value is either a data type such as ``int`` or ``np.float32``; a list of such types which is tried in order until a successful conversion is achieved; or a list of converter tuples (see the `~astropy.io.ascii.convert_numpy` function for details).<\/ins> data_Splitter : `~astropy.io.ascii.BaseSplitter` Splitter class to split data columns header_Splitter : `~astropy.io.ascii.BaseSplitter`"} {"_id":"doc-en-astropy__astropy-13075-6e709371a19021cdc54a5290de71161c270d6ac576252c03d555a61d966fc463","title":"","text":" \"\"\" # Import to register with the I\/O machineryfrom . import cosmology, ecsv, mapping, model, row, table, yaml<\/del>from . import cosmology, ecsv, html, mapping, model, row, table, yaml # noqa: F401<\/ins>diff --git a\/astropy\/cosmology\/io\/html.py b\/astropy\/cosmology\/io\/html.pynew file mode 100644-- \/dev\/null<\/del>++ b\/astropy\/cosmology\/io\/html.py<\/ins>"} {"_id":"doc-en-astropy__astropy-13075-f98259bc32b6cb9deec1624573154ce047bb1c37b536db16dc2bc0ea882e1a86","title":"","text":"import astropy.cosmology.units as cu\rimport astropy.units as u\rfrom astropy.cosmology.connect import readwrite_registry\rfrom astropy.cosmology.core import Cosmology\rfrom astropy.cosmology.parameter import Parameter\rfrom astropy.table import QTable\r\rfrom .table import from_table, to_table\r\r# Format look-up for conversion, {original_name: new_name}\r# TODO! move this information into the Parameters themselves\r_FORMAT_TABLE = {\r \"H0\": \"$$H_{0}$$\",\r \"Om0\": \"$$\\\\Omega_{m,0}$$\",\r \"Ode0\": \"$$\\\\Omega_{\\\\Lambda,0}$$\",\r \"Tcmb0\": \"$$T_{0}$$\",\r \"Neff\": \"$$N_{eff}$$\",\r \"m_nu\": \"$$m_{nu}$$\",\r \"Ob0\": \"$$\\\\Omega_{b,0}$$\",\r \"w0\": \"$$w_{0}$$\",\r \"wa\": \"$$w_{a}$$\",\r \"wz\": \"$$w_{z}$$\",\r \"wp\": \"$$w_{p}$$\",\r \"zp\": \"$$z_{p}$$\",\r}\r\r\rdef read_html_table(filename, index=None, *, move_to_meta=False, cosmology=None, latex_names=True, **kwargs):\r \"\"\"Read a |Cosmology| from an HTML file.\r\r Parameters\r ----------\r filename : path-like or file-like\r From where to read the Cosmology.\r index : int or str or None, optional\r Needed to select the row in tables with multiple rows. ``index`` can be\r an integer for the row number or, if the table is indexed by a column,\r the value of that column. If the table is not indexed and ``index`` is a\r string, the \"name\" column is used as the indexing column.\r\r move_to_meta : bool, optional keyword-only\r Whether to move keyword arguments that are not in the Cosmology class'\r signature to the Cosmology's metadata. This will only be applied if the\r Cosmology does NOT have a keyword-only argument (e.g. ``**kwargs``).\r Arguments moved to the metadata will be merged with existing metadata,\r preferring specified metadata in the case of a merge conflict (e.g. for\r ``Cosmology(meta={'key':10}, key=42)``, the ``Cosmology.meta`` will be\r ``{'key': 10}``).\r cosmology : str or |Cosmology| class or None, optional keyword-only\r The cosmology class (or string name thereof) to use when constructing\r the cosmology instance. The class also provides default parameter\r values, filling in any non-mandatory arguments missing in 'table'.\r latex_names : bool, optional keyword-only\r Whether the |Table| (might) have latex column names for the parameters\r that need to be mapped to the correct parameter name -- e.g. $$H_{0}$$\r to 'H0'. This is `True` by default, but can be turned off (set to\r `False`) if there is a known name conflict (e.g. both an 'H0' and\r '$$H_{0}$$' column) as this will raise an error. In this case, the\r correct name ('H0') is preferred.\r **kwargs : Any\r Passed to :attr:`astropy.table.QTable.read`. ``format`` is set to\r 'ascii.html', regardless of input.\r\r Returns\r -------\r |Cosmology| subclass instance\r\r Raises\r ------\r ValueError\r If the keyword argument 'format' is given and is not \"ascii.html\".\r \"\"\"\r # Check that the format is 'ascii.html' (or not specified)\r format = kwargs.pop(\"format\", \"ascii.html\")\r if format != \"ascii.html\":\r raise ValueError(f\"format must be 'ascii.html', not {format}\")\r\r # Reading is handled by `QTable`.\r with u.add_enabled_units(cu): # (cosmology units not turned on by default)\r table = QTable.read(filename, format=\"ascii.html\", **kwargs)\r\r # Need to map the table's column names to Cosmology inputs (parameter\r # names).\r # TODO! move the `latex_names` into `from_table`\r if latex_names:\r table_columns = set(table.colnames)\r for name, latex in _FORMAT_TABLE.items():\r if latex in table_columns:\r table.rename_column(latex, name)\r\r # Build the cosmology from table, using the private backend.\r return from_table(table, index=index, move_to_meta=move_to_meta, cosmology=cosmology)\r\r\rdef write_html_table(cosmology, file, *, overwrite=False, cls=QTable, latex_names=False, **kwargs):\r r\"\"\"Serialize the |Cosmology| into a HTML table.\r\r Parameters\r ----------\r cosmology : |Cosmology| subclass instance file : path-like or file-like\r Location to save the serialized cosmology.\r file : path-like or file-like\r Where to write the html table.\r\r overwrite : bool, optional keyword-only\r Whether to overwrite the file, if it exists.\r cls : |Table| class, optional keyword-only\r Astropy |Table| (sub)class to use when writing. Default is |QTable|\r class.\r latex_names : bool, optional keyword-only\r Whether to format the parameters (column) names to latex -- e.g. 'H0' to\r $$H_{0}$$.\r **kwargs : Any\r Passed to ``cls.write``.\r\r Raises\r ------\r TypeError\r If the optional keyword-argument 'cls' is not a subclass of |Table|.\r ValueError\r If the keyword argument 'format' is given and is not \"ascii.html\".\r\r Notes\r -----\r A HTML file containing a Cosmology HTML table should have scripts enabling\r MathJax.\r\r ::\r <\/script>\r