code: def test_fractional_weights():
      ana = (
          analysis.RegexTokenizer(r"\S+")
          | analysis.DelimitedAttributeFilter()
      )
  
      # With Positions format
      schema = fields.Schema(f=fields.TEXT(analyzer=ana))
      ix = RamStorage().create_index(schema)
      w = ix.writer()
      w.add_document(f="alfa^0.5 bravo^1.5 charlie^2.0 delta^1.5")
      w.commit()
  
      with ix.searcher() as s:
          wts = []
          for word in s.lexicon("f"):
              p = s.postings("f", word)
              wts.append(p.weight())
          assert wts == [0.5, 1.5, 2.0, 1.5]
  
      # Try again with Frequency format
      schema = fields.Schema(f=fields.TEXT(analyzer=ana, phrase=False))
      ix = RamStorage().create_index(schema)
      w = ix.writer()
      w.add_document(f="alfa^0.5 bravo^1.5 charlie^2.0 delta^1.5")
      w.commit()
  
      with ix.searcher() as s:
          wts = []
          for word in s.lexicon("f"):
              p = s.postings("f", word)
              wts.append(p.weight())
          assert wts == [0.5, 1.5, 2.0, 1.5]
  
imports: from __future__ import with_statement
  import random, time, threading
  import pytest
  from whoosh import analysis, fields, query, writing
  from whoosh.compat import b, u, xrange, text_type
  from whoosh.filedb.filestore import RamStorage
  from whoosh.util.testing import TempIndex
label_desc: Use image node_id 9 for calling a global function with example usage: test_fractional_weights() without return types