AttributeError: 'Tensor' object has no attribute 'close' - numpy

this is the code I am working with:
I searched for a similiar error do i need to change the .close() ?
Can anyone help please?

You should remove the close() function call on the parameter tensor image in line -
image = tensor.cpu().close().detach().numpy(). This should be replaced with - image = tensor.cpu().detach().numpy()

Related

chromium lldb debug not show string

I am debuging chromium in xcode,
and config the ../chromium/src/third_party/WebKit/Tool/lldb/lldb_webkit.py in ~/.lldinit fileļ¼Œ
but it not show the string correct, it only show the length of the string,can not show the content,
so it is inconvenient for debuging, I can not see the content of the string, this problem show in the picture.
in the picture1, picture2
I hope the content is not empty, and show the string content currect, or is there a good way to show the content of string correct
The summary formatter code doesn't look right to me. It does:
def WTFStringImpl_SummaryProvider(valobj, dict):
provider = WTFStringImplProvider(valobj, dict)
return "{ length = %d, is8bit = %d, contents = '%s' }" % (provider.get_length(), provider.is_8bit(), provider.to_string())
where the WTFStringImplProvider.is8_bit is:
def is_8bit(self):
return self.valobj.GetChildMemberWithName('is8_bit_')
That is returning an SBValue, not an integer, so printing it with a %d format doesn't seem like the right thing to do.
I created this issue (https://bugs.chromium.org/p/chromium/issues/detail?id=1004272) to confirm that this is a bug, and have opened this code review to try to fix it: https://chromium-review.googlesource.com/c/chromium/src/+/1810444 .
This patch works in my local environment, you can give it a try.

QML access properties of elements in list

I have a list of MapPolyline and I try to save dynamically added objects into this list. well It works but when I try to get the objects in list it does not work. it says TypeError: Cannot read property of undefined Here is my code
property list<MapPolyline> lines
var component;
var sprite;
component = Qt.createComponent("lineStringComponent.qml");
sprite = component.createObject(window,{"id": "button1"});
sprite.addCoordinate(QtPositioning.coordinate(currentgcppoint.lat, currentgcppoint.lon));
sprite.addCoordinate(gcppoint);
map.addMapItem(sprite)
lines.push(sprite)
gcps.push(currentgcppoint)
console.log("Added:", lines[1])
console.log("width:", lines[1].line.width)
Here is lineStringComponent.qml
import QtQuick 2.2
import QtLocation 5.6
import QtPositioning 5.6
MapPolyline {
id:polyline
line.width: 3
line.color: Qt.rgba(Math.random(),Math.random(),Math.random())
}
The consoles output is :
Added: undefined
TypeError: Cannot read property 'line' of undefined
It seems it has a delay when it tries to create a new object. How can we overcome this delay?
If I read your code correctly you only add 1 element to lines, and than you try to retrieve the second element of lines with line[1]. This is obviously undefined.
Try to access the first element of lines with line[0].
Indices of JS arrays start with 0 (as in most languages).
If there would be a delay with object creation, than you could not alter any of its properties, which you do (sprite.addCoordinate(...))

ALV is not refreshed after edit. Why?

I know my problem has been asked hundred times.
But I still cannot find any suitable solution for me
I have a dropdown, every time I change data in dropdown it will load new data based on dropdown data
From step one, I refresh editable ALV
Any change in editable ALV willbe saved (another action for saving)
My problem if, After I save, I can't refresh my ALV.
But it's not problem if I haven't pressed save button
NOTE :
in SAP forum, they told me to move refresh function to PBO, I tried this but still failed.
Attached Code is Step 1 is "when SET_P" in this code
PBO
MODULE pbo_1000 OUTPUT.
IF flag = 0.
SET PF-STATUS '1000'.
SET TITLEBAR '1000'.
PERFORM create_toolbar.
PERFORM create_catalog.
PERFORM select_data.
CREATE OBJECT ob_custom
EXPORTING
container_name = 'CCTRL'.
CREATE OBJECT ob_grid
EXPORTING
i_parent = ob_custom
i_appl_events = 'X'.
PERFORM create_dropbox.
CALL METHOD ob_grid->set_table_for_first_display
EXPORTING
i_structure_name = 'TYPE'
it_toolbar_excluding = lt_toolbar
is_layout = lyt
CHANGING
it_fieldcatalog = fld[]
it_outtab = itab[].
CALL METHOD ob_grid->set_ready_for_input
EXPORTING
i_ready_for_input = 1.
CALL METHOD ob_grid->register_edit_event
EXPORTING
i_event_id = cl_gui_alv_grid=>mc_evt_enter.
ENDIF.
ENDMODULE.
PAI
MODULE user_command_1000 INPUT .
DATA: v_perio(6) TYPE c.
CASE sy-ucomm.
WHEN 'BACK' OR 'EXIT' OR 'CANCEL'.
LEAVE TO SCREEN 0.
WHEN 'SAVE'.
PERFORM save_data.
PERFORM send_email.
WHEN 'SET_S'.
flag = 1.
PERFORM set_status.
CALL METHOD ob_grid->refresh_table_display
EXPORTING
is_stable = stbl.
WHEN 'SET_P'.
flag = 1.
PERFORM select_data.
CALL METHOD ob_grid->refresh_table_display
EXPORTING
is_stable = stbl.
ENDCASE.
ENDMODULE.
I guess you will need the CHECK_CHANGED_DATA method called as first thing in the PAI, which would fire up the events DATA_CHANGED and DATA_CHANGED_FINISHED.
But most important thing is, that it will synchronize the OLE object with the instance backend and then when you are calling the REFRESH_TABLE_DISPLAY it would refresh your ALV properly. I don't have any example at the moment, but I can maybe try next week when I have access to system.
By the way in PBO you don't need to have the variable flag you can use check if the ALV object has been already initialized or not and according to this you can create/refresh alv. Something like this:
if alvGridRef is NOT bound .
data(container) = new cl_gui_custom_container( ) .
data(alvGridRef) = new cl_gui_alv_grid( ) .
else .
alvGridRef->refresh_table_display( ) .
endif .
I've done something similar in an application that needed to be refreshed when saved because some calculations had to change in the screen. I set part of the following code in the command form for the 'REUSE_ALV_GRID_DISPLAY' function module.
form user_command using r_ucomm like sy-ucomm
rs_selfield type slis_selfield.
data: ref_grid type ref to cl_gui_alv_grid, l_valid type c.
if ref_grid is initial.
call function 'GET_GLOBALS_FROM_SLVC_FULLSCR'
importing
e_grid = ref_grid.
endif.
if not ref_grid is initial.
call method ref_grid->check_changed_data
importing
e_valid = l_valid.
endif.
rs_selfield-refresh = 'X'.
...
if not ref_grid is initial.
call method ref_grid->refresh_table_display( ) .
endif.
endform.
Hope it helps
You might achieve this by manually triggering PBO. You stated that the Editing is saved, so you can just display the ALV in PBO again:
CALL FUNCTION 'SAPGUI_SET_FUNCTIONCODE'
EXPORTING
functioncode = 'REFRESH'
EXCEPTIONS
function_not_supported = 1
OTHERS = 2.
After this action, sy-ucomm in PBO has the value REFRESH.

Mouseover not working on image_tag

I want to show a different image on the mouse over event.
This is the code I have (haml):
= image_tag(product.photos.first.asset.thumb.url, :onMouseover=> "this.src=product.photos.second.asset.thumb.url'", :onMouseout=> "this.src=product.photos.first.asset.thumb.url'")
but I keep getting "Uncaught SyntaxError: Unexpected token ILLEGAL" on that line.
Any suggestions of what am I doing wrong? thanks!
This was the solution:
= image_tag(product.photos.first.asset.thumb.url, :onMouseover=> "this.src='#{product.photos.second.asset.thumb.url}'", :onMouseout=> "this.src='#{product.photos.first.asset.thumb.url}'")

Need to include image with PDF in Magento

I need to include the 'customer's logo' in the PDF file when we download it from invoice.
I tried with the following code.
$page->drawImage($customerLogo, 25, 800, 125, 825);
But it through the following fatal error...
Fatal error: Call to a member function getResource() on a non-object in D:\Application\xampp\htdocs\projects\guardian\lib\Zend\Pdf\Page.php on line 344
Any one knows, how to fix this problem.
I have used this method before:
Place an image in image in your /media folder then where you want the image to appear inser this code:
$image = Mage::getConfig()->getOptions()->getMediaDir().DS.'you-logo-here.png';
if (is_file($image)) {
$image = Zend_Pdf_Image::imageWithPath($image);
$page->drawImage($image, $x+5, $y-18, $x+45, $y-6);
}
You will have to play with your php drawImage dimensions and coordinates. But this should do it.
For that error to occur $customerLogo must have been null. The answer is to make sure that $customerLogo is not null.