Skip to content
Snippets Groups Projects

Output fixes, str vs repr, exceptions and type hints

Merged Cresson Remi requested to merge fixes into develop

Sorry, a big diff for many changes, but they were all linked :sweat_smile:

  • Do not setattr(self, parameter) on App obj anymore
  • Refac save_objects and data - fixes #75 #72 (closed)
  • Using save_objects, App.parameters (and summarize()) is now correctly in sync with otb.Application parameters
  • Move summarize() back to App
  • Fix bugs with Output, __getitem__ in OTBObject and Output[slice], summarize() call parent pyotb app.
  • Add App.outputs to access Output objects via App[param_key] (see __getitem__)
  • Rename key_input and key_input_image to input_key and input_image_key
  • Raise TypeError when get_first_key failed, fixes #71 (closed)
  • Rename write() arg filename_extension to ext_fname, fixes #77 (closed) and error when "?" is not passed: add missing "?&"
  • Add App.output_key
  • Remove App.image_dic : fixes #79 (closed)
  • Type hints
  • Update tests, move data dicts to tests_data
  • Use __repr__ in OTBObject so user is free to implement __str__, add missing hash and id dunder methods
  • Merge summarize tests in test_core, and move summaries data to json file

The diff is positive because of test json data for summarize() - output is now far bigger, since App.parameters is really in sync with otb.Application instance.

TODOs from Remi's comments

  • TBD: Path and local files stuff removal (my thought) or at least disabled when using /vsi prefix
  • Add tests for the improved getitem behavior
  • Keep using otbApplication's enums for pixel types, parameter types, ...
  • Fix summarize (back to same state than in current develop branch)
Edited by Cresson Remi

Merge request reports

Loading
Loading

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
  • added bug style labels

  • Cresson Remi requested review from @remicress

    requested review from @remicress

    By Vincent Delbar on 2023-02-04T19:35:08 (imported from GitLab)

  • Cresson Remi assigned to @vidlb

    assigned to @vidlb

    By Vincent Delbar on 2023-02-04T19:35:08 (imported from GitLab)

  • Cresson Remi changed the description

    changed the description

    By Vincent Delbar on 2023-02-04T19:35:32 (imported from GitLab)

  • Cresson Remi changed the description

    changed the description

    By Vincent Delbar on 2023-02-04T19:37:29 (imported from GitLab)

  • Cresson Remi added 1 commit

    added 1 commit

    Compare with previous version

    By Vincent Delbar on 2023-02-04T19:41:40 (imported from GitLab)

  • Cresson Remi added 2 commits

    added 2 commits

    • 8a60776b - ENH: style and raise exceptions when get_first_key failed
    • d678ef5f - ENH: rename filename_extension to ext_fname

    Compare with previous version

    By Vincent Delbar on 2023-02-04T20:19:03 (imported from GitLab)

  • Cresson Remi changed the description

    changed the description

    By Vincent Delbar on 2023-02-04T20:19:47 (imported from GitLab)

  • Cresson Remi marked this merge request as draft

    marked this merge request as draft

    By Vincent Delbar on 2023-02-04T20:24:27 (imported from GitLab)

  • I realized we were missing a test for ext_fname, and suprise : it failed !
    Even if it passed locally, here with my Windows PC.
    This "?" or "?&" is still quite strange to me.

    By Vincent Delbar on 2023-02-04T20:28:25 (imported from GitLab)

  • Cresson Remi added 1 commit

    added 1 commit

    • b198e991 - FIX: try to add "?&" to ext_fname test

    Compare with previous version

    By Vincent Delbar on 2023-02-04T20:29:19 (imported from GitLab)

  • Cresson Remi added 1 commit

    added 1 commit

    • d29d17c6 - FIX: force use of "?&" in ext_fname when "?" is missing

    Compare with previous version

    By Vincent Delbar on 2023-02-04T20:36:00 (imported from GitLab)

  • Cresson Remi changed the description

    changed the description

    By Vincent Delbar on 2023-02-04T20:36:53 (imported from GitLab)

  • Cresson Remi marked this merge request as ready

    marked this merge request as ready

    By Vincent Delbar on 2023-02-04T20:37:11 (imported from GitLab)

    • Resolved by Cresson Remi

      Now regarding the repr / str changes, here is the new behaviour :

      
      In [1]: app
      Out[1]: <pyotb.BandMath object, id 1672876477320>
      
      In [8]: inp
      Out[8]: <pyotb.Input object, from tests\image.tif>
      
      In [14]: app["out"]
      Out[14]: <pyotb.Output object, id 1946345255176>
      
      In [15]: repr(app["out"])
      Out[15]: '<pyotb.Output object, id 1946345255176>'
      
      In [18]: str(app["out"])
      Out[18]: 'test.tif'

      What do you think ? The idea is that the user is free to implement __str__ when subclassing App or OTBObject, but repr is used by default for str when __str__ is not defined.

      By Vincent Delbar on 2023-02-05T18:49:43 (imported from GitLab)

      Edited by Cresson Remi
  • Cresson Remi changed the description

    changed the description

    By Vincent Delbar on 2023-02-04T20:41:12 (imported from GitLab)

  • Cresson Remi changed the description

    changed the description

    By Vincent Delbar on 2023-02-04T20:45:59 (imported from GitLab)

  • Cresson Remi changed the description

    changed the description

    By Vincent Delbar on 2023-02-04T20:46:31 (imported from GitLab)

  • Cresson Remi changed the description

    changed the description

    By Vincent Delbar on 2023-02-04T20:46:42 (imported from GitLab)

  • Cresson Remi added 1 commit

    added 1 commit

    Compare with previous version

    By Vincent Delbar on 2023-02-04T20:51:45 (imported from GitLab)

  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
  • Loading
Please register or sign in to reply
Loading