mteb/BrightProStackoverflowRetrieval huggingface dataset:
lt function Clock({ time }) {
      return (
        <>
          <h1>{time}</h1>
          <input />
        </>
      );
    }
    
    

This works because during this last step, React only updates the content of `
<h1> ` with the new ` time ` . It sees that the ` <input> ` appears in the JSX
in the same place as last time, so React doesn’t touch the ` <input> ` —or its
` value ` !

##  Epilogue: Browser paint

After rendering is done and React updated the DOM, the browser will repaint
the screen. Although this process is known as “browser rendering”, we’ll refer
to it as “painting” to avoid confusion throughout the docs.

![A browser painting 'still life with card
element'.](/images/docs/illustrations/i_browser-paint.png)

Illustrated by  [ Rachel Lee Nabors ](https://nearestnabors.com/)

##  Recap

  * Any screen update in a React app happens in three steps: 
    1. Trigger 
    2. Render 
    3. Commit 
  * You can use Strict Mode to find mistakes in your components 
  * React does not touch the DOM if the rendering result is the same as last time 

[ Previous  State: A Component's Memory  ](/learn/state-a-components-memory) [
Next  State as a Snapshot  ](/learn/state-as-a-snapshot)

* * *

How do you like these docs?

[ Take our survey!  ](https://www.surveymonkey.co.uk/r/PYRPF3X)

* * *

[ ](https://opensource.fb.com/)

©  2024

[ Learn React ](/learn)

[ Quick Start ](/learn)

[ Installation ](/learn/installation)

[ Describing the UI ](/learn/describing-the-ui)

[ Adding Interactivity ](/learn/adding-interactivity)

[ Managing State ](/learn/managing-state)

[ Escape Hatches ](/learn/escape-hatches)

[ API Reference ](/reference/react)

[ React APIs ](/reference/react)

[ React DOM APIs ](/reference/react-dom)

[ Community ](/community)

[ Code of Conduct
](https://github.com/facebook/react/blob/main/CODE_OF_CONDUCT.md)

[ Meet the Team ](/community/team)

[ Docs Contributors ](/community/docs-contributors)

[ Acknowledgements ](/community/acknowledgements)

More

[ Blog ](/blog)

[ React Native ](https://reactnative.dev/)

[ Privacy ](https://opensource.facebook.com/legal/privacy)

[ Terms ](https://opensource.fb.com/legal/terms/)

[ ](https://www.facebook.com/react) [ ](https://twitter.com/reactjs) [
](https://github.com/facebook/react)

##  On this page

  * Overview 
  * Step 1: Trigger a render 
  * Initial render 
  * Re-renders when state updates 
  * Step 2: React renders your components 
  * Step 3: React commits changes to the DOM 
  * Epilogue: Browser paint 
  * Recap
o switch the page background between white
and black. However, nothing happens when you click it. Fix the problem. (Don’t
worry about the logic inside ` handleClick ` —that part is fine.)

App.js

App.js

Reset  [ Fork
](https://codesandbox.io/api/v1/sandboxes/define?undefined&environment=create-
react-app "Open in CodeSandbox")

    
    
    export default function LightSwitch() {
      function handleClick() {
        let bodyStyle = document.body.style;
        if (bodyStyle.backgroundColor === 'black') {
          bodyStyle.backgroundColor = 'white';
        } else {
          bodyStyle.backgroundColor = 'black';
        }
      }
    
      return (
        <button onClick={handleClick()}>
          Toggle the lights
        </button>
      );
    }
    
    

Show more

Show solution  Next  Challenge

[ Previous  Adding Interactivity  ](/learn/adding-interactivity) [ Next
State: A Component's Memory  ](/learn/state-a-components-memory)

* * *

How do you like these docs?

[ Take our survey!  ](https://www.surveymonkey.co.uk/r/PYRPF3X)

* * *

[ ](https://opensource.fb.com/)

©  2024

[ Learn React ](/learn)

[ Quick Start ](/learn)

[ Installation ](/learn/installation)

[ Describing the UI ](/learn/describing-the-ui)

[ Adding Interactivity ](/learn/adding-interactivity)

[ Managing State ](/learn/managing-state)

[ Escape Hatches ](/learn/escape-hatches)

[ API Reference ](/reference/react)

[ React APIs ](/reference/react)

[ React DOM APIs ](/reference/react-dom)

[ Community ](/community)

[ Code of Conduct
](https://github.com/facebook/react/blob/main/CODE_OF_CONDUCT.md)

[ Meet the Team ](/community/team)

[ Docs Contributors ](/community/docs-contributors)

[ Acknowledgements ](/community/acknowledgements)

More

[ Blog ](/blog)

[ React Native ](https://reactnative.dev/)

[ Privacy ](https://opensource.facebook.com/legal/privacy)

[ Terms ](https://opensource.fb.com/legal/terms/)

[ ](https://www.facebook.com/react) [ ](https://twitter.com/reactjs) [
](https://github.com/facebook/react)

##  On this page

  * Overview 
  * Adding event handlers 
  * Reading props in event handlers 
  * Passing event handlers as props 
  * Naming event handler props 
  * Event propagation 
  * Stopping propagation 
  * Passing handlers as alternative to propagation 
  * Preventing default behavior 
  * Can event handlers have side effects? 
  * Recap 
  * Challenges
ed instead

You can’t put a function into state like this:

    
    
    const [fn, setFn] = useState(someFunction);  
    
    
      
    
    
    function handleClick() {  
    
    
      setFn(someOtherFunction);  
    
    
    }

Because you’re passing a function, React assumes that ` someFunction ` is an
initializer function  , and that ` someOtherFunction ` is an  updater function
, so it tries to call them and store the result. To actually _store_ a
function, you have to put ` () => ` before them in both cases. Then React will
store the functions you pass.

    
    
    const [fn, setFn] = useState(() => someFunction);  
    
    
      
    
    
    function handleClick() {  
    
    
      setFn(() => someOtherFunction);  
    
    
    }

[ Previous  useRef  ](/reference/react/useRef) [ Next  useSyncExternalStore
](/reference/react/useSyncExternalStore)

* * *

How do you like these docs?

[ Take our survey!  ](https://www.surveymonkey.co.uk/r/PYRPF3X)

* * *

[ ](https://opensource.fb.com/)

©  2024

[ Learn React ](/learn)

[ Quick Start ](/learn)

[ Installation ](/learn/installation)

[ Describing the UI ](/learn/describing-the-ui)

[ Adding Interactivity ](/learn/adding-interactivity)

[ Managing State ](/learn/managing-state)

[ Escape Hatches ](/learn/escape-hatches)

[ API Reference ](/reference/react)

[ React APIs ](/reference/react)

[ React DOM APIs ](/reference/react-dom)

[ Community ](/community)

[ Code of Conduct
](https://github.com/facebook/react/blob/main/CODE_OF_CONDUCT.md)

[ Meet the Team ](/community/team)

[ Docs Contributors ](/community/docs-contributors)

[ Acknowledgements ](/community/acknowledgements)

More

[ Blog ](/blog)

[ React Native ](https://reactnative.dev/)

[ Privacy ](https://opensource.facebook.com/legal/privacy)

[ Terms ](https://opensource.fb.com/legal/terms/)

[ ](https://www.facebook.com/react) [ ](https://twitter.com/reactjs) [
](https://github.com/facebook/react)

##  On this page

  * Overview 
  * Reference 
  * ` useState(initialState) `
  * ` set ` functions, like ` setSomething(nextState) `
  * Usage 
  * Adding state to a component 
  * Updating state based on the previous state 
  * Updating objects and arrays in state 
  * Avoiding recreating the initial state 
  * Resetting state with a key 
  * Storing information from previous renders 
  * Troubleshooting 
  * I’ve updated the state, but logging gives me the old value 
  * I’ve updated the state, but the screen doesn’t update 
  * I’m getting an error: “Too many re-renders” 
  * My initializer or updater function runs twice 
  * I’m trying to set state to a function, but it gets called instead
);  
    
    
    }

Alternatively, you could remove ` useCallback ` in the last snippet and
instead wrap ` Report ` itself in [ ` memo ` . ](/reference/react/memo) If the
` item ` prop does not change, ` Report ` will skip re-rendering, so ` Chart `
will skip re-rendering too:

    
    
    function ReportList({ items }) {  
    
    
      // ...  
    
    
    }  
    
    
      
    
    
    const Report = memo(function Report({ item }) {  
    
    
      function handleClick() {  
    
    
        sendReport(item);  
    
    
      }  
    
    
      
    
    
      return (  
    
    
        <figure>  
    
    
          <Chart onClick={handleClick} />  
    
    
        </figure>  
    
    
      );  
    
    
    });

[ Previous  use  ](/reference/react/use) [ Next  useContext
](/reference/react/useContext)

* * *

How do you like these docs?

[ Take our survey!  ](https://www.surveymonkey.co.uk/r/PYRPF3X)

* * *

[ ](https://opensource.fb.com/)

©  2024

[ Learn React ](/learn)

[ Quick Start ](/learn)

[ Installation ](/learn/installation)

[ Describing the UI ](/learn/describing-the-ui)

[ Adding Interactivity ](/learn/adding-interactivity)

[ Managing State ](/learn/managing-state)

[ Escape Hatches ](/learn/escape-hatches)

[ API Reference ](/reference/react)

[ React APIs ](/reference/react)

[ React DOM APIs ](/reference/react-dom)

[ Community ](/community)

[ Code of Conduct
](https://github.com/facebook/react/blob/main/CODE_OF_CONDUCT.md)

[ Meet the Team ](/community/team)

[ Docs Contributors ](/community/docs-contributors)

[ Acknowledgements ](/community/acknowledgements)

More

[ Blog ](/blog)

[ React Native ](https://reactnative.dev/)

[ Privacy ](https://opensource.facebook.com/legal/privacy)

[ Terms ](https://opensource.fb.com/legal/terms/)

[ ](https://www.facebook.com/react) [ ](https://twitter.com/reactjs) [
](https://github.com/facebook/react)

##  On this page

  * Overview 
  * Reference 
  * ` useCallback(fn, dependencies) `
  * Usage 
  * Skipping re-rendering of components 
  * Updating state from a memoized callback 
  * Preventing an Effect from firing too often 
  * Optimizing a custom Hook 
  * Troubleshooting 
  * Every time my component renders, ` useCallback ` returns a different function 
  * I need to call ` useCallback ` for each list item in a loop, but it’s not allowed
<img 
            src={sculpture.url} 
            alt={sculpture.alt}
          />
        </>
      );
    }
    
    

Show more

Show solution  Next  Challenge

[ Previous  Responding to Events  ](/learn/responding-to-events) [ Next
Render and Commit  ](/learn/render-and-commit)

* * *

How do you like these docs?

[ Take our survey!  ](https://www.surveymonkey.co.uk/r/PYRPF3X)

* * *

[ ](https://opensource.fb.com/)

©  2024

[ Learn React ](/learn)

[ Quick Start ](/learn)

[ Installation ](/learn/installation)

[ Describing the UI ](/learn/describing-the-ui)

[ Adding Interactivity ](/learn/adding-interactivity)

[ Managing State ](/learn/managing-state)

[ Escape Hatches ](/learn/escape-hatches)

[ API Reference ](/reference/react)

[ React APIs ](/reference/react)

[ React DOM APIs ](/reference/react-dom)

[ Community ](/community)

[ Code of Conduct
](https://github.com/facebook/react/blob/main/CODE_OF_CONDUCT.md)

[ Meet the Team ](/community/team)

[ Docs Contributors ](/community/docs-contributors)

[ Acknowledgements ](/community/acknowledgements)

More

[ Blog ](/blog)

[ React Native ](https://reactnative.dev/)

[ Privacy ](https://opensource.facebook.com/legal/privacy)

[ Terms ](https://opensource.fb.com/legal/terms/)

[ ](https://www.facebook.com/react) [ ](https://twitter.com/reactjs) [
](https://github.com/facebook/react)

##  On this page

  * Overview 
  * When a regular variable isn’t enough 
  * Adding a state variable 
  * Meet your first Hook 
  * Anatomy of ` useState `
  * Giving a component multiple state variables 
  * State is isolated and private 
  * Recap 
  * Challenges
[ SciPy v1.12.0 Manual  ](../../index.html)

  * [ Installing ](https://scipy.org/install/)
  * [ User Guide ](../../tutorial/index.html)
  * [ API reference ](../index.html)
  * [ Building from source ](../../building/index.html)
  * [ Development ](../../dev/index.html)
  * [ Release notes ](../../release.html)

__ __ __

1.12.0

  * [ __ GitHub  ](https://github.com/scipy/scipy "GitHub")
  * [ __ Twitter  ](https://twitter.com/SciPy_team "Twitter")

__

  * [ scipy ](../main_namespace.html)
  * [ scipy.cluster ](../cluster.html)
  * [ scipy.constants ](../constants.html)
  * [ scipy.datasets ](../datasets.html)
  * [ scipy.fft ](../fft.html)
  * [ scipy.fftpack ](../fftpack.html)
  * [ scipy.integrate ](../integrate.html)
  * [ scipy.interpolate ](../interpolate.html)
  * [ scipy.io ](../io.html)
  * [ scipy.linalg ](../linalg.html)
  * [ scipy.misc ](../misc.html)
  * [ scipy.ndimage ](../ndimage.html)
  * [ scipy.odr ](../odr.html)
  * [ scipy.optimize ](../optimize.html)
  * [ scipy.signal ](../signal.html)
  * [ scipy.sparse ](../sparse.html)
  * [ scipy.spatial ](../spatial.html)
  * [ scipy.special ](../special.html)
  * [ scipy.stats ](../stats.html)

__ On this page

  * ` mmread  `

#  scipy.io.mmread  #

scipy.io.  mmread  (  _ source  _ )  [ [source]
](https://github.com/scipy/scipy/blob/v1.12.0/scipy/io/_fast_matrix_market/__init__.py#L294-L366)
#

    

Reads the contents of a Matrix Market file-like âsourceâ into a matrix.

Parameters  :

    

**source** str or file-like

    

Matrix Market filename (extensions .mtx, .mtz.gz) or open file-like object.

Returns  :

    

**a** ndarray or coo_matrix

    

Dense or sparse matrix depending on the matrix format in the Matrix Market
file.

Notes

Changed in version 1.12.0:  C++ implementation.

Examples

    
    
    >>> from io import StringIO
    >>> from scipy.io import mmread
    
    
    
    >>> text = '''%%MatrixMarket matrix coordinate real general
    ...  5 5 7
    ...  2 3 1.0
    ...  3 4 2.0
    ...  3 5 3.0
    ...  4 1 4.0
    ...  4 2 5.0
    ...  4 3 6.0
    ...  4 4 7.0
    ... '''
    

` mmread(source)  ` returns the data as sparse matrix in COO format.

    
    
    >>> m = mmread(StringIO(text))
    >>> m
    <5x5 sparse matrix of type '<class 'numpy.float64'>'
    with 7 stored elements in COOrdinate format>
    >>> m.A
    array([[0., 0., 0., 0., 0.],
           [0., 0., 1., 0., 0.],
           [0., 0., 0., 2., 3.],
           [4., 5., 6., 7., 0.],
           [0., 0., 0., 0., 0.]])
    

This method is threaded. The default number of threads is equal to the number
of CPUs in the system. Use [ threadpoolctl
](https://github.com/joblib/threadpoolctl) to override:

    
    
    >>> import threadpoolctl
    >>>
    >>> with threadpoolctl.threadpool_limits(limits=2):
    ...     m = mmread(StringIO(text))
    

[ __ previous  scipy.io.mminfo  ](scipy.io.mminfo.html "previous page") [ next
scipy.io.mmwrite  __ ](scipy.io.mmwrite.html "next page")

© Copyright 2008-2024, The SciPy community.  

Created using [ Sphinx ](http://sphinx-doc.org/) 7.2.6.
* [ Code  ](/rstudio/reticulate)
* [ Issues  ](/rstudio/reticulate/issues)
* [ Pull requests  ](/rstudio/reticulate/pulls)
* [ Actions  ](/rstudio/reticulate/actions)
* [ Projects  ](/rstudio/reticulate/projects)
* [ Security  ](/rstudio/reticulate/security)
* [ Insights  ](/rstudio/reticulate/pulse)
[ SciPy v1.12.0 Manual  ](../../index.html)

  * [ Installing ](https://scipy.org/install/)
  * [ User Guide ](../../tutorial/index.html)
  * [ API reference ](../index.html)
  * [ Building from source ](../../building/index.html)
  * [ Development ](../../dev/index.html)
  * [ Release notes ](../../release.html)

__ __ __

1.12.0

  * [ __ GitHub  ](https://github.com/scipy/scipy "GitHub")
  * [ __ Twitter  ](https://twitter.com/SciPy_team "Twitter")

__

  * [ scipy ](../main_namespace.html)
  * [ scipy.cluster ](../cluster.html)
  * [ scipy.constants ](../constants.html)
  * [ scipy.datasets ](../datasets.html)
  * [ scipy.fft ](../fft.html)
  * [ scipy.fftpack ](../fftpack.html)
  * [ scipy.integrate ](../integrate.html)
  * [ scipy.interpolate ](../interpolate.html)
  * [ scipy.io ](../io.html)
  * [ scipy.linalg ](../linalg.html)
  * [ scipy.misc ](../misc.html)
  * [ scipy.ndimage ](../ndimage.html)
  * [ scipy.odr ](../odr.html)
  * [ scipy.optimize ](../optimize.html)
  * [ scipy.signal ](../signal.html)
  * [ scipy.sparse ](../sparse.html)
  * [ scipy.spatial ](../spatial.html)
  * [ scipy.special ](../special.html)
  * [ scipy.stats ](../stats.html)

__ On this page

  * ` ArffError  `
    * ` ArffError.errno  `
    * ` ArffError.filename  `
    * ` ArffError.filename2  `
    * ` ArffError.strerror  `
    * ` ArffError.with_traceback  `

#  scipy.io.arff.ArffError  #

_ exception  _ scipy.io.arff.  ArffError  [ [source]
](https://github.com/scipy/scipy/blob/v1.12.0/scipy/io/arff/_arffread.py#L54-L55)
#

    

errno  #

    

POSIX exception code

filename  #

    

exception filename

filename2  #

    

second exception filename

strerror  #

    

exception strerror

with_traceback  (  )  #

    

Exception.with_traceback(tb) â set self.__traceback__ to tb and return self.

[ __ previous  scipy.io.arff.MetaData.types
](scipy.io.arff.MetaData.types.html "previous page") [ next
scipy.io.arff.ParseArffError  __ ](scipy.io.arff.ParseArffError.html "next
page")

© Copyright 2008-2024, The SciPy community.  

Created using [ Sphinx ](http://sphinx-doc.org/) 7.2.6.
* [ Code  ](/scipy/scipy)
* [ Issues  1.5k  ](/scipy/scipy/issues)
* [ Pull requests  302  ](/scipy/scipy/pulls)
* [ Actions  ](/scipy/scipy/actions)
* [ Projects  0  ](/scipy/scipy/projects)
* [ Wiki  ](/scipy/scipy/wiki)
* [ Security  ](/scipy/scipy/security)
* [ Insights  ](/scipy/scipy/pulse)
* [ nanmean ](sparse.nanmean.html)
* [ nanmin ](sparse.nanmin.html)
* [ nanprod ](sparse.nanprod.html)
* [ nanreduce ](sparse.nanreduce.html)
* [ nansum ](sparse.nansum.html)
* [ nonzero ](sparse.nonzero.html)
* [ ones ](sparse.ones.html)
* [ ones_like ](sparse.ones_like.html)
* [ outer ](sparse.outer.html)
* [ pad ](sparse.pad.html)
* [ permute_dims ](sparse.permute_dims.html)
* [ prod ](sparse.prod.html)
* [ random ](sparse.random.html)
* [ reshape ](sparse.reshape.html)
* [ result_type ](sparse.result_type.html)
* [ roll ](sparse.roll.html)
* [ round ](sparse.round.html)
* save_npz
* ` save_npz()  `
* [ squeeze ](sparse.squeeze.html)
* [ stack ](sparse.stack.html)
* [ std ](sparse.std.html)
* [ sum ](sparse.sum.html)
* [ tensordot ](sparse.tensordot.html)
* [ tril ](sparse.tril.html)
* [ triu ](sparse.triu.html)
* [ unique_counts ](sparse.unique_counts.html)
* [ unique_values ](sparse.unique_values.html)
* [ where ](sparse.where.html)
* [ zeros ](sparse.zeros.html)
* [ zeros_like ](sparse.zeros_like.html)
* [ Roadmap ](../roadmap.html)
* [ Completed Tasks ](../roadmap.html#completed-tasks)
* [ Contributing ](../contributing.html)
* [ Changelog ](../changelog.html)
* [ Contributor Covenant Code of Conduct ](../conduct.html)
[ SciPy v1.12.0 Manual  ](../../index.html)

  * [ Installing ](https://scipy.org/install/)
  * [ User Guide ](../../tutorial/index.html)
  * [ API reference ](../index.html)
  * [ Building from source ](../../building/index.html)
  * [ Development ](../../dev/index.html)
  * [ Release notes ](../../release.html)

__ __ __

1.12.0

  * [ __ GitHub  ](https://github.com/scipy/scipy "GitHub")
  * [ __ Twitter  ](https://twitter.com/SciPy_team "Twitter")

__

  * [ scipy ](../main_namespace.html)
  * [ scipy.cluster ](../cluster.html)
  * [ scipy.constants ](../constants.html)
  * [ scipy.datasets ](../datasets.html)
  * [ scipy.fft ](../fft.html)
  * [ scipy.fftpack ](../fftpack.html)
  * [ scipy.integrate ](../integrate.html)
  * [ scipy.interpolate ](../interpolate.html)
  * [ scipy.io ](../io.html)
  * [ scipy.linalg ](../linalg.html)
  * [ scipy.misc ](../misc.html)
  * [ scipy.ndimage ](../ndimage.html)
  * [ scipy.odr ](../odr.html)
  * [ scipy.optimize ](../optimize.html)
  * [ scipy.signal ](../signal.html)
  * [ scipy.sparse ](../sparse.html)
  * [ scipy.spatial ](../spatial.html)
  * [ scipy.special ](../special.html)
  * [ scipy.stats ](../stats.html)

__ On this page

  * ` hb_write  `

#  scipy.io.hb_write  #

scipy.io.  hb_write  (  _ path_or_open_file  _ , _ m  _ , _ hb_info  =  None
_ )  [ [source]
](https://github.com/scipy/scipy/blob/v1.12.0/scipy/io/_harwell_boeing/hb.py#L518-L571)
#

    

Write HB-format file.

Parameters  :

    

**path_or_open_file** path-like or file-like

    

If a file-like object, it is used as-is. Otherwise, it is opened before
writing.

**m** sparse-matrix

    

the sparse matrix to write

**hb_info** HBInfo

    

contains the meta-data for write

Returns  :

    

None

    

Notes

At the moment not the full Harwell-Boeing format is supported. Supported
features are:

>   * assembled, non-symmetric, real matrices
>
>   * integer for pointer/indices
>
>   * exponential format for float values, and int format
>
>

Examples

We can read and write a harwell-boeing format file:

    
    
    >>> from scipy.io import hb_read, hb_write
    >>> from scipy.sparse import csr_matrix, eye
    >>> data = csr_matrix(eye(3))  # create a sparse matrix
    >>> hb_write("data.hb", data)  # write a hb file
    >>> print(hb_read("data.hb"))  # read a hb file
      (0, 0)    1.0
      (1, 1)    1.0
      (2, 2)    1.0
    

[ __ previous  scipy.io.hb_read  ](scipy.io.hb_read.html "previous page") [
next  scipy.io.wavfile.read  __ ](scipy.io.wavfile.read.html "next page")

© Copyright 2008-2024, The SciPy community.  

Created using [ Sphinx ](http://sphinx-doc.org/) 7.2.6.
[ SciPy v1.12.0 Manual  ](../../index.html)

  * [ Installing ](https://scipy.org/install/)
  * [ User Guide ](../../tutorial/index.html)
  * [ API reference ](../index.html)
  * [ Building from source ](../../building/index.html)
  * [ Development ](../../dev/index.html)
  * [ Release notes ](../../release.html)

__ __ __

1.12.0

  * [ __ GitHub  ](https://github.com/scipy/scipy "GitHub")
  * [ __ Twitter  ](https://twitter.com/SciPy_team "Twitter")

__

  * [ scipy ](../main_namespace.html)
  * [ scipy.cluster ](../cluster.html)
  * [ scipy.constants ](../constants.html)
  * [ scipy.datasets ](../datasets.html)
  * [ scipy.fft ](../fft.html)
  * [ scipy.fftpack ](../fftpack.html)
  * [ scipy.integrate ](../integrate.html)
  * [ scipy.interpolate ](../interpolate.html)
  * [ scipy.io ](../io.html)
  * [ scipy.linalg ](../linalg.html)
  * [ scipy.misc ](../misc.html)
  * [ scipy.ndimage ](../ndimage.html)
  * [ scipy.odr ](../odr.html)
  * [ scipy.optimize ](../optimize.html)
  * [ scipy.signal ](../signal.html)
  * [ scipy.sparse ](../sparse.html)
  * [ scipy.spatial ](../spatial.html)
  * [ scipy.special ](../special.html)
  * [ scipy.stats ](../stats.html)

__ On this page

  * ` hb_read  `

#  scipy.io.hb_read  #

scipy.io.  hb_read  (  _ path_or_open_file  _ )  [ [source]
](https://github.com/scipy/scipy/blob/v1.12.0/scipy/io/_harwell_boeing/hb.py#L470-L515)
#

    

Read HB-format file.

Parameters  :

    

**path_or_open_file** path-like or file-like

    

If a file-like object, it is used as-is. Otherwise, it is opened before
reading.

Returns  :

    

**data** scipy.sparse.csc_matrix instance

    

The data read from the HB file as a sparse matrix.

Notes

At the moment not the full Harwell-Boeing format is supported. Supported
features are:

>   * assembled, non-symmetric, real matrices
>
>   * integer for pointer/indices
>
>   * exponential format for float values, and int format
>
>

Examples

We can read and write a harwell-boeing format file:

    
    
    >>> from scipy.io import hb_read, hb_write
    >>> from scipy.sparse import csr_matrix, eye
    >>> data = csr_matrix(eye(3))  # create a sparse matrix
    >>> hb_write("data.hb", data)  # write a hb file
    >>> print(hb_read("data.hb"))  # read a hb file
      (0, 0)    1.0
      (1, 1)    1.0
      (2, 2)    1.0
    

[ __ previous  scipy.io.netcdf_variable.typecode
](scipy.io.netcdf_variable.typecode.html "previous page") [ next
scipy.io.hb_write  __ ](scipy.io.hb_write.html "next page")

© Copyright 2008-2024, The SciPy community.  

Created using [ Sphinx ](http://sphinx-doc.org/) 7.2.6.
[ latest ](/en/latest/)
[ stable ](/en/stable/)
[ 0.15.1 ](/en/0.15.1/)
[ 0.14.0 ](/en/0.14.0/)
[ 0.13.0 ](/en/0.13.0/)
[ 0.12.0 ](/en/0.12.0/)
[ 0.11.2 ](/en/0.11.2/)
[ 0.11.1 ](/en/0.11.1/)
[ 0.11.0 ](/en/0.11.0/)
[ 0.10.0 ](/en/0.10.0/)
[ 0.9.1 ](/en/0.9.1/)
[ 0.8.0 ](/en/0.8.0/)
[ 0.7.0 ](/en/0.7.0/)
[ 0.6.0 ](/en/0.6.0/)
[ 0.5.0 ](/en/0.5.0/)
[ 0.4.1 ](/en/0.4.1/)
[ 0.3.1 ](/en/0.3.1/)
[ 0.3.0 ](/en/0.3.0/)
[ 0.2.0 ](/en/0.2.0/)