rhayes777 / PyAutoFit

PyAutoFit: Classy Probabilistic Programming
https://pyautofit.readthedocs.io/
MIT License
60 stars 11 forks source link

Error with new Constant type in database #1079

Open Jammy2211 opened 1 week ago

Jammy2211 commented 1 week ago

This example script:

https://github.com/Jammy2211/autolens_workspace_test/blob/main/scripts/database/scrape/slam_pix.py

Gives this error:

2024-11-21 17:47:48,638 - autofit.database.aggregator.aggregator - INFO - 1 fit(s) found matching query
TracerAgg with linear light profiles raises correct ProfileException
TracerAgg Checked
2024-11-21 17:47:48,756 - autoarray.dataset.imaging.dataset - INFO - IMAGING - Data masked, contains a total of 716 image-pixels
ImagingAgg Checked
2024-11-21 17:47:49,190 - autoarray.dataset.imaging.dataset - INFO - IMAGING - Data masked, contains a total of 716 image-pixels
Traceback (most recent call last):
  File "/mnt/c/Users/Jammy/Code/PyAuto/autolens_workspace_test/scripts/database/scrape/slam_pix.py", line 388, in <module>
    fit_plotter.subplot_fit()
  File "/mnt/c/Users/Jammy/Code/PyAuto/PyAutoLens/autolens/imaging/plot/fit_imaging_plotters.py", line 435, in subplot_fit
    self.figures_2d(data=True)
  File "/mnt/c/Users/Jammy/Code/PyAuto/PyAutoLens/autolens/imaging/plot/fit_imaging_plotters.py", line 755, in figures_2d
    visuals_2d = self.get_visuals_2d()
  File "/mnt/c/Users/Jammy/Code/PyAuto/PyAutoLens/autolens/imaging/plot/fit_imaging_plotters.py", line 71, in get_visuals_2d
    return self.get_2d.via_fit_imaging_from(fit=self.fit)
  File "/mnt/c/Users/Jammy/Code/PyAuto/PyAutoLens/autolens/plot/get_visuals/two_d.py", line 171, in via_fit_imaging_from
    visuals_2d_via_tracer = self.via_tracer_from(
  File "/mnt/c/Users/Jammy/Code/PyAuto/PyAutoLens/autolens/plot/get_visuals/two_d.py", line 80, in via_tracer_from
    tracer.planes[plane_index].extract_attribute(
  File "/mnt/c/Users/Jammy/Code/PyAuto/PyAutoLens/autolens/lens/tracer.py", line 212, in planes
    galaxies=self.galaxies_ascending_redshift,
  File "/mnt/c/Users/Jammy/Code/PyAuto/PyAutoLens/autolens/lens/tracer.py", line 155, in galaxies_ascending_redshift
    return sorted(self.galaxies, key=lambda galaxy: galaxy.redshift)
TypeError: '<' not supported between instances of 'Constant' and 'float'

Presuambly the constants refactor.

Jammy2211 commented 5 days ago

The example script now returns this error:

TracerAgg with linear light profiles raises correct ProfileException
TracerAgg Checked
2024-11-24 20:59:45,555 - autoarray.dataset.imaging.dataset - INFO - IMAGING - Data masked, contains a total of 716 image-pixels
ImagingAgg Checked
2024-11-24 20:59:45,966 - autoarray.dataset.imaging.dataset - INFO - IMAGING - Data masked, contains a total of 716 image-pixels
Traceback (most recent call last):
  File "/mnt/c/Users/Jammy/Code/PyAuto/autolens_workspace_test/scripts/database/scrape/slam_pix.py", line 388, in <module>
    fit_plotter.subplot_fit()
  File "/mnt/c/Users/Jammy/Code/PyAuto/PyAutoLens/autolens/imaging/plot/fit_imaging_plotters.py", line 435, in subplot_fit
    self.figures_2d(data=True)
  File "/mnt/c/Users/Jammy/Code/PyAuto/PyAutoLens/autolens/imaging/plot/fit_imaging_plotters.py", line 755, in figures_2d
    visuals_2d = self.get_visuals_2d()
  File "/mnt/c/Users/Jammy/Code/PyAuto/PyAutoLens/autolens/imaging/plot/fit_imaging_plotters.py", line 71, in get_visuals_2d
    return self.get_2d.via_fit_imaging_from(fit=self.fit)
  File "/mnt/c/Users/Jammy/Code/PyAuto/PyAutoLens/autolens/plot/get_visuals/two_d.py", line 171, in via_fit_imaging_from
    visuals_2d_via_tracer = self.via_tracer_from(
  File "/mnt/c/Users/Jammy/Code/PyAuto/PyAutoLens/autolens/plot/get_visuals/two_d.py", line 80, in via_tracer_from
    tracer.planes[plane_index].extract_attribute(
  File "/mnt/c/Users/Jammy/Code/PyAuto/PyAutoLens/autolens/lens/tracer.py", line 213, in planes
    plane_redshifts=self.plane_redshifts,
  File "/mnt/c/Users/Jammy/Code/PyAuto/PyAutoLens/autolens/lens/tracer.py", line 179, in plane_redshifts
    return tracer_util.plane_redshifts_from(
  File "/mnt/c/Users/Jammy/Code/PyAuto/PyAutoLens/autolens/lens/tracer_util.py", line 34, in plane_redshifts_from
    return list(dict.fromkeys(plane_redshifts))
TypeError: __hash__ method should return an integer

I also get this error when running a different script:

EUCLJ174517.55+655612.5
2024-11-24 20:55:52,321 - autoarray.dataset.imaging.dataset - INFO - IMAGING - Computing W-Tilde... May take a moment.
Traceback (most recent call last):
  File "/mnt/c/Users/Jammy/Results/euclid/paper/result_single_line.py", line 107, in <module>
    mapper = fit.inversion.cls_list_from(cls=al.AbstractMapper)[0]
  File "/mnt/c/Users/Jammy/Code/PyAuto/PyAutoConf/autoconf/tools/decorators.py", line 17, in __get__
    obj.__dict__[self.func.__name__] = self.func(obj)
  File "/mnt/c/Users/Jammy/Code/PyAuto/PyAutoLens/autolens/imaging/fit_imaging.py", line 169, in inversion
    return self.tracer_to_inversion.inversion
  File "/mnt/c/Users/Jammy/Code/PyAuto/PyAutoConf/autoconf/tools/decorators.py", line 17, in __get__
    obj.__dict__[self.func.__name__] = self.func(obj)
  File "/mnt/c/Users/Jammy/Code/PyAuto/PyAutoLens/autolens/lens/to_inversion.py", line 523, in inversion
    linear_obj_list=self.linear_obj_list,
  File "/mnt/c/Users/Jammy/Code/PyAuto/PyAutoConf/autoconf/tools/decorators.py", line 17, in __get__
    obj.__dict__[self.func.__name__] = self.func(obj)
  File "/mnt/c/Users/Jammy/Code/PyAuto/PyAutoGalaxy/autogalaxy/galaxy/to_inversion.py", line 191, in linear_obj_list
    return list(self.linear_obj_galaxy_dict.keys())
  File "/mnt/c/Users/Jammy/Code/PyAuto/PyAutoConf/autoconf/tools/decorators.py", line 17, in __get__
    obj.__dict__[self.func.__name__] = self.func(obj)
  File "/mnt/c/Users/Jammy/Code/PyAuto/PyAutoGalaxy/autogalaxy/galaxy/to_inversion.py", line 172, in linear_obj_galaxy_dict
    lp_linear_func_galaxy_dict = self.lp_linear_func_list_galaxy_dict
  File "/mnt/c/Users/Jammy/Code/PyAuto/PyAutoConf/autoconf/tools/decorators.py", line 17, in __get__
    obj.__dict__[self.func.__name__] = self.func(obj)
  File "/mnt/c/Users/Jammy/Code/PyAuto/PyAutoLens/autolens/lens/to_inversion.py", line 174, in lp_linear_func_list_galaxy_dict
    traced_grids_of_planes_list = self.tracer.traced_grid_2d_list_from(
  File "/mnt/c/Users/Jammy/Code/PyAuto/PyAutoArray/autoarray/structures/decorators/to_grid.py", line 131, in wrapper
    return GridMaker(func=func, obj=obj, grid=grid, *args, **kwargs).result
  File "/mnt/c/Users/Jammy/Code/PyAuto/PyAutoArray/autoarray/structures/decorators/abstract.py", line 120, in result
    return self.via_grid_2d_irr(self.evaluate_func)
  File "/mnt/c/Users/Jammy/Code/PyAuto/PyAutoArray/autoarray/structures/decorators/abstract.py", line 99, in evaluate_func
    return self.func(self.obj, self.grid, *self.args, **self.kwargs)
  File "/mnt/c/Users/Jammy/Code/PyAuto/PyAutoLens/autolens/lens/tracer.py", line 344, in traced_grid_2d_list_from
    return tracer_util.traced_grid_2d_list_from(
  File "/mnt/c/Users/Jammy/Code/PyAuto/PyAutoLens/autolens/lens/tracer_util.py", line 145, in traced_grid_2d_list_from
    scaling_factor = cosmology.scaling_factor_between_redshifts_from(
  File "/mnt/c/Users/Jammy/Code/PyAuto/PyAutoGalaxy/autogalaxy/cosmology/lensing.py", line 258, in scaling_factor_between_redshifts_from
    self.angular_diameter_distance_z1z2(z1=redshift_0, z2=redshift_1)
  File "/home/jammy/venvs/PyAuto/lib/python3.10/site-packages/astropy/cosmology/flrw/base.py", line 1293, in angular_diameter_distance_z1z2
    z1, z2 = aszarr(z1), aszarr(z2)
  File "/home/jammy/venvs/PyAuto/lib/python3.10/site-packages/astropy/cosmology/_utils.py", line 88, in aszarr
    return Quantity(z, cu.redshift).value
  File "/home/jammy/venvs/PyAuto/lib/python3.10/site-packages/astropy/units/quantity.py", line 557, in __new__
    raise TypeError("The value must be a valid Python or Numpy numeric type.")
TypeError: The value must be a valid Python or Numpy numeric type.

I guess we still need to cast to a float correctly?

rhayes777 commented 19 hours ago

There's another issue now but I think the two errors here are fixed