Can't import `Box2I, Point2I, Extent2I` from lsst.afw.geom

While reading Image Indexing, Array Views, and Bounding Boxes, while execute the following code:

from lsst.afw.geom import Box2I, Point2I, Extent2I

It raises error:

---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
/tmp/ipykernel_15236/5202209.py in <module>
----> 1 from lsst.afw.geom import Box2I, Point2I, Extent2I

ImportError: cannot import name 'Box2I' from 'lsst.afw.geom' (/home/yu/lsst_stack/stack/miniconda3-py38_4.9.2-0.7.0/Linux64/afw/22.0.1-42-gca6935d93+2883c49432/python/lsst/afw/geom/__init__.py)

I guess it may have changed name, I canā€™t find them in lsst.afw.geom.
I used tab, and find Bo can invoke Box2D, Po can invoke Point2Endpoint, and Extent can invoke EXtent2I, but they can not been imported, too.
like:

from lsst.afw.geom import Extent2I
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
/tmp/ipykernel_15236/2123666387.py in <module>
----> 1 from lsst.afw.geom import Extent2I

ImportError: cannot import name 'Extent2I' from 'lsst.afw.geom' (/home/yu/lsst_stack/stack/miniconda3-py38_4.9.2-0.7.0/Linux64/afw/22.0.1-42-gca6935d93+2883c49432/python/lsst/afw/geom/__init__.py) 

So, what have changed? How can I import them?
Thank you!

Use lsst.geom. The class was renamed a long time ago but it seems we missed sone of the documentation.

1 Like

Iā€™ve made a pull request with the fixes in it. When merged the docs will update on the daily site first.

1 Like

Hello, I am now studying the dimension concept and I want to see an example since I canā€™t image that dimension tables. But when I execute the following code:

from lsst.daf.butler import Butler
butler = Butler('SMALL_HSC')

print(butler.registry.dimensions.names)

Raise:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
/tmp/ipykernel_9084/3396315571.py in <module>
      2 butler = Butler('SMALL_HSC')
      3 
----> 4 print(butler.registry.dimensions.names)

AttributeError: 'DimensionUniverse' object has no attribute 'names'

I thought something may have changed. So, what have it changed to?
Thank you!

I think you may want

butler.registry.dimensions.getStaticElements().names

But this change was made in part because we donā€™t want any code to start depending on the full set of dimension elements; if youā€™re just poking around and trying to see what dimensions are defined, then you can use the above, but you may be better off looking at the configuration file where they are defined.