- 
                Notifications
    
You must be signed in to change notification settings  - Fork 170
 
          fix: Always accept {Expr,Series}.is_in(other: Iterable) 
          #3207
        
          New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
          
     Open
      
      
            dangotbanned
  wants to merge
  14
  commits into
  main
  
    
      
        
          
  
    
      Choose a base branch
      
     
    
      
        
      
      
        
          
          
        
        
          
            
              
              
              
  
           
        
        
          
            
              
              
           
        
       
     
  
        
          
            
          
            
          
        
       
    
      
from
fix/expr-is-in-iterable
  
      
      
   
  
    
  
  
  
 
  
      
    base: main
Could not load branches
            
              
  
    Branch not found: {{ refName }}
  
            
                
      Loading
              
            Could not load tags
            
            
              Nothing to show
            
              
  
            
                
      Loading
              
            Are you sure you want to change the base?
            Some commits from the old base branch may be removed from the timeline,
            and old review comments may become outdated.
          
          
  
     Open
                    Changes from all commits
      Commits
    
    
            Show all changes
          
          
            14 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      234a091
              
                test: Repurpose `Series.from_iterable` constructors
              
              
                dangotbanned 26ae2eb
              
                test: Add `test_expr_is_in_iterable`
              
              
                dangotbanned ce8e591
              
                test: Add `test_ser_is_in_iterable`
              
              
                dangotbanned 98cc8bd
              
                chore: Add `_utils.iterable_to_sequence`
              
              
                dangotbanned 2cd832c
              
                fix: `Series.is_in`
              
              
                dangotbanned 38d6d5d
              
                fix: `Expr.is_in`
              
              
                dangotbanned 633a06d
              
                coverage?
              
              
                dangotbanned 0c66432
              
                test: Track down the xfail
              
              
                dangotbanned a6921ea
              
                test: Add `test_expr_is_in_series_wrong_backend`
              
              
                dangotbanned 5409c21
              
                chore(typing): Update narwhals-level typing
              
              
                dangotbanned b08ffe0
              
                Update narwhals/_utils.py
              
              
                dangotbanned ffc848c
              
                chore(typing): Update compliant-level typing
              
              
                dangotbanned e318bdf
              
                Merge remote-tracking branch 'upstream/main' into fix/expr-is-in-iterβ¦
              
              
                dangotbanned e9eb08e
              
                Merge branch 'main' into fix/expr-is-in-iterable
              
              
                dangotbanned File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
      
      Oops, something went wrong.
        
    
  
      
      Oops, something went wrong.
        
    
  
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW I hate this as well π
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe a better idea would be to ...
Rename
_CanTo_List->ToList, and move to_translate.pyalongside:narwhals/narwhals/_translate.py
Lines 124 to 125 in f05011c
Move these as well, but rename to reflect they their naming originates from
numpyandpyarrow(respectively):narwhals/narwhals/_utils.py
Lines 2131 to 2132 in 0c66432
narwhals/narwhals/_utils.py
Lines 2135 to 2136 in 0c66432
The names of the guards can still stay the same, since their implementations will (after updating the protocol names) the link between origin, protocol, method name:
narwhals/narwhals/_utils.py
Lines 2139 to 2144 in 0c66432
narwhals/narwhals/_utils.py
Lines 2147 to 2148 in 0c66432
narwhals/narwhals/_utils.py
Lines 2151 to 2154 in 0c66432
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I updated my comment (#3207 (comment)) - I would argue that native series are not ok, while numpy 1d arrays are.
My thought process for this is that if someone is doing something along the lines of:
then the function is clearly not agnostic and polars would be required in this case.
A different case would be if a narwhals series with a different backend is provided. This could mean that the function is agnostic but a user is "mixin" backends:
This is the case I suggested to yell at the user with a warning.
From our side, I think it would greatly simplify (read as, get rid of) most of the protocols here, the type guards as well as
iterable_to_sequencefunction.